2cc4cff177586febe032992dc26362b26eccc6ed
[openwrt/staging/ansuel.git] /
1 From df490e112fa3285ba73edbc33e02a41dad5e4d2e Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jakub=20Van=C4=9Bk?= <linuxtardis@gmail.com>
3 Date: Wed, 7 Jul 2021 22:48:20 +0200
4 Subject: [PATCH] media: bcm2835-unicam: Forward input status from
5 subdevice
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 The vidioc_enum_input() v4l2 ioctl is capable of returning
11 sensor/input status as well. This is used in current
12 GStreamer HEAD for signal detection [1].
13
14 bcm2835-unicam does handle this syscall, but it didn't ask
15 the subdevice driver about the input status. The input then
16 appeared as always present.
17
18 This commit adds the necessary query. There is a precedent for
19 this - the R-Car VIN V4L2 driver does a similar call [2].
20
21 [1]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/ce0be27caf69aa9d96b73bc2b50737451b6f6936/sys/v4l2/gstv4l2src.c#L553
22 [2]: https://github.com/raspberrypi/linux/blob/7fb9d006d3ff3baf2e205e0c85c4e4fd0a64fcd0/drivers/media/platform/rcar-vin/rcar-v4l2.c#L548
23
24 Signed-off-by: Jakub Vaněk <linuxtardis@gmail.com>
25 ---
26 drivers/media/platform/bcm2835/bcm2835-unicam.c | 9 +++++++++
27 1 file changed, 9 insertions(+)
28
29 --- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
30 +++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
31 @@ -1809,6 +1809,7 @@ static int unicam_enum_input(struct file
32 {
33 struct unicam_node *node = video_drvdata(file);
34 struct unicam_device *dev = node->dev;
35 + int ret;
36
37 if (inp->index != 0)
38 return -EINVAL;
39 @@ -1825,6 +1826,14 @@ static int unicam_enum_input(struct file
40 inp->capabilities = 0;
41 inp->std = 0;
42 }
43 +
44 + if (v4l2_subdev_has_op(dev->sensor, video, g_input_status)) {
45 + ret = v4l2_subdev_call(dev->sensor, video, g_input_status,
46 + &inp->status);
47 + if (ret < 0)
48 + return ret;
49 + }
50 +
51 snprintf(inp->name, sizeof(inp->name), "Camera 0");
52 return 0;
53 }