public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	niklas.soderlund+renesas@ragnatech.se,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	satish.nagireddy@getcruise.com
Subject: Re: [PATCH v4 6/8] media-ctl: Check for Streams API support
Date: Mon, 24 Apr 2023 10:54:54 +0300	[thread overview]
Message-ID: <20230424075454.GF4926@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230421124428.393261-7-tomi.valkeinen@ideasonboard.com>

Hi Tomi,

Thank you for the patch.

On Fri, Apr 21, 2023 at 03:44:26PM +0300, Tomi Valkeinen wrote:
> Do two things:

That usually calls for two patches ;-) Or an explanation in the commit
message about why the two are combined.

> - Inform the kernel that we support streams with a call to
>   VIDIOC_SUBDEV_S_CLIENT_CAP
> 
> - Use the returns from VIDIOC_SUBDEV_S_CLIENT_CAP and
>   VIDIOC_SUBDEV_QUERYCAP to decide if streams are supported. If not,
>   fail in case the user tries to use streams.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  utils/media-ctl/libv4l2subdev.c | 54 +++++++++++++++++++++++++++++++++
>  utils/media-ctl/mediactl-priv.h |  1 +
>  2 files changed, 55 insertions(+)
> 
> diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
> index 9205cfa4..186708ff 100644
> --- a/utils/media-ctl/libv4l2subdev.c
> +++ b/utils/media-ctl/libv4l2subdev.c
> @@ -42,6 +42,12 @@
>  
>  int v4l2_subdev_open(struct media_entity *entity)
>  {
> +	struct v4l2_subdev_client_capability clientcap = {};
> +	struct v4l2_subdev_capability subdevcap = {};
> +	bool subdev_streams;
> +	bool client_streams;
> +	int ret;
> +
>  	if (entity->fd != -1)
>  		return 0;
>  
> @@ -54,6 +60,16 @@ int v4l2_subdev_open(struct media_entity *entity)
>  		return ret;
>  	}
>  
> +	ret = ioctl(entity->fd, VIDIOC_SUBDEV_QUERYCAP, &subdevcap);
> +	subdev_streams = !ret && (subdevcap.capabilities & V4L2_SUBDEV_CAP_STREAMS);
> +
> +	clientcap.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;
> +
> +	ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_CLIENT_CAP, &clientcap);
> +	client_streams = !ret && (clientcap.capabilities & V4L2_SUBDEV_CLIENT_CAP_STREAMS);
> +
> +	entity->supports_streams = subdev_streams && client_streams;
> +
>  	return 0;
>  }
>  
> @@ -74,6 +90,11 @@ int v4l2_subdev_get_format(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&fmt, 0, sizeof(fmt));
>  	fmt.pad = pad;
>  	fmt.stream = stream;
> @@ -99,6 +120,11 @@ int v4l2_subdev_set_format(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&fmt, 0, sizeof(fmt));
>  	fmt.pad = pad;
>  	fmt.stream = stream;
> @@ -127,6 +153,11 @@ int v4l2_subdev_get_selection(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&u.sel, 0, sizeof(u.sel));
>  	u.sel.pad = pad;
>  	u.sel.target = target;
> @@ -166,6 +197,11 @@ int v4l2_subdev_set_selection(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&u.sel, 0, sizeof(u.sel));
>  	u.sel.pad = pad;
>  	u.sel.stream = stream;
> @@ -210,6 +246,11 @@ int v4l2_subdev_set_routing(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_ROUTING, &routing);
>  	if (ret == -1)
>  		return -errno;
> @@ -231,6 +272,9 @@ int v4l2_subdev_get_routing(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams)

No need for a debug message here ?

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> +		return -ENOTSUP;
> +
>  	ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_ROUTING, &routing);
>  	if (ret == -1 && errno != ENOSPC)
>  		return -errno;
> @@ -341,6 +385,11 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&ival, 0, sizeof(ival));
>  	ival.pad = pad;
>  	ival.stream = stream;
> @@ -364,6 +413,11 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,
>  	if (ret < 0)
>  		return ret;
>  
> +	if (!entity->supports_streams && stream) {
> +		media_dbg(entity->media, "Streams API not supported\n");
> +		return -ENOTSUP;
> +	}
> +
>  	memset(&ival, 0, sizeof(ival));
>  	ival.pad = pad;
>  	ival.stream = stream;
> diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
> index a0d3a55a..eb55e07e 100644
> --- a/utils/media-ctl/mediactl-priv.h
> +++ b/utils/media-ctl/mediactl-priv.h
> @@ -33,6 +33,7 @@ struct media_entity {
>  	struct media_link *links;
>  	unsigned int max_links;
>  	unsigned int num_links;
> +	bool supports_streams;
>  
>  	char devname[32];
>  	int fd;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-04-24  7:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 12:44 [PATCH v4 0/8] v4l-utils: Support multiplexed streams Tomi Valkeinen
2023-04-21 12:44 ` [PATCH v4 1/8] v4l2-ctl: Add routing and streams support Tomi Valkeinen
2023-04-24  7:04   ` Laurent Pinchart
2023-05-29  7:02     ` Tomi Valkeinen
2023-05-29  7:47       ` Laurent Pinchart
2023-04-21 12:44 ` [PATCH v4 2/8] media-ctl: Add support for routes and streams Tomi Valkeinen
2023-04-24  7:29   ` Laurent Pinchart
2023-05-29  7:34     ` Tomi Valkeinen
2023-05-29  7:49       ` Laurent Pinchart
2023-05-29  8:14         ` Tomi Valkeinen
2023-04-21 12:44 ` [PATCH v4 3/8] v4l2-ctl/compliance: Add routing and streams multiplexed streams Tomi Valkeinen
2023-04-21 12:44 ` [PATCH v4 4/8] v4l2-ctl/compliance: Add simple routing test Tomi Valkeinen
2023-04-24  8:04   ` Laurent Pinchart
2023-04-21 12:44 ` [PATCH v4 5/8] HACK: include/linux: Add client capabilities Tomi Valkeinen
2023-04-24  7:32   ` Laurent Pinchart
2023-05-25 14:05     ` Hans Verkuil
2023-05-26  8:19       ` Tomi Valkeinen
2023-04-21 12:44 ` [PATCH v4 6/8] media-ctl: Check for Streams API support Tomi Valkeinen
2023-04-24  7:54   ` Laurent Pinchart [this message]
2023-04-21 12:44 ` [PATCH v4 7/8] utils/common: Set V4L2_SUBDEV_CLIENT_CAP_STREAMS for subdevs Tomi Valkeinen
2023-04-24  8:01   ` Laurent Pinchart
2023-04-21 12:44 ` [PATCH v4 8/8] v4l2-ctl: Check for Streams API support Tomi Valkeinen
2023-04-24  8:03   ` Laurent Pinchart

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=20230424075454.GF4926@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sakari.ailus@linux.intel.com \
    --cc=satish.nagireddy@getcruise.com \
    --cc=tomi.valkeinen@ideasonboard.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