linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Maxime Ripard" <maxime.ripard@bootlin.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>,
	"Marco Franchi" <marco.franchi@nxp.com>,
	"Icenowy Zheng" <icenowy@aosc.io>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Keiichi Watanabe" <keiichiw@chromium.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Smitha T Murthy" <smitha.t@samsung.com>,
	"Tom Saeger" <tom.saeger@oracle.com>,
	"Andrzej Hajda" <a.hajda@samsung.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
	"Jacob Chen" <jacob-chen@iotwrt.com>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	"Benoit Parrot" <bparrot@ti.com>,
	"Todor Tomov" <todor.tomov@linaro.org>,
	"Alexandre Courbot" <acourbot@chromium.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Pawel Osciak" <posciak@chromium.org>,
	"Ricardo Ribalda Delgado" <ricardo.ribalda@gmail.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	linux-sunxi@googlegroups.com,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Hugues Fruchet" <hugues.fruchet@st.com>,
	"Randy Li" <ayaka@soulik.info>,
	"Hans Verkuil" <hans.verkuil@cisco.com>
Subject: [PATCH v5 01/22] v4l2-ctrls: add v4l2_ctrl_request_hdl_find/put/ctrl_find functions
Date: Tue, 10 Jul 2018 10:00:53 +0200	[thread overview]
Message-ID: <20180710080114.31469-2-paul.kocialkowski@bootlin.com> (raw)
In-Reply-To: <20180710080114.31469-1-paul.kocialkowski@bootlin.com>

From: Hans Verkuil <hverkuil@xs4all.nl>

If a driver needs to find/inspect the controls set in a request then
it can use these functions.

E.g. to check if a required control is set in a request use this in the
req_validate() implementation:

	int res = -EINVAL;

	hdl = v4l2_ctrl_request_hdl_find(req, parent_hdl);
	if (hdl) {
		if (v4l2_ctrl_request_hdl_ctrl_find(hdl, ctrl_id))
			res = 0;
		v4l2_ctrl_request_hdl_put(hdl);
	}
	return res;

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 25 ++++++++++++++++
 include/media/v4l2-ctrls.h           | 44 +++++++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 86a6ae54ccaa..198b7e924d21 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -2976,6 +2976,31 @@ static const struct media_request_object_ops req_ops = {
 	.release = v4l2_ctrl_request_release,
 };
 
+struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
+					struct v4l2_ctrl_handler *parent)
+{
+	struct media_request_object *obj;
+	
+	if (WARN_ON(req->state != MEDIA_REQUEST_STATE_VALIDATING &&
+		    req->state != MEDIA_REQUEST_STATE_QUEUED))
+		return NULL;
+
+	obj = media_request_object_find(req, &req_ops, parent);
+	if (obj)
+		return container_of(obj, struct v4l2_ctrl_handler, req_obj);
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(v4l2_ctrl_request_hdl_find);
+
+struct v4l2_ctrl *
+v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id)
+{
+	struct v4l2_ctrl_ref *ref = find_ref_lock(hdl, id);
+
+	return (ref && ref->req == ref) ? ref : NULL;
+}
+EXPORT_SYMBOL_GPL(v4l2_ctrl_request_hdl_ctrl_find);
+
 static int v4l2_ctrl_request_bind(struct media_request *req,
 			   struct v4l2_ctrl_handler *hdl,
 			   struct v4l2_ctrl_handler *from)
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index de70cc3a1b80..34ee3167d7dd 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -1111,7 +1111,49 @@ void v4l2_ctrl_request_setup(struct media_request *req,
  * request object.
  */
 void v4l2_ctrl_request_complete(struct media_request *req,
-				struct v4l2_ctrl_handler *hdl);
+				struct v4l2_ctrl_handler *parent);
+
+/**
+ * v4l2_ctrl_request_hdl_find - Find the control handler in the request
+ *
+ * @req: The request
+ * @parent: The parent control handler ('priv' in media_request_object_find())
+ *
+ * This function finds the control handler in the request. It may return
+ * NULL if not found. When done, you must call v4l2_ctrl_request_put_hdl()
+ * with the returned handler pointer.
+ *
+ * If the request is not in state VALIDATING or QUEUED, then this function
+ * will always return NULL.
+ */
+struct v4l2_ctrl_handler *v4l2_ctrl_request_hdl_find(struct media_request *req,
+					struct v4l2_ctrl_handler *parent);
+
+/**
+ * v4l2_ctrl_request_hdl_put - Put the control handler
+ *
+ * @hdl: Put this control handler
+ *
+ * This function released the control handler previously obtained from'
+ * v4l2_ctrl_request_hdl_find().
+ */
+static inline void v4l2_ctrl_request_hdl_put(struct v4l2_ctrl_handler *hdl)
+{
+	if (hdl)
+		media_request_object_put(&hdl->req_obj);
+}
+
+/**
+ * v4l2_ctrl_request_ctrl_find() - Find a control with the given ID.
+ *
+ * @hdl: The control handler from the request.
+ * @id: The ID of the control to find.
+ *
+ * This function returns a pointer to the control if this control is
+ * part of the request or NULL otherwise.
+ */
+struct v4l2_ctrl *
+v4l2_ctrl_request_hdl_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
 
 /* Helpers for ioctl_ops */
 
-- 
2.17.1


  reply	other threads:[~2018-07-10  8:08 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10  8:00 [PATCH v5 00/22] Sunxi-Cedrus driver for the Allwinner Video Engine, using media requests Paul Kocialkowski
2018-07-10  8:00 ` Paul Kocialkowski [this message]
2018-07-10  8:00 ` [PATCH v5 02/22] fixup! v4l2-ctrls: add v4l2_ctrl_request_hdl_find/put/ctrl_find functions Paul Kocialkowski
2018-07-10  8:07   ` Geert Uytterhoeven
2018-07-10  8:13     ` Paul Kocialkowski
2018-07-10  8:17       ` Hans Verkuil
2018-07-10  8:21         ` Paul Kocialkowski
2018-07-10  8:00 ` [PATCH v5 03/22] dt-bindings: sram: sunxi: Introduce new A10 binding for system-control Paul Kocialkowski
2018-07-10 14:02   ` Chen-Yu Tsai
2018-07-11  8:34   ` Maxime Ripard
2018-07-10  8:00 ` [PATCH v5 04/22] dt-bindings: sram: sunxi: Add A13, A20, A23 and H3 dedicated bindings Paul Kocialkowski
2018-07-10 14:36   ` Chen-Yu Tsai
2018-07-11  8:46     ` Maxime Ripard
2018-07-10  8:00 ` [PATCH v5 05/22] dt-bindings: sram: sunxi: Populate valid sections compatibles Paul Kocialkowski
2018-07-10 14:47   ` Chen-Yu Tsai
2018-07-11  8:55     ` Maxime Ripard
2018-07-10  8:00 ` [PATCH v5 06/22] soc: sunxi: sram: Add dt match for the A10 system-control compatible Paul Kocialkowski
2018-07-10 14:48   ` Chen-Yu Tsai
2018-07-11  8:35   ` Maxime Ripard
2018-07-10  8:00 ` [PATCH v5 07/22] drivers: soc: sunxi: Add support for the C1 SRAM region Paul Kocialkowski
2018-07-10 14:49   ` Chen-Yu Tsai
2018-07-10  8:01 ` [PATCH v5 08/22] ARM: dts: sun4i-a10: Use system-control compatible Paul Kocialkowski
2018-07-10 14:52   ` Chen-Yu Tsai
2018-07-10 14:58     ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 09/22] ARM: dts: sun5i: Use most-qualified system control compatibles Paul Kocialkowski
2018-07-10 14:53   ` [linux-sunxi] " Chen-Yu Tsai
2018-07-11  9:01     ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 10/22] ARM: dts: sun7i-a20: " Paul Kocialkowski
2018-07-10 14:54   ` [linux-sunxi] " Chen-Yu Tsai
2018-07-10  8:01 ` [PATCH v5 11/22] ARM: sun5i: Add support for the C1 SRAM region with the SRAM controller Paul Kocialkowski
2018-07-10 14:56   ` Chen-Yu Tsai
2018-07-11  9:08     ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 12/22] ARM: sun7i-a20: " Paul Kocialkowski
2018-07-11  9:11   ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 13/22] ARM: sun8i-a23-a33: Add SRAM controller node and C1 SRAM region Paul Kocialkowski
2018-07-11  9:14   ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 14/22] ARM: sun8i-h3: " Paul Kocialkowski
2018-07-11  9:15   ` Maxime Ripard
2018-07-10  8:01 ` [PATCH v5 15/22] media: v4l: Add definitions for MPEG2 slice format and header metadata Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 16/22] media: v4l: Add definition for Allwinner's MB32-tiled NV12 format Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 17/22] dt-bindings: media: Document bindings for the Sunxi-Cedrus VPU driver Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 18/22] media: platform: Add Sunxi-Cedrus VPU decoder driver Paul Kocialkowski
2018-07-10  8:42   ` Maxime Ripard
2018-07-24 14:56     ` Paul Kocialkowski
2018-07-10 19:57   ` Ezequiel Garcia
2018-07-13  8:40     ` Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 19/22] ARM: dts: sun5i: Add Video Engine and reserved memory nodes Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 20/22] ARM: dts: sun7i-a20: " Paul Kocialkowski
2018-07-10  9:23   ` Maxime Ripard
2018-07-13  8:28     ` Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 21/22] ARM: dts: sun8i-a33: " Paul Kocialkowski
2018-07-10  8:01 ` [PATCH v5 22/22] ARM: dts: sun8i-h3: " Paul Kocialkowski

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=20180710080114.31469-2-paul.kocialkowski@bootlin.com \
    --to=paul.kocialkowski@bootlin.com \
    --cc=a.hajda@samsung.com \
    --cc=acourbot@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=ayaka@soulik.info \
    --cc=bparrot@ti.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hans.verkuil@cisco.com \
    --cc=hdegoede@redhat.com \
    --cc=hugues.fruchet@st.com \
    --cc=hverkuil@xs4all.nl \
    --cc=icenowy@aosc.io \
    --cc=jacob-chen@iotwrt.com \
    --cc=keiichiw@chromium.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=marco.franchi@nxp.com \
    --cc=mark.rutland@arm.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=mchehab@kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=posciak@chromium.org \
    --cc=rdunlap@infradead.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=samitolvanen@google.com \
    --cc=smitha.t@samsung.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=todor.tomov@linaro.org \
    --cc=tom.saeger@oracle.com \
    --cc=wens@csie.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).