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

Commit 3c41e7c8 authored by Praneeth Paladugu's avatar Praneeth Paladugu Committed by Arun Menon
Browse files

msm: vidc: Add encoder input extradata support



Venus uses encoder input extradata for input crop
information. This change adds the support for input
extradata.

Change-Id: If952073aa49cbe1cc5e071fbf40c839a8d05e0fe
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
Signed-off-by: default avatarArun Menon <avmenon@codeaurora.org>
parent 442d7807
Loading
Loading
Loading
Loading
+29 −9
Original line number Diff line number Diff line
@@ -368,6 +368,8 @@ static int get_hfi_extradata_index(enum hal_extradata_id index)
		ret = HFI_PROPERTY_PARAM_VDEC_NUM_CONCEALED_MB;
		break;
	case HAL_EXTRADATA_ASPECT_RATIO:
	case HAL_EXTRADATA_INPUT_CROP:
	case HAL_EXTRADATA_DIGITAL_ZOOM:
		ret = HFI_PROPERTY_PARAM_INDEX_EXTRADATA;
		break;
	case HAL_EXTRADATA_MPEG2_SEQDISP:
@@ -389,6 +391,26 @@ static int get_hfi_extradata_index(enum hal_extradata_id index)
	return ret;
}

static int get_hfi_extradata_id(enum hal_extradata_id index)
{
	int ret = 0;
	switch (index) {
	case HAL_EXTRADATA_ASPECT_RATIO:
		ret = MSM_VIDC_EXTRADATA_ASPECT_RATIO;
		break;
	case HAL_EXTRADATA_INPUT_CROP:
		ret = MSM_VIDC_EXTRADATA_INPUT_CROP;
		break;
	case HAL_EXTRADATA_DIGITAL_ZOOM:
		ret = MSM_VIDC_EXTRADATA_DIGITAL_ZOOM;
		break;
	default:
		ret = get_hfi_extradata_index(index);
		break;
	}
	return ret;
}

static u32 get_hfi_buf_mode(enum buffer_mode_type hal_buf_mode)
{
	u32 buf_mode;
@@ -544,6 +566,7 @@ int create_pkt_cmd_session_etb_encoder(
	pkt->filled_len = input_frame->filled_len;
	pkt->input_tag = input_frame->clnt_data;
	pkt->packet_buffer = (u8 *) input_frame->device_addr;
	pkt->extra_data_buffer = (u8 *) input_frame->extradata_addr;

	if (!pkt->packet_buffer)
		return -EINVAL;
@@ -1358,23 +1381,20 @@ int create_pkt_cmd_session_set_property(
	{
		struct hfi_index_extradata_config *hfi;
		struct hal_extradata_enable *extra = pdata;
		int index = 0;
		int id = 0;
		pkt->rg_property_data[0] =
			get_hfi_extradata_index(extra->index);
		hfi =
			(struct hfi_index_extradata_config *)
			&pkt->rg_property_data[1];
		hfi->enable = extra->enable;
		if (extra->index == HAL_EXTRADATA_ASPECT_RATIO)
			index = MSM_VIDC_EXTRADATA_ASPECT_RATIO;
		else
			index = get_hfi_extradata_index(extra->index);
		if (index)
			hfi->index_extra_data_id = index;
		id = get_hfi_extradata_id(extra->index);
		if (id)
			hfi->index_extra_data_id = id;
		else {
			dprintk(VIDC_WARN,
				"Failed to find extradata index: %d\n",
				index);
				"Failed to find extradata id: %d\n",
				id);
			rc = -EINVAL;
		}
		pkt->size += sizeof(u32) +
+1 −0
Original line number Diff line number Diff line
@@ -971,6 +971,7 @@ static void hfi_process_session_etb_done(
	data_done.input_done.offset = pkt->offset;
	data_done.input_done.filled_len = pkt->filled_len;
	data_done.input_done.packet_buffer = pkt->packet_buffer;
	data_done.input_done.extra_data_buffer = pkt->extra_data_buffer;
	data_done.input_done.status =
		hfi_map_err_status((u32) pkt->error_type);
	callback(SESSION_ETB_DONE, &data_done);
+44 −10
Original line number Diff line number Diff line
@@ -866,7 +866,9 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
	struct hfi_device *hdev;
	struct hal_buffer_requirements *buff_req;
	struct v4l2_ctrl *ctrl = NULL;
	u32 extradata = 0;
	u32 extradata = 0, extra_idx = 0;
	struct hal_buffer_requirements *buff_req_buffer = NULL;

	if (!q || !q->drv_priv) {
		dprintk(VIDC_ERR, "Invalid input\n");
		return -EINVAL;
@@ -901,7 +903,7 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
				V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA);
		if (ctrl)
			extradata = v4l2_ctrl_g_ctrl(ctrl);
		if (extradata)
		if (extradata == V4L2_MPEG_VIDC_EXTRADATA_MULTISLICE_INFO)
			*num_planes = *num_planes + 1;
		inst->fmts[CAPTURE_PORT]->num_planes = *num_planes;
		for (i = 0; i < *num_planes; i++) {
@@ -936,16 +938,30 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
		property_id = HAL_PARAM_BUFFER_COUNT_ACTUAL;
		new_buf_count.buffer_type = HAL_BUFFER_INPUT;
		new_buf_count.buffer_count_actual = *num_buffers;
		ctrl = v4l2_ctrl_find(&inst->ctrl_handler,
			V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA);
		if (ctrl)
			extradata = v4l2_ctrl_g_ctrl(ctrl);
		if (extradata == V4L2_MPEG_VIDC_INDEX_EXTRADATA_INPUT_CROP)
			*num_planes = *num_planes + 1;
		inst->fmts[OUTPUT_PORT]->num_planes = *num_planes;
		rc = call_hfi_op(hdev, session_set_property, inst->session,
					property_id, &new_buf_count);
		dprintk(VIDC_DBG, "size = %d, alignment = %d, count = %d\n",
				inst->buff_req.buffer[0].buffer_size,
				inst->buff_req.buffer[0].buffer_alignment,
				inst->buff_req.buffer[0].buffer_count_actual);
		for (i = 0; i < *num_planes; i++) {
			sizes[i] = inst->fmts[OUTPUT_PORT]->get_frame_size(
					i, inst->prop.height[OUTPUT_PORT],
		sizes[0] = inst->fmts[OUTPUT_PORT]->get_frame_size(
				0, inst->prop.height[OUTPUT_PORT],
				inst->prop.width[OUTPUT_PORT]);
		extra_idx =
			EXTRADATA_IDX(inst->fmts[OUTPUT_PORT]->num_planes);
		if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
			buff_req_buffer = get_buff_req_buffer(inst,
				HAL_BUFFER_EXTRADATA_INPUT);
			sizes[extra_idx] =
				buff_req_buffer ?
				buff_req_buffer->buffer_size : 0;
		}
		break;
	default:
@@ -2429,6 +2445,18 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
					"Failed to set OUTPUT framesize\n");
				goto exit;
			}
		} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
			struct hal_buffer_requirements *buff_req_buffer = NULL;
			int extra_idx = 0;
			extra_idx = EXTRADATA_IDX(fmt->num_planes);
			if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
				buff_req_buffer =
					get_buff_req_buffer(inst,
						HAL_BUFFER_EXTRADATA_INPUT);
				f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage =
					buff_req_buffer ?
					buff_req_buffer->buffer_size : 0;
			}
		}
	} else {
		dprintk(VIDC_ERR, "Buf type not recognized, type = %d\n",
@@ -2446,7 +2474,7 @@ int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
	int i;
	u32 height, width;
	int extra_idx = 0;
	struct hal_buffer_requirements *buff_req_buffer;
	struct hal_buffer_requirements *buff_req_buffer = NULL;

	if (!inst || !f) {
		dprintk(VIDC_ERR,
@@ -2474,9 +2502,15 @@ int msm_venc_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
		}
		extra_idx = EXTRADATA_IDX(fmt->num_planes);
		if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
			if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
				buff_req_buffer =
					get_buff_req_buffer(inst,
						HAL_BUFFER_EXTRADATA_OUTPUT);
			else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
				buff_req_buffer =
					get_buff_req_buffer(inst,
						HAL_BUFFER_EXTRADATA_INPUT);

			f->fmt.pix_mp.plane_fmt[extra_idx].sizeimage =
				buff_req_buffer ?
				buff_req_buffer->buffer_size : 0;
+17 −1
Original line number Diff line number Diff line
@@ -2375,6 +2375,8 @@ int msm_comm_qbuf(struct vb2_buffer *vb)
	struct vidc_frame_data frame_data;
	struct msm_vidc_core *core;
	struct hfi_device *hdev;
	int extra_idx = 0;

	q = vb->vb2_queue;
	inst = q->drv_priv;
	if (!inst || !vb) {
@@ -2470,6 +2472,15 @@ int msm_comm_qbuf(struct vb2_buffer *vb)
				dprintk(VIDC_DBG,
					"Received TS_ERROR on output cap\n");
			}
			extra_idx =
				EXTRADATA_IDX(inst->fmts[OUTPUT_PORT]->
					num_planes);
			if (extra_idx && (extra_idx < VIDEO_MAX_PLANES) &&
					vb->v4l2_planes[extra_idx].m.userptr) {
				frame_data.extradata_addr =
					vb->v4l2_planes[extra_idx].m.userptr;
				frame_data.flags |= HAL_BUFFERFLAG_EXTRADATA;
			}
			dprintk(VIDC_DBG,
				"Sending etb to hal: device_addr: 0x%x"
				"Alloc: %d, filled: %d, offset: %d\n",
@@ -2484,7 +2495,6 @@ int msm_comm_qbuf(struct vb2_buffer *vb)
			dprintk(VIDC_DBG, "Sent etb to HAL\n");
		} else if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
			struct vidc_seq_hdr seq_hdr;
			int extra_idx = 0;
			frame_data.filled_len = 0;
			frame_data.offset = 0;
			frame_data.alloc_len = vb->v4l2_planes[0].length;
@@ -3197,6 +3207,12 @@ enum hal_extradata_id msm_comm_get_hal_extradata_index(
	case V4L2_MPEG_VIDC_INDEX_EXTRADATA_ASPECT_RATIO:
		ret = HAL_EXTRADATA_ASPECT_RATIO;
		break;
	case V4L2_MPEG_VIDC_INDEX_EXTRADATA_INPUT_CROP:
		ret = HAL_EXTRADATA_INPUT_CROP;
		break;
	case V4L2_MPEG_VIDC_INDEX_EXTRADATA_DIGITAL_ZOOM:
		ret = HAL_EXTRADATA_DIGITAL_ZOOM;
		break;
	case V4L2_MPEG_VIDC_EXTRADATA_MPEG2_SEQDISP:
		ret = HAL_EXTRADATA_MPEG2_SEQDISP;
		break;
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ enum hal_extradata_id {
	HAL_EXTRADATA_STREAM_USERDATA,
	HAL_EXTRADATA_FRAME_QP,
	HAL_EXTRADATA_FRAME_BITS_INFO,
	HAL_EXTRADATA_INPUT_CROP,
	HAL_EXTRADATA_DIGITAL_ZOOM,
};

enum hal_property {
Loading