All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	gjasny@googlemail.com, hdegoede@redhat.com, hverkuil@xs4all.nl
Subject: Re: [PATCH 13/15] mediactl: Add media device ioctl API
Date: Thu, 18 Feb 2016 14:14:40 +0100	[thread overview]
Message-ID: <56C5C3C0.7000808@samsung.com> (raw)
In-Reply-To: <20160218120951.GO32612@valkosipuli.retiisi.org.uk>

Hi Sakari,

On 02/18/2016 01:09 PM, Sakari Ailus wrote:
> Hi Jacek,
>
> On Mon, Feb 15, 2016 at 02:06:06PM +0100, Jacek Anaszewski wrote:
>> Hi Sakari,
>>
>> Thanks for the review.
>>
>> On 02/15/2016 01:41 PM, Sakari Ailus wrote:
>>> Hi Jacek,
>>>
>>> Jacek Anaszewski wrote:
>>>> Ioctls executed on complex media devices need special handling.
>>>> For instance some ioctls need to be targeted for specific sub-devices,
>>>> depending on the media device configuration. The APIs being introduced
>>>> address such requirements.
>>>>
>>>> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
>>>> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
>>>> ---
>>>>   utils/media-ctl/Makefile.am          |    2 +-
>>>>   utils/media-ctl/libv4l2media_ioctl.c |  404 ++++++++++++++++++++++++++++++++++
>>>>   utils/media-ctl/libv4l2media_ioctl.h |   48 ++++
>>>>   3 files changed, 453 insertions(+), 1 deletion(-)
>>>>   create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
>>>>   create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
>>>>
>>>> diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
>>>> index 3e883e0..7f18624 100644
>>>> --- a/utils/media-ctl/Makefile.am
>>>> +++ b/utils/media-ctl/Makefile.am
>>>> @@ -1,6 +1,6 @@
>>>>   noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
>>>>
>>>> -libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
>>>> +libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libv4l2media_ioctl.c libv4l2media_ioctl.h
>>>>   libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
>>>>   libmediactl_la_LDFLAGS = -static $(LIBUDEV_LIBS)
>>>>
>>>> diff --git a/utils/media-ctl/libv4l2media_ioctl.c b/utils/media-ctl/libv4l2media_ioctl.c
>>>> new file mode 100644
>>>> index 0000000..b186121
>>>> --- /dev/null
>>>> +++ b/utils/media-ctl/libv4l2media_ioctl.c
>>>> @@ -0,0 +1,404 @@
>>>> +/*
>>>> + * Copyright (c) 2015 Samsung Electronics Co., Ltd.
>>>> + *              http://www.samsung.com
>>>> + *
>>>> + * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or modify
>>>> + * it under the terms of the GNU Lesser General Public License as published by
>>>> + * the Free Software Foundation; either version 2.1 of the License, or
>>>> + * (at your option) any later version.
>>>> + *
>>>> + * 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
>>>> + * Lesser General Public License for more details.
>>>> + */
>>>> +
>>>> +#include <errno.h>
>>>> +#include <stdlib.h>
>>>> +#include <sys/syscall.h>
>>>> +#include <unistd.h>
>>>> +
>>>> +#include <linux/videodev2.h>
>>>> +
>>>> +#include "libv4l2media_ioctl.h"
>>>> +#include "mediactl-priv.h"
>>>> +#include "mediactl.h"
>>>> +#include "v4l2subdev.h"
>>>> +
>>>> +#define VIDIOC_CTRL(type)					\
>>>> +	((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" :		\
>>>> +				   "VIDIOC_G_CTRL")
>>>> +
>>>> +#define VIDIOC_EXT_CTRL(type)					\
>>>> +	((type) == VIDIOC_S_EXT_CTRLS ? 			\
>>>> +		"VIDIOC_S_EXT_CTRLS"	:			\
>>>> +		 ((type) == VIDIOC_G_EXT_CTRLS ? 		\
>>>> +				    "VIDIOC_G_EXT_CTRLS" :	\
>>>> +				    "VIDIOC_TRY_EXT_CTRLS"))
>>>> +
>>>> +#define SYS_IOCTL(fd, cmd, arg) \
>>>> +	syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
>>>> +
>>>> +
>>>> +int media_ioctl_ctrl(struct media_device *media, int request,
>>>
>>> unsigned int request
>>
>> OK.
>>
>>>
>>>> +		     struct v4l2_control *arg)
>>>
>>> I wonder if it'd make sense to always use v4l2_ext_control instead. You
>>> can't access 64-bit integer controls with VIDIOC_S_CTRL for instance.
>>
>> This function is meant to handle VIDIOC_S_CTRL/VIDIOC_G_CTRL ioctls.
>> For ext ctrls there is media_ioctl_ext_ctrl().
>
> Is there any reason not to use extended control always?
>
> In other words, do we have a driver that does support Media controller but
> does not support extended controls?

Shouldn't we support non-extended controls for backward compatibility
reasons? I am not aware of the policy in this matter.

>>> As this is a user space library, I'd probably add a function to handle
>>> S/G/TRY control each.
>>
>> There is media_ioctl_ext_ctrl() that handles VIDIOC_S_EXT_CTRLS,
>> VIDIOC_G_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS.
>>
>>> Have you considered binding the control to a video node rather than a
>>> media device? We have many sensors on current media devices already, and
>>> e.g. exposure time control can be found in multiple sub-devices.
>>
>> Doesn't v4l2-ctrl-redir config entry address that?
>
> How does it work if you have, say, two video nodes where you can capture
> images from a different sensor? I.e. your media graph could look like this:
>
> 	sensor0 -> CSI-2 0 -> video0
>
> 	sensor1 -> CSI-2 1 -> video1

Exemplary config settings for this case:

v4l2-ctrl-redir 0x0098091f -> "sensor0"
v4l2-ctrl-redir 0x0098091f -> "sensor1"

In media_ioctl_ctrl the v4l2_subdev_get_pipeline_entity_by_cid(media,
ctrl.id) is called which walks through the pipeline and checks if there
has been a v4l2 control redirection defined for given entity.

If no redirection is defined then the control is set on the first
entity in the pipeline that supports it. Effectively, for this
arrangement no redirection would be required if the control
is to be set on sensors. It would be required if we wanted
to bind the control to the videoN entity. Now I am wondering
if I should change the entry name to v4l2-ctrl-binding, or maybe
someone has better idea?

BTW, are there some unique identifiers added to the entity names if
more than one entity of a name is to be registered? E.g. what would
happen if I had two S5C73M3 sensors in a media device? I assumed that
entity names are unique.

-- 
Best regards,
Jacek Anaszewski

  reply	other threads:[~2016-02-18 13:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 16:17 [PATCH 00/15] Add a plugin for Exynos4 camera Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 01/15] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
2016-02-12 12:42   ` Sakari Ailus
2016-02-18 14:15     ` Jacek Anaszewski
2016-03-20 23:39       ` Sakari Ailus
2016-03-22  9:26         ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 02/15] mediactl: Add support for v4l2-ctrl-redir config Jacek Anaszewski
2016-02-15 10:58   ` Sakari Ailus
2016-02-15 11:39     ` Jacek Anaszewski
2016-02-15 12:22       ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 03/15] mediactl: Separate entity and pad parsing Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 04/15] mediatext: Add library Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 05/15] mediactl: Add media device graph helpers Jacek Anaszewski
2016-02-15 12:02   ` Sakari Ailus
2016-02-15 12:45     ` Jacek Anaszewski
2016-02-15 14:14       ` Sakari Ailus
2016-02-15 14:57         ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 06/15] mediactl: Add media_device creation helpers Jacek Anaszewski
2016-02-15 14:30   ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 07/15] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
2016-02-15 15:55   ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 08/15] mediactl: Add support for media device pipelines Jacek Anaszewski
2016-02-15 16:53   ` Sakari Ailus
2016-02-16  9:19     ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 09/15] mediactl: libv4l2subdev: Add colorspace logging Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 10/15] mediactl: libv4l2subdev: add support for comparing mbus formats Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 11/15] mediactl: libv4l2subdev: add support for setting pipeline format Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 12/15] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 13/15] mediactl: Add media device ioctl API Jacek Anaszewski
2016-02-15 12:41   ` Sakari Ailus
2016-02-15 13:06     ` Jacek Anaszewski
2016-02-18 12:09       ` Sakari Ailus
2016-02-18 13:14         ` Jacek Anaszewski [this message]
2016-03-21  0:07           ` Sakari Ailus
2016-03-22  9:36             ` Jacek Anaszewski
2016-03-23 16:24               ` Sakari Ailus
2016-03-24 15:55                 ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 14/15] mediactl: libv4l2subdev: Enable opening/closing pipelines Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 15/15] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski

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=56C5C3C0.7000808@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=gjasny@googlemail.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.