]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: qcom: iris: Improve crop_offset handling for encoder
authorWangao Wang <wangao.wang@oss.qualcomm.com>
Fri, 14 Nov 2025 03:08:59 +0000 (11:08 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 20 Jan 2026 15:22:23 +0000 (16:22 +0100)
The setting of HFI_PROP_CROP_OFFSETS for the OUTPUT port is correct,
but on the CAPTURE port it is used to inform the firmware about the
region of interest, so crop_offset needs to be handled accordingly.

Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
drivers/media/platform/qcom/iris/iris_venc.c

index 91eca524d021a7ae79554d24f7cd6d2cfce20730..c73019efaea68a6018e1be475e039e2924b632f5 100644 (file)
@@ -217,7 +217,7 @@ static int iris_hfi_gen2_set_crop_offsets(struct iris_inst *inst, u32 plane)
        u32 port = iris_hfi_gen2_get_port(inst, plane);
        u32 bottom_offset, right_offset;
        u32 left_offset, top_offset;
-       u32 payload[2];
+       u32 payload[2], codec_align;
 
        if (inst->domain == DECODER) {
                if (V4L2_TYPE_IS_OUTPUT(plane)) {
@@ -232,10 +232,20 @@ static int iris_hfi_gen2_set_crop_offsets(struct iris_inst *inst, u32 plane)
                        top_offset = inst->compose.top;
                }
        } else {
-               bottom_offset = (inst->fmt_src->fmt.pix_mp.height - inst->crop.height);
-               right_offset = (inst->fmt_src->fmt.pix_mp.width - inst->crop.width);
-               left_offset = inst->crop.left;
-               top_offset = inst->crop.top;
+               codec_align = inst->codec == V4L2_PIX_FMT_HEVC ? 32 : 16;
+               if (V4L2_TYPE_IS_OUTPUT(plane)) {
+                       bottom_offset = (inst->enc_raw_height - inst->crop.height);
+                       right_offset = (inst->enc_raw_width - inst->crop.width);
+                       left_offset = inst->crop.left;
+                       top_offset = inst->crop.top;
+               } else {
+                       bottom_offset = (ALIGN(inst->fmt_dst->fmt.pix_mp.height, codec_align) -
+                                       inst->fmt_dst->fmt.pix_mp.height);
+                       right_offset = (ALIGN(inst->fmt_dst->fmt.pix_mp.width, codec_align) -
+                                       inst->fmt_dst->fmt.pix_mp.width);
+                       left_offset = 0;
+                       top_offset = 0;
+               }
        }
 
        payload[0] = FIELD_PREP(GENMASK(31, 16), left_offset) | top_offset;
index 6a94c08652b7b38476bf567f4eae13fa1baa8827..6628e9a3ab01d6a1b85932e4eec89120ba8e5063 100644 (file)
@@ -62,8 +62,8 @@ int iris_venc_inst_init(struct iris_inst *inst)
 
        inst->crop.left = 0;
        inst->crop.top = 0;
-       inst->crop.width = f->fmt.pix_mp.width;
-       inst->crop.height = f->fmt.pix_mp.height;
+       inst->crop.width = DEFAULT_WIDTH;
+       inst->crop.height = DEFAULT_HEIGHT;
 
        inst->operating_rate = DEFAULT_FPS;
        inst->frame_rate = DEFAULT_FPS;