linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	magnus.damm@gmail.com, geert@glider.be, mchehab@kernel.org,
	festevam@gmail.com, sakari.ailus@iki.fi, robh+dt@kernel.org,
	mark.rutland@arm.com, pombredanne@nexb.com,
	linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org,
	linux-sh@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 03/11] media: platform: Add Renesas CEU driver
Date: Wed, 21 Feb 2018 14:02:59 +0100	[thread overview]
Message-ID: <19015eda-c830-f987-92fa-49a407033ada@xs4all.nl> (raw)
In-Reply-To: <2908261.btsdL5a7UQ@avalon>

On 02/21/18 13:29, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Wednesday, 21 February 2018 14:03:24 EET Hans Verkuil wrote:
>> On 02/19/18 17:59, Jacopo Mondi wrote:
>>> Add driver for Renesas Capture Engine Unit (CEU).
>>>
>>> The CEU interface supports capturing 'data' (YUV422) and 'images'
>>> (NV[12|21|16|61]).
>>>
>>> This driver aims to replace the soc_camera-based sh_mobile_ceu one.
>>>
>>> Tested with ov7670 camera sensor, providing YUYV_2X8 data on Renesas RZ
>>> platform GR-Peach.
>>>
>>> Tested with ov7725 camera sensor on SH4 platform Migo-R.
>>>
>>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>>
>>>  drivers/media/platform/Kconfig       |    9 +
>>>  drivers/media/platform/Makefile      |    1 +
>>>  drivers/media/platform/renesas-ceu.c | 1661 +++++++++++++++++++++++++++++
>>>  3 files changed, 1671 insertions(+)
>>>  create mode 100644 drivers/media/platform/renesas-ceu.c
>>
>> <snip>
>>
>>> +static int ceu_s_input(struct file *file, void *priv, unsigned int i)
>>> +{
>>> +	struct ceu_device *ceudev = video_drvdata(file);
>>> +	struct ceu_subdev *ceu_sd_old;
>>> +	int ret;
>>> +
>>> +	if (i >= ceudev->num_sd)
>>> +		return -EINVAL;
>>> +
>>> +	if (vb2_is_streaming(&ceudev->vb2_vq))
>>> +		return -EBUSY;
>>> +
>>> +	if (i == ceudev->sd_index)
>>> +		return 0;
>>> +
>>> +	ceu_sd_old = ceudev->sd;
>>> +	ceudev->sd = &ceudev->subdevs[i];
>>> +
>>> +	/* Make sure we can generate output image formats. */
>>> +	ret = ceu_init_formats(ceudev);
>>
>> Why is this done for every s_input? I would expect that this is done only
>> once for each subdev.
>>
>> I also expect to see a ceu_set_default_fmt() call here. Or that the v4l2_pix
>> is kept in ceu_subdev (i.e. per subdev) instead of a single fmt in cuedev.
>> I think I prefer that over configuring a new default format every time you
>> switch inputs.
> 
> What does userspace expect today ? I don't think we document anywhere that 
> formats are stored per-input in drivers. The VIDIOC_S_INPUT documentation is 
> very vague:
> 
> "To select a video input applications store the number of the desired input in 
> an integer and call the VIDIOC_S_INPUT ioctl with a pointer to this integer. 
> Side effects are possible. For example inputs may support different video 
> standards, so the driver may implicitly switch the current standard. Because 
> of these possible side effects applications must select an input before 
> querying or negotiating any other parameters."
> 
> I understand that as meaning "anything can happen when you switch inputs, so 
> be prepared to reconfigure everything explicitly without assuming any 
> particular parameter to have a sane value".
> 
>> This code will work for two subdevs with exactly the same
>> formats/properties. But switching between e.g. a sensor and a video
>> receiver will leave things in an inconsistent state as far as I can see.
>>
>> E.g. if input 1 is the video receiver then switching to that input and
>> running 'v4l2-ctl -V' will show the sensor format, not the video receiver
>> format.
> 
> I agree that the format should be consistent with the selected input, as 
> calling VIDIOC_S_INPUT immediately followed by a stream start sequence without 
> configuring formats should work (but produce a format that is not known to 
> userspace). My question is whether we should reset to a default format for the 
> newly select input, or switch back to the previously set format. I'd tend to 
> go for the former to keep as little state as possible, but I'm open to 
> counter-proposals.

What to do is up to the driver. My personal preference is to make it persistent
per input, but that's just me. I won't block the other approach (resetting it
to a default). Be aware that for video receivers the format depends on the current
selected standard as well. I think the code does that correctly already, but it
would be good to verify if possible.

BTW, I think it is right that the spec isn't specific about what changes when
you switch inputs. It can be quite complex for drivers to handle this and it
is not unreasonable in my view for userspace to just assume it needs to configure
from scratch after switching inputs.

Regards,

	Hans

> 
>>> +	if (ret) {
>>> +		ceudev->sd = ceu_sd_old;
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	/* now that we're sure we can use the sensor, power off the old one. */
>>> +	v4l2_subdev_call(ceu_sd_old->v4l2_sd, core, s_power, 0);
>>> +	v4l2_subdev_call(ceudev->sd->v4l2_sd, core, s_power, 1);
>>> +
>>> +	ceudev->sd_index = i;
>>> +
>>> +	return 0;
>>> +}
>>
>> The remainder of this driver looks good.
> 

  reply	other threads:[~2018-02-21 14:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 16:59 [PATCH v9 00/11] Renesas Capture Engine Unit (CEU) V4L2 driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 01/11] dt-bindings: media: Add Renesas CEU bindings Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 02/11] include: media: Add Renesas CEU driver interface Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 03/11] media: platform: Add Renesas CEU driver Jacopo Mondi
2018-02-20  3:35   ` kbuild test robot
2018-02-21 12:03   ` Hans Verkuil
2018-02-21 12:29     ` Laurent Pinchart
2018-02-21 13:02       ` Hans Verkuil [this message]
2018-02-21 16:43         ` jacopo mondi
2018-02-19 16:59 ` [PATCH v9 04/11] ARM: dts: r7s72100: Add Capture Engine Unit (CEU) Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 05/11] media: i2c: Copy ov772x soc_camera sensor driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 06/11] media: i2c: ov772x: Remove soc_camera dependencies Jacopo Mondi
2018-02-21 12:08   ` Hans Verkuil
2018-02-19 16:59 ` [PATCH v9 07/11] media: i2c: ov772x: Support frame interval handling Jacopo Mondi
2018-02-20  4:25   ` kbuild test robot
2018-02-20  5:22   ` kbuild test robot
2018-02-20  5:22   ` [RFC PATCH] media: i2c: ov772x: ov772x_frame_intervals[] can be static kbuild test robot
2018-02-21 12:12   ` [PATCH v9 07/11] media: i2c: ov772x: Support frame interval handling Hans Verkuil
2018-02-21 15:16     ` jacopo mondi
2018-02-21 15:23       ` Hans Verkuil
2018-02-19 16:59 ` [PATCH v9 08/11] media: i2c: Copy tw9910 soc_camera sensor driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 09/11] media: i2c: tw9910: Remove soc_camera dependencies Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 10/11] arch: sh: migor: Use new renesas-ceu camera driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 11/11] media: i2c: ov7670: Fully set mbus frame fmt Jacopo Mondi
2018-02-19 19:19   ` Laurent Pinchart
2018-02-20  8:58     ` jacopo mondi
2018-02-21 15:47       ` jacopo mondi
2018-02-21 16:28         ` Hans Verkuil
2018-02-21 20:28       ` Laurent Pinchart
2018-02-22 12:04         ` jacopo mondi
2018-02-22 12:14           ` Laurent Pinchart
2018-02-22 12:36             ` jacopo mondi
2018-02-22 12:47               ` Laurent Pinchart
2018-02-22 14:26                 ` jacopo mondi

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=19015eda-c830-f987-92fa-49a407033ada@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=geert@glider.be \
    --cc=jacopo+renesas@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=pombredanne@nexb.com \
    --cc=robh+dt@kernel.org \
    --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 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).