]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/si.c
Merge tag 'csky-for-linus-5.13-rc1' of git://github.com/c-sky/csky-linux
[linux.git] / drivers / gpu / drm / amd / amdgpu / si.c
index 6b5cf7882a12d03aa133ec30a5c1b0177162c6e1..7cbc2bb03bc63596d07cab21e5d4ba3f522abb7a 100644 (file)
@@ -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"
@@ -905,6 +907,114 @@ static const u32 hainan_mgcg_cgcg_init[] =
        0x3630, 0xfffffff0, 0x00000100,
 };
 
+/* XXX: update when we support VCE */
+#if 0
+/* tahiti, pitcarin, verde */
+static const struct amdgpu_video_codec_info tahiti_video_codecs_encode_array[] =
+{
+       {
+               .codec_type = AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4_AVC,
+               .max_width = 2048,
+               .max_height = 1152,
+               .max_pixels_per_frame = 2048 * 1152,
+               .max_level = 0,
+       },
+};
+
+static const struct amdgpu_video_codecs tahiti_video_codecs_encode =
+{
+       .codec_count = ARRAY_SIZE(tahiti_video_codecs_encode_array),
+       .codec_array = tahiti_video_codecs_encode_array,
+};
+#else
+static const struct amdgpu_video_codecs tahiti_video_codecs_encode =
+{
+       .codec_count = 0,
+       .codec_array = NULL,
+};
+#endif
+/* oland and hainan don't support encode */
+static const struct amdgpu_video_codecs hainan_video_codecs_encode =
+{
+       .codec_count = 0,
+       .codec_array = NULL,
+};
+
+/* tahiti, pitcarin, verde, oland */
+static const struct amdgpu_video_codec_info tahiti_video_codecs_decode_array[] =
+{
+       {
+               .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_INFO_VIDEO_CAPS_CODEC_IDX_MPEG4,
+               .max_width = 2048,
+               .max_height = 1152,
+               .max_pixels_per_frame = 2048 * 1152,
+               .max_level = 5,
+       },
+       {
+               .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_INFO_VIDEO_CAPS_CODEC_IDX_VC1,
+               .max_width = 2048,
+               .max_height = 1152,
+               .max_pixels_per_frame = 2048 * 1152,
+               .max_level = 4,
+       },
+};
+
+static const struct amdgpu_video_codecs tahiti_video_codecs_decode =
+{
+       .codec_count = ARRAY_SIZE(tahiti_video_codecs_decode_array),
+       .codec_array = tahiti_video_codecs_decode_array,
+};
+
+/* hainan doesn't support decode */
+static const struct amdgpu_video_codecs hainan_video_codecs_decode =
+{
+       .codec_count = 0,
+       .codec_array = NULL,
+};
+
+static int si_query_video_codecs(struct amdgpu_device *adev, bool encode,
+                                const struct amdgpu_video_codecs **codecs)
+{
+       switch (adev->asic_type) {
+       case CHIP_VERDE:
+       case CHIP_TAHITI:
+       case CHIP_PITCAIRN:
+               if (encode)
+                       *codecs = &tahiti_video_codecs_encode;
+               else
+                       *codecs = &tahiti_video_codecs_decode;
+               return 0;
+       case CHIP_OLAND:
+               if (encode)
+                       *codecs = &hainan_video_codecs_encode;
+               else
+                       *codecs = &tahiti_video_codecs_decode;
+               return 0;
+       case CHIP_HAINAN:
+               if (encode)
+                       *codecs = &hainan_video_codecs_encode;
+               else
+                       *codecs = &hainan_video_codecs_decode;
+               return 0;
+       default:
+               return -EINVAL;
+       }
+}
+
 static u32 si_pcie_rreg(struct amdgpu_device *adev, u32 reg)
 {
        unsigned long flags;
@@ -1903,6 +2013,7 @@ static const struct amdgpu_asic_funcs si_asic_funcs =
        .get_pcie_replay_count = &si_get_pcie_replay_count,
        .supports_baco = &si_asic_supports_baco,
        .pre_asic_init = &si_pre_asic_init,
+       .query_video_codecs = &si_query_video_codecs,
 };
 
 static uint32_t si_get_rev_id(struct amdgpu_device *adev)
This page took 0.036901 seconds and 4 git commands to generate.