Index: [thread] [date] [subject] [author]
  From: Steffen Seeger <seeger@physik.tu-chemnitz.de>
  To  : ggi-develop@eskimo.com
  Date: Mon, 7 Sep 1998 17:25:44 +0200 (MEST)

Re: vision-driver

 
> On Mon, 7 Sep 1998, Steffen Seeger wrote:
> 
> >  
> > > - the PCICFG_VADDR-hack is gone. it is replaced by a more general version
> > > that will be used in the s3-common-driver, too. i will pollish it a bit more
> > > and will propose it for all the other drivers out there because every driver
> > > are is doing it its own way.
> > 
> > What's your solution instead? The PCICFG_VADDR was not meant to be a hack. 
> the PCICFG_VADDR was used this way:
> 
> 	pci->dev = PCICFG_VADDR (0, 10, 0);
> 
> this is a hack.

If you use it this way, yes, that's a hack. The pci_options->dev field was
meant to be initialized by the operating system layer, not the chipset driver.
The 'not meant to be a hack' referred to the PCICFG I/O space itself and the
handling of PCI-Device addressing.

The new KGI handles PCI autodetection as follows (PCICFG_SIGNATURE being 
a macro that merges vendor and model ID into one 32bit int):

static const kgi_u32 pgc_pcicfg[] =
{
        PCICFG_SIGNATURE(PCI_VENDOR_ID_3Dlabs, PCI_DEVICE_ID_PERMEDIA),
        PCICFG_SIGNATURE(PCI_VENDOR_ID_3Dlabs, PCI_DEVICE_ID_PERMEDIA2),
        PCICFG_SIGNATURE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TVP4010),
        PCICFG_SIGNATURE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TVP4020),
        PCICFG_SIGNATURE(0,0)
};

kgim_chipset_init(kgi_display *dpy)
{
	struct kgim_options_pci *pci = KGIM_OPTIONS(dpy, pci);
	kgi_u vendor, device;

        if (pci->dev == PCICFG_NULL) {

		/* the user didn't specify a particular device, thus we scan
		** for supported ones. pcicfg_find takes a zero-terminated list
		** of signatures (vendor,model) for supported devices and
		** returns the first one found in pci->dev.
		*/
                if (pcicfg_find(&pci->dev, pgc_pcicfg)) {

                        KRN_ERROR("No supported device found!");
                        return -E(CHIPSET,INVAL);
                }
        }

        vendor = pcicfg_in16(pci->dev + PCI_VENDOR_ID);
        device = pcicfg_in16(pci->dev + PCI_DEVICE_ID);

        switch (PCICFG_SIGNATURE(vendor, device)) {

        case PCICFG_SIGNATURE(PCI_VENDOR_ID_3Dlabs, PCI_DEVICE_ID_PERMEDIA):
                KGIM_SET_INFO(dpy, chipset, CS_3Dlabs_PERMEDIA);
                break;

        case PCICFG_SIGNATURE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TVP4010):
                KGIM_SET_INFO(dpy, chipset, CS_TI_TVP4010);
                break;
	...
	default:
                KRN_ERROR("Device not supported (vendor %.4x, device %.4x).",
                        vendor, device);
                return -E(CHIPSET,NOSUP);
        }

	...
}

The idea is that in the driver you don't have to care if a PCI bus is
present at all, and that you only have to worry about the devices you
can support. The effect of this code:

- in single-head environments, just load the driver and everthing is 
  auto-detected

- in multi-head environments you have to give the pcibus,pcidev and 
  (optionally) pcifn options and the driver knows the device to drive.
  It cannot use auto-detection, as there is no general way to tell if 
  a detected device is served by a driver or not.

- you have one scan for all supported devices, even if they are from different
  vendors/are different models.

Compared to a current driver, this only requires to add the pcicfg_find
call and the array of signatures, given the current driver does
a check for validity of pci->dev and then verifies the device.

			Steffen

----------------- e-mail: seeger@physik.tu-chemnitz.de -----------------

Index: [thread] [date] [subject] [author]