media: bcm2835-unicam: Fix querycap multiple caps
Subsystems (4)
PATCH 1/1 media: bcm2835-unicam: Fix querycap multiple caps
The unicam exposes two video nodes, one for image, another for metadata. Querycap should return the right caps for the respective node, not both.
video0:
Capabilities : 0xa4200001
Video Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x24200001
Video Capture
I/O MC
Streaming
Extended Pix Format
video1:
Capabilities : 0xa4a00000
Metadata Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x24a00000
Metadata Capture
I/O MC
Streaming
Extended Pix Format
--- drivers/media/platform/broadcom/bcm2835-unicam.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/broadcom/bcm2835-unicam.c +4 -1
@@ -1833,7 +1833,10 @@ static int unicam_querycap(struct file *file, void *priv,strscpy (cap->driver,UNICAM_MODULE_NAME ,sizeof (cap->driver));strscpy (cap->card,UNICAM_MODULE_NAME ,sizeof (cap->card)); - cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_META_CAPTURE ; +if (is_image_node (node)) + cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE ; +else + cap->capabilities |=V4L2_CAP_META_CAPTURE ;return 0 ; }
---
base-commit: a87737435cfa134f9cdcc696ba3080759d04cf72
change-id: 20260611-bcmpiqcap-f893a9ea2da9
Best regards,
Signature · 1 line
Eugen Hristev <[email protected]>
Hi Eugen,
Thank you for the patch.
Two issues with this one, I'm afraid.
Le 11/06/2026 à 08:09, Eugen Hristev a écrit :
Quoted 42 lines
The unicam exposes two video nodes, one for image, another for metadata. Querycap should return the right caps for the respective node, not both.
video0:
Capabilities :
0xa4200001
Video Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps :0x24200001
Video Capture
I/O MC
Streaming
Extended Pix Formatvideo1:
Capabilities :
0xa4a00000
Metadata Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps :0x24a00000
Metadata Capture
I/O MC
Streaming
Extended Pix FormatFixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>--- drivers/media/platform/broadcom/bcm2835-unicam.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/media/platform/broadcom/bcm2835-unicam.c +0
-0
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_querycap(struct file *file, void *priv, · line 1836
Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1@@ -1833,7 +1833,10 @@ static int unicam_querycap(struct file *file, void *priv,strscpy (cap->driver,UNICAM_MODULE_NAME ,sizeof (cap->driver));strscpy (cap->card,UNICAM_MODULE_NAME ,sizeof (cap->card)); - cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_META_CAPTURE ; +if (is_image_node (node))
First, it does not compile, as node is not declared here. 'struct unicam_node *node = video_drvdata(file);' would be needed.
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_querycap(struct file *file, void *priv, · line 1842
Quoted 7 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +3
-0+ cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE ; + else + cap->capabilities |= V4L2_CAP_META_CAPTURE;return 0 ; }
Second, and more important, I don't think the current behaviour is a bug. Documentation/userspace-api/media/v4l/vidioc-querycap.rst states about the 'capabilities' field:
"The capabilities field should contain a union of all capabilities available around the several V4L2 devices exported to userspace. For all those devices the capabilities field returns the same set of capabilities."
Per-node differentiation is the job of 'device_caps', which unicam already sets correctly when registering each video device (your v4l2-ctl output shows the Device Caps are already right).
So this looks like working as intended to me, and the patch should be dropped.
Thanks,
JM
Quoted 8 lines
---
base-commit:a87737435cfa134f9cdcc696ba3080759d04cf72
change-id: 20260611-bcmpiqcap-f893a9ea2da9Best regards,
--
Eugen Hristev <[email protected]>
Re: {Spam?} Re: [PATCH] media: bcm2835-unicam: Fix querycap multiple caps
Quoted 52 lines · Jean-Michel Hautbois
Hi Eugen,
Thank you for the patch.
Two issues with this one, I'm afraid.
Le 11/06/2026 à 08:09, Eugen Hristev a écrit :
Quoted 45 lines
The unicam exposes two video nodes, one for image, another for metadata. Querycap should return the right caps for the respective node, not both.
video0:
Capabilities :
0xa4200001
Video Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps :0x24200001
Video Capture
I/O MC
Streaming
Extended Pix Formatvideo1:
Capabilities :
0xa4a00000
Metadata Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps :0x24a00000
Metadata Capture
I/O MC
Streaming
Extended Pix FormatFixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>--- drivers/media/platform/broadcom/bcm2835-unicam.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/media/platform/broadcom/bcm2835-unicam.c +0
-0@@ -1833,7 +1833,10 @@ static int unicam_querycap(struct file *file, void *priv,strscpy (cap->driver,UNICAM_MODULE_NAME ,sizeof (cap->driver));strscpy (cap->card,UNICAM_MODULE_NAME ,sizeof (cap->card));
Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_querycap(struct file *file, void *priv, · line 1836
Quoted 2 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1- cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_META_CAPTURE ; +if (is_image_node (node))First, it does not compile, as node is not declared here. 'struct
unicam_node*node =video_drvdata(file);' would be needed.
Sorry, my brain must have been sleeping
Quoted 18 lines
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_querycap(struct file *file, void *priv, · line 1842
Quoted 8 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +3
-0+ cap->capabilities |=V4L2_CAP_VIDEO_CAPTURE ; + else + cap->capabilities |= V4L2_CAP_META_CAPTURE;return 0 ; }Second, and more important, I don't think the current behaviour is a bug.
Documentation/userspace-api/media/v4l/vidioc-querycap.rststates about the 'capabilities' field:"The capabilities field should contain a union of all capabilities available around the several V4L2 devices exported to userspace. For all those devices the capabilities field returns the same set of capabilities."
Quoted 6 lines
Per-node differentiation is the job of '
device_caps', which unicam already sets correctly when registering each video device (your v4l2-ctl output shows the Device Caps are already right).So this looks like working as intended to me, and the patch should be dropped.
Thanks for taking the time to explain.
Let's drop the patch.
Eugen
Quoted 13 lines
Thanks,
JMQuoted 8 lines
---
base-commit:a87737435cfa134f9cdcc696ba3080759d04cf72
change-id: 20260611-bcmpiqcap-f893a9ea2da9Best regards,
--
Eugen Hristev <[email protected]>
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Eugen,
kernel test robot noticed the following build errors:
[auto build test ERROR on a87737435cfa134f9cdcc696ba3080759d04cf72]
url: https://github.com/intel-lab-lkp/linux/commits/Eugen-Hristev/media-bcm2835-unicam-Fix-querycap-multiple-caps/20260611-141320 base: a87737435cfa134f9cdcc696ba3080759d04cf72 patch link: https://lore.kernel.org/r/20260611-bcmpiqcap-v1-1-10cf7fb438df%40kernel.org patch subject: [PATCH] media: bcm2835-unicam: Fix querycap multiple caps config: um-allmodconfig (https://download.01.org/0day-ci/archive/20260612/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260612/[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/platform/broadcom/bcm2835-unicam.c:33:
In file included from include/linux/dma-mapping.h:8:
In file included from include/linux/scatterlist.h:9:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:1209:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
1209 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
| ~~~~~~~~~~ ^
>> drivers/media/platform/broadcom/bcm2835-unicam.c:1836:20: error: use of undeclared identifier 'node'
1836 | if (is_image_node(node))
| ^1 warning and 1 error generated.
vim +/node +1836 drivers/media/platform/broadcom/bcm2835-unicam.c
1825
1826 /* -----------------------------------------------------------------------------
1827 * V4L2 video device operations
1828 */
1829
1830 static int unicam_querycap(struct file *file, void *priv,
1831 struct v4l2_capability *cap)
1832 {
1833 strscpy(cap->driver, UNICAM_MODULE_NAME, sizeof(cap->driver));
1834 strscpy(cap->card, UNICAM_MODULE_NAME, sizeof(cap->card));
1835
> 1836 if (is_image_node(node))
1837 cap->capabilities |= V4L2_CAP_VIDEO_CAPTURE;
1838 else
1839 cap->capabilities |= V4L2_CAP_META_CAPTURE;
1840
1841 return 0;
1842 }
1843
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Eugen,
kernel test robot noticed the following build errors:
[auto build test ERROR on a87737435cfa134f9cdcc696ba3080759d04cf72]
url: https://github.com/intel-lab-lkp/linux/commits/Eugen-Hristev/media-bcm2835-unicam-Fix-querycap-multiple-caps/20260611-141320 base: a87737435cfa134f9cdcc696ba3080759d04cf72 patch link: https://lore.kernel.org/r/20260611-bcmpiqcap-v1-1-10cf7fb438df%40kernel.org patch subject: [PATCH] media: bcm2835-unicam: Fix querycap multiple caps config: arc-allmodconfig (https://download.01.org/0day-ci/archive/20260612/[email protected]/config) compiler: arc-linux-gcc (GCC) 16.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260612/[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/platform/broadcom/bcm2835-unicam.c: In function 'unicam_querycap':
>> drivers/media/platform/broadcom/bcm2835-unicam.c:1836:27: error: 'node' undeclared (first use in this function)
1836 | if (is_image_node(node))
| ^~~~ drivers/media/platform/broadcom/bcm2835-unicam.c:1836:27: note: each undeclared identifier is reported only once for each function it appears in
vim +/node +1836 drivers/media/platform/broadcom/bcm2835-unicam.c
1825
1826 /* -----------------------------------------------------------------------------
1827 * V4L2 video device operations
1828 */
1829
1830 static int unicam_querycap(struct file *file, void *priv,
1831 struct v4l2_capability *cap)
1832 {
1833 strscpy(cap->driver, UNICAM_MODULE_NAME, sizeof(cap->driver));
1834 strscpy(cap->card, UNICAM_MODULE_NAME, sizeof(cap->card));
1835
> 1836 if (is_image_node(node))
1837 cap->capabilities |= V4L2_CAP_VIDEO_CAPTURE;
1838 else
1839 cap->capabilities |= V4L2_CAP_META_CAPTURE;
1840
1841 return 0;
1842 }
1843
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki