[PATCH 1/5] media: iris: give the gen1 encoder the visible frame size
From: Dmitry Baryshkov
Date: Sat Dec 05 2026 - 18:12:40 EST
On HFI gen1 the encoder input and output resolutions are set to the
aligned format sizes, so a 1280x720 stream comes out as 1280x736 even
after userspace crops it to 720 lines with S_SELECTION: the firmware
encodes the whole aligned buffer, padding included. Formats whose
aligned height differs from the output alignment break completely: the
firmware does not scale up, and with a 720-line QC10C input against a
736-line output it returns empty bitstream buffers.
Pass the cropped frame size, limited to the raw size, as the input
resolution, and the same size as the output resolution unless scaling
was requested, as the venus driver does for the same firmware
interface. The padded layout is already described to the firmware by
the plane stride and scanlines.
Fixes: 92e007ca5ab6 ("media: iris: Add V4L2 streaming support for encoder video device")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
---
.../platform/qcom/iris/iris_hfi_gen1_command.c | 38 +++++++++++++++++-----
1 file changed, 30 insertions(+), 8 deletions(-)
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 862ce20e2c5d..bed0e0adb524 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
@@ -896,7 +896,32 @@ static int iris_hfi_gen1_session_set_property(struct iris_inst *inst, u32 packet
return hfi_gen1_set_property(inst, packet_type, payload, payload_size);
}
-static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane)
+static int iris_hfi_gen1_set_enc_resolution(struct iris_inst *inst, u32 plane)
+{
+ u32 ptype = HFI_PROPERTY_PARAM_FRAME_SIZE;
+ u32 width = min(inst->crop.width, inst->enc_raw_width);
+ u32 height = min(inst->crop.height, inst->enc_raw_height);
+ struct hfi_framesize fs;
+ int ret;
+
+ fs.buffer_type = HFI_BUFFER_INPUT;
+ fs.width = width;
+ fs.height = height;
+ ret = hfi_gen1_set_property(inst, ptype, &fs, sizeof(fs));
+ if (ret)
+ return ret;
+
+ fs.buffer_type = HFI_BUFFER_OUTPUT;
+ if (inst->enc_scale_width != inst->enc_raw_width ||
+ inst->enc_scale_height != inst->enc_raw_height) {
+ fs.width = inst->enc_scale_width;
+ fs.height = inst->enc_scale_height;
+ }
+
+ return hfi_gen1_set_property(inst, ptype, &fs, sizeof(fs));
+}
+
+static int iris_hfi_gen1_set_dec_resolution(struct iris_inst *inst, u32 plane)
{
u32 ptype = HFI_PROPERTY_PARAM_FRAME_SIZE;
struct hfi_framesize fs;
@@ -911,11 +936,8 @@ static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane)
if (ret)
return ret;
}
- if (inst->domain == DECODER)
- fs.buffer_type = HFI_BUFFER_OUTPUT2;
- else
- fs.buffer_type = HFI_BUFFER_OUTPUT;
+ fs.buffer_type = HFI_BUFFER_OUTPUT2;
fs.width = inst->fmt_dst->fmt.pix_mp.width;
fs.height = inst->fmt_dst->fmt.pix_mp.height;
@@ -1163,7 +1185,7 @@ static int iris_hfi_gen1_session_set_config_params(struct iris_inst *inst, u32 p
static const struct iris_hfi_prop_type_handle vdec_prop_type_handle_inp_arr[] = {
{HFI_PROPERTY_PARAM_FRAME_SIZE,
- iris_hfi_gen1_set_resolution},
+ iris_hfi_gen1_set_dec_resolution},
{HFI_PROPERTY_CONFIG_VIDEOCORES_USAGE,
iris_hfi_gen1_decide_core},
{HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT,
@@ -1180,7 +1202,7 @@ static int iris_hfi_gen1_session_set_config_params(struct iris_inst *inst, u32 p
static const struct iris_hfi_prop_type_handle vdec_prop_type_handle_out_arr[] = {
{HFI_PROPERTY_PARAM_FRAME_SIZE,
- iris_hfi_gen1_set_resolution},
+ iris_hfi_gen1_set_dec_resolution},
{HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT,
iris_hfi_gen1_set_raw_format},
{HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO,
@@ -1199,7 +1221,7 @@ static int iris_hfi_gen1_session_set_config_params(struct iris_inst *inst, u32 p
{HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO,
iris_hfi_gen1_set_stride},
{HFI_PROPERTY_PARAM_FRAME_SIZE,
- iris_hfi_gen1_set_resolution},
+ iris_hfi_gen1_set_enc_resolution},
{HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT,
iris_hfi_gen1_set_raw_format},
{HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL,
--
2.47.3