linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-media@vger.kernel.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 06/24] V4L2: add a common V4L2 subdevice platform data type
Date: Mon, 04 Nov 2013 12:24:10 +0100	[thread overview]
Message-ID: <527783DA.5050905@xs4all.nl> (raw)
In-Reply-To: <Pine.LNX.4.64.1310171945170.27369@axis700.grange>

Hi Guennadi,

Sorry for the delay, I only saw this today while I was going through my
mail backlog.

On 10/17/2013 08:24 PM, Guennadi Liakhovetski wrote:
> Hi Hans
> 
> Sorry for reviving this old thread. I was going to resubmit a part of 
> those patches for mainlining and then I found this your comment, which I 
> didn't reply to back then.
> 
> On Fri, 19 Apr 2013, Hans Verkuil wrote:
> 
>> On Fri April 19 2013 09:48:27 Guennadi Liakhovetski wrote:
>>> Hi Hans
>>>
>>> Thanks for reviewing.
>>>
>>> On Fri, 19 Apr 2013, Hans Verkuil wrote:
>>>
>>>> On Thu April 18 2013 23:35:27 Guennadi Liakhovetski wrote:
>>>>> This struct shall be used by subdevice drivers to pass per-subdevice data,
>>>>> e.g. power supplies, to generic V4L2 methods, at the same time allowing
>>>>> optional host-specific extensions via the host_priv pointer. To avoid
>>>>> having to pass two pointers to those methods, add a pointer to this new
>>>>> struct to struct v4l2_subdev.
>>>>>
>>>>> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>>>>> ---
>>>>>  include/media/v4l2-subdev.h |   13 +++++++++++++
>>>>>  1 files changed, 13 insertions(+), 0 deletions(-)
>>>>>
>>>>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>>>>> index eb91366..b15c6e0 100644
>>>>> --- a/include/media/v4l2-subdev.h
>>>>> +++ b/include/media/v4l2-subdev.h
>>>>> @@ -561,6 +561,17 @@ struct v4l2_subdev_internal_ops {
>>>>>  /* Set this flag if this subdev generates events. */
>>>>>  #define V4L2_SUBDEV_FL_HAS_EVENTS		(1U << 3)
>>>>>  
>>>>> +struct regulator_bulk_data;
>>>>> +
>>>>> +struct v4l2_subdev_platform_data {
>>>>> +	/* Optional regulators uset to power on/off the subdevice */
>>>>> +	struct regulator_bulk_data *regulators;
>>>>> +	int num_regulators;
>>>>> +
>>>>> +	/* Per-subdevice data, specific for a certain video host device */
>>>>> +	void *host_priv;
>>>>> +};
>>>>> +
>>>>>  /* Each instance of a subdev driver should create this struct, either
>>>>>     stand-alone or embedded in a larger struct.
>>>>>   */
>>>>> @@ -589,6 +600,8 @@ struct v4l2_subdev {
>>>>>  	/* pointer to the physical device */
>>>>>  	struct device *dev;
>>>>>  	struct v4l2_async_subdev_list asdl;
>>>>> +	/* common part of subdevice platform data */
>>>>> +	struct v4l2_subdev_platform_data *pdata;
>>>>>  };
>>>>>  
>>>>>  static inline struct v4l2_subdev *v4l2_async_to_subdev(
>>>>>
>>>>
>>>> Sorry, this is the wrong approach.
>>>>
>>>> This is data that is of no use to the subdev driver itself. It really is
>>>> v4l2_subdev_host_platform_data, and as such must be maintained by the bridge
>>>> driver.
>>>
>>> I don't think so. It has been discussed and agreed upon, that only 
>>> subdevice drivers know when to switch power on and off, because only they 
>>> know when they need to access the hardware. So, they have to manage 
>>> regulators. In fact, those regulators supply power to respective 
>>> subdevices, e.g. a camera sensor. Why should the bridge driver manage 
>>> them? The V4L2 core can (and probably should) provide helper functions for 
>>> that, like soc-camera currently does, but in any case it's the subdevice 
>>> driver, that has to call them.
>>
>> Ah, OK. I just realized I missed some context there. I didn't pay much
>> attention to the regulator discussions since that's not my area of expertise.
>>
>> In that case my only comment is to drop the host_priv pointer since that just
>> duplicates v4l2_get/set_subdev_hostdata().
> 
> I think it's different. This is _platform_ data, whereas struct 
> v4l2_subdev::host_priv is more like run-time data.

You mean subdev_hostdata() instead of host_priv, right?

> This field is for the 
> per-subdevice host-specific data, that the platform has to pass to the 
> host driver. In the soc-camera case this is the largest bulk of the data, 
> that platforms currently pass to the soc-camera framework in the host part 
> of struct soc_camera_link. This data most importantly includes I2C 
> information. Yes, this _could_ be passed to soc-camera separately from the 
> host driver, but that would involve quite some refactoring of the "legacy" 
> synchronous probing mode, which I'd like to avoid if possible. This won't 
> be used in the asynchronous case. Do you think we can keep this pointer in 
> this sruct? We could rename it to avoid confusion with the field, that you 
> told about.

I'm wondering: do we need host_priv at all? Can't drivers use container_of to
go from struct v4l2_subdev_platform_data to the platform_data struct containing
v4l2_subdev_platform_data?

That would be a cleaner solution IMHO. Using host_priv basically forces you
to split up the platform_data into two parts, and a void pointer isn't very
type-safe.

Regards,

	Hans

  reply	other threads:[~2013-11-04 11:24 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 21:35 [PATCH 00/24] V4L2: subdevice pad-level API wrapper Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 01/24] V4L2: (cosmetic) remove redundant use of unlikely() Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 02/24] imx074: fix error handling for failed async subdevice registration Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 03/24] mt9t031: fix NULL dereference during probe() Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 04/24] V4L2: fix Oops on rmmod path Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 05/24] V4L2: allow dummy file-handle initialisation by v4l2_fh_init() Guennadi Liakhovetski
2013-04-19  7:22   ` Hans Verkuil
2013-04-22 12:07     ` Laurent Pinchart
2013-04-18 21:35 ` [PATCH 06/24] V4L2: add a common V4L2 subdevice platform data type Guennadi Liakhovetski
2013-04-19  7:33   ` Hans Verkuil
2013-04-19  7:48     ` Guennadi Liakhovetski
2013-04-19  8:26       ` Hans Verkuil
2013-10-17 18:24         ` Guennadi Liakhovetski
2013-11-04 11:24           ` Hans Verkuil [this message]
2013-11-06  0:13             ` Laurent Pinchart
2013-04-18 21:35 ` [PATCH 07/24] soc-camera: switch to using the new struct v4l2_subdev_platform_data Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 08/24] ARM: update all soc-camera users to new platform data layout Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 09/24] SH: " Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 10/24] soc-camera: update soc-camera-platform & its users to a " Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 11/24] soc-camera: completely remove struct soc_camera_link Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 12/24] V4L2: soc-camera: retrieve subdevice platform data from struct v4l2_subdev Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 13/24] ARM: pcm037: convert custom GPIO-based power function to a regulator Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 14/24] mx3-camera: clean up the use of platform data, add driver owner Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 15/24] mx3-camera: support asynchronous subdevice registration Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 16/24] V4L2: mt9p031: add support for V4L2 clock and asynchronous probing Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 17/24] V4L2: mt9p031: add support for .g_mbus_config() video operation Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 18/24] V4L2: mt9p031: power down the sensor if no supported device has been detected Guennadi Liakhovetski
2013-04-22 12:19   ` Laurent Pinchart
2013-04-22 12:33     ` Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 19/24] V4L2: add struct v4l2_subdev_try_buf Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 20/24] V4L2: add a subdev pointer to struct v4l2_subdev_fh Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 21/24] V4L2: add a subdevice-driver pad-operation wrapper Guennadi Liakhovetski
2013-04-19  8:20   ` Hans Verkuil
2013-04-19  8:52     ` Guennadi Liakhovetski
2013-04-19  9:40       ` Hans Verkuil
2013-04-18 21:35 ` [PATCH 22/24] V4L2: soc-camera: use the " Guennadi Liakhovetski
2013-04-18 21:35 ` [PATCH 23/24] V4L2: mt9p031: add struct v4l2_subdev_platform_data to platform data Guennadi Liakhovetski
2013-04-18 21:47   ` Guennadi Liakhovetski
2013-04-22 12:31     ` Laurent Pinchart
2013-04-22 12:39       ` Guennadi Liakhovetski
2013-04-22 12:46         ` Laurent Pinchart
2013-04-26  8:30         ` Sascha Hauer
2013-04-26  8:43           ` Guennadi Liakhovetski
2013-04-26  9:15             ` Sascha Hauer
2013-04-29  9:55               ` Laurent Pinchart
2013-04-22 12:45   ` Laurent Pinchart
2013-04-18 21:35 ` [PATCH 24/24] ARM: pcm037: support mt9p031 / mt9p006 camera sensors Guennadi Liakhovetski
2013-04-18 21:45   ` Guennadi Liakhovetski
2013-04-19 10:29 ` [PATCH 00/24] V4L2: subdevice pad-level API wrapper 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=527783DA.5050905@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=g.liakhovetski@gmx.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /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).