Skip to contentSkip to conversation

media: uvcvideo:Create input device for all uvc devices with status endpoints.

PATCH NAK chenchangcheng 3 participants 6 messages Nov 4, 2024 – Nov 5, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: uvcvideo:Create input device for all uvc devices with status endpoints.

Some applications need to check if there is an input device on the camera before proceeding to the next step. When there is no input device, the application will report an error.
Create input device for all uvc devices with status endpoints. and only when bTriggerSupport and bTriggerUsage are one are allowed to report camera button.

Fixes 3bc22dc66a4f ("media: uvcvideo: Only create input devs if hw supports it")
---
 drivers/media/usb/uvc/uvc_status.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/media/usb/uvc/uvc_status.c +6 -7
index a78a88c710e2..177640c6a813 100644
@@ -44,9 +44,6 @@ static int uvc_input_init(struct uvc_device *dev)
 	struct input_dev *input;
 	int ret;
 
-	if (!uvc_input_has_button(dev))
-		return 0;
-
 	input = input_allocate_device();
 	if (input == NULL)
 		return -ENOMEM;
@@ -110,10 +107,12 @@ static void uvc_event_streaming(struct uvc_device *dev,
 		if (len <= offsetof(struct uvc_status, streaming))
 			return;
 
-		uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
-			status->bOriginator,
-			status->streaming.button ? "pressed" : "released", len);
-		uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
+		if (uvc_input_has_button(dev)) {
+			uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
+				status->bOriginator,
+				status->streaming.button ? "pressed" : "released", len);
+			uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
+		}
 	} else {
 		uvc_dbg(dev, STATUS, "Stream %u error event %02x len %d\n",
 			status->bOriginator, status->bEvent, len);
Signature · 1 line
2.25.1
#1 lore raw
FYI: kernel test robot notices the stable kernel rule is not satisfied.

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] media: uvcvideo:Create input device for all uvc devices with status endpoints.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to chenchangcheng
kernel test robot noticed the following build errors:

Hi chenchangcheng,

kernel test robot noticed the following build errors:

[auto build test ERROR on linuxtv-media-stage/master]
[also build test ERROR on linus/master media-tree/master v6.12-rc6 next-20241101] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/chenchangcheng/media-uvcvideo-Create-input-device-for-all-uvc-devices-with-status-endpoints/20241104-104225
base:   https://git.linuxtv.org/media_stage.git master
patch link:    https://lore.kernel.org/r/20241104023947.826707-1-ccc194101%40163.com
patch subject: [PATCH] media: uvcvideo:Create input device for all uvc devices with status endpoints.
config: i386-buildonly-randconfig-003-20241104 (https://download.01.org/0day-ci/archive/20241104/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/media/usb/uvc/uvc_status.c:16:
In file included from drivers/media/usb/uvc/uvcvideo.h:17:
In file included from include/media/media-device.h:16:
In file included from include/linux/pci.h:1650:
In file included from include/linux/dmapool.h:14:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2213:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> drivers/media/usb/uvc/uvc_status.c:110:7: error: call to undeclared function 'uvc_input_has_button'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     110 |                 if (uvc_input_has_button(dev)) {
         |                     ^

1 warning and 1 error generated.

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for MODVERSIONS
Depends on [n]: MODULES [=y] && !COMPILE_TEST [=y]
Selected by [y]:
- RANDSTRUCT_FULL [=y] && (CC_HAS_RANDSTRUCT [=y] || GCC_PLUGINS [=n]) && MODULES [=y]

vim +/uvc_input_has_button +110 drivers/media/usb/uvc/uvc_status.c

    93	
    94	/* --------------------------------------------------------------------------
    95	 * Status interrupt endpoint
    96	 */
    97	static void uvc_event_streaming(struct uvc_device *dev,
    98					struct uvc_status *status, int len)
    99	{
   100		if (len <= offsetof(struct uvc_status, bEvent)) {
   101			uvc_dbg(dev, STATUS,
   102				"Invalid streaming status event received\n");
   103			return;
   104		}
   105	
   106		if (status->bEvent == 0) {
   107			if (len <= offsetof(struct uvc_status, streaming))
   108				return;
   109	
 > 110			if (uvc_input_has_button(dev)) {

111 uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
112 status->bOriginator,
113 status->streaming.button ? "pressed" : "released", len);
114 uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
115 }
116 } else {
117 uvc_dbg(dev, STATUS, "Stream %u error event %02x len %d\n",
118 status->bOriginator, status->bEvent, len);
119 }
120 }
121

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to chenchangcheng

Em Mon, 4 Nov 2024 10:39:47 +0800
chenchangcheng <[email protected]> escreveu:

Quoted 3 lines

Some applications need to check if there is an input device on the camera before proceeding to the next step. When there is no input device, the application will report an error.

Nack.

It is not mandatory for V4L2 devices to create input devices.

It sounds to me that this is an application bug, not a Kernel one. What applications have such bug?

Quoted 3 lines

Create input device for all uvc devices with status endpoints. and only when bTriggerSupport and bTriggerUsage are one are allowed to report camera button.

Please fix the application instead.

Quoted 2 lines
Fixes 3bc22dc66a4f ("media: uvcvideo: Only create input devs if hw supports it")

Regards,
Mauro

Quoted 28 lines
---
 drivers/media/usb/uvc/uvc_status.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/media/usb/uvc/uvc_status.c +0 -3
index a78a88c710e2..177640c6a813 100644
@@ -44,9 +44,6 @@ static int uvc_input_init(struct uvc_device *dev)
 	struct input_dev *input;
 	int ret;
 
-	if (!uvc_input_has_button(dev))
-		return 0;
-
 
 
 	input = input_allocate_device();
drivers/media/usb/uvc/uvc_status.c +0 -3
 	if (input == NULL)
 		return -ENOMEM;
@@ -110,10 +107,12 @@ static void uvc_event_streaming(struct uvc_device *dev,
 		if (len <= offsetof(struct uvc_status, streaming))
 			return;
 
-		uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
-			status->bOriginator,
-			status->streaming.button ? "pressed" : "released", len);

drivers/media/usb/uvc/uvc_status.c static void uvc_event_streaming(struct uvc_device *dev, · line 118

Quoted 10 lines
drivers/media/usb/uvc/uvc_status.c +6 -1
-		uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
+		if (uvc_input_has_button(dev)) {
+			uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
+				status->bOriginator,
+				status->streaming.button ? "pressed" : "released", len);
+			uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
+		}
 	} else {
 		uvc_dbg(dev, STATUS, "Stream %u error event %02x len %d\n",
 			status->bOriginator, status->bEvent, len);

Thanks,
Mauro

#4 lore raw

hi Mauro:

Quoted 5 lines

It sounds to me that this is an application bug, not a Kernel one.

What applications have such bug?

??? This is a testing application produced by a third-party company, and the modification is mainly aimed at improving compatibility.

??? And retaining nodes has no harm and is more suitable for application scenarios.

--------------

[email protected]

Quoted 681 lines

Em Mon,? 4 Nov 2024 10:39:47 +0800

chenchangcheng <[email protected]> escreveu:

Quoted 20 lines

Some applications need to check if there is an input device on the camera

before proceeding to the next step. When there is no input device,

Quoted 1 line

the application will report an error.

Nack.

It is not mandatory for V4L2 devices to create input devices.

It sounds to me that this is an application bug, not a Kernel one.

What applications have such bug?

Quoted 20 lines

Create input device for all uvc devices with status endpoints.

and only when bTriggerSupport and bTriggerUsage are one are

Quoted 1 line

allowed to report camera button.

Please fix the application instead.

Quoted 11 lines
Fixes 3bc22dc66a4f ("media: uvcvideo: Only create input devs if hw supports it")

Regards,

Mauro

Quoted 370 lines

---

? drivers/media/usb/uvc/uvc_status.c | 13 ++++++-------

? 1 file changed, 6 insertions(+), 7 deletions(-)

drivers/media/usb/uvc/uvc_status.c +0 -0

index a78a88c710e2..177640c6a813 100644

--- a/drivers/media/usb/uvc/uvc_status.c

+++ b/drivers/media/usb/uvc/uvc_status.c

drivers/media/usb/uvc/uvc_status.c +0 -0
@@ -44,9 +44,6 @@ static int uvc_input_init(struct uvc_device *dev)
 
 
 
 
 
 

? struct input_dev *input;

? int ret;

?

drivers/media/usb/uvc/uvc_status.c +0 -3
-	if (!uvc_input_has_button(dev))
 
 
 
 
 
 
 
 
 
-		return 0;
 
 
 
 
 
 
 
 
 
-

? input = input_allocate_device();

? if (input == NULL)

? return -ENOMEM;

drivers/media/usb/uvc/uvc_status.c +0 -0
@@ -110,10 +107,12 @@ static void uvc_event_streaming(struct uvc_device *dev,
 
 
 
 
 
 
 
 
 
 ? 		if (len <= offsetof(struct uvc_status, streaming))

? return;

?

drivers/media/usb/uvc/uvc_status.c +6 -4
-		uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
 
 
 
 
 
 
 
 
 
-			status->bOriginator,
 
 
 
 
 
 
 
 
 
-			status->streaming.button ? "pressed" : "released", len);
 
 
 
 
 
 
 
 
 
-		uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
 
 
 
 
 
 
 
 
 
+		if (uvc_input_has_button(dev)) {
 
 
 
 
 
 
 
 
 
+			uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
 
 
 
 
 
 
 
 
 
+				status->bOriginator,
 
 
 
 
 
 
 
 
 
+				status->streaming.button ? "pressed" : "released", len);
 
 
 
 
 
 
 
 
 
+			uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
 
 
 
 
 
 
 
 
 
+		}

? } else {

? uvc_dbg(dev, STATUS, "Stream %u error event %02x len %d\n",

Quoted 1 line

? status->bOriginator, status->bEvent, len);

Thanks,

Mauro

#5 lore raw
In reply to chenchangcheng
kernel test robot noticed the following build errors:

Hi chenchangcheng,

kernel test robot noticed the following build errors:

[auto build test ERROR on linuxtv-media-stage/master]
[also build test ERROR on linus/master v6.12-rc6 next-20241101] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/chenchangcheng/media-uvcvideo-Create-input-device-for-all-uvc-devices-with-status-endpoints/20241104-104225
base:   https://git.linuxtv.org/media_stage.git master
patch link:    https://lore.kernel.org/r/20241104023947.826707-1-ccc194101%40163.com
patch subject: [PATCH] media: uvcvideo:Create input device for all uvc devices with status endpoints.
config: x86_64-buildonly-randconfig-001-20241104 (https://download.01.org/0day-ci/archive/20241104/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/media/usb/uvc/uvc_status.c: In function 'uvc_event_streaming':

>> drivers/media/usb/uvc/uvc_status.c:110:21: error: implicit declaration of function 'uvc_input_has_button' [-Werror=implicit-function-declaration]
     110 |                 if (uvc_input_has_button(dev)) {
         |                     ^~~~~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +/uvc_input_has_button +110 drivers/media/usb/uvc/uvc_status.c

    93	
    94	/* --------------------------------------------------------------------------
    95	 * Status interrupt endpoint
    96	 */
    97	static void uvc_event_streaming(struct uvc_device *dev,
    98					struct uvc_status *status, int len)
    99	{
   100		if (len <= offsetof(struct uvc_status, bEvent)) {
   101			uvc_dbg(dev, STATUS,
   102				"Invalid streaming status event received\n");
   103			return;
   104		}
   105	
   106		if (status->bEvent == 0) {
   107			if (len <= offsetof(struct uvc_status, streaming))
   108				return;
   109	
 > 110			if (uvc_input_has_button(dev)) {

111 uvc_dbg(dev, STATUS, "Button (intf %u) %s len %d\n",
112 status->bOriginator,
113 status->streaming.button ? "pressed" : "released", len);
114 uvc_input_report_key(dev, KEY_CAMERA, status->streaming.button);
115 }
116 } else {
117 uvc_dbg(dev, STATUS, "Stream %u error event %02x len %d\n",
118 status->bOriginator, status->bEvent, len);
119 }
120 }
121

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki