Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cda17380 authored by Dave Airlie's avatar Dave Airlie Committed by Dave Airlie
Browse files

drm: add test for AGP devices and driver override for it.



Added device_is_agp callback to drm_driver.  This function is called by the
platform-specific drm_device_is_agp function.  Added implementation of this
function the the Linux-specific portion of the MGA driver to detect PCI G450
cards.  Added code to the Linux-specific portion of the generic DRM layer to
not initialize AGP infrastructure if the card is not AGP (this matches what
already existed in BSD).

Fix up i810/i830 and i915 drivers to always return AGP as they don't always
report the capability.

Fix the MGA to not report AGP for a card that has an AGP chip behind a PCI
bridge.

From: Ian Romanick, Dave Airlie, Alan Hourihane
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent ceb9c27a
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -586,7 +586,22 @@ struct drm_driver {
 	int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
	void (*kernel_context_switch_unlock)(struct drm_device *dev, drm_lock_t *lock);
	int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
	
	/**
	 * Called by \c drm_device_is_agp.  Typically used to determine if a
	 * card is really attached to AGP or not.
	 *
	 * \param dev  DRM device handle
	 *
	 * \returns
	 * One of three values is returned depending on whether or not the
	 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
	 * (return of 1), or may or may not be AGP (return of 2).
	 */
	int (*device_is_agp) (struct drm_device * dev);

	/* these have to be filled in */
  
 	int (*postinit)(struct drm_device *, unsigned long flags);
	irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
 	void (*irq_preinstall)(struct drm_device *dev);
@@ -1041,6 +1056,19 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsig
	return NULL;
}

static __inline__ int drm_device_is_agp(drm_device_t *dev)
{
	if ( dev->driver->device_is_agp != NULL ) {
		int err = (*dev->driver->device_is_agp)( dev );
	
		if (err != 2) {
			return err;
		}
	}

	return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
}

static __inline__ void drm_core_dropmap(struct drm_map *map)
{
}
+2 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ static int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct
			goto error_out_unreg;

	if (drm_core_has_AGP(dev)) {
		if (drm_device_is_agp(dev))
			dev->agp = drm_agp_init(dev);
		if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) {
			DRM_ERROR( "Cannot initialize the agpgart module.\n" );
+16 −0
Original line number Diff line number Diff line
@@ -1383,3 +1383,19 @@ drm_ioctl_desc_t i810_ioctls[] = {
};

int i810_max_ioctl = DRM_ARRAY_SIZE(i810_ioctls);

/**
 * Determine if the device really is AGP or not.
 *
 * All Intel graphics chipsets are treated as AGP, even if they are really
 * PCI-e.
 *
 * \param dev   The device to be tested.
 *
 * \returns
 * A value of 1 is always retured to indictate every i810 is AGP.
 */
int i810_driver_device_is_agp(drm_device_t * dev)
{
	return 1;
}
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ static struct drm_driver driver = {
	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
	.pretakedown = i810_driver_pretakedown,
	.prerelease = i810_driver_prerelease,
	.device_is_agp = i810_driver_device_is_agp,
	.release = i810_driver_release,
	.dma_quiescent = i810_driver_dma_quiescent,
	.reclaim_buffers = i810_reclaim_buffers,
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ extern int i810_driver_dma_quiescent(drm_device_t *dev);
extern void i810_driver_release(drm_device_t *dev, struct file *filp);
extern void i810_driver_pretakedown(drm_device_t *dev);
extern void i810_driver_prerelease(drm_device_t *dev, DRMFILE filp);
extern int i810_driver_device_is_agp(drm_device_t * dev);

#define I810_BASE(reg)		((unsigned long) \
				dev_priv->mmio_map->handle)
Loading