ソースを参照

video: driver: move v4l2 to vidc mappings to target specific file

Move mapping of v4l2 to vidc macros for codec, color format,
color primaries etc to target specific file to restirct the
usage of private v4l2 defines to target specific file.

Change-Id: Ie83968cb944c756e55b6514c496c0b23c5d16413
Signed-off-by: Dikshita Agarwal <[email protected]>
Dikshita Agarwal 2 年 前
コミット
c5c78e3ba2

+ 41 - 0
driver/platform/common/inc/msm_vidc_platform.h

@@ -41,6 +41,33 @@ extern u32 vpe_csc_custom_matrix_coeff[MAX_MATRIX_COEFFS];
 extern u32 vpe_csc_custom_bias_coeff[MAX_BIAS_COEFFS];
 extern u32 vpe_csc_custom_limit_coeff[MAX_LIMIT_COEFFS];
 
+struct codec_info {
+	u32 v4l2_codec;
+	enum msm_vidc_codec_type vidc_codec;
+	const char *pixfmt_name;
+};
+
+struct color_format_info {
+	u32 v4l2_color_format;
+	enum msm_vidc_colorformat_type vidc_color_format;
+	const char *pixfmt_name;
+};
+
+struct color_primaries_info {
+	u32 v4l2_color_primaries;
+	enum msm_vidc_color_primaries vidc_color_primaries;
+};
+
+struct transfer_char_info {
+	u32 v4l2_transfer_char;
+	enum msm_vidc_transfer_characteristics vidc_transfer_char;
+};
+
+struct matrix_coeff_info {
+	u32 v4l2_matrix_coeff;
+	enum msm_vidc_matrix_coefficients vidc_matrix_coeff;
+};
+
 struct msm_platform_core_capability {
 	enum msm_vidc_core_capability_type type;
 	u32 value;
@@ -95,6 +122,19 @@ struct msm_vidc_ubwc_config_data {
 	u32 bank_spreading;
 };
 
+struct msm_vidc_format_capability {
+	struct codec_info *codec_info;
+	u32 codec_info_size;
+	struct color_format_info *color_format_info;
+	u32 color_format_info_size;
+	struct color_primaries_info *color_prim_info;
+	u32 color_prim_info_size;
+	struct transfer_char_info *transfer_char_info;
+	u32 transfer_char_info_size;
+	struct matrix_coeff_info *matrix_coeff_info;
+	u32 matrix_coeff_info_size;
+};
+
 struct msm_vidc_platform_data {
 	struct msm_platform_core_capability *core_data;
 	u32 core_data_size;
@@ -107,6 +147,7 @@ struct msm_vidc_platform_data {
 	struct msm_vidc_efuse_data *efuse_data;
 	unsigned int efuse_data_size;
 	unsigned int sku_version;
+	struct msm_vidc_format_capability *format_data;
 };
 
 struct msm_vidc_platform {

+ 143 - 1
driver/platform/kalama/src/kalama.c

@@ -9,7 +9,6 @@
 #include "msm_vidc_kalama.h"
 #include "msm_vidc_platform.h"
 #include "msm_vidc_debug.h"
-#include "msm_vidc_internal.h"
 #include "hfi_property.h"
 #include "msm_vidc_iris3.h"
 #include "hfi_command.h"
@@ -41,6 +40,135 @@
 #define CODECS_ALL     (H264 | HEVC | VP9 | HEIC | AV1)
 #define MAXIMUM_OVERRIDE_VP9_FPS 180
 
+static struct codec_info codec_data_kalama[] = {
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_H264,
+		.vidc_codec  = MSM_VIDC_H264,
+		.pixfmt_name = "AVC",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_HEVC,
+		.vidc_codec  = MSM_VIDC_HEVC,
+		.pixfmt_name = "HEVC",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_VP9,
+		.vidc_codec  = MSM_VIDC_VP9,
+		.pixfmt_name = "VP9",
+	},
+};
+
+static struct color_format_info color_format_data_kalama[] = {
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_NV12,
+		.vidc_color_format = MSM_VIDC_FMT_NV12,
+		.pixfmt_name       = "NV12",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_NV21,
+		.vidc_color_format = MSM_VIDC_FMT_NV21,
+		.pixfmt_name       = "NV21",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_RGBA32,
+		.vidc_color_format = MSM_VIDC_FMT_RGBA8888,
+		.pixfmt_name       = "RGBA",
+	},
+};
+
+static struct color_primaries_info color_primaries_data_kalama[] = {
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_DEFAULT,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_RESERVED,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_REC709,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT709,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_470_SYSTEM_M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT470_SYSTEM_M,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_470_SYSTEM_BG,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT470_SYSTEM_BG,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_SMPTE170M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT601_525,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_SMPTE240M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_ST240M,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_BT2020,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT2020,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_DCI_P3,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_RP431_2,
+	},
+};
+
+static struct transfer_char_info transfer_char_data_kalama[] = {
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_DEFAULT,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_RESERVED,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_709,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT709,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SMPTE240M,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SMPTE_ST240M,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SRGB,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SRGB_SYCC,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SMPTE2084,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SMPTE_ST2084_PQ,
+	},
+};
+
+static struct matrix_coeff_info matrix_coeff_data_kalama[] = {
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_DEFAULT,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_RESERVED,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_709,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT709,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_XV709,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT709,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_XV601,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT470_SYS_BG_OR_BT601_625,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_601,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT601_525_BT1358_525_OR_625,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_SMPTE240M,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_SMPTE_ST240,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_BT2020,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT2020_NON_CONSTANT,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_BT2020_CONST_LUM,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT2020_CONSTANT,
+	},
+};
+
 static struct msm_platform_core_capability core_data_kalama[] = {
 	/* {type, value} */
 	{ENC_CODECS, H264|HEVC|HEIC},
@@ -1799,6 +1927,19 @@ static struct msm_vidc_ubwc_config_data ubwc_config_kalama[] = {
 	UBWC_CONFIG(8, 32, 16, 0, 1, 1, 1),
 };
 
+static struct msm_vidc_format_capability format_data_kalama = {
+	.codec_info = codec_data_kalama,
+	.codec_info_size = ARRAY_SIZE(codec_data_kalama),
+	.color_format_info = color_format_data_kalama,
+	.color_format_info_size = ARRAY_SIZE(color_format_data_kalama),
+	.color_prim_info = color_primaries_data_kalama,
+	.color_prim_info_size = ARRAY_SIZE(color_primaries_data_kalama),
+	.transfer_char_info = transfer_char_data_kalama,
+	.transfer_char_info_size = ARRAY_SIZE(transfer_char_data_kalama),
+	.matrix_coeff_info = matrix_coeff_data_kalama,
+	.matrix_coeff_info_size = ARRAY_SIZE(matrix_coeff_data_kalama),
+};
+
 static const struct msm_vidc_platform_data kalama_data = {
 	.core_data = core_data_kalama,
 	.core_data_size = ARRAY_SIZE(core_data_kalama),
@@ -1810,6 +1951,7 @@ static const struct msm_vidc_platform_data kalama_data = {
 	.csc_data.vpe_csc_custom_matrix_coeff = vpe_csc_custom_matrix_coeff,
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
 	.ubwc_config = ubwc_config_kalama,
+	.format_data = &format_data_kalama,
 };
 
 int msm_vidc_kalama_check_ddr_type(void)

+ 234 - 0
driver/platform/kalama/src/msm_vidc_kalama.c

@@ -43,6 +43,226 @@
 #define CODECS_ALL     (H264 | HEVC | VP9 | HEIC | AV1)
 #define MAXIMUM_OVERRIDE_VP9_FPS 180
 
+static struct codec_info codec_data_kalama[] = {
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_H264,
+		.vidc_codec  = MSM_VIDC_H264,
+		.pixfmt_name = "AVC",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_HEVC,
+		.vidc_codec  = MSM_VIDC_HEVC,
+		.pixfmt_name = "HEVC",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_VP9,
+		.vidc_codec  = MSM_VIDC_VP9,
+		.pixfmt_name = "VP9",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_AV1,
+		.vidc_codec  = MSM_VIDC_AV1,
+		.pixfmt_name = "AV1",
+	},
+	{
+		.v4l2_codec  = V4L2_PIX_FMT_HEIC,
+		.vidc_codec  = MSM_VIDC_HEIC,
+		.pixfmt_name = "HEIC",
+	},
+};
+
+static struct color_format_info color_format_data_kalama[] = {
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_NV12,
+		.vidc_color_format = MSM_VIDC_FMT_NV12,
+		.pixfmt_name       = "NV12",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_NV21,
+		.vidc_color_format = MSM_VIDC_FMT_NV21,
+		.pixfmt_name       = "NV21",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_VIDC_NV12C,
+		.vidc_color_format = MSM_VIDC_FMT_NV12C,
+		.pixfmt_name       = "NV12C",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_VIDC_TP10C,
+		.vidc_color_format = MSM_VIDC_FMT_TP10C,
+		.pixfmt_name       = "TP10C",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_RGBA32,
+		.vidc_color_format = MSM_VIDC_FMT_RGBA8888,
+		.pixfmt_name       = "RGBA",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_VIDC_ARGB32C,
+		.vidc_color_format = MSM_VIDC_FMT_RGBA8888C,
+		.pixfmt_name       = "RGBAC",
+	},
+	{
+		.v4l2_color_format = V4L2_PIX_FMT_VIDC_P010,
+		.vidc_color_format = MSM_VIDC_FMT_P010,
+		.pixfmt_name       = "P010",
+	},
+	{
+		.v4l2_color_format = V4L2_META_FMT_VIDC,
+		.vidc_color_format = MSM_VIDC_FMT_META,
+		.pixfmt_name       = "META",
+	},
+};
+
+static struct color_primaries_info color_primaries_data_kalama[] = {
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_DEFAULT,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_RESERVED,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_REC709,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT709,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_470_SYSTEM_M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT470_SYSTEM_M,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_470_SYSTEM_BG,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT470_SYSTEM_BG,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_SMPTE170M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT601_525,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_SMPTE240M,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_ST240M,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_VIDC_GENERIC_FILM,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_GENERIC_FILM,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_BT2020,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_BT2020,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_DCI_P3,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_RP431_2,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_VIDC_EG431,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_EG431_1,
+	},
+	{
+		.v4l2_color_primaries  = V4L2_COLORSPACE_VIDC_EBU_TECH,
+		.vidc_color_primaries  = MSM_VIDC_PRIMARIES_SMPTE_EBU_TECH,
+	},
+};
+
+static struct transfer_char_info transfer_char_data_kalama[] = {
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_DEFAULT,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_RESERVED,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_709,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT709,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_M,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT470_SYSTEM_M,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_BG,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT470_SYSTEM_BG,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_BT601_525_OR_625,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT601_525_OR_625,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SMPTE240M,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SMPTE_ST240M,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_LINEAR,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_LINEAR,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_XVYCC,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_XVYCC,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_BT1361,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT1361_0,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SRGB,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SRGB_SYCC,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_BT2020,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT2020_14,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_SMPTE2084,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SMPTE_ST2084_PQ,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_ST428,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_SMPTE_ST428_1,
+	},
+	{
+		.v4l2_transfer_char  = V4L2_XFER_FUNC_VIDC_HLG,
+		.vidc_transfer_char  = MSM_VIDC_TRANSFER_BT2100_2_HLG,
+	},
+};
+
+static struct matrix_coeff_info matrix_coeff_data_kalama[] = {
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_DEFAULT,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_RESERVED,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_VIDC_SRGB_OR_SMPTE_ST428,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_SRGB_SMPTE_ST428_1,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_709,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT709,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_XV709,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT709,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_VIDC_FCC47_73_682,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_FCC_TITLE_47,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_XV601,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT470_SYS_BG_OR_BT601_625,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_601,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT601_525_BT1358_525_OR_625,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_SMPTE240M,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_SMPTE_ST240,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_BT2020,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT2020_NON_CONSTANT,
+	},
+	{
+		.v4l2_matrix_coeff  = V4L2_YCBCR_ENC_BT2020_CONST_LUM,
+		.vidc_matrix_coeff  = MSM_VIDC_MATRIX_COEFF_BT2020_CONSTANT,
+	},
+};
+
 static struct msm_platform_core_capability core_data_kalama[] = {
 	/* {type, value} */
 	{ENC_CODECS, H264|HEVC|HEIC},
@@ -2419,6 +2639,19 @@ static struct msm_vidc_ubwc_config_data ubwc_config_kalama[] = {
 	UBWC_CONFIG(8, 32, 16, 0, 1, 1, 1),
 };
 
+static struct msm_vidc_format_capability format_data_kalama = {
+	.codec_info = codec_data_kalama,
+	.codec_info_size = ARRAY_SIZE(codec_data_kalama),
+	.color_format_info = color_format_data_kalama,
+	.color_format_info_size = ARRAY_SIZE(color_format_data_kalama),
+	.color_prim_info = color_primaries_data_kalama,
+	.color_prim_info_size = ARRAY_SIZE(color_primaries_data_kalama),
+	.transfer_char_info = transfer_char_data_kalama,
+	.transfer_char_info_size = ARRAY_SIZE(transfer_char_data_kalama),
+	.matrix_coeff_info = matrix_coeff_data_kalama,
+	.matrix_coeff_info_size = ARRAY_SIZE(matrix_coeff_data_kalama),
+};
+
 static const struct msm_vidc_platform_data kalama_data = {
 	.core_data = core_data_kalama,
 	.core_data_size = ARRAY_SIZE(core_data_kalama),
@@ -2430,6 +2663,7 @@ static const struct msm_vidc_platform_data kalama_data = {
 	.csc_data.vpe_csc_custom_matrix_coeff = vpe_csc_custom_matrix_coeff,
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
 	.ubwc_config = ubwc_config_kalama,
+	.format_data = &format_data_kalama,
 };
 
 int msm_vidc_kalama_check_ddr_type(void)

+ 2 - 2
driver/variant/iris2/src/msm_vidc_buffer_iris2.c

@@ -143,7 +143,7 @@ static u32 msm_vidc_decoder_line_size_iris2(struct msm_vidc_inst *inst)
 	}
 	num_vpp_pipes = core->capabilities[NUM_VPP_PIPE].value;
 
-	color_fmt = v4l2_colorformat_to_driver(
+	color_fmt = v4l2_colorformat_to_driver(inst,
 			inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 	if (is_linear_colorformat(color_fmt))
 		is_opb = true;
@@ -473,7 +473,7 @@ static u32 msm_vidc_encoder_vpss_size_iris2(struct msm_vidc_inst* inst)
 	}
 
 	f = &inst->fmts[INPUT_PORT];
-	driver_colorfmt = v4l2_colorformat_to_driver(
+	driver_colorfmt = v4l2_colorformat_to_driver(inst,
 			f->fmt.pix_mp.pixelformat, __func__);
 	is_tenbit = is_10bit_colorformat(driver_colorfmt);
 	if (inst->capabilities->cap[BLUR_TYPES].value != VIDC_BLUR_NONE)

+ 2 - 2
driver/variant/iris3/src/msm_vidc_buffer_iris3.c

@@ -157,7 +157,7 @@ static u32 msm_vidc_decoder_line_size_iris3(struct msm_vidc_inst *inst)
 	}
 	num_vpp_pipes = core->capabilities[NUM_VPP_PIPE].value;
 
-	color_fmt = v4l2_colorformat_to_driver(
+	color_fmt = v4l2_colorformat_to_driver(inst,
 			inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 	if (is_linear_colorformat(color_fmt))
 		is_opb = true;
@@ -539,7 +539,7 @@ static u32 msm_vidc_encoder_vpss_size_iris3(struct msm_vidc_inst* inst)
 	}
 
 	f = &inst->fmts[INPUT_PORT];
-	driver_colorfmt = v4l2_colorformat_to_driver(
+	driver_colorfmt = v4l2_colorformat_to_driver(inst,
 			f->fmt.pix_mp.pixelformat, __func__);
 	is_tenbit = is_10bit_colorformat(driver_colorfmt);
 	if (inst->capabilities->cap[BLUR_TYPES].value != VIDC_BLUR_NONE)

+ 8 - 8
driver/vidc/inc/msm_vidc_driver.h

@@ -364,20 +364,20 @@ static inline bool is_sub_state(struct msm_vidc_inst *inst,
 }
 
 const char *cap_name(enum msm_vidc_inst_capability_type cap_id);
-const char *v4l2_pixelfmt_name(u32 pixelfmt);
+const char *v4l2_pixelfmt_name(struct msm_vidc_inst *inst, u32 pixelfmt);
 const char *v4l2_type_name(u32 port);
 void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
 		struct msm_vidc_buffer *vbuf);
 void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,
 		struct vb2_buffer *vb2);
-enum msm_vidc_codec_type v4l2_codec_to_driver(u32 v4l2_codec,
-	const char *func);
-u32 v4l2_codec_from_driver(enum msm_vidc_codec_type codec,
-	const char *func);
-enum msm_vidc_colorformat_type v4l2_colorformat_to_driver(u32 colorformat,
-	const char *func);
-u32 v4l2_colorformat_from_driver(enum msm_vidc_colorformat_type colorformat,
+enum msm_vidc_codec_type v4l2_codec_to_driver(struct msm_vidc_inst *inst,
+	u32 v4l2_codec, const char *func);
+u32 v4l2_codec_from_driver(struct msm_vidc_inst *inst, enum msm_vidc_codec_type codec,
 	const char *func);
+enum msm_vidc_colorformat_type v4l2_colorformat_to_driver(struct msm_vidc_inst *inst,
+	u32 colorformat, const char *func);
+u32 v4l2_colorformat_from_driver(struct msm_vidc_inst *inst,
+	enum msm_vidc_colorformat_type colorformat, const char *func);
 u32 v4l2_color_primaries_to_driver(struct msm_vidc_inst *inst,
 	u32 v4l2_primaries, const char *func);
 u32 v4l2_color_primaries_from_driver(struct msm_vidc_inst *inst,

+ 1 - 0
driver/vidc/inc/msm_vidc_internal.h

@@ -164,6 +164,7 @@ enum msm_vidc_colorformat_type {
 	MSM_VIDC_FMT_P010          = BIT(4),
 	MSM_VIDC_FMT_RGBA8888C     = BIT(5),
 	MSM_VIDC_FMT_RGBA8888      = BIT(6),
+	MSM_VIDC_FMT_META          = BIT(31),
 };
 
 enum msm_vidc_buffer_type {

+ 33 - 25
driver/vidc/src/msm_vdec.c

@@ -104,10 +104,10 @@ static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
 		return 0;
 
 	i_vpr_h(inst, "%s: codec changed from %s to %s\n",
-		__func__, v4l2_pixelfmt_name(inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat),
-		v4l2_pixelfmt_name(v4l2_codec));
+		__func__, v4l2_pixelfmt_name(inst, inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat),
+		v4l2_pixelfmt_name(inst, v4l2_codec));
 
-	inst->codec = v4l2_codec_to_driver(v4l2_codec, __func__);
+	inst->codec = v4l2_codec_to_driver(inst, v4l2_codec, __func__);
 	if (!inst->codec) {
 		i_vpr_e(inst, "%s: invalid codec %#x\n", __func__, v4l2_codec);
 		rc = -EINVAL;
@@ -177,7 +177,7 @@ static int msm_vdec_set_linear_stride_scanline(struct msm_vidc_inst *inst)
 	u32 payload[2];
 	enum msm_vidc_colorformat_type colorformat;
 
-	colorformat = v4l2_colorformat_to_driver(
+	colorformat = v4l2_colorformat_to_driver(inst,
 		inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 
 	if (!is_linear_yuv_colorformat(colorformat))
@@ -222,7 +222,7 @@ static int msm_vdec_set_ubwc_stride_scanline(struct msm_vidc_inst *inst)
 	width = f->fmt.pix_mp.width;
 	height = f->fmt.pix_mp.height;
 
-	colorformat = v4l2_colorformat_to_driver(pix_fmt, __func__);
+	colorformat = v4l2_colorformat_to_driver(inst, pix_fmt, __func__);
 
 	if (inst->codec != MSM_VIDC_AV1 ||
 		(!is_ubwc_colorformat(colorformat)))
@@ -316,7 +316,7 @@ static int msm_vdec_set_bit_depth(struct msm_vidc_inst *inst,
 	}
 
 	pix_fmt = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
-	colorformat = v4l2_colorformat_to_driver(pix_fmt, __func__);
+	colorformat = v4l2_colorformat_to_driver(inst, pix_fmt, __func__);
 	if (is_10bit_colorformat(colorformat))
 		bitdepth = 10 << 16 | 10;
 
@@ -705,7 +705,7 @@ static int msm_vdec_set_colorformat(struct msm_vidc_inst *inst)
 	u32 hfi_colorformat;
 
 	pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
-	colorformat = v4l2_colorformat_to_driver(pixelformat, __func__);
+	colorformat = v4l2_colorformat_to_driver(inst, pixelformat, __func__);
 	hfi_colorformat = get_hfi_colorformat(inst, colorformat);
 	i_vpr_h(inst, "%s: hfi colorformat: %d",
 		__func__, hfi_colorformat);
@@ -1250,7 +1250,7 @@ static int msm_vdec_read_input_subcr_params(struct msm_vidc_inst *inst)
 	inst->fmts[INPUT_PORT].fmt.pix_mp.width = width;
 	inst->fmts[INPUT_PORT].fmt.pix_mp.height = height;
 
-	output_fmt = v4l2_colorformat_to_driver(
+	output_fmt = v4l2_colorformat_to_driver(inst,
 		inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 
 	inst->fmts[OUTPUT_PORT].fmt.pix_mp.width = video_y_stride_pix(
@@ -2245,22 +2245,23 @@ int msm_vdec_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 
 	memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
 	if (f->type == INPUT_MPLANE) {
-		pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+		pix_fmt = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		if (!pix_fmt) {
 			i_vpr_e(inst, "%s: unsupported codec, set current params\n", __func__);
 			f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
 			f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
 			f->fmt.pix_mp.pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
-			pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+			pix_fmt = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		}
 	} else if (f->type == OUTPUT_MPLANE) {
-		pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+		pix_fmt = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		if (!pix_fmt) {
 			i_vpr_e(inst, "%s: unsupported format, set current params\n", __func__);
 			f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
 			f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
 			f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
-			pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+			pix_fmt = v4l2_colorformat_to_driver(inst,
+				f->fmt.pix_mp.pixelformat, __func__);
 		}
 		if (inst->bufq[INPUT_PORT].vb2q->streaming) {
 			f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
@@ -2378,7 +2379,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 		inst->crop.height = f->fmt.pix_mp.height;
 		i_vpr_h(inst,
 			"%s: type: INPUT, codec %s width %d height %d size %u min_count %d extra_count %d\n",
-			__func__, v4l2_pixelfmt_name(f->fmt.pix_mp.pixelformat),
+			__func__, v4l2_pixelfmt_name(inst, f->fmt.pix_mp.pixelformat),
 			f->fmt.pix_mp.width, f->fmt.pix_mp.height,
 			fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
 			inst->buffers.input.min_count,
@@ -2386,7 +2387,8 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 	} else if (f->type == INPUT_META_PLANE) {
 		fmt = &inst->fmts[INPUT_META_PORT];
 		fmt->type = INPUT_META_PLANE;
-		fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+		fmt->fmt.meta.dataformat =
+			v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 		fmt->fmt.meta.buffersize = call_session_op(core,
 			buffer_size, inst, MSM_VIDC_BUF_INPUT_META);
 		inst->buffers.input_meta.min_count =
@@ -2409,7 +2411,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 			f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
 		}
 		fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
-		colorformat = v4l2_colorformat_to_driver(fmt->fmt.pix_mp.pixelformat,
+		colorformat = v4l2_colorformat_to_driver(inst, fmt->fmt.pix_mp.pixelformat,
 			__func__);
 		fmt->fmt.pix_mp.width = video_y_stride_pix(
 			colorformat, f->fmt.pix_mp.width);
@@ -2447,7 +2449,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 		}
 		i_vpr_h(inst,
 			"%s: type: OUTPUT, format %s width %d height %d size %u min_count %d extra_count %d\n",
-			__func__, v4l2_pixelfmt_name(fmt->fmt.pix_mp.pixelformat),
+			__func__, v4l2_pixelfmt_name(inst, fmt->fmt.pix_mp.pixelformat),
 			fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height,
 			fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
 			inst->buffers.output.min_count,
@@ -2455,7 +2457,8 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 	} else if (f->type == OUTPUT_META_PLANE) {
 		fmt = &inst->fmts[OUTPUT_META_PORT];
 		fmt->type = OUTPUT_META_PLANE;
-		fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+		fmt->fmt.meta.dataformat =
+			v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 		fmt->fmt.meta.buffersize = call_session_op(core,
 			buffer_size, inst, MSM_VIDC_BUF_OUTPUT_META);
 		inst->buffers.output_meta.min_count =
@@ -2633,7 +2636,7 @@ int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 		}
 		if (!array[f->index])
 			return -EINVAL;
-		f->pixelformat = v4l2_codec_from_driver(array[f->index],
+		f->pixelformat = v4l2_codec_from_driver(inst, array[f->index],
 				__func__);
 		if (!f->pixelformat)
 			return -EINVAL;
@@ -2656,14 +2659,15 @@ int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 		}
 		if (!array[f->index])
 			return -EINVAL;
-		f->pixelformat = v4l2_colorformat_from_driver(array[f->index],
+		f->pixelformat = v4l2_colorformat_from_driver(inst, array[f->index],
 				__func__);
 		if (!f->pixelformat)
 			return -EINVAL;
 		strlcpy(f->description, "colorformat", sizeof(f->description));
 	} else if (f->type == INPUT_META_PLANE || f->type == OUTPUT_META_PLANE) {
 		if (!f->index) {
-			f->pixelformat = V4L2_META_FMT_VIDC;
+			f->pixelformat =
+				v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 			strlcpy(f->description, "metadata", sizeof(f->description));
 		} else {
 			return -EINVAL;
@@ -2672,7 +2676,8 @@ int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 	memset(f->reserved, 0, sizeof(f->reserved));
 
 	i_vpr_h(inst, "%s: index %d, %s: %s, flags %#x\n",
-		__func__, f->index, f->description, v4l2_pixelfmt_name(f->pixelformat), f->flags);
+		__func__, f->index, f->description,
+		v4l2_pixelfmt_name(inst, f->pixelformat), f->flags);
 	return rc;
 }
 
@@ -2722,7 +2727,8 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[INPUT_META_PORT];
 	f->type = INPUT_META_PLANE;
-	f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	f->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);;
 	f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
 	inst->buffers.input_meta.min_count = 0;
 	inst->buffers.input_meta.extra_count = 0;
@@ -2731,8 +2737,9 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[OUTPUT_PORT];
 	f->type = OUTPUT_MPLANE;
-	f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_VIDC_NV12C;
-	colorformat = v4l2_colorformat_to_driver(
+	f->fmt.pix_mp.pixelformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_NV12C, __func__);
+	colorformat = v4l2_colorformat_to_driver(inst,
 		f->fmt.pix_mp.pixelformat, __func__);
 	f->fmt.pix_mp.width = video_y_stride_pix(colorformat, DEFAULT_WIDTH);
 	f->fmt.pix_mp.height = video_y_scanlines(colorformat, DEFAULT_HEIGHT);
@@ -2758,7 +2765,8 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[OUTPUT_META_PORT];
 	f->type = OUTPUT_META_PLANE;
-	f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	f->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 	f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
 	inst->buffers.output_meta.min_count = 0;
 	inst->buffers.output_meta.extra_count = 0;

+ 30 - 23
driver/vidc/src/msm_venc.c

@@ -66,10 +66,10 @@ static int msm_venc_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
 		return 0;
 
 	i_vpr_h(inst, "%s: codec changed from %s to %s\n",
-		__func__, v4l2_pixelfmt_name(inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat),
-		v4l2_pixelfmt_name(v4l2_codec));
+		__func__, v4l2_pixelfmt_name(inst, inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat),
+		v4l2_pixelfmt_name(inst, v4l2_codec));
 
-	inst->codec = v4l2_codec_to_driver(v4l2_codec, __func__);
+	inst->codec = v4l2_codec_to_driver(inst, v4l2_codec, __func__);
 	if (!inst->codec) {
 		i_vpr_e(inst, "%s: invalid codec %#x\n", __func__, v4l2_codec);
 		rc = -EINVAL;
@@ -120,10 +120,10 @@ static int msm_venc_set_colorformat(struct msm_vidc_inst *inst,
 	}
 
 	pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
-	colorformat = v4l2_colorformat_to_driver(pixelformat, __func__);
+	colorformat = v4l2_colorformat_to_driver(inst, pixelformat, __func__);
 	if (!(colorformat & inst->capabilities->cap[PIX_FMTS].step_or_mask)) {
 		i_vpr_e(inst, "%s: invalid pixelformat %s\n",
-			__func__, v4l2_pixelfmt_name(pixelformat));
+			__func__, v4l2_pixelfmt_name(inst, pixelformat));
 		return -EINVAL;
 	}
 
@@ -324,7 +324,7 @@ static int msm_venc_set_colorspace(struct msm_vidc_inst* inst,
 	}
 
 	input_fmt = &inst->fmts[INPUT_PORT];
-	pix_fmt = v4l2_colorformat_to_driver(
+	pix_fmt = v4l2_colorformat_to_driver(inst,
 		input_fmt->fmt.pix_mp.pixelformat, __func__);
 	if (inst->fmts[port].fmt.pix_mp.colorspace != V4L2_COLORSPACE_DEFAULT ||
 	    inst->fmts[port].fmt.pix_mp.ycbcr_enc != V4L2_YCBCR_ENC_DEFAULT ||
@@ -1039,22 +1039,23 @@ int msm_venc_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 	memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
 
 	if (f->type == INPUT_MPLANE) {
-		pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+		pix_fmt = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		if (!pix_fmt) {
 			i_vpr_e(inst, "%s: unsupported format, set current params\n", __func__);
 			f->fmt.pix_mp.pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
 			f->fmt.pix_mp.width = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
 			f->fmt.pix_mp.height = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
-			pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+			pix_fmt = v4l2_colorformat_to_driver(inst,
+				f->fmt.pix_mp.pixelformat, __func__);
 		}
 	} else if (f->type == OUTPUT_MPLANE) {
-		pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+		pix_fmt = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		if (!pix_fmt) {
 			i_vpr_e(inst, "%s: unsupported codec, set current params\n", __func__);
 			f->fmt.pix_mp.width = inst->fmts[OUTPUT_PORT].fmt.pix_mp.width;
 			f->fmt.pix_mp.height = inst->fmts[OUTPUT_PORT].fmt.pix_mp.height;
 			f->fmt.pix_mp.pixelformat = inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat;
-			pix_fmt = v4l2_codec_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+			pix_fmt = v4l2_codec_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 		}
 	} else if (f->type == INPUT_META_PLANE) {
 		f->fmt.meta.dataformat = inst->fmts[INPUT_META_PORT].fmt.meta.dataformat;
@@ -1143,7 +1144,7 @@ int msm_venc_s_fmt_output(struct msm_vidc_inst *inst, struct v4l2_format *f)
 
 	i_vpr_h(inst,
 		"%s: type: OUTPUT, codec %s width %d height %d size %u min_count %d extra_count %d\n",
-		__func__, v4l2_pixelfmt_name(fmt->fmt.pix_mp.pixelformat),
+		__func__, v4l2_pixelfmt_name(inst, fmt->fmt.pix_mp.pixelformat),
 		fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height,
 		fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
 		inst->buffers.output.min_count,
@@ -1168,7 +1169,8 @@ static int msm_venc_s_fmt_output_meta(struct msm_vidc_inst *inst, struct v4l2_fo
 
 	fmt = &inst->fmts[OUTPUT_META_PORT];
 	fmt->type = OUTPUT_META_PLANE;
-	fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	fmt->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 	fmt->fmt.meta.buffersize = call_session_op(core,
 		buffer_size, inst, MSM_VIDC_BUF_OUTPUT_META);
 	inst->buffers.output_meta.min_count =
@@ -1203,7 +1205,7 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
 	core = inst->core;
 	msm_venc_try_fmt(inst, f);
 
-	pix_fmt = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat, __func__);
+	pix_fmt = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat, __func__);
 	msm_vidc_update_cap_value(inst, PIX_FMTS, pix_fmt, __func__);
 
 	width = f->fmt.pix_mp.width;
@@ -1283,7 +1285,7 @@ static int msm_venc_s_fmt_input(struct msm_vidc_inst *inst, struct v4l2_format *
 
 	i_vpr_h(inst,
 		"%s: type: INPUT, format %s width %d height %d size %u min_count %d extra_count %d\n",
-		__func__, v4l2_pixelfmt_name(fmt->fmt.pix_mp.pixelformat),
+		__func__, v4l2_pixelfmt_name(inst, fmt->fmt.pix_mp.pixelformat),
 		fmt->fmt.pix_mp.width, fmt->fmt.pix_mp.height,
 		fmt->fmt.pix_mp.plane_fmt[0].sizeimage,
 		inst->buffers.input.min_count,
@@ -1309,7 +1311,8 @@ static int msm_venc_s_fmt_input_meta(struct msm_vidc_inst *inst, struct v4l2_for
 
 	fmt = &inst->fmts[INPUT_META_PORT];
 	fmt->type = INPUT_META_PLANE;
-	fmt->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	fmt->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 	fmt->fmt.meta.buffersize = call_session_op(core,
 		buffer_size, inst, MSM_VIDC_BUF_INPUT_META);
 	inst->buffers.input_meta.min_count =
@@ -1742,7 +1745,7 @@ int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 		}
 		if (!array[f->index])
 			return -EINVAL;
-		f->pixelformat = v4l2_codec_from_driver(array[f->index],
+		f->pixelformat = v4l2_codec_from_driver(inst, array[f->index],
 				__func__);
 		if (!f->pixelformat)
 			return -EINVAL;
@@ -1762,14 +1765,15 @@ int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 		}
 		if (!array[f->index])
 			return -EINVAL;
-		f->pixelformat = v4l2_colorformat_from_driver(array[f->index],
+		f->pixelformat = v4l2_colorformat_from_driver(inst, array[f->index],
 				__func__);
 		if (!f->pixelformat)
 			return -EINVAL;
 		strlcpy(f->description, "colorformat", sizeof(f->description));
 	} else if (f->type == INPUT_META_PLANE || f->type == OUTPUT_META_PLANE) {
 		if (!f->index) {
-			f->pixelformat = V4L2_META_FMT_VIDC;
+			f->pixelformat =
+				v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 			strlcpy(f->description, "metadata", sizeof(f->description));
 		} else {
 			return -EINVAL;
@@ -1779,7 +1783,7 @@ int msm_venc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
 
 	i_vpr_h(inst, "%s: index %d, %s: %s, flags %#x\n",
 		__func__, f->index, f->description,
-		v4l2_pixelfmt_name(f->pixelformat), f->flags);
+		v4l2_pixelfmt_name(inst, f->pixelformat), f->flags);
 	return rc;
 }
 
@@ -1834,7 +1838,8 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[OUTPUT_META_PORT];
 	f->type = OUTPUT_META_PLANE;
-	f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	f->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 	f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
 	inst->buffers.output_meta.min_count = 0;
 	inst->buffers.output_meta.extra_count = 0;
@@ -1843,11 +1848,12 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[INPUT_PORT];
 	f->type = INPUT_MPLANE;
-	f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_VIDC_NV12C;
+	f->fmt.pix_mp.pixelformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_NV12C, __func__);
 	f->fmt.pix_mp.width = DEFAULT_WIDTH;
 	f->fmt.pix_mp.height = DEFAULT_HEIGHT;
 	f->fmt.pix_mp.num_planes = 1;
-	colorformat = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat,
+	colorformat = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat,
 		__func__);
 	f->fmt.pix_mp.plane_fmt[0].bytesperline =
 		video_y_stride_bytes(colorformat, DEFAULT_WIDTH);
@@ -1869,7 +1875,8 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
 
 	f = &inst->fmts[INPUT_META_PORT];
 	f->type = INPUT_META_PLANE;
-	f->fmt.meta.dataformat = V4L2_META_FMT_VIDC;
+	f->fmt.meta.dataformat =
+		v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
 	f->fmt.meta.buffersize = MSM_VIDC_METADATA_SIZE;
 	inst->buffers.input_meta.min_count = 0;
 	inst->buffers.input_meta.extra_count = 0;

+ 11 - 6
driver/vidc/src/msm_vidc.c

@@ -287,7 +287,7 @@ int msm_vidc_g_fmt(void *instance, struct v4l2_format *f)
 	if (f->type == INPUT_MPLANE || f->type == OUTPUT_MPLANE)
 		i_vpr_h(inst, "%s: type %s format %s width %d height %d size %d\n",
 			__func__, v4l2_type_name(f->type),
-			v4l2_pixelfmt_name(f->fmt.pix_mp.pixelformat),
+			v4l2_pixelfmt_name(inst, f->fmt.pix_mp.pixelformat),
 			f->fmt.pix_mp.width, f->fmt.pix_mp.height,
 			f->fmt.pix_mp.plane_fmt[0].sizeimage);
 	else if (f->type == INPUT_META_PLANE || f->type == OUTPUT_META_PLANE)
@@ -684,6 +684,7 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize)
 	struct msm_vidc_inst_capability *capability;
 	enum msm_vidc_colorformat_type colorfmt;
 	enum msm_vidc_codec_type codec;
+	u32 meta_fmt;
 
 	if (!inst || !fsize) {
 		d_vpr_e("%s: invalid params: %pK %pK\n",
@@ -700,11 +701,13 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize)
 	if (fsize->index)
 		return -EINVAL;
 
-	if (fsize->pixel_format != V4L2_META_FMT_VIDC) {
+	meta_fmt = v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
+	if (fsize->pixel_format != meta_fmt) {
 		/* validate pixel format */
-		codec = v4l2_codec_to_driver(fsize->pixel_format, __func__);
+		codec = v4l2_codec_to_driver(inst, fsize->pixel_format, __func__);
 		if (!codec) {
-			colorfmt = v4l2_colorformat_to_driver(fsize->pixel_format, __func__);
+			colorfmt = v4l2_colorformat_to_driver(inst, fsize->pixel_format,
+				__func__);
 			if (colorfmt == MSM_VIDC_FMT_NONE) {
 				i_vpr_e(inst, "%s: unsupported pix fmt %#x\n",
 					__func__, fsize->pixel_format);
@@ -734,6 +737,7 @@ int msm_vidc_enum_frameintervals(void *instance, struct v4l2_frmivalenum *fival)
 	struct msm_vidc_inst_capability *capability;
 	enum msm_vidc_colorformat_type colorfmt;
 	u32 fps, mbpf;
+	u32 meta_fmt;
 
 	if (!inst || !fival) {
 		d_vpr_e("%s: invalid params: %pK %pK\n",
@@ -758,9 +762,10 @@ int msm_vidc_enum_frameintervals(void *instance, struct v4l2_frmivalenum *fival)
 	if (fival->index)
 		return -EINVAL;
 
-	if (fival->pixel_format != V4L2_META_FMT_VIDC) {
+	meta_fmt = v4l2_colorformat_from_driver(inst, MSM_VIDC_FMT_META, __func__);
+	if (fival->pixel_format != meta_fmt) {
 		/* validate pixel format */
-		colorfmt = v4l2_colorformat_to_driver(fival->pixel_format, __func__);
+		colorfmt = v4l2_colorformat_to_driver(inst, fival->pixel_format, __func__);
 		if (colorfmt == MSM_VIDC_FMT_NONE) {
 			i_vpr_e(inst, "%s: unsupported pix fmt %#x\n",
 				__func__, fival->pixel_format);

+ 2 - 2
driver/vidc/src/msm_vidc_buffer.c

@@ -275,7 +275,7 @@ u32 msm_vidc_decoder_output_size(struct msm_vidc_inst *inst)
 	enum msm_vidc_colorformat_type colorformat;
 
 	f = &inst->fmts[OUTPUT_PORT];
-	colorformat = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat,
+	colorformat = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat,
 		__func__);
 	size = video_buffer_size(colorformat, f->fmt.pix_mp.width,
 			f->fmt.pix_mp.height, true);
@@ -307,7 +307,7 @@ u32 msm_vidc_encoder_input_size(struct msm_vidc_inst *inst)
 	f = &inst->fmts[INPUT_PORT];
 	width = f->fmt.pix_mp.width;
 	height = f->fmt.pix_mp.height;
-	colorformat = v4l2_colorformat_to_driver(f->fmt.pix_mp.pixelformat,
+	colorformat = v4l2_colorformat_to_driver(inst, f->fmt.pix_mp.pixelformat,
 		__func__);
 	if (is_image_session(inst)) {
 		width = ALIGN(width, HEIC_GRID_DIMENSION);

+ 257 - 350
driver/vidc/src/msm_vidc_driver.c

@@ -398,27 +398,40 @@ const char *v4l2_type_name(u32 port)
 	return "UNKNOWN";
 }
 
-const char *v4l2_pixelfmt_name(u32 pixfmt)
-{
-	switch (pixfmt) {
-	/* raw port: color format */
-	case V4L2_PIX_FMT_NV12:         return "NV12";
-	case V4L2_PIX_FMT_NV21:         return "NV21";
-	case V4L2_PIX_FMT_VIDC_NV12C:   return "NV12C";
-	case V4L2_PIX_FMT_VIDC_P010:    return "P010";
-	case V4L2_PIX_FMT_VIDC_TP10C:   return "TP10C";
-	case V4L2_PIX_FMT_RGBA32:       return "RGBA";
-	case V4L2_PIX_FMT_VIDC_ARGB32C: return "RGBAC";
-	/* bitstream port: codec type */
-	case V4L2_PIX_FMT_H264:         return "AVC";
-	case V4L2_PIX_FMT_HEVC:         return "HEVC";
-	case V4L2_PIX_FMT_HEIC:         return "HEIC";
-	case V4L2_PIX_FMT_VP9:          return "VP9";
-	case V4L2_PIX_FMT_AV1:          return "AV1";
-	/* meta port */
-	case V4L2_META_FMT_VIDC:        return "META";
+const char *v4l2_pixelfmt_name(struct msm_vidc_inst *inst, u32 pixfmt)
+{
+	struct msm_vidc_core *core;
+	const struct codec_info *codec_info;
+	const struct color_format_info *color_format_info;
+	u32 i, size;
+
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		goto exit;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		goto exit;
+	}
+	codec_info = core->platform->data.format_data->codec_info;
+	size = core->platform->data.format_data->codec_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (codec_info[i].v4l2_codec == pixfmt)
+			return codec_info[i].pixfmt_name;
 	}
 
+	color_format_info = core->platform->data.format_data->color_format_info;
+	size = core->platform->data.format_data->color_format_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (color_format_info[i].v4l2_color_format == pixfmt)
+			return color_format_info[i].pixfmt_name;
+	}
+
+exit:
 	return "UNKNOWN";
 }
 
@@ -546,174 +559,156 @@ u32 v4l2_type_from_driver(enum msm_vidc_buffer_type buffer_type,
 	return type;
 }
 
-enum msm_vidc_codec_type v4l2_codec_to_driver(u32 v4l2_codec, const char *func)
+enum msm_vidc_codec_type v4l2_codec_to_driver(struct msm_vidc_inst *inst,
+	u32 v4l2_codec, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct codec_info *codec_info;
+	u32 i, size;
 	enum msm_vidc_codec_type codec = 0;
 
-	switch (v4l2_codec) {
-	case V4L2_PIX_FMT_H264:
-		codec = MSM_VIDC_H264;
-		break;
-	case V4L2_PIX_FMT_HEVC:
-		codec = MSM_VIDC_HEVC;
-		break;
-	case V4L2_PIX_FMT_VP9:
-		codec = MSM_VIDC_VP9;
-		break;
-	case V4L2_PIX_FMT_AV1:
-		codec = MSM_VIDC_AV1;
-		break;
-	case V4L2_PIX_FMT_HEIC:
-		codec = MSM_VIDC_HEIC;
-		break;
-	default:
-		d_vpr_h("%s: invalid v4l2 codec %#x\n", func, v4l2_codec);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
 	}
+	codec_info = core->platform->data.format_data->codec_info;
+	size = core->platform->data.format_data->codec_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (codec_info[i].v4l2_codec == v4l2_codec)
+			return codec_info[i].vidc_codec;
+	}
+
+	d_vpr_h("%s: invalid v4l2 codec %#x\n", func, v4l2_codec);
 	return codec;
 }
 
-u32 v4l2_codec_from_driver(enum msm_vidc_codec_type codec, const char *func)
+u32 v4l2_codec_from_driver(struct msm_vidc_inst *inst,
+	enum msm_vidc_codec_type codec, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct codec_info *codec_info;
+	u32 i, size;
 	u32 v4l2_codec = 0;
 
-	switch (codec) {
-	case MSM_VIDC_H264:
-		v4l2_codec = V4L2_PIX_FMT_H264;
-		break;
-	case MSM_VIDC_HEVC:
-		v4l2_codec = V4L2_PIX_FMT_HEVC;
-		break;
-	case MSM_VIDC_VP9:
-		v4l2_codec = V4L2_PIX_FMT_VP9;
-		break;
-	case MSM_VIDC_AV1:
-		v4l2_codec = V4L2_PIX_FMT_AV1;
-		break;
-	case MSM_VIDC_HEIC:
-		v4l2_codec = V4L2_PIX_FMT_HEIC;
-		break;
-	default:
-		d_vpr_e("%s: invalid driver codec %#x\n", func, codec);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	codec_info = core->platform->data.format_data->codec_info;
+	size = core->platform->data.format_data->codec_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (codec_info[i].vidc_codec == codec)
+			return codec_info[i].v4l2_codec;
 	}
+
+	d_vpr_e("%s: invalid driver codec %#x\n", func, codec);
 	return v4l2_codec;
 }
 
-enum msm_vidc_colorformat_type v4l2_colorformat_to_driver(u32 v4l2_colorformat,
-	const char *func)
+enum msm_vidc_colorformat_type v4l2_colorformat_to_driver(
+	struct msm_vidc_inst *inst,
+	u32 v4l2_colorformat, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct color_format_info *color_format_info;
+	u32 i, size;
 	enum msm_vidc_colorformat_type colorformat = 0;
 
-	switch (v4l2_colorformat) {
-	case V4L2_PIX_FMT_NV12:
-		colorformat = MSM_VIDC_FMT_NV12;
-		break;
-	case V4L2_PIX_FMT_NV21:
-		colorformat = MSM_VIDC_FMT_NV21;
-		break;
-	case V4L2_PIX_FMT_VIDC_NV12C:
-		colorformat = MSM_VIDC_FMT_NV12C;
-		break;
-	case V4L2_PIX_FMT_VIDC_TP10C:
-		colorformat = MSM_VIDC_FMT_TP10C;
-		break;
-	case V4L2_PIX_FMT_RGBA32:
-		colorformat = MSM_VIDC_FMT_RGBA8888;
-		break;
-	case V4L2_PIX_FMT_VIDC_ARGB32C:
-		colorformat = MSM_VIDC_FMT_RGBA8888C;
-		break;
-	case V4L2_PIX_FMT_VIDC_P010:
-		colorformat = MSM_VIDC_FMT_P010;
-		break;
-	default:
-		d_vpr_e("%s: invalid v4l2 color format %#x\n",
-			func, v4l2_colorformat);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
 	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	color_format_info = core->platform->data.format_data->color_format_info;
+	size = core->platform->data.format_data->color_format_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (color_format_info[i].v4l2_color_format == v4l2_colorformat)
+			return color_format_info[i].vidc_color_format;
+	}
+
+	d_vpr_e("%s: invalid v4l2 color format %#x\n", func, v4l2_colorformat);
 	return colorformat;
 }
 
-u32 v4l2_colorformat_from_driver(enum msm_vidc_colorformat_type colorformat,
+u32 v4l2_colorformat_from_driver(struct msm_vidc_inst *inst,
+	enum msm_vidc_colorformat_type colorformat,
 	const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct color_format_info *color_format_info;
+	u32 i, size;
 	u32 v4l2_colorformat = 0;
 
-	switch (colorformat) {
-	case MSM_VIDC_FMT_NV12:
-		v4l2_colorformat = V4L2_PIX_FMT_NV12;
-		break;
-	case MSM_VIDC_FMT_NV21:
-		v4l2_colorformat = V4L2_PIX_FMT_NV21;
-		break;
-	case MSM_VIDC_FMT_NV12C:
-		v4l2_colorformat = V4L2_PIX_FMT_VIDC_NV12C;
-		break;
-	case MSM_VIDC_FMT_TP10C:
-		v4l2_colorformat = V4L2_PIX_FMT_VIDC_TP10C;
-		break;
-	case MSM_VIDC_FMT_RGBA8888:
-		v4l2_colorformat = V4L2_PIX_FMT_RGBA32;
-		break;
-	case MSM_VIDC_FMT_RGBA8888C:
-		v4l2_colorformat = V4L2_PIX_FMT_VIDC_ARGB32C;
-		break;
-	case MSM_VIDC_FMT_P010:
-		v4l2_colorformat = V4L2_PIX_FMT_VIDC_P010;
-		break;
-	default:
-		d_vpr_e("%s: invalid driver color format %#x\n",
-			func, colorformat);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	color_format_info = core->platform->data.format_data->color_format_info;
+	size = core->platform->data.format_data->color_format_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (color_format_info[i].vidc_color_format == colorformat)
+			return color_format_info[i].v4l2_color_format;
 	}
+
+	d_vpr_e("%s: invalid driver color format %#x\n", func, colorformat);
 	return v4l2_colorformat;
 }
 
 u32 v4l2_color_primaries_to_driver(struct msm_vidc_inst *inst,
 	u32 v4l2_primaries, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct color_primaries_info *color_prim_info;
+	u32 i, size;
 	u32 vidc_color_primaries = MSM_VIDC_PRIMARIES_RESERVED;
 
-	switch(v4l2_primaries) {
-	case V4L2_COLORSPACE_DEFAULT:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_RESERVED;
-		break;
-	case V4L2_COLORSPACE_REC709:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_BT709;
-		break;
-	case V4L2_COLORSPACE_470_SYSTEM_M:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_BT470_SYSTEM_M;
-		break;
-	case V4L2_COLORSPACE_470_SYSTEM_BG:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_BT470_SYSTEM_BG;
-		break;
-	case V4L2_COLORSPACE_SMPTE170M:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_BT601_525;
-		break;
-	case V4L2_COLORSPACE_SMPTE240M:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_SMPTE_ST240M;
-		break;
-	case V4L2_COLORSPACE_VIDC_GENERIC_FILM:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_GENERIC_FILM;
-		break;
-	case V4L2_COLORSPACE_BT2020:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_BT2020;
-		break;
-	case V4L2_COLORSPACE_DCI_P3:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_SMPTE_RP431_2;
-		break;
-	case V4L2_COLORSPACE_VIDC_EG431:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_SMPTE_EG431_1;
-		break;
-	case V4L2_COLORSPACE_VIDC_EBU_TECH:
-		vidc_color_primaries = MSM_VIDC_PRIMARIES_SMPTE_EBU_TECH;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid v4l2 color primaries %d\n",
-			func, v4l2_primaries);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
 	}
+	color_prim_info = core->platform->data.format_data->color_prim_info;
+	size = core->platform->data.format_data->color_prim_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (color_prim_info[i].v4l2_color_primaries == v4l2_primaries)
+			return color_prim_info[i].vidc_color_primaries;
+	}
+
+	i_vpr_e(inst, "%s: invalid v4l2 color primaries %d\n",
+		func, v4l2_primaries);
 
 	return vidc_color_primaries;
 }
@@ -721,248 +716,160 @@ u32 v4l2_color_primaries_to_driver(struct msm_vidc_inst *inst,
 u32 v4l2_color_primaries_from_driver(struct msm_vidc_inst *inst,
 	u32 vidc_color_primaries, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct color_primaries_info *color_prim_info;
+	u32 i, size;
 	u32 v4l2_primaries = V4L2_COLORSPACE_DEFAULT;
 
-	switch(vidc_color_primaries) {
-	case MSM_VIDC_PRIMARIES_UNSPECIFIED:
-		v4l2_primaries = V4L2_COLORSPACE_DEFAULT;
-		break;
-	case MSM_VIDC_PRIMARIES_BT709:
-		v4l2_primaries = V4L2_COLORSPACE_REC709;
-		break;
-	case MSM_VIDC_PRIMARIES_BT470_SYSTEM_M:
-		v4l2_primaries = V4L2_COLORSPACE_470_SYSTEM_M;
-		break;
-	case MSM_VIDC_PRIMARIES_BT470_SYSTEM_BG:
-		v4l2_primaries = V4L2_COLORSPACE_470_SYSTEM_BG;
-		break;
-	case MSM_VIDC_PRIMARIES_BT601_525:
-		v4l2_primaries = V4L2_COLORSPACE_SMPTE170M;
-		break;
-	case MSM_VIDC_PRIMARIES_SMPTE_ST240M:
-		v4l2_primaries = V4L2_COLORSPACE_SMPTE240M;
-		break;
-	case MSM_VIDC_PRIMARIES_GENERIC_FILM:
-		v4l2_primaries = V4L2_COLORSPACE_VIDC_GENERIC_FILM;
-		break;
-	case MSM_VIDC_PRIMARIES_BT2020:
-		v4l2_primaries = V4L2_COLORSPACE_BT2020;
-		break;
-	case MSM_VIDC_PRIMARIES_SMPTE_RP431_2:
-		v4l2_primaries = V4L2_COLORSPACE_DCI_P3;
-		break;
-	case MSM_VIDC_PRIMARIES_SMPTE_EG431_1:
-		v4l2_primaries = V4L2_COLORSPACE_VIDC_EG431;
-		break;
-	case MSM_VIDC_PRIMARIES_SMPTE_EBU_TECH:
-		v4l2_primaries = V4L2_COLORSPACE_VIDC_EBU_TECH;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid hfi color primaries %d\n",
-			func, vidc_color_primaries);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	color_prim_info = core->platform->data.format_data->color_prim_info;
+	size = core->platform->data.format_data->color_prim_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (color_prim_info[i].vidc_color_primaries == vidc_color_primaries)
+			return color_prim_info[i].v4l2_color_primaries;
 	}
 
+	i_vpr_e(inst, "%s: invalid hfi color primaries %d\n",
+		func, vidc_color_primaries);
+
 	return v4l2_primaries;
 }
 
 u32 v4l2_transfer_char_to_driver(struct msm_vidc_inst *inst,
 	u32 v4l2_transfer_char, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct transfer_char_info *transfer_char_info;
+	u32 i, size;
 	u32 vidc_transfer_char = MSM_VIDC_TRANSFER_RESERVED;
 
-	switch(v4l2_transfer_char) {
-	case V4L2_XFER_FUNC_DEFAULT:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_RESERVED;
-		break;
-	case V4L2_XFER_FUNC_709:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT709;
-		break;
-	case V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_M:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT470_SYSTEM_M;
-		break;
-	case V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_BG:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT470_SYSTEM_BG;
-		break;
-	case V4L2_XFER_FUNC_VIDC_BT601_525_OR_625:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT601_525_OR_625;
-		break;
-	case V4L2_XFER_FUNC_SMPTE240M:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_SMPTE_ST240M;
-		break;
-	case V4L2_XFER_FUNC_VIDC_LINEAR:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_LINEAR;
-		break;
-	case V4L2_XFER_FUNC_VIDC_XVYCC:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_XVYCC;
-		break;
-	case V4L2_XFER_FUNC_VIDC_BT1361:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT1361_0;
-		break;
-	case V4L2_XFER_FUNC_SRGB:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_SRGB_SYCC;
-		break;
-	case V4L2_XFER_FUNC_VIDC_BT2020:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT2020_14;
-		break;
-	case V4L2_XFER_FUNC_SMPTE2084:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_SMPTE_ST2084_PQ;
-		break;
-	case V4L2_XFER_FUNC_VIDC_ST428:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_SMPTE_ST428_1;
-		break;
-	case V4L2_XFER_FUNC_VIDC_HLG:
-		vidc_transfer_char = MSM_VIDC_TRANSFER_BT2100_2_HLG;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid v4l2 transfer char %d\n",
-			func, v4l2_transfer_char);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	transfer_char_info = core->platform->data.format_data->transfer_char_info;
+	size = core->platform->data.format_data->transfer_char_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (transfer_char_info[i].v4l2_transfer_char == v4l2_transfer_char)
+			return transfer_char_info[i].vidc_transfer_char;
 	}
 
+	i_vpr_e(inst, "%s: invalid v4l2 transfer char %d\n",
+		func, v4l2_transfer_char);
+
 	return vidc_transfer_char;
 }
 
 u32 v4l2_transfer_char_from_driver(struct msm_vidc_inst *inst,
 	u32 vidc_transfer_char, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct transfer_char_info *transfer_char_info;
+	u32 i, size;
 	u32  v4l2_transfer_char = V4L2_XFER_FUNC_DEFAULT;
 
-	switch(vidc_transfer_char) {
-	case MSM_VIDC_TRANSFER_UNSPECIFIED:
-		v4l2_transfer_char = V4L2_XFER_FUNC_DEFAULT;
-		break;
-	case MSM_VIDC_TRANSFER_BT709:
-		v4l2_transfer_char = V4L2_XFER_FUNC_709;
-		break;
-	case MSM_VIDC_TRANSFER_BT470_SYSTEM_M:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_M;
-		break;
-	case MSM_VIDC_TRANSFER_BT470_SYSTEM_BG:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_BT470_SYSTEM_BG;
-		break;
-	case MSM_VIDC_TRANSFER_BT601_525_OR_625:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_BT601_525_OR_625;
-		break;
-	case MSM_VIDC_TRANSFER_SMPTE_ST240M:
-		v4l2_transfer_char = V4L2_XFER_FUNC_SMPTE240M;
-		break;
-	case MSM_VIDC_TRANSFER_LINEAR:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_LINEAR;
-		break;
-	case MSM_VIDC_TRANSFER_XVYCC:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_XVYCC;
-		break;
-	case MSM_VIDC_TRANSFER_BT1361_0:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_BT1361;
-		break;
-	case MSM_VIDC_TRANSFER_SRGB_SYCC:
-		v4l2_transfer_char = V4L2_XFER_FUNC_SRGB;
-		break;
-	case MSM_VIDC_TRANSFER_BT2020_14:
-	case MSM_VIDC_TRANSFER_BT2020_15:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_BT2020;
-		break;
-	case MSM_VIDC_TRANSFER_SMPTE_ST2084_PQ:
-		v4l2_transfer_char = V4L2_XFER_FUNC_SMPTE2084;
-		break;
-	case MSM_VIDC_TRANSFER_SMPTE_ST428_1:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_ST428;
-		break;
-	case MSM_VIDC_TRANSFER_BT2100_2_HLG:
-		v4l2_transfer_char = V4L2_XFER_FUNC_VIDC_HLG;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid hfi transfer char %d\n",
-			func, vidc_transfer_char);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
 	}
 
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	transfer_char_info = core->platform->data.format_data->transfer_char_info;
+	size = core->platform->data.format_data->transfer_char_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (transfer_char_info[i].vidc_transfer_char == vidc_transfer_char)
+			return transfer_char_info[i].v4l2_transfer_char;
+	}
+
+	i_vpr_e(inst, "%s: invalid hfi transfer char %d\n",
+			func, vidc_transfer_char);
+
 	return v4l2_transfer_char;
 }
 
 u32 v4l2_matrix_coeff_to_driver(struct msm_vidc_inst *inst,
 	u32 v4l2_matrix_coeff, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct matrix_coeff_info *matrix_coeff_info;
+	u32 i, size;
 	u32 vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_RESERVED;
 
-	switch(v4l2_matrix_coeff) {
-	case V4L2_YCBCR_ENC_DEFAULT:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_RESERVED;
-		break;
-	case V4L2_YCBCR_VIDC_SRGB_OR_SMPTE_ST428:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_SRGB_SMPTE_ST428_1;
-		break;
-	case V4L2_YCBCR_ENC_709:
-	case V4L2_YCBCR_ENC_XV709:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT709;
-		break;
-	case V4L2_YCBCR_VIDC_FCC47_73_682:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_FCC_TITLE_47;
-		break;
-	case V4L2_YCBCR_ENC_XV601:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT470_SYS_BG_OR_BT601_625;
-		break;
-	case V4L2_YCBCR_ENC_601:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT601_525_BT1358_525_OR_625;
-		break;
-	case V4L2_YCBCR_ENC_SMPTE240M:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_SMPTE_ST240;
-		break;
-	case V4L2_YCBCR_ENC_BT2020:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT2020_NON_CONSTANT;
-		break;
-	case V4L2_YCBCR_ENC_BT2020_CONST_LUM:
-		vidc_matrix_coeff = MSM_VIDC_MATRIX_COEFF_BT2020_CONSTANT;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid v4l2 matrix coeff %d\n",
-			func, v4l2_matrix_coeff);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	matrix_coeff_info = core->platform->data.format_data->matrix_coeff_info;
+	size = core->platform->data.format_data->matrix_coeff_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (matrix_coeff_info[i].v4l2_matrix_coeff == v4l2_matrix_coeff)
+			return matrix_coeff_info[i].vidc_matrix_coeff;
 	}
 
+	i_vpr_e(inst, "%s: invalid v4l2 matrix coeff %d\n",
+		func, v4l2_matrix_coeff);
+
 	return vidc_matrix_coeff;
 }
 
 u32 v4l2_matrix_coeff_from_driver(struct msm_vidc_inst *inst,
 	u32 vidc_matrix_coeff, const char *func)
 {
+	struct msm_vidc_core *core;
+	const struct matrix_coeff_info *matrix_coeff_info;
+	u32 i, size;
 	u32 v4l2_matrix_coeff = V4L2_YCBCR_ENC_DEFAULT;
 
-	switch(vidc_matrix_coeff) {
-	case MSM_VIDC_MATRIX_COEFF_SRGB_SMPTE_ST428_1:
-		v4l2_matrix_coeff = V4L2_YCBCR_VIDC_SRGB_OR_SMPTE_ST428;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_BT709:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_709;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_UNSPECIFIED:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_DEFAULT;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_FCC_TITLE_47:
-		v4l2_matrix_coeff = V4L2_YCBCR_VIDC_FCC47_73_682;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_BT470_SYS_BG_OR_BT601_625:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_XV601;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_BT601_525_BT1358_525_OR_625:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_601;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_SMPTE_ST240:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_SMPTE240M;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_BT2020_NON_CONSTANT:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_BT2020;
-		break;
-	case MSM_VIDC_MATRIX_COEFF_BT2020_CONSTANT:
-		v4l2_matrix_coeff = V4L2_YCBCR_ENC_BT2020_CONST_LUM;
-		break;
-	default:
-		i_vpr_e(inst, "%s: invalid hfi matrix coeff %d\n",
-			func, vidc_matrix_coeff);
-		break;
+	if (!inst || !inst->core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
 	}
 
+	core = inst->core;
+	if (!core->platform || !core->platform->data.format_data) {
+		d_vpr_e("%s: invalid core platform\n", __func__);
+		return -EINVAL;
+	}
+	matrix_coeff_info = core->platform->data.format_data->matrix_coeff_info;
+	size = core->platform->data.format_data->matrix_coeff_info_size;
+
+	for (i = 0; i < size; i++) {
+		if (matrix_coeff_info[i].v4l2_matrix_coeff == v4l2_matrix_coeff)
+			return matrix_coeff_info[i].vidc_matrix_coeff;
+	}
+
+	i_vpr_e(inst, "%s: invalid hfi matrix coeff %d\n",
+		func, vidc_matrix_coeff);
+
 	return v4l2_matrix_coeff;
 }
 

+ 2 - 2
driver/vidc/src/msm_vidc_power.c

@@ -247,7 +247,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 			vote_data->bitrate = (vote_data->bitrate / frame_rate) * operating_rate;
 
 		vote_data->num_formats = 1;
-		vote_data->color_formats[0] = v4l2_colorformat_to_driver(
+		vote_data->color_formats[0] = v4l2_colorformat_to_driver(inst,
 			inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 		vote_data->vpss_preprocessing_enabled =
 			inst->capabilities->cap[REQUEST_PREPROCESS].value;
@@ -256,7 +256,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 
 		vote_data->domain = MSM_VIDC_DECODER;
 		vote_data->bitrate = inst->max_input_data_size * vote_data->fps * 8;
-		color_format = v4l2_colorformat_to_driver(
+		color_format = v4l2_colorformat_to_driver(inst,
 			inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
 		if (is_linear_colorformat(color_format)) {
 			vote_data->num_formats = 2;