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

Commit ef857677 authored by Deva Ramasubramanian's avatar Deva Ramasubramanian Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Advertise extradata size in queue_setup()



If extradata is enabled, the correct size must be advertised as part of
queue_setup().  Prior to this commit, the output buffer size was taken
to be the extradata size.

In order to make sure that we aren't advertising stale buffer sizes,
query the core for both CAPTURE and OUTPUT planes.

Change-Id: I300e0e1d852caab208fd4cfc6df7cf3152f52431
Signed-off-by: default avatarDeva Ramasubramanian <dramasub@codeaurora.org>
parent c77af294
Loading
Loading
Loading
Loading
+30 −14
Original line number Diff line number Diff line
@@ -1038,9 +1038,23 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
	}
	hdev = inst->core->device;

	rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
	if (rc) {
		dprintk(VIDC_ERR, "Failed to open instance\n");
		return rc;
	}

	rc = msm_comm_try_get_bufreqs(inst);
	if (rc) {
		dprintk(VIDC_ERR,
				"Failed to get buffer requirements: %d\n", rc);
		return rc;
	}

	switch (q->type) {
	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
		*num_planes = 1;

		buff_req = get_buff_req_buffer(inst, HAL_BUFFER_OUTPUT);
		if (buff_req) {
			*num_buffers = buff_req->buffer_count_actual =
@@ -1068,9 +1082,18 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
		inst->fmts[CAPTURE_PORT]->num_planes = *num_planes;

		for (i = 0; i < *num_planes; i++) {
			int extra_idx = EXTRADATA_IDX(*num_planes);

			sizes[i] = inst->fmts[CAPTURE_PORT]->get_frame_size(
					i, inst->prop.height[CAPTURE_PORT],
					inst->prop.width[CAPTURE_PORT]);

			if (extra_idx && i == extra_idx &&
					extra_idx < VIDEO_MAX_PLANES) {
				buff_req_buffer = get_buff_req_buffer(inst,
						HAL_BUFFER_EXTRADATA_OUTPUT);
				sizes[i] = buff_req_buffer->buffer_size;
			}
		}

		property_id = HAL_PARAM_BUFFER_COUNT_ACTUAL;
@@ -1080,26 +1103,18 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
			property_id, &new_buf_count);
		break;
	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
		rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
		if (rc) {
			dprintk(VIDC_ERR, "Failed to open instance\n");
			break;
		}
		rc = msm_comm_try_get_bufreqs(inst);
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to get buffer requirements: %d\n", rc);
			break;
		}
		*num_planes = 1;

		mutex_lock(&inst->lock);
		*num_buffers = inst->buff_req.buffer[0].buffer_count_actual =
			max(*num_buffers, inst->buff_req.buffer[0].
				buffer_count_actual);
		mutex_unlock(&inst->lock);

		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)
@@ -1107,6 +1122,7 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
		if (extradata == V4L2_MPEG_VIDC_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",
@@ -1116,15 +1132,15 @@ static int msm_venc_queue_setup(struct vb2_queue *q,
		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;
			sizes[extra_idx] = buff_req_buffer->buffer_size;
		}

		break;
	default:
		dprintk(VIDC_ERR, "Invalid q type = %d\n", q->type);