amdgpu: add function of INFO ioctl for querying video caps
authorLeo Liu <leo.liu@amd.com>
Tue, 19 Jan 2021 21:51:02 +0000 (16:51 -0500)
committerLeo Liu <leo.liu@amd.com>
Tue, 6 Apr 2021 12:58:57 +0000 (08:58 -0400)
via the newly added uapi/amdgpu_drm interface

Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
amdgpu/amdgpu-symbols.txt
amdgpu/amdgpu.h
amdgpu/amdgpu_gpu_info.c

index e3bafaa..a2ed652 100644 (file)
@@ -66,6 +66,7 @@ amdgpu_query_hw_ip_count
 amdgpu_query_hw_ip_info
 amdgpu_query_info
 amdgpu_query_sensor_info
+amdgpu_query_video_caps_info
 amdgpu_read_mm_registers
 amdgpu_va_range_alloc
 amdgpu_va_range_free
index 188179c..77f58c2 100644 (file)
@@ -1238,6 +1238,23 @@ int amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned sensor_type,
                             unsigned size, void *value);
 
 /**
+ * Query information about video capabilities
+ *
+ * The return sizeof(struct drm_amdgpu_info_video_caps)
+ *
+ * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
+ * \param   caps_type   - \c [in] AMDGPU_INFO_VIDEO_CAPS_DECODE(ENCODE)
+ * \param   size        - \c [in] Size of the returned value.
+ * \param   value       - \c [out] Pointer to the return value.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+*/
+int amdgpu_query_video_caps_info(amdgpu_device_handle dev, unsigned cap_type,
+                                 unsigned size, void *value);
+
+/**
  * Read a set of consecutive memory-mapped registers.
  * Not all registers are allowed to be read by userspace.
  *
index 777087f..9f8695c 100644 (file)
@@ -331,3 +331,18 @@ drm_public int amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned senso
        return drmCommandWrite(dev->fd, DRM_AMDGPU_INFO, &request,
                               sizeof(struct drm_amdgpu_info));
 }
+
+drm_public int amdgpu_query_video_caps_info(amdgpu_device_handle dev, unsigned cap_type,
+                                            unsigned size, void *value)
+{
+       struct drm_amdgpu_info request;
+
+       memset(&request, 0, sizeof(request));
+       request.return_pointer = (uintptr_t)value;
+       request.return_size = size;
+       request.query = AMDGPU_INFO_VIDEO_CAPS;
+       request.sensor_info.type = cap_type;
+
+       return drmCommandWrite(dev->fd, DRM_AMDGPU_INFO, &request,
+                              sizeof(struct drm_amdgpu_info));
+}