Module: Mesa
Branch: master
Commit: c3e305616cbc53317bbace6f1f316c9167f14313
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3e305616cbc53317bbace6f1f316c9167f14313

Author: Lionel Landwerlin <[email protected]>
Date:   Mon Feb 10 16:15:58 2020 +0200

drm-shim: return device platform as specified

v2: Embed the libdrm dependency inside the drm-shim dependency

Signed-off-by: Lionel Landwerlin <[email protected]>
Acked-by: Eric Anholt <[email protected]> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4429>

---

 src/broadcom/drm-shim/v3d.c             |  1 +
 src/broadcom/drm-shim/v3d_noop.c        |  1 +
 src/drm-shim/drm_shim.c                 | 22 ++++++++++++++++++++--
 src/drm-shim/drm_shim.h                 |  3 +++
 src/drm-shim/meson.build                |  5 +++--
 src/etnaviv/drm-shim/etnaviv_noop.c     |  1 +
 src/freedreno/drm-shim/freedreno_noop.c |  1 +
 7 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/broadcom/drm-shim/v3d.c b/src/broadcom/drm-shim/v3d.c
index e75657f59f7..81e34c128e2 100644
--- a/src/broadcom/drm-shim/v3d.c
+++ b/src/broadcom/drm-shim/v3d.c
@@ -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"
diff --git a/src/broadcom/drm-shim/v3d_noop.c b/src/broadcom/drm-shim/v3d_noop.c
index 7c7d751285d..3caa757bb3e 100644
--- a/src/broadcom/drm-shim/v3d_noop.c
+++ b/src/broadcom/drm-shim/v3d_noop.c
@@ -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);
diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c
index 381a94fb9d1..e6f7bf9e992 100644
--- a/src/drm-shim/drm_shim.c
+++ b/src/drm-shim/drm_shim.c
@@ -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;
 }
diff --git a/src/drm-shim/drm_shim.h b/src/drm-shim/drm_shim.h
index 2cd053f6d65..2d262fa35d4 100644
--- a/src/drm-shim/drm_shim.h
+++ b/src/drm-shim/drm_shim.h
@@ -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;
diff --git a/src/drm-shim/meson.build b/src/drm-shim/meson.build
index c22aea87349..197c8253995 100644
--- a/src/drm-shim/meson.build
+++ b/src/drm-shim/meson.build
@@ -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,
 )
diff --git a/src/etnaviv/drm-shim/etnaviv_noop.c 
b/src/etnaviv/drm-shim/etnaviv_noop.c
index 66b1c420efb..f583e299a54 100644
--- a/src/etnaviv/drm-shim/etnaviv_noop.c
+++ b/src/etnaviv/drm-shim/etnaviv_noop.c
@@ -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);
diff --git a/src/freedreno/drm-shim/freedreno_noop.c 
b/src/freedreno/drm-shim/freedreno_noop.c
index 6a3fbb7b67f..8f074be7397 100644
--- a/src/freedreno/drm-shim/freedreno_noop.c
+++ b/src/freedreno/drm-shim/freedreno_noop.c
@@ -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);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to