[PATCH v3 07/12] dt-bindings: media: Add usb-camera-module

Ricardo Ribalda posted 12 patches 5 days, 9 hours ago
[PATCH v3 07/12] dt-bindings: media: Add usb-camera-module
Posted by Ricardo Ribalda 5 days, 9 hours ago
For fixed cameras modules the OS needs to know where they are mounted.
This information is used to determine if images need to be rotated or
not.

ACPI has a property for this purpose, which is parsed by
acpi_get_physical_device_location():
https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#pld-physical-location-of-device

In DT we have similar properties for video-interface-devices called
orientation and rotation:
Documentation/devicetree/bindings/media/video-interface-devices.yaml

Add a new schema that combines usb/usb-device.yaml and
media/video-interface-devices.yaml

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 .../bindings/media/usb-camera-module.yaml          | 46 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 47 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/usb-camera-module.yaml b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..e4ad6f557b9151751522e49b72ae6584deb0c7ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/usb-camera-module.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: USB Camera Module
+
+maintainers:
+  - Ricardo Ribalda <ribalda@chromium.org>
+
+description: |
+  This schema allows for annotating auxiliary information for fixed camera
+  modules. This information enables the system to determine if incoming frames
+  require rotation, mirroring, or other transformations. It also describes the
+  module's relationship with other hardware elements, such as flash LEDs or
+  Voice Coil Motors (VCMs).
+
+allOf:
+  - $ref: /schemas/usb/usb-device.yaml#
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  reg:
+    maxItems: 1
+
+required:
+  - reg
+
+additionalProperties: true
+
+examples:
+  - |
+    usb@11270000 {
+        reg = <0x11270000 0x1000>;
+        interrupts = <0x0 0x4e 0x0>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        device@1 {
+            compatible = "usb123,4567";
+            reg = <2>;
+            orientation = <0>;
+            rotation = <90>;
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index ee8cb2db483f6a5e96b62b6f2edd05b1427b69f5..1503502a3aed2625e8ff488456ccd7305cc74ba7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26258,6 +26258,7 @@ L:	linux-media@vger.kernel.org
 S:	Maintained
 W:	http://www.ideasonboard.org/uvc/
 T:	git git://linuxtv.org/media.git
+F:	Documentation/devicetree/bindings/media/usb-camera-module.yaml
 F:	Documentation/userspace-api/media/drivers/uvcvideo.rst
 F:	Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst
 F:	Documentation/userspace-api/media/v4l/metafmt-uvc.rst

-- 
2.51.0.536.g15c5d4f767-goog
Re: [PATCH v3 07/12] dt-bindings: media: Add usb-camera-module
Posted by Conor Dooley 5 days, 5 hours ago
On Fri, Sep 26, 2025 at 01:11:31PM +0000, Ricardo Ribalda wrote:
> For fixed cameras modules the OS needs to know where they are mounted.
> This information is used to determine if images need to be rotated or
> not.
> 
> ACPI has a property for this purpose, which is parsed by
> acpi_get_physical_device_location():
> https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#pld-physical-location-of-device
> 
> In DT we have similar properties for video-interface-devices called
> orientation and rotation:
> Documentation/devicetree/bindings/media/video-interface-devices.yaml
> 
> Add a new schema that combines usb/usb-device.yaml and
> media/video-interface-devices.yaml
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  .../bindings/media/usb-camera-module.yaml          | 46 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 47 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/usb-camera-module.yaml b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..e4ad6f557b9151751522e49b72ae6584deb0c7ba
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> @@ -0,0 +1,46 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/media/usb-camera-module.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: USB Camera Module
> +
> +maintainers:
> +  - Ricardo Ribalda <ribalda@chromium.org>
> +
> +description: |
> +  This schema allows for annotating auxiliary information for fixed camera
> +  modules. This information enables the system to determine if incoming frames
> +  require rotation, mirroring, or other transformations. It also describes the
> +  module's relationship with other hardware elements, such as flash LEDs or
> +  Voice Coil Motors (VCMs).
> +
> +allOf:
> +  - $ref: /schemas/usb/usb-device.yaml#
> +  - $ref: /schemas/media/video-interface-devices.yaml#
> +
> +properties:
> +  reg:
> +    maxItems: 1
> +

What actually causes this schema to be applied? Did I miss it getting
included somewhere?

> +required:
> +  - reg
> +
> +additionalProperties: true
> +
> +examples:
> +  - |
> +    usb@11270000 {
> +        reg = <0x11270000 0x1000>;
> +        interrupts = <0x0 0x4e 0x0>;
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        device@1 {
> +            compatible = "usb123,4567";
> +            reg = <2>;
> +            orientation = <0>;
> +            rotation = <90>;
> +        };
> +    };
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ee8cb2db483f6a5e96b62b6f2edd05b1427b69f5..1503502a3aed2625e8ff488456ccd7305cc74ba7 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -26258,6 +26258,7 @@ L:	linux-media@vger.kernel.org
>  S:	Maintained
>  W:	http://www.ideasonboard.org/uvc/
>  T:	git git://linuxtv.org/media.git
> +F:	Documentation/devicetree/bindings/media/usb-camera-module.yaml
>  F:	Documentation/userspace-api/media/drivers/uvcvideo.rst
>  F:	Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst
>  F:	Documentation/userspace-api/media/v4l/metafmt-uvc.rst
> 
> -- 
> 2.51.0.536.g15c5d4f767-goog
> 
Re: [PATCH v3 07/12] dt-bindings: media: Add usb-camera-module
Posted by Ricardo Ribalda 2 days, 13 hours ago
Hi Conor

On Fri, 26 Sept 2025 at 18:55, Conor Dooley <conor@kernel.org> wrote:
>
> On Fri, Sep 26, 2025 at 01:11:31PM +0000, Ricardo Ribalda wrote:
> > For fixed cameras modules the OS needs to know where they are mounted.
> > This information is used to determine if images need to be rotated or
> > not.
> >
> > ACPI has a property for this purpose, which is parsed by
> > acpi_get_physical_device_location():
> > https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#pld-physical-location-of-device
> >
> > In DT we have similar properties for video-interface-devices called
> > orientation and rotation:
> > Documentation/devicetree/bindings/media/video-interface-devices.yaml
> >
> > Add a new schema that combines usb/usb-device.yaml and
> > media/video-interface-devices.yaml
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> >  .../bindings/media/usb-camera-module.yaml          | 46 ++++++++++++++++++++++
> >  MAINTAINERS                                        |  1 +
> >  2 files changed, 47 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/media/usb-camera-module.yaml b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> > new file mode 100644
> > index 0000000000000000000000000000000000000000..e4ad6f557b9151751522e49b72ae6584deb0c7ba
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> > @@ -0,0 +1,46 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/media/usb-camera-module.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: USB Camera Module
> > +
> > +maintainers:
> > +  - Ricardo Ribalda <ribalda@chromium.org>
> > +
> > +description: |
> > +  This schema allows for annotating auxiliary information for fixed camera
> > +  modules. This information enables the system to determine if incoming frames
> > +  require rotation, mirroring, or other transformations. It also describes the
> > +  module's relationship with other hardware elements, such as flash LEDs or
> > +  Voice Coil Motors (VCMs).
> > +
> > +allOf:
> > +  - $ref: /schemas/usb/usb-device.yaml#
> > +  - $ref: /schemas/media/video-interface-devices.yaml#
> > +
> > +properties:
> > +  reg:
> > +    maxItems: 1
> > +
>
> What actually causes this schema to be applied? Did I miss it getting
> included somewhere?

I guess your question is why I have not defined the compatible field?

I tried this change[1] with no luck:
/usr/local/google/home/ribalda/work/linux/Documentation/devicetree/bindings/media/uvc-camera.example.dtb:
device@1 (uvc-camera): compatible: ['uvc-camera'] does not contain
items matching the given schema

I think it failed, because If we add these allOfs as Rob proposed
https://lore.kernel.org/all/20250625185608.GA2010256-robh@kernel.org/:
```
allOf:
  - $ref: /schemas/usb/usb-device.yaml#
  - $ref: /schemas/media/video-interface-devices.yaml#
```
We cannot (or I do not know how to) have a different compatible than
the one from usb-device.yaml


Any suggestion on how to do this properly will be highly appreciated :)

Thanks!



[1]

@@ -21,10 +21,14 @@ allOf:
   - $ref: /schemas/media/video-interface-devices.yaml#

 properties:
+  compatible:
+    const: uvc-camera
+
   reg:
     maxItems: 1

 required:
+  - compatible
   - reg

 additionalProperties: true
@@ -38,8 +42,8 @@ examples:
         #size-cells = <0>;

         device@1 {
-            compatible = "usb123,4567";
+           compatible = "uvc-camera";
             reg = <2>;
             orientation = <0>;
             rotation = <90>;
         };

>
> > +required:
> > +  - reg
> > +
> > +additionalProperties: true
> > +
> > +examples:
> > +  - |
> > +    usb@11270000 {
> > +        reg = <0x11270000 0x1000>;
> > +        interrupts = <0x0 0x4e 0x0>;
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        device@1 {
> > +            compatible = "usb123,4567";
> > +            reg = <2>;
> > +            orientation = <0>;
> > +            rotation = <90>;
> > +        };
> > +    };
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index ee8cb2db483f6a5e96b62b6f2edd05b1427b69f5..1503502a3aed2625e8ff488456ccd7305cc74ba7 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -26258,6 +26258,7 @@ L:    linux-media@vger.kernel.org
> >  S:   Maintained
> >  W:   http://www.ideasonboard.org/uvc/
> >  T:   git git://linuxtv.org/media.git
> > +F:   Documentation/devicetree/bindings/media/usb-camera-module.yaml
> >  F:   Documentation/userspace-api/media/drivers/uvcvideo.rst
> >  F:   Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst
> >  F:   Documentation/userspace-api/media/v4l/metafmt-uvc.rst
> >
> > --
> > 2.51.0.536.g15c5d4f767-goog
> >



--
Ricardo Ribalda
Re: [PATCH v3 07/12] dt-bindings: media: Add usb-camera-module
Posted by Conor Dooley 2 days, 3 hours ago
On Mon, Sep 29, 2025 at 10:30:35AM +0200, Ricardo Ribalda wrote:
> Hi Conor
> 
> On Fri, 26 Sept 2025 at 18:55, Conor Dooley <conor@kernel.org> wrote:
> >
> > On Fri, Sep 26, 2025 at 01:11:31PM +0000, Ricardo Ribalda wrote:
> > > For fixed cameras modules the OS needs to know where they are mounted.
> > > This information is used to determine if images need to be rotated or
> > > not.
> > >
> > > ACPI has a property for this purpose, which is parsed by
> > > acpi_get_physical_device_location():
> > > https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#pld-physical-location-of-device
> > >
> > > In DT we have similar properties for video-interface-devices called
> > > orientation and rotation:
> > > Documentation/devicetree/bindings/media/video-interface-devices.yaml
> > >
> > > Add a new schema that combines usb/usb-device.yaml and
> > > media/video-interface-devices.yaml
> > >
> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > > ---
> > >  .../bindings/media/usb-camera-module.yaml          | 46 ++++++++++++++++++++++
> > >  MAINTAINERS                                        |  1 +
> > >  2 files changed, 47 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/media/usb-camera-module.yaml b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> > > new file mode 100644
> > > index 0000000000000000000000000000000000000000..e4ad6f557b9151751522e49b72ae6584deb0c7ba
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/media/usb-camera-module.yaml
> > > @@ -0,0 +1,46 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/media/usb-camera-module.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: USB Camera Module
> > > +
> > > +maintainers:
> > > +  - Ricardo Ribalda <ribalda@chromium.org>
> > > +
> > > +description: |
> > > +  This schema allows for annotating auxiliary information for fixed camera
> > > +  modules. This information enables the system to determine if incoming frames
> > > +  require rotation, mirroring, or other transformations. It also describes the
> > > +  module's relationship with other hardware elements, such as flash LEDs or
> > > +  Voice Coil Motors (VCMs).
> > > +
> > > +allOf:
> > > +  - $ref: /schemas/usb/usb-device.yaml#
> > > +  - $ref: /schemas/media/video-interface-devices.yaml#
> > > +
> > > +properties:
> > > +  reg:
> > > +    maxItems: 1
> > > +
> >
> > What actually causes this schema to be applied? Did I miss it getting
> > included somewhere?
> 
> I guess your question is why I have not defined the compatible field?
> 
> I tried this change[1] with no luck:
> /usr/local/google/home/ribalda/work/linux/Documentation/devicetree/bindings/media/uvc-camera.example.dtb:
> device@1 (uvc-camera): compatible: ['uvc-camera'] does not contain
> items matching the given schema
> 
> I think it failed, because If we add these allOfs as Rob proposed
> https://lore.kernel.org/all/20250625185608.GA2010256-robh@kernel.org/:
> ```
> allOf:
>   - $ref: /schemas/usb/usb-device.yaml#
>   - $ref: /schemas/media/video-interface-devices.yaml#
> ```
> We cannot (or I do not know how to) have a different compatible than
> the one from usb-device.yaml
> 
> 
> Any suggestion on how to do this properly will be highly appreciated :)

It'd work, I think, if you permitted the pattern from usb-device as a
fallback compatible. I don't know if that would work for whatever niche
you're attempting to fill here though.

Probably a Rob question ultimately.

> 
> Thanks!
> 
> 
> 
> [1]
> 
> @@ -21,10 +21,14 @@ allOf:
>    - $ref: /schemas/media/video-interface-devices.yaml#
> 
>  properties:
> +  compatible:
> +    const: uvc-camera
> +
>    reg:
>      maxItems: 1
> 
>  required:
> +  - compatible
>    - reg
> 
>  additionalProperties: true
> @@ -38,8 +42,8 @@ examples:
>          #size-cells = <0>;
> 
>          device@1 {
> -            compatible = "usb123,4567";
> +           compatible = "uvc-camera";
>              reg = <2>;
>              orientation = <0>;
>              rotation = <90>;
>          };
> 
> >
> > > +required:
> > > +  - reg
> > > +
> > > +additionalProperties: true
> > > +
> > > +examples:
> > > +  - |
> > > +    usb@11270000 {
> > > +        reg = <0x11270000 0x1000>;
> > > +        interrupts = <0x0 0x4e 0x0>;
> > > +        #address-cells = <1>;
> > > +        #size-cells = <0>;
> > > +
> > > +        device@1 {
> > > +            compatible = "usb123,4567";
> > > +            reg = <2>;
> > > +            orientation = <0>;
> > > +            rotation = <90>;
> > > +        };
> > > +    };
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index ee8cb2db483f6a5e96b62b6f2edd05b1427b69f5..1503502a3aed2625e8ff488456ccd7305cc74ba7 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -26258,6 +26258,7 @@ L:    linux-media@vger.kernel.org
> > >  S:   Maintained
> > >  W:   http://www.ideasonboard.org/uvc/
> > >  T:   git git://linuxtv.org/media.git
> > > +F:   Documentation/devicetree/bindings/media/usb-camera-module.yaml
> > >  F:   Documentation/userspace-api/media/drivers/uvcvideo.rst
> > >  F:   Documentation/userspace-api/media/v4l/metafmt-uvc-msxu-1-5.rst
> > >  F:   Documentation/userspace-api/media/v4l/metafmt-uvc.rst
> > >
> > > --
> > > 2.51.0.536.g15c5d4f767-goog
> > >
> 
> 
> 
> --
> Ricardo Ribalda
>