i.MX Media Driver
Subsystems (11)
Steve Longerbeam
maintainerv7 cover i.MX Media Driver
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to Documentation/media/v4l-drivers/imx.rst.
- ov5640: do nothing if entity stream count is greater than 1 in ov5640_s_stream().
- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls() used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.
These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the v4l2_pipeline_inherit_controls() patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.
- A new function imx_media_fill_default_mbus_fields() is added to setup colorimetry at sink pads, and these are propagated to source pads.
- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the s_stream() subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely in s_stream(), and s_power() is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.
- Converted the v4l2_subdev and media_entity ops structures to const.
Marek Vasut (1):
media: imx: Drop warning upon multiple S_STREAM disable calls
Philipp Zabel (9):
dt-bindings: Add bindings for video-multiplexer device
ARM: dts: imx6qdl: add multiplexer controls
ARM: dts: imx6qdl: Add video multiplexers, mipi_csi, and their
connections
add mux and video interface bridge entity functions
platform: add video-multiplexer subdevice driver
platform: video-mux: include temporary mmio-mux support
media: imx: csi: increase burst size for YUV formats
media: imx: csi: add frame skipping support
media: imx: csi: add sink selection rectangles
Russell King (3):
media: imx: csi: add support for bayer formats
media: imx: csi: add frame size/interval enumeration
media: imx: capture: add frame sizes/interval enumeration
Steve Longerbeam (21):
[media] dt-bindings: Add bindings for i.MX media driver [media] dt/bindings: Add bindings for OV5640
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] add Omnivision OV5640 sensor driver
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
ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers
media: imx: set and propagate default field, colorimetry
.../devicetree/bindings/media/i2c/ov5640.txt | 45 + Documentation/devicetree/bindings/media/imx.txt | 74 + .../devicetree/bindings/media/video-mux.txt | 60 + Documentation/media/uapi/mediactl/media-types.rst | 22 + Documentation/media/v4l-drivers/imx.rst | 590 ++++++ arch/arm/boot/dts/imx6dl-sabrelite.dts | 5 + arch/arm/boot/dts/imx6dl-sabresd.dts | 5 + arch/arm/boot/dts/imx6dl.dtsi | 189 ++ arch/arm/boot/dts/imx6q-sabrelite.dts | 5 + arch/arm/boot/dts/imx6q-sabresd.dts | 5 + arch/arm/boot/dts/imx6q.dtsi | 125 ++ 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 | 20 +- arch/arm/configs/imx_v6_v7_defconfig | 11 + drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++ drivers/media/platform/Kconfig | 6 + drivers/media/platform/Makefile | 2 + drivers/media/platform/video-mux.c | 357 ++++ 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 | 15 + drivers/staging/media/imx/imx-ic-common.c | 113 + drivers/staging/media/imx/imx-ic-prp.c | 514 +++++ drivers/staging/media/imx/imx-ic-prpencvf.c | 1309 ++++++++++++ drivers/staging/media/imx/imx-ic.h | 38 + drivers/staging/media/imx/imx-media-capture.c | 775 +++++++ drivers/staging/media/imx/imx-media-csi.c | 1842 ++++++++++++++++ drivers/staging/media/imx/imx-media-dev.c | 665 ++++++ 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 | 268 +++ drivers/staging/media/imx/imx-media-utils.c | 896 ++++++++ drivers/staging/media/imx/imx-media-vdic.c | 1009 +++++++++ drivers/staging/media/imx/imx-media.h | 326 +++ drivers/staging/media/imx/imx6-mipi-csi2.c | 697 ++++++ include/linux/imx-media.h | 27 + include/media/imx.h | 15 + include/uapi/linux/media.h | 6 + include/uapi/linux/v4l2-controls.h | 4 + 45 files changed, 13504 insertions(+), 27 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-mux.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-mux.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/linux/imx-media.h create mode 100644 include/media/imx.h
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 1/34 dt-bindings: Add bindings for video-multiplexer device
From: Philipp Zabel <[email protected]>
Add bindings documentation for the video multiplexer device.
--- .../devicetree/bindings/media/video-mux.txt | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/video-mux.txt
Documentation/devicetree/bindings/media/video-mux.txt new file +60 -0
@@ -0,0 +1,60 @@ +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 are controlled by a multiplexer controller that is described by +the bindings in Documentation/devicetree/bindings/mux/mux-controller.txt + +Required properties: +- compatible : should be "video-mux" +- mux-controls : mux controller node to use for operating the mux +- #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. + +Optionally, #address-cells, #size-cells, and port nodes can be grouped under a +ports node as described in Documentation/devicetree/bindings/graph.txt. + +Example: + + mux: mux-controller { + compatible = "gpio-mux"; + #mux-control-cells = <0>; + + mux-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>; + }; + + video-mux { + compatible = "video-mux"; + mux-controls = <&mux>; + #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>; + }; + }; + }; +};
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 2/34 dt-bindings: Add bindings for i.MX media driver
In reply to Steve LongerbeamAdd bindings documentation for the i.MX media driver.
--- Documentation/devicetree/bindings/media/imx.txt | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/imx.txt
Documentation/devicetree/bindings/media/imx.txt new file +74 -0
@@ -0,0 +1,74 @@ +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,imx-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 D-PHY clock), video_27m (D-PHY PLL reference + clock), and eim_podf; +- clock-names : must contain "dphy", "ref", "pix"; +- port@* : five port nodes must exist, containing endpoints + connecting to the source and sink devices according to + of_graph bindings. The first port is an input port, + connecting with a MIPI CSI-2 source, and ports 1 + through 4 are output ports connecting with parallel + bus sink endpoint nodes and correspond to the four + MIPI CSI-2 virtual channel outputs. + +Optional properties: +- interrupts : must contain two level-triggered interrupts, + in order: 100 and 101;
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 3/34 dt/bindings: Add bindings for OV5640
In reply to Steve LongerbeamAdd device tree binding documentation for the OV5640 camera sensor.
--- .../devicetree/bindings/media/i2c/ov5640.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt
Documentation/devicetree/bindings/media/i2c/ov5640.txt new file +45 -0
@@ -0,0 +1,45 @@ +* Omnivision OV5640 MIPI CSI-2 sensor + +Required Properties: +- compatible: should be "ovti,ov5640" +- clocks: reference to the xclk input clock. +- clock-names: should be "xclk". +- DOVDD-supply: Digital I/O voltage supply, 1.8 volts +- AVDD-supply: Analog voltage supply, 2.8 volts +- DVDD-supply: Digital core voltage supply, 1.5 volts + +Optional Properties: +- reset-gpios: reference to the GPIO connected to the reset pin, if any. + This is an active low signal to the OV5640. +- powerdown-gpios: reference to the GPIO connected to the powerdown pin, + if any. This is an active high signal to the OV5640. + +The device node must contain one 'port' child node for its digital output +video port, in accordance with the video interface bindings defined in +Documentation/devicetree/bindings/media/video-interfaces.txt. + +Example: + +&i2c1 { + ov5640: camera at 3c { + compatible = "ovti,ov5640"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ov5640>; + reg = <0x3c>; + clocks = <&clks IMX6QDL_CLK_CKO>; + clock-names = "xclk"; + DOVDD-supply = <&vgen4_reg>; /* 1.8v */ + AVDD-supply = <&vgen3_reg>; /* 2.8v */ + DVDD-supply = <&vgen2_reg>; /* 1.5v */ + powerdown-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; + + port { + ov5640_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_from_ov5640>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; +};
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 4/34 ARM: dts: imx6qdl: add multiplexer controls
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
The IOMUXC General Purpose Register space contains various bitfields that control video bus multiplexers. Describe them using a mmio-mux node. The placement of the IPU CSI video mux controls differs between i.MX6D/Q and i.MX6S/DL.
--- arch/arm/boot/dts/imx6dl.dtsi | 10 ++++++++++ arch/arm/boot/dts/imx6q.dtsi | 10 ++++++++++ arch/arm/boot/dts/imx6qdl.dtsi | 7 ++++++- 3 files changed, 26 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6dl.dtsi +10 -0
@@ -181,6 +181,16 @@ "di0", "di1"; }; +&mux { + mux-reg-masks = <0x34 0x00000007>, /* IPU_CSI0_MUX */ + <0x34 0x00000038>, /* IPU_CSI1_MUX */ + <0x0c 0x0000000c>, /* HDMI_MUX_CTL */ + <0x0c 0x000000c0>, /* LVDS0_MUX_CTL */ + <0x0c 0x00000300>, /* LVDS1_MUX_CTL */ + <0x28 0x00000003>, /* DCIC1_MUX_CTL */ + <0x28 0x0000000c>; /* DCIC2_MUX_CTL */ +}; + &vpu { compatible = "fsl,imx6dl-vpu", "cnm,coda960"; };
arch/arm/boot/dts/imx6q.dtsi +10 -0
@@ -332,6 +332,16 @@ }; }; +&mux { + mux-reg-masks = <0x04 0x00080000>, /* MIPI_IPU1_MUX */ + <0x04 0x00100000>, /* MIPI_IPU2_MUX */ + <0x0c 0x0000000c>, /* HDMI_MUX_CTL */ + <0x0c 0x000000c0>, /* LVDS0_MUX_CTL */ + <0x0c 0x00000300>, /* LVDS1_MUX_CTL */ + <0x28 0x00000003>, /* DCIC1_MUX_CTL */ + <0x28 0x0000000c>; /* DCIC2_MUX_CTL */ +}; + &vpu { compatible = "fsl,imx6q-vpu", "cnm,coda960"; };
arch/arm/boot/dts/imx6qdl.dtsi +6 -1
@@ -808,8 +808,13 @@ }; gpr: iomuxc-gpr at 020e0000 { - compatible = "fsl,imx6q-iomuxc-gpr", "syscon"; + compatible = "fsl,imx6q-iomuxc-gpr", "syscon", "simple-mfd"; reg = <0x020e0000 0x38>; + + mux: mux-controller { + compatible = "mmio-mux"; + #mux-control-cells = <1>; + }; }; iomuxc: iomuxc at 020e0000 {
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 5/34 ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node
In reply to Steve LongerbeamAdd 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
@@ -1140,7 +1140,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", "ref", "pix"; + status = "disabled"; }; mipi_dsi: mipi at 021e0000 {
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 6/34 ARM: dts: imx6qdl: Add video multiplexers, mipi_csi, and their connections
In reply to Steve LongerbeamFrom: 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 | 174 +++++++++++++++++++++++++++++++++++++++++ arch/arm/boot/dts/imx6q.dtsi | 110 ++++++++++++++++++++++++++ arch/arm/boot/dts/imx6qdl.dtsi | 6 ++ 3 files changed, 290 insertions(+)
arch/arm/boot/dts/imx6dl.dtsi +174 -0
@@ -164,6 +164,116 @@ <&iomuxc 9 207 1>, <&iomuxc 10 206 1>, <&iomuxc 11 133 3>; }; +&gpr { + ipu1_csi0_mux: ipu1_csi0_mux at 34 { + compatible = "video-mux"; + mux-controls = <&mux 0>; + #address-cells = <1>; + #size-cells = <0>; + + 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-mux"; + mux-controls = <&mux 1>; + #address-cells = <1>; + #size-cells = <0>; + + 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>; + }; + }; + }; +}; + &gpt { compatible = "fsl,imx6dl-gpt"; };
@@ -172,6 +282,12 @@ compatible = "fsl,imx6dl-hdmi"; }; +&ipu1_csi1 { + ipu1_csi1_from_ipu1_csi1_mux: endpoint { + remote-endpoint = <&ipu1_csi1_mux_to_ipu1_csi1>; + }; +}; + &ldb { clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>, <&clks IMX6QDL_CLK_LDB_DI1_SEL>, <&clks IMX6QDL_CLK_IPU1_DI0_SEL>, <&clks IMX6QDL_CLK_IPU1_DI1_SEL>,
@@ -181,6 +297,64 @@ "di0", "di1"; }; +&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>; + }; + }; +}; + &mux { mux-reg-masks = <0x34 0x00000007>, /* IPU_CSI0_MUX */ <0x34 0x00000038>, /* IPU_CSI1_MUX */
arch/arm/boot/dts/imx6q.dtsi +110 -0
138 lines not on this page · raw message
arch/arm/boot/dts/imx6qdl.dtsi +6 -0
@@ -1142,6 +1142,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>,
@@ -1249,6 +1251,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
Steve Longerbeam
maintainerPATCH v7 7/34 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
@@ -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
@@ -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
Steve Longerbeam
maintainerPATCH v7 8/34 ARM: dts: imx6qdl-sabrelite: remove erratum ERR006687 workaround
In reply to Steve LongerbeamThere 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
@@ -270,9 +270,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"; };
@@ -373,7 +370,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
Steve Longerbeam
maintainerPATCH v7 9/34 ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors
In reply to Steve LongerbeamAdds 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
@@ -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
@@ -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
Steve Longerbeam
maintainerPATCH v7 10/34 ARM: dts: imx6-sabresd: add OV5642 and OV5640 camera sensors
In reply to Steve LongerbeamEnables 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
@@ -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
@@ -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
Steve Longerbeam
maintainerPATCH v7 11/34 ARM: dts: imx6-sabreauto: create i2cmux for i2c3
In reply to Steve LongerbeamThe 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
@@ -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 {
@@ -290,27 +328,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 {
@@ -418,6 +435,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
Steve Longerbeam
maintainerPATCH v7 12/34 ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b
In reply to Steve LongerbeamThe 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
@@ -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 {
@@ -441,6 +444,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
Steve Longerbeam
maintainerPATCH v7 13/34 ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture
In reply to Steve LongerbeamAdd 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
@@ -456,6 +456,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
Steve Longerbeam
maintainerPATCH v7 14/34 ARM: dts: imx6-sabreauto: add the ADV7180 video decoder
In reply to Steve LongerbeamEnables 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
@@ -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>,
@@ -444,6 +478,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
Steve Longerbeam
maintainerPATCH v7 15/34 add mux and video interface bridge entity functions
In reply to Steve LongerbeamFrom: 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
@@ -299,6 +299,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-VID-MUX: + + - ``MEDIA_ENT_F_VID_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
@@ -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
Re: [PATCH v7 15/34] add mux and video interface bridge entity functions
Quoted 32 lines · Steve Longerbeam
From: Philipp Zabel <[email protected]>
Signed-off-by Philipp Zabel <[email protected]>- renamed
MEDIA_ENT_F_MUXtoMEDIA_ENT_F_VID_MUXSigned-off-by Steve Longerbeam <[email protected]>--- 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 +12
-0@@ -299,6 +299,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-VID-MUX: + + - ``MEDIA_ENT_F_VID_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
Documentation/media/uapi/mediactl/media-types.rst Types and flags used to represent the media graph elements · line 323
Quoted 10 lines
Documentation/media/uapi/mediactl/media-types.rst +10
-0+ + .. _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, ...).
I'm unhappy with the term 'bus format'. It's too close to 'mediabus format'. How about calling it "bus protocol"?
Regards,
Hans
Quoted 21 lines
Documentation/media/uapi/mediactl/media-types.rst +0
-0.. tabularcolumns:: |p{5.5cm}|p{12.0cm}|include/uapi/linux/media.h +6
-0@@ -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 */
Philipp Zabel
maintainerRe: [PATCH v7 15/34] add mux and video interface bridge entity functions
Quoted 38 lines · Hans Verkuil
Quoted 37 lines · Steve Longerbeam
From: Philipp Zabel <[email protected]>
Signed-off-by Philipp Zabel <[email protected]>- renamed
MEDIA_ENT_F_MUXtoMEDIA_ENT_F_VID_MUXSigned-off-by Steve Longerbeam <[email protected]>--- 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 +17
-0@@ -299,6 +299,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-VID-MUX: + + - ``MEDIA_ENT_F_VID_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`` +
Quoted 8 lines
Documentation/media/uapi/mediactl/media-types.rst Types and flags used to represent the media graph elements · line 323
Quoted 5 lines
Documentation/media/uapi/mediactl/media-types.rst +5
-0+ - 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, ...).I'm unhappy with the term 'bus format'. It's too close to 'mediabus format'. How about calling it "bus protocol"?
How about:
"It receives video frames on its sink pad from an input video bus
of one type (HDMI, eDP, MIPI CSI-2, ...), and outputs them on its source pad to an output video bus of another type (eDP, MIPI CSI-2, parallel, ...)."
regards
Philipp
Re: [PATCH v7 15/34] add mux and video interface bridge entity functions
Quoted 48 lines · Philipp Zabel
Quoted 38 lines · Hans Verkuil
Quoted 37 lines · Steve Longerbeam
From: Philipp Zabel <[email protected]>
Signed-off-by Philipp Zabel <[email protected]>- renamed
MEDIA_ENT_F_MUXtoMEDIA_ENT_F_VID_MUXSigned-off-by Steve Longerbeam <[email protected]>--- 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 +17
-0@@ -299,6 +299,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-VID-MUX: + + - ``MEDIA_ENT_F_VID_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`` +Quoted 8 lines
Documentation/media/uapi/mediactl/media-types.rst Types and flags used to represent the media graph elements · line 323
Quoted 5 lines
Documentation/media/uapi/mediactl/media-types.rst +5
-0+ - 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, ...).I'm unhappy with the term 'bus format'. It's too close to 'mediabus format'. How about calling it "bus protocol"?
Quoted 6 lines
How about:
"It receives video frames on its sink pad from an input video bus
of one type (HDMI, eDP, MIPI CSI-2, ...), and outputs them on its source pad to an output video bus of another type (eDP, MIPI CSI-2, parallel, ...)."
That's even better!
Regards,
Hans
Steve Longerbeam
maintainerPATCH v7 16/34 add Omnivision OV5640 sensor driver
In reply to Steve LongerbeamThis driver is based on ov5640_mipi.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup.
--- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2234 insertions(+) create mode 100644 drivers/media/i2c/ov5640.c
drivers/media/i2c/Kconfig +9 -0
@@ -539,6 +539,15 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on OF + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV5645 tristate "OmniVision OV5645 sensor support" depends on OF
drivers/media/i2c/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV5645) += ov5645.o obj-$(CONFIG_VIDEO_OV5647) += ov5647.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
drivers/media/i2c/ov5640.c new file +2224 -0
2,224 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Quoted 5 lines · Steve Longerbeam
This driver is based on
ov5640_mipi.cfrom Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup.Signed-off-by Steve Longerbeam <[email protected]>
Thanks,
Hans
Quoted 2,270 lines
--- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2234 insertions(+)create mode 100644
drivers/media/i2c/ov5640.cdrivers/media/i2c/Kconfig +9
-0@@ -539,6 +539,15 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on OF + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV5645 tristate "OmniVision OV5645 sensor support" depends on OFdrivers/media/i2c/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV5645) += ov5645.o obj-$(CONFIG_VIDEO_OV5647) += ov5647.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.odrivers/media/i2c/ov5640.c new file +2224
-0@@ -0,0 +1,2224 @@ +/* +* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2014-2017 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 <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/clkdev.h> +#include <linux/ctype.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/slab.h> +#include <linux/types.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> +#include <media/v4l2-async.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-of.h> +#include <media/v4l2-subdev.h> + +/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 6000000 +#define OV5640_XCLK_MAX 24000000 + +/* +* FIXME: there is no subdev API to set the MIPI CSI-2 +* virtual channel yet, so this is hardcoded for now. +*/ +#define OV5640_MIPI_VC 1 + +#define OV5640_DEFAULT_SLAVE_ID 0x3c + +#define OV5640_REG_CHIP_ID 0x300a +#define OV5640_REG_PAD_OUTPUT00 0x3019 +#define OV5640_REG_SC_PLL_CTRL0 0x3034 +#define OV5640_REG_SC_PLL_CTRL1 0x3035 +#define OV5640_REG_SC_PLL_CTRL2 0x3036 +#define OV5640_REG_SC_PLL_CTRL3 0x3037 +#define OV5640_REG_SLAVE_ID 0x3100 +#define OV5640_REG_SYS_ROOT_DIVIDER 0x3108 +#define OV5640_REG_AWB_R_GAIN 0x3400 +#define OV5640_REG_AWB_G_GAIN 0x3402 +#define OV5640_REG_AWB_B_GAIN 0x3404 +#define OV5640_REG_AWB_MANUAL_CTRL 0x3406 +#define OV5640_REG_AEC_PK_EXPOSURE_HI 0x3500 +#define OV5640_REG_AEC_PK_EXPOSURE_MED 0x3501 +#define OV5640_REG_AEC_PK_EXPOSURE_LO 0x3502 +#define OV5640_REG_AEC_PK_MANUAL 0x3503 +#define OV5640_REG_AEC_PK_REAL_GAIN 0x350a +#define OV5640_REG_AEC_PK_VTS 0x350c +#define OV5640_REG_TIMING_HTS 0x380c +#define OV5640_REG_TIMING_VTS 0x380e +#define OV5640_REG_TIMING_TC_REG21 0x3821 +#define OV5640_REG_AEC_CTRL00 0x3a00 +#define OV5640_REG_AEC_B50_STEP 0x3a08 +#define OV5640_REG_AEC_B60_STEP 0x3a0a +#define OV5640_REG_AEC_CTRL0D 0x3a0d +#define OV5640_REG_AEC_CTRL0E 0x3a0e +#define OV5640_REG_AEC_CTRL0F 0x3a0f +#define OV5640_REG_AEC_CTRL10 0x3a10 +#define OV5640_REG_AEC_CTRL11 0x3a11 +#define OV5640_REG_AEC_CTRL1B 0x3a1b +#define OV5640_REG_AEC_CTRL1E 0x3a1e +#define OV5640_REG_AEC_CTRL1F 0x3a1f +#define OV5640_REG_HZ5060_CTRL00 0x3c00 +#define OV5640_REG_HZ5060_CTRL01 0x3c01 +#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c +#define OV5640_REG_FRAME_CTRL01 0x4202 +#define OV5640_REG_MIPI_CTRL00 0x4800 +#define OV5640_REG_DEBUG_MODE 0x4814 +#define OV5640_REG_PRE_ISP_TEST_SET1 0x503d +#define OV5640_REG_SDE_CTRL0 0x5580 +#define OV5640_REG_SDE_CTRL1 0x5581 +#define OV5640_REG_SDE_CTRL3 0x5583 +#define OV5640_REG_SDE_CTRL4 0x5584 +#define OV5640_REG_SDE_CTRL5 0x5585 +#define OV5640_REG_AVG_READOUT 0x56a1 + +enum ov5640_mode_id { +OV5640_MODE_QCIF_176_144 =0 , +OV5640_MODE_QVGA_320_240 , +OV5640_MODE_VGA_640_480 , +OV5640_MODE_NTSC_720_480 , +OV5640_MODE_PAL_720_576 , +OV5640_MODE_XGA_1024_768 , +OV5640_MODE_720P_1280_720 , +OV5640_MODE_1080P_1920_1080 , +OV5640_MODE_QSXGA_2592_1944 , +OV5640_NUM_MODES , +}; + +enum ov5640_frame_rate { +OV5640_15_FPS =0 , +OV5640_30_FPS , +OV5640_NUM_FRAMERATES , +}; + +static const int ov5640_framerates[] = { + [OV5640_15_FPS ] =15 , + [OV5640_30_FPS ] =30 , +}; + +/* regulator supplies */ +static const char *const ov5640_supply_name[] = { +"DOVDD" ,/* Digital I/O (1.8V) suppply */ +"DVDD" ,/* Digital Core (1.5V) supply */ +"AVDD" ,/* Analog (2.8V) supply */ +}; + +#define OV5640_NUM_SUPPLIES ARRAY_SIZE(ov5640_supply_name) + +/* +* image size under 1280 * 960 are SUBSAMPLING +* image size upper 1280 * 960 are SCALING +*/ +enum ov5640_downsize_mode { +SUBSAMPLING , +SCALING , +}; + +struct reg_value { +u16 reg_addr; +u8 val; +u8 mask; +u32 delay_ms; +}; + +struct ov5640_mode_info { +enum ov5640_mode_id id; +enum ov5640_downsize_mode dn_mode; +u32 width; +u32 height; +const struct reg_value *reg_data; +u32 reg_data_size; +}; + +struct ov5640_ctrls { +struct v4l2_ctrl_handler handler; +struct { +struct v4l2_ctrl *auto_exp; +struct v4l2_ctrl *exposure; + }; +struct { +struct v4l2_ctrl *auto_wb; +struct v4l2_ctrl *blue_balance; +struct v4l2_ctrl *red_balance; + }; +struct { +struct v4l2_ctrl *auto_gain; +struct v4l2_ctrl *gain; + }; +struct v4l2_ctrl *brightness; +struct v4l2_ctrl *saturation; +struct v4l2_ctrl *contrast; +struct v4l2_ctrl *hue; +struct v4l2_ctrl *test_pattern; +}; + +struct ov5640_dev { +struct i2c_client *i2c_client; +struct v4l2_subdev sd; +struct media_pad pad; +struct v4l2_of_endpoint ep;/* the parsed DT endpoint info */ +struct clk *xclk;/* system clock to OV5640 */ +u32 xclk_freq; + +struct regulator_bulk_data supplies[OV5640_NUM_SUPPLIES ]; +struct gpio_desc *reset_gpio; +struct gpio_desc *pwdn_gpio; + +/* lock to protect all members below */ +struct mutex lock; + +int power_count; + +struct v4l2_mbus_framefmt fmt; + +const struct ov5640_mode_info *current_mode; +enum ov5640_frame_rate current_fr; +struct v4l2_fract frame_interval; + +struct ov5640_ctrls ctrls; + +u32 prev_sysclk, prev_hts; +u32 ae_low, ae_high, ae_target; + +bool pending_mode_change; +bool streaming; +}; + +static inline struct ov5640_dev *to_ov5640_dev (struct v4l2_subdev *sd) +{ + return container_of(sd, struct ov5640_dev, sd); +} + +static inline struct v4l2_subdev *ctrl_to_sd (struct v4l2_ctrl *ctrl) +{ + return &container_of(ctrl->handler, struct ov5640_dev, + ctrls.handler)->sd; +} + +/* +* FIXME: all of these register tables are likely filled with +* entries that set the register to their power-on default values, +* and which are otherwise not touched by this driver. Those entries +* should be identified and removed to speed register load time +* over i2c. +*/ + +static const struct reg_value ov5640_init_setting_30fps_VGA[] = { + + {0x3103 ,0x11 ,0 ,0 }, {0x3008 ,0x82 ,0 ,5 }, {0x3008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x3a0d ,0x04 ,0 ,0 }, {0x3a14 ,0x03 ,0 ,0 }, {0x3a15 ,0xd8 ,0 ,0 }, + {0x4001 ,0x02 ,0 ,0 }, {0x4004 ,0x06 ,0 ,0 }, {0x4713 ,0x03 ,0 ,0 }, + {0x4407 ,0x04 ,0 ,0 }, {0x460b ,0x35 ,0 ,0 }, {0x460c ,0x22 ,0 ,0 }, + {0x3824 ,0x02 ,0 ,0 }, {0x5001 ,0x83 ,0 ,70 }, +}; + +/* power-on sensor init reg table */ +static const struct ov5640_mode_info ov5640_mode_init_data = { +0 ,SUBSAMPLING ,640 ,480 , ov5640_init_setting_30fps_VGA, +ARRAY_SIZE (ov5640_init_setting_30fps_VGA), +}; + +static const struct ov5640_mode_info +ov5640_mode_data[OV5640_NUM_FRAMERATES ][OV5640_NUM_MODES ] = { + { + {OV5640_MODE_QCIF_176_144 ,SUBSAMPLING ,176 ,144 , + ov5640_setting_15fps_QCIF_176_144, +ARRAY_SIZE (ov5640_setting_15fps_QCIF_176_144)}, + {OV5640_MODE_QVGA_320_240 ,SUBSAMPLING ,320 ,240 , + ov5640_setting_15fps_QVGA_320_240, +ARRAY_SIZE (ov5640_setting_15fps_QVGA_320_240)}, + {OV5640_MODE_VGA_640_480 ,SUBSAMPLING ,640 ,480 , + ov5640_setting_15fps_VGA_640_480, +ARRAY_SIZE (ov5640_setting_15fps_VGA_640_480)}, + {OV5640_MODE_NTSC_720_480 ,SUBSAMPLING ,720 ,480 , + ov5640_setting_15fps_NTSC_720_480, +ARRAY_SIZE (ov5640_setting_15fps_NTSC_720_480)}, + {OV5640_MODE_PAL_720_576 ,SUBSAMPLING ,720 ,576 , + ov5640_setting_15fps_PAL_720_576, +ARRAY_SIZE (ov5640_setting_15fps_PAL_720_576)}, + {OV5640_MODE_XGA_1024_768 ,SUBSAMPLING ,1024 ,768 , + ov5640_setting_15fps_XGA_1024_768, +ARRAY_SIZE (ov5640_setting_15fps_XGA_1024_768)}, + {OV5640_MODE_720P_1280_720 ,SUBSAMPLING ,1280 ,720 , + ov5640_setting_15fps_720P_1280_720, +ARRAY_SIZE (ov5640_setting_15fps_720P_1280_720)}, + {OV5640_MODE_1080P_1920_1080 ,SCALING ,1920 ,1080 , + ov5640_setting_15fps_1080P_1920_1080, +ARRAY_SIZE (ov5640_setting_15fps_1080P_1920_1080)}, + {OV5640_MODE_QSXGA_2592_1944 ,SCALING ,2592 ,1944 , + ov5640_setting_15fps_QSXGA_2592_1944, +ARRAY_SIZE (ov5640_setting_15fps_QSXGA_2592_1944)}, + }, { + {OV5640_MODE_QCIF_176_144 ,SUBSAMPLING ,176 ,144 , + ov5640_setting_30fps_QCIF_176_144, +ARRAY_SIZE (ov5640_setting_30fps_QCIF_176_144)}, + {OV5640_MODE_QVGA_320_240 ,SUBSAMPLING ,320 ,240 , + ov5640_setting_30fps_QVGA_320_240, +ARRAY_SIZE (ov5640_setting_30fps_QVGA_320_240)}, + {OV5640_MODE_VGA_640_480 ,SUBSAMPLING ,640 ,480 , + ov5640_setting_30fps_VGA_640_480, +ARRAY_SIZE (ov5640_setting_30fps_VGA_640_480)}, + {OV5640_MODE_NTSC_720_480 ,SUBSAMPLING ,720 ,480 , + ov5640_setting_30fps_NTSC_720_480, +ARRAY_SIZE (ov5640_setting_30fps_NTSC_720_480)}, + {OV5640_MODE_PAL_720_576 ,SUBSAMPLING ,720 ,576 , + ov5640_setting_30fps_PAL_720_576, +ARRAY_SIZE (ov5640_setting_30fps_PAL_720_576)}, + {OV5640_MODE_XGA_1024_768 ,SUBSAMPLING ,1024 ,768 , + ov5640_setting_30fps_XGA_1024_768, +ARRAY_SIZE (ov5640_setting_30fps_XGA_1024_768)}, + {OV5640_MODE_720P_1280_720 ,SUBSAMPLING ,1280 ,720 , + ov5640_setting_30fps_720P_1280_720, +ARRAY_SIZE (ov5640_setting_30fps_720P_1280_720)}, + {OV5640_MODE_1080P_1920_1080 ,SCALING ,1920 ,1080 , + ov5640_setting_30fps_1080P_1920_1080, +ARRAY_SIZE (ov5640_setting_30fps_1080P_1920_1080)}, + {OV5640_MODE_QSXGA_2592_1944 ,-1 ,0 ,0 ,NULL ,0 }, + }, +}; + +static int ov5640_init_slave_id (struct ov5640_dev *sensor) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg; +u8 buf[3 ]; +int ret; + +if (client->addr ==OV5640_DEFAULT_SLAVE_ID ) +return 0 ; + + buf[0 ] =OV5640_REG_SLAVE_ID >>8 ; + buf[1 ] =OV5640_REG_SLAVE_ID &0xff ; + buf[2 ] = client->addr <<1 ; + + msg.addr =OV5640_DEFAULT_SLAVE_ID ; + msg.flags =0 ; + msg.buf = buf; + msg.len =sizeof (buf); + + ret =i2c_transfer (client->adapter, &msg,1 ); +if (ret <0 ) { +dev_err (&client->dev,"%s: failed with %d\n" , __func__, ret); +return ret; + } + +return 0 ; +} + +static int ov5640_write_reg (struct ov5640_dev *sensor,u16 reg,u8 val) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg; +u8 buf[3 ]; +int ret; + + buf[0 ] = reg >>8 ; + buf[1 ] = reg &0xff ; + buf[2 ] = val; + + msg.addr = client->addr; + msg.flags = client->flags; + msg.buf = buf; + msg.len =sizeof (buf); + + ret =i2c_transfer (client->adapter, &msg,1 ); +if (ret <0 ) { +v4l2_err (&sensor->sd,"%s: error: reg=%x, val=%x\n" , + __func__, reg, val); +return ret; + } + +return 0 ; +} + +static int ov5640_read_reg (struct ov5640_dev *sensor,u16 reg,u8 *val) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg[2 ]; +u8 buf[2 ]; +int ret; + + buf[0 ] = reg >>8 ; + buf[1 ] = reg &0xff ; + + msg[0 ].addr = client->addr; + msg[0 ].flags = client->flags; + msg[0 ].buf = buf; + msg[0 ].len =sizeof (buf); + + msg[1 ].addr = client->addr; + msg[1 ].flags = client->flags |I2C_M_RD ; + msg[1 ].buf = buf; + msg[1 ].len =1 ; + + ret =i2c_transfer (client->adapter, msg,2 ); +if (ret <0 ) +return ret; + + *val = buf[0 ]; +return 0 ; +} + +static int ov5640_read_reg16 (struct ov5640_dev *sensor,u16 reg,u16 *val) +{ +u8 hi, lo; +int ret; + + ret =ov5640_read_reg (sensor, reg, &hi); +if (ret) +return ret; + ret =ov5640_read_reg (sensor, reg+1 , &lo); +if (ret) +return ret; + + *val = ((u16 )hi <<8 ) | (u16 )lo; +return 0 ; +} + +static int ov5640_write_reg16 (struct ov5640_dev *sensor,u16 reg,u16 val) +{ +int ret; + + ret =ov5640_write_reg (sensor, reg, val >>8 ); +if (ret) +return ret; + +return ov5640_write_reg (sensor, reg +1 , val &0xff ); +} + +static int ov5640_mod_reg (struct ov5640_dev *sensor,u16 reg, +u8 mask,u8 val) +{ +u8 readval; +int ret; + + ret =ov5640_read_reg (sensor, reg, &readval); +if (ret) +return ret; + + readval &= ~mask; + val &= mask; + val |= readval; + +return ov5640_write_reg (sensor, reg, val); +} + +/* download ov5640 settings to sensor through i2c */ +static int ov5640_load_regs (struct ov5640_dev *sensor, +const struct ov5640_mode_info *mode) +{ +const struct reg_value *regs = mode->reg_data; +unsigned int i; +u32 delay_ms; +u16 reg_addr; +u8 mask, val; +int ret =0 ; + +for (i =0 ; i < mode->reg_data_size; ++i, ++regs) { + delay_ms = regs->delay_ms; + reg_addr = regs->reg_addr; + val = regs->val; + mask = regs->mask; + +if (mask) + ret =ov5640_mod_reg (sensor, reg_addr, mask, val); +else + ret =ov5640_write_reg (sensor, reg_addr, val); +if (ret) +break ; + +if (delay_ms) +usleep_range (1000 *delay_ms,1000 *delay_ms+100 ); + } + +return ret; +} + +static int ov5640_set_hue (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (0 ),BIT (0 )); +ov5640_write_reg16 (sensor,OV5640_REG_SDE_CTRL1 , value); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (0 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_contrast (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (2 ),BIT (2 )); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL5 , value &0xff ); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (2 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_saturation (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (1 ),BIT (1 )); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL3 , value &0xff ); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL4 , value &0xff ); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (1 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_white_balance (struct ov5640_dev *sensor,int awb) +{ +ov5640_mod_reg (sensor,OV5640_REG_AWB_MANUAL_CTRL , +BIT (0 ), awb ?0 :1 ); + +if (!awb) { +u16 red = (u16 )sensor->ctrls.red_balance->val; +u16 blue = (u16 )sensor->ctrls.blue_balance->val; + +ov5640_write_reg16 (sensor,OV5640_REG_AWB_R_GAIN , red); +ov5640_write_reg16 (sensor,OV5640_REG_AWB_B_GAIN , blue); + } + +return 0 ; +} + +static int ov5640_set_exposure (struct ov5640_dev *sensor,int exp) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; +bool auto_exposure = (exp ==V4L2_EXPOSURE_AUTO ); + +if (ctrls->auto_exp->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (0 ), auto_exposure ?0 :BIT (0 )); + } + +if (!auto_exposure && ctrls->exposure->is_new) { +u16 max_exp; + +ov5640_read_reg16 (sensor,OV5640_REG_AEC_PK_VTS , &max_exp); +if (ctrls->exposure->val < max_exp) { +u32 exposure = ctrls->exposure->val <<4 ; + +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_LO , + exposure &0xff ); +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_MED , + (exposure >>8 ) &0xff ); +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_HI , + (exposure >>16 ) &0x0f ); + } + } + +return 0 ; +} + +/* read exposure, in number of line periods */ +static int ov5640_get_exposure (struct ov5640_dev *sensor) +{ +u8 temp; +int exp; + +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_HI , &temp); + exp = ((int )temp &0x0f ) <<16 ; +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_MED , &temp); + exp |= ((int )temp <<8 ); +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_LO , &temp); + exp |= (int )temp; + +return exp >>4 ; +} + +static int ov5640_set_gain (struct ov5640_dev *sensor,int auto_gain) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; + +if (ctrls->auto_gain->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (1 ), ctrls->auto_gain->val ?0 :BIT (1 )); + } + +if (!auto_gain && ctrls->gain->is_new) { +u16 gain = (u16 )ctrls->gain->val; + +ov5640_write_reg16 (sensor,OV5640_REG_AEC_PK_REAL_GAIN , + gain &0x3ff ); + } + +return 0 ; +} + +static int ov5640_get_gain (struct ov5640_dev *sensor) +{ +u16 gain; + +ov5640_read_reg16 (sensor,OV5640_REG_AEC_PK_REAL_GAIN , &gain); + +return gain &0x3ff ; +} + +static int ov5640_set_agc_aec (struct ov5640_dev *sensor,bool on) +{ +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +0x3 , on ?0 :0x3 ); +return 0 ; +} + +static int ov5640_set_test_pattern (struct ov5640_dev *sensor,int value) +{ +ov5640_mod_reg (sensor,OV5640_REG_PRE_ISP_TEST_SET1 , +0xa4 , value ?0xa4 :0 ); +return 0 ; +} + +static int ov5640_set_stream (struct ov5640_dev *sensor,bool on) +{ +ov5640_mod_reg (sensor,OV5640_REG_MIPI_CTRL00 ,BIT (5 ), + on ?0 :BIT (5 )); +ov5640_write_reg (sensor,OV5640_REG_PAD_OUTPUT00 , + on ?0x00 :0x70 ); +ov5640_write_reg (sensor,OV5640_REG_FRAME_CTRL01 , + on ?0x00 :0x0f ); +return 0 ; +} + +static int ov5640_get_sysclk (struct ov5640_dev *sensor) +{ +/* calculate sysclk */ +u32 xvclk = sensor->xclk_freq /10000 ; +u32 multiplier, prediv,VCO , sysdiv, pll_rdiv; +u32 sclk_rdiv_map[] = {1 ,2 ,4 ,8 }; +u32 bit_div2x =1 , sclk_rdiv, sysclk; +u8 temp1, temp2; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL0 , &temp1); + temp2 = temp1 &0x0f ; +if (temp2 ==8 || temp2 ==10 ) + bit_div2x = temp2 /2 ; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL1 , &temp1); + sysdiv = temp1 >>4 ; +if (sysdiv ==0 ) + sysdiv =16 ; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL2 , &temp1); + multiplier = temp1; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL3 , &temp1); + prediv = temp1 &0x0f ; + pll_rdiv = ((temp1 >>4 ) &0x01 ) +1 ; + +ov5640_read_reg (sensor,OV5640_REG_SYS_ROOT_DIVIDER , &temp1); + temp2 = temp1 &0x03 ; + sclk_rdiv = sclk_rdiv_map[temp2]; + +if (!prediv || !sysdiv || !pll_rdiv || !bit_div2x) +return -EINVAL ; + +VCO = xvclk * multiplier / prediv; + + sysclk =VCO / sysdiv / pll_rdiv *2 / bit_div2x / sclk_rdiv; + +return sysclk; +} + +static int ov5640_set_night_mode (struct ov5640_dev *sensor) +{ +/* read HTS from register settings */ +u8 mode; + +ov5640_read_reg (sensor,OV5640_REG_AEC_CTRL00 , &mode); + mode &=0xfb ; +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL00 , mode); +return 0 ; +} + +static int ov5640_get_hts (struct ov5640_dev *sensor) +{ +/* read HTS from register settings */ +u16 hts; + +ov5640_read_reg16 (sensor,OV5640_REG_TIMING_HTS , &hts); +return hts; +} + +static int ov5640_get_vts (struct ov5640_dev *sensor) +{ +u16 vts; + +ov5640_read_reg16 (sensor,OV5640_REG_TIMING_VTS , &vts); +return vts; +} + +static int ov5640_set_vts (struct ov5640_dev *sensor,int vts) +{ +ov5640_write_reg16 (sensor,OV5640_REG_TIMING_VTS , vts); +return 0 ; +} + +static int ov5640_get_light_freq (struct ov5640_dev *sensor) +{ +/* get banding filter value */ +u8 temp, temp1; +int light_freq =0 ; + +ov5640_read_reg (sensor,OV5640_REG_HZ5060_CTRL01 , &temp); + +if (temp &0x80 ) { +/* manual */ +ov5640_read_reg (sensor,OV5640_REG_HZ5060_CTRL00 , &temp1); +if (temp1 &0x04 ) { +/* 50Hz */ + light_freq =50 ; + }else { +/* 60Hz */ + light_freq =60 ; + } + }else { +/* auto */ +ov5640_read_reg (sensor,OV5640_REG_SIGMADELTA_CTRL0C , + &temp1); +if (temp1 &0x01 ) { +/* 50Hz */ + light_freq =50 ; + }else { +/* 60Hz */ + } + } + +return light_freq; +} + +static int ov5640_set_bandingfilter (struct ov5640_dev *sensor) +{ +u32 band_step60, max_band60, band_step50, max_band50, prev_vts; +int ret; + +/* read preview PCLK */ + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_sysclk = ret; +/* read preview HTS */ + ret =ov5640_get_hts (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_hts = ret; + +/* read preview VTS */ + ret =ov5640_get_vts (sensor); +if (ret <0 ) +return ret; + prev_vts = ret; + + +/* calculate banding filter */ +/* 60Hz */ + band_step60 = sensor->prev_sysclk *100 / sensor->prev_hts *100 /120 ; +ov5640_write_reg16 (sensor,OV5640_REG_AEC_B60_STEP , band_step60); +if (!band_step60) +return -EINVAL ; + max_band60 = (int )((prev_vts -4 ) / band_step60); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0D , max_band60); + +/* 50Hz */ + band_step50 = sensor->prev_sysclk *100 / sensor->prev_hts; +ov5640_write_reg16 (sensor,OV5640_REG_AEC_B50_STEP , band_step50); +if (!band_step50) +return -EINVAL ; + max_band50 = (int )((prev_vts -4 ) / band_step50); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0E , max_band50); + +return 0 ; +} + +static int ov5640_set_ae_target (struct ov5640_dev *sensor,int target) +{ +/* stable in high */ +u32 fast_high, fast_low; + + sensor->ae_low = target *23 /25 ;/* 0.92 */ + sensor->ae_high = target *27 /25 ;/* 1.08 */ + + fast_high = sensor->ae_high <<1 ; +if (fast_high >255 ) + fast_high =255 ; + + fast_low = sensor->ae_low >>1 ; + +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0F , sensor->ae_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL10 , sensor->ae_low); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1B , sensor->ae_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1E , sensor->ae_low); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL11 , fast_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1F , fast_low); + +return 0 ; +} + +static int ov5640_binning_on (struct ov5640_dev *sensor) +{ +u8 temp; + +ov5640_read_reg (sensor,OV5640_REG_TIMING_TC_REG21 , &temp); + temp &=0xfe ; + +return temp ?1 :0 ; +} + +static int ov5640_set_virtual_channel (struct ov5640_dev *sensor) +{ +u8 temp, channel =OV5640_MIPI_VC ; + +ov5640_read_reg (sensor,OV5640_REG_DEBUG_MODE , &temp); + temp &= ~(3 <<6 ); + temp |= (channel <<6 ); +ov5640_write_reg (sensor,OV5640_REG_DEBUG_MODE , temp); + +return 0 ; +} + +static const struct ov5640_mode_info * +ov5640_find_mode (struct ov5640_dev *sensor,enum ov5640_frame_rate fr, +int width,int height,bool nearest) +{ +const struct ov5640_mode_info *mode =NULL ; +int i; + +for (i =OV5640_NUM_MODES -1 ; i >=0 ; i--) { + mode = &ov5640_mode_data[fr][i]; + +if (!mode->reg_data) +continue ; + +if ((nearest && mode->width <= width && + mode->height <= height) || + (!nearest && mode->width == width && + mode->height == height)) +break ; + } + +if (nearest && i <0 ) + mode = &ov5640_mode_data[fr][0 ]; + +return mode; +} + +/* +* sensor changes between scaling and subsampling, go through +* exposure calculation +*/ +static int ov5640_set_mode_exposure_calc ( +struct ov5640_dev *sensor,const struct ov5640_mode_info *mode) +{ +u32 prev_shutter, prev_gain16; +u32 cap_shutter, cap_gain16; +u32 cap_sysclk, cap_hts, cap_vts; +u32 light_freq, cap_bandfilt, cap_maxband; +u32 cap_gain16_shutter; +u8 average; +int ret; + +if (mode->reg_data ==NULL ) +return -EINVAL ; + +/* turn off AE/AG */ + ret =ov5640_set_agc_aec (sensor, false); +if (ret <0 ) +return ret; + +/* read preview shutter */ + ret =ov5640_get_exposure (sensor); +if (ret <0 ) +return ret; + prev_shutter = ret; + ret =ov5640_binning_on (sensor); +if (ret <0 ) +return ret; +if (ret && mode->id !=OV5640_MODE_720P_1280_720 && + mode->id !=OV5640_MODE_1080P_1920_1080 ) + prev_shutter *=2 ; + +/* read preview gain */ + ret =ov5640_get_gain (sensor); +if (ret <0 ) +return ret; + prev_gain16 = ret; + +/* get average */ +ov5640_read_reg (sensor,OV5640_REG_AVG_READOUT , &average); + +/* turn off night mode for capture */ + ret =ov5640_set_night_mode (sensor); +if (ret <0 ) +return ret; + +/* Write capture setting */ + ret =ov5640_load_regs (sensor, mode); +if (ret <0 ) +return ret; + +/* read capture VTS */ + ret =ov5640_get_vts (sensor); +if (ret <0 ) +return ret; + cap_vts = ret; + ret =ov5640_get_hts (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + cap_hts = ret; + + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + cap_sysclk = ret; + +/* calculate capture banding filter */ + ret =ov5640_get_light_freq (sensor); +if (ret <0 ) +return ret; + light_freq = ret; + +if (light_freq ==60 ) { +/* 60Hz */ + cap_bandfilt = cap_sysclk *100 / cap_hts *100 /120 ; + }else { +/* 50Hz */ + cap_bandfilt = cap_sysclk *100 / cap_hts; + } + +if (!sensor->prev_sysclk) { + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_sysclk = ret; + } + +if (!cap_bandfilt) +return -EINVAL ; + + cap_maxband = (int )((cap_vts -4 ) / cap_bandfilt); + +/* calculate capture shutter/gain16 */ +if (average > sensor->ae_low && average < sensor->ae_high) { +/* in stable range */ + cap_gain16_shutter = + prev_gain16 * prev_shutter * + cap_sysclk / sensor->prev_sysclk * + sensor->prev_hts / cap_hts * + sensor->ae_target / average; + }else { + cap_gain16_shutter = + prev_gain16 * prev_shutter * + cap_sysclk / sensor->prev_sysclk * + sensor->prev_hts / cap_hts; + } + +/* gain to shutter */ +if (cap_gain16_shutter < (cap_bandfilt *16 )) { +/* shutter < 1/100 */ + cap_shutter = cap_gain16_shutter /16 ; +if (cap_shutter <1 ) + cap_shutter =1 ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; +if (cap_gain16 <16 ) + cap_gain16 =16 ; + }else { +if (cap_gain16_shutter > (cap_bandfilt * cap_maxband *16 )) { +/* exposure reach max */ + cap_shutter = cap_bandfilt * cap_maxband; +if (!cap_shutter) +return -EINVAL ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; + }else { +/* 1/100 < (cap_shutter = n/100) =< max */ + cap_shutter = + ((int )(cap_gain16_shutter /16 / cap_bandfilt)) + * cap_bandfilt; +if (!cap_shutter) +return -EINVAL ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; + } + } + +/* write capture gain */ + ret =ov5640_set_gain (sensor, cap_gain16); +if (ret <0 ) +return ret; + +/* write capture shutter */ +if (cap_shutter > (cap_vts -4 )) { + cap_vts = cap_shutter +4 ; + ret =ov5640_set_vts (sensor, cap_vts); +if (ret <0 ) +return ret; + } + +return ov5640_set_exposure (sensor, cap_shutter); +} + +/* +* if sensor changes inside scaling or subsampling +* change mode directly +*/ +static int ov5640_set_mode_direct (struct ov5640_dev *sensor, +const struct ov5640_mode_info *mode) +{ +int ret; + +if (mode->reg_data ==NULL ) +return -EINVAL ; + +/* turn off AE/AG */ + ret =ov5640_set_agc_aec (sensor, false); +if (ret <0 ) +return ret; + +/* Write capture setting */ + ret =ov5640_load_regs (sensor, mode); +if (ret <0 ) +return ret; + +return ov5640_set_agc_aec (sensor, true); +} + +static int ov5640_set_mode (struct ov5640_dev *sensor, +const struct ov5640_mode_info *orig_mode) +{ +const struct ov5640_mode_info *mode = sensor->current_mode; +enum ov5640_downsize_mode dn_mode, orig_dn_mode; +int ret; + + dn_mode = mode->dn_mode; + orig_dn_mode = orig_mode->dn_mode; + +if ((dn_mode ==SUBSAMPLING && orig_dn_mode ==SCALING ) || + (dn_mode ==SCALING && orig_dn_mode ==SUBSAMPLING )) { +/* +* change between subsampling and scaling +* go through exposure calucation +*/ + ret =ov5640_set_mode_exposure_calc (sensor, mode); + }else { +/* +* change inside subsampling or scaling +* download firmware directly +*/ + ret =ov5640_set_mode_direct (sensor, mode); + } + +if (ret <0 ) +return ret; + + ret =ov5640_set_ae_target (sensor, sensor->ae_target); +if (ret <0 ) +return ret; + ret =ov5640_get_light_freq (sensor); +if (ret <0 ) +return ret; + ret =ov5640_set_bandingfilter (sensor); +if (ret <0 ) +return ret; + ret =ov5640_set_virtual_channel (sensor); +if (ret <0 ) +return ret; + + sensor->pending_mode_change = false; + +return 0 ; +} + +/* restore the last set video mode after chip power-on */ +static int ov5640_restore_mode (struct ov5640_dev *sensor) +{ +int ret; + +/* first load the initial register values */ + ret =ov5640_load_regs (sensor, &ov5640_mode_init_data); +if (ret <0 ) +return ret; + +/* now restore the last capture mode */ +return ov5640_set_mode (sensor, &ov5640_mode_init_data); +} + +static void ov5640_power (struct ov5640_dev *sensor,bool enable) +{ +if (sensor->pwdn_gpio) +gpiod_set_value (sensor->pwdn_gpio, enable ?0 :1 ); +} + +static void ov5640_reset (struct ov5640_dev *sensor) +{ +if (!sensor->reset_gpio) +return ; + +gpiod_set_value (sensor->reset_gpio,0 ); + +/* camera power cycle */ +ov5640_power (sensor, false); +usleep_range (5000 ,10000 ); +ov5640_power (sensor, true); +usleep_range (5000 ,10000 ); + +gpiod_set_value (sensor->reset_gpio,1 ); +usleep_range (1000 ,2000 ); + +gpiod_set_value (sensor->reset_gpio,0 ); +usleep_range (5000 ,10000 ); +} + +static int ov5640_set_power (struct ov5640_dev *sensor,bool on) +{ +int ret =0 ; + +if (on) { +clk_prepare_enable (sensor->xclk); + + ret =regulator_bulk_enable (OV5640_NUM_SUPPLIES , + sensor->supplies); +if (ret) + goto xclk_off; + +ov5640_reset (sensor); +ov5640_power (sensor, true); + + ret =ov5640_init_slave_id (sensor); +if (ret) + goto power_off; + + ret =ov5640_restore_mode (sensor); +if (ret) + goto power_off; + +/* +* start streaming briefly followed by stream off in +* order to coax the clock lane into LP-11 state. +*/ +ov5640_set_stream (sensor, true); +usleep_range (1000 ,2000 ); +ov5640_set_stream (sensor, false); + +return 0 ; + } + +power_off: +ov5640_power (sensor, false); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies); +xclk_off: +clk_disable_unprepare (sensor->xclk); +return ret; +} + +/* --------------- Subdev Operations --------------- */ + +static int ov5640_s_power (struct v4l2_subdev *sd,int on) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +/* +* If the power count is modified from 0 to != 0 or from != 0 to 0, +* update the power state. +*/ +if (sensor->power_count == !on) { + ret =ov5640_set_power (sensor, !!on); +if (ret) + goto out; + } + +/* Update the power count. */ + sensor->power_count += on ?1 :-1 ; +WARN_ON (sensor->power_count <0 ); +out: +mutex_unlock (&sensor->lock); + +if (on && !ret && sensor->power_count ==1 ) { +/* restore controls */ + ret =v4l2_ctrl_handler_setup (&sensor->ctrls.handler); + } + +return ret; +} + +static int ov5640_try_frame_interval (struct ov5640_dev *sensor, +struct v4l2_fract *fi, +u32 width,u32 height) +{ +const struct ov5640_mode_info *mode; +u32 minfps, maxfps, fps; +int ret; + + minfps = ov5640_framerates[OV5640_15_FPS ]; + maxfps = ov5640_framerates[OV5640_30_FPS ]; + +if (fi->numerator ==0 ) { + fi->denominator = maxfps; + fi->numerator =1 ; +return OV5640_30_FPS ; + } + + fps =DIV_ROUND_CLOSEST (fi->denominator, fi->numerator); + + fi->numerator =1 ; +if (fps > maxfps) + fi->denominator = maxfps; +else if (fps < minfps) + fi->denominator = minfps; +else if (2 * fps >=2 * minfps + (maxfps - minfps)) + fi->denominator = maxfps; +else + fi->denominator = minfps; + + ret = (fi->denominator == minfps) ?OV5640_15_FPS :OV5640_30_FPS ; + + mode =ov5640_find_mode (sensor, ret, width, height, false); +return mode ? ret : -EINVAL ; +} + +static int ov5640_get_fmt (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_format *format) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +struct v4l2_mbus_framefmt *fmt; + +if (format->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (format->which ==V4L2_SUBDEV_FORMAT_TRY ) + fmt =v4l2_subdev_get_try_format (&sensor->sd, cfg, + format->pad); +else + fmt = &sensor->fmt; + + format->format = *fmt; + +mutex_unlock (&sensor->lock); + +return 0 ; +} + +static int ov5640_try_fmt_internal (struct v4l2_subdev *sd, +struct v4l2_mbus_framefmt *fmt, +enum ov5640_frame_rate fr, +const struct ov5640_mode_info **new_mode) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *mode; + + mode =ov5640_find_mode (sensor, fr, fmt->width, fmt->height, true); +if (!mode) +return -EINVAL ; + + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = sensor->fmt.code; + +if (new_mode) + *new_mode = mode; +return 0 ; +} + +static int ov5640_set_fmt (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_format *format) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *new_mode; +int ret; + +if (format->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (sensor->streaming) { + ret = -EBUSY ; + goto out; + } + + ret =ov5640_try_fmt_internal (sd, &format->format, + sensor->current_fr, &new_mode); +if (ret) + goto out; + +if (format->which ==V4L2_SUBDEV_FORMAT_TRY ) { +struct v4l2_mbus_framefmt *fmt = +v4l2_subdev_get_try_format (sd, cfg,0 ); + + *fmt = format->format; + goto out; + } + + sensor->current_mode = new_mode; + sensor->fmt = format->format; + sensor->pending_mode_change = true; +out: +mutex_unlock (&sensor->lock); +return ret; +} + + +/* +* Sensor Controls. +*/ + +static int ov5640_g_volatile_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +mutex_lock (&sensor->lock); + +switch (ctrl->id) { +case V4L2_CID_AUTOGAIN : +if (!ctrl->val) + goto out; + sensor->ctrls.gain->val =ov5640_get_gain (sensor); +break ; +case V4L2_CID_EXPOSURE_AUTO : +if (ctrl->val ==V4L2_EXPOSURE_MANUAL ) + goto out; + sensor->ctrls.exposure->val =ov5640_get_exposure (sensor); +break ; + } + +out: +mutex_unlock (&sensor->lock); +return 0 ; +} + +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +/* +* If the device is not powered up by the host driver do +* not apply any controls to H/W at this time. Instead +* the controls will be restored right after power-up. +*/ +if (sensor->power_count ==0 ) + goto out; + +switch (ctrl->id) { +case V4L2_CID_AUTOGAIN : + ret =ov5640_set_gain (sensor, ctrl->val); +break ; +case V4L2_CID_EXPOSURE_AUTO : + ret =ov5640_set_exposure (sensor, ctrl->val); +break ; +case V4L2_CID_AUTO_WHITE_BALANCE : + ret =ov5640_set_white_balance (sensor, ctrl->val); +break ; +case V4L2_CID_HUE : + ret =ov5640_set_hue (sensor, ctrl->val); +break ; +case V4L2_CID_CONTRAST : + ret =ov5640_set_contrast (sensor, ctrl->val); +break ; +case V4L2_CID_SATURATION : + ret =ov5640_set_saturation (sensor, ctrl->val); +break ; +case V4L2_CID_TEST_PATTERN : + ret =ov5640_set_test_pattern (sensor, ctrl->val); +break ; +default : + ret = -EINVAL ; +break ; + } + +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static const struct v4l2_ctrl_ops ov5640_ctrl_ops = { + .g_volatile_ctrl = ov5640_g_volatile_ctrl, + .s_ctrl = ov5640_s_ctrl, +}; + +static const char *const test_pattern_menu[] = { +"Disabled" , +"Color bars" , +}; + +static int ov5640_init_controls (struct ov5640_dev *sensor) +{ +const struct v4l2_ctrl_ops *ops = &ov5640_ctrl_ops; +struct ov5640_ctrls *ctrls = &sensor->ctrls; +struct v4l2_ctrl_handler *hdl = &ctrls->handler; +int ret; + +v4l2_ctrl_handler_init (hdl,32 ); + +/* Auto/manual white balance */ + ctrls->auto_wb =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_AUTO_WHITE_BALANCE , +0 ,1 ,1 ,1 ); + ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_BLUE_BALANCE , +0 ,4095 ,1 ,0 ); + ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_RED_BALANCE , +0 ,4095 ,1 ,0 ); +/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 ); +/* Auto/manual gain */ + ctrls->auto_gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTOGAIN , +0 ,1 ,1 ,1 ); + ctrls->gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_GAIN , +0 ,1023 ,1 ,0 ); + + ctrls->saturation =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_SATURATION , +0 ,255 ,1 ,64 ); + ctrls->hue =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_HUE , +0 ,359 ,1 ,0 ); + ctrls->contrast =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_CONTRAST , +0 ,255 ,1 ,0 ); + ctrls->test_pattern = +v4l2_ctrl_new_std_menu_items (hdl, ops,V4L2_CID_TEST_PATTERN , +ARRAY_SIZE (test_pattern_menu) -1 , +0 ,0 , test_pattern_menu); + +if (hdl->error) { + ret = hdl->error; + goto free_ctrls; + } + + ctrls->gain->flags |=V4L2_CTRL_FLAG_VOLATILE ; + ctrls->exposure->flags |=V4L2_CTRL_FLAG_VOLATILE ; + +v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , false); +v4l2_ctrl_auto_cluster (2 , &ctrls->auto_gain,0 , true); +v4l2_ctrl_auto_cluster (2 , &ctrls->auto_exp,1 , true); + + sensor->sd.ctrl_handler = hdl; +return 0 ; + +free_ctrls: +v4l2_ctrl_handler_free (hdl); +return ret; +} + +static int ov5640_enum_frame_size (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_size_enum *fse) +{ +if (fse->pad !=0 ) +return -EINVAL ; +if (fse->index >=OV5640_NUM_MODES ) +return -EINVAL ; + + fse->min_width = fse->max_width = + ov5640_mode_data[0 ][fse->index].width; + fse->min_height = fse->max_height = + ov5640_mode_data[0 ][fse->index].height; + +return 0 ; +} + +static int ov5640_enum_frame_interval ( +struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_interval_enum *fie) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +struct v4l2_fract tpf; +int ret; + +if (fie->pad !=0 ) +return -EINVAL ; +if (fie->index >=OV5640_NUM_FRAMERATES ) +return -EINVAL ; + + tpf.numerator =1 ; + tpf.denominator = ov5640_framerates[fie->index]; + + ret =ov5640_try_frame_interval (sensor, &tpf, + fie->width, fie->height); +if (ret <0 ) +return -EINVAL ; + + fie->interval = tpf; +return 0 ; +} + +static int ov5640_g_frame_interval (struct v4l2_subdev *sd, +struct v4l2_subdev_frame_interval *fi) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +mutex_lock (&sensor->lock); + fi->interval = sensor->frame_interval; +mutex_unlock (&sensor->lock); + +return 0 ; +} + +static int ov5640_s_frame_interval (struct v4l2_subdev *sd, +struct v4l2_subdev_frame_interval *fi) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *mode; +int frame_rate, ret =0 ; + +if (fi->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (sensor->streaming) { + ret = -EBUSY ; + goto out; + } + + mode = sensor->current_mode; + + frame_rate =ov5640_try_frame_interval (sensor, &fi->interval, + mode->width, mode->height); +if (frame_rate <0 ) + frame_rate =OV5640_15_FPS ; + + sensor->current_fr = frame_rate; + sensor->frame_interval = fi->interval; + sensor->pending_mode_change = true; +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static int ov5640_enum_mbus_code (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_mbus_code_enum *code) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +if (code->pad !=0 ) +return -EINVAL ; +if (code->index !=0 ) +return -EINVAL ; + + code->code = sensor->fmt.code; + +return 0 ; +} + +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 ) + goto out; +#endif + +if (sensor->streaming == !enable) { +if (enable && sensor->pending_mode_change) { + ret =ov5640_set_mode (sensor, sensor->current_mode); +if (ret) + goto out; + } + + ret =ov5640_set_stream (sensor, enable); +if (!ret) + sensor->streaming = enable; + } +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static const struct v4l2_subdev_core_ops ov5640_core_ops = { + .s_power = ov5640_s_power, +}; + +static const struct v4l2_subdev_video_ops ov5640_video_ops = { + .g_frame_interval = ov5640_g_frame_interval, + .s_frame_interval = ov5640_s_frame_interval, + .s_stream = ov5640_s_stream, +}; + +static const struct v4l2_subdev_pad_ops ov5640_pad_ops = { + .enum_mbus_code = ov5640_enum_mbus_code, + .get_fmt = ov5640_get_fmt, + .set_fmt = ov5640_set_fmt, + .enum_frame_size = ov5640_enum_frame_size, + .enum_frame_interval = ov5640_enum_frame_interval, +}; + +static const struct v4l2_subdev_ops ov5640_subdev_ops = { + .core = &ov5640_core_ops, + .video = &ov5640_video_ops, + .pad = &ov5640_pad_ops, +}; + +static int ov5640_get_regulators (struct ov5640_dev *sensor) +{ +int i; + +for (i =0 ; i <OV5640_NUM_SUPPLIES ; i++) + sensor->supplies[i].supply = ov5640_supply_name[i]; + +return devm_regulator_bulk_get (&sensor->i2c_client->dev, +OV5640_NUM_SUPPLIES , + sensor->supplies); +} + +static int ov5640_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device *dev = &client->dev; +struct device_node *endpoint; +struct ov5640_dev *sensor; +int ret; + + sensor =devm_kzalloc (dev,sizeof (*sensor),GFP_KERNEL ); +if (!sensor) +return -ENOMEM ; + + sensor->i2c_client = client; + sensor->fmt.code =MEDIA_BUS_FMT_UYVY8_2X8 ; + sensor->fmt.width =640 ; + sensor->fmt.height =480 ; + sensor->fmt.field =V4L2_FIELD_NONE ; + sensor->frame_interval.numerator =1 ; + sensor->frame_interval.denominator = ov5640_framerates[OV5640_30_FPS ]; + sensor->current_fr =OV5640_30_FPS ; + sensor->current_mode = + &ov5640_mode_data[OV5640_30_FPS ][OV5640_MODE_VGA_640_480 ]; + sensor->pending_mode_change = true; + + sensor->ae_target =52 ; + + endpoint =of_graph_get_next_endpoint (client->dev.of_node,NULL ); +if (!endpoint) { +dev_err (dev,"endpoint node not found\n" ); +return -EINVAL ; + } + +v4l2_of_parse_endpoint (endpoint, &sensor->ep); +of_node_put (endpoint); + +if (sensor->ep.bus_type !=V4L2_MBUS_CSI2 ) { +dev_err (dev,"invalid bus type, must be MIPI CSI2\n" ); +return -EINVAL ; + } + +/* get system clock (xclk) */ + sensor->xclk =devm_clk_get (dev,"xclk" ); +if (IS_ERR (sensor->xclk)) { +dev_err (dev,"failed to get xclk\n" ); +return PTR_ERR (sensor->xclk); + } + + sensor->xclk_freq =clk_get_rate (sensor->xclk); +if (sensor->xclk_freq <OV5640_XCLK_MIN || + sensor->xclk_freq >OV5640_XCLK_MAX ) { +dev_err (dev,"xclk frequency out of range: %d Hz\n" , + sensor->xclk_freq); +return -EINVAL ; + } + +/* request optional power down pin */ + sensor->pwdn_gpio =devm_gpiod_get_optional (dev,"powerdown" , +GPIOD_OUT_HIGH ); +/* request optional reset pin */ + sensor->reset_gpio =devm_gpiod_get_optional (dev,"reset" , +GPIOD_OUT_HIGH ); + +v4l2_i2c_subdev_init (&sensor->sd, client, &ov5640_subdev_ops); + + sensor->sd.flags =V4L2_SUBDEV_FL_HAS_DEVNODE ; + sensor->pad.flags =MEDIA_PAD_FL_SOURCE ; + sensor->sd.entity.function =MEDIA_ENT_F_CAM_SENSOR ; + ret =media_entity_pads_init (&sensor->sd.entity,1 , &sensor->pad); +if (ret) +return ret; + + ret =ov5640_get_regulators (sensor); +if (ret) +return ret; + +mutex_init (&sensor->lock); + + ret =ov5640_init_controls (sensor); +if (ret) + goto entity_cleanup; + + ret =v4l2_async_register_subdev (&sensor->sd); +if (ret) + goto free_ctrls; + +return 0 ; + +free_ctrls: +v4l2_ctrl_handler_free (&sensor->ctrls.handler); +entity_cleanup: +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies); +return ret; +} + +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies); + +v4l2_async_unregister_subdev (&sensor->sd); +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +v4l2_ctrl_handler_free (&sensor->ctrls.handler); + +return 0 ; +} + +static const struct i2c_device_id ov5640_id[] = { + {"ov5640" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, ov5640_id); + +static const struct of_device_id ov5640_dt_ids[] = { + { .compatible ="ovti,ov5640" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, ov5640_dt_ids); + +static struct i2c_driver ov5640_i2c_driver = { + .driver = { + .name ="ov5640" , + .of_match_table = ov5640_dt_ids, + }, + .id_table = ov5640_id, + .probe = ov5640_probe, + .remove = ov5640_remove, +}; + +module_i2c_driver (ov5640_i2c_driver); + +MODULE_DESCRIPTION ("OV5640 MIPI Camera Subdev Driver" ); +MODULE_LICENSE ("GPL" );
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
In reply to Steve LongerbeamHi Steve,
A few comments below.
Quoted 68 lines · Steve Longerbeam
This driver is based on
ov5640_mipi.cfrom Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup.Signed-off-by Steve Longerbeam <[email protected]>--- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2234 insertions(+) create mode 100644 drivers/media/i2c/ov5640.cdrivers/media/i2c/Kconfig +9
-0@@ -539,6 +539,15 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on OF + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV5645 tristate "OmniVision OV5645 sensor support" depends on OFdrivers/media/i2c/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV5645) += ov5645.o obj-$(CONFIG_VIDEO_OV5647) += ov5647.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.odrivers/media/i2c/ov5640.c new file +18
-0@@ -0,0 +1,2224 @@ +/* +* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2014-2017 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 <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/clkdev.h> +#include <linux/ctype.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/i2c.h> +#include <linux/init.h>
drivers/media/i2c/ov5640.c line 28
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/slab.h> +#include <linux/types.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> +#include <media/v4l2-async.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-of.h>
Could you rebase this on the V4L2 fwnode patchset here, please?
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-acpi>
Quoted 837 lines
drivers/media/i2c/ov5640.c new file +837
-0+#include <media/v4l2-subdev.h> + +/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 6000000 +#define OV5640_XCLK_MAX 24000000 + +/* +* FIXME: there is no subdev API to set the MIPI CSI-2 +* virtual channel yet, so this is hardcoded for now. +*/ +#define OV5640_MIPI_VC 1 + +#define OV5640_DEFAULT_SLAVE_ID 0x3c + +#define OV5640_REG_CHIP_ID 0x300a +#define OV5640_REG_PAD_OUTPUT00 0x3019 +#define OV5640_REG_SC_PLL_CTRL0 0x3034 +#define OV5640_REG_SC_PLL_CTRL1 0x3035 +#define OV5640_REG_SC_PLL_CTRL2 0x3036 +#define OV5640_REG_SC_PLL_CTRL3 0x3037 +#define OV5640_REG_SLAVE_ID 0x3100 +#define OV5640_REG_SYS_ROOT_DIVIDER 0x3108 +#define OV5640_REG_AWB_R_GAIN 0x3400 +#define OV5640_REG_AWB_G_GAIN 0x3402 +#define OV5640_REG_AWB_B_GAIN 0x3404 +#define OV5640_REG_AWB_MANUAL_CTRL 0x3406 +#define OV5640_REG_AEC_PK_EXPOSURE_HI 0x3500 +#define OV5640_REG_AEC_PK_EXPOSURE_MED 0x3501 +#define OV5640_REG_AEC_PK_EXPOSURE_LO 0x3502 +#define OV5640_REG_AEC_PK_MANUAL 0x3503 +#define OV5640_REG_AEC_PK_REAL_GAIN 0x350a +#define OV5640_REG_AEC_PK_VTS 0x350c +#define OV5640_REG_TIMING_HTS 0x380c +#define OV5640_REG_TIMING_VTS 0x380e +#define OV5640_REG_TIMING_TC_REG21 0x3821 +#define OV5640_REG_AEC_CTRL00 0x3a00 +#define OV5640_REG_AEC_B50_STEP 0x3a08 +#define OV5640_REG_AEC_B60_STEP 0x3a0a +#define OV5640_REG_AEC_CTRL0D 0x3a0d +#define OV5640_REG_AEC_CTRL0E 0x3a0e +#define OV5640_REG_AEC_CTRL0F 0x3a0f +#define OV5640_REG_AEC_CTRL10 0x3a10 +#define OV5640_REG_AEC_CTRL11 0x3a11 +#define OV5640_REG_AEC_CTRL1B 0x3a1b +#define OV5640_REG_AEC_CTRL1E 0x3a1e +#define OV5640_REG_AEC_CTRL1F 0x3a1f +#define OV5640_REG_HZ5060_CTRL00 0x3c00 +#define OV5640_REG_HZ5060_CTRL01 0x3c01 +#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c +#define OV5640_REG_FRAME_CTRL01 0x4202 +#define OV5640_REG_MIPI_CTRL00 0x4800 +#define OV5640_REG_DEBUG_MODE 0x4814 +#define OV5640_REG_PRE_ISP_TEST_SET1 0x503d +#define OV5640_REG_SDE_CTRL0 0x5580 +#define OV5640_REG_SDE_CTRL1 0x5581 +#define OV5640_REG_SDE_CTRL3 0x5583 +#define OV5640_REG_SDE_CTRL4 0x5584 +#define OV5640_REG_SDE_CTRL5 0x5585 +#define OV5640_REG_AVG_READOUT 0x56a1 + +enum ov5640_mode_id { +OV5640_MODE_QCIF_176_144 =0 , +OV5640_MODE_QVGA_320_240 , +OV5640_MODE_VGA_640_480 , +OV5640_MODE_NTSC_720_480 , +OV5640_MODE_PAL_720_576 , +OV5640_MODE_XGA_1024_768 , +OV5640_MODE_720P_1280_720 , +OV5640_MODE_1080P_1920_1080 , +OV5640_MODE_QSXGA_2592_1944 , +OV5640_NUM_MODES , +}; + +enum ov5640_frame_rate { +OV5640_15_FPS =0 , +OV5640_30_FPS , +OV5640_NUM_FRAMERATES , +}; + +static const int ov5640_framerates[] = { + [OV5640_15_FPS ] =15 , + [OV5640_30_FPS ] =30 , +}; + +/* regulator supplies */ +static const char *const ov5640_supply_name[] = { +"DOVDD" ,/* Digital I/O (1.8V) suppply */ +"DVDD" ,/* Digital Core (1.5V) supply */ +"AVDD" ,/* Analog (2.8V) supply */ +}; + +#define OV5640_NUM_SUPPLIES ARRAY_SIZE(ov5640_supply_name) + +/* +* image size under 1280 * 960 are SUBSAMPLING +* image size upper 1280 * 960 are SCALING +*/ +enum ov5640_downsize_mode { +SUBSAMPLING , +SCALING , +}; + +struct reg_value { +u16 reg_addr; +u8 val; +u8 mask; +u32 delay_ms; +}; + +struct ov5640_mode_info { +enum ov5640_mode_id id; +enum ov5640_downsize_mode dn_mode; +u32 width; +u32 height; +const struct reg_value *reg_data; +u32 reg_data_size; +}; + +struct ov5640_ctrls { +struct v4l2_ctrl_handler handler; +struct { +struct v4l2_ctrl *auto_exp; +struct v4l2_ctrl *exposure; + }; +struct { +struct v4l2_ctrl *auto_wb; +struct v4l2_ctrl *blue_balance; +struct v4l2_ctrl *red_balance; + }; +struct { +struct v4l2_ctrl *auto_gain; +struct v4l2_ctrl *gain; + }; +struct v4l2_ctrl *brightness; +struct v4l2_ctrl *saturation; +struct v4l2_ctrl *contrast; +struct v4l2_ctrl *hue; +struct v4l2_ctrl *test_pattern; +}; + +struct ov5640_dev { +struct i2c_client *i2c_client; +struct v4l2_subdev sd; +struct media_pad pad; +struct v4l2_of_endpoint ep;/* the parsed DT endpoint info */ +struct clk *xclk;/* system clock to OV5640 */ +u32 xclk_freq; + +struct regulator_bulk_data supplies[OV5640_NUM_SUPPLIES ]; +struct gpio_desc *reset_gpio; +struct gpio_desc *pwdn_gpio; + +/* lock to protect all members below */ +struct mutex lock; + +int power_count; + +struct v4l2_mbus_framefmt fmt; + +const struct ov5640_mode_info *current_mode; +enum ov5640_frame_rate current_fr; +struct v4l2_fract frame_interval; + +struct ov5640_ctrls ctrls; + +u32 prev_sysclk, prev_hts; +u32 ae_low, ae_high, ae_target; + +bool pending_mode_change; +bool streaming; +}; + +static inline struct ov5640_dev *to_ov5640_dev (struct v4l2_subdev *sd) +{ + return container_of(sd, struct ov5640_dev, sd); +} + +static inline struct v4l2_subdev *ctrl_to_sd (struct v4l2_ctrl *ctrl) +{ + return &container_of(ctrl->handler, struct ov5640_dev, + ctrls.handler)->sd; +} + +/* +* FIXME: all of these register tables are likely filled with +* entries that set the register to their power-on default values, +* and which are otherwise not touched by this driver. Those entries +* should be identified and removed to speed register load time +* over i2c. +*/ + +static const struct reg_value ov5640_init_setting_30fps_VGA[] = { + + {0x3103 ,0x11 ,0 ,0 }, {0x3008 ,0x82 ,0 ,5 }, {0x3008 ,0x42 ,0 ,0 }, + {0x3103 ,0x03 ,0 ,0 }, {0x3017 ,0x00 ,0 ,0 }, {0x3018 ,0x00 ,0 ,0 }, + {0x3034 ,0x18 ,0 ,0 }, {0x3035 ,0x14 ,0 ,0 }, {0x3036 ,0x38 ,0 ,0 }, + {0x3037 ,0x13 ,0 ,0 }, {0x3108 ,0x01 ,0 ,0 }, {0x3630 ,0x36 ,0 ,0 }, + {0x3631 ,0x0e ,0 ,0 }, {0x3632 ,0xe2 ,0 ,0 }, {0x3633 ,0x12 ,0 ,0 }, + {0x3621 ,0xe0 ,0 ,0 }, {0x3704 ,0xa0 ,0 ,0 }, {0x3703 ,0x5a ,0 ,0 }, + {0x3715 ,0x78 ,0 ,0 }, {0x3717 ,0x01 ,0 ,0 }, {0x370b ,0x60 ,0 ,0 }, + {0x3705 ,0x1a ,0 ,0 }, {0x3905 ,0x02 ,0 ,0 }, {0x3906 ,0x10 ,0 ,0 }, + {0x3901 ,0x0a ,0 ,0 }, {0x3731 ,0x12 ,0 ,0 }, {0x3600 ,0x08 ,0 ,0 }, + {0x3601 ,0x33 ,0 ,0 }, {0x302d ,0x60 ,0 ,0 }, {0x3620 ,0x52 ,0 ,0 }, + {0x371b ,0x20 ,0 ,0 }, {0x471c ,0x50 ,0 ,0 }, {0x3a13 ,0x43 ,0 ,0 }, + {0x3a18 ,0x00 ,0 ,0 }, {0x3a19 ,0xf8 ,0 ,0 }, {0x3635 ,0x13 ,0 ,0 }, + {0x3636 ,0x03 ,0 ,0 }, {0x3634 ,0x40 ,0 ,0 }, {0x3622 ,0x01 ,0 ,0 }, + {0x3c01 ,0xa4 ,0 ,0 }, {0x3c04 ,0x28 ,0 ,0 }, {0x3c05 ,0x98 ,0 ,0 },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,0 ,0 }, {0x3a08 ,0x01 ,0 ,0 }, {0x3a09 ,0x27 ,0 ,0 }, + {0x3a0a ,0x00 ,0 ,0 }, {0x3a0b ,0xf6 ,0 ,0 }, {0x3a0e ,0x03 ,0 ,0 }, + {0x3a0d ,0x04 ,0 ,0 }, {0x3a14 ,0x03 ,0 ,0 }, {0x3a15 ,0xd8 ,0 ,0 }, + {0x4001 ,0x02 ,0 ,0 }, {0x4004 ,0x06 ,0 ,0 }, {0x4713 ,0x03 ,0 ,0 }, + {0x4407 ,0x04 ,0 ,0 }, {0x460b ,0x35 ,0 ,0 }, {0x460c ,0x22 ,0 ,0 }, + {0x3824 ,0x02 ,0 ,0 }, {0x5001 ,0x83 ,0 ,70 }, +}; + +/* power-on sensor init reg table */ +static const struct ov5640_mode_info ov5640_mode_init_data = { +0 ,SUBSAMPLING ,640 ,480 , ov5640_init_setting_30fps_VGA, +ARRAY_SIZE (ov5640_init_setting_30fps_VGA), +}; + +static const struct ov5640_mode_info +ov5640_mode_data[OV5640_NUM_FRAMERATES ][OV5640_NUM_MODES ] = { + { + {OV5640_MODE_QCIF_176_144 ,SUBSAMPLING ,176 ,144 , + ov5640_setting_15fps_QCIF_176_144, +ARRAY_SIZE (ov5640_setting_15fps_QCIF_176_144)}, + {OV5640_MODE_QVGA_320_240 ,SUBSAMPLING ,320 ,240 , + ov5640_setting_15fps_QVGA_320_240, +ARRAY_SIZE (ov5640_setting_15fps_QVGA_320_240)}, + {OV5640_MODE_VGA_640_480 ,SUBSAMPLING ,640 ,480 , + ov5640_setting_15fps_VGA_640_480, +ARRAY_SIZE (ov5640_setting_15fps_VGA_640_480)}, + {OV5640_MODE_NTSC_720_480 ,SUBSAMPLING ,720 ,480 , + ov5640_setting_15fps_NTSC_720_480, +ARRAY_SIZE (ov5640_setting_15fps_NTSC_720_480)}, + {OV5640_MODE_PAL_720_576 ,SUBSAMPLING ,720 ,576 , + ov5640_setting_15fps_PAL_720_576, +ARRAY_SIZE (ov5640_setting_15fps_PAL_720_576)}, + {OV5640_MODE_XGA_1024_768 ,SUBSAMPLING ,1024 ,768 , + ov5640_setting_15fps_XGA_1024_768, +ARRAY_SIZE (ov5640_setting_15fps_XGA_1024_768)}, + {OV5640_MODE_720P_1280_720 ,SUBSAMPLING ,1280 ,720 , + ov5640_setting_15fps_720P_1280_720, +ARRAY_SIZE (ov5640_setting_15fps_720P_1280_720)}, + {OV5640_MODE_1080P_1920_1080 ,SCALING ,1920 ,1080 , + ov5640_setting_15fps_1080P_1920_1080, +ARRAY_SIZE (ov5640_setting_15fps_1080P_1920_1080)}, + {OV5640_MODE_QSXGA_2592_1944 ,SCALING ,2592 ,1944 , + ov5640_setting_15fps_QSXGA_2592_1944, +ARRAY_SIZE (ov5640_setting_15fps_QSXGA_2592_1944)}, + }, { + {OV5640_MODE_QCIF_176_144 ,SUBSAMPLING ,176 ,144 , + ov5640_setting_30fps_QCIF_176_144, +ARRAY_SIZE (ov5640_setting_30fps_QCIF_176_144)}, + {OV5640_MODE_QVGA_320_240 ,SUBSAMPLING ,320 ,240 , + ov5640_setting_30fps_QVGA_320_240, +ARRAY_SIZE (ov5640_setting_30fps_QVGA_320_240)}, + {OV5640_MODE_VGA_640_480 ,SUBSAMPLING ,640 ,480 , + ov5640_setting_30fps_VGA_640_480, +ARRAY_SIZE (ov5640_setting_30fps_VGA_640_480)}, + {OV5640_MODE_NTSC_720_480 ,SUBSAMPLING ,720 ,480 , + ov5640_setting_30fps_NTSC_720_480, +ARRAY_SIZE (ov5640_setting_30fps_NTSC_720_480)}, + {OV5640_MODE_PAL_720_576 ,SUBSAMPLING ,720 ,576 , + ov5640_setting_30fps_PAL_720_576, +ARRAY_SIZE (ov5640_setting_30fps_PAL_720_576)}, + {OV5640_MODE_XGA_1024_768 ,SUBSAMPLING ,1024 ,768 , + ov5640_setting_30fps_XGA_1024_768, +ARRAY_SIZE (ov5640_setting_30fps_XGA_1024_768)}, + {OV5640_MODE_720P_1280_720 ,SUBSAMPLING ,1280 ,720 , + ov5640_setting_30fps_720P_1280_720, +ARRAY_SIZE (ov5640_setting_30fps_720P_1280_720)}, + {OV5640_MODE_1080P_1920_1080 ,SCALING ,1920 ,1080 , + ov5640_setting_30fps_1080P_1920_1080, +ARRAY_SIZE (ov5640_setting_30fps_1080P_1920_1080)}, + {OV5640_MODE_QSXGA_2592_1944 ,-1 ,0 ,0 ,NULL ,0 }, + }, +}; + +static int ov5640_init_slave_id (struct ov5640_dev *sensor) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg; +u8 buf[3 ]; +int ret; + +if (client->addr ==OV5640_DEFAULT_SLAVE_ID ) +return 0 ; + + buf[0 ] =OV5640_REG_SLAVE_ID >>8 ; + buf[1 ] =OV5640_REG_SLAVE_ID &0xff ; + buf[2 ] = client->addr <<1 ; + + msg.addr =OV5640_DEFAULT_SLAVE_ID ; + msg.flags =0 ; + msg.buf = buf; + msg.len =sizeof (buf); + + ret =i2c_transfer (client->adapter, &msg,1 ); +if (ret <0 ) { +dev_err (&client->dev,"%s: failed with %d\n" , __func__, ret); +return ret; + } + +return 0 ; +} + +static int ov5640_write_reg (struct ov5640_dev *sensor,u16 reg,u8 val) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg; +u8 buf[3 ]; +int ret; + + buf[0 ] = reg >>8 ; + buf[1 ] = reg &0xff ; + buf[2 ] = val; + + msg.addr = client->addr; + msg.flags = client->flags; + msg.buf = buf; + msg.len =sizeof (buf); + + ret =i2c_transfer (client->adapter, &msg,1 ); +if (ret <0 ) { +v4l2_err (&sensor->sd,"%s: error: reg=%x, val=%x\n" , + __func__, reg, val); +return ret; + } + +return 0 ; +} + +static int ov5640_read_reg (struct ov5640_dev *sensor,u16 reg,u8 *val) +{ +struct i2c_client *client = sensor->i2c_client; +struct i2c_msg msg[2 ]; +u8 buf[2 ]; +int ret; + + buf[0 ] = reg >>8 ; + buf[1 ] = reg &0xff ; + + msg[0 ].addr = client->addr; + msg[0 ].flags = client->flags; + msg[0 ].buf = buf; + msg[0 ].len =sizeof (buf); + + msg[1 ].addr = client->addr; + msg[1 ].flags = client->flags |I2C_M_RD ; + msg[1 ].buf = buf; + msg[1 ].len =1 ; + + ret =i2c_transfer (client->adapter, msg,2 ); +if (ret <0 ) +return ret; + + *val = buf[0 ]; +return 0 ; +} + +static int ov5640_read_reg16 (struct ov5640_dev *sensor,u16 reg,u16 *val) +{ +u8 hi, lo; +int ret; + + ret =ov5640_read_reg (sensor, reg, &hi); +if (ret) +return ret; + ret =ov5640_read_reg (sensor, reg+1 , &lo); +if (ret) +return ret; + + *val = ((u16 )hi <<8 ) | (u16 )lo; +return 0 ; +}
drivers/media/i2c/ov5640.c line 875
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_write_reg16 (struct ov5640_dev *sensor,u16 reg,u16 val) +{ +int ret; + + ret =ov5640_write_reg (sensor, reg, val >>8 ); +if (ret) +return ret; + +return ov5640_write_reg (sensor, reg +1 , val &0xff );
Does the sensor datasheet suggest doing this? Making the write in two transactions will make it non-atomic that could be an issue in some corner cases.
Quoted 145 lines
drivers/media/i2c/ov5640.c new file +145
-0+} + +static int ov5640_mod_reg (struct ov5640_dev *sensor,u16 reg, +u8 mask,u8 val) +{ +u8 readval; +int ret; + + ret =ov5640_read_reg (sensor, reg, &readval); +if (ret) +return ret; + + readval &= ~mask; + val &= mask; + val |= readval; + +return ov5640_write_reg (sensor, reg, val); +} + +/* download ov5640 settings to sensor through i2c */ +static int ov5640_load_regs (struct ov5640_dev *sensor, +const struct ov5640_mode_info *mode) +{ +const struct reg_value *regs = mode->reg_data; +unsigned int i; +u32 delay_ms; +u16 reg_addr; +u8 mask, val; +int ret =0 ; + +for (i =0 ; i < mode->reg_data_size; ++i, ++regs) { + delay_ms = regs->delay_ms; + reg_addr = regs->reg_addr; + val = regs->val; + mask = regs->mask; + +if (mask) + ret =ov5640_mod_reg (sensor, reg_addr, mask, val); +else + ret =ov5640_write_reg (sensor, reg_addr, val); +if (ret) +break ; + +if (delay_ms) +usleep_range (1000 *delay_ms,1000 *delay_ms+100 ); + } + +return ret; +} + +static int ov5640_set_hue (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (0 ),BIT (0 )); +ov5640_write_reg16 (sensor,OV5640_REG_SDE_CTRL1 , value); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (0 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_contrast (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (2 ),BIT (2 )); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL5 , value &0xff ); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (2 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_saturation (struct ov5640_dev *sensor,int value) +{ +if (value) { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (1 ),BIT (1 )); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL3 , value &0xff ); +ov5640_write_reg (sensor,OV5640_REG_SDE_CTRL4 , value &0xff ); + }else { +ov5640_mod_reg (sensor,OV5640_REG_SDE_CTRL0 ,BIT (1 ),0 ); + } + +return 0 ; +} + +static int ov5640_set_white_balance (struct ov5640_dev *sensor,int awb) +{ +ov5640_mod_reg (sensor,OV5640_REG_AWB_MANUAL_CTRL , +BIT (0 ), awb ?0 :1 ); + +if (!awb) { +u16 red = (u16 )sensor->ctrls.red_balance->val; +u16 blue = (u16 )sensor->ctrls.blue_balance->val; + +ov5640_write_reg16 (sensor,OV5640_REG_AWB_R_GAIN , red); +ov5640_write_reg16 (sensor,OV5640_REG_AWB_B_GAIN , blue); + } + +return 0 ; +} + +static int ov5640_set_exposure (struct ov5640_dev *sensor,int exp) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; +bool auto_exposure = (exp ==V4L2_EXPOSURE_AUTO ); + +if (ctrls->auto_exp->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (0 ), auto_exposure ?0 :BIT (0 )); + } + +if (!auto_exposure && ctrls->exposure->is_new) { +u16 max_exp; + +ov5640_read_reg16 (sensor,OV5640_REG_AEC_PK_VTS , &max_exp); +if (ctrls->exposure->val < max_exp) { +u32 exposure = ctrls->exposure->val <<4 ; + +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_LO , + exposure &0xff ); +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_MED , + (exposure >>8 ) &0xff ); +ov5640_write_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_HI , + (exposure >>16 ) &0x0f ); + } + } + +return 0 ; +} + +/* read exposure, in number of line periods */ +static int ov5640_get_exposure (struct ov5640_dev *sensor) +{ +u8 temp; +int exp; + +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_HI , &temp); + exp = ((int )temp &0x0f ) <<16 ; +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_MED , &temp); + exp |= ((int )temp <<8 ); +ov5640_read_reg (sensor,OV5640_REG_AEC_PK_EXPOSURE_LO , &temp); + exp |= (int )temp; +
drivers/media/i2c/ov5640.c line 1030
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+return exp >>4 ; +} + +static int ov5640_set_gain (struct ov5640_dev *sensor,int auto_gain) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; + +if (ctrls->auto_gain->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (1 ), ctrls->auto_gain->val ?0 :BIT (1 ));
You're generally silently ignoring all I?C access errors. Is that intentional?
Quoted 767 lines
drivers/media/i2c/ov5640.c new file +767
-0+ } + +if (!auto_gain && ctrls->gain->is_new) { +u16 gain = (u16 )ctrls->gain->val; + +ov5640_write_reg16 (sensor,OV5640_REG_AEC_PK_REAL_GAIN , + gain &0x3ff ); + } + +return 0 ; +} + +static int ov5640_get_gain (struct ov5640_dev *sensor) +{ +u16 gain; + +ov5640_read_reg16 (sensor,OV5640_REG_AEC_PK_REAL_GAIN , &gain); + +return gain &0x3ff ; +} + +static int ov5640_set_agc_aec (struct ov5640_dev *sensor,bool on) +{ +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +0x3 , on ?0 :0x3 ); +return 0 ; +} + +static int ov5640_set_test_pattern (struct ov5640_dev *sensor,int value) +{ +ov5640_mod_reg (sensor,OV5640_REG_PRE_ISP_TEST_SET1 , +0xa4 , value ?0xa4 :0 ); +return 0 ; +} + +static int ov5640_set_stream (struct ov5640_dev *sensor,bool on) +{ +ov5640_mod_reg (sensor,OV5640_REG_MIPI_CTRL00 ,BIT (5 ), + on ?0 :BIT (5 )); +ov5640_write_reg (sensor,OV5640_REG_PAD_OUTPUT00 , + on ?0x00 :0x70 ); +ov5640_write_reg (sensor,OV5640_REG_FRAME_CTRL01 , + on ?0x00 :0x0f ); +return 0 ; +} + +static int ov5640_get_sysclk (struct ov5640_dev *sensor) +{ +/* calculate sysclk */ +u32 xvclk = sensor->xclk_freq /10000 ; +u32 multiplier, prediv,VCO , sysdiv, pll_rdiv; +u32 sclk_rdiv_map[] = {1 ,2 ,4 ,8 }; +u32 bit_div2x =1 , sclk_rdiv, sysclk; +u8 temp1, temp2; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL0 , &temp1); + temp2 = temp1 &0x0f ; +if (temp2 ==8 || temp2 ==10 ) + bit_div2x = temp2 /2 ; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL1 , &temp1); + sysdiv = temp1 >>4 ; +if (sysdiv ==0 ) + sysdiv =16 ; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL2 , &temp1); + multiplier = temp1; + +ov5640_read_reg (sensor,OV5640_REG_SC_PLL_CTRL3 , &temp1); + prediv = temp1 &0x0f ; + pll_rdiv = ((temp1 >>4 ) &0x01 ) +1 ; + +ov5640_read_reg (sensor,OV5640_REG_SYS_ROOT_DIVIDER , &temp1); + temp2 = temp1 &0x03 ; + sclk_rdiv = sclk_rdiv_map[temp2]; + +if (!prediv || !sysdiv || !pll_rdiv || !bit_div2x) +return -EINVAL ; + +VCO = xvclk * multiplier / prediv; + + sysclk =VCO / sysdiv / pll_rdiv *2 / bit_div2x / sclk_rdiv; + +return sysclk; +} + +static int ov5640_set_night_mode (struct ov5640_dev *sensor) +{ +/* read HTS from register settings */ +u8 mode; + +ov5640_read_reg (sensor,OV5640_REG_AEC_CTRL00 , &mode); + mode &=0xfb ; +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL00 , mode); +return 0 ; +} + +static int ov5640_get_hts (struct ov5640_dev *sensor) +{ +/* read HTS from register settings */ +u16 hts; + +ov5640_read_reg16 (sensor,OV5640_REG_TIMING_HTS , &hts); +return hts; +} + +static int ov5640_get_vts (struct ov5640_dev *sensor) +{ +u16 vts; + +ov5640_read_reg16 (sensor,OV5640_REG_TIMING_VTS , &vts); +return vts; +} + +static int ov5640_set_vts (struct ov5640_dev *sensor,int vts) +{ +ov5640_write_reg16 (sensor,OV5640_REG_TIMING_VTS , vts); +return 0 ; +} + +static int ov5640_get_light_freq (struct ov5640_dev *sensor) +{ +/* get banding filter value */ +u8 temp, temp1; +int light_freq =0 ; + +ov5640_read_reg (sensor,OV5640_REG_HZ5060_CTRL01 , &temp); + +if (temp &0x80 ) { +/* manual */ +ov5640_read_reg (sensor,OV5640_REG_HZ5060_CTRL00 , &temp1); +if (temp1 &0x04 ) { +/* 50Hz */ + light_freq =50 ; + }else { +/* 60Hz */ + light_freq =60 ; + } + }else { +/* auto */ +ov5640_read_reg (sensor,OV5640_REG_SIGMADELTA_CTRL0C , + &temp1); +if (temp1 &0x01 ) { +/* 50Hz */ + light_freq =50 ; + }else { +/* 60Hz */ + } + } + +return light_freq; +} + +static int ov5640_set_bandingfilter (struct ov5640_dev *sensor) +{ +u32 band_step60, max_band60, band_step50, max_band50, prev_vts; +int ret; + +/* read preview PCLK */ + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_sysclk = ret; +/* read preview HTS */ + ret =ov5640_get_hts (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_hts = ret; + +/* read preview VTS */ + ret =ov5640_get_vts (sensor); +if (ret <0 ) +return ret; + prev_vts = ret; + + +/* calculate banding filter */ +/* 60Hz */ + band_step60 = sensor->prev_sysclk *100 / sensor->prev_hts *100 /120 ; +ov5640_write_reg16 (sensor,OV5640_REG_AEC_B60_STEP , band_step60); +if (!band_step60) +return -EINVAL ; + max_band60 = (int )((prev_vts -4 ) / band_step60); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0D , max_band60); + +/* 50Hz */ + band_step50 = sensor->prev_sysclk *100 / sensor->prev_hts; +ov5640_write_reg16 (sensor,OV5640_REG_AEC_B50_STEP , band_step50); +if (!band_step50) +return -EINVAL ; + max_band50 = (int )((prev_vts -4 ) / band_step50); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0E , max_band50); + +return 0 ; +} + +static int ov5640_set_ae_target (struct ov5640_dev *sensor,int target) +{ +/* stable in high */ +u32 fast_high, fast_low; + + sensor->ae_low = target *23 /25 ;/* 0.92 */ + sensor->ae_high = target *27 /25 ;/* 1.08 */ + + fast_high = sensor->ae_high <<1 ; +if (fast_high >255 ) + fast_high =255 ; + + fast_low = sensor->ae_low >>1 ; + +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL0F , sensor->ae_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL10 , sensor->ae_low); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1B , sensor->ae_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1E , sensor->ae_low); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL11 , fast_high); +ov5640_write_reg (sensor,OV5640_REG_AEC_CTRL1F , fast_low); + +return 0 ; +} + +static int ov5640_binning_on (struct ov5640_dev *sensor) +{ +u8 temp; + +ov5640_read_reg (sensor,OV5640_REG_TIMING_TC_REG21 , &temp); + temp &=0xfe ; + +return temp ?1 :0 ; +} + +static int ov5640_set_virtual_channel (struct ov5640_dev *sensor) +{ +u8 temp, channel =OV5640_MIPI_VC ; + +ov5640_read_reg (sensor,OV5640_REG_DEBUG_MODE , &temp); + temp &= ~(3 <<6 ); + temp |= (channel <<6 ); +ov5640_write_reg (sensor,OV5640_REG_DEBUG_MODE , temp); + +return 0 ; +} + +static const struct ov5640_mode_info * +ov5640_find_mode (struct ov5640_dev *sensor,enum ov5640_frame_rate fr, +int width,int height,bool nearest) +{ +const struct ov5640_mode_info *mode =NULL ; +int i; + +for (i =OV5640_NUM_MODES -1 ; i >=0 ; i--) { + mode = &ov5640_mode_data[fr][i]; + +if (!mode->reg_data) +continue ; + +if ((nearest && mode->width <= width && + mode->height <= height) || + (!nearest && mode->width == width && + mode->height == height)) +break ; + } + +if (nearest && i <0 ) + mode = &ov5640_mode_data[fr][0 ]; + +return mode; +} + +/* +* sensor changes between scaling and subsampling, go through +* exposure calculation +*/ +static int ov5640_set_mode_exposure_calc ( +struct ov5640_dev *sensor,const struct ov5640_mode_info *mode) +{ +u32 prev_shutter, prev_gain16; +u32 cap_shutter, cap_gain16; +u32 cap_sysclk, cap_hts, cap_vts; +u32 light_freq, cap_bandfilt, cap_maxband; +u32 cap_gain16_shutter; +u8 average; +int ret; + +if (mode->reg_data ==NULL ) +return -EINVAL ; + +/* turn off AE/AG */ + ret =ov5640_set_agc_aec (sensor, false); +if (ret <0 ) +return ret; + +/* read preview shutter */ + ret =ov5640_get_exposure (sensor); +if (ret <0 ) +return ret; + prev_shutter = ret; + ret =ov5640_binning_on (sensor); +if (ret <0 ) +return ret; +if (ret && mode->id !=OV5640_MODE_720P_1280_720 && + mode->id !=OV5640_MODE_1080P_1920_1080 ) + prev_shutter *=2 ; + +/* read preview gain */ + ret =ov5640_get_gain (sensor); +if (ret <0 ) +return ret; + prev_gain16 = ret; + +/* get average */ +ov5640_read_reg (sensor,OV5640_REG_AVG_READOUT , &average); + +/* turn off night mode for capture */ + ret =ov5640_set_night_mode (sensor); +if (ret <0 ) +return ret; + +/* Write capture setting */ + ret =ov5640_load_regs (sensor, mode); +if (ret <0 ) +return ret; + +/* read capture VTS */ + ret =ov5640_get_vts (sensor); +if (ret <0 ) +return ret; + cap_vts = ret; + ret =ov5640_get_hts (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + cap_hts = ret; + + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + cap_sysclk = ret; + +/* calculate capture banding filter */ + ret =ov5640_get_light_freq (sensor); +if (ret <0 ) +return ret; + light_freq = ret; + +if (light_freq ==60 ) { +/* 60Hz */ + cap_bandfilt = cap_sysclk *100 / cap_hts *100 /120 ; + }else { +/* 50Hz */ + cap_bandfilt = cap_sysclk *100 / cap_hts; + } + +if (!sensor->prev_sysclk) { + ret =ov5640_get_sysclk (sensor); +if (ret <0 ) +return ret; +if (ret ==0 ) +return -EINVAL ; + sensor->prev_sysclk = ret; + } + +if (!cap_bandfilt) +return -EINVAL ; + + cap_maxband = (int )((cap_vts -4 ) / cap_bandfilt); + +/* calculate capture shutter/gain16 */ +if (average > sensor->ae_low && average < sensor->ae_high) { +/* in stable range */ + cap_gain16_shutter = + prev_gain16 * prev_shutter * + cap_sysclk / sensor->prev_sysclk * + sensor->prev_hts / cap_hts * + sensor->ae_target / average; + }else { + cap_gain16_shutter = + prev_gain16 * prev_shutter * + cap_sysclk / sensor->prev_sysclk * + sensor->prev_hts / cap_hts; + } + +/* gain to shutter */ +if (cap_gain16_shutter < (cap_bandfilt *16 )) { +/* shutter < 1/100 */ + cap_shutter = cap_gain16_shutter /16 ; +if (cap_shutter <1 ) + cap_shutter =1 ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; +if (cap_gain16 <16 ) + cap_gain16 =16 ; + }else { +if (cap_gain16_shutter > (cap_bandfilt * cap_maxband *16 )) { +/* exposure reach max */ + cap_shutter = cap_bandfilt * cap_maxband; +if (!cap_shutter) +return -EINVAL ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; + }else { +/* 1/100 < (cap_shutter = n/100) =< max */ + cap_shutter = + ((int )(cap_gain16_shutter /16 / cap_bandfilt)) + * cap_bandfilt; +if (!cap_shutter) +return -EINVAL ; + + cap_gain16 = cap_gain16_shutter / cap_shutter; + } + } + +/* write capture gain */ + ret =ov5640_set_gain (sensor, cap_gain16); +if (ret <0 ) +return ret; + +/* write capture shutter */ +if (cap_shutter > (cap_vts -4 )) { + cap_vts = cap_shutter +4 ; + ret =ov5640_set_vts (sensor, cap_vts); +if (ret <0 ) +return ret; + } + +return ov5640_set_exposure (sensor, cap_shutter); +} + +/* +* if sensor changes inside scaling or subsampling +* change mode directly +*/ +static int ov5640_set_mode_direct (struct ov5640_dev *sensor, +const struct ov5640_mode_info *mode) +{ +int ret; + +if (mode->reg_data ==NULL ) +return -EINVAL ; + +/* turn off AE/AG */ + ret =ov5640_set_agc_aec (sensor, false); +if (ret <0 ) +return ret; + +/* Write capture setting */ + ret =ov5640_load_regs (sensor, mode); +if (ret <0 ) +return ret; + +return ov5640_set_agc_aec (sensor, true); +} + +static int ov5640_set_mode (struct ov5640_dev *sensor, +const struct ov5640_mode_info *orig_mode) +{ +const struct ov5640_mode_info *mode = sensor->current_mode; +enum ov5640_downsize_mode dn_mode, orig_dn_mode; +int ret; + + dn_mode = mode->dn_mode; + orig_dn_mode = orig_mode->dn_mode; + +if ((dn_mode ==SUBSAMPLING && orig_dn_mode ==SCALING ) || + (dn_mode ==SCALING && orig_dn_mode ==SUBSAMPLING )) { +/* +* change between subsampling and scaling +* go through exposure calucation +*/ + ret =ov5640_set_mode_exposure_calc (sensor, mode); + }else { +/* +* change inside subsampling or scaling +* download firmware directly +*/ + ret =ov5640_set_mode_direct (sensor, mode); + } + +if (ret <0 ) +return ret; + + ret =ov5640_set_ae_target (sensor, sensor->ae_target); +if (ret <0 ) +return ret; + ret =ov5640_get_light_freq (sensor); +if (ret <0 ) +return ret; + ret =ov5640_set_bandingfilter (sensor); +if (ret <0 ) +return ret; + ret =ov5640_set_virtual_channel (sensor); +if (ret <0 ) +return ret; + + sensor->pending_mode_change = false; + +return 0 ; +} + +/* restore the last set video mode after chip power-on */ +static int ov5640_restore_mode (struct ov5640_dev *sensor) +{ +int ret; + +/* first load the initial register values */ + ret =ov5640_load_regs (sensor, &ov5640_mode_init_data); +if (ret <0 ) +return ret; + +/* now restore the last capture mode */ +return ov5640_set_mode (sensor, &ov5640_mode_init_data); +} + +static void ov5640_power (struct ov5640_dev *sensor,bool enable) +{ +if (sensor->pwdn_gpio) +gpiod_set_value (sensor->pwdn_gpio, enable ?0 :1 ); +} + +static void ov5640_reset (struct ov5640_dev *sensor) +{ +if (!sensor->reset_gpio) +return ; + +gpiod_set_value (sensor->reset_gpio,0 ); + +/* camera power cycle */ +ov5640_power (sensor, false); +usleep_range (5000 ,10000 ); +ov5640_power (sensor, true); +usleep_range (5000 ,10000 ); + +gpiod_set_value (sensor->reset_gpio,1 ); +usleep_range (1000 ,2000 ); + +gpiod_set_value (sensor->reset_gpio,0 ); +usleep_range (5000 ,10000 ); +} + +static int ov5640_set_power (struct ov5640_dev *sensor,bool on) +{ +int ret =0 ; + +if (on) { +clk_prepare_enable (sensor->xclk); + + ret =regulator_bulk_enable (OV5640_NUM_SUPPLIES , + sensor->supplies); +if (ret) + goto xclk_off; + +ov5640_reset (sensor); +ov5640_power (sensor, true); + + ret =ov5640_init_slave_id (sensor); +if (ret) + goto power_off; + + ret =ov5640_restore_mode (sensor); +if (ret) + goto power_off; + +/* +* start streaming briefly followed by stream off in +* order to coax the clock lane into LP-11 state. +*/ +ov5640_set_stream (sensor, true); +usleep_range (1000 ,2000 ); +ov5640_set_stream (sensor, false); + +return 0 ; + } + +power_off: +ov5640_power (sensor, false); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies); +xclk_off: +clk_disable_unprepare (sensor->xclk); +return ret; +} + +/* --------------- Subdev Operations --------------- */ + +static int ov5640_s_power (struct v4l2_subdev *sd,int on) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +/* +* If the power count is modified from 0 to != 0 or from != 0 to 0, +* update the power state. +*/ +if (sensor->power_count == !on) { + ret =ov5640_set_power (sensor, !!on); +if (ret) + goto out; + } + +/* Update the power count. */ + sensor->power_count += on ?1 :-1 ; +WARN_ON (sensor->power_count <0 ); +out: +mutex_unlock (&sensor->lock); + +if (on && !ret && sensor->power_count ==1 ) { +/* restore controls */ + ret =v4l2_ctrl_handler_setup (&sensor->ctrls.handler); + } + +return ret; +} + +static int ov5640_try_frame_interval (struct ov5640_dev *sensor, +struct v4l2_fract *fi, +u32 width,u32 height) +{ +const struct ov5640_mode_info *mode; +u32 minfps, maxfps, fps; +int ret; + + minfps = ov5640_framerates[OV5640_15_FPS ]; + maxfps = ov5640_framerates[OV5640_30_FPS ]; + +if (fi->numerator ==0 ) { + fi->denominator = maxfps; + fi->numerator =1 ; +return OV5640_30_FPS ; + } + + fps =DIV_ROUND_CLOSEST (fi->denominator, fi->numerator); + + fi->numerator =1 ; +if (fps > maxfps) + fi->denominator = maxfps; +else if (fps < minfps) + fi->denominator = minfps; +else if (2 * fps >=2 * minfps + (maxfps - minfps)) + fi->denominator = maxfps; +else + fi->denominator = minfps; + + ret = (fi->denominator == minfps) ?OV5640_15_FPS :OV5640_30_FPS ; + + mode =ov5640_find_mode (sensor, ret, width, height, false); +return mode ? ret : -EINVAL ; +} + +static int ov5640_get_fmt (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_format *format) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +struct v4l2_mbus_framefmt *fmt; + +if (format->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (format->which ==V4L2_SUBDEV_FORMAT_TRY ) + fmt =v4l2_subdev_get_try_format (&sensor->sd, cfg, + format->pad); +else + fmt = &sensor->fmt; + + format->format = *fmt; + +mutex_unlock (&sensor->lock); + +return 0 ; +} + +static int ov5640_try_fmt_internal (struct v4l2_subdev *sd, +struct v4l2_mbus_framefmt *fmt, +enum ov5640_frame_rate fr, +const struct ov5640_mode_info **new_mode) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *mode; + + mode =ov5640_find_mode (sensor, fr, fmt->width, fmt->height, true); +if (!mode) +return -EINVAL ; + + fmt->width = mode->width; + fmt->height = mode->height; + fmt->code = sensor->fmt.code; + +if (new_mode) + *new_mode = mode; +return 0 ; +} + +static int ov5640_set_fmt (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_format *format) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *new_mode; +int ret; + +if (format->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (sensor->streaming) { + ret = -EBUSY ; + goto out; + } + + ret =ov5640_try_fmt_internal (sd, &format->format, + sensor->current_fr, &new_mode); +if (ret) + goto out; + +if (format->which ==V4L2_SUBDEV_FORMAT_TRY ) { +struct v4l2_mbus_framefmt *fmt = +v4l2_subdev_get_try_format (sd, cfg,0 ); + + *fmt = format->format; + goto out; + } + + sensor->current_mode = new_mode; + sensor->fmt = format->format; + sensor->pending_mode_change = true; +out: +mutex_unlock (&sensor->lock); +return ret; +} + + +/* +* Sensor Controls. +*/ + +static int ov5640_g_volatile_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +mutex_lock (&sensor->lock); + +switch (ctrl->id) { +case V4L2_CID_AUTOGAIN : +if (!ctrl->val) + goto out; + sensor->ctrls.gain->val =ov5640_get_gain (sensor); +break ; +case V4L2_CID_EXPOSURE_AUTO : +if (ctrl->val ==V4L2_EXPOSURE_MANUAL ) + goto out; + sensor->ctrls.exposure->val =ov5640_get_exposure (sensor); +break ; + } + +out: +mutex_unlock (&sensor->lock);
drivers/media/i2c/ov5640.c line 1807
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+return 0 ; +} + +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);
Could you use the same lock for the controls as you use for the rest? Just setting handler->lock after handler init does the trick.
Quoted 215 lines
drivers/media/i2c/ov5640.c new file +215
-0+ +/* +* If the device is not powered up by the host driver do +* not apply any controls to H/W at this time. Instead +* the controls will be restored right after power-up. +*/ +if (sensor->power_count ==0 ) + goto out; + +switch (ctrl->id) { +case V4L2_CID_AUTOGAIN : + ret =ov5640_set_gain (sensor, ctrl->val); +break ; +case V4L2_CID_EXPOSURE_AUTO : + ret =ov5640_set_exposure (sensor, ctrl->val); +break ; +case V4L2_CID_AUTO_WHITE_BALANCE : + ret =ov5640_set_white_balance (sensor, ctrl->val); +break ; +case V4L2_CID_HUE : + ret =ov5640_set_hue (sensor, ctrl->val); +break ; +case V4L2_CID_CONTRAST : + ret =ov5640_set_contrast (sensor, ctrl->val); +break ; +case V4L2_CID_SATURATION : + ret =ov5640_set_saturation (sensor, ctrl->val); +break ; +case V4L2_CID_TEST_PATTERN : + ret =ov5640_set_test_pattern (sensor, ctrl->val); +break ; +default : + ret = -EINVAL ; +break ; + } + +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static const struct v4l2_ctrl_ops ov5640_ctrl_ops = { + .g_volatile_ctrl = ov5640_g_volatile_ctrl, + .s_ctrl = ov5640_s_ctrl, +}; + +static const char *const test_pattern_menu[] = { +"Disabled" , +"Color bars" , +}; + +static int ov5640_init_controls (struct ov5640_dev *sensor) +{ +const struct v4l2_ctrl_ops *ops = &ov5640_ctrl_ops; +struct ov5640_ctrls *ctrls = &sensor->ctrls; +struct v4l2_ctrl_handler *hdl = &ctrls->handler; +int ret; + +v4l2_ctrl_handler_init (hdl,32 ); + +/* Auto/manual white balance */ + ctrls->auto_wb =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_AUTO_WHITE_BALANCE , +0 ,1 ,1 ,1 ); + ctrls->blue_balance =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_BLUE_BALANCE , +0 ,4095 ,1 ,0 ); + ctrls->red_balance =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_RED_BALANCE , +0 ,4095 ,1 ,0 ); +/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 ); +/* Auto/manual gain */ + ctrls->auto_gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTOGAIN , +0 ,1 ,1 ,1 ); + ctrls->gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_GAIN , +0 ,1023 ,1 ,0 ); + + ctrls->saturation =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_SATURATION , +0 ,255 ,1 ,64 ); + ctrls->hue =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_HUE , +0 ,359 ,1 ,0 ); + ctrls->contrast =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_CONTRAST , +0 ,255 ,1 ,0 ); + ctrls->test_pattern = +v4l2_ctrl_new_std_menu_items (hdl, ops,V4L2_CID_TEST_PATTERN , +ARRAY_SIZE (test_pattern_menu) -1 , +0 ,0 , test_pattern_menu); + +if (hdl->error) { + ret = hdl->error; + goto free_ctrls; + } + + ctrls->gain->flags |=V4L2_CTRL_FLAG_VOLATILE ; + ctrls->exposure->flags |=V4L2_CTRL_FLAG_VOLATILE ; + +v4l2_ctrl_auto_cluster (3 , &ctrls->auto_wb,0 , false); +v4l2_ctrl_auto_cluster (2 , &ctrls->auto_gain,0 , true); +v4l2_ctrl_auto_cluster (2 , &ctrls->auto_exp,1 , true); + + sensor->sd.ctrl_handler = hdl; +return 0 ; + +free_ctrls: +v4l2_ctrl_handler_free (hdl); +return ret; +} + +static int ov5640_enum_frame_size (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_size_enum *fse) +{ +if (fse->pad !=0 ) +return -EINVAL ; +if (fse->index >=OV5640_NUM_MODES ) +return -EINVAL ; + + fse->min_width = fse->max_width = + ov5640_mode_data[0 ][fse->index].width; + fse->min_height = fse->max_height = + ov5640_mode_data[0 ][fse->index].height; + +return 0 ; +} + +static int ov5640_enum_frame_interval ( +struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_interval_enum *fie) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +struct v4l2_fract tpf; +int ret; + +if (fie->pad !=0 ) +return -EINVAL ; +if (fie->index >=OV5640_NUM_FRAMERATES ) +return -EINVAL ; + + tpf.numerator =1 ; + tpf.denominator = ov5640_framerates[fie->index]; + + ret =ov5640_try_frame_interval (sensor, &tpf, + fie->width, fie->height); +if (ret <0 ) +return -EINVAL ; + + fie->interval = tpf; +return 0 ; +} + +static int ov5640_g_frame_interval (struct v4l2_subdev *sd, +struct v4l2_subdev_frame_interval *fi) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +mutex_lock (&sensor->lock); + fi->interval = sensor->frame_interval; +mutex_unlock (&sensor->lock); + +return 0 ; +} + +static int ov5640_s_frame_interval (struct v4l2_subdev *sd, +struct v4l2_subdev_frame_interval *fi) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +const struct ov5640_mode_info *mode; +int frame_rate, ret =0 ; + +if (fi->pad !=0 ) +return -EINVAL ; + +mutex_lock (&sensor->lock); + +if (sensor->streaming) { + ret = -EBUSY ; + goto out; + } + + mode = sensor->current_mode; + + frame_rate =ov5640_try_frame_interval (sensor, &fi->interval, + mode->width, mode->height); +if (frame_rate <0 ) + frame_rate =OV5640_15_FPS ; + + sensor->current_fr = frame_rate; + sensor->frame_interval = fi->interval; + sensor->pending_mode_change = true; +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static int ov5640_enum_mbus_code (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_mbus_code_enum *code) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +if (code->pad !=0 ) +return -EINVAL ; +if (code->index !=0 ) +return -EINVAL ; + + code->code = sensor->fmt.code; + +return 0 ; +}
drivers/media/i2c/ov5640.c line 2032
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 )
The entity stream_count isn't connected to the number of times s_stream(sd, true) is called. Please remove the check.
Quoted 138 lines
drivers/media/i2c/ov5640.c new file +138
-0+ goto out; +#endif + +if (sensor->streaming == !enable) { +if (enable && sensor->pending_mode_change) { + ret =ov5640_set_mode (sensor, sensor->current_mode); +if (ret) + goto out; + } + + ret =ov5640_set_stream (sensor, enable); +if (!ret) + sensor->streaming = enable; + } +out: +mutex_unlock (&sensor->lock); +return ret; +} + +static const struct v4l2_subdev_core_ops ov5640_core_ops = { + .s_power = ov5640_s_power, +}; + +static const struct v4l2_subdev_video_ops ov5640_video_ops = { + .g_frame_interval = ov5640_g_frame_interval, + .s_frame_interval = ov5640_s_frame_interval, + .s_stream = ov5640_s_stream, +}; + +static const struct v4l2_subdev_pad_ops ov5640_pad_ops = { + .enum_mbus_code = ov5640_enum_mbus_code, + .get_fmt = ov5640_get_fmt, + .set_fmt = ov5640_set_fmt, + .enum_frame_size = ov5640_enum_frame_size, + .enum_frame_interval = ov5640_enum_frame_interval, +}; + +static const struct v4l2_subdev_ops ov5640_subdev_ops = { + .core = &ov5640_core_ops, + .video = &ov5640_video_ops, + .pad = &ov5640_pad_ops, +}; + +static int ov5640_get_regulators (struct ov5640_dev *sensor) +{ +int i; + +for (i =0 ; i <OV5640_NUM_SUPPLIES ; i++) + sensor->supplies[i].supply = ov5640_supply_name[i]; + +return devm_regulator_bulk_get (&sensor->i2c_client->dev, +OV5640_NUM_SUPPLIES , + sensor->supplies); +} + +static int ov5640_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct device *dev = &client->dev; +struct device_node *endpoint; +struct ov5640_dev *sensor; +int ret; + + sensor =devm_kzalloc (dev,sizeof (*sensor),GFP_KERNEL ); +if (!sensor) +return -ENOMEM ; + + sensor->i2c_client = client; + sensor->fmt.code =MEDIA_BUS_FMT_UYVY8_2X8 ; + sensor->fmt.width =640 ; + sensor->fmt.height =480 ; + sensor->fmt.field =V4L2_FIELD_NONE ; + sensor->frame_interval.numerator =1 ; + sensor->frame_interval.denominator = ov5640_framerates[OV5640_30_FPS ]; + sensor->current_fr =OV5640_30_FPS ; + sensor->current_mode = + &ov5640_mode_data[OV5640_30_FPS ][OV5640_MODE_VGA_640_480 ]; + sensor->pending_mode_change = true; + + sensor->ae_target =52 ; + + endpoint =of_graph_get_next_endpoint (client->dev.of_node,NULL ); +if (!endpoint) { +dev_err (dev,"endpoint node not found\n" ); +return -EINVAL ; + } + +v4l2_of_parse_endpoint (endpoint, &sensor->ep); +of_node_put (endpoint); + +if (sensor->ep.bus_type !=V4L2_MBUS_CSI2 ) { +dev_err (dev,"invalid bus type, must be MIPI CSI2\n" ); +return -EINVAL ; + } + +/* get system clock (xclk) */ + sensor->xclk =devm_clk_get (dev,"xclk" ); +if (IS_ERR (sensor->xclk)) { +dev_err (dev,"failed to get xclk\n" ); +return PTR_ERR (sensor->xclk); + } + + sensor->xclk_freq =clk_get_rate (sensor->xclk); +if (sensor->xclk_freq <OV5640_XCLK_MIN || + sensor->xclk_freq >OV5640_XCLK_MAX ) { +dev_err (dev,"xclk frequency out of range: %d Hz\n" , + sensor->xclk_freq); +return -EINVAL ; + } + +/* request optional power down pin */ + sensor->pwdn_gpio =devm_gpiod_get_optional (dev,"powerdown" , +GPIOD_OUT_HIGH ); +/* request optional reset pin */ + sensor->reset_gpio =devm_gpiod_get_optional (dev,"reset" , +GPIOD_OUT_HIGH ); + +v4l2_i2c_subdev_init (&sensor->sd, client, &ov5640_subdev_ops); + + sensor->sd.flags =V4L2_SUBDEV_FL_HAS_DEVNODE ; + sensor->pad.flags =MEDIA_PAD_FL_SOURCE ; + sensor->sd.entity.function =MEDIA_ENT_F_CAM_SENSOR ; + ret =media_entity_pads_init (&sensor->sd.entity,1 , &sensor->pad); +if (ret) +return ret; + + ret =ov5640_get_regulators (sensor); +if (ret) +return ret; + +mutex_init (&sensor->lock); + + ret =ov5640_init_controls (sensor); +if (ret) + goto entity_cleanup; + + ret =v4l2_async_register_subdev (&sensor->sd); +if (ret)
drivers/media/i2c/ov5640.c line 2180
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ goto free_ctrls; + +return 0 ; + +free_ctrls: +v4l2_ctrl_handler_free (&sensor->ctrls.handler); +entity_cleanup: +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);
Should this still be here?
drivers/media/i2c/ov5640.c line 2189
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+return ret; +} + +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);
Ditto.
Quoted 35 lines
drivers/media/i2c/ov5640.c new file +35
-0+ +v4l2_async_unregister_subdev (&sensor->sd); +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +v4l2_ctrl_handler_free (&sensor->ctrls.handler); + +return 0 ; +} + +static const struct i2c_device_id ov5640_id[] = { + {"ov5640" ,0 }, + {}, +}; +MODULE_DEVICE_TABLE (i2c, ov5640_id); + +static const struct of_device_id ov5640_dt_ids[] = { + { .compatible ="ovti,ov5640" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, ov5640_dt_ids); + +static struct i2c_driver ov5640_i2c_driver = { + .driver = { + .name ="ov5640" , + .of_match_table = ov5640_dt_ids, + }, + .id_table = ov5640_id, + .probe = ov5640_probe, + .remove = ov5640_remove, +}; + +module_i2c_driver (ov5640_i2c_driver); + +MODULE_DESCRIPTION ("OV5640 MIPI Camera Subdev Driver" ); +MODULE_LICENSE ("GPL" );
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi Sakari,
Quoted 85 lines · Sakari Ailus
Hi Steve,
A few comments below.
Quoted 68 lines · Steve Longerbeam
This driver is based on
ov5640_mipi.cfrom Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup.Signed-off-by Steve Longerbeam<[email protected]>--- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2234 insertions(+)create mode 100644
drivers/media/i2c/ov5640.cdrivers/media/i2c/Kconfig +9
-0@@ -539,6 +539,15 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on OF + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV5645 tristate "OmniVision OV5645 sensor support" depends on OFdrivers/media/i2c/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV5645) += ov5645.o obj-$(CONFIG_VIDEO_OV5647) += ov5647.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.odrivers/media/i2c/ov5640.c new file +18
-0@@ -0,0 +1,2224 @@ +/* +* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2014-2017 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 <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/clkdev.h> +#include <linux/ctype.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/i2c.h> +#include <linux/init.h> drivers/media/i2c/ov5640.c line 28
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/slab.h> +#include <linux/types.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> +#include <media/v4l2-async.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-of.h> Could you rebase this on the V4L2 fwnode patchset here, please?
Quoted 1 line
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-acpi>
Once the fwnode patchset hits mediatree, then yes it can be converted along with all the others under media/i2c.
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 875
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_write_reg16 (struct ov5640_dev *sensor,u16 reg,u16 val) +{ +int ret; + + ret =ov5640_write_reg (sensor, reg, val >>8 ); +if (ret) +return ret; + +return ov5640_write_reg (sensor, reg +1 , val &0xff );Does the sensor datasheet suggest doing this?
Why would the datasheet suggest or not suggest such things? Coding details like this don't belong in the datasheet.
Quoted 3 lines
Making the write in two
transactions will make it non-atomic that could be an issue in some corner cases.
It's called everywhere under the same device mutex.
Quoted 11 lines
<snip>
drivers/media/i2c/ov5640.c line 1030
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_set_gain (struct ov5640_dev *sensor,int auto_gain) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; + +if (ctrls->auto_gain->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (1 ), ctrls->auto_gain->val ?0 :BIT (1 ));You're generally silently ignoring all I²C access errors. Is that intentional?
Yeah, this driver is much cleaned up from the original, but there are still some issues like this. The register access errors are really only being paid attention to during s_power() when loading the initial register set, which is enough at least to catch a non-existent chip or basic i2c bus or other hardware issues. But I should work on catching all access errors. This is something I did in an earlier rev but I used a questionable short-cut to make it easier to implement. I'll just have to catch every case one by one.
Quoted 12 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just setting
handler->lockafter handler init does the trick.
Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver and I am already using that same lock.
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 2032
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 )The entity
stream_countisn't connected to the number of timess_stream(sd, true)is called. Please remove the check.
It's incremented by media_pipeline_start(), even if the entity is already a member of the given pipeline.
I added this check because in imx-media, the ov5640 can be streaming concurrently to multiple video capture devices, and each capture device calls media_pipeline_start() at stream on, which increments the entity stream count.
So if one capture device issues a stream off while others are still streaming, ov5640 should remain at stream on. So the entity stream count is being used as a streaming usage counter. Is there a better way to do this? Should I use a private stream use counter instead?
Quoted 11 lines
<snip>
drivers/media/i2c/ov5640.c line 2180
Quoted 7 lines
drivers/media/i2c/ov5640.c new file +7
-0+ +free_ctrls: +v4l2_ctrl_handler_free (&sensor->ctrls.handler); +entity_cleanup: +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Should this still be here?
Quoted 10 lines
drivers/media/i2c/ov5640.c line 2189
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+return ret; +} + +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Ditto.
I don't understand. regulator_bulk_disable() is still needed, am I missing something?
Steve
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
In reply to Sakari AilusHi Sakari,
Quoted 85 lines · Sakari Ailus
Hi Steve,
A few comments below.
Quoted 68 lines · Steve Longerbeam
This driver is based on
ov5640_mipi.cfrom Freescale imx_3.10.17_1.0.0_beta branch, modified heavily to bring forward to latest interfaces and code cleanup.Signed-off-by Steve Longerbeam<[email protected]>--- drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2234 insertions(+)create mode 100644
drivers/media/i2c/ov5640.cdrivers/media/i2c/Kconfig +9
-0@@ -539,6 +539,15 @@ config VIDEO_OV2659 To compile this driver as a module, choose M here: the module will be called ov2659. +config VIDEO_OV5640 + tristate "OmniVision OV5640 sensor support" + depends on OF + depends on GPIOLIB && VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the Omnivision + OV5640 camera sensor with a MIPI CSI-2 interface. + config VIDEO_OV5645 tristate "OmniVision OV5645 sensor support" depends on OFdrivers/media/i2c/Makefile +1
-0@@ -58,6 +58,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o obj-$(CONFIG_VIDEO_OV2640) += ov2640.o +obj-$(CONFIG_VIDEO_OV5640) += ov5640.o obj-$(CONFIG_VIDEO_OV5645) += ov5645.o obj-$(CONFIG_VIDEO_OV5647) += ov5647.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.odrivers/media/i2c/ov5640.c new file +18
-0@@ -0,0 +1,2224 @@ +/* +* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. +* Copyright (C) 2014-2017 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 <linux/clk.h> +#include <linux/clk-provider.h> +#include <linux/clkdev.h> +#include <linux/ctype.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/i2c.h> +#include <linux/init.h> drivers/media/i2c/ov5640.c line 28
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/slab.h> +#include <linux/types.h> +#include <linux/gpio/consumer.h> +#include <linux/regulator/consumer.h> +#include <media/v4l2-async.h> +#include <media/v4l2-ctrls.h> +#include <media/v4l2-device.h> +#include <media/v4l2-of.h> Could you rebase this on the V4L2 fwnode patchset here, please?
Quoted 1 line
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=v4l2-acpi>
Once the fwnode patchset hits mediatree, then yes it can be converted along with all the others under media/i2c.
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 875
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_write_reg16 (struct ov5640_dev *sensor,u16 reg,u16 val) +{ +int ret; + + ret =ov5640_write_reg (sensor, reg, val >>8 ); +if (ret) +return ret; + +return ov5640_write_reg (sensor, reg +1 , val &0xff );Does the sensor datasheet suggest doing this?
Why would the datasheet suggest or not suggest such things? Coding details like this don't belong in the datasheet.
Quoted 3 lines
Making the write in two
transactions will make it non-atomic that could be an issue in some corner cases.
It's called everywhere under the same device mutex.
Quoted 11 lines
<snip>
drivers/media/i2c/ov5640.c line 1030
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_set_gain (struct ov5640_dev *sensor,int auto_gain) +{ +struct ov5640_ctrls *ctrls = &sensor->ctrls; + +if (ctrls->auto_gain->is_new) { +ov5640_mod_reg (sensor,OV5640_REG_AEC_PK_MANUAL , +BIT (1 ), ctrls->auto_gain->val ?0 :BIT (1 ));You're generally silently ignoring all I?C access errors. Is that intentional?
Yeah, this driver is much cleaned up from the original, but there are still some issues like this. The register access errors are really only being paid attention to during s_power() when loading the initial register set, which is enough at least to catch a non-existent chip or basic i2c bus or other hardware issues. But I should work on catching all access errors. This is something I did in an earlier rev but I used a questionable short-cut to make it easier to implement. I'll just have to catch every case one by one.
Quoted 12 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just setting
handler->lockafter handler init does the trick.
Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver and I am already using that same lock.
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 2032
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 )The entity
stream_countisn't connected to the number of timess_stream(sd, true)is called. Please remove the check.
It's incremented by media_pipeline_start(), even if the entity is already a member of the given pipeline.
I added this check because in imx-media, the ov5640 can be streaming concurrently to multiple video capture devices, and each capture device callsmedia_pipeline_start() at stream on, which increments the entity stream count.
So if one capture device issues a stream off while others are still streaming,
ov5640 should remain at stream on. So the entity stream count is being used as a streaming usage counter. Is there a better way to do this? Should I use a private stream use counter instead?
Quoted 11 lines
<snip>
drivers/media/i2c/ov5640.c line 2180
Quoted 7 lines
drivers/media/i2c/ov5640.c new file +7
-0+ +free_ctrls: +v4l2_ctrl_handler_free (&sensor->ctrls.handler); +entity_cleanup: +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Should this still be here?
Quoted 10 lines
drivers/media/i2c/ov5640.c line 2189
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+return ret; +} + +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Ditto.
I don't understand. regulator_bulk_disable() is still needed, am I missing something?
Steve
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi Steve,
Quoted 13 lines · Steve Longerbeam
Quoted 12 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just setting
handler->lockafter handler init does the trick.
Quoted 3 lines
Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver and I am already using that same lock.
There's another in the control handler. You could use your own lock for the control handler as well.
Quoted 25 lines
Quoted 15 lines
<snip>
drivers/media/i2c/ov5640.c line 2032
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 )The entity
stream_countisn't connected to the number of timess_stream(sd, true)is called. Please remove the check.It's incremented by
media_pipeline_start(), even if the entity is already a member of the given pipeline.I added this check because in imx-media, the ov5640 can be streaming concurrently to multiple video capture devices, and each capture device calls
media_pipeline_start()at stream on, which increments the entity stream count.
Quoted 5 lines
So if one capture device issues a stream off while others are still streaming,
ov5640 should remain at stream on. So the entity stream count is being used as a streaming usage counter. Is there a better way to do this? Should I use a private stream use counter instead?
Different drivers may use media_pipeline_start() in different ways. Stream control shouldn't depend on that count. This could cause issues in using the driver with other ISP / receiver drivers.
I think it should be enough to move the check to the imx driver in this case.
Quoted 25 lines
Quoted 14 lines
<snip>
drivers/media/i2c/ov5640.c line 2180
Quoted 7 lines
drivers/media/i2c/ov5640.c new file +7
-0+ +free_ctrls: +v4l2_ctrl_handler_free (&sensor->ctrls.handler); +entity_cleanup: +mutex_destroy (&sensor->lock); +media_entity_cleanup (&sensor->sd.entity); +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Should this still be here?
Quoted 10 lines
drivers/media/i2c/ov5640.c line 2189
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+return ret; +} + +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Ditto.
Quoted 2 lines
I don't understand.
regulator_bulk_disable()is still needed, am I missing something?
You still need to enable it first. I don't see that being done in probe. As the driver implements the s_power() op, I don't see a need for powering the device on at probe time (and conversely off at remove time).
Signature · 4 lines
Regards, Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi Sakari,
Quoted 16 lines · Sakari Ailus
Hi Steve,
Quoted 13 lines · Steve Longerbeam
Quoted 12 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just setting
handler->lockafter handler init does the trick.
Quoted 6 lines
Quoted 3 lines
Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver and I am already using that same lock.
There's another in the control handler. You could use your own lock for the control handler as well.
I still don't understand.
Quoted 32 lines
Quoted 26 lines
Quoted 4 lines
<snip>
Quoted 12 lines
drivers/media/i2c/ov5640.c line 2032
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ +static int ov5640_s_stream (struct v4l2_subdev *sd,int enable) +{ +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock); + +#if defined(CONFIG_MEDIA_CONTROLLER ) +if (sd->entity.stream_count >1 )The entity
stream_countisn't connected to the number of timess_stream(sd, true)is called. Please remove the check.It's incremented by
media_pipeline_start(), even if the entity is already a member of the given pipeline.I added this check because in imx-media, the ov5640 can be streaming concurrently to multiple video capture devices, and each capture device calls
media_pipeline_start()at stream on, which increments the entity stream count.Quoted 5 lines
So if one capture device issues a stream off while others are still streaming,
ov5640 should remain at stream on. So the entity stream count is being used as a streaming usage counter. Is there a better way to do this? Should I use a private stream use counter instead?
Quoted 6 lines
Different drivers may use
media_pipeline_start()in different ways. Stream control shouldn't depend on that count. This could cause issues in using the driver with other ISP / receiver drivers.I think it should be enough to move the check to the imx driver in this case.
I will remove this check.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/media/i2c/ov5640.c line 2189
Quoted 7 lines
drivers/media/i2c/ov5640.c new file +7
-0+ +static int ov5640_remove (struct i2c_client *client) +{ +struct v4l2_subdev *sd =i2c_get_clientdata (client); +struct ov5640_dev *sensor =to_ov5640_dev (sd); + +regulator_bulk_disable (OV5640_NUM_SUPPLIES , sensor->supplies);Ditto.
Quoted 6 lines
Quoted 2 lines
I don't understand.
regulator_bulk_disable()is still needed, am I missing something?You still need to enable it first. I don't see that being done in probe. As the driver implements the
s_power()op, I don't see a need for powering the device on at probe time (and conversely off at remove time).
Oh you're right, it must have been left over from a previous revision I guess. Yes, regulator_bulk_enable|disable() is only called in ov5640_set_power(). I'll remove regulator_bulk_disable() from probe/remove.
Steve
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Quoted 26 lines · Steve Longerbeam
Hi Sakari,
Quoted 22 lines · Sakari Ailus
Hi Steve,
Quoted 18 lines · Steve Longerbeam
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just
settinghandler->lockafter handler init does the trick.Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver
and I am already using that same lock.
Quoted 6 lines
Quoted 3 lines
There's another in the control handler. You could use your own lock for the
control handler as well.I still don't understand.
Hi Sakari, sorry I see what you are referring to now. The lock in 'struct v4l2_ctrl_handler' can be overridden by a caller's own lock. Yes that's a good idea, I'll do that.
Steve
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Quoted 33 lines · Steve Longerbeam
Quoted 30 lines · Steve Longerbeam
Hi Sakari,
Quoted 25 lines · Sakari Ailus
Hi Steve,
Quoted 14 lines · Steve Longerbeam
Quoted 13 lines
<snip>
drivers/media/i2c/ov5640.c line 1807
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+ +static int ov5640_s_ctrl (struct v4l2_ctrl *ctrl) +{ +struct v4l2_subdev *sd =ctrl_to_sd (ctrl); +struct ov5640_dev *sensor =to_ov5640_dev (sd); +int ret =0 ; + +mutex_lock (&sensor->lock);Could you use the same lock for the controls as you use for the rest? Just
settinghandler->lockafter handler init does the trick.Quoted 4 lines
Can you please rephrase, I don't follow. "same lock for the controls as you use for the rest" - there's only one device lock owned by this driver
and I am already using that same lock.There's another in the control handler. You could use your own lock for the
control handler as well.
Quoted 6 lines
Quoted 2 lines
I still don't understand.
Hi Sakari, sorry I see what you are referring to now. The lock in 'struct
v4l2_ctrl_handler' can be overridden by a caller's own lock. Yes that's a good idea, I'll do that.
Ack, good! :-)
Signature · 2 lines
Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
In reply to Steve LongerbeamHi!
drivers/media/i2c/ov5640.c line 39
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 6000000 +#define OV5640_XCLK_MAX 24000000 + +/* +* FIXME: there is no subdev API to set the MIPI CSI-2 +* virtual channel yet, so this is hardcoded for now. +*/ +#define OV5640_MIPI_VC 1
Can the FIXME be fixed?
Quoted 2 lines
+/*
+ * image size under 1280 * 960 are SUBSAMPLING
-> Image
Quoted 1 line
+ * image size upper 1280 * 960 are SCALING
above?
Quoted 7 lines
+/*
+ * FIXME: all of these register tables are likely filled with
+ * entries that set the register to their power-on default values,
+ * and which are otherwise not touched by this driver. Those entries
+ * should be identified and removed to speed register load time
+ * over i2c.
+ */
load->loading? Can the FIXME be fixed?
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );
Is exposure_absolute supposed to be in microseconds...?
Quoted 7 lines
drivers/media/i2c/ov5640.c new file +7
-0+/* Auto/manual gain */ + ctrls->auto_gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_AUTOGAIN , +0 ,1 ,1 ,1 ); + ctrls->gain =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_GAIN , +0 ,1023 ,1 ,0 ); + + ctrls->saturation = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION,
drivers/media/i2c/ov5640.c line 1900
Quoted 10 lines
drivers/media/i2c/ov5640.c new file +10
-0+ 0, 255, 1, 64); + ctrls->hue =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_HUE , +0 ,359 ,1 ,0 ); + ctrls->contrast =v4l2_ctrl_new_std (hdl, ops,V4L2_CID_CONTRAST , +0 ,255 ,1 ,0 ); + ctrls->test_pattern = +v4l2_ctrl_new_std_menu_items (hdl, ops,V4L2_CID_TEST_PATTERN , +ARRAY_SIZE (test_pattern_menu) -1 , +0 ,0 , test_pattern_menu); +
It is good to see sensor that has autogain/etc. I'm emulating them in v4l-utils, and hardware that supports it is a good argument.
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/20170531/4a85ce8e/attachment.sig>
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi Pavel,
Quoted 13 lines · Pavel Machek
Hi!
drivers/media/i2c/ov5640.c line 39
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 6000000 +#define OV5640_XCLK_MAX 24000000 + +/* +* FIXME: there is no subdev API to set the MIPI CSI-2 +* virtual channel yet, so this is hardcoded for now. +*/ +#define OV5640_MIPI_VC 1Can the FIXME be fixed?
Yes, but it's quite a bit of work. It makes sense to use a static virtual channel for now. A patchset which is however incomplete can be found here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=vc>
For what it's worth, all other devices use virtual channel zero for image data and so should this one.
Quoted 20 lines
Quoted 3 lines
+/*
+ * image size under 1280 * 960 are SUBSAMPLING-> Image
Quoted 1 line
+ * image size upper 1280 * 960 are SCALING
above?
Quoted 7 lines
+/*
+ * FIXME: all of these register tables are likely filled with
+ * entries that set the register to their power-on default values,
+ * and which are otherwise not touched by this driver. Those entries
+ * should be identified and removed to speed register load time
+ * over i2c.
+ */
load->loading? Can the FIXME be fixed?
Quoted 10 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?
Yes. OTOH V4L2_CID_EXPOSURE has no defined unit, so it's a better fit IMO. Way more drivers appear to be using EXPOSURE than EXPOSURE_ABSOLUTE, too.
Ideally we should have only one control for exposure.
Signature · 4 lines
Regards, Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
exposure vs. exposure_absolute was Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi!
Quoted 11 lines
Quoted 10 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?
Quoted 4 lines
Yes. OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO. Way more drivers appear to be using EXPOSURE thanEXPOSURE_ABSOLUTE, too.Ideally we should have only one control for exposure.
No. N-o. No no no. NO! No. N-o. NONONO. No. NooooooooooOOO!!!!!!!!!!!!!
Sorry, no.
Userspace needs to know exposure times. It is not so important for a webcam, but it is mandatory for digital camera. As it gets darker, autogain wants to scale exposure to cca 1/100 sec, then it wants to scale gain up to maximum, and only then it wants to continue scaling exposure. (Threshold will be shorter in "sports" mode, perhaps 1/300sec?)
Plus, we want user to be able to manually set exposure parameters.
So... _this_ driver probably should use V4L2_CID_EXPOSURE. (If the units are not known). But in general we'd prefer drivers using V4L2_CID_EXPOSURE_ABSOLUTE. Your car has speedometer calibrated in km/h or mph, not in "% of max", right?
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/20170601/7414ea5a/attachment-0001.sig>
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
In reply to Sakari AilusQuoted 17 lines · Sakari Ailus
Hi Pavel,
Quoted 13 lines · Pavel Machek
Hi!
drivers/media/i2c/ov5640.c line 39
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +9
-0+/* min/typical/max system clock (xclk) frequencies */ +#define OV5640_XCLK_MIN 6000000 +#define OV5640_XCLK_MAX 24000000 + +/* +* FIXME: there is no subdev API to set the MIPI CSI-2 +* virtual channel yet, so this is hardcoded for now. +*/ +#define OV5640_MIPI_VC 1Can the FIXME be fixed?
Quoted 7 lines
Yes, but it's quite a bit of work. It makes sense to use a static virtual channel for now. A patchset which is however incomplete can be found here:
<URL:https://git.linuxtv.org/sailus/media_tree.git/log/?h=vc>
For what it's worth, all other devices use virtual channel zero for image data and so should this one.
Actually no. The CSI2IPU gasket in i.MX6 quad sends virtual channel 0 streams to IPU1-CSI0. But input to IPU1-CSI0 is also muxed with parallel bus cameras. So if vc0 were chosen instead, platforms that support parallel cameras to IPU1-CSI0 (SabreLite, SabreSD) would not be able to use them concurrently with a MIPI CSI-2 source to IPU1-CSI1. So I prefer to use static channel 1 to support those platforms.
I could convert this to a module parameter however, until a virtual channel selection subdev API becomes available, at which point that would have to be stripped.
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
+/*
+ * image size under 1280 * 960 are SUBSAMPLING-> Image
Quoted 1 line
+ * image size upper 1280 * 960 are SCALING
above?
done.
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
+/*
+ * FIXME: all of these register tables are likely filled with
+ * entries that set the register to their power-on default values,
+ * and which are otherwise not touched by this driver. Those entries
+ * should be identified and removed to speed register load time
+ * over i2c.
+ */
load->loading? Can the FIXME be fixed?
That's a lot of work, and risky work at that. If someone could take this on (strip out power-on default values from the tables), I'd be grateful, but I don't have the time. For now at least, these registers sets work fine.
Quoted 12 lines
Quoted 11 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 9 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?
Quoted 1 line
Yes.
According to the docs V4L2_CID_EXPOSURE_ABSOLUTE is in 100 usec units.
OTOH V4L2_CID_EXPOSURE has no defined unit, so it's a better fit IMO.
Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.
Done, switched to V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.
Steve
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi!
Quoted 13 lines
Quoted 11 lines
Quoted 10 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?Quoted 1 line
Yes.
Quoted 7 lines
According to the docs
V4L2_CID_EXPOSURE_ABSOLUTEis in 100 usec units.OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO.Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.Done, switched to
V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.
Thanks. If you know the units, it would be of course better to use right units...
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/20170603/64113cea/attachment.sig>
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Quoted 17 lines · Pavel Machek
Hi!
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?Quoted 1 line
Yes.
According to the docs
V4L2_CID_EXPOSURE_ABSOLUTEis in 100 usec units.
Quoted 8 lines
Quoted 5 lines
OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO.Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.Done, switched to
V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.Thanks. If you know the units, it would be of course better to use right units...
Steve: what's the unit in this case? Is it lines or something else?
Pavel: we do need to make sure the user space will be able to know the unit, too. It's rather a case with a number of controls: the unit is known but there's no API to convey it to the user.
The exposure is a bit special, too: granularity matters a lot on small values. On most other controls it does not.
Signature · 2 lines
Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Hi!
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
According to the docs
V4L2_CID_EXPOSURE_ABSOLUTEis in 100 usec units.OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO.Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.Done, switched to
V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.Thanks. If you know the units, it would be of course better to use right units...
Quoted 8 lines
Steve: what's the unit in this case? Is it lines or something else?
Pavel: we do need to make sure the user space will be able to know the unit, too. It's rather a case with a number of controls: the unit is known but there's no API to convey it to the user.
The exposure is a bit special, too: granularity matters a lot on small values. On most other controls it does not.
Yeah. Basically problem with exposure is that the control is logarithmic; by using linear scale we got too much resolution at long times and too little resolution at short times.
(Plus, 100 usec ... n900 can do times _way_ shorter than that.)
Anyway, even u32 gives us enough range, but I so the linear/log confusion does not matter. But it would be nicer if values were in 10 usec or usec, not 100 usec...
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/20170604/6f0aa838/attachment-0001.sig>
Steve Longerbeam
maintainerRe: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
In reply to Sakari AilusQuoted 21 lines · Sakari Ailus
Quoted 20 lines · Pavel Machek
Hi!
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
drivers/media/i2c/ov5640.c line 1883
Quoted 8 lines
drivers/media/i2c/ov5640.c new file +8
-0+/* Auto/manual exposure */ + ctrls->auto_exp =v4l2_ctrl_new_std_menu (hdl, ops, +V4L2_CID_EXPOSURE_AUTO , +V4L2_EXPOSURE_MANUAL ,0 , +V4L2_EXPOSURE_AUTO ); + ctrls->exposure =v4l2_ctrl_new_std (hdl, ops, +V4L2_CID_EXPOSURE_ABSOLUTE , +0 ,65535 ,1 ,0 );Is
exposure_absolutesupposed to be in microseconds...?Quoted 1 line
Yes.
According to the docs
V4L2_CID_EXPOSURE_ABSOLUTEis in 100 usec units.OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO.Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Done, switched to
V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.Thanks. If you know the units, it would be of course better to use right units...
Steve: what's the unit in this case? Is it lines or something else?
Yes, the register interface for exposure takes lines*16.
Maybe converting from seconds to lines is as simple as framerate * height * seconds. But I'm not sure about that.
Steve
Quoted 8 lines
Pavel: we do need to make sure the user space will be able to know the unit, too. It's rather a case with a number of controls: the unit is known but there's no API to convey it to the user.
The exposure is a bit special, too: granularity matters a lot on small values. On most other controls it does not.
Re: [PATCH v7 16/34] [media] add Omnivision OV5640 sensor driver
Quoted 30 lines · Steve Longerbeam
Quoted 27 lines · Sakari Ailus
Quoted 25 lines · Pavel Machek
Hi!
Quoted 13 lines
Quoted 11 lines
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +8
-0+ /* Auto/manual exposure */ + ctrls->auto_exp = v4l2_ctrl_new_std_menu(hdl, ops, + V4L2_CID_EXPOSURE_AUTO, + V4L2_EXPOSURE_MANUAL, 0, + V4L2_EXPOSURE_AUTO); + ctrls->exposure = v4l2_ctrl_new_std(hdl, ops, + V4L2_CID_EXPOSURE_ABSOLUTE, + 0, 65535, 1, 0);Is
exposure_absolutesupposed to be in microseconds...?Quoted 1 line
Yes.
Quoted 7 lines
According to the docs
V4L2_CID_EXPOSURE_ABSOLUTEis in 100 usec units.OTOH
V4L2_CID_EXPOSUREhas no defined unit, so it's a better fit IMO.Quoted 1 line
Way more drivers appear to be using EXPOSURE than
EXPOSURE_ABSOLUTE, too.Done, switched to
V4L2_CID_EXPOSURE. It's true, this control is not taking 100 usec units, so unit-less is better.Thanks. If you know the units, it would be of course better to use right units...
Quoted 6 lines
Quoted 1 line
Steve: what's the unit in this case? Is it lines or something else?
Yes, the register interface for exposure takes lines*16.
Maybe converting from seconds to lines is as simple as framerate * height * seconds. But I'm not sure about that.
The smiapp and a few other drivers are using lines. One option could be to use lines as the unit and have step as 16.
Then the hblank + vblank controls will be needed, too, to enable the user to at least figure out the conversion to Si units.
Signature · 2 lines
Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Steve Longerbeam
maintainerPATCH v7 17/34 platform: add video-multiplexer subdevice driver
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
This driver can handle SoC internal and external video bus multiplexers, controlled by mux controllers provided by the mux controller framework, such as MMIO register bitfields or GPIOs. The subdevice passes through the mbus configuration of the active input to the output side.
--- drivers/media/platform/Kconfig | 7 + drivers/media/platform/Makefile | 2 + drivers/media/platform/video-mux.c | 295 +++++++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 drivers/media/platform/video-mux.c
drivers/media/platform/Kconfig +7 -0
@@ -74,6 +74,13 @@ config VIDEO_M32R_AR_M64278 To compile this driver as a module, choose M here: the module will be called arv. +config VIDEO_MUX + tristate "Video Multiplexer" + depends on OF && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER + depends on MULTIPLEXER + help + This driver provides support for N:1 video bus multiplexers. + 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
@@ -28,6 +28,8 @@ obj-$(CONFIG_VIDEO_SH_VEU) += sh_veu.o obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE) += m2m-deinterlace.o +obj-$(CONFIG_VIDEO_MUX) += video-mux.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-mux.c new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 18/34 platform: video-mux: include temporary mmio-mux support
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
As long as the mux framework is not merged, add temporary mmio-mux support to the video-mux driver itself. This patch is to be reverted once the "mux: minimal mux subsystem" and "mux: mmio-based syscon mux controller" patches are merged.
--- drivers/media/platform/Kconfig | 1 - drivers/media/platform/video-mux.c | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-)
drivers/media/platform/Kconfig +0 -1
@@ -77,7 +77,6 @@ config VIDEO_M32R_AR_M64278 config VIDEO_MUX tristate "Video Multiplexer" depends on OF && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER - depends on MULTIPLEXER help This driver provides support for N:1 video bus multiplexers.
drivers/media/platform/video-mux.c +62 -0
105 lines not on this page · raw message
Signature · 1 line
2.7.4
kbuild test robot
build bot[PATCH] platform: video-mux: fix ptr_ret.cocci warnings
drivers/media/platform/video-mux.c:246:1-3: WARNING: PTR_ERR_OR_ZERO can be used
drivers/media/platform/video-mux.c:246:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
---
video-mux.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/platform/video-mux.c +1 -4
@@ -243,10 +243,7 @@ static int video_mux_probe_mmio_mux(stru field.lsb =ffs (mask) -1 ; vmux->field =devm_regmap_field_alloc (dev, regmap, field); -if (IS_ERR (vmux->field)) -return PTR_ERR (vmux->field); - - return 0; + return PTR_ERR_OR_ZERO(vmux->field); }#endif
kbuild test robot
build botRe: [PATCH v7 18/34] platform: video-mux: include temporary mmio-mux support
In reply to Steve Longerbeamcoccinelle warnings: (new ones prefixed by >>)
Hi Philipp,
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.12-rc2 next-20170525]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Steve-Longerbeam/i-MX-Media-Driver/20170525-135051 base: git://linuxtv.org/media_tree.git master
coccinelle warnings: (new ones prefixed by >>)
>> drivers/media/platform/video-mux.c:246:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Steve Longerbeam
maintainerPATCH v7 19/34 media: Add userspace header file for i.MX
In reply to Steve LongerbeamThis adds a header file for use by userspace programs wanting to interact with the i.MX media driver. It defines custom events and v4l2 controls for the i.MX v4l2 subdevices.
--- include/linux/imx-media.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/linux/imx-media.h
include/linux/imx-media.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (c) 2014-2017 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 __LINUX_IMX_MEDIA_H__ +#define __LINUX_IMX_MEDIA_H__ + +/* +* events from the subdevs +*/ +#define V4L2_EVENT_IMX_CLASS V4L2_EVENT_PRIVATE_START +#define V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR (V4L2_EVENT_IMX_CLASS + 1) + +enum imx_ctrl_id { +V4L2_CID_IMX_FIM_ENABLE = (V4L2_CID_USER_IMX_BASE +0 ), +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
Steve Longerbeam
maintainerPATCH v7 20/34 media: Add i.MX media core driver
In reply to Steve LongerbeamAdd the core media driver for i.MX SOC.
Add the bayer formats to imx-media's list of supported pixel and bus formats.
--- Documentation/media/v4l-drivers/imx.rst | 590 +++++++++++++++ drivers/staging/media/Kconfig | 2 + drivers/staging/media/Makefile | 1 + drivers/staging/media/imx/Kconfig | 6 + drivers/staging/media/imx/Makefile | 5 + drivers/staging/media/imx/TODO | 15 + drivers/staging/media/imx/imx-media-dev.c | 665 +++++++++++++++++ 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 | 268 +++++++ drivers/staging/media/imx/imx-media-utils.c | 834 ++++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 324 +++++++++ include/media/imx.h | 15 + include/uapi/linux/v4l2-controls.h | 4 + 14 files changed, 3541 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 +590 -0
@@ -0,0 +1,590 @@ +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 [#f1]_ and [#f2]_. + + +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. + +- Concurrent independent streams, by configuring pipelines to multiple + video capture interfaces using independent entities. + +- 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. Pipelines are + defined that allow sending frames to the VDIC subdev directly from the + CSI. There is also support in the future for sending frames to the + VDIC from memory buffers via a output/mem2mem devices. + +- Includes a Frame Interval Monitor (FIM) that can correct vertical sync + problems with the ADV718x video decoders. + + +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. Multpiple source pads can be enabled to independently +stream from multiple virtual channels. + +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 can be processed by one or both 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 directly to memory buffers +via the SMFC and an IDMAC channel, bypassing IC pre-processing. This +source pad is routed to a capture device node, with a node name of the +format "ipuX_csiY capture". + +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. + +This subdev can generate the following event when enabling the second +IDMAC source pad: + +- V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR + +The user application can subscribe to this event from the ipuX_csiY +subdev node. This event is generated by the Frame Interval Monitor +(see below for more on the FIM). + +Cropping in ipuX_csiY +--------------------- + +The CSI supports cropping the incoming raw sensor frames. This is +implemented in the ipuX_csiY entities at the sink pad, using the +crop selection subdev API. + +The CSI also supports fixed divide-by-two downscaling indepently in +width and height. This is implemented in the ipuX_csiY entities at +the sink pad, using the compose selection subdev API. + +The output rectangle at the ipuX_csiY source pad is the same as +the compose rectangle at the sink pad. So the source pad rectangle +cannot be negotiated, it must be set using the compose selection +API at sink pad (if /w downscale is desired, otherwise source pad +rectangle is equal to incoming rectangle). + +To give an example of crop and /2 downscale, this will crop a +1280x960 input frame to 640x480, and then /2 downscale in both +dimensions to 320x240 (assumes ipu1_csi0 is linked to ipu1_csi0_mux): + +media-ctl -V "'ipu1_csi0_mux':2[fmt:UYVY2X8/1280x960]" +media-ctl -V "'ipu1_csi0':0[crop:(0,0)/640x480]" +media-ctl -V "'ipu1_csi0':0[compose:(0,0)/320x240]" + +Frame Skipping in ipuX_csiY +--------------------------- + +The CSI supports frame rate decimation, via frame skipping. Frame +rate decimation is specified by setting the frame intervals at +sink and source pads. The ipuX_csiY entity then applies the best +frame skip setting to the CSI to achieve the desired frame rate +at the source pad. + +The following example reduces an assumed incoming 60 Hz frame +rate by half at the IDMAC output source pad: + +media-ctl -V "'ipu1_csi0':0[fmt:UYVY2X8/640x480@1/60]" +media-ctl -V "'ipu1_csi0':2[fmt:UYVY2X8/640x480@1/30]" + +Frame Interval Monitor in ipuX_csiY +----------------------------------- + +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, the ipuX_csiY subdev will send the event +V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR. Userland can register with +the FIM event notification on the ipuX_csiY subdev device node. +Userland can issue a streaming restart when this event is received +to correct the rolling/split image. + +The ipuX_csiY subdev 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 measurements to average before comparing against +the nominal frame interval reported by the sensor. This can reduce noise +caused by interrupt latency. + +- V4L2_CID_IMX_FIM_TOLERANCE_MIN + +If the averaged intervals fall outside nominal by this amount, in +microseconds, the V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR event is sent. + +- V4L2_CID_IMX_FIM_TOLERANCE_MAX + +If any intervals are higher than this value, those 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 interrupt +latency from high system load. + +- V4L2_CID_IMX_FIM_NUM_SKIP + +How many frames to skip after a FIM reset or stream restart before +FIM begins to average intervals. + +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 the menu control V4L2_CID_DEINTERLACING_MODE. 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, with a node name of the format +"ipuX_ic_prpenc capture". + +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. Flip +and rotation are provided via standard V4L2 controls. + +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, with a node name of the format +"ipuX_ic_prpvf capture". + +It is identical in operation to ipuX_ic_prpenc, with the same resizing +and CSC operations and flip/rotation controls. 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 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, via ipuX_csiY IDMAC source pad: + +-> ipuX_csiY:2 -> ipuX_csiY capture + +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:1 -> 0:ipuX_ic_prp:1 -> 0:ipuX_ic_prpenc:1 -> + ipuX_ic_prpenc capture + +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:1 -> 0:ipuX_vdic:2 -> 0:ipuX_ic_prp:2 -> + 0:ipuX_ic_prpvf:1 -> ipuX_ic_prpvf capture + + +Usage Notes +----------- + +To aid in configuration and for backward compatibility with V4L2 +applications that access controls only from video device nodes, the +capture device interfaces inherit controls from the active entities +in the current pipeline, so controls can be accessed either directly +from the subdev or from the active capture device interface. For +example, the FIM controls are available either from the ipuX_csiY +subdevs or from the active capture device. + +The following are specific usage notes for the Sabre* reference +boards: + + +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/product/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 (which is +imx6-mipi-csi2 pad 2), is routed to ipu1_csi1. Both sensors are +configured to output 640x480, and 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 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:AYUV32/640x480 field:none]" + # Configure pads for OV5640 pipeline + media-ctl -V "'ov5640 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:AYUV32/640x480 field:none]" + +Streaming can then begin independently on the capture device nodes +"ipu1_csi0 capture" and "ipu1_csi1 capture". The v4l2-ctl tool can +be used to select any supported YUV pixelformat on the capture device +nodes, including planar. + +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 +"interlaced". $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 3-0021':0 -> 'ipu1_csi0_mux':1[1]" + media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]" + media-ctl -l "'ipu1_csi0':1 -> '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 3-0021':0 [fmt:UYVY2X8/720x480]" + media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480 field:interlaced]" + media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x480 field:interlaced]" + 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". The v4l2-ctl tool can be used to select any +supported YUV or RGB pixelformat on the capture device node. + +This platform accepts Composite Video analog inputs to the ADV7180 on +Ain1 (connector J42). + +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, transmitting on MIPI CSI-2 virtual channel 1. $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 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 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. The v4l2-ctl +tool can be used to select any supported YUV or RGB pixelformat on the +capture device 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/linux/imx-media.h + +References +---------- + +.. [#f1] http://www.nxp.com/assets/documents/data/en/reference-manuals/IMX6DQRM.pdf +.. [#f2] http://www.nxp.com/assets/documents/data/en/reference-manuals/IMX6SDLRM.pdf + + +Authors +------- +Steve Longerbeam <[email protected]> +Philipp Zabel <[email protected]> +Russell King <[email protected]> + +Copyright (C) 2012-2017 Mentor Graphics Inc.
drivers/staging/media/Kconfig +2 -0
@@ -27,6 +27,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" # Keep LIRC at the end, as it has sub-menus
drivers/staging/media/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_I2C_BCM2048) += bcm2048/ 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 +6 -0
@@ -0,0 +1,6 @@ +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 +5 -0
@@ -0,0 +1,5 @@ +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 +15 -0
@@ -0,0 +1,15 @@ + +- 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. + +- 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 imx-media-csi.c to setup the CSI. + Laurent Pinchart argues that instead the CSI 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 +665 -0
665 lines not on this page · raw message
drivers/staging/media/imx/imx-media-fim.c new file +463 -0
463 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 +268 -0
268 lines not on this page · raw message
drivers/staging/media/imx/imx-media-utils.c new file +834 -0
625 lines not on this page · raw message
drivers/staging/media/imx/imx-media.h new file +324 -0
324 lines not on this page · 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.
Steve Longerbeam
maintainerPATCH v7 21/34 media: imx: Add Capture Device Interface
In reply to Steve LongerbeamThis 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 | 1 + drivers/staging/media/imx/imx-media-capture.c | 702 ++++++++++++++++++++++++++ 2 files changed, 703 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-capture.c
drivers/staging/media/imx/Makefile +1 -0
@@ -3,3 +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 +702 -0
702 lines not on this page · raw message
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 22/34 media: imx: Add CSI subdev driver
In reply to Steve LongerbeamThis is a media entity subdevice for the i.MX Camera Sensor Interface module.
- Added support for negotiation of frame intervals.
- Fixed cropping rectangle negotiation at input and output pads.
- Added support for /2 downscaling, if the output pad dimension(s) are 1/2 the crop dimension(s) at csi_setup() time.
--- drivers/staging/media/imx/Kconfig | 14 + drivers/staging/media/imx/Makefile | 2 + drivers/staging/media/imx/imx-media-csi.c | 1498 +++++++++++++++++++++++++++++ 3 files changed, 1514 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/imx/Kconfig +14 -0
@@ -4,3 +4,17 @@ config VIDEO_IMX_MEDIA ---help--- 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
@@ -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 +1498 -0
1,498 lines not on this page · raw message
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 23/34 media: imx: Add VDIC subdev driver
In reply to Steve LongerbeamThis 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 | 1004 ++++++++++++++++++++++++++++ 2 files changed, 1005 insertions(+) create mode 100644 drivers/staging/media/imx/imx-media-vdic.c
drivers/staging/media/imx/Makefile +1 -0
@@ -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 +1004 -0
1,004 lines not on this page · raw message
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 24/34 media: imx: Add IC subdev drivers
In reply to Steve LongerbeamThis is a set of three media entity subdevice drivers for the i.MX Image Converter:
- Pre-process Router: Takes input frames from CSI0, CSI1, or VDIC. Two output pads enable either or both of the preprocess tasks below. If the input is from one of the CSIs, both proprocess task links can be enabled to process frames from that CSI simultaneously. If the input is the VDIC, only the Pre-processing Viewfinder task link can be enabled.
- Pre-processing Encode task: video frames are routed directly from the CSI and can be scaled, color-space converted, and rotated. Scaled output is limited to 1024x1024 resolution. Output frames are routed to the prpenc capture device.
- Pre-processing Viewfinder task: this task can perform the same conversions as the pre-process encode task, but in addition can be used for hardware motion compensated deinterlacing. Frames can come either directly from the CSI or from the VDIC. Scaled output is limited to 1024x1024 resolution. Output frames are routed to the prpvf capture device.
--- drivers/staging/media/imx/Makefile | 2 + drivers/staging/media/imx/imx-ic-common.c | 113 +++ drivers/staging/media/imx/imx-ic-prp.c | 509 +++++++++++ drivers/staging/media/imx/imx-ic-prpencvf.c | 1299 +++++++++++++++++++++++++++ drivers/staging/media/imx/imx-ic.h | 38 + 5 files changed, 1961 insertions(+) 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
drivers/staging/media/imx/Makefile +2 -0
@@ -1,9 +1,11 @@ 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 +imx-media-ic-objs := imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.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_MEDIA) += imx-media-ic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o
drivers/staging/media/imx/imx-ic-common.c new file +113 -0
113 lines not on this page · raw message
drivers/staging/media/imx/imx-ic-prp.c new file +509 -0
509 lines not on this page · raw message
drivers/staging/media/imx/imx-ic-prpencvf.c new file +1299 -0
1,299 lines not on this page · raw message
drivers/staging/media/imx/imx-ic.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* V4L2 Image Converter Subdev for Freescale i.MX5/6 SOC +* +* Copyright (c) 2016 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 _IMX_IC_H +#define _IMX_IC_H + +#include <media/v4l2-subdev.h> + +struct imx_ic_priv { +struct device *dev; +struct v4l2_subdev sd; +int ipu_id; +int task_id; +void *prp_priv; +void *task_priv; +}; + +struct imx_ic_ops { +const struct v4l2_subdev_ops *subdev_ops; +const struct v4l2_subdev_internal_ops *internal_ops; +const struct media_entity_operations *entity_ops; + +int (*init)(struct imx_ic_priv *ic_priv); +void (*remove)(struct imx_ic_priv *ic_priv); +}; + +extern struct imx_ic_ops imx_ic_prp_ops; +extern struct imx_ic_ops imx_ic_prpencvf_ops; +extern struct imx_ic_ops imx_ic_pp_ops; + +#endif
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 25/34 media: imx: Add MIPI CSI-2 Receiver subdev driver
In reply to Steve LongerbeamAdds MIPI CSI-2 Receiver subdev driver. This subdev is required for sensors with a MIPI CSI2 interface.
- Add the function csi2ipu_gasket_init() to initialize the gasket at s_power(ON). The gasket needs to be programmed with the correct color component ordering to handle UYVY vs. YUYV ordered mbus formats from sensors. Note that the description of the CSI2IPU_GASKET register in the i.MX6 reference manual is wrong w.r.t bit 2 (the manual refers to this register as CSI2_SW_RST): setting bit 2 selects YUYV order, not UYVY.
--- drivers/staging/media/imx/Makefile | 1 + drivers/staging/media/imx/imx6-mipi-csi2.c | 696 +++++++++++++++++++++++++++++ 2 files changed, 697 insertions(+) create mode 100644 drivers/staging/media/imx/imx6-mipi-csi2.c
drivers/staging/media/imx/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-vdic.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-ic.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx-media-csi.o +obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o
drivers/staging/media/imx/imx6-mipi-csi2.c new file +696 -0
696 lines not on this page · raw message
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 26/34 ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers
In reply to Steve LongerbeamEnable i.MX v4l2 media staging driver. For video capture on i.MX, the video multiplexer subdev is required. On the SabreAuto, the ADV7180 video decoder is required along with i2c-mux-gpio. The Sabrelite and SabreSD require the OV5640 and the SabreLite requires PWM clocks for the OV5640.
Increase max zoneorder to allow larger video buffer allocations.
--- arch/arm/configs/imx_v6_v7_defconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm/configs/imx_v6_v7_defconfig +11 -0
@@ -51,6 +51,7 @@ CONFIG_PREEMPT_VOLUNTARY=y CONFIG_AEABI=y CONFIG_HIGHMEM=y CONFIG_CMA=y +CONFIG_FORCE_MAX_ZONEORDER=14 CONFIG_CMDLINE="noinitrd console=ttymxc0,115200" CONFIG_KEXEC=y CONFIG_CPU_FREQ=y
@@ -183,6 +184,7 @@ CONFIG_SERIAL_FSL_LPUART=y CONFIG_SERIAL_FSL_LPUART_CONSOLE=y # CONFIG_I2C_COMPAT is not set CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=y CONFIG_I2C_MUX_GPIO=y # CONFIG_I2C_HELPER_AUTO is not set CONFIG_I2C_ALGOPCF=m
@@ -223,14 +225,20 @@ CONFIG_REGULATOR_PFUZE100=y CONFIG_MEDIA_SUPPORT=y CONFIG_MEDIA_CAMERA_SUPPORT=y CONFIG_MEDIA_RC_SUPPORT=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y CONFIG_RC_DEVICES=y CONFIG_IR_GPIO_CIR=y CONFIG_MEDIA_USB_SUPPORT=y CONFIG_USB_VIDEO_CLASS=m CONFIG_V4L_PLATFORM_DRIVERS=y +CONFIG_VIDEO_MUX=y CONFIG_SOC_CAMERA=y CONFIG_V4L_MEM2MEM_DRIVERS=y CONFIG_VIDEO_CODA=y +# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set +CONFIG_VIDEO_ADV7180=m +CONFIG_VIDEO_OV5640=m CONFIG_SOC_CAMERA_OV2640=y CONFIG_IMX_IPUV3_CORE=y CONFIG_DRM=y
@@ -340,6 +348,9 @@ CONFIG_FSL_EDMA=y CONFIG_IMX_SDMA=y CONFIG_MXS_DMA=y CONFIG_STAGING=y +CONFIG_STAGING_MEDIA=y +CONFIG_VIDEO_IMX_MEDIA=y +CONFIG_COMMON_CLK_PWM=y CONFIG_IIO=y CONFIG_VF610_ADC=y CONFIG_MPL3115=y
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 27/34 media: imx: csi: add support for bayer formats
In reply to Steve LongerbeamFrom: Russell King <[email protected]>
Bayer formats must be treated as generic data and passthrough mode must be used. Add the correct setup for these formats.
- added check to csi_link_validate() to verify that destination is IDMAC output pad when passthrough conditions exist: bayer formats and 16-bit parallel buses.
--- drivers/staging/media/imx/imx-media-csi.c | 74 ++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 17 deletions(-)
drivers/staging/media/imx/imx-media-csi.c +57 -17
@@ -288,10 +288,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)struct imx_media_video_dev *vdev = priv->vdev;struct v4l2_of_endpoint *sensor_ep;struct v4l2_mbus_framefmt *infmt; -unsigned int burst_size;struct ipu_image image; +u32 passthrough_bits;dma_addr_t phys[2 ];bool passthrough; +u32 burst_size;int ret; infmt = &priv->format_mbus[CSI_SINK_PAD ];
@@ -309,24 +310,52 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) image.phys0 = phys[0 ]; image.phys1 = phys[1 ]; - ret =ipu_cpmem_set_image (priv->idmac_ch, &image); -if (ret) - goto unsetup_vb2; - - burst_size = (image.pix.width &0xf ) ?8 :16 ; - -ipu_cpmem_set_burstsize (priv->idmac_ch, burst_size); -/* -* If the sensor uses 16-bit parallel CSI bus, we must handle -* the data internally in the IPU as 16-bit generic, aka -* passthrough mode. +* Check for conditions that require the IPU to handle the +* data internally as generic data, aka passthrough mode: +* - raw bayer formats +* - the sensor bus is 16-bit parallel */ - passthrough = (sensor_ep->bus_type !=V4L2_MBUS_CSI2 && - sensor_ep->bus.parallel.bus_width >=16 ); +switch (image.pix.pixelformat) { +case V4L2_PIX_FMT_SBGGR8 : +case V4L2_PIX_FMT_SGBRG8 : +case V4L2_PIX_FMT_SGRBG8 : +case V4L2_PIX_FMT_SRGGB8 : + burst_size =8 ; + passthrough = true; + passthrough_bits =8 ; +break ; +case V4L2_PIX_FMT_SBGGR16 : +case V4L2_PIX_FMT_SGBRG16 : +case V4L2_PIX_FMT_SGRBG16 : +case V4L2_PIX_FMT_SRGGB16 : + burst_size =4 ; + passthrough = true; + passthrough_bits =16 ; +break ; +default : + burst_size = (image.pix.width &0xf ) ?8 :16 ; + passthrough = (sensor_ep->bus_type !=V4L2_MBUS_CSI2 && + sensor_ep->bus.parallel.bus_width >=16 ); + passthrough_bits =16 ; +break ; + } -if (passthrough) -ipu_cpmem_set_format_passthrough (priv->idmac_ch,16 ); +if (passthrough) { +ipu_cpmem_set_resolution (priv->idmac_ch, image.rect.width, + image.rect.height); +ipu_cpmem_set_stride (priv->idmac_ch, image.pix.bytesperline); +ipu_cpmem_set_buffer (priv->idmac_ch,0 , image.phys0); +ipu_cpmem_set_buffer (priv->idmac_ch,1 , image.phys1); +ipu_cpmem_set_format_passthrough (priv->idmac_ch, + passthrough_bits); + }else { + ret =ipu_cpmem_set_image (priv->idmac_ch, &image); +if (ret) + goto unsetup_vb2; + } + +ipu_cpmem_set_burstsize (priv->idmac_ch, burst_size);/* * Set the channel for the direct CSI-->memory via SMFC
@@ -823,6 +852,7 @@ static int csi_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) {struct csi_priv *priv =v4l2_get_subdevdata (sd); +const struct imx_media_pixfmt *incc;struct v4l2_of_endpoint *sensor_ep;struct imx_media_subdev *sensor;bool is_csi2;
@@ -844,6 +874,16 @@ static int csi_link_validate(struct v4l2_subdev *sd, priv->sensor = sensor; sensor_ep = &priv->sensor->sensor_ep; is_csi2 = (sensor_ep->bus_type ==V4L2_MBUS_CSI2 ); + incc = priv->cc[CSI_SINK_PAD ]; + +if (priv->dest !=IPU_CSI_DEST_IDMAC && + (incc->bayer || (!is_csi2 && + sensor_ep->bus.parallel.bus_width >=16 ))) { +v4l2_err (&priv->sd, +"bayer/16-bit parallel buses must go to IDMAC pad\n" ); + ret = -EINVAL ; + goto out; + }if (is_csi2) {int vc_num =0 ;
@@ -868,7 +908,7 @@ static int csi_link_validate(struct v4l2_subdev *sd,/* select either parallel or MIPI-CSI2 as input to CSI */ ipu_set_csi_src_mux (priv->ipu, priv->csi_id, is_csi2); - +out:mutex_unlock (&priv->lock);return ret; }
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 28/34 media: imx: csi: increase burst size for YUV formats
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
The IDMAC supports burst sizes of up to 32 pixels for interleaved YUV formats and up to 64 pixels for planar YUV formats.
--- drivers/staging/media/imx/imx-media-csi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/staging/media/imx/imx-media-csi.c +17 -0
@@ -333,6 +333,23 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) passthrough = true; passthrough_bits =16 ;break ; +case V4L2_PIX_FMT_YUV420 : +case V4L2_PIX_FMT_NV12 : + burst_size = (image.pix.width &0x3f ) ? + ((image.pix.width &0x1f ) ? + ((image.pix.width &0xf ) ?8 :16 ) :32 ) :64 ; + passthrough = (sensor_ep->bus_type !=V4L2_MBUS_CSI2 && + sensor_ep->bus.parallel.bus_width >=16 ); + passthrough_bits =16 ; +break ; +case V4L2_PIX_FMT_YUYV : +case V4L2_PIX_FMT_UYVY : + burst_size = (image.pix.width &0x1f ) ? + ((image.pix.width &0xf ) ?8 :16 ) :32 ; + passthrough = (sensor_ep->bus_type !=V4L2_MBUS_CSI2 && + sensor_ep->bus.parallel.bus_width >=16 ); + passthrough_bits =16 ; +break ;default : burst_size = (image.pix.width &0xf ) ?8 :16 ; passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 &&
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 29/34 media: imx: csi: add frame skipping support
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
The CSI can skip any out of up to 6 input frames, allowing to reduce the frame rate at the output pads by small fractions.
--- drivers/staging/media/imx/imx-media-csi.c | 167 ++++++++++++++++++++++++++---- 1 file changed, 146 insertions(+), 21 deletions(-)
drivers/staging/media/imx/imx-media-csi.c +146 -21
@@ -2,6 +2,7 @@* V4L2 Capture CSI Subdev for Freescale i.MX5/6 SOC * * Copyright (c) 2014-2017 Mentor Graphics Inc. +* Copyright (C) 2017 Pengutronix, Philipp Zabel <[email protected]> * * 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
@@ -9,6 +10,7 @@* (at your option) any later version. */ #include <linux/delay.h> +#include <linux/gcd.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/platform_device.h>
@@ -41,6 +43,18 @@#define H_ALIGN 1/* multiple of 2 lines */ #define S_ALIGN 1/* multiple of 2 */ +/* +* struct csi_skip_desc - CSI frame skipping descriptor +* @keep - number of frames kept per max_ratio frames +* @max_ratio - width of skip_smfc, written to MAX_RATIO bitfield +* @skip_smfc - skip pattern written to the SKIP_SMFC bitfield +*/ +struct csi_skip_desc { +u8 keep; +u8 max_ratio; +u8 skip_smfc; +}; +struct csi_priv {struct device *dev;struct ipu_soc *ipu;
@@ -64,8 +78,9 @@ struct csi_priv {struct v4l2_mbus_framefmt format_mbus[CSI_NUM_PADS ];const struct imx_media_pixfmt *cc[CSI_NUM_PADS ]; -struct v4l2_fract frame_interval; +struct v4l2_fract frame_interval[CSI_NUM_PADS ];struct v4l2_rect crop; +const struct csi_skip_desc *skip;/* active vb2 buffers to send to video dev sink */ struct imx_media_buffer *active_vb2_buf[2 ];
@@ -581,6 +596,10 @@ static int csi_setup(struct csi_priv *priv)ipu_csi_set_dest (priv->csi, priv->dest); +if (priv->dest ==IPU_CSI_DEST_IDMAC ) +ipu_csi_set_skip_smfc (priv->csi, priv->skip->skip_smfc, + priv->skip->max_ratio -1 ,0 ); +ipu_csi_dump (priv->csi);return 0 ;
@@ -588,6 +607,7 @@ static int csi_setup(struct csi_priv *priv)static int csi_start (struct csi_priv *priv) { +struct v4l2_fract *output_fi, *input_fi;u32 bad_frames =0 ;int ret;
@@ -596,10 +616,12 @@ static int csi_start(struct csi_priv *priv)return -EINVAL ; } + output_fi = &priv->frame_interval[priv->active_output_pad]; + input_fi = &priv->frame_interval[CSI_SINK_PAD ]; + ret =v4l2_subdev_call (priv->sensor->sd, sensor, g_skip_frames, &bad_frames);if (!ret && bad_frames) { -struct v4l2_fract *fi = &priv->frame_interval;u32 delay_usec;/*
@@ -610,8 +632,8 @@ static int csi_start(struct csi_priv *priv)* to lose vert/horiz sync. */ delay_usec =DIV_ROUND_UP_ULL ( - (u64 )USEC_PER_SEC * fi->numerator * bad_frames, - fi->denominator); + (u64 )USEC_PER_SEC * input_fi->numerator * bad_frames, + input_fi->denominator);usleep_range (delay_usec, delay_usec +1000 ); }
@@ -627,8 +649,7 @@ static int csi_start(struct csi_priv *priv)/* start the frame interval monitor */ if (priv->fim && priv->dest ==IPU_CSI_DEST_IDMAC ) -imx_media_fim_set_stream (priv->fim, &priv->frame_interval, - true); +imx_media_fim_set_stream (priv->fim, output_fi, true); ret =ipu_csi_enable (priv->csi);if (ret) {
@@ -640,8 +661,7 @@ static int csi_start(struct csi_priv *priv) fim_off:if (priv->fim && priv->dest ==IPU_CSI_DEST_IDMAC ) -imx_media_fim_set_stream (priv->fim, &priv->frame_interval, - false); +imx_media_fim_set_stream (priv->fim,NULL , false); idmac_stop:if (priv->dest ==IPU_CSI_DEST_IDMAC )csi_idmac_stop (priv);
@@ -655,14 +675,85 @@ static void csi_stop(struct csi_priv *priv)/* stop the frame interval monitor */ if (priv->fim) -imx_media_fim_set_stream (priv->fim, - &priv->frame_interval, - false); +imx_media_fim_set_stream (priv->fim,NULL , false); }ipu_csi_disable (priv->csi); } +static const struct csi_skip_desc csi_skip[12 ] = { + {1 ,1 ,0x00 },/* Keep all frames */ + {5 ,6 ,0x10 },/* Skip every sixth frame */ + {4 ,5 ,0x08 },/* Skip every fifth frame */ + {3 ,4 ,0x04 },/* Skip every fourth frame */ + {2 ,3 ,0x02 },/* Skip every third frame */ + {3 ,5 ,0x0a },/* Skip frames 1 and 3 of every 5 */ + {1 ,2 ,0x01 },/* Skip every second frame */ + {2 ,5 ,0x0b },/* Keep frames 1 and 4 of every 5 */ + {1 ,3 ,0x03 },/* Keep one in three frames */ + {1 ,4 ,0x07 },/* Keep one in four frames */ + {1 ,5 ,0x0f },/* Keep one in five frames */ + {1 ,6 ,0x1f },/* Keep one in six frames */ +}; + +static void csi_apply_skip_interval (const struct csi_skip_desc *skip, +struct v4l2_fract *interval) +{ +unsigned int div; + + interval->numerator *= skip->max_ratio; + interval->denominator *= skip->keep; + +/* Reduce fraction to lowest terms */ + div =gcd (interval->numerator, interval->denominator); +if (div >1 ) { + interval->numerator /= div; + interval->denominator /= div; + } +} + +/* +* Find the skip pattern to produce the output frame interval closest to the +* requested one, for the given input frame interval. Updates the output frame +* interval to the exact value. +*/ +static const struct csi_skip_desc *csi_find_best_skip (struct v4l2_fract *in, +struct v4l2_fract *out) +{ +const struct csi_skip_desc *skip = &csi_skip[0 ], *best_skip = skip; +u32 min_err =UINT_MAX ; +u64 want_us; +int i; + +/* Default to 1:1 ratio */ +if (out->numerator ==0 || out->denominator ==0 || + in->numerator ==0 || in->denominator ==0 ) { + *out = *in; +return best_skip; + } + + want_us =div_u64 ((u64 )USEC_PER_SEC * out->numerator, out->denominator); + +/* Find the reduction closest to the requested time per frame */ +for (i =0 ; i <ARRAY_SIZE (csi_skip); i++, skip++) { +u64 tmp, err; + + tmp =div_u64 ((u64 )USEC_PER_SEC * in->numerator * + skip->max_ratio, in->denominator * skip->keep); + + err =abs ((s64 )tmp - want_us); +if (err < min_err) { + min_err = err; + best_skip = skip; + } + } + + *out = *in; +csi_apply_skip_interval (best_skip, out); + +return best_skip; +} +/* * V4L2 subdev operations. */
@@ -672,8 +763,13 @@ static int csi_g_frame_interval(struct v4l2_subdev *sd, {struct csi_priv *priv =v4l2_get_subdevdata (sd); +if (fi->pad >=CSI_NUM_PADS ) +return -EINVAL ; +mutex_lock (&priv->lock); - fi->interval = priv->frame_interval; + + fi->interval = priv->frame_interval[fi->pad]; +mutex_unlock (&priv->lock);return 0 ;
@@ -683,18 +779,44 @@ static int csi_s_frame_interval(struct v4l2_subdev *sd, struct v4l2_subdev_frame_interval *fi) {struct csi_priv *priv =v4l2_get_subdevdata (sd); +struct v4l2_fract *input_fi; +int ret =0 ;mutex_lock (&priv->lock); -/* Output pads mirror active input pad, no limits on input pads */ -if (fi->pad ==CSI_SRC_PAD_IDMAC || fi->pad ==CSI_SRC_PAD_DIRECT ) - fi->interval = priv->frame_interval; + input_fi = &priv->frame_interval[CSI_SINK_PAD ]; - priv->frame_interval = fi->interval; +switch (fi->pad) { +case CSI_SINK_PAD : +/* No limits on input frame interval */ +/* Reset output intervals and frame skipping ratio to 1:1 */ + priv->frame_interval[CSI_SRC_PAD_IDMAC ] = fi->interval; + priv->frame_interval[CSI_SRC_PAD_DIRECT ] = fi->interval; + priv->skip = &csi_skip[0 ]; +break ; +case CSI_SRC_PAD_IDMAC : +/* +* frame interval at IDMAC output pad depends on input +* interval, modified by frame skipping. +*/ + priv->skip =csi_find_best_skip (input_fi, &fi->interval); +break ; +case CSI_SRC_PAD_DIRECT : +/* +* frame interval at DIRECT output pad is same as input +* interval. +*/ + fi->interval = *input_fi; +break ; +default : + ret = -EINVAL ; + goto out; + } + priv->frame_interval[fi->pad] = fi->interval; +out:mutex_unlock (&priv->lock); - -return 0 ; +return ret; }static int csi_s_stream (struct v4l2_subdev *sd,int enable)
@@ -1358,11 +1480,14 @@ static int csi_registered(struct v4l2_subdev *sd) &priv->cc[i]);if (ret) goto put_csi; + +/* init default frame interval */ + priv->frame_interval[i].numerator =1 ; + priv->frame_interval[i].denominator =30 ; } -/* init default frame interval */ - priv->frame_interval.numerator =1 ; - priv->frame_interval.denominator =30 ; +/* disable frame skipping */ + priv->skip = &csi_skip[0 ]; priv->fim =imx_media_fim_init (&priv->sd);if (IS_ERR (priv->fim)) {
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 30/34 media: imx: csi: add sink selection rectangles
In reply to Steve LongerbeamFrom: Philipp Zabel <[email protected]>
Move the crop rectangle to the sink pad and add a sink compose rectangle to configure scaling. Also propagate rectangles from sink pad to crop rectangle, to compose rectangle, and to the source pads both in ACTIVE and TRY variants of set_fmt/selection, and initialize the default crop and compose rectangles.
--- drivers/staging/media/imx/imx-media-csi.c | 153 +++++++++++++++++++++++------- 1 file changed, 117 insertions(+), 36 deletions(-)
drivers/staging/media/imx/imx-media-csi.c +117 -36
@@ -80,6 +80,7 @@ struct csi_priv {const struct imx_media_pixfmt *cc[CSI_NUM_PADS ];struct v4l2_fract frame_interval[CSI_NUM_PADS ];struct v4l2_rect crop; +struct v4l2_rect compose;const struct csi_skip_desc *skip;/* active vb2 buffers to send to video dev sink */
@@ -589,8 +590,8 @@ static int csi_setup(struct csi_priv *priv)ipu_csi_set_window (priv->csi, &priv->crop);ipu_csi_set_downsize (priv->csi, - priv->crop.width ==2 * outfmt->width, - priv->crop.height ==2 * outfmt->height); + priv->crop.width ==2 * priv->compose.width, + priv->crop.height ==2 * priv->compose.height);ipu_csi_init_interface (priv->csi, &sensor_mbus_cfg, &if_fmt);
@@ -1072,6 +1073,17 @@ __csi_get_crop(struct csi_priv *priv, struct v4l2_subdev_pad_config *cfg,return &priv->crop; } +static struct v4l2_rect * +__csi_get_compose (struct csi_priv *priv,struct v4l2_subdev_pad_config *cfg, +enum v4l2_subdev_format_whence which) +{ +if (which ==V4L2_SUBDEV_FORMAT_TRY ) +return v4l2_subdev_get_try_compose (&priv->sd, cfg, +CSI_SINK_PAD ); +else +return &priv->compose; +} + static void csi_try_crop(struct csi_priv *priv, struct v4l2_rect *crop, struct v4l2_subdev_pad_config *cfg,
@@ -1181,6 +1193,7 @@ static void csi_try_fmt(struct csi_priv *priv,struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *sdformat, struct v4l2_rect *crop, + struct v4l2_rect *compose, const struct imx_media_pixfmt **cc) { const struct imx_media_pixfmt *incc;
@@ -1195,15 +1208,8 @@ static void csi_try_fmt(struct csi_priv *priv, incc =imx_media_find_mbus_format (infmt->code,CS_SEL_ANY , true); -if (sdformat->format.width < crop->width *3 /4 ) - sdformat->format.width = crop->width /2 ; -else - sdformat->format.width = crop->width; - -if (sdformat->format.height < crop->height *3 /4 ) - sdformat->format.height = crop->height /2 ; -else - sdformat->format.height = crop->height; + sdformat->format.width = compose->width; + sdformat->format.height = compose->height;if (incc->bayer) { sdformat->format.code = infmt->code;
@@ -1239,11 +1245,17 @@ static void csi_try_fmt(struct csi_priv *priv,v4l_bound_align_image (&sdformat->format.width,MIN_W ,MAX_W ,W_ALIGN , &sdformat->format.height,MIN_H ,MAX_H ,H_ALIGN ,S_ALIGN ); + +/* Reset crop and compose rectangles */ crop->left =0 ; crop->top =0 ; crop->width = sdformat->format.width; crop->height = sdformat->format.height;csi_try_crop (priv, crop, cfg, &sdformat->format, sensor); + compose->left =0 ; + compose->top =0 ; + compose->width = crop->width; + compose->height = crop->height; *cc =imx_media_find_mbus_format (sdformat->format.code,CS_SEL_ANY , true);
@@ -1268,7 +1280,7 @@ static int csi_set_fmt(struct v4l2_subdev *sd,struct imx_media_subdev *sensor;struct v4l2_pix_format vdev_fmt;struct v4l2_mbus_framefmt *fmt; -struct v4l2_rect *crop; +struct v4l2_rect *crop, *compose;int ret =0 ;if (sdformat->pad >=CSI_NUM_PADS )
@@ -1288,8 +1300,9 @@ static int csi_set_fmt(struct v4l2_subdev *sd, } crop =__csi_get_crop (priv, cfg, sdformat->which); + compose =__csi_get_compose (priv, cfg, sdformat->which); -csi_try_fmt (priv, sensor, cfg, sdformat, crop, &cc); +csi_try_fmt (priv, sensor, cfg, sdformat, crop, compose, &cc); fmt =__csi_get_fmt (priv, cfg, sdformat->pad, sdformat->which); *fmt = sdformat->format;
@@ -1306,7 +1319,8 @@ static int csi_set_fmt(struct v4l2_subdev *sd, format.pad = pad; format.which = sdformat->which; format.format = sdformat->format; -csi_try_fmt (priv, sensor, cfg, &format, crop, &outcc); +csi_try_fmt (priv, sensor, cfg, &format,NULL , compose, + &outcc); outfmt =__csi_get_fmt (priv, cfg, pad, sdformat->which); *outfmt = format.format;
@@ -1340,16 +1354,17 @@ static int csi_get_selection(struct v4l2_subdev *sd, {struct csi_priv *priv =v4l2_get_subdevdata (sd);struct v4l2_mbus_framefmt *infmt; -struct v4l2_rect *crop; +struct v4l2_rect *crop, *compose;int ret =0 ; -if (sel->pad >=CSI_NUM_PADS || sel->pad ==CSI_SINK_PAD ) +if (sel->pad !=CSI_SINK_PAD )return -EINVAL ;mutex_lock (&priv->lock); infmt =__csi_get_fmt (priv, cfg,CSI_SINK_PAD , sel->which); crop =__csi_get_crop (priv, cfg, sel->which); + compose =__csi_get_compose (priv, cfg, sel->which);switch (sel->target) {case V4L2_SEL_TGT_CROP_BOUNDS :
@@ -1361,6 +1376,15 @@ static int csi_get_selection(struct v4l2_subdev *sd,case V4L2_SEL_TGT_CROP : sel->r = *crop;break ; +case V4L2_SEL_TGT_COMPOSE_BOUNDS : + sel->r.left =0 ; + sel->r.top =0 ; + sel->r.width = crop->width; + sel->r.height = crop->height; +break ; +case V4L2_SEL_TGT_COMPOSE : + sel->r = *compose; +break ;default : ret = -EINVAL ; }
@@ -1369,19 +1393,34 @@ static int csi_get_selection(struct v4l2_subdev *sd,return ret; } +static int csi_set_scale (u32 *compose,u32 crop,u32 flags) +{ +if ((flags & (V4L2_SEL_FLAG_LE |V4L2_SEL_FLAG_GE )) == + (V4L2_SEL_FLAG_LE |V4L2_SEL_FLAG_GE ) && + *compose != crop && *compose != crop /2 ) +return -ERANGE ; + +if (*compose <= crop /2 || + (*compose < crop *3 /4 && !(flags &V4L2_SEL_FLAG_GE )) || + (*compose < crop && (flags &V4L2_SEL_FLAG_LE ))) + *compose = crop /2 ; +else + *compose = crop; + +return 0 ; +} +static int csi_set_selection (struct v4l2_subdev *sd,struct v4l2_subdev_pad_config *cfg,struct v4l2_subdev_selection *sel) {struct csi_priv *priv =v4l2_get_subdevdata (sd);struct v4l2_mbus_framefmt *infmt; +struct v4l2_rect *crop, *compose;struct imx_media_subdev *sensor; -struct v4l2_rect *crop;int pad, ret =0 ; -if (sel->pad >=CSI_NUM_PADS || - sel->pad ==CSI_SINK_PAD || - sel->target !=V4L2_SEL_TGT_CROP ) +if (sel->pad !=CSI_SINK_PAD )return -EINVAL ; sensor =imx_media_find_sensor (priv->md, &priv->sd.entity);
@@ -1399,30 +1438,66 @@ static int csi_set_selection(struct v4l2_subdev *sd, infmt =__csi_get_fmt (priv, cfg,CSI_SINK_PAD , sel->which); crop =__csi_get_crop (priv, cfg, sel->which); + compose =__csi_get_compose (priv, cfg, sel->which); -/* -* Modifying the crop rectangle always changes the format on the source -* pad. If the KEEP_CONFIG flag is set, just return the current crop -* rectangle. -*/ -if (sel->flags &V4L2_SEL_FLAG_KEEP_CONFIG ) { - sel->r = priv->crop; -if (sel->which ==V4L2_SUBDEV_FORMAT_TRY ) - *crop = sel->r; - goto out; - } +switch (sel->target) { +case V4L2_SEL_TGT_CROP : +/* +* Modifying the crop rectangle always changes the format on +* the source pads. If the KEEP_CONFIG flag is set, just return +* the current crop rectangle. +*/ +if (sel->flags &V4L2_SEL_FLAG_KEEP_CONFIG ) { + sel->r = priv->crop; +if (sel->which ==V4L2_SUBDEV_FORMAT_TRY ) + *crop = sel->r; + goto out; + } + +csi_try_crop (priv, &sel->r, cfg, infmt, sensor); + + *crop = sel->r; + +/* Reset scaling to 1:1 */ + compose->width = crop->width; + compose->height = crop->height; +break ; +case V4L2_SEL_TGT_COMPOSE : +/* +* Modifying the compose rectangle always changes the format on +* the source pads. If the KEEP_CONFIG flag is set, just return +* the current compose rectangle. +*/ +if (sel->flags &V4L2_SEL_FLAG_KEEP_CONFIG ) { + sel->r = priv->compose; +if (sel->which ==V4L2_SUBDEV_FORMAT_TRY ) + *compose = sel->r; + goto out; + } -csi_try_crop (priv, &sel->r, cfg, infmt, sensor); + sel->r.left =0 ; + sel->r.top =0 ; + ret =csi_set_scale (&sel->r.width, crop->width, sel->flags); +if (ret) + goto out; + ret =csi_set_scale (&sel->r.height, crop->height, sel->flags); +if (ret) + goto out; - *crop = sel->r; + *compose = sel->r; +break ; +default : + ret = -EINVAL ; + goto out; + } -/* Update the source pad formats */ +/* Reset source pads to sink compose rectangle */ for (pad =CSI_SINK_PAD +1 ; pad <CSI_NUM_PADS ; pad++) {struct v4l2_mbus_framefmt *outfmt; outfmt =__csi_get_fmt (priv, cfg, pad, sel->which); - outfmt->width = crop->width; - outfmt->height = crop->height; + outfmt->width = compose->width; + outfmt->height = compose->height; } out:
@@ -1489,6 +1564,12 @@ static int csi_registered(struct v4l2_subdev *sd)/* disable frame skipping */ priv->skip = &csi_skip[0 ]; +/* init default crop and compose rectangle sizes */ + priv->crop.width =640 ; + priv->crop.height =480 ; + priv->compose.width =640 ; + priv->compose.height =480 ; + priv->fim =imx_media_fim_init (&priv->sd);if (IS_ERR (priv->fim)) { ret =PTR_ERR (priv->fim);
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 31/34 media: imx: csi: add frame size/interval enumeration
In reply to Steve LongerbeamFrom: Russell King <[email protected]>
Add frame size and frame interval enumeration to CSI.
CSI can downscale the image independently horizontally and vertically by a factor of two, which enumerates to four different frame sizes at the output pads. The input pad supports a range of frame sizes.
CSI can also drop frames, resulting in frame rate reduction, so enumerate the resulting possible output frame rates.
--- drivers/staging/media/imx/imx-media-csi.c | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
drivers/staging/media/imx/imx-media-csi.c +70 -0
@@ -1163,6 +1163,74 @@ static int csi_enum_mbus_code(struct v4l2_subdev *sd,return ret; } +static int csi_enum_frame_size (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_size_enum *fse) +{ +struct csi_priv *priv =v4l2_get_subdevdata (sd); +struct v4l2_rect *crop; +int ret =0 ; + +if (fse->pad >=CSI_NUM_PADS || + fse->index > (fse->pad ==CSI_SINK_PAD ?0 :3 )) +return -EINVAL ; + +mutex_lock (&priv->lock); + +if (fse->pad ==CSI_SINK_PAD ) { + fse->min_width =MIN_W ; + fse->max_width =MAX_W ; + fse->min_height =MIN_H ; + fse->max_height =MAX_H ; + }else { + crop =__csi_get_crop (priv, cfg, fse->which); + + fse->min_width = fse->max_width = fse->index &1 ? + crop->width /2 : crop->width; + fse->min_height = fse->max_height = fse->index &2 ? + crop->height /2 : crop->height; + } + +mutex_unlock (&priv->lock); +return ret; +} + +static int csi_enum_frame_interval (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg, +struct v4l2_subdev_frame_interval_enum *fie) +{ +struct csi_priv *priv =v4l2_get_subdevdata (sd); +struct v4l2_fract *input_fi; +struct v4l2_rect *crop; +int ret =0 ; + +if (fie->pad >=CSI_NUM_PADS || + fie->index >= (fie->pad !=CSI_SRC_PAD_IDMAC ? +1 :ARRAY_SIZE (csi_skip))) +return -EINVAL ; + +mutex_lock (&priv->lock); + + input_fi = &priv->frame_interval[CSI_SINK_PAD ]; + crop =__csi_get_crop (priv, cfg, fie->which); + +if ((fie->width != crop->width && fie->width != crop->width /2 ) || + (fie->height != crop->height && fie->height != crop->height /2 )) { + ret = -EINVAL ; + goto out; + } + + fie->interval = *input_fi; + +if (fie->pad ==CSI_SRC_PAD_IDMAC ) +csi_apply_skip_interval (&csi_skip[fie->index], + &fie->interval); + +out: +mutex_unlock (&priv->lock); +return ret; +} +static int csi_get_fmt (struct v4l2_subdev *sd,struct v4l2_subdev_pad_config *cfg,struct v4l2_subdev_format *sdformat)
@@ -1631,6 +1699,8 @@ static const struct v4l2_subdev_video_ops csi_video_ops = {static const struct v4l2_subdev_pad_ops csi_pad_ops = { .enum_mbus_code = csi_enum_mbus_code, + .enum_frame_size = csi_enum_frame_size, + .enum_frame_interval = csi_enum_frame_interval, .get_fmt = csi_get_fmt, .set_fmt = csi_set_fmt, .get_selection = csi_get_selection,
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 32/34 media: imx: capture: add frame sizes/interval enumeration
In reply to Steve LongerbeamFrom: Russell King <[email protected]>
Add support for enumerating frame sizes and frame intervals from the first subdev via the V4L2 interfaces.
--- drivers/staging/media/imx/imx-media-capture.c | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
drivers/staging/media/imx/imx-media-capture.c +73 -0
@@ -81,6 +81,76 @@ static int vidioc_querycap(struct file *file, void *fh,return 0 ; } +static int capture_enum_framesizes (struct file *file,void *fh, +struct v4l2_frmsizeenum *fsize) +{ +struct capture_priv *priv =video_drvdata (file); +const struct imx_media_pixfmt *cc; +struct v4l2_subdev_frame_size_enum fse = { + .index = fsize->index, + .pad = priv->src_sd_pad, + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + }; +int ret; + + cc =imx_media_find_format (fsize->pixel_format,CS_SEL_ANY , true); +if (!cc) +return -EINVAL ; + + fse.code = cc->codes[0 ]; + + ret =v4l2_subdev_call (priv->src_sd, pad, enum_frame_size,NULL , &fse); +if (ret) +return ret; + +if (fse.min_width == fse.max_width && + fse.min_height == fse.max_height) { + fsize->type =V4L2_FRMSIZE_TYPE_DISCRETE ; + fsize->discrete.width = fse.min_width; + fsize->discrete.height = fse.min_height; + }else { + fsize->type =V4L2_FRMSIZE_TYPE_CONTINUOUS ; + fsize->stepwise.min_width = fse.min_width; + fsize->stepwise.max_width = fse.max_width; + fsize->stepwise.min_height = fse.min_height; + fsize->stepwise.max_height = fse.max_height; + fsize->stepwise.step_width =1 ; + fsize->stepwise.step_height =1 ; + } + +return 0 ; +} + +static int capture_enum_frameintervals (struct file *file,void *fh, +struct v4l2_frmivalenum *fival) +{ +struct capture_priv *priv =video_drvdata (file); +const struct imx_media_pixfmt *cc; +struct v4l2_subdev_frame_interval_enum fie = { + .index = fival->index, + .pad = priv->src_sd_pad, + .width = fival->width, + .height = fival->height, + .which =V4L2_SUBDEV_FORMAT_ACTIVE , + }; +int ret; + + cc =imx_media_find_format (fival->pixel_format,CS_SEL_ANY , true); +if (!cc) +return -EINVAL ; + + fie.code = cc->codes[0 ]; + + ret =v4l2_subdev_call (priv->src_sd, pad, enum_frame_interval,NULL , &fie); +if (ret) +return ret; + + fival->type =V4L2_FRMIVAL_TYPE_DISCRETE ; + fival->discrete = fie.interval; + +return 0 ; +} +static int capture_enum_fmt_vid_cap (struct file *file,void *fh,struct v4l2_fmtdesc *f) {
@@ -269,6 +339,9 @@ static int capture_s_parm(struct file *file, void *fh,static const struct v4l2_ioctl_ops capture_ioctl_ops = { .vidioc_querycap = vidioc_querycap, + .vidioc_enum_framesizes = capture_enum_framesizes, + .vidioc_enum_frameintervals = capture_enum_frameintervals, + .vidioc_enum_fmt_vid_cap = capture_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap = capture_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = capture_try_fmt_vid_cap,
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 33/34 media: imx: set and propagate default field, colorimetry
In reply to Steve LongerbeamThis patch adds a call to imx_media_fill_default_mbus_fields() in the *_try_fmt() functions at the sink pads, to set empty field order and colorimetry parameters.
If the field order is set to ANY, choose the currently set field order at the sink pad. If the colorspace is set to DEFAULT, choose the current colorspace at the sink pad. If any of xfer_func, ycbcr_enc or quantization are set to DEFAULT, either choose the current sink pad setting, or the default setting for the new colorspace, if non-DEFAULT colorspace was given.
If a format is destined to be routed through the Image Converter, fixed quantization and Y`CbCr encoding must be set.
Colorimetry is also propagated from sink to source pads anywhere this has not already been done.
--- drivers/staging/media/imx/imx-ic-prp.c | 10 +++-- drivers/staging/media/imx/imx-ic-prpencvf.c | 17 ++++++-- drivers/staging/media/imx/imx-media-csi.c | 14 ++++++- drivers/staging/media/imx/imx-media-utils.c | 62 +++++++++++++++++++++++++++++ drivers/staging/media/imx/imx-media-vdic.c | 8 +++- drivers/staging/media/imx/imx-media.h | 4 +- 6 files changed, 103 insertions(+), 12 deletions(-)
drivers/staging/media/imx/imx-ic-prp.c +7 -3
@@ -166,8 +166,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *sdformat) {struct prp_priv *priv =sd_to_priv (sd); +struct v4l2_mbus_framefmt *fmt, *infmt;const struct imx_media_pixfmt *cc; -struct v4l2_mbus_framefmt *fmt;int ret =0 ;u32 code;
@@ -181,6 +181,8 @@ static int prp_set_fmt(struct v4l2_subdev *sd, goto out; } + infmt =__prp_get_fmt (priv, cfg,PRP_SINK_PAD , sdformat->which); +switch (sdformat->pad) {case PRP_SINK_PAD : v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W,
@@ -194,12 +196,14 @@ static int prp_set_fmt(struct v4l2_subdev *sd, cc =imx_media_find_ipu_format (code,CS_SEL_ANY ); sdformat->format.code = cc->codes[0 ]; } + +imx_media_fill_default_mbus_fields (&sdformat->format, infmt, + true);break ;case PRP_SRC_PAD_PRPENC :case PRP_SRC_PAD_PRPVF :/* Output pads mirror input pad */ - fmt =__prp_get_fmt (priv, cfg,PRP_SINK_PAD , sdformat->which); - sdformat->format = *fmt; + sdformat->format = *infmt;break ; }
drivers/staging/media/imx/imx-ic-prpencvf.c +13 -4
@@ -805,6 +805,8 @@ static void prp_try_fmt(struct prp_priv *priv,struct v4l2_subdev_format *sdformat, const struct imx_media_pixfmt **cc) { + struct v4l2_mbus_framefmt *infmt; + *cc =imx_media_find_ipu_format (sdformat->format.code,CS_SEL_ANY );if (!*cc) {u32 code;
@@ -814,22 +816,29 @@ static void prp_try_fmt(struct prp_priv *priv, sdformat->format.code = (*cc)->codes[0 ]; } -if (sdformat->pad ==PRPENCVF_SRC_PAD ) { -struct v4l2_mbus_framefmt *infmt = -__prp_get_fmt (priv, cfg,PRPENCVF_SINK_PAD , - sdformat->which); + infmt =__prp_get_fmt (priv, cfg,PRPENCVF_SINK_PAD , sdformat->which); +if (sdformat->pad ==PRPENCVF_SRC_PAD ) {if (sdformat->format.field !=V4L2_FIELD_NONE ) sdformat->format.field = infmt->field;prp_bound_align_output (&sdformat->format, infmt, priv->rot_mode); + +/* propagate colorimetry from sink */ + sdformat->format.colorspace = infmt->colorspace; + sdformat->format.xfer_func = infmt->xfer_func; + sdformat->format.quantization = infmt->quantization; + sdformat->format.ycbcr_enc = infmt->ycbcr_enc; }else {v4l_bound_align_image (&sdformat->format.width,MIN_W_SINK ,MAX_W_SINK ,W_ALIGN_SINK , &sdformat->format.height,MIN_H_SINK ,MAX_H_SINK ,H_ALIGN_SINK ,S_ALIGN ); + +imx_media_fill_default_mbus_fields (&sdformat->format, infmt, + true); } }
drivers/staging/media/imx/imx-media-csi.c +12 -2
@@ -1268,11 +1268,11 @@ static void csi_try_fmt(struct csi_priv *priv,struct v4l2_mbus_framefmt *infmt;u32 code; + infmt =__csi_get_fmt (priv, cfg,CSI_SINK_PAD , sdformat->which); +switch (sdformat->pad) {case CSI_SRC_PAD_DIRECT :case CSI_SRC_PAD_IDMAC : - infmt =__csi_get_fmt (priv, cfg,CSI_SINK_PAD , - sdformat->which); incc =imx_media_find_mbus_format (infmt->code,CS_SEL_ANY , true);
@@ -1308,6 +1308,12 @@ static void csi_try_fmt(struct csi_priv *priv, sdformat->format.field = (infmt->height ==480 ) ?V4L2_FIELD_SEQ_TB :V4L2_FIELD_SEQ_BT ; } + +/* propagate colorimetry from sink */ + sdformat->format.colorspace = infmt->colorspace; + sdformat->format.xfer_func = infmt->xfer_func; + sdformat->format.quantization = infmt->quantization; + sdformat->format.ycbcr_enc = infmt->ycbcr_enc;break ;case CSI_SINK_PAD : v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W,
@@ -1334,6 +1340,10 @@ static void csi_try_fmt(struct csi_priv *priv, CS_SEL_ANY, false); sdformat->format.code = (*cc)->codes[0 ]; } + +imx_media_fill_default_mbus_fields ( + &sdformat->format, infmt, + priv->active_output_pad ==CSI_SRC_PAD_DIRECT );break ; } }
drivers/staging/media/imx/imx-media-utils.c +62 -0
68 lines not on this page · raw message
drivers/staging/media/imx/imx-media-vdic.c +6 -2
@@ -603,10 +603,11 @@ static void vdic_try_fmt(struct vdic_priv *priv, sdformat->format.code = (*cc)->codes[0 ]; } + infmt =__vdic_get_fmt (priv, cfg, priv->active_input_pad, + sdformat->which); +switch (sdformat->pad) {case VDIC_SRC_PAD_DIRECT : - infmt =__vdic_get_fmt (priv, cfg, priv->active_input_pad, - sdformat->which); sdformat->format = *infmt;/* output is always progressive! */ sdformat->format.field =V4L2_FIELD_NONE ;
@@ -618,6 +619,9 @@ static void vdic_try_fmt(struct vdic_priv *priv, &sdformat->format.height, MIN_H, MAX_H_VDIC, H_ALIGN, S_ALIGN); +imx_media_fill_default_mbus_fields (&sdformat->format, infmt, + true); +/* input must be interlaced! Choose SEQ_TB if not */ if (!V4L2_FIELD_HAS_BOTH (sdformat->format.field)) sdformat->format.field =V4L2_FIELD_SEQ_TB ;
drivers/staging/media/imx/imx-media.h +3 -1
@@ -209,7 +209,9 @@ int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel);int imx_media_init_mbus_fmt (struct v4l2_mbus_framefmt *mbus,u32 width,u32 height,u32 code,u32 field,const struct imx_media_pixfmt **cc); - +void imx_media_fill_default_mbus_fields (struct v4l2_mbus_framefmt *tryfmt, +struct v4l2_mbus_framefmt *fmt, +bool ic_route);int imx_media_mbus_fmt_to_pix_fmt (struct v4l2_pix_format *pix,struct v4l2_mbus_framefmt *mbus,const struct imx_media_pixfmt *cc);
Signature · 1 line
2.7.4
Steve Longerbeam
maintainerPATCH v7 34/34 media: imx: Drop warning upon multiple S_STREAM disable calls
In reply to Steve LongerbeamFrom: Marek Vasut <[email protected]>
Calling S_STREAM OFF multiple times on a video device is valid, although dubious, practice. Instead of warning about it and setting stream count lower than zero, just ignore the subsequent S_STREAM calls and correct the stream count to zero.
--- drivers/staging/media/imx/imx-ic-prp.c | 3 ++- drivers/staging/media/imx/imx-ic-prpencvf.c | 3 ++- drivers/staging/media/imx/imx-media-csi.c | 3 ++- drivers/staging/media/imx/imx-media-vdic.c | 3 ++- drivers/staging/media/imx/imx6-mipi-csi2.c | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-)
drivers/staging/media/imx/imx-ic-prp.c +2 -1
@@ -387,7 +387,8 @@ static int prp_s_stream(struct v4l2_subdev *sd, int enable) update_count: priv->stream_count += enable ?1 :-1 ; -WARN_ON (priv->stream_count <0 ); +if (priv->stream_count <0 ) + priv->stream_count =0 ; out:mutex_unlock (&priv->lock);return ret;
drivers/staging/media/imx/imx-ic-prpencvf.c +2 -1
@@ -1140,7 +1140,8 @@ static int prp_s_stream(struct v4l2_subdev *sd, int enable) update_count: priv->stream_count += enable ?1 :-1 ; -WARN_ON (priv->stream_count <0 ); +if (priv->stream_count <0 ) + priv->stream_count =0 ; out:mutex_unlock (&priv->lock);return ret;
drivers/staging/media/imx/imx-media-csi.c +2 -1
@@ -861,7 +861,8 @@ static int csi_s_stream(struct v4l2_subdev *sd, int enable) update_count: priv->stream_count += enable ?1 :-1 ; -WARN_ON (priv->stream_count <0 ); +if (priv->stream_count <0 ) + priv->stream_count =0 ; out:mutex_unlock (&priv->lock);return ret;
drivers/staging/media/imx/imx-media-vdic.c +2 -1
@@ -536,7 +536,8 @@ static int vdic_s_stream(struct v4l2_subdev *sd, int enable) update_count: priv->stream_count += enable ?1 :-1 ; -WARN_ON (priv->stream_count <0 ); +if (priv->stream_count <0 ) + priv->stream_count =0 ; out:mutex_unlock (&priv->lock);return ret;
drivers/staging/media/imx/imx6-mipi-csi2.c +2 -1
@@ -396,7 +396,8 @@ static int csi2_s_stream(struct v4l2_subdev *sd, int enable) update_count: csi2->stream_count += enable ?1 :-1 ; -WARN_ON (csi2->stream_count <0 ); +if (csi2->stream_count <0 ) + csi2->stream_count =0 ; out:mutex_unlock (&csi2->lock);return ret;
Signature · 1 line
2.7.4
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.
Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.
What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).
I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise. Any idea when the multiplexer is expected to be merged? (just curious)
I would really like to get this merged for 4.13, so did I miss anything?
From what I can tell it is really just an Ack for patch 2/34.
Regards,
Hans
Quoted 117 lines
Marek Vasut (1):
media: imx: Drop warning upon multipleS_STREAMdisable callsPhilipp Zabel (9):
dt-bindings: Add bindings for video-multiplexer device
ARM: dts: imx6qdl: add multiplexer controls
ARM: dts: imx6qdl: Add video multiplexers,mipi_csi, and their
connections
add mux and video interface bridge entity functions
platform: add video-multiplexer subdevice driver
platform: video-mux: include temporary mmio-mux support
media: imx: csi: increase burst size for YUV formats
media: imx: csi: add frame skipping support
media: imx: csi: add sink selection rectanglesRussell King (3):
media: imx: csi: add support for bayer formats
media: imx: csi: add frame size/interval enumeration
media: imx: capture: add frame sizes/interval enumerationSteve Longerbeam (21):
[media] dt-bindings: Add bindings for i.MX media driver [media] dt/bindings: Add bindings for OV5640
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 formax7310_b
ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture
ARM: dts: imx6-sabreauto: add the ADV7180 video decoder [media] add Omnivision OV5640 sensor driver
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
ARM:imx_v6_v7_defconfig: Enable staging video4linux drivers
media: imx: set and propagate default field, colorimetry.../devicetree/bindings/media/i2c/ov5640.txt | 45 + Documentation/devicetree/bindings/media/imx.txt | 74 + .../devicetree/bindings/media/video-mux.txt | 60 + Documentation/media/uapi/mediactl/media-types.rst | 22 + Documentation/media/v4l-drivers/imx.rst | 590 ++++++ arch/arm/boot/dts/imx6dl-sabrelite.dts | 5 + arch/arm/boot/dts/imx6dl-sabresd.dts | 5 + arch/arm/boot/dts/imx6dl.dtsi | 189 ++ arch/arm/boot/dts/imx6q-sabrelite.dts | 5 + arch/arm/boot/dts/imx6q-sabresd.dts | 5 + arch/arm/boot/dts/imx6q.dtsi | 125 ++ 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 | 20 +- arch/arm/configs/imx_v6_v7_defconfig | 11 + drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++ drivers/media/platform/Kconfig | 6 + drivers/media/platform/Makefile | 2 + drivers/media/platform/video-mux.c | 357 ++++ 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 | 15 + drivers/staging/media/imx/imx-ic-common.c | 113 + drivers/staging/media/imx/imx-ic-prp.c | 514 +++++ drivers/staging/media/imx/imx-ic-prpencvf.c | 1309 ++++++++++++ drivers/staging/media/imx/imx-ic.h | 38 + drivers/staging/media/imx/imx-media-capture.c | 775 +++++++ drivers/staging/media/imx/imx-media-csi.c | 1842 ++++++++++++++++ drivers/staging/media/imx/imx-media-dev.c | 665 ++++++ 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 | 268 +++ drivers/staging/media/imx/imx-media-utils.c | 896 ++++++++ drivers/staging/media/imx/imx-media-vdic.c | 1009 +++++++++ drivers/staging/media/imx/imx-media.h | 326 +++ drivers/staging/media/imx/imx6-mipi-csi2.c | 697 ++++++ include/linux/imx-media.h | 27 + include/media/imx.h | 15 + include/uapi/linux/media.h | 6 + include/uapi/linux/v4l2-controls.h | 4 + 45 files changed, 13504 insertions(+), 27 deletions(-)create mode 100644
Documentation/devicetree/bindings/media/i2c/ov5640.txtcreate mode 100644Documentation/devicetree/bindings/media/imx.txtcreate mode 100644Documentation/devicetree/bindings/media/video-mux.txtcreate mode 100644Documentation/media/v4l-drivers/imx.rstcreate mode 100644drivers/media/i2c/ov5640.c
create mode 100644drivers/media/platform/video-mux.c
create mode 100644drivers/staging/media/imx/Kconfig
create mode 100644drivers/staging/media/imx/Makefile
create mode 100644drivers/staging/media/imx/TODO
create mode 100644drivers/staging/media/imx/imx-ic-common.ccreate mode 100644drivers/staging/media/imx/imx-ic-prp.ccreate mode 100644drivers/staging/media/imx/imx-ic-prpencvf.ccreate mode 100644drivers/staging/media/imx/imx-ic.h
create mode 100644drivers/staging/media/imx/imx-media-capture.ccreate mode 100644drivers/staging/media/imx/imx-media-csi.ccreate mode 100644drivers/staging/media/imx/imx-media-dev.ccreate mode 100644drivers/staging/media/imx/imx-media-fim.ccreate mode 100644drivers/staging/media/imx/imx-media-internal-sd.ccreate mode 100644drivers/staging/media/imx/imx-media-of.ccreate mode 100644drivers/staging/media/imx/imx-media-utils.ccreate mode 100644drivers/staging/media/imx/imx-media-vdic.ccreate mode 100644drivers/staging/media/imx/imx-media.hcreate mode 100644drivers/staging/media/imx/imx6-mipi-csi2.ccreate mode 100644include/linux/imx-media.h
create mode 100644include/media/imx.h
Philipp Zabel
maintainerQuoted 66 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).
Quoted 7 lines
I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise.
Is this a problem? It won't break any builds as patch 17 depends on CONFIG_MULTIPLEXER, which doesn't exist yet. I'm fine with merging the two patches, though.
Quoted 1 line
Any idea when the multiplexer is expected to be merged? (just curious)
I have no idea. v15 of the multiplexer framework patchset was posted on 2017-05-14, is still waiting for comments.
Quoted 1 line
I would really like to get this merged for 4.13, so did I miss anything?
Seconded, and not that I can tell.
Quoted 1 line
From what I can tell it is really just an Ack for patch 2/34.
regards
Philipp
Quoted 71 lines · Philipp Zabel
Quoted 70 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Quoted 7 lines
Quoted 3 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise.
Is this a problem? It won't break any builds as patch 17 depends on
CONFIG_MULTIPLEXER, which doesn't exist yet. I'm fine with merging the two patches, though.
You are right, but it is weird. I think I would prefer to have these two merged and the #ifdef CONFIG_MULTIPLEXER bits removed. Just a note in the commit log that this should be converted to the multiplexer when that gets merged would be enough.
Dead code in drivers/media should be avoided because that's what this driver currently has.
Regards,
Hans
Quoted 15 lines
Quoted 2 lines
Any idea when the multiplexer is expected to be merged? (just curious)
I have no idea. v15 of the multiplexer framework patchset was posted on 2017-05-14, is still waiting for comments.
Quoted 1 line
I would really like to get this merged for 4.13, so did I miss anything?
Seconded, and not that I can tell.
Quoted 1 line
From what I can tell it is really just an Ack for patch 2/34.
regards
Philipp
Quoted 80 lines · Hans Verkuil
Quoted 71 lines · Philipp Zabel
Quoted 70 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Quoted 7 lines
Quoted 3 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise.
Is this a problem? It won't break any builds as patch 17 depends on
CONFIG_MULTIPLEXER, which doesn't exist yet. I'm fine with merging the two patches, though.
Quoted 7 lines
You are right, but it is weird. I think I would prefer to have these two merged and the #ifdef
CONFIG_MULTIPLEXERbits removed. Just a note in the commit log that this should be converted to the multiplexer when that gets merged would be enough.Dead code in
drivers/mediashould be avoided because that's what this driver currently has.
Thanks for those updates! That really leaves just an Ack for patch 2/34.
Sooo close!
Regards,
Hans
Hi Hans,
Quoted 70 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches 4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).
I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Quoted 7 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise. Any idea when the multiplexer is expected to be merged? (just curious)
I would really like to get this merged for 4.13, so did I miss anything? From what I can tell it is really just an Ack for patch 2/34.
The patchset re-initialises the control handler in the video node in its media device link_setup callback, among other things. I don't think that this as such should prevent including the driver in staging, but at the same time my concern is what kind of guarantees can we give in terms of V4L2 framework support on things like this using the current API. I'd say "none".
If there's a need for this (there should not be, as the controls are exposed to the user space through the sub-device nodes as the other drivers do), the framework APIs need to be extended.
I think it'd be good to add a TODO file (such as the one in OMAP4ISS) as part of the patchset that would include a list of things left to do so they're not forgotten.
Signature · 4 lines
Regards, Sakari Ailus e-mail: sakari.ailus at iki.fi XMPP: sailus at retiisi.org.uk
Quoted 87 lines · Sakari Ailus
Hi Hans,
Quoted 70 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Quoted 7 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise. Any idea when the multiplexer is expected to be merged? (just curious)
I would really like to get this merged for 4.13, so did I miss anything?
From what I can tell it is really just an Ack for patch 2/34.The patchset re-initialises the control handler in the video node in its media device
link_setupcallback, among other things. I don't think that this as such should prevent including the driver in staging, but at the same time my concern is what kind of guarantees can we give in terms of V4L2 framework support on things like this using the current API. I'd say "none".
Quoted 8 lines
If there's a need for this (there should not be, as the controls are exposed to the user space through the sub-device nodes as the other drivers do), the framework APIs need to be extended.
I think it'd be good to add a TODO file (such as the one in OMAP4ISS) as part of the patchset that would include a list of things left to do so they're not forgotten.
A TODO file, that's a very good point. Yes, we need that.
Regards,
Hans
Steve Longerbeam
maintainerHi Sakari,
Quoted 77 lines · Sakari Ailus
Hi Hans,
Quoted 74 lines · Hans Verkuil
Hi Steve,
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.Quoted 1 line
- Converted the
v4l2_subdevandmedia_entityops structures to const.What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring, patches
4-14 are out of scope for the media subsystem, patches 20-25 and 27-34 are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one patch since patch 17 won't compile otherwise. Any idea when the multiplexer is expected to be merged? (just curious)
Quoted 7 lines
Quoted 2 lines
I would really like to get this merged for 4.13, so did I miss anything?
From what I can tell it is really just an Ack for patch 2/34.The patchset re-initialises the control handler in the video node in its media device
link_setupcallback, among other things. I don't think that this as such should prevent including the driver in staging, but at the same time my concern is what kind of guarantees can we give in terms of V4L2 framework support on things like this using the current API. I'd say "none".
Re-initializing a control handler in itself works fine (maybe we should add a v4l2_ctrl_handler_reinit() ?).
I agree that calling free/init/add at this time (in link_setup and link_notify)
is a new way to use those APIs. The effect is that a video node's controls can change post driver load.
There's nothing in Documentation/kapi/v4l2-controls.rst that states that a video node's control list can't change at runtime. But as I said free/init/add
works just fine and can be called any time after a subdevice or video device is registered.
Quoted 4 lines
If there's a need for this (there should not be, as the controls are exposed to the user space through the sub-device nodes as the other drivers do), the framework APIs need to be extended.
Right, this gets back to the media framework usability arguments. At least myself, Philipp, and Russell feel that automatic inheritance of a configured pipeline's controls to a video device adds to the usability.
Quoted 4 lines
I think it'd be good to add a TODO file (such as the one in OMAP4ISS) as part of the patchset that would include a list of things left to do so they're not forgotten.
Right, there is a TODO, but I will add an item that mentions this included feature and whether it should eventually become part of the framework or dropped.
Steve
Hi!
Quoted 7 lines
Quoted 3 lines
If there's a need for this (there should not be, as the controls are exposed to the user space through the sub-device nodes as the other drivers do), the framework APIs need to be extended.
Right, this gets back to the media framework usability arguments. At least myself, Philipp, and Russell feel that automatic inheritance of a configured pipeline's controls to a video device adds to the usability.
For the record, usability can be pretty much fixed in v4l-utils... I have patches that try ioctls on a list of fd's. Now we need a way to find out which /dev/video* files belong to single camera. I believe kernel already has required APIs, we just need to apply v4l-utils patch to use them...
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/20170531/70aa8570/attachment.sig>
Steve Longerbeam
maintainerHi Hans, thanks for the reply...
Quoted 10 lines · Hans Verkuil
Hi Steve,
Quoted 3 lines · Steve Longerbeam
In version 7:
What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring,
Yes still missing that Ack. I think the issue is likely the Synopsys DW mipi csi-2 bindings. Someone earlier noted that there is another driver under devel for this Synopsys core, with another set of bindings. But it was determined that in fact this is a different device with a different register set.
From what I remember of dealing with Synopsys cores in the past,
these cores are highly configurable using their coreBuilder tools. So while the other device might stem from the same initial core from Synopsys, it was probably built with different design parameters compared to the core that exists in the i.MX6. So in essence it is a different device.
Quoted 2 lines
patches
4-14 are out of scope for the media subsystem,
Ok. I did submit patches 4-14 to the right set of folks. Should I just drop this set in the next submission if they have not changed?
Quoted 6 lines
patches 20-25 and 27-34
are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Ok.
Quoted 7 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one
patch since patch 17 won't compile otherwise. Any idea when the multiplexer is
expected to be merged? (just curious)
Philipp replied separately.
Quoted 3 lines
I would really like to get this merged for 4.13, so did I miss anything? From what I can tell it is really just an Ack for patch 2/34.
Agreed.
Steve
Quoted 124 lines
Quoted 123 lines
Marek Vasut (1):
media: imx: Drop warning upon multipleS_STREAMdisable callsPhilipp Zabel (9):
dt-bindings: Add bindings for video-multiplexer device
ARM: dts: imx6qdl: add multiplexer controls
ARM: dts: imx6qdl: Add video multiplexers,mipi_csi, and their
connections
add mux and video interface bridge entity functions
platform: add video-multiplexer subdevice driver
platform: video-mux: include temporary mmio-mux support
media: imx: csi: increase burst size for YUV formats
media: imx: csi: add frame skipping support
media: imx: csi: add sink selection rectanglesRussell King (3):
media: imx: csi: add support for bayer formats
media: imx: csi: add frame size/interval enumeration
media: imx: capture: add frame sizes/interval enumerationSteve Longerbeam (21):
[media] dt-bindings: Add bindings for i.MX media driver [media] dt/bindings: Add bindings for OV5640
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 formax7310_b
ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture
ARM: dts: imx6-sabreauto: add the ADV7180 video decoder [media] add Omnivision OV5640 sensor driver
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
ARM:imx_v6_v7_defconfig: Enable staging video4linux drivers
media: imx: set and propagate default field, colorimetry.../devicetree/bindings/media/i2c/ov5640.txt | 45 + Documentation/devicetree/bindings/media/imx.txt | 74 + .../devicetree/bindings/media/video-mux.txt | 60 + Documentation/media/uapi/mediactl/media-types.rst | 22 + Documentation/media/v4l-drivers/imx.rst | 590 ++++++ arch/arm/boot/dts/imx6dl-sabrelite.dts | 5 + arch/arm/boot/dts/imx6dl-sabresd.dts | 5 + arch/arm/boot/dts/imx6dl.dtsi | 189 ++ arch/arm/boot/dts/imx6q-sabrelite.dts | 5 + arch/arm/boot/dts/imx6q-sabresd.dts | 5 + arch/arm/boot/dts/imx6q.dtsi | 125 ++ 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 | 20 +- arch/arm/configs/imx_v6_v7_defconfig | 11 + drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov5640.c | 2224 ++++++++++++++++++++ drivers/media/platform/Kconfig | 6 + drivers/media/platform/Makefile | 2 + drivers/media/platform/video-mux.c | 357 ++++ 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 | 15 + drivers/staging/media/imx/imx-ic-common.c | 113 + drivers/staging/media/imx/imx-ic-prp.c | 514 +++++ drivers/staging/media/imx/imx-ic-prpencvf.c | 1309 ++++++++++++ drivers/staging/media/imx/imx-ic.h | 38 + drivers/staging/media/imx/imx-media-capture.c | 775 +++++++ drivers/staging/media/imx/imx-media-csi.c | 1842 ++++++++++++++++ drivers/staging/media/imx/imx-media-dev.c | 665 ++++++ 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 | 268 +++ drivers/staging/media/imx/imx-media-utils.c | 896 ++++++++ drivers/staging/media/imx/imx-media-vdic.c | 1009 +++++++++ drivers/staging/media/imx/imx-media.h | 326 +++ drivers/staging/media/imx/imx6-mipi-csi2.c | 697 ++++++ include/linux/imx-media.h | 27 + include/media/imx.h | 15 + include/uapi/linux/media.h | 6 + include/uapi/linux/v4l2-controls.h | 4 + 45 files changed, 13504 insertions(+), 27 deletions(-)create mode 100644
Documentation/devicetree/bindings/media/i2c/ov5640.txt
create mode 100644Documentation/devicetree/bindings/media/imx.txtcreate mode 100644Documentation/devicetree/bindings/media/video-mux.txt
create mode 100644Documentation/media/v4l-drivers/imx.rstcreate mode 100644drivers/media/i2c/ov5640.c
create mode 100644drivers/media/platform/video-mux.ccreate mode 100644drivers/staging/media/imx/Kconfigcreate mode 100644drivers/staging/media/imx/Makefilecreate mode 100644drivers/staging/media/imx/TODO
create mode 100644drivers/staging/media/imx/imx-ic-common.ccreate mode 100644drivers/staging/media/imx/imx-ic-prp.ccreate mode 100644drivers/staging/media/imx/imx-ic-prpencvf.ccreate mode 100644drivers/staging/media/imx/imx-ic.hcreate mode 100644drivers/staging/media/imx/imx-media-capture.ccreate mode 100644drivers/staging/media/imx/imx-media-csi.ccreate mode 100644drivers/staging/media/imx/imx-media-dev.ccreate mode 100644drivers/staging/media/imx/imx-media-fim.ccreate mode 100644drivers/staging/media/imx/imx-media-internal-sd.ccreate mode 100644drivers/staging/media/imx/imx-media-of.ccreate mode 100644drivers/staging/media/imx/imx-media-utils.ccreate mode 100644drivers/staging/media/imx/imx-media-vdic.ccreate mode 100644drivers/staging/media/imx/imx-media.hcreate mode 100644drivers/staging/media/imx/imx6-mipi-csi2.ccreate mode 100644include/linux/imx-media.h
create mode 100644include/media/imx.h
Quoted 30 lines · Steve Longerbeam
Hi Hans, thanks for the reply...
Quoted 10 lines · Hans Verkuil
Hi Steve,
Quoted 3 lines · Steve Longerbeam
In version 7:
What is the status as of v7?
From what I can tell patch 2/34 needs an Ack from Rob Herring,
Yes still missing that Ack. I think the issue is likely the Synopsys DW mipi csi-2 bindings. Someone earlier noted that there is another driver under devel for this Synopsys core, with another set of bindings. But it was determined that in fact this is a different device with a different register set.
From what I remember of dealing with Synopsys cores in the past,
these cores are highly configurable using their coreBuilder tools. So while the other device might stem from the same initial core from Synopsys, it was probably built with different design parameters compared to the core that exists in the i.MX6. So in essence it is a different device.
Quoted 5 lines
Quoted 2 lines
patches
4-14 are out of scope for the media subsystem,Ok. I did submit patches 4-14 to the right set of folks. Should I just drop this set in the next submission if they have not changed?
No, please keep them. Just make a note in the cover letter that they go through a different tree. I like seeing the whole set :-)
Quoted 17 lines
Quoted 6 lines
patches 20-25 and 27-34
are all staging (so fine to be merged from my point of view).I'm not sure if patch 26 (defconfig) should be applied while the imx driver is in staging. I would suggest that this patch is moved to the end of the series.
Ok.
Quoted 7 lines
That leaves patches 15-19. I replied to patch 15 with a comment, patches 16-18 look good to me, although patches 17 and 18 should be combined to one
patch since patch 17 won't compile otherwise. Any idea when the multiplexer is
expected to be merged? (just curious)
Quoted 7 lines
Philipp replied separately.
Quoted 3 lines
I would really like to get this merged for 4.13, so did I miss anything?
From what I can tell it is really just an Ack for patch 2/34.Agreed.
Can you split off the TODO file in its own patch? It was buried in the big patch and I missed it because of that.
Take a look at Sakari's comment from today about another TODO item that probably should be in the TODO file.
Regards,
Hans
Regards,
Hans
Quoted 55 lines · Steve Longerbeam
In version 7:
- video-mux: switched to Philipp's latest video-mux driver and updated bindings docs, that makes use of the mmio-mux framework.
- mmio-mux: includes Philipp's temporary patch that adds mmio-mux support to video-mux driver, until mux framework is merged.
- mmio-mux: updates to device tree from Philipp that define the i.MX6 mux devices and modifies the video-mux device to become a consumer of the video mmio-mux.
- minor updates to
Documentation/media/v4l-drivers/imx.rst.- ov5640: do nothing if entity stream count is greater than 1 in
ov5640_s_stream().- Previous versions of this driver had not tested the ability to enable multiple independent streams, for instance enabling multiple output pads from the imx6-mipi-csi2 subdevice, or enabling both prpenc and prpvf outputs. Marek Vasut tested this support and reported issues with it.
v4l2_pipeline_inherit_controls()used the media graph walk APIs, but that walks both sink and source pads, so if there are multiple paths enabled to video capture devices, controls would be added to the wrong video capture device, and no controls added to the other enabled capture devices.These issues have been fixed. Control inheritance works correctly now even with multiple enabled capture paths, and (for example) simultaneous capture from prpenc and prpvf works also, and each with independent scaling, CSC, and controls. For example prpenc can be capturing with a 90 degree rotation, while prpvf is capturing with vertical flip.
So the
v4l2_pipeline_inherit_controls()patch has been dropped. The new version of control inheritance could be made generically available, but it would be more involved to incorporate it into v4l2-core.- A new function
imx_media_fill_default_mbus_fields()is added to setup colorimetry at sink pads, and these are propagated to source pads.- Ensure that the current sink and source rectangles meet alignment restrictions before applying a new rotation control setting in prp-enc/vf subdevices.
- Chain the
s_stream()subdev calls instead of implementing a custom stream on/off function that attempts to call a fixed set of subdevices in a pipeline in the correct order. This also simplifies imx6-mipi-csi2 subdevice, since the correct MIPI CSI-2 startup sequence can be enforced completely ins_stream(), ands_power()is no longer required. This also paves the way for more arbitrary OF graphs external to the i.MX6.
Quoted 2 lines
- Converted the
v4l2_subdevandmedia_entityops structures to const.
Hi Steve,
I've applied adv7180 device-tree config for the Gateworks ventana boards on top of your imx-media-staging-md-v15 github branch but am not able to get it to work.
Here's my device-tree patch that adds adv7180 to the GW54xx connected to IPU2_CSI1:
arch/arm/boot/dts/imx6q-gw54xx.dts +17 -0
@@ -18,6 +18,76 @@ compatible = "gw,imx6q-gw54xx", "gw,ventana", "fsl,imx6q"; }; +&i2c3 { + adv7180: camera at 20 { + compatible = "adi,adv7180"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adv7180>; + reg = <0x20>; + powerdown-gpios = <&gpio3 31 GPIO_ACTIVE_LOW>; + interrupt-parent = <&gpio3>; + interrupts = <30 GPIO_ACTIVE_LOW>; + inputs = <0x00 0x01 0x02>; + input-names = "ADV7180 Composite on Ain1", + "ADV7180 Composite on Ain2", + "ADV7180 Composite on Ain3"; + + port { + adv7180_to_ipu2_csi1_mux: endpoint { + remote-endpoint =
<&ipu2_csi1_mux_from_parallel_sensor>;
+ bus-width = <8>;
+ };
+ };
+ };
+};
+
+&ipu2_csi1_from_ipu2_csi1_mux {
+ bus-width = <8>;
+};
+
+&ipu2_csi1_mux_from_parallel_sensor {
+ remote-endpoint = <&adv7180_to_ipu2_csi1_mux>;
+ bus-width = <8>;
+};
+
+&ipu2_csi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_ipu2_csi1>;
+
+ /* enable frame interval monitor on this port */
+ fim {
+ status = "okay";
+ };
+};
+
&sata {
status = "okay"; };
+
+&iomuxc {
+ video {
+ pinctrl_adv7180: adv7180grp {
+ fsl,pins = <
+ MX6QDL_PAD_EIM_D30__GPIO3_IO30
0x0001b0b0
+ MX6QDL_PAD_EIM_D31__GPIO3_IO31
0x4001b0b0
+ >;
+ };
+
+ pinctrl_ipu2_csi1: ipu2_csi1grp { /* IPU2_CSI1: 8-bit input */
+ fsl,pins = <
+ MX6QDL_PAD_EIM_EB2__IPU2_CSI1_DATA19 0x1b0b0 + MX6QDL_PAD_EIM_D16__IPU2_CSI1_DATA18 0x1b0b0 + MX6QDL_PAD_EIM_D18__IPU2_CSI1_DATA17 0x1b0b0 + MX6QDL_PAD_EIM_D19__IPU2_CSI1_DATA16 0x1b0b0 + MX6QDL_PAD_EIM_D20__IPU2_CSI1_DATA15 0x1b0b0 + MX6QDL_PAD_EIM_D26__IPU2_CSI1_DATA14 0x1b0b0 + MX6QDL_PAD_EIM_D27__IPU2_CSI1_DATA13 0x1b0b0 + MX6QDL_PAD_EIM_A17__IPU2_CSI1_DATA12 0x1b0b0 + MX6QDL_PAD_EIM_D29__IPU2_CSI1_VSYNC 0x1b0b0 + MX6QDL_PAD_EIM_EB3__IPU2_CSI1_HSYNC 0x1b0b0 + MX6QDL_PAD_EIM_A16__IPU2_CSI1_PIXCLK 0x1b0b0
+ >;
+ };
+ };
+};
+
Here's my userspace test commands:
media-ctl -r # reset all links
export outputfmt="UYVY2X8/720x480"
# Setup links (ADV7180 IPU2_CSI1)
media-ctl -l '"adv7180 2-0020":0 -> "ipu2_csi1_mux":1[1]' media-ctl -l '"ipu2_csi1_mux":2 -> "ipu2_csi1":0[1]' media-ctl -l '"ipu2_csi1":1 -> "ipu2_vdic":0[1]'
media-ctl -l '"ipu2_vdic":2 -> "ipu2_ic_prp":0[1]'
media-ctl -l '"ipu2_ic_prp":2 -> "ipu2_ic_prpvf":0[1]' media-ctl -l '"ipu2_ic_prpvf":1 -> "ipu2_ic_prpvf capture":0[1]' # Configure pads
media-ctl -V "'adv7180 2-0020':0 [fmt:UYVY2X8/720x480]" media-ctl -V "'ipu2_csi1_mux':2 [fmt:UYVY2X8/720x480 field:interlaced]" media-ctl -V "'ipu2_csi1':1 [fmt:UYVY2X8/720x480 field:interlaced]" media-ctl -V "'ipu2_vdic':2 [fmt:UYVY2X8/720x480 field:none]" media-ctl -V "'ipu2_ic_prp':2 [fmt:AYUV32/720x480 field:none]" media-ctl -V "'ipu2_ic_prpvf':1 [fmt:$outputfmt field:none]" ^^^^ no errors up to this point; streaming can now begin on 'ipu2_ic_prpvf capture'
# select input v4l2-ctl --device /dev/video3 -i0 # 0=AIN1 1=AIN2 2=AIN3 VIDIOC_S_INPUT: failed: Inappropriate ioctl for device ^^^^ /sys/class/video4linux/v4l-subdev2/name is 'ipu2_ic_prpvf capture' - is this not right?
# select any supported YUV or RGB pixelformat on the capture device node v4l2-ctl --device /dev/video3 --set-fmt-video=width=720,height=480,pixelformat=UYVY v4l2-ctl --device /dev/video3 --stream-mmap --stream-to=/x.raw --stream-count=1 # capture single raw-frame [ 904.870444] ipu2_ic_prpvf: EOF timeout VIDIOC_DQBUF: failed: Input/output error [ 905.910702] ipu2_ic_prpvf: wait last EOF timeout ^^^^ not getting any frames
The last patchset of yours I had running on this board was your v3 patchset - any ideas?
As it looks like things have settled down with this patchset and it sounds like it will get merged for 4.13 I'm going to start working on a driver for the tda1997x HDMI receiver which is also on this board connected to IPU1_CSI0.
Thanks,
Tim
Steve Longerbeam
maintainerHi Tim,
arch/arm/boot/dts/imx6q-gw54xx.dts
Quoted 12 lines · Tim Harvey
Hi Steve,
I've applied adv7180 device-tree config for the Gateworks ventana boards on top of your imx-media-staging-md-v15 github branch but am not able to get it to work.
Here's my device-tree patch that adds adv7180 to the GW54xx connected to
IPU2_CSI1:arch/arm/boot/dts/imx6q-gw54xx.dts +0
-0
I haven't studied your device-tree in detail yet, I'll try to have a better look this weekend.
<snip>
Quoted 23 lines
Here's my userspace test commands:
media-ctl -r # reset all links
export outputfmt="UYVY2X8/720x480"
# Setup links (ADV7180IPU2_CSI1)
media-ctl -l '"adv7180 2-0020":0 -> "ipu2_csi1_mux":1[1]' media-ctl -l '"ipu2_csi1_mux":2 -> "ipu2_csi1":0[1]' media-ctl -l '"ipu2_csi1":1 -> "ipu2_vdic":0[1]'
media-ctl -l '"ipu2_vdic":2 -> "ipu2_ic_prp":0[1]'
media-ctl -l '"ipu2_ic_prp":2 -> "ipu2_ic_prpvf":0[1]' media-ctl -l '"ipu2_ic_prpvf":1 -> "ipu2_ic_prpvfcapture":0[1]' # Configure pads
media-ctl -V "'adv7180 2-0020':0 [fmt:UYVY2X8/720x480]" media-ctl -V "'ipu2_csi1_mux':2 [fmt:UYVY2X8/720x480 field:interlaced]" media-ctl -V "'ipu2_csi1':1 [fmt:UYVY2X8/720x480 field:interlaced]" media-ctl -V "'ipu2_vdic':2 [fmt:UYVY2X8/720x480 field:none]" media-ctl -V "'ipu2_ic_prp':2 [fmt:AYUV32/720x480 field:none]" media-ctl -V "'ipu2_ic_prpvf':1 [fmt:$outputfmt field:none]" ^^^^ no errors up to this point; streaming can now begin on 'ipu2_ic_prpvfcapture'
Quoted 5 lines
# select input v4l2-ctl --device /dev/video3 -i0 # 0=AIN1 1=AIN2 2=AIN3 VIDIOC_S_INPUT: failed: Inappropriate ioctl for device ^^^^ /sys/class/video4linux/v4l-subdev2/name is 'ipu2_ic_prpvf capture' - is this not right?
Support for setting sensor inputs from the main video capture nodes was long ago removed. Sorry about that, but there were objections to reaching across the media graph to make this happen.
Until a VIDIOC_SUBDEV_S_INPUT is added to v4l2, you will just need to send your analog signal to whichever ADV7180 input is active.
Quoted 11 lines
# select any supported YUV or RGB pixelformat on the capture device node v4l2-ctl --device /dev/video3 --set-fmt-video=width=720,height=480,pixelformat=UYVY v4l2-ctl --device /dev/video3 --stream-mmap --stream-to=/x.raw --stream-count=1 # capture single raw-frame [ 904.870444] ipu2_ic_prpvf: EOF timeout VIDIOC_DQBUF: failed: Input/output error [ 905.910702] ipu2_ic_prpvf: wait last EOF timeout ^^^^ not getting any frames
Quoted 2 lines
The last patchset of yours I had running on this board was your v3 patchset - any ideas?
Beyond maybe the input selection issue above, not really, your pipeline config looks correct.
I have a script for the ADV7180 VDIC -> prpvf pipeline on IPU1 for the SabreAuto, I will send to you separately to see if that helps.
Quoted 5 lines
As it looks like things have settled down with this patchset and it sounds like it will get merged for 4.13 I'm going to start working on a driver for the tda1997x HDMI receiver which is also on this board connected to
IPU1_CSI0.
Awesome, thanks.
Steve