drm-shim: return device platform as specified
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 10 Feb 2020 14:15:58 +0000 (16:15 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 3 Apr 2020 21:14:18 +0000 (21:14 +0000)
v2: Embed the libdrm dependency inside the drm-shim dependency

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Eric Anholt <eric@anholt.net> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4429>

src/broadcom/drm-shim/v3d.c
src/broadcom/drm-shim/v3d_noop.c
src/drm-shim/drm_shim.c
src/drm-shim/drm_shim.h
src/drm-shim/meson.build
src/etnaviv/drm-shim/etnaviv_noop.c
src/freedreno/drm-shim/freedreno_noop.c

index e75657f59f72c0148ace9974ecdda7847eedee96..81e34c128e20b235fbd1ff8a8bc2861f226da1c0 100644 (file)
@@ -78,6 +78,7 @@ v3d_ioctl_get_bo_offset(int fd, unsigned long request, void *arg)
 void
 drm_shim_driver_init(void)
 {
+        shim_device.bus_type = DRM_BUS_PLATFORM;
         shim_device.driver_name = "v3d";
 
         drm_shim_override_file("OF_FULLNAME=/rdb/v3d\n"
index 7c7d751285d5fd80d5e8eba94139026d1bf3acae..3caa757bb3ed1b25f85511445b8b183b8e41c2ca 100644 (file)
@@ -146,6 +146,7 @@ static ioctl_fn_t driver_ioctls[] = {
 void
 drm_shim_driver_init(void)
 {
+        shim_device.bus_type = DRM_BUS_PLATFORM;
         shim_device.driver_name = "v3d";
         shim_device.driver_ioctls = driver_ioctls;
         shim_device.driver_ioctl_count = ARRAY_SIZE(driver_ioctls);
index 381a94fb9d1c7ccac26e4584cf0a3e1f6450942b..e6f7bf9e9924a10c03f417a5ae7237ea825be31a 100644 (file)
@@ -452,8 +452,26 @@ readlink(const char *path, char *buf, size_t size)
 
    if (strcmp(path, subsystem_path) != 0)
       return real_readlink(path, buf, size);
-   strncpy(buf, "/platform", size);
-   buf[size - 1] = 0;
+
+   static const struct {
+      const char *name;
+      int bus_type;
+   } bus_types[] = {
+      { "/pci", DRM_BUS_PCI },
+      { "/usb", DRM_BUS_USB },
+      { "/platform", DRM_BUS_PLATFORM },
+      { "/spi", DRM_BUS_PLATFORM },
+      { "/host1x", DRM_BUS_HOST1X },
+   };
+
+   for (uint32_t i = 0; i < ARRAY_SIZE(bus_types); i++) {
+      if (bus_types[i].bus_type != shim_device.bus_type)
+         continue;
+
+      strncpy(buf, bus_types[i].name, size);
+      buf[size - 1] = 0;
+      break;
+   }
 
    return strlen(buf) + 1;
 }
index 2cd053f6d652e2cdbef6cd914580c4eb87c2a3d9..2d262fa35d49344eed7a8baddb9f2016682e51c1 100644 (file)
@@ -24,6 +24,8 @@
 #include "util/macros.h"
 #include "util/hash_table.h"
 
+#include <xf86drm.h>
+
 #ifdef __linux__
 #define DRM_MAJOR 226
 #endif
@@ -44,6 +46,7 @@ struct shim_device {
    /* Returned by drmGetVersion(). */
    const char *driver_name;
    int version_major, version_minor, version_patchlevel;
+   int bus_type;
 };
 
 extern struct shim_device shim_device;
index c22aea87349d9adad752cb7d9976021d53a6c307..197c8253995acdce4c3ac38f77620965aa3a3541 100644 (file)
@@ -25,9 +25,10 @@ drm_shim = static_library(
     'drm_shim.c',
   ],
   include_directories: [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
-  dependencies: [idep_mesautil, dep_dl],
+  dependencies: [dep_libdrm, idep_mesautil, dep_dl],
   c_args : [c_vis_args, '-std=gnu99'],
 )
 dep_drm_shim = declare_dependency(
-  link_with: drm_shim
+  link_with: drm_shim,
+  dependencies: dep_libdrm,
 )
index 66b1c420efb1e9e49d94fa99b7e3fd5356518413..f583e299a54540c3759de1d322ac0153848a01d7 100644 (file)
@@ -215,6 +215,7 @@ static ioctl_fn_t driver_ioctls[] = {
 void
 drm_shim_driver_init(void)
 {
+   shim_device.bus_type = DRM_BUS_PLATFORM;
    shim_device.driver_name = "etnaviv";
    shim_device.driver_ioctls = driver_ioctls;
    shim_device.driver_ioctl_count = ARRAY_SIZE(driver_ioctls);
index 6a3fbb7b67f3f8932c11f4f7874d6b45e9876cdc..8f074be739748d022a54367d79bc609d68089134 100644 (file)
@@ -168,6 +168,7 @@ static ioctl_fn_t driver_ioctls[] = {
 void
 drm_shim_driver_init(void)
 {
+       shim_device.bus_type = DRM_BUS_PLATFORM;
        shim_device.driver_name = "msm";
        shim_device.driver_ioctls = driver_ioctls;
        shim_device.driver_ioctl_count = ARRAY_SIZE(driver_ioctls);