Linux Media Controller development
 help / color / mirror / Atom feed
From: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
	Abhinav Kumar <abhinav.kumar@linux.dev>,
	Bryan O'Donoghue <bod@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/9] media: iris: add MPEG2 decode support on Gen1 firmware
Date: Wed, 26 Aug 2026 10:20:43 +0530	[thread overview]
Message-ID: <fc07bf67-2c7e-ec68-c9bc-595bcfb050d5@oss.qualcomm.com> (raw)
In-Reply-To: <20260709-iris-vp8-v1-7-6af3ab578a7c@oss.qualcomm.com>


On 7/10/2026 1:07 AM, Dmitry Baryshkov wrote:
> The Gen1 firmware supports decoding MPEG2, but the iris driver never
> advertised or wired up the codec.
>
> Add the MPEG2 HFI codec code, map V4L2_PIX_FMT_MPEG2 to it in the Gen1
> session open path, and compute the MPEG2 internal buffer sizes (line
> buffer and the quantisation-matrix / QP-dump persist buffer). Advertise
> the codec through the new Gen1 decode format list and register the MPEG2
> profile and level menu controls so userspace can query them.
>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>  drivers/media/platform/qcom/iris/iris_ctrls.c      | 15 ++++++++++++++
>  drivers/media/platform/qcom/iris/iris_hfi_gen1.c   | 24 ++++++++++++++++++++++
>  .../platform/qcom/iris/iris_hfi_gen1_command.c     |  3 +++
>  .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  1 +
>  .../platform/qcom/iris/iris_platform_common.h      |  2 ++
>  drivers/media/platform/qcom/iris/iris_vpu_buffer.c |  9 +++++++-
>  drivers/media/platform/qcom/iris/iris_vpu_buffer.h |  3 +++
>  7 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_ctrls.c b/drivers/media/platform/qcom/iris/iris_ctrls.c
> index 1bd6460a1b0a..8f9347c1df2b 100644
> --- a/drivers/media/platform/qcom/iris/iris_ctrls.c
> +++ b/drivers/media/platform/qcom/iris/iris_ctrls.c
> @@ -30,12 +30,16 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
>  		return PROFILE_VP9;
>  	case V4L2_CID_MPEG_VIDEO_VP8_PROFILE:
>  		return PROFILE_VP8;
> +	case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE:
> +		return PROFILE_MPEG2;
>  	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
>  		return LEVEL_H264;
>  	case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
>  		return LEVEL_HEVC;
>  	case V4L2_CID_MPEG_VIDEO_VP9_LEVEL:
>  		return LEVEL_VP9;
> +	case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL:
> +		return LEVEL_MPEG2;
>  	case V4L2_CID_MPEG_VIDEO_HEVC_TIER:
>  		return TIER;
>  	case V4L2_CID_MPEG_VIDEO_HEADER_MODE:
> @@ -175,12 +179,16 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
>  		return V4L2_CID_MPEG_VIDEO_VP9_PROFILE;
>  	case PROFILE_VP8:
>  		return V4L2_CID_MPEG_VIDEO_VP8_PROFILE;
> +	case PROFILE_MPEG2:
> +		return V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE;
>  	case LEVEL_H264:
>  		return V4L2_CID_MPEG_VIDEO_H264_LEVEL;
>  	case LEVEL_HEVC:
>  		return V4L2_CID_MPEG_VIDEO_HEVC_LEVEL;
>  	case LEVEL_VP9:
>  		return V4L2_CID_MPEG_VIDEO_VP9_LEVEL;
> +	case LEVEL_MPEG2:
> +		return V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL;
>  	case TIER:
>  		return V4L2_CID_MPEG_VIDEO_HEVC_TIER;
>  	case HEADER_MODE:
> @@ -527,6 +535,7 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id
>  		 * content also uses a single stage.
>  		 */
>  		if (inst->is_interlaced ||
> +		    inst->codec == V4L2_PIX_FMT_MPEG2 ||
>  		    iris_res_is_less_than(width, height, 1280, 720))
>  			work_mode = STAGE_1;
>  	}
> @@ -565,6 +574,9 @@ int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_
>  	} else if (inst->codec == V4L2_PIX_FMT_VP8) {
>  		hfi_id = inst->fw_caps[PROFILE_VP8].hfi_id;
>  		hfi_value = inst->fw_caps[PROFILE_VP8].value;
> +	} else if (inst->codec == V4L2_PIX_FMT_MPEG2) {
> +		hfi_id = inst->fw_caps[PROFILE_MPEG2].hfi_id;
> +		hfi_value = inst->fw_caps[PROFILE_MPEG2].value;
>  	} else {
>  		hfi_id = inst->fw_caps[PROFILE_HEVC].hfi_id;
>  		hfi_value = inst->fw_caps[PROFILE_HEVC].value;
> @@ -585,6 +597,9 @@ int iris_set_level(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id
>  	if (inst->codec == V4L2_PIX_FMT_H264) {
>  		hfi_id = inst->fw_caps[LEVEL_H264].hfi_id;
>  		hfi_value = inst->fw_caps[LEVEL_H264].value;
> +	} else if (inst->codec == V4L2_PIX_FMT_MPEG2) {
> +		hfi_id = inst->fw_caps[LEVEL_MPEG2].hfi_id;
> +		hfi_value = inst->fw_caps[LEVEL_MPEG2].value;
>  	} else {
>  		hfi_id = inst->fw_caps[LEVEL_HEVC].hfi_id;
>  		hfi_value = inst->fw_caps[LEVEL_HEVC].value;
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> index 4c3aa5a03ddd..4b05c2a47b0b 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1.c
> @@ -41,6 +41,29 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_dec[] = {
>  		.value = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
>  		.flags = CAP_FLAG_MENU,
>  	},
> +	{
> +		.cap_id = PROFILE_MPEG2,
> +		.min = V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE,
> +		.max = V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH,
> +		.step_or_mask = BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SNR_SCALABLE) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SPATIALLY_SCALABLE) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH),
> +		.value = V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN,
> +		.flags = CAP_FLAG_MENU,
> +	},
> +	{
> +		.cap_id = LEVEL_MPEG2,
> +		.min = V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW,
> +		.max = V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH,
> +		.step_or_mask = BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440) |
> +				BIT(V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH),
> +		.value = V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN,
> +		.flags = CAP_FLAG_MENU,
> +	},
>  };
>  
>  static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
> @@ -435,6 +458,7 @@ static const u32 iris_hfi_gen1_dec_fmts[] = {
>  	V4L2_PIX_FMT_HEVC,
>  	V4L2_PIX_FMT_VP9,
>  	V4L2_PIX_FMT_VP8,
> +	V4L2_PIX_FMT_MPEG2,
>  };
>  
>  static const u32 iris_hfi_gen1_ar50lt_dec_fmts[] = {
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> index 90645ed3e0d8..53ba48f88410 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> @@ -111,6 +111,9 @@ static int iris_hfi_gen1_session_open(struct iris_inst *inst)
>  	case V4L2_PIX_FMT_VP9:
>  		codec = HFI_VIDEO_CODEC_VP9;
>  		break;
> +	case V4L2_PIX_FMT_MPEG2:
> +		codec = HFI_VIDEO_CODEC_MPEG2;
> +		break;
>  	}
>  
>  	packet.shdr.hdr.size = sizeof(struct hfi_session_open_pkt);
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> index 13c8ff59d6e4..3c8ae1c82540 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h
> @@ -14,6 +14,7 @@
>  #define HFI_SESSION_TYPE_DEC				2
>  
>  #define HFI_VIDEO_CODEC_H264				0x00000002
> +#define HFI_VIDEO_CODEC_MPEG2				0x00000010
>  #define HFI_VIDEO_CODEC_VP8				0x00001000
>  #define HFI_VIDEO_CODEC_HEVC				0x00002000
>  #define HFI_VIDEO_CODEC_VP9				0x00004000
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index 84017b66e98f..3d631effe307 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -116,9 +116,11 @@ enum platform_inst_fw_cap_type {
>  	PROFILE_HEVC,
>  	PROFILE_VP9,
>  	PROFILE_VP8,
> +	PROFILE_MPEG2,
>  	LEVEL_H264,
>  	LEVEL_HEVC,
>  	LEVEL_VP9,
> +	LEVEL_MPEG2,
>  	PROFILE_AV1,
>  	LEVEL_AV1,
>  	TIER_AV1,
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> index ca90414e6c19..c16e2b652cf4 100644
> --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.c
> @@ -298,6 +298,11 @@ static u32 hfi_buffer_persist_vp8d(void)
>  	return ALIGN(VP8_NUM_PROBABILITY_TABLE_BUF * VP8_PROB_TABLE_SIZE, DMA_ALIGNMENT);
>  }
>  
> +static u32 hfi_buffer_persist_mpeg2d(void)
> +{
> +	return QMATRIX_SIZE + MP2D_QPDUMP_SIZE;
> +}
> +
>  static u32 hfi_buffer_persist_vp9d_ar50lt(void)
>  {
>  	return ALIGN(VP9_NUM_PROBABILITY_TABLE_BUF * VP9_PROB_TABLE_SIZE, DMA_ALIGNMENT) +
> @@ -1083,6 +1088,8 @@ static u32 iris_vpu_dec_persist_size(struct iris_inst *inst)
>  		return hfi_buffer_persist_vp9d();
>  	else if (inst->codec == V4L2_PIX_FMT_VP8)
>  		return hfi_buffer_persist_vp8d();
> +	else if (inst->codec == V4L2_PIX_FMT_MPEG2)
> +		return hfi_buffer_persist_mpeg2d();
>  	else if (inst->codec == V4L2_PIX_FMT_AV1) {
>  		caps = inst->core->iris_platform_data->inst_caps;
>  		if (inst->fw_caps[DRAP].value)
> @@ -1163,7 +1170,7 @@ static u32 iris_vpu_dec_line_size(struct iris_inst *inst)
>  	else if (inst->codec == V4L2_PIX_FMT_VP9)
>  		return hfi_buffer_line_vp9d(width, height, out_min_count, is_opb,
>  			num_vpp_pipes);
> -	else if (inst->codec == V4L2_PIX_FMT_VP8)
> +	else if (inst->codec == V4L2_PIX_FMT_VP8 || inst->codec == V4L2_PIX_FMT_MPEG2)
>  		return hfi_buffer_line_vp8d(width, height, is_opb, num_vpp_pipes);
>  	else if (inst->codec == V4L2_PIX_FMT_AV1)
>  		return hfi_buffer_line_av1d(width, height, is_opb, num_vpp_pipes);
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
> index 684b459c0cad..4694467677f6 100644
> --- a/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
> +++ b/drivers/media/platform/qcom/iris/iris_vpu_buffer.h
> @@ -69,6 +69,9 @@ struct iris_inst;
>  #define VP8_NUM_PROBABILITY_TABLE_BUF (5 + 1)
>  #define VP8_PROB_TABLE_SIZE (3840)
>  
> +#define QMATRIX_SIZE (sizeof(u32) * 128 + 256)
> +#define MP2D_QPDUMP_SIZE (115200)
> +
>  #define SIZE_SEI_USERDATA			4096
>  #define SIZE_DOLBY_RPU_METADATA (41 * 1024)
>  #define H264_CABAC_HDR_RATIO_HD_TOT	1

Reviewed-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>


  reply	other threads:[~2026-08-26  4:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 19:36 [PATCH 0/9] media: iris: enable VP8, MPEG2 and interlaced video support Dmitry Baryshkov
2026-07-09 19:36 ` [PATCH 1/9] media: iris: translate Gen1 profile/level to HFI enumerants Dmitry Baryshkov
2026-08-05 16:11   ` Vishnu Reddy
2026-07-09 19:36 ` [PATCH 2/9] media: iris: account for UBWC extradata in the QC08C buffer size Dmitry Baryshkov
2026-08-05 15:58   ` Vishnu Reddy
2026-07-09 19:37 ` [PATCH 3/9] media: iris: add support for interlaced decoded content Dmitry Baryshkov
2026-07-09 19:37 ` [PATCH 4/9] media: iris: split Gen2 firmware data for vpu2-generation SoCs Dmitry Baryshkov
2026-08-05 17:08   ` Vishnu Reddy
2026-07-09 19:37 ` [PATCH 5/9] media: iris: move the decode format list into the firmware data Dmitry Baryshkov
2026-08-26  4:09   ` Vishnu Reddy
2026-07-09 19:37 ` [PATCH 6/9] media: iris: add VP8 decode support on Gen1 firmware Dmitry Baryshkov
2026-08-26  4:18   ` Vishnu Reddy
2026-07-09 19:37 ` [PATCH 7/9] media: iris: add MPEG2 " Dmitry Baryshkov
2026-08-26  4:50   ` Vishnu Reddy [this message]
2026-07-09 19:37 ` [PATCH 8/9] media: iris: move the encode format list into the firmware data Dmitry Baryshkov
2026-07-09 19:37 ` [PATCH 9/9] media: iris: add VP8 encode support on Gen1 firmware Dmitry Baryshkov
2026-07-30 22:52 ` [PATCH 0/9] media: iris: enable VP8, MPEG2 and interlaced video support Dmitry Baryshkov
2026-07-31  7:37   ` Vikash Garodia
2026-07-31 12:25     ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fc07bf67-2c7e-ec68-c9bc-595bcfb050d5@oss.qualcomm.com \
    --to=busanna.reddy@oss.qualcomm.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=bod@kernel.org \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=vikash.garodia@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox