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

Commit 69c24a90 authored by Animesh Kishore's avatar Animesh Kishore
Browse files

msm: sde: Cache capture fence descriptor



Generate and cache fence file descriptor. Multiple
ioctl calls return cached value.

Change-Id: I60d1b46b04007899c9ed983aafc5d0dd3e13312a
Depends-On: Ic83d93fd3c7f404774007065df02b402adbf80af
Signed-off-by: default avatarAnimesh Kishore <animeshk@codeaurora.org>
parent be58516a
Loading
Loading
Loading
Loading
+28 −7
Original line number Diff line number Diff line
@@ -1785,6 +1785,7 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,
	struct msm_sde_rotator_fence *fence = arg;
	struct msm_sde_rotator_comp_ratio *comp_ratio = arg;
	struct sde_rotator_vbinfo *vbinfo;
	int ret;

	switch (cmd) {
	case VIDIOC_S_SDE_ROTATOR_FENCE:
@@ -1843,19 +1844,39 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,

		vbinfo = &ctx->vbinfo_cap[fence->index];

		if (vbinfo->fence == NULL) {
			vbinfo->fd = -1;
		} else {
			vbinfo->fd =
				sde_rotator_get_sync_fence_fd(vbinfo->fence);
			if (vbinfo->fd < 0) {
		if (!vbinfo)
			return -EINVAL;

		if (vbinfo->fence) {
			ret = sde_rotator_get_sync_fence_fd(vbinfo->fence);
			if (ret < 0) {
				SDEDEV_ERR(rot_dev->dev,
					"fail get fence fd s:%d\n",
					ctx->session_id);
				return vbinfo->fd;
				return ret;
			}

			/*
			 * Loose any reference to sync fence once we pass
			 * it to user. Driver does not clean up user
			 * unclosed fence descriptors.
			 */
			vbinfo->fence = NULL;

			/*
			 * Cache fence descriptor in case user calls this
			 * ioctl multiple times. Cached value would be stale
			 * if user duplicated and closed old descriptor.
			 */
			vbinfo->fd = ret;
		} else if (!sde_rotator_get_fd_sync_fence(vbinfo->fd)) {
			/*
			 * User has closed cached fence descriptor.
			 * Invalidate descriptor cache.
			 */
			vbinfo->fd = -1;
		}

		fence->fd = vbinfo->fd;

		SDEDEV_DBG(rot_dev->dev,