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

Commit 360f01b0 authored by Alan Kwong's avatar Alan Kwong Committed by Narendra Muppalla
Browse files

msm: sde: move config validation earlier to stream on



Current configuration validation is performed when both
stream on is set and minimum buffers are queued. This is
too late for client application that queues buffer only in
commit phase. Since commit cannot fail, client application
cannot recover from configuration error. To support earlier
configuration validation in pre-commit phase, move configuration
validation to stream on state.

CRs-Fixed: 1102087
Change-Id: Id4541d7064d54e3bab8505c590cf624e58d111c1
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent 92c56f0e
Loading
Loading
Loading
Loading
+28 −13
Original line number Diff line number Diff line
@@ -416,23 +416,10 @@ static int sde_rotator_start_streaming(struct vb2_queue *q, unsigned int count)
{
	struct sde_rotator_ctx *ctx = vb2_get_drv_priv(q);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_rotation_config config;
	int ret;

	SDEDEV_DBG(rot_dev->dev, "start streaming s:%d t:%d\n",
			ctx->session_id, q->type);

	sde_rot_mgr_lock(rot_dev->mgr);
	sde_rotator_get_config_from_ctx(ctx, &config);
	ret = sde_rotator_session_config(rot_dev->mgr, ctx->private, &config);
	sde_rot_mgr_unlock(rot_dev->mgr);
	if (ret < 0) {
		SDEDEV_ERR(rot_dev->dev,
			"fail config in stream on s:%d t:%d r:%d\n",
			ctx->session_id, q->type, ret);
		return -EINVAL;
	}

	if (!IS_ERR_OR_NULL(ctx->request) ||
				atomic_read(&ctx->command_pending))
		SDEDEV_ERR(rot_dev->dev,
@@ -1501,11 +1488,39 @@ static int sde_rotator_streamon(struct file *file,
	void *fh, enum v4l2_buf_type buf_type)
{
	struct sde_rotator_ctx *ctx = sde_rotator_ctx_from_fh(fh);
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_rotation_config config;
	struct vb2_queue *vq;
	int ret;

	SDEDEV_DBG(ctx->rot_dev->dev, "stream on s:%d t:%d\n",
			ctx->session_id, buf_type);

	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
			buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT ?
			V4L2_BUF_TYPE_VIDEO_CAPTURE :
			V4L2_BUF_TYPE_VIDEO_OUTPUT);

	if (!vq) {
		SDEDEV_ERR(ctx->rot_dev->dev, "fail to get vq on s:%d t:%d\n",
				ctx->session_id, buf_type);
		return -EINVAL;
	}

	if (vb2_is_streaming(vq)) {
		sde_rot_mgr_lock(rot_dev->mgr);
		sde_rotator_get_config_from_ctx(ctx, &config);
		ret = sde_rotator_session_config(rot_dev->mgr, ctx->private,
				&config);
		sde_rot_mgr_unlock(rot_dev->mgr);
		if (ret < 0) {
			SDEDEV_ERR(rot_dev->dev,
				"fail config in stream on s:%d t:%d r:%d\n",
				ctx->session_id, buf_type, ret);
			return ret;
		}
	}

	ret = v4l2_m2m_streamon(file, ctx->fh.m2m_ctx, buf_type);
	if (ret < 0)
		SDEDEV_ERR(ctx->rot_dev->dev, "fail stream on s:%d t:%d\n",