Mechanical API conversions for libpciaccess.

Uncomplicated API transistions for libpciaccess usage:

	Legacy xf86 API		libpciaccess API
	---------------		----------------
	xf86ReadPciBIOS 	pci_device_read_rom
	pciReadWord 		pci_device_cfg_read_u16
	pciWriteByte 		pci_device_cfg_write_u8

And, more use of the API-independent DEVICE_ID/SUBVENDOR_ID/SUBSYS_ID macros
to pull PCI identification data from the underlying structure.
This commit is contained in:
Keith Packard 2007-08-26 22:46:19 -07:00
parent 70e8e59572
commit 2c79419205
5 changed files with 25 additions and 6 deletions

View File

@ -97,7 +97,11 @@ i830_bios_get (ScrnInfoPtr pScrn)
INTEL_VBIOS_SIZE);
vbeFree (pVbe);
} else {
#if XSERVER_LIBPCIACCESS
pci_device_read_rom (pI830->PciInfo, bios);
#else
xf86ReadPciBIOS(0, pI830->PciTag, 0, bios, INTEL_VBIOS_SIZE);
#endif
}
if (0)

View File

@ -868,9 +868,14 @@ i830_get_core_clock_speed(ScrnInfoPtr pScrn)
else if (IS_I945GM(pI830) || IS_845G(pI830))
return 200000;
else if (IS_I915GM(pI830)) {
CARD16 gcfgc = pciReadWord(pI830->PciTag, I915_GCFGC);
uint16_t gcfgc;
if (gcfgc & I915_LOW_FREQUENCY_ENABLE)
#if XSERVER_LIBPCIACCESS
pci_device_cfg_read_u16 (pI830->PciInfo, &gcfgc, I915_GCFGC);
#else
gcfgc = pciReadWord(pI830->PciTag, I915_GCFGC);
#endif
if (gcfgc & I915_LOW_FREQUENCY_ENABLE)
return 133000;
else {
switch (gcfgc & I915_DISPLAY_CLOCK_MASK) {
@ -884,8 +889,14 @@ i830_get_core_clock_speed(ScrnInfoPtr pScrn)
} else if (IS_I865G(pI830))
return 266000;
else if (IS_I855(pI830)) {
#if XSERVER_LIBPCIACCESS
struct pci_device *bridge = intel_host_bridge ();
uint16_t hpllcc;
pci_device_cfg_read_u16 (bridge, &hpllcc, I855_HPLLCC);
#else
PCITAG bridge = pciTag(0, 0, 0); /* This is always the host bridge */
CARD16 hpllcc = pciReadWord(bridge, I855_HPLLCC);
#endif
/* Assume that the hardware is in the high speed state. This
* should be the default.

View File

@ -84,7 +84,11 @@ i830_lvds_set_backlight(xf86OutputPtr output, int level)
CARD32 blc_pwm_ctl;
if (i830_lvds_backlight_legacy(pI830))
#if XSERVER_LIBPCIACCESS
pci_device_cfg_write_u8 (pI830->PciInfo, 0xfe, LEGACY_BACKLIGHT_BRIGHTNESS);
#else
pciWriteByte(pI830->PciTag, LEGACY_BACKLIGHT_BRIGHTNESS, 0xfe);
#endif
blc_pwm_ctl = INREG(BLC_PWM_CTL);
blc_pwm_ctl &= ~BACKLIGHT_DUTY_CYCLE_MASK;

View File

@ -84,9 +84,9 @@ void i830_fixup_devices(ScrnInfoPtr scrn)
i830_quirk_ptr p = i830_quirk_list;
while (p && p->chipType != 0) {
if (pI830->PciInfo->chipType == p->chipType &&
pI830->PciInfo->subsysVendor == p->subsysVendor &&
(pI830->PciInfo->subsysCard == p->subsysCard ||
if (DEVICE_ID(pI830->PciInfo) == p->chipType &&
SUBVENDOR_ID(pI830->PciInfo) == p->subsysVendor &&
(SUBSYS_ID(pI830->PciInfo) == p->subsysCard ||
p->subsysCard == SUBSYS_ANY))
p->hook(pI830);
++p;

View File

@ -1138,7 +1138,7 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode,
tv_mode->dda3_inc << TV_SCDDA3_INC_SHIFT;
/* Enable two fixes for the chips that need them. */
if (pI830->PciInfo->chipType < PCI_CHIP_I945_G)
if (DEVICE_ID(pI830->PciInfo) < PCI_CHIP_I945_G)
tv_ctl |= TV_ENC_C0_FIX | TV_ENC_SDP_FIX;
OUTREG(TV_H_CTL_1, hctl1);