Skip to contentSkip to conversation

i.MX Media Driver

PATCH Superseded Steve Longerbeam 14 participants 229 messages Feb 16, 2017 – Mar 26, 2017 Page 1 of 2

Subsystems (14)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Steve Longerbeam

author maintainer
#0 lore raw

v4 cover i.MX Media Driver

In version 4:

Changes suggested by Philipp Zabel <[email protected]> and Jean-Michel Hautbois <[email protected]>:

- split out VDIC from imx-ic-prpvf into a distinct VDIC subdev.

Changes suggested by Philipp Zabel <[email protected]>:

- Re-org of pre-process entities. Created an ipuX_ic_prp entity that receives on a single sink pad from the CSIs and the VDIC. Two source pads route to ipuX_ic_prpenc and ipuX_ic_prpvf. The code for ipuX_ic_prpenc and ipuX_ic_prpvf is now identical, which adds rotation to ipuX_ic_prpvf.

- renamed media node in DT to capture-subsystem, compatible string to "fsl,imx-capture-subsystem".

- the ov564x subdevs get the xclk rate from clk_get_rate() instead of attempting to change the rate. "xclk" property in ov564x DT nodes is removed.

- changed "pix" clock to IMX6QDL_CLK_EIM_PODF in mipi_csi node.

- added comptible string "snps,dw-mipi-csi2" to mipi_csi node in DT.

- silenced many of the v4l2_info()'s.

- move conversion of ALTERNATE field type to SEQ_BT/TB to output pad of ipuX_csiY entity.

- added bounds checks to set_fmt in ipuX_csiY and ipuX_vdic entities.

- Get rid of SMFC entity. CSI frame output via SMFC and IDMAC channel is now built into the CSI entities via a new source pad. So CSI entities now have two source pads : direct and IDMAC.

- the IPU internal pads (direct between subunuits, not via IDMAC channels), should only accept the pixel formats used internally by the IPU:
MEDIA_BUS_FMT_AYUV8_1X32 and MEDIA_BUS_FMT_ARGB8888_1X32.

- export V4L2_EVENT_IMX_EOF_TIMEOUT as V4L2_EVENT_FRAME_TIMEOUT for general use.

- export imx_media_inherit_controls() as v4l2_pipeline_inherit_controls() for general use.

- completely removed dma_buf ring support. There is no capture interface or ic-pp subdevs any longer. The CSI and ic-prp enc/vf subdevs now attach directly to a capture device node from their IDMAC (non-direct) source pads.

Changes suggested by Javier Martinez Canillas <[email protected]>:

- add missing MODULE_DEVICE_TABLE() to video mux subdev.

Changes suggested by Hans Verkuil <[email protected]>:

- entity function type MEDIA_ENT_F_MUX renamed to MEDIA_ENT_F_VID_MUX.

- removed use of g_mbus_config subdev op. Sensor bus config is instead gotten from the sensor DT node via v4l2_of_parse_endpoint().

- use v4l2_ctrl_handler_setup() for restoring current control values in the ov564x subdevs, rather than a custom control cache.

Changes suggested by Russell King <[email protected]>:

- re-ordered clock lane and data lane # assignments in device tree.

- fixed module unload.

- propagate the return code from ipu_ic_task_idma_init(), don't start streaming if it returned error!

Changes suggested by Laurent Pinchart <[email protected]>:

- ov5640 subdev is improved and moved to drivers/media/i2c, along with binding docs. The ov5642 subdev has been dropped for now.

- regulator DT properties are now required in ov5640 subdev, and resewt/power GPIOs are optional. Created dummy regulator nodes in imx6qdl-sabrelite.dtsi for the ov5640 node (the ov5640 regulators are fixed regulators on the OV5640 module for sabrelite).

- removed use of endpoint ID in device tree as a way to specify a MIPI CSI-2 virtual channel for the OV5640. The ov5640 subdev now hard-codes the virtual channel to 1 until a new subdev API becomes available to allow run-time virtual channel selection.

Other changes:

- v4l2-compliance fixes.

- since dma_buf ring support is gone, the VDIC subdev is modified to potentially receive frames from a future output device node on its IDMAC sink pad.

- fixed mbus pixel format enumeration and selection. The source pads and capture device select the correct formats based on the sink formats. For example the capture device can only report and allow selecting an RGB format if the attached source pad's format is RGB. Likewise for YUV space, with the added benefit that the capture device can select a YUV planar format in this case, and the attached subdev will comply and output planar.

- stripped out sensor input OF properties and parsing for now. It is problematic since there is currently no subdev op so that the bridge can retrieve this information and use for VIDIOC_{ENUM|S|G}_INPUT.

- modified imx6-mipi-csi2 subdev to comply strictly with the MIPI CSI-2 startup sequence described in the i.MX6 reference manual.

Philipp Zabel (6):
ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their
connections
add mux and video interface bridge entity functions
platform: add video-multiplexer subdevice driver
media: imx: csi: fix crop rectangle changes in set_fmt
media: imx: csi: add frame skipping support
media: imx: csi: fix crop rectangle reset in sink set_fmt

Russell King (3):
media: imx: add support for bayer formats
media: imx: csi: add support for bayer formats
media: imx: mipi-csi2: enable setting and getting of frame rates

Steve Longerbeam (27):
[media] dt-bindings: Add bindings for i.MX media driver
ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node
ARM: dts: imx6qdl: add capture-subsystem device
ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround
ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors
ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors
ARM: dts: imx6-sabreauto: create i2cmux for i2c3
ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b
ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture
ARM: dts: imx6-sabreauto: add the ADV7180 video decoder [media] v4l2: add a frame timeout event
[media] v4l2-mc: add a function to inherit controls from a pipeline
UAPI: Add media UAPI Kbuild file
media: Add userspace header file for i.MX
media: Add i.MX media core driver
media: imx: Add Capture Device Interface
media: imx: Add CSI subdev driver
media: imx: Add VDIC subdev driver
media: imx: Add IC subdev drivers
media: imx: Add MIPI CSI-2 Receiver subdev driver [media] add Omnivision OV5640 sensor driver
ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers
media: imx: update capture dev format on IDMAC output pad set_fmt
media: imx: csi: add __csi_get_fmt
media: imx: csi/fim: add support for frame intervals
media: imx: redo pixel format enumeration and negotiation
media: imx: propagate sink pad formats to source pads

 .../devicetree/bindings/media/i2c/ov5640.txt       |   43 +
 Documentation/devicetree/bindings/media/imx.txt    |   66 +
 .../bindings/media/video-multiplexer.txt           |   59 +
 Documentation/media/uapi/mediactl/media-types.rst  |   22 +
 Documentation/media/uapi/v4l/vidioc-dqevent.rst    |    5 +
 Documentation/media/v4l-drivers/imx.rst            |  542 +++++
 Documentation/media/videodev2.h.rst.exceptions     |    1 +
 arch/arm/boot/dts/imx6dl-sabrelite.dts             |    5 +
 arch/arm/boot/dts/imx6dl-sabresd.dts               |    5 +
 arch/arm/boot/dts/imx6dl.dtsi                      |  185 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts              |    5 +
 arch/arm/boot/dts/imx6q-sabresd.dts                |    5 +
 arch/arm/boot/dts/imx6q.dtsi                       |  121 ++
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |  144 +-
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi           |  152 +-
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |  114 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |   17 +-
 arch/arm/configs/imx_v6_v7_defconfig               |   14 +-
 drivers/media/i2c/Kconfig                          |    7 +
 drivers/media/i2c/Makefile                         |    1 +
 drivers/media/i2c/ov5640.c                         | 2109 ++++++++++++++++++++
 drivers/media/platform/Kconfig                     |    8 +
 drivers/media/platform/Makefile                    |    2 +
 drivers/media/platform/video-multiplexer.c         |  474 +++++
 drivers/media/v4l2-core/v4l2-mc.c                  |   48 +
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/imx/Kconfig                  |   20 +
 drivers/staging/media/imx/Makefile                 |   12 +
 drivers/staging/media/imx/TODO                     |   36 +
 drivers/staging/media/imx/imx-ic-common.c          |  113 ++
 drivers/staging/media/imx/imx-ic-prp.c             |  458 +++++
 drivers/staging/media/imx/imx-ic-prpencvf.c        | 1138 +++++++++++
 drivers/staging/media/imx/imx-ic.h                 |   38 +
 drivers/staging/media/imx/imx-media-capture.c      |  671 +++++++
 drivers/staging/media/imx/imx-media-csi.c          | 1483 ++++++++++++++
 drivers/staging/media/imx/imx-media-dev.c          |  487 +++++
 drivers/staging/media/imx/imx-media-fim.c          |  463 +++++
 drivers/staging/media/imx/imx-media-internal-sd.c  |  349 ++++
 drivers/staging/media/imx/imx-media-of.c           |  267 +++
 drivers/staging/media/imx/imx-media-utils.c        |  930 +++++++++
 drivers/staging/media/imx/imx-media-vdic.c         |  915 +++++++++
 drivers/staging/media/imx/imx-media.h              |  305 +++
 drivers/staging/media/imx/imx6-mipi-csi2.c         |  600 ++++++
 include/media/imx.h                                |   15 +
 include/media/v4l2-mc.h                            |   25 +
 include/uapi/Kbuild                                |    1 +
 include/uapi/linux/media.h                         |    6 +
 include/uapi/linux/v4l2-controls.h                 |    4 +
 include/uapi/linux/videodev2.h                     |    1 +
 include/uapi/media/Kbuild                          |    2 +
 include/uapi/media/imx.h                           |   29 +
 52 files changed, 12496 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt
 create mode 100644 Documentation/devicetree/bindings/media/video-multiplexer.txt
 create mode 100644 Documentation/media/v4l-drivers/imx.rst
 create mode 100644 drivers/media/i2c/ov5640.c
 create mode 100644 drivers/media/platform/video-multiplexer.c
 create mode 100644 drivers/staging/media/imx/Kconfig
 create mode 100644 drivers/staging/media/imx/Makefile
 create mode 100644 drivers/staging/media/imx/TODO
 create mode 100644 drivers/staging/media/imx/imx-ic-common.c
 create mode 100644 drivers/staging/media/imx/imx-ic-prp.c
 create mode 100644 drivers/staging/media/imx/imx-ic-prpencvf.c
 create mode 100644 drivers/staging/media/imx/imx-ic.h
 create mode 100644 drivers/staging/media/imx/imx-media-capture.c
 create mode 100644 drivers/staging/media/imx/imx-media-csi.c
 create mode 100644 drivers/staging/media/imx/imx-media-dev.c
 create mode 100644 drivers/staging/media/imx/imx-media-fim.c
 create mode 100644 drivers/staging/media/imx/imx-media-internal-sd.c
 create mode 100644 drivers/staging/media/imx/imx-media-of.c
 create mode 100644 drivers/staging/media/imx/imx-media-utils.c
 create mode 100644 drivers/staging/media/imx/imx-media-vdic.c
 create mode 100644 drivers/staging/media/imx/imx-media.h
 create mode 100644 drivers/staging/media/imx/imx6-mipi-csi2.c
 create mode 100644 include/media/imx.h
 create mode 100644 include/uapi/media/Kbuild
 create mode 100644 include/uapi/media/imx.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v4 1/36 dt-bindings: Add bindings for i.MX media driver

Add bindings documentation for the i.MX media driver.

---
 Documentation/devicetree/bindings/media/imx.txt | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt
Documentation/devicetree/bindings/media/imx.txt new file +66 -0
new file mode 100644
index 0000000..fd5af50
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=================================
+
+Video Media Controller node
+---------------------------
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports      : Should contain a list of phandles pointing to camera
+		sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+	compatible = "fsl,capture-subsystem";
+	ports = <&ipu1_csi0>, <&ipu1_csi1>;
+};
+
+fim child node
+--------------
+
+This is an optional child node of the ipu_csi port nodes. If present and
+available, it enables the Frame Interval Monitor. Its properties can be
+used to modify the method in which the FIM measures frame intervals.
+Refer to Documentation/media/v4l-drivers/imx.rst for more info on the
+Frame Interval Monitor.
+
+Optional properties:
+- fsl,input-capture-channel: an input capture channel and channel flags,
+			     specified as <chan flags>. The channel number
+			     must be 0 or 1. The flags can be
+			     IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or
+			     IRQ_TYPE_EDGE_BOTH, and specify which input
+			     capture signal edge will trigger the input
+			     capture event. If an input capture channel is
+			     specified, the FIM will use this method to
+			     measure frame intervals instead of via the EOF
+			     interrupt. The input capture method is much
+			     preferred over EOF as it is not subject to
+			     interrupt latency errors. However it requires
+			     routing the VSYNC or FIELD output signals of
+			     the camera sensor to one of the i.MX input
+			     capture pads (SD1_DAT0, SD1_DAT1), which also
+			     gives up support for SD1.
+
+
+mipi_csi2 node
+--------------
+
+This is the device node for the MIPI CSI-2 Receiver, required for MIPI
+CSI-2 sensors.
+
+Required properties:
+- compatible	: "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
+- reg           : physical base address and length of the register set;
+- clocks	: the MIPI CSI-2 receiver requires three clocks: hsi_tx
+                  (the DPHY clock), video_27m, and eim_podf;
+- clock-names	: must contain "dphy", "cfg", "pix";
+
+Optional properties:
+- interrupts	: must contain two level-triggered interrupts,
+                  in order: 100 and 101;
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v4 01/36] [media] dt-bindings: Add bindings for i.MX media driver

Quoted 23 lines · Steve Longerbeam

Add bindings documentation for the i.MX media driver.

---
 Documentation/devicetree/bindings/media/imx.txt | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt
Documentation/devicetree/bindings/media/imx.txt new file +9 -0
new file mode 100644
index 0000000..fd5af50
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=================================
+
+Video Media Controller node
+---------------------------
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.

Documentation/devicetree/bindings/media/imx.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/media/imx.txt new file +10 -0
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports      : Should contain a list of phandles pointing to camera
+		sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+	compatible = "fsl,capture-subsystem";

"fsl,imx-capture-subsystem"

regards
Philipp

author maintainer
#3 lore raw

Re: [PATCH v4 01/36] [media] dt-bindings: Add bindings for i.MX media driver

Quoted 28 lines · Philipp Zabel
Quoted 27 lines · Steve Longerbeam

Add bindings documentation for the i.MX media driver.

---
 Documentation/devicetree/bindings/media/imx.txt | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt
Documentation/devicetree/bindings/media/imx.txt new file +13 -0
new file mode 100644
index 0000000..fd5af50
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=================================
+
+Video Media Controller node
+---------------------------
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports      : Should contain a list of phandles pointing to camera
Quoted 8 lines

Documentation/devicetree/bindings/media/imx.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/media/imx.txt new file +6 -0
+		sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+	compatible = "fsl,capture-subsystem";

"fsl,imx-capture-subsystem"

Fixed.

Steve

maintainer
#4 lore raw

Re: [PATCH v4 01/36] [media] dt-bindings: Add bindings for i.MX media driver

In reply to Steve Longerbeam
Quoted 34 lines · Steve Longerbeam

Add bindings documentation for the i.MX media driver.

---
 Documentation/devicetree/bindings/media/imx.txt | 66 +++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx.txt
Documentation/devicetree/bindings/media/imx.txt new file +20 -0
new file mode 100644
index 0000000..fd5af50
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=================================
+
+Video Media Controller node
+---------------------------
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports      : Should contain a list of phandles pointing to camera
+		sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+	compatible = "fsl,capture-subsystem";
+	ports = <&ipu1_csi0>, <&ipu1_csi1>;

Documentation/devicetree/bindings/media/imx.txt line 30

Quoted 10 lines
Documentation/devicetree/bindings/media/imx.txt new file +10 -0
+};
+
+fim child node
+--------------
+
+This is an optional child node of the ipu_csi port nodes. If present and
+available, it enables the Frame Interval Monitor. Its properties can be
+used to modify the method in which the FIM measures frame intervals.
+Refer to Documentation/media/v4l-drivers/imx.rst for more info on the
+Frame Interval Monitor.

This should have a compatible string.

Quoted 22 lines
Documentation/devicetree/bindings/media/imx.txt new file +22 -0
+
+Optional properties:
+- fsl,input-capture-channel: an input capture channel and channel flags,
+			     specified as <chan flags>. The channel number
+			     must be 0 or 1. The flags can be
+			     IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or
+			     IRQ_TYPE_EDGE_BOTH, and specify which input
+			     capture signal edge will trigger the input
+			     capture event. If an input capture channel is
+			     specified, the FIM will use this method to
+			     measure frame intervals instead of via the EOF
+			     interrupt. The input capture method is much
+			     preferred over EOF as it is not subject to
+			     interrupt latency errors. However it requires
+			     routing the VSYNC or FIELD output signals of
+			     the camera sensor to one of the i.MX input
+			     capture pads (SD1_DAT0, SD1_DAT1), which also
+			     gives up support for SD1.
+
+
+mipi_csi2 node
+--------------

Documentation/devicetree/bindings/media/imx.txt line 62

Quoted 10 lines
Documentation/devicetree/bindings/media/imx.txt new file +10 -0
+
+This is the device node for the MIPI CSI-2 Receiver, required for MIPI
+CSI-2 sensors.
+
+Required properties:
+- compatible	: "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
+- reg           : physical base address and length of the register set;
+- clocks	: the MIPI CSI-2 receiver requires three clocks: hsi_tx
+                  (the DPHY clock), video_27m, and eim_podf;
+- clock-names	: must contain "dphy", "cfg", "pix";

Don't you need ports to describe the sensor and IPU connections?

Quoted 7 lines
Documentation/devicetree/bindings/media/imx.txt new file +4 -0
+
+Optional properties:
+- interrupts	: must contain two level-triggered interrupts,
+                  in order: 100 and 101;
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

Re: [PATCH v4 01/36] [media] dt-bindings: Add bindings for i.MX media driver

Hi Rob,

Quoted 38 lines · Rob Herring
Quoted 37 lines · Steve Longerbeam

Add bindings documentation for the i.MX media driver.

---
  Documentation/devicetree/bindings/media/imx.txt | 66 +++++++++++++++++++++++++
  1 file changed, 66 insertions(+)

create mode 100644 Documentation/devicetree/bindings/media/imx.txt

Documentation/devicetree/bindings/media/imx.txt new file +23 -0
new file mode 100644
index 0000000..fd5af50
@@ -0,0 +1,66 @@
+Freescale i.MX Media Video Device
+=================================
+
+Video Media Controller node
+---------------------------
+
+This is the media controller node for video capture support. It is a
+virtual device that lists the camera serial interface nodes that the
+media device will control.
+
+Required properties:
+- compatible : "fsl,imx-capture-subsystem";
+- ports      : Should contain a list of phandles pointing to camera
+		sensor interface ports of IPU devices
+
+example:
+
+capture-subsystem {
+	compatible = "fsl,capture-subsystem";
+	ports = <&ipu1_csi0>, <&ipu1_csi1>;
+};
+
+fim child node
Quoted 8 lines

Documentation/devicetree/bindings/media/imx.txt line 30

Quoted 7 lines
Documentation/devicetree/bindings/media/imx.txt new file +7 -0
+--------------
+
+This is an optional child node of the ipu_csi port nodes. If present and
+available, it enables the Frame Interval Monitor. Its properties can be
+used to modify the method in which the FIM measures frame intervals.
+Refer to Documentation/media/v4l-drivers/imx.rst for more info on the
+Frame Interval Monitor.

This should have a compatible string.

I don't think so. The fim child node does not represent a device. The CSI supports monitoring frame intervals (reporting via a v4l2 event when a measured frame interval falls outside the nominal interval by some tolerance value). The fim child node is only to group properties for the FIM under a common child node.

Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/media/imx.txt new file +25 -0
+
+Optional properties:
+- fsl,input-capture-channel: an input capture channel and channel flags,
+			     specified as <chan flags>. The channel number
+			     must be 0 or 1. The flags can be
+			     IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, or
+			     IRQ_TYPE_EDGE_BOTH, and specify which input
+			     capture signal edge will trigger the input
+			     capture event. If an input capture channel is
+			     specified, the FIM will use this method to
+			     measure frame intervals instead of via the EOF
+			     interrupt. The input capture method is much
+			     preferred over EOF as it is not subject to
+			     interrupt latency errors. However it requires
+			     routing the VSYNC or FIELD output signals of
+			     the camera sensor to one of the i.MX input
+			     capture pads (SD1_DAT0, SD1_DAT1), which also
+			     gives up support for SD1.
+
+
+mipi_csi2 node
+--------------
+
+This is the device node for the MIPI CSI-2 Receiver, required for MIPI
+CSI-2 sensors.
Quoted 8 lines

Documentation/devicetree/bindings/media/imx.txt line 62

Quoted 7 lines
Documentation/devicetree/bindings/media/imx.txt new file +7 -0
+
+Required properties:
+- compatible	: "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
+- reg           : physical base address and length of the register set;
+- clocks	: the MIPI CSI-2 receiver requires three clocks: hsi_tx
+                  (the DPHY clock), video_27m, and eim_podf;
+- clock-names	: must contain "dphy", "cfg", "pix";

Don't you need ports to describe the sensor and IPU connections?

Done.

Steve

author maintainer
#6 lore raw

PATCH v4 2/36 ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node

In reply to Steve Longerbeam

Add to the MIPI CSI2 receiver node: compatible strings, interrupt sources, and clocks.

---
 arch/arm/boot/dts/imx6qdl.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +7 -0
index 61569c8..aac70b9 100644
@@ -1125,7 +1125,14 @@
 			};
 
 			mipi_csi: mipi at 021dc000 {
+				compatible = "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
 				reg = <0x021dc000 0x4000>;
+				interrupts = <0 100 0x04>, <0 101 0x04>;
+				clocks = <&clks IMX6QDL_CLK_HSI_TX>,
+					 <&clks IMX6QDL_CLK_VIDEO_27M>,
+					 <&clks IMX6QDL_CLK_EIM_PODF>;
+				clock-names = "dphy", "cfg", "pix";
+				status = "disabled";
 			};
 
 			mipi_dsi: mipi at 021e0000 {
Signature · 1 line
2.7.4
author maintainer
#7 lore raw

PATCH v4 3/36 ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections

In reply to Steve Longerbeam

From: Philipp Zabel <[email protected]>

This patch adds the device tree graph connecting the input multiplexers to the IPU CSIs and the MIPI-CSI2 gasket on i.MX6. The MIPI_IPU multiplexers are added as children of the iomuxc-gpr syscon device node. On i.MX6Q/D two two-input multiplexers in front of IPU1 CSI0 and IPU2 CSI1 allow to select between CSI0/1 parallel input pads and the MIPI CSI-2 virtual channels 0/3.
On i.MX6DL/S two five-input multiplexers in front of IPU1 CSI0 and IPU1 CSI1 allow to select between CSI0/1 parallel input pads and any of the four MIPI CSI-2 virtual channels.

--

- Removed some dangling/unused endpoints (ipu2_csi0_from_csi2ipu)
- Renamed the mipi virtual channel endpoint labels, from "mipi_csiX_..." to "mipi_vcX...".
- Added input endpoint anchors to the video muxes for the connections from parallel sensors.

---
 arch/arm/boot/dts/imx6dl.dtsi  | 180 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/imx6q.dtsi   | 116 ++++++++++++++++++++++++++
 arch/arm/boot/dts/imx6qdl.dtsi |  10 ++-
 3 files changed, 305 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6dl.dtsi +180 -0
index 1ade195..371288a 100644
@@ -181,6 +181,186 @@
 		      "di0", "di1";
 };
 
+&gpr {
+	ipu1_csi0_mux: ipu1_csi0_mux at 34 {
+		compatible = "video-multiplexer";
+		reg = <0x34>;
+		bit-mask = <0x7>;
+		bit-shift = <0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+
+		port at 0 {
+			reg = <0>;
+
+			ipu1_csi0_mux_from_mipi_vc0: endpoint {
+				remote-endpoint = <&mipi_vc0_to_ipu1_csi0_mux>;
+			};
+		};
+
+		port at 1 {
+			reg = <1>;
+
+			ipu1_csi0_mux_from_mipi_vc1: endpoint {
+				remote-endpoint = <&mipi_vc1_to_ipu1_csi0_mux>;
+			};
+		};
+
+		port at 2 {
+			reg = <2>;
+
+			ipu1_csi0_mux_from_mipi_vc2: endpoint {
+				remote-endpoint = <&mipi_vc2_to_ipu1_csi0_mux>;
+			};
+		};
+
+		port at 3 {
+			reg = <3>;
+
+			ipu1_csi0_mux_from_mipi_vc3: endpoint {
+				remote-endpoint = <&mipi_vc3_to_ipu1_csi0_mux>;
+			};
+		};
+
+		port at 4 {
+			reg = <4>;
+
+			ipu1_csi0_mux_from_parallel_sensor: endpoint {
+			};
+		};
+
+		port at 5 {
+			reg = <5>;
+
+			ipu1_csi0_mux_to_ipu1_csi0: endpoint {
+				remote-endpoint = <&ipu1_csi0_from_ipu1_csi0_mux>;
+			};
+		};
+	};
+
+	ipu1_csi1_mux: ipu1_csi1_mux at 34 {
+		compatible = "video-multiplexer";
+		reg = <0x34>;
+		bit-mask = <0x7>;
+		bit-shift = <3>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+
+		port at 0 {
+			reg = <0>;
+
+			ipu1_csi1_mux_from_mipi_vc0: endpoint {
+				remote-endpoint = <&mipi_vc0_to_ipu1_csi1_mux>;
+			};
+		};
+
+		port at 1 {
+			reg = <1>;
+
+			ipu1_csi1_mux_from_mipi_vc1: endpoint {
+				remote-endpoint = <&mipi_vc1_to_ipu1_csi1_mux>;
+			};
+		};
+
+		port at 2 {
+			reg = <2>;
+
+			ipu1_csi1_mux_from_mipi_vc2: endpoint {
+				remote-endpoint = <&mipi_vc2_to_ipu1_csi1_mux>;
+			};
+		};
+
+		port at 3 {
+			reg = <3>;
+
+			ipu1_csi1_mux_from_mipi_vc3: endpoint {
+				remote-endpoint = <&mipi_vc3_to_ipu1_csi1_mux>;
+			};
+		};
+
+		port at 4 {
+			reg = <4>;
+
+			ipu1_csi1_mux_from_parallel_sensor: endpoint {
+			};
+		};
+
+		port at 5 {
+			reg = <5>;
+
+			ipu1_csi1_mux_to_ipu1_csi1: endpoint {
+				remote-endpoint = <&ipu1_csi1_from_ipu1_csi1_mux>;
+			};
+		};
+	};
+};
+
+&ipu1_csi1 {
+	ipu1_csi1_from_ipu1_csi1_mux: endpoint {
+		remote-endpoint = <&ipu1_csi1_mux_to_ipu1_csi1>;
+	};
+};
+
+&mipi_csi {
+	port at 1 {
+		reg = <1>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mipi_vc0_to_ipu1_csi0_mux: endpoint at 0 {
+			remote-endpoint = <&ipu1_csi0_mux_from_mipi_vc0>;
+		};
+
+		mipi_vc0_to_ipu1_csi1_mux: endpoint at 1 {
+			remote-endpoint = <&ipu1_csi1_mux_from_mipi_vc0>;
+		};
+	};
+
+	port at 2 {
+		reg = <2>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mipi_vc1_to_ipu1_csi0_mux: endpoint at 0 {
+			remote-endpoint = <&ipu1_csi0_mux_from_mipi_vc1>;
+		};
+
+		mipi_vc1_to_ipu1_csi1_mux: endpoint at 1 {
+			remote-endpoint = <&ipu1_csi1_mux_from_mipi_vc1>;
+		};
+	};
+
+	port at 3 {
+		reg = <3>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mipi_vc2_to_ipu1_csi0_mux: endpoint at 0 {
+			remote-endpoint = <&ipu1_csi0_mux_from_mipi_vc2>;
+		};
+
+		mipi_vc2_to_ipu1_csi1_mux: endpoint at 1 {
+			remote-endpoint = <&ipu1_csi1_mux_from_mipi_vc2>;
+		};
+	};
+
+	port at 4 {
+		reg = <4>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mipi_vc3_to_ipu1_csi0_mux: endpoint at 0 {
+			remote-endpoint = <&ipu1_csi0_mux_from_mipi_vc3>;
+		};
+
+		mipi_vc3_to_ipu1_csi1_mux: endpoint at 1 {
+			remote-endpoint = <&ipu1_csi1_mux_from_mipi_vc3>;
+		};
+	};
+};
+
 &vpu {
 	compatible = "fsl,imx6dl-vpu", "cnm,coda960";
 };
arch/arm/boot/dts/imx6q.dtsi +116 -0

138 lines not on this page · raw message

arch/arm/boot/dts/imx6qdl.dtsi +9 -1
index aac70b9..c4130d5 100644
@@ -799,8 +799,10 @@
 			};
 
 			gpr: iomuxc-gpr at 020e0000 {
-				compatible = "fsl,imx6q-iomuxc-gpr", "syscon";
+				compatible = "fsl,imx6q-iomuxc-gpr", "syscon", "simple-mfd";
 				reg = <0x020e0000 0x38>;
+				#address-cells = <1>;
+				#size-cells = <0>;
 			};
 
 			iomuxc: iomuxc at 020e0000 {
@@ -1127,6 +1129,8 @@
 			mipi_csi: mipi at 021dc000 {
 				compatible = "fsl,imx6-mipi-csi2", "snps,dw-mipi-csi2";
 				reg = <0x021dc000 0x4000>;
+				#address-cells = <1>;
+				#size-cells = <0>;
 				interrupts = <0 100 0x04>, <0 101 0x04>;
 				clocks = <&clks IMX6QDL_CLK_HSI_TX>,
 					 <&clks IMX6QDL_CLK_VIDEO_27M>,
@@ -1234,6 +1238,10 @@
 
 			ipu1_csi0: port at 0 {
 				reg = <0>;
+
+				ipu1_csi0_from_ipu1_csi0_mux: endpoint {
+					remote-endpoint = <&ipu1_csi0_mux_to_ipu1_csi0>;
+				};
 			};
 
 			ipu1_csi1: port at 1 {
Signature · 1 line
2.7.4
author maintainer
#8 lore raw

PATCH v4 4/36 ARM: dts: imx6qdl: add capture-subsystem device

In reply to Steve Longerbeam
---
 arch/arm/boot/dts/imx6dl.dtsi | 5 +++++
 arch/arm/boot/dts/imx6q.dtsi  | 5 +++++
 2 files changed, 10 insertions(+)
arch/arm/boot/dts/imx6dl.dtsi +5 -0
index 371288a..f1743fc 100644
@@ -100,6 +100,11 @@
 		};
 	};
 
+	capture-subsystem {
+		compatible = "fsl,imx-capture-subsystem";
+		ports = <&ipu1_csi0>, <&ipu1_csi1>;
+	};
+
 	display-subsystem {
 		compatible = "fsl,imx-display-subsystem";
 		ports = <&ipu1_di0>, <&ipu1_di1>;
arch/arm/boot/dts/imx6q.dtsi +5 -0
index b833b0d..4cc6579 100644
@@ -206,6 +206,11 @@
 		};
 	};
 
+	capture-subsystem {
+		compatible = "fsl,imx-capture-subsystem";
+		ports = <&ipu1_csi0>, <&ipu1_csi1>, <&ipu2_csi0>, <&ipu2_csi1>;
+	};
+
 	display-subsystem {
 		compatible = "fsl,imx-display-subsystem";
 		ports = <&ipu1_di0>, <&ipu1_di1>, <&ipu2_di0>, <&ipu2_di1>;
Signature · 1 line
2.7.4
author maintainer
#9 lore raw

PATCH v4 5/36 ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround

In reply to Steve Longerbeam

There is a pin conflict with GPIO_6. This pin functions as a power input pin to the OV5642 camera sensor, but ENET uses it as the h/w workaround for erratum ERR006687, to wake-up the ARM cores on normal RX and TX packet done events. So we need to remove the h/w workaround to support the OV5642. The result is that the CPUidle driver will no longer allow entering the deep idle states on the sabrelite.

This is a partial revert of

commit 6261c4c8f13e ("ARM: dts: imx6qdl-sabrelite: use GPIO_6 for FEC
interrupt.")
commit a28eeb43ee57 ("ARM: dts: imx6: tag boards that have the HW workaround

			for ERR006687")
---
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 4 ----
 1 file changed, 4 deletions(-)
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +0 -4
index 1f9076e..795b5a5 100644
@@ -271,9 +271,6 @@
 	txd1-skew-ps = <0>;
 	txd2-skew-ps = <0>;
 	txd3-skew-ps = <0>;
-	interrupts-extended = <&gpio1 6 IRQ_TYPE_LEVEL_HIGH>,
-			      <&intc 0 119 IRQ_TYPE_LEVEL_HIGH>;
-	fsl,err006687-workaround-present;
 	status = "okay";
 };
 
@@ -374,7 +371,6 @@
 				MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL	0x1b030
 				/* Phy reset */
 				MX6QDL_PAD_EIM_D23__GPIO3_IO23		0x000b0
-				MX6QDL_PAD_GPIO_6__ENET_IRQ		0x000b1
 			>;
 		};
 
Signature · 1 line
2.7.4
author maintainer
#10 lore raw

PATCH v4 6/36 ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors

In reply to Steve Longerbeam

Adds the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor. Both hang off the same i2c2 bus, so they require different (and non- default) i2c slave addresses.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi.

The OV5642 node is disabled temporarily while the subdev driver is cleaned up and submitted later.

---
 arch/arm/boot/dts/imx6dl-sabrelite.dts   |   5 ++
 arch/arm/boot/dts/imx6q-sabrelite.dts    |   5 ++
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi | 148 +++++++++++++++++++++++++++++++
 3 files changed, 158 insertions(+)
arch/arm/boot/dts/imx6dl-sabrelite.dts +5 -0
index 0f06ca5..cfd5110 100644
@@ -48,3 +48,8 @@
 	model = "Freescale i.MX6 DualLite SABRE Lite Board";
 	compatible = "fsl,imx6dl-sabrelite", "fsl,imx6dl";
 };
+
+&ipu1_csi1_from_ipu1_csi1_mux {
+	clock-lanes = <0>;
+	data-lanes = <1 2>;
+};
arch/arm/boot/dts/imx6q-sabrelite.dts +5 -0
index 66d10d8..e00fc06 100644
@@ -52,3 +52,8 @@
 &sata {
 	status = "okay";
 };
+
+&ipu1_csi1_from_mipi_vc1 {
+	clock-lanes = <0>;
+	data-lanes = <1 2>;
+};
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +148 -0

187 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#11 lore raw

PATCH v4 7/36 ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors

In reply to Steve Longerbeam

Enables the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi.

Until the OV5652 sensor module compatible with the SabreSD becomes available for testing, the ov5642 node is currently disabled.

---
 arch/arm/boot/dts/imx6dl-sabresd.dts   |   5 ++
 arch/arm/boot/dts/imx6q-sabresd.dts    |   5 ++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 114 ++++++++++++++++++++++++++++++++-
 3 files changed, 123 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6dl-sabresd.dts +5 -0
index 1e45f2f..9607afe 100644
@@ -15,3 +15,8 @@
 	model = "Freescale i.MX6 DualLite SABRE Smart Device Board";
 	compatible = "fsl,imx6dl-sabresd", "fsl,imx6dl";
 };
+
+&ipu1_csi1_from_ipu1_csi1_mux {
+	clock-lanes = <0>;
+	data-lanes = <1 2>;
+};
arch/arm/boot/dts/imx6q-sabresd.dts +5 -0
index 9cbdfe7..527772b 100644
@@ -23,3 +23,8 @@
 &sata {
 	status = "okay";
 };
+
+&ipu1_csi1_from_mipi_vc1 {
+	clock-lanes = <0>;
+	data-lanes = <1 2>;
+};
arch/arm/boot/dts/imx6qdl-sabresd.dtsi +113 -1

144 lines not on this page · raw message

Signature · 1 line
2.7.4
reviewer
#12 lore raw

Re: [PATCH v4 07/36] ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors

Hi Steve,

Quoted 9 lines · Steve Longerbeam

Enables the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi.

Until the OV5652 sensor module compatible with the SabreSD becomes available for testing, the ov5642 node is currently disabled.

You missed your Signed-off-by.

author maintainer
#13 lore raw

Re: [PATCH v4 07/36] ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors

Quoted 8 lines · Fabio Estevam

Hi Steve,

Quoted 4 lines · Steve Longerbeam

Enables the OV5642 parallel-bus sensor, and the OV5640 MIPI CSI-2 sensor.

The OV5642 connects to the parallel-bus mux input port on ipu1_csi0_mux.

Quoted 7 lines
Quoted 5 lines

The OV5640 connects to the input port on the MIPI CSI-2 receiver on mipi_csi.

Until the OV5652 sensor module compatible with the SabreSD becomes available for testing, the ov5642 node is currently disabled.

You missed your Signed-off-by.

Thanks, fixed.

Steve

author maintainer
#14 lore raw

PATCH v4 8/36 ARM: dts: imx6-sabreauto: create i2cmux for i2c3

In reply to Steve Longerbeam

The sabreauto uses a steering pin to select between the SDA signal on i2c3 bus, and a data-in pin for an SPI NOR chip. Use i2cmux to control this steering pin. Idle state of the i2cmux selects SPI NOR. This is not a classic way to use i2cmux, since one side of the mux selects something other than an i2c bus, but it works and is probably the cleanest solution. Note that if one thread is attempting to access SPI NOR while another thread is accessing i2c3, the SPI NOR access will fail since the i2cmux has selected the SDA pin rather than SPI NOR data-in. This couldn't be avoided in any case, the board is not designed to allow concurrent i2c3 and SPI NOR functions (and the default device-tree does not enable SPI NOR anyway).

Devices hanging off i2c3 should now be defined under i2cmux, so that the steering pin can be properly controlled to access those devices. The port expanders (MAX7310) are thus moved into i2cmux.

---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 65 +++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 21 deletions(-)
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +44 -21
index 52390ba..cace88c 100644
@@ -108,6 +108,44 @@
 		default-brightness-level = <7>;
 		status = "okay";
 	};
+
+	i2cmux {
+		compatible = "i2c-mux-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_i2c3mux>;
+		mux-gpios = <&gpio5 4 0>;
+		i2c-parent = <&i2c3>;
+		idle-state = <0>;
+
+		i2c at 1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+
+			max7310_a: gpio at 30 {
+				compatible = "maxim,max7310";
+				reg = <0x30>;
+				gpio-controller;
+				#gpio-cells = <2>;
+			};
+
+			max7310_b: gpio at 32 {
+				compatible = "maxim,max7310";
+				reg = <0x32>;
+				gpio-controller;
+				#gpio-cells = <2>;
+			};
+
+			max7310_c: gpio at 34 {
+				compatible = "maxim,max7310";
+				reg = <0x34>;
+				gpio-controller;
+				#gpio-cells = <2>;
+			};
+		};
+	};
 };
 
 &clks {
@@ -291,27 +329,6 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_i2c3>;
 	status = "okay";
-
-	max7310_a: gpio at 30 {
-		compatible = "maxim,max7310";
-		reg = <0x30>;
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
-
-	max7310_b: gpio at 32 {
-		compatible = "maxim,max7310";
-		reg = <0x32>;
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
-
-	max7310_c: gpio at 34 {
-		compatible = "maxim,max7310";
-		reg = <0x34>;
-		gpio-controller;
-		#gpio-cells = <2>;
-	};
 };
 
 &iomuxc {
@@ -419,6 +436,12 @@
 			>;
 		};
 
+		pinctrl_i2c3mux: i2c3muxgrp {
+			fsl,pins = <
+				MX6QDL_PAD_EIM_A24__GPIO5_IO04 0x0b0b1
+			>;
+		};
+
 		pinctrl_pwm3: pwm1grp {
 			fsl,pins = <
 				MX6QDL_PAD_SD4_DAT1__PWM3_OUT		0x1b0b1
Signature · 1 line
2.7.4
author maintainer
#15 lore raw

PATCH v4 9/36 ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b

In reply to Steve Longerbeam

The reset pin to the port expander chip (MAX7310) is controlled by a gpio, so define a reset-gpios property to control it. There are three MAX7310's on the SabreAuto CPU card (max7310_[abc]), but all use the same pin for their reset. Since all can't acquire the same pin, assign it to max7310_b, that chip is needed by more functions (usb and adv7180).

---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +9 -0
index cace88c..967c3b8 100644
@@ -136,6 +136,9 @@
 				reg = <0x32>;
 				gpio-controller;
 				#gpio-cells = <2>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&pinctrl_max7310>;
+				reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
 			};
 
 			max7310_c: gpio at 34 {
@@ -442,6 +445,12 @@
 			>;
 		};
 
+		pinctrl_max7310: max7310grp {
+			fsl,pins = <
+				MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0
+			>;
+		};
+
 		pinctrl_pwm3: pwm1grp {
 			fsl,pins = <
 				MX6QDL_PAD_SD4_DAT1__PWM3_OUT		0x1b0b1
Signature · 1 line
2.7.4
author maintainer
#16 lore raw

PATCH v4 10/36 ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture

In reply to Steve Longerbeam

Add pinctrl groups for both GPT input capture channels.

---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +12 -0
index 967c3b8..495709f 100644
@@ -457,6 +457,18 @@
 			>;
 		};
 
+		pinctrl_gpt_input_capture0: gptinputcapture0grp {
+			fsl,pins = <
+				MX6QDL_PAD_SD1_DAT0__GPT_CAPTURE1	0x1b0b0
+			>;
+		};
+
+		pinctrl_gpt_input_capture1: gptinputcapture1grp {
+			fsl,pins = <
+				MX6QDL_PAD_SD1_DAT1__GPT_CAPTURE2	0x1b0b0
+			>;
+		};
+
 		pinctrl_spdif: spdifgrp {
 			fsl,pins = <
 				MX6QDL_PAD_KEY_COL3__SPDIF_IN 0x1b0b0
Signature · 1 line
2.7.4
author maintainer
#17 lore raw

PATCH v4 11/36 ARM: dts: imx6-sabreauto: add the ADV7180 video decoder

In reply to Steve Longerbeam

Enables the ADV7180 decoder sensor. The ADV7180 connects to the parallel-bus mux input on ipu1_csi0_mux.

The ADV7180 power pin is via max7310_b port expander.

---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 58 ++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +58 -0
index 495709f..f03057b 100644
@@ -124,6 +124,21 @@
 			#size-cells = <0>;
 			reg = <1>;
 
+			adv7180: camera at 21 {
+				compatible = "adi,adv7180";
+				reg = <0x21>;
+				powerdown-gpios = <&max7310_b 2 GPIO_ACTIVE_LOW>;
+				interrupt-parent = <&gpio1>;
+				interrupts = <27 0x8>;
+
+				port {
+					adv7180_to_ipu1_csi0_mux: endpoint {
+						remote-endpoint = <&ipu1_csi0_mux_from_parallel_sensor>;
+						bus-width = <8>;
+					};
+				};
+			};
+
 			max7310_a: gpio at 30 {
 				compatible = "maxim,max7310";
 				reg = <0x30>;
@@ -151,6 +166,25 @@
 	};
 };
 
+&ipu1_csi0_from_ipu1_csi0_mux {
+	bus-width = <8>;
+};
+
+&ipu1_csi0_mux_from_parallel_sensor {
+	remote-endpoint = <&adv7180_to_ipu1_csi0_mux>;
+	bus-width = <8>;
+};
+
+&ipu1_csi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_ipu1_csi0>;
+
+	/* enable frame interval monitor on this port */
+	fim {
+		status = "okay";
+	};
+};
+
 &clks {
 	assigned-clocks = <&clks IMX6QDL_PLL4_BYPASS_SRC>,
 			  <&clks IMX6QDL_PLL4_BYPASS>,
@@ -445,6 +479,30 @@
 			>;
 		};
 
+		pinctrl_ipu1_csi0: ipu1csi0grp {
+			fsl,pins = <
+				MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09   0x1b0b0
+				MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18  0x1b0b0
+				MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19  0x1b0b0
+				MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK 0x1b0b0
+				MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC    0x1b0b0
+				MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC   0x1b0b0
+			>;
+		};
+
 		pinctrl_max7310: max7310grp {
 			fsl,pins = <
 				MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x1b0b0
Signature · 1 line
2.7.4
author maintainer
#18 lore raw

PATCH v4 12/36 add mux and video interface bridge entity functions

In reply to Steve Longerbeam

From: Philipp Zabel <[email protected]>

- renamed MEDIA_ENT_F_MUX to MEDIA_ENT_F_VID_MUX

---
 Documentation/media/uapi/mediactl/media-types.rst | 22 ++++++++++++++++++++++
 include/uapi/linux/media.h                        |  6 ++++++
 2 files changed, 28 insertions(+)
Documentation/media/uapi/mediactl/media-types.rst +22 -0
index 3e03dc2..023be29 100644
@@ -298,6 +298,28 @@ Types and flags used to represent the media graph elements
 	  received on its sink pad and outputs the statistics data on
 	  its source pad.
 
+    -  ..  row 29
+
+       ..  _MEDIA-ENT-F-MUX:
+
+       -  ``MEDIA_ENT_F_MUX``
+
+       - Video multiplexer. An entity capable of multiplexing must have at
+         least two sink pads and one source pad, and must pass the video
+         frame(s) received from the active sink pad to the source pad. Video
+         frame(s) from the inactive sink pads are discarded.
+
+    -  ..  row 30
+
+       ..  _MEDIA-ENT-F-VID-IF-BRIDGE:
+
+       -  ``MEDIA_ENT_F_VID_IF_BRIDGE``
+
+       - Video interface bridge. A video interface bridge entity must have at
+         least one sink pad and one source pad. It receives video frame(s) on
+         its sink pad in one bus format (HDMI, eDP, MIPI CSI-2, ...) and
+         converts them and outputs them on its source pad in another bus format
+         (eDP, MIPI CSI-2, parallel, ...).
 
 ..  tabularcolumns:: |p{5.5cm}|p{12.0cm}|
 
include/uapi/linux/media.h +6 -0
index 4890787..fac96c6 100644
@@ -105,6 +105,12 @@ struct media_device_info {
 #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS	(MEDIA_ENT_F_BASE + 0x4006)
 
 /*
+ * Switch and bridge entitites
+ */
+#define MEDIA_ENT_F_VID_MUX			(MEDIA_ENT_F_BASE + 0x5001)
+#define MEDIA_ENT_F_VID_IF_BRIDGE		(MEDIA_ENT_F_BASE + 0x5002)
+
+/*
  * Connectors
  */
 /* It is a responsibility of the entity drivers to add connectors and links */
Signature · 1 line
2.7.4
Reviewed-by on v4 12/36
#19 lore raw

Re: [PATCH v4 12/36] add mux and video interface bridge entity functions

Quoted 7 lines · Steve Longerbeam

From: Philipp Zabel <[email protected]>

- renamed MEDIA_ENT_F_MUX to MEDIA_ENT_F_VID_MUX

This is slightly "interesting" format of changelog. Normally signoffs go below.

Documentation/media/uapi/mediactl/media-types.rst Types and flags used to represent the media graph elements · line 305

Quoted 13 lines
Documentation/media/uapi/mediactl/media-types.rst +5 -0
index 3e03dc2..023be29 100644
@@ -298,6 +298,28 @@ Types and flags used to represent the media graph elements
 	  received on its sink pad and outputs the statistics data on
 	  its source pad.
 
+    -  ..  row 29
+
+       ..  _MEDIA-ENT-F-MUX:
+
+       -  ``MEDIA_ENT_F_MUX``

And you probably want to rename it here, too.

With that fixed:

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170219/b1c5bf01/attachment.sig>
author maintainer
#20 lore raw

Re: [PATCH v4 12/36] add mux and video interface bridge entity functions

Quoted 20 lines · Pavel Machek
Quoted 7 lines · Steve Longerbeam

From: Philipp Zabel <[email protected]>

- renamed MEDIA_ENT_F_MUX to MEDIA_ENT_F_VID_MUX

This is slightly "interesting" format of changelog. Normally signoffs go below.

Quoted 8 lines
Documentation/media/uapi/mediactl/media-types.rst +0 -0
index 3e03dc2..023be29 100644
@@ -298,6 +298,28 @@ Types and flags used to represent the media graph elements
 	  received on its sink pad and outputs the statistics data on
 	  its source pad.
 
Quoted 7 lines

Documentation/media/uapi/mediactl/media-types.rst Types and flags used to represent the media graph elements · line 305

Quoted 5 lines
Documentation/media/uapi/mediactl/media-types.rst +5 -0
+    -  ..  row 29
+
+       ..  _MEDIA-ENT-F-MUX:
+
+       -  ``MEDIA_ENT_F_MUX``

And you probably want to rename it here, too.

Done, thanks.
Steve

Quoted 5 lines

With that fixed:

author maintainer
#21 lore raw

PATCH v4 13/36 v4l2: add a frame timeout event

In reply to Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---
 Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
 Documentation/media/videodev2.h.rst.exceptions  | 1 +
 include/uapi/linux/videodev2.h                  | 1 +
 3 files changed, 7 insertions(+)
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.
     * - ``V4L2_EVENT_PRIVATE_START``
       - 0x08000000
       - Base event number for driver-private events.
Documentation/media/videodev2.h.rst.exceptions +1 -0
index e11a0d0..5b0f767 100644
@@ -459,6 +459,7 @@ replace define V4L2_EVENT_CTRL event-type
 replace define V4L2_EVENT_FRAME_SYNC event-type
 replace define V4L2_EVENT_SOURCE_CHANGE event-type
 replace define V4L2_EVENT_MOTION_DET event-type
+replace define V4L2_EVENT_FRAME_TIMEOUT event-type
 replace define V4L2_EVENT_PRIVATE_START event-type
 
 replace define V4L2_EVENT_CTRL_CH_VALUE ctrl-changes-flags
include/uapi/linux/videodev2.h +1 -0
index 46e8a2e3..e174c45 100644
@@ -2132,6 +2132,7 @@ struct v4l2_streamparm {
 #define V4L2_EVENT_FRAME_SYNC			4
 #define V4L2_EVENT_SOURCE_CHANGE		5
 #define V4L2_EVENT_MOTION_DET			6
+#define V4L2_EVENT_FRAME_TIMEOUT		7
 #define V4L2_EVENT_PRIVATE_START		0x08000000
 
 /* Payload for V4L2_EVENT_VSYNC */
Signature · 1 line
2.7.4
#22 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Hi Steve,

Quoted 16 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---
 Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
 Documentation/media/videodev2.h.rst.exceptions  | 1 +
 include/uapi/linux/videodev2.h                  | 1 +
 3 files changed, 7 insertions(+)
Documentation/media/uapi/v4l/vidioc-dqevent.rst +0 -0
index 8d663a7..dd77d9b 100644

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 8 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

Quoted 27 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +0 -0
     * - ``V4L2_EVENT_PRIVATE_START``
       - 0x08000000
       - Base event number for driver-private events.
Documentation/media/videodev2.h.rst.exceptions +1 -0
index e11a0d0..5b0f767 100644
@@ -459,6 +459,7 @@ replace define V4L2_EVENT_CTRL event-type
 replace define V4L2_EVENT_FRAME_SYNC event-type
 replace define V4L2_EVENT_SOURCE_CHANGE event-type
 replace define V4L2_EVENT_MOTION_DET event-type
+replace define V4L2_EVENT_FRAME_TIMEOUT event-type
 replace define V4L2_EVENT_PRIVATE_START event-type
 
 replace define V4L2_EVENT_CTRL_CH_VALUE ctrl-changes-flags
include/uapi/linux/videodev2.h +1 -0
index 46e8a2e3..e174c45 100644
@@ -2132,6 +2132,7 @@ struct v4l2_streamparm {
 #define V4L2_EVENT_FRAME_SYNC			4
 #define V4L2_EVENT_SOURCE_CHANGE		5
 #define V4L2_EVENT_MOTION_DET			6
+#define V4L2_EVENT_FRAME_TIMEOUT		7
 #define V4L2_EVENT_PRIVATE_START		0x08000000
 
 /* Payload for V4L2_EVENT_VSYNC */
Signature · 4 lines
Regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
author maintainer
#23 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 14 lines · Sakari Ailus

Hi Steve,

Quoted 11 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---
 Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
 Documentation/media/videodev2.h.rst.exceptions  | 1 +
 include/uapi/linux/videodev2.h                  | 1 +
 3 files changed, 7 insertions(+)
Quoted 16 lines

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 13 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

Steve

#24 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 34 lines · Steve Longerbeam
Quoted 14 lines · Sakari Ailus

Hi Steve,

Quoted 11 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---

Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
Documentation/media/videodev2.h.rst.exceptions  | 1 +
include/uapi/linux/videodev2.h                  | 1 +
3 files changed, 7 insertions(+)
Quoted 16 lines

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 13 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

Quoted 2 lines

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

The frame rate is not necessarily constant during streaming. It may well change as a result of lighting conditions. I wouldn't add an event for this:
this is unreliable and 30 times the frame period is an arbitrary value anyway. No other drivers do this either.

The user space is generally in control of the frame period (or on some devices it could be the sensor, too, but *not* the CSI-2 receiver driver), so detecting the condition of not receiving any frames is more reliably done in the user space --- if needed.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
author maintainer
#25 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 35 lines · Sakari Ailus
Quoted 34 lines · Steve Longerbeam
Quoted 30 lines · Sakari Ailus

Hi Steve,

Quoted 16 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---

Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
Documentation/media/videodev2.h.rst.exceptions  | 1 +
include/uapi/linux/videodev2.h                  | 1 +
3 files changed, 7 insertions(+)
Documentation/media/uapi/v4l/vidioc-dqevent.rst +0 -0
index 8d663a7..dd77d9b 100644

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 8 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

Quoted 5 lines
Quoted 2 lines

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

The frame rate is not necessarily constant during streaming. It may well change as a result of lighting conditions.

I think you mean that would be a _temporary_ change in frame rate, but yes I agree the data rate can temporarily fluctuate. Although I doubt lighting conditions would cause a sensor to pause data transmission for a full 1 second.

Quoted 3 lines

I wouldn't add an event for this:
this is unreliable and 30 times the frame period is an arbitrary value anyway. No other drivers do this either.

If no other drivers do this I don't mind removing it. It is really meant to deal with the ADV718x CVBS decoder, which often simply stops sending data on the BT.656 bus if there is an interruption in the input analog signal. But I agree that user space could detect this timeout instead. Unless I hear from someone else that they would like to keep this feature I'll remove it in version 5.

Steve

Quoted 6 lines

The user space is generally in control of the frame period (or on some devices it could be the sensor, too, but *not* the CSI-2 receiver driver), so detecting the condition of not receiving any frames is more reliably done in the user space --- if needed.

#26 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Hi Steve,

Quoted 41 lines · Steve Longerbeam
Quoted 38 lines · Sakari Ailus
Quoted 36 lines · Steve Longerbeam
Quoted 14 lines · Sakari Ailus

Hi Steve,

Quoted 11 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---

Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
Documentation/media/videodev2.h.rst.exceptions  | 1 +
include/uapi/linux/videodev2.h                  | 1 +
3 files changed, 7 insertions(+)
Quoted 16 lines

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 13 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

Quoted 7 lines
Quoted 2 lines

The frame rate is not necessarily constant during streaming. It may well change as a result of lighting conditions.

I think you mean that would be a _temporary_ change in frame rate, but yes I agree the data rate can temporarily fluctuate. Although I doubt lighting conditions would cause a sensor to pause data transmission for a full 1 second.

Likely not, at least not in typical conditions. The exposure time is still quite specific to applications: it could be minutes if you take photos e.g. of the night sky.

What I'm saying here is that any static value is likely not both reasonable and workable in all potential situations all the time. Still there are cases (as yours below) that may happen in relatively common cases on some hardware (more common than taking long exposure photos of the night sky with the said hardware :)).

Quoted 6 lines
Quoted 5 lines

I wouldn't add an event for this:
this is unreliable and 30 times the frame period is an arbitrary value anyway. No other drivers do this either.

Quoted 6 lines

If no other drivers do this I don't mind removing it. It is really meant to deal with the ADV718x CVBS decoder, which often simply stops sending data on the BT.656 bus if there is an interruption in the input analog signal. But I agree that user space could detect this timeout instead. Unless I hear from someone else that they would like to keep this feature I'll remove it in version 5.

That's a bit of a special situation --- still there are alike conditions on existing hardware. You should return the buffers to the user with the ERROR flag set --- or return -EIO from VIDIOC_DQBUF, if the condition will persist:

<URL:https://www.linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/vidioc-qbuf.html>

Do you already obtain the frame rate from the image source (e.g. tuner, sensor, decoder) and multiply the frame time by some number in the current implementation? Not all sub-device drivers may implement g_frame_interval() so I'd disable the timeout in that case.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
author maintainer
#27 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 56 lines · Sakari Ailus

Hi Steve,

Quoted 41 lines · Steve Longerbeam
Quoted 38 lines · Sakari Ailus
Quoted 36 lines · Steve Longerbeam
Quoted 14 lines · Sakari Ailus

Hi Steve,

Quoted 11 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---

Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
Documentation/media/videodev2.h.rst.exceptions  | 1 +
include/uapi/linux/videodev2.h                  | 1 +
3 files changed, 7 insertions(+)
Quoted 16 lines

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 13 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

Quoted 7 lines
Quoted 2 lines

The frame rate is not necessarily constant during streaming. It may well change as a result of lighting conditions.

I think you mean that would be a _temporary_ change in frame rate, but yes I agree the data rate can temporarily fluctuate. Although I doubt lighting conditions would cause a sensor to pause data transmission for a full 1 second.

Likely not, at least not in typical conditions. The exposure time is still quite specific to applications: it could be minutes if you take photos e.g. of the night sky.

Quoted 5 lines

What I'm saying here is that any static value is likely not both reasonable and workable in all potential situations all the time. Still there are cases (as yours below) that may happen in relatively common cases on some hardware (more common than taking long exposure photos of the night sky with the said hardware :)).

I doubt night photography will ever be a use-case for i.MX. The most common use-case for this driver will be used in automotive applications such as rear-view or 360 degree view cameras.

Quoted 14 lines
Quoted 7 lines
Quoted 6 lines

I wouldn't add an event for this:
this is unreliable and 30 times the frame period is an arbitrary value anyway. No other drivers do this either.

Quoted 6 lines

If no other drivers do this I don't mind removing it. It is really meant to deal with the ADV718x CVBS decoder, which often simply stops sending data on the BT.656 bus if there is an interruption in the input analog signal. But I agree that user space could detect this timeout instead. Unless I hear from someone else that they would like to keep this feature I'll remove it in version 5.

Quoted 4 lines

That's a bit of a special situation --- still there are alike conditions on existing hardware. You should return the buffers to the user with the ERROR flag set --- or return -EIO from VIDIOC_DQBUF, if the condition will persist:

On i.MX an EOF timeout is not recoverable without a stream restart, so I decided to call vb2_queue_error() when the timeout occurs (instead of sending an event). The user will then get -EIO when it attempts to queue or dequeue further buffers.

Quoted 6 lines

<URL:https://www.linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/vidioc-qbuf.html>

Do you already obtain the frame rate from the image source (e.g. tuner, sensor, decoder) and multiply the frame time by some number in the current implementation?

No the timeout is a constant value, regardless of the source frame rate. Should the timeout be based on a constant time, or based on a constant # of frames? I really don't think it matters much, what matters is that it be long enough to be reasonably sure no data is forthcoming, for most use-cases.

Steve

Quoted 3 lines

Not all sub-device drivers may implement g_frame_interval() so I'd disable the timeout in that case.

#28 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 65 lines · Steve Longerbeam
Quoted 56 lines · Sakari Ailus

Hi Steve,

Quoted 41 lines · Steve Longerbeam
Quoted 38 lines · Sakari Ailus
Quoted 36 lines · Steve Longerbeam
Quoted 14 lines · Sakari Ailus

Hi Steve,

Quoted 11 lines · Steve Longerbeam

Add a new FRAME_TIMEOUT event to signal that a video capture or output device has timed out waiting for reception or transmit completion of a video frame.

---

Documentation/media/uapi/v4l/vidioc-dqevent.rst | 5 +++++
Documentation/media/videodev2.h.rst.exceptions  | 1 +
include/uapi/linux/videodev2.h                  | 1 +
3 files changed, 7 insertions(+)
Quoted 16 lines

Documentation/media/uapi/v4l/vidioc-dqevent.rst call. · line 204

Quoted 13 lines
Documentation/media/uapi/v4l/vidioc-dqevent.rst +5 -0
index 8d663a7..dd77d9b 100644
@@ -197,6 +197,11 @@ call.
 	the regions changes. This event has a struct
 	:c:type:`v4l2_event_motion_det`
 	associated with it.
+    * - ``V4L2_EVENT_FRAME_TIMEOUT``
+      - 7
+      - This event is triggered when the video capture or output device
+	has timed out waiting for the reception or transmit completion of
+	a frame of video.

As you're adding a new interface, I suppose you have an implementation around. How do you determine what that timeout should be?

The imx-media driver sets the timeout to 1 second, or 30 frame periods at 30 fps.

Quoted 7 lines
Quoted 2 lines

The frame rate is not necessarily constant during streaming. It may well change as a result of lighting conditions.

I think you mean that would be a _temporary_ change in frame rate, but yes I agree the data rate can temporarily fluctuate. Although I doubt lighting conditions would cause a sensor to pause data transmission for a full 1 second.

Likely not, at least not in typical conditions. The exposure time is still quite specific to applications: it could be minutes if you take photos e.g. of the night sky.

Quoted 5 lines

What I'm saying here is that any static value is likely not both reasonable and workable in all potential situations all the time. Still there are cases (as yours below) that may happen in relatively common cases on some hardware (more common than taking long exposure photos of the night sky with the said hardware :)).

Quoted 3 lines

I doubt night photography will ever be a use-case for i.MX. The most common use-case for this driver will be used in automotive applications such as rear-view or 360 degree view cameras.

Ack.

Quoted 21 lines
Quoted 16 lines
Quoted 9 lines
Quoted 8 lines

I wouldn't add an event for this:
this is unreliable and 30 times the frame period is an arbitrary value anyway. No other drivers do this either.

Quoted 6 lines

If no other drivers do this I don't mind removing it. It is really meant to deal with the ADV718x CVBS decoder, which often simply stops sending data on the BT.656 bus if there is an interruption in the input analog signal. But I agree that user space could detect this timeout instead. Unless I hear from someone else that they would like to keep this feature I'll remove it in version 5.

Quoted 4 lines

That's a bit of a special situation --- still there are alike conditions on existing hardware. You should return the buffers to the user with the ERROR flag set --- or return -EIO from VIDIOC_DQBUF, if the condition will persist:

Quoted 4 lines

On i.MX an EOF timeout is not recoverable without a stream restart, so I decided to call vb2_queue_error() when the timeout occurs (instead of sending an event). The user will then get -EIO when it attempts to queue or dequeue further buffers.

It believe that's the correct thing to do.

Quoted 9 lines
Quoted 8 lines

<URL:https://www.linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/vidioc-qbuf.html>

Do you already obtain the frame rate from the image source (e.g. tuner, sensor, decoder) and multiply the frame time by some number in the current implementation?

Quoted 5 lines

No the timeout is a constant value, regardless of the source frame rate. Should the timeout be based on a constant time, or based on a constant # of frames? I really don't think it matters much, what matters is that it be long enough to be reasonably sure no data is forthcoming, for most use-cases.

That should be fine. If there is a use case that requires something else, then the implementation can be changed: it's not visible to the user space anyway.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#29 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

In reply to Steve Longerbeam
Quoted 8 lines · Steve Longerbeam
Quoted 4 lines · Sakari Ailus

That's a bit of a special situation --- still there are alike conditions on existing hardware. You should return the buffers to the user with the ERROR flag set --- or return -EIO from VIDIOC_DQBUF, if the condition will persist:

Quoted 4 lines

On i.MX an EOF timeout is not recoverable without a stream restart, so I decided to call vb2_queue_error() when the timeout occurs (instead of sending an event). The user will then get -EIO when it attempts to queue or dequeue further buffers.

I'm not sure that statement is entirely accurate. With the IMX219 camera, I _could_ (with previous iterations of the iMX capture code) stop it streaming, wait a while, and restart it, and everything continues to work.

Are you sure that the problem you have here is caused by the iMX6 rather than the ADV718x CVBS decoder (your initial description said it was the decoder.)

If it _is_ the decoder that's going wrong, that doesn't justify cripping the rest of the driver for one instance of broken hardware that _might_ be attached to it.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#30 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 14 lines · Russell King - ARM Linux
Quoted 8 lines · Steve Longerbeam
Quoted 4 lines · Sakari Ailus

That's a bit of a special situation --- still there are alike conditions on existing hardware. You should return the buffers to the user with the ERROR flag set --- or return -EIO from VIDIOC_DQBUF, if the condition will persist:

Quoted 4 lines

On i.MX an EOF timeout is not recoverable without a stream restart, so I decided to call vb2_queue_error() when the timeout occurs (instead of sending an event). The user will then get -EIO when it attempts to queue or dequeue further buffers.

Quoted 4 lines

I'm not sure that statement is entirely accurate. With the IMX219 camera, I _could_ (with previous iterations of the iMX capture code) stop it streaming, wait a while, and restart it, and everything continues to work.

Hi Russell, did you see the "EOF timeout" kernel error message when you stopped the IMX219 from streaming? Only a "EOF timeout" message indicates the unrecoverable case.

Quoted 4 lines

Are you sure that the problem you have here is caused by the iMX6 rather than the ADV718x CVBS decoder (your initial description said it was the decoder.)

Actually yes I did say it was the adv718x, but in fact I doubt the adv718x has abruptly stopped data transmission on the bt.656 bus. I actually suspect the IPU, specifically the CSI. In our experience the CSI is rather sensitive to glitches and/or truncated frames on the bt.656 bus and can easily loose vertical sync, and/or lock-up.

Steve

Quoted 5 lines

If it _is_ the decoder that's going wrong, that doesn't justify cripping the rest of the driver for one instance of broken hardware that _might_ be attached to it.

#31 lore raw

Re: [PATCH v4 13/36] [media] v4l2: add a frame timeout event

Quoted 9 lines · Steve Longerbeam
Quoted 4 lines · Russell King - ARM Linux

I'm not sure that statement is entirely accurate. With the IMX219 camera, I _could_ (with previous iterations of the iMX capture code) stop it streaming, wait a while, and restart it, and everything continues to work.

Hi Russell, did you see the "EOF timeout" kernel error message when you stopped the IMX219 from streaming? Only a "EOF timeout" message indicates the unrecoverable case.

I really couldn't tell you anymore - I can't go back and test at all, because:

(a) your v4 patch set never worked for me
(b) I've now moved forward to v4.11-rc1, which conflicts with your v4 and older patch sets.

In any case, I'm in complete disagreement with many of the points that Sakari has been bringing up, and I'm finding the direction that things are progressing to be abhorrent.

I've discussed with Mauro about (eg) the application interface, and unsurprisingly to me, Mauro immediately said about control inheritence to the main v4l2 device, contradicting what Sakari has been saying. The subdev API is supposed to be there to allow for finer control, it's not a "one or the other" thing. The controls are still supposed to be exposed through the main v4l2 subdev device.

Since the v4l2 stuff is becoming abhorrent, and I've also come to realise that I'm going to have to write an entirely new userspace application to capture, debayer and encode efficiently, I'm finding that I've little motivation to take much of a further interest in iMX6 capture, or indeed continue my reverse engineering efforts of the IMX219 sensor.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#32 lore raw

PATCH v4 14/36 v4l2-mc: add a function to inherit controls from a pipeline

In reply to Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +48 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)
+{
+	struct media_device *mdev = start_entity->graph_obj.mdev;
+	struct media_entity *entity;
+	struct media_graph graph;
+	struct v4l2_subdev *sd;
+	int ret;
+
+	ret = media_graph_walk_init(&graph, mdev);
+	if (ret)
+		return ret;
+
+	media_graph_walk_start(&graph, start_entity);
+
+	while ((entity = media_graph_walk_next(&graph))) {
+		if (!is_media_entity_v4l2_subdev(entity))
+			continue;
+
+		sd = media_entity_to_v4l2_subdev(entity);
+
+		ret = v4l2_ctrl_add_handler(vfd->ctrl_handler,
+					    sd->ctrl_handler,
+					    NULL);
+		if (ret)
+			break;
+	}
+
+	media_graph_walk_cleanup(&graph);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(__v4l2_pipeline_inherit_controls);
+
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				   struct media_entity *start_entity)
+{
+	struct media_device *mdev = start_entity->graph_obj.mdev;
+	int ret;
+
+	mutex_lock(&mdev->graph_mutex);
+	ret = __v4l2_pipeline_inherit_controls(vfd, start_entity);
+	mutex_unlock(&mdev->graph_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_pipeline_inherit_controls);
+
 /* -----------------------------------------------------------------------------
  * Pipeline power management
  *
include/media/v4l2-mc.h +25 -0
index 2634d9d..9848e77 100644
@@ -171,6 +171,17 @@ void v4l_disable_media_source(struct video_device *vdev);
  */
 int v4l_vb2q_enable_media_source(struct vb2_queue *q);
 
+/**
+ * v4l2_pipeline_inherit_controls - Add the v4l2 controls from all
+ *				    subdev entities in a pipeline to
+ *				    the given video device.
+ * @vfd: the video device
+ * @start_entity: Starting entity
+ */
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity);
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				   struct media_entity *start_entity);
 
 /**
  * v4l2_pipeline_pm_use - Update the use count of an entity
@@ -231,6 +242,20 @@ static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 	return 0;
 }
 
+static inline int __v4l2_pipeline_inherit_controls(
+	struct video_device *vfd,
+	struct media_entity *start_entity)
+{
+	return 0;
+}
+
+static inline int v4l2_pipeline_inherit_controls(
+	struct video_device *vfd,
+	struct media_entity *start_entity)
+{
+	return 0;
+}
+
 static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
 {
 	return 0;
Signature · 1 line
2.7.4
Reviewed-by on v4 14/36
#33 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 4 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170219/db57b10d/attachment.sig>
#34 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Steve Longerbeam

Hi Steve,

Quoted 22 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 5 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

- This implementation is only workable as long as you do not modify the pipeline. Once you disable a link along the pipeline, a device where the control was inherited from may no longer be a part of the pipeline. Depending on the hardware, it could be a part of another pipeline, in which case it certainly must not be accessible through an unrelated video node. As the function is added to the framework, I would expect it to handle such a case correctly.

- I assume it is the responsibility of the caller of this function to ensure the device in question will not be powered off whilst the video node is used as another user space interface to such a sub-device. If the driver uses the generic PM functions in the same file, this works, but it still has to be documented.

Quoted 91 lines
drivers/media/v4l2-core/v4l2-mc.c +45 -0
+{
+	struct media_device *mdev = start_entity->graph_obj.mdev;
+	struct media_entity *entity;
+	struct media_graph graph;
+	struct v4l2_subdev *sd;
+	int ret;
+
+	ret = media_graph_walk_init(&graph, mdev);
+	if (ret)
+		return ret;
+
+	media_graph_walk_start(&graph, start_entity);
+
+	while ((entity = media_graph_walk_next(&graph))) {
+		if (!is_media_entity_v4l2_subdev(entity))
+			continue;
+
+		sd = media_entity_to_v4l2_subdev(entity);
+
+		ret = v4l2_ctrl_add_handler(vfd->ctrl_handler,
+					    sd->ctrl_handler,
+					    NULL);
+		if (ret)
+			break;
+	}
+
+	media_graph_walk_cleanup(&graph);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(__v4l2_pipeline_inherit_controls);
+
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				   struct media_entity *start_entity)
+{
+	struct media_device *mdev = start_entity->graph_obj.mdev;
+	int ret;
+
+	mutex_lock(&mdev->graph_mutex);
+	ret = __v4l2_pipeline_inherit_controls(vfd, start_entity);
+	mutex_unlock(&mdev->graph_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_pipeline_inherit_controls);
+
 /* -----------------------------------------------------------------------------
  * Pipeline power management
  *
include/media/v4l2-mc.h +25 -0
index 2634d9d..9848e77 100644
@@ -171,6 +171,17 @@ void v4l_disable_media_source(struct video_device *vdev);
  */
 int v4l_vb2q_enable_media_source(struct vb2_queue *q);
 
+/**
+ * v4l2_pipeline_inherit_controls - Add the v4l2 controls from all
+ *				    subdev entities in a pipeline to
+ *				    the given video device.
+ * @vfd: the video device
+ * @start_entity: Starting entity
+ */
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity);
+int v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				   struct media_entity *start_entity);
 
 /**
  * v4l2_pipeline_pm_use - Update the use count of an entity
@@ -231,6 +242,20 @@ static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 	return 0;
 }
 
+static inline int __v4l2_pipeline_inherit_controls(
+	struct video_device *vfd,
+	struct media_entity *start_entity)
+{
+	return 0;
+}
+
+static inline int v4l2_pipeline_inherit_controls(
+	struct video_device *vfd,
+	struct media_entity *start_entity)
+{
+	return 0;
+}
+
 static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
 {
 	return 0;
Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
author maintainer
#35 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 28 lines · Sakari Ailus

Hi Steve,

Quoted 25 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
Quoted 7 lines

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 2 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

I don't really understand what you are trying to say. That's exactly what this function is doing, accessing every subdevice in a pipeline directly, in one convenient function call.

Quoted 4 lines

- This implementation is only workable as long as you do not modify the pipeline. Once you disable a link along the pipeline, a device where the control was inherited from may no longer be a part of the pipeline.

That's correct. It's up to the media driver to clear the video device's inherited controls whenever the pipeline is modified, and then call this function again if need be.

In imx-media driver, the function is called in link_setup when the link from a source pad that is attached to a capture video node is enabled. This is the last link that must be made to define the pipeline, so it is at this time that a complete list of subdevice controls can be gathered by walking the pipeline.

Quoted 4 lines

Depending on the hardware, it could be a part of another pipeline, in which case it certainly must not be accessible through an unrelated video node. As the function is added to the framework, I would expect it to handle such a case correctly.

The function will not inherit controls from a device that is not reachable from the given starting subdevice, so I don't understand you're point here.

Quoted 6 lines

- I assume it is the responsibility of the caller of this function to ensure the device in question will not be powered off whilst the video node is used as another user space interface to such a sub-device. If the driver uses the generic PM functions in the same file, this works, but it still has to be documented.

I guess I'm missing something. Why are you bringing up the subject of power? What does this function have to do with whether a subdevice is powered or not? The function makes use of v4l2_ctrl_add_handler(), and the latter has no requirements about whether the device's owning the control handlers are powered or not.

Steve

author maintainer
#36 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 49 lines · Steve Longerbeam
Quoted 31 lines · Sakari Ailus

Hi Steve,

Quoted 28 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48
+++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct
 vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
Quoted 7 lines

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct · line 244

Quoted 2 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+                     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

I don't really understand what you are trying to say. That's exactly what this function is doing, accessing every subdevice in a pipeline directly, in one convenient function call.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

- This implementation is only workable as long as you do not modify the pipeline. Once you disable a link along the pipeline, a device where
the
control was inherited from may no longer be a part of the pipeline.

That's correct. It's up to the media driver to clear the video device's inherited controls whenever the pipeline is modified, and then call this function again if need be.

And here is where I need to eat my words :). I'm not actually clearing the inherited controls if an upstream link from the device node link is modified after the whole pipeline has been configured. If the user does that the controls can become invalid. Need to fix that by clearing device node controls in the link_notify callback.

Steve

Quoted 7 lines

In imx-media driver, the function is called in link_setup when the link from a source pad that is attached to a capture video node is enabled. This is the last link that must be made to define the pipeline, so it is at this time that a complete list of subdevice controls can be gathered by walking the pipeline.

author maintainer
#37 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Steve Longerbeam
Quoted 39 lines · Steve Longerbeam
Quoted 36 lines · Sakari Ailus

Hi Steve,

Quoted 24 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48
+++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct · line 244

Quoted 6 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct
 vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+                     struct media_entity *start_entity)

I have a few concerns / questions:

Quoted 6 lines
Quoted 2 lines

- What's the purpose of this patch? Why not to access the sub-device node directly?

I don't really understand what you are trying to say.<snip>

Actually I think I understand what you mean now. Yes, the user can always access a subdev's control directly from its /dev/v4l-subdevXX. I'm only providing this feature as a convenience to the user, so that all controls in a pipeline can be accessed from one place, i.e. the main capture device node.

Steve

#38 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Steve,

Quoted 46 lines · Steve Longerbeam
Quoted 43 lines · Steve Longerbeam
Quoted 38 lines · Sakari Ailus

Hi Steve,

Quoted 24 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
drivers/media/v4l2-core/v4l2-mc.c | 48
+++++++++++++++++++++++++++++++++++++++
include/media/v4l2-mc.h | 25 ++++++++++++++++++++

2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct · line 244

Quoted 6 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct
 vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+                     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

Quoted 8 lines
Quoted 2 lines

I don't really understand what you are trying to say.<snip>

Actually I think I understand what you mean now. Yes, the user can always access a subdev's control directly from its /dev/v4l-subdevXX. I'm only providing this feature as a convenience to the user, so that all controls in a pipeline can be accessed from one place, i.e. the main capture device node.

No other MC based V4L2 driver does this. You'd be creating device specific behaviour that differs from what the rest of the drivers do. The purpose of MC is to provide the user with knowledge of what devices are there, and the V4L2 sub-devices interface is used to access them in this case.

It does matter where a control is implemented, too. If the pipeline contains multiple sub-devices that implement the same control, only one of them may be accessed. The driver calling the function (or even less the function) would not know which one of them should be ignored.

If you need such functionality, it should be implemented in the user space instead.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
author maintainer
#39 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 58 lines · Sakari Ailus

Hi Steve,

Quoted 46 lines · Steve Longerbeam
Quoted 43 lines · Steve Longerbeam
Quoted 38 lines · Sakari Ailus

Hi Steve,

Quoted 24 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
drivers/media/v4l2-core/v4l2-mc.c | 48
+++++++++++++++++++++++++++++++++++++++
include/media/v4l2-mc.h | 25 ++++++++++++++++++++

2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct · line 244

Quoted 6 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct
 vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+                     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

Quoted 8 lines
Quoted 2 lines

I don't really understand what you are trying to say.<snip>

Actually I think I understand what you mean now. Yes, the user can always access a subdev's control directly from its /dev/v4l-subdevXX. I'm only providing this feature as a convenience to the user, so that all controls in a pipeline can be accessed from one place, i.e. the main capture device node.

Quoted 4 lines

No other MC based V4L2 driver does this. You'd be creating device specific behaviour that differs from what the rest of the drivers do. The purpose of MC is to provide the user with knowledge of what devices are there, and the V4L2 sub-devices interface is used to access them in this case.

Well, again, I don't mind removing this. As I said it is only a convenience (although quite a nice one in my opinion). I'd like to hear from others whether this is worth keeping though.

Quoted 5 lines

It does matter where a control is implemented, too. If the pipeline contains multiple sub-devices that implement the same control, only one of them may be accessed. The driver calling the function (or even less the function) would not know which one of them should be ignored.

Yes the pipeline should not have any duplicate controls. On imx-media no pipelines that can be configured have duplicate controls.

Steve

Quoted 4 lines

If you need such functionality, it should be implemented in the user space instead.

#40 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Sakari Ailus
Quoted 28 lines · Sakari Ailus

Hi Steve,

Quoted 25 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
Quoted 7 lines

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 2 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

What tools are in existance _today_ to provide access to these controls via the sub-device nodes?

v4l-tools doesn't last time I looked - in fact, the only tool in v4l-tools which is capable of accessing the subdevices is media-ctl, and that only provides functionality for configuring the pipeline.

So, pointing people at vapourware userspace is really quite rediculous.

The established way to control video capture is through the main video capture device, not through the sub-devices. Yes, the controls are exposed through sub-devices too, but that does not mean that is the correct way to access them.

The v4l2 documentation (Documentation/media/kapi/v4l2-controls.rst) even disagrees with your statements. That talks about control inheritence from sub-devices to the main video device, and the core v4l2 code provides _automatic_ support for this - see v4l2_device_register_subdev():

        /* This just returns 0 if either of the two args is NULL */
        err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL);

which merges the subdev's controls into the main device's control handler.

So, (a) I don't think Steve needs to add this code, and (b) I think your statements about not inheriting controls goes against the documentation and API compatibility with _existing_ applications, and ultimately hurts the user experience, since there's nothing existing today to support what you're suggesting in userspace.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#41 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 37 lines · Russell King - ARM Linux
Quoted 28 lines · Sakari Ailus

Hi Steve,

Quoted 25 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
Quoted 7 lines

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 2 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

- What's the purpose of this patch? Why not to access the sub-device node directly?

Quoted 8 lines

What tools are in existance _today_ to provide access to these controls via the sub-device nodes?

v4l-tools doesn't last time I looked - in fact, the only tool in v4l-tools which is capable of accessing the subdevices is media-ctl, and that only provides functionality for configuring the pipeline.

So, pointing people at vapourware userspace is really quite rediculous.

Hi Russell,

Yes, that's a big reason why I added this capability. The v4l2-ctl tool won't accept subdev nodes, although Philipp Zabel has a quick hack to get around this (ignore return code from VIDIOC_QUERYCAP).

Quoted 12 lines

The established way to control video capture is through the main video capture device, not through the sub-devices. Yes, the controls are exposed through sub-devices too, but that does not mean that is the correct way to access them.

The v4l2 documentation (Documentation/media/kapi/v4l2-controls.rst) even disagrees with your statements. That talks about control inheritence from sub-devices to the main video device, and the core v4l2 code provides _automatic_ support for this - see v4l2_device_register_subdev():

Quoted 5 lines
        /* This just returns 0 if either of the two args is NULL */
        err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL);

which merges the subdev's controls into the main device's control handler.

Actually v4l2_dev->ctrl_handler is not of much use to me. This will compose a list of controls from all registered subdevs, i.e. _all possible controls_.

What v4l2_pipeline_inherit_controls() does is compose a list of controls that are reachable and available in the currently configured pipeline.

Steve

Quoted 7 lines

So, (a) I don't think Steve needs to add this code, and (b) I think your statements about not inheriting controls goes against the documentation and API compatibility with _existing_ applications, and ultimately hurts the user experience, since there's nothing existing today to support what you're suggesting in userspace.

#42 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux

Hi Russell,

Quoted 34 lines · Russell King - ARM Linux
Quoted 33 lines · Sakari Ailus

Hi Steve,

Quoted 22 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 5 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

Quoted 5 lines
Quoted 2 lines

- What's the purpose of this patch? Why not to access the sub-device node directly?

What tools are in existance _today_ to provide access to these controls via the sub-device nodes?

yavta, for instance:

<URL:http://git.ideasonboard.org/yavta.git>

VIDIOC_QUERYCAP isn't supported on sub-devices and v4l2-ctl appears to be checking for that. That check should be removed (with possible other implications taken into account).

Quoted 6 lines

v4l-tools doesn't last time I looked - in fact, the only tool in v4l-tools which is capable of accessing the subdevices is media-ctl, and that only provides functionality for configuring the pipeline.

So, pointing people at vapourware userspace is really quite rediculous.

Do bear in mind that there are other programs that can make use of these interfaces. It's not just the test programs, or a test program you attempted to use.

Quoted 5 lines

The established way to control video capture is through the main video capture device, not through the sub-devices. Yes, the controls are exposed through sub-devices too, but that does not mean that is the correct way to access them.

It is. That's the very purpose of the sub-devices: to provide access to the hardware independently of how the links are configured.

Quoted 7 lines

The v4l2 documentation (Documentation/media/kapi/v4l2-controls.rst) even disagrees with your statements. That talks about control inheritence from sub-devices to the main video device, and the core v4l2 code provides _automatic_ support for this - see v4l2_device_register_subdev():

Quoted 5 lines
        /* This just returns 0 if either of the two args is NULL */
        err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL);

which merges the subdev's controls into the main device's control handler.

That's done on different kind of devices: those that provide plain V4L2 API to control the entire device. V4L2 sub-device interface is used *in kernel* as an interface to control sub-devices that do not need to be exposed to the user space.

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#43 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 43 lines · Sakari Ailus

Hi Russell,

Quoted 34 lines · Russell King - ARM Linux
Quoted 33 lines · Sakari Ailus

Hi Steve,

Quoted 22 lines · Steve Longerbeam

v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device.

---
 drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++
 include/media/v4l2-mc.h           | 25 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
drivers/media/v4l2-core/v4l2-mc.c +1 -0
index 303980b..09d4d97 100644
@@ -22,6 +22,7 @@
 #include <linux/usb.h>
 #include <media/media-device.h>
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
 #include <media/v4l2-mc.h>
 #include <media/v4l2-subdev.h>

drivers/media/v4l2-core/v4l2-mc.c int v4l_vb2q_enable_media_source(struct vb2_queue *q) · line 243

Quoted 5 lines
drivers/media/v4l2-core/v4l2-mc.c +2 -0
@@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 
+int __v4l2_pipeline_inherit_controls(struct video_device *vfd,
+				     struct media_entity *start_entity)

I have a few concerns / questions:

Quoted 5 lines
Quoted 2 lines

- What's the purpose of this patch? Why not to access the sub-device node directly?

What tools are in existance _today_ to provide access to these controls via the sub-device nodes?

Quoted 7 lines

yavta, for instance:

<URL:http://git.ideasonboard.org/yavta.git>

VIDIOC_QUERYCAP isn't supported on sub-devices and v4l2-ctl appears to be checking for that. That check should be removed (with possible other implications taken into account).

No, the subdev API should get a similar QUERYCAP ioctl. There isn't a single ioctl that is guaranteed to be available for all subdev devices. I've made proposals for this in the past, and those have all been shot down.

Add that, and I'll add support for subdevs in v4l2-ctl.

Quoted 34 lines
Quoted 7 lines

v4l-tools doesn't last time I looked - in fact, the only tool in v4l-tools which is capable of accessing the subdevices is media-ctl, and that only provides functionality for configuring the pipeline.

So, pointing people at vapourware userspace is really quite rediculous.

Do bear in mind that there are other programs that can make use of these interfaces. It's not just the test programs, or a test program you attempted to use.

Quoted 5 lines

The established way to control video capture is through the main video capture device, not through the sub-devices. Yes, the controls are exposed through sub-devices too, but that does not mean that is the correct way to access them.

It is. That's the very purpose of the sub-devices: to provide access to the hardware independently of how the links are configured.

Quoted 7 lines

The v4l2 documentation (Documentation/media/kapi/v4l2-controls.rst) even disagrees with your statements. That talks about control inheritence from sub-devices to the main video device, and the core v4l2 code provides _automatic_ support for this - see v4l2_device_register_subdev():

Quoted 5 lines
        /* This just returns 0 if either of the two args is NULL */
        err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL);

which merges the subdev's controls into the main device's control handler.

Quoted 8 lines

That's done on different kind of devices: those that provide plain V4L2 API to control the entire device. V4L2 sub-device interface is used *in kernel* as an interface to control sub-devices that do not need to be exposed to the user space.

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Russell's comments are spot on and it is a thorn in my side that this still hasn't been addressed.

I want to see if I can get time from my boss to work on this this summer, but there is no guarantee.

The main reason this hasn't been a much bigger problem is that most end-users make custom applications for this hardware. It makes sense, if you need full control over everything you make the application yourself, that's the whole point.

But there was always meant to be a layer (libv4l plugin) that could be used to setup a 'default scenario' that existing applications could use, but that was never enforced, sadly.

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Regards,

Hans

#44 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 3 lines · Hans Verkuil

But there was always meant to be a layer (libv4l plugin) that could be used to setup a 'default scenario' that existing applications could use, but that was never enforced, sadly.

However, there's other painful issues lurking in userspace, particularly to do with the v4l libraries.

The idea that the v4l libraries should intercept the format negotiation between the application and kernel is a particularly painful one - the default gstreamer build detects the v4l libraries, and links against it. That much is fine.

However, the problem comes when you're trying to use bayer formats. The v4l libraries "helpfully" (or rather unhelpfully) intercept the format negotiation, and decide that they'll invoke v4lconvert to convert the bayer to RGB for you, whether you want them to do that or not.

v4lconvert may not be the most efficient way to convert, or even what is desired (eg, you may want to receive the raw bayer image.) However, since the v4l libraries/v4lconvert gives you no option but to have its conversion forced into the pipeline, other options (such as using the gstreamer neon accelerated de-bayer plugin) isn't an option without rebuilding gstreamer _without_ linking against the v4l libraries.

At that point, saying "this should be done in a libv4l plugin" becomes a total nonsense, because if you need to avoid libv4l due to its stupidities, you don't get the benefit of subdevs, and it yet again _forces_ people down the route of custom applications.

So, I really don't agree with pushing this into a userspace library plugin - at least not with the current state there.

_At least_ the debayering in the v4l libraries needs to become optional.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#45 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 30 lines · Russell King - ARM Linux
Quoted 3 lines · Hans Verkuil

But there was always meant to be a layer (libv4l plugin) that could be used to setup a 'default scenario' that existing applications could use, but that was never enforced, sadly.

However, there's other painful issues lurking in userspace, particularly to do with the v4l libraries.

The idea that the v4l libraries should intercept the format negotiation between the application and kernel is a particularly painful one - the default gstreamer build detects the v4l libraries, and links against it. That much is fine.

However, the problem comes when you're trying to use bayer formats. The v4l libraries "helpfully" (or rather unhelpfully) intercept the format negotiation, and decide that they'll invoke v4lconvert to convert the bayer to RGB for you, whether you want them to do that or not.

v4lconvert may not be the most efficient way to convert, or even what is desired (eg, you may want to receive the raw bayer image.) However, since the v4l libraries/v4lconvert gives you no option but to have its conversion forced into the pipeline, other options (such as using the gstreamer neon accelerated de-bayer plugin) isn't an option without rebuilding gstreamer _without_ linking against the v4l libraries.

At that point, saying "this should be done in a libv4l plugin" becomes a total nonsense, because if you need to avoid libv4l due to its stupidities, you don't get the benefit of subdevs, and it yet again _forces_ people down the route of custom applications.

Quoted 5 lines

So, I really don't agree with pushing this into a userspace library plugin - at least not with the current state there.

_At least_ the debayering in the v4l libraries needs to become optional.

I *thought* that when a plugin is used the format conversion code was disabled. But I'm not sure.

The whole problem is that we still don't have a decent plugin for an MC driver. There is one for the exynos4 floating around, but it's still not accepted.

Companies write the driver, but the plugin isn't really needed since their customers won't use it anyway since they make their own embedded driver.

And nobody of the media core developers has the time to work on the docs, utilities and libraries you need to make this all work cleanly and reliably.

As mentioned, I will attempt to try and get some time to work on this later this year. Fingers crossed.

We also have a virtual MC driver floating around. I've pinged the author if she can fix the last round of review comments and post a new version. Having a virtual driver makes life much easier when writing docs, utilities, etc. since you don't need real hardware which can be hard to obtain and run.

Again, I agree completely with you. But we don't have many core developers who can do something like this, and it's even harder for them to find the time.

Solutions on a postcard...

BTW, Steve: this has nothing to do with your work, it's a problem in our subsystem.

Regards,

Hans

#46 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 2 lines · Hans Verkuil

And nobody of the media core developers has the time to work on the docs, utilities and libraries you need to make this all work cleanly and reliably.

Well, talking about docs, and in connection to control inheritence, this is already documented in at least three separate places:

Documentation/media/uapi/v4l/dev-subdev.rst:

Controls
========
...
Depending on the driver, those controls might also be exposed through one (or several) V4L2 device nodes.

Documentation/media/kapi/v4l2-subdev.rst:

``VIDIOC_QUERYCTRL``,
``VIDIOC_QUERYMENU``,
``VIDIOC_G_CTRL``,
``VIDIOC_S_CTRL``,
``VIDIOC_G_EXT_CTRLS``,
``VIDIOC_S_EXT_CTRLS`` and
``VIDIOC_TRY_EXT_CTRLS``:

The controls ioctls are identical to the ones defined in V4L2. They behave identically, with the only exception that they deal only with controls implemented in the sub-device. Depending on the driver, those controls can be also be accessed through one (or several) V4L2 device nodes.

Then there's Documentation/media/kapi/v4l2-controls.rst, which gives a step by step approach to the main video device inheriting controls from its subdevices, and it says:

Inheriting Controls
-------------------

When a sub-device is registered with a V4L2 driver by calling v4l2_device_register_subdev() and the ctrl_handler fields of both v4l2_subdev and v4l2_device are set, then the controls of the subdev will become automatically available in the V4L2 driver as well. If the subdev driver contains controls that already exist in the V4L2 driver, then those will be skipped (so a V4L2 driver can always override a subdev control).

What happens here is that v4l2_device_register_subdev() calls v4l2_ctrl_add_handler() adding the controls of the subdev to the controls of v4l2_device.

So, either the docs are wrong, or the advice being mentioned in emails about subdev control inheritence is misleading. Whatever, the two are currently inconsistent.

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

Right now, my view is that v4l2 is currently being screwed up by people with different opinions - there is no unified concensus on how any of this stuff is supposed to work, everyone is pulling in different directions. That needs solving _really_ quickly, so I suggest that v4l2 people urgently talk to each other and thrash out some of the issues that Steve's patch set has brought up, and settle on a way forward, rather than what is seemingly happening today - which is everyone working in isolation of everyone else with their own bias on how things should be done.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#47 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 45 lines · Russell King - ARM Linux
Quoted 2 lines · Hans Verkuil

And nobody of the media core developers has the time to work on the docs, utilities and libraries you need to make this all work cleanly and reliably.

Well, talking about docs, and in connection to control inheritence, this is already documented in at least three separate places:

Documentation/media/uapi/v4l/dev-subdev.rst:

Controls
========
...
Depending on the driver, those controls might also be exposed through one (or several) V4L2 device nodes.

Documentation/media/kapi/v4l2-subdev.rst:

``VIDIOC_QUERYCTRL``,
``VIDIOC_QUERYMENU``,
``VIDIOC_G_CTRL``,
``VIDIOC_S_CTRL``,
``VIDIOC_G_EXT_CTRLS``,
``VIDIOC_S_EXT_CTRLS`` and
``VIDIOC_TRY_EXT_CTRLS``:

The controls ioctls are identical to the ones defined in V4L2. They behave identically, with the only exception that they deal only with controls implemented in the sub-device. Depending on the driver, those controls can be also be accessed through one (or several) V4L2 device nodes.

Then there's Documentation/media/kapi/v4l2-controls.rst, which gives a step by step approach to the main video device inheriting controls from its subdevices, and it says:

Inheriting Controls
-------------------

When a sub-device is registered with a V4L2 driver by calling v4l2_device_register_subdev() and the ctrl_handler fields of both v4l2_subdev and v4l2_device are set, then the controls of the subdev will become automatically available in the V4L2 driver as well. If the subdev driver contains controls that already exist in the V4L2 driver, then those will be skipped (so a V4L2 driver can always override a subdev control).

Quoted 7 lines

What happens here is that v4l2_device_register_subdev() calls v4l2_ctrl_add_handler() adding the controls of the subdev to the controls of v4l2_device.

So, either the docs are wrong, or the advice being mentioned in emails about subdev control inheritence is misleading. Whatever, the two are currently inconsistent.

These docs were written for non-MC drivers, and for those the documentation is correct. Unfortunately, this was never updated for MC drivers.

Quoted 4 lines

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

I can't comment either, not having seen his mail and reasoning.

Quoted 9 lines

Right now, my view is that v4l2 is currently being screwed up by people with different opinions - there is no unified concensus on how any of this stuff is supposed to work, everyone is pulling in different directions. That needs solving _really_ quickly, so I suggest that v4l2 people urgently talk to each other and thrash out some of the issues that Steve's patch set has brought up, and settle on a way forward, rather than what is seemingly happening today - which is everyone working in isolation of everyone else with their own bias on how things should be done.

The simple fact is that to my knowledge no other MC applications inherit controls from subdevs. Suddenly doing something different here seems very wrong to me and needs very good reasons.

But yes, the current situation sucks. Yelling doesn't help though if nobody has time and there are several other high-prio projects that need our attention as well.

If you know a good kernel developer who has a few months to spare, please point him/her in our direction!

Regards,

Hans

#48 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Fri, 10 Mar 2017 15:20:48 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 5 lines

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

I can't comment either, not having seen his mail and reasoning.

The rationale is that we should support the simplest use cases first.

In the case of the first MC-based driver (and several subsequent ones), the simplest use case required MC, as it was meant to suport a custom-made sophisticated application that required fine control on each component of the pipeline and to allow their advanced proprietary AAA userspace-based algorithms to work.

That's not true, for example, for the UVC driver. There, MC is optional, as it should be.

Quoted 10 lines
Quoted 9 lines

Right now, my view is that v4l2 is currently being screwed up by people with different opinions - there is no unified concensus on how any of this stuff is supposed to work, everyone is pulling in different directions. That needs solving _really_ quickly, so I suggest that v4l2 people urgently talk to each other and thrash out some of the issues that Steve's patch set has brought up, and settle on a way forward, rather than what is seemingly happening today - which is everyone working in isolation of everyone else with their own bias on how things should be done.

Quoted 3 lines

The simple fact is that to my knowledge no other MC applications inherit controls from subdevs. Suddenly doing something different here seems very wrong to me and needs very good reasons.

That's because it was not needed before, as other subdev-based drivers are meant to be used only on complex scenarios with custom-made apps.

Thanks,
Mauro

#49 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Mauro (and others),

Quoted 11 lines · Mauro Carvalho Chehab

Em Fri, 10 Mar 2017 15:20:48 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 5 lines

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

I can't comment either, not having seen his mail and reasoning.

Quoted 7 lines

The rationale is that we should support the simplest use cases first.

In the case of the first MC-based driver (and several subsequent ones), the simplest use case required MC, as it was meant to suport a custom-made sophisticated application that required fine control on each component of the pipeline and to allow their advanced proprietary AAA userspace-based algorithms to work.

The first MC based driver (omap3isp) supports what the hardware can do, it does not support applications as such.

Adding support to drivers for different "operation modes" --- this is essentially what is being asked for --- is not an approach which could serve either purpose (some functionality with simple interface vs. fully support what the hardware can do, with interfaces allowing that) adequately in the short or the long run.

If we are missing pieces in the puzzle --- in this case the missing pieces in the puzzle are a generic pipeline configuration library and another library that, with the help of pipeline autoconfiguration would implement "best effort" service for regular V4L2 on top of the MC + V4L2 subdev + V4L2 --- then these pieces need to be impelemented. The solution is *not* to attempt to support different types of applications in each driver separately. That will make writing drivers painful, error prone and is unlikely ever deliver what either purpose requires.

So let's continue to implement the functionality that the hardware supports. Making a different choice here is bound to create a lasting conflict between having to change kernel interface behaviour and the requirement of supporting new functionality that hasn't been previously thought of, pushing away SoC vendors from V4L2 ecosystem. This is what we all do want to avoid.

As far as i.MX6 driver goes, it is always possible to implement i.MX6 plugin for libv4l to perform this. This should be much easier than getting the automatic pipe configuration library and the rest working, and as it is custom for i.MX6, the resulting plugin may make informed technical choices for better functionality. Jacek has been working on such a plugin for Samsung Exynos hardware, but I don't think he has quite finished it yey.

The original plan was and continues to be sound, it's just that there have always been too few hands to implement it. :-(

Quoted 3 lines

That's not true, for example, for the UVC driver. There, MC is optional, as it should be.

UVC is different. The device simply provides additional information through MC to the user but MC (or V4L2 sub-device interface) is not used for controlling the device.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#50 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Sat, 11 Mar 2017 00:37:14 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 16 lines

Hi Mauro (and others),

Quoted 13 lines · Mauro Carvalho Chehab

Em Fri, 10 Mar 2017 15:20:48 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 5 lines

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

I can't comment either, not having seen his mail and reasoning.

The rationale is that we should support the simplest use cases first.

Quoted 8 lines
Quoted 5 lines

In the case of the first MC-based driver (and several subsequent ones), the simplest use case required MC, as it was meant to suport a custom-made sophisticated application that required fine control on each component of the pipeline and to allow their advanced proprietary AAA userspace-based algorithms to work.

The first MC based driver (omap3isp) supports what the hardware can do, it does not support applications as such.

All media drivers support a subset of what the hardware can do. The question is if such subset covers the use cases or not.

The current MC-based drivers (except for uvc) took a patch to offer a more advanced API, to allow direct control to each IP module, as it was said, by the time we merged the OMAP3 driver, that, for the N9/N900 camera to work, it was mandatory to access the pipeline's individual components.

Such approach require that some userspace software will have knowledge about some hardware details, in order to setup pipelines and send controls to the right components. That makes really hard to have a generic user friendly application to use such devices.

Non-MC based drivers control the hardware via a portable interface with doesn't require any knowledge about the hardware specifics, as either the Kernel or some firmware at the device will set any needed pipelines.

In the case of V4L2 controls, when there's no subdev API, the main driver (e. g. the driver that creates the /dev/video nodes) sends a multicast message to all bound I2C drivers. The driver(s) that need them handle it. When the same control may be implemented on different drivers, the main driver sends a unicast message to just one driver[1].

[1] There are several non-MC drivers that have multiple ways to control some things, like doing scaling or adjust volume levels at either the bridge driver or at a subdriver.

There's nothing wrong with this approach: it works, it is simpler, it is generic. So, if it covers most use cases, why not allowing it for usecases where a finer control is not a requirement?

Quoted 5 lines

Adding support to drivers for different "operation modes" --- this is essentially what is being asked for --- is not an approach which could serve either purpose (some functionality with simple interface vs. fully support what the hardware can do, with interfaces allowing that) adequately in the short or the long run.

Why not?

Quoted 9 lines

If we are missing pieces in the puzzle --- in this case the missing pieces in the puzzle are a generic pipeline configuration library and another library that, with the help of pipeline autoconfiguration would implement "best effort" service for regular V4L2 on top of the MC + V4L2 subdev + V4L2 --- then these pieces need to be impelemented. The solution is *not* to attempt to support different types of applications in each driver separately. That will make writing drivers painful, error prone and is unlikely ever deliver what either purpose requires.

Quoted 5 lines

So let's continue to implement the functionality that the hardware supports. Making a different choice here is bound to create a lasting conflict between having to change kernel interface behaviour and the requirement of supporting new functionality that hasn't been previously thought of, pushing away SoC vendors from V4L2 ecosystem. This is what we all do want to avoid.

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

That's why I'm saying that I'm OK on merging any patch that would allow setting controls via the /dev/video interface on MC-based drivers when compiled without subdev API. I may also consider merging patches allowing to change the behavior on runtime, when compiled with subdev API.

Quoted 5 lines

As far as i.MX6 driver goes, it is always possible to implement i.MX6 plugin for libv4l to perform this. This should be much easier than getting the automatic pipe configuration library and the rest working, and as it is custom for i.MX6, the resulting plugin may make informed technical choices for better functionality.

I wouldn't call "much easier" something that experienced media developers failed to do over the last 8 years.

It is just the opposite: broadcasting a control via I2C is very easy:
there are several examples about how to do that all over the media drivers.

Quoted 2 lines

Jacek has been working on such a plugin for
Samsung Exynos hardware, but I don't think he has quite finished it yey.

As Jacek answered when questioned about the merge status:

Hi Hans,

On 11/03/2016 12:51 PM, Hans Verkuil wrote:
> Hi all,
>
> Is there anything that blocks me from merging this?
>
> This plugin work has been ongoing for years and unless there are serious > objections I propose that this is merged.
>
> Jacek, is there anything missing that would prevent merging this?

There were issues raised by Sakari during last review, related to the way how v4l2 control bindings are defined. That discussion wasn't finished, so I stayed by my approach. Other than that - I've tested it and it works fine both with GStreamer and my test app.

After that, he sent a new version (v7.1), but never got reviews.

Quoted 2 lines

The original plan was and continues to be sound, it's just that there have always been too few hands to implement it. :-(

If there are no people to implement a plan, it doesn't matter how good the plan is, it won't work.

Quoted 6 lines
Quoted 2 lines

That's not true, for example, for the UVC driver. There, MC is optional, as it should be.

UVC is different. The device simply provides additional information through MC to the user but MC (or V4L2 sub-device interface) is not used for controlling the device.

It is not different. If the Kernel is compiled without the V4L2 subdev interface, the i.MX6 driver (or whatever other driver) won't receive any control via the subdev interface. So, it has to handle the control logic control via the only interface that supports it, e. g. via the video devnode.

Thanks,
Mauro

#51 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi!

Quoted 19 lines
Quoted 10 lines
Quoted 7 lines

The rationale is that we should support the simplest use cases first.

In the case of the first MC-based driver (and several subsequent ones), the simplest use case required MC, as it was meant to suport a custom-made sophisticated application that required fine control on each component of the pipeline and to allow their advanced proprietary AAA userspace-based algorithms to work.

The first MC based driver (omap3isp) supports what the hardware can do, it does not support applications as such.

All media drivers support a subset of what the hardware can do. The question is if such subset covers the use cases or not.

The current MC-based drivers (except for uvc) took a patch to offer a more advanced API, to allow direct control to each IP module, as it was said, by the time we merged the OMAP3 driver, that, for the N9/N900 camera to work, it was mandatory to access the pipeline's individual components.

Quoted 4 lines

Such approach require that some userspace software will have knowledge about some hardware details, in order to setup pipelines and send controls to the right components. That makes really hard to have a generic user friendly application to use such devices.

Well. Even if you propagate controls to the right components, there's still a lot application needs to know about the camera subsystem. Focus lengths, for example. Speed of the focus coil. Whether or not aperture controls are available. If they are not, what is the fixed aperture.

Dunno. Knowing what control to apply on what subdevice does not look like the hardest part of camera driver. Yes, it would be a tiny bit easier if I would have just one device to deal with, but.... fcam-dev has cca 20000 lines of C++ code.

Quoted 6 lines

In the case of V4L2 controls, when there's no subdev API, the main driver (e. g. the driver that creates the /dev/video nodes) sends a multicast message to all bound I2C drivers. The driver(s) that need them handle it. When the same control may be implemented on different drivers, the main driver sends a unicast message to just one driver[1].

Dunno. There's quite common to have two flashes. In that case, will application control both at the same time?

Quoted 3 lines

There's nothing wrong with this approach: it works, it is simpler, it is generic. So, if it covers most use cases, why not allowing it for usecases where a finer control is not a requirement?

Because the resulting interface is quite ugly?

Quoted 3 lines

That's why I'm saying that I'm OK on merging any patch that would allow setting controls via the /dev/video interface on MC-based drivers when compiled without subdev API. I may also consider merging patches allowing

So.. userspace will now have to detect if subdev is available or not, and access hardware in different ways?

Quoted 5 lines
Quoted 2 lines

The original plan was and continues to be sound, it's just that there have always been too few hands to implement it. :-(

If there are no people to implement a plan, it doesn't matter how good the plan is, it won't work.

If the plan is good, someone will do it.
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/4438a42a/attachment.sig>
#52 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Mauro Carvalho Chehab
Quoted 10 lines · Mauro Carvalho Chehab

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

This is what really worries me right now about the current proposal for iMX6. What's being proposed is to make the driver exclusively MC-based.

What that means is that existing applications are _not_ going to work until we have some answer for libv4l2, and from what you've said above, it seems that this has been attempted multiple times over the last _8_ years, and each time it's failed.

When thinking about it, it's quite obvious why merely trying to push the problem into userspace fails:

If we assert that the kernel does not have sufficient information to make decisions about how to route and control the hardware, then under what scenario does a userspace library have sufficient information to make those decisions?

So, merely moving the problem into userspace doesn't solve anything.

Loading the problem onto the user in the hope that the user knows enough to properly configure it also doesn't work - who is going to educate the user about the various quirks of the hardware they're dealing with?

I don't think pushing it into platform specific libv4l2 plugins works either - as you say above, even just trying to develop a plugin for exynos4 seems to have failed, so what makes us think that developing a plugin for iMX6 is going to succeed? Actually, that's exactly where the problem lies.

Is "iMX6 plugin" even right? That only deals with the complexity of one part of the system - what about the source device, which as we have already seen can be a tuner or a camera with its own multiple sub-devices. What if there's a video improvement chip in the chain as well - how is a "generic" iMX6 plugin supposed to know how to deal with that?

It seems to me that what's required is not an "iMX6 plugin" but a separate plugin for each platform - or worse. Consider boards like the Raspberry Pi, where users can attach a variety of cameras. I don't think this approach scales. (This is relevant: the iMX6 board I have here has a RPi compatible connector for a MIPI CSI2 camera. In fact, the IMX219 module I'm using _is_ a RPi camera, it's the RPi NoIR Camera V2.)

The iMX6 problem is way larger than just "which subdev do I need to configure for control X" - if you look at the dot graphs both Steve and myself have supplied, you'll notice that there are eight (yes,
8) video capture devices. Let's say that we can solve the subdev problem in libv4l2. There's another problem lurking here - libv4l2 is /dev/video* based. How does it know which /dev/video* device to open?

We don't open by sensor, we open by /dev/video*. In my case, there is only one correct /dev/video* node for the attached sensor, the other seven are totally irrelevant. For other situations, there may be the choice of three functional /dev/video* nodes.

Right now, for my case, there isn't the information exported from the kernel to know which is the correct one, since that requires knowing which virtual channel the data is going to be sent over the CSI2 interface. That information is not present in DT, or anywhere. It only comes from system knowledge - in my case, I know that the IMX219 is currently being configured to use virtual channel 0. SMIA cameras are also configurable. Then there's CSI2 cameras that can produce different formats via different virtual channels (eg, JPEG compressed image on one channel while streaming a RGB image via the other channel.)

Whether you can use one or three in _this_ scenario depends on the source format - again, another bit of implementation specific information that userspace would need to know. Kernel space should know that, and it's discoverable by testing which paths accept the source format - but that doesn't tell you ahead of time which /dev/video* node to open.

So, the problem space we have here is absolutely huge, and merely having a plugin that activates when you open a /dev/video* node really doesn't solve it.

All in all, I really don't think "lets hope someone writes a v4l2 plugin to solve it" is ever going to be successful. I don't even see that there will ever be a userspace application that is anything more than a representation of the dot graphs that users can use to manually configure the capture system with system knowledge.

I think everyone needs to take a step back and think long and hard about this from the system usability perspective - I seriously doubt that we will ever see any kind of solution to this if we continue to progress with "we'll sort it in userspace some day."

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#53 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 9 lines · Russell King - ARM Linux
Quoted 8 lines · Mauro Carvalho Chehab

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

Quoted 6 lines
Quoted 2 lines

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

This is what really worries me right now about the current proposal for iMX6. What's being proposed is to make the driver exclusively MC-based.

I don't see anything wrong with that.

Quoted 13 lines

What that means is that existing applications are _not_ going to work until we have some answer for libv4l2, and from what you've said above, it seems that this has been attempted multiple times over the last _8_ years, and each time it's failed.

When thinking about it, it's quite obvious why merely trying to push the problem into userspace fails:

If we assert that the kernel does not have sufficient information to make decisions about how to route and control the hardware, then under what scenario does a userspace library have sufficient information to make those decisions?

Quoted 6 lines

So, merely moving the problem into userspace doesn't solve anything.

Loading the problem onto the user in the hope that the user knows enough to properly configure it also doesn't work - who is going to educate the user about the various quirks of the hardware they're dealing with?

Documentation?

Quoted 22 lines

I don't think pushing it into platform specific libv4l2 plugins works either - as you say above, even just trying to develop a plugin for exynos4 seems to have failed, so what makes us think that developing a plugin for iMX6 is going to succeed? Actually, that's exactly where the problem lies.

Is "iMX6 plugin" even right? That only deals with the complexity of one part of the system - what about the source device, which as we have already seen can be a tuner or a camera with its own multiple sub-devices. What if there's a video improvement chip in the chain as well - how is a "generic" iMX6 plugin supposed to know how to deal with that?

It seems to me that what's required is not an "iMX6 plugin" but a separate plugin for each platform - or worse. Consider boards like the Raspberry Pi, where users can attach a variety of cameras. I don't think this approach scales. (This is relevant: the iMX6 board I have here has a RPi compatible connector for a MIPI CSI2 camera. In fact, the IMX219 module I'm using _is_ a RPi camera, it's the RPi NoIR Camera V2.)

Quoted 4 lines

The iMX6 problem is way larger than just "which subdev do I need to configure for control X" - if you look at the dot graphs both Steve and myself have supplied, you'll notice that there are eight (yes,
8) video capture devices.

There are 4 video nodes (per IPU):

- unconverted capture from CSI0
- unconverted capture from CSI1
- scaled, CSC, and/or rotated capture from PRP ENC
- scaled, CSC, rotated, and/or de-interlaced capture from PRP VF

Configuring the imx6 pipelines are not that difficult. I've put quite a bit of detail in the media doc, so it should become clear to any user with MC knowledge (even those with absolutely no knowledge of imx) to quickly start getting working pipelines.

Let's say that we can solve the subdev

Quoted 9 lines

problem in libv4l2. There's another problem lurking here - libv4l2 is /dev/video* based. How does it know which /dev/video* device to open?

We don't open by sensor, we open by /dev/video*. In my case, there is only one correct /dev/video* node for the attached sensor, the other seven are totally irrelevant. For other situations, there may be the choice of three functional /dev/video* nodes.

Quoted 4 lines

Right now, for my case, there isn't the information exported from the kernel to know which is the correct one, since that requires knowing which virtual channel the data is going to be sent over the CSI2 interface. That information is not present in DT, or anywhere.

It is described in the media doc:

"This is the MIPI CSI-2 receiver entity. It has one sink pad to receive the MIPI CSI-2 stream (usually from a MIPI CSI-2 camera sensor). It has four source pads, corresponding to the four MIPI CSI-2 demuxed virtual channel outputs."

Quoted 23 lines

It only comes from system knowledge - in my case, I know that the IMX219 is currently being configured to use virtual channel 0. SMIA cameras are also configurable. Then there's CSI2 cameras that can produce different formats via different virtual channels (eg, JPEG compressed image on one channel while streaming a RGB image via the other channel.)

Whether you can use one or three in _this_ scenario depends on the source format - again, another bit of implementation specific information that userspace would need to know. Kernel space should know that, and it's discoverable by testing which paths accept the source format - but that doesn't tell you ahead of time which /dev/video* node to open.

So, the problem space we have here is absolutely huge, and merely having a plugin that activates when you open a /dev/video* node really doesn't solve it.

All in all, I really don't think "lets hope someone writes a v4l2 plugin to solve it" is ever going to be successful. I don't even see that there will ever be a userspace application that is anything more than a representation of the dot graphs that users can use to manually configure the capture system with system knowledge.

Quoted 4 lines

I think everyone needs to take a step back and think long and hard about this from the system usability perspective - I seriously doubt that we will ever see any kind of solution to this if we continue to progress with "we'll sort it in userspace some day."

While I admit when I first came across the MC idea a couple years ago, my first impression was it was putting a lot of burden on the user to have a detailed knowledge of the system in question. But I don't think that is a problem with good documentation, and most people who have a need to use a specific MC driver will already have that knowledge.

Steve

#54 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux
Quoted 12 lines · Russell King - ARM Linux
Quoted 10 lines · Mauro Carvalho Chehab

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

Quoted 7 lines

This is what really worries me right now about the current proposal for iMX6. What's being proposed is to make the driver exclusively MC-based.

What that means is that existing applications are _not_ going to work until we have some answer for libv4l2, and from what you've said above, it seems that this has been attempted multiple times over the last _8_ years, and each time it's failed.

Yeah. We need a mid-layer between legacy applications and MC devices. Such layer does not exist in userspace or in kernel.

Quoted 4 lines

Loading the problem onto the user in the hope that the user knows enough to properly configure it also doesn't work - who is going to educate the user about the various quirks of the hardware they're dealing with?

We have docs. Users can write shell scripts. Still, mid-layer would be nice.

Quoted 10 lines

So, the problem space we have here is absolutely huge, and merely having a plugin that activates when you open a /dev/video* node really doesn't solve it.

All in all, I really don't think "lets hope someone writes a v4l2 plugin to solve it" is ever going to be successful. I don't even see that there will ever be a userspace application that is anything more than a representation of the dot graphs that users can use to manually configure the capture system with system knowledge.

Quoted 4 lines

I think everyone needs to take a step back and think long and hard about this from the system usability perspective - I seriously doubt that we will ever see any kind of solution to this if we continue to progress with "we'll sort it in userspace some day."

Mid-layer is difficult... there are _hundreds_ of possible pipeline setups. If it should live in kernel or in userspace is a question... but I don't think having it in kernel helps in any way.

Best regards,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170312/493191de/attachment-0001.sig>
#55 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Sun, 12 Mar 2017 22:29:04 +0100
Pavel Machek <[email protected]> escreveu:

Quoted 3 lines

Mid-layer is difficult... there are _hundreds_ of possible pipeline setups. If it should live in kernel or in userspace is a question... but I don't think having it in kernel helps in any way.

Mid-layer is difficult, because we either need to feed some library with knowledge for all kernel drivers or we need to improve the MC API to provide more details.

For example, several drivers used to expose entities via the generic MEDIA_ENT_T_DEVNODE to represent entities of different types. See, for example, entities 1, 5 and 7 (and others) at:
https://mchehab.fedorapeople.org/mc-next-gen/igepv2_omap3isp.png

A device-specific code could either be hardcoding the entity number or checking for the entity strings to add some logic to setup controls on those "unknown" entities, a generic app won't be able to do anything with them, as it doesn't know what function(s) such entity provide.

Also, on some devices, like the analog TV decoder at:
https://mchehab.fedorapeople.org/mc-next-gen/au0828_test/mc_nextgen_test-output.png

May have pads with different signals on their output. In such case, pads 1 and 2 provide video, while pad 3 provides audio using a different type of output.

The application needs to know such kind of things in order to be able to properly setup the pipeline [1].

[1] this specific device has a fixed pipeline, but I'm aware of SoC with flexible pipelines that have this kind of issue (nobody upstreamed the V4L part of those devices yet).

Thanks,
Mauro

#56 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi!

Quoted 4 lines
Quoted 3 lines

Mid-layer is difficult... there are _hundreds_ of possible pipeline setups. If it should live in kernel or in userspace is a question... but I don't think having it in kernel helps in any way.

Quoted 9 lines

Mid-layer is difficult, because we either need to feed some library with knowledge for all kernel drivers or we need to improve the MC API to provide more details.

For example, several drivers used to expose entities via the generic MEDIA_ENT_T_DEVNODE to represent entities of different types. See, for example, entities 1, 5 and 7 (and others) at:

Quoted 1 line

https://mchehab.fedorapeople.org/mc-next-gen/igepv2_omap3isp.png

Well... we provide enough information, so that device-specific code does not have to be in kernel.

There are few types of ENT_T_DEVNODE there. "ISP CCP2" does not really provide any functionality to the user. It just has to be there, because the pipeline needs to be connected. "ISP Preview" provides format conversion. "ISP Resizer" provides rescaling.

I'm not sure if it ever makes sense to use "ISP Preview output". Normally you take data for display from "ISP Resizer output". (Would there be some power advantage from that?)

Quoted 5 lines

A device-specific code could either be hardcoding the entity number or checking for the entity strings to add some logic to setup controls on those "unknown" entities, a generic app won't be able to do anything with them, as it doesn't know what function(s) such entity provide.

Generic app should know if it wants RGGB10 data, then it can use "ISP CCDC output", or if it wants "cooked" data suitable for display, then it wants to use "ISP Resizer output". Once application knows what output it wants, there's just one path through the system. So being able to tell the ENT_T_DEVNODEs apart does not seem to be critical.

OTOH, for useful camera application, different paths are needed at different phases.
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170314/bf43497f/attachment.sig>
maintainer
#57 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Pavel,

Quoted 19 lines · On Tuesday 14 Mar 2017 19:26:35 Pavel Machek wrote:

Hi!

Quoted 4 lines
Quoted 3 lines

Mid-layer is difficult... there are _hundreds_ of possible pipeline setups. If it should live in kernel or in userspace is a question... but I don't think having it in kernel helps in any way.

Quoted 9 lines

Mid-layer is difficult, because we either need to feed some library with knowledge for all kernel drivers or we need to improve the MC API to provide more details.

For example, several drivers used to expose entities via the generic MEDIA_ENT_T_DEVNODE to represent entities of different

types. See, for example, entities 1, 5 and 7 (and others) at:

Quoted 1 line

https://mchehab.fedorapeople.org/mc-next-gen/igepv2_omap3isp.png

Well... we provide enough information, so that device-specific code does not have to be in kernel.

Quoted 8 lines

There are few types of ENT_T_DEVNODE there. "ISP CCP2" does not really provide any functionality to the user. It just has to be there, because the pipeline needs to be connected. "ISP Preview" provides format conversion. "ISP Resizer" provides rescaling.

I'm not sure if it ever makes sense to use "ISP Preview output". Normally you take data for display from "ISP Resizer output". (Would there be some power advantage from that?)

There was a bug on the preview engine to resizer hardware bus in OMAP34xx that required capturing data from the preview engine output and performing the scaling in memory-to-memory mode in some cases. You can also capture at the preview engine output if you don't need scaling, or if you want to render on the image before scaling (to draw pieces of a GUI for instance). There could be other use cases.

Quoted 14 lines
Quoted 5 lines

A device-specific code could either be hardcoding the entity number or checking for the entity strings to add some logic to setup controls on those "unknown" entities, a generic app won't be able to do anything with them, as it doesn't know what function(s) such entity provide.

Generic app should know if it wants RGGB10 data, then it can use "ISP CCDC output", or if it wants "cooked" data suitable for display, then it wants to use "ISP Resizer output". Once application knows what output it wants, there's just one path through the system. So being able to tell the ENT_T_DEVNODEs apart does not seem to be critical.

OTOH, for useful camera application, different paths are needed at different phases.

Signature · 3 lines
Regards,

Laurent Pinchart
#58 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Mauro Carvalho Chehab

Hi Mauro,

Quoted 25 lines · Mauro Carvalho Chehab

Em Sat, 11 Mar 2017 00:37:14 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 22 lines

Hi Mauro (and others),

Quoted 18 lines · Mauro Carvalho Chehab

Em Fri, 10 Mar 2017 15:20:48 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 5 lines

As I've already mentioned, from talking about this with Mauro, it seems Mauro is in agreement with permitting the control inheritence... I wish Mauro would comment for himself, as I can't quote our private discussion on the subject.

I can't comment either, not having seen his mail and reasoning.

The rationale is that we should support the simplest use cases first.

In the case of the first MC-based driver (and several subsequent ones), the simplest use case required MC, as it was meant to suport a custom-made sophisticated application that required fine control on each component of the pipeline and to allow their advanced proprietary AAA userspace-based algorithms to work.

Quoted 5 lines
Quoted 2 lines

The first MC based driver (omap3isp) supports what the hardware can do, it does not support applications as such.

All media drivers support a subset of what the hardware can do. The question is if such subset covers the use cases or not.

Can you name a feature in the OMAP 3 ISP that is not and can not be supported using the current driver model (MC + V4L2 sub-device + V4L2) that could be even remotely useful?

Quoted 10 lines

The current MC-based drivers (except for uvc) took a patch to offer a more advanced API, to allow direct control to each IP module, as it was said, by the time we merged the OMAP3 driver, that, for the N9/N900 camera to work, it was mandatory to access the pipeline's individual components.

Such approach require that some userspace software will have knowledge about some hardware details, in order to setup pipelines and send controls to the right components. That makes really hard to have a generic user friendly application to use such devices.

The effect you described above is true, but I disagree with the cause. The cause is the hardware is more complex and variable than what has been supported previously, and providing a generic interface for accessing such hardware will require more complex interface.

The hardware we have today and the user cases we have today are more --- not less --- complex and nuanced than when the Media controller was merged back in 2010. Arguably there is thus more need for the functionality it provides, not less.

Quoted 11 lines

Non-MC based drivers control the hardware via a portable interface with doesn't require any knowledge about the hardware specifics, as either the Kernel or some firmware at the device will set any needed pipelines.

In the case of V4L2 controls, when there's no subdev API, the main driver (e. g. the driver that creates the /dev/video nodes) sends a multicast message to all bound I2C drivers. The driver(s) that need them handle it. When the same control may be implemented on different drivers, the main driver sends a unicast message to just one driver[1].

Quoted 7 lines

[1] There are several non-MC drivers that have multiple ways to control some things, like doing scaling or adjust volume levels at either the bridge driver or at a subdriver.

There's nothing wrong with this approach: it works, it is simpler, it is generic. So, if it covers most use cases, why not allowing it for usecases where a finer control is not a requirement?

Drivers are written to support hardware, not particular use case. Use case specific knowledge should be present only in applications, not in drivers. Doing it otherwise will lead to use case specific drivers and more driver code to maintain for any particular piece of hardware.

An individual could possibly choose the right driver for his / her use case, but this approach could hardly work for Linux distribution kernels.

The plain V4L2 interface is generic within its own scope: hardware can be supported within the hardware model assumed by the interface. However, on some devices this will end up being a small subset of what the hardware can do. Besides that, when writing the driver, you need to decide at detail level what kind of subset that might be.

That's not something anyone writing a driver should need to confront.

Quoted 8 lines
Quoted 6 lines

Adding support to drivers for different "operation modes" --- this is essentially what is being asked for --- is not an approach which could serve either purpose (some functionality with simple interface vs. fully support what the hardware can do, with interfaces allowing that) adequately in the short or the long run.

Why not?

Let's suppose that the omap3isp driver provided an "operation mode" for more simple applications.

Would you continue to have a V4L2 video device per DMA engine? Without Media controller it'd be rather confusing for applications since depending on which format (and level of processing) is requested defines the video node where the images is captured.

Instead you'd probably want to have a single video node. For the driver to expose just a single device node, should that be a Kconfig option or a module parameter, for instance?

I have to say I wouldn't be even particularly interested to know how much driver changes you'd have to implement to achieve that and how unmaintainable to end result would be. Consider inflicting the same on all drivers.

That's just *one* of a large number of things you'd need to change in order to support plain V4L2 applications from the driver, while still continuing to support the current interface.

With the help of a user space library, we can show the omap3isp device as a single video node with a number of inputs (sensors) that can provide some level of service to the user. I'm using "can", because it's just up to a missing implementation of such a library.

It may be hardware specific or not. A hardware specific one may produce better results than best effort since it may use knowledge of the hardware not available through the kernel interfaces.

Quoted 16 lines
Quoted 10 lines

If we are missing pieces in the puzzle --- in this case the missing pieces in the puzzle are a generic pipeline configuration library and another library that, with the help of pipeline autoconfiguration would implement "best effort" service for regular V4L2 on top of the MC + V4L2 subdev + V4L2 --- then these pieces need to be impelemented. The solution is *not* to attempt to support different types of applications in each driver separately. That will make writing drivers painful, error prone and is unlikely ever deliver what either purpose requires.

Quoted 5 lines

So let's continue to implement the functionality that the hardware supports. Making a different choice here is bound to create a lasting conflict between having to change kernel interface behaviour and the requirement of supporting new functionality that hasn't been previously thought of, pushing away SoC vendors from V4L2 ecosystem. This is what we all do want to avoid.

Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012. The prototype could figure out that the ccdc -> resizer path isn't usable with raw sensors due to the lack of common formats between the two, something that was argued to be too complex to implement.

I'm not aware of anyone else who would have tried that. Are you?

Quoted 7 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

Having provided feedback on that patchset, I don't see additional technical problems that require solving before the patches can be merged. The remaining matters seem to be actually fairly trivial.

Quoted 12 lines

That's why I'm saying that I'm OK on merging any patch that would allow setting controls via the /dev/video interface on MC-based drivers when compiled without subdev API. I may also consider merging patches allowing to change the behavior on runtime, when compiled with subdev API.

Quoted 5 lines

As far as i.MX6 driver goes, it is always possible to implement i.MX6 plugin for libv4l to perform this. This should be much easier than getting the automatic pipe configuration library and the rest working, and as it is custom for i.MX6, the resulting plugin may make informed technical choices for better functionality.

Quoted 6 lines

I wouldn't call "much easier" something that experienced media developers failed to do over the last 8 years.

It is just the opposite: broadcasting a control via I2C is very easy:
there are several examples about how to do that all over the media drivers.

That's one of the things Jacek's plugin actually does. This is still functionality that *only* some user applications wish to have, and as implemented in the plugin it works correctly without use case specific semantics --- please see my comments on the patch picking the controls from the pipeline.

Drivers can also make use of v4l2_device_for_each_subdev() to distribute setting controls on different sub-devices. A few drivers actually do that.

Quoted 18 lines
Quoted 3 lines

Jacek has been working on such a plugin for
Samsung Exynos hardware, but I don't think he has quite finished it yey.

As Jacek answered when questioned about the merge status:

Hi Hans,

On 11/03/2016 12:51 PM, Hans Verkuil wrote:
> Hi all,
>
> Is there anything that blocks me from merging this?
>
> This plugin work has been ongoing for years and unless there are serious > objections I propose that this is merged.
>
> Jacek, is there anything missing that would prevent merging this?

Quoted 6 lines

There were issues raised by Sakari during last review, related to the way how v4l2 control bindings are defined. That discussion wasn't finished, so I stayed by my approach. Other than that - I've tested it and it works fine both with GStreamer and my test app.

After that, he sent a new version (v7.1), but never got reviews.

There are a number of mutually agreed but unaddressed comments against v7. Also, v7.1 is just a single patch that does not address issues pointed out in v7, but something Jacek wanted to fix himself.

In other words, there are comments to address but no patches to review. Let's see how to best address them. I could possibly fix at least some of those, but due to lack of hardware I have no ability to test the end result.

Quoted 6 lines
Quoted 3 lines

The original plan was and continues to be sound, it's just that there have always been too few hands to implement it. :-(

If there are no people to implement a plan, it doesn't matter how good the plan is, it won't work.

Do you have other proposals than what we have commonly agreed on? I don't see other approaches that could satisfactorily address all the requirements going forward.

That said, I do think we need to reinvigorate the efforts to get things rolling again on supporting plain V4L2 applications on devices that are controlled through the MC inteface. These matters have received undeservedly little attention in recent years.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

That's not true, for example, for the UVC driver. There, MC is optional, as it should be.

UVC is different. The device simply provides additional information through MC to the user but MC (or V4L2 sub-device interface) is not used for controlling the device.

Quoted 5 lines

It is not different. If the Kernel is compiled without the V4L2 subdev interface, the i.MX6 driver (or whatever other driver) won't receive any control via the subdev interface. So, it has to handle the control logic control via the only interface that supports it, e. g. via the video devnode.

Looking at the driver code and the Kconfig file, i.MX6 driver depends on CONFIG_MEDIA_CONTROLLER and uses the Media controller API. So if Media controller is disabled in kernel configuration, the i.MX6 IPU driver won't be compiled.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#59 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Sakari,

I started preparing a long argument about it, but gave up in favor of a simpler one.

Em Mon, 13 Mar 2017 14:46:22 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 1 line

Drivers are written to support hardware, not particular use case.

No, it is just the reverse: drivers and hardware are developed to support use cases.

Btw, you should remember that the hardware is the full board, not just the SoC. In practice, the board do limit the use cases: several provide a single physical CSI connector, allowing just one sensor.

Quoted 7 lines
Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012.

...

Quoted 9 lines
Quoted 6 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

The two above basically summaries the issue: the task of doing a generic plugin on userspace, even for a single driver is complex enough to not cover within a reasonable timeline.

Quoted 1 line

From 2009 to 2012, you were working on it, but didn't finish it.

Apparently, nobody worked on it between 2013-2014 (but I may be wrong, as I didn't check when the generic plugin interface was added to libv4l).

In the case of Jacek's work, the first patch I was able to find was written in Oct, 2014:

	https://patchwork.kernel.org/patch/5098111/
	(not sure what happened with the version 1).

The last e-mail about this subject was issued in Dec, 2016.

In summary, you had this on your task for 3 years for an OMAP3 plugin (where you have a good expertise), and Jacek for 2 years, for Exynos 4, where he should also have a good knowledge.

Yet, with all that efforts, no concrete results were achieved, as none of the plugins got merged.

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Thanks,
Mauro

#60 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 60 lines · Mauro Carvalho Chehab

Hi Sakari,

I started preparing a long argument about it, but gave up in favor of a simpler one.

Em Mon, 13 Mar 2017 14:46:22 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 1 line

Drivers are written to support hardware, not particular use case.

No, it is just the reverse: drivers and hardware are developed to support use cases.

Btw, you should remember that the hardware is the full board, not just the SoC. In practice, the board do limit the use cases: several provide a single physical CSI connector, allowing just one sensor.

Quoted 7 lines
Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012.

...

Quoted 9 lines
Quoted 6 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

The two above basically summaries the issue: the task of doing a generic plugin on userspace, even for a single driver is complex enough to not cover within a reasonable timeline.

From 2009 to 2012, you were working on it, but didn't finish it.

Apparently, nobody worked on it between 2013-2014 (but I may be wrong, as I didn't check when the generic plugin interface was added to libv4l).

In the case of Jacek's work, the first patch I was able to find was written in Oct, 2014:

	https://patchwork.kernel.org/patch/5098111/
	(not sure what happened with the version 1).

The last e-mail about this subject was issued in Dec, 2016.

In summary, you had this on your task for 3 years for an OMAP3 plugin (where you have a good expertise), and Jacek for 2 years, for Exynos 4, where he should also have a good knowledge.

Yet, with all that efforts, no concrete results were achieved, as none of the plugins got merged.

Quoted 6 lines

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Or:

- userspace plugin development had a very a low priority and never got the attention it needed.

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

I know it took me a very long time before I had a working omap3.

So I am not at all surprised that little progress has been made.

Regards,

Hans

#61 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Tue, 14 Mar 2017 08:55:36 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 65 lines · Mauro Carvalho Chehab
Quoted 64 lines

Hi Sakari,

I started preparing a long argument about it, but gave up in favor of a simpler one.

Em Mon, 13 Mar 2017 14:46:22 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 1 line

Drivers are written to support hardware, not particular use case.

No, it is just the reverse: drivers and hardware are developed to support use cases.

Btw, you should remember that the hardware is the full board, not just the SoC. In practice, the board do limit the use cases: several provide a single physical CSI connector, allowing just one sensor.

Quoted 7 lines
Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012.

...

Quoted 9 lines
Quoted 6 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

The two above basically summaries the issue: the task of doing a generic plugin on userspace, even for a single driver is complex enough to not cover within a reasonable timeline.

From 2009 to 2012, you were working on it, but didn't finish it.

Apparently, nobody worked on it between 2013-2014 (but I may be wrong, as I didn't check when the generic plugin interface was added to libv4l).

In the case of Jacek's work, the first patch I was able to find was written in Oct, 2014:

	https://patchwork.kernel.org/patch/5098111/
	(not sure what happened with the version 1).

The last e-mail about this subject was issued in Dec, 2016.

In summary, you had this on your task for 3 years for an OMAP3 plugin (where you have a good expertise), and Jacek for 2 years, for Exynos 4, where he should also have a good knowledge.

Yet, with all that efforts, no concrete results were achieved, as none of the plugins got merged.

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

Quoted 7 lines
Quoted 2 lines

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Or:

- userspace plugin development had a very a low priority and never got the attention it needed.

The end result is the same: we can't count on it.

Quoted 11 lines

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

No. We should look it the other way: basically, there are patches for i.MX6 driver that sends control from videonode to subdevs.

If we nack apply it, who will write the userspace plugin? When such change will be merged upstream?

If we don't have answers to any of the above questions, we should not nack it.

That's said, that doesn't prevent merging a libv4l plugin if/when someone can find time/interest to develop it.

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls that a generic application like camorama/google talk/skype/zbar... would work should be enough to make them happy, even if they need to add some udev rule and/or run some "prep" application that would setup the pipelines via MC and eventually rename the device with a working pipeline to /dev/video0.

Quoted 6 lines

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

I'd say that we should not care anymore on providing a solution for generic applications to run on boards like OMAP3[1]. For hardware that are currently available that have Kernel driver and boards developed to be used as "cheap hobbyist devkit", I'd say we should implement a Kernel solution that would allow them to be used without subdev API, e. g. having all ioctls needed by generic applications to work functional, after some external application sets the pipeline.

[1] Yet, I might eventually do that for fun, an OMAP3 board with tvp5150 just arrived here last week. It would be nice to have xawtv3 running on it :-) So, if I have a lot of spare time (with is very unlikely), I might eventually do something for it to work.

Quoted 1 line

I know it took me a very long time before I had a working omap3.

My first OMAP3 board with working V4L2 source just arrived last week :-)

Quoted 1 line

So I am not at all surprised that little progress has been made.

I'm not surprised, but I'm disappointed, as I tried to push toward a solution for this problem since when we had our initial meetings about it.

Thanks,
Mauro

#62 lore raw

media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Hi!

Quoted 26 lines
Quoted 11 lines
Quoted 6 lines

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Or:

- userspace plugin development had a very a low priority and never got the attention it needed.

The end result is the same: we can't count on it.

Quoted 11 lines

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 5 lines

No. We should look it the other way: basically, there are patches for i.MX6 driver that sends control from videonode to subdevs.

If we nack apply it, who will write the userspace plugin? When such change will be merged upstream?

Well, I believe first question is: what applications would we want to run on complex devices? Will sending control from video to subdevs actually help?

mplayer is useful for testing... but that one already works (after you setup the pipeline, and configure exposure/gain).

But thats useful for testing, not really for production. Image will be out of focus and with wrong white balance.

What I would really like is an application to get still photos. For taking pictures with manual settings we need

a) units for controls: user wants to focus on 1m, and take picture with ISO200, 1/125 sec. We should also tell him that lens is f/5.6 and focal length is 20mm with 5mm chip.

But... autofocus/autogain would really be good to have. Thus we need:

b) for each frame, we need exposure settings and focus position at time frame was taken. Otherwise autofocus/autogain will be too slow. At least focus position is going to be tricky -- either kernel would have to compute focus position for us (not trivial) or we'd need enough information to compute it in userspace.

There are more problems: hardware-accelerated preview is not trivial to set up (and I'm unsure if it can be done in generic way). Still photos application needs to switch resolutions between preview and photo capture. Probably hardware-accelerated histograms are needed for white balance, auto gain and auto focus, ....

It seems like there's a _lot_ of stuff to be done before we have useful support for complex cameras...

(And I'm not sure... when application such as skype is running, is there some way to run autogain/autofocus/autowhitebalance? Is that something we want to support?)

Quoted 5 lines

If we don't have answers to any of the above questions, we should not nack it.

That's said, that doesn't prevent merging a libv4l plugin if/when someone can find time/interest to develop it.

I believe other question is: will not having same control on main video device and subdevs be confusing? Does it actually help userspace in any way? Yes, we can make controls accessible to old application, but does it make them more useful?

Quoted 9 lines
Quoted 5 lines

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls

Having different interface based on config options... is just weird. What about poor people (like me) trying to develop complex applications?

Quoted 9 lines

[1] Yet, I might eventually do that for fun, an OMAP3 board with tvp5150 just arrived here last week. It would be nice to have xawtv3 running on it :-) So, if I have a lot of spare time (with is very unlikely), I might eventually do something for it to work.

Quoted 1 line

I know it took me a very long time before I had a working omap3.

My first OMAP3 board with working V4L2 source just arrived last week :-)

You can get Nokia N900 on aliexpress. If not, they are still available between people :-).

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170314/52d3f8de/attachment.sig>
#63 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Em Tue, 14 Mar 2017 23:32:54 +0100
Pavel Machek <[email protected]> escreveu:

Quoted 31 lines

Hi!

Quoted 29 lines
Quoted 11 lines
Quoted 6 lines

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Or:

- userspace plugin development had a very a low priority and never got the attention it needed.

The end result is the same: we can't count on it.

Quoted 11 lines

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

No. We should look it the other way: basically, there are patches for i.MX6 driver that sends control from videonode to subdevs.

Quoted 6 lines
Quoted 2 lines

If we nack apply it, who will write the userspace plugin? When such change will be merged upstream?

Well, I believe first question is: what applications would we want to run on complex devices? Will sending control from video to subdevs actually help?

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

Quoted 21 lines

mplayer is useful for testing... but that one already works (after you setup the pipeline, and configure exposure/gain).

But thats useful for testing, not really for production. Image will be out of focus and with wrong white balance.

What I would really like is an application to get still photos. For taking pictures with manual settings we need

a) units for controls: user wants to focus on 1m, and take picture with ISO200, 1/125 sec. We should also tell him that lens is f/5.6 and focal length is 20mm with 5mm chip.

But... autofocus/autogain would really be good to have. Thus we need:

b) for each frame, we need exposure settings and focus position at time frame was taken. Otherwise autofocus/autogain will be too slow. At least focus position is going to be tricky -- either kernel would have to compute focus position for us (not trivial) or we'd need enough information to compute it in userspace.

Quoted 8 lines

There are more problems: hardware-accelerated preview is not trivial to set up (and I'm unsure if it can be done in generic way). Still photos application needs to switch resolutions between preview and photo capture. Probably hardware-accelerated histograms are needed for white balance, auto gain and auto focus, ....

It seems like there's a _lot_ of stuff to be done before we have useful support for complex cameras...

Taking still pictures using a hardware-accelerated preview is a sophisticated use case. I don't know any userspace application that does that. Ok, several allow taking snapshots, by simply storing the image of the current frame.

Quoted 3 lines

(And I'm not sure... when application such as skype is running, is there some way to run autogain/autofocus/autowhitebalance? Is that something we want to support?)

Autofocus no. Autogain/Autowhite can be done via libv4l, provided that it can access the device's controls via /dev/video devnode. Other applications may be using some other similar algorithms.

Ok, they don't use histograms provided by the SoC. So, they do it in software, with is slower. Still, it works fine when the light conditions don't change too fast.

Quoted 10 lines
Quoted 5 lines

If we don't have answers to any of the above questions, we should not nack it.

That's said, that doesn't prevent merging a libv4l plugin if/when someone can find time/interest to develop it.

I believe other question is: will not having same control on main video device and subdevs be confusing? Does it actually help userspace in any way? Yes, we can make controls accessible to old application, but does it make them more useful?

Yes. As I said, libv4l (and some apps) have logic inside to adjust the image via bright, contrast and white balance controls, using the video devnode. They don't talk subdev API. So, if those controls aren't exported, they won't be able to provide a good quality image.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

Quoted 7 lines
Quoted 3 lines

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls

Having different interface based on config options... is just weird. What about poor people (like me) trying to develop complex applications?

Well, that could be done using other mechanisms, like a modprobe parameter or by switching the behaviour if a subdev interface is opened. I don't see much trouble on allowing accessing a control via both interfaces.

Quoted 6 lines
Quoted 6 lines

[1] Yet, I might eventually do that for fun, an OMAP3 board with tvp5150 just arrived here last week. It would be nice to have xawtv3 running on it :-) So, if I have a lot of spare time (with is very unlikely), I might eventually do something for it to work.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I know it took me a very long time before I had a working omap3.

My first OMAP3 board with working V4L2 source just arrived last week :-)

You can get Nokia N900 on aliexpress. If not, they are still available between people :-)

I have one. Unfortunately, I never had a chance to use it, as the display stopped working one week after I get it.

Thanks,
Mauro

#64 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Quoted 11 lines · Mauro Carvalho Chehab

Em Tue, 14 Mar 2017 23:32:54 +0100
Pavel Machek <[email protected]> escreveu:

Quoted 4 lines

Well, I believe first question is: what applications would we want to run on complex devices? Will sending control from video to subdevs actually help?

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its imx-specific counterpart 'imxv4l2videosrc' from the gstreamer-imx package at https://github.com/Freescale/gstreamer-imx, and 'v4l2-ctl'.

Philippe

Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
#65 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Le mercredi 15 mars 2017 ? 11:50 +0100, Philippe De Muyter a ?crit?:

Quoted 6 lines
Quoted 3 lines

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its

While it would be nice if somehow you would get v4l2src to work (in some legacy/emulation mode through libv4l2), the longer plan is to implement smart bin that handle several v4l2src, that can do the required interactions so we can expose similar level of controls as found in Android Camera HAL3, and maybe even further assuming userspace can change the media tree at run-time. We might be a long way from there, specially that some of the features depends on how much the hardware can do. Just being able to figure-out how to build the MC tree dynamically seems really hard when thinking of generic mechanism. Also, Request API will be needed.

I think for this one, we'll need some userspace driver that enable the features (not hide them), and that's what I'd be looking for from libv4l2 in this regard.

Quoted 3 lines

imx-specific counterpart 'imxv4l2videosrc' from the gstreamer-imx package
at https://github.com/Freescale/gstreamer-imx, and 'v4l2-ctl'.

This one is specific to IMX hardware using vendor driver. You can probably ignore that.

Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170315/6895c2fe/attachment.sig>

maintainer
#66 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Quoted 10 lines · Nicolas Dufresne

Le mercredi 15 mars 2017 ? 11:50 +0100, Philippe De Muyter a ?crit :

Quoted 6 lines
Quoted 3 lines

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its

While it would be nice if somehow you would get v4l2src to work (in some legacy/emulation mode through libv4l2),

v4l2src works just fine, provided the pipeline is configured manually in advance via media-ctl.

Quoted 10 lines

the longer plan is to
implement smart bin that handle several v4l2src, that can do the required interactions so we can expose similar level of controls as found in Android Camera HAL3, and maybe even further assuming userspace can change the media tree at run-time. We might be a long way from there, specially that some of the features depends on how much the hardware can do. Just being able to figure-out how to build the MC tree dynamically seems really hard when thinking of generic mechanism. Also, Request API will be needed.

Quoted 3 lines

I think for this one, we'll need some userspace driver that enable the features (not hide them), and that's what I'd be looking for from libv4l2 in this regard.

regards
Philipp

#67 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Quoted 6 lines · Philipp Zabel
Quoted 5 lines · Nicolas Dufresne

Le mercredi 15 mars 2017 ? 11:50 +0100, Philippe De Muyter a ?crit :

Quoted 4 lines
Quoted 3 lines

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its

While it would be nice if somehow you would get v4l2src to work (in some legacy/emulation mode through libv4l2),

v4l2src works just fine, provided the pipeline is configured manually in advance via media-ctl.

Including choosing the framerate ? Sorry, I have no time these days to test it myself.

And I cited imxv4l2videosrc for its ability to provide the physical address of the image buffers for further processing by other (not necessarily next in gstreamer pipeline, or for all frames) hardware-accelerated plugins likes the h.264 video encoder. As I am stuck with fsl/nxp kernel and driver on that matter, I don't know how the interfaces have evolved in current linux kernels.

BR

Philippe

Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
maintainer
#68 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Quoted 10 lines · Philippe De Muyter
Quoted 9 lines · Philipp Zabel
Quoted 8 lines · Nicolas Dufresne

Le mercredi 15 mars 2017 ? 11:50 +0100, Philippe De Muyter a ?crit :

Quoted 6 lines
Quoted 3 lines

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

While it would be nice if somehow you would get v4l2src to work (in some legacy/emulation mode through libv4l2),

v4l2src works just fine, provided the pipeline is configured manually in advance via media-ctl.

Including choosing the framerate ? Sorry, I have no time these days to test it myself.

No, the framerate is set with media-ctl on the CSI output pad. To really choose the framerate, the element would indeed need a deeper understanding of the pipeline, as the resulting framerate depends on at least the source v4l2_subdevice (sensor) framerate and the CSI frame skipping.

Quoted 5 lines

And I cited imxv4l2videosrc for its ability to provide the physical address of the image buffers for further processing by other (not necessarily next in gstreamer pipeline, or for all frames) hardware-accelerated plugins likes the h.264 video encoder. As I am stuck with fsl/nxp kernel and driver on that matter, I don't know how the interfaces have evolved in current linux kernels.

The physical address of the image buffers is hidden from userspace by dma-buf objects, but those can be passed around to the next driver without copying the image data.

regards
Philipp

#69 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Quoted 17 lines · Philipp Zabel
Quoted 16 lines · Philippe De Muyter
Quoted 14 lines · Philipp Zabel
Quoted 10 lines · Nicolas Dufresne

Le mercredi 15 mars 2017 ? 11:50 +0100, Philippe De Muyter a ?crit :

Quoted 6 lines
Quoted 3 lines

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I would like to add the 'v4l2src' plugin of gstreamer, and on the imx6 its

While it would be nice if somehow you would get v4l2src to work (in some legacy/emulation mode through libv4l2),

v4l2src works just fine, provided the pipeline is configured manually in advance via media-ctl.

Quoted 8 lines
Quoted 2 lines

Including choosing the framerate ? Sorry, I have no time these days to test it myself.

No, the framerate is set with media-ctl on the CSI output pad. To really choose the framerate, the element would indeed need a deeper understanding of the pipeline, as the resulting framerate depends on at least the source v4l2_subdevice (sensor) framerate and the CSI frame skipping.

Count me in than as a supporter of Steve's "v4l2-mc: add a function to inherit controls from a pipeline" patch

Quoted 8 lines
Quoted 4 lines

of the image buffers for further processing by other (not necessarily next in gstreamer pipeline, or for all frames) hardware-accelerated plugins likes the h.264 video encoder. As I am stuck with fsl/nxp kernel and driver on that matter, I don't know how the interfaces have evolved in current linux kernels.

The physical address of the image buffers is hidden from userspace by dma-buf objects, but those can be passed around to the next driver without copying the image data.

OK

thanks

Philippe

#70 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

In reply to Mauro Carvalho Chehab

Hi!

Quoted 6 lines
Quoted 3 lines

Well, I believe first question is: what applications would we want to run on complex devices? Will sending control from video to subdevs actually help?

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I'll take a look when I'm at better internet access.

Quoted 27 lines
Quoted 27 lines

mplayer is useful for testing... but that one already works (after you setup the pipeline, and configure exposure/gain).

But thats useful for testing, not really for production. Image will be out of focus and with wrong white balance.

What I would really like is an application to get still photos. For taking pictures with manual settings we need

a) units for controls: user wants to focus on 1m, and take picture with ISO200, 1/125 sec. We should also tell him that lens is f/5.6 and focal length is 20mm with 5mm chip.

But... autofocus/autogain would really be good to have. Thus we need:

b) for each frame, we need exposure settings and focus position at time frame was taken. Otherwise autofocus/autogain will be too slow. At least focus position is going to be tricky -- either kernel would have to compute focus position for us (not trivial) or we'd need enough information to compute it in userspace.

There are more problems: hardware-accelerated preview is not trivial to set up (and I'm unsure if it can be done in generic way). Still photos application needs to switch resolutions between preview and photo capture. Probably hardware-accelerated histograms are needed for white balance, auto gain and auto focus, ....

Quoted 7 lines
Quoted 2 lines

It seems like there's a _lot_ of stuff to be done before we have useful support for complex cameras...

Taking still pictures using a hardware-accelerated preview is a sophisticated use case. I don't know any userspace application that does that. Ok, several allow taking snapshots, by simply storing the image of the current frame.

Well, there are applications that take still pictures. Android has one. Maemo has another. Then there's fcam-dev. Its open source; with modified kernel it is fully usable. I have version that runs on recent nearly-mainline on N900.

So yes, I'd like solution for problems a) and b).

Quoted 11 lines
Quoted 3 lines

(And I'm not sure... when application such as skype is running, is there some way to run autogain/autofocus/autowhitebalance? Is that something we want to support?)

Autofocus no. Autogain/Autowhite can be done via libv4l, provided that it can access the device's controls via /dev/video devnode. Other applications may be using some other similar algorithms.

Ok, they don't use histograms provided by the SoC. So, they do it in software, with is slower. Still, it works fine when the light conditions don't change too fast.

I guess it is going to work well enough with higher CPU usage. Question is if camera without autofocus is usable. I'd say "not really".

Quoted 9 lines
Quoted 4 lines

I believe other question is: will not having same control on main video device and subdevs be confusing? Does it actually help userspace in any way? Yes, we can make controls accessible to old application, but does it make them more useful?

Yes. As I said, libv4l (and some apps) have logic inside to adjust the image via bright, contrast and white balance controls, using the video devnode. They don't talk subdev API. So, if those controls aren't exported, they won't be able to provide a good quality image.

Next question is if the libv4l will do the right thing if we just put all controls to one node. For example on N900 you have exposure/gain and brightness. But the brightness is applied at preview phase, so it is "basically useless". You really need to adjust the image using the exposure/gain.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls

Quoted 8 lines
Quoted 3 lines

Having different interface based on config options... is just weird. What about poor people (like me) trying to develop complex applications?

Well, that could be done using other mechanisms, like a modprobe parameter or by switching the behaviour if a subdev interface is opened. I don't see much trouble on allowing accessing a control via both interfaces.

If we really want to go that way (is not modifying library to access the right files quite easy?), I believe non-confusing option would be to have '/dev/video0 -- omap3 camera for legacy applications' which would include all the controls.

Quoted 5 lines
Quoted 2 lines

You can get Nokia N900 on aliexpress. If not, they are still available between people :-)

I have one. Unfortunately, I never had a chance to use it, as the display stopped working one week after I get it.

Well, I guess the easiest option is to just get another one :-).

But otoh -- N900 is quite usable without the screen. 0xffff tool can be used to boot the kernel, then you can use nfsroot and usb networking. It also has serial port (over strange connector). Connected over ssh over usb network is actually how I do most of the v4l work.

Best regards,

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170315/da50f767/attachment.sig>
#71 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Em Wed, 15 Mar 2017 19:04:21 +0100
Pavel Machek <[email protected]> escreveu:

Quoted 10 lines

Hi!

Quoted 6 lines
Quoted 3 lines

Well, I believe first question is: what applications would we want to run on complex devices? Will sending control from video to subdevs actually help?

I would say: camorama, xawtv3, zbar, google talk, skype. If it runs with those, it will likely run with any other application.

I'll take a look when I'm at better internet access.

Ok.

Quoted 35 lines
Quoted 27 lines
Quoted 27 lines

mplayer is useful for testing... but that one already works (after you setup the pipeline, and configure exposure/gain).

But thats useful for testing, not really for production. Image will be out of focus and with wrong white balance.

What I would really like is an application to get still photos. For taking pictures with manual settings we need

a) units for controls: user wants to focus on 1m, and take picture with ISO200, 1/125 sec. We should also tell him that lens is f/5.6 and focal length is 20mm with 5mm chip.

But... autofocus/autogain would really be good to have. Thus we need:

b) for each frame, we need exposure settings and focus position at time frame was taken. Otherwise autofocus/autogain will be too slow. At least focus position is going to be tricky -- either kernel would have to compute focus position for us (not trivial) or we'd need enough information to compute it in userspace.

There are more problems: hardware-accelerated preview is not trivial to set up (and I'm unsure if it can be done in generic way). Still photos application needs to switch resolutions between preview and photo capture. Probably hardware-accelerated histograms are needed for white balance, auto gain and auto focus, ....

Quoted 7 lines
Quoted 2 lines

It seems like there's a _lot_ of stuff to be done before we have useful support for complex cameras...

Taking still pictures using a hardware-accelerated preview is a sophisticated use case. I don't know any userspace application that does that. Ok, several allow taking snapshots, by simply storing the image of the current frame.

Quoted 4 lines

Well, there are applications that take still pictures. Android has one. Maemo has another. Then there's fcam-dev. Its open source; with modified kernel it is fully usable. I have version that runs on recent nearly-mainline on N900.

Hmm... it seems that FCam is specific for N900:
http://fcam.garage.maemo.org/

If so, then we have here just the opposite problem, if want it to be used as a generic application, as very likely it requires OMAP3-specific graph/subdevs.

Quoted 10 lines

So yes, I'd like solution for problems a) and b).

Quoted 8 lines
Quoted 3 lines

(And I'm not sure... when application such as skype is running, is there some way to run autogain/autofocus/autowhitebalance? Is that something we want to support?)

Autofocus no. Autogain/Autowhite can be done via libv4l, provided that it can access the device's controls via /dev/video devnode. Other applications may be using some other similar algorithms.

Quoted 6 lines
Quoted 3 lines

Ok, they don't use histograms provided by the SoC. So, they do it in software, with is slower. Still, it works fine when the light conditions don't change too fast.

I guess it is going to work well enough with higher CPU usage.

Yes.

Quoted 2 lines

Question is if camera without autofocus is usable. I'd say "not really".qv4l2

That actually depends on the sensor and how focus is adjusted.

I'm testing right now this camera module for RPi:
https://www.raspberrypi.org/products/camera-module-v2/

I might be wrong, but this sensor doesn't seem to have auto-focus. Instead, it seems to use a wide-angle lens. So, except when the object is too close, the focus look OK.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

I believe other question is: will not having same control on main video device and subdevs be confusing? Does it actually help userspace in any way? Yes, we can make controls accessible to old application, but does it make them more useful?

Yes. As I said, libv4l (and some apps) have logic inside to adjust the image via bright, contrast and white balance controls, using the video devnode. They don't talk subdev API. So, if those controls aren't exported, they won't be able to provide a good quality image.

Quoted 5 lines

Next question is if the libv4l will do the right thing if we just put all controls to one node. For example on N900 you have exposure/gain and brightness. But the brightness is applied at preview phase, so it is "basically useless". You really need to adjust the image using the exposure/gain.

I've no idea, but I suspect it shouldn't be hard to teach libv4l to prefer use an exposure/gain instead of brightness when available.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls

Quoted 8 lines
Quoted 3 lines

Having different interface based on config options... is just weird. What about poor people (like me) trying to develop complex applications?

Well, that could be done using other mechanisms, like a modprobe parameter or by switching the behaviour if a subdev interface is opened. I don't see much trouble on allowing accessing a control via both interfaces.

Quoted 4 lines

If we really want to go that way (is not modifying library to access the right files quite easy?), I believe non-confusing option would be to have '/dev/video0 -- omap3 camera for legacy applications' which would include all the controls.

Yeah, keeping /dev/video0 reserved for generic applications is something that could work. Not sure how easy would be to implement it.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

You can get Nokia N900 on aliexpress. If not, they are still available between people :-)

I have one. Unfortunately, I never had a chance to use it, as the display stopped working one week after I get it.

Well, I guess the easiest option is to just get another one :-).

:-) Well, I guess very few units of N900 was sold in Brazil. Importing one is too expensive, due to taxes.

Quoted 5 lines

But otoh -- N900 is quite usable without the screen. 0xffff tool can be used to boot the kernel, then you can use nfsroot and usb networking. It also has serial port (over strange connector). Connected over ssh over usb network is actually how I do most of the v4l work.

If you pass me the pointers, I can try it when I have some time.

Anyway, I got myself an ISEE IGEPv2, with the expansion board:
https://www.isee.biz/products/igep-processor-boards/igepv2-dm3730
https://www.isee.biz/products/igep-expansion-boards/igepv2-expansion

The expansion board comes with a tvp5150 analog TV demod. So, with this device, I can simply connect it to a composite input signal. I have some sources here that I can use to test it.

Thanks,
Mauro

#72 lore raw

Re: media / v4l2-mc: wishlist for complex cameras (was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline)

Hi!

Quoted 40 lines
Quoted 35 lines
Quoted 27 lines
Quoted 27 lines

mplayer is useful for testing... but that one already works (after you setup the pipeline, and configure exposure/gain).

But thats useful for testing, not really for production. Image will be out of focus and with wrong white balance.

What I would really like is an application to get still photos. For taking pictures with manual settings we need

a) units for controls: user wants to focus on 1m, and take picture with ISO200, 1/125 sec. We should also tell him that lens is f/5.6 and focal length is 20mm with 5mm chip.

But... autofocus/autogain would really be good to have. Thus we need:

b) for each frame, we need exposure settings and focus position at time frame was taken. Otherwise autofocus/autogain will be too slow. At least focus position is going to be tricky -- either kernel would have to compute focus position for us (not trivial) or we'd need enough information to compute it in userspace.

There are more problems: hardware-accelerated preview is not trivial to set up (and I'm unsure if it can be done in generic way). Still photos application needs to switch resolutions between preview and photo capture. Probably hardware-accelerated histograms are needed for white balance, auto gain and auto focus, ....

Quoted 7 lines
Quoted 2 lines

It seems like there's a _lot_ of stuff to be done before we have useful support for complex cameras...

Taking still pictures using a hardware-accelerated preview is a sophisticated use case. I don't know any userspace application that does that. Ok, several allow taking snapshots, by simply storing the image of the current frame.

Quoted 4 lines

Well, there are applications that take still pictures. Android has one. Maemo has another. Then there's fcam-dev. Its open source; with modified kernel it is fully usable. I have version that runs on recent nearly-mainline on N900.

Quoted 6 lines

Hmm... it seems that FCam is specific for N900:
http://fcam.garage.maemo.org/

If so, then we have here just the opposite problem, if want it to be used as a generic application, as very likely it requires OMAP3-specific graph/subdevs.

Well... there's quick and great version on maemo.org. I do have local version (still somehow N900-specific), but it no longer uses hardware histogram/sharpness support. Should be almost generic.

Quoted 1 line
Quoted 1 line

So yes, I'd like solution for problems a) and b).

...but it has camera parameters hardcoded (problem a) and slow (problem b).

Quoted 11 lines
Quoted 2 lines

Question is if camera without autofocus is usable. I'd say "not really".qv4l2

That actually depends on the sensor and how focus is adjusted.

I'm testing right now this camera module for RPi:
https://www.raspberrypi.org/products/camera-module-v2/

I might be wrong, but this sensor doesn't seem to have auto-focus. Instead, it seems to use a wide-angle lens. So, except when the object is too close, the focus look OK.

Well, cameras without autofocus are somehow usable without autofocus. But cameras with autofocus don't work too well without one.

Quoted 7 lines
Quoted 4 lines

If we really want to go that way (is not modifying library to access the right files quite easy?), I believe non-confusing option would be to have '/dev/video0 -- omap3 camera for legacy applications' which would include all the controls.

Yeah, keeping /dev/video0 reserved for generic applications is something that could work. Not sure how easy would be to implement it.

Plus advanced applications would just ignore /dev/video0.. and not be confused.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

You can get Nokia N900 on aliexpress. If not, they are still available

between people :-)

I have one. Unfortunately, I never had a chance to use it, as the display stopped working one week after I get it.

Well, I guess the easiest option is to just get another one :-).

:-) Well, I guess very few units of N900 was sold in Brazil. Importing one is too expensive, due to taxes.

Try to ask at local mailing list. Those machines were quite common.

Quoted 7 lines
Quoted 5 lines

But otoh -- N900 is quite usable without the screen. 0xffff tool can be used to boot the kernel, then you can use nfsroot and usb networking. It also has serial port (over strange connector). Connected over ssh over usb network is actually how I do most of the v4l work.

If you pass me the pointers, I can try it when I have some time.

Ok, I guess I'll do that in private email.

Quoted 7 lines

Anyway, I got myself an ISEE IGEPv2, with the expansion board:
https://www.isee.biz/products/igep-processor-boards/igepv2-dm3730
https://www.isee.biz/products/igep-expansion-boards/igepv2-expansion

The expansion board comes with a tvp5150 analog TV demod. So, with this device, I can simply connect it to a composite input signal. I have some sources here that I can use to test it.

Well... it looks like TV capture is a "solved" problem. Taking useful photos is what is hard...

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170316/e7a0287a/attachment-0001.sig>
#73 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Mauro Carvalho Chehab
Quoted 93 lines · Mauro Carvalho Chehab

Em Tue, 14 Mar 2017 08:55:36 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 65 lines · Mauro Carvalho Chehab
Quoted 64 lines

Hi Sakari,

I started preparing a long argument about it, but gave up in favor of a simpler one.

Em Mon, 13 Mar 2017 14:46:22 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 1 line

Drivers are written to support hardware, not particular use case.

No, it is just the reverse: drivers and hardware are developed to support use cases.

Btw, you should remember that the hardware is the full board, not just the SoC. In practice, the board do limit the use cases: several provide a single physical CSI connector, allowing just one sensor.

Quoted 7 lines
Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012.

...

Quoted 9 lines
Quoted 6 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

The two above basically summaries the issue: the task of doing a generic plugin on userspace, even for a single driver is complex enough to not cover within a reasonable timeline.

From 2009 to 2012, you were working on it, but didn't finish it.

Apparently, nobody worked on it between 2013-2014 (but I may be wrong, as I didn't check when the generic plugin interface was added to libv4l).

In the case of Jacek's work, the first patch I was able to find was written in Oct, 2014:

	https://patchwork.kernel.org/patch/5098111/
	(not sure what happened with the version 1).

The last e-mail about this subject was issued in Dec, 2016.

In summary, you had this on your task for 3 years for an OMAP3 plugin (where you have a good expertise), and Jacek for 2 years, for Exynos 4, where he should also have a good knowledge.

Yet, with all that efforts, no concrete results were achieved, as none of the plugins got merged.

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

Quoted 7 lines
Quoted 2 lines

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Or:

- userspace plugin development had a very a low priority and never got the attention it needed.

The end result is the same: we can't count on it.

Quoted 11 lines

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

No. We should look it the other way: basically, there are patches for i.MX6 driver that sends control from videonode to subdevs.

Quoted 8 lines

If we nack apply it, who will write the userspace plugin? When such change will be merged upstream?

If we don't have answers to any of the above questions, we should not nack it.

That's said, that doesn't prevent merging a libv4l plugin if/when someone can find time/interest to develop it.

I don't think this control inheritance patch will magically prevent you from needed a plugin.

Quoted 9 lines
Quoted 8 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

Quoted 8 lines

What are the needs for a cheap hobbyist devkit owner? Do we currently satisfy those needs? I'd say that having a functional driver when compiled without the subdev API, that implements the ioctl's/controls that a generic application like camorama/google talk/skype/zbar... would work should be enough to make them happy, even if they need to add some udev rule and/or run some "prep" application that would setup the pipelines via MC and eventually rename the device with a working pipeline to /dev/video0.

This is literally the first time we have to cater to a cheap devkit. We were always aware of this issue, but nobody really needed it.

Quoted 8 lines
Quoted 7 lines

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

Quoted 7 lines

I'd say that we should not care anymore on providing a solution for generic applications to run on boards like OMAP3[1]. For hardware that are currently available that have Kernel driver and boards developed to be used as "cheap hobbyist devkit", I'd say we should implement a Kernel solution that would allow them to be used without subdev API, e. g. having all ioctls needed by generic applications to work functional, after some external application sets the pipeline.

I liked Russell's idea of having the DT set up an initial video path. This would (probably) make it much easier to provide a generic plugin since there is already an initial valid path when the driver is loaded, and it doesn't require custom code in the driver since this is left to the DT which really knows about the HW.

Quoted 8 lines

[1] Yet, I might eventually do that for fun, an OMAP3 board with tvp5150 just arrived here last week. It would be nice to have xawtv3 running on it :-) So, if I have a lot of spare time (with is very unlikely), I might eventually do something for it to work.

Quoted 1 line

I know it took me a very long time before I had a working omap3.

Quoted 7 lines

My first OMAP3 board with working V4L2 source just arrived last week :-)

Quoted 1 line

So I am not at all surprised that little progress has been made.

I'm not surprised, but I'm disappointed, as I tried to push toward a solution for this problem since when we had our initial meetings about it.

So many things to do, so little time. Sounds corny, but really, that's what this is all about. There were always (and frankly, still are) more important things that needed to be done.

Regards,

Hans

#74 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Mon, 20 Mar 2017 14:24:25 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 20 lines · Mauro Carvalho Chehab
Quoted 19 lines

Em Tue, 14 Mar 2017 08:55:36 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 9 lines · Mauro Carvalho Chehab
Quoted 2 lines

Hi Sakari,

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

No. We should look it the other way: basically, there are patches for i.MX6 driver that sends control from videonode to subdevs.

If we nack apply it, who will write the userspace plugin? When such change will be merged upstream?

Quoted 8 lines
Quoted 5 lines

If we don't have answers to any of the above questions, we should not nack it.

That's said, that doesn't prevent merging a libv4l plugin if/when someone can find time/interest to develop it.

I don't think this control inheritance patch will magically prevent you from needed a plugin.

Yeah, it is not just control inheritance. The driver needs to work without subdev API, e. g. mbus settings should also be done via the video devnode.

Btw, Sakari made a good point on IRC: what happens if some app try to change the pipeline or subdev settings while another application is using the device? The driver should block such changes, maybe using the V4L2 priority mechanism.

Quoted 2 lines

This is literally the first time we have to cater to a cheap devkit. We were always aware of this issue, but nobody really needed it.

That's true. Now that we have a real need for that, we need to provide a solution.

Quoted 8 lines
Quoted 7 lines

I'd say that we should not care anymore on providing a solution for generic applications to run on boards like OMAP3[1]. For hardware that are currently available that have Kernel driver and boards developed to be used as "cheap hobbyist devkit", I'd say we should implement a Kernel solution that would allow them to be used without subdev API, e. g. having all ioctls needed by generic applications to work functional, after some external application sets the pipeline.

Quoted 5 lines

I liked Russell's idea of having the DT set up an initial video path. This would (probably) make it much easier to provide a generic plugin since there is already an initial valid path when the driver is loaded, and it doesn't require custom code in the driver since this is left to the DT which really knows about the HW.

Setting the device via DT indeed makes easier (either for a kernel or userspace solution), but things like resolution changes should be possible without needing to change DT.

Also, as MC and subdev changes should be blocked while a V4L2 app is using the device, using a mechanism like calling VIDIOC_S_PRIORITY ioctl via the V4l2 interface, Kernel will require changes, anyway.

My suggestion is to touch on one driver to make it work with a generic application. As we currently have efforts and needs for the i.MX6 to do it, I'd say that the best would be to make it work on such driver. Once the work is done, we can see if the approach taken there would work at libv4l or not.

In parallel, someone has to fix libv4l for it to be default on applications like gstreamer, e. g. adding support for DMABUF and fixing other issues that are preventing it to be used by default.

Nicolas,

Why libv4l is currently disabled at gstreamer's default settings?

Quoted 11 lines
Quoted 11 lines

[1] Yet, I might eventually do that for fun, an OMAP3 board with tvp5150 just arrived here last week. It would be nice to have xawtv3 running on it :-) So, if I have a lot of spare time (with is very unlikely), I might eventually do something for it to work.

Quoted 1 line

I know it took me a very long time before I had a working omap3.

My first OMAP3 board with working V4L2 source just arrived last week :-)

Quoted 1 line

So I am not at all surprised that little progress has been made.

Quoted 7 lines
Quoted 3 lines

I'm not surprised, but I'm disappointed, as I tried to push toward a solution for this problem since when we had our initial meetings about it.

So many things to do, so little time. Sounds corny, but really, that's what this is all about. There were always (and frankly, still are) more important things that needed to be done.

What's most important for some developer may not be so important for another developer.

My understanding here is that there are developers wanting/needing to have standard V4L2 apps support for (some) i.MX6 devices. Those are the ones that may/will allocate some time for it to happen.

Thanks,
Mauro

#75 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 5 lines · Mauro Carvalho Chehab

Em Mon, 20 Mar 2017 14:24:25 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 2 lines

I don't think this control inheritance patch will magically prevent you from needed a plugin.

Quoted 8 lines

Yeah, it is not just control inheritance. The driver needs to work without subdev API, e. g. mbus settings should also be done via the video devnode.

Btw, Sakari made a good point on IRC: what happens if some app try to change the pipeline or subdev settings while another application is using the device? The driver should block such changes, maybe using the V4L2 priority mechanism.

My understanding is that there are already mechanisms in place to prevent that, but it's driver dependent - certainly several of the imx driver subdevs check whether they have an active stream, and refuse (eg) all set_fmt calls with -EBUSY if that is so.

(That statement raises another question in my mind: if the subdev is streaming, should it refuse all set_fmt, even for the TRY stuff?)

Quoted 4 lines

In parallel, someone has to fix libv4l for it to be default on applications like gstreamer, e. g. adding support for DMABUF and fixing other issues that are preventing it to be used by default.

Hmm, not sure what you mean there - I've used dmabuf with gstreamer's v4l2src linked to libv4l2, importing the buffers into etnaviv using a custom plugin. There are distros around (ubuntu) where the v4l2 plugin is built against libv4l2.

Quoted 3 lines

My understanding here is that there are developers wanting/needing to have standard V4L2 apps support for (some) i.MX6 devices. Those are the ones that may/will allocate some time for it to happen.

Quite - but we need to first know what is acceptable to the v4l2 community before we waste a lot of effort coding something up that may not be suitable. Like everyone else, there's only a limited amount of effort available, so using it wisely is a very good idea.

Up until recently, it seemed that the only solution was to solve the userspace side of the media controller API via v4l2 plugins and the like.

Much of my time that I have available to look at the imx6 capture stuff at the moment is taken up by triping over UAPI issues with the current code (such as the ones about CSI scaling, colorimetry, etc) and trying to get concensus on what the right solution to fix those issues actually is, and at the moment I don't have spare time to start addressing any kind of v4l2 plugin for user controls nor any other solution.

Eg, I spent much of this last weekend sorting out my IMX219 camera sensor driver for my new understanding about how scaling is supposed to work, the frame enumeration issue (which I've posted patches for) and the CSI scaling issue (which I've some half-baked patch for at the moment, but probably by the time I've finished sorting that, Philipp or Steve will already have a solution.)

That said, my new understanding of the scaling impacts the four patches I posted, and probably makes the frame size enumeration in CSI (due to its scaling) rather obsolete.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#76 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Mon, 20 Mar 2017 16:10:03 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 15 lines · Mauro Carvalho Chehab
Quoted 5 lines

Em Mon, 20 Mar 2017 14:24:25 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 2 lines

I don't think this control inheritance patch will magically prevent you from needed a plugin.

Quoted 8 lines

Yeah, it is not just control inheritance. The driver needs to work without subdev API, e. g. mbus settings should also be done via the video devnode.

Btw, Sakari made a good point on IRC: what happens if some app try to change the pipeline or subdev settings while another application is using the device? The driver should block such changes, maybe using the V4L2 priority mechanism.

Quoted 7 lines

My understanding is that there are already mechanisms in place to prevent that, but it's driver dependent - certainly several of the imx driver subdevs check whether they have an active stream, and refuse (eg) all set_fmt calls with -EBUSY if that is so.

(That statement raises another question in my mind: if the subdev is streaming, should it refuse all set_fmt, even for the TRY stuff?)

Returning -EBUSY only when streaming is too late, as ioctl's may be changing the pipeline configuration and/or buffer allocation, while the application is sending other ioctls in order to prepare for streaming.

V4L2 has a mechanism of blocking other apps to change such parameters via VIDIOC_S_PRIORITY[1]. If an application sets priority to V4L2_PRIORITY_RECORD, any other application attempting to change the device via some other file descriptor will fail. So, it is a sort of "exclusive write access".

On a quick look at V4L2 core, currently, sending a VIDIOC_S_PRIORITY ioctl to a /dev/video device doesn't seem to have any effect at either MC or V4L2 subdev API for the subdevs connected to it. We'll likely need to add some code at v4l2_prio_change() for it to notify the subdevs for them to return -EBUSY if one would try to change something there, while the device is priorized.

[1] https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/vidioc-g-priority.html

Quoted 9 lines
Quoted 4 lines

In parallel, someone has to fix libv4l for it to be default on applications like gstreamer, e. g. adding support for DMABUF and fixing other issues that are preventing it to be used by default.

Hmm, not sure what you mean there - I've used dmabuf with gstreamer's v4l2src linked to libv4l2, importing the buffers into etnaviv using a custom plugin. There are distros around (ubuntu) where the v4l2 plugin is built against libv4l2.

Hmm... I guess some gst developer mentioned that there are/where some restrictions at libv4l2 with regards to DMABUF. I may be wrong.

Quoted 9 lines
Quoted 4 lines

My understanding here is that there are developers wanting/needing to have standard V4L2 apps support for (some) i.MX6 devices. Those are the ones that may/will allocate some time for it to happen.

Quite - but we need to first know what is acceptable to the v4l2 community before we waste a lot of effort coding something up that may not be suitable. Like everyone else, there's only a limited amount of effort available, so using it wisely is a very good idea.

Sure. That's why we're discussing here :-)

Quoted 11 lines

Up until recently, it seemed that the only solution was to solve the userspace side of the media controller API via v4l2 plugins and the like.

Much of my time that I have available to look at the imx6 capture stuff at the moment is taken up by triping over UAPI issues with the current code (such as the ones about CSI scaling, colorimetry, etc) and trying to get concensus on what the right solution to fix those issues actually is, and at the moment I don't have spare time to start addressing any kind of v4l2 plugin for user controls nor any other solution.

I hear you. A solution via libv4l could be more elegant, but it doesn't seem simple, as nobody did it before, and depends on the libv4l plugin mechanism, with is currently unused.

Also, I think it is easier to provide a solution using DT and some driver and/or core support for it, specially since, AFAICT, currently there's no way request exclusive access to MC and subdevs.

It is probably not possible do to that exclusively in userspace.

Quoted 10 lines

Eg, I spent much of this last weekend sorting out my IMX219 camera sensor driver for my new understanding about how scaling is supposed to work, the frame enumeration issue (which I've posted patches for) and the CSI scaling issue (which I've some half-baked patch for at the moment, but probably by the time I've finished sorting that, Philipp or Steve will already have a solution.)

That said, my new understanding of the scaling impacts the four patches I posted, and probably makes the frame size enumeration in CSI (due to its scaling) rather obsolete.

Yeah, when there's no scaler, it should report just the resolution(s) supported by the sensor (actually, at the CSI) via V4L2_FRMSIZE_TYPE_DISCRETE.

However, when there's a scaler at the pipeline, it should report the range supported by the scaler, e. g.:

- V4L2_FRMSIZE_TYPE_CONTINUOUS - when an entire range of resolutions is supported with step = 1 for both H and V .

- V4L2_FRMSIZE_TYPE_STEPWISE - when there's either a H or V step at the possible values for resolutions. This is actually more common in practice, as several encodings take a 2x2 pixel block. So, the step should be at least 2.

There is something to be considered by the logic that forwards the resolution to the CSI: a lower resolution there means a higher number of frames per second.

So, if the driver is setting the resolution via a V4L2 device, it will provide a higher number of fps if it selects the lowest resolution at CSI that it is greater or equal to the resolution set at the scaler. On the other hand, the image quality could be better if it doesn't scale at CSI.

Thanks,
Mauro

#77 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Hans Verkuil
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

I think you're looking at it with a programmers hat on, not a users hat.

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

Hasn't the way technology has moved towards graphical interfaces, particularly smart phones, taught us that the vast majority of users want is intuitive, easy to use interfaces, and not the command line with reams of documentation?

Why are smart phones soo popular - it's partly because they're flashy, but also because of the wealth of apps, and apps which follow the philosophy of "do one job, do it well" (otherwise they get bad reviews.)

Quoted 5 lines

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

Right, and that in itself tells us something - the problem that we're trying to solve is not one that commonly exists in the real world.

Yes, the hardware we have in front of us may be very complex, but if there's very few systems out there which are capable of making use of all that complexity, then we're trying to solve a problem that isn't the common case - and if it's going to take years to solve it (it already has taken years) then it's the wrong problem to be solved.

I bet most of the problem can be eliminated if, rather than exposing all this complexity, we instead expose a simpler capture system where the board designer gets to "wire up" the capture system.

I'll go back to my Bayer example, because that's the simplest. As I've already said many times in these threads, there is only one possible path through the iMX6 device that such a source can be used with - it's a fixed path. The actual path depends on the CSI2 virtual channel that the camera has been _configured_ to use, but apart from that, it's effectively a well known set of blocks. Such a configuration could be placed in DT.

For RGB connected to a single parallel CSI, things get a little more complex - capture through the CSI or through two other capture devices for de-interlacing or other features. However, I'm not convinced that exposing multiple /dev/video* devices for different features for the same video source is a sane approach - I think that's a huge usability problem. (The user is expected to select the capture device on iMX6 depending on the features they want, and if they want to change features, they're expected to shut down their application and start it up on a different capture device.) For the most part on iMX6, there's one path down to the CSI block, and then there's optional routing through the rest of the IPU depending on what features you want (such as de-interlacing.)

The complex case is a CSI2 connected camera which produces multiple streams through differing virtual channels - and that's IMHO the only case where we need multiple different /dev/video* capture devices to be present.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
maintainer
#78 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Russell,

Quoted 15 lines · Russell King - ARM Linux
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

Quoted 5 lines

I think you're looking at it with a programmers hat on, not a users hat.

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

It depends on who the user is. I don't think anyone is suggesting a regular end user is the user of all these APIs: it is either an application tailored for that given device, a skilled user with his test scripts or as suggested previously, a libv4l plugin knowing the device or a generic library geared towards providing best effort service. The last one of this list does not exist yet and the second last item requires help.

Typically this class of devices is simply not up to provide the level of service you're requesting without additional user space control library which is responsible for automatic white balance, exposure and focus.

Making use of the full potential of the hardware requires using a more expressive interface. That's what the kernel interface must provide. If we decide to limit ourselves to a small sub-set of that potential on the level of the kernel interface, we have made a wrong decision. It's as simple as that. This is why the functionality (and which requires taking a lot of policy decisions) belongs to the user space. We cannot have multiple drivers providing multiple kernel interfaces for the same hardware.

That said, I'm not trying to provide an excuse for not having libraries available to help the user to configure and control the device more or less automatically even in terms of best effort. It's something that does require attention, a lot more of it than it has received in recent few years.

Signature · 4 lines
Kind regards,

Sakari Ailus
sakari.ailus at linux.intel.com
#79 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Fri, 17 Mar 2017 13:55:33 +0200
Sakari Ailus <[email protected]> escreveu:

Quoted 19 lines

Hi Russell,

Quoted 16 lines · Russell King - ARM Linux
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

I think you're looking at it with a programmers hat on, not a users hat.

I fully agree with you: whatever solution is provided, this should be fully transparent for the end user, no matter what V4L2 application he's using.

Quoted 4 lines
Quoted 4 lines

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

The need of su can easily be fixed with a simple addition at the udev rules.d, for it to consider media controller as part of the v4l stuff:

rules.d/50-udev-default.rules +1 -0
@@ -30,6 +30,7 @@ SUBSYSTEM=="mem", KERNEL=="mem|kmem|port
 SUBSYSTEM=="input", GROUP="input"
 SUBSYSTEM=="input", KERNEL=="js[0-9]*", MODE="0664"
 
+SUBSYSTEM=="media", GROUP="video"
 SUBSYSTEM=="video4linux", GROUP="video"
 SUBSYSTEM=="graphics", GROUP="video"
 SUBSYSTEM=="drm", GROUP="video"

Ok, someone should base it on upstream and submit this to udev maintainers[1].

[1] On a side note, it would also be possible to have an udev rule that would be automatically setting the pipeline then the media device pops up.

I wrote something like that for remote controllers, with gets installed together with v4l-utils package: when a remote controller is detected, it checks the driver and the remote controller table that the driver wants and load it on userspace.

It would be possible to do something like that for MC, but someone would need to do such task. Of course, that would require to have a way for a generic application to detect the board type and be able to automatically setup the pipelines. So, we'll go back to the initial problem that nobody was able to do that so far.

Quoted 4 lines

It depends on who the user is. I don't think anyone is suggesting a regular end user is the user of all these APIs: it is either an application tailored for that given device, a skilled user with his test scripts

Test scripts are just test scripts, meant for development purposes. We shouldn't even consider this seriously.

Quoted 2 lines

Making use of the full potential of the hardware requires using a more expressive interface.

That's the core of the problem: most users don't need "full potential of the hardware". It is actually worse than that: several boards don't allow "full potential" of the SoC capabilities.

Ok, when the user requires "full potential", they may need a complex tailored application. But, on most cases, all it is needed is to support a simple application that controls a video stream via /dev/video0.

Quoted 6 lines

That's what the kernel interface must provide. If
we decide to limit ourselves to a small sub-set of that potential on the level of the kernel interface, we have made a wrong decision. It's as simple as that. This is why the functionality (and which requires taking a lot of policy decisions) belongs to the user space. We cannot have multiple drivers providing multiple kernel interfaces for the same hardware.

I strongly disagree. Looking only at the hardware capabilities without having a solution to provide what the user wants is *wrong*.

The project decisions should be based on the common use cases, and, if possible and not to expensive/complex, covering exotic cases.

The V4L2 API was designed to fulfill the user needs. Drivers should take it in consideration when choosing policy decisions.

In order to give you some examples, before the V4L2 API, the bttv driver used to have its own set of ioctls, meant to provide functionality based on its hardware capabilities (like selecting other standards like PAL/M). The end result is that applications written for bttv were not generic enough[1]. The V4L2 API was designed to be generic enough to cover the common use-cases.

[1] As the bttv board were very popular, most userspace apps didn't work on other hardware. The big advantage of V4L2 API is that it contains a set of functions that it is good enough to control any hardware. Ok, some features are missing.

For example, in the past, one could use the bttv hardware to "decrypt" analog cable TV using custom ioctls. Those ioctls got removed during the V4L2 conversion, as they are specific to the way bttv hardware works.

Also, the cx88 hardware could be used as a generic fast A/D converter, using a custom set of ioctls - something similar to SDR. In this specific case, such patchset was never merged upstream.

To give you a few examples about policy decisions taken by the drivers in order to fulfill the user needs, the Conexant chipsets (supported by bttv, cx88, cx231xx and cx25821 drivers, among others) provide a way more possibilities than what the driver supports.

Basically, they all have fast A/D converters, running at around 27-30 MHz clock. The samples of the A/D can be passed as-is to userspace and/or handled by some IP blocks inside the chips.

Also, even the simplest one (bttv) uses a RISC with a firmware that is built dynamically at runtime by the Kernel driver. Such firmware needs to setup several DMA pipelines.

For example, the cx88 driver sets those DMA pipelines (see drivers/media/pci/cx88/cx88-core.c):

* FIFO space allocations:

 *    channel  21    (y video)  - 10.0k
 *    channel  22    (u video)  -  2.0k
 *    channel  23    (v video)  -  2.0k
 *    channel  24    (vbi)      -  4.0k
 *    channels 25+26 (audio)    -  4.0k
 *    channel  28    (mpeg)     -  4.0k
 *    channel  27    (audio rds)-  3.0k

In order to provide the generic V4L2 API, the driver need to take lots of device-specific decisions.

For example, the DMA from channel 28 is only enabled if the device has an IP block to do MPEG, and the user wants to receive mpeg data, instead of YUV.

The DMA from channel 27 has samples taken from the audio IF. The audio decoding itself are at DMA channels 25 and 26.

The data from DMA channel 27 is used by a software dsp code, implemented at drivers/media/pci/cx88/cx88-dsp.c, with detects if the IF contains AM or FM modulation and what are the carriers, in order to identify the audio standard. Once the standard is detected, it sets the hardware audio decoder to the right standard, and the DMA from channels 25 and 26 will contain audio PCM samples.

The net result is that an user of any of the V4L2 drivers

That's a way more complex than deciding if a pipeline would require an IP block to convert from Bayer format to YUV.

Another case: the cx25821 hardware supports 12 video streams, consuming almost all available bandwidth of an ePCI bus. Each video stream connector can either be configured to be capture or output, in runtime. The hardware vendor chose to hardcode the driver to provide 8 inputs and 4 outputs. Their decision was based in the fact that the driver is already very complex, and it satisfies their customer's needs. The cost/efforts of make the driver to be reconfigured in runtime were too high for almost no benefit.

Quoted 5 lines

That said, I'm not trying to provide an excuse for not having libraries available to help the user to configure and control the device more or less automatically even in terms of best effort. It's something that does require attention, a lot more of it than it has received in recent few years.

The big question, waiting for an answer on the last 8 years is who would do that? Such person would need to have several different hardware from different vendors, in order to ensure that it has a generic solution.

It is a way more feasible that the Kernel developers that already have a certain hardware on their hands to add support inside the driver to forward the controls through the pipeline and to setup a "default" pipeline that would cover the common use cases at driver's probe.

Thanks,
Mauro

maintainer
#80 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

On Fri, 2017-03-17 at 10:24 -0300, Mauro Carvalho Chehab wrote:
[...]

Quoted 10 lines

The big question, waiting for an answer on the last 8 years is who would do that? Such person would need to have several different hardware from different vendors, in order to ensure that it has a generic solution.

It is a way more feasible that the Kernel developers that already have a certain hardware on their hands to add support inside the driver to forward the controls through the pipeline and to setup a "default" pipeline that would cover the common use cases at driver's probe.

Actually, would setting pipeline via libv4l2 plugin and letting drivers provide a sane enabled default pipeline configuration be mutually exclusive? Not sure about the control forwarding, but at least a simple link setup and format forwarding would also be possible in the kernel without hindering userspace from doing it themselves later.

regards
Philipp

#81 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 13 lines · Philipp Zabel

On Fri, 2017-03-17 at 10:24 -0300, Mauro Carvalho Chehab wrote:
[...]

Quoted 10 lines

The big question, waiting for an answer on the last 8 years is who would do that? Such person would need to have several different hardware from different vendors, in order to ensure that it has a generic solution.

It is a way more feasible that the Kernel developers that already have a certain hardware on their hands to add support inside the driver to forward the controls through the pipeline and to setup a "default" pipeline that would cover the common use cases at driver's probe.

Quoted 5 lines

Actually, would setting pipeline via libv4l2 plugin and letting drivers provide a sane enabled default pipeline configuration be mutually exclusive? Not sure about the control forwarding, but at least a simple link setup and format forwarding would also be possible in the kernel without hindering userspace from doing it themselves later.

I think this is the exact same problem as controls in ALSA.

When ALSA started off in life, the requirement was that all controls shall default to minimum, and the user is expected to adjust controls after the system is running.

After OSS, this gave quite a marked change in system behaviour, and led to a lot of "why doesn't my sound work anymore" problems, because people then had to figure out which combination of controls had to be set to get sound out of their systems.

Now it seems to be much better, where install Linux on a platform, and you have a working sound system (assuming that the drivers are all there which is generally the case for x86.)

However, it's still possible to adjust all the controls from userspace. All that's changed is the defaults.

Why am I mentioning this - because from what I understand Mauro saying, it's no different from this situation. Userspace will still have the power to disable all links and setup its own. The difference is that there will be a default configuration that the kernel sets up at boot time that will be functional, rather than the current default configuration where the system is completely non-functional until manually configured.

However, at the end of the day, I don't care _where_ the usability problems are solved, only that there is some kind of solution. It's not the _where_ that's the real issue here, but the _how_, and discussion of the _how_ is completely missing.

So, let's try kicking off a discussion about _how_ to do things.

_How_ do we setup a media controller system so that we end up with a usable configuration - let's start with the obvious bit... which links should be enabled.

I think the first pre-requisit is that we stop exposing capture devices that can never be functional for the hardware that's present on the board, so that there isn't this plentora of useless /dev/video* nodes and useless subdevices.

One possible solution to finding a default path may be "find the shortest path between the capture device and the sensor and enable intervening links".

Then we need to try configuring that path with format/resolution information.

However, what if something in the shortest path can't handle the format that the sensor produces? I think at that point, we'd need to drop that subdev out of the path resolution, re-run the "find the shortest path" algorithm, and try again.

Repeat until success or no path between the capture and sensor exists.

This works fine if you have just one sensor visible from a capture device, but not if there's more than one (which I suspect is the case with the Sabrelite board with its two cameras and video receiver.) That breaks the "find the shortest path" algorithm.

So, maybe it's a lot better to just let the board people provide via DT a default setup for the connectivity of the modules somehow - certainly one big step forward would be to disable in DT parts of the capture system that can never be used (remembering that boards like the RPi / Hummingboard may end up using DT overlays to describe this for different cameras, so the capture setup may change after initial boot.)

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#82 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 81 lines · Russell King - ARM Linux
Quoted 13 lines · Philipp Zabel

On Fri, 2017-03-17 at 10:24 -0300, Mauro Carvalho Chehab wrote:
[...]

Quoted 10 lines

The big question, waiting for an answer on the last 8 years is who would do that? Such person would need to have several different hardware from different vendors, in order to ensure that it has a generic solution.

It is a way more feasible that the Kernel developers that already have a certain hardware on their hands to add support inside the driver to forward the controls through the pipeline and to setup a "default" pipeline that would cover the common use cases at driver's probe.

Quoted 5 lines

Actually, would setting pipeline via libv4l2 plugin and letting drivers provide a sane enabled default pipeline configuration be mutually exclusive? Not sure about the control forwarding, but at least a simple link setup and format forwarding would also be possible in the kernel without hindering userspace from doing it themselves later.

I think this is the exact same problem as controls in ALSA.

When ALSA started off in life, the requirement was that all controls shall default to minimum, and the user is expected to adjust controls after the system is running.

After OSS, this gave quite a marked change in system behaviour, and led to a lot of "why doesn't my sound work anymore" problems, because people then had to figure out which combination of controls had to be set to get sound out of their systems.

Now it seems to be much better, where install Linux on a platform, and you have a working sound system (assuming that the drivers are all there which is generally the case for x86.)

However, it's still possible to adjust all the controls from userspace. All that's changed is the defaults.

Why am I mentioning this - because from what I understand Mauro saying, it's no different from this situation. Userspace will still have the power to disable all links and setup its own. The difference is that there will be a default configuration that the kernel sets up at boot time that will be functional, rather than the current default configuration where the system is completely non-functional until manually configured.

However, at the end of the day, I don't care _where_ the usability problems are solved, only that there is some kind of solution. It's not the _where_ that's the real issue here, but the _how_, and discussion of the _how_ is completely missing.

So, let's try kicking off a discussion about _how_ to do things.

_How_ do we setup a media controller system so that we end up with a usable configuration - let's start with the obvious bit... which links should be enabled.

I think the first pre-requisit is that we stop exposing capture devices that can never be functional for the hardware that's present on the board, so that there isn't this plentora of useless /dev/video* nodes and useless subdevices.

One possible solution to finding a default path may be "find the shortest path between the capture device and the sensor and enable intervening links".

Then we need to try configuring that path with format/resolution information.

However, what if something in the shortest path can't handle the format that the sensor produces? I think at that point, we'd need to drop that subdev out of the path resolution, re-run the "find the shortest path" algorithm, and try again.

Repeat until success or no path between the capture and sensor exists.

This works fine if you have just one sensor visible from a capture device, but not if there's more than one (which I suspect is the case with the Sabrelite board with its two cameras and video receiver.) That breaks the "find the shortest path" algorithm.

Quoted 6 lines

So, maybe it's a lot better to just let the board people provide via DT a default setup for the connectivity of the modules somehow - certainly one big step forward would be to disable in DT parts of the capture system that can never be used (remembering that boards like the RPi / Hummingboard may end up using DT overlays to describe this for different cameras, so the capture setup may change after initial boot.)

The MC was developed before the device tree came along. But now that the DT is here, I think this could be a sensible idea to let the DT provide an initial path.

Sakari, Laurent, Mauro: any opinions?

Regards,

Hans

#83 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Mon, 20 Mar 2017 14:10:30 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 89 lines · Russell King - ARM Linux
Quoted 81 lines · Philipp Zabel
Quoted 13 lines · Mauro Carvalho Chehab

[...]

Quoted 10 lines

The big question, waiting for an answer on the last 8 years is who would do that? Such person would need to have several different hardware from different vendors, in order to ensure that it has a generic solution.

It is a way more feasible that the Kernel developers that already have a certain hardware on their hands to add support inside the driver to forward the controls through the pipeline and to setup a "default" pipeline that would cover the common use cases at driver's probe.

Quoted 5 lines

Actually, would setting pipeline via libv4l2 plugin and letting drivers provide a sane enabled default pipeline configuration be mutually exclusive? Not sure about the control forwarding, but at least a simple link setup and format forwarding would also be possible in the kernel without hindering userspace from doing it themselves later.

I think this is the exact same problem as controls in ALSA.

When ALSA started off in life, the requirement was that all controls shall default to minimum, and the user is expected to adjust controls after the system is running.

After OSS, this gave quite a marked change in system behaviour, and led to a lot of "why doesn't my sound work anymore" problems, because people then had to figure out which combination of controls had to be set to get sound out of their systems.

Now it seems to be much better, where install Linux on a platform, and you have a working sound system (assuming that the drivers are all there which is generally the case for x86.)

However, it's still possible to adjust all the controls from userspace. All that's changed is the defaults.

Why am I mentioning this - because from what I understand Mauro saying, it's no different from this situation. Userspace will still have the power to disable all links and setup its own. The difference is that there will be a default configuration that the kernel sets up at boot time that will be functional, rather than the current default configuration where the system is completely non-functional until manually configured.

However, at the end of the day, I don't care _where_ the usability problems are solved, only that there is some kind of solution. It's not the _where_ that's the real issue here, but the _how_, and discussion of the _how_ is completely missing.

So, let's try kicking off a discussion about _how_ to do things.

_How_ do we setup a media controller system so that we end up with a usable configuration - let's start with the obvious bit... which links should be enabled.

I think the first pre-requisit is that we stop exposing capture devices that can never be functional for the hardware that's present on the board, so that there isn't this plentora of useless /dev/video* nodes and useless subdevices.

One possible solution to finding a default path may be "find the shortest path between the capture device and the sensor and enable intervening links".

Then we need to try configuring that path with format/resolution information.

However, what if something in the shortest path can't handle the format that the sensor produces? I think at that point, we'd need to drop that subdev out of the path resolution, re-run the "find the shortest path" algorithm, and try again.

Repeat until success or no path between the capture and sensor exists.

This works fine if you have just one sensor visible from a capture device, but not if there's more than one (which I suspect is the case with the Sabrelite board with its two cameras and video receiver.) That breaks the "find the shortest path" algorithm.

Quoted 6 lines

So, maybe it's a lot better to just let the board people provide via DT a default setup for the connectivity of the modules somehow - certainly one big step forward would be to disable in DT parts of the capture system that can never be used (remembering that boards like the RPi / Hummingboard may end up using DT overlays to describe this for different cameras, so the capture setup may change after initial boot.)

Quoted 5 lines

The MC was developed before the device tree came along. But now that the DT is here, I think this could be a sensible idea to let the DT provide an initial path.

Sakari, Laurent, Mauro: any opinions?

It makes perfect sense to me.

By setting the pipeline via DT on boards with simple configurations, e. g. just one CSI physical interface, it can create just one devnode (e. g. /dev/video0) with would fully control the device, without enabling subdev API for such hardware, making the hardware usable with all V4L2 applications.

Regards,
Mauro

#84 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Mauro Carvalho Chehab

Hi!

Quoted 6 lines
Quoted 2 lines

Making use of the full potential of the hardware requires using a more expressive interface.

That's the core of the problem: most users don't need "full potential of the hardware". It is actually worse than that: several boards don't allow "full potential" of the SoC capabilities.

Well, in kernel we usually try to support "full hardware" potential.

And we are pretty sure users would like to take still photos, even if common v4l2 applications can not do it.

Quoted 9 lines
Quoted 6 lines

That's what the kernel interface must provide. If
we decide to limit ourselves to a small sub-set of that potential on the level of the kernel interface, we have made a wrong decision. It's as simple as that. This is why the functionality (and which requires taking a lot of policy decisions) belongs to the user space. We cannot have multiple drivers providing multiple kernel interfaces for the same hardware.

I strongly disagree. Looking only at the hardware capabilities without having a solution to provide what the user wants is *wrong*.

Hardware manufacturers already did this kind of research for us. They don't usually include features noone wants...

Quoted 8 lines

Another case: the cx25821 hardware supports 12 video streams, consuming almost all available bandwidth of an ePCI bus. Each video stream connector can either be configured to be capture or output, in runtime. The hardware vendor chose to hardcode the driver to provide 8 inputs and 4 outputs. Their decision was based in the fact that the driver is already very complex, and it satisfies their customer's needs. The cost/efforts of make the driver to be reconfigured in runtime were too high for almost no benefit.

Well, it is okay to provide 'limited' driver -- there's possibility to fix the driver. But IMO it is not okay to provide 'limited' kernel interface -- because if you try to fix it, you'll suddenly have regressions.

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170321/42dc569f/attachment.sig>
#85 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Sakari Ailus
Quoted 36 lines · Sakari Ailus

Hi Russell,

Quoted 15 lines · Russell King - ARM Linux
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

Quoted 5 lines

I think you're looking at it with a programmers hat on, not a users hat.

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

It depends on who the user is. I don't think anyone is suggesting a regular end user is the user of all these APIs: it is either an application tailored for that given device, a skilled user with his test scripts or as suggested previously, a libv4l plugin knowing the device or a generic library geared towards providing best effort service. The last one of this list does not exist yet and the second last item requires help.

Typically this class of devices is simply not up to provide the level of service you're requesting without additional user space control library which is responsible for automatic white balance, exposure and focus.

Quoted 7 lines

Making use of the full potential of the hardware requires using a more expressive interface. That's what the kernel interface must provide. If we decide to limit ourselves to a small sub-set of that potential on the level of the kernel interface, we have made a wrong decision. It's as simple as that. This is why the functionality (and which requires taking a lot of policy decisions) belongs to the user space. We cannot have multiple drivers providing multiple kernel interfaces for the same hardware.

Right. With my Cisco hat on I can tell you that Cisco would want full low-level control. If the driver would limit us we would not be able to use it.

Same with anyone who wants to put Android CameraHAL on top of a V4L2 driver:
they would need full control. Some simplified interface would be unacceptable.

Quoted 6 lines

That said, I'm not trying to provide an excuse for not having libraries available to help the user to configure and control the device more or less automatically even in terms of best effort. It's something that does require attention, a lot more of it than it has received in recent few years.

Right.

Regards,

Hans

maintainer
#86 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux
Quoted 70 lines · Russell King - ARM Linux
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

I think you're looking at it with a programmers hat on, not a users hat.

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

Hasn't the way technology has moved towards graphical interfaces, particularly smart phones, taught us that the vast majority of users want is intuitive, easy to use interfaces, and not the command line with reams of documentation?

Why are smart phones soo popular - it's partly because they're flashy, but also because of the wealth of apps, and apps which follow the philosophy of "do one job, do it well" (otherwise they get bad reviews.)

Quoted 5 lines

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

Right, and that in itself tells us something - the problem that we're trying to solve is not one that commonly exists in the real world.

Yes, the hardware we have in front of us may be very complex, but if there's very few systems out there which are capable of making use of all that complexity, then we're trying to solve a problem that isn't the common case - and if it's going to take years to solve it (it already has taken years) then it's the wrong problem to be solved.

I bet most of the problem can be eliminated if, rather than exposing all this complexity, we instead expose a simpler capture system where the board designer gets to "wire up" the capture system.

I'll go back to my Bayer example, because that's the simplest. As I've already said many times in these threads, there is only one possible path through the iMX6 device that such a source can be used with - it's a fixed path. The actual path depends on the CSI2 virtual channel that the camera has been _configured_ to use, but apart from that, it's effectively a well known set of blocks. Such a configuration could be placed in DT.

For RGB connected to a single parallel CSI, things get a little more complex - capture through the CSI or through two other capture devices for de-interlacing or other features. However, I'm not convinced that exposing multiple /dev/video* devices for different features for the same video source is a sane approach - I think that's a huge usability problem. (The user is expected to select the capture device on iMX6 depending on the features they want, and if they want to change features, they're expected to shut down their application and start it up on a different capture device.) For the most part on iMX6, there's one path down to the CSI block, and then there's optional routing through the rest of the IPU depending on what features you want (such as de-interlacing.)

Quoted 4 lines

The complex case is a CSI2 connected camera which produces multiple streams through differing virtual channels - and that's IMHO the only case where we need multiple different /dev/video* capture devices to be present.

I wanted to have the IC PRP outputs separate because the IC PRP should support running both the VF and ENC tasks with different parameters from the same input. That would allow to capture two different resolutions (up to 1024x1024) at the same time.

I think most of the simple, fixed pipeline use cases could be handled by libv4l2, by allowing to pass a v4l2 subdevice path to v4l2_open. If that function internally would set up the media links to the nearest /dev/video interface, propagate format, resolution and frame intervals if necessary, and return an fd to the video device, there'd be no additional complexity for the users beyond selecting the v4l2_subdev instead of the video device.

regards
Philipp

#87 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 7 lines · Philipp Zabel

I think most of the simple, fixed pipeline use cases could be handled by libv4l2, by allowing to pass a v4l2 subdevice path to v4l2_open. If that function internally would set up the media links to the nearest /dev/video interface, propagate format, resolution and frame intervals if necessary, and return an fd to the video device, there'd be no additional complexity for the users beyond selecting the v4l2_subdev instead of the video device.

... which would then require gstreamer to be modified too. The gstreamer v4l2 plugin looks for /dev/video* or /dev/v4l2/video* devices and monitors these for changes, so gstreamer applications know which capture devices are available:

  const gchar *paths[] = { "/dev", "/dev/v4l2", NULL };
  const gchar *names[] = { "video", NULL };

/* Add some depedency, so the dynamic features get updated upon changes in
* /dev/video* */
gst_plugin_add_dependency (plugin,

      NULL, paths, names, GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX);

I haven't checked yet whether sys/v4l2/gstv4l2deviceprovider.c knows anything about the v4l2 subdevs.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#88 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Fri, 17 Mar 2017 12:16:08 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 17 lines · Philipp Zabel
Quoted 7 lines

I think most of the simple, fixed pipeline use cases could be handled by libv4l2, by allowing to pass a v4l2 subdevice path to v4l2_open. If that function internally would set up the media links to the nearest /dev/video interface, propagate format, resolution and frame intervals if necessary, and return an fd to the video device, there'd be no additional complexity for the users beyond selecting the v4l2_subdev instead of the video device.

... which would then require gstreamer to be modified too. The gstreamer v4l2 plugin looks for /dev/video* or /dev/v4l2/video* devices and monitors these for changes, so gstreamer applications know which capture devices are available:

  const gchar *paths[] = { "/dev", "/dev/v4l2", NULL };
  const gchar *names[] = { "video", NULL };
Quoted 7 lines

/* Add some depedency, so the dynamic features get updated upon changes in
* /dev/video* */
gst_plugin_add_dependency (plugin,

      NULL, paths, names, GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX);

I haven't checked yet whether sys/v4l2/gstv4l2deviceprovider.c knows anything about the v4l2 subdevs.

Not only gstreamer do that, but all simple V4L2 applications, although on most of them, you can either pass a command line argument or setup the patch via GUI.

Btw, I've no idea from where gstreamer took /dev/v4l2 :-) I'm yet to find a distribution using it.

On the other hand, /dev/v4l/by-patch and /dev/v4l/by-id are usual directories where V4L2 devices can be found, and should provide persistent names. So, IMHO, gst should prefer those names, when they exist:

$ tree /dev/v4l
/dev/v4l
??? by-id
??? ??? usb-046d_HD_Pro_Webcam_C920_55DA1CCF-video-index0 -> ../../video1
??? ??? usb-Sunplus_mMobile_Inc_USB_Web-CAM-video-index0 -> ../../video0
??? by-path
    ??? platform-3f980000.usb-usb-0:1.2:1.0-video-index0 -> ../../video1
    ??? platform-3f980000.usb-usb-0:1.5:1.0-video-index0 -> ../../video0

Thanks,
Mauro

#89 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux
Quoted 15 lines · Russell King - ARM Linux
Quoted 6 lines · Hans Verkuil

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

Quoted 7 lines

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

Quoted 5 lines

I think you're looking at it with a programmers hat on, not a users hat.

Are you really telling me that requiring users to 'su' to root, and then use media-ctl to manually configure the capture device is what most users "want" ?

If you want to help users, right way is to improve userland support.

Quoted 4 lines

Hasn't the way technology has moved towards graphical interfaces, particularly smart phones, taught us that the vast majority of users want is intuitive, easy to use interfaces, and not the command line with reams of documentation?

How is it relevant to _kernel_ interfaces?
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170319/1fdadf3e/attachment-0001.sig>
maintainer
#90 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Hans Verkuil

Hi Hans,

Quoted 67 lines · On Tuesday 14 Mar 2017 08:55:36 Hans Verkuil wrote:
Quoted 59 lines · Mauro Carvalho Chehab

Hi Sakari,

I started preparing a long argument about it, but gave up in favor of a simpler one.

Em Mon, 13 Mar 2017 14:46:22 +0200 Sakari Ailus escreveu:

Quoted 1 line

Drivers are written to support hardware, not particular use case.

No, it is just the reverse: drivers and hardware are developed to support use cases.

Btw, you should remember that the hardware is the full board, not just the SoC. In practice, the board do limit the use cases: several provide a single physical CSI connector, allowing just one sensor.

Quoted 8 lines
Quoted 3 lines

This situation is there since 2009. If I remember well, you tried to write such generic plugin in the past, but never finished it, apparently because it is too complex. Others tried too over the years.

I'd argue I know better what happened with that attempt than you do. I had a prototype of a generic pipeline configuration library but due to various reasons I haven't been able to continue working on that since around 2012.

...

Quoted 9 lines
Quoted 6 lines

The last trial was done by Jacek, trying to cover just the exynos4 driver. Yet, even such limited scope plugin was not good enough, as it was never merged upstream. Currently, there's no such plugins upstream.

If we can't even merge a plugin that solves it for just *one* driver, I have no hope that we'll be able to do it for the generic case.

I believe Jacek ceased to work on that plugin in his day job; other than that, there are some matters left to be addressed in his latest patchset.

The two above basically summaries the issue: the task of doing a generic plugin on userspace, even for a single driver is complex enough to not cover within a reasonable timeline.

From 2009 to 2012, you were working on it, but didn't finish it.

Apparently, nobody worked on it between 2013-2014 (but I may be wrong, as I didn't check when the generic plugin interface was added to libv4l).

In the case of Jacek's work, the first patch I was able to find was

written in Oct, 2014:

	https://patchwork.kernel.org/patch/5098111/
	(not sure what happened with the version 1).

The last e-mail about this subject was issued in Dec, 2016.

In summary, you had this on your task for 3 years for an OMAP3 plugin (where you have a good expertise), and Jacek for 2 years, for Exynos 4, where he should also have a good knowledge.

Yet, with all that efforts, no concrete results were achieved, as none of the plugins got merged.

Quoted 6 lines

Even if they were merged, if we keep the same mean time to develop a libv4l plugin, that would mean that a plugin for i.MX6 could take 2-3 years to be developed.

There's a clear message on it:
- we shouldn't keep pushing for a solution via libv4l.

Quoted 8 lines

Or:
- userspace plugin development had a very a low priority and never got the attention it needed.

I know that's *my* reason. I rarely if ever looked at it. I always assumed Sakari and/or Laurent would look at it. If this reason is also valid for Sakari and Laurent, then it is no wonder nothing has happened in all that time.

The reason is also valid for me. I'd really love to work on the userspace side, but I just can't find time at the moment.

Quoted 23 lines

We're all very driver-development-driven, and userspace gets very little attention in general. So before just throwing in the towel we should take a good look at the reasons why there has been little or no development: is it because of fundamental design defects, or because nobody paid attention to it?

I strongly suspect it is the latter.

In addition, I suspect end-users of these complex devices don't really care about a plugin: they want full control and won't typically use generic applications. If they would need support for that, we'd have seen much more interest. The main reason for having a plugin is to simplify testing and if this is going to be used on cheap hobbyist devkits.

An additional complication is simply that it is hard to find fully supported MC hardware. omap3 boards are hard to find these days, renesas boards are not easy to get, freescale isn't the most popular either. Allwinner, mediatek, amlogic, broadcom and qualcomm all have closed source implementations or no implementation at all.

I know it took me a very long time before I had a working omap3.

So I am not at all surprised that little progress has been made.

Signature · 3 lines
Regards,

Laurent Pinchart
#91 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux

Hi Russell,

Em Fri, 10 Mar 2017 13:07:33 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 10 lines

The idea that the v4l libraries should intercept the format negotiation between the application and kernel is a particularly painful one - the default gstreamer build detects the v4l libraries, and links against it. That much is fine.

However, the problem comes when you're trying to use bayer formats. The v4l libraries "helpfully" (or rather unhelpfully) intercept the format negotiation, and decide that they'll invoke v4lconvert to convert the bayer to RGB for you, whether you want them to do that or not.

Quoted 5 lines

v4lconvert may not be the most efficient way to convert, or even what is desired (eg, you may want to receive the raw bayer image.) However, since the v4l libraries/v4lconvert gives you no option but to have its conversion forced into the pipeline, other options (such as using the gstreamer neon accelerated de-bayer plugin) isn't an option

That's not true. There is an special flag, used only by libv4l2 emulated formats, that indicates when a video format is handled via v4lconvert:

* - ``V4L2_FMT_FLAG_EMULATED``
- 0x0002
- This format is not native to the device but emulated through software (usually libv4l2), where possible try to use a native format instead for better performance.

Using this flag, if the application supports a video format directly supported by the hardware, it can use their own video format decoder. If not, it is still possible to use the V4L2 hardware, by using v4lconvert.

Unfortunately, very few applications currently check it.

I wrote a patch for zbar (a multi-format barcode reader) in the past, adding a logic there that gives a high priority to hardware formats, and a low priority to emulated ones:

	https://lists.fedoraproject.org/pipermail/scm-commits/2010-December/537428.html
Quoted 2 lines

without
rebuilding gstreamer _without_ linking against the v4l libraries.

I guess it wouldn't be complex to add a logic similar to that at gstreamer.

AFAIKT, there's another problem that would prevent to make libv4l the default on gstreamer: right now, libv4l doesn't support DMABUF. As gstreamer is being used on embedded hardware, I'd say that DMABUF support should be default there.

Thanks,
Mauro

#92 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 21 lines · Mauro Carvalho Chehab

Hi Russell,

Em Fri, 10 Mar 2017 13:07:33 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 10 lines

The idea that the v4l libraries should intercept the format negotiation between the application and kernel is a particularly painful one - the default gstreamer build detects the v4l libraries, and links against it. That much is fine.

However, the problem comes when you're trying to use bayer formats. The v4l libraries "helpfully" (or rather unhelpfully) intercept the format negotiation, and decide that they'll invoke v4lconvert to convert the bayer to RGB for you, whether you want them to do that or not.

Quoted 5 lines

v4lconvert may not be the most efficient way to convert, or even what is desired (eg, you may want to receive the raw bayer image.) However, since the v4l libraries/v4lconvert gives you no option but to have its conversion forced into the pipeline, other options (such as using the gstreamer neon accelerated de-bayer plugin) isn't an option

Quoted 3 lines

That's not true. There is an special flag, used only by libv4l2 emulated formats, that indicates when a video format is handled via v4lconvert:

I'm afraid that my statement comes from trying to use gstreamer with libv4l2 and _not_ being able to use the 8-bit bayer formats there at all - they are simply not passed across to the application through libv4l2/v4lconvert.

Instead, the formats that are passed across are the emulated formats. As I said above, that forces applications to use only the v4lconvert formats, the raw formats are not available.

So, the presence or absence of the V4L2_FMT_FLAG_EMULATED is quite meaningless if you can't even enumerate the non-converted formats.

The problem comes from the "always needs conversion" stuff in v4lconvert coupled with the way this subdev stuff works - since it requires manual configuration of all the pads within the kernel media pipeline, the kernel ends up only advertising _one_ format to userspace - in my case, that's RGGB8.

When v4lconvert_create_with_dev_ops() enumerates the formats from the kernel, it gets only RGGB8. That causes always_needs_conversion in there to remain true, so the special v4l control which enables/ disables conversion gets created with a default value of "true". The RGGB8 bit is also set in data->supported_src_formats.

This causes v4lconvert_supported_dst_fmt_only() to return true.

What this all means is that v4lconvert_enum_fmt() will _not_ return any of the kernel formats, only the faked formats.

Ergo, the RGGB8 format from the kernel is completely hidden from the application, and only the emulated format is made available. As I said above, this forces v4lconvert's debayering on the application, whether you want it or not.

In the gstreamer case, it knows nothing about this special control, which means that trying to use this gstreamer pipeline:

$ gst-launch-1.0 v4l2src device=/dev/video6 ! bayer2rgbneon ! xvimagesink

is completely impossible without first rebuilding gstreamer _without_ libv4l support. Build gstreamer without libv4l support, and the above works.

Enabling debug output in gstreamer's v4l2src plugin confirms that the kernel's bayer format are totally hidden from gstreamer when linked with libv4l2, but are present when it isn't linked with libv4l2.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#93 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 4 lines · Russell King - ARM Linux

Enabling debug output in gstreamer's v4l2src plugin confirms that the kernel's bayer format are totally hidden from gstreamer when linked with libv4l2, but are present when it isn't linked with libv4l2.

Here's the information to back up my claims:

root at hbi2ex:~# v4l2-ctl -d 6 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'RGGB'
Name : 8-bit Bayer RGRG/GBGB

root at hbi2ex:~# DISPLAY=:0 GST_DEBUG_NO_COLOR=1 GST_DEBUG=v4l2:9 gst-launch-1.0 v4l2src device=/dev/video6 ! bayer2rgbneon ! xvimagesink > gst-v4l2-1.log 2>&1 root at hbi2ex:~# cut -b65- gst-v4l2-1.log|less
v4l2_calls.c:519:gst_v4l2_open:<v4l2src0> Trying to open device /dev/video6
v4l2_calls.c:69:gst_v4l2_get_capabilities:<v4l2src0> getting capabilities

v4l2_calls.c:77:gst_v4l2_get_capabilities:<v4l2src0> driver:      'imx-media-camif'
v4l2_calls.c:78:gst_v4l2_get_capabilities:<v4l2src0> card:        'imx-media-camif'
v4l2_calls.c:79:gst_v4l2_get_capabilities:<v4l2src0> bus_info:    ''
v4l2_calls.c:80:gst_v4l2_get_capabilities:<v4l2src0> version:     00040a00

v4l2_calls.c:81:gst_v4l2_get_capabilities:<v4l2src0> capabilites: 85200001
...
v4l2_calls.c:258:gst_v4l2_fill_lists:<v4l2src0> controls+menus
v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00000000 v4l2_calls.c:319:gst_v4l2_fill_lists:<v4l2src0> starting control class 'User Controls' v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00980001 v4l2_calls.c:389:gst_v4l2_fill_lists:<v4l2src0> Adding ControlID white_balance_automatic (98090c) v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 0098090c v4l2_calls.c:389:gst_v4l2_fill_lists:<v4l2src0> Adding ControlID gamma (980910) v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00980910 v4l2_calls.c:389:gst_v4l2_fill_lists:<v4l2src0> Adding ControlID gain (980913) v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00980913 v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00980914 v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 00980915 v4l2_calls.c:319:gst_v4l2_fill_lists:<v4l2src0> starting control class 'Camera Controls' v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009a0001 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID exposure_time_absolute (9a0902) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009a0902 v4l2_calls.c:319:gst_v4l2_fill_lists:<v4l2src0> starting control class 'Image Source Controls' v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0001 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID vertical_blanking (9e0901) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0901 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID horizontal_blanking (9e0902) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0902 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID analogue_gain (9e0903) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0903 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID red_pixel_value (9e0904) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0904 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID green_red_pixel_value (9e0905) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0905 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID blue_pixel_value (9e0906) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0906 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID green_blue_pixel_value (9e0907) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009e0907 v4l2_calls.c:319:gst_v4l2_fill_lists:<v4l2src0> starting control class 'Image Processing Controls' v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009f0001 v4l2_calls.c:340:gst_v4l2_fill_lists:<v4l2src0> Control type for 'Pixel Rate' not suppored for extra controls. v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID Pixel Rate (9f0902) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009f0902 v4l2_calls.c:382:gst_v4l2_fill_lists:<v4l2src0> ControlID test_pattern (9f0903) unhandled, FIXME v4l2_calls.c:278:gst_v4l2_fill_lists:<v4l2src0> checking control 009f0903 v4l2_calls.c:284:gst_v4l2_fill_lists:<v4l2src0> controls finished v4l2_calls.c:451:gst_v4l2_fill_lists:<v4l2src0> done v4l2_calls.c:587:gst_v4l2_open:<v4l2src0> Opened device 'imx-media-camif' (/dev/video6) successfully gstv4l2object.c:804:gst_v4l2_set_defaults:<v4l2src0> tv_norm=0x0, norm=(nil) v4l2_calls.c:734:gst_v4l2_get_norm:<v4l2src0> getting norm v4l2_calls.c:1021:gst_v4l2_get_input:<v4l2src0> trying to get input v4l2_calls.c:1031:gst_v4l2_get_input:<v4l2src0> input: 0

gstv4l2object.c:1106:gst_v4l2_object_fill_format_list:<v4l2src0> getting src format enumerations

gstv4l2object.c:1124:gst_v4l2_object_fill_format_list:<v4l2src0> index:       0
gstv4l2object.c:1125:gst_v4l2_object_fill_format_list:<v4l2src0> type:        1
gstv4l2object.c:1126:gst_v4l2_object_fill_format_list:<v4l2src0> flags:       00000002
gstv4l2object.c:1128:gst_v4l2_object_fill_format_list:<v4l2src0> description: 'RGB3'
gstv4l2object.c:1130:gst_v4l2_object_fill_format_list:<v4l2src0> pixelformat: RGB3
gstv4l2object.c:1124:gst_v4l2_object_fill_format_list:<v4l2src0> index:       1
gstv4l2object.c:1125:gst_v4l2_object_fill_format_list:<v4l2src0> type:        1
gstv4l2object.c:1126:gst_v4l2_object_fill_format_list:<v4l2src0> flags:       00000002
gstv4l2object.c:1128:gst_v4l2_object_fill_format_list:<v4l2src0> description: 'BGR3'
gstv4l2object.c:1130:gst_v4l2_object_fill_format_list:<v4l2src0> pixelformat: BGR3
gstv4l2object.c:1124:gst_v4l2_object_fill_format_list:<v4l2src0> index:       2
gstv4l2object.c:1125:gst_v4l2_object_fill_format_list:<v4l2src0> type:        1
gstv4l2object.c:1126:gst_v4l2_object_fill_format_list:<v4l2src0> flags:       00000002
gstv4l2object.c:1128:gst_v4l2_object_fill_format_list:<v4l2src0> description: 'YU12'
gstv4l2object.c:1130:gst_v4l2_object_fill_format_list:<v4l2src0> pixelformat: YU12
gstv4l2object.c:1124:gst_v4l2_object_fill_format_list:<v4l2src0> index:       3
gstv4l2object.c:1125:gst_v4l2_object_fill_format_list:<v4l2src0> type:        1
gstv4l2object.c:1126:gst_v4l2_object_fill_format_list:<v4l2src0> flags:       00000002

gstv4l2object.c:1128:gst_v4l2_object_fill_format_list:<v4l2src0> description: 'YV12'

gstv4l2object.c:1130:gst_v4l2_object_fill_format_list:<v4l2src0> pixelformat: YV12 gstv4l2object.c:1143:gst_v4l2_object_fill_format_list:<v4l2src0> got 4 format(s):

gstv4l2object.c:1149:gst_v4l2_object_fill_format_list:<v4l2src0>   YU12 (emulated)
gstv4l2object.c:1149:gst_v4l2_object_fill_format_list:<v4l2src0>   YV12 (emulated)
gstv4l2object.c:1149:gst_v4l2_object_fill_format_list:<v4l2src0>   BGR3 (emulated)
gstv4l2object.c:1149:gst_v4l2_object_fill_format_list:<v4l2src0>   RGB3 (emulated)

As you can see from this, the RGGB bayer format advertised from the kernel is not listed - only the four emulated formats provided by v4lconvert are listed, so the application has _no_ choice but to use v4lconvert's RGGB conversion.

The result is that the above pipeline fails:

0:00:00.345739030 2794 0x3ade60 DEBUG v4l2 gstv4l2object.c:3812:gst_v4l2_object_get_caps:<v4l2src0> ret: video/x-raw, format=(string)I420, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)816, height=(int)616, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)YV12, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)816, height=(int)616, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)BGR, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)816, height=(int)616, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)RGB, framerate=(fraction)[ 0/1, 2147483647/1 ], width=(int)816, height=(int)616, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error. Additional debug info:
gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)

as the v4l2src element is offering an I420-formatted buffer to the gstreamer bayer converter, which obviously objects.

Rebuilding without libv4l2 linked results in gstreamer working. Using a kernel driver which exposes some formats that libv4lconvert _doesn't_ need to convert in addition to bayer _also_ works.

The only case where this fails is where the kernel device only advertises formats where libv4lconvert is in "we must always convert" mode, where upon the unconverted formats are completely hidden from the application.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#94 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux

Em Fri, 10 Mar 2017 15:57:09 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 65 lines · Mauro Carvalho Chehab
Quoted 21 lines

Hi Russell,

Em Fri, 10 Mar 2017 13:07:33 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 10 lines

The idea that the v4l libraries should intercept the format negotiation between the application and kernel is a particularly painful one - the default gstreamer build detects the v4l libraries, and links against it. That much is fine.

However, the problem comes when you're trying to use bayer formats. The v4l libraries "helpfully" (or rather unhelpfully) intercept the format negotiation, and decide that they'll invoke v4lconvert to convert the bayer to RGB for you, whether you want them to do that or not.

Quoted 5 lines

v4lconvert may not be the most efficient way to convert, or even what is desired (eg, you may want to receive the raw bayer image.) However, since the v4l libraries/v4lconvert gives you no option but to have its conversion forced into the pipeline, other options (such as using the gstreamer neon accelerated de-bayer plugin) isn't an option

Quoted 3 lines

That's not true. There is an special flag, used only by libv4l2 emulated formats, that indicates when a video format is handled via v4lconvert:

I'm afraid that my statement comes from trying to use gstreamer with libv4l2 and _not_ being able to use the 8-bit bayer formats there at all - they are simply not passed across to the application through libv4l2/v4lconvert.

Instead, the formats that are passed across are the emulated formats. As I said above, that forces applications to use only the v4lconvert formats, the raw formats are not available.

So, the presence or absence of the V4L2_FMT_FLAG_EMULATED is quite meaningless if you can't even enumerate the non-converted formats.

The problem comes from the "always needs conversion" stuff in v4lconvert coupled with the way this subdev stuff works - since it requires manual configuration of all the pads within the kernel media pipeline, the kernel ends up only advertising _one_ format to userspace - in my case, that's RGGB8.

When v4lconvert_create_with_dev_ops() enumerates the formats from the kernel, it gets only RGGB8. That causes always_needs_conversion in there to remain true, so the special v4l control which enables/ disables conversion gets created with a default value of "true". The RGGB8 bit is also set in data->supported_src_formats.

This causes v4lconvert_supported_dst_fmt_only() to return true.

What this all means is that v4lconvert_enum_fmt() will _not_ return any of the kernel formats, only the faked formats.

Ergo, the RGGB8 format from the kernel is completely hidden from the application, and only the emulated format is made available. As I said above, this forces v4lconvert's debayering on the application, whether you want it or not.

In the gstreamer case, it knows nothing about this special control, which means that trying to use this gstreamer pipeline:

$ gst-launch-1.0 v4l2src device=/dev/video6 ! bayer2rgbneon ! xvimagesink
Quoted 8 lines

is completely impossible without first rebuilding gstreamer _without_ libv4l support. Build gstreamer without libv4l support, and the above works.

Enabling debug output in gstreamer's v4l2src plugin confirms that the kernel's bayer format are totally hidden from gstreamer when linked with libv4l2, but are present when it isn't linked with libv4l2.

Argh! that is indeed a bug at libv4l (and maybe at gstreamer).

I guess that the always_needs_conversion logic was meant to be used to really odd proprietary formats, e. g:

/*  Vendor-specific formats   */
#define V4L2_PIX_FMT_CPIA1    v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
#define V4L2_PIX_FMT_WNVA     v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
#define V4L2_PIX_FMT_SN9C10X  v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */

...

I suspect that nobody uses libv4l2 with MC-based V4L2 devices. That's likely why nobody reported this bug before (that I know of).

In any case, for non-proprietary formats, the default should be to always offer both the emulated format and the original one.

I suspect that the enclosed patch should fix the issue with bayer formats.

Quoted 1 line

Thanks,
Mauro

[PATCH RFC] libv4lconvert: by default, offer the original format to the client

Applications should have the right to decide between using a libv4lconvert emulated format or to implement the decoding themselves, as this may have significative performance impact.

So, change the default to always show both formats.

Change also the default for Bayer encoded formats, as userspace likely will want to handle it directly.

lib/libv4lconvert/libv4lconvert.c +7 -7
index da718918b030..2e5458fa420d 100644
@@ -118,10 +118,10 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = {
 	{ V4L2_PIX_FMT_OV511,		 0,	 7,	 7,	1 },
 	{ V4L2_PIX_FMT_OV518,		 0,	 7,	 7,	1 },
 	/* uncompressed bayer */
-	{ V4L2_PIX_FMT_SBGGR8,		 8,	 8,	 8,	1 },
-	{ V4L2_PIX_FMT_SGBRG8,		 8,	 8,	 8,	1 },
-	{ V4L2_PIX_FMT_SGRBG8,		 8,	 8,	 8,	1 },
-	{ V4L2_PIX_FMT_SRGGB8,		 8,	 8,	 8,	1 },
+	{ V4L2_PIX_FMT_SBGGR8,		 8,	 8,	 8,	0 },
+	{ V4L2_PIX_FMT_SGBRG8,		 8,	 8,	 8,	0 },
+	{ V4L2_PIX_FMT_SGRBG8,		 8,	 8,	 8,	0 },
+	{ V4L2_PIX_FMT_SRGGB8,		 8,	 8,	 8,	0 },
 	{ V4L2_PIX_FMT_STV0680,		 8,	 8,	 8,	1 },
 	/* compressed bayer */
 	{ V4L2_PIX_FMT_SPCA561,		 0,	 9,	 9,	1 },
@@ -178,7 +178,7 @@ struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_pri
 	/* This keeps tracks of devices which have only formats for which apps
 	   most likely will need conversion and we can thus safely add software
 	   processing controls without a performance impact. */
-	int always_needs_conversion = 1;
+	int always_needs_conversion = 0;
 
 	if (!data) {
 		fprintf(stderr, "libv4lconvert: error: out of memory!\n");
@@ -208,8 +208,8 @@ struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_pri
 		if (j < ARRAY_SIZE(supported_src_pixfmts)) {
 			data->supported_src_formats |= 1ULL << j;
 			v4lconvert_get_framesizes(data, fmt.pixelformat, j);
-			if (!supported_src_pixfmts[j].needs_conversion)
-				always_needs_conversion = 0;
+			if (supported_src_pixfmts[j].needs_conversion)
+				always_needs_conversion = 1;
 		} else
 			always_needs_conversion = 0;
 	}
#95 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi!

Quoted 18 lines

Argh! that is indeed a bug at libv4l (and maybe at gstreamer).

I guess that the always_needs_conversion logic was meant to be used to really odd proprietary formats, e. g:

/*  Vendor-specific formats   */
#define V4L2_PIX_FMT_CPIA1    v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
#define V4L2_PIX_FMT_WNVA     v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
#define V4L2_PIX_FMT_SN9C10X  v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */

...

I suspect that nobody uses libv4l2 with MC-based V4L2 devices. That's likely why nobody reported this bug before (that I know of).

In any case, for non-proprietary formats, the default should be to always offer both the emulated format and the original one.

I suspect that the enclosed patch should fix the issue with bayer formats.

...

Quoted 10 lines
lib/libv4lconvert/libv4lconvert.c +1 -1
@@ -178,7 +178,7 @@ struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_pri
 	/* This keeps tracks of devices which have only formats for which apps
 	   most likely will need conversion and we can thus safely add software
 	   processing controls without a performance impact. */
-	int always_needs_conversion = 1;
+	int always_needs_conversion = 0;
 
 	if (!data) {
 		fprintf(stderr, "libv4lconvert: error: out of memory!\n");

lib/libv4lconvert/libv4lconvert.c struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_pri · line 215

Quoted 10 lines
lib/libv4lconvert/libv4lconvert.c +2 -2
@@ -208,8 +208,8 @@ struct v4lconvert_data *v4lconvert_create_with_dev_ops(int fd, void *dev_ops_pri
 		if (j < ARRAY_SIZE(supported_src_pixfmts)) {
 			data->supported_src_formats |= 1ULL << j;
 			v4lconvert_get_framesizes(data, fmt.pixelformat, j);
-			if (!supported_src_pixfmts[j].needs_conversion)
-				always_needs_conversion = 0;
+			if (supported_src_pixfmts[j].needs_conversion)
+				always_needs_conversion = 1;
 		} else
 			always_needs_conversion = 0;
 	}

Is the else still needed? You changed default to 0...

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170310/9f4e10d8/attachment-0001.sig>
#96 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Hans Verkuil

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

This way, if the subdev API is disabled, the driver will be functional for V4L2-based applications that don't support neither MC or subdev APIs.

Quoted 2 lines

As mentioned, I will attempt to try and get some time to work on this later this year. Fingers crossed.

That will be good, and, once we have a solution that works, we can work on cleanup the code, but, until then, drivers for arm-based boards sold to end consumers should work out of the box with standard V4L2 apps.

While we don't have that, I'm OK to merge patches adding such support upstream.

Thanks,
Mauro

#97 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 72 lines · Mauro Carvalho Chehab

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

Quoted 4 lines

This way, if the subdev API is disabled, the driver will be functional for V4L2-based applications that don't support neither MC or subdev APIs.

I'm not sure if it makes sense for the i.MX driver to behave differently depending on whether the subdev API is enabled or disabled. I don't know enough of the hardware to tell if it would ever make sense to disable the subdev API.

Regards,

Hans

Quoted 14 lines
Quoted 3 lines

As mentioned, I will attempt to try and get some time to work on this later this year. Fingers crossed.

That will be good, and, once we have a solution that works, we can work on cleanup the code, but, until then, drivers for arm-based boards sold to end consumers should work out of the box with standard V4L2 apps.

While we don't have that, I'm OK to merge patches adding such support upstream.

Thanks,
Mauro

#98 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Sat, 11 Mar 2017 12:32:43 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 77 lines · Mauro Carvalho Chehab
Quoted 72 lines

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Quoted 7 lines

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

I tend to agree with that.

Quoted 9 lines
Quoted 4 lines

This way, if the subdev API is disabled, the driver will be functional for V4L2-based applications that don't support neither MC or subdev APIs.

I'm not sure if it makes sense for the i.MX driver to behave differently depending on whether the subdev API is enabled or disabled. I don't know enough of the hardware to tell if it would ever make sense to disable the subdev API.

Yeah, I don't know enough about it either. The point is: this is something that the driver maintainer and driver users should decide if it either makes sense or not, based on the expected use cases.

Thanks,
Mauro

#99 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi Mauro and Hans,

Quoted 84 lines · Mauro Carvalho Chehab

Em Sat, 11 Mar 2017 12:32:43 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 81 lines · Mauro Carvalho Chehab
Quoted 72 lines

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

Quoted 5 lines
Quoted 3 lines

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

I tend to agree with that.

I agree as well.

This is in line with how existing drivers behave, too.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

This way, if the subdev API is disabled, the driver will be functional for V4L2-based applications that don't support neither MC or subdev APIs.

Quoted 8 lines
Quoted 4 lines

I'm not sure if it makes sense for the i.MX driver to behave differently depending on whether the subdev API is enabled or disabled. I don't know enough of the hardware to tell if it would ever make sense to disable the subdev API.

Yeah, I don't know enough about it either. The point is: this is something that the driver maintainer and driver users should decide if it either makes sense or not, based on the expected use cases.

My understanding of the i.MX6 case is the hardware is configurable enough to warrant the use of the Media controller API. Some patches indicate there are choices to be made in data routing.

Steve: could you enlighten us on the topic, by e.g. doing media-ctl --print-dot and sending the results to the list? What kind of different IP blocks are there and what do they do? A pointer to hardware documentation wouldn't hurt either (if it's available).

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: sakari.ailus at iki.fi	XMPP: sailus at retiisi.org.uk
#100 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 3 lines · Sakari Ailus

My understanding of the i.MX6 case is the hardware is configurable enough to warrant the use of the Media controller API. Some patches indicate there are choices to be made in data routing.

The iMX6 does have configurable data routing, but in some scenarios (eg, when receiving bayer data) there's only one possible routing.

Quoted 4 lines

Steve: could you enlighten us on the topic, by e.g. doing media-ctl --print-dot and sending the results to the list? What kind of different IP blocks are there and what do they do? A pointer to hardware documentation wouldn't hurt either (if it's available).

Attached for the imx219 camera. Note that although the CSI2 block has four outputs, each output is dedicated to a CSI virtual channel, so they can not be arbitarily assigned without configuring the sensor.

Since the imx219 only produces bayer, the graph is also showing the _only_ possible routing for the imx219 configured for CSI virtual channel 0.

The iMX6 manuals are available on the 'net.

	https://community.nxp.com/docs/DOC-101840

There are several chapters that cover the capture side:

* MIPI CSI2
* IPU CSI2 gasket
* IPU

The IPU not only performs capture, but also display as well.

Signature · 10 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imx219.dot
Type: text/vnd.graphviz
Size: 4557 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/dfafb712/attachment.dot>
author maintainer
#101 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Sakari Ailus
Quoted 91 lines · Sakari Ailus

Hi Mauro and Hans,

Quoted 88 lines · Mauro Carvalho Chehab

Em Sat, 11 Mar 2017 12:32:43 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 84 lines · Mauro Carvalho Chehab
Quoted 72 lines

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

Quoted 5 lines
Quoted 1 line

I tend to agree with that.

I agree as well.

This is in line with how existing drivers behave, too.

Well, sounds like there is consensus on this topic. I guess I'll go ahead and remove the control inheritance support. I suppose having a control appear in two places (subdev and video nodes) can be confusing.

As for the configurability vs. ease-of-use debate, I added the control inheritance to make it a little easier on the user, but, as the dot graphs below will show, the user already needs quite a lot of knowledge of the architecture already, in order to setup the different pipelines. So perhaps the control inheritance is rather pointless anyway.

Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

This way, if the subdev API is disabled, the driver will be functional for V4L2-based applications that don't support neither MC or subdev APIs.

Quoted 8 lines
Quoted 4 lines

I'm not sure if it makes sense for the i.MX driver to behave differently depending on whether the subdev API is enabled or disabled. I don't know enough of the hardware to tell if it would ever make sense to disable the subdev API.

Yeah, I don't know enough about it either. The point is: this is something that the driver maintainer and driver users should decide if it either makes sense or not, based on the expected use cases.

Quoted 8 lines

My understanding of the i.MX6 case is the hardware is configurable enough to warrant the use of the Media controller API. Some patches indicate there are choices to be made in data routing.

Steve: could you enlighten us on the topic, by e.g. doing media-ctl --print-dot and sending the results to the list? What kind of different IP blocks are there and what do they do? A pointer to hardware documentation wouldn't hurt either (if it's available).

Wow, I didn't realize there was so little knowledge of the imx6 IPU capture architecture.

Yes, the imx6 definitely warrants the need for MC, as the dot graphs will attest.

The graphs follows very closely the actual hardware architecture of the IPU capture blocks. I.e., all the subdevs and links shown correspond to actual hardware connections and sub-blocks.

Russell just provided a link to the imx6 reference manual, and dot graph for the imx219 based platform.

Also I've added quite a lot of detail to the media doc at Documentation/media/v4l-drivers/imx.rst.

The dot graphs for SabreSD, SabreLite, and SabreAuto reference platforms are attached. This is generated from the most recent (version 5) imx-media driver.

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sabresd.dot
Type: application/msword-template
Size: 4432 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/9dd15d05/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sabrelite.dot
Type: application/msword-template
Size: 4432 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/9dd15d05/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sabreauto.dot
Type: application/msword-template
Size: 4062 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/9dd15d05/attachment-0005.bin>

#102 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 94 lines · Steve Longerbeam
Quoted 93 lines · Sakari Ailus

Hi Mauro and Hans,

Quoted 89 lines · Mauro Carvalho Chehab

Em Sat, 11 Mar 2017 12:32:43 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 77 lines · Mauro Carvalho Chehab
Quoted 72 lines

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Quoted 7 lines

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

I tend to agree with that.

Quoted 8 lines
Quoted 3 lines

I agree as well.

This is in line with how existing drivers behave, too.

Well, sounds like there is consensus on this topic. I guess I'll go ahead and remove the control inheritance support. I suppose having a control appear in two places (subdev and video nodes) can be confusing.

I would say _don't_ do that until there are tools/libraries in place that are able to support controlling subdevs, otherwise it's just going to be another reason for me to walk away from this stuff, and stick with a version that does work sensibly.

Quoted 6 lines

As for the configurability vs. ease-of-use debate, I added the control inheritance to make it a little easier on the user, but, as the dot graphs below will show, the user already needs quite a lot of knowledge of the architecture already, in order to setup the different pipelines. So perhaps the control inheritance is rather pointless anyway.

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#103 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 127 lines · Russell King - ARM Linux
Quoted 94 lines · Steve Longerbeam
Quoted 93 lines · Sakari Ailus

Hi Mauro and Hans,

Quoted 89 lines · Mauro Carvalho Chehab

Em Sat, 11 Mar 2017 12:32:43 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 77 lines · Mauro Carvalho Chehab
Quoted 72 lines

Em Fri, 10 Mar 2017 13:54:28 +0100
Hans Verkuil <[email protected]> escreveu:

Quoted 7 lines
Quoted 3 lines

Devices that have complex pipeline that do essentially require using the Media controller interface to configure them are out of that scope.

Way too much of how the MC devices should be used is in the minds of developers. There is a major lack for good detailed documentation, utilities, compliance test (really needed!) and libv4l plugins.

Unfortunately, we merged an incomplete MC support at the Kernel. We knew all the problems with MC-based drivers and V4L2 applications by the time it was developed, and we requested Nokia developers (with was sponsoring MC develoment, on that time) to work on a solution to allow standard V4L2 applications to work with MC based boards.

Unfortunately, we took the decision to merge MC without that, because Nokia was giving up on Linux development, and we didn't want to lose the 2 years of discussions and work around it, as Nokia employers were leaving the company. Also, on that time, there was already some patches floating around adding backward support via libv4l. Unfortunately, those patches were never finished.

The net result is that MC was merged with some huge gaps, including the lack of a proper solution for a generic V4L2 program to work with V4L2 devices that use the subdev API.

That was not that bad by then, as MC was used only on cell phones that run custom-made applications.

The reallity changed, as now, we have lots of low cost SoC based boards, used for all sort of purposes. So, we need a quick solution for it.

In other words, while that would be acceptable support special apps on really embedded systems, it is *not OK* for general purpose SoC harware[1].

[1] I'm calling "general purpose SoC harware" those ARM boards like Raspberry Pi that are shipped to the mass and used by a wide range of hobbyists and other people that just wants to run Linux on ARM. It is possible to buy such boards for a very cheap price, making them to be used not only on special projects, where a custom made application could be interesting, but also for a lot of users that just want to run Linux on a low cost ARM board, while keeping using standard V4L2 apps, like "camorama".

That's perhaps one of the reasons why it took a long time for us to start receiving drivers upstream for such hardware: it is quite intimidating and not logical to require developers to implement on their drivers 2 complex APIs (MC, subdev) for those hardware that most users won't care. From user's perspective, being able to support generic applications like "camorama" and "zbar" is all they want.

In summary, I'm pretty sure we need to support standard V4L2 applications on boards like Raspberry Pi and those low-cost SoC-based boards that are shipped to end users.

Quoted 2 lines

Anyway, regarding this specific patch and for this MC-aware driver: no, you shouldn't inherit controls from subdevs. It defeats the purpose.

Sorry, but I don't agree with that. The subdev API is an optional API (and even the MC API can be optional).

I see the rationale for using MC and subdev APIs on cell phones, ISV and other embedded hardware, as it will allow fine-tuning the driver's support to allow providing the required quality for certain custom-made applications. but on general SoC hardware, supporting standard V4L2 applications is a need.

Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Quoted 7 lines

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

I tend to agree with that.

Quoted 8 lines
Quoted 3 lines

I agree as well.

This is in line with how existing drivers behave, too.

Well, sounds like there is consensus on this topic. I guess I'll go ahead and remove the control inheritance support. I suppose having a control appear in two places (subdev and video nodes) can be confusing.

I would say _don't_ do that until there are tools/libraries in place that are able to support controlling subdevs, otherwise it's just going to be another reason for me to walk away from this stuff, and stick with a version that does work sensibly.

Quoted 6 lines

As for the configurability vs. ease-of-use debate, I added the control inheritance to make it a little easier on the user, but, as the dot graphs below will show, the user already needs quite a lot of knowledge of the architecture already, in order to setup the different pipelines. So perhaps the control inheritance is rather pointless anyway.

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

Steve

#104 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Let me re-state. If the source can _only_ produce bayer, then there is _only_ _one_ possible path, and all the overhead of the media controller stuff is totally unnecessary.

Or, are you going to tell me that the user should have the right to configure paths through the iMX6 hardware that are not permitted by the iMX6 manuals for the data format being produced by the sensor?

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#105 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 29 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Quoted 8 lines

Let me re-state. If the source can _only_ produce bayer, then there is _only_ _one_ possible path, and all the overhead of the media controller stuff is totally unnecessary.

Or, are you going to tell me that the user should have the right to configure paths through the iMX6 hardware that are not permitted by the iMX6 manuals for the data format being produced by the sensor?

Russell, I'm not following you. The imx6 pipelines allow for many different sources, not just the inx219 that only outputs bayer. You seem to be saying that those other pipelines should not be present because they don't support raw bayer.

Steve

#106 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 39 lines · Steve Longerbeam
Quoted 29 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Quoted 8 lines

Let me re-state. If the source can _only_ produce bayer, then there is _only_ _one_ possible path, and all the overhead of the media controller stuff is totally unnecessary.

Or, are you going to tell me that the user should have the right to configure paths through the iMX6 hardware that are not permitted by the iMX6 manuals for the data format being produced by the sensor?

Quoted 4 lines

Russell, I'm not following you. The imx6 pipelines allow for many different sources, not just the inx219 that only outputs bayer. You seem to be saying that those other pipelines should not be present because they don't support raw bayer.

What I'm saying is this:

_If_ you have a sensor connected that can _only_ produce bayer, _then_ there is only _one_ possible path through the imx6 pipelines that is legal. Offering other paths from the source is noise, because every other path can't be used with a bayer source.

_If_ you have a sensor connected which can produce RGB or YUV formats, _then_ other paths are available, and pipeline needs to be configured to select the appropriate path with the desired features.

So, in the case of a bayer source, offering the user the chance to manually configure the _single_ allowable route through the tree is needless complexity. Forcing the user to have to use the subdev interfaces to configure the camera is needless complexity. Such a source can only ever be used with one single /dev/video* node.

Moreover, this requires user education, and this brings me on to much larger concerns. We seem to be saying "this is too complicated, the user can work it out!"

We've been here with VGA devices. Remember the old days when you had to put mode lines into the Xorg.conf, or go through a lengthy setup process to get X running? It wasn't very user-friendly. We seem to be making the same mistake here.

Usability comes first and foremost - throwing complex problems at users is not a solution.

Now, given that this media control API has been around for several years, and the userspace side of the story has not really improved (according to Mauro, several attempts have been made, every single attempt so far has failed, even for specific hardware) it seems to me that using the media control API is a very poor choice for the very simple reason that _no one_ knows how to configure a system using it. Hans thoughts of getting some funding to look at this aspect is a good idea, but I really wonder, given the history so far, how long this will take - and whether it _ever_ will get solved.

If it doesn't get solved, then we're stuck with quite a big problem.

So, I suggest that we don't merge any further media-controller based kernel code _until_ we have the userspace side sorted out. Merging the kernel side drivers when we don't even know that the userspace API is functionally usable in userspace beyond test programs is utterly absurd - what if it turns out that no one can write v4l plugins that sort out the issues that have been highlighted throughout these discussions.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#107 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux
Quoted 21 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 16 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 7 lines
Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

...and there are lots of those sources! You should try getting out of your imx219 shell some time, and have a look around! :)

Quoted 8 lines

Let me re-state. If the source can _only_ produce bayer, then there is _only_ _one_ possible path, and all the overhead of the media controller stuff is totally unnecessary.

Or, are you going to tell me that the user should have the right to configure paths through the iMX6 hardware that are not permitted by the iMX6 manuals for the data format being produced by the sensor?

Anyway, no the user is not allowed to configure a path that is not allowed by the hardware, such as attempting to pass raw bayer through an Image Converter path.

I guess you are simply commenting that for users of bayer sensors, the other pipelines can be "confusing". But I trust you're not saying those other pipelines should therefore not be present, which would be a completely nutty argument.

Steve

#108 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 29 lines · Steve Longerbeam
Quoted 26 lines · Russell King - ARM Linux
Quoted 24 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

Quoted 5 lines
Quoted 2 lines

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

...and there are lots of those sources! You should try getting out of your imx219 shell some time, and have a look around! :)

If you think that, you are insulting me. I've been thinking about this from the "big picture" point of view. If you think I'm only thinking about this from only the bayer point of view, you're wrong.

Given what Mauro has said, I'm convinced that the media controller stuff is a complete failure for usability, and adding further drivers using it is a mistake.

I counter your accusation by saying that you are actually so focused on the media controller way of doing things that you can't see the bigger picture here.

So, tell me how the user can possibly use iMX6 video capture without resorting to opening up a terminal and using media-ctl to manually configure the pipeline. How is the user going to control the source device without using media-ctl to find the subdev node, and then using v4l2-ctl on it. How is the user supposed to know which /dev/video* node they should be opening with their capture application?

If you can actually respond to the points that I've been raising about end user usability, then we can have a discussion.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#109 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 33 lines · Russell King - ARM Linux
Quoted 32 lines · Steve Longerbeam
Quoted 28 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Quoted 6 lines
Quoted 2 lines

...and there are lots of those sources! You should try getting out of your imx219 shell some time, and have a look around! :)

If you think that, you are insulting me. I've been thinking about this from the "big picture" point of view. If you think I'm only thinking about this from only the bayer point of view, you're wrong.

No insult there, you have my utmost respect Russel. Me gives you the Ali-G "respec!" :)

It was just a light-hearted attempt at suggesting you might be too entangled with the imx219 (or short on hardware access, which I can certainly understand).

Quoted 5 lines

Given what Mauro has said, I'm convinced that the media controller stuff is a complete failure for usability, and adding further drivers using it is a mistake.

I do agree with you that MC places a lot of burden on the user to attain a lot of knowledge of the system's architecture. That's really why I included that control inheritance patch, to ease the burden somewhat.

On the other hand, I also think this just requires that MC drivers have very good user documentation.

And my other point is, I think most people who have a need to work with the media framework on a particular platform will likely already be quite familiar with that platform.

Quoted 4 lines

I counter your accusation by saying that you are actually so focused on the media controller way of doing things that you can't see the bigger picture here.

Yeah I've been too mired in the details of this driver.

Quoted 6 lines

So, tell me how the user can possibly use iMX6 video capture without resorting to opening up a terminal and using media-ctl to manually configure the pipeline. How is the user going to control the source device without using media-ctl to find the subdev node, and then using v4l2-ctl on it. How is the user supposed to know which /dev/video* node they should be opening with their capture application?

The media graph for imx6 is fairly self-explanatory in my opinion. Yes that graph has to be generated, but just with a simple 'media-ctl --print-dot', I don't see how that is difficult for the user.

The graph makes it quite clear which subdev node belongs to which entity.

As for which /dev/videoX node to use, I hope I made it fairly clear in the user doc what functions each node performs. But I will review the doc again and make sure it's been made explicitly clear.

Quoted 3 lines

If you can actually respond to the points that I've been raising about end user usability, then we can have a discussion.

Right, I haven't added my input to the middle-ware discussions (libv4l, v4lconvert, and the auto-pipeline-configuration library work). I can only say at this point that v4lconvert does indeed sound broken w.r.t bayer formats from your description. But it also sounds like an isolated problem and it just needs a patch to allow passing bayer through without software conversion.

I wish I had the IMX219 to help you debug these bayer issues. I don't have any bayer sources.

In summary, I do like the media framework, it's a good abstraction of hardware pipelines. It does require a lot of system level knowledge to configure, but as I said that is a matter of good documentation.

Steve

#110 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Em Sun, 12 Mar 2017 10:56:53 -0700
Steve Longerbeam <[email protected]> escreveu:

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Steve Longerbeam

Given what Mauro has said, I'm convinced that the media controller stuff is a complete failure for usability, and adding further drivers using it is a mistake.

I never said that. The thing is that the V4L2 API was designed in 1999, when the video hardware were a way simpler: just one DMA engine on a PCI device, one video/audio input switch and a few video entries.

On those days, setting up a pipeline on such devices is simple, and can be done via VIDIOC_*_INPUT ioctls.

Nowadays hardware used on SoC devices are a way more complex.

SoC devices comes with several DMA engines for buffer transfers, plus video transform blocks whose pipeline can be set dynamically.

The MC API is a need to allow setting a complex pipeline, as VIDIOC_*_INPUT cannot work with such complexity.

The subdev API solves a different issue. On a "traditional" device, we usually have a pipeline like:

<video input> ==> <processing> ==> /dev/video0

Where <processing> controls something at the device (like bright and/or resolution) if you change something at the /dev/video0 node, it is clear that the <processing> block should handle it.

On complex devices, with a pipeline like:
<camera> ==> <processing0> ==> <CSI bus> ==> <processing1> ==> /dev/video0

If you send a command to adjust the something at /dev/video0, it is not clear for the device driver to do it at processing0 or at processing1. Ok, the driver can decide it, but this can be sub-optimal.

Yet, several drivers do that. For example, with em28xx-based drivers several parameters can be adjusted either at the em28xx driver or at the video decoder driver (saa711x). There's a logic inside the driver that decides it. The pipeline there is fixed, though, so it is easy to hardcode a logic for that.

So, I've no doubt that both MC and subdev APIs are needed when full hardware control is required.

I don't know about how much flexibility the i.MX6 hardware gives, nor if all such flexibility is needed for most use case applications.

If I were to code a driver for such hardware, though, I would try to provide a subset of the functionality that would work without the subdev API, allowing it to work with standard V4L applications.

That doesn't sound hard to do, as the driver may limit the pipelines to a subset that would make sense, in order to make easier for the driver to take the right decision about to where send a control to setup some parameter.

Quoted 2 lines

I do agree with you that MC places a lot of burden on the user to attain a lot of knowledge of the system's architecture.

Setting up the pipeline is not the hard part. One could write a script to do that.

Quoted 2 lines

That's really why I included that control inheritance patch, to ease the burden somewhat.

IMHO, that makes sense, as, once some script sets the pipeline, any V4L2 application can work, if you forward the controls to the right I2C devices.

Quoted 2 lines

On the other hand, I also think this just requires that MC drivers have very good user documentation.

No, it is not a matter of just documentation. It is a matter of having to rewrite applications for each device, as the information exposed by MC are not enough for an application to do what's needed.

For a generic application to work properly with MC, we need to have to add more stuff to MC, in order to allow applications to know more about the features of each subdevice and to things like discovering what kind of signal is present on each PAD. We're calling it as "properties API"[1].

[1] we discussed about that at the ML and at the MC workshop:

	https://linuxtv.org/news.php?entry=2015-08-17.mchehab

Unfortunately, nobody sent any patches implementing it so far :-(

Quoted 3 lines

And my other point is, I think most people who have a need to work with the media framework on a particular platform will likely already be quite familiar with that platform.

I disagree. The most popular platform device currently is Raspberry PI.

I doubt that almost all owners of RPi + camera module know anything about MC. They just use Raspberry's official driver with just provides the V4L2 interface.

I have a strong opinion that, for hardware like RPi, just the V4L2 API is enough for more than 90% of the cases.

Quoted 3 lines

The media graph for imx6 is fairly self-explanatory in my opinion. Yes that graph has to be generated, but just with a simple 'media-ctl --print-dot', I don't see how that is difficult for the user.

Again, IMHO, the problem is not how to setup the pipeline, but, instead, the need to forward controls to the subdevices.

To use a camera, the user needs to set up a set of controls for the image to make sense (bright, contrast, focus, etc). If the driver doesn't forward those controls to the subdevs, an application like "camorama" won't actually work for real, as the user won't be able to adjust those parameters via GUI.

Thanks,
Mauro

#111 lore raw

script to setup pipeline was Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Hi!

Quoted 5 lines
Quoted 2 lines

I do agree with you that MC places a lot of burden on the user to attain a lot of knowledge of the system's architecture.

Setting up the pipeline is not the hard part. One could write a script to do that.

Can you try to write that script? I believe it would solve big part of the problem.

Quoted 4 lines
Quoted 3 lines

And my other point is, I think most people who have a need to work with the media framework on a particular platform will likely already be quite familiar with that platform.

Quoted 8 lines

I disagree. The most popular platform device currently is Raspberry PI.

I doubt that almost all owners of RPi + camera module know anything about MC. They just use Raspberry's official driver with just provides the V4L2 interface.

I have a strong opinion that, for hardware like RPi, just the V4L2 API is enough for more than 90% of the cases.

Maybe V4L2 API is enough for 90% of the users. But I don't believe that means that we should provide compatibility. V4L2 API is not good enough for complex devices, and if we can make RPi people fix userspace... that's a good thing.

Quoted 4 lines
Quoted 3 lines

The media graph for imx6 is fairly self-explanatory in my opinion. Yes that graph has to be generated, but just with a simple 'media-ctl --print-dot', I don't see how that is difficult for the user.

Quoted 8 lines

Again, IMHO, the problem is not how to setup the pipeline, but, instead, the need to forward controls to the subdevices.

To use a camera, the user needs to set up a set of controls for the image to make sense (bright, contrast, focus, etc). If the driver doesn't forward those controls to the subdevs, an application like "camorama" won't actually work for real, as the user won't be able to adjust those parameters via GUI.

I believe this can be fixed in libv4l2.
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170326/1149c675/attachment.sig>
#112 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Steve Longerbeam
Quoted 107 lines · Steve Longerbeam
Quoted 33 lines · Russell King - ARM Linux
Quoted 32 lines · Steve Longerbeam
Quoted 28 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Quoted 6 lines
Quoted 2 lines

...and there are lots of those sources! You should try getting out of your imx219 shell some time, and have a look around! :)

If you think that, you are insulting me. I've been thinking about this from the "big picture" point of view. If you think I'm only thinking about this from only the bayer point of view, you're wrong.

No insult there, you have my utmost respect Russel. Me gives you the Ali-G "respec!" :)

It was just a light-hearted attempt at suggesting you might be too entangled with the imx219 (or short on hardware access, which I can certainly understand).

Quoted 5 lines

Given what Mauro has said, I'm convinced that the media controller stuff is a complete failure for usability, and adding further drivers using it is a mistake.

I do agree with you that MC places a lot of burden on the user to attain a lot of knowledge of the system's architecture. That's really why I included that control inheritance patch, to ease the burden somewhat.

On the other hand, I also think this just requires that MC drivers have very good user documentation.

And my other point is, I think most people who have a need to work with the media framework on a particular platform will likely already be quite familiar with that platform.

Quoted 4 lines

I counter your accusation by saying that you are actually so focused on the media controller way of doing things that you can't see the bigger picture here.

Yeah I've been too mired in the details of this driver.

Quoted 6 lines

So, tell me how the user can possibly use iMX6 video capture without resorting to opening up a terminal and using media-ctl to manually configure the pipeline. How is the user going to control the source device without using media-ctl to find the subdev node, and then using v4l2-ctl on it. How is the user supposed to know which /dev/video* node they should be opening with their capture application?

The media graph for imx6 is fairly self-explanatory in my opinion. Yes that graph has to be generated, but just with a simple 'media-ctl --print-dot', I don't see how that is difficult for the user.

The graph makes it quite clear which subdev node belongs to which entity.

As for which /dev/videoX node to use, I hope I made it fairly clear in the user doc what functions each node performs. But I will review the doc again and make sure it's been made explicitly clear.

Quoted 3 lines

If you can actually respond to the points that I've been raising about end user usability, then we can have a discussion.

Right, I haven't added my input to the middle-ware discussions (libv4l, v4lconvert, and the auto-pipeline-configuration library work). I can only say at this point that v4lconvert does indeed sound broken w.r.t bayer formats from your description. But it also sounds like an isolated problem and it just needs a patch to allow passing bayer through without software conversion.

Quoted 6 lines

I wish I had the IMX219 to help you debug these bayer issues. I don't have any bayer sources.

In summary, I do like the media framework, it's a good abstraction of hardware pipelines. It does require a lot of system level knowledge to configure, but as I said that is a matter of good documentation.

And the reason we went into this direction is that the end-users that use these SoCs with complex pipelines actually *need* this functionality. Which is also part of the reason why work on improved userspace support gets little attention: they don't need to have a plugin that allows generic V4L2 applications to work (at least with simple scenarios).

If they would need it, it would have been done (and paid for) before.

And improving userspace support for this isn't even at the top of our prio
list: getting the request API and stateless codec support in is our highest priority. And that's a big job as well.

If you want to blame anyone for this, blame Nokia who set fire to their linux-based phones and thus to the funding for this work.

Yes, I am very unhappy with the current state, but given the limited resources I understand why it is as it is. I will try to get time to work on this this summer, but there is no guarantee that that will be granted. If someone else is interested in doing this and can get funding for it, then that would be very welcome.

Regards,

Hans

#113 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 10 lines · Hans Verkuil
Quoted 3 lines · Steve Longerbeam

In summary, I do like the media framework, it's a good abstraction of hardware pipelines. It does require a lot of system level knowledge to configure, but as I said that is a matter of good documentation.

And the reason we went into this direction is that the end-users that use these SoCs with complex pipelines actually *need* this functionality. Which is also part of the reason why work on improved userspace support gets little attention: they don't need to have a plugin that allows generic V4L2 applications to work (at least with simple scenarios).

If you stop inheriting controls from the capture sensor to the v4l2 capture device, then this breaks - generic v4l2 applications are not going to be able to show the controls, because they're not visible at the v4l2 capture device anymore. They're only visible through the subdev interfaces, which these generic applications know nothing about.

Quoted 2 lines

If you want to blame anyone for this, blame Nokia who set fire to their linux-based phones and thus to the funding for this work.

No, I think that's completely unfair to Nokia. If the MC approach is the way you want to go, you should be thanking Nokia for the amount of effort that they have put in to it, and recognising that it was rather unfortunate that the market had changed, which meant that they weren't able to continue.

No one has any right to require any of us to finish what we start coding up in open source, unless there is a contractual obligation in place. That goes for Nokia too.

Nokia's decision had ramifications far and wide (resulting in knock on effects in TI and further afield), so don't think for a moment I wasn't affected by what happened in Nokia. Even so, it was a decision for Nokia to make, they had the right to make it, and we have no right to attribute "blame" to Nokia for having made that decision.

To even suggest that Nokia should be blamed is absurd.

Open source gives rights to everyone. It gives rights to contribute and use, but it also gives rights to walk away without notice (remember the "as is" and "no warranty" clauses?)

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#114 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 37 lines · Russell King - ARM Linux
Quoted 10 lines · Hans Verkuil
Quoted 3 lines · Steve Longerbeam

In summary, I do like the media framework, it's a good abstraction of hardware pipelines. It does require a lot of system level knowledge to configure, but as I said that is a matter of good documentation.

And the reason we went into this direction is that the end-users that use these SoCs with complex pipelines actually *need* this functionality. Which is also part of the reason why work on improved userspace support gets little attention: they don't need to have a plugin that allows generic V4L2 applications to work (at least with simple scenarios).

If you stop inheriting controls from the capture sensor to the v4l2 capture device, then this breaks - generic v4l2 applications are not going to be able to show the controls, because they're not visible at the v4l2 capture device anymore. They're only visible through the subdev interfaces, which these generic applications know nothing about.

Quoted 2 lines

If you want to blame anyone for this, blame Nokia who set fire to their linux-based phones and thus to the funding for this work.

No, I think that's completely unfair to Nokia. If the MC approach is the way you want to go, you should be thanking Nokia for the amount of effort that they have put in to it, and recognising that it was rather unfortunate that the market had changed, which meant that they weren't able to continue.

No one has any right to require any of us to finish what we start coding up in open source, unless there is a contractual obligation in place. That goes for Nokia too.

Nokia's decision had ramifications far and wide (resulting in knock on effects in TI and further afield), so don't think for a moment I wasn't affected by what happened in Nokia. Even so, it was a decision for Nokia to make, they had the right to make it, and we have no right to attribute "blame" to Nokia for having made that decision.

Quoted 5 lines

To even suggest that Nokia should be blamed is absurd.

Open source gives rights to everyone. It gives rights to contribute and use, but it also gives rights to walk away without notice (remember the "as is" and "no warranty" clauses?)

Sorry, unfortunate choice of words. While it lasted they did great work. But the reason why MC development stopped for quite some time (esp. the work on userspace software) was because the funding from Nokia dried up.

Regards,

Hans

#115 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux

Em Mon, 13 Mar 2017 10:58:42 +0000
Russell King - ARM Linux <[email protected]> escreveu:

Quoted 12 lines · Hans Verkuil
Quoted 10 lines · Steve Longerbeam
Quoted 3 lines

In summary, I do like the media framework, it's a good abstraction of hardware pipelines. It does require a lot of system level knowledge to configure, but as I said that is a matter of good documentation.

And the reason we went into this direction is that the end-users that use these SoCs with complex pipelines actually *need* this functionality. Which is also part of the reason why work on improved userspace support gets little attention: they don't need to have a plugin that allows generic V4L2 applications to work (at least with simple scenarios).

Quoted 5 lines

If you stop inheriting controls from the capture sensor to the v4l2 capture device, then this breaks - generic v4l2 applications are not going to be able to show the controls, because they're not visible at the v4l2 capture device anymore. They're only visible through the subdev interfaces, which these generic applications know nothing about.

True. That's why IMHO, the best is to do control inheritance when there are use cases for generic applications and is possible for the driver to do it (e. g. when the pipeline is not too complex to prevent it to work).

As Hans said, for the drivers currently upstreamed at drivers/media, there are currently very little interest on running generic apps there, as they're meant to be used inside embedded hardware using specialized applications.

I don't have myself any hardware with i.MX6. Yet, I believe that a low cost board like SolidRun Hummingboard - with comes with a CSI interface compatible with RPi camera modules - will likely attract users who need to run generic applications on their devices.

So, I believe that it makes sense for i.MX6 driver to inherit controls from video devnode.

Thanks,
Mauro

#116 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 5 lines · Mauro Carvalho Chehab

I don't have myself any hardware with i.MX6. Yet, I believe that a low cost board like SolidRun Hummingboard - with comes with a CSI interface compatible with RPi camera modules - will likely attract users who need to run generic applications on their devices.

As you've previously mentioned about camorama, I've installed it (I run Ubuntu 16.04 with "gnome-flashback-metacity" on the HB) and I'm able to use camorama to view the IMX219 camera sensor.

There's some gotcha's though:

* you need to start it on the command line, manually specifying which /dev/video device to use, as it always wants to use /dev/video0. With the CODA mem2mem driver loaded, this may not be a camera device:

$ v4l2-ctl -d 0 --all
Driver Info (not using libv4l2):
        Driver name   : coda
        Card type     : CODA960
        Bus info      : platform:coda
        Driver version: 4.11.0

* camorama seems to use the v4lconvert library, and looking at the resulting image quality, is rather pixelated - my guess is that v4lconvert is using a basic algorithm to de-bayer the data. It also appears to only manage 7fps at best. The gstreamer neon debayer plugin appears to be faster and higher quality.

* it provides five controls - brightness/contrast/color/hue/white balance, each of which are not supported by the hardware (IMX219 supports gain and analogue gain only.) These controls appear to have no effect on the resulting image.

However, using qv4l2 (with the segfault bug in GeneralTab::updateFrameSize() fixed - m_frameSize, m_frameWidth and m_frameHeight can be NULL) provides access to all controls. This can happen if GeneralTab::inputSection() is not called.

The USB uvcvideo camera achieves around 24fps with functional controls in camorama (mainly because it provides those exact controls to userspace.)

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#117 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Russell King - ARM Linux
Quoted 33 lines · Russell King - ARM Linux
Quoted 32 lines · Steve Longerbeam
Quoted 28 lines · Russell King - ARM Linux
Quoted 20 lines · Steve Longerbeam
Quoted 11 lines · Russell King - ARM Linux

I really don't think expecting the user to understand and configure the pipeline is a sane way forward. Think about it - should the user need to know that, because they have a bayer-only CSI data source, that there is only one path possible, and if they try to configure a different path, then things will just error out?

For the case of imx219 connected to iMX6, it really is as simple as "there is only one possible path" and all the complexity of the media interfaces/subdevs is completely unnecessary. Every other block in the graph is just noise.

Quoted 5 lines

The fact is that these dot graphs show a complex picture, but reality is somewhat different - there's only relatively few paths available depending on the connected source and the rest of the paths are completely useless.

Quoted 4 lines

I totally disagree there. Raw bayer requires passthrough yes, but for all other media bus formats on a mipi csi-2 bus, and all other media bus formats on 8-bit parallel buses, the conersion pipelines can be used for scaling, CSC, rotation, and motion-compensated de-interlacing.

... which only makes sense _if_ your source can produce those formats. We don't actually disagree on that.

Quoted 6 lines
Quoted 2 lines

...and there are lots of those sources! You should try getting out of your imx219 shell some time, and have a look around! :)

If you think that, you are insulting me. I've been thinking about this from the "big picture" point of view. If you think I'm only thinking about this from only the bayer point of view, you're wrong.

Can you stop that insults nonsense?

Quoted 3 lines

Given what Mauro has said, I'm convinced that the media controller stuff is a complete failure for usability, and adding further drivers using it is a mistake.

Hmm. But you did not present any alternative. Seems some hardware is simply complex. So either we don't add complex drivers (_that_ would be a mistake), or some userspace solution will need to be done. Shell-script running media-ctl does not seem that hard.

Quoted 6 lines

So, tell me how the user can possibly use iMX6 video capture without resorting to opening up a terminal and using media-ctl to manually configure the pipeline. How is the user going to control the source device without using media-ctl to find the subdev node, and then using v4l2-ctl on it. How is the user supposed to know which /dev/video* node they should be opening with their capture application?

Complex hardware sometimes requires userspace configuration. Running a shell script on startup does not seem that hard.

And maybe we could do some kind of default setup in kernel, but that does not really solve the problem.

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170312/1776bfee/attachment.sig>
#118 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Steve Longerbeam

Hi!

Quoted 11 lines
Quoted 5 lines
Quoted 1 line

I tend to agree with that.

I agree as well.

This is in line with how existing drivers behave, too.

Well, sounds like there is consensus on this topic. I guess I'll go ahead and remove the control inheritance support. I suppose having a control appear in two places (subdev and video nodes) can be confusing.

I guess that's way to go. It is impossible to change userland APIs once the patch is merged...
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
author maintainer
#119 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

Quoted 9 lines · Pavel Machek

Hi!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I tend to agree with that.

I agree as well.

This is in line with how existing drivers behave, too.

Quoted 7 lines
Quoted 4 lines

Well, sounds like there is consensus on this topic. I guess I'll go ahead and remove the control inheritance support. I suppose having a control appear in two places (subdev and video nodes) can be confusing.

I guess that's way to go. It is impossible to change userland APIs once the patch is merged...

Ok, not including myself, it's now 4 in favor of removing, 1 against...

Steve

#120 lore raw

Re: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline

In reply to Mauro Carvalho Chehab

Hi!

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Ok, perhaps supporting both subdev API and V4L2 API at the same time doesn't make much sense. We could disable one in favor of the other, either at compilation time or at runtime.

Right. If the subdev API is disabled, then you have to inherit the subdev controls in the bridge driver (how else would you be able to access them?). And that's the usual case.

Quoted 5 lines
Quoted 3 lines

If you do have the subdev API enabled, AND you use the MC, then the intention clearly is to give userspace full control and inheriting controls no longer makes any sense (and is highly confusing IMHO).

I tend to agree with that.

Well, having different userspace interface according to config options is strange. I believe the right solution is to make complex drivers depend on CONFIG_VIDEO_V4L2_SUBDEV_API...

Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170311/e1dd4344/attachment-0001.sig>
author maintainer
#121 lore raw

PATCH v4 15/36 platform: add video-multiplexer subdevice driver

In reply to Steve Longerbeam

From: Philipp Zabel <[email protected]>

This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side.

--

- fixed a cut&paste error in vidsw_remove(): v4l2_async_register_subdev() should be unregister.

- added media_entity_cleanup() and v4l2_device_unregister_subdev() to vidsw_remove().

- added missing MODULE_DEVICE_TABLE().

- there was a line left over from a previous iteration that negated the new way of determining the pad count just before it which has been removed (num_pads = of_get_child_count(np)).

- Philipp Zabel has developed a set of patches that allow adding to the subdev async notifier waiting list using a chaining method from the async registered callbacks (v4l2_of_subdev_registered() and the prep patches for that). For now, I've removed the use of v4l2_of_subdev_registered() for the vidmux driver's registered callback. This doesn't affect the functionality of this driver, but allows for it to be merged now, before adding the chaining support.

---
 .../bindings/media/video-multiplexer.txt           |  59 +++
 drivers/media/platform/Kconfig                     |   8 +
 drivers/media/platform/Makefile                    |   2 +
 drivers/media/platform/video-multiplexer.c         | 474 +++++++++++++++++++++
 4 files changed, 543 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/video-multiplexer.txt
 create mode 100644 drivers/media/platform/video-multiplexer.c
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +59 -0
new file mode 100644
index 0000000..9d133d9
@@ -0,0 +1,59 @@
+Video Multiplexer
+=================
+
+Video multiplexers allow to select between multiple input ports. Video received
+on the active input port is passed through to the output port. Muxes described
+by this binding may be controlled by a syscon register bitfield or by a GPIO.
+
+Required properties:
+- compatible : should be "video-multiplexer"
+- reg: should be register base of the register containing the control bitfield
+- bit-mask: bitmask of the control bitfield in the control register
+- bit-shift: bit offset of the control bitfield in the control register
+- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle
+  may be given to switch between two inputs
+- #address-cells: should be <1>
+- #size-cells: should be <0>
+- port@*: at least three port nodes containing endpoints connecting to the
+  source and sink devices according to of_graph bindings. The last port is
+  the output port, all others are inputs.
+
+Example:
+
+syscon {
+	compatible = "syscon", "simple-mfd";
+
+	mux {
+		compatible = "video-multiplexer";
+		/* Single bit (1 << 19) in syscon register 0x04: */
+		reg = <0x04>;
+		bit-mask = <1>;
+		bit-shift = <19>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port at 0 {
+			reg = <0>;
+
+			mux_in0: endpoint {
+				remote-endpoint = <&video_source0_out>;
+			};
+		};
+
+		port at 1 {
+			reg = <1>;
+
+			mux_in1: endpoint {
+				remote-endpoint = <&video_source1_out>;
+			};
+		};
+
+		port at 2 {
+			reg = <2>;
+
+			mux_out: endpoint {
+				remote-endpoint = <&capture_interface_in>;
+			};
+		};
+	};
+};
drivers/media/platform/Kconfig +8 -0
index c9106e1..3d60d4c 100644
@@ -74,6 +74,14 @@ config VIDEO_M32R_AR_M64278
 	  To compile this driver as a module, choose M here: the
 	  module will be called arv.
 
+config VIDEO_MULTIPLEXER
+	tristate "Video Multiplexer"
+	depends on VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
+	help
+	  This driver provides support for SoC internal N:1 video bus
+	  multiplexers controlled by register bitfields as well as external
+	  2:1 video multiplexers controlled by a single GPIO.
+
 config VIDEO_OMAP3
 	tristate "OMAP 3 Camera support"
 	depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3
drivers/media/platform/Makefile +2 -0
index 349ddf6..31bfa99 100644
@@ -27,6 +27,8 @@ obj-$(CONFIG_VIDEO_SH_VEU)		+= sh_veu.o
 
 obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)	+= m2m-deinterlace.o
 
+obj-$(CONFIG_VIDEO_MULTIPLEXER)		+= video-multiplexer.o
+
 obj-$(CONFIG_VIDEO_S3C_CAMIF) 		+= s3c-camif/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) 	+= exynos4-is/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)	+= s5p-jpeg/
drivers/media/platform/video-multiplexer.c new file +474 -0

474 lines not on this page · raw message

Signature · 1 line
2.7.4
#122 lore raw

Re: [PATCH v4 15/36] platform: add video-multiplexer subdevice driver

Hi!

Quoted 11 lines

From: Philipp Zabel <[email protected]>

This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side.

--

Again, this is slightly non-standard format. Normally changes from v1 go below ---, but in your case it would cut off the signoff...

Quoted 15 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +9 -0
new file mode 100644
index 0000000..9d133d9
@@ -0,0 +1,59 @@
+Video Multiplexer
+=================
+
+Video multiplexers allow to select between multiple input ports. Video received
+on the active input port is passed through to the output port. Muxes described
+by this binding may be controlled by a syscon register bitfield or by a GPIO.
+
+Required properties:
+- compatible : should be "video-multiplexer"

Documentation/devicetree/bindings/media/video-multiplexer.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +10 -0
+- reg: should be register base of the register containing the control bitfield
+- bit-mask: bitmask of the control bitfield in the control register
+- bit-shift: bit offset of the control bitfield in the control register
+- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle
+  may be given to switch between two inputs
+- #address-cells: should be <1>
+- #size-cells: should be <0>
+- port@*: at least three port nodes containing endpoints connecting to the
+  source and sink devices according to of_graph bindings. The last port is
+  the output port, all others are inputs.

At least three? I guess it is exactly three with the gpio?

Plus you might want to describe which port correspond to which gpio state/bitfield values...

Documentation/devicetree/bindings/media/video-multiplexer.txt line 20

Quoted 1 line
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +1 -0
+struct vidsw {

I knew it: it is secretely a switch! :-).

Documentation/devicetree/bindings/media/video-multiplexer.txt line 32

Quoted 12 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +12 -0
+static void vidsw_set_active(struct vidsw *vidsw, int active)
+{
+	vidsw->active = active;
+	if (active < 0)
+		return;
+
+	dev_dbg(vidsw->subdev.dev, "setting %d active\n", active);
+
+	if (vidsw->field)
+		regmap_field_write(vidsw->field, active);
+	else if (vidsw->gpio)
+		gpiod_set_value(vidsw->gpio, active);
         else dev_err()...?

Documentation/devicetree/bindings/media/video-multiplexer.txt line 37

Quoted 5 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +5 -0
+static int vidsw_async_init(struct vidsw *vidsw, struct device_node *node)
+{
+	struct device_node *ep;
+	u32 portno;
+	int numports;

numbports is int, so I guess portno should be, too?

Documentation/devicetree/bindings/media/video-multiplexer.txt

Quoted 12 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +10 -0
+		portno = endpoint.base.port;
+		if (portno >= numports - 1)
+			continue;
 
 
+	if (!pad) {
+		/* Mirror the input side on the output side */
+		cfg->type = vidsw->endpoint[vidsw->active].bus_type;
+		if (cfg->type == V4L2_MBUS_PARALLEL ||
+		    cfg->type == V4L2_MBUS_BT656)
+			cfg->flags = vidsw->endpoint[vidsw->active].bus.parallel.flags;
+	}

Will this need support for other V4L2_MBUS_ values?

Documentation/devicetree/bindings/media/video-multiplexer.txt

Quoted 2 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +2 -0
+MODULE_AUTHOR("Sascha Hauer, Pengutronix");
+MODULE_AUTHOR("Philipp Zabel, Pengutronix");

Normally, MODULE_AUTHOR contains comma separated names of authors, perhaps with <email@addresses>. Not sure two MODULE_AUTHORs per file will work.

Thanks,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170219/3eb79876/attachment.sig>
maintainer
#123 lore raw

Re: [PATCH v4 15/36] platform: add video-multiplexer subdevice driver

Quoted 36 lines · Pavel Machek

Hi!

Quoted 11 lines

From: Philipp Zabel <[email protected]>

This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side.

--

Again, this is slightly non-standard format. Normally changes from v1 go below ---, but in your case it would cut off the signoff...

Quoted 19 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +13 -0
new file mode 100644
index 0000000..9d133d9
@@ -0,0 +1,59 @@
+Video Multiplexer
+=================
+
+Video multiplexers allow to select between multiple input ports. Video received
+on the active input port is passed through to the output port. Muxes described
+by this binding may be controlled by a syscon register bitfield or by a GPIO.
+
+Required properties:
+- compatible : should be "video-multiplexer"
+- reg: should be register base of the register containing the control bitfield
+- bit-mask: bitmask of the control bitfield in the control register
+- bit-shift: bit offset of the control bitfield in the control register
+- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle
Quoted 8 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 19

Quoted 6 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +6 -0
+  may be given to switch between two inputs
+- #address-cells: should be <1>
+- #size-cells: should be <0>
+- port@*: at least three port nodes containing endpoints connecting to the
+  source and sink devices according to of_graph bindings. The last port is
+  the output port, all others are inputs.

At least three? I guess it is exactly three with the gpio?

Yes. With the mmio bitfield muxes there can be more.

Quoted 6 lines

Plus you might want to describe which port correspond to which gpio state/bitfield values...

Documentation/devicetree/bindings/media/video-multiplexer.txt line 20

Quoted 1 line
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +1 -0
+struct vidsw {

I knew it: it is secretely a switch! :-).

This driver started as a two-input gpio controlled bus switch. I changed the name when adding support for bitfield controlled multiplexers with more than two inputs.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +6 -0
+static void vidsw_set_active(struct vidsw *vidsw, int active)
+{
+	vidsw->active = active;
+	if (active < 0)
+		return;
+
Quoted 8 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 32

Quoted 6 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +6 -0
+	dev_dbg(vidsw->subdev.dev, "setting %d active\n", active);
+
+	if (vidsw->field)
+		regmap_field_write(vidsw->field, active);
+	else if (vidsw->gpio)
+		gpiod_set_value(vidsw->gpio, active);
         else dev_err()...?

If neither field nor gpio are set, probe will have failed and this will never be called.

Quoted 7 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 37

Quoted 5 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +5 -0
+static int vidsw_async_init(struct vidsw *vidsw, struct device_node *node)
+{
+	struct device_node *ep;
+	u32 portno;
+	int numports;

numbports is int, so I guess portno should be, too?

We could change both to unsigned int, as both vidsw->num_pads and endpoint.base.port are unsigned int, and they are only compared/assigned to those and each other.

Quoted 4 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 40

Quoted 3 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +3 -0
+		portno = endpoint.base.port;
+		if (portno >= numports - 1)
+			continue;
     I. 
Quoted 9 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 47

Quoted 7 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +7 -0
+	if (!pad) {
+		/* Mirror the input side on the output side */
+		cfg->type = vidsw->endpoint[vidsw->active].bus_type;
+		if (cfg->type == V4L2_MBUS_PARALLEL ||
+		    cfg->type == V4L2_MBUS_BT656)
+			cfg->flags = vidsw->endpoint[vidsw->active].bus.parallel.flags;
+	}

Will this need support for other V4L2_MBUS_ values?

To support CSI-2 multiplexers, yes.

Quoted 9 lines

Documentation/devicetree/bindings/media/video-multiplexer.txt line 49

Quoted 2 lines
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +2 -0
+MODULE_AUTHOR("Sascha Hauer, Pengutronix");
+MODULE_AUTHOR("Philipp Zabel, Pengutronix");

Normally, MODULE_AUTHOR contains comma separated names of authors, perhaps with <email@addresses>. Not sure two MODULE_AUTHORs per file will work.

Thanks,
Pavel

regards
Philipp

#124 lore raw

Re: [PATCH v4 15/36] platform: add video-multiplexer subdevice driver

Hi!

Quoted 10 lines
Quoted 6 lines

Plus you might want to describe which port correspond to which gpio state/bitfield values...

Quoted 1 line

+struct vidsw {

I knew it: it is secretely a switch! :-).

This driver started as a two-input gpio controlled bus switch. I changed the name when adding support for bitfield controlled multiplexers with more than two inputs.

We had discussion with Sakari / Rob whether gpio controlled thing is a switch or a multiplexer :-).

Quoted 11 lines
Quoted 9 lines

drivers/media/platform/video-multiplexer.c line 217

Quoted 7 lines
drivers/media/platform/video-multiplexer.c new file +7 -0
+	if (!pad) {
+		/* Mirror the input side on the output side */
+		cfg->type = vidsw->endpoint[vidsw->active].bus_type;
+		if (cfg->type == V4L2_MBUS_PARALLEL ||
+		    cfg->type == V4L2_MBUS_BT656)
+			cfg->flags = vidsw->endpoint[vidsw->active].bus.parallel.flags;
+	}

Will this need support for other V4L2_MBUS_ values?

To support CSI-2 multiplexers, yes.

Can you stick switch () { .... default: dev_err() } there, to help future hackers?

Thank,
Pavel

Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170224/521fe700/attachment.sig>
maintainer
#125 lore raw

Re: [PATCH v4 15/36] platform: add video-multiplexer subdevice driver

In reply to Steve Longerbeam
Quoted 34 lines · Steve Longerbeam

From: Philipp Zabel <[email protected]>

This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side.

--

- fixed a cut&paste error in vidsw_remove(): v4l2_async_register_subdev() should be unregister.

- added media_entity_cleanup() and v4l2_device_unregister_subdev() to vidsw_remove().

- added missing MODULE_DEVICE_TABLE().

- there was a line left over from a previous iteration that negated the new way of determining the pad count just before it which has been removed (num_pads = of_get_child_count(np)).

- Philipp Zabel has developed a set of patches that allow adding to the subdev async notifier waiting list using a chaining method from the async registered callbacks (v4l2_of_subdev_registered() and the prep patches for that). For now, I've removed the use of v4l2_of_subdev_registered() for the vidmux driver's registered callback. This doesn't affect the functionality of this driver, but allows for it to be merged now, before adding the chaining support.

Quoted 3 lines
---
 .../bindings/media/video-multiplexer.txt           |  59 +++

Please make this a separate commit.

Quoted 72 lines
 drivers/media/platform/Kconfig                     |   8 +
 drivers/media/platform/Makefile                    |   2 +
 drivers/media/platform/video-multiplexer.c         | 474 +++++++++++++++++++++
 4 files changed, 543 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/video-multiplexer.txt
 create mode 100644 drivers/media/platform/video-multiplexer.c
Documentation/devicetree/bindings/media/video-multiplexer.txt new file +59 -0
new file mode 100644
index 0000000..9d133d9
@@ -0,0 +1,59 @@
+Video Multiplexer
+=================
+
+Video multiplexers allow to select between multiple input ports. Video received
+on the active input port is passed through to the output port. Muxes described
+by this binding may be controlled by a syscon register bitfield or by a GPIO.
+
+Required properties:
+- compatible : should be "video-multiplexer"
+- reg: should be register base of the register containing the control bitfield
+- bit-mask: bitmask of the control bitfield in the control register
+- bit-shift: bit offset of the control bitfield in the control register
+- gpios: alternatively to reg, bit-mask, and bit-shift, a single GPIO phandle
+  may be given to switch between two inputs
+- #address-cells: should be <1>
+- #size-cells: should be <0>
+- port@*: at least three port nodes containing endpoints connecting to the
+  source and sink devices according to of_graph bindings. The last port is
+  the output port, all others are inputs.
+
+Example:
+
+syscon {
+	compatible = "syscon", "simple-mfd";
+
+	mux {
+		compatible = "video-multiplexer";
+		/* Single bit (1 << 19) in syscon register 0x04: */
+		reg = <0x04>;
+		bit-mask = <1>;
+		bit-shift = <19>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port at 0 {
+			reg = <0>;
+
+			mux_in0: endpoint {
+				remote-endpoint = <&video_source0_out>;
+			};
+		};
+
+		port at 1 {
+			reg = <1>;
+
+			mux_in1: endpoint {
+				remote-endpoint = <&video_source1_out>;
+			};
+		};
+
+		port at 2 {
+			reg = <2>;
+
+			mux_out: endpoint {
+				remote-endpoint = <&capture_interface_in>;
+			};
+		};
+	};
+};
author maintainer
#126 lore raw

Re: [PATCH v4 15/36] platform: add video-multiplexer subdevice driver

Quoted 35 lines · Rob Herring
Quoted 34 lines · Steve Longerbeam

From: Philipp Zabel <[email protected]>

This driver can handle SoC internal and external video bus multiplexers, controlled either by register bit fields or by a GPIO. The subdevice passes through frame interval and mbus configuration of the active input to the output side.

--

- fixed a cut&paste error in vidsw_remove(): v4l2_async_register_subdev() should be unregister.

- added media_entity_cleanup() and v4l2_device_unregister_subdev() to vidsw_remove().

- added missing MODULE_DEVICE_TABLE().

- there was a line left over from a previous iteration that negated the new way of determining the pad count just before it which has been removed (num_pads = of_get_child_count(np)).

- Philipp Zabel has developed a set of patches that allow adding to the subdev async notifier waiting list using a chaining method from the async registered callbacks (v4l2_of_subdev_registered() and the prep patches for that). For now, I've removed the use of v4l2_of_subdev_registered() for the vidmux driver's registered callback. This doesn't affect the functionality of this driver, but allows for it to be merged now, before adding the chaining support.

Quoted 4 lines
Quoted 3 lines
---
  .../bindings/media/video-multiplexer.txt           |  59 +++

Please make this a separate commit.

Done.

Steve

author maintainer
#127 lore raw

PATCH v4 16/36 UAPI: Add media UAPI Kbuild file

In reply to Steve Longerbeam

Add an empty UAPI Kbuild file for media UAPI headers.

---
 include/uapi/Kbuild       | 1 +
 include/uapi/media/Kbuild | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 include/uapi/media/Kbuild
include/uapi/Kbuild +1 -0
index 245aa6e..9a51957 100644
@@ -6,6 +6,7 @@
 header-y += asm-generic/
 header-y += linux/
 header-y += sound/
+header-y += media/
 header-y += mtd/
 header-y += rdma/
 header-y += video/
include/uapi/media/Kbuild new file +1 -0
new file mode 100644
index 0000000..aafaa5a
@@ -0,0 +1 @@
+# UAPI Header export list
Signature · 1 line
2.7.4
author maintainer
#128 lore raw

PATCH v4 17/36 media: Add userspace header file for i.MX

In reply to Steve Longerbeam

This adds a header file for use by userspace programs wanting to interact with the i.MX media driver. It defines custom v4l2 controls and events generated by the i.MX v4l2 subdevices.

---
 include/uapi/media/Kbuild |  1 +
 include/uapi/media/imx.h  | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 include/uapi/media/imx.h
include/uapi/media/Kbuild +1 -0
index aafaa5a..fa78958 100644
@@ -1 +1,2 @@
 # UAPI Header export list
+header-y += imx.h
include/uapi/media/imx.h new file +29 -0
new file mode 100644
index 0000000..1fdd1c1
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014-2015 Mentor Graphics Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */
+
+#ifndef __UAPI_MEDIA_IMX_H__
+#define __UAPI_MEDIA_IMX_H__
+
+/*
+ * events from the subdevs
+ */
+#define V4L2_EVENT_IMX_CLASS          V4L2_EVENT_PRIVATE_START
+#define V4L2_EVENT_IMX_NFB4EOF        (V4L2_EVENT_IMX_CLASS + 1)
+#define V4L2_EVENT_IMX_FRAME_INTERVAL (V4L2_EVENT_IMX_CLASS + 2)
+
+enum imx_ctrl_id {
+	V4L2_CID_IMX_MOTION = (V4L2_CID_USER_IMX_BASE + 0),
+	V4L2_CID_IMX_FIM_ENABLE,
+	V4L2_CID_IMX_FIM_NUM,
+	V4L2_CID_IMX_FIM_TOLERANCE_MIN,
+	V4L2_CID_IMX_FIM_TOLERANCE_MAX,
+	V4L2_CID_IMX_FIM_NUM_SKIP,
+};
+
+#endif
Signature · 1 line
2.7.4
maintainer
#129 lore raw

Re: [PATCH v4 17/36] media: Add userspace header file for i.MX

Quoted 32 lines · Steve Longerbeam

This adds a header file for use by userspace programs wanting to interact with the i.MX media driver. It defines custom v4l2 controls and events generated by the i.MX v4l2 subdevices.

---
 include/uapi/media/Kbuild |  1 +
 include/uapi/media/imx.h  | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 include/uapi/media/imx.h
include/uapi/media/Kbuild +1 -0
index aafaa5a..fa78958 100644
@@ -1 +1,2 @@
 # UAPI Header export list
+header-y += imx.h
include/uapi/media/imx.h new file +8 -0
new file mode 100644
index 0000000..1fdd1c1
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014-2015 Mentor Graphics Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */

include/uapi/media/imx.h line 18

Quoted 10 lines
include/uapi/media/imx.h new file +10 -0
+
+#ifndef __UAPI_MEDIA_IMX_H__
+#define __UAPI_MEDIA_IMX_H__
+
+/*
+ * events from the subdevs
+ */
+#define V4L2_EVENT_IMX_CLASS          V4L2_EVENT_PRIVATE_START
+#define V4L2_EVENT_IMX_NFB4EOF        (V4L2_EVENT_IMX_CLASS + 1)
+#define V4L2_EVENT_IMX_FRAME_INTERVAL (V4L2_EVENT_IMX_CLASS + 2)

These events are still i.MX specific. I think they shouldn't be.

include/uapi/media/imx.h line 29

Quoted 10 lines
include/uapi/media/imx.h new file +10 -0
+enum imx_ctrl_id {
+	V4L2_CID_IMX_MOTION = (V4L2_CID_USER_IMX_BASE + 0),
+	V4L2_CID_IMX_FIM_ENABLE,
+	V4L2_CID_IMX_FIM_NUM,
+	V4L2_CID_IMX_FIM_TOLERANCE_MIN,
+	V4L2_CID_IMX_FIM_TOLERANCE_MAX,
+	V4L2_CID_IMX_FIM_NUM_SKIP,
+};
+
+#endif

regards
Philipp

author maintainer
#130 lore raw

Re: [PATCH v4 17/36] media: Add userspace header file for i.MX

Quoted 10 lines · Philipp Zabel

include/uapi/media/imx.h line 18

Quoted 7 lines · Steve Longerbeam
include/uapi/media/imx.h new file +6 -0
+/*
+ * events from the subdevs
+ */
+#define V4L2_EVENT_IMX_CLASS          V4L2_EVENT_PRIVATE_START
+#define V4L2_EVENT_IMX_NFB4EOF        (V4L2_EVENT_IMX_CLASS + 1)
+#define V4L2_EVENT_IMX_FRAME_INTERVAL (V4L2_EVENT_IMX_CLASS + 2)

These events are still i.MX specific. I think they shouldn't be.

Done, I've exported them to

V4L2_EVENT_FRAME_INTERVAL_ERROR
V4L2_EVENT_NEW_FRAME_BEFORE_EOF

Steve

author maintainer
#131 lore raw

PATCH v4 18/36 media: Add i.MX media core driver

In reply to Steve Longerbeam

Add the core media driver for i.MX SOC.

---
 Documentation/media/v4l-drivers/imx.rst           | 542 +++++++++++++++++
 drivers/staging/media/Kconfig                     |   2 +
 drivers/staging/media/Makefile                    |   1 +
 drivers/staging/media/imx/Kconfig                 |   7 +
 drivers/staging/media/imx/Makefile                |   6 +
 drivers/staging/media/imx/TODO                    |  36 ++
 drivers/staging/media/imx/imx-media-dev.c         | 487 +++++++++++++++
 drivers/staging/media/imx/imx-media-fim.c         | 471 +++++++++++++++
 drivers/staging/media/imx/imx-media-internal-sd.c | 349 +++++++++++
 drivers/staging/media/imx/imx-media-of.c          | 267 ++++++++
 drivers/staging/media/imx/imx-media-utils.c       | 701 ++++++++++++++++++++++
 drivers/staging/media/imx/imx-media.h             | 297 +++++++++
 include/media/imx.h                               |  15 +
 include/uapi/linux/v4l2-controls.h                |   4 +
 14 files changed, 3185 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx.rst
 create mode 100644 drivers/staging/media/imx/Kconfig
 create mode 100644 drivers/staging/media/imx/Makefile
 create mode 100644 drivers/staging/media/imx/TODO
 create mode 100644 drivers/staging/media/imx/imx-media-dev.c
 create mode 100644 drivers/staging/media/imx/imx-media-fim.c
 create mode 100644 drivers/staging/media/imx/imx-media-internal-sd.c
 create mode 100644 drivers/staging/media/imx/imx-media-of.c
 create mode 100644 drivers/staging/media/imx/imx-media-utils.c
 create mode 100644 drivers/staging/media/imx/imx-media.h
 create mode 100644 include/media/imx.h
Documentation/media/v4l-drivers/imx.rst new file +542 -0
new file mode 100644
index 0000000..f085e43
@@ -0,0 +1,542 @@
+i.MX Video Capture Driver
+=========================
+
+Introduction
+------------
+
+The Freescale i.MX5/6 contains an Image Processing Unit (IPU), which
+handles the flow of image frames to and from capture devices and
+display devices.
+
+For image capture, the IPU contains the following internal subunits:
+
+- Image DMA Controller (IDMAC)
+- Camera Serial Interface (CSI)
+- Image Converter (IC)
+- Sensor Multi-FIFO Controller (SMFC)
+- Image Rotator (IRT)
+- Video De-Interlacing or Combining Block (VDIC)
+
+The IDMAC is the DMA controller for transfer of image frames to and from
+memory. Various dedicated DMA channels exist for both video capture and
+display paths. During transfer, the IDMAC is also capable of vertical
+image flip, 8x8 block transfer (see IRT description), pixel component
+re-ordering (for example UYVY to YUYV) within the same colorspace, and
+even packed <--> planar conversion. It can also perform a simple
+de-interlacing by interleaving even and odd lines during transfer
+(without motion compensation which requires the VDIC).
+
+The CSI is the backend capture unit that interfaces directly with
+camera sensors over Parallel, BT.656/1120, and MIPI CSI-2 busses.
+
+The IC handles color-space conversion, resizing (downscaling and
+upscaling), horizontal flip, and 90/270 degree rotation operations.
+
+There are three independent "tasks" within the IC that can carry out
+conversions concurrently: pre-process encoding, pre-process viewfinder,
+and post-processing. Within each task, conversions are split into three
+sections: downsizing section, main section (upsizing, flip, colorspace
+conversion, and graphics plane combining), and rotation section.
+
+The IPU time-shares the IC task operations. The time-slice granularity
+is one burst of eight pixels in the downsizing section, one image line
+in the main processing section, one image frame in the rotation section.
+
+The SMFC is composed of four independent FIFOs that each can transfer
+captured frames from sensors directly to memory concurrently via four
+IDMAC channels.
+
+The IRT carries out 90 and 270 degree image rotation operations. The
+rotation operation is carried out on 8x8 pixel blocks at a time. This
+operation is supported by the IDMAC which handles the 8x8 block transfer
+along with block reordering, in coordination with vertical flip.
+
+The VDIC handles the conversion of interlaced video to progressive, with
+support for different motion compensation modes (low, medium, and high
+motion). The deinterlaced output frames from the VDIC can be sent to the
+IC pre-process viewfinder task for further conversions. The VDIC also
+contains a Combiner that combines two image planes, with alpha blending
+and color keying.
+
+In addition to the IPU internal subunits, there are also two units
+outside the IPU that are also involved in video capture on i.MX:
+
+- MIPI CSI-2 Receiver for camera sensors with the MIPI CSI-2 bus
+  interface. This is a Synopsys DesignWare core.
+- Two video multiplexers for selecting among multiple sensor inputs
+  to send to a CSI.
+
+For more info, refer to the latest versions of the i.MX5/6 reference
+manuals listed under References.
+
+
+Features
+--------
+
+Some of the features of this driver include:
+
+- Many different pipelines can be configured via media controller API,
+  that correspond to the hardware video capture pipelines supported in
+  the i.MX.
+
+- Supports parallel, BT.565, and MIPI CSI-2 interfaces.
+
+- Up to four concurrent sensor acquisitions, by configuring each
+  sensor's pipeline using independent entities. This is currently
+  demonstrated with the SabreSD and SabreLite reference boards with
+  independent OV5642 and MIPI CSI-2 OV5640 sensor modules.
+
+- Scaling, color-space conversion, horizontal and vertical flip, and
+  image rotation via IC task subdevs.
+
+- Many pixel formats supported (RGB, packed and planar YUV, partial
+  planar YUV).
+
+- The VDIC subdev supports motion compensated de-interlacing, with three
+  motion compensation modes: low, medium, and high motion. The mode is
+  specified with a custom control. Pipelines are defined that allow
+  sending frames to the VDIC subdev directly from the CSI or from
+  memory buffers via an output/mem2mem device node. For low and medium
+  motion modes, the VDIC must receive from memory buffers via a device
+  node.
+
+- Includes a Frame Interval Monitor (FIM) that can correct vertical sync
+  problems with the ADV718x video decoders. See below for a description
+  of the FIM.
+
+
+Entities
+--------
+
+imx6-mipi-csi2
+--------------
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to receive
+the MIPI CSI-2 stream (usually from a MIPI CSI-2 camera sensor). It has
+four source pads, corresponding to the four MIPI CSI-2 demuxed virtual
+channel outputs.
+
+This entity actually consists of two sub-blocks. One is the MIPI CSI-2
+core. This is a Synopsys Designware MIPI CSI-2 core. The other sub-block
+is a "CSI-2 to IPU gasket". The gasket acts as a demultiplexer of the
+four virtual channels streams, providing four separate parallel buses
+containing each virtual channel that are routed to CSIs or video
+multiplexers as described below.
+
+On i.MX6 solo/dual-lite, all four virtual channel buses are routed to
+two video multiplexers. Both CSI0 and CSI1 can receive any virtual
+channel, as selected by the video multiplexers.
+
+On i.MX6 Quad, virtual channel 0 is routed to IPU1-CSI0 (after selected
+by a video mux), virtual channels 1 and 2 are hard-wired to IPU1-CSI1
+and IPU2-CSI0, respectively, and virtual channel 3 is routed to
+IPU2-CSI1 (again selected by a video mux).
+
+ipuX_csiY_mux
+-------------
+
+These are the video multiplexers. They have two or more sink pads to
+select from either camera sensors with a parallel interface, or from
+MIPI CSI-2 virtual channels from imx6-mipi-csi2 entity. They have a
+single source pad that routes to a CSI (ipuX_csiY entities).
+
+On i.MX6 solo/dual-lite, there are two video mux entities. One sits
+in front of IPU1-CSI0 to select between a parallel sensor and any of
+the four MIPI CSI-2 virtual channels (a total of five sink pads). The
+other mux sits in front of IPU1-CSI1, and again has five sink pads to
+select between a parallel sensor and any of the four MIPI CSI-2 virtual
+channels.
+
+On i.MX6 Quad, there are two video mux entities. One sits in front of
+IPU1-CSI0 to select between a parallel sensor and MIPI CSI-2 virtual
+channel 0 (two sink pads). The other mux sits in front of IPU2-CSI1 to
+select between a parallel sensor and MIPI CSI-2 virtual channel 3 (two
+sink pads).
+
+ipuX_csiY
+---------
+
+These are the CSI entities. They have a single sink pad receiving from
+either a video mux or from a MIPI CSI-2 virtual channel as described
+above.
+
+This entity has two source pads. The first source pad can link directly
+to the ipuX_vdic entity or the ipuX_ic_prp entity, using hardware links
+that require no IDMAC memory buffer transfer.
+
+When the direct source pad is routed to the ipuX_ic_prp entity, frames
+from the CSI will be processed by one of the IC pre-processing tasks.
+
+When the direct source pad is routed to the ipuX_vdic entity, the VDIC
+will carry out motion-compensated de-interlace using "high motion" mode
+(see description of ipuX_vdic entity).
+
+The second source pad sends video frames to memory buffers via the SMFC
+and an IDMAC channel. This source pad is routed to a capture device
+node.
+
+Note that since the IDMAC source pad makes use of an IDMAC channel, it
+can do pixel reordering within the same colorspace. For example, the
+sink pad can take UYVY2X8, but the IDMAC source pad can output YUYV2X8.
+If the sink pad is receiving YUV, the output at the capture device can
+also be converted to a planar YUV format such as YUV420.
+
+It will also perform simple de-interlace without motion compensation,
+which is activated if the sink pad's field type is an interlaced type,
+and the IDMAC source pad field type is set to none.
+
+ipuX_vdic
+---------
+
+The VDIC carries out motion compensated de-interlacing, with three
+motion compensation modes: low, medium, and high motion. The mode is
+specified with a custom v4l2 control. It has two sink pads and a
+single source pad.
+
+The direct sink pad receives from an ipuX_csiY direct pad. With this
+link the VDIC can only operate in high motion mode.
+
+When the IDMAC sink pad is activated, it receives from an output
+or mem2mem device node. With this pipeline, it can also operate
+in low and medium modes, because these modes require receiving
+frames from memory buffers. Note that an output or mem2mem device
+is not implemented yet, so this sink pad currently has no links.
+
+The source pad routes to the IC pre-processing entity ipuX_ic_prp.
+
+ipuX_ic_prp
+-----------
+
+This is the IC pre-processing entity. It acts as a router, routing
+data from its sink pad to one or both of its source pads.
+
+It has a single sink pad. The sink pad can receive from the ipuX_csiY
+direct pad, or from ipuX_vdic.
+
+This entity has two source pads. One source pad routes to the
+pre-process encode task entity (ipuX_ic_prpenc), the other to the
+pre-process viewfinder task entity (ipuX_ic_prpvf). Both source pads
+can be activated at the same time if the sink pad is receiving from
+ipuX_csiY. Only the source pad to the pre-process viewfinder task entity
+can be activated if the sink pad is receiving from ipuX_vdic (frames
+from the VDIC can only be processed by the pre-process viewfinder task).
+
+ipuX_ic_prpenc
+--------------
+
+This is the IC pre-processing encode entity. It has a single sink pad
+from ipuX_ic_prp, and a single source pad. The source pad is routed
+to a capture device node.
+
+This entity performs the IC pre-process encode task operations:
+color-space conversion, resizing (downscaling and upscaling), horizontal
+and vertical flip, and 90/270 degree rotation.
+
+Like the ipuX_csiY IDMAC source, it can also perform simple de-interlace
+without motion compensation, and pixel reordering.
+
+ipuX_ic_prpvf
+-------------
+
+This is the IC pre-processing viewfinder entity. It has a single sink pad
+from ipuX_ic_prp, and a single source pad. The source pad is routed to
+a capture device node.
+
+It is identical in operation to ipuX_ic_prpenc. It will receive and
+process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is
+receiving from ipuX_vdic.
+
+Like the ipuX_csiY IDMAC source, it can perform simple de-interlace
+without motion compensation. However, note that if the ipuX_vdic is
+included in the pipeline (ipuX_ic_prp is receiving from ipuX_vdic),
+it's not possible to use simple de-interlace in ipuX_ic_prpvf, since
+the ipuX_vdic has already carried out de-interlacing (with motion
+compensation) and therefore the field type output from ipuX_ic_prp can
+only be none.
+
+Capture Pipelines
+-----------------
+
+The following describe the various use-cases supported by the pipelines.
+
+The links shown do not include the backend sensor, video mux, or mipi
+csi-2 receiver links. This depends on the type of sensor interface
+(parallel or mipi csi-2). So in all cases, these pipelines begin with:
+
+sensor -> ipuX_csiY_mux -> ...
+
+for parallel sensors, or:
+
+sensor -> imx6-mipi-csi2 -> (ipuX_csiY_mux) -> ...
+
+for mipi csi-2 sensors. The imx6-mipi-csi2 receiver may need to route
+to the video mux (ipuX_csiY_mux) before sending to the CSI, depending
+on the mipi csi-2 virtual channel, hence ipuX_csiY_mux is shown in
+parenthesis.
+
+Unprocessed Video Capture:
+--------------------------
+
+Send frames directly from sensor to camera device interface node, with
+no conversions:
+
+-> ipuX_csiY IDMAC pad -> capture node
+
+IC Direct Conversions:
+----------------------
+
+This pipeline uses the preprocess encode entity to route frames directly
+from the CSI to the IC, to carry out scaling up to 1024x1024 resolution,
+CSC, flipping, and image rotation:
+
+-> ipuX_csiY direct pad -> ipuX_ic_prp -> ipuX_ic_prpenc -> capture node
+
+Motion Compensated De-interlace:
+--------------------------------
+
+This pipeline routes frames from the CSI direct pad to the VDIC entity to
+support motion-compensated de-interlacing (high motion mode only),
+scaling up to 1024x1024, CSC, flip, and rotation:
+
+-> ipuX_csiY direct pad -> ipuX_vdic direct pad -> ipuX_ic_prp ->
+   ipuX_ic_prpvf -> capture node
+
+
+Usage Notes
+-----------
+
+Many of the subdevs require information from the active sensor in the
+current pipeline when configuring pad formats. Therefore the media links
+should be established before configuring the media pad formats.
+
+Similarly, the capture device interfaces inherit controls from the
+active entities in the current pipeline at link-setup time. Therefore
+the capture device node links should be the last links established in
+order for the capture interfaces to "see" and inherit all possible
+controls.
+
+The following are usage notes for Sabre- reference platforms:
+
+
+SabreLite with OV5642 and OV5640
+--------------------------------
+
+This platform requires the OmniVision OV5642 module with a parallel
+camera interface, and the OV5640 module with a MIPI CSI-2
+interface. Both modules are available from Boundary Devices:
+
+https://boundarydevices.com/products/nit6x_5mp
+https://boundarydevices.com/product/nit6x_5mp_mipi
+
+Note that if only one camera module is available, the other sensor
+node can be disabled in the device tree.
+
+The OV5642 module is connected to the parallel bus input on the i.MX
+internal video mux to IPU1 CSI0. It's i2c bus connects to i2c bus 2.
+
+The MIPI CSI-2 OV5640 module is connected to the i.MX internal MIPI CSI-2
+receiver, and the four virtual channel outputs from the receiver are
+routed as follows: vc0 to the IPU1 CSI0 mux, vc1 directly to IPU1 CSI1,
+vc2 directly to IPU2 CSI0, and vc3 to the IPU2 CSI1 mux. The OV5640 is
+also connected to i2c bus 2 on the SabreLite, therefore the OV5642 and
+OV5640 must not share the same i2c slave address.
+
+The following basic example configures unprocessed video capture
+pipelines for both sensors. The OV5642 is routed to ipu1_csi0, and
+the OV5640 (transmitting on mipi csi-2 virtual channel 1) is routed
+to ipu1_csi1. Both sensors are configured to output 640x480, the
+OV5642 outputs YUYV2X8, the OV5640 UYVY2X8:
+
+.. code-block:: none
+
+   # Setup links for OV5642
+   media-ctl -l '"ov5642 1-0042":0 -> "ipu1_csi0_mux":1[1]'
+   media-ctl -l '"ipu1_csi0_mux":2 -> "ipu1_csi0":0[1]'
+   media-ctl -l '"ipu1_csi0":2 -> "ipu1_csi0 capture":0[1]'
+   # Setup links for OV5640
+   media-ctl -l '"ov5640_mipi 1-0040":0 -> "imx6-mipi-csi2":0[1]'
+   media-ctl -l '"imx6-mipi-csi2":2 -> "ipu1_csi1":0[1]'
+   media-ctl -l '"ipu1_csi1":2 -> "ipu1_csi1 capture":0[1]'
+   # Configure pads for OV5642 pipeline
+   media-ctl -V "\"ov5642 1-0042\":0 [fmt:YUYV2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi0_mux\":2 [fmt:YUYV2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi0\":2 [fmt:YUYV2X8/640x480 field:none]"
+   # Configure pads for OV5640 pipeline
+   media-ctl -V "\"ov5640_mipi 1-0040\":0 [fmt:UYVY2X8/640x480 field:none]"
+   media-ctl -V "\"imx6-mipi-csi2\":2 [fmt:UYVY2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi1\":2 [fmt:UYVY2X8/640x480 field:none]"
+
+Streaming can then begin independently on the capture device nodes
+"ipu1_csi0 capture" and "ipu1_csi1 capture".
+
+SabreAuto with ADV7180 decoder
+------------------------------
+
+On the SabreAuto, an on-board ADV7180 SD decoder is connected to the
+parallel bus input on the internal video mux to IPU1 CSI0.
+
+The following example configures a pipeline to capture from the ADV7180
+video decoder, assuming NTSC 720x480 input signals, with Motion
+Compensated de-interlacing. Pad field types assume the adv7180 outputs
+"alternate", which the ipu1_csi0 entity converts to "seq-tb" at its
+source pad. $outputfmt can be any format supported by the ipu1_ic_prpvf
+entity at its output pad:
+
+.. code-block:: none
+
+   # Setup links
+   media-ctl -l '"adv7180 4-0021":0 -> "ipu1_csi0_mux":1[1]'
+   media-ctl -l '"ipu1_csi0_mux":2 -> "ipu1_csi0":0[1]'
+   media-ctl -l '"ipu1_csi0":2 -> "ipu1_vdic":0[1]'
+   media-ctl -l '"ipu1_vdic":2 -> "ipu1_ic_prp":0[1]'
+   media-ctl -l '"ipu1_ic_prp":2 -> "ipu1_ic_prpvf":0[1]'
+   media-ctl -l '"ipu1_ic_prpvf":1 -> "ipu1_ic_prpvf capture":0[1]'
+   # Configure pads
+   media-ctl -V "\"adv7180 4-0021\":0 [fmt:UYVY2X8/720x480]"
+   media-ctl -V "\"ipu1_csi0_mux\":2 [fmt:UYVY2X8/720x480 field:alternate]"
+   media-ctl -V "\"ipu1_csi0\":1 [fmt:AYUV32/720x480 field:seq-tb]"
+   media-ctl -V "\"ipu1_vdic\":2 [fmt:AYUV32/720x480 field:none]"
+   media-ctl -V "\"ipu1_ic_prp\":2 [fmt:AYUV32/720x480 field:none]"
+   media-ctl -V "\"ipu1_ic_prpvf\":1 [fmt:$outputfmt field:none]"
+
+Streaming can then begin on the capture device node at
+"ipu1_ic_prpvf capture".
+
+This platform accepts Composite Video analog inputs to the ADV7180 on
+Ain1 (connector J42).
+
+Frame Interval Monitor
+----------------------
+
+The adv718x decoders can occasionally send corrupt fields during
+NTSC/PAL signal re-sync (too little or too many video lines). When
+this happens, the IPU triggers a mechanism to re-establish vertical
+sync by adding 1 dummy line every frame, which causes a rolling effect
+from image to image, and can last a long time before a stable image is
+recovered. Or sometimes the mechanism doesn't work at all, causing a
+permanent split image (one frame contains lines from two consecutive
+captured images).
+
+From experiment it was found that during image rolling, the frame
+intervals (elapsed time between two EOF's) drop below the nominal
+value for the current standard, by about one frame time (60 usec),
+and remain at that value until rolling stops.
+
+While the reason for this observation isn't known (the IPU dummy
+line mechanism should show an increase in the intervals by 1 line
+time every frame, not a fixed value), we can use it to detect the
+corrupt fields using a frame interval monitor. If the FIM detects a
+bad frame interval, a subdev event is sent. In response, userland can
+issue a streaming restart to correct the rolling/split image.
+
+The FIM is implemented in the ipuX_csiY entity, and the entities that
+generate End-Of-Frame interrupts call into the FIM to monitor the frame
+intervals: ipuX_ic_prpenc, and ipuX_ic_prpvf. Userland can register with
+the FIM event notifications on the ipuX_csiY subdev device node
+(V4L2_EVENT_IMX_FRAME_INTERVAL).
+
+The ipuX_csiY entity includes custom controls to tweak some dials for
+FIM. If one of these controls is changed during streaming, the FIM will
+be reset and will continue at the new settings.
+
+- V4L2_CID_IMX_FIM_ENABLE
+
+Enable/disable the FIM.
+
+- V4L2_CID_IMX_FIM_NUM
+
+How many frame interval errors to average before comparing against the
+nominal frame interval reported by the sensor. This can reduce noise
+from interrupt latency.
+
+- V4L2_CID_IMX_FIM_TOLERANCE_MIN
+
+If the averaged intervals fall outside nominal by this amount, in
+microseconds, streaming will be restarted.
+
+- V4L2_CID_IMX_FIM_TOLERANCE_MAX
+
+If any interval errors are higher than this value, those error samples
+are discarded and do not enter into the average. This can be used to
+discard really high interval errors that might be due to very high
+system load, causing excessive interrupt latencies.
+
+- V4L2_CID_IMX_FIM_NUM_SKIP
+
+How many frames to skip after a FIM reset or stream restart before
+FIM begins to average intervals. It has been found that there can
+be a few bad frame intervals after stream restart which are not
+attributed to adv718x sending a corrupt field, so this is used to
+skip those frames to prevent unnecessary restarts.
+
+
+SabreSD with MIPI CSI-2 OV5640
+------------------------------
+
+Similarly to SabreLite, the SabreSD supports a parallel interface
+OV5642 module on IPU1 CSI0, and a MIPI CSI-2 OV5640 module. The OV5642
+connects to i2c bus 1 and the OV5640 to i2c bus 2.
+
+The device tree for SabreSD includes OF graphs for both the parallel
+OV5642 and the MIPI CSI-2 OV5640, but as of this writing only the MIPI
+CSI-2 OV5640 has been tested, so the OV5642 node is currently disabled.
+The OV5640 module connects to MIPI connector J5 (sorry I don't have the
+compatible module part number or URL).
+
+The following example configures a direct conversion pipeline to capture
+from the OV5640. $sensorfmt can be any format supported by the OV5640.
+$sensordim is the frame dimension part of $sensorfmt (minus the mbus
+pixel code). $outputfmt can be any format supported by the
+ipu1_ic_prpenc entity at its output pad:
+
+.. code-block:: none
+
+   # Setup links
+   media-ctl -l '"ov5640_mipi 1-003c":0 -> "imx6-mipi-csi2":0[1]'
+   media-ctl -l '"imx6-mipi-csi2":2 -> "ipu1_csi1":0[1]'
+   media-ctl -l '"ipu1_csi1":1 -> "ipu1_ic_prp":0[1]'
+   media-ctl -l '"ipu1_ic_prp":1 -> "ipu1_ic_prpenc":0[1]'
+   media-ctl -l '"ipu1_ic_prpenc":1 -> "ipu1_ic_prpenc capture":0[1]'
+   # Configure pads
+   media-ctl -V "\"ov5640_mipi 1-003c\":0 [fmt:$sensorfmt field:none]"
+   media-ctl -V "\"imx6-mipi-csi2\":2 [fmt:$sensorfmt field:none]"
+   media-ctl -V "\"ipu1_csi1\":1 [fmt:AYUV32/$sensordim field:none]"
+   media-ctl -V "\"ipu1_ic_prp\":1 [fmt:AYUV32/$sensordim field:none]"
+   media-ctl -V "\"ipu1_ic_prpenc\":1 [fmt:$outputfmt field:none]"
+
+Streaming can then begin on "ipu1_ic_prpenc capture" node.
+
+
+
+Known Issues
+------------
+
+1. When using 90 or 270 degree rotation control at capture resolutions
+   near the IC resizer limit of 1024x1024, and combined with planar
+   pixel formats (YUV420, YUV422p), frame capture will often fail with
+   no end-of-frame interrupts from the IDMAC channel. To work around
+   this, use lower resolution and/or packed formats (YUYV, RGB3, etc.)
+   when 90 or 270 rotations are needed.
+
+
+File list
+---------
+
+drivers/staging/media/imx/
+include/media/imx.h
+include/uapi/media/imx.h
+
+References
+----------
+
+[1] "i.MX 6Dual/6Quad Applications Processor Reference Manual"
+[2] "i.MX 6Solo/6DualLite Applications Processor Reference Manual"
+
+
+Authors
+-------
+Steve Longerbeam <[email protected]>
+Philipp Zabel <[email protected]>
+Russell King - ARM Linux <[email protected]>
+
+Copyright (C) 2012-2017 Mentor Graphics Inc.
drivers/staging/media/Kconfig +2 -0
index ffb8fa7..05b55a8 100644
@@ -25,6 +25,8 @@ source "drivers/staging/media/cxd2099/Kconfig"
 
 source "drivers/staging/media/davinci_vpfe/Kconfig"
 
+source "drivers/staging/media/imx/Kconfig"
+
 source "drivers/staging/media/omap4iss/Kconfig"
 
 source "drivers/staging/media/s5p-cec/Kconfig"
drivers/staging/media/Makefile +1 -0
index a28e82c..6f50ddd 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_I2C_BCM2048)	+= bcm2048/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/
 obj-$(CONFIG_DVB_CXD2099)	+= cxd2099/
+obj-$(CONFIG_VIDEO_IMX_MEDIA)	+= imx/
 obj-$(CONFIG_LIRC_STAGING)	+= lirc/
 obj-$(CONFIG_VIDEO_DM365_VPFE)	+= davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)	+= omap4iss/
drivers/staging/media/imx/Kconfig new file +7 -0
new file mode 100644
index 0000000..722ed55
@@ -0,0 +1,7 @@
+config VIDEO_IMX_MEDIA
+	tristate "i.MX5/6 V4L2 media core driver"
+	depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
+	---help---
+	  Say yes here to enable support for video4linux media controller
+	  driver for the i.MX5/6 SOC.
+
drivers/staging/media/imx/Makefile new file +6 -0
new file mode 100644
index 0000000..ba8e4fb
@@ -0,0 +1,6 @@
+imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
+imx-media-common-objs := imx-media-utils.o imx-media-fim.o
+
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
+
drivers/staging/media/imx/TODO new file +36 -0
new file mode 100644
index 0000000..f6d2bac
@@ -0,0 +1,36 @@
+
+- Finish v4l2-compliance
+
+- imx-csi subdev is not being autoloaded as a kernel module, probably
+  because ipu_add_client_devices() does not register the IPU client
+  platform devices, but only allocates those devices.
+
+- Currently registering with notifications from subdevs are only
+  available through the subdev device nodes and not through the main
+  capture device node. Need to come up with a way to find the capture
+  device in the current pipeline that owns the subdev that sent the
+  notify.
+
+- Clean up and move the ov5642 subdev driver to drivers/media/i2c, and
+  create the binding docs for it.
+
+- The Frame Interval Monitor could be exported to v4l2-core for
+  general use.
+
+- The subdev that is the original source of video data (referred to as
+  the "sensor" in the code), is called from various subdevs in the
+  pipeline in order to set/query the video standard ({g|s|enum}_std)
+  and to get/set the original frame interval from the capture interface
+  ([gs]_parm). Instead, the entities that need this info should call its
+  direct neighbor, and the neighbor should propagate the call to its
+  neighbor in turn if necessary.
+
+- At driver load time, the device-tree node that is the original source
+  (the "sensor"), is parsed to record its media bus configuration, and
+  this info is required in various subdevs to setup the pipeline.
+  Laurent Pinchart argues that instead the subdev should call its
+  neighbor's g_mbus_config op (which should be propagated if necessary)
+  to get this info. However Hans Verkuil is planning to remove the
+  g_mbus_config op. For now this driver uses the parsed DT mbus config
+  method until this issue is resolved.
+
drivers/staging/media/imx/imx-media-dev.c new file +487 -0

487 lines not on this page · raw message

drivers/staging/media/imx/imx-media-fim.c new file +471 -0

471 lines not on this page · raw message

drivers/staging/media/imx/imx-media-internal-sd.c new file +349 -0

349 lines not on this page · raw message

drivers/staging/media/imx/imx-media-of.c new file +267 -0

267 lines not on this page · raw message

drivers/staging/media/imx/imx-media-utils.c new file +701 -0

701 lines not on this page · raw message

drivers/staging/media/imx/imx-media.h new file +297 -0

119 lines not on this page · raw message

include/media/imx.h new file +15 -0
new file mode 100644
index 0000000..5025a72

Lines of this file are not shown. View the raw message.

include/uapi/linux/v4l2-controls.h +4 -0
index 0d2e1e0..6c29f42 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.7.4

Part of the diff is not shown here. View the raw message.

#132 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

Quoted 3 lines · Steve Longerbeam

Add the core media driver for i.MX SOC.

Just as I reported on the 30th January:

Applying: media: Add i.MX media core driver .git/rebase-apply/patch:614: new blank line at EOF. +
.git/rebase-apply/patch:626: new blank line at EOF. +
.git/rebase-apply/patch:668: new blank line at EOF. +

These need fixing.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#133 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

Quoted 14 lines · Russell King - ARM Linux
Quoted 3 lines · Steve Longerbeam

Add the core media driver for i.MX SOC.

Just as I reported on the 30th January:

Applying: media: Add i.MX media core driver .git/rebase-apply/patch:614: new blank line at EOF. +
.git/rebase-apply/patch:626: new blank line at EOF. +
.git/rebase-apply/patch:668: new blank line at EOF. +

Quoted 1 line

These need fixing.

Missed these obviously, fixed.

Steve

maintainer
#134 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

In reply to Steve Longerbeam
Quoted 635 lines · Steve Longerbeam

Add the core media driver for i.MX SOC.

---
 Documentation/media/v4l-drivers/imx.rst           | 542 +++++++++++++++++
 drivers/staging/media/Kconfig                     |   2 +
 drivers/staging/media/Makefile                    |   1 +
 drivers/staging/media/imx/Kconfig                 |   7 +
 drivers/staging/media/imx/Makefile                |   6 +
 drivers/staging/media/imx/TODO                    |  36 ++
 drivers/staging/media/imx/imx-media-dev.c         | 487 +++++++++++++++
 drivers/staging/media/imx/imx-media-fim.c         | 471 +++++++++++++++
 drivers/staging/media/imx/imx-media-internal-sd.c | 349 +++++++++++
 drivers/staging/media/imx/imx-media-of.c          | 267 ++++++++
 drivers/staging/media/imx/imx-media-utils.c       | 701 ++++++++++++++++++++++
 drivers/staging/media/imx/imx-media.h             | 297 +++++++++
 include/media/imx.h                               |  15 +
 include/uapi/linux/v4l2-controls.h                |   4 +
 14 files changed, 3185 insertions(+)
 create mode 100644 Documentation/media/v4l-drivers/imx.rst
 create mode 100644 drivers/staging/media/imx/Kconfig
 create mode 100644 drivers/staging/media/imx/Makefile
 create mode 100644 drivers/staging/media/imx/TODO
 create mode 100644 drivers/staging/media/imx/imx-media-dev.c
 create mode 100644 drivers/staging/media/imx/imx-media-fim.c
 create mode 100644 drivers/staging/media/imx/imx-media-internal-sd.c
 create mode 100644 drivers/staging/media/imx/imx-media-of.c
 create mode 100644 drivers/staging/media/imx/imx-media-utils.c
 create mode 100644 drivers/staging/media/imx/imx-media.h
 create mode 100644 include/media/imx.h
Documentation/media/v4l-drivers/imx.rst new file +542 -0
new file mode 100644
index 0000000..f085e43
@@ -0,0 +1,542 @@
+i.MX Video Capture Driver
+=========================
+
+Introduction
+------------
+
+The Freescale i.MX5/6 contains an Image Processing Unit (IPU), which
+handles the flow of image frames to and from capture devices and
+display devices.
+
+For image capture, the IPU contains the following internal subunits:
+
+- Image DMA Controller (IDMAC)
+- Camera Serial Interface (CSI)
+- Image Converter (IC)
+- Sensor Multi-FIFO Controller (SMFC)
+- Image Rotator (IRT)
+- Video De-Interlacing or Combining Block (VDIC)
+
+The IDMAC is the DMA controller for transfer of image frames to and from
+memory. Various dedicated DMA channels exist for both video capture and
+display paths. During transfer, the IDMAC is also capable of vertical
+image flip, 8x8 block transfer (see IRT description), pixel component
+re-ordering (for example UYVY to YUYV) within the same colorspace, and
+even packed <--> planar conversion. It can also perform a simple
+de-interlacing by interleaving even and odd lines during transfer
+(without motion compensation which requires the VDIC).
+
+The CSI is the backend capture unit that interfaces directly with
+camera sensors over Parallel, BT.656/1120, and MIPI CSI-2 busses.
+
+The IC handles color-space conversion, resizing (downscaling and
+upscaling), horizontal flip, and 90/270 degree rotation operations.
+
+There are three independent "tasks" within the IC that can carry out
+conversions concurrently: pre-process encoding, pre-process viewfinder,
+and post-processing. Within each task, conversions are split into three
+sections: downsizing section, main section (upsizing, flip, colorspace
+conversion, and graphics plane combining), and rotation section.
+
+The IPU time-shares the IC task operations. The time-slice granularity
+is one burst of eight pixels in the downsizing section, one image line
+in the main processing section, one image frame in the rotation section.
+
+The SMFC is composed of four independent FIFOs that each can transfer
+captured frames from sensors directly to memory concurrently via four
+IDMAC channels.
+
+The IRT carries out 90 and 270 degree image rotation operations. The
+rotation operation is carried out on 8x8 pixel blocks at a time. This
+operation is supported by the IDMAC which handles the 8x8 block transfer
+along with block reordering, in coordination with vertical flip.
+
+The VDIC handles the conversion of interlaced video to progressive, with
+support for different motion compensation modes (low, medium, and high
+motion). The deinterlaced output frames from the VDIC can be sent to the
+IC pre-process viewfinder task for further conversions. The VDIC also
+contains a Combiner that combines two image planes, with alpha blending
+and color keying.
+
+In addition to the IPU internal subunits, there are also two units
+outside the IPU that are also involved in video capture on i.MX:
+
+- MIPI CSI-2 Receiver for camera sensors with the MIPI CSI-2 bus
+  interface. This is a Synopsys DesignWare core.
+- Two video multiplexers for selecting among multiple sensor inputs
+  to send to a CSI.
+
+For more info, refer to the latest versions of the i.MX5/6 reference
+manuals listed under References.
+
+
+Features
+--------
+
+Some of the features of this driver include:
+
+- Many different pipelines can be configured via media controller API,
+  that correspond to the hardware video capture pipelines supported in
+  the i.MX.
+
+- Supports parallel, BT.565, and MIPI CSI-2 interfaces.
+
+- Up to four concurrent sensor acquisitions, by configuring each
+  sensor's pipeline using independent entities. This is currently
+  demonstrated with the SabreSD and SabreLite reference boards with
+  independent OV5642 and MIPI CSI-2 OV5640 sensor modules.
+
+- Scaling, color-space conversion, horizontal and vertical flip, and
+  image rotation via IC task subdevs.
+
+- Many pixel formats supported (RGB, packed and planar YUV, partial
+  planar YUV).
+
+- The VDIC subdev supports motion compensated de-interlacing, with three
+  motion compensation modes: low, medium, and high motion. The mode is
+  specified with a custom control. Pipelines are defined that allow
+  sending frames to the VDIC subdev directly from the CSI or from
+  memory buffers via an output/mem2mem device node. For low and medium
+  motion modes, the VDIC must receive from memory buffers via a device
+  node.
+
+- Includes a Frame Interval Monitor (FIM) that can correct vertical sync
+  problems with the ADV718x video decoders. See below for a description
+  of the FIM.
+
+
+Entities
+--------
+
+imx6-mipi-csi2
+--------------
+
+This is the MIPI CSI-2 receiver entity. It has one sink pad to receive
+the MIPI CSI-2 stream (usually from a MIPI CSI-2 camera sensor). It has
+four source pads, corresponding to the four MIPI CSI-2 demuxed virtual
+channel outputs.
+
+This entity actually consists of two sub-blocks. One is the MIPI CSI-2
+core. This is a Synopsys Designware MIPI CSI-2 core. The other sub-block
+is a "CSI-2 to IPU gasket". The gasket acts as a demultiplexer of the
+four virtual channels streams, providing four separate parallel buses
+containing each virtual channel that are routed to CSIs or video
+multiplexers as described below.
+
+On i.MX6 solo/dual-lite, all four virtual channel buses are routed to
+two video multiplexers. Both CSI0 and CSI1 can receive any virtual
+channel, as selected by the video multiplexers.
+
+On i.MX6 Quad, virtual channel 0 is routed to IPU1-CSI0 (after selected
+by a video mux), virtual channels 1 and 2 are hard-wired to IPU1-CSI1
+and IPU2-CSI0, respectively, and virtual channel 3 is routed to
+IPU2-CSI1 (again selected by a video mux).
+
+ipuX_csiY_mux
+-------------
+
+These are the video multiplexers. They have two or more sink pads to
+select from either camera sensors with a parallel interface, or from
+MIPI CSI-2 virtual channels from imx6-mipi-csi2 entity. They have a
+single source pad that routes to a CSI (ipuX_csiY entities).
+
+On i.MX6 solo/dual-lite, there are two video mux entities. One sits
+in front of IPU1-CSI0 to select between a parallel sensor and any of
+the four MIPI CSI-2 virtual channels (a total of five sink pads). The
+other mux sits in front of IPU1-CSI1, and again has five sink pads to
+select between a parallel sensor and any of the four MIPI CSI-2 virtual
+channels.
+
+On i.MX6 Quad, there are two video mux entities. One sits in front of
+IPU1-CSI0 to select between a parallel sensor and MIPI CSI-2 virtual
+channel 0 (two sink pads). The other mux sits in front of IPU2-CSI1 to
+select between a parallel sensor and MIPI CSI-2 virtual channel 3 (two
+sink pads).
+
+ipuX_csiY
+---------
+
+These are the CSI entities. They have a single sink pad receiving from
+either a video mux or from a MIPI CSI-2 virtual channel as described
+above.
+
+This entity has two source pads. The first source pad can link directly
+to the ipuX_vdic entity or the ipuX_ic_prp entity, using hardware links
+that require no IDMAC memory buffer transfer.
+
+When the direct source pad is routed to the ipuX_ic_prp entity, frames
+from the CSI will be processed by one of the IC pre-processing tasks.
+
+When the direct source pad is routed to the ipuX_vdic entity, the VDIC
+will carry out motion-compensated de-interlace using "high motion" mode
+(see description of ipuX_vdic entity).
+
+The second source pad sends video frames to memory buffers via the SMFC
+and an IDMAC channel. This source pad is routed to a capture device
+node.
+
+Note that since the IDMAC source pad makes use of an IDMAC channel, it
+can do pixel reordering within the same colorspace. For example, the
+sink pad can take UYVY2X8, but the IDMAC source pad can output YUYV2X8.
+If the sink pad is receiving YUV, the output at the capture device can
+also be converted to a planar YUV format such as YUV420.
+
+It will also perform simple de-interlace without motion compensation,
+which is activated if the sink pad's field type is an interlaced type,
+and the IDMAC source pad field type is set to none.
+
+ipuX_vdic
+---------
+
+The VDIC carries out motion compensated de-interlacing, with three
+motion compensation modes: low, medium, and high motion. The mode is
+specified with a custom v4l2 control. It has two sink pads and a
+single source pad.
+
+The direct sink pad receives from an ipuX_csiY direct pad. With this
+link the VDIC can only operate in high motion mode.
+
+When the IDMAC sink pad is activated, it receives from an output
+or mem2mem device node. With this pipeline, it can also operate
+in low and medium modes, because these modes require receiving
+frames from memory buffers. Note that an output or mem2mem device
+is not implemented yet, so this sink pad currently has no links.
+
+The source pad routes to the IC pre-processing entity ipuX_ic_prp.
+
+ipuX_ic_prp
+-----------
+
+This is the IC pre-processing entity. It acts as a router, routing
+data from its sink pad to one or both of its source pads.
+
+It has a single sink pad. The sink pad can receive from the ipuX_csiY
+direct pad, or from ipuX_vdic.
+
+This entity has two source pads. One source pad routes to the
+pre-process encode task entity (ipuX_ic_prpenc), the other to the
+pre-process viewfinder task entity (ipuX_ic_prpvf). Both source pads
+can be activated at the same time if the sink pad is receiving from
+ipuX_csiY. Only the source pad to the pre-process viewfinder task entity
+can be activated if the sink pad is receiving from ipuX_vdic (frames
+from the VDIC can only be processed by the pre-process viewfinder task).
+
+ipuX_ic_prpenc
+--------------
+
+This is the IC pre-processing encode entity. It has a single sink pad
+from ipuX_ic_prp, and a single source pad. The source pad is routed
+to a capture device node.
+
+This entity performs the IC pre-process encode task operations:
+color-space conversion, resizing (downscaling and upscaling), horizontal
+and vertical flip, and 90/270 degree rotation.
+
+Like the ipuX_csiY IDMAC source, it can also perform simple de-interlace
+without motion compensation, and pixel reordering.
+
+ipuX_ic_prpvf
+-------------
+
+This is the IC pre-processing viewfinder entity. It has a single sink pad
+from ipuX_ic_prp, and a single source pad. The source pad is routed to
+a capture device node.
+
+It is identical in operation to ipuX_ic_prpenc. It will receive and
+process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is
+receiving from ipuX_vdic.
+
+Like the ipuX_csiY IDMAC source, it can perform simple de-interlace
+without motion compensation. However, note that if the ipuX_vdic is
+included in the pipeline (ipuX_ic_prp is receiving from ipuX_vdic),
+it's not possible to use simple de-interlace in ipuX_ic_prpvf, since
+the ipuX_vdic has already carried out de-interlacing (with motion
+compensation) and therefore the field type output from ipuX_ic_prp can
+only be none.
+
+Capture Pipelines
+-----------------
+
+The following describe the various use-cases supported by the pipelines.
+
+The links shown do not include the backend sensor, video mux, or mipi
+csi-2 receiver links. This depends on the type of sensor interface
+(parallel or mipi csi-2). So in all cases, these pipelines begin with:
+
+sensor -> ipuX_csiY_mux -> ...
+
+for parallel sensors, or:
+
+sensor -> imx6-mipi-csi2 -> (ipuX_csiY_mux) -> ...
+
+for mipi csi-2 sensors. The imx6-mipi-csi2 receiver may need to route
+to the video mux (ipuX_csiY_mux) before sending to the CSI, depending
+on the mipi csi-2 virtual channel, hence ipuX_csiY_mux is shown in
+parenthesis.
+
+Unprocessed Video Capture:
+--------------------------
+
+Send frames directly from sensor to camera device interface node, with
+no conversions:
+
+-> ipuX_csiY IDMAC pad -> capture node
+
+IC Direct Conversions:
+----------------------
+
+This pipeline uses the preprocess encode entity to route frames directly
+from the CSI to the IC, to carry out scaling up to 1024x1024 resolution,
+CSC, flipping, and image rotation:
+
+-> ipuX_csiY direct pad -> ipuX_ic_prp -> ipuX_ic_prpenc -> capture node
+
+Motion Compensated De-interlace:
+--------------------------------
+
+This pipeline routes frames from the CSI direct pad to the VDIC entity to
+support motion-compensated de-interlacing (high motion mode only),
+scaling up to 1024x1024, CSC, flip, and rotation:
+
+-> ipuX_csiY direct pad -> ipuX_vdic direct pad -> ipuX_ic_prp ->
+   ipuX_ic_prpvf -> capture node
+
+
+Usage Notes
+-----------
+
+Many of the subdevs require information from the active sensor in the
+current pipeline when configuring pad formats. Therefore the media links
+should be established before configuring the media pad formats.
+
+Similarly, the capture device interfaces inherit controls from the
+active entities in the current pipeline at link-setup time. Therefore
+the capture device node links should be the last links established in
+order for the capture interfaces to "see" and inherit all possible
+controls.
+
+The following are usage notes for Sabre- reference platforms:
+
+
+SabreLite with OV5642 and OV5640
+--------------------------------
+
+This platform requires the OmniVision OV5642 module with a parallel
+camera interface, and the OV5640 module with a MIPI CSI-2
+interface. Both modules are available from Boundary Devices:
+
+https://boundarydevices.com/products/nit6x_5mp
+https://boundarydevices.com/product/nit6x_5mp_mipi
+
+Note that if only one camera module is available, the other sensor
+node can be disabled in the device tree.
+
+The OV5642 module is connected to the parallel bus input on the i.MX
+internal video mux to IPU1 CSI0. It's i2c bus connects to i2c bus 2.
+
+The MIPI CSI-2 OV5640 module is connected to the i.MX internal MIPI CSI-2
+receiver, and the four virtual channel outputs from the receiver are
+routed as follows: vc0 to the IPU1 CSI0 mux, vc1 directly to IPU1 CSI1,
+vc2 directly to IPU2 CSI0, and vc3 to the IPU2 CSI1 mux. The OV5640 is
+also connected to i2c bus 2 on the SabreLite, therefore the OV5642 and
+OV5640 must not share the same i2c slave address.
+
+The following basic example configures unprocessed video capture
+pipelines for both sensors. The OV5642 is routed to ipu1_csi0, and
+the OV5640 (transmitting on mipi csi-2 virtual channel 1) is routed
+to ipu1_csi1. Both sensors are configured to output 640x480, the
+OV5642 outputs YUYV2X8, the OV5640 UYVY2X8:
+
+.. code-block:: none
+
+   # Setup links for OV5642
+   media-ctl -l '"ov5642 1-0042":0 -> "ipu1_csi0_mux":1[1]'
+   media-ctl -l '"ipu1_csi0_mux":2 -> "ipu1_csi0":0[1]'
+   media-ctl -l '"ipu1_csi0":2 -> "ipu1_csi0 capture":0[1]'
+   # Setup links for OV5640
+   media-ctl -l '"ov5640_mipi 1-0040":0 -> "imx6-mipi-csi2":0[1]'
+   media-ctl -l '"imx6-mipi-csi2":2 -> "ipu1_csi1":0[1]'
+   media-ctl -l '"ipu1_csi1":2 -> "ipu1_csi1 capture":0[1]'
+   # Configure pads for OV5642 pipeline
+   media-ctl -V "\"ov5642 1-0042\":0 [fmt:YUYV2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi0_mux\":2 [fmt:YUYV2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi0\":2 [fmt:YUYV2X8/640x480 field:none]"
+   # Configure pads for OV5640 pipeline
+   media-ctl -V "\"ov5640_mipi 1-0040\":0 [fmt:UYVY2X8/640x480 field:none]"
+   media-ctl -V "\"imx6-mipi-csi2\":2 [fmt:UYVY2X8/640x480 field:none]"
+   media-ctl -V "\"ipu1_csi1\":2 [fmt:UYVY2X8/640x480 field:none]"
+
+Streaming can then begin independently on the capture device nodes
+"ipu1_csi0 capture" and "ipu1_csi1 capture".
+
+SabreAuto with ADV7180 decoder
+------------------------------
+
+On the SabreAuto, an on-board ADV7180 SD decoder is connected to the
+parallel bus input on the internal video mux to IPU1 CSI0.
+
+The following example configures a pipeline to capture from the ADV7180
+video decoder, assuming NTSC 720x480 input signals, with Motion
+Compensated de-interlacing. Pad field types assume the adv7180 outputs
+"alternate", which the ipu1_csi0 entity converts to "seq-tb" at its
+source pad. $outputfmt can be any format supported by the ipu1_ic_prpvf
+entity at its output pad:
+
+.. code-block:: none
+
+   # Setup links
+   media-ctl -l '"adv7180 4-0021":0 -> "ipu1_csi0_mux":1[1]'
+   media-ctl -l '"ipu1_csi0_mux":2 -> "ipu1_csi0":0[1]'
+   media-ctl -l '"ipu1_csi0":2 -> "ipu1_vdic":0[1]'
+   media-ctl -l '"ipu1_vdic":2 -> "ipu1_ic_prp":0[1]'
+   media-ctl -l '"ipu1_ic_prp":2 -> "ipu1_ic_prpvf":0[1]'
+   media-ctl -l '"ipu1_ic_prpvf":1 -> "ipu1_ic_prpvf capture":0[1]'
+   # Configure pads
+   media-ctl -V "\"adv7180 4-0021\":0 [fmt:UYVY2X8/720x480]"
+   media-ctl -V "\"ipu1_csi0_mux\":2 [fmt:UYVY2X8/720x480 field:alternate]"
+   media-ctl -V "\"ipu1_csi0\":1 [fmt:AYUV32/720x480 field:seq-tb]"
+   media-ctl -V "\"ipu1_vdic\":2 [fmt:AYUV32/720x480 field:none]"
+   media-ctl -V "\"ipu1_ic_prp\":2 [fmt:AYUV32/720x480 field:none]"
+   media-ctl -V "\"ipu1_ic_prpvf\":1 [fmt:$outputfmt field:none]"
+
+Streaming can then begin on the capture device node at
+"ipu1_ic_prpvf capture".
+
+This platform accepts Composite Video analog inputs to the ADV7180 on
+Ain1 (connector J42).
+
+Frame Interval Monitor
+----------------------
+
+The adv718x decoders can occasionally send corrupt fields during
+NTSC/PAL signal re-sync (too little or too many video lines). When
+this happens, the IPU triggers a mechanism to re-establish vertical
+sync by adding 1 dummy line every frame, which causes a rolling effect
+from image to image, and can last a long time before a stable image is
+recovered. Or sometimes the mechanism doesn't work at all, causing a
+permanent split image (one frame contains lines from two consecutive
+captured images).
+
+From experiment it was found that during image rolling, the frame
+intervals (elapsed time between two EOF's) drop below the nominal
+value for the current standard, by about one frame time (60 usec),
+and remain at that value until rolling stops.
+
+While the reason for this observation isn't known (the IPU dummy
+line mechanism should show an increase in the intervals by 1 line
+time every frame, not a fixed value), we can use it to detect the
+corrupt fields using a frame interval monitor. If the FIM detects a
+bad frame interval, a subdev event is sent. In response, userland can
+issue a streaming restart to correct the rolling/split image.
+
+The FIM is implemented in the ipuX_csiY entity, and the entities that
+generate End-Of-Frame interrupts call into the FIM to monitor the frame
+intervals: ipuX_ic_prpenc, and ipuX_ic_prpvf. Userland can register with
+the FIM event notifications on the ipuX_csiY subdev device node
+(V4L2_EVENT_IMX_FRAME_INTERVAL).
+
+The ipuX_csiY entity includes custom controls to tweak some dials for
+FIM. If one of these controls is changed during streaming, the FIM will
+be reset and will continue at the new settings.
+
+- V4L2_CID_IMX_FIM_ENABLE
+
+Enable/disable the FIM.
+
+- V4L2_CID_IMX_FIM_NUM
+
+How many frame interval errors to average before comparing against the
+nominal frame interval reported by the sensor. This can reduce noise
+from interrupt latency.
+
+- V4L2_CID_IMX_FIM_TOLERANCE_MIN
+
+If the averaged intervals fall outside nominal by this amount, in
+microseconds, streaming will be restarted.
+
+- V4L2_CID_IMX_FIM_TOLERANCE_MAX
+
+If any interval errors are higher than this value, those error samples
+are discarded and do not enter into the average. This can be used to
+discard really high interval errors that might be due to very high
+system load, causing excessive interrupt latencies.
+
+- V4L2_CID_IMX_FIM_NUM_SKIP
+
+How many frames to skip after a FIM reset or stream restart before
+FIM begins to average intervals. It has been found that there can
+be a few bad frame intervals after stream restart which are not
+attributed to adv718x sending a corrupt field, so this is used to
+skip those frames to prevent unnecessary restarts.
+
+
+SabreSD with MIPI CSI-2 OV5640
+------------------------------
+
+Similarly to SabreLite, the SabreSD supports a parallel interface
+OV5642 module on IPU1 CSI0, and a MIPI CSI-2 OV5640 module. The OV5642
+connects to i2c bus 1 and the OV5640 to i2c bus 2.
+
+The device tree for SabreSD includes OF graphs for both the parallel
+OV5642 and the MIPI CSI-2 OV5640, but as of this writing only the MIPI
+CSI-2 OV5640 has been tested, so the OV5642 node is currently disabled.
+The OV5640 module connects to MIPI connector J5 (sorry I don't have the
+compatible module part number or URL).
+
+The following example configures a direct conversion pipeline to capture
+from the OV5640. $sensorfmt can be any format supported by the OV5640.
+$sensordim is the frame dimension part of $sensorfmt (minus the mbus
+pixel code). $outputfmt can be any format supported by the
+ipu1_ic_prpenc entity at its output pad:
+
+.. code-block:: none
+
+   # Setup links
+   media-ctl -l '"ov5640_mipi 1-003c":0 -> "imx6-mipi-csi2":0[1]'
+   media-ctl -l '"imx6-mipi-csi2":2 -> "ipu1_csi1":0[1]'
+   media-ctl -l '"ipu1_csi1":1 -> "ipu1_ic_prp":0[1]'
+   media-ctl -l '"ipu1_ic_prp":1 -> "ipu1_ic_prpenc":0[1]'
+   media-ctl -l '"ipu1_ic_prpenc":1 -> "ipu1_ic_prpenc capture":0[1]'
+   # Configure pads
+   media-ctl -V "\"ov5640_mipi 1-003c\":0 [fmt:$sensorfmt field:none]"
+   media-ctl -V "\"imx6-mipi-csi2\":2 [fmt:$sensorfmt field:none]"
+   media-ctl -V "\"ipu1_csi1\":1 [fmt:AYUV32/$sensordim field:none]"
+   media-ctl -V "\"ipu1_ic_prp\":1 [fmt:AYUV32/$sensordim field:none]"
+   media-ctl -V "\"ipu1_ic_prpenc\":1 [fmt:$outputfmt field:none]"
+
+Streaming can then begin on "ipu1_ic_prpenc capture" node.
+
+
+
+Known Issues
+------------
+
+1. When using 90 or 270 degree rotation control at capture resolutions
+   near the IC resizer limit of 1024x1024, and combined with planar
+   pixel formats (YUV420, YUV422p), frame capture will often fail with
+   no end-of-frame interrupts from the IDMAC channel. To work around
+   this, use lower resolution and/or packed formats (YUYV, RGB3, etc.)
+   when 90 or 270 rotations are needed.
+
+
+File list
+---------
+
+drivers/staging/media/imx/
+include/media/imx.h
+include/uapi/media/imx.h
+
+References
+----------
+
+[1] "i.MX 6Dual/6Quad Applications Processor Reference Manual"
+[2] "i.MX 6Solo/6DualLite Applications Processor Reference Manual"
+
+
+Authors
+-------
+Steve Longerbeam <[email protected]>
+Philipp Zabel <[email protected]>
+Russell King - ARM Linux <[email protected]>
+
+Copyright (C) 2012-2017 Mentor Graphics Inc.
drivers/staging/media/Kconfig +2 -0
index ffb8fa7..05b55a8 100644
@@ -25,6 +25,8 @@ source "drivers/staging/media/cxd2099/Kconfig"
 
 source "drivers/staging/media/davinci_vpfe/Kconfig"
 
+source "drivers/staging/media/imx/Kconfig"
+
 source "drivers/staging/media/omap4iss/Kconfig"
 
 source "drivers/staging/media/s5p-cec/Kconfig"
drivers/staging/media/Makefile +1 -0
index a28e82c..6f50ddd 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_I2C_BCM2048)	+= bcm2048/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/
 obj-$(CONFIG_DVB_CXD2099)	+= cxd2099/
+obj-$(CONFIG_VIDEO_IMX_MEDIA)	+= imx/
 obj-$(CONFIG_LIRC_STAGING)	+= lirc/
 obj-$(CONFIG_VIDEO_DM365_VPFE)	+= davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)	+= omap4iss/
drivers/staging/media/imx/Kconfig new file +7 -0
new file mode 100644
index 0000000..722ed55
@@ -0,0 +1,7 @@
+config VIDEO_IMX_MEDIA
+	tristate "i.MX5/6 V4L2 media core driver"
+	depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
+	---help---
+	  Say yes here to enable support for video4linux media controller
+	  driver for the i.MX5/6 SOC.
+
drivers/staging/media/imx/Makefile new file +6 -0
new file mode 100644
index 0000000..ba8e4fb
@@ -0,0 +1,6 @@
+imx-media-objs := imx-media-dev.o imx-media-internal-sd.o imx-media-of.o
+imx-media-common-objs := imx-media-utils.o imx-media-fim.o
+
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
+
drivers/staging/media/imx/TODO new file +0 -0
new file mode 100644
index 0000000..f6d2bac

drivers/staging/media/imx/TODO line 6

Quoted 6 lines
drivers/staging/media/imx/TODO new file +6 -0
@@ -0,0 +1,36 @@
+
+- Finish v4l2-compliance
+
+- imx-csi subdev is not being autoloaded as a kernel module, probably
+  because ipu_add_client_devices() does not register the IPU client
+  platform devices, but only allocates those devices.

As Russell points out, this is an issue with the ipu-v3 driver, which needs to be fixed to stop setting the ipu client devices' dev->of_node field.

drivers/staging/media/imx/TODO line 15

Quoted 8 lines
drivers/staging/media/imx/TODO new file +8 -0
+- Currently registering with notifications from subdevs are only
+  available through the subdev device nodes and not through the main
+  capture device node. Need to come up with a way to find the capture
+  device in the current pipeline that owns the subdev that sent the
+  notify.
+
+- Clean up and move the ov5642 subdev driver to drivers/media/i2c, and
+  create the binding docs for it.

This is done already, right?

drivers/staging/media/imx/TODO line 26

Quoted 10 lines
drivers/staging/media/imx/TODO new file +10 -0
+- The Frame Interval Monitor could be exported to v4l2-core for
+  general use.
+
+- The subdev that is the original source of video data (referred to as
+  the "sensor" in the code), is called from various subdevs in the
+  pipeline in order to set/query the video standard ({g|s|enum}_std)
+  and to get/set the original frame interval from the capture interface
+  ([gs]_parm). Instead, the entities that need this info should call its
+  direct neighbor, and the neighbor should propagate the call to its
+  neighbor in turn if necessary.

Especially the [gs]_parm fix is necessary to present userspace with the correct frame interval in case of frame skipping in the CSI.

Quoted 14 lines
drivers/staging/media/imx/TODO new file +9 -0
+- At driver load time, the device-tree node that is the original source
+  (the "sensor"), is parsed to record its media bus configuration, and
+  this info is required in various subdevs to setup the pipeline.
+  Laurent Pinchart argues that instead the subdev should call its
+  neighbor's g_mbus_config op (which should be propagated if necessary)
+  to get this info. However Hans Verkuil is planning to remove the
+  g_mbus_config op. For now this driver uses the parsed DT mbus config
+  method until this issue is resolved.
+
drivers/staging/media/imx/imx-media-dev.c new file +0 -0
new file mode 100644
index 0000000..e2041ad

[...]

drivers/staging/media/imx/imx-media-dev.c

Quoted 5 lines
drivers/staging/media/imx/imx-media-dev.c new file +5 -0
+static inline u32 pixfmt_to_colorspace(const struct imx_media_pixfmt *fmt)
+{
+	return (fmt->cs == IPUV3_COLORSPACE_RGB) ?
+		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+}

This ...

[...]

Quoted 8 lines
drivers/staging/media/imx/imx-media-dev.c new file +8 -0
+int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
+				  struct v4l2_mbus_framefmt *mbus,
+				  const struct imx_media_pixfmt *cc)
+{
+	u32 stride;
+
+	if (!cc) {
+		cc = imx_media_find_format(0, mbus->code, true, false);

drivers/staging/media/imx/imx-media-dev.c

Quoted 10 lines
drivers/staging/media/imx/imx-media-dev.c new file +10 -0
+		if (!cc)
+			return -EINVAL;
+	}
+
+	stride = cc->planar ? mbus->width : (mbus->width * cc->bpp) >> 3;
+
+	pix->width = mbus->width;
+	pix->height = mbus->height;
+	pix->pixelformat = cc->fourcc;
+	pix->colorspace = pixfmt_to_colorspace(cc);

... is not right. The colorspace should be taken from the input pad colorspace everywhere (except for the IC output pad in the future, once that supports changing YCbCr encoding and quantization), not guessed based on the media bus format.

regards
Philipp

#135 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

Quoted 10 lines · Philipp Zabel

drivers/staging/media/imx/TODO line 6

Quoted 3 lines · Steve Longerbeam

+- imx-csi subdev is not being autoloaded as a kernel module, probably

drivers/staging/media/imx/TODO new file +2 -0
+  because ipu_add_client_devices() does not register the IPU client
+  platform devices, but only allocates those devices.

As Russell points out, this is an issue with the ipu-v3 driver, which needs to be fixed to stop setting the ipu client devices' dev->of_node field.

From my local testing (albiet the shambles that is bits of v4l2) setting

dev->of_node is not necessary for imx-drm - imx-drm comes up fine without.

Fixing _this_ code for that is not too difficult - it's a matter of:

	priv->sd.of_node = pdata->of_node;

in imx_csi_probe(). However, the difficult bit is the poor state of code in v4l2, particularly the v4l2-async crap. Right now, fixing the module autoloading will oops the kernel, so it's best that module autoloading remains broken for the time being.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#136 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

In reply to Philipp Zabel
Quoted 1 line · Philipp Zabel

On Wed, 2017-02-15 at 18:19 -0800, Steve Longerbeam wrote:

<snip>

Quoted 5 lines

drivers/staging/media/imx/TODO line 15

Quoted 3 lines
drivers/staging/media/imx/TODO new file +3 -0
+
+- Clean up and move the ov5642 subdev driver to drivers/media/i2c, and
+  create the binding docs for it.

This is done already, right?

I cleaned up ov5640 and moved it to drivers/media/i2c with binding docs, but not the ov5642 yet.

Quoted 12 lines

drivers/staging/media/imx/TODO line 26

Quoted 11 lines

+- The Frame Interval Monitor could be exported to v4l2-core for

drivers/staging/media/imx/TODO new file +9 -0
+  general use.
+
+- The subdev that is the original source of video data (referred to as
+  the "sensor" in the code), is called from various subdevs in the
+  pipeline in order to set/query the video standard ({g|s|enum}_std)
+  and to get/set the original frame interval from the capture interface
+  ([gs]_parm). Instead, the entities that need this info should call its
+  direct neighbor, and the neighbor should propagate the call to its
+  neighbor in turn if necessary.
Quoted 2 lines

Especially the [gs]_parm fix is necessary to present userspace with the correct frame interval in case of frame skipping in the CSI.

Right, understood. I've added this to list of fixes for version 5.

What a pain though! It means propagating every call to g_frame_interval upstream until a subdev "that cares" returns ret == 0 or
ret != -ENOIOCTLCMD. And that goes for any other chained subdev call as well.

I've thought of writing something like a v4l2_chained_subdev_call() macro to do this, but it would be a big macro.

Quoted 40 lines
Quoted 15 lines

+- At driver load time, the device-tree node that is the original source

drivers/staging/media/imx/TODO new file +8 -0
+  (the "sensor"), is parsed to record its media bus configuration, and
+  this info is required in various subdevs to setup the pipeline.
+  Laurent Pinchart argues that instead the subdev should call its
+  neighbor's g_mbus_config op (which should be propagated if necessary)
+  to get this info. However Hans Verkuil is planning to remove the
+  g_mbus_config op. For now this driver uses the parsed DT mbus config
+  method until this issue is resolved.
+
drivers/staging/media/imx/imx-media-dev.c new file +0 -0
new file mode 100644
index 0000000..e2041ad

[...]

drivers/staging/media/imx/imx-media-dev.c

Quoted 5 lines
drivers/staging/media/imx/imx-media-dev.c new file +5 -0
+static inline u32 pixfmt_to_colorspace(const struct imx_media_pixfmt *fmt)
+{
+	return (fmt->cs == IPUV3_COLORSPACE_RGB) ?
+		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+}

This ...

[...]

Quoted 15 lines
drivers/staging/media/imx/imx-media-dev.c new file +15 -0
+int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
+				  struct v4l2_mbus_framefmt *mbus,
+				  const struct imx_media_pixfmt *cc)
+{
+	u32 stride;
+
+	if (!cc) {
+		cc = imx_media_find_format(0, mbus->code, true, false);
+		if (!cc)
+			return -EINVAL;
+	}
+
+	stride = cc->planar ? mbus->width : (mbus->width * cc->bpp) >> 3;
+
+	pix->width = mbus->width;
Quoted 8 lines

drivers/staging/media/imx/imx-media-dev.c

Quoted 3 lines
drivers/staging/media/imx/imx-media-dev.c new file +3 -0
+	pix->height = mbus->height;
+	pix->pixelformat = cc->fourcc;
+	pix->colorspace = pixfmt_to_colorspace(cc);

... is not right. The colorspace should be taken from the input pad colorspace everywhere (except for the IC output pad in the future, once that supports changing YCbCr encoding and quantization), not guessed based on the media bus format.

Ok, will fix this to assign pix->colorspace to mbus->colorspace, after all the subdevs assign colorspace values to their pads.

Steve

maintainer
#137 lore raw

Re: [PATCH v4 18/36] media: Add i.MX media core driver

Quoted 8 lines · Steve Longerbeam
Quoted 1 line · Philipp Zabel

On Wed, 2017-02-15 at 18:19 -0800, Steve Longerbeam wrote:

<snip>

Quoted 4 lines
Quoted 3 lines
drivers/staging/media/imx/TODO new file +3 -0
+
+- Clean up and move the ov5642 subdev driver to drivers/media/i2c, and
+  create the binding docs for it.
Quoted 5 lines
Quoted 1 line

This is done already, right?

I cleaned up ov5640 and moved it to drivers/media/i2c with binding docs, but not the ov5642 yet.

Ok, thanks.

Quoted 15 lines
Quoted 11 lines

drivers/staging/media/imx/TODO line 26

Quoted 10 lines

+- The Frame Interval Monitor could be exported to v4l2-core for

drivers/staging/media/imx/TODO new file +9 -0
+  general use.
+
+- The subdev that is the original source of video data (referred to as
+  the "sensor" in the code), is called from various subdevs in the
+  pipeline in order to set/query the video standard ({g|s|enum}_std)
+  and to get/set the original frame interval from the capture interface
+  ([gs]_parm). Instead, the entities that need this info should call its
+  direct neighbor, and the neighbor should propagate the call to its
+  neighbor in turn if necessary.
Quoted 2 lines

Especially the [gs]_parm fix is necessary to present userspace with the correct frame interval in case of frame skipping in the CSI.

Quoted 6 lines

Right, understood. I've added this to list of fixes for version 5.

What a pain though! It means propagating every call to g_frame_interval upstream until a subdev "that cares" returns ret == 0 or
ret != -ENOIOCTLCMD. And that goes for any other chained subdev call as well.

Not at all. Since the frame interval is a property of the pad, that had to be propagated downstream by media-ctl along with media bus format, frame size, and colorimetry earlier.

regards
Philipp

author maintainer
#138 lore raw

PATCH v4 19/36 media: imx: Add Capture Device Interface

In reply to Steve Longerbeam

This is the capture device interface driver that provides the v4l2 user interface. Frames can be received from various sources:

- directly from CSI for capturing unconverted images directly from camera sensors.

- from the IC pre-process encode task.

- from the IC pre-process viewfinder task.

---
 drivers/staging/media/imx/Makefile            |   2 +-
 drivers/staging/media/imx/imx-media-capture.c | 654 ++++++++++++++++++++++++++
 2 files changed, 655 insertions(+), 1 deletion(-)
 create mode 100644 drivers/staging/media/imx/imx-media-capture.c
drivers/staging/media/imx/Makefile +1 -1
index ba8e4fb..4606a3a 100644
@@ -3,4 +3,4 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
-
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
drivers/staging/media/imx/imx-media-capture.c new file +654 -0

654 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#139 lore raw

PATCH v4 20/36 media: imx: Add CSI subdev driver

In reply to Steve Longerbeam

This is a media entity subdevice for the i.MX Camera Sensor Interface module.

---
 drivers/staging/media/imx/Kconfig         |   13 +
 drivers/staging/media/imx/Makefile        |    2 +
 drivers/staging/media/imx/imx-media-csi.c | 1220 +++++++++++++++++++++++++++++
 3 files changed, 1235 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/imx/Kconfig +13 -0
index 722ed55..e27ad6d 100644
@@ -5,3 +5,16 @@ config VIDEO_IMX_MEDIA
 	  Say yes here to enable support for video4linux media controller
 	  driver for the i.MX5/6 SOC.
 
+if VIDEO_IMX_MEDIA
+menu "i.MX5/6 Media Sub devices"
+
+config VIDEO_IMX_CSI
+	tristate "i.MX5/6 Camera Sensor Interface driver"
+	depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
+	select VIDEOBUF2_DMA_CONTIG
+	default y
+	---help---
+	  A video4linux camera sensor interface driver for i.MX5/6.
+
+endmenu
+endif
drivers/staging/media/imx/Makefile +2 -0
index 4606a3a..c054490 100644
@@ -4,3 +4,5 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
+
+obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
drivers/staging/media/imx/imx-media-csi.c new file +1220 -0

1,220 lines not on this page · raw message

Signature · 1 line
2.7.4
#140 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 10 lines · Steve Longerbeam
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+static const struct platform_device_id imx_csi_ids[] = {
+	{ .name = "imx-ipuv3-csi" },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, imx_csi_ids);
+
+static struct platform_driver imx_csi_driver = {
+	.probe = imx_csi_probe,
+	.remove = imx_csi_remove,
+	.id_table = imx_csi_ids,

drivers/staging/media/imx/imx-media-csi.c line 1220

Quoted 10 lines
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+	.driver = {
+		.name = "imx-ipuv3-csi",
+	},
+};
+module_platform_driver(imx_csi_driver);
+
+MODULE_DESCRIPTION("i.MX CSI subdev driver");
+MODULE_AUTHOR("Steve Longerbeam <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:imx-ipuv3-csi");

Just a reminder that automatic module loading of this is completely broken right now (not your problem) due to this stupid idea in the IPUv3 code:

		if (!ret)
			ret = platform_device_add(pdev);
		if (ret) {
			platform_device_put(pdev);
			goto err_register;
		}

		/*
		 * Set of_node only after calling platform_device_add. Otherwise
		 * the platform:imx-ipuv3-crtc modalias won't be used.
		 */
		pdev->dev.of_node = of_node;

setting pdev->dev.of_node changes the modalias exported to userspace, so udev sees a DT based modalias, which causes it to totally miss any driver using a non-DT based modalias.

The IPUv3 code needs fixing, not only for imx-media-csi, but also for imx-ipuv3-crtc too, because that module will also suffer the same issue.

The only solution is... don't fsck with dev->of_node assignment. In this case, it's probably much better to pass it in via platform data. If you then absolutely must have dev->of_node, doing it in the driver means that you avoid the modalias mess before the appropriate driver is loaded. However, that's still not a nice solution because the modalias file still ends up randomly changing its contents.

As I say, not _your_ problem, but it's still a problem that needs solving, and I don't want it forgotten about.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#141 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 54 lines · Russell King - ARM Linux
Quoted 10 lines · Steve Longerbeam
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+static const struct platform_device_id imx_csi_ids[] = {
+	{ .name = "imx-ipuv3-csi" },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, imx_csi_ids);
+
+static struct platform_driver imx_csi_driver = {
+	.probe = imx_csi_probe,
+	.remove = imx_csi_remove,
+	.id_table = imx_csi_ids,

drivers/staging/media/imx/imx-media-csi.c line 1220

Quoted 10 lines
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+	.driver = {
+		.name = "imx-ipuv3-csi",
+	},
+};
+module_platform_driver(imx_csi_driver);
+
+MODULE_DESCRIPTION("i.MX CSI subdev driver");
+MODULE_AUTHOR("Steve Longerbeam <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:imx-ipuv3-csi");

Just a reminder that automatic module loading of this is completely broken right now (not your problem) due to this stupid idea in the IPUv3 code:

		if (!ret)
			ret = platform_device_add(pdev);
		if (ret) {
			platform_device_put(pdev);
			goto err_register;
		}

		/*
		 * Set of_node only after calling platform_device_add. Otherwise
		 * the platform:imx-ipuv3-crtc modalias won't be used.
		 */
		pdev->dev.of_node = of_node;

setting pdev->dev.of_node changes the modalias exported to userspace, so udev sees a DT based modalias, which causes it to totally miss any driver using a non-DT based modalias.

The IPUv3 code needs fixing, not only for imx-media-csi, but also for imx-ipuv3-crtc too, because that module will also suffer the same issue.

The only solution is... don't fsck with dev->of_node assignment. In this case, it's probably much better to pass it in via platform data. If you then absolutely must have dev->of_node, doing it in the driver means that you avoid the modalias mess before the appropriate driver is loaded. However, that's still not a nice solution because the modalias file still ends up randomly changing its contents.

Quoted 2 lines

As I say, not _your_ problem, but it's still a problem that needs solving, and I don't want it forgotten about.

I've just hacked up a solution to this, and unfortunately it reveals a problem with Steve's code. Picking out the imx & media-related messages:

[    8.012191] imx_media_common: module is from the staging directory, the quality is unknown, you have been warned.
[    8.018175] imx_media: module is from the staging directory, the quality is unknown, you have been warned.
[    8.748345] imx-media: Registered subdev ipu1_csi0_mux
[    8.753451] imx-media: Registered subdev ipu2_csi1_mux
[    9.055196] imx219 0-0010: detected IMX219 sensor
[    9.090733] imx6_mipi_csi2: module is from the staging directory, the quality is unknown, you have been warned.
[    9.092247] imx-media: Registered subdev imx219 0-0010
[    9.334338] imx-media: Registered subdev imx6-mipi-csi2
[    9.372452] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.378163] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.390033] imx_media_csi: module is from the staging directory, the quality is unknown, you have been warned.
[    9.394362] imx-media: Received unknown subdev ipu1_csi0
[    9.394699] imx-ipuv3-csi: probe of imx-ipuv3-csi.0 failed with error -22
[    9.394840] imx-media: Received unknown subdev ipu1_csi1
[    9.394887] imx-ipuv3-csi: probe of imx-ipuv3-csi.1 failed with error -22
[    9.394992] imx-media: Received unknown subdev ipu2_csi0
[    9.395026] imx-ipuv3-csi: probe of imx-ipuv3-csi.4 failed with error -22
[    9.395119] imx-media: Received unknown subdev ipu2_csi1
[    9.395159] imx-ipuv3-csi: probe of imx-ipuv3-csi.5 failed with error -22
[    9.411722] imx_media_vdic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.412820] imx-media: Registered subdev ipu1_vdic
[    9.424687] imx-media: Registered subdev ipu2_vdic
[    9.436074] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.437455] imx-media: Registered subdev ipu1_ic_prp
[    9.437788] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.447542] imx-media: Registered subdev ipu1_ic_prpenc
[    9.455225] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video3
[    9.459203] imx-media: Registered subdev ipu1_ic_prpvf
[    9.460484] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.460726] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video4
[    9.460983] imx-media: Registered subdev ipu2_ic_prp
[    9.461161] imx-media: Registered subdev ipu2_ic_prpenc
[    9.461737] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video5
[    9.463767] imx-media: Registered subdev ipu2_ic_prpvf
[    9.464294] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video6
[    9.464345] imx-media: imx_media_create_link: (null):1 -> ipu1_ic_prp:0
[    9.464413] ------------[ cut here ]------------
[    9.469134] kernel BUG at /home/rmk/git/linux-rmk/drivers/media/media-entity.c:628!
[    9.476924] Internal error: Oops - BUG: 0 [#1] SMP ARM
[    9.482246] Modules linked in: imx_media_ic(C+) imx_media_vdic(C) imx_media_csi(C) imx_media_capture(C) uvcvideo imx6_mipi_csi2(C) snd_soc_imx_audmux imx219 snd_soc_sgtl5000 video_multiplexer caam imx_sdma imx2_wdt snd_soc_fsl_ssi snd_soc_fsl_spdif imx_pcm_dma coda imx_thermal v4l2_mem2mem videobuf2_v4l2 videobuf2_dma_contig videobuf2_core videobuf2_vmalloc videobuf2_memops imx_media(C) imx_media_common(C) rc_pinnacle_pctv_hd nfsd dw_hdmi_cec dw_hdmi_ahb_audio etnaviv
[    9.524500] CPU: 1 PID: 263 Comm: systemd-udevd Tainted: G         C      4.10.0-rc7+ #2112
[    9.532995] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[    9.539619] task: edef1880 task.stack: d03ca000
[    9.544313] PC is at media_create_pad_link+0x134/0x140
[    9.549541] LR is at imx_media_probe_complete+0x164/0x24c [imx_media]
[    9.556080] pc : [<c04f0eb0>]    lr : [<bf052524>]    psr: 60070013
               sp : d03cbbc8  ip : d03cbbf8  fp : d03cbbf4
[    9.567712] r10: 00000001  r9 : 00000000  r8 : d0170d14
[    9.573007] r7 : 00000000  r6 : 00000001  r5 : 00000000  r4 : d0170d14
[    9.579612] r3 : 00000000  r2 : d0170d14  r1 : 00000001  r0 : 00000000
[    9.586256] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none[    9.593486] Control: 10c5387d  Table: 3e77c04a  DAC: 00000051
[    9.599317] Process systemd-udevd (pid: 263, stack limit = 0xd03ca210)
[    9.605950] Stack: (0xd03cbbc8 to 0xd03cc000)
[    9.610368] bbc0:                   00000000 00000000 ee980410 00000000 00000000 d0170d14
[    9.618658] bbe0: 00000000 00000001 d03cbc54 d03cbbf8 bf052524 c04f0d88 00000000 d0170d88
[    9.626961] bc00: 00000000 c0a57dc4 0004a364 ee98011c 00000000 00000003 00000001 ee980230
[    9.635267] bc20: ee980274 ee980010 d03cbc54 d0170f14 ee9ca4cc ee9974c4 bf0523c0 c0a57dc4
[    9.643539] bc40: f184bb30 00000026 d03cbc74 d03cbc58 c0502f50 bf0523cc ee9ca4cc d0170f14
[    9.651824] bc60: c0a57e08 d0170fc0 d03cbc9c d03cbc78 c0502fdc c0502e70 00000000 d0170f10
[    9.660132] bc80: 00000000 d02c0c10 bf122cd0 d0170f14 d03cbcc4 d03cbca0 bf121154 c0502f68
[    9.668423] bca0: bf12104c ffffffed d02c0c10 fffffdfb bf123248 00000000 d03cbce4 d03cbcc8
[    9.676713] bcc0: c041aeb4 bf121058 d02c0c10 c1419d70 00000000 bf123248 d03cbd0c d03cbce8
[    9.684992] bce0: c0418ec4 c041ae68 d02c0c10 bf123248 d02c0c44 00000000 00000001 00000124
[    9.693282] bd00: d03cbd2c d03cbd10 c0419044 c0418ccc 00000000 00000000 bf123248 c0418f88
[    9.701618] bd20: d03cbd54 d03cbd30 c04172e4 c0418f94 ef0f64a4 d01b8cd0 d03d9858 bf123248
[    9.709900] bd40: d03d9c00 c0a45e10 d03cbd64 d03cbd58 c0418728 c0417294 d03cbd8c d03cbd68
[    9.718203] bd60: c0418428 c0418710 bf122e48 d03cbd78 bf123248 c0a704a8 bf126000 00000000
[    9.729180] bd80: d03cbda4 d03cbd90 c0419ec4 c0418340 bf123480 c0a704a8 d03cbdb4 d03cbda8
[    9.739950] bda0: c041ad88 c0419e50 d03cbdc4 d03cbdb8 bf126018 c041ad4c d03cbe34 d03cbdc8
[    9.751089] bdc0: c00098ac bf12600c d03cbdec d03cbdd8 c00a8888 c0087240 00000000 ed4a9440
[    9.761941] bde0: d03cbe34 d03cbdf0 c016c690 c00a8814 c016b554 c016aa60 00000001 c015f3f8
[    9.772940] be00: 00000005 0000000c edef1880 bf123480 c0a704a8 bf123480 c0a704a8 ed4a9440
[    9.784008] be20: bf123480 00000001 d03cbe5c d03cbe38 c011b1e4 c0009874 d03cbe5c d03cbe48
[    9.795017] be40: c09f5ea7 c0a704a8 c09e04ec bf123480 d03cbf14 d03cbe60 c00d2dd0 c011b188
[    9.806069] be60: bf12348c 00007fff bf123480 c00d09f0 f1847000 bf12792c f18495c0 bf123680
[    9.817194] be80: bf12348c bf1236f0 00000000 bf1234c8 c017c1d0 c017bfac f1847000 00004f68
[    9.828347] bea0: c017c2e8 00000000 edef1880 00000000 00000000 00000000 00000000 00000000
[    9.839542] bec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    9.850754] bee0: 00000000 00000000 00000003 7fffffff 00000000 00000000 00000007 b6c9e63c
[    9.861991] bf00: d03ca000 00000000 d03cbfa4 d03cbf18 c00d36cc c00d1480 7fffffff 00000000
[    9.873266] bf20: 00000003 ee0384d4 d03cbf74 f1847000 00004f68 00000000 00000002 f1847000
[    9.884593] bf40: 00004f68 f184bb30 f184989b f184a7d8 000026f0 00002dd0 00000000 00000000
[    9.895998] bf60: 00000000 0000192c 00000019 0000001a 00000011 00000000 0000000a 00000000
[    9.907408] bf80: c008b848 80c36630 00000000 2529fc00 0000017b c000ff04 00000000 d03cbfa8
[    9.918858] bfa0: c000fd60 c00d3644 80c36630 00000000 00000007 b6c9e63c 00000000 80c38178
[    9.930354] bfc0: 80c36630 00000000 2529fc00 0000017b 00020000 7f96eb0c 80c37848 00000000
[    9.941900] bfe0: bed55928 bed55918 b6c988ff b6bea572 600f0030 00000007 3fffd861 3fffdc61
[    9.953532] Backtrace:
[    9.959442] [<c04f0d7c>] (media_create_pad_link) from [<bf052524>] (imx_media_probe_complete+0x164/0x24c [imx_media])
[    9.973644]  r10:00000001 r9:00000000 r8:d0170d14 r7:00000000 r6:00000000 r5:ee980410
[    9.985112]  r4:00000000 r3:00000000
[    9.992696] [<bf0523c0>] (imx_media_probe_complete [imx_media]) from [<c0502f50>] (v4l2_async_test_notify+0xec/0xf8)
[   10.007413]  r10:00000026 r9:f184bb30 r8:c0a57dc4 r7:bf0523c0 r6:ee9974c4 r5:ee9ca4cc
[   10.019212]  r4:d0170f14
[   10.025650] [<c0502e64>] (v4l2_async_test_notify) from [<c0502fdc>] (v4l2_async_register_subdev+0x80/0xdc)
[   10.039736]  r7:d0170fc0 r6:c0a57e08 r5:d0170f14 r4:ee9ca4cc
[   10.049613] [<c0502f5c>] (v4l2_async_register_subdev) from [<bf121154>] (imx_ic_probe+0x108/0x144 [imx_media_ic])
[   10.063953]  r8:d0170f14 r7:bf122cd0 r6:d02c0c10 r5:00000000 r4:d0170f10 r3:00000000
[   10.075786] [<bf12104c>] (imx_ic_probe [imx_media_ic]) from [<c041aeb4>] (platform_drv_probe+0x58/0xb8)
[   10.089118]  r8:00000000 r7:bf123248 r6:fffffdfb r5:d02c0c10 r4:ffffffed r3:bf12104c
[   10.100683] [<c041ae5c>] (platform_drv_probe) from [<c0418ec4>] (driver_probe_device+0x204/0x2c8)
[   10.113279]  r7:bf123248 r6:00000000 r5:c1419d70 r4:d02c0c10
[   10.122765] [<c0418cc0>] (driver_probe_device) from [<c0419044>] (__driver_attach+0xbc/0xc0)
[   10.135098]  r10:00000124 r8:00000001 r7:00000000 r6:d02c0c44 r5:bf123248 r4:d02c0c10
[   10.146785] [<c0418f88>] (__driver_attach) from [<c04172e4>] (bus_for_each_dev+0x5c/0x90)
[   10.158811]  r6:c0418f88 r5:bf123248 r4:00000000 r3:00000000
[   10.168375] [<c0417288>] (bus_for_each_dev) from [<c0418728>] (driver_attach+0x24/0x28)
[   10.180413]  r6:c0a45e10 r5:d03d9c00 r4:bf123248
[   10.188959] [<c0418704>] (driver_attach) from [<c0418428>] (bus_add_driver+0xf4/0x200)
[   10.200775] [<c0418334>] (bus_add_driver) from [<c0419ec4>] (driver_register+0x80/0xfc)
[   10.212707]  r7:00000000 r6:bf126000 r5:c0a704a8 r4:bf123248
[   10.222254] [<c0419e44>] (driver_register) from [<c041ad88>] (__platform_driver_register+0x48/0x4c)
[   10.235212]  r5:c0a704a8 r4:bf123480
[   10.242694] [<c041ad40>] (__platform_driver_register) from [<bf126018>] (imx_ic_driver_init+0x18/0x24 [imx_media_ic])
[   10.257308] [<bf126000>] (imx_ic_driver_init [imx_media_ic]) from [<c00098ac>] (do_one_initcall+0x44/0x170)
[   10.271043] [<c0009868>] (do_one_initcall) from [<c011b1e4>] (do_init_module+0x68/0x1d8)
[   10.283139]  r8:00000001 r7:bf123480 r6:ed4a9440 r5:c0a704a8 r4:bf123480
[   10.293849] [<c011b17c>] (do_init_module) from [<c00d2dd0>] (load_module+0x195c/0x2080)
[   10.305867]  r7:bf123480 r6:c09e04ec r5:c0a704a8 r4:c09f5ea7
[   10.315523] [<c00d1474>] (load_module) from [<c00d36cc>] (SyS_finit_module+0x94/0xa0)
[   10.327382]  r10:00000000 r9:d03ca000 r8:b6c9e63c r7:00000007 r6:00000000 r5:00000000
[   10.339238]  r4:7fffffff
[   10.345766] [<c00d3638>] (SyS_finit_module) from [<c000fd60>] (ret_fast_syscall+0x0/0x1c)
[   10.357994]  r8:c000ff04 r7:0000017b r6:2529fc00 r5:00000000 r4:80c36630
[   10.368747] Code: e1a01007 ebfffce1 e3e0000b e89daff8 (e7f001f2)
[   10.378883] ---[ end trace 2051fac455b36c5a ]---
[   11.228961] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[   11.247536] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[   11.301366] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.

So there's probably some sort of race going on.

However, the following is primerily directed at Laurent as the one who introduced the BUG_ON() in question...

NEVER EVER USE BUG_ON() IN A PATH THAT CAN RETURN AN ERROR.

It's possible to find Linus rants about this, eg,
https://www.spinics.net/lists/stable/msg146439.html

I should have reacted to the damn added BUG_ON() lines. I suspect I will have to finally just remove the idiotic BUG_ON() concept once and for all, because there is NO F*CKING EXCUSE to knowingly kill the kernel.

Also: http://yarchive.net/comp/linux/BUG.html

Rule of thumb: BUG() is only good for something that never happens and that we really have no other option for (ie state is so corrupt that continuing is deadly).

So, _unless_ people want to see BUG_ON() removed from the kernel, I strongly suggest to _STOP_ using it as "we didn't like the function arguments, let's use it as an assert() statement instead of returning an error."

There's no excuse what so ever to be killing the machine in media_create_pad_link(). If it doesn't like a NULL pointer, it's damn well got an error path to report that fact. Use that mechanism and stop needlessly killing the kernel.

BUG_ON() IS NOT ASSERT(). DO NOT USE IT AS SUCH.

Linus is absolutely right about BUG_ON() - it hurts debuggability, because now the only way to do further tests is to reboot the damned machine after removing those fscking BUG_ON()s that should *never* have been there in the first place.

As Linus went on to say:

And dammit, if anybody else feels that they had done "debugging messages with BUG_ON()", I would suggest you

(a) rethink your approach to programming

(b) send me patches to remove the crap entirely, or make them real
*DEBUGGING* messages, not "kill the whole machine" messages.

I've ranted against people using BUG_ON() for debugging in the past. Why the f*ck does this still happen? And Andrew - please stop taking those kinds of patches! Lookie here:

     https://lwn.net/Articles/13183/

so excuse me for being upset that people still do this shit almost 15 years later.

So I suggest people heed that advice and start fixing these stupid BUG_ON()s that they've created.

Thanks.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#142 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 50 lines · Russell King - ARM Linux

However, the following is primerily directed at Laurent as the one who introduced the BUG_ON() in question...

NEVER EVER USE BUG_ON() IN A PATH THAT CAN RETURN AN ERROR.

It's possible to find Linus rants about this, eg,
https://www.spinics.net/lists/stable/msg146439.html

I should have reacted to the damn added BUG_ON() lines. I suspect I will have to finally just remove the idiotic BUG_ON() concept once and for all, because there is NO F*CKING EXCUSE to knowingly kill the kernel.

Also: http://yarchive.net/comp/linux/BUG.html

Rule of thumb: BUG() is only good for something that never happens and that we really have no other option for (ie state is so corrupt that continuing is deadly).

So, _unless_ people want to see BUG_ON() removed from the kernel, I strongly suggest to _STOP_ using it as "we didn't like the function arguments, let's use it as an assert() statement instead of returning an error."

There's no excuse what so ever to be killing the machine in media_create_pad_link(). If it doesn't like a NULL pointer, it's damn well got an error path to report that fact. Use that mechanism and stop needlessly killing the kernel.

BUG_ON() IS NOT ASSERT(). DO NOT USE IT AS SUCH.

Linus is absolutely right about BUG_ON() - it hurts debuggability, because now the only way to do further tests is to reboot the damned machine after removing those fscking BUG_ON()s that should *never* have been there in the first place.

As Linus went on to say:

And dammit, if anybody else feels that they had done "debugging messages with BUG_ON()", I would suggest you

(a) rethink your approach to programming

(b) send me patches to remove the crap entirely, or make them real
*DEBUGGING* messages, not "kill the whole machine" messages.

I've ranted against people using BUG_ON() for debugging in the past. Why the f*ck does this still happen? And Andrew - please stop taking those kinds of patches! Lookie here:

Quoted 7 lines
     https://lwn.net/Articles/13183/

so excuse me for being upset that people still do this shit almost 15 years later.

So I suggest people heed that advice and start fixing these stupid BUG_ON()s that they've created.

More crap.

If the "complete" method fails (or, in fact, anything in v4l2_async_test_notify() fails) then all hell breaks loose, because of the total lack of clean up (and no, this isn't anything to do with some stupid justification of those BUG_ON()s above.)

v4l2_async_notifier_register() gets called, it adds the notifier to the global notifier list. v4l2_async_test_notify() gets called. It returns an error, which is propagated out of v4l2_async_notifier_register().

So the caller thinks that v4l2_async_notifier_register() failed, which will cause imx_media_probe() to fail, causing imxmd->subdev_notifier to be kfree()'d. We now have a use-after free bug.

Second case. v4l2_async_register_subdev(). Almost exactly the same, except in this case adding sd->async_list to the notifier->done list may have succeeded, and failure after that, again, results in an in-use list_head being kfree()'d.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#143 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 71 lines · Russell King - ARM Linux
Quoted 50 lines · Russell King - ARM Linux

However, the following is primerily directed at Laurent as the one who introduced the BUG_ON() in question...

NEVER EVER USE BUG_ON() IN A PATH THAT CAN RETURN AN ERROR.

It's possible to find Linus rants about this, eg,
https://www.spinics.net/lists/stable/msg146439.html

I should have reacted to the damn added BUG_ON() lines. I suspect I will have to finally just remove the idiotic BUG_ON() concept once and for all, because there is NO F*CKING EXCUSE to knowingly kill the kernel.

Also: http://yarchive.net/comp/linux/BUG.html

Rule of thumb: BUG() is only good for something that never happens and that we really have no other option for (ie state is so corrupt that continuing is deadly).

So, _unless_ people want to see BUG_ON() removed from the kernel, I strongly suggest to _STOP_ using it as "we didn't like the function arguments, let's use it as an assert() statement instead of returning an error."

There's no excuse what so ever to be killing the machine in media_create_pad_link(). If it doesn't like a NULL pointer, it's damn well got an error path to report that fact. Use that mechanism and stop needlessly killing the kernel.

BUG_ON() IS NOT ASSERT(). DO NOT USE IT AS SUCH.

Linus is absolutely right about BUG_ON() - it hurts debuggability, because now the only way to do further tests is to reboot the damned machine after removing those fscking BUG_ON()s that should *never* have been there in the first place.

As Linus went on to say:

And dammit, if anybody else feels that they had done "debugging messages with BUG_ON()", I would suggest you

(a) rethink your approach to programming

(b) send me patches to remove the crap entirely, or make them real
*DEBUGGING* messages, not "kill the whole machine" messages.

I've ranted against people using BUG_ON() for debugging in the past. Why the f*ck does this still happen? And Andrew - please stop taking those kinds of patches! Lookie here:

Quoted 7 lines
     https://lwn.net/Articles/13183/

so excuse me for being upset that people still do this shit almost 15 years later.

So I suggest people heed that advice and start fixing these stupid BUG_ON()s that they've created.

More crap.

If the "complete" method fails (or, in fact, anything in v4l2_async_test_notify() fails) then all hell breaks loose, because of the total lack of clean up (and no, this isn't anything to do with some stupid justification of those BUG_ON()s above.)

v4l2_async_notifier_register() gets called, it adds the notifier to the global notifier list. v4l2_async_test_notify() gets called. It returns an error, which is propagated out of v4l2_async_notifier_register().

Quoted 8 lines

So the caller thinks that v4l2_async_notifier_register() failed, which will cause imx_media_probe() to fail, causing imxmd->subdev_notifier to be kfree()'d. We now have a use-after free bug.

Second case. v4l2_async_register_subdev(). Almost exactly the same, except in this case adding sd->async_list to the notifier->done list may have succeeded, and failure after that, again, results in an in-use list_head being kfree()'d.

And here's a patch which, combined with the fixes for ipuv3, results in everything appearing to work properly. Feel free to tear out the bits for your area and turn them into proper patches.

 drivers/gpu/ipu-v3/ipu-common.c           |  6 ---
 drivers/media/media-entity.c              |  7 +--
 drivers/media/v4l2-core/v4l2-async.c      | 71 +++++++++++++++++++++++--------
 drivers/staging/media/imx/imx-media-csi.c |  1 +
 drivers/staging/media/imx/imx-media-dev.c |  2 +-
 5 files changed, 59 insertions(+), 28 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +0 -6
index 97218af4fe75..8368e6f766ee 100644
@@ -1238,12 +1238,6 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 			platform_device_put(pdev);
 			goto err_register;
 		}
-
-		/*
-		 * Set of_node only after calling platform_device_add. Otherwise
-		 * the platform:imx-ipuv3-crtc modalias won't be used.
-		 */
-		pdev->dev.of_node = of_node;
 	}
 
 	return 0;
drivers/media/media-entity.c +4 -3
index f9f723f5e4f0..154593a168df 100644
@@ -625,9 +625,10 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 	struct media_link *link;
 	struct media_link *backlink;
 
-	BUG_ON(source == NULL || sink == NULL);
-	BUG_ON(source_pad >= source->num_pads);
-	BUG_ON(sink_pad >= sink->num_pads);
+	if (WARN_ON(source == NULL || sink == NULL) ||
+	    WARN_ON(source_pad >= source->num_pads) ||
+	    WARN_ON(sink_pad >= sink->num_pads))
+		return -EINVAL;
 
 	link = media_add_link(&source->links);
 	if (link == NULL)
drivers/media/v4l2-core/v4l2-async.c +53 -18

131 lines not on this page · raw message

drivers/staging/media/imx/imx-media-csi.c +1 -0
index 9d9ec03436e4..507026feee91 100644
@@ -1427,6 +1427,7 @@ static int imx_csi_probe(struct platform_device *pdev)
 	priv->sd.entity.ops = &csi_entity_ops;
 	priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
 	priv->sd.dev = &pdev->dev;
+	priv->sd.of_node = pdata->of_node;
 	priv->sd.owner = THIS_MODULE;
 	priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 	priv->sd.grp_id = priv->csi_id ?
drivers/staging/media/imx/imx-media-dev.c +1 -1
index 60f45fe4b506..5b4dfc1fb6ab 100644
@@ -197,7 +197,7 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
 	struct imx_media_subdev *imxsd;
 	int ret = -EINVAL;
 
-	imxsd = imx_media_find_async_subdev(imxmd, sd->dev->of_node,
+	imxsd = imx_media_find_async_subdev(imxmd, sd->of_node,
 					    dev_name(sd->dev));
 	if (!imxsd)
 		goto out;
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#144 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 40 lines · Russell King - ARM Linux
Quoted 14 lines · Russell King - ARM Linux

<snip>
More crap.

If the "complete" method fails (or, in fact, anything in v4l2_async_test_notify() fails) then all hell breaks loose, because of the total lack of clean up (and no, this isn't anything to do with some stupid justification of those BUG_ON()s above.)

v4l2_async_notifier_register() gets called, it adds the notifier to the global notifier list. v4l2_async_test_notify() gets called. It returns an error, which is propagated out of v4l2_async_notifier_register().

Quoted 8 lines

So the caller thinks that v4l2_async_notifier_register() failed, which will cause imx_media_probe() to fail, causing imxmd->subdev_notifier to be kfree()'d. We now have a use-after free bug.

Second case. v4l2_async_register_subdev(). Almost exactly the same, except in this case adding sd->async_list to the notifier->done list may have succeeded, and failure after that, again, results in an in-use list_head being kfree()'d.

And here's a patch which, combined with the fixes for ipuv3, results in everything appearing to work properly. Feel free to tear out the bits for your area and turn them into proper patches.

 drivers/gpu/ipu-v3/ipu-common.c           |  6 ---
 drivers/media/media-entity.c              |  7 +--
 drivers/media/v4l2-core/v4l2-async.c      | 71 +++++++++++++++++++++++--------
 drivers/staging/media/imx/imx-media-csi.c |  1 +
 drivers/staging/media/imx/imx-media-dev.c |  2 +-
 5 files changed, 59 insertions(+), 28 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +0 -0
index 97218af4fe75..8368e6f766ee 100644

drivers/gpu/ipu-v3/ipu-common.c static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) · line 1241

Quoted 10 lines
drivers/gpu/ipu-v3/ipu-common.c +0 -6
@@ -1238,12 +1238,6 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 			platform_device_put(pdev);
 			goto err_register;
 		}
-
-		/*
-		 * Set of_node only after calling platform_device_add. Otherwise
-		 * the platform:imx-ipuv3-crtc modalias won't be used.
-		 */
-		pdev->dev.of_node = of_node;
 	}

Ah, never mind my question earlier, I see now why the CSI's were likely not recognized, probably because of this. Anyway I agree with this change and I made the accompanying requisite change to imx-media-csi.c and imx-media-dev.c below.

Steve

Quoted 189 lines
drivers/gpu/ipu-v3/ipu-common.c +0 -0
 	return 0;
drivers/media/media-entity.c +4 -3
index f9f723f5e4f0..154593a168df 100644
@@ -625,9 +625,10 @@ media_create_pad_link(struct media_entity *source, u16 source_pad,
 	struct media_link *link;
 	struct media_link *backlink;
 
-	BUG_ON(source == NULL || sink == NULL);
-	BUG_ON(source_pad >= source->num_pads);
-	BUG_ON(sink_pad >= sink->num_pads);
+	if (WARN_ON(source == NULL || sink == NULL) ||
+	    WARN_ON(source_pad >= source->num_pads) ||
+	    WARN_ON(sink_pad >= sink->num_pads))
+		return -EINVAL;
 
 	link = media_add_link(&source->links);
 	if (link == NULL)
drivers/media/v4l2-core/v4l2-async.c +53 -18
index 5bada202b2d3..09934fb96a8d 100644
@@ -94,7 +94,7 @@ static struct v4l2_async_subdev *v4l2_async_belongs(struct v4l2_async_notifier *
 }
 
 static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
-				  struct v4l2_subdev *sd,
+				  struct list_head *new, struct v4l2_subdev *sd,
 				  struct v4l2_async_subdev *asd)
 {
 	int ret;
@@ -107,22 +107,36 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
 	if (notifier->bound) {
 		ret = notifier->bound(notifier, sd, asd);
 		if (ret < 0)
-			return ret;
+			goto err_bind;
 	}
+
 	/* Move from the global subdevice list to notifier's done */
-	list_move(&sd->async_list, &notifier->done);
+	list_move(&sd->async_list, new);
 
 	ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
-	if (ret < 0) {
-		if (notifier->unbind)
-			notifier->unbind(notifier, sd, asd);
-		return ret;
-	}
+	if (ret < 0)
+		goto err_register;
 
-	if (list_empty(&notifier->waiting) && notifier->complete)
-		return notifier->complete(notifier);
+	if (list_empty(&notifier->waiting) && notifier->complete) {
+		ret = notifier->complete(notifier);
+		if (ret < 0)
+			goto err_complete;
+	}
 
 	return 0;
+
+err_complete:
+	v4l2_device_unregister_subdev(sd);
+err_register:
+	if (notifier->unbind)
+		notifier->unbind(notifier, sd, asd);
+err_bind:
+	sd->notifier = NULL;
+	sd->asd = NULL;
+	list_add(&asd->list, &notifier->waiting);
+	/* always take this off the list on error */
+	list_del(&sd->async_list);
+	return ret;
 }
 
 static void v4l2_async_cleanup(struct v4l2_subdev *sd)
@@ -139,7 +153,8 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
 {
 	struct v4l2_subdev *sd, *tmp;
 	struct v4l2_async_subdev *asd;
-	int i;
+	LIST_HEAD(new);
+	int ret, i;
 
 	if (!notifier->num_subdevs || notifier->num_subdevs > V4L2_MAX_SUBDEVS)
 		return -EINVAL;
@@ -172,22 +187,39 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
 	list_add(&notifier->list, &notifier_list);
 
 	list_for_each_entry_safe(sd, tmp, &subdev_list, async_list) {
-		int ret;
-
 		asd = v4l2_async_belongs(notifier, sd);
 		if (!asd)
 			continue;
 
-		ret = v4l2_async_test_notify(notifier, sd, asd);
+		ret = v4l2_async_test_notify(notifier, &new, sd, asd);
 		if (ret < 0) {
-			mutex_unlock(&list_lock);
-			return ret;
+			/*
+			 * On failure, v4l2_async_test_notify() takes the
+			 * sd off the subdev list.  Add it back.
+			 */
+			list_add(&sd->async_list, &subdev_list);
+			goto err_notify;
 		}
 	}
 
+	list_splice(&new, &notifier->done);
+
 	mutex_unlock(&list_lock);
 
 	return 0;
+
+err_notify:
+	list_del(&notifier->list);
+	list_for_each_entry_safe(sd, tmp, &new, async_list) {
+		v4l2_device_unregister_subdev(sd);
+		list_move(&sd->async_list, &subdev_list);
+		if (notifier->unbind)
+			notifier->unbind(notifier, sd, sd->asd);
+		sd->notifier = NULL;
+		sd->asd = NULL;
+	}
+	mutex_unlock(&list_lock);
+	return ret;
 }
 EXPORT_SYMBOL(v4l2_async_notifier_register);
 
@@ -213,6 +245,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 	list_del(&notifier->list);
 
 	list_for_each_entry_safe(sd, tmp, &notifier->done, async_list) {
+		struct v4l2_async_subdev *asd = sd->asd;
 		struct device *d;
 
 		d = get_device(sd->dev);
@@ -223,7 +256,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 		device_release_driver(d);
 
 		if (notifier->unbind)
-			notifier->unbind(notifier, sd, sd->asd);
+			notifier->unbind(notifier, sd, asd);
 
 		/*
 		 * Store device at the device cache, in order to call
@@ -288,7 +321,9 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
 	list_for_each_entry(notifier, &notifier_list, list) {
 		struct v4l2_async_subdev *asd = v4l2_async_belongs(notifier, sd);
 		if (asd) {
-			int ret = v4l2_async_test_notify(notifier, sd, asd);
+			int ret = v4l2_async_test_notify(notifier,
+							 &notifier->done,
+							 sd, asd);
 			mutex_unlock(&list_lock);
 			return ret;
 		}
drivers/staging/media/imx/imx-media-csi.c +1 -0
index 9d9ec03436e4..507026feee91 100644
@@ -1427,6 +1427,7 @@ static int imx_csi_probe(struct platform_device *pdev)
 	priv->sd.entity.ops = &csi_entity_ops;
 	priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
 	priv->sd.dev = &pdev->dev;
+	priv->sd.of_node = pdata->of_node;
 	priv->sd.owner = THIS_MODULE;
 	priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 	priv->sd.grp_id = priv->csi_id ?
drivers/staging/media/imx/imx-media-dev.c +1 -1
index 60f45fe4b506..5b4dfc1fb6ab 100644
@@ -197,7 +197,7 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
 	struct imx_media_subdev *imxsd;
 	int ret = -EINVAL;
 
-	imxsd = imx_media_find_async_subdev(imxmd, sd->dev->of_node,
+	imxsd = imx_media_find_async_subdev(imxmd, sd->of_node,
 					    dev_name(sd->dev));
 	if (!imxsd)
 		goto out;
author maintainer
#145 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

In reply to Russell King - ARM Linux
Quoted 61 lines · Russell King - ARM Linux
Quoted 54 lines · Russell King - ARM Linux
Quoted 10 lines · Steve Longerbeam
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+static const struct platform_device_id imx_csi_ids[] = {
+	{ .name = "imx-ipuv3-csi" },
+	{ },
+};
+MODULE_DEVICE_TABLE(platform, imx_csi_ids);
+
+static struct platform_driver imx_csi_driver = {
+	.probe = imx_csi_probe,
+	.remove = imx_csi_remove,
+	.id_table = imx_csi_ids,

drivers/staging/media/imx/imx-media-csi.c line 1220

Quoted 10 lines
drivers/staging/media/imx/imx-media-csi.c new file +10 -0
+	.driver = {
+		.name = "imx-ipuv3-csi",
+	},
+};
+module_platform_driver(imx_csi_driver);
+
+MODULE_DESCRIPTION("i.MX CSI subdev driver");
+MODULE_AUTHOR("Steve Longerbeam <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:imx-ipuv3-csi");

Just a reminder that automatic module loading of this is completely broken right now (not your problem) due to this stupid idea in the IPUv3 code:

		if (!ret)
			ret = platform_device_add(pdev);
		if (ret) {
			platform_device_put(pdev);
			goto err_register;
		}

		/*
		 * Set of_node only after calling platform_device_add. Otherwise
		 * the platform:imx-ipuv3-crtc modalias won't be used.
		 */
		pdev->dev.of_node = of_node;

setting pdev->dev.of_node changes the modalias exported to userspace, so udev sees a DT based modalias, which causes it to totally miss any driver using a non-DT based modalias.

The IPUv3 code needs fixing, not only for imx-media-csi, but also for imx-ipuv3-crtc too, because that module will also suffer the same issue.

The only solution is... don't fsck with dev->of_node assignment. In this case, it's probably much better to pass it in via platform data. If you then absolutely must have dev->of_node, doing it in the driver means that you avoid the modalias mess before the appropriate driver is loaded. However, that's still not a nice solution because the modalias file still ends up randomly changing its contents.

Quoted 2 lines

As I say, not _your_ problem, but it's still a problem that needs solving, and I don't want it forgotten about.

I've just hacked up a solution to this, and unfortunately it reveals a problem with Steve's code. Picking out the imx & media-related messages:

Quoted 12 lines
[    8.012191] imx_media_common: module is from the staging directory, the quality is unknown, you have been warned.
[    8.018175] imx_media: module is from the staging directory, the quality is unknown, you have been warned.
[    8.748345] imx-media: Registered subdev ipu1_csi0_mux
[    8.753451] imx-media: Registered subdev ipu2_csi1_mux
[    9.055196] imx219 0-0010: detected IMX219 sensor
[    9.090733] imx6_mipi_csi2: module is from the staging directory, the quality is unknown, you have been warned.
[    9.092247] imx-media: Registered subdev imx219 0-0010
[    9.334338] imx-media: Registered subdev imx6-mipi-csi2
[    9.372452] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.378163] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.390033] imx_media_csi: module is from the staging directory, the quality is unknown, you have been warned.
[    9.394362] imx-media: Received unknown subdev ipu1_csi0

The root problem is here. I don't know why the CSI entities are not being recognized. Can you share the changes you made?

So imx_media_subdev_bound() returns error because it didn't recognize the subdev that was bound.

And for some reason, even though some of the subdev bound ops return error, v4l2-core still calls the async completion notifier (imx_media_probe_complete()).

I'll add some checks to imx_media_probe_complete() to try and detect when not all subdevs were bound correctly to get around this issue. That should prevent the kernel BUG() below.

Steve

Quoted 180 lines
[    9.394699] imx-ipuv3-csi: probe of imx-ipuv3-csi.0 failed with error -22
[    9.394840] imx-media: Received unknown subdev ipu1_csi1
[    9.394887] imx-ipuv3-csi: probe of imx-ipuv3-csi.1 failed with error -22
[    9.394992] imx-media: Received unknown subdev ipu2_csi0
[    9.395026] imx-ipuv3-csi: probe of imx-ipuv3-csi.4 failed with error -22
[    9.395119] imx-media: Received unknown subdev ipu2_csi1
[    9.395159] imx-ipuv3-csi: probe of imx-ipuv3-csi.5 failed with error -22
[    9.411722] imx_media_vdic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.412820] imx-media: Registered subdev ipu1_vdic
[    9.424687] imx-media: Registered subdev ipu2_vdic
[    9.436074] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.437455] imx-media: Registered subdev ipu1_ic_prp
[    9.437788] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.447542] imx-media: Registered subdev ipu1_ic_prpenc
[    9.455225] ipu1_ic_prpenc: Registered ipu1_ic_prpenc capture as /dev/video3
[    9.459203] imx-media: Registered subdev ipu1_ic_prpvf
[    9.460484] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[    9.460726] ipu1_ic_prpvf: Registered ipu1_ic_prpvf capture as /dev/video4
[    9.460983] imx-media: Registered subdev ipu2_ic_prp
[    9.461161] imx-media: Registered subdev ipu2_ic_prpenc
[    9.461737] ipu2_ic_prpenc: Registered ipu2_ic_prpenc capture as /dev/video5
[    9.463767] imx-media: Registered subdev ipu2_ic_prpvf
[    9.464294] ipu2_ic_prpvf: Registered ipu2_ic_prpvf capture as /dev/video6
[    9.464345] imx-media: imx_media_create_link: (null):1 -> ipu1_ic_prp:0
[    9.464413] ------------[ cut here ]------------
[    9.469134] kernel BUG at /home/rmk/git/linux-rmk/drivers/media/media-entity.c:628!
[    9.476924] Internal error: Oops - BUG: 0 [#1] SMP ARM
[    9.482246] Modules linked in: imx_media_ic(C+) imx_media_vdic(C) imx_media_csi(C) imx_media_capture(C) uvcvideo imx6_mipi_csi2(C) snd_soc_imx_audmux imx219 snd_soc_sgtl5000 video_multiplexer caam imx_sdma imx2_wdt snd_soc_fsl_ssi snd_soc_fsl_spdif imx_pcm_dma coda imx_thermal v4l2_mem2mem videobuf2_v4l2 videobuf2_dma_contig videobuf2_core videobuf2_vmalloc videobuf2_memops imx_media(C) imx_media_common(C) rc_pinnacle_pctv_hd nfsd dw_hdmi_cec dw_hdmi_ahb_audio etnaviv
[    9.524500] CPU: 1 PID: 263 Comm: systemd-udevd Tainted: G         C      4.10.0-rc7+ #2112
[    9.532995] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[    9.539619] task: edef1880 task.stack: d03ca000
[    9.544313] PC is at media_create_pad_link+0x134/0x140
[    9.549541] LR is at imx_media_probe_complete+0x164/0x24c [imx_media]
[    9.556080] pc : [<c04f0eb0>]    lr : [<bf052524>]    psr: 60070013
               sp : d03cbbc8  ip : d03cbbf8  fp : d03cbbf4
[    9.567712] r10: 00000001  r9 : 00000000  r8 : d0170d14
[    9.573007] r7 : 00000000  r6 : 00000001  r5 : 00000000  r4 : d0170d14
[    9.579612] r3 : 00000000  r2 : d0170d14  r1 : 00000001  r0 : 00000000
[    9.586256] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none[    9.593486] Control: 10c5387d  Table: 3e77c04a  DAC: 00000051
[    9.599317] Process systemd-udevd (pid: 263, stack limit = 0xd03ca210)
[    9.605950] Stack: (0xd03cbbc8 to 0xd03cc000)
[    9.610368] bbc0:                   00000000 00000000 ee980410 00000000 00000000 d0170d14
[    9.618658] bbe0: 00000000 00000001 d03cbc54 d03cbbf8 bf052524 c04f0d88 00000000 d0170d88
[    9.626961] bc00: 00000000 c0a57dc4 0004a364 ee98011c 00000000 00000003 00000001 ee980230
[    9.635267] bc20: ee980274 ee980010 d03cbc54 d0170f14 ee9ca4cc ee9974c4 bf0523c0 c0a57dc4
[    9.643539] bc40: f184bb30 00000026 d03cbc74 d03cbc58 c0502f50 bf0523cc ee9ca4cc d0170f14
[    9.651824] bc60: c0a57e08 d0170fc0 d03cbc9c d03cbc78 c0502fdc c0502e70 00000000 d0170f10
[    9.660132] bc80: 00000000 d02c0c10 bf122cd0 d0170f14 d03cbcc4 d03cbca0 bf121154 c0502f68
[    9.668423] bca0: bf12104c ffffffed d02c0c10 fffffdfb bf123248 00000000 d03cbce4 d03cbcc8
[    9.676713] bcc0: c041aeb4 bf121058 d02c0c10 c1419d70 00000000 bf123248 d03cbd0c d03cbce8
[    9.684992] bce0: c0418ec4 c041ae68 d02c0c10 bf123248 d02c0c44 00000000 00000001 00000124
[    9.693282] bd00: d03cbd2c d03cbd10 c0419044 c0418ccc 00000000 00000000 bf123248 c0418f88
[    9.701618] bd20: d03cbd54 d03cbd30 c04172e4 c0418f94 ef0f64a4 d01b8cd0 d03d9858 bf123248
[    9.709900] bd40: d03d9c00 c0a45e10 d03cbd64 d03cbd58 c0418728 c0417294 d03cbd8c d03cbd68
[    9.718203] bd60: c0418428 c0418710 bf122e48 d03cbd78 bf123248 c0a704a8 bf126000 00000000
[    9.729180] bd80: d03cbda4 d03cbd90 c0419ec4 c0418340 bf123480 c0a704a8 d03cbdb4 d03cbda8
[    9.739950] bda0: c041ad88 c0419e50 d03cbdc4 d03cbdb8 bf126018 c041ad4c d03cbe34 d03cbdc8
[    9.751089] bdc0: c00098ac bf12600c d03cbdec d03cbdd8 c00a8888 c0087240 00000000 ed4a9440
[    9.761941] bde0: d03cbe34 d03cbdf0 c016c690 c00a8814 c016b554 c016aa60 00000001 c015f3f8
[    9.772940] be00: 00000005 0000000c edef1880 bf123480 c0a704a8 bf123480 c0a704a8 ed4a9440
[    9.784008] be20: bf123480 00000001 d03cbe5c d03cbe38 c011b1e4 c0009874 d03cbe5c d03cbe48
[    9.795017] be40: c09f5ea7 c0a704a8 c09e04ec bf123480 d03cbf14 d03cbe60 c00d2dd0 c011b188
[    9.806069] be60: bf12348c 00007fff bf123480 c00d09f0 f1847000 bf12792c f18495c0 bf123680
[    9.817194] be80: bf12348c bf1236f0 00000000 bf1234c8 c017c1d0 c017bfac f1847000 00004f68
[    9.828347] bea0: c017c2e8 00000000 edef1880 00000000 00000000 00000000 00000000 00000000
[    9.839542] bec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    9.850754] bee0: 00000000 00000000 00000003 7fffffff 00000000 00000000 00000007 b6c9e63c
[    9.861991] bf00: d03ca000 00000000 d03cbfa4 d03cbf18 c00d36cc c00d1480 7fffffff 00000000
[    9.873266] bf20: 00000003 ee0384d4 d03cbf74 f1847000 00004f68 00000000 00000002 f1847000
[    9.884593] bf40: 00004f68 f184bb30 f184989b f184a7d8 000026f0 00002dd0 00000000 00000000
[    9.895998] bf60: 00000000 0000192c 00000019 0000001a 00000011 00000000 0000000a 00000000
[    9.907408] bf80: c008b848 80c36630 00000000 2529fc00 0000017b c000ff04 00000000 d03cbfa8
[    9.918858] bfa0: c000fd60 c00d3644 80c36630 00000000 00000007 b6c9e63c 00000000 80c38178
[    9.930354] bfc0: 80c36630 00000000 2529fc00 0000017b 00020000 7f96eb0c 80c37848 00000000
[    9.941900] bfe0: bed55928 bed55918 b6c988ff b6bea572 600f0030 00000007 3fffd861 3fffdc61
[    9.953532] Backtrace:
[    9.959442] [<c04f0d7c>] (media_create_pad_link) from [<bf052524>] (imx_media_probe_complete+0x164/0x24c [imx_media])
[    9.973644]  r10:00000001 r9:00000000 r8:d0170d14 r7:00000000 r6:00000000 r5:ee980410
[    9.985112]  r4:00000000 r3:00000000
[    9.992696] [<bf0523c0>] (imx_media_probe_complete [imx_media]) from [<c0502f50>] (v4l2_async_test_notify+0xec/0xf8)
[   10.007413]  r10:00000026 r9:f184bb30 r8:c0a57dc4 r7:bf0523c0 r6:ee9974c4 r5:ee9ca4cc
[   10.019212]  r4:d0170f14
[   10.025650] [<c0502e64>] (v4l2_async_test_notify) from [<c0502fdc>] (v4l2_async_register_subdev+0x80/0xdc)
[   10.039736]  r7:d0170fc0 r6:c0a57e08 r5:d0170f14 r4:ee9ca4cc
[   10.049613] [<c0502f5c>] (v4l2_async_register_subdev) from [<bf121154>] (imx_ic_probe+0x108/0x144 [imx_media_ic])
[   10.063953]  r8:d0170f14 r7:bf122cd0 r6:d02c0c10 r5:00000000 r4:d0170f10 r3:00000000
[   10.075786] [<bf12104c>] (imx_ic_probe [imx_media_ic]) from [<c041aeb4>] (platform_drv_probe+0x58/0xb8)
[   10.089118]  r8:00000000 r7:bf123248 r6:fffffdfb r5:d02c0c10 r4:ffffffed r3:bf12104c
[   10.100683] [<c041ae5c>] (platform_drv_probe) from [<c0418ec4>] (driver_probe_device+0x204/0x2c8)
[   10.113279]  r7:bf123248 r6:00000000 r5:c1419d70 r4:d02c0c10
[   10.122765] [<c0418cc0>] (driver_probe_device) from [<c0419044>] (__driver_attach+0xbc/0xc0)
[   10.135098]  r10:00000124 r8:00000001 r7:00000000 r6:d02c0c44 r5:bf123248 r4:d02c0c10
[   10.146785] [<c0418f88>] (__driver_attach) from [<c04172e4>] (bus_for_each_dev+0x5c/0x90)
[   10.158811]  r6:c0418f88 r5:bf123248 r4:00000000 r3:00000000
[   10.168375] [<c0417288>] (bus_for_each_dev) from [<c0418728>] (driver_attach+0x24/0x28)
[   10.180413]  r6:c0a45e10 r5:d03d9c00 r4:bf123248
[   10.188959] [<c0418704>] (driver_attach) from [<c0418428>] (bus_add_driver+0xf4/0x200)
[   10.200775] [<c0418334>] (bus_add_driver) from [<c0419ec4>] (driver_register+0x80/0xfc)
[   10.212707]  r7:00000000 r6:bf126000 r5:c0a704a8 r4:bf123248
[   10.222254] [<c0419e44>] (driver_register) from [<c041ad88>] (__platform_driver_register+0x48/0x4c)
[   10.235212]  r5:c0a704a8 r4:bf123480
[   10.242694] [<c041ad40>] (__platform_driver_register) from [<bf126018>] (imx_ic_driver_init+0x18/0x24 [imx_media_ic])
[   10.257308] [<bf126000>] (imx_ic_driver_init [imx_media_ic]) from [<c00098ac>] (do_one_initcall+0x44/0x170)
[   10.271043] [<c0009868>] (do_one_initcall) from [<c011b1e4>] (do_init_module+0x68/0x1d8)
[   10.283139]  r8:00000001 r7:bf123480 r6:ed4a9440 r5:c0a704a8 r4:bf123480
[   10.293849] [<c011b17c>] (do_init_module) from [<c00d2dd0>] (load_module+0x195c/0x2080)
[   10.305867]  r7:bf123480 r6:c09e04ec r5:c0a704a8 r4:c09f5ea7
[   10.315523] [<c00d1474>] (load_module) from [<c00d36cc>] (SyS_finit_module+0x94/0xa0)
[   10.327382]  r10:00000000 r9:d03ca000 r8:b6c9e63c r7:00000007 r6:00000000 r5:00000000
[   10.339238]  r4:7fffffff
[   10.345766] [<c00d3638>] (SyS_finit_module) from [<c000fd60>] (ret_fast_syscall+0x0/0x1c)
[   10.357994]  r8:c000ff04 r7:0000017b r6:2529fc00 r5:00000000 r4:80c36630
[   10.368747] Code: e1a01007 ebfffce1 e3e0000b e89daff8 (e7f001f2)
[   10.378883] ---[ end trace 2051fac455b36c5a ]---
[   11.228961] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[   11.247536] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.
[   11.301366] imx_media_ic: module is from the staging directory, the quality is unknown, you have been warned.

So there's probably some sort of race going on.

However, the following is primerily directed at Laurent as the one who introduced the BUG_ON() in question...

NEVER EVER USE BUG_ON() IN A PATH THAT CAN RETURN AN ERROR.

It's possible to find Linus rants about this, eg,
https://www.spinics.net/lists/stable/msg146439.html

I should have reacted to the damn added BUG_ON() lines. I suspect I will have to finally just remove the idiotic BUG_ON() concept once and for all, because there is NO F*CKING EXCUSE to knowingly kill the kernel.

Also: http://yarchive.net/comp/linux/BUG.html

Rule of thumb: BUG() is only good for something that never happens and that we really have no other option for (ie state is so corrupt that continuing is deadly).

So, _unless_ people want to see BUG_ON() removed from the kernel, I strongly suggest to _STOP_ using it as "we didn't like the function arguments, let's use it as an assert() statement instead of returning an error."

There's no excuse what so ever to be killing the machine in media_create_pad_link(). If it doesn't like a NULL pointer, it's damn well got an error path to report that fact. Use that mechanism and stop needlessly killing the kernel.

BUG_ON() IS NOT ASSERT(). DO NOT USE IT AS SUCH.

Linus is absolutely right about BUG_ON() - it hurts debuggability, because now the only way to do further tests is to reboot the damned machine after removing those fscking BUG_ON()s that should *never* have been there in the first place.

As Linus went on to say:

And dammit, if anybody else feels that they had done "debugging messages with BUG_ON()", I would suggest you

(a) rethink your approach to programming

(b) send me patches to remove the crap entirely, or make them real
*DEBUGGING* messages, not "kill the whole machine" messages.

I've ranted against people using BUG_ON() for debugging in the past. Why the f*ck does this still happen? And Andrew - please stop taking those kinds of patches! Lookie here:

     https://lwn.net/Articles/13183/

so excuse me for being upset that people still do this shit almost 15 years later.

So I suggest people heed that advice and start fixing these stupid BUG_ON()s that they've created.

Thanks.

#146 lore raw

Re: [PATCH v4 20/36] media: imx: Add CSI subdev driver

Quoted 14 lines · Steve Longerbeam
Quoted 4 lines · Russell King - ARM Linux
[    8.012191] imx_media_common: module is from the staging directory, the quality is unknown, you have been warned.
[    8.018175] imx_media: module is from the staging directory, the quality is unknown, you have been warned.
[    8.748345] imx-media: Registered subdev ipu1_csi0_mux
[    8.753451] imx-media: Registered subdev ipu2_csi1_mux
Quoted 8 lines
[    9.055196] imx219 0-0010: detected IMX219 sensor
[    9.090733] imx6_mipi_csi2: module is from the staging directory, the quality is unknown, you have been warned.
[    9.092247] imx-media: Registered subdev imx219 0-0010
[    9.334338] imx-media: Registered subdev imx6-mipi-csi2
[    9.372452] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.378163] imx_media_capture: module is from the staging directory, the quality is unknown, you have been warned.
[    9.390033] imx_media_csi: module is from the staging directory, the quality is unknown, you have been warned.
[    9.394362] imx-media: Received unknown subdev ipu1_csi0
Quoted 2 lines

The root problem is here. I don't know why the CSI entities are not being recognized. Can you share the changes you made?

No, it's not the root problem that's causing the BUG/etc, but it is _a_ problem. Nevertheless, it's something I fixed - disconnecting the of_node from the struct device needed one other change in the imx-media code that was missing at this time.

However, that's no excuse what so ever for the BUG_ON() and lack of error cleanup (causing use-after-free, which is just another way of saying "data corruption waiting to happen") that I identified.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
author maintainer
#147 lore raw

PATCH v4 21/36 media: imx: Add VDIC subdev driver

In reply to Steve Longerbeam

This is a media entity subdevice driver for the i.MX Video De-Interlacing or Combining Block. So far this entity does not implement the Combining function but only motion compensated deinterlacing. Video frames are received from the CSI and are routed to the IC PRPVF entity.

---
 drivers/staging/media/imx/Makefile         |   1 +
 drivers/staging/media/imx/imx-media-vdic.c | 886 +++++++++++++++++++++++++++++
 2 files changed, 887 insertions(+)
 create mode 100644 drivers/staging/media/imx/imx-media-vdic.c
drivers/staging/media/imx/Makefile +1 -0
index c054490..1f01520 100644
@@ -4,5 +4,6 @@ imx-media-common-objs := imx-media-utils.o imx-media-fim.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
 obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-capture.o
+obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o
 
 obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
drivers/staging/media/imx/imx-media-vdic.c new file +886 -0

886 lines not on this page · raw message

Signature · 1 line
2.7.4