Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c822ab63 authored by Ashray Kulkarni's avatar Ashray Kulkarni
Browse files

msm: vidc: Add support for setting initial qp



Adds support to set initial qp, thereby allowing the client to set
initial qp for I,P, and B frames.

Change-Id: Ie956651bde85e800d97a0007769af9aec8ca16a4
Signed-off-by: default avatarAshray Kulkarni <ashrayk@codeaurora.org>
parent 97d5ac84
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -1716,6 +1716,22 @@ int create_pkt_cmd_session_set_property(
		pkt->size += sizeof(u32) * 2;
		break;
	}
	case HAL_PARAM_VENC_ENABLE_INITIAL_QP:
	{
		struct hfi_initial_quantization *hfi;
		struct hal_initial_quantization *quant = pdata;
		pkt->rg_property_data[0] =
			HFI_PROPERTY_PARAM_VENC_INITIAL_QP;
		hfi = (struct hfi_initial_quantization *)
			&pkt->rg_property_data[1];
		hfi->init_qp_enable = quant->init_qp_enable;
		hfi->qp_i = quant->qpi;
		hfi->qp_p = quant->qpp;
		hfi->qp_b = quant->qpb;
		pkt->size += sizeof(u32) +
			sizeof(struct hfi_initial_quantization);
		break;
	}
	/* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */
	case HAL_CONFIG_BUFFER_REQUIREMENTS:
	case HAL_CONFIG_PRIORITY:
+65 −4
Original line number Diff line number Diff line
@@ -890,6 +890,46 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
		(1 << V4L2_MPEG_VIDC_VIDEO_RATE_CONTROL_TIMESTAMP_MODE_IGNORE)),
		.qmenu = timestamp_mode,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_INITIAL_QP,
		.name = "Enable setting initial QP",
		.type = V4L2_CTRL_TYPE_BUTTON,
		.minimum = 0,
		.maximum = 0,
		.default_value = 0,
		.step = 0,
		.cluster = 0,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP,
		.name = "Iframe initial QP",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 1,
		.maximum = 51,
		.default_value = 1,
		.step = 1,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP,
		.name = "Pframe initial QP",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 1,
		.maximum = 51,
		.default_value = 1,
		.step = 1,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP,
		.name = "Bframe initial QP",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 1,
		.maximum = 51,
		.default_value = 1,
		.step = 1,
		.qmenu = NULL,
	}
};

#define NUM_CTRLS ARRAY_SIZE(msm_venc_ctrls)
@@ -2273,6 +2313,7 @@ static int try_set_ext_ctrl(struct msm_vidc_inst *inst,
	u32 property_id = 0;
	void *pdata = NULL;
	struct msm_vidc_core_capability *cap = NULL;
	struct hal_initial_quantization quant;

	if (!inst || !inst->core || !inst->core->device || !ctrl) {
		dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
@@ -2317,6 +2358,26 @@ static int try_set_ext_ctrl(struct msm_vidc_inst *inst,
			property_id = HAL_PARAM_VENC_LTRMODE;
			pdata = &ltrmode;
			break;
		case V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_INITIAL_QP:
			property_id = HAL_PARAM_VENC_ENABLE_INITIAL_QP;
			quant.init_qp_enable = control[i].value;
			pdata = &quant;
			break;
		case V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP:
			quant.qpi = control[i].value;
			property_id = HAL_PARAM_VENC_ENABLE_INITIAL_QP;
			pdata = &quant;
			break;
		case V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP:
			quant.qpp = control[i].value;
			property_id = HAL_PARAM_VENC_ENABLE_INITIAL_QP;
			pdata = &quant;
			break;
		case V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP:
			quant.qpb = control[i].value;
			property_id = HAL_PARAM_VENC_ENABLE_INITIAL_QP;
			pdata = &quant;
			break;
		default:
			dprintk(VIDC_ERR, "Invalid id set: %d\n",
				control[i].id);
+8 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ enum hal_property {
	HAL_CONFIG_VENC_LTRPERIOD,
	HAL_PARAM_VENC_HIER_P_NUM_FRAMES,
	HAL_PARAM_VENC_DISABLE_RC_TIMESTAMP,
	HAL_PARAM_VENC_ENABLE_INITIAL_QP,
};

enum hal_domain {
@@ -637,6 +638,13 @@ struct hal_quantization {
	u32 layer_id;
};

struct hal_initial_quantization {
	u32 qpi;
	u32 qpp;
	u32 qpb;
	u32 init_qp_enable;
};

struct hal_quantization_range {
	u32 min_qp;
	u32 max_qp;
+9 −1
Original line number Diff line number Diff line
@@ -327,7 +327,8 @@ struct hfi_buffer_info {
	(HFI_PROPERTY_PARAM_VENC_COMMON_START + 0x023)
#define HFI_PROPERTY_PARAM_VENC_DISABLE_RC_TIMESTAMP \
	(HFI_PROPERTY_PARAM_VENC_COMMON_START + 0x027)

#define HFI_PROPERTY_PARAM_VENC_INITIAL_QP	\
	(HFI_PROPERTY_PARAM_VENC_COMMON_START + 0x028)

#define HFI_PROPERTY_CONFIG_VENC_COMMON_START				\
	(HFI_DOMAIN_BASE_VENC + HFI_ARCH_COMMON_OFFSET + 0x6000)
@@ -541,6 +542,13 @@ struct hfi_quantization {
	u32 layer_id;
};

struct hfi_initial_quantization {
	u32 qp_i;
	u32 qp_p;
	u32 qp_b;
	u32 init_qp_enable;
};

struct hfi_quantization_range {
	u32 min_qp;
	u32 max_qp;
+12 −0
Original line number Diff line number Diff line
@@ -878,6 +878,18 @@ enum v4l2_mpeg_vidc_video_rate_control_timestamp_mode {
	V4L2_MPEG_VIDC_VIDEO_RATE_CONTROL_TIMESTAMP_MODE_IGNORE = 1,
};

#define V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_INITIAL_QP \
		(V4L2_CID_MPEG_MSM_VIDC_BASE + 53)

#define V4L2_CID_MPEG_VIDC_VIDEO_I_FRAME_QP \
		(V4L2_CID_MPEG_MSM_VIDC_BASE + 54)

#define V4L2_CID_MPEG_VIDC_VIDEO_P_FRAME_QP \
		(V4L2_CID_MPEG_MSM_VIDC_BASE + 55)

#define V4L2_CID_MPEG_VIDC_VIDEO_B_FRAME_QP \
		(V4L2_CID_MPEG_MSM_VIDC_BASE + 56)

/*  Camera class control IDs */

#define V4L2_CID_CAMERA_CLASS_BASE 	(V4L2_CTRL_CLASS_CAMERA | 0x900)