drm/amdgpu: add asic callback for querying video codec info (v3)
Subsystems (3)
Alex Deucher
maintainerPATCH 1/5 drm/amdgpu: add asic callback for querying video codec info (v3)
This will be used by a new INFO ioctl query to fetch the decode and encode capabilities from the kernel driver rather than hardcoding them in mesa. This gives us more fine grained control of capabilities using information that is only availabl in the kernel (e.g., platform limitations or bandwidth restrictions).
v2: reorder the codecs to better align with mesa
v3: add max_pixels_per_frame to handle the portrait case
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +26 -0
@@ -583,6 +583,28 @@ enum amd_reset_method { AMD_RESET_METHOD_PCI, }; +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG2 0 +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4 1 +#define AMDGPU_VIDEO_CODEC_TYPE_VC1 2 +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC 3 +#define AMDGPU_VIDEO_CODEC_TYPE_HEVC 4 +#define AMDGPU_VIDEO_CODEC_TYPE_JPEG 5 +#define AMDGPU_VIDEO_CODEC_TYPE_VP9 6 +#define AMDGPU_VIDEO_CODEC_TYPE_AV1 7 + +struct amdgpu_video_codec_info { +u32 codec_type; +u32 max_width; +u32 max_height; +u32 max_pixels_per_frame; +u32 max_level; +}; + +struct amdgpu_video_codecs { +const u32 codec_count; +const struct amdgpu_video_codec_info *codec_array; +}; +/* * ASIC specific functions. */
@@ -627,6 +649,9 @@ struct amdgpu_asic_funcs {void (*pre_asic_init)(struct amdgpu_device *adev);/* enter/exit umd stable pstate */ int (*update_umd_stable_pstate)(struct amdgpu_device *adev,bool enter); +/* query video codecs */ +int (*query_video_codecs)(struct amdgpu_device *adev,bool encode, +const struct amdgpu_video_codecs **codecs); };/*
@@ -1221,6 +1246,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_pre_asic_init (adev) (adev)->asic_funcs->pre_asic_init((adev))#define amdgpu_asic_update_umd_stable_pstate (adev, enter) \ ((adev)->asic_funcs->update_umd_stable_pstate ? (adev)->asic_funcs->update_umd_stable_pstate((adev), (enter)) : 0) +#define amdgpu_asic_query_video_codecs (adev, e, c) (adev)->asic_funcs->query_video_codecs((adev), (e), (c))#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter));
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 2/5 drm/amdgpu: add video decode/encode cap tables and asic callbacks (v3)
For each asic family. Will be used to populate tables for the new INFO ioctl query.
v2: add max_pixels_per_frame to handle the portrait case
v3: fix copy paste typos
--- drivers/gpu/drm/amd/amdgpu/cik.c | 75 ++++++++++ drivers/gpu/drm/amd/amdgpu/nv.c | 179 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/si.c | 109 ++++++++++++++ drivers/gpu/drm/amd/amdgpu/soc15.c | 230 +++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vi.c | 188 +++++++++++++++++++++++ 5 files changed, 781 insertions(+)
drivers/gpu/drm/amd/amdgpu/cik.c +75 -0
@@ -70,6 +70,80 @@#include "amdgpu_amdkfd.h" #include "dce_virtual.h" +static const struct amdgpu_video_codec_info cik_video_codecs_encode_array[] = +{ + { + .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .max_width =2048 , + .max_height =1152 , + .max_pixels_per_frame =2048 *1152 , + .max_level =0 , + }, +}; + +static const struct amdgpu_video_codecs cik_video_codecs_encode = +{ + .codec_count =ARRAY_SIZE (cik_video_codecs_encode_array), + .codec_array = cik_video_codecs_encode_array, +}; + +static const struct amdgpu_video_codec_info cik_video_codecs_decode_array[] = +{ + { + .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .max_width =2048 , + .max_height =1152 , + .max_pixels_per_frame =2048 *1152 , + .max_level =3 , + }, + { + .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .max_width =2048 , + .max_height =1152 , + .max_pixels_per_frame =2048 *1152 , + .max_level =5 , + }, + { + .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .max_width =2048 , + .max_height =1152 , + .max_pixels_per_frame =2048 *1152 , + .max_level =41 , + }, + { + .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .max_width =2048 , + .max_height =1152 , + .max_pixels_per_frame =2048 *1152 , + .max_level =4 , + }, +}; + +static const struct amdgpu_video_codecs cik_video_codecs_decode = +{ + .codec_count =ARRAY_SIZE (cik_video_codecs_decode_array), + .codec_array = cik_video_codecs_decode_array, +}; + +static int cik_query_video_codecs (struct amdgpu_device *adev,bool encode, +const struct amdgpu_video_codecs **codecs) +{ +switch (adev->asic_type) { +case CHIP_BONAIRE : +case CHIP_HAWAII : +case CHIP_KAVERI : +case CHIP_KABINI : +case CHIP_MULLINS : +if (encode) + *codecs = &cik_video_codecs_encode; +else + *codecs = &cik_video_codecs_decode; +return 0 ; +default : +return -EINVAL ; + } +} +/* * Indirect registers accessor */
@@ -1933,6 +2007,7 @@ static const struct amdgpu_asic_funcs cik_asic_funcs = .get_pcie_replay_count = &cik_get_pcie_replay_count, .supports_baco = &cik_asic_supports_baco, .pre_asic_init = &cik_pre_asic_init, + .query_video_codecs = &cik_query_video_codecs, };static int cik_common_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/nv.c +179 -0
191 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/si.c +109 -0
121 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/soc15.c +230 -0
248 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/vi.c +188 -0
200 lines not on this page · raw message
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 3/5 drm/amdgpu: add INFO ioctl support for querying video caps (v4)
In reply to Alex DeucherWe currently hardcode these in mesa, but querying them from the kernel makes more sense since there may be board specific limitations that the kernel driver is better suited to determining.
Userpace patches that use this interface:
https://gitlab.freedesktop.org/leoliu/drm/-/commits/info_video_caps
https://gitlab.freedesktop.org/leoliu/mesa/-/commits/info_video_caps
v2: reorder the codecs to better align with mesa
v3: add max_pixels_per_frame to handle the portrait case, squash in
memory leak fix
v4: drop extra break
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 57 +++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 34 +++++++++++++++ 2 files changed, 91 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +57 -0
@@ -982,6 +982,63 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) min_t(u64, size, sizeof(ras_mask))) ? -EFAULT :0 ; } +case AMDGPU_INFO_VIDEO_CAPS : { +const struct amdgpu_video_codecs *codecs; +struct drm_amdgpu_info_video_caps *caps; +int r; + +switch (info->video_cap.type) { +case AMDGPU_INFO_VIDEO_CAPS_DECODE : + r =amdgpu_asic_query_video_codecs (adev, false, &codecs); +if (r) +return -EINVAL ; +break ; +case AMDGPU_INFO_VIDEO_CAPS_ENCODE : + r =amdgpu_asic_query_video_codecs (adev, true, &codecs); +if (r) +return -EINVAL ; +break ; +default : +DRM_DEBUG_KMS ("Invalid request %d\n" , + info->video_cap.type); +return -EINVAL ; + } + + caps =kzalloc (sizeof (*caps),GFP_KERNEL ); +if (!caps) +return -ENOMEM ; + +for (i =0 ; i < codecs->codec_count; i++) { +int idx = codecs->codec_array[i].codec_type; + +switch (idx) { +case AMDGPU_VIDEO_CODEC_TYPE_MPEG2 : +case AMDGPU_VIDEO_CODEC_TYPE_MPEG4 : +case AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC : +case AMDGPU_VIDEO_CODEC_TYPE_VC1 : +case AMDGPU_VIDEO_CODEC_TYPE_HEVC : +case AMDGPU_VIDEO_CODEC_TYPE_JPEG : +case AMDGPU_VIDEO_CODEC_TYPE_VP9 : +case AMDGPU_VIDEO_CODEC_TYPE_AV1 : + caps->codec_info[idx].valid =1 ; + caps->codec_info[idx].max_width = + codecs->codec_array[i].max_width; + caps->codec_info[idx].max_height = + codecs->codec_array[i].max_height; + caps->codec_info[idx].max_pixels_per_frame = + codecs->codec_array[i].max_pixels_per_frame; + caps->codec_info[idx].max_level = + codecs->codec_array[i].max_level; +break ; +default : +break ; + } + } + r =copy_to_user (out, caps, +min ((size_t )size,sizeof (*caps))) ? -EFAULT :0 ; +kfree (caps); +return r; + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
include/uapi/drm/amdgpu_drm.h +34 -0
@@ -782,6 +782,12 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F/* query ras mask of enabled features*/ #define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20 +/* query video encode/decode caps */ +#define AMDGPU_INFO_VIDEO_CAPS 0x21 +/* Subquery id: Decode */ +#define AMDGPU_INFO_VIDEO_CAPS_DECODE 0 +/* Subquery id: Encode */ +#define AMDGPU_INFO_VIDEO_CAPS_ENCODE 1/* RAS MASK: UMC (VRAM) */ #define AMDGPU_INFO_RAS_ENABLED_UMC (1 << 0)
@@ -878,6 +884,10 @@ struct drm_amdgpu_info {struct {__u32 type; } sensor_info; + +struct { +__u32 type; + } video_cap; }; };
@@ -1074,6 +1084,30 @@ struct drm_amdgpu_info_vce_clock_table {__u32 pad; }; +/* query video encode/decode caps */ +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 0 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 1 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 2 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC 3 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC 4 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG 5 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 6 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 7 +#define AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT 8 + +struct drm_amdgpu_info_video_codec_info { +__u32 valid; +__u32 max_width; +__u32 max_height; +__u32 max_pixels_per_frame; +__u32 max_level; +__u32 pad; +}; + +struct drm_amdgpu_info_video_caps { +struct drm_amdgpu_info_video_codec_info codec_info[AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_COUNT ]; +}; +/* * Supported GPU families */
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 4/5 drm/amdgpu: bump driver version for new video codec INFO ioctl query
In reply to Alex DeucherSo mesa can check when to query the kernel vs use hardcoded codec bandwidth data.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -90,9 +90,10 @@* - 3.38.0 - Add AMDGPU_IB_FLAG_EMIT_MEM_SYNC * - 3.39.0 - DMABUF implicit sync does a full pipeline sync * - 3.40.0 - Add AMDGPU_IDS_FLAGS_TMZ +* - 3.41.0 - Add video codec query */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 40 +#define KMS_DRIVER_MINOR 41#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit;
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
maintainerPATCH 5/5 drm/amdgpu/codec: drop the internal codec index
In reply to Alex DeucherAnd just use the ioctl index. They are the same.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 16 ++++----- drivers/gpu/drm/amd/amdgpu/cik.c | 12 ++++--- drivers/gpu/drm/amd/amdgpu/nv.c | 36 ++++++++++--------- drivers/gpu/drm/amd/amdgpu/si.c | 12 ++++--- drivers/gpu/drm/amd/amdgpu/soc15.c | 46 +++++++++++++------------ drivers/gpu/drm/amd/amdgpu/vi.c | 28 ++++++++------- 7 files changed, 80 insertions(+), 79 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -9
@@ -583,15 +583,6 @@ enum amd_reset_method { AMD_RESET_METHOD_PCI, }; -#define AMDGPU_VIDEO_CODEC_TYPE_MPEG2 0 -#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4 1 -#define AMDGPU_VIDEO_CODEC_TYPE_VC1 2 -#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC 3 -#define AMDGPU_VIDEO_CODEC_TYPE_HEVC 4 -#define AMDGPU_VIDEO_CODEC_TYPE_JPEG 5 -#define AMDGPU_VIDEO_CODEC_TYPE_VP9 6 -#define AMDGPU_VIDEO_CODEC_TYPE_AV1 7 -struct amdgpu_video_codec_info {u32 codec_type;u32 max_width;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +8 -8
@@ -1012,14 +1012,14 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)int idx = codecs->codec_array[i].codec_type;switch (idx) { -case AMDGPU_VIDEO_CODEC_TYPE_MPEG2 : -case AMDGPU_VIDEO_CODEC_TYPE_MPEG4 : -case AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC : -case AMDGPU_VIDEO_CODEC_TYPE_VC1 : -case AMDGPU_VIDEO_CODEC_TYPE_HEVC : -case AMDGPU_VIDEO_CODEC_TYPE_JPEG : -case AMDGPU_VIDEO_CODEC_TYPE_VP9 : -case AMDGPU_VIDEO_CODEC_TYPE_AV1 : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 : +case AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 : caps->codec_info[idx].valid =1 ; caps->codec_info[idx].max_width = codecs->codec_array[i].max_width;
drivers/gpu/drm/amd/amdgpu/cik.c +7 -5
@@ -26,6 +26,8 @@#include <linux/module.h> #include <linux/pci.h> +#include <drm/amdgpu_drm.h> +#include "amdgpu.h" #include "amdgpu_atombios.h" #include "amdgpu_ih.h"
@@ -73,7 +75,7 @@static const struct amdgpu_video_codec_info cik_video_codecs_encode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 ,
@@ -90,28 +92,28 @@ static const struct amdgpu_video_codecs cik_video_codecs_encode =static const struct amdgpu_video_codec_info cik_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =41 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 ,
drivers/gpu/drm/amd/amdgpu/nv.c +19 -17
@@ -25,6 +25,8 @@#include <linux/module.h> #include <linux/pci.h> +#include <drm/amdgpu_drm.h> +#include "amdgpu.h" #include "amdgpu_atombios.h" #include "amdgpu_ih.h"
@@ -69,14 +71,14 @@ static const struct amd_ip_funcs nv_common_ip_funcs;static const struct amdgpu_video_codec_info nv_video_codecs_encode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =2304 , .max_pixels_per_frame =4096 *2304 , .max_level =0 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_HEVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC , .max_width =4096 , .max_height =2304 , .max_pixels_per_frame =4096 *2304 ,
@@ -94,49 +96,49 @@ static const struct amdgpu_video_codecs nv_video_codecs_encode =static const struct amdgpu_video_codec_info nv_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =52 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =4 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_HEVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC , .max_width =8192 , .max_height =4352 , .max_pixels_per_frame =8192 *4352 , .max_level =186 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_JPEG , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =0 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VP9 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 , .max_width =8192 , .max_height =4352 , .max_pixels_per_frame =8192 *4352 ,
@@ -154,56 +156,56 @@ static const struct amdgpu_video_codecs nv_video_codecs_decode =static const struct amdgpu_video_codec_info sc_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =52 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =4 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_HEVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC , .max_width =8192 , .max_height =4352 , .max_pixels_per_frame =8192 *4352 , .max_level =186 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_JPEG , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =0 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VP9 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9 , .max_width =8192 , .max_height =4352 , .max_pixels_per_frame =8192 *4352 , .max_level =0 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_AV1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1 , .max_width =8192 , .max_height =4352 , .max_pixels_per_frame =8192 *4352 ,
drivers/gpu/drm/amd/amdgpu/si.c +7 -5
@@ -26,6 +26,8 @@#include <linux/module.h> #include <linux/pci.h> +#include <drm/amdgpu_drm.h> +#include "amdgpu.h" #include "amdgpu_atombios.h" #include "amdgpu_ih.h"
@@ -911,7 +913,7 @@ static const u32 hainan_mgcg_cgcg_init[] =static const struct amdgpu_video_codec_info tahiti_video_codecs_encode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 ,
@@ -942,28 +944,28 @@ static const struct amdgpu_video_codecs hainan_video_codecs_encode =static const struct amdgpu_video_codec_info tahiti_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 , .max_level =41 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =2048 , .max_height =1152 , .max_pixels_per_frame =2048 *1152 ,
drivers/gpu/drm/amd/amdgpu/soc15.c +24 -22
184 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/vi.c +15 -13
@@ -24,6 +24,8 @@#include <linux/pci.h> #include <linux/slab.h> +#include <drm/amdgpu_drm.h> +#include "amdgpu.h" #include "amdgpu_atombios.h" #include "amdgpu_ih.h"
@@ -90,7 +92,7 @@ static const struct amdgpu_video_codecs topaz_video_codecs_encode =static const struct amdgpu_video_codec_info tonga_video_codecs_encode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =2304 , .max_pixels_per_frame =4096 *2304 ,
@@ -108,14 +110,14 @@ static const struct amdgpu_video_codecs tonga_video_codecs_encode =static const struct amdgpu_video_codec_info polaris_video_codecs_encode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =2304 , .max_pixels_per_frame =4096 *2304 , .max_level =0 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_HEVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC , .max_width =4096 , .max_height =2304 , .max_pixels_per_frame =4096 *2304 ,
@@ -140,28 +142,28 @@ static const struct amdgpu_video_codecs topaz_video_codecs_decode =static const struct amdgpu_video_codec_info tonga_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =52 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 ,
@@ -179,42 +181,42 @@ static const struct amdgpu_video_codecs tonga_video_codecs_decode =static const struct amdgpu_video_codec_info cz_video_codecs_decode_array[] = { { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG2 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG2 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =3 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =5 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =52 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_VC1 , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VC1 , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =4 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_HEVC , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 , .max_level =186 , }, { - .codec_type =AMDGPU_VIDEO_CODEC_TYPE_JPEG , + .codec_type =AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG , .max_width =4096 , .max_height =4096 , .max_pixels_per_frame =4096 *4096 ,
Signature · 6 lines
2.29.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 25.02.21 um 21:16 schrieb Alex Deucher:
Quoted 11 lines
This will be used by a new INFO ioctl query to fetch the decode and encode capabilities from the kernel driver rather than hardcoding them in mesa. This gives us more fine grained control of capabilities using information that is only availabl in the kernel (e.g., platform limitations or bandwidth restrictions).
v2: reorder the codecs to better align with mesa
v3: addmax_pixels_per_frameto handle the portrait caseReviewed-by Leo Liu <[email protected]> (v2)Signed-off-by Alex Deucher <[email protected]>
Quoted 48 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +25
-0@@ -583,6 +583,28 @@ enum amd_reset_method { AMD_RESET_METHOD_PCI, }; +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG2 0 +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4 1 +#define AMDGPU_VIDEO_CODEC_TYPE_VC1 2 +#define AMDGPU_VIDEO_CODEC_TYPE_MPEG4_AVC 3 +#define AMDGPU_VIDEO_CODEC_TYPE_HEVC 4 +#define AMDGPU_VIDEO_CODEC_TYPE_JPEG 5 +#define AMDGPU_VIDEO_CODEC_TYPE_VP9 6 +#define AMDGPU_VIDEO_CODEC_TYPE_AV1 7 + +struct amdgpu_video_codec_info { +u32 codec_type; +u32 max_width; +u32 max_height; +u32 max_pixels_per_frame; +u32 max_level; +}; + +struct amdgpu_video_codecs { +const u32 codec_count; +const struct amdgpu_video_codec_info *codec_array; +}; +/* * ASIC specific functions. */ @@ -627,6 +649,9 @@ struct amdgpu_asic_funcs {void (*pre_asic_init)(struct amdgpu_device *adev);/* enter/exit umd stable pstate */ int (*update_umd_stable_pstate)(struct amdgpu_device *adev,bool enter); +/* query video codecs */ +int (*query_video_codecs)(struct amdgpu_device *adev,bool encode, +const struct amdgpu_video_codecs **codecs); };/*
drivers/gpu/drm/amd/amdgpu/amdgpu.h int emu_soc_asic_init(struct amdgpu_device *adev); · line 1252
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1221,6 +1246,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_pre_asic_init (adev) (adev)->asic_funcs->pre_asic_init((adev))#define amdgpu_asic_update_umd_stable_pstate (adev, enter) \ ((adev)->asic_funcs->update_umd_stable_pstate ? (adev)->asic_funcs->update_umd_stable_pstate((adev), (enter)) : 0) +#define amdgpu_asic_query_video_codecs (adev, e, c) (adev)->asic_funcs->query_video_codecs((adev), (e), (c))#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter));
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx