Bug 2260 - Make AGP/PCI detection a generic function
Summary: Make AGP/PCI detection a generic function
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: unspecified
Hardware: x86 (IA32) All
: high normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-11 06:25 UTC by Alex Deucher
Modified: 2009-04-03 01:27 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
generic-agp-detect-1.patch (5.09 KB, patch)
2005-08-28 12:07 UTC, Adam Jackson
no flags Details | Splinter Review

Description Alex Deucher 2005-01-11 06:25:45 UTC
The PCI/AGP detection code in the radeon driver should work for any card.  Felix
used it in the savage driver, and I may port it to the r128 driver as well.  It
would probably be useful as a generic routine.

mharris' comment (from radeon driver):
/* Proper autodetection of an AGP capable device requires examining
* PCI config registers to determine if the device implements extended
* PCI capabilities, and then walking the capability list as indicated
* in the PCI 2.2 and AGP 2.0 specifications, to determine if AGP
* capability is present.  The procedure is outlined as follows:
*
* 1) Test bit 4 (CAP_LIST) of the PCI status register of the device
*    to determine wether or not this device implements any extended
*    capabilities.  If this bit is zero, then the device is a PCI 2.1
*    or earlier device and is not AGP capable, and we can conclude it
*    to be a PCI device.
*
* 2) If bit 4 of the status register is set, then the device implements
*    extended capabilities.  There is an 8 bit wide capabilities pointer
*    register located at offset 0x34 in PCI config space which points to
*    the first capability in a linked list of extended capabilities that
*    this device implements.  The lower two bits of this register are
*    reserved and MBZ so must be masked out.
*
* 3) The extended capabilities list is formed by one or more extended
*    capabilities structures which are aligned on DWORD boundaries.
*    The first byte of the structure is the capability ID (CAP_ID)
*    indicating what extended capability this structure refers to.  The
*    second byte of the structure is an offset from the beginning of
*    PCI config space pointing to the next capability in the linked
*    list (NEXT_PTR) or NULL (0x00) at the end of the list.  The lower
*    two bits of this pointer are reserved and MBZ.  By examining the
*    CAP_ID of each capability and walking through the list, we will
*    either find the AGP_CAP_ID (0x02) indicating this device is an
*    AGP device, or we'll reach the end of the list, indicating it is
*    a PCI device.
*
* Mike A. Harris <mharris@redhat.com>
*
* References:
*  - PCI Local Bus Specification Revision 2.2, Chapter 6
*  - AGP Interface Specification Revision 2.0, Section 6.1.5
*/
Comment 1 Adam Jackson 2005-08-28 12:07:18 UTC
Created attachment 3088 [details] [review]
generic-agp-detect-1.patch

factor it up to Pci.c, add it to the export list, add some #defines for magic
reg values.  drivers would still need to be converted.

i'm moderately happy with it as-is, but maybe we want to extend it to
xorgPciHasCapability() for things like PCI66 detect.
Comment 2 Mike A. Harris 2005-09-25 15:50:54 UTC
Yeah, I think it would be better to reimplement this as a generic mechanism
for probing any PCI capabilities.
Comment 3 Alex Deucher 2005-09-25 15:51:52 UTC
(In reply to comment #2)
> Yeah, I think it would be better to reimplement this as a generic mechanism
> for probing any PCI capabilities.

We should probably add PCIE checking as well.  Dave added that to the radeon
driver recently. 
Comment 4 Adam Jackson 2005-11-30 16:02:02 UTC
mmm, not critical enough to hold up 7.0.
Comment 5 Adam Jackson 2006-04-15 08:18:37 UTC
probably not going to make 7.1 either at this rate.  this will likely fall out
in the wash with idr's pci rework.
Comment 6 Adam Jackson 2006-04-25 05:37:37 UTC
(In reply to comment #5)
> probably not going to make 7.1 either at this rate.  this will likely fall out
> in the wash with idr's pci rework.

I'm right; moving out.
Comment 7 Daniel Stone 2006-11-04 09:56:38 UTC
and out again.  dropping it off the radar, since it'll just happen with
pci-rework ...
Comment 8 Daniel Stone 2007-02-27 01:25:04 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 9 Adam Jackson 2008-07-11 14:26:51 UTC
const struct pci_agp_info *
pci_device_get_agp_info( struct pci_device * dev );


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.