All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Helen Koike <helen.koike@collabora.com>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Mauro Carvalho Chehab <mchehab@s-opensource.com>,
	linux-media@vger.kernel.org, jgebben@codeaurora.org
Subject: Re: [PATCH RFC 1/2] [media] v4l2: add V4L2_INPUT_TYPE_DEFAULT
Date: Fri, 31 Mar 2017 11:08:26 +0200	[thread overview]
Message-ID: <c328fd19-e7d1-2964-35b3-a82ec5cb4d73@xs4all.nl> (raw)
In-Reply-To: <1528696.yNy6IkbhZk@avalon>

On 31/03/17 10:41, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Friday 31 Mar 2017 10:29:04 Hans Verkuil wrote:
>> On 30/03/17 18:02, Helen Koike wrote:
>>> Add V4L2_INPUT_TYPE_DEFAULT and helpers functions for input ioctls to be
>>> used when no inputs are available in the device
>>>
>>> Signed-off-by: Helen Koike <helen.koike@collabora.com>
>>> ---
>>>
>>>  drivers/media/v4l2-core/v4l2-ioctl.c | 27 +++++++++++++++++++++++++++
>>>  include/media/v4l2-ioctl.h           | 26 ++++++++++++++++++++++++++
>>>  include/uapi/linux/videodev2.h       |  1 +
>>>  3 files changed, 54 insertions(+)
>>>
>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>>> b/drivers/media/v4l2-core/v4l2-ioctl.c index 0c3f238..ccaf04b 100644
>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>> @@ -2573,6 +2573,33 @@ struct mutex *v4l2_ioctl_get_lock(struct
>>> video_device *vdev, unsigned cmd)> 
>>>  	return vdev->lock;
>>>  
>>>  }
>>>
>>> +int v4l2_ioctl_enum_input_default(struct file *file, void *priv,
>>> +				  struct v4l2_input *i)
>>> +{
>>> +	if (i->index > 0)
>>> +		return -EINVAL;
>>> +
>>> +	memset(i, 0, sizeof(*i));
>>> +	i->type = V4L2_INPUT_TYPE_DEFAULT;
>>> +	strlcpy(i->name, "Default", sizeof(i->name));
>>> +
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL(v4l2_ioctl_enum_input_default);
>>> +
>>> +int v4l2_ioctl_g_input_default(struct file *file, void *priv, unsigned
>>> int *i)
>>> +{
>>> +	*i = 0;
>>> +	return 0;
>>> +}
>>> +EXPORT_SYMBOL(v4l2_ioctl_g_input_default);
>>> +
>>> +int v4l2_ioctl_s_input_default(struct file *file, void *priv, unsigned
>>> int i)
>>> +{
>>> +	return i ? -EINVAL : 0;
>>> +}
>>> +EXPORT_SYMBOL(v4l2_ioctl_s_input_default);
>>> +
>>>  /* Common ioctl debug function. This function can be used by
>>>     external ioctl messages as well as internal V4L ioctl */
>>>  void v4l_printk_ioctl(const char *prefix, unsigned int cmd)
>>> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
>>> index 6cd94e5..accc470 100644
>>> --- a/include/media/v4l2-ioctl.h
>>> +++ b/include/media/v4l2-ioctl.h
>>> @@ -652,6 +652,32 @@ struct video_device;
>>>   */
>>>  
>>>  struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned int
>>>  cmd);
>>> +
>>> +/**
>>> + * v4l2_ioctl_enum_input_default - v4l2 ioctl helper for
>>> VIDIOC_ENUM_INPUT ioctl + *
>>> + * Plug this function in vidioc_enum_input field of the struct
>>> v4l2_ioctl_ops to + * enumerate a single input as V4L2_INPUT_TYPE_DEFAULT
>>> + */
>>> +int v4l2_ioctl_enum_input_default(struct file *file, void *priv,
>>> +				  struct v4l2_input *i);
>>> +
>>> +/**
>>> + * v4l2_ioctl_g_input_default - v4l2 ioctl helper for VIDIOC_G_INPUT
>>> ioctl
>>> + *
>>> + * Plug this function in vidioc_g_input field of the struct
>>> v4l2_ioctl_ops
>>> + * when using v4l2_ioctl_enum_input_default
>>> + */
>>> +int v4l2_ioctl_g_input_default(struct file *file, void *priv, unsigned
>>> int *i); +
>>> +/**
>>> + * v4l2_ioctl_s_input_default - v4l2 ioctl helper for VIDIOC_S_INPUT
>>> ioctl
>>> + *
>>> + * Plug this function in vidioc_s_input field of the struct
>>> v4l2_ioctl_ops
>>> + * when using v4l2_ioctl_enum_input_default
>>> + */
>>> +int v4l2_ioctl_s_input_default(struct file *file, void *priv, unsigned
>>> int i); +
>>>
>>>  /* names for fancy debug output */
>>>  extern const char *v4l2_field_names[];
>>>  extern const char *v4l2_type_names[];
>>>
>>> diff --git a/include/uapi/linux/videodev2.h
>>> b/include/uapi/linux/videodev2.h index 316be62..c10bbde 100644
>>> --- a/include/uapi/linux/videodev2.h
>>> +++ b/include/uapi/linux/videodev2.h
>>> @@ -1477,6 +1477,7 @@ struct v4l2_input {
>>>
>>>  };
>>>  
>>>  /*  Values for the 'type' field */
>>>
>>> +#define V4L2_INPUT_TYPE_DEFAULT		0
>>
>> I don't think we should add a new type here. The whole point of this
>> exercise is to allow existing apps to work, and existing apps expect a
>> TYPE_CAMERA.
>>
>> BTW, don't read to much in the term 'CAMERA': it's really a catch all for
>> any video stream, whether it is from a sensor, composite input, HDMI, etc.
>>
>> The description for V4L2_INPUT_TYPE_CAMERA in the spec is hopelessly out of
>> date :-(
>>
>> Rather than creating a new type I would add a new V4L2_IN_CAP_MC capability
>> that indicates that this input is controlled via the media controller. That
>> makes much more sense and it wouldn't potentially break applications.
>>
>> Exactly the same can be done for outputs as well: add V4L2_OUT_CAP_MC and
>> use V4L2_OUTPUT_TYPE_ANALOG as the output type (again, a horrible outdated
>> name and the spec is again out of date).
> 
> What would those capabilities be used for ? Applications can already know 
> whether the MC API is used by a driver. Furthermore, if we really need such a 
> flag, I wouldn't add it at the input/output level but as a video node 
> capability flag.

I have no objection to adding a V4L2_CAP_MC capability instead. In fact, I
think that would be a good idea and better than adding IN/OUT_CAP_MC.

>> Regarding the name: should we use the name stored in struct video_device
>> instead? That might be more descriptive. Alternatively use something like
>> "Media Controller Input".
>>
>> More helpful (perhaps) than just "Default" or "Unknown".
> 
> If the purpose of the name field is to be displayed as-is to the end-user, 
> then "Media Controller Input" is as useless as "Unknown". "Default" would be 
> slightly better.

I would like to have something that indicates to the user that this input is
controlled via the MC. "Default" doesn't do that. I'm honestly not certain
what would be a good description. Frankly, I think that copying the video_device
name might be the better solution here. At least that way the name can actually
map to something sensible.

Regards,

	Hans

> 
>> I'll make a patch to update the input/output type description in the spec.
>>
>>>  #define V4L2_INPUT_TYPE_TUNER		1
>>>  #define V4L2_INPUT_TYPE_CAMERA		2
>>>  #define V4L2_INPUT_TYPE_TOUCH		3
> 

  reply	other threads:[~2017-03-31  9:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30 16:02 [PATCH RFC 1/2] [media] v4l2: add V4L2_INPUT_TYPE_DEFAULT Helen Koike
2017-03-30 16:02 ` [PATCH 2/2] [media] docs-rst: " Helen Koike
2017-03-30 20:26   ` Sakari Ailus
2017-03-31  9:47     ` Mauro Carvalho Chehab
2017-03-30 19:56 ` [PATCH RFC 1/2] [media] v4l2: " Laurent Pinchart
2017-03-31  2:39   ` Helen Koike
2017-03-31  3:55     ` Helen Koike
2017-03-31  9:42       ` Mauro Carvalho Chehab
2017-03-31  9:51         ` Hans Verkuil
2017-03-31  8:41     ` Laurent Pinchart
2017-03-31  9:33       ` Mauro Carvalho Chehab
2017-03-31  8:29 ` Hans Verkuil
2017-03-31  8:41   ` Laurent Pinchart
2017-03-31  9:08     ` Hans Verkuil [this message]
2017-03-31  9:57   ` Mauro Carvalho Chehab
2017-04-03 15:11     ` Helen Koike
2017-04-04 13:22       ` Sakari Ailus
2017-04-07  9:46         ` Hans Verkuil
2017-04-07  9:53           ` Laurent Pinchart
2017-06-06 16:22             ` Helen Koike
2017-06-12  9:26               ` Hans Verkuil
2017-06-30 11:03                 ` Sakari Ailus
2017-06-30 11:13                   ` Hans Verkuil
2017-06-30 13:49                     ` Sakari Ailus
2017-04-07  9:36     ` Hans Verkuil
2017-06-14  4:50 ` [PATCH v2] [media] v4l2: add V4L2_CAP_IO_MC Helen Koike
2017-06-19 11:15   ` Hans Verkuil
2017-06-19 17:49     ` Helen Koike

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=c328fd19-e7d1-2964-35b3-a82ec5cb4d73@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=helen.koike@collabora.com \
    --cc=jgebben@codeaurora.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@s-opensource.com \
    --cc=sakari.ailus@iki.fi \
    /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.