Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com,
	hongju.wang@intel.com, hverkuil@xs4all.nl,
	Andrey Konovalov <andrey.konovalov@linaro.org>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Dmitry Perchanov <dmitry.perchanov@intel.com>,
	"Ng, Khai Wen" <khai.wen.ng@intel.com>,
	Alain Volmat <alain.volmat@foss.st.com>
Subject: [PATCH v2 13/14] media: v4l: subdev: Return routes set using S_ROUTING
Date: Fri, 26 Apr 2024 00:27:10 +0300	[thread overview]
Message-ID: <20240425212711.928300-14-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20240425212711.928300-1-sakari.ailus@linux.intel.com>

Return the routes set using S_ROUTING back to the user. Also reflect this
in documentation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .../media/v4l/vidioc-subdev-g-routing.rst            |  7 ++-----
 drivers/media/v4l2-core/v4l2-subdev.c                | 12 +++++++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
index cbd9370006b6..1cf795480602 100644
--- a/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
+++ b/Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
@@ -44,7 +44,8 @@ Drivers report their current routing tables using the
 ``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes
 with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and
 setting or clearing flags of the ``flags`` field of a struct
-:c:type:`v4l2_subdev_route`.
+:c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also
+``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user.
 
 All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called.
 This means that the userspace must reconfigure all stream formats and selections
@@ -153,10 +154,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set
 appropriately. The generic error codes are described at the
 :ref:`Generic Error Codes <gen-errors>` chapter.
 
-ENOSPC
-   The application provided ``num_routes`` is not big enough to contain
-   all the available routes the subdevice exposes.
-
 EINVAL
    The sink or source pad identifiers reference a non-existing pad or reference
    pads of different types (ie. the sink_pad identifiers refers to a source
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index b565f202df67..3d1ed8ab5229 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1017,8 +1017,18 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
 		krouting.len_routes = routing->len_routes;
 		krouting.routes = routes;
 
-		return v4l2_subdev_call(sd, pad, set_routing, state,
+		rval = v4l2_subdev_call(sd, pad, set_routing, state,
 					routing->which, &krouting);
+		if (rval < 0)
+			return rval;
+
+		memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes,
+		       state->routing.routes,
+		       min(state->routing.num_routes, routing->len_routes) *
+		       sizeof(*state->routing.routes));
+		routing->num_routes = state->routing.num_routes;
+
+		return 0;
 	}
 
 	case VIDIOC_SUBDEV_G_CLIENT_CAP: {
-- 
2.39.2


  parent reply	other threads:[~2024-04-25 21:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 21:26 [PATCH v2 00/14] Generic line based metadata, without sensor API changes Sakari Ailus
2024-04-25 21:26 ` [PATCH v2 01/14] media: v4l2-subdev: Clearly document that the crop API won't be extended Sakari Ailus
2024-04-25 21:26 ` [PATCH v2 02/14] media: Documentation: Add "stream" into glossary Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 03/14] media: uapi: Add generic serial metadata mbus formats Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 04/14] media: uapi: Document which mbus format fields are valid for metadata Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 05/14] media: uapi: v4l: Add generic 8-bit metadata format definitions Sakari Ailus
2024-04-26  8:05   ` [PATCH v2.1 " Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 06/14] media: v4l: Support line-based metadata capture Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 07/14] media: v4l: Set line based metadata flag in V4L2 core Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 08/14] media: Documentation: Additional streams generally don't harm capture Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 09/14] media: Documentation: Document S_ROUTING behaviour Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 10/14] media: v4l: subdev: Add a function to lock two sub-device states, use it Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 11/14] media: v4l: subdev: Copy argument back to user also for S_ROUTING Sakari Ailus
2024-04-25 21:27 ` [PATCH v2 12/14] media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing Sakari Ailus
2024-04-25 21:27 ` Sakari Ailus [this message]
2024-04-25 21:27 ` [PATCH v2 14/14] media: v4l: subdev: Add trivial set_routing support Sakari Ailus

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=20240425212711.928300-14-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=alain.volmat@foss.st.com \
    --cc=andrey.konovalov@linaro.org \
    --cc=bingbu.cao@intel.com \
    --cc=dmitry.perchanov@intel.com \
    --cc=hongju.wang@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=khai.wen.ng@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).