[PATCH 2/2] xfree86: Support autoloading of non-PCI drivers

Thierry Reding thierry.reding at gmail.com
Wed Feb 12 11:09:10 PST 2014


On Wed, Feb 12, 2014 at 05:28:56PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 02/12/2014 05:11 PM, Thierry Reding wrote:
> > Drivers for non-PCI devices cannot be autoloaded because there is no
> > mechanism in place to correlate the device to the driver name.
> > 
> > This patch adds a simple table that maps the name of the Linux kernel
> > driver name to a list of DDX module names. Matching modules will be
> > added to the list of drivers that X tries to load for a given device.
> > 
> > Signed-off-by: Thierry Reding <treding at nvidia.com>
> > ---
> >  hw/xfree86/common/xf86platformBus.c | 41 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 41 insertions(+)
> > 
> > diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
> > index 5875a91363cc..16c9bb6c1dbc 100644
> > --- a/hw/xfree86/common/xf86platformBus.c
> > +++ b/hw/xfree86/common/xf86platformBus.c
> > @@ -176,6 +176,41 @@ xf86_check_platform_slot(const struct xf86_platform_device *pd)
> >      return TRUE;
> >  }
> >  
> > +#ifdef __linux__
> 
> I'm not a big fan of this, why not put most of this in:
> 
> hw/xfree86/os-support/linux/lnx_platform.c
> 
> And make xf86platformBus.c simple call a helper for this
> from hw/xfree86/os-support/linux/lnx_platform.c ?

I can easily move the table and the function below into lnx_platform.c
and only call it from here if that's preferred. This really should've
been marked RFC, since it's not clear to me if this is what we want. It
works and isn't all that ugly, so I thought I'd post it to get early
feedback if this is a good direction.

Rob, Dave and I discussed this on IRC yesterday and Dave said that
having a lookup table like this was really the only sane thing to do.

Thierry

> > +static const struct xf86platformDriver {
> > +    const char *name;
> > +    const char **modules;
> > +} xf86platformDrivers[] = {
> > +    {
> > +        .name = "tegra",
> > +        .modules = (const char *[]) {
> > +            "opentegra",
> > +            NULL
> > +        },
> > +    },
> > +    { },
> > +};
> > +
> > +static int xf86platformDriverList(char *name, char *matches[], int nmatches)
> > +{
> > +    const struct xf86platformDriver *driver = xf86platformDrivers;
> > +    int i = 0;
> > +
> > +    while (driver->name) {
> > +        if (strcmp(driver->name, name) == 0) {
> > +            for (i = 0; driver->modules[i] && (i < nmatches); i++)
> > +                matches[i] = xstrdup(driver->modules[i]);
> > +
> > +            break;
> > +        }
> > +
> > +        driver++;
> > +    }
> > +
> > +    return i;
> > +}
> > +#endif
> > +
> >  /**
> >   *  @return The numbers of found devices that match with the current system
> >   *  drivers.
> > @@ -208,6 +243,12 @@ xf86PlatformMatchDriver(char *matches[], int nmatches)
> >              if ((info != NULL) && (j < nmatches)) {
> >                  j += xf86VideoPtrToDriverList(info, &(matches[j]), nmatches - j);
> >              }
> > +#ifdef __linux__
> > +            else if (j < nmatches) {
> > +                char *name = xf86_get_platform_attrib(i, ODEV_ATTRIB_DRIVER);
> > +                j += xf86platformDriverList(name, &matches[j], nmatches - j);
> > +            }
> > +#endif
> >          }
> >      }
> >      return j;
> > 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140212/0e612477/attachment.pgp>


More information about the xorg-devel mailing list