From 1d13cc1032bf66fca7fc28b7a5d96ceec96285a9 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Tue, 19 Jan 2021 16:51:02 -0500 Subject: [PATCH] amdgpu: add function of INFO ioctl for querying video caps via the newly added uapi/amdgpu_drm interface Signed-off-by: Leo Liu Reviewed-by: Alex Deucher --- amdgpu/amdgpu-symbols.txt | 1 + amdgpu/amdgpu.h | 17 +++++++++++++++++ amdgpu/amdgpu_gpu_info.c | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/amdgpu/amdgpu-symbols.txt b/amdgpu/amdgpu-symbols.txt index e3bafaab..a2ed6527 100644 --- a/amdgpu/amdgpu-symbols.txt +++ b/amdgpu/amdgpu-symbols.txt @@ -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 diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 188179c9..77f58c2b 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -1237,6 +1237,23 @@ int amdgpu_query_gds_info(amdgpu_device_handle dev, 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. diff --git a/amdgpu/amdgpu_gpu_info.c b/amdgpu/amdgpu_gpu_info.c index 777087f2..9f8695ce 100644 --- a/amdgpu/amdgpu_gpu_info.c +++ b/amdgpu/amdgpu_gpu_info.c @@ -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)); +}