diff options
author | Abrahm Scully <abrahm.scully@gmail.com> | 2014-06-18 22:28:42 -0400 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-06-19 16:19:52 +0800 |
commit | 78fc685c58e472bb4114184e9e7f3fa239cc768a (patch) | |
tree | f04f19458268d572e35c9e821faceea80e2e4b10 /src/intel/intel_driver.c | |
parent | c2d2853c55d7ab12e422301d1c359b4f736b87d8 (diff) |
Try to use drm render nodes.
Allows non-root user to run without X.
Works on Fedora 20 with render nodes enabled.
Signed-off-by: Abrahm Scully <abrahm.scully@gmail.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/intel/intel_driver.c')
-rw-r--r-- | src/intel/intel_driver.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c index f0e860c3..4a33661d 100644 --- a/src/intel/intel_driver.c +++ b/src/intel/intel_driver.c @@ -222,6 +222,18 @@ intel_driver_open(intel_driver_t *intel, cl_context_prop props) } if(!intel_driver_is_active(intel)) { + printf("Trying to open render node...\n"); + char card_name[20]; + for(cardi = 0; cardi < 16; cardi++) { + sprintf(card_name, "/dev/dri/renderD%d", 128+cardi); + if(intel_driver_init_render(intel, card_name)) { + printf("Success at %s.\n", card_name); + break; + } + } + } + + if(!intel_driver_is_active(intel)) { printf("Trying to open directly...\n"); char card_name[20]; for(cardi = 0; cardi < 16; cardi++) { @@ -232,6 +244,7 @@ intel_driver_open(intel_driver_t *intel, cl_context_prop props) } } } + if(!intel_driver_is_active(intel)) { printf("Device open failed\n"); exit(-1); @@ -324,6 +337,24 @@ intel_driver_init_master(intel_driver_t *driver, const char* dev_name) return 1; } +LOCAL int +intel_driver_init_render(intel_driver_t *driver, const char* dev_name) +{ + int dev_fd; + + // usually dev_name = "/dev/dri/renderD%d" + dev_fd = open(dev_name, O_RDWR); + if (dev_fd == -1) { + printf("open(\"%s\", O_RDWR) failed: %s\n", dev_name, strerror(errno)); + return 0; + } + + intel_driver_init(driver, dev_fd); + driver->master = 1; + + return 1; +} + LOCAL int intel_driver_terminate(intel_driver_t *driver) { |