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

Commit 6af3bb3b authored by Maheshwar Ajja's avatar Maheshwar Ajja Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Add v4l2 private ioctl support



Add v4l2 private ioctl support to send private data
and commands to driver to utilize video hardware
features which are not supported by v4l2 framework.

Change-Id: I7f3a183aad0ad923a03417a0340c316fd1e9c671
Signed-off-by: default avatarMaheshwar Ajja <majja@codeaurora.org>
parent f52bab74
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
ccflags-y += -I$(srctree)/drivers/media/platform/msm/vidc/

msm-vidc-objs := msm_v4l2_vidc.o \
                                msm_v4l2_private.o \
				msm_vidc_platform.o \
                                msm_vidc_common.o \
                                msm_vidc.o \
+88 −0
Original line number Diff line number Diff line
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include "msm_v4l2_private.h"

static int convert_from_user(struct msm_vidc_arg *kp, unsigned long arg)
{
	int rc = 0;
	struct msm_vidc_arg __user *up = compat_ptr(arg);

	if (get_user(kp->type, &up->type))
		return -EFAULT;

	switch (kp->type) {
	default:
		dprintk(VIDC_ERR, "%s: unknown cmd type 0x%x\n",
			__func__, kp->type);
		rc = -EINVAL;
		break;
	}

	return rc;
}

static int convert_to_user(struct msm_vidc_arg *kp, unsigned long arg)
{
	int rc = 0;
	struct msm_vidc_arg __user *up = compat_ptr(arg);

	if (put_user(kp->type, &up->type))
		return -EFAULT;

	switch (kp->type) {
	default:
		dprintk(VIDC_ERR, "%s: unknown cmd type 0x%x\n",
			__func__, kp->type);
		rc = -EINVAL;
		break;
	}

	return rc;
}

long msm_v4l2_private(struct file *filp, unsigned int cmd, unsigned long arg)
{
	int rc;
	struct msm_vidc_inst *inst;
	struct msm_vidc_arg karg;

	if (!filp || !filp->private_data) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
		return -EINVAL;
	}

	inst = container_of(filp->private_data, struct msm_vidc_inst,
			event_handler);
	memset(&karg, 0, sizeof(struct msm_vidc_arg));

	/*
	 * the arg points to user space memory and needs
	 * to be converted to kernel space before using it.
	 * Check do_video_ioctl() for more details.
	 */
	if (convert_from_user(&karg, arg))
		return -EFAULT;

	rc = msm_vidc_private((void *)inst, cmd, &karg);
	if (rc) {
		dprintk(VIDC_ERR, "%s: failed cmd type %x\n",
			__func__, karg.type);
		return -EINVAL;
	}

	if (convert_to_user(&karg, arg))
		return -EFAULT;

	return rc;
}
+22 −0
Original line number Diff line number Diff line
/* Copyright (c) 2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef _MSM_V4L2_PRIVATE_H_
#define _MSM_V4L2_PRIVATE_H_

#include <media/msm_vidc_private.h>
#include "msm_vidc_debug.h"

long msm_v4l2_private(struct file *file, unsigned int cmd, unsigned long arg);

#endif
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "msm_vidc_resources.h"
#include "venus_boot.h"
#include "vidc_hfi_api.h"
#include "msm_v4l2_private.h"

#define BASE_DEVICE_NUMBER 32

@@ -292,6 +293,7 @@ static const struct v4l2_file_operations msm_v4l2_vidc_fops = {
	.open = msm_v4l2_open,
	.release = msm_v4l2_close,
	.unlocked_ioctl = video_ioctl2,
	.compat_ioctl32 = msm_v4l2_private,
	.poll = msm_v4l2_poll,
};

+15 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,21 @@ int msm_vidc_dqevent(void *inst, struct v4l2_event *event)
}
EXPORT_SYMBOL(msm_vidc_dqevent);

int msm_vidc_private(void *vidc_inst, unsigned int cmd,
		struct msm_vidc_arg *arg)
{
	int rc = 0;
	struct msm_vidc_inst *inst = (struct msm_vidc_inst *)vidc_inst;

	if (!inst || !arg) {
		dprintk(VIDC_ERR, "%s: invalid args\n", __func__);
		return -EINVAL;
	}

	return rc;
}
EXPORT_SYMBOL(msm_vidc_private);

static bool msm_vidc_check_for_inst_overload(struct msm_vidc_core *core)
{
	u32 instance_count = 0;
Loading