public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* imx7-media-csi: Adding BT656 format
@ 2025-11-18 15:39 Matthias Weißer
  2025-12-01 16:23 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Weißer @ 2025-11-18 15:39 UTC (permalink / raw)
  To: linux-media
  Cc: Rui Miguel Silva, Purism Kernel Team, Laurent Pinchart,
	Martin Kepplinger

Hi

I am hoping for some basic help here regarding a feature I want to add to
to imx7-media-csi.c.

(taking the maintainers in CC, hoping this is okay)

If this is not the right place to ask my stupid questions please advice.

I have a custom board with a TW9990 analog video decoder connected
to an iMX6SX. For the TW9990 I use a slightly modified version of
tw9910.c. I use the following DT:

&i2c3 {
    tvin1@44 {
        compatible = "renesas,tw9990";
        reg = <0x44>;

        port {
            tw9990_1_to_parallel: endpoint {
                remote-endpoint = <&parallel_from_tw9990_1>;
                bus-width = <8>;
                data-shift = <2>; /* your board wiring */
                hsync-active = <0>;
                vsync-active = <0>;
                pclk-sample = <1>;
                bus-type = <MEDIA_BUS_TYPE_BT656>;
            };
        };
    };
};

&csi1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_csi1>;
    status = "okay";

    port {
        parallel_from_tw9990_1: endpoint {
            remote-endpoint = <&tw9990_1_to_parallel>;
            bus-width = <8>;
            bus-type = <MEDIA_BUS_TYPE_BT656>;
        };
    };
};

Issuing this command

# v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=50 --stream-to=frame.raw

enables the TW9990 and it starts streaming the analog video signal in
BT656 format to the iMX. I verified that using an osscilloscope.
But I see no interrupt generated by the CSI module. I am sure I have to
add BT656 format handling to the driver but have no idea where to start.

I have also verified that the hardware is working correctly by implementing
a simple capture driver, not in the context of v4l2, but with my own very
hakish uio implementation.

Some maybe helpful outputs:

# media-ctl -v -p
Opening media device /dev/media0
Enumerating entities
looking up device: 81:1
looking up device: 81:0
looking up device: 81:2
Found 3 entities
Enumerating pads and links
Media controller API version 6.6.52

Media device information
------------------------
driver          imx7-csi
model           imx-media
serial
bus info        platform:2214000.csi
hw revision     0x0
driver version  6.6.52

Device topology
Streams API not supported
- entity 1: csi (2 pads, 2 links, 0 routes)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        pad0: SINK
                [stream:0 fmt:UYVY8_2X8/640x480 field:none
colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
                <- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
        pad1: SOURCE
                [stream:0 fmt:UYVY8_2X8/640x480 field:none
colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
                -> "csi capture":0 [ENABLED,IMMUTABLE]

- entity 4: csi capture (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
        pad0: SINK
                <- "csi":1 [ENABLED,IMMUTABLE]

Streams API not supported
- entity 10: tw9910 2-0044 (1 pad, 1 link, 0 routes)
             type V4L2 subdev subtype Decoder flags 0
             device node name /dev/v4l-subdev1
        pad0: SOURCE
                [stream:0 fmt:UYVY8_2X8/640x480 field:interlaced-bt
colorspace:smpte170m
                 crop.bounds:(0,0)/640x480
                 crop:(0,0)/640x480]
                -> "csi":0 [ENABLED,IMMUTABLE]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: imx7-media-csi: Adding BT656 format
  2025-11-18 15:39 imx7-media-csi: Adding BT656 format Matthias Weißer
@ 2025-12-01 16:23 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2025-12-01 16:23 UTC (permalink / raw)
  To: Matthias Weißer
  Cc: linux-media, Rui Miguel Silva, Purism Kernel Team,
	Martin Kepplinger

Hi Matthias,

On Tue, Nov 18, 2025 at 04:39:57PM +0100, Matthias Weißer wrote:
> Hi
> 
> I am hoping for some basic help here regarding a feature I want to add to
> to imx7-media-csi.c.
> 
> (taking the maintainers in CC, hoping this is okay)
> 
> If this is not the right place to ask my stupid questions please advice.

This is the right place, and your question isn't stupid.

> I have a custom board with a TW9990 analog video decoder connected
> to an iMX6SX. For the TW9990 I use a slightly modified version of
> tw9910.c. I use the following DT:
> 
> &i2c3 {
>     tvin1@44 {
>         compatible = "renesas,tw9990";
>         reg = <0x44>;
> 
>         port {
>             tw9990_1_to_parallel: endpoint {
>                 remote-endpoint = <&parallel_from_tw9990_1>;
>                 bus-width = <8>;
>                 data-shift = <2>; /* your board wiring */
>                 hsync-active = <0>;
>                 vsync-active = <0>;
>                 pclk-sample = <1>;
>                 bus-type = <MEDIA_BUS_TYPE_BT656>;
>             };
>         };
>     };
> };
> 
> &csi1 {
>     pinctrl-names = "default";
>     pinctrl-0 = <&pinctrl_csi1>;
>     status = "okay";
> 
>     port {
>         parallel_from_tw9990_1: endpoint {
>             remote-endpoint = <&tw9990_1_to_parallel>;
>             bus-width = <8>;
>             bus-type = <MEDIA_BUS_TYPE_BT656>;
>         };
>     };
> };
> 
> Issuing this command
> 
> # v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=50 --stream-to=frame.raw
> 
> enables the TW9990 and it starts streaming the analog video signal in
> BT656 format to the iMX. I verified that using an osscilloscope.
> But I see no interrupt generated by the CSI module. I am sure I have to
> add BT656 format handling to the driver but have no idea where to start.

The driver indeed doesn't seem to support BT656. 

> I have also verified that the hardware is working correctly by implementing
> a simple capture driver, not in the context of v4l2, but with my own very
> hakish uio implementation.

Does that mean that you know what register values to set to get it
working ? If so things shouldn't be too difficult. The driver should
call v4l2_fwnode_endpoint_parse() to parse the endpoint and get the bus
type (external sync or BT656). The information should be stored in the
imx7_csi structure, and the registers should then be configured
accordingly (likely in imx7_csi_configure()).

Interlaced mode seems to be implemented in the driver, so if you're
lucky the above will be all you need. If there are issues with the
interlace implementation (I don't think it has been tested as
extensively as progressive mode) then more work may be required.

> Some maybe helpful outputs:
> 
> # media-ctl -v -p
> Opening media device /dev/media0
> Enumerating entities
> looking up device: 81:1
> looking up device: 81:0
> looking up device: 81:2
> Found 3 entities
> Enumerating pads and links
> Media controller API version 6.6.52
> 
> Media device information
> ------------------------
> driver          imx7-csi
> model           imx-media
> serial
> bus info        platform:2214000.csi
> hw revision     0x0
> driver version  6.6.52
> 
> Device topology
> Streams API not supported
> - entity 1: csi (2 pads, 2 links, 0 routes)
>             type V4L2 subdev subtype Unknown flags 0
>             device node name /dev/v4l-subdev0
>         pad0: SINK
>                 [stream:0 fmt:UYVY8_2X8/640x480 field:none
> colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
>                 <- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
>         pad1: SOURCE
>                 [stream:0 fmt:UYVY8_2X8/640x480 field:none
> colorspace:smpte170m xfer:709 ycbcr:601 quantization:lim-range]
>                 -> "csi capture":0 [ENABLED,IMMUTABLE]
> 
> - entity 4: csi capture (1 pad, 1 link)
>             type Node subtype V4L flags 0
>             device node name /dev/video0
>         pad0: SINK
>                 <- "csi":1 [ENABLED,IMMUTABLE]
> 
> Streams API not supported
> - entity 10: tw9910 2-0044 (1 pad, 1 link, 0 routes)
>              type V4L2 subdev subtype Decoder flags 0
>              device node name /dev/v4l-subdev1
>         pad0: SOURCE
>                 [stream:0 fmt:UYVY8_2X8/640x480 field:interlaced-bt
> colorspace:smpte170m
>                  crop.bounds:(0,0)/640x480
>                  crop:(0,0)/640x480]
>                 -> "csi":0 [ENABLED,IMMUTABLE]

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-01 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 15:39 imx7-media-csi: Adding BT656 format Matthias Weißer
2025-12-01 16:23 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox