From: Ricardo Ribalda <ribalda@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH v2 1/7] media: uvcvideo: Allow custom control mapping
Date: Mon, 10 Jun 2024 23:09:52 +0000 [thread overview]
Message-ID: <20240610-billion-v2-1-38e861475f85@chromium.org> (raw)
In-Reply-To: <20240610-billion-v2-0-38e861475f85@chromium.org>
Some advanced controls might not be completely implemented by vendors.
If the controls are a enumeration, UVC does not gives a way to probe
what is implemented and what is not.
Let's create a new callback function where heuristics can be implemented
to detect what is implemented and what not.
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_ctrl.c | 10 +++++++++-
drivers/media/usb/uvc/uvcvideo.h | 5 +++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index e59a463c2761..44ec185a8c8b 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2360,7 +2360,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl,
/*
* Add a control mapping to a given control.
*/
-static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
+static int __uvc_ctrl_add_mapping_to_list(struct uvc_video_chain *chain,
struct uvc_control *ctrl, const struct uvc_control_mapping *mapping)
{
struct uvc_control_mapping *map;
@@ -2434,6 +2434,14 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
return -ENOMEM;
}
+static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
+ struct uvc_control *ctrl, const struct uvc_control_mapping *mapping)
+{
+ if (mapping && mapping->add_mapping)
+ return mapping->add_mapping(chain, ctrl, mapping);
+ return __uvc_ctrl_add_mapping_to_list(chain, ctrl, mapping);
+}
+
int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
const struct uvc_control_mapping *mapping)
{
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 6fb0a78b1b00..fa0396dd5b35 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -84,7 +84,9 @@
struct gpio_desc;
struct sg_table;
+struct uvc_control;
struct uvc_device;
+struct uvc_video_chain;
/*
* TODO: Put the most frequently accessed fields at the beginning of
@@ -123,6 +125,9 @@ struct uvc_control_mapping {
s32 master_manual;
u32 slave_ids[2];
+ int (*add_mapping)(struct uvc_video_chain *chain,
+ struct uvc_control *ctrl,
+ const struct uvc_control_mapping *mapping);
s32 (*get)(struct uvc_control_mapping *mapping, u8 query,
const u8 *data);
void (*set)(struct uvc_control_mapping *mapping, s32 value,
--
2.45.2.505.gda0bf45e8d-goog
next prev parent reply other threads:[~2024-06-10 23:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 23:09 [PATCH v2 0/7] media: uvc: Probe PLF limits at start-up Ricardo Ribalda
2024-06-10 23:09 ` Ricardo Ribalda [this message]
2024-06-16 23:06 ` [PATCH v2 1/7] media: uvcvideo: Allow custom control mapping Laurent Pinchart
2024-06-10 23:09 ` [PATCH v2 2/7] media: uvcvideo: Refactor Power Line Frequency limit selection Ricardo Ribalda
2024-06-16 23:03 ` Laurent Pinchart
2024-06-10 23:09 ` [PATCH v2 3/7] media: uvcvideo: Probe the PLF characteristics Ricardo Ribalda
2024-06-16 23:04 ` Laurent Pinchart
2024-06-10 23:09 ` [PATCH v2 4/7] media: uvcvideo: Cleanup version-specific mapping Ricardo Ribalda
2024-06-10 23:09 ` [PATCH v2 5/7] media: uvcvideo: Remove PLF device quirking Ricardo Ribalda
2024-06-16 23:05 ` Laurent Pinchart
2024-06-10 23:09 ` [PATCH v2 6/7] media: uvcvideo: Remove mappings form uvc_device_info Ricardo Ribalda
2024-06-16 23:05 ` Laurent Pinchart
2024-06-10 23:09 ` [PATCH v2 7/7] media: uvcvideo: Replace get_mapping with filter_mapping Ricardo Ribalda
2024-06-16 22:17 ` 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=20240610-billion-v2-1-38e861475f85@chromium.org \
--to=ribalda@chromium.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=senozhatsky@chromium.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
all inboxes | Powered by JetHome®