Commit 0708f305 authored by Wangao Wang's avatar Wangao Wang Committed by Hans Verkuil
Browse files

media: qcom: iris: Improve crop_offset handling for encoder



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: default avatarDikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Signed-off-by: default avatarWangao Wang <wangao.wang@oss.qualcomm.com>
Signed-off-by: default avatarBryan O'Donoghue <bod@kernel.org>
Signed-off-by: default avatarHans Verkuil <hverkuil+cisco@kernel.org>
parent d9967fa3
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -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);
		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;
+2 −2
Original line number Diff line number Diff line
@@ -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;