[Mesa-dev] [PATCH] loader: add special logic to distinguish nouveau from nouveau_vieux

Emil Velikov emil.l.velikov at gmail.com
Mon Mar 17 10:12:28 PDT 2014


On 17/03/14 14:22, Ilia Mirkin wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Hi Ilia

I'm not sure if a nouveau specific quirk is a nice idea, although the
only other solution is to add the "quirk" in the driver_map table.

> ---
>  include/pci_ids/pci_id_driver_map.h |  1 -
>  src/loader/loader.c                 | 25 +++++++++++++++++++++++--
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/include/pci_ids/pci_id_driver_map.h b/include/pci_ids/pci_id_driver_map.h
> index db9e07f..064e8d4 100644
> --- a/include/pci_ids/pci_id_driver_map.h
> +++ b/include/pci_ids/pci_id_driver_map.h
> @@ -73,7 +73,6 @@ static const struct {
>     { 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids), _LOADER_GALLIUM },
>     { 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids), _LOADER_GALLIUM },
>     { 0x1002, "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids), _LOADER_GALLIUM},
> -   { 0x10de, "nouveau", NULL, -1,  _LOADER_GALLIUM  },
+   { 0x10de, "nouveau_vieux", NULL, -1,  _LOADER_DRI  },

This produces slightly shorter patch diff, although I'm not sure if this
isn't a bigger hack than your approach.

-Emil

>     { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids), _LOADER_GALLIUM },
>     { 0x0000, NULL, NULL, 0 },
>  };
> diff --git a/src/loader/loader.c b/src/loader/loader.c
> index 811f8a2..fe41b39 100644
> --- a/src/loader/loader.c
> +++ b/src/loader/loader.c
> @@ -258,9 +258,19 @@ loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
>        }
>     }
>     else if (strcmp(version->name, "nouveau") == 0) {
> +      struct drm_nouveau_getparam gp;
> +      int ret;
> +
>        *vendor_id = 0x10de;
> -      /* not used */
> -      *chip_id = 0;
> +
> +      memset(&gp, 0, sizeof(gp));
> +      gp.param = NOUVEAU_GETPARAM_CHIPSET_ID;
> +      gp.value = chip_id;
> +      ret = drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
> +      if (ret) {
> +         log_(_LOADER_WARNING, "MESA-LOADER: failed to get param for nouveau\n");
> +         *chip_id = -1;
> +      }
>     }
>     else if (strcmp(version->name, "vmwgfx") == 0) {
>        *vendor_id = 0x15ad;
> @@ -345,6 +355,17 @@ loader_get_driver_for_fd(int fd, unsigned driver_types)
>        return driver;
>     }
>  
> +   /* Special handling for nouveau, we don't want to list out all of the pci,
> +    * or even chipset ids
> +    */
> +   if (vendor_id == 0x10de) {
> +      if (driver_types & _LOADER_GALLIUM && chip_id >= 0x30)
> +         driver = strdup("nouveau");
> +      else if (driver_types & _LOADER_DRI && chip_id < 0x30)
> +         driver = strdup("nouveau_vieux");
> +      goto out;
> +   }
> +
>     for (i = 0; driver_map[i].driver; i++) {
>        if (vendor_id != driver_map[i].vendor_id)
>           continue;
> 



More information about the mesa-dev mailing list