Commit 121d6d7a authored by Wangao Wang's avatar Wangao Wang Committed by Hans Verkuil
Browse files

media: qcom: iris: Add scale support for encoder



Add members enc_scale_width, enc_scale_height to the struct iris_inst to
support scale requirements.

Add output width and height settings in iris_venc_s_fmt_output to
enable scaling functionality.

Add VPSS buffer to platform data, which the scale function requires.

Reviewed-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: default avatarDikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
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 0708f305
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -196,8 +196,8 @@ static int iris_hfi_gen2_set_bitstream_resolution(struct iris_inst *inst, u32 pl
		payload_type = HFI_PAYLOAD_U32;
	} else {
		codec_align = inst->codec == V4L2_PIX_FMT_HEVC ? 32 : 16;
		resolution = ALIGN(inst->fmt_dst->fmt.pix_mp.width, codec_align) << 16 |
			ALIGN(inst->fmt_dst->fmt.pix_mp.height, codec_align);
		resolution = ALIGN(inst->enc_scale_width, codec_align) << 16 |
			ALIGN(inst->enc_scale_height, codec_align);
		inst_hfi_gen2->dst_subcr_params.bitstream_resolution = resolution;
		payload_type = HFI_PAYLOAD_32_PACKED;
	}
@@ -239,10 +239,10 @@ static int iris_hfi_gen2_set_crop_offsets(struct iris_inst *inst, u32 plane)
			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);
			bottom_offset = (ALIGN(inst->enc_scale_height, codec_align) -
					inst->enc_scale_height);
			right_offset = (ALIGN(inst->enc_scale_width, codec_align) -
				       inst->enc_scale_width);
			left_offset = 0;
			top_offset = 0;
		}
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ static u32 iris_hfi_gen2_buf_type_to_driver(struct iris_inst *inst,
		return BUF_PERSIST;
	case HFI_BUFFER_PARTIAL_DATA:
		return BUF_PARTIAL;
	case HFI_BUFFER_VPSS:
		return BUF_VPSS;
	default:
		return 0;
	}
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ struct iris_fmt {
 * @hfi_rc_type: rate control type
 * @enc_raw_width: source image width for encoder instance
 * @enc_raw_height: source image height for encoder instance
 * @enc_scale_width: scale width for encoder instance
 * @enc_scale_height: scale height for encoder instance
 */

struct iris_inst {
@@ -112,6 +114,8 @@ struct iris_inst {
	u32				hfi_rc_type;
	u32				enc_raw_width;
	u32				enc_raw_height;
	u32				enc_scale_width;
	u32				enc_scale_height;
};

#endif
+12 −0
Original line number Diff line number Diff line
@@ -851,6 +851,10 @@ static const u32 sm8550_dec_op_int_buf_tbl[] = {
	BUF_DPB,
};

static const u32 sm8550_enc_ip_int_buf_tbl[] = {
	BUF_VPSS,
};

static const u32 sm8550_enc_op_int_buf_tbl[] = {
	BUF_BIN,
	BUF_COMV,
@@ -947,6 +951,8 @@ const struct iris_platform_data sm8550_data = {
	.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),
};
@@ -1048,6 +1054,8 @@ const struct iris_platform_data sm8650_data = {
	.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),
};
@@ -1140,6 +1148,8 @@ const struct iris_platform_data sm8750_data = {
	.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),
};
@@ -1236,6 +1246,8 @@ const struct iris_platform_data qcs8300_data = {
	.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),
};
+22 −1
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ int iris_venc_inst_init(struct iris_inst *inst)

	inst->enc_raw_width = DEFAULT_WIDTH;
	inst->enc_raw_height = DEFAULT_HEIGHT;
	inst->enc_scale_width = DEFAULT_WIDTH;
	inst->enc_scale_height = DEFAULT_HEIGHT;

	memcpy(&inst->fw_caps[0], &core->inst_fw_caps_enc[0],
	       INST_FW_CAP_MAX * sizeof(struct platform_inst_fw_cap));
@@ -226,15 +228,32 @@ int iris_venc_try_fmt(struct iris_inst *inst, struct v4l2_format *f)

static int iris_venc_s_fmt_output(struct iris_inst *inst, struct v4l2_format *f)
{
	const struct iris_fmt *venc_fmt;
	struct v4l2_format *fmt;
	u32 codec_align;

	iris_venc_try_fmt(inst, f);

	if (!(find_format(inst, f->fmt.pix_mp.pixelformat, f->type)))
	venc_fmt = find_format(inst, f->fmt.pix_mp.pixelformat, f->type);
	if (!venc_fmt)
		return -EINVAL;

	codec_align = venc_fmt->pixfmt == V4L2_PIX_FMT_HEVC ? 32 : 16;

	fmt = inst->fmt_dst;
	fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
	/*
	 * If output format size != input format size,
	 * it is considered a scaling case,
	 * and the scaled size needs to be saved.
	 */
	if (f->fmt.pix_mp.width != inst->fmt_src->fmt.pix_mp.width ||
	    f->fmt.pix_mp.height != inst->fmt_src->fmt.pix_mp.height) {
		inst->enc_scale_width = f->fmt.pix_mp.width;
		inst->enc_scale_height = f->fmt.pix_mp.height;
		fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, codec_align);
		fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, codec_align);
	}
	fmt->fmt.pix_mp.num_planes = 1;
	fmt->fmt.pix_mp.plane_fmt[0].bytesperline = 0;
	fmt->fmt.pix_mp.plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
@@ -292,6 +311,8 @@ static int iris_venc_s_fmt_input(struct iris_inst *inst, struct v4l2_format *f)

	inst->enc_raw_width = f->fmt.pix_mp.width;
	inst->enc_raw_height = f->fmt.pix_mp.height;
	inst->enc_scale_width = f->fmt.pix_mp.width;
	inst->enc_scale_height = f->fmt.pix_mp.height;

	if (f->fmt.pix_mp.width != inst->crop.width ||
	    f->fmt.pix_mp.height != inst->crop.height) {
Loading