From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, sakari.ailus@maxwell.research.nokia.com
Subject: Re: [RFC/PATCH 2/6] v4l: subdev: Add device node support
Date: Thu, 08 Jul 2010 10:51:33 -0300 [thread overview]
Message-ID: <4C35D7E5.60407@redhat.com> (raw)
In-Reply-To: <201007081408.50289.laurent.pinchart@ideasonboard.com>
Em 08-07-2010 09:08, Laurent Pinchart escreveu:
> Hi Mauro,
>
> On Wednesday 07 July 2010 22:53:40 Mauro Carvalho Chehab wrote:
>> Em 07-07-2010 16:44, Laurent Pinchart escreveu:
>>> On Wednesday 07 July 2010 16:58:01 Mauro Carvalho Chehab wrote:
>>>> Em 07-07-2010 08:53, Laurent Pinchart escreveu:
>>>>> Create a device node named subdevX for every registered subdev.
>>>>> As the device node is registered before the subdev core::s_config
>>>>> function is called, return -EGAIN on open until initialization
>>>>> completes.
>>>
>>> [snip]
>>>
>>>>> +static int subdev_open(struct file *file)
>>>>> +{
>>>>> + struct video_device *vdev = video_devdata(file);
>>>>> + struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
>>>>> +
>>>>> + if (!sd->initialized)
>>>>> + return -EAGAIN;
>>>>
>>>> Those internal interfaces should not be used on normal
>>>> devices/applications, as none of the existing drivers are tested or
>>>> supposed to properly work if an external program is touching on its
>>>>
>>>> internal interfaces. So, please add:
>>>> if (!capable(CAP_SYS_ADMIN))
>>>>
>>>> return -EPERM;
>>>
>>> As Hans pointed out, subdev device nodes should only be created if the
>>> subdev request it explicitly. I'll fix the patch accordingly. Existing
>>> subdevs will not have a device node by default anymore, so the
>>> CAP_SYS_ADMIN capability won't be required (new subdevs that explicitly
>>> ask for a device node are supposed to handle the calls properly,
>>> otherwise it's a bit pointless :-)).
>>
>> It should be not requested by the subdev, but by the bridge driver (or
>> maybe by both).
>>
>> On several drivers, the bridge is connected to more than one subdev, and
>> some changes need to go to both subdevs, in order to work. As the glue
>> logic is at the bridge driver, creating subdev interfaces will not make
>> sense on those devices.
>
> Agreed. I've added a flag that subdev drivers can set to request creation of a
> device node explicitly, and an argument to to v4l2_i2c_new_subdev_board and
> v4l2_spi_new_subdev to overwrite the flag. A device node will only be created
> if the flag is set by the subdev (meaning "I can support device nodes") and
> the flag is not forced to 0 by the bridge driver (meaning "I allow userspace
> to access the subdev directly).
OK.
> [snip]
>
>>>>> +static long subdev_ioctl(struct file *file, unsigned int cmd,
>>>>> + unsigned long arg)
>>>>> +{
>>>>> + return video_usercopy(file, cmd, arg, subdev_do_ioctl);
>>>>
>>>> This is a legacy call. Please, don't use it.
>>>
>>> What should I use instead then ? I need the functionality of
>>> video_usercopy. I could copy it to v4l2-subdev.c verbatim. As
>>> video_ioctl2 shares lots of code with video_usercopy I think
>>> video_usercopy should stay, and video_ioctl2 should use it.
>>
>> The bad thing of video_usercopy() is that it has a "compat" code, to fix
>> broken definitions of some iotls (see video_fix_command()), and that a few
>> drivers still use it, instead of video_ioctl2.
>
> video_ioctl2 has the same compat code.
Yes, in order to avoid breaking binary compatibility with files compiled against
the old videodev2.h header that used to declare some ioctls as:
#define VIDIOC_OVERLAY _IOWR('V', 14, int)
#define VIDIOC_S_PARM _IOW('V', 22, struct v4l2_streamparm)
#define VIDIOC_S_CTRL _IOW('V', 28, struct v4l2_control)
#define VIDIOC_G_AUDIO _IOWR('V', 33, struct v4l2_audio)
#define VIDIOC_G_AUDOUT _IOWR('V', 49, struct v4l2_audioout)
#define VIDIOC_CROPCAP _IOR('V', 58, struct v4l2_cropcap)
instead of:
#define VIDIOC_OVERLAY _IOW('V', 14, int)
#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
(basically, the old ioctl's were using the wrong _IO macros, preventing a generic
copy_from_user/copy_to_user code to work)
This doesn't make sense for subdev, as old binary-only applications will never
use the legacy ioctl definitions.
Probably, we can mark this legacy support for removal at
Documentation/feature-removal-schedule.txt, and remove
it on a latter version of the kernel. It seems that the old ioctl definitions are
before 2005 (before 2.6.12):
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1461) #define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1462) #define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm)
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1463) #define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control)
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1464) #define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio)
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1465) #define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout)
^1da177e (Linus Torvalds 2005-04-16 15:20:36 -0700 1466) #define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap)
>> For sure, we don't need the "compat" code for subdev interface. Also, as
>> time goes by, we'll eventually have different needs at the subdev interface,
>> as some types of ioctl's may be specific to subdevs and may require
>> different copy logic.
>
> We can change the logic then :-)
>
>> IMO, the better is to use the same logic inside the subdev stuff, of course
>> removing that "old ioctl" fix logic:
>>
>> #ifdef __OLD_VIDIOC_
>> cmd = video_fix_command(cmd);
>> #endif
>>
>> And replacing the call to:
>> err = func(file, cmd, parg);
>>
>> By the proper subdev handling.
>
> What about renaming video_usercopy to __video_usercopy, adding an argument to
> enable/disable the compat code, create a new video_usercopy that calls
> __video_usercopy with compat code enabled, have video_ioctl2 call
> __video_usercopy with compat code enabled, and having subdev_ioctl call
> __video_usercopy with compat code disabled ?
Seems good, but maybe the better is to put the call to video_fix_command() outside
the common function.
We may add also a printk for the video_usercopy wrapper printing that the
driver is using a legacy API call, and that this will be removed on a next kernel version.
Maybe this way, people will finally submit patches porting the last remaining drivers to
video_ioctl2.
I suspect, however, that we'll end by needing a subdev-specific version of __video_usercopy,
as we add new ioctls to subdev.
Cheers,
Mauro.
next prev parent reply other threads:[~2010-07-08 13:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-07 11:53 [RFC/PATCH 0/6] V4L2 subdev userspace API Laurent Pinchart
2010-07-07 11:53 ` [RFC/PATCH 1/6] v4l: subdev: Don't require core operations Laurent Pinchart
2010-07-07 12:21 ` Hans Verkuil
2010-07-07 14:05 ` Karicheri, Muralidharan
2010-07-07 11:53 ` [RFC/PATCH 2/6] v4l: subdev: Add device node support Laurent Pinchart
2010-07-07 12:30 ` Hans Verkuil
2010-07-07 12:53 ` Laurent Pinchart
2010-07-07 13:04 ` Hans Verkuil
2010-07-08 12:01 ` Laurent Pinchart
2010-07-08 12:34 ` Hans Verkuil
2010-07-07 12:43 ` Hans Verkuil
2010-07-07 14:00 ` Laurent Pinchart
2010-07-07 14:14 ` Karicheri, Muralidharan
2010-07-07 14:39 ` Sylwester Nawrocki
2010-07-07 15:08 ` Mauro Carvalho Chehab
2010-07-08 7:20 ` Pawel Osciak
2010-07-07 14:58 ` Mauro Carvalho Chehab
2010-07-07 19:44 ` Laurent Pinchart
2010-07-07 20:53 ` Mauro Carvalho Chehab
2010-07-08 12:08 ` Laurent Pinchart
2010-07-08 13:51 ` Mauro Carvalho Chehab [this message]
2010-07-09 8:57 ` Laurent Pinchart
2010-07-07 11:53 ` [RFC/PATCH 3/6] v4l: subdev: Uninline the v4l2_subdev_init function Laurent Pinchart
2010-07-07 12:31 ` Hans Verkuil
2010-07-07 11:53 ` [RFC/PATCH 4/6] v4l: subdev: Control ioctls support Laurent Pinchart
2010-07-07 12:33 ` Hans Verkuil
2010-07-07 12:35 ` Laurent Pinchart
2010-07-07 11:53 ` [RFC/PATCH 5/6] v4l: subdev: Events support Laurent Pinchart
2010-07-07 12:37 ` Hans Verkuil
2010-07-07 11:53 ` [RFC/PATCH 6/6] v4l: subdev: Generic ioctl support Laurent Pinchart
2010-07-07 12:38 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C35D7E5.60407@redhat.com \
--to=mchehab@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@maxwell.research.nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).