Merge "goldfish-opengl: remove unused code"
diff --git a/platform/include/VirtGpu.h b/platform/include/VirtGpu.h
index 6bf976d..bfa3f37 100644
--- a/platform/include/VirtGpu.h
+++ b/platform/include/VirtGpu.h
@@ -19,6 +19,8 @@
 #include <cstdint>
 #include <memory>
 
+#include "virtgpu_gfxstream_protocol.h"
+
 enum VirtGpuParamId {
     kParam3D,
     kParamCapsetFix,
@@ -157,6 +159,7 @@
     static VirtGpuDevice mInstance;
     int64_t mDeviceHandle;
     struct VirtGpuParam mParams[kParamMax];
+    struct gfxstreamCapset mGfxstreamCapset;
 };
 
 // HACK: We can use android::base::EnumFlags, but we'll have to do more guest
diff --git a/platform/include/virtgpu_gfxstream_protocol.h b/platform/include/virtgpu_gfxstream_protocol.h
index 6bf26a2..325fa9c 100644
--- a/platform/include/virtgpu_gfxstream_protocol.h
+++ b/platform/include/virtgpu_gfxstream_protocol.h
@@ -65,4 +65,14 @@
     uint32_t imageHandleHi;
 };
 
+struct gfxstreamCapset {
+    uint32_t protocolVersion;
+
+    // ASG Ring Parameters
+    uint32_t ringSize;
+    uint32_t bufferSize;
+
+    uint32_t pad;
+};
+
 #endif
diff --git a/platform/linux/VirtGpuDevice.cpp b/platform/linux/VirtGpuDevice.cpp
index 6f4f86c..8faece4 100644
--- a/platform/linux/VirtGpuDevice.cpp
+++ b/platform/linux/VirtGpuDevice.cpp
@@ -25,6 +25,7 @@
 
 #include "VirtGpu.h"
 #include "virtgpu_drm.h"
+#include "virtgpu_gfxstream_protocol.h"
 
 #define PARAM(x) \
     (struct VirtGpuParam) { x, #x, 0 }
@@ -48,6 +49,7 @@
     };
 
     int ret;
+    struct drm_virtgpu_get_caps get_caps = {0};
     struct drm_virtgpu_context_init init = {0};
     struct drm_virtgpu_context_set_param ctx_set_params[2] = {{0}};
 
@@ -62,7 +64,7 @@
         get_param.param = params[i].param;
         get_param.value = (uint64_t)(uintptr_t)&params[i].value;
 
-        int ret = drmIoctl(mDeviceHandle, DRM_IOCTL_VIRTGPU_GETPARAM, &get_param);
+        ret = drmIoctl(mDeviceHandle, DRM_IOCTL_VIRTGPU_GETPARAM, &get_param);
         if (ret) {
             ALOGE("virtgpu backend not enabling %s", params[i].name);
         }
@@ -70,6 +72,19 @@
         mParams[i] = params[i];
     }
 
+    get_caps.cap_set_id = static_cast<uint32_t>(capset);
+    if (capset == kCapsetGfxStream) {
+        get_caps.size = sizeof(struct gfxstreamCapset);
+        get_caps.addr = (unsigned long long)&mGfxstreamCapset;
+    }
+
+    ret = drmIoctl(mDeviceHandle, DRM_IOCTL_VIRTGPU_GET_CAPS, &get_caps);
+    if (ret) {
+        // Don't fail get capabilities just yet, AEMU doesn't use this API
+        // yet (b/272121235);
+        ALOGE("DRM_IOCTL_VIRTGPU_GET_CAPS failed with %s", strerror(errno));
+    }
+
 
     ctx_set_params[0].param = VIRTGPU_CONTEXT_PARAM_NUM_RINGS;
     ctx_set_params[0].value = 1;