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

Commit d4e94261 authored by Govindaraj Rajagopal's avatar Govindaraj Rajagopal
Browse files

msm: vidc: do not allow qbuf during flush



1. Don't allow qbuf (etb & ftb), if flush is issued to
   (encoder & decoder) input port.
2. Don't allow qbuf (etb & ftb), if flush is issued to encoder
   output port
3. Don't qbuf (ftb), if flush is issued to decoder output port
4. Allow qbuf (etb), if flush is issued to decoder output port
   to handle decoder reconfig.

Change-Id: I08a6a10612cc1a14ad164c55c5c8e54550c84845
Signed-off-by: default avatarGovindaraj Rajagopal <grajagop@codeaurora.org>
parent 0f6ff621
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -346,9 +346,10 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b)
		return -EINVAL;
	}

	if (inst->in_flush && is_decode_session(inst) &&
		b->type == OUTPUT_MPLANE) {
		dprintk(VIDC_ERR, "%s: in flush, discarding qbuf\n", __func__);
	if ((inst->out_flush && b->type == OUTPUT_MPLANE) || inst->in_flush) {
		dprintk(VIDC_ERR,
			"%s: %x: in flush, discarding qbuf, type %u, index %u\n",
			__func__, hash32_ptr(inst->session), b->type, b->index);
		return -EINVAL;
	}

+20 −8
Original line number Diff line number Diff line
@@ -2096,19 +2096,22 @@ static void handle_session_flush(enum hal_command_response cmd, void *data)
			}
		}
	}
	inst->in_flush = false;
	flush_event.type = V4L2_EVENT_MSM_VIDC_FLUSH_DONE;
	ptr = (u32 *)flush_event.u.data;

	flush_type = response->data.flush_type;
	switch (flush_type) {
	case HAL_FLUSH_INPUT:
		inst->in_flush = false;
		ptr[0] = V4L2_CMD_FLUSH_OUTPUT;
		break;
	case HAL_FLUSH_OUTPUT:
		inst->out_flush = false;
		ptr[0] = V4L2_CMD_FLUSH_CAPTURE;
		break;
	case HAL_FLUSH_ALL:
		inst->in_flush = false;
		inst->out_flush = false;
		ptr[0] |= V4L2_CMD_FLUSH_CAPTURE;
		ptr[0] |= V4L2_CMD_FLUSH_OUTPUT;
		break;
@@ -5391,14 +5394,20 @@ int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
	core = inst->core;
	hdev = core->device;

	ip_flush = flags & V4L2_CMD_FLUSH_OUTPUT;
	op_flush = flags & V4L2_CMD_FLUSH_CAPTURE;
	ip_flush = !!(flags & V4L2_CMD_FLUSH_OUTPUT);
	op_flush = !!(flags & V4L2_CMD_FLUSH_CAPTURE);

	if (ip_flush && !op_flush) {
		dprintk(VIDC_ERR,
			"Input only flush not supported, making it flush all\n");
		op_flush = true;
		return 0;
		goto exit;
	}

	if ((inst->in_flush && ip_flush) || (inst->out_flush && op_flush)) {
		dprintk(VIDC_ERR, "%s: %x : Already in flush\n",
			__func__, hash32_ptr(inst->session));
		goto exit;
	}

	msm_clock_data_reset(inst);
@@ -5409,12 +5418,13 @@ int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
				"Core %pK and inst %pK are in bad state\n",
					core, inst);
		msm_comm_flush_in_invalid_state(inst);
		return 0;
		goto exit;
	}

	mutex_lock(&inst->flush_lock);
	/* enable in flush */
	inst->in_flush = true;
	inst->in_flush = ip_flush;
	inst->out_flush = op_flush;

	mutex_lock(&inst->registeredbufs.lock);
	list_for_each_entry_safe(mbuf, next, &inst->registeredbufs.list, list) {
@@ -5472,10 +5482,12 @@ int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
		dprintk(VIDC_ERR,
			"Sending flush to firmware failed, flush out all buffers\n");
		msm_comm_flush_in_invalid_state(inst);
		/* disable in_flush */
		/* disable in_flush & out_flush */
		inst->in_flush = false;
		inst->out_flush = false;
	}

exit:
	return rc;
}

@@ -6850,7 +6862,7 @@ void handle_release_buffer_reference(struct msm_vidc_inst *inst,
		goto unlock;

	/* buffer found means client queued the buffer already */
	if (inst->in_reconfig || inst->in_flush) {
	if (inst->in_reconfig || inst->out_flush) {
		print_vidc_buffer(VIDC_HIGH, "rbr flush buf", inst, mbuf);
		msm_comm_flush_vidc_buffer(inst, mbuf);
		msm_comm_unmap_vidc_buffer(inst, mbuf);
+1 −0
Original line number Diff line number Diff line
@@ -526,6 +526,7 @@ struct msm_vidc_inst {
	int bit_depth;
	struct kref kref;
	bool in_flush;
	bool out_flush;
	u32 pic_struct;
	u32 colour_space;
	u32 profile;