diff options
author | Ilia Mirkin <[email protected]> | 2014-03-17 14:42:12 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2014-03-19 18:17:40 -0400 |
commit | 51989817e6767d8ef469708c69d7ce38b87e9b6e (patch) | |
tree | 921fa2c336e3976b3336615f1981303921debc5b /src/loader/pci_id_driver_map.c | |
parent | c049dd4396d1639859810d6124faa863dae61d1b (diff) |
loader: add special logic to distinguish nouveau from nouveau_vieux
There are a lot of different pci ids supported by nouveau, and more are
added all the time. The relevant distinguisher between drivers is the
chipset id.
Signed-off-by: Ilia Mirkin <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Cc: "10.1" <[email protected]>
Diffstat (limited to 'src/loader/pci_id_driver_map.c')
-rw-r--r-- | src/loader/pci_id_driver_map.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/loader/pci_id_driver_map.c b/src/loader/pci_id_driver_map.c new file mode 100644 index 00000000000..cb6f705acbd --- /dev/null +++ b/src/loader/pci_id_driver_map.c @@ -0,0 +1,55 @@ +/* + * Copyright 2014 Ilia Mirkin + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +int is_nouveau_vieux(int fd); + +#ifndef __NOT_HAVE_DRM_H + +#include <xf86drm.h> +#include <nouveau_drm.h> + +static int +nouveau_chipset(int fd) +{ + struct drm_nouveau_getparam gp = { NOUVEAU_GETPARAM_CHIPSET_ID, 0 }; + int ret; + + ret = drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp)); + if (ret) + return -1; + + return gp.value; +} + +int +is_nouveau_vieux(int fd) +{ + int chipset = nouveau_chipset(fd); + return chipset > 0 && chipset < 0x30; +} + +#else + +int is_nouveau_vieux(int fd) { return 0; } + +#endif |