Skip to contentSkip to conversation

media: iris: enable VP8, MPEG1/MPEG2 and interlaced MPEG2 support

PATCH New Dmitry Baryshkov 1 participant 14 messages Dec 4

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover media: iris: enable VP8, MPEG1/MPEG2 and interlaced MPEG2 support

Bring back features supported by the Venus driver, but not supported by the Iris driver: VP8 (encoding, decoding), MPEG1 and MPEG2 (decoding only) video support and also support for interlaced MPEG2 streams.

Interlaced H.264 is deliberately left out. Streams that mix frame and field coding (MBAFF and PAFF, e.g. the CAMA*, CVMA*, CVPA*, CAPA* and HCAFF/HPCAFL conformance vectors) make the firmware fail fatally in its H.264 hardware interface (vfw_h264_hw_if.c) on both SM8250 and SC7280, and the Gen2 firmware fails on them as well. This persists with the reconstruction buffers sized as downstream does (fixed here, it was a real overrun), with every internal buffer doubled, with a single pipe, and with the buffer counts declared as downstream does. Field-only streams decode correctly, but the firmware only reports progressive_only, so the driver cannot tell them apart and keeps rejecting interlaced H.264 for now. Venus has the same vectors on its skip lists.

On the SM8250 (RB5):

debian@debian:~$ v4l2-compliance -d /dev/video0
v4l2-compliance 1.30.1, 64 bits, 64-bit time_t

Compliance test for iris_driver device /dev/video0:

Driver Info:

	Driver name      : iris_driver
	Card type        : Iris Decoder
	Bus info         : platform:aa00000.video-codec:de
	Driver version   : 7.4.0
	Capabilities     : 0x84204000

Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected Stateful Decoder

Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/video0 open: OK test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
fail: v4l2-compliance.cpp(771): !ok
test for unlimited opens: FAIL

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 6 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK

Total for iris_driver device /dev/video0: 48, Succeeded: 47, Failed: 1, Warnings: 0

debian@debian:~$ v4l2-compliance -d /dev/video1
v4l2-compliance 1.30.1, 64 bits, 64-bit time_t

Compliance test for iris_driver device /dev/video1:

Driver Info:

	Driver name      : iris_driver
	Card type        : Iris Encoder
	Bus info         : platform:aa00000.video-codec:en
	Driver version   : 7.4.0
	Capabilities     : 0x84204000

Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected Stateful Encoder

Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK

Allow for multiple opens:
test second /dev/video1 open: OK test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
fail: v4l2-compliance.cpp(771): !ok
test for unlimited opens: FAIL

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 35 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK

Total for iris_driver device /dev/video1: 48, Succeeded: 47, Failed: 1, Warnings: 0

The "unlimited opens" failure comes from commit 397ebadcbc21 ("media:
iris: reject open() when the session limit is reached") in linux-next and is not related to this series.

|Test|FFmpeg-VP8-v4l2m2m|GStreamer-VP8-V4L2|
|-|-|-|
|PASSED|53/61|57/61|
|FAILED\ERROR|8/61|4/61|
|TOTAL TIME|11.220s|8.579s|

Failing with both GStreamer and FFmpeg:
- vp80-01-intra-1411
- vp80-02-inter-1412
- vp80-03-segmentation-1413
- vp80-05-sharpness-1443

Failing only with FFmpeg:
- vp80-00-comprehensive-018
- vp80-03-segmentation-1425
- vp80-03-segmentation-1436 (intermittent, fails the same way with v1)
- vp80-05-sharpness-1439

|Test|FFmpeg-MPEG2_VIDEO-v4l2m2m|GStreamer-MPEG2_VIDEO-V4L2|
|-|-|-|
|PASSED|35/43|30/43|
|FAILED\ERROR|8/43|13/43|
|TOTAL TIME|69.772s|60.073s|

Failing with both GStreamer and FFmpeg:
- att, ccm1: frame size below the 128x128 minimum
- tcela-18: D-pictures only, not supported by the hardware
- sony-ct1, teracom_vlc4, ntr_skipped_v3: small mismatches against the reference decoder

Failing with GStreamer only:
- MEI, MEI.stream16, tcela-16, tcela-19: MPEG-1 streams, v4l2videodec puts MPEG-2 profile/level fields into the MPEG-1 caps (fix to be sent to GStreamer)
- sony-ct2, sony-ct3, sony-ct4: the parser reports the display size from the sequence display extension, which is below the 128x128 minimum

Failing with FFmpeg only:
- test
- tcela-6: timed out in this run, passes on reruns

4:2:2 streams (MPEG2_VIDEO-422) are not supported by the hardware.

Test results for Kodiak (RB3 Gen2) mostly follow results on SM8250.

---
Changes in v2:
- Rebased on next-20261123, dropped the merged AR50LT prerequisite.
- New fix: apply the capture buffer minimum in queue_setup instead of
racing with REQBUFS (made FFmpeg fail on small VP8 streams).
- Gave the new Milos firmware data its decode and encode format lists.
- Mapped HFI_H264_LEVEL_52 to V4L2 level 5.2 (Vishnu).
- Replaced the QC08C extradata padding with the two-field layout used downstream, which is what interlaced content actually needs (this supersedes the extradata naming comment, Vishnu).
- Limited interlaced support to MPEG2 and moved it after the MPEG2 patch, see above for H.264.
- Picked up Reviewed-by tags.
- Accept MPEG1 streams through the MPEG2 codec (dropped the MPEG2 R-b, the patch changed).
- New patch adding read-only controls; the VP8 and MPEG2 decoder profile/level controls are now read-only, report the stream's values and only list what the hardware decodes.
- Link to v1: https://patch.msgid.link/[email protected]

---
Dmitry Baryshkov (13):
media: iris: apply the capture buffer minimum in queue_setup
media: iris: translate Gen1 profile/level to HFI enumerants
media: iris: default the Gen1 encoder level to a usable value
media: iris: size QC08C buffers to fit field-coded pictures
media: iris: split Gen2 firmware data for vpu2-generation SoCs
media: iris: move the decode format list into the firmware data
media: iris: support read-only controls
media: iris: add VP8 decode support on Gen1 firmware
media: iris: add MPEG1 and MPEG2 decode support on Gen1 firmware
media: iris: support interlaced MPEG2 content
media: iris: move the encode format list into the firmware data
media: iris: accept gen1 encoder output at a non-zero offset
media: iris: add VP8 encode support on Gen1 firmware

 drivers/media/platform/qcom/iris/iris_buffer.c     |  56 ++--
 drivers/media/platform/qcom/iris/iris_ctrls.c      |  32 ++-
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c   |  88 ++++++-
 .../platform/qcom/iris/iris_hfi_gen1_command.c     | 128 +++++++++-
 .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  64 +++++
 .../platform/qcom/iris/iris_hfi_gen1_response.c    |  83 +++++-
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c   | 284 +++++++++++++++++++++
 .../platform/qcom/iris/iris_hfi_gen2_response.c    |   3 -
 drivers/media/platform/qcom/iris/iris_instance.h   |   2 +
 .../platform/qcom/iris/iris_platform_common.h      |  19 +-
 .../media/platform/qcom/iris/iris_platform_vpu2.c  |  14 +-
 .../media/platform/qcom/iris/iris_platform_vpu3x.c |  17 --
 .../platform/qcom/iris/iris_platform_vpu_ar50lt.c  |   8 -
 drivers/media/platform/qcom/iris/iris_vb2.c        |   6 +-
 drivers/media/platform/qcom/iris/iris_vdec.c       |  10 +-
 drivers/media/platform/qcom/iris/iris_venc.c       |  13 +-
 drivers/media/platform/qcom/iris/iris_vpu_buffer.c |  86 +++++++
 drivers/media/platform/qcom/iris/iris_vpu_buffer.h |   6 +
 18 files changed, 821 insertions(+), 98 deletions(-)

---
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
change-id: 20260708-iris-vp8-8130cdae989d

Best regards,

Signature · 2 lines
With best wishes
Dmitry
#1 lore raw

PATCH v2 1/13 media: iris: apply the capture buffer minimum in queue_setup

Decoding a small VP8 stream with FFmpeg fails with -ENOMEM from the first VIDIOC_REQBUFS on the capture queue. The sequence change handler sets min_reqbufs_allocation on the capture queue from the firmware's buffer count, but it runs from the HFI response path without the queue lock. When the event arrives while REQBUFS is in progress, vb2 sizes the request with the old minimum and then checks the allocation against the new, larger one, and fails.

Leave min_reqbufs_allocation alone and raise the requested count to the firmware minimum in queue_setup instead, which runs with the instance lock held, the same lock the sequence change handler holds while it updates that minimum.

Fixes 84e17adae3e3 ("media: iris: add support for dynamic resolution change")
---
 drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c | 3 ---
 drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c | 3 ---
 drivers/media/platform/qcom/iris/iris_vb2.c               | 4 ++++
 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +0 -3
index ffa98139f0eb..a1167ce524ff 100644
@@ -32,7 +32,6 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 	struct hfi_bit_depth *pixel_depth;
 	struct hfi_pic_struct *pic_struct;
 	struct hfi_framesize *frame_sz;
-	struct vb2_queue *dst_q;
 	struct v4l2_ctrl *ctrl;
 	u32 full_range, ptype;
 
@@ -162,8 +161,6 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 	if (ctrl)
 		v4l2_ctrl_s_ctrl(ctrl, inst->buffers[BUF_OUTPUT].min_count);
 
-	dst_q = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
-	dst_q->min_reqbufs_allocation = inst->buffers[BUF_OUTPUT].min_count;
 
 	if (event.bit_depth || !event.pic_struct) {
 		dev_err(core->dev, "unsupported content, bit depth: %x, pic_struct = %x\n",
drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c +0 -3
index f0782c4b1e6e..69d5f0639fae 100644
@@ -532,7 +532,6 @@ static void iris_hfi_gen2_read_input_subcr_params(struct iris_inst *inst)
 	u32 video_signal_type_present_flag;
 	struct iris_core *core = inst->core;
 	u32 full_range, width, height;
-	struct vb2_queue *dst_q;
 	struct v4l2_ctrl *ctrl;
 
 	subsc_params = inst_hfi_gen2->src_subcr_params;
@@ -660,8 +659,6 @@ static void iris_hfi_gen2_read_input_subcr_params(struct iris_inst *inst)
 	if (ctrl)
 		v4l2_ctrl_s_ctrl(ctrl, inst->buffers[BUF_OUTPUT].min_count);
 
-	dst_q = v4l2_m2m_get_dst_vq(inst->m2m_ctx);
-	dst_q->min_reqbufs_allocation = inst->buffers[BUF_OUTPUT].min_count;
 }
 
 static int iris_hfi_gen2_handle_src_change(struct iris_inst *inst,
drivers/media/platform/qcom/iris/iris_vb2.c +4 -0
index 8faf709c26c1..2d5052782975 100644
@@ -145,6 +145,10 @@ int iris_vb2_queue_setup(struct vb2_queue *q,
 			goto unlock;
 	}
 
+	if (inst->domain == DECODER && !V4L2_TYPE_IS_OUTPUT(q->type))
+		*num_buffers = clamp(*num_buffers, inst->buffers[BUF_OUTPUT].min_count,
+				     q->max_num_buffers);
+
 	*num_planes = 1;
 	sizes[0] = f->fmt.pix_mp.plane_fmt[0].sizeimage;
 
Signature · 1 line
2.47.3
#2 lore raw

PATCH v2 2/13 media: iris: translate Gen1 profile/level to HFI enumerants

In reply to Dmitry Baryshkov

The Gen1 firmware expects the profile and level in the HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT property as HFI-specific enumerants (a one-hot bitmask), but the iris driver passed the raw V4L2 profile and level values straight through. Only the V4L2 H264 high profile happened to match its HFI value (both 0x4); every other profile and all levels were programmed with a wrong value.

Translate the V4L2 profile and level to the HFI enumerants per codec before building the property, mirroring the mapping the venus driver performs for the same firmware interface.

Fixes d22037f3fd33 ("media: iris: Set platform capabilities to firmware for encoder video device")
---
 .../platform/qcom/iris/iris_hfi_gen1_command.c     | 109 +++++++++++++++++++--
 .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  44 +++++++++
 2 files changed, 144 insertions(+), 9 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +100 -9
index 47e9147a9b6d..ba0be31efa00 100644
@@ -479,6 +479,105 @@ static int iris_hfi_gen1_session_drain(struct iris_inst *inst, u32 plane)
 	return -EINVAL;
 }
 
+struct iris_hfi_gen1_id_mapping {
+	u32 hfi_id;
+	u32 v4l2_id;
+};
+
+static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_h264_profiles[] = {
+	{ HFI_H264_PROFILE_BASELINE, V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE },
+	{ HFI_H264_PROFILE_MAIN, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN },
+	{ HFI_H264_PROFILE_HIGH, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH },
+	{ HFI_H264_PROFILE_STEREO_HIGH, V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH },
+	{ HFI_H264_PROFILE_MULTIVIEW_HIGH, V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH },
+	{ HFI_H264_PROFILE_CONSTRAINED_BASE, V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE },
+	{ HFI_H264_PROFILE_CONSTRAINED_HIGH, V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH },
+};
+
+static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_h264_levels[] = {
+	{ HFI_H264_LEVEL_1, V4L2_MPEG_VIDEO_H264_LEVEL_1_0 },
+	{ HFI_H264_LEVEL_1b, V4L2_MPEG_VIDEO_H264_LEVEL_1B },
+	{ HFI_H264_LEVEL_11, V4L2_MPEG_VIDEO_H264_LEVEL_1_1 },
+	{ HFI_H264_LEVEL_12, V4L2_MPEG_VIDEO_H264_LEVEL_1_2 },
+	{ HFI_H264_LEVEL_13, V4L2_MPEG_VIDEO_H264_LEVEL_1_3 },
+	{ HFI_H264_LEVEL_2, V4L2_MPEG_VIDEO_H264_LEVEL_2_0 },
+	{ HFI_H264_LEVEL_21, V4L2_MPEG_VIDEO_H264_LEVEL_2_1 },
+	{ HFI_H264_LEVEL_22, V4L2_MPEG_VIDEO_H264_LEVEL_2_2 },
+	{ HFI_H264_LEVEL_3, V4L2_MPEG_VIDEO_H264_LEVEL_3_0 },
+	{ HFI_H264_LEVEL_31, V4L2_MPEG_VIDEO_H264_LEVEL_3_1 },
+	{ HFI_H264_LEVEL_32, V4L2_MPEG_VIDEO_H264_LEVEL_3_2 },
+	{ HFI_H264_LEVEL_4, V4L2_MPEG_VIDEO_H264_LEVEL_4_0 },
+	{ HFI_H264_LEVEL_41, V4L2_MPEG_VIDEO_H264_LEVEL_4_1 },
+	{ HFI_H264_LEVEL_42, V4L2_MPEG_VIDEO_H264_LEVEL_4_2 },
+	{ HFI_H264_LEVEL_5, V4L2_MPEG_VIDEO_H264_LEVEL_5_0 },
+	{ HFI_H264_LEVEL_51, V4L2_MPEG_VIDEO_H264_LEVEL_5_1 },
+	{ HFI_H264_LEVEL_52, V4L2_MPEG_VIDEO_H264_LEVEL_5_2 },
+};
+
+static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_hevc_profiles[] = {
+	{ HFI_HEVC_PROFILE_MAIN, V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN },
+	{ HFI_HEVC_PROFILE_MAIN_STILL_PIC, V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE },
+	{ HFI_HEVC_PROFILE_MAIN10, V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10 },
+};
+
+static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_hevc_levels[] = {
+	{ HFI_HEVC_LEVEL_1, V4L2_MPEG_VIDEO_HEVC_LEVEL_1 },
+	{ HFI_HEVC_LEVEL_2, V4L2_MPEG_VIDEO_HEVC_LEVEL_2 },
+	{ HFI_HEVC_LEVEL_21, V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1 },
+	{ HFI_HEVC_LEVEL_3, V4L2_MPEG_VIDEO_HEVC_LEVEL_3 },
+	{ HFI_HEVC_LEVEL_31, V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1 },
+	{ HFI_HEVC_LEVEL_4, V4L2_MPEG_VIDEO_HEVC_LEVEL_4 },
+	{ HFI_HEVC_LEVEL_41, V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1 },
+	{ HFI_HEVC_LEVEL_5, V4L2_MPEG_VIDEO_HEVC_LEVEL_5 },
+	{ HFI_HEVC_LEVEL_51, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1 },
+	{ HFI_HEVC_LEVEL_52, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2 },
+	{ HFI_HEVC_LEVEL_6, V4L2_MPEG_VIDEO_HEVC_LEVEL_6 },
+	{ HFI_HEVC_LEVEL_61, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1 },
+	{ HFI_HEVC_LEVEL_62, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2 },
+};
+
+static u32 iris_hfi_gen1_find_hfi_id(u32 v4l2_id,
+				     const struct iris_hfi_gen1_id_mapping *array,
+				     unsigned int array_sz)
+{
+	unsigned int i;
+
+	for (i = 0; i < array_sz; i++)
+		if (v4l2_id == array[i].v4l2_id)
+			return array[i].hfi_id;
+
+	return 0;
+}
+
+/*
+ * The Gen1 firmware expects profile and level as HFI enumerants, while the
+ * client provides raw V4L2 values. Translate them per codec, mirroring the
+ * mapping performed by the venus driver for the same firmware interface.
+ */
+static void
+iris_hfi_gen1_profile_level(struct iris_inst *inst, u32 v4l2_pf, u32 v4l2_lvl,
+			    struct hfi_profile_level *pl)
+{
+	switch (inst->codec) {
+	case V4L2_PIX_FMT_H264:
+		pl->profile = iris_hfi_gen1_find_hfi_id(v4l2_pf, iris_hfi_gen1_h264_profiles,
+							ARRAY_SIZE(iris_hfi_gen1_h264_profiles));
+		pl->level = iris_hfi_gen1_find_hfi_id(v4l2_lvl, iris_hfi_gen1_h264_levels,
+						      ARRAY_SIZE(iris_hfi_gen1_h264_levels));
+		break;
+	case V4L2_PIX_FMT_HEVC:
+		pl->profile = iris_hfi_gen1_find_hfi_id(v4l2_pf, iris_hfi_gen1_hevc_profiles,
+							ARRAY_SIZE(iris_hfi_gen1_hevc_profiles));
+		pl->level = iris_hfi_gen1_find_hfi_id(v4l2_lvl, iris_hfi_gen1_hevc_levels,
+						      ARRAY_SIZE(iris_hfi_gen1_hevc_levels));
+		break;
+	default:
+		pl->profile = 0;
+		pl->level = 0;
+		break;
+	}
+}
+
 static int
 iris_hfi_gen1_packet_session_set_property(struct hfi_session_set_property_pkt *packet,
 					  struct iris_inst *inst, u32 ptype, void *pdata)
@@ -582,15 +681,7 @@ iris_hfi_gen1_packet_session_set_property(struct hfi_session_set_property_pkt *p
 	case HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT: {
 		struct hfi_profile_level *in = pdata, *pl = prop_data;
 
-		pl->level = in->level;
-		pl->profile = in->profile;
-		if (pl->profile <= 0)
-			/* Profile not supported, falling back to high */
-			pl->profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
-
-		if (!pl->level)
-			/* Level not supported, falling back to 1 */
-			pl->level = 1;
+		iris_hfi_gen1_profile_level(inst, in->profile, in->level, pl);
 
 		packet->shdr.hdr.size += sizeof(*pl);
 		break;
drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +44 -0

50 lines not on this page · raw message

Signature · 1 line
2.47.3
#3 lore raw

PATCH v2 3/13 media: iris: default the Gen1 encoder level to a usable value

In reply to Dmitry Baryshkov

The Gen1 encoder H.264 and HEVC level controls default to level 1. Now that the level is translated to its HFI value, unless userspace sets the level, every Gen1 stream is encoded as level 1, which only allows tiny frames (176x144 for H.264): a 1280x720 stream claims a level it exceeds many times over, which strict decoders may refuse.

Default the level to the highest one the core is meant for, as the Gen2 platforms do: 5.1 for SM8250-class cores, 4.2 (H.264) and 4.1 (HEVC) for AR50_LITE.

---
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +4 -4
index 1f87cef986ef..c377ae1f84db 100644
@@ -89,7 +89,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2) |
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_0) |
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_1),
-		.value = V4L2_MPEG_VIDEO_H264_LEVEL_1_0,
+		.value = V4L2_MPEG_VIDEO_H264_LEVEL_5_1,
 		.hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT,
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_profile_level_gen1,
@@ -111,7 +111,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6) |
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1) |
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2),
-		.value = V4L2_MPEG_VIDEO_HEVC_LEVEL_1,
+		.value = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1,
 		.hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT,
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_profile_level_gen1,
@@ -512,7 +512,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_gen1_ar50lt_enc[] = {
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) |
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) |
 				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2),
-		.value = V4L2_MPEG_VIDEO_H264_LEVEL_1_0,
+		.value = V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
 		.hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT,
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_profile_level_gen1,
@@ -528,7 +528,7 @@ static const struct platform_inst_fw_cap inst_fw_cap_gen1_ar50lt_enc[] = {
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1) |
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4) |
 				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1),
-		.value = V4L2_MPEG_VIDEO_HEVC_LEVEL_1,
+		.value = V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1,
 		.hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT,
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_profile_level_gen1,
Signature · 1 line
2.47.3
#4 lore raw

PATCH v2 4/13 media: iris: size QC08C buffers to fit field-coded pictures

In reply to Dmitry Baryshkov

Decoding interlaced content faults in the IOMMU: the firmware writes past the end of a reconstruction (DPB) buffer. iris_yuv_buffer_size_qc08c() lays a UBWC NV12 buffer out as one frame, but for field pictures the hardware stores the two fields separately, each with its planes and metadata aligned on its own, which takes more space at most sizes.

Size the buffer as the downstream driver does for both directions: up to 1920x1088, take the larger two-field layout, otherwise one frame.

Fixes cfd71b14b0d6 ("media: iris: Add support for QC08C format for decoder")
---
 drivers/media/platform/qcom/iris/iris_buffer.c | 53 +++++++++++++++++---------
 1 file changed, 34 insertions(+), 19 deletions(-)
drivers/media/platform/qcom/iris/iris_buffer.c +34 -19
index eb8de60c1177..b5588fd8997e 100644
@@ -228,40 +228,55 @@ static u32 iris_yuv_buffer_size_p010(struct iris_inst *inst)
  *
  * Note: All the alignments are hardware requirements.
  */
-static u32 iris_yuv_buffer_size_qc08c(struct iris_inst *inst)
+static u32 iris_yuv_planes_size_qc08c(u32 width, u32 height)
 {
 	u32 y_plane, uv_plane, y_stride, uv_stride;
 	u32 uv_meta_stride, uv_meta_plane;
 	u32 y_meta_stride, y_meta_plane;
-	struct v4l2_format *f = NULL;
+	u32 uv_height = DIV_ROUND_UP(height, 2);
 
-	if (inst->domain == DECODER)
-		f = inst->fmt_dst;
-	else
-		f = inst->fmt_src;
-
-	y_meta_stride = ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.width, META_STRIDE_ALIGNED >> 1),
+	y_meta_stride = ALIGN(DIV_ROUND_UP(width, META_STRIDE_ALIGNED >> 1),
 			      META_STRIDE_ALIGNED);
-	y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.height,
-							  META_SCANLINE_ALIGNED >> 1),
+	y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(height, META_SCANLINE_ALIGNED >> 1),
 					     META_SCANLINE_ALIGNED);
 	y_meta_plane = ALIGN(y_meta_plane, PIXELS_4K);
 
-	y_stride = ALIGN(f->fmt.pix_mp.width, Y_STRIDE_ALIGN);
-	y_plane = ALIGN(y_stride * ALIGN(f->fmt.pix_mp.height, Y_SCANLINE_ALIGN), PIXELS_4K);
+	y_stride = ALIGN(width, Y_STRIDE_ALIGN);
+	y_plane = ALIGN(y_stride * ALIGN(height, Y_SCANLINE_ALIGN), PIXELS_4K);
 
-	uv_meta_stride = ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.width / 2, META_STRIDE_ALIGNED >> 2),
+	uv_meta_stride = ALIGN(DIV_ROUND_UP(width / 2, META_STRIDE_ALIGNED >> 2),
 			       META_STRIDE_ALIGNED);
-	uv_meta_plane = uv_meta_stride * ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.height / 2,
-							    META_SCANLINE_ALIGNED >> 1),
+	uv_meta_plane = uv_meta_stride * ALIGN(DIV_ROUND_UP(uv_height, META_SCANLINE_ALIGNED >> 1),
 					       META_SCANLINE_ALIGNED);
 	uv_meta_plane = ALIGN(uv_meta_plane, PIXELS_4K);
 
-	uv_stride = ALIGN(f->fmt.pix_mp.width, UV_STRIDE_ALIGN);
-	uv_plane = ALIGN(uv_stride * ALIGN(f->fmt.pix_mp.height / 2, UV_SCANLINE_ALIGN_QC08C),
-			 PIXELS_4K);
+	uv_stride = ALIGN(width, UV_STRIDE_ALIGN);
+	uv_plane = ALIGN(uv_stride * ALIGN(uv_height, UV_SCANLINE_ALIGN_QC08C), PIXELS_4K);
 
-	return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane, PIXELS_4K);
+	return y_meta_plane + y_plane + uv_meta_plane + uv_plane;
+}
+
+static u32 iris_yuv_buffer_size_qc08c(struct iris_inst *inst)
+{
+	struct v4l2_format *f;
+	u32 width, height;
+
+	if (inst->domain == DECODER)
+		f = inst->fmt_dst;
+	else
+		f = inst->fmt_src;
+
+	width = f->fmt.pix_mp.width;
+	height = f->fmt.pix_mp.height;
+
+	/*
+	 * Up to 1080p the buffer must also fit two separately aligned fields,
+	 * which is larger than one frame.
+	 */
+	if (width <= 1920 && height <= 1920 && width * height <= 1920 * 1088)
+		return 2 * iris_yuv_planes_size_qc08c(width, DIV_ROUND_UP(height, 2));
+
+	return iris_yuv_planes_size_qc08c(width, height);
 }
 
 /*
Signature · 1 line
2.47.3
#5 lore raw

PATCH v2 5/13 media: iris: split Gen2 firmware data for vpu2-generation SoCs

In reply to Dmitry Baryshkov

The single iris_hfi_gen2_data instance is shared by both vpu3x SoCs (sm8550/sm8650/sm8750/x1p42100), which support AV1, and the vpu2 SoC sc7280, which does not. This is harmless today because the list of advertised decode formats is kept separately in the per-SoC platform data, but it prevents moving those format lists onto the firmware data where they belong: a shared struct cannot describe both an AV1-capable and an AV1-incapable generation.

Add a dedicated iris_hfi_gen2_vpu2_data instance for vpu2-generation SoCs booting Gen2 firmware, using a decode cap table and config parameter lists with all AV1-specific entries dropped, and point sc7280's Gen2 firmware descriptor at it. The vpu3x SoCs keep using iris_hfi_gen2_data unchanged.

No functional change: sc7280 already did not advertise or accept AV1.

---
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c   | 247 +++++++++++++++++++++
 .../platform/qcom/iris/iris_platform_common.h      |   1 +
 .../media/platform/qcom/iris/iris_platform_vpu2.c  |   2 +-
 3 files changed, 249 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +247 -0
index 79bbd06ef8d2..79fb74af6ea6 100644
@@ -1108,6 +1108,189 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_dec[] = {
 	},
 };
 
+static const struct platform_inst_fw_cap inst_fw_cap_vpu2_gen2_dec[] = {
+	{
+		.cap_id = PROFILE_H264,
+		.min = V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE,
+		.max = V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) |
+				BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE) |
+				BIT(V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) |
+				BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH) |
+				BIT(V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH),
+		.value = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
+		.hfi_id = HFI_PROP_PROFILE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = PROFILE_HEVC,
+		.min = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN,
+		.max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10),
+		.value = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN,
+		.hfi_id = HFI_PROP_PROFILE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = PROFILE_VP9,
+		.min = V4L2_MPEG_VIDEO_VP9_PROFILE_0,
+		.max = V4L2_MPEG_VIDEO_VP9_PROFILE_2,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_VP9_PROFILE_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_PROFILE_2),
+		.value = V4L2_MPEG_VIDEO_VP9_PROFILE_0,
+		.hfi_id = HFI_PROP_PROFILE,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = LEVEL_H264,
+		.min = V4L2_MPEG_VIDEO_H264_LEVEL_1_0,
+		.max = V4L2_MPEG_VIDEO_H264_LEVEL_6_2,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1B) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_2) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_1_3) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_2_2) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_3_2) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_4_2) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_5_2) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_6_0) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_6_1) |
+				BIT(V4L2_MPEG_VIDEO_H264_LEVEL_6_2),
+		.value = V4L2_MPEG_VIDEO_H264_LEVEL_6_1,
+		.hfi_id = HFI_PROP_LEVEL,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = LEVEL_HEVC,
+		.min = V4L2_MPEG_VIDEO_HEVC_LEVEL_1,
+		.max = V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2),
+		.value = V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1,
+		.hfi_id = HFI_PROP_LEVEL,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = LEVEL_VP9,
+		.min = V4L2_MPEG_VIDEO_VP9_LEVEL_1_0,
+		.max = V4L2_MPEG_VIDEO_VP9_LEVEL_6_0,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_1_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_1_1) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_2_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_2_1) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_3_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_3_1) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_4_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_4_1) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_5_0) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_5_1) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_5_2) |
+				BIT(V4L2_MPEG_VIDEO_VP9_LEVEL_6_0),
+		.value = V4L2_MPEG_VIDEO_VP9_LEVEL_6_0,
+		.hfi_id = HFI_PROP_LEVEL,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = TIER,
+		.min = V4L2_MPEG_VIDEO_HEVC_TIER_MAIN,
+		.max = V4L2_MPEG_VIDEO_HEVC_TIER_HIGH,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_HEVC_TIER_MAIN) |
+				BIT(V4L2_MPEG_VIDEO_HEVC_TIER_HIGH),
+		.value = V4L2_MPEG_VIDEO_HEVC_TIER_HIGH,
+		.hfi_id = HFI_PROP_TIER,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_u32_enum,
+	},
+	{
+		.cap_id = INPUT_BUF_HOST_MAX_COUNT,
+		.min = DEFAULT_MAX_HOST_BUF_COUNT,
+		.max = DEFAULT_MAX_HOST_BURST_BUF_COUNT,
+		.step_or_mask = 1,
+		.value = DEFAULT_MAX_HOST_BUF_COUNT,
+		.hfi_id = HFI_PROP_BUFFER_HOST_MAX_COUNT,
+		.flags = CAP_FLAG_INPUT_PORT,
+		.set = iris_set_u32,
+	},
+	{
+		.cap_id = STAGE,
+		.min = STAGE_1,
+		.max = STAGE_2,
+		.step_or_mask = 1,
+		.value = STAGE_2,
+		.hfi_id = HFI_PROP_STAGE,
+		.set = iris_set_stage,
+	},
+	{
+		.cap_id = PIPE,
+		/* .max, .min and .value are set via platform data */
+		.step_or_mask = 1,
+		.hfi_id = HFI_PROP_PIPE,
+		.set = iris_set_pipe,
+	},
+	{
+		.cap_id = POC,
+		.min = 0,
+		.max = 2,
+		.step_or_mask = 1,
+		.value = 1,
+		.hfi_id = HFI_PROP_PIC_ORDER_CNT_TYPE,
+	},
+	{
+		.cap_id = CODED_FRAMES,
+		.min = CODED_FRAMES_PROGRESSIVE,
+		.max = CODED_FRAMES_PROGRESSIVE,
+		.step_or_mask = 0,
+		.value = CODED_FRAMES_PROGRESSIVE,
+		.hfi_id = HFI_PROP_CODED_FRAMES,
+	},
+	{
+		.cap_id = BIT_DEPTH,
+		.min = BIT_DEPTH_8,
+		.max = BIT_DEPTH_10,
+		.step_or_mask = 1,
+		.value = BIT_DEPTH_8,
+		.hfi_id = HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
+	},
+	{
+		.cap_id = RAP_FRAME,
+		.min = 0,
+		.max = 1,
+		.step_or_mask = 1,
+		.value = 1,
+		.hfi_id = HFI_PROP_DEC_START_FROM_RAP_FRAME,
+		.flags = CAP_FLAG_INPUT_PORT,
+		.set = iris_set_u32,
+	},
+};
+
 static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
 	{
 		.cap_id = PROFILE_H264,
@@ -2055,6 +2238,70 @@ const struct iris_firmware_data iris_hfi_milos_data = {
 	.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
 };
 
+/*
+ * Firmware data for vpu2-generation SoCs (e.g. sc7280) booting Gen2 firmware.
+ * These do not support AV1, so the decode cap table and the config parameters
+ * omit all AV1-specific entries.
+ */
+const struct iris_firmware_data iris_hfi_gen2_vpu2_data = {
+	.init_hfi_ops = iris_hfi_gen2_sys_ops_init,
+
+	.core_arch = VIDEO_ARCH_LX,
+
+	.inst_fw_caps_dec = inst_fw_cap_vpu2_gen2_dec,
+	.inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_vpu2_gen2_dec),
+	.inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
+	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
+
+	.dec_input_config_params_default =
+		sm8550_vdec_input_config_params_default,
+	.dec_input_config_params_default_size =
+		ARRAY_SIZE(sm8550_vdec_input_config_params_default),
+	.dec_input_config_params_hevc =
+		sm8550_vdec_input_config_param_hevc,
+	.dec_input_config_params_hevc_size =
+		ARRAY_SIZE(sm8550_vdec_input_config_param_hevc),
+	.dec_input_config_params_vp9 =
+		sm8550_vdec_input_config_param_vp9,
+	.dec_input_config_params_vp9_size =
+		ARRAY_SIZE(sm8550_vdec_input_config_param_vp9),
+	.dec_output_config_params =
+		sm8550_vdec_output_config_params,
+	.dec_output_config_params_size =
+		ARRAY_SIZE(sm8550_vdec_output_config_params),
+
+	.enc_input_config_params =
+		sm8550_venc_input_config_params,
+	.enc_input_config_params_size =
+		ARRAY_SIZE(sm8550_venc_input_config_params),
+	.enc_output_config_params =
+		sm8550_venc_output_config_params,
+	.enc_output_config_params_size =
+		ARRAY_SIZE(sm8550_venc_output_config_params),
+
+	.dec_input_prop = sm8550_vdec_subscribe_input_properties,
+	.dec_input_prop_size = ARRAY_SIZE(sm8550_vdec_subscribe_input_properties),
+	.dec_output_prop_avc = sm8550_vdec_subscribe_output_properties_avc,
+	.dec_output_prop_avc_size =
+		ARRAY_SIZE(sm8550_vdec_subscribe_output_properties_avc),
+	.dec_output_prop_hevc = sm8550_vdec_subscribe_output_properties_hevc,
+	.dec_output_prop_hevc_size =
+		ARRAY_SIZE(sm8550_vdec_subscribe_output_properties_hevc),
+	.dec_output_prop_vp9 = sm8550_vdec_subscribe_output_properties_vp9,
+	.dec_output_prop_vp9_size =
+		ARRAY_SIZE(sm8550_vdec_subscribe_output_properties_vp9),
+
+	.dec_ip_int_buf_tbl = sm8550_dec_ip_int_buf_tbl,
+	.dec_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_ip_int_buf_tbl),
+	.dec_op_int_buf_tbl = sm8550_dec_op_int_buf_tbl,
+	.dec_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_dec_op_int_buf_tbl),
+
+	.enc_ip_int_buf_tbl = sm8550_enc_ip_int_buf_tbl,
+	.enc_ip_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_ip_int_buf_tbl),
+	.enc_op_int_buf_tbl = sm8550_enc_op_int_buf_tbl,
+	.enc_op_int_buf_tbl_size = ARRAY_SIZE(sm8550_enc_op_int_buf_tbl),
+};
+
 static const struct platform_inst_fw_cap inst_fw_cap_gen2_ar50lt_dec[] = {
 	{
 		.cap_id = PROFILE_H264,
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
index cddab9a9c375..6318dbaab7e8 100644
@@ -58,6 +58,7 @@ extern const struct iris_firmware_data iris_hfi_gen1_data;
 extern const struct iris_firmware_data iris_hfi_gen1_ar50lt_data;
 extern const struct iris_firmware_data iris_hfi_gen2_data;
 extern const struct iris_firmware_data iris_hfi_milos_data;
+extern const struct iris_firmware_data iris_hfi_gen2_vpu2_data;
 extern const struct iris_firmware_data iris_hfi_gen2_ar50lt_data;
 extern const struct platform_inst_slice_caps iris_vpu2_vpu3x_slice_caps;
 extern const struct platform_inst_slice_caps iris_ar50lt_slice_caps;
drivers/media/platform/qcom/iris/iris_platform_vpu2.c +1 -1
index becbe3776544..923898067540 100644
@@ -32,7 +32,7 @@ static const struct iris_firmware_desc iris_vpu20_p1_gen1_desc = {
 };
 
 static const struct iris_firmware_desc iris_vpu20_p1_gen2_s6_desc = {
-	.firmware_data = &iris_hfi_gen2_data,
+	.firmware_data = &iris_hfi_gen2_vpu2_data,
 	.get_vpu_buffer_size = iris_vpu33_buf_size,
 	.fwname = "qcom/vpu/vpu20_p1_gen2_s6.mbn",
 };
Signature · 1 line
2.47.3
#6 lore raw

PATCH v2 6/13 media: iris: move the decode format list into the firmware data

In reply to Dmitry Baryshkov

The set of supported coded formats depends on the firmware generation:
a single SoC can boot either Gen1 or Gen2 firmware, and some codecs are only supported by one generation. The decode format list was however kept per-SoC in iris_platform_data::inst_iris_fmts, which is too coarse to express this - a per-SoC list cannot describe the two different format sets the same SoC exposes depending on which firmware it booted.

Move the decode format list into struct iris_firmware_data, which is already selected per firmware generation, and drop the per-SoC inst_iris_fmts field. Each firmware data instance now carries the exact set of decode formats its generation supports, so the formats advertised to userspace always match the running firmware.

No functional change: every SoC advertises the same decode formats as before.

---
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c   | 12 +++++++++++
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c   | 24 ++++++++++++++++++++++
 .../platform/qcom/iris/iris_platform_common.h      | 12 +++++++++--
 .../media/platform/qcom/iris/iris_platform_vpu2.c  | 12 -----------
 .../media/platform/qcom/iris/iris_platform_vpu3x.c | 17 ---------------
 .../platform/qcom/iris/iris_platform_vpu_ar50lt.c  |  8 --------
 drivers/media/platform/qcom/iris/iris_vdec.c       |  8 ++++----
 7 files changed, 50 insertions(+), 43 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +12 -0
index c377ae1f84db..4b38af68625e 100644
@@ -421,6 +421,12 @@ static const u32 sm8250_enc_ip_int_buf_tbl[] = {
 	BUF_SCRATCH_2,
 };
 
+static const u32 iris_hfi_gen1_dec_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+	V4L2_PIX_FMT_VP9,
+};
+
 const struct iris_firmware_data iris_hfi_gen1_data = {
 	.init_hfi_ops = &iris_hfi_gen1_sys_ops_init,
 
@@ -429,6 +435,9 @@ const struct iris_firmware_data iris_hfi_gen1_data = {
 	.inst_fw_caps_enc = inst_fw_cap_sm8250_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8250_enc),
 
+	.dec_fmts = iris_hfi_gen1_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_dec_fmts),
+
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
 	.dec_input_config_params_default_size =
@@ -833,6 +842,9 @@ const struct iris_firmware_data iris_hfi_gen1_ar50lt_data = {
 	.inst_fw_caps_enc = inst_fw_cap_gen1_ar50lt_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_gen1_ar50lt_enc),
 
+	.dec_fmts = iris_hfi_gen1_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_dec_fmts),
+
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
 	.dec_input_config_params_default_size =
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +24 -0
index 79fb74af6ea6..539e5352763d 100644
@@ -2113,6 +2113,19 @@ static const u32 sm8550_enc_op_int_buf_tbl[] = {
 	BUF_SCRATCH_2,
 };
 
+static const u32 iris_hfi_gen2_dec_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+	V4L2_PIX_FMT_VP9,
+	V4L2_PIX_FMT_AV1,
+};
+
+static const u32 iris_hfi_gen2_vpu2_dec_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+	V4L2_PIX_FMT_VP9,
+};
+
 const struct iris_firmware_data iris_hfi_gen2_data = {
 	.init_hfi_ops = iris_hfi_gen2_sys_ops_init,
 
@@ -2123,6 +2136,9 @@ const struct iris_firmware_data iris_hfi_gen2_data = {
 	.inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
 
+	.dec_fmts = iris_hfi_gen2_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_dec_fmts),
+
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
 	.dec_input_config_params_default_size =
@@ -2189,6 +2205,9 @@ const struct iris_firmware_data iris_hfi_milos_data = {
 	.inst_fw_caps_enc = inst_fw_cap_milos_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_milos_enc),
 
+	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
+
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
 	.dec_input_config_params_default_size =
@@ -2253,6 +2272,9 @@ const struct iris_firmware_data iris_hfi_gen2_vpu2_data = {
 	.inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
 
+	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
+
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
 	.dec_input_config_params_default_size =
@@ -3141,6 +3163,8 @@ const struct iris_firmware_data iris_hfi_gen2_ar50lt_data = {
 	.inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_gen2_ar50lt_dec),
 	.inst_fw_caps_enc = inst_fw_cap_gen2_ar50lt_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_gen2_ar50lt_enc),
+	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
 	.dec_input_config_params_default_size =
drivers/media/platform/qcom/iris/iris_platform_common.h +10 -2
index 6318dbaab7e8..30cfa3d793b2 100644
@@ -278,6 +278,16 @@ struct iris_firmware_data {
 	const struct platform_inst_fw_cap *inst_fw_caps_enc;
 	u32 inst_fw_caps_enc_size;
 
+	/*
+	 * List of coded formats supported by this firmware generation, used to
+	 * advertise decode (bitstream) formats to userspace. This lives in the
+	 * firmware data because a single SoC can boot either firmware
+	 * generation, and some codecs (e.g. VP8, MPEG2, AV1) are only supported
+	 * by one generation.
+	 */
+	const u32 *dec_fmts;
+	unsigned int dec_fmts_size;
+
 	const u32 *dec_input_config_params_default;
 	unsigned int dec_input_config_params_default_size;
 	const u32 *dec_input_config_params_hevc;
@@ -340,8 +350,6 @@ struct iris_platform_data {
 	const char * const *controller_rst_tbl;
 	unsigned int controller_rst_tbl_size;
 	u64 dma_mask;
-	const u32 *inst_iris_fmts;
-	u32 inst_iris_fmts_size;
 	struct platform_inst_caps *inst_caps;
 	const struct platform_inst_slice_caps *slice_caps;
 	const struct tz_cp_config *tz_cp_config_data;
drivers/media/platform/qcom/iris/iris_platform_vpu2.c +0 -12
index 923898067540..5b3518935aba 100644
@@ -43,12 +43,6 @@ static const struct iris_firmware_desc iris_vpu20_p4_gen1_desc = {
 	.fwname = "qcom/vpu/vpu20_p4.mbn",
 };
 
-static const u32 iris_fmts_vpu2_dec[] = {
-	V4L2_PIX_FMT_H264,
-	V4L2_PIX_FMT_HEVC,
-	V4L2_PIX_FMT_VP9,
-};
-
 static struct platform_inst_caps platform_inst_cap_vpu2 = {
 	.min_frame_width = 128,
 	.max_frame_width = 8192,
@@ -96,8 +90,6 @@ const struct iris_platform_data milos_data = {
 	.clk_rst_tbl = iris_clk_reset_table_vpu2,
 	.clk_rst_tbl_size = ARRAY_SIZE(iris_clk_reset_table_vpu2),
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu2_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu2_dec),
 	.inst_caps = &platform_inst_cap_milos,
 	.tz_cp_config_data = tz_cp_config_vpu2,
 	.tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_vpu2),
@@ -124,8 +116,6 @@ const struct iris_platform_data sc7280_data = {
 	.opp_clk_tbl = sc7280_opp_clk_table,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu2_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu2_dec),
 	.inst_caps = &platform_inst_cap_vpu2,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu2,
@@ -158,8 +148,6 @@ const struct iris_platform_data sm8250_data = {
 	.opp_clk_tbl = sm8250_opp_clk_table,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu2_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu2_dec),
 	.inst_caps = &platform_inst_cap_vpu2,
 	.tz_cp_config_data = tz_cp_config_vpu2,
 	.tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_vpu2),
drivers/media/platform/qcom/iris/iris_platform_vpu3x.c +0 -17
index e963cb116313..b3d66bd5a937 100644
@@ -50,13 +50,6 @@ static const struct iris_firmware_desc iris_vpu35_p4_gen2_desc = {
 	.fwname = "qcom/vpu/vpu35_p4.mbn",
 };
 
-static const u32 iris_fmts_vpu3x_dec[] = {
-	V4L2_PIX_FMT_H264,
-	V4L2_PIX_FMT_HEVC,
-	V4L2_PIX_FMT_VP9,
-	V4L2_PIX_FMT_AV1,
-};
-
 static const struct icc_info iris_icc_info_vpu3x[] = {
 	{ "cpu-cfg",    1000, 1000     },
 	{ "video-mem",  1000, 15000000 },
@@ -109,8 +102,6 @@ const struct iris_platform_data qcs8300_data = {
 	.opp_clk_tbl = iris_opp_clk_table_vpu3x,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu3x_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu3x_dec),
 	.inst_caps = &platform_inst_cap_qcs8300,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu3,
@@ -141,8 +132,6 @@ const struct iris_platform_data sm8550_data = {
 	.opp_clk_tbl = iris_opp_clk_table_vpu3x,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu3x_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu3x_dec),
 	.inst_caps = &platform_inst_cap_sm8550,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu3,
@@ -181,8 +170,6 @@ const struct iris_platform_data sm8650_data = {
 	.opp_clk_tbl = iris_opp_clk_table_vpu3x,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu3x_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu3x_dec),
 	.inst_caps = &platform_inst_cap_sm8550,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu3,
@@ -213,8 +200,6 @@ const struct iris_platform_data sm8750_data = {
 	.opp_clk_tbl = iris_opp_clk_table_vpu3x,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu3x_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu3x_dec),
 	.inst_caps = &platform_inst_cap_sm8550,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu3,
@@ -251,8 +236,6 @@ const struct iris_platform_data x1p42100_data = {
 	.opp_clk_tbl = x1p42100_opp_clk_table,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_vpu3x_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_vpu3x_dec),
 	.inst_caps = &platform_inst_cap_sm8550,
 	.slice_caps = &iris_vpu2_vpu3x_slice_caps,
 	.tz_cp_config_data = tz_cp_config_vpu3,
drivers/media/platform/qcom/iris/iris_platform_vpu_ar50lt.c +0 -8
index 43460b82ae77..59b5460dd3b9 100644
@@ -25,12 +25,6 @@ static const struct iris_firmware_desc iris_vpu_ar50lt_p1_gen2_s6_desc = {
 	.fwname = "qcom/vpu/ar50lt_p1_gen2_s6.mbn",
 };
 
-static const u32 iris_fmts_ar50lt_dec[] = {
-	V4L2_PIX_FMT_H264,
-	V4L2_PIX_FMT_HEVC,
-	V4L2_PIX_FMT_VP9,
-};
-
 static const struct bw_info iris_bw_table_dec_ar50lt[] = {
 	{ ((1920 * 1080) / 256) * 60, 1564000, },
 	{ ((1920 * 1080) / 256) * 30,  791000, },
@@ -100,8 +94,6 @@ const struct iris_platform_data qcm2290_data = {
 	.opp_clk_tbl = iris_opp_clk_table_ar50lt,
 	/* Upper bound of DMA address range */
 	.dma_mask = 0xe0000000 - 1,
-	.inst_iris_fmts = iris_fmts_ar50lt_dec,
-	.inst_iris_fmts_size = ARRAY_SIZE(iris_fmts_ar50lt_dec),
 	.inst_caps = &platform_inst_cap_ar50lt,
 	.slice_caps = &iris_ar50lt_slice_caps,
 	.tz_cp_config_data = tz_cp_config_ar50lt,
drivers/media/platform/qcom/iris/iris_vdec.c +4 -4
index 0dd33ff447bb..737ccad68314 100644
@@ -83,8 +83,8 @@ static bool check_format(struct iris_inst *inst, u32 pixfmt, u32 type)
 
 	switch (type) {
 	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
-		fmt = inst->core->iris_platform_data->inst_iris_fmts;
-		size = inst->core->iris_platform_data->inst_iris_fmts_size;
+		fmt = inst->core->iris_firmware_data->dec_fmts;
+		size = inst->core->iris_firmware_data->dec_fmts_size;
 		break;
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
 		if (ubwc->ubwc_enc_version) {
@@ -118,8 +118,8 @@ static u32 find_format_by_index(struct iris_inst *inst, u32 index, u32 type)
 
 	switch (type) {
 	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
-		fmt = inst->core->iris_platform_data->inst_iris_fmts;
-		size = inst->core->iris_platform_data->inst_iris_fmts_size;
+		fmt = inst->core->iris_firmware_data->dec_fmts;
+		size = inst->core->iris_firmware_data->dec_fmts_size;
 		break;
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
 		if (ubwc->ubwc_enc_version) {
Signature · 1 line
2.47.3
#7 lore raw

PATCH v2 7/13 media: iris: support read-only controls

In reply to Dmitry Baryshkov

Some decoder controls describe the bitstream rather than configure the decoder, for example the profile and level of the stream being decoded. Userspace cannot meaningfully set them, and the driver needs to update them from the parameters reported by the firmware.

Add a CAP_FLAG_READ_ONLY capability flag that marks the V4L2 control read-only. The V4L2 core already rejects writes from userspace to such controls, so the only updates reaching the s_ctrl handler come from the driver itself: store the value without the streaming-state checks that apply to client-set controls, and without marking it as set by the client.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c           | 8 ++++++++
 drivers/media/platform/qcom/iris/iris_platform_common.h | 1 +
 2 files changed, 9 insertions(+)
drivers/media/platform/qcom/iris/iris_ctrls.c +8 -0
index 4f2633bbb49f..f1903e028ea8 100644
@@ -331,6 +331,11 @@ static int iris_op_s_ctrl(struct v4l2_ctrl *ctrl)
 	if (!iris_valid_cap_id(cap_id))
 		return -EINVAL;
 
+	if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) {
+		inst->fw_caps[cap_id].value = ctrl->val;
+		return 0;
+	}
+
 	q = v4l2_m2m_get_src_vq(inst->m2m_ctx);
 	if (vb2_is_streaming(q) &&
 	    (!(inst->fw_caps[cap_id].flags & CAP_FLAG_DYNAMIC_ALLOWED)))
@@ -406,6 +411,9 @@ int iris_ctrls_init(struct iris_inst *inst)
 			goto error;
 		}
 
+		if (cap[idx].flags & CAP_FLAG_READ_ONLY)
+			ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+
 		ctrl_idx++;
 	}
 
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
index 30cfa3d793b2..47bca539d50d 100644
@@ -223,6 +223,7 @@ enum platform_inst_fw_cap_flags {
 	CAP_FLAG_CLIENT_SET		= BIT(4),
 	CAP_FLAG_BITMASK		= BIT(5),
 	CAP_FLAG_VOLATILE		= BIT(6),
+	CAP_FLAG_READ_ONLY		= BIT(7),
 };
 
 struct platform_inst_fw_cap {
Signature · 1 line
2.47.3
#8 lore raw

PATCH v2 8/13 media: iris: add VP8 decode support on Gen1 firmware

In reply to Dmitry Baryshkov

The Gen1 firmware supports decoding VP8, but the iris driver never advertised or wired up the codec.

Add the VP8 HFI codec code, map V4L2_PIX_FMT_VP8 to it in the Gen1 session open path, and compute the VP8 internal buffer sizes (bin, collocated motion vector, line and probability-table persist buffers, which reuse the shared VPX helpers). Advertise the codec through the Gen1 decode format list.

Register the VP8 profile menu control read-only and fill it in from the profile the firmware reports with the sequence change.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c      |  7 +++
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c   | 22 ++++++-
 .../platform/qcom/iris/iris_hfi_gen1_command.c     |  3 +
 .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  6 ++
 .../platform/qcom/iris/iris_hfi_gen1_response.c    | 36 ++++++++++++
 .../platform/qcom/iris/iris_platform_common.h      |  1 +
 drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 67 ++++++++++++++++++++++
 drivers/media/platform/qcom/iris/iris_vpu_buffer.h |  3 +
 8 files changed, 143 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +7 -0
index f1903e028ea8..dd1ecf1d90ca 100644
@@ -29,6 +29,8 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
 		return PROFILE_HEVC;
 	case V4L2_CID_MPEG_VIDEO_VP9_PROFILE:
 		return PROFILE_VP9;
+	case V4L2_CID_MPEG_VIDEO_VP8_PROFILE:
+		return PROFILE_VP8;
 	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
 		return LEVEL_H264;
 	case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
@@ -180,6 +182,8 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
 		return V4L2_CID_MPEG_VIDEO_HEVC_PROFILE;
 	case PROFILE_VP9:
 		return V4L2_CID_MPEG_VIDEO_VP9_PROFILE;
+	case PROFILE_VP8:
+		return V4L2_CID_MPEG_VIDEO_VP8_PROFILE;
 	case LEVEL_H264:
 		return V4L2_CID_MPEG_VIDEO_H264_LEVEL;
 	case LEVEL_HEVC:
@@ -582,6 +586,9 @@ int iris_set_profile(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_
 	if (inst->codec == V4L2_PIX_FMT_H264) {
 		hfi_id = inst->fw_caps[PROFILE_H264].hfi_id;
 		hfi_value = inst->fw_caps[PROFILE_H264].value;
+	} 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 {
 		hfi_id = inst->fw_caps[PROFILE_HEVC].hfi_id;
 		hfi_value = inst->fw_caps[PROFILE_HEVC].value;
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +20 -2
index 4b38af68625e..178de720246b 100644
@@ -30,6 +30,17 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_dec[] = {
 		.hfi_id = HFI_PROPERTY_PARAM_WORK_MODE,
 		.set = iris_set_stage,
 	},
+	{
+		.cap_id = PROFILE_VP8,
+		.min = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
+		.max = V4L2_MPEG_VIDEO_VP8_PROFILE_3,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_0) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_1) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_2) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_3),
+		.value = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
+		.flags = CAP_FLAG_MENU | CAP_FLAG_READ_ONLY,
+	},
 };
 
 static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
@@ -425,6 +436,13 @@ static const u32 iris_hfi_gen1_dec_fmts[] = {
 	V4L2_PIX_FMT_H264,
 	V4L2_PIX_FMT_HEVC,
 	V4L2_PIX_FMT_VP9,
+	V4L2_PIX_FMT_VP8,
+};
+
+static const u32 iris_hfi_gen1_ar50lt_dec_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+	V4L2_PIX_FMT_VP9,
 };
 
 const struct iris_firmware_data iris_hfi_gen1_data = {
@@ -842,8 +860,8 @@ const struct iris_firmware_data iris_hfi_gen1_ar50lt_data = {
 	.inst_fw_caps_enc = inst_fw_cap_gen1_ar50lt_enc,
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_gen1_ar50lt_enc),
 
-	.dec_fmts = iris_hfi_gen1_dec_fmts,
-	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_dec_fmts),
+	.dec_fmts = iris_hfi_gen1_ar50lt_dec_fmts,
+	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_ar50lt_dec_fmts),
 
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +3 -0
index ba0be31efa00..1f210a9a9a99 100644
@@ -105,6 +105,9 @@ static int iris_hfi_gen1_session_open(struct iris_inst *inst)
 	case V4L2_PIX_FMT_HEVC:
 		codec = HFI_VIDEO_CODEC_HEVC;
 		break;
+	case V4L2_PIX_FMT_VP8:
+		codec = HFI_VIDEO_CODEC_VP8;
+		break;
 	case V4L2_PIX_FMT_VP9:
 		codec = HFI_VIDEO_CODEC_VP9;
 		break;
drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +6 -0
index 699f22cc7255..07d128fe96ee 100644
@@ -14,6 +14,7 @@
 #define HFI_SESSION_TYPE_DEC				2
 
 #define HFI_VIDEO_CODEC_H264				0x00000002
+#define HFI_VIDEO_CODEC_VP8				0x00001000
 #define HFI_VIDEO_CODEC_HEVC				0x00002000
 #define HFI_VIDEO_CODEC_VP9				0x00004000
 
@@ -61,6 +62,11 @@
 #define HFI_HEVC_LEVEL_61				0x00000800
 #define HFI_HEVC_LEVEL_62				0x00001000
 
+#define HFI_VPX_LEVEL_VERSION_0				0x00000001
+#define HFI_VPX_LEVEL_VERSION_1				0x00000002
+#define HFI_VPX_LEVEL_VERSION_2				0x00000004
+#define HFI_VPX_LEVEL_VERSION_3				0x00000008
+
 #define HFI_ERR_NONE					0x0
 
 #define HFI_CMD_SYS_INIT				0x10001
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +36 -0
index a1167ce524ff..88d625589eab 100644
@@ -12,6 +12,41 @@
 #include "iris_vdec.h"
 #include "iris_vpu_buffer.h"
 
+static void iris_hfi_gen1_update_profile_level(struct iris_inst *inst,
+					       u32 hfi_profile, u32 hfi_level)
+{
+	struct v4l2_ctrl *ctrl;
+	u32 profile_id = 0;
+	int profile = -1;
+
+	switch (inst->codec) {
+	case V4L2_PIX_FMT_VP8:
+		/* the firmware reports the VP8 version as the level */
+		profile_id = V4L2_CID_MPEG_VIDEO_VP8_PROFILE;
+		switch (hfi_level) {
+		case HFI_VPX_LEVEL_VERSION_0:
+			profile = V4L2_MPEG_VIDEO_VP8_PROFILE_0;
+			break;
+		case HFI_VPX_LEVEL_VERSION_1:
+			profile = V4L2_MPEG_VIDEO_VP8_PROFILE_1;
+			break;
+		case HFI_VPX_LEVEL_VERSION_2:
+			profile = V4L2_MPEG_VIDEO_VP8_PROFILE_2;
+			break;
+		case HFI_VPX_LEVEL_VERSION_3:
+			profile = V4L2_MPEG_VIDEO_VP8_PROFILE_3;
+			break;
+		}
+		break;
+	default:
+		return;
+	}
+
+	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, profile_id);
+	if (ctrl && profile >= 0)
+		v4l2_ctrl_s_ctrl(ctrl, profile);
+}
+
 static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 					      struct hfi_msg_event_notify_pkt *pkt)
 {
@@ -161,6 +196,7 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 	if (ctrl)
 		v4l2_ctrl_s_ctrl(ctrl, inst->buffers[BUF_OUTPUT].min_count);
 
+	iris_hfi_gen1_update_profile_level(inst, event.profile, event.level);
 
 	if (event.bit_depth || !event.pic_struct) {
 		dev_err(core->dev, "unsupported content, bit depth: %x, pic_struct = %x\n",
drivers/media/platform/qcom/iris/iris_platform_common.h +1 -0
index 47bca539d50d..13f94af2a9d9 100644
@@ -131,6 +131,7 @@ enum platform_inst_fw_cap_type {
 	PROFILE_H264 = 1,
 	PROFILE_HEVC,
 	PROFILE_VP9,
+	PROFILE_VP8,
 	LEVEL_H264,
 	LEVEL_HEVC,
 	LEVEL_VP9,
drivers/media/platform/qcom/iris/iris_vpu_buffer.c +67 -0

103 lines not on this page · raw message

drivers/media/platform/qcom/iris/iris_vpu_buffer.h +3 -0
index 2085e316a6bd..684b459c0cad 100644
@@ -66,6 +66,9 @@ struct iris_inst;
 #define MAX_SE_NBR_CTRL_LCU64_LINE_BUFFER_SIZE_AR50LT (32 / 8)
 #define VP9_UDC_HEADER_BUF_SIZE	(3 * 128)
 
+#define VP8_NUM_PROBABILITY_TABLE_BUF (5 + 1)
+#define VP8_PROB_TABLE_SIZE (3840)
+
 #define SIZE_SEI_USERDATA			4096
 #define SIZE_DOLBY_RPU_METADATA (41 * 1024)
 #define H264_CABAC_HDR_RATIO_HD_TOT	1
Signature · 1 line
2.47.3
#9 lore raw

PATCH v2 9/13 media: iris: add MPEG1 and MPEG2 decode support on Gen1 firmware

In reply to Dmitry Baryshkov

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.

Register the MPEG2 profile and level menu controls read-only, limited to what the hardware decodes (Simple and Main profiles, Low to High levels), and fill them in from the profile and level the firmware reports with the sequence change, as the coda driver does. Nothing is sent to the firmware from them.

Also accept MPEG1 elementary streams. The MPEG2 decoder handles MPEG1 syntax, and the firmware's separate MPEG1 codec produces identical output, so run MPEG1 through the MPEG2 codec. MPEG1 D-pictures are not supported by the hardware.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c      | 13 +++++++-
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c   | 22 +++++++++++++
 .../platform/qcom/iris/iris_hfi_gen1_command.c     |  4 +++
 .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  9 ++++++
 .../platform/qcom/iris/iris_hfi_gen1_response.c    | 37 ++++++++++++++++++++--
 .../platform/qcom/iris/iris_platform_common.h      |  2 ++
 drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 10 +++++-
 drivers/media/platform/qcom/iris/iris_vpu_buffer.h |  3 ++
 8 files changed, 96 insertions(+), 4 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +12 -1
index dd1ecf1d90ca..b8414c6da2d0 100644
@@ -31,12 +31,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:
@@ -184,12 +188,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:
@@ -546,7 +554,10 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id
 	u32 work_mode = STAGE_2;
 
 	if (inst->domain == DECODER) {
-		if (iris_res_is_less_than(width, height, 1280, 720))
+		/* The two-stage pipeline cannot decode MPEG1 or MPEG2 */
+		if (inst->codec == V4L2_PIX_FMT_MPEG1 ||
+		    inst->codec == V4L2_PIX_FMT_MPEG2 ||
+		    iris_res_is_less_than(width, height, 1280, 720))
 			work_mode = STAGE_1;
 	} else if (inst->domain == ENCODER) {
 		if (inst->fw_caps[BITRATE_MODE].value == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +22 -0
index 178de720246b..613ca0497716 100644
@@ -41,6 +41,26 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_dec[] = {
 		.value = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
 		.flags = CAP_FLAG_MENU | CAP_FLAG_READ_ONLY,
 	},
+	{
+		.cap_id = PROFILE_MPEG2,
+		.min = V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE,
+		.max = V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE) |
+				BIT(V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN),
+		.value = V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN,
+		.flags = CAP_FLAG_MENU | CAP_FLAG_READ_ONLY,
+	},
+	{
+		.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 | CAP_FLAG_READ_ONLY,
+	},
 };
 
 static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
@@ -437,6 +457,8 @@ static const u32 iris_hfi_gen1_dec_fmts[] = {
 	V4L2_PIX_FMT_HEVC,
 	V4L2_PIX_FMT_VP9,
 	V4L2_PIX_FMT_VP8,
+	V4L2_PIX_FMT_MPEG1,
+	V4L2_PIX_FMT_MPEG2,
 };
 
 static const u32 iris_hfi_gen1_ar50lt_dec_fmts[] = {
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +4 -0
index 1f210a9a9a99..eebed65e95c7 100644
@@ -111,6 +111,10 @@ 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_MPEG1:
+	case V4L2_PIX_FMT_MPEG2:
+		codec = HFI_VIDEO_CODEC_MPEG2;
+		break;
 	}
 
 	packet.shdr.hdr.size = sizeof(struct hfi_session_open_pkt);
drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +9 -0
index 07d128fe96ee..a834135954d9 100644
@@ -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
@@ -67,6 +68,14 @@
 #define HFI_VPX_LEVEL_VERSION_2				0x00000004
 #define HFI_VPX_LEVEL_VERSION_3				0x00000008
 
+#define HFI_MPEG2_PROFILE_SIMPLE			0x00000001
+#define HFI_MPEG2_PROFILE_MAIN				0x00000002
+
+#define HFI_MPEG2_LEVEL_LL				0x00000001
+#define HFI_MPEG2_LEVEL_ML				0x00000002
+#define HFI_MPEG2_LEVEL_H14				0x00000004
+#define HFI_MPEG2_LEVEL_HL				0x00000008
+
 #define HFI_ERR_NONE					0x0
 
 #define HFI_CMD_SYS_INIT				0x10001
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +35 -2
index 88d625589eab..3195cf0ffda7 100644
@@ -15,9 +15,9 @@
 static void iris_hfi_gen1_update_profile_level(struct iris_inst *inst,
 					       u32 hfi_profile, u32 hfi_level)
 {
+	u32 profile_id = 0, level_id = 0;
+	int profile = -1, level = -1;
 	struct v4l2_ctrl *ctrl;
-	u32 profile_id = 0;
-	int profile = -1;
 
 	switch (inst->codec) {
 	case V4L2_PIX_FMT_VP8:
@@ -38,6 +38,32 @@ static void iris_hfi_gen1_update_profile_level(struct iris_inst *inst,
 			break;
 		}
 		break;
+	case V4L2_PIX_FMT_MPEG2:
+		profile_id = V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE;
+		switch (hfi_profile) {
+		case HFI_MPEG2_PROFILE_SIMPLE:
+			profile = V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE;
+			break;
+		case HFI_MPEG2_PROFILE_MAIN:
+			profile = V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN;
+			break;
+		}
+		level_id = V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL;
+		switch (hfi_level) {
+		case HFI_MPEG2_LEVEL_LL:
+			level = V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW;
+			break;
+		case HFI_MPEG2_LEVEL_ML:
+			level = V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN;
+			break;
+		case HFI_MPEG2_LEVEL_H14:
+			level = V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440;
+			break;
+		case HFI_MPEG2_LEVEL_HL:
+			level = V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH;
+			break;
+		}
+		break;
 	default:
 		return;
 	}
@@ -45,6 +71,13 @@ static void iris_hfi_gen1_update_profile_level(struct iris_inst *inst,
 	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, profile_id);
 	if (ctrl && profile >= 0)
 		v4l2_ctrl_s_ctrl(ctrl, profile);
+
+	if (!level_id)
+		return;
+
+	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, level_id);
+	if (ctrl && level >= 0)
+		v4l2_ctrl_s_ctrl(ctrl, level);
 }
 
 static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
drivers/media/platform/qcom/iris/iris_platform_common.h +2 -0
index 13f94af2a9d9..5709f6dc2996 100644
@@ -132,9 +132,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,
drivers/media/platform/qcom/iris/iris_vpu_buffer.c +9 -1
index 8d5692c82afb..e4add2bd05e2 100644
@@ -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) +
@@ -1079,6 +1084,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_MPEG1 || 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)
@@ -1159,7 +1166,8 @@ 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_MPEG1 ||
+		 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);
drivers/media/platform/qcom/iris/iris_vpu_buffer.h +3 -0
index 684b459c0cad..4694467677f6 100644
@@ -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
Signature · 1 line
2.47.3
#10 lore raw

PATCH v2 10/13 media: iris: support interlaced MPEG2 content

In reply to Dmitry Baryshkov

The Gen1 firmware reports whether a decoded stream is interlaced through the progressive_only field of HFI_PROPERTY_PARAM_VDEC_PIC_STRUCT. The driver treats any interlaced content as unsupported and moves the instance to the error state, so interlaced MPEG2, which is common, cannot be decoded at all.

Accept interlaced MPEG2. Track the interlaced state on the instance, report V4L2_FIELD_INTERLACED on the capture queue, use a single pipeline stage and skip the bin buffer, as the downstream driver does.

Keep rejecting interlaced H.264: streams mixing frame and field coding (MBAFF and PAFF) make the firmware fail fatally on both SM8250 and SC7280, even with all internal buffers sized as downstream does.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c             | 5 +++--
 drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c | 7 ++++++-
 drivers/media/platform/qcom/iris/iris_instance.h          | 2 ++
 drivers/media/platform/qcom/iris/iris_vb2.c               | 2 --
 drivers/media/platform/qcom/iris/iris_vdec.c              | 2 ++
 drivers/media/platform/qcom/iris/iris_vpu_buffer.c        | 7 +++++++
 6 files changed, 20 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +3 -2
index b8414c6da2d0..5efbce4383c9 100644
@@ -554,8 +554,9 @@ int iris_set_stage(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id
 	u32 work_mode = STAGE_2;
 
 	if (inst->domain == DECODER) {
-		/* The two-stage pipeline cannot decode MPEG1 or MPEG2 */
-		if (inst->codec == V4L2_PIX_FMT_MPEG1 ||
+		/* The two-stage pipeline cannot decode interlaced, MPEG1 or MPEG2 content */
+		if (inst->is_interlaced ||
+		    inst->codec == V4L2_PIX_FMT_MPEG1 ||
 		    inst->codec == V4L2_PIX_FMT_MPEG2 ||
 		    iris_res_is_less_than(width, height, 1280, 720))
 			work_mode = STAGE_1;
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +6 -1
index 3195cf0ffda7..8de6d86e7c66 100644
@@ -170,11 +170,15 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 		num_properties_changed--;
 	} while (num_properties_changed > 0);
 
+	/* pic_struct carries progressive_only: 0 means the content is interlaced */
+	inst->is_interlaced = !event.pic_struct;
+
 	pixmp_ip->width = event.width;
 	pixmp_ip->height = event.height;
 
 	pixmp_op->width = ALIGN(event.width, 128);
 	pixmp_op->height = ALIGN(event.height, 32);
+	pixmp_op->field = inst->is_interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE;
 	pixmp_op->plane_fmt[0].bytesperline = ALIGN(event.width, 128);
 	pixmp_op->plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
 
@@ -231,7 +235,8 @@ static void iris_hfi_gen1_read_changed_params(struct iris_inst *inst,
 
 	iris_hfi_gen1_update_profile_level(inst, event.profile, event.level);
 
-	if (event.bit_depth || !event.pic_struct) {
+	if (event.bit_depth ||
+	    (inst->is_interlaced && inst->codec != V4L2_PIX_FMT_MPEG2)) {
 		dev_err(core->dev, "unsupported content, bit depth: %x, pic_struct = %x\n",
 			event.bit_depth, event.pic_struct);
 		iris_inst_change_state(inst, IRIS_INST_ERROR);
drivers/media/platform/qcom/iris/iris_instance.h +2 -0
index 771269e705d9..fe702ebc4409 100644
@@ -56,6 +56,7 @@ struct iris_hfi_session_ops;
  * @metadata_idx: index for metadata buffer
  * @codec: codec type
  * @last_buffer_dequeued: a flag to indicate that last buffer is sent by driver
+ * @is_interlaced: a flag to indicate that decoded content is interlaced
  * @last_buf_ns: start time of received input buffer for current one second FPS window
  * @frame_counter: input buffer counter for current one second FPS window
  * @frame_rate: frame rate of current instance
@@ -104,6 +105,7 @@ struct iris_inst {
 	u32				metadata_idx;
 	u32				codec;
 	bool				last_buffer_dequeued;
+	bool				is_interlaced;
 	u64				last_buf_ns;
 	u32				frame_counter;
 	u32				frame_rate;
drivers/media/platform/qcom/iris/iris_vb2.c +0 -2
index 2d5052782975..6638a899ea31 100644
@@ -268,8 +268,6 @@ int iris_vb2_buf_prepare(struct vb2_buffer *vb)
 	if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
 		if (vbuf->field == V4L2_FIELD_ANY)
 			vbuf->field = V4L2_FIELD_NONE;
-		if (vbuf->field != V4L2_FIELD_NONE)
-			return -EINVAL;
 	}
 
 	if (!(inst->sub_state & IRIS_INST_SUB_DRC)) {
drivers/media/platform/qcom/iris/iris_vdec.c +2 -0
index 737ccad68314..8ef3aa068c0c 100644
@@ -241,6 +241,7 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)
 		fmt = inst->fmt_src;
 		fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 		fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
+		fmt->fmt.pix_mp.field = f->fmt.pix_mp.field;
 		inst->codec = fmt->fmt.pix_mp.pixelformat;
 		codec_align = inst->codec == V4L2_PIX_FMT_HEVC ? 32 : 16;
 		fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, codec_align);
@@ -280,6 +281,7 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)
 		fmt = inst->fmt_dst;
 		fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
 		fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
+		fmt->fmt.pix_mp.field = f->fmt.pix_mp.field;
 		fmt->fmt.pix_mp.num_planes = 1;
 		switch (f->fmt.pix_mp.pixelformat) {
 		case V4L2_PIX_FMT_P010:
drivers/media/platform/qcom/iris/iris_vpu_buffer.c +7 -0
index e4add2bd05e2..e74746d73ea7 100644
@@ -1001,6 +1001,13 @@ static u32 iris_vpu_dec_bin_size(struct iris_inst *inst)
 	u32 height = f->fmt.pix_mp.height;
 	u32 width = f->fmt.pix_mp.width;
 
+	/*
+	 * The bin (scratch) buffer is not used when decoding interlaced
+	 * content.
+	 */
+	if (inst->is_interlaced)
+		return 0;
+
 	if (inst->codec == V4L2_PIX_FMT_H264)
 		return hfi_buffer_bin_h264d(width, height, num_vpp_pipes);
 	else if (inst->codec == V4L2_PIX_FMT_HEVC)
Signature · 1 line
2.47.3
#11 lore raw

PATCH v2 11/13 media: iris: move the encode format list into the firmware data

In reply to Dmitry Baryshkov

Like the decode format list, the set of supported encode formats depends on the firmware generation, but it was kept in the encoder's built-in iris_venc_formats_cap[] array. A single static array cannot describe the different format sets the same SoC exposes depending on which firmware it booted.

Move the encode format list into struct iris_firmware_data next to the decode list, and drop the static iris_venc_formats_cap[] array. Each firmware data instance now carries the exact set of encode formats its generation supports, so the formats advertised to userspace always match the running firmware.

No functional change: every SoC advertises the same encode formats as before.

---
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c        |  9 +++++++++
 drivers/media/platform/qcom/iris/iris_hfi_gen2.c        | 13 +++++++++++++
 drivers/media/platform/qcom/iris/iris_platform_common.h | 12 +++++++-----
 drivers/media/platform/qcom/iris/iris_venc.c            | 13 ++++---------
 4 files changed, 33 insertions(+), 14 deletions(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +9 -0
index 613ca0497716..d3f579f43153 100644
@@ -467,6 +467,11 @@ static const u32 iris_hfi_gen1_ar50lt_dec_fmts[] = {
 	V4L2_PIX_FMT_VP9,
 };
 
+static const u32 iris_hfi_gen1_enc_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+};
+
 const struct iris_firmware_data iris_hfi_gen1_data = {
 	.init_hfi_ops = &iris_hfi_gen1_sys_ops_init,
 
@@ -477,6 +482,8 @@ const struct iris_firmware_data iris_hfi_gen1_data = {
 
 	.dec_fmts = iris_hfi_gen1_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_dec_fmts),
+	.enc_fmts = iris_hfi_gen1_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen1_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
@@ -884,6 +891,8 @@ const struct iris_firmware_data iris_hfi_gen1_ar50lt_data = {
 
 	.dec_fmts = iris_hfi_gen1_ar50lt_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_ar50lt_dec_fmts),
+	.enc_fmts = iris_hfi_gen1_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen1_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
drivers/media/platform/qcom/iris/iris_hfi_gen2.c +13 -0
index 539e5352763d..604f172797a9 100644
@@ -2126,6 +2126,11 @@ static const u32 iris_hfi_gen2_vpu2_dec_fmts[] = {
 	V4L2_PIX_FMT_VP9,
 };
 
+static const u32 iris_hfi_gen2_enc_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
+};
+
 const struct iris_firmware_data iris_hfi_gen2_data = {
 	.init_hfi_ops = iris_hfi_gen2_sys_ops_init,
 
@@ -2138,6 +2143,8 @@ const struct iris_firmware_data iris_hfi_gen2_data = {
 
 	.dec_fmts = iris_hfi_gen2_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_dec_fmts),
+	.enc_fmts = iris_hfi_gen2_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen2_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
@@ -2207,6 +2214,8 @@ const struct iris_firmware_data iris_hfi_milos_data = {
 
 	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
+	.enc_fmts = iris_hfi_gen2_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen2_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
@@ -2274,6 +2283,8 @@ const struct iris_firmware_data iris_hfi_gen2_vpu2_data = {
 
 	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
+	.enc_fmts = iris_hfi_gen2_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen2_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
@@ -3165,6 +3176,8 @@ const struct iris_firmware_data iris_hfi_gen2_ar50lt_data = {
 	.inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_gen2_ar50lt_enc),
 	.dec_fmts = iris_hfi_gen2_vpu2_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen2_vpu2_dec_fmts),
+	.enc_fmts = iris_hfi_gen2_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen2_enc_fmts),
 	.dec_input_config_params_default =
 		sm8550_vdec_input_config_params_default,
 	.dec_input_config_params_default_size =
drivers/media/platform/qcom/iris/iris_platform_common.h +7 -5
index 5709f6dc2996..a949feb6202f 100644
@@ -283,14 +283,16 @@ struct iris_firmware_data {
 	u32 inst_fw_caps_enc_size;
 
 	/*
-	 * List of coded formats supported by this firmware generation, used to
-	 * advertise decode (bitstream) formats to userspace. This lives in the
-	 * firmware data because a single SoC can boot either firmware
-	 * generation, and some codecs (e.g. VP8, MPEG2, AV1) are only supported
-	 * by one generation.
+	 * Lists of coded formats supported by this firmware generation, used
+	 * to advertise decode (bitstream) and encode (capture) formats to
+	 * userspace. These live in the firmware data because a single SoC can
+	 * boot either firmware generation, and some codecs (e.g. VP8, MPEG2,
+	 * AV1) are only supported by one generation.
 	 */
 	const u32 *dec_fmts;
 	unsigned int dec_fmts_size;
+	const u32 *enc_fmts;
+	unsigned int enc_fmts_size;
 
 	const u32 *dec_input_config_params_default;
 	unsigned int dec_input_config_params_default_size;
drivers/media/platform/qcom/iris/iris_venc.c +4 -9
index 2f2c56bf9122..91749e580d5b 100644
@@ -80,11 +80,6 @@ int iris_venc_inst_init(struct iris_inst *inst)
 	return iris_ctrls_init(inst);
 }
 
-static const u32 iris_venc_formats_cap[] = {
-	V4L2_PIX_FMT_H264,
-	V4L2_PIX_FMT_HEVC,
-};
-
 static const u32 iris_venc_formats_out[] = {
 	V4L2_PIX_FMT_NV12,
 	V4L2_PIX_FMT_QC08C,
@@ -111,8 +106,8 @@ static bool check_format(struct iris_inst *inst, u32 pixfmt, u32 type)
 		}
 		break;
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
-		fmt = iris_venc_formats_cap;
-		size = ARRAY_SIZE(iris_venc_formats_cap);
+		fmt = inst->core->iris_firmware_data->enc_fmts;
+		size = inst->core->iris_firmware_data->enc_fmts_size;
 		break;
 	default:
 		return false;
@@ -143,8 +138,8 @@ static u32 find_format_by_index(struct iris_inst *inst, u32 index, u32 type)
 		}
 		break;
 	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
-		fmt = iris_venc_formats_cap;
-		size = ARRAY_SIZE(iris_venc_formats_cap);
+		fmt = inst->core->iris_firmware_data->enc_fmts;
+		size = inst->core->iris_firmware_data->enc_fmts_size;
 		break;
 	default:
 		return 0;
Signature · 1 line
2.47.3
#12 lore raw

PATCH v2 12/13 media: iris: accept gen1 encoder output at a non-zero offset

In reply to Dmitry Baryshkov

FILL_BUFFER_DONE handling looks an encoder output buffer up by its tag and by the offset it was queued with, which is always zero, and reports the payload from the start of the buffer. Firmware that returns the bitstream at a non-zero offset, as the Gen1 firmware does for VP8, has every frame dropped with "error in ftb done", and the leading bytes would be reported as payload even if the buffer were found.

Match encoder output buffers by tag alone and report the offset through the plane's data_offset, with bytesused covering it as V4L2 requires.

---
 drivers/media/platform/qcom/iris/iris_buffer.c            | 3 ++-
 drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_buffer.c +2 -1
index b5588fd8997e..da8f3bd37f76 100644
@@ -920,7 +920,8 @@ int iris_vb2_buffer_done(struct iris_inst *inst, struct iris_buffer *buf)
 	}
 
 	if (V4L2_TYPE_IS_CAPTURE(type)) {
-		vb2_set_plane_payload(vb2, 0, buf->data_size);
+		vb2->planes[0].data_offset = buf->data_offset;
+		vb2_set_plane_payload(vb2, 0, buf->data_offset + buf->data_size);
 		vbuf->sequence = inst->sequence_cap++;
 		iris_get_ts_metadata(inst, buf->timestamp, vbuf);
 	} else {
drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c +2 -2
index 8de6d86e7c66..4d4bd5fa92d0 100644
@@ -533,8 +533,8 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
 			if (!(buf->attr & BUF_ATTR_QUEUED))
 				continue;
 
-			found = (buf->index == output_tag &&
-				 buf->data_offset == offset);
+			found = buf->index == output_tag &&
+				(inst->domain == ENCODER || buf->data_offset == offset);
 
 			if (found)
 				break;
Signature · 1 line
2.47.3
#13 lore raw

PATCH v2 13/13 media: iris: add VP8 encode support on Gen1 firmware

In reply to Dmitry Baryshkov

The Gen1 firmware supports encoding VP8, but the iris driver never advertised or wired up the codec.

Advertise VP8 through the Gen1 encode format list and register the VP8 profile control, sending the profile to the firmware through the profile/level property. VP8 has no level, so only the profile is set.

The VP8 encoder also needs a SCRATCH_1 buffer, sized like the vendor driver does: the H.264 formula with 16x16 macroblocks on a single pipe.

---
 drivers/media/platform/qcom/iris/iris_ctrls.c      |  3 +++
 drivers/media/platform/qcom/iris/iris_hfi_gen1.c   | 23 ++++++++++++++++++++--
 .../platform/qcom/iris/iris_hfi_gen1_command.c     | 12 +++++++++++
 .../platform/qcom/iris/iris_hfi_gen1_defines.h     |  5 +++++
 drivers/media/platform/qcom/iris/iris_vpu_buffer.c |  4 ++++
 5 files changed, 45 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_ctrls.c +3 -0
index 5efbce4383c9..d6a5515e888f 100644
@@ -642,6 +642,9 @@ int iris_set_profile_level_gen1(struct iris_inst *inst, enum platform_inst_fw_ca
 	if (inst->codec == V4L2_PIX_FMT_H264) {
 		pl.profile = inst->fw_caps[PROFILE_H264].value;
 		pl.level = inst->fw_caps[LEVEL_H264].value;
+	} else if (inst->codec == V4L2_PIX_FMT_VP8) {
+		pl.profile = inst->fw_caps[PROFILE_VP8].value;
+		pl.level = 0;
 	} else {
 		pl.profile = inst->fw_caps[PROFILE_HEVC].value;
 		pl.level = inst->fw_caps[LEVEL_HEVC].value;
drivers/media/platform/qcom/iris/iris_hfi_gen1.c +21 -2
index d3f579f43153..5e38f13e72a8 100644
@@ -147,6 +147,19 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
 		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
 		.set = iris_set_profile_level_gen1,
 	},
+	{
+		.cap_id = PROFILE_VP8,
+		.min = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
+		.max = V4L2_MPEG_VIDEO_VP8_PROFILE_3,
+		.step_or_mask = BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_0) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_1) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_2) |
+				BIT(V4L2_MPEG_VIDEO_VP8_PROFILE_3),
+		.value = V4L2_MPEG_VIDEO_VP8_PROFILE_0,
+		.hfi_id = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT,
+		.flags = CAP_FLAG_OUTPUT_PORT | CAP_FLAG_MENU,
+		.set = iris_set_profile_level_gen1,
+	},
 	{
 		.cap_id = HEADER_MODE,
 		.min = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE,
@@ -470,6 +483,12 @@ static const u32 iris_hfi_gen1_ar50lt_dec_fmts[] = {
 static const u32 iris_hfi_gen1_enc_fmts[] = {
 	V4L2_PIX_FMT_H264,
 	V4L2_PIX_FMT_HEVC,
+	V4L2_PIX_FMT_VP8,
+};
+
+static const u32 iris_hfi_gen1_ar50lt_enc_fmts[] = {
+	V4L2_PIX_FMT_H264,
+	V4L2_PIX_FMT_HEVC,
 };
 
 const struct iris_firmware_data iris_hfi_gen1_data = {
@@ -891,8 +910,8 @@ const struct iris_firmware_data iris_hfi_gen1_ar50lt_data = {
 
 	.dec_fmts = iris_hfi_gen1_ar50lt_dec_fmts,
 	.dec_fmts_size = ARRAY_SIZE(iris_hfi_gen1_ar50lt_dec_fmts),
-	.enc_fmts = iris_hfi_gen1_enc_fmts,
-	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen1_enc_fmts),
+	.enc_fmts = iris_hfi_gen1_ar50lt_enc_fmts,
+	.enc_fmts_size = ARRAY_SIZE(iris_hfi_gen1_ar50lt_enc_fmts),
 
 	.dec_input_config_params_default =
 		sm8250_vdec_input_config_param_default,
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +12 -0
index eebed65e95c7..862ce20e2c5d 100644
@@ -543,6 +543,13 @@ static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_hevc_levels[] = {
 	{ HFI_HEVC_LEVEL_62, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2 },
 };
 
+static const struct iris_hfi_gen1_id_mapping iris_hfi_gen1_vp8_profiles[] = {
+	{ HFI_VPX_PROFILE_VERSION_0, V4L2_MPEG_VIDEO_VP8_PROFILE_0 },
+	{ HFI_VPX_PROFILE_VERSION_1, V4L2_MPEG_VIDEO_VP8_PROFILE_1 },
+	{ HFI_VPX_PROFILE_VERSION_2, V4L2_MPEG_VIDEO_VP8_PROFILE_2 },
+	{ HFI_VPX_PROFILE_VERSION_3, V4L2_MPEG_VIDEO_VP8_PROFILE_3 },
+};
+
 static u32 iris_hfi_gen1_find_hfi_id(u32 v4l2_id,
 				     const struct iris_hfi_gen1_id_mapping *array,
 				     unsigned int array_sz)
@@ -578,6 +585,11 @@ iris_hfi_gen1_profile_level(struct iris_inst *inst, u32 v4l2_pf, u32 v4l2_lvl,
 		pl->level = iris_hfi_gen1_find_hfi_id(v4l2_lvl, iris_hfi_gen1_hevc_levels,
 						      ARRAY_SIZE(iris_hfi_gen1_hevc_levels));
 		break;
+	case V4L2_PIX_FMT_VP8:
+		pl->profile = iris_hfi_gen1_find_hfi_id(v4l2_pf, iris_hfi_gen1_vp8_profiles,
+							ARRAY_SIZE(iris_hfi_gen1_vp8_profiles));
+		pl->level = 0;
+		break;
 	default:
 		pl->profile = 0;
 		pl->level = 0;
drivers/media/platform/qcom/iris/iris_hfi_gen1_defines.h +5 -0
index a834135954d9..d4a066d8765d 100644
@@ -68,6 +68,11 @@
 #define HFI_VPX_LEVEL_VERSION_2				0x00000004
 #define HFI_VPX_LEVEL_VERSION_3				0x00000008
 
+#define HFI_VPX_PROFILE_VERSION_0			0x00000004
+#define HFI_VPX_PROFILE_VERSION_1			0x00000008
+#define HFI_VPX_PROFILE_VERSION_2			0x00000010
+#define HFI_VPX_PROFILE_VERSION_3			0x00000020
+
 #define HFI_MPEG2_PROFILE_SIMPLE			0x00000001
 #define HFI_MPEG2_PROFILE_MAIN				0x00000002
 
drivers/media/platform/qcom/iris/iris_vpu_buffer.c +4 -0
index e74746d73ea7..47388036d1b6 100644
@@ -2042,6 +2042,10 @@ static u32 iris_vpu_enc_scratch1_size(struct iris_inst *inst)
 	} else if (inst->codec == V4L2_PIX_FMT_HEVC) {
 		lcu_size = 32;
 		is_h265 = true;
+	} else if (inst->codec == V4L2_PIX_FMT_VP8) {
+		lcu_size = 16;
+		is_h265 = false;
+		num_vpp_pipes = 1;
 	} else {
 		return 0;
 	}
Signature · 1 line
2.47.3