2009-12-09 18:38:49 +07:00
|
|
|
/*
|
2009-12-09 18:38:52 +07:00
|
|
|
* V4L2 sub-device
|
2009-12-09 18:38:49 +07:00
|
|
|
*
|
2009-12-09 18:38:52 +07:00
|
|
|
* Copyright (C) 2010 Nokia Corporation
|
2009-12-09 18:38:49 +07:00
|
|
|
*
|
2009-12-09 18:38:52 +07:00
|
|
|
* Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
|
|
* Sakari Ailus <sakari.ailus@iki.fi>
|
2009-12-09 18:38:49 +07:00
|
|
|
*
|
2009-12-09 18:38:52 +07:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
2009-12-09 18:38:49 +07:00
|
|
|
*
|
2009-12-09 18:38:52 +07:00
|
|
|
* 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.
|
2009-12-09 18:38:49 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/ioctl.h>
|
[media] v4l2-core: Use kvmalloc() for potentially big allocations
There are multiple places where arrays or otherwise variable sized
buffer are allocated through V4L2 core code, including things like
controls, memory pages, staging buffers for ioctls and so on. Such
allocations can potentially require an order > 0 allocation from the
page allocator, which is not guaranteed to be fulfilled and is likely to
fail on a system with severe memory fragmentation (e.g. a system with
very long uptime).
Since the memory being allocated is intended to be used by the CPU
exclusively, we can consider using vmalloc() as a fallback and this is
exactly what the recently merged kvmalloc() helpers do. A kmalloc() call
is still attempted, even for order > 0 allocations, but it is done
with __GFP_NORETRY and __GFP_NOWARN, with expectation of failing if
requested memory is not available instantly. Only then the vmalloc()
fallback is used. This should give us fast and more reliable allocations
even on systems with higher memory pressure and/or more fragmentation,
while still retaining the same performance level on systems not
suffering from such conditions.
While at it, replace explicit array size calculations on changed
allocations with kvmalloc_array().
Purposedly not touching videobuf1, as it is deprecated, has only few
users remaining and would rather be seen removed instead.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-19 10:53:43 +07:00
|
|
|
#include <linux/mm.h>
|
2010-03-03 22:49:38 +07:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/types.h>
|
2009-12-09 18:38:49 +07:00
|
|
|
#include <linux/videodev2.h>
|
2011-08-02 02:26:38 +07:00
|
|
|
#include <linux/export.h>
|
2009-12-09 18:38:49 +07:00
|
|
|
|
2009-12-09 18:39:54 +07:00
|
|
|
#include <media/v4l2-ctrls.h>
|
2009-12-09 18:38:49 +07:00
|
|
|
#include <media/v4l2-device.h>
|
|
|
|
#include <media/v4l2-ioctl.h>
|
2010-03-03 22:49:38 +07:00
|
|
|
#include <media/v4l2-fh.h>
|
|
|
|
#include <media/v4l2-event.h>
|
2009-12-09 18:38:49 +07:00
|
|
|
|
2010-05-21 16:04:24 +07:00
|
|
|
static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
2015-04-25 06:06:31 +07:00
|
|
|
if (sd->entity.num_pads) {
|
|
|
|
fh->pad = v4l2_subdev_alloc_pad_config(sd);
|
|
|
|
if (fh->pad == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2010-05-21 16:04:24 +07:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subdev_fh_free(struct v4l2_subdev_fh *fh)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
2015-04-25 06:06:31 +07:00
|
|
|
v4l2_subdev_free_pad_config(fh->pad);
|
2011-10-15 00:14:26 +07:00
|
|
|
fh->pad = NULL;
|
2010-05-21 16:04:24 +07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
static int subdev_open(struct file *file)
|
|
|
|
{
|
2010-03-03 22:49:38 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
|
2010-05-21 16:04:24 +07:00
|
|
|
struct v4l2_subdev_fh *subdev_fh;
|
2009-12-09 18:40:08 +07:00
|
|
|
#if defined(CONFIG_MEDIA_CONTROLLER)
|
2010-08-02 05:05:09 +07:00
|
|
|
struct media_entity *entity = NULL;
|
2009-12-09 18:40:08 +07:00
|
|
|
#endif
|
2010-03-03 22:49:38 +07:00
|
|
|
int ret;
|
|
|
|
|
2010-05-21 16:04:24 +07:00
|
|
|
subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL);
|
|
|
|
if (subdev_fh == NULL)
|
|
|
|
return -ENOMEM;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
2010-05-21 16:04:24 +07:00
|
|
|
ret = subdev_fh_init(subdev_fh, sd);
|
|
|
|
if (ret) {
|
|
|
|
kfree(subdev_fh);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-06-14 03:44:42 +07:00
|
|
|
v4l2_fh_init(&subdev_fh->vfh, vdev);
|
2010-05-21 16:04:24 +07:00
|
|
|
v4l2_fh_add(&subdev_fh->vfh);
|
|
|
|
file->private_data = &subdev_fh->vfh;
|
2009-12-09 18:40:08 +07:00
|
|
|
#if defined(CONFIG_MEDIA_CONTROLLER)
|
|
|
|
if (sd->v4l2_dev->mdev) {
|
|
|
|
entity = media_entity_get(&sd->entity);
|
|
|
|
if (!entity) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2010-05-21 16:04:24 +07:00
|
|
|
|
2010-08-02 05:05:09 +07:00
|
|
|
if (sd->internal_ops && sd->internal_ops->open) {
|
|
|
|
ret = sd->internal_ops->open(sd, subdev_fh);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
return 0;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
err:
|
2010-08-02 05:05:09 +07:00
|
|
|
#if defined(CONFIG_MEDIA_CONTROLLER)
|
2015-02-03 21:27:38 +07:00
|
|
|
media_entity_put(entity);
|
2010-08-02 05:05:09 +07:00
|
|
|
#endif
|
2010-05-21 16:04:24 +07:00
|
|
|
v4l2_fh_del(&subdev_fh->vfh);
|
|
|
|
v4l2_fh_exit(&subdev_fh->vfh);
|
|
|
|
subdev_fh_free(subdev_fh);
|
|
|
|
kfree(subdev_fh);
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
return ret;
|
2009-12-09 18:38:49 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int subdev_close(struct file *file)
|
|
|
|
{
|
2009-12-09 18:40:08 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
|
2010-03-03 22:49:38 +07:00
|
|
|
struct v4l2_fh *vfh = file->private_data;
|
2010-05-21 16:04:24 +07:00
|
|
|
struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
|
2010-03-03 22:49:38 +07:00
|
|
|
|
2010-08-02 05:05:09 +07:00
|
|
|
if (sd->internal_ops && sd->internal_ops->close)
|
|
|
|
sd->internal_ops->close(sd, subdev_fh);
|
2009-12-09 18:40:08 +07:00
|
|
|
#if defined(CONFIG_MEDIA_CONTROLLER)
|
|
|
|
if (sd->v4l2_dev->mdev)
|
|
|
|
media_entity_put(&sd->entity);
|
|
|
|
#endif
|
2010-05-21 16:04:24 +07:00
|
|
|
v4l2_fh_del(vfh);
|
|
|
|
v4l2_fh_exit(vfh);
|
|
|
|
subdev_fh_free(subdev_fh);
|
|
|
|
kfree(subdev_fh);
|
|
|
|
file->private_data = NULL;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-22 11:40:00 +07:00
|
|
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
2014-06-04 18:22:03 +07:00
|
|
|
static int check_format(struct v4l2_subdev *sd,
|
|
|
|
struct v4l2_subdev_format *format)
|
|
|
|
{
|
|
|
|
if (format->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
format->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (format->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int check_crop(struct v4l2_subdev *sd, struct v4l2_subdev_crop *crop)
|
|
|
|
{
|
|
|
|
if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (crop->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int check_selection(struct v4l2_subdev *sd,
|
|
|
|
struct v4l2_subdev_selection *sel)
|
|
|
|
{
|
|
|
|
if (sel->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (sel->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int check_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid)
|
|
|
|
{
|
|
|
|
if (edid->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (edid->blocks && edid->edid == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-07-22 11:40:00 +07:00
|
|
|
#endif
|
2014-06-04 18:22:03 +07:00
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
|
|
|
|
{
|
2009-12-09 18:39:54 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
|
2010-05-21 16:04:24 +07:00
|
|
|
struct v4l2_fh *vfh = file->private_data;
|
2010-03-16 06:26:04 +07:00
|
|
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
|
|
|
struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
|
2014-06-04 18:22:03 +07:00
|
|
|
int rval;
|
2014-07-22 11:40:00 +07:00
|
|
|
#endif
|
2009-12-09 18:39:54 +07:00
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
switch (cmd) {
|
2009-12-09 18:39:54 +07:00
|
|
|
case VIDIOC_QUERYCTRL:
|
2018-02-02 20:05:23 +07:00
|
|
|
/*
|
|
|
|
* TODO: this really should be folded into v4l2_queryctrl (this
|
|
|
|
* currently returns -EINVAL for NULL control handlers).
|
|
|
|
* However, v4l2_queryctrl() is still called directly by
|
|
|
|
* drivers as well and until that has been addressed I believe
|
|
|
|
* it is safer to do the check here. The same is true for the
|
|
|
|
* other control ioctls below.
|
|
|
|
*/
|
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-05-25 18:52:13 +07:00
|
|
|
return v4l2_queryctrl(vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
2014-06-10 14:22:06 +07:00
|
|
|
case VIDIOC_QUERY_EXT_CTRL:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2014-06-10 14:22:06 +07:00
|
|
|
return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);
|
|
|
|
|
2009-12-09 18:39:54 +07:00
|
|
|
case VIDIOC_QUERYMENU:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-05-25 18:52:13 +07:00
|
|
|
return v4l2_querymenu(vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
|
|
|
case VIDIOC_G_CTRL:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-05-25 18:52:13 +07:00
|
|
|
return v4l2_g_ctrl(vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
|
|
|
case VIDIOC_S_CTRL:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-06-07 16:47:18 +07:00
|
|
|
return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
|
|
|
case VIDIOC_G_EXT_CTRLS:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-05-25 18:52:13 +07:00
|
|
|
return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
|
|
|
case VIDIOC_S_EXT_CTRLS:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-06-07 16:47:18 +07:00
|
|
|
return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
|
|
|
case VIDIOC_TRY_EXT_CTRLS:
|
2018-02-02 20:05:23 +07:00
|
|
|
if (!vfh->ctrl_handler)
|
|
|
|
return -ENOTTY;
|
2011-05-25 18:52:13 +07:00
|
|
|
return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);
|
2009-12-09 18:39:54 +07:00
|
|
|
|
2010-03-03 22:49:38 +07:00
|
|
|
case VIDIOC_DQEVENT:
|
|
|
|
if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
|
2010-05-21 16:04:24 +07:00
|
|
|
return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
case VIDIOC_SUBSCRIBE_EVENT:
|
2010-05-21 16:04:24 +07:00
|
|
|
return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
case VIDIOC_UNSUBSCRIBE_EVENT:
|
2010-05-21 16:04:24 +07:00
|
|
|
return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);
|
2011-09-19 12:04:56 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
|
|
case VIDIOC_DBG_G_REGISTER:
|
|
|
|
{
|
|
|
|
struct v4l2_dbg_register *p = arg;
|
|
|
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
return v4l2_subdev_call(sd, core, g_register, p);
|
|
|
|
}
|
|
|
|
case VIDIOC_DBG_S_REGISTER:
|
|
|
|
{
|
|
|
|
struct v4l2_dbg_register *p = arg;
|
|
|
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN))
|
|
|
|
return -EPERM;
|
|
|
|
return v4l2_subdev_call(sd, core, s_register, p);
|
|
|
|
}
|
2018-02-03 20:24:44 +07:00
|
|
|
case VIDIOC_DBG_G_CHIP_INFO:
|
|
|
|
{
|
|
|
|
struct v4l2_dbg_chip_info *p = arg;
|
|
|
|
|
|
|
|
if (p->match.type != V4L2_CHIP_MATCH_SUBDEV || p->match.addr)
|
|
|
|
return -EINVAL;
|
|
|
|
if (sd->ops->core && sd->ops->core->s_register)
|
|
|
|
p->flags |= V4L2_CHIP_FL_WRITABLE;
|
|
|
|
if (sd->ops->core && sd->ops->core->g_register)
|
|
|
|
p->flags |= V4L2_CHIP_FL_READABLE;
|
|
|
|
strlcpy(p->name, sd->name, sizeof(p->name));
|
|
|
|
return 0;
|
|
|
|
}
|
2011-09-19 12:04:56 +07:00
|
|
|
#endif
|
2011-10-01 21:13:59 +07:00
|
|
|
|
2012-02-02 18:26:20 +07:00
|
|
|
case VIDIOC_LOG_STATUS: {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pr_info("%s: ================= START STATUS =================\n",
|
|
|
|
sd->name);
|
|
|
|
ret = v4l2_subdev_call(sd, core, log_status);
|
|
|
|
pr_info("%s: ================== END STATUS ==================\n",
|
|
|
|
sd->name);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-10-01 21:13:59 +07:00
|
|
|
|
2010-03-16 06:26:04 +07:00
|
|
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
|
|
|
case VIDIOC_SUBDEV_G_FMT: {
|
|
|
|
struct v4l2_subdev_format *format = arg;
|
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_format(sd, format);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2010-03-16 06:26:04 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(format->reserved, 0, sizeof(format->reserved));
|
|
|
|
memset(format->format.reserved, 0, sizeof(format->format.reserved));
|
2015-03-04 16:47:54 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
|
2010-03-16 06:26:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_S_FMT: {
|
|
|
|
struct v4l2_subdev_format *format = arg;
|
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_format(sd, format);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(format->reserved, 0, sizeof(format->reserved));
|
|
|
|
memset(format->format.reserved, 0, sizeof(format->format.reserved));
|
2015-03-04 16:47:54 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
|
2010-03-16 06:26:04 +07:00
|
|
|
}
|
|
|
|
|
2010-06-23 15:03:42 +07:00
|
|
|
case VIDIOC_SUBDEV_G_CROP: {
|
|
|
|
struct v4l2_subdev_crop *crop = arg;
|
2011-11-15 01:30:24 +07:00
|
|
|
struct v4l2_subdev_selection sel;
|
2010-06-23 15:03:42 +07:00
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_crop(sd, crop);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2010-06-23 15:03:42 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(crop->reserved, 0, sizeof(crop->reserved));
|
2011-11-15 01:30:24 +07:00
|
|
|
memset(&sel, 0, sizeof(sel));
|
|
|
|
sel.which = crop->which;
|
|
|
|
sel.pad = crop->pad;
|
2012-05-18 19:31:18 +07:00
|
|
|
sel.target = V4L2_SEL_TGT_CROP;
|
2011-11-15 01:30:24 +07:00
|
|
|
|
|
|
|
rval = v4l2_subdev_call(
|
2015-03-04 16:47:54 +07:00
|
|
|
sd, pad, get_selection, subdev_fh->pad, &sel);
|
2011-11-15 01:30:24 +07:00
|
|
|
|
|
|
|
crop->rect = sel.r;
|
|
|
|
|
|
|
|
return rval;
|
2010-06-23 15:03:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_S_CROP: {
|
|
|
|
struct v4l2_subdev_crop *crop = arg;
|
2011-11-15 01:30:24 +07:00
|
|
|
struct v4l2_subdev_selection sel;
|
2010-06-23 15:03:42 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(crop->reserved, 0, sizeof(crop->reserved));
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_crop(sd, crop);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2010-06-23 15:03:42 +07:00
|
|
|
|
2011-11-15 01:30:24 +07:00
|
|
|
memset(&sel, 0, sizeof(sel));
|
|
|
|
sel.which = crop->which;
|
|
|
|
sel.pad = crop->pad;
|
2012-05-18 19:31:18 +07:00
|
|
|
sel.target = V4L2_SEL_TGT_CROP;
|
2011-11-15 01:30:24 +07:00
|
|
|
sel.r = crop->rect;
|
|
|
|
|
|
|
|
rval = v4l2_subdev_call(
|
2015-03-04 16:47:54 +07:00
|
|
|
sd, pad, set_selection, subdev_fh->pad, &sel);
|
2011-11-15 01:30:24 +07:00
|
|
|
|
|
|
|
crop->rect = sel.r;
|
|
|
|
|
|
|
|
return rval;
|
2010-06-23 15:03:42 +07:00
|
|
|
}
|
|
|
|
|
2010-03-16 06:26:04 +07:00
|
|
|
case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
|
|
|
|
struct v4l2_subdev_mbus_code_enum *code = arg;
|
|
|
|
|
2015-03-04 16:47:56 +07:00
|
|
|
if (code->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
code->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-03-16 06:26:04 +07:00
|
|
|
if (code->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(code->reserved, 0, sizeof(code->reserved));
|
2015-03-04 16:47:54 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
|
2010-03-16 06:26:04 +07:00
|
|
|
code);
|
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
|
|
|
|
struct v4l2_subdev_frame_size_enum *fse = arg;
|
|
|
|
|
2015-03-04 16:47:56 +07:00
|
|
|
if (fse->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
fse->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-03-16 06:26:04 +07:00
|
|
|
if (fse->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(fse->reserved, 0, sizeof(fse->reserved));
|
2015-03-04 16:47:54 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
|
2010-03-16 06:26:04 +07:00
|
|
|
fse);
|
|
|
|
}
|
2010-05-05 21:38:35 +07:00
|
|
|
|
2013-04-22 20:24:51 +07:00
|
|
|
case VIDIOC_SUBDEV_G_FRAME_INTERVAL: {
|
|
|
|
struct v4l2_subdev_frame_interval *fi = arg;
|
|
|
|
|
|
|
|
if (fi->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(fi->reserved, 0, sizeof(fi->reserved));
|
2010-05-05 21:38:35 +07:00
|
|
|
return v4l2_subdev_call(sd, video, g_frame_interval, arg);
|
2013-04-22 20:24:51 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_S_FRAME_INTERVAL: {
|
|
|
|
struct v4l2_subdev_frame_interval *fi = arg;
|
|
|
|
|
|
|
|
if (fi->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
2010-05-05 21:38:35 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(fi->reserved, 0, sizeof(fi->reserved));
|
2010-05-05 21:38:35 +07:00
|
|
|
return v4l2_subdev_call(sd, video, s_frame_interval, arg);
|
2013-04-22 20:24:51 +07:00
|
|
|
}
|
2010-05-05 21:38:35 +07:00
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
|
|
|
|
struct v4l2_subdev_frame_interval_enum *fie = arg;
|
|
|
|
|
2015-03-04 16:47:56 +07:00
|
|
|
if (fie->which != V4L2_SUBDEV_FORMAT_TRY &&
|
|
|
|
fie->which != V4L2_SUBDEV_FORMAT_ACTIVE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-05-05 21:38:35 +07:00
|
|
|
if (fie->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(fie->reserved, 0, sizeof(fie->reserved));
|
2015-03-04 16:47:54 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
|
2010-05-05 21:38:35 +07:00
|
|
|
fie);
|
|
|
|
}
|
2011-10-15 00:14:26 +07:00
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_G_SELECTION: {
|
|
|
|
struct v4l2_subdev_selection *sel = arg;
|
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_selection(sd, sel);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2011-10-15 00:14:26 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(sel->reserved, 0, sizeof(sel->reserved));
|
2011-10-15 00:14:26 +07:00
|
|
|
return v4l2_subdev_call(
|
2015-03-04 16:47:54 +07:00
|
|
|
sd, pad, get_selection, subdev_fh->pad, sel);
|
2011-10-15 00:14:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_S_SELECTION: {
|
|
|
|
struct v4l2_subdev_selection *sel = arg;
|
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_selection(sd, sel);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2011-10-15 00:14:26 +07:00
|
|
|
|
2018-02-03 20:20:21 +07:00
|
|
|
memset(sel->reserved, 0, sizeof(sel->reserved));
|
2011-10-15 00:14:26 +07:00
|
|
|
return v4l2_subdev_call(
|
2015-03-04 16:47:54 +07:00
|
|
|
sd, pad, set_selection, subdev_fh->pad, sel);
|
2011-10-15 00:14:26 +07:00
|
|
|
}
|
2012-08-10 16:07:12 +07:00
|
|
|
|
2014-01-29 20:07:13 +07:00
|
|
|
case VIDIOC_G_EDID: {
|
|
|
|
struct v4l2_subdev_edid *edid = arg;
|
2012-08-10 16:07:12 +07:00
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_edid(sd, edid);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2014-01-29 20:07:13 +07:00
|
|
|
|
|
|
|
return v4l2_subdev_call(sd, pad, get_edid, edid);
|
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_S_EDID: {
|
|
|
|
struct v4l2_subdev_edid *edid = arg;
|
|
|
|
|
2014-06-04 18:22:03 +07:00
|
|
|
rval = check_edid(sd, edid);
|
|
|
|
if (rval)
|
|
|
|
return rval;
|
2014-01-29 20:07:13 +07:00
|
|
|
|
|
|
|
return v4l2_subdev_call(sd, pad, set_edid, edid);
|
|
|
|
}
|
2014-01-29 20:07:13 +07:00
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
|
|
|
|
struct v4l2_dv_timings_cap *cap = arg;
|
|
|
|
|
|
|
|
if (cap->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
|
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_ENUM_DV_TIMINGS: {
|
|
|
|
struct v4l2_enum_dv_timings *dvt = arg;
|
|
|
|
|
|
|
|
if (dvt->pad >= sd->entity.num_pads)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return v4l2_subdev_call(sd, pad, enum_dv_timings, dvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_QUERY_DV_TIMINGS:
|
|
|
|
return v4l2_subdev_call(sd, video, query_dv_timings, arg);
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_G_DV_TIMINGS:
|
|
|
|
return v4l2_subdev_call(sd, video, g_dv_timings, arg);
|
|
|
|
|
|
|
|
case VIDIOC_SUBDEV_S_DV_TIMINGS:
|
|
|
|
return v4l2_subdev_call(sd, video, s_dv_timings, arg);
|
2010-03-16 06:26:04 +07:00
|
|
|
#endif
|
2009-12-09 18:38:49 +07:00
|
|
|
default:
|
2010-02-26 22:23:10 +07:00
|
|
|
return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
|
2009-12-09 18:38:49 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-11 16:32:24 +07:00
|
|
|
static long subdev_do_ioctl_lock(struct file *file, unsigned int cmd, void *arg)
|
|
|
|
{
|
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct mutex *lock = vdev->lock;
|
|
|
|
long ret = -ENODEV;
|
|
|
|
|
|
|
|
if (lock && mutex_lock_interruptible(lock))
|
|
|
|
return -ERESTARTSYS;
|
|
|
|
if (video_is_registered(vdev))
|
|
|
|
ret = subdev_do_ioctl(file, cmd, arg);
|
|
|
|
if (lock)
|
|
|
|
mutex_unlock(lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
static long subdev_ioctl(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
2018-05-11 16:32:24 +07:00
|
|
|
return video_usercopy(file, cmd, arg, subdev_do_ioctl_lock);
|
2009-12-09 18:38:49 +07:00
|
|
|
}
|
|
|
|
|
2014-02-10 18:08:44 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
static long subdev_compat_ioctl32(struct file *file, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
|
|
|
|
|
|
|
|
return v4l2_subdev_call(sd, core, compat_ioctl32, cmd, arg);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-03 14:02:56 +07:00
|
|
|
static __poll_t subdev_poll(struct file *file, poll_table *wait)
|
2010-03-03 22:49:38 +07:00
|
|
|
{
|
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
|
|
|
|
struct v4l2_fh *fh = file->private_data;
|
|
|
|
|
|
|
|
if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
|
2018-02-12 05:34:03 +07:00
|
|
|
return EPOLLERR;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
2011-06-14 03:44:42 +07:00
|
|
|
poll_wait(file, &fh->wait, wait);
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
if (v4l2_event_pending(fh))
|
2018-02-12 05:34:03 +07:00
|
|
|
return EPOLLPRI;
|
2010-03-03 22:49:38 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-09 18:38:49 +07:00
|
|
|
const struct v4l2_file_operations v4l2_subdev_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = subdev_open,
|
|
|
|
.unlocked_ioctl = subdev_ioctl,
|
2014-02-10 18:08:44 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
.compat_ioctl32 = subdev_compat_ioctl32,
|
|
|
|
#endif
|
2009-12-09 18:38:49 +07:00
|
|
|
.release = subdev_close,
|
2010-03-03 22:49:38 +07:00
|
|
|
.poll = subdev_poll,
|
2009-12-09 18:38:49 +07:00
|
|
|
};
|
2009-12-09 18:38:52 +07:00
|
|
|
|
2011-10-11 03:01:25 +07:00
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
|
|
|
|
struct media_link *link,
|
|
|
|
struct v4l2_subdev_format *source_fmt,
|
|
|
|
struct v4l2_subdev_format *sink_fmt)
|
|
|
|
{
|
2014-05-19 21:36:23 +07:00
|
|
|
/* The width, height and code must match. */
|
2011-10-11 03:01:25 +07:00
|
|
|
if (source_fmt->format.width != sink_fmt->format.width
|
|
|
|
|| source_fmt->format.height != sink_fmt->format.height
|
|
|
|
|| source_fmt->format.code != sink_fmt->format.code)
|
2015-06-29 02:14:10 +07:00
|
|
|
return -EPIPE;
|
2011-10-11 03:01:25 +07:00
|
|
|
|
2014-05-19 21:36:23 +07:00
|
|
|
/* The field order must match, or the sink field order must be NONE
|
|
|
|
* to support interlaced hardware connected to bridges that support
|
|
|
|
* progressive formats only.
|
|
|
|
*/
|
|
|
|
if (source_fmt->format.field != sink_fmt->format.field &&
|
|
|
|
sink_fmt->format.field != V4L2_FIELD_NONE)
|
2015-06-29 02:14:10 +07:00
|
|
|
return -EPIPE;
|
2014-05-19 21:36:23 +07:00
|
|
|
|
2011-10-11 03:01:25 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate_default);
|
|
|
|
|
|
|
|
static int
|
|
|
|
v4l2_subdev_link_validate_get_format(struct media_pad *pad,
|
|
|
|
struct v4l2_subdev_format *fmt)
|
|
|
|
{
|
2015-05-08 08:12:32 +07:00
|
|
|
if (is_media_entity_v4l2_subdev(pad->entity)) {
|
2012-10-21 03:47:22 +07:00
|
|
|
struct v4l2_subdev *sd =
|
|
|
|
media_entity_to_v4l2_subdev(pad->entity);
|
|
|
|
|
2011-10-11 03:01:25 +07:00
|
|
|
fmt->which = V4L2_SUBDEV_FORMAT_ACTIVE;
|
|
|
|
fmt->pad = pad->index;
|
2012-10-21 03:47:22 +07:00
|
|
|
return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt);
|
2011-10-11 03:01:25 +07:00
|
|
|
}
|
2012-10-21 03:47:22 +07:00
|
|
|
|
2015-12-11 02:25:41 +07:00
|
|
|
WARN(pad->entity->function != MEDIA_ENT_F_IO_V4L,
|
2012-10-21 03:47:22 +07:00
|
|
|
"Driver bug! Wrong media entity type 0x%08x, entity %s\n",
|
2015-09-06 19:33:39 +07:00
|
|
|
pad->entity->function, pad->entity->name);
|
2012-10-21 03:47:22 +07:00
|
|
|
|
|
|
|
return -EINVAL;
|
2011-10-11 03:01:25 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int v4l2_subdev_link_validate(struct media_link *link)
|
|
|
|
{
|
|
|
|
struct v4l2_subdev *sink;
|
|
|
|
struct v4l2_subdev_format sink_fmt, source_fmt;
|
|
|
|
int rval;
|
|
|
|
|
|
|
|
rval = v4l2_subdev_link_validate_get_format(
|
|
|
|
link->source, &source_fmt);
|
|
|
|
if (rval < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rval = v4l2_subdev_link_validate_get_format(
|
|
|
|
link->sink, &sink_fmt);
|
|
|
|
if (rval < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
sink = media_entity_to_v4l2_subdev(link->sink->entity);
|
|
|
|
|
|
|
|
rval = v4l2_subdev_call(sink, pad, link_validate, link,
|
|
|
|
&source_fmt, &sink_fmt);
|
|
|
|
if (rval != -ENOIOCTLCMD)
|
|
|
|
return rval;
|
|
|
|
|
|
|
|
return v4l2_subdev_link_validate_default(
|
|
|
|
sink, link, &source_fmt, &sink_fmt);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
|
2015-04-25 06:06:31 +07:00
|
|
|
|
|
|
|
struct v4l2_subdev_pad_config *
|
|
|
|
v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
|
|
|
|
{
|
|
|
|
struct v4l2_subdev_pad_config *cfg;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!sd->entity.num_pads)
|
|
|
|
return NULL;
|
|
|
|
|
[media] v4l2-core: Use kvmalloc() for potentially big allocations
There are multiple places where arrays or otherwise variable sized
buffer are allocated through V4L2 core code, including things like
controls, memory pages, staging buffers for ioctls and so on. Such
allocations can potentially require an order > 0 allocation from the
page allocator, which is not guaranteed to be fulfilled and is likely to
fail on a system with severe memory fragmentation (e.g. a system with
very long uptime).
Since the memory being allocated is intended to be used by the CPU
exclusively, we can consider using vmalloc() as a fallback and this is
exactly what the recently merged kvmalloc() helpers do. A kmalloc() call
is still attempted, even for order > 0 allocations, but it is done
with __GFP_NORETRY and __GFP_NOWARN, with expectation of failing if
requested memory is not available instantly. Only then the vmalloc()
fallback is used. This should give us fast and more reliable allocations
even on systems with higher memory pressure and/or more fragmentation,
while still retaining the same performance level on systems not
suffering from such conditions.
While at it, replace explicit array size calculations on changed
allocations with kvmalloc_array().
Purposedly not touching videobuf1, as it is deprecated, has only few
users remaining and would rather be seen removed instead.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-19 10:53:43 +07:00
|
|
|
cfg = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg),
|
|
|
|
GFP_KERNEL | __GFP_ZERO);
|
2015-04-25 06:06:31 +07:00
|
|
|
if (!cfg)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = v4l2_subdev_call(sd, pad, init_cfg, cfg);
|
|
|
|
if (ret < 0 && ret != -ENOIOCTLCMD) {
|
[media] v4l2-core: Use kvmalloc() for potentially big allocations
There are multiple places where arrays or otherwise variable sized
buffer are allocated through V4L2 core code, including things like
controls, memory pages, staging buffers for ioctls and so on. Such
allocations can potentially require an order > 0 allocation from the
page allocator, which is not guaranteed to be fulfilled and is likely to
fail on a system with severe memory fragmentation (e.g. a system with
very long uptime).
Since the memory being allocated is intended to be used by the CPU
exclusively, we can consider using vmalloc() as a fallback and this is
exactly what the recently merged kvmalloc() helpers do. A kmalloc() call
is still attempted, even for order > 0 allocations, but it is done
with __GFP_NORETRY and __GFP_NOWARN, with expectation of failing if
requested memory is not available instantly. Only then the vmalloc()
fallback is used. This should give us fast and more reliable allocations
even on systems with higher memory pressure and/or more fragmentation,
while still retaining the same performance level on systems not
suffering from such conditions.
While at it, replace explicit array size calculations on changed
allocations with kvmalloc_array().
Purposedly not touching videobuf1, as it is deprecated, has only few
users remaining and would rather be seen removed instead.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-19 10:53:43 +07:00
|
|
|
kvfree(cfg);
|
2015-04-25 06:06:31 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cfg;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
|
|
|
|
|
|
|
|
void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
|
|
|
|
{
|
[media] v4l2-core: Use kvmalloc() for potentially big allocations
There are multiple places where arrays or otherwise variable sized
buffer are allocated through V4L2 core code, including things like
controls, memory pages, staging buffers for ioctls and so on. Such
allocations can potentially require an order > 0 allocation from the
page allocator, which is not guaranteed to be fulfilled and is likely to
fail on a system with severe memory fragmentation (e.g. a system with
very long uptime).
Since the memory being allocated is intended to be used by the CPU
exclusively, we can consider using vmalloc() as a fallback and this is
exactly what the recently merged kvmalloc() helpers do. A kmalloc() call
is still attempted, even for order > 0 allocations, but it is done
with __GFP_NORETRY and __GFP_NOWARN, with expectation of failing if
requested memory is not available instantly. Only then the vmalloc()
fallback is used. This should give us fast and more reliable allocations
even on systems with higher memory pressure and/or more fragmentation,
while still retaining the same performance level on systems not
suffering from such conditions.
While at it, replace explicit array size calculations on changed
allocations with kvmalloc_array().
Purposedly not touching videobuf1, as it is deprecated, has only few
users remaining and would rather be seen removed instead.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-19 10:53:43 +07:00
|
|
|
kvfree(cfg);
|
2015-04-25 06:06:31 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(v4l2_subdev_free_pad_config);
|
2011-10-11 03:01:25 +07:00
|
|
|
#endif /* CONFIG_MEDIA_CONTROLLER */
|
|
|
|
|
2009-12-09 18:38:52 +07:00
|
|
|
void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
|
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&sd->list);
|
|
|
|
BUG_ON(!ops);
|
|
|
|
sd->ops = ops;
|
|
|
|
sd->v4l2_dev = NULL;
|
|
|
|
sd->flags = 0;
|
|
|
|
sd->name[0] = '\0';
|
|
|
|
sd->grp_id = 0;
|
|
|
|
sd->dev_priv = NULL;
|
|
|
|
sd->host_priv = NULL;
|
2009-12-09 18:40:08 +07:00
|
|
|
#if defined(CONFIG_MEDIA_CONTROLLER)
|
|
|
|
sd->entity.name = sd->name;
|
2016-02-29 18:45:44 +07:00
|
|
|
sd->entity.obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV;
|
2015-12-11 02:25:41 +07:00
|
|
|
sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
|
2009-12-09 18:40:08 +07:00
|
|
|
#endif
|
2009-12-09 18:38:52 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(v4l2_subdev_init);
|
2015-06-24 23:50:29 +07:00
|
|
|
|
|
|
|
void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
|
|
|
|
const struct v4l2_event *ev)
|
|
|
|
{
|
|
|
|
v4l2_event_queue(sd->devnode, ev);
|
|
|
|
v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT, (void *)ev);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event);
|