summary refs log tree commit diff
path: root/gpu_buffer/src
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2019-06-07 17:30:11 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-03 05:42:25 +0000
commitab827ab177971b5f0f948d1c1feb3c6e5ff481eb (patch)
tree44d949cf33f3858dd85e66bccb1d5a21daf307ce /gpu_buffer/src
parent44863792aae915c0bc33155352ade8013144dcd3 (diff)
downloadcrosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar.gz
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar.bz2
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar.lz
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar.xz
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.tar.zst
crosvm-ab827ab177971b5f0f948d1c1feb3c6e5ff481eb.zip
gpu_buffer: add ability to get backend name
This is useful for letting the guest know about host-specific
features.

BUG=chromium:924405
TEST=compile

Change-Id: I0edc4280eec7235644c9ad8561dbe063276bb3bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650288
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Diffstat (limited to 'gpu_buffer/src')
-rw-r--r--gpu_buffer/src/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/gpu_buffer/src/lib.rs b/gpu_buffer/src/lib.rs
index 16aae50..53fca92 100644
--- a/gpu_buffer/src/lib.rs
+++ b/gpu_buffer/src/lib.rs
@@ -35,10 +35,11 @@ mod raw;
 pub mod rendernode;
 
 use std::cmp::min;
+use std::ffi::CStr;
 use std::fmt::{self, Display};
 use std::fs::File;
 use std::isize;
-use std::os::raw::c_void;
+use std::os::raw::{c_char, c_void};
 use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
 use std::ptr::null_mut;
 use std::rc::Rc;
@@ -379,6 +380,14 @@ impl Device {
         }
     }
 
+    /// Copies and returns name of GBM backend.
+    pub fn get_backend_name(&self) -> String {
+        let backend_name: *const c_char = unsafe { gbm_device_get_backend_name(self.0.gbm) };
+        let c_str: &CStr = unsafe { CStr::from_ptr(backend_name) };
+        let str_slice: &str = c_str.to_str().unwrap_or("");
+        str_slice.to_owned()
+    }
+
     /// Creates a new buffer with the given metadata.
     pub fn create_buffer(
         &self,