public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>, Yong Zhi <yong.zhi@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	niklas.soderlund@ragnatech.se, Sebastian Reichel <sre@kernel.org>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH v3 06/13] media: platform: video-mux: Register a subdev notifier
Date: Fri, 20 Apr 2018 09:40:14 -0700	[thread overview]
Message-ID: <b32ba558-60e2-3185-871c-ecc679bd6e24@gmail.com> (raw)
In-Reply-To: <9d85012a-bd0d-6676-9918-7c9804d9a040@xs4all.nl>

Hi Hans,


On 04/20/2018 05:28 AM, Hans Verkuil wrote:
> On 03/21/18 01:37, Steve Longerbeam wrote:
>> Parse neighbor remote devices on the video muxes input ports, add them to a
>> subdev notifier, and register the subdev notifier for the video mux, by
>> calling v4l2_async_register_fwnode_subdev().
>>
>> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
>> ---
>> Changes since v2:
>> - none
>> Changes since v1:
>> - add #include <linux/slab.h> for kcalloc() declaration.
>> ---
>>   drivers/media/platform/video-mux.c | 36 +++++++++++++++++++++++++++++++++++-
>>   1 file changed, 35 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
>> index ee89ad7..b93b0af 100644
>> --- a/drivers/media/platform/video-mux.c
>> +++ b/drivers/media/platform/video-mux.c
>> @@ -21,8 +21,10 @@
>>   #include <linux/of.h>
>>   #include <linux/of_graph.h>
>>   #include <linux/platform_device.h>
>> +#include <linux/slab.h>
>>   #include <media/v4l2-async.h>
>>   #include <media/v4l2-device.h>
>> +#include <media/v4l2-fwnode.h>
>>   #include <media/v4l2-subdev.h>
>>   
>>   struct video_mux {
>> @@ -193,6 +195,38 @@ static const struct v4l2_subdev_ops video_mux_subdev_ops = {
>>   	.video = &video_mux_subdev_video_ops,
>>   };
>>   
>> +static int video_mux_parse_endpoint(struct device *dev,
>> +				    struct v4l2_fwnode_endpoint *vep,
>> +				    struct v4l2_async_subdev *asd)
>> +{
>> +	/*
>> +	 * it's not an error if remote is missing on a video-mux
>> +	 * input port, return -ENOTCONN to skip this endpoint with
>> +	 * no error.
>> +	 */
>> +	return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
>> +}
>> +
>> +static int video_mux_async_register(struct video_mux *vmux,
>> +				    unsigned int num_pads)
>> +{
>> +	unsigned int i, *ports;
>> +	int ret;
>> +
>> +	ports = kcalloc(num_pads - 1, sizeof(*ports), GFP_KERNEL);
>> +	if (!ports)
>> +		return -ENOMEM;
>> +	for (i = 0; i < num_pads - 1; i++)
>> +		ports[i] = i;
>> +
>> +	ret = v4l2_async_register_fwnode_subdev(
>> +		&vmux->subdev, sizeof(struct v4l2_async_subdev),
>> +		ports, num_pads - 1, video_mux_parse_endpoint);
>> +
>> +	kfree(ports);
>> +	return ret;
>> +}
>> +
>>   static int video_mux_probe(struct platform_device *pdev)
>>   {
>>   	struct device_node *np = pdev->dev.of_node;
>> @@ -258,7 +292,7 @@ static int video_mux_probe(struct platform_device *pdev)
>>   
>>   	vmux->subdev.entity.ops = &video_mux_ops;
>>   
>> -	return v4l2_async_register_subdev(&vmux->subdev);
>> +	return video_mux_async_register(vmux, num_pads);
> I would prefer to change the last argument to 'num_pads - 1' and drop the ' - 1'
> part in the video_mux_async_register() function. Perhaps renaming the num_pads
> argument there to num_input_pads.

Yes makes sense. I will do that.

Steve

  reply	other threads:[~2018-04-20 16:40 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21  0:37 [PATCH v3 00/13] media: imx: Switch to subdev notifiers Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 01/13] media: v4l2-fwnode: ignore endpoints that have no remote port parent Steve Longerbeam
2018-04-20 11:53   ` Hans Verkuil
2018-03-21  0:37 ` [PATCH v3 02/13] media: v4l2: async: Allow searching for asd of any type Steve Longerbeam
2018-04-20 12:22   ` Hans Verkuil
2018-04-20 16:37     ` Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 03/13] media: v4l2: async: Add v4l2_async_notifier_add_subdev Steve Longerbeam
2018-04-20 12:24   ` Sakari Ailus
2018-04-20 17:12     ` Steve Longerbeam
2018-05-08 10:12       ` Sakari Ailus
2018-05-09 23:06         ` Steve Longerbeam
2018-06-26  7:12           ` Sakari Ailus
2018-06-26 20:47             ` Steve Longerbeam
2018-07-02  7:49               ` Sakari Ailus
2018-03-21  0:37 ` [PATCH v3 04/13] media: v4l2-fwnode: Switch to v4l2_async_notifier_add_subdev Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 05/13] media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers Steve Longerbeam
2018-04-23  7:14   ` Sakari Ailus
2018-04-23 18:00     ` Steve Longerbeam
2018-05-08 10:28       ` Sakari Ailus
2018-05-09  3:55         ` Steve Longerbeam
2018-06-26  7:45           ` Sakari Ailus
2018-06-26 20:58             ` Steve Longerbeam
2018-07-02  7:43           ` Sakari Ailus
2018-03-21  0:37 ` [PATCH v3 06/13] media: platform: video-mux: Register a subdev notifier Steve Longerbeam
2018-04-20 12:28   ` Hans Verkuil
2018-04-20 16:40     ` Steve Longerbeam [this message]
2018-03-21  0:37 ` [PATCH v3 07/13] media: imx: csi: " Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 08/13] media: imx: mipi csi-2: " Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 09/13] media: staging/imx: of: Remove recursive graph walk Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 10/13] media: staging/imx: Loop through all registered subdevs for media links Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 11/13] media: staging/imx: Rename root notifier Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 12/13] media: staging/imx: Switch to v4l2_async_notifier_add_subdev Steve Longerbeam
2018-03-21  0:37 ` [PATCH v3 13/13] media: staging/imx: TODO: Remove one assumption about OF graph parsing Steve Longerbeam
2018-04-02 17:22 ` [PATCH v3 00/13] media: imx: Switch to subdev notifiers Steve Longerbeam
2018-05-07 14:20 ` Hans Verkuil
2018-05-07 16:34   ` Steve Longerbeam

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=b32ba558-60e2-3185-871c-ecc679bd6e24@gmail.com \
    --to=slongerbeam@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=p.zabel@pengutronix.de \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sre@kernel.org \
    --cc=yong.zhi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox