Skip to contentSkip to conversation

i.MX6 Video capture

PATCH In review Steve Longerbeam 7 participants 79 messages Jun 7, 2014 – Jan 17, 2015

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover i.MX6 Video capture

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

Usage notes are found in Documentation/video4linux/mx6_camera.txt for the above three reference platforms.

The driver source is under drivers/staging/media/imx6/capture/.

Steve Longerbeam (43):
imx-drm: ipu-v3: Move imx-ipu-v3.h to include/linux/platform_data/
ARM: dts: imx6qdl: Add ipu aliases
imx-drm: ipu-v3: Add ipu_get_num()
imx-drm: ipu-v3: Add solo/dual-lite IPU device type
imx-drm: ipu-v3: Map IOMUXC registers
imx-drm: ipu-v3: Add functions to set CSI/IC source muxes
imx-drm: ipu-v3: Rename and add IDMAC channels
imx-drm: ipu-v3: Add units required for video capture
imx-drm: ipu-v3: Add ipu_mbus_code_to_colorspace()
imx-drm: ipu-v3: Add rotation mode conversion utilities
imx-drm: ipu-v3: Add helper function checking if pixfmt is planar
imx-drm: ipu-v3: Move IDMAC channel names to imx-ipu-v3.h
imx-drm: ipu-v3: Add ipu_idmac_buffer_is_ready()
imx-drm: ipu-v3: Add ipu_idmac_clear_buffer()
imx-drm: ipu-v3: Add ipu_idmac_current_buffer()
imx-drm: ipu-v3: Add __ipu_idmac_reset_current_buffer()
imx-drm: ipu-v3: Add ipu_stride_to_bytes()
imx-drm: ipu-v3: Add ipu_idmac_enable_watermark()
imx-drm: ipu-v3: Add ipu_idmac_lock_enable()
imx-drm: ipu-v3: Add idmac channel linking support
imx-drm: ipu-v3: Add ipu_bits_per_pixel()
imx-drm: ipu-v3: Add ipu-cpmem unit
imx-drm: ipu-cpmem: Add ipu_cpmem_set_block_mode()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_axi_id()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_rotation()
imx-drm: ipu-cpmem: Add second buffer support to ipu_cpmem_set_image()
imx-drm: ipu-v3: Add more planar formats support
imx-drm: ipu-cpmem: Add ipu_cpmem_dump()
imx-drm: ipu-v3: Add ipu_dump()
ARM: dts: imx6: add pin groups for imx6q/dl for IPU1 CSI0
ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node
ARM: dts: imx: sabrelite: add video capture ports and endpoints
ARM: dts: imx6-sabresd: add video capture ports and endpoints
ARM: dts: imx6-sabreauto: add video capture ports and endpoints
ARM: dts: imx6qdl: Add simple-bus to ipu compatibility
gpio: pca953x: Add reset-gpios property
ARM: imx6q: clk: Add video 27m clock
media: imx6: Add device tree binding documentation
media: Add new camera interface driver for i.MX6
media: imx6: Add support for MIPI CSI-2 OV5640
media: imx6: Add support for Parallel OV5642
media: imx6: Add support for ADV7180 Video Decoder
ARM: imx_v6_v7_defconfig: Enable video4linux drivers

 .../devicetree/bindings/clock/imx6q-clock.txt      |    1 +
 Documentation/devicetree/bindings/media/imx6.txt   |  433 ++
 .../bindings/staging/imx-drm/fsl-imx-drm.txt       |    6 +-
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 Documentation/video4linux/mx6_camera.txt           |  188 +
 arch/arm/boot/dts/imx6q.dtsi                       |    3 +-
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |  149 +
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi           |   91 +
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |  116 +
 arch/arm/boot/dts/imx6qdl.dtsi                     |   62 +-
 arch/arm/configs/imx_v6_v7_defconfig               |    4 +
 arch/arm/mach-imx/clk-imx6q.c                      |    3 +-
 drivers/gpio/gpio-pca953x.c                        |   26 +
 drivers/staging/imx-drm/imx-hdmi.c                 |    2 +-
 drivers/staging/imx-drm/imx-tve.c                  |    2 +-
 drivers/staging/imx-drm/ipu-v3/Makefile            |    3 +-
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h        |  326 --
 drivers/staging/imx-drm/ipu-v3/ipu-common.c        | 1151 ++++--
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c         |  814 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c           |  821 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c          |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dp.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c            |  835 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c           |  103 +
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h           |  126 +-
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c          |  348 ++
 drivers/staging/imx-drm/ipuv3-crtc.c               |    2 +-
 drivers/staging/imx-drm/ipuv3-plane.c              |   18 +-
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/imx6/Kconfig                 |   25 +
 drivers/staging/media/imx6/Makefile                |    1 +
 drivers/staging/media/imx6/capture/Kconfig         |   33 +
 drivers/staging/media/imx6/capture/Makefile        |    7 +
 drivers/staging/media/imx6/capture/adv7180.c       | 1298 ++++++
 drivers/staging/media/imx6/capture/mipi-csi2.c     |  322 ++
 drivers/staging/media/imx6/capture/mx6-camif.c     | 2235 ++++++++++
 drivers/staging/media/imx6/capture/mx6-camif.h     |  197 +
 drivers/staging/media/imx6/capture/mx6-encode.c    |  775 ++++
 drivers/staging/media/imx6/capture/mx6-preview.c   |  748 ++++
 drivers/staging/media/imx6/capture/ov5640-mipi.c   | 2158 ++++++++++
 drivers/staging/media/imx6/capture/ov5642.c        | 4258 ++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h           |  425 ++
 include/media/imx6.h                               |   18 +
 46 files changed, 17340 insertions(+), 805 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/imx6.txt
 create mode 100644 Documentation/video4linux/mx6_camera.txt
 delete mode 100644 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
 create mode 100644 drivers/staging/media/imx6/Kconfig
 create mode 100644 drivers/staging/media/imx6/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/Kconfig
 create mode 100644 drivers/staging/media/imx6/capture/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/adv7180.c
 create mode 100644 drivers/staging/media/imx6/capture/mipi-csi2.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.h
 create mode 100644 drivers/staging/media/imx6/capture/mx6-encode.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-preview.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5640-mipi.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5642.c
 create mode 100644 include/linux/platform_data/imx-ipu-v3.h
 create mode 100644 include/media/imx6.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/43 imx-drm: ipu-v3: Move imx-ipu-v3.h to include/linux/platform_data/

In subsequent patches, the video capture units will be added (csi, smfc, ic, irt). So the IPU prototypes are no longer needed only by imx-drm, so we need to export them to a common include path.

---
 drivers/staging/imx-drm/imx-hdmi.c                 |    2 +-
 drivers/staging/imx-drm/imx-tve.c                  |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-common.c        |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c          |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dp.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h           |    2 +-
 drivers/staging/imx-drm/ipuv3-crtc.c               |    2 +-
 drivers/staging/imx-drm/ipuv3-plane.c              |    2 +-
 .../linux/platform_data}/imx-ipu-v3.h              |    9 +++++----
 11 files changed, 15 insertions(+), 14 deletions(-)
 rename {drivers/staging/imx-drm/ipu-v3 => include/linux/platform_data}/imx-ipu-v3.h (99%)
drivers/staging/imx-drm/imx-hdmi.c +1 -1
index d47dedd..f0710a4 100644
@@ -28,7 +28,7 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_encoder_slave.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "imx-hdmi.h"
 #include "imx-drm.h"
 
drivers/staging/imx-drm/imx-tve.c +1 -1
index a23f4f7..8b91588 100644
@@ -31,7 +31,7 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "imx-drm.h"
 
 #define TVE_COM_CONF_REG	0x00
drivers/staging/imx-drm/ipu-v3/ipu-common.c +1 -1
index ca85d3d..2aca7dd 100644
@@ -31,7 +31,7 @@
 
 #include <drm/drm_fourcc.h>
 
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 static inline u32 ipu_cm_read(struct ipu_soc *ipu, unsigned offset)
drivers/staging/imx-drm/ipu-v3/ipu-dc.c +1 -1
index d5de8bb..e86010b 100644
@@ -21,7 +21,7 @@
 #include <linux/io.h>
 
 #include "../imx-drm.h"
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DC_MAP_CONF_PTR(n)	(0x108 + ((n) & ~0x1) * 2)
drivers/staging/imx-drm/ipu-v3/ipu-di.c +1 -1
index 82a9eba..1e54c00 100644
@@ -20,7 +20,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 struct ipu_di {
drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c +1 -1
index 4521301..3c24111 100644
@@ -17,7 +17,7 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DMFC_RD_CHAN		0x0000
drivers/staging/imx-drm/ipu-v3/ipu-dp.c +1 -1
index 58f87c8..27d9a81 100644
@@ -19,7 +19,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipu-prv.h"
 
 #define DP_SYNC 0
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +1 -1
index 4df0050..40211f6 100644
@@ -22,7 +22,7 @@ struct ipu_soc;
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 
-#include "imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 
 #define IPUV3_CHANNEL_CSI0			 0
 #define IPUV3_CHANNEL_CSI1			 1
drivers/staging/imx-drm/ipuv3-crtc.c +1 -1
index c48f640..9b707aa 100644
@@ -30,7 +30,7 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "imx-drm.h"
 #include "ipuv3-plane.h"
 
drivers/staging/imx-drm/ipuv3-plane.c +1 -1
index 27a8d73..e9e4e7a 100644
@@ -17,7 +17,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 
-#include "ipu-v3/imx-ipu-v3.h"
+#include <linux/platform_data/imx-ipu-v3.h>
 #include "ipuv3-plane.h"
 
 #define to_ipu_plane(x)	container_of(x, struct ipu_plane, base)
include/linux/platform_data/imx-ipu-v3.h renamed from drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h +5 -4
similarity index 99%
rename from drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
rename to include/linux/platform_data/imx-ipu-v3.h
index c4d14ea..c083a2a 100644
@@ -9,8 +9,8 @@
  * http://www.gnu.org/copyleft/lgpl.html
  */
 
-#ifndef __DRM_IPU_H__
-#define __DRM_IPU_H__
+#ifndef __IMX_IPU_H__
+#define __IMX_IPU_H__
 
 #include <linux/types.h>
 #include <linux/videodev2.h>
@@ -230,7 +230,8 @@ struct ipu_ch_param {
 	struct ipu_cpmem_word word[2];
 };
 
-void ipu_ch_param_write_field(struct ipu_ch_param __iomem *base, u32 wbs, u32 v);
+void ipu_ch_param_write_field(struct ipu_ch_param __iomem *base,
+			      u32 wbs, u32 v);
 u32 ipu_ch_param_read_field(struct ipu_ch_param __iomem *base, u32 wbs);
 struct ipu_ch_param __iomem *ipu_get_cpmem(struct ipuv3_channel *channel);
 void ipu_ch_param_dump(struct ipu_ch_param __iomem *p);
@@ -323,4 +324,4 @@ struct ipu_client_platformdata {
 	int dma[2];
 };
 
-#endif /* __DRM_IPU_H__ */
+#endif /* __IMX_IPU_H__ */
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 01/43] imx-drm: ipu-v3: Move imx-ipu-v3.h to include/linux/platform_data/

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 5 lines

In subsequent patches, the video capture units will be added (csi, smfc, ic, irt). So the IPU prototypes are no longer needed only by imx-drm, so we need to export them to a common include path.

I have already moved the header into include/video/imx-ipu-v3.h in 39b9004d1f626b88b775c7655d3f286e135dfec6.

regards
Philipp

#3 lore raw

PATCH 2/43 ARM: dts: imx6qdl: Add ipu aliases

In reply to Steve Longerbeam

Add ipu0 (and ipu1 for quad) aliases to ipu1/ipu2 nodes respectively.

---
 arch/arm/boot/dts/imx6q.dtsi   |    1 +
 arch/arm/boot/dts/imx6qdl.dtsi |    1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/imx6q.dtsi +1 -0
index addd3f8..c7544f0 100644
@@ -15,6 +15,7 @@
 / {
 	aliases {
 		spi4 = &ecspi5;
+		ipu1 = &ipu2;
 	};
 
 	cpus {
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
index eca0971..04c978c 100644
@@ -43,6 +43,7 @@
 		spi3 = &ecspi4;
 		usbphy0 = &usbphy1;
 		usbphy1 = &usbphy2;
+		ipu0 = &ipu1;
 	};
 
 	intc: interrupt-controller@00a01000 {
Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH 02/43] ARM: dts: imx6qdl: Add ipu aliases

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 25 lines

Add ipu0 (and ipu1 for quad) aliases to ipu1/ipu2 nodes respectively.

---
 arch/arm/boot/dts/imx6q.dtsi   |    1 +
 arch/arm/boot/dts/imx6qdl.dtsi |    1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/imx6q.dtsi +1 -0
index addd3f8..c7544f0 100644
@@ -15,6 +15,7 @@
 / {
 	aliases {
 		spi4 = &ecspi5;
+		ipu1 = &ipu2;
 	};
 
 	cpus {
arch/arm/boot/dts/imx6qdl.dtsi +0 -0
index eca0971..04c978c 100644

arch/arm/boot/dts/imx6qdl.dtsi line 49

Quoted 7 lines
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
@@ -43,6 +43,7 @@
 		spi3 = &ecspi4;
 		usbphy0 = &usbphy1;
 		usbphy1 = &usbphy2;
+		ipu0 = &ipu1;
 	};
 
 	intc: interrupt-controller@00a01000 {

That could be useful, although I think those aliases are supposed to be in alphabetic order.

regards
Philipp

#5 lore raw

PATCH 3/43 imx-drm: ipu-v3: Add ipu_get_num()

In reply to Steve Longerbeam

Adds of-alias id to ipu_soc and retrieve with ipu_get_num().

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |    8 ++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    1 +
 include/linux/platform_data/imx-ipu-v3.h    |    5 +++++
 3 files changed, 14 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
index 2aca7dd..f8e8c56 100644
@@ -55,6 +55,12 @@ static inline void ipu_idmac_write(struct ipu_soc *ipu, u32 value,
 	writel(value, ipu->idmac_reg + offset);
 }
 
+int ipu_get_num(struct ipu_soc *ipu)
+{
+	return ipu->id;
+}
+EXPORT_SYMBOL_GPL(ipu_get_num);
+
 void ipu_srm_dp_sync_update(struct ipu_soc *ipu)
 {
 	u32 val;
@@ -1104,6 +1110,7 @@ static int ipu_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *of_id =
 			of_match_device(imx_ipu_dt_ids, &pdev->dev);
+	struct device_node *np = pdev->dev.of_node;
 	struct ipu_soc *ipu;
 	struct resource *res;
 	unsigned long ipu_base;
@@ -1132,6 +1139,7 @@ static int ipu_probe(struct platform_device *pdev)
 		ipu->channel[i].ipu = ipu;
 	ipu->devtype = devtype;
 	ipu->ipu_type = devtype->type;
+	ipu->id = of_alias_get_id(np, "ipu");
 
 	spin_lock_init(&ipu->lock);
 	mutex_init(&ipu->channel_lock);
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +1 -0
index 40211f6..9e4cf4b 100644
@@ -164,6 +164,7 @@ struct ipu_soc {
 	void __iomem		*idmac_reg;
 	struct ipu_ch_param __iomem	*cpmem_base;
 
+	int			id;
 	int			usecount;
 
 	struct clk		*clk;
include/linux/platform_data/imx-ipu-v3.h +5 -0
index c083a2a..ca91dd9 100644
@@ -92,6 +92,11 @@ int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
 #define IPU_IRQ_VSYNC_PRE_1		(448 + 15)
 
 /*
+ * IPU Common functions
+ */
+int ipu_get_num(struct ipu_soc *ipu);
+
+/*
  * IPU Image DMA Controller (idmac) functions
  */
 struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned channel);
Signature · 1 line
1.7.9.5
#6 lore raw

Re: [PATCH 03/43] imx-drm: ipu-v3: Add ipu_get_num()

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 1 line

Adds of-alias id to ipu_soc and retrieve with ipu_get_num().

It would be nice to have a comment here what this will be needed for.

I see that later ipu-csi uses this to find the correct input mux and mx6-encode selects the DMA channel depending on this.
I feel like the mux should be handled as a separate v4l2_subdev since it is not part of the IPU, it is different between i.MX6Q and i.MX6DL, and it doesn't even exist on i.MX5.

regards
Philipp

#7 lore raw

PATCH 4/43 imx-drm: ipu-v3: Add solo/dual-lite IPU device type

In reply to Steve Longerbeam
---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   18 ++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 19 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +18 -0
index f8e8c56..2d95a7c 100644
@@ -829,10 +829,28 @@ static struct ipu_devtype ipu_type_imx6q = {
 	.type = IPUV3H,
 };
 
+static struct ipu_devtype ipu_type_imx6dl = {
+	.name = "IPUv3HDL",
+	.cm_ofs = 0x00200000,
+	.cpmem_ofs = 0x00300000,
+	.srm_ofs = 0x00340000,
+	.tpm_ofs = 0x00360000,
+	.csi0_ofs = 0x00230000,
+	.csi1_ofs = 0x00238000,
+	.disp0_ofs = 0x00240000,
+	.disp1_ofs = 0x00248000,
+	.smfc_ofs =  0x00250000,
+	.ic_ofs = 0x00220000,
+	.vdi_ofs = 0x00268000,
+	.dc_tmpl_ofs = 0x00380000,
+	.type = IPUV3HDL,
+};
+
 static const struct of_device_id imx_ipu_dt_ids[] = {
 	{ .compatible = "fsl,imx51-ipu", .data = &ipu_type_imx51, },
 	{ .compatible = "fsl,imx53-ipu", .data = &ipu_type_imx53, },
 	{ .compatible = "fsl,imx6q-ipu", .data = &ipu_type_imx6q, },
+	{ .compatible = "fsl,imx6dl-ipu", .data = &ipu_type_imx6dl, },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, imx_ipu_dt_ids);
include/linux/platform_data/imx-ipu-v3.h +1 -0
index ca91dd9..8050277 100644
@@ -23,6 +23,7 @@ enum ipuv3_type {
 	IPUV3EX,
 	IPUV3M,
 	IPUV3H,
+	IPUV3HDL,
 };
 
 #define IPU_PIX_FMT_GBR24	v4l2_fourcc('G', 'B', 'R', '3')
Signature · 1 line
1.7.9.5
maintainer
#8 lore raw

Re: [PATCH 04/43] imx-drm: ipu-v3: Add solo/dual-lite IPU device type

Hi Steve,

Quoted 20 lines · Steve Longerbeam
---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   18 ++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 19 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +6 -0
index f8e8c56..2d95a7c 100644
@@ -829,10 +829,28 @@ static struct ipu_devtype ipu_type_imx6q = {
 	.type = IPUV3H,
 };
 
+static struct ipu_devtype ipu_type_imx6dl = {
+	.name = "IPUv3HDL",
+	.cm_ofs = 0x00200000,
+	.cpmem_ofs = 0x00300000,
+	.srm_ofs = 0x00340000,
+	.tpm_ofs = 0x00360000,

drivers/staging/imx-drm/ipu-v3/ipu-common.c static struct ipu_devtype ipu_type_imx6q = { · line 847

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+	.csi0_ofs = 0x00230000,
+	.csi1_ofs = 0x00238000,
+	.disp0_ofs = 0x00240000,
+	.disp1_ofs = 0x00248000,
+	.smfc_ofs =  0x00250000,
+	.ic_ofs = 0x00220000,
+	.vdi_ofs = 0x00268000,
+	.dc_tmpl_ofs = 0x00380000,
+	.type = IPUV3HDL,
+};

This breaks bisectibility. This patch must come after

[PATCH 08/43] imx-drm: ipu-v3: Add units required for video capture

Besides, is there any difference between IPUv3HDL and IPUv3H? Can't you reuse it?

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#9 lore raw

Re: [PATCH 04/43] imx-drm: ipu-v3: Add solo/dual-lite IPU device type

In reply to Steve Longerbeam

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 20 lines
---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   18 ++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 19 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +6 -0
index f8e8c56..2d95a7c 100644
@@ -829,10 +829,28 @@ static struct ipu_devtype ipu_type_imx6q = {
 	.type = IPUV3H,
 };
 
+static struct ipu_devtype ipu_type_imx6dl = {
+	.name = "IPUv3HDL",
+	.cm_ofs = 0x00200000,
+	.cpmem_ofs = 0x00300000,
+	.srm_ofs = 0x00340000,
+	.tpm_ofs = 0x00360000,

drivers/staging/imx-drm/ipu-v3/ipu-common.c static struct ipu_devtype ipu_type_imx6q = { · line 847

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+	.csi0_ofs = 0x00230000,
+	.csi1_ofs = 0x00238000,
+	.disp0_ofs = 0x00240000,
+	.disp1_ofs = 0x00248000,
+	.smfc_ofs =  0x00250000,
+	.ic_ofs = 0x00220000,
+	.vdi_ofs = 0x00268000,
+	.dc_tmpl_ofs = 0x00380000,
+	.type = IPUV3HDL,
+};

This just duplicates ipu_type_imx6. Do I understand correctly that this new type was added just to account for the different input multiplexer setup between i.MX6Q and i.MX6DL outside of the IPU?

This would not be necessary if we describe the multiplexers as separate v4l2_subdev entities. The same applies to the following patch 05/43.

regards
Philipp

#10 lore raw

PATCH 5/43 imx-drm: ipu-v3: Map IOMUXC registers

In reply to Steve Longerbeam

Map the IOMUXC registers, which will be needed by ipu-csi for mux control.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |    8 ++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    4 ++++
 2 files changed, 12 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
index 2d95a7c..635dafe 100644
@@ -1196,6 +1196,14 @@ static int ipu_probe(struct platform_device *pdev)
 	if (!ipu->cm_reg || !ipu->idmac_reg || !ipu->cpmem_base)
 		return -ENOMEM;
 
+	ipu->gp_reg = syscon_regmap_lookup_by_compatible(
+		"fsl,imx6q-iomuxc-gpr");
+	if (IS_ERR(ipu->gp_reg)) {
+		ret = PTR_ERR(ipu->gp_reg);
+		dev_err(&pdev->dev, "failed to map iomuxc regs with %d\n", ret);
+		return ret;
+	}
+
 	ipu->clk = devm_clk_get(&pdev->dev, "bus");
 	if (IS_ERR(ipu->clk)) {
 		ret = PTR_ERR(ipu->clk);
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +4 -0
index 9e4cf4b..90c0c50 100644
@@ -21,6 +21,9 @@ struct ipu_soc;
 #include <linux/device.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
 
 #include <linux/platform_data/imx-ipu-v3.h>
 
@@ -163,6 +166,7 @@ struct ipu_soc {
 	void __iomem		*cm_reg;
 	void __iomem		*idmac_reg;
 	struct ipu_ch_param __iomem	*cpmem_base;
+	struct regmap		*gp_reg;
 
 	int			id;
 	int			usecount;
Signature · 1 line
1.7.9.5
#11 lore raw

Re: [PATCH 05/43] imx-drm: ipu-v3: Map IOMUXC registers

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 15 lines

Map the IOMUXC registers, which will be needed by ipu-csi for mux control.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |    8 ++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    4 ++++
 2 files changed, 12 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +0 -0
index 2d95a7c..635dafe 100644
@@ -1196,6 +1196,14 @@ static int ipu_probe(struct platform_device *pdev)
 	if (!ipu->cm_reg || !ipu->idmac_reg || !ipu->cpmem_base)

drivers/staging/imx-drm/ipu-v3/ipu-common.c static int ipu_probe(struct platform_device *pdev) · line 1206

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
 		return -ENOMEM;
 
+	ipu->gp_reg = syscon_regmap_lookup_by_compatible(
+		"fsl,imx6q-iomuxc-gpr");
+	if (IS_ERR(ipu->gp_reg)) {
+		ret = PTR_ERR(ipu->gp_reg);
+		dev_err(&pdev->dev, "failed to map iomuxc regs with %d\n", ret);
+		return ret;
+	}
+

This will break i.MX5. The IPU core driver shouldn't touch those registers anyway.

regards
Philipp

#12 lore raw

PATCH 6/43 imx-drm: ipu-v3: Add functions to set CSI/IC source muxes

In reply to Steve Longerbeam

Adds two new functions, ipu_set_csi_src_mux() and ipu_set_ic_src_mux(), that select the inputs to the CSI and IC respectively. Both muxes are programmed in the IPU_CONF register.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   51 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    3 ++
 2 files changed, 54 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +51 -0
index 635dafe..1c606b5 100644
@@ -777,6 +777,57 @@ static int ipu_memory_reset(struct ipu_soc *ipu)
 	return 0;
 }
 
+/*
+ * Set the source mux for the given CSI. Selects either parallel or
+ * MIPI CSI2 sources. This is not exported because it is used only
+ * by ipu.
+ */
+void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2)
+{
+	unsigned long flags;
+	u32 val, mask;
+
+	mask = (csi_id == 1) ? IPU_CONF_CSI1_DATA_SOURCE :
+		IPU_CONF_CSI0_DATA_SOURCE;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	val = ipu_cm_read(ipu, IPU_CONF);
+	if (mipi_csi2)
+		val |= mask;
+	else
+		val &= ~mask;
+	ipu_cm_write(ipu, val, IPU_CONF);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+}
+
+/*
+ * Set the source mux for the IC. Selects either CSI[01] or the VDI.
+ * This is not exported because it is used only by ipu.
+ */
+void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi)
+{
+	unsigned long flags;
+	u32 val;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	val = ipu_cm_read(ipu, IPU_CONF);
+	if (vdi) {
+		val |= IPU_CONF_IC_INPUT;
+	} else {
+		val &= ~IPU_CONF_IC_INPUT;
+		if (csi_id == 1)
+			val |= IPU_CONF_CSI_SEL;
+		else
+			val &= ~IPU_CONF_CSI_SEL;
+	}
+	ipu_cm_write(ipu, val, IPU_CONF);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+}
+
 struct ipu_devtype {
 	const char *name;
 	unsigned long cm_ofs;
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +3 -0
index 90c0c50..69d99b0 100644
@@ -190,6 +190,9 @@ void ipu_srm_dp_sync_update(struct ipu_soc *ipu);
 int ipu_module_enable(struct ipu_soc *ipu, u32 mask);
 int ipu_module_disable(struct ipu_soc *ipu, u32 mask);
 
+void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2);
+void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi);
+
 int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id,
 		unsigned long base, u32 module, struct clk *ipu_clk);
 void ipu_di_exit(struct ipu_soc *ipu, int id);
Signature · 1 line
1.7.9.5
Acked-by on v1 6/43
#13 lore raw

Re: [PATCH 06/43] imx-drm: ipu-v3: Add functions to set CSI/IC source muxes

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 5 lines

Adds two new functions, ipu_set_csi_src_mux() and ipu_set_ic_src_mux(), that select the inputs to the CSI and IC respectively. Both muxes are programmed in the IPU_CONF register.

regards
Philipp

#14 lore raw

PATCH 7/43 imx-drm: ipu-v3: Rename and add IDMAC channels

In reply to Steve Longerbeam

Rename the ENC/VF/PP rotation channel names, to be more consistent with the convention that *_MEM is write-to-memory channels and MEM_* is read-from-memory channels. Also add the channels who's source and destination is the IC.

---
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +14 -6
index 69d99b0..1398752 100644
@@ -31,17 +31,25 @@ struct ipu_soc;
 #define IPUV3_CHANNEL_CSI1			 1
 #define IPUV3_CHANNEL_CSI2			 2
 #define IPUV3_CHANNEL_CSI3			 3
+#define IPUV3_CHANNEL_VDI_MEM_IC_VF              5
+#define IPUV3_CHANNEL_MEM_IC_PP                 11
+#define IPUV3_CHANNEL_MEM_IC_PRP_VF             12
+#define IPUV3_CHANNEL_G_MEM_IC_PRP_VF           14
+#define IPUV3_CHANNEL_G_MEM_IC_PP               15
+#define IPUV3_CHANNEL_IC_PRP_ENC_MEM            20
+#define IPUV3_CHANNEL_IC_PRP_VF_MEM             21
+#define IPUV3_CHANNEL_IC_PP_MEM                 22
 #define IPUV3_CHANNEL_MEM_BG_SYNC		23
 #define IPUV3_CHANNEL_MEM_FG_SYNC		27
 #define IPUV3_CHANNEL_MEM_DC_SYNC		28
 #define IPUV3_CHANNEL_MEM_FG_SYNC_ALPHA		31
 #define IPUV3_CHANNEL_MEM_DC_ASYNC		41
-#define IPUV3_CHANNEL_ROT_ENC_MEM		45
-#define IPUV3_CHANNEL_ROT_VF_MEM		46
-#define IPUV3_CHANNEL_ROT_PP_MEM		47
-#define IPUV3_CHANNEL_ROT_ENC_MEM_OUT		48
-#define IPUV3_CHANNEL_ROT_VF_MEM_OUT		49
-#define IPUV3_CHANNEL_ROT_PP_MEM_OUT		50
+#define IPUV3_CHANNEL_MEM_ROT_ENC		45
+#define IPUV3_CHANNEL_MEM_ROT_VF		46
+#define IPUV3_CHANNEL_MEM_ROT_PP		47
+#define IPUV3_CHANNEL_ROT_ENC_MEM		48
+#define IPUV3_CHANNEL_ROT_VF_MEM		49
+#define IPUV3_CHANNEL_ROT_PP_MEM		50
 #define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA		51
 
 #define IPU_MCU_T_DEFAULT	8
Signature · 1 line
1.7.9.5
Acked-by on v1 7/43
#15 lore raw

Re: [PATCH 07/43] imx-drm: ipu-v3: Rename and add IDMAC channels

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 6 lines

Rename the ENC/VF/PP rotation channel names, to be more consistent with the convention that *_MEM is write-to-memory channels and MEM_* is read-from-memory channels. Also add the channels who's source and destination is the IC.

Looks good to me,

regards
Philipp

#16 lore raw

PATCH 8/43 imx-drm: ipu-v3: Add units required for video capture

In reply to Steve Longerbeam

Adds the following new IPU units:

- Camera Sensor Interface (csi)
- Sensor Multi FIFO Controller (smfc)
- Image Converter (ic)
- Image Rotator (irt)

---
 drivers/staging/imx-drm/ipu-v3/Makefile     |    3 +-
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   67 ++-
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c    |  821 ++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c     |  835 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c    |  103 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |   24 +
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c   |  348 +++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |  151 +++++
 8 files changed, 2350 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
drivers/staging/imx-drm/ipu-v3/Makefile +2 -1
index 28ed72e..79c0c88 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o
+imx-ipu-v3-objs := ipu-common.o ipu-csi.o ipu-dc.o ipu-di.o \
+	ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-irt.o ipu-smfc.o
drivers/staging/imx-drm/ipu-v3/ipu-common.c +66 -1

106 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-csi.c new file +821 -0

821 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-ic.c new file +835 -0

835 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-irt.c new file +103 -0

103 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-prv.h +24 -0
index 1398752..211d6f2 100644
@@ -163,6 +163,10 @@ struct ipu_dc_priv;
 struct ipu_dmfc_priv;
 struct ipu_di;
 struct ipu_devtype;
+struct ipu_csi;
+struct ipu_smfc;
+struct ipu_ic_priv;
+struct ipu_irt;
 
 struct ipu_soc {
 	struct device		*dev;
@@ -191,6 +195,10 @@ struct ipu_soc {
 	struct ipu_dp_priv	*dp_priv;
 	struct ipu_dmfc_priv	*dmfc_priv;
 	struct ipu_di		*di_priv[2];
+	struct ipu_csi		*csi_priv[2];
+	struct ipu_smfc		*smfc_priv;
+	struct ipu_ic_priv	*ic_priv;
+	struct ipu_irt		*irt_priv;
 };
 
 void ipu_srm_dp_sync_update(struct ipu_soc *ipu);
@@ -201,6 +209,22 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask);
 void ipu_set_csi_src_mux(struct ipu_soc *ipu, int csi_id, bool mipi_csi2);
 void ipu_set_ic_src_mux(struct ipu_soc *ipu, int csi_id, bool vdi);
 
+int ipu_csi_init(struct ipu_soc *ipu, struct device *dev, int id,
+		 unsigned long base, u32 module, struct clk *clk_ipu);
+void ipu_csi_exit(struct ipu_soc *ipu, int id);
+
+int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev,
+		  unsigned long base, u32 module);
+void ipu_smfc_exit(struct ipu_soc *ipu);
+
+int ipu_ic_init(struct ipu_soc *ipu, struct device *dev,
+		unsigned long base, unsigned long tpmem_base,
+		u32 module);
+void ipu_ic_exit(struct ipu_soc *ipu);
+
+int ipu_irt_init(struct ipu_soc *ipu, struct device *dev, u32 module);
+void ipu_irt_exit(struct ipu_soc *ipu);
+
 int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id,
 		unsigned long base, u32 module, struct clk *ipu_clk);
 void ipu_di_exit(struct ipu_soc *ipu, int id);
drivers/staging/imx-drm/ipu-v3/ipu-smfc.c new file +348 -0

348 lines not on this page · raw message

include/linux/platform_data/imx-ipu-v3.h +151 -0

163 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#17 lore raw

Re: [PATCH 08/43] imx-drm: ipu-v3: Add units required for video capture

Quoted 62 lines · Steve Longerbeam

Adds the following new IPU units:

- Camera Sensor Interface (csi)
- Sensor Multi FIFO Controller (smfc)
- Image Converter (ic)
- Image Rotator (irt)

---
 drivers/staging/imx-drm/ipu-v3/Makefile     |    3 +-
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   67 ++-
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c    |  821 ++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c     |  835 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c    |  103 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |   24 +
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c   |  348 +++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |  151 +++++
 8 files changed, 2350 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
drivers/staging/imx-drm/ipu-v3/Makefile +2 -1
index 28ed72e..79c0c88 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o
+imx-ipu-v3-objs := ipu-common.o ipu-csi.o ipu-dc.o ipu-di.o \
+	ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-irt.o ipu-smfc.o
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
index 1c606b5..3d7e28d 100644
@@ -834,6 +834,10 @@ struct ipu_devtype {
 	unsigned long cpmem_ofs;
 	unsigned long srm_ofs;
 	unsigned long tpm_ofs;
+	unsigned long csi0_ofs;
+	unsigned long csi1_ofs;
+	unsigned long smfc_ofs;
+	unsigned long ic_ofs;
 	unsigned long disp0_ofs;
 	unsigned long disp1_ofs;
 	unsigned long dc_tmpl_ofs;
@@ -873,8 +877,12 @@ static struct ipu_devtype ipu_type_imx6q = {
 	.cpmem_ofs = 0x00300000,
 	.srm_ofs = 0x00340000,
 	.tpm_ofs = 0x00360000,
+	.csi0_ofs = 0x00230000,
+	.csi1_ofs = 0x00238000,
 	.disp0_ofs = 0x00240000,
 	.disp1_ofs = 0x00248000,
+	.smfc_ofs =  0x00250000,
+	.ic_ofs = 0x00220000,
 	.dc_tmpl_ofs = 0x00380000,
 	.vdi_ofs = 0x00268000,
 	.type = IPUV3H,

drivers/staging/imx-drm/ipu-v3/ipu-common.c static int ipu_submodules_init(struct ipu_soc *ipu, · line 931

Quoted 9 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +6 -0
@@ -915,8 +923,44 @@ static int ipu_submodules_init(struct ipu_soc *ipu,
 	struct device *dev = &pdev->dev;
 	const struct ipu_devtype *devtype = ipu->devtype;
 
+	ret = ipu_csi_init(ipu, dev, 0, ipu_base + devtype->csi0_ofs,
+			   IPU_CONF_CSI0_EN, ipu_clk);
+	if (ret) {
+		unit = "csi0";
+		goto err_csi_0;
+	}

Please be nice to other SoCs. You set csi0_ofs for i.MX6, but not for i.MX5. For i.MX5 you silently initialize the CSI with bogus register offsets. Either test for _ofs == 0 before initializing it or add the correct values for i.MX51/53 (preferred).

Quoted 35 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +35 -0
+int ipu_csi_set_src(struct ipu_csi *csi, u32 vc, bool select_mipi_csi2)
+{
+	struct ipu_soc *ipu = csi->ipu;
+	int ipu_id = ipu_get_num(ipu);
+	u32 val, bit;
+
+	/*
+	 * Set the muxes that choose between mipi-csi2 and parallel inputs
+	 * to the CSI's.
+	 */
+	if (csi->ipu->ipu_type == IPUV3HDL) {
+		/*
+		 * On D/L, the mux is in GPR13. The TRM is unclear,
+		 * but it appears the mux allows selecting the MIPI
+		 * CSI-2 virtual channel number to route to the CSIs.
+		 */
+		bit = GPR13_IPUV3HDL_CSI_MUX_CTL_SHIFT + csi->id * 3;
+		val = select_mipi_csi2 ? vc << bit : 4 << bit;
+		regmap_update_bits(ipu->gp_reg, IOMUXC_GPR13,
+				   0x7 << bit, val);
+	} else if (csi->ipu->ipu_type == IPUV3H) {
+		/*
+		 * For Q/D, the mux only exists on IPU0-CSI0 and IPU1-CSI1,
+		 * and the routed virtual channel numbers are fixed at 0 and
+		 * 3 respectively.
+		 */
+		if ((ipu_id == 0 && csi->id == 0) ||
+		    (ipu_id == 1 && csi->id == 1)) {
+			bit = GPR1_IPU_CSI_MUX_CTL_SHIFT + csi->ipu->id;
+			val = select_mipi_csi2 ? 0 : 1 << bit;
+			regmap_update_bits(ipu->gp_reg, IOMUXC_GPR1,
+					   0x1 << bit, val);
+		}
+	} else {
+		dev_err(csi->ipu->dev,

drivers/staging/imx-drm/ipu-v3/ipu-common.c static int ipu_submodules_init(struct ipu_soc *ipu,

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+			"ERROR: %s: unsupported CPU version!\n",
+			__func__);
+		return -EINVAL;
+	}
+
+	/*
+	 * there is another mux in the IPU config register that
+	 * must be set as well
+	 */
+	ipu_set_csi_src_mux(ipu, csi->id, select_mipi_csi2);

This is not a property of the IPU but how the IPU is integrated into the SoC. I'm unsure this should be integrated like this, it sounds more like a job for mediactrl.

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 12 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +12 -0
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/spinlock.h>
+#include <linux/videodev2.h>
+#include <linux/bitrev.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>

Please clean up the include list. There is nothing used from clk-provider.h for example.

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 8 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
+static int init_csc(struct ipu_ic *ic,
+		    enum ipu_color_space in_format,
+		    enum ipu_color_space out_format,
+		    int csc_index);
+static int calc_resize_coeffs(struct ipu_ic *ic,
+			      u32 in_size, u32 out_size,
+			      u32 *resize_coeff,
+			      u32 *downsize_coeff);

Please reorder functions to get rid of static function declarations.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#18 lore raw

Re: [PATCH 08/43] imx-drm: ipu-v3: Add units required for video capture

In reply to Steve Longerbeam

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 8 lines

Adds the following new IPU units:

- Camera Sensor Interface (csi)
- Sensor Multi FIFO Controller (smfc)
- Image Converter (ic)
- Image Rotator (irt)

Quoted 9 lines
---
 drivers/staging/imx-drm/ipu-v3/Makefile     |    3 +-
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   67 ++-
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c    |  821 ++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c     |  835 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c    |  103 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |   24 +
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c   |  348 +++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |  151 +++++

You are broadening the internal API quite a bit. For the IC and IRT that certainly can't be helped, but the CSI could very well be completely encapsulated in a v4l2_subdev. I wonder if it wouldn't be better to move the CSI code into the drivers/media part.

Quoted 34 lines
 8 files changed, 2350 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
drivers/staging/imx-drm/ipu-v3/Makefile +2 -1
index 28ed72e..79c0c88 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o
+imx-ipu-v3-objs := ipu-common.o ipu-csi.o ipu-dc.o ipu-di.o \
+	ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-irt.o ipu-smfc.o
drivers/staging/imx-drm/ipu-v3/ipu-common.c +4 -0
index 1c606b5..3d7e28d 100644
@@ -834,6 +834,10 @@ struct ipu_devtype {
 	unsigned long cpmem_ofs;
 	unsigned long srm_ofs;
 	unsigned long tpm_ofs;
+	unsigned long csi0_ofs;
+	unsigned long csi1_ofs;
+	unsigned long smfc_ofs;
+	unsigned long ic_ofs;
 	unsigned long disp0_ofs;
 	unsigned long disp1_ofs;
 	unsigned long dc_tmpl_ofs;
@@ -873,8 +877,12 @@ static struct ipu_devtype ipu_type_imx6q = {
 	.cpmem_ofs = 0x00300000,
 	.srm_ofs = 0x00340000,

drivers/staging/imx-drm/ipu-v3/ipu-common.c static struct ipu_devtype ipu_type_imx6q = { · line 888

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +4 -0
 	.tpm_ofs = 0x00360000,
+	.csi0_ofs = 0x00230000,
+	.csi1_ofs = 0x00238000,
 	.disp0_ofs = 0x00240000,
 	.disp1_ofs = 0x00248000,
+	.smfc_ofs =  0x00250000,
+	.ic_ofs = 0x00220000,
 	.dc_tmpl_ofs = 0x00380000,
 	.vdi_ofs = 0x00268000,
 	.type = IPUV3H,

This is missing the initalization for i.MX5.

[...]

Quoted 42 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +42 -0
+#define GPR1_IPU_CSI_MUX_CTL_SHIFT 19
+#define GPR13_IPUV3HDL_CSI_MUX_CTL_SHIFT 0
+
+int ipu_csi_set_src(struct ipu_csi *csi, u32 vc, bool select_mipi_csi2)
+{
+	struct ipu_soc *ipu = csi->ipu;
+	int ipu_id = ipu_get_num(ipu);
+	u32 val, bit;
+
+	/*
+	 * Set the muxes that choose between mipi-csi2 and parallel inputs
+	 * to the CSI's.
+	 */
+	if (csi->ipu->ipu_type == IPUV3HDL) {
+		/*
+		 * On D/L, the mux is in GPR13. The TRM is unclear,
+		 * but it appears the mux allows selecting the MIPI
+		 * CSI-2 virtual channel number to route to the CSIs.
+		 */
+		bit = GPR13_IPUV3HDL_CSI_MUX_CTL_SHIFT + csi->id * 3;
+		val = select_mipi_csi2 ? vc << bit : 4 << bit;
+		regmap_update_bits(ipu->gp_reg, IOMUXC_GPR13,
+				   0x7 << bit, val);
+	} else if (csi->ipu->ipu_type == IPUV3H) {
+		/*
+		 * For Q/D, the mux only exists on IPU0-CSI0 and IPU1-CSI1,
+		 * and the routed virtual channel numbers are fixed at 0 and
+		 * 3 respectively.
+		 */
+		if ((ipu_id == 0 && csi->id == 0) ||
+		    (ipu_id == 1 && csi->id == 1)) {
+			bit = GPR1_IPU_CSI_MUX_CTL_SHIFT + csi->ipu->id;
+			val = select_mipi_csi2 ? 0 : 1 << bit;
+			regmap_update_bits(ipu->gp_reg, IOMUXC_GPR1,
+					   0x1 << bit, val);
+		}
+	} else {
+		dev_err(csi->ipu->dev,
+			"ERROR: %s: unsupported CPU version!\n",
+			__func__);
+		return -EINVAL;
+	}

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+
+	/*
+	 * there is another mux in the IPU config register that
+	 * must be set as well
+	 */
+	ipu_set_csi_src_mux(ipu, csi->id, select_mipi_csi2);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_csi_set_src);

In my opinion, this doesn't belong here. These multiplexers should be separate subdevices described in the device tree.

[...]

Quoted 8 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +8 -0
+int ipu_csi_get_sensor_protocol(struct ipu_csi *csi)
+bool ipu_csi_is_interlaced(struct ipu_csi *csi)
+void ipu_csi_get_window_size(struct ipu_csi *csi, u32 *width, u32 *height)
+void ipu_csi_set_window_size(struct ipu_csi *csi, u32 width, u32 height)
+void ipu_csi_set_window_pos(struct ipu_csi *csi, u32 left, u32 top)
+void ipu_csi_horizontal_downsize_enable(struct ipu_csi *csi)
+void ipu_csi_horizontal_downsize_disable(struct ipu_csi *csi)
+void ipu_csi_vertical_downsize_enable(struct ipu_csi *csi)

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+void ipu_csi_vertical_downsize_disable(struct ipu_csi *csi)
+void ipu_csi_set_test_generator(struct ipu_csi *csi, bool active,
+				u32 r_value, u32 g_value, u32 b_value,
+				u32 pix_clk)
+int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc,
+			      struct ipu_csi_signal_cfg *cfg)
+int ipu_csi_set_skip_isp(struct ipu_csi *csi, u32 skip, u32 max_ratio)
+int ipu_csi_set_skip_smfc(struct ipu_csi *csi, u32 skip,
+			  u32 max_ratio, u32 id)
+int ipu_csi_set_dest(struct ipu_csi *csi, bool ic)

All of these are small wrappers around register access, making them ideal candidates for being inlined if included in the driver using them ...

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 5 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +5 -0
+int ipu_csi_get_num(struct ipu_csi *csi)
+{
+	return csi->id;
+}
+EXPORT_SYMBOL_GPL(ipu_csi_get_num);

... and this could be dropped completely.

[...]

Quoted 33 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +33 -0
+static int init_csc(struct ipu_ic *ic,
+		    enum ipu_color_space in_format,
+		    enum ipu_color_space out_format,
+		    int csc_index)
+{
+	struct ipu_ic_priv *priv = ic->priv;
+	u32 __iomem *base;
+	u32 param;
+
+	base = (u32 __iomem *)
+		(priv->tpmem_base + ic->reg->tpmem_csc[csc_index]);
+
+	if (in_format == IPUV3_COLORSPACE_YUV &&
+	    out_format == IPUV3_COLORSPACE_RGB) {
+		/* Init CSC (YCbCr->RGB) */
+		param = (ycbcr2rgb_coeff[3][0] << 27) |
+			(ycbcr2rgb_coeff[0][0] << 18) |
+			(ycbcr2rgb_coeff[1][1] << 9) |
+			ycbcr2rgb_coeff[2][2];
+		writel(param, base++);
+
+		/* scale = 2, sat = 0 */
+		param = (ycbcr2rgb_coeff[3][0] >> 5) |
+			(2L << (40 - 32));
+		writel(param, base++);
+
+		param = (ycbcr2rgb_coeff[3][1] << 27) |
+			(ycbcr2rgb_coeff[0][1] << 18) |
+			(ycbcr2rgb_coeff[1][0] << 9) |
+			ycbcr2rgb_coeff[2][0];
+		writel(param, base++);
+
+		param = (ycbcr2rgb_coeff[3][1] >> 5);

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+		writel(param, base++);
+
+		param = (ycbcr2rgb_coeff[3][2] << 27) |
+			(ycbcr2rgb_coeff[0][2] << 18) |
+			(ycbcr2rgb_coeff[1][2] << 9) |
+			ycbcr2rgb_coeff[2][1];
+		writel(param, base++);
+
+		param = (ycbcr2rgb_coeff[3][2] >> 5);
+		writel(param, base++);

This should be split out into a helper function ...

Quoted 20 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +20 -0
+	} else if (in_format == IPUV3_COLORSPACE_RGB &&
+		   out_format == IPUV3_COLORSPACE_YUV) {
+		/* Init CSC (RGB->YCbCr) */
+		param = (rgb2ycbcr_coeff[3][0] << 27) |
+			(rgb2ycbcr_coeff[0][0] << 18) |
+			(rgb2ycbcr_coeff[1][1] << 9) |
+			rgb2ycbcr_coeff[2][2];
+		writel(param, base++);
+
+		/* scale = 1, sat = 0 */
+		param = (rgb2ycbcr_coeff[3][0] >> 5) | (1UL << 8);
+		writel(param, base++);
+
+		param = (rgb2ycbcr_coeff[3][1] << 27) |
+			(rgb2ycbcr_coeff[0][1] << 18) |
+			(rgb2ycbcr_coeff[1][0] << 9) |
+			rgb2ycbcr_coeff[2][0];
+		writel(param, base++);
+
+		param = (rgb2ycbcr_coeff[3][1] >> 5);

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+		writel(param, base++);
+
+		param = (rgb2ycbcr_coeff[3][2] << 27) |
+			(rgb2ycbcr_coeff[0][2] << 18) |
+			(rgb2ycbcr_coeff[1][2] << 9) |
+			rgb2ycbcr_coeff[2][1];
+		writel(param, base++);
+
+		param = (rgb2ycbcr_coeff[3][2] >> 5);
+		writel(param, base++);

... and be reused here ...

Quoted 20 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +20 -0
+	} else if (in_format == IPUV3_COLORSPACE_RGB &&
+		   out_format == IPUV3_COLORSPACE_RGB) {
+		/* Init CSC */
+		param = (rgb2rgb_coeff[3][0] << 27) |
+			(rgb2rgb_coeff[0][0] << 18) |
+			(rgb2rgb_coeff[1][1] << 9) |
+			rgb2rgb_coeff[2][2];
+		writel(param, base++);
+
+		/* scale = 2, sat = 0 */
+		param = (rgb2rgb_coeff[3][0] >> 5) | (2UL << 8);
+		writel(param, base++);
+
+		param = (rgb2rgb_coeff[3][1] << 27) |
+			(rgb2rgb_coeff[0][1] << 18) |
+			(rgb2rgb_coeff[1][0] << 9) |
+			rgb2rgb_coeff[2][0];
+		writel(param, base++);
+
+		param = (rgb2rgb_coeff[3][1] >> 5);

drivers/staging/imx-drm/ipu-v3/ipu-common.c

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+		writel(param, base++);
+
+		param = (rgb2rgb_coeff[3][2] << 27) |
+			(rgb2rgb_coeff[0][2] << 18) |
+			(rgb2rgb_coeff[1][2] << 9) |
+			rgb2rgb_coeff[2][1];
+		writel(param, base++);
+
+		param = (rgb2rgb_coeff[3][2] >> 5);
+		writel(param, base++);

... and here.

Quoted 7 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +7 -0
+	} else {
+		dev_err(priv->ipu->dev, "Unsupported color space conversion\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}

[...]

drivers/staging/imx-drm/ipu-v3/ipu-irt.c

Quoted 1 line
drivers/staging/imx-drm/ipu-v3/ipu-irt.c +0 -0

This whole file just contains a use count and and module enable/disable wrappers. I believe this is simple enough to be included in ipu-common.

[...]

drivers/staging/imx-drm/ipu-v3/ipu-smfc.c

Quoted 1 line
drivers/staging/imx-drm/ipu-v3/ipu-smfc.c +0 -0

This is mostly included in drm-next already. It would be great if you could rebase on that.

regards
Philipp

#19 lore raw

PATCH 9/43 imx-drm: ipu-v3: Add ipu_mbus_code_to_colorspace()

In reply to Steve Longerbeam

Add ipu_mbus_code_to_colorspace() to find ipu_color_space from a media bus pixel format code.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   13 +++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 14 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +13 -0
index 3d7e28d..9c29e19 100644
@@ -551,6 +551,19 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 }
 EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
 
+enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
+{
+	switch (mbus_code & 0xf000) {
+	case 0x1000:
+		return IPUV3_COLORSPACE_RGB;
+	case 0x2000:
+		return IPUV3_COLORSPACE_YUV;
+	default:
+		return IPUV3_COLORSPACE_UNKNOWN;
+	}
+}
+EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
+
 struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
 {
 	struct ipuv3_channel *channel;
include/linux/platform_data/imx-ipu-v3.h +1 -0
index b4bc549..21226a2 100644
@@ -466,6 +466,7 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
 
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
+enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
 
 static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p,
 		int burstsize)
Signature · 1 line
1.7.9.5
#20 lore raw

PATCH 10/43 imx-drm: ipu-v3: Add rotation mode conversion utilities

In reply to Steve Longerbeam

Add two functions:

- ipu_degrees_to_rot_mode(): converts a degrees, hflip, and vflip setting to an IPU rotation mode.
- ipu_rot_mode_to_degrees(): converts an IPU rotation mode with given hflip and vflip settings to degrees.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   64 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    4 ++
 2 files changed, 68 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +64 -0
index 9c29e19..02577cc 100644
@@ -564,6 +564,70 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
 }
 EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
 
+int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
+			    bool hflip, bool vflip)
+{
+	u32 r90, vf, hf;
+
+	switch (degrees) {
+	case 0:
+		vf = hf = r90 = 0;
+		break;
+	case 90:
+		vf = hf = 0;
+		r90 = 1;
+		break;
+	case 180:
+		vf = hf = 1;
+		r90 = 0;
+		break;
+	case 270:
+		vf = hf = r90 = 1;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	hf ^= (u32)hflip;
+	vf ^= (u32)vflip;
+
+	*mode = (enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_degrees_to_rot_mode);
+
+int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
+			    bool hflip, bool vflip)
+{
+	u32 r90, vf, hf;
+
+	r90 = ((u32)mode >> 2) & 0x1;
+	hf = ((u32)mode >> 1) & 0x1;
+	vf = ((u32)mode >> 0) & 0x1;
+	hf ^= (u32)hflip;
+	vf ^= (u32)vflip;
+
+	switch ((enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf)) {
+	case IPU_ROTATE_NONE:
+		*degrees = 0;
+		break;
+	case IPU_ROTATE_90_RIGHT:
+		*degrees = 90;
+		break;
+	case IPU_ROTATE_180:
+		*degrees = 180;
+		break;
+	case IPU_ROTATE_90_LEFT:
+		*degrees = 270;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees);
+
 struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
 {
 	struct ipuv3_channel *channel;
include/linux/platform_data/imx-ipu-v3.h +4 -0
index 21226a2..ffcfe20 100644
@@ -467,6 +467,10 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
+int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
+			    bool hflip, bool vflip);
+int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
+			    bool hflip, bool vflip);
 
 static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p,
 		int burstsize)
Signature · 1 line
1.7.9.5
#21 lore raw

PATCH 11/43 imx-drm: ipu-v3: Add helper function checking if pixfmt is planar

In reply to Steve Longerbeam

Add simple helper function returning true if passed pixel format is one of supported planar ones.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   12 ++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 13 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +12 -0
index 02577cc..d005ed5 100644
@@ -551,6 +551,18 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 }
 EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
 
+bool ipu_pixelformat_is_planar(u32 pixelformat)
+{
+	switch (pixelformat) {
+	case V4L2_PIX_FMT_YUV420:
+	case V4L2_PIX_FMT_YVU420:
+		return true;
+	}
+
+	return false;
+}
+EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar);
+
 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
 {
 	switch (mbus_code & 0xf000) {
include/linux/platform_data/imx-ipu-v3.h +1 -0
index ffcfe20..dcf2c57 100644
@@ -467,6 +467,7 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
+bool ipu_pixelformat_is_planar(u32 pixelformat);
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
 			    bool hflip, bool vflip);
 int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
Signature · 1 line
1.7.9.5
#22 lore raw

PATCH 12/43 imx-drm: ipu-v3: Move IDMAC channel names to imx-ipu-v3.h

In reply to Steve Longerbeam

Move the IDMAC channel names to imx-ipu-v3.h, to make the names available outside IPU. Add a couple new channels in the process (async display BG/FG, channels 24 and 29).

---
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h |   25 -------------------------
 include/linux/platform_data/imx-ipu-v3.h |   30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 25 deletions(-)
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +0 -25
index 211d6f2..104e296 100644
@@ -27,31 +27,6 @@ struct ipu_soc;
 
 #include <linux/platform_data/imx-ipu-v3.h>
 
-#define IPUV3_CHANNEL_CSI0			 0
-#define IPUV3_CHANNEL_CSI1			 1
-#define IPUV3_CHANNEL_CSI2			 2
-#define IPUV3_CHANNEL_CSI3			 3
-#define IPUV3_CHANNEL_VDI_MEM_IC_VF              5
-#define IPUV3_CHANNEL_MEM_IC_PP                 11
-#define IPUV3_CHANNEL_MEM_IC_PRP_VF             12
-#define IPUV3_CHANNEL_G_MEM_IC_PRP_VF           14
-#define IPUV3_CHANNEL_G_MEM_IC_PP               15
-#define IPUV3_CHANNEL_IC_PRP_ENC_MEM            20
-#define IPUV3_CHANNEL_IC_PRP_VF_MEM             21
-#define IPUV3_CHANNEL_IC_PP_MEM                 22
-#define IPUV3_CHANNEL_MEM_BG_SYNC		23
-#define IPUV3_CHANNEL_MEM_FG_SYNC		27
-#define IPUV3_CHANNEL_MEM_DC_SYNC		28
-#define IPUV3_CHANNEL_MEM_FG_SYNC_ALPHA		31
-#define IPUV3_CHANNEL_MEM_DC_ASYNC		41
-#define IPUV3_CHANNEL_MEM_ROT_ENC		45
-#define IPUV3_CHANNEL_MEM_ROT_VF		46
-#define IPUV3_CHANNEL_MEM_ROT_PP		47
-#define IPUV3_CHANNEL_ROT_ENC_MEM		48
-#define IPUV3_CHANNEL_ROT_VF_MEM		49
-#define IPUV3_CHANNEL_ROT_PP_MEM		50
-#define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA		51
-
 #define IPU_MCU_T_DEFAULT	8
 #define IPU_CM_IDMAC_REG_OFS	0x00008000
 #define IPU_CM_IC_REG_OFS	0x00020000
include/linux/platform_data/imx-ipu-v3.h +30 -0
index dcf2c57..65ff5ce 100644
@@ -136,6 +136,36 @@ enum ipu_channel_irq {
 	IPU_IRQ_EOS = 192,
 };
 
+/*
+ * Enumeration of IDMAC channels
+ */
+#define IPUV3_CHANNEL_CSI0			 0
+#define IPUV3_CHANNEL_CSI1			 1
+#define IPUV3_CHANNEL_CSI2			 2
+#define IPUV3_CHANNEL_CSI3			 3
+#define IPUV3_CHANNEL_VDI_MEM_IC_VF              5
+#define IPUV3_CHANNEL_MEM_IC_PP                 11
+#define IPUV3_CHANNEL_MEM_IC_PRP_VF             12
+#define IPUV3_CHANNEL_G_MEM_IC_PRP_VF           14
+#define IPUV3_CHANNEL_G_MEM_IC_PP               15
+#define IPUV3_CHANNEL_IC_PRP_ENC_MEM            20
+#define IPUV3_CHANNEL_IC_PRP_VF_MEM             21
+#define IPUV3_CHANNEL_IC_PP_MEM                 22
+#define IPUV3_CHANNEL_MEM_BG_SYNC		23
+#define IPUV3_CHANNEL_MEM_BG_ASYNC		24
+#define IPUV3_CHANNEL_MEM_FG_SYNC		27
+#define IPUV3_CHANNEL_MEM_DC_SYNC		28
+#define IPUV3_CHANNEL_MEM_FG_ASYNC		29
+#define IPUV3_CHANNEL_MEM_FG_SYNC_ALPHA		31
+#define IPUV3_CHANNEL_MEM_DC_ASYNC		41
+#define IPUV3_CHANNEL_MEM_ROT_ENC		45
+#define IPUV3_CHANNEL_MEM_ROT_VF		46
+#define IPUV3_CHANNEL_MEM_ROT_PP		47
+#define IPUV3_CHANNEL_ROT_ENC_MEM		48
+#define IPUV3_CHANNEL_ROT_VF_MEM		49
+#define IPUV3_CHANNEL_ROT_PP_MEM		50
+#define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA		51
+
 int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
 		enum ipu_channel_irq irq);
 
Signature · 1 line
1.7.9.5
#23 lore raw

PATCH 13/43 imx-drm: ipu-v3: Add ipu_idmac_buffer_is_ready()

In reply to Steve Longerbeam

Add ipu_idmac_buffer_is_ready(), returns true if the given buffer in the given channel is set ready (owned by IPU), or false if not ready (owned by CPU core).

Support has been added for third buffer, there is no support yet for triple-buffering in idmac channels, but this function checks buffer-ready for third buffer in case this support is added later.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   26 +++++++++++++++++++++++++-
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    1 +
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +25 -1
index d005ed5..3ff55da 100644
@@ -682,7 +682,7 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_put);
 
-#define idma_mask(ch)			(1 << (ch & 0x1f))
+#define idma_mask(ch)			(1 << ((ch) & 0x1f))
 
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer)
@@ -756,6 +756,30 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask)
 }
 EXPORT_SYMBOL_GPL(ipu_module_disable);
 
+bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned long flags;
+	u32 reg = 0;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+	switch (buf_num) {
+	case 0:
+		reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(channel->num));
+		break;
+	case 1:
+		reg = ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(channel->num));
+		break;
+	case 2:
+		reg = ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(channel->num));
+		break;
+	}
+	spin_unlock_irqrestore(&ipu->lock, flags);
+
+	return ((reg & idma_mask(channel->num)) != 0);
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_buffer_is_ready);
+
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
 {
 	struct ipu_soc *ipu = channel->ipu;
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +1 -0
index 104e296..43ac6c3 100644
@@ -71,6 +71,7 @@ struct ipu_soc;
 #define IPU_DISP_TASK_STAT		IPU_CM_REG(0x0254)
 #define IPU_CHA_BUF0_RDY(ch)		IPU_CM_REG(0x0268 + 4 * ((ch) / 32))
 #define IPU_CHA_BUF1_RDY(ch)		IPU_CM_REG(0x0270 + 4 * ((ch) / 32))
+#define IPU_CHA_BUF2_RDY(ch)		IPU_CM_REG(0x0288 + 4 * ((ch) / 32))
 #define IPU_ALT_CHA_BUF0_RDY(ch)	IPU_CM_REG(0x0278 + 4 * ((ch) / 32))
 #define IPU_ALT_CHA_BUF1_RDY(ch)	IPU_CM_REG(0x0280 + 4 * ((ch) / 32))
 
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 65ff5ce..0128667 100644
@@ -199,6 +199,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer);
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
+bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
 
 /*
  * IPU Display Controller (dc) functions
Signature · 1 line
1.7.9.5
#24 lore raw

PATCH 14/43 imx-drm: ipu-v3: Add ipu_idmac_clear_buffer()

In reply to Steve Longerbeam

Add the reverse of ipu_idmac_select_buffer(), that is, clear a buffer ready status in a channel.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   28 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 29 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +28 -0
index 3ff55da..fd15eae 100644
@@ -798,6 +798,34 @@ void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_select_buffer);
 
+void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned int chno = channel->num;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	ipu_cm_write(ipu, 0xF0300000, IPU_GPR); /* write one to clear */
+	switch (buf_num) {
+	case 0:
+		ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF0_RDY(chno));
+		break;
+	case 1:
+		ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF1_RDY(chno));
+		break;
+	case 2:
+		ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_BUF2_RDY(chno));
+		break;
+	default:
+		break;
+	}
+	ipu_cm_write(ipu, 0x0, IPU_GPR); /* write one to set */
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_clear_buffer);
+
 int ipu_idmac_enable_channel(struct ipuv3_channel *channel)
 {
 	struct ipu_soc *ipu = channel->ipu;
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 0128667..480c30d 100644
@@ -199,6 +199,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer);
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
+void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num);
 bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
 
 /*
Signature · 1 line
1.7.9.5
#25 lore raw

PATCH 15/43 imx-drm: ipu-v3: Add ipu_idmac_current_buffer()

In reply to Steve Longerbeam

Add ipu_idmac_current_buffer(), returns the currently active buffer number in the given channel.

Checks for third buffer ready in case triple-buffer support is added later.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   27 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |    2 ++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 3 files changed, 30 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +27 -0
index fd15eae..4839893 100644
@@ -683,6 +683,8 @@ void ipu_idmac_put(struct ipuv3_channel *channel)
 EXPORT_SYMBOL_GPL(ipu_idmac_put);
 
 #define idma_mask(ch)			(1 << ((ch) & 0x1f))
+#define tri_cur_buf_mask(ch)		(idma_mask((ch) * 2) * 3)
+#define tri_cur_buf_shift(ch)		(ffs(idma_mask((ch) * 2)) - 1)
 
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer)
@@ -780,6 +782,31 @@ bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_buffer_is_ready);
 
+int ipu_idmac_current_buffer(struct ipuv3_channel *channel)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned long flags;
+	int bufnum;
+	u32 reg;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	reg = ipu_cm_read(ipu, IPU_CHA_TRB_MODE_SEL(channel->num));
+	if (reg & idma_mask(channel->num)) {
+		reg = ipu_cm_read(ipu, IPU_CHA_TRIPLE_CUR_BUF(channel->num));
+		bufnum = (reg & tri_cur_buf_mask(channel->num)) >>
+			tri_cur_buf_shift(channel->num);
+	} else {
+		reg = ipu_cm_read(ipu, IPU_CHA_CUR_BUF(channel->num));
+		bufnum = (reg & idma_mask(channel->num)) ? 1 : 0;
+	}
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+
+	return bufnum;
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_current_buffer);
+
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num)
 {
 	struct ipu_soc *ipu = channel->ipu;
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +2 -0
index 43ac6c3..446ed20 100644
@@ -62,8 +62,10 @@ struct ipu_soc;
 #define IPU_PM				IPU_CM_REG(0x00e0)
 #define IPU_GPR				IPU_CM_REG(0x00e4)
 #define IPU_CHA_DB_MODE_SEL(ch)		IPU_CM_REG(0x0150 + 4 * ((ch) / 32))
+#define IPU_CHA_TRB_MODE_SEL(ch)	IPU_CM_REG(0x0178 + 4 * ((ch) / 32))
 #define IPU_ALT_CHA_DB_MODE_SEL(ch)	IPU_CM_REG(0x0168 + 4 * ((ch) / 32))
 #define IPU_CHA_CUR_BUF(ch)		IPU_CM_REG(0x023C + 4 * ((ch) / 32))
+#define IPU_CHA_TRIPLE_CUR_BUF(ch)	IPU_CM_REG(0x0258 + 4 * ((ch) / 32))
 #define IPU_ALT_CUR_BUF0		IPU_CM_REG(0x0244)
 #define IPU_ALT_CUR_BUF1		IPU_CM_REG(0x0248)
 #define IPU_SRM_STAT			IPU_CM_REG(0x024C)
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 480c30d..6f2c408 100644
@@ -201,6 +201,7 @@ void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
 void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num);
 bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
+int ipu_idmac_current_buffer(struct ipuv3_channel *channel);
 
 /*
  * IPU Display Controller (dc) functions
Signature · 1 line
1.7.9.5
#26 lore raw

Re: [PATCH 15/43] imx-drm: ipu-v3: Add ipu_idmac_current_buffer()

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 2 lines

Add ipu_idmac_current_buffer(), returns the currently active buffer number in the given channel.

This is already implemented in drm-next ...

Quoted 2 lines

Checks for third buffer ready in case triple-buffer support is added later.

... but this is not.

regards
Philipp

#27 lore raw

PATCH 16/43 imx-drm: ipu-v3: Add __ipu_idmac_reset_current_buffer()

In reply to Steve Longerbeam

Adds __ipu_idmac_reset_current_buffer() that resets a channel's internal current buffer pointer so that transfers start from buffer 0 on the next channel enable.

This operation is required for channel linking to work correctly, for instance video capture pipelines that carry out image rotations will fail after the first streaming unless this function is called for each channel before re-enabling the channels.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +23 -0
index 4839893..07b025f 100644
@@ -686,6 +686,25 @@ EXPORT_SYMBOL_GPL(ipu_idmac_put);
 #define tri_cur_buf_mask(ch)		(idma_mask((ch) * 2) * 3)
 #define tri_cur_buf_shift(ch)		(ffs(idma_mask((ch) * 2)) - 1)
 
+/*
+ * This is an undocumented feature, a write one to a channel bit in
+ * IPU_CHA_CUR_BUF and IPU_CHA_TRIPLE_CUR_BUF will reset the channel's
+ * internal current buffer pointer so that transfers start from buffer
+ * 0 on the next channel enable (that's the theory anyway, the imx6 TRM
+ * only says these are read-only registers). This operation is required
+ * for channel linking to work correctly, for instance video capture
+ * pipelines that carry out image rotations will fail after the first
+ * streaming unless this function is called for each channel before
+ * re-enabling the channels.
+ */
+static void __ipu_idmac_reset_current_buffer(struct ipuv3_channel *channel)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned int chno = channel->num;
+
+	ipu_cm_write(ipu, idma_mask(chno), IPU_CHA_CUR_BUF(chno));
+}
+
 void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		bool doublebuffer)
 {
@@ -702,6 +721,8 @@ void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 		reg &= ~idma_mask(channel->num);
 	ipu_cm_write(ipu, reg, IPU_CHA_DB_MODE_SEL(channel->num));
 
+	__ipu_idmac_reset_current_buffer(channel);
+
 	spin_unlock_irqrestore(&ipu->lock, flags);
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_set_double_buffer);
@@ -901,6 +922,8 @@ int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
 	val &= ~idma_mask(channel->num);
 	ipu_idmac_write(ipu, val, IDMAC_CHA_EN(channel->num));
 
+	__ipu_idmac_reset_current_buffer(channel);
+
 	/* Set channel buffers NOT to be ready */
 	ipu_cm_write(ipu, 0xf0000000, IPU_GPR); /* write one to clear */
 
Signature · 1 line
1.7.9.5
#28 lore raw

PATCH 17/43 imx-drm: ipu-v3: Add ipu_stride_to_bytes()

In reply to Steve Longerbeam

Adds ipu_stride_to_bytes(), which converts a pixel stride to bytes, suitable for passing to cpmem.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   30 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 31 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +30 -0
index 07b025f..32a51d6 100644
@@ -576,6 +576,36 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
 }
 EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
 
+int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
+{
+	switch (pixelformat) {
+	case V4L2_PIX_FMT_YUV420:
+	case V4L2_PIX_FMT_YVU420:
+		/*
+		 * for the planar YUV formats, the stride passed to
+		 * cpmem must be the stride in bytes of the Y plane.
+		 * And all the planar YUV formats have an 8-bit
+		 * Y component.
+		 */
+		return (8 * pixel_stride) >> 3;
+	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_YUYV:
+	case V4L2_PIX_FMT_UYVY:
+		return (16 * pixel_stride) >> 3;
+	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_RGB24:
+		return (24 * pixel_stride) >> 3;
+	case V4L2_PIX_FMT_BGR32:
+	case V4L2_PIX_FMT_RGB32:
+		return (32 * pixel_stride) >> 3;
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
+
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
 			    bool hflip, bool vflip)
 {
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 6f2c408..681b9fd 100644
@@ -500,6 +500,7 @@ int ipu_cpmem_set_image(struct ipu_ch_param __iomem *cpmem,
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
+int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
 bool ipu_pixelformat_is_planar(u32 pixelformat);
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
 			    bool hflip, bool vflip);
Signature · 1 line
1.7.9.5
#29 lore raw

PATCH 18/43 imx-drm: ipu-v3: Add ipu_idmac_enable_watermark()

In reply to Steve Longerbeam

Adds the function ipu_idmac_enable_watermark(), which enables or disables watermarking in the IDMAC channel. Enabling watermarking can increase a channel's AXI bus arbitration priority.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   25 +++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 26 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +25 -0
index 32a51d6..8c5b8d3 100644
@@ -982,6 +982,31 @@ int ipu_idmac_disable_channel(struct ipuv3_channel *channel)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_disable_channel);
 
+/*
+ * The imx6 rev. D TRM says that enabling the WM feature will increase
+ * a channel's priority. Refer to Table 36-8 Calculated priority value.
+ * The sub-module that is the sink or source for the channel must enable
+ * watermark signal for this to take effect (SMFC_WM for instance).
+ */
+void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned long flags;
+	u32 val;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	val = ipu_idmac_read(ipu, IDMAC_WM_EN(channel->num));
+	if (enable)
+		val |= 1 << (channel->num % 32);
+	else
+		val &= ~(1 << (channel->num % 32));
+	ipu_idmac_write(ipu, val, IDMAC_WM_EN(channel->num));
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_enable_watermark);
+
 static int ipu_memory_reset(struct ipu_soc *ipu)
 {
 	unsigned long timeout;
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 681b9fd..d1def4d 100644
@@ -202,6 +202,7 @@ void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
 void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num);
 bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
 int ipu_idmac_current_buffer(struct ipuv3_channel *channel);
+void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable);
 
 /*
  * IPU Display Controller (dc) functions
Signature · 1 line
1.7.9.5
#30 lore raw

PATCH 19/43 imx-drm: ipu-v3: Add ipu_idmac_lock_enable()

In reply to Steve Longerbeam

Adds ipu_idmac_lock_enable(), which enables or disables channel burst locking.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   69 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 70 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +69 -0
index 8c5b8d3..dfa6cf3 100644
@@ -757,6 +757,75 @@ void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel,
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_set_double_buffer);
 
+static const struct {
+	int chnum;
+	u32 reg;
+	int shift;
+} idmac_lock_en_info[] = {
+	{ .chnum =  5, .reg = IDMAC_CH_LOCK_EN_1, .shift =  0, },
+	{ .chnum = 11, .reg = IDMAC_CH_LOCK_EN_1, .shift =  2, },
+	{ .chnum = 12, .reg = IDMAC_CH_LOCK_EN_1, .shift =  4, },
+	{ .chnum = 14, .reg = IDMAC_CH_LOCK_EN_1, .shift =  6, },
+	{ .chnum = 15, .reg = IDMAC_CH_LOCK_EN_1, .shift =  8, },
+	{ .chnum = 20, .reg = IDMAC_CH_LOCK_EN_1, .shift = 10, },
+	{ .chnum = 21, .reg = IDMAC_CH_LOCK_EN_1, .shift = 12, },
+	{ .chnum = 22, .reg = IDMAC_CH_LOCK_EN_1, .shift = 14, },
+	{ .chnum = 23, .reg = IDMAC_CH_LOCK_EN_1, .shift = 16, },
+	{ .chnum = 27, .reg = IDMAC_CH_LOCK_EN_1, .shift = 18, },
+	{ .chnum = 28, .reg = IDMAC_CH_LOCK_EN_1, .shift = 20, },
+	{ .chnum = 45, .reg = IDMAC_CH_LOCK_EN_2, .shift =  0, },
+	{ .chnum = 46, .reg = IDMAC_CH_LOCK_EN_2, .shift =  2, },
+	{ .chnum = 47, .reg = IDMAC_CH_LOCK_EN_2, .shift =  4, },
+	{ .chnum = 48, .reg = IDMAC_CH_LOCK_EN_2, .shift =  6, },
+	{ .chnum = 49, .reg = IDMAC_CH_LOCK_EN_2, .shift =  8, },
+	{ .chnum = 50, .reg = IDMAC_CH_LOCK_EN_2, .shift = 10, },
+};
+
+int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts)
+{
+	struct ipu_soc *ipu = channel->ipu;
+	unsigned long flags;
+	u32 bursts, regval;
+	int i;
+
+	switch (num_bursts) {
+	case 0:
+	case 1:
+		bursts = 0x00; /* locking disabled */
+		break;
+	case 2:
+		bursts = 0x01;
+		break;
+	case 4:
+		bursts = 0x02;
+		break;
+	case 8:
+		bursts = 0x03;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(idmac_lock_en_info); i++) {
+		if (channel->num == idmac_lock_en_info[i].chnum)
+			break;
+	}
+	if (i >= ARRAY_SIZE(idmac_lock_en_info))
+		return -EINVAL;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	regval = ipu_idmac_read(ipu, idmac_lock_en_info[i].reg);
+	regval &= ~(0x03 << idmac_lock_en_info[i].shift);
+	regval |= (bursts << idmac_lock_en_info[i].shift);
+	ipu_idmac_write(ipu, regval, idmac_lock_en_info[i].reg);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_idmac_lock_enable);
+
 int ipu_module_enable(struct ipu_soc *ipu, u32 mask)
 {
 	unsigned long lock_flags;
include/linux/platform_data/imx-ipu-v3.h +1 -0
index d1def4d..949beec 100644
@@ -203,6 +203,7 @@ void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num);
 bool ipu_idmac_buffer_is_ready(struct ipuv3_channel *channel, u32 buf_num);
 int ipu_idmac_current_buffer(struct ipuv3_channel *channel);
 void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable);
+int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts);
 
 /*
  * IPU Display Controller (dc) functions
Signature · 1 line
1.7.9.5
#31 lore raw

PATCH 20/43 imx-drm: ipu-v3: Add idmac channel linking support

In reply to Steve Longerbeam

Add idmac channel linking/unlinking functions for specific IPU client use cases. The following linkings are currently needed:

- ipu_link_prp_enc_rot_enc():

Link IPUV3_CHANNEL_IC_PRP_ENC_MEM to IPUV3_CHANNEL_MEM_ROT_ENC.

- ipu_link_prpvf_rot_prpvf():

Links IPUV3_CHANNEL_IC_PRP_VF_MEM to IPUV3_CHANNEL_MEM_ROT_VF.

- ipu_link_pp_rot_pp():

Links IPUV3_CHANNEL_IC_PP_MEM to IPUV3_CHANNEL_MEM_ROT_PP.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |  159 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |   58 ++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    7 ++
 3 files changed, 224 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +159 -0
index dfa6cf3..de66d02 100644
@@ -973,6 +973,165 @@ void ipu_idmac_clear_buffer(struct ipuv3_channel *channel, u32 buf_num)
 }
 EXPORT_SYMBOL_GPL(ipu_idmac_clear_buffer);
 
+/*
+ * Links IPUV3_CHANNEL_IC_PRP_ENC_MEM to IPUV3_CHANNEL_MEM_ROT_ENC
+ */
+int ipu_link_prp_enc_rot_enc(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PRPENC_ROT_SRC_SEL_MASK;
+	fs_proc_flow1 |= (0x07 << FS_PRPENC_ROT_SRC_SEL_OFFSET);
+
+	fs_proc_flow2 &= ~FS_PRPENC_DEST_SEL_MASK;
+	fs_proc_flow2 |= (0x01 << FS_PRPENC_DEST_SEL_OFFSET);
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_link_prp_enc_rot_enc);
+
+/*
+ * Unlinks IPUV3_CHANNEL_IC_PRP_ENC_MEM from IPUV3_CHANNEL_MEM_ROT_ENC
+ */
+int ipu_unlink_prp_enc_rot_enc(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PRPENC_ROT_SRC_SEL_MASK;
+	fs_proc_flow2 &= ~FS_PRPENC_DEST_SEL_MASK;
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_unlink_prp_enc_rot_enc);
+
+/*
+ * Links IPUV3_CHANNEL_IC_PRP_VF_MEM to IPUV3_CHANNEL_MEM_ROT_VF
+ */
+int ipu_link_prpvf_rot_prpvf(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PRPVF_ROT_SRC_SEL_MASK;
+	fs_proc_flow1 |= (0x08 << FS_PRPVF_ROT_SRC_SEL_OFFSET);
+
+	fs_proc_flow2 &= ~FS_PRPVF_DEST_SEL_MASK;
+	fs_proc_flow2 |= (0x01 << FS_PRPVF_DEST_SEL_OFFSET);
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_link_prpvf_rot_prpvf);
+
+/*
+ * Unlinks IPUV3_CHANNEL_IC_PRP_VF_MEM from IPUV3_CHANNEL_MEM_ROT_VF
+ */
+int ipu_unlink_prpvf_rot_prpvf(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PRPVF_ROT_SRC_SEL_MASK;
+	fs_proc_flow2 &= ~FS_PRPVF_DEST_SEL_MASK;
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_unlink_prpvf_rot_prpvf);
+
+/*
+ * Links IPUV3_CHANNEL_IC_PP_MEM to IPUV3_CHANNEL_MEM_ROT_PP
+ */
+int ipu_link_pp_rot_pp(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PP_ROT_SRC_SEL_MASK;
+	fs_proc_flow1 |= (0x05 << FS_PP_ROT_SRC_SEL_OFFSET);
+
+	fs_proc_flow2 &= ~FS_PP_DEST_SEL_MASK;
+	fs_proc_flow2 |= (0x03 << FS_PP_DEST_SEL_OFFSET);
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_link_pp_rot_pp);
+
+/*
+ * Unlinks IPUV3_CHANNEL_IC_PP_MEM from IPUV3_CHANNEL_MEM_ROT_PP
+ */
+int ipu_unlink_pp_rot_pp(struct ipu_soc *ipu)
+{
+	unsigned long flags;
+	u32 fs_proc_flow1;
+	u32 fs_proc_flow2;
+
+	spin_lock_irqsave(&ipu->lock, flags);
+
+	fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
+	fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
+
+	fs_proc_flow1 &= ~FS_PP_ROT_SRC_SEL_MASK;
+	fs_proc_flow2 &= ~FS_PP_DEST_SEL_MASK;
+
+	ipu_cm_write(ipu, fs_proc_flow1, IPU_FS_PROC_FLOW1);
+	ipu_cm_write(ipu, fs_proc_flow2, IPU_FS_PROC_FLOW2);
+
+	spin_unlock_irqrestore(&ipu->lock, flags);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_unlink_pp_rot_pp);
+
 int ipu_idmac_enable_channel(struct ipuv3_channel *channel)
 {
 	struct ipu_soc *ipu = channel->ipu;
drivers/staging/imx-drm/ipu-v3/ipu-prv.h +58 -0

64 lines not on this page · raw message

include/linux/platform_data/imx-ipu-v3.h +7 -0
index 949beec..75a6a5d 100644
@@ -205,6 +205,13 @@ int ipu_idmac_current_buffer(struct ipuv3_channel *channel);
 void ipu_idmac_enable_watermark(struct ipuv3_channel *channel, bool enable);
 int ipu_idmac_lock_enable(struct ipuv3_channel *channel, int num_bursts);
 
+int ipu_link_prp_enc_rot_enc(struct ipu_soc *ipu);
+int ipu_unlink_prp_enc_rot_enc(struct ipu_soc *ipu);
+int ipu_link_prpvf_rot_prpvf(struct ipu_soc *ipu);
+int ipu_unlink_prpvf_rot_prpvf(struct ipu_soc *ipu);
+int ipu_link_pp_rot_pp(struct ipu_soc *ipu);
+int ipu_unlink_pp_rot_pp(struct ipu_soc *ipu);
+
 /*
  * IPU Display Controller (dc) functions
  */
Signature · 1 line
1.7.9.5
#32 lore raw

PATCH 21/43 imx-drm: ipu-v3: Add ipu_bits_per_pixel()

In reply to Steve Longerbeam

Add simple conversion from pixelformat to total bits-per-pixel.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   27 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 28 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +27 -0
index de66d02..8a03ad2 100644
@@ -606,6 +606,33 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
 }
 EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
 
+/*
+ * Standard bpp from pixel format.
+ */
+int ipu_bits_per_pixel(u32 pixelformat)
+{
+	switch (pixelformat) {
+	case V4L2_PIX_FMT_YUV420:
+	case V4L2_PIX_FMT_YVU420:
+		return 12;
+	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_YUYV:
+	case V4L2_PIX_FMT_UYVY:
+		return 16;
+	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_RGB24:
+		return 24;
+	case V4L2_PIX_FMT_BGR32:
+	case V4L2_PIX_FMT_RGB32:
+		return 32;
+	default:
+		break;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_bits_per_pixel);
+
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
 			    bool hflip, bool vflip)
 {
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 75a6a5d..49e69a9 100644
@@ -510,6 +510,7 @@ enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
 enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
 int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
+int ipu_bits_per_pixel(u32 pixelformat);
 bool ipu_pixelformat_is_planar(u32 pixelformat);
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
 			    bool hflip, bool vflip);
Signature · 1 line
1.7.9.5
#33 lore raw

Re: [PATCH 21/43] imx-drm: ipu-v3: Add ipu_bits_per_pixel()

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 1 line

Add simple conversion from pixelformat to total bits-per-pixel.

[...]

Quoted 16 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +16 -0
+/*
+ * Standard bpp from pixel format.
+ */
+int ipu_bits_per_pixel(u32 pixelformat)
+{
+	switch (pixelformat) {
+	case V4L2_PIX_FMT_YUV420:
+	case V4L2_PIX_FMT_YVU420:
+		return 12;
+	case V4L2_PIX_FMT_RGB565:
+	case V4L2_PIX_FMT_YUYV:
+	case V4L2_PIX_FMT_UYVY:
+		return 16;
+	case V4L2_PIX_FMT_BGR24:
+	case V4L2_PIX_FMT_RGB24:
+		return 24;

drivers/staging/imx-drm/ipu-v3/ipu-common.c int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) · line 634

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -0
+	case V4L2_PIX_FMT_BGR32:
+	case V4L2_PIX_FMT_RGB32:
+		return 32;
+	default:
+		break;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ipu_bits_per_pixel);

This isn't really IPU specific. Should we have a v4l2-wide helper for this? Also, it seems that this is only ever used to calculate the bytesperline, so why not return bytes per pixel directly?

regards
Philipp

#34 lore raw

PATCH 22/43 imx-drm: ipu-v3: Add ipu-cpmem unit

In reply to Steve Longerbeam

Move channel parameter memory setup functions and macros into a new submodule ipu-cpmem. In the process, cleanup arguments to the functions to take a channel pointer instead of a pointer into cpmem for that channel. That allows the structure of the parameter memory to be private to ipu-cpmem.c.

---
 drivers/staging/imx-drm/ipu-v3/Makefile     |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |  457 +-------------------
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c  |  595 +++++++++++++++++++++++++++
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h    |   14 +-
 drivers/staging/imx-drm/ipuv3-plane.c       |   16 +-
 include/linux/platform_data/imx-ipu-v3.h    |  190 ++-------
 6 files changed, 662 insertions(+), 612 deletions(-)
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c
drivers/staging/imx-drm/ipu-v3/Makefile +1 -1
index 79c0c88..147a1b7 100644
@@ -1,4 +1,4 @@
 obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o
 
-imx-ipu-v3-objs := ipu-common.o ipu-csi.o ipu-dc.o ipu-di.o \
+imx-ipu-v3-objs := ipu-common.o ipu-cpmem.o ipu-csi.o ipu-dc.o ipu-di.o \
 	ipu-dp.o ipu-dmfc.o ipu-ic.o ipu-irt.o ipu-smfc.o
drivers/staging/imx-drm/ipu-v3/ipu-common.c +10 -447

500 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c new file +595 -0

595 lines not on this page · raw message

drivers/staging/imx-drm/ipu-v3/ipu-prv.h +13 -1
index d10e624..f56b3fd 100644
@@ -195,6 +195,7 @@ struct ipuv3_channel {
 	struct ipu_soc *ipu;
 };
 
+struct ipu_cpmem;
 struct ipu_dc_priv;
 struct ipu_dmfc_priv;
 struct ipu_di;
@@ -213,7 +214,6 @@ struct ipu_soc {
 
 	void __iomem		*cm_reg;
 	void __iomem		*idmac_reg;
-	struct ipu_ch_param __iomem	*cpmem_base;
 	struct regmap		*gp_reg;
 
 	int			id;
@@ -227,6 +227,7 @@ struct ipu_soc {
 	int			irq_err;
 	struct irq_domain	*domain;
 
+	struct ipu_cpmem	*cpmem_priv;
 	struct ipu_dc_priv	*dc_priv;
 	struct ipu_dp_priv	*dp_priv;
 	struct ipu_dmfc_priv	*dmfc_priv;
@@ -237,6 +238,17 @@ struct ipu_soc {
 	struct ipu_irt		*irt_priv;
 };
 
+static inline u32 ipu_idmac_read(struct ipu_soc *ipu, unsigned offset)
+{
+	return readl(ipu->idmac_reg + offset);
+}
+
+static inline void ipu_idmac_write(struct ipu_soc *ipu, u32 value,
+		unsigned offset)
+{
+	writel(value, ipu->idmac_reg + offset);
+}
+
 void ipu_srm_dp_sync_update(struct ipu_soc *ipu);
 
 int ipu_module_enable(struct ipu_soc *ipu, u32 mask);
drivers/staging/imx-drm/ipuv3-plane.c +6 -10
index e9e4e7a..f962cc8 100644
@@ -62,7 +62,6 @@ static inline int calc_bandwidth(int width, int height, unsigned int vref)
 int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb,
 		       int x, int y)
 {
-	struct ipu_ch_param __iomem *cpmem;
 	struct drm_gem_cma_object *cma_obj;
 	unsigned long eba;
 
@@ -75,13 +74,12 @@ int ipu_plane_set_base(struct ipu_plane *ipu_plane, struct drm_framebuffer *fb,
 	dev_dbg(ipu_plane->base.dev->dev, "phys = %pad, x = %d, y = %d",
 		&cma_obj->paddr, x, y);
 
-	cpmem = ipu_get_cpmem(ipu_plane->ipu_ch);
-	ipu_cpmem_set_stride(cpmem, fb->pitches[0]);
+	ipu_cpmem_set_stride(ipu_plane->ipu_ch, fb->pitches[0]);
 
 	eba = cma_obj->paddr + fb->offsets[0] +
 	      fb->pitches[0] * y + (fb->bits_per_pixel >> 3) * x;
-	ipu_cpmem_set_buffer(cpmem, 0, eba);
-	ipu_cpmem_set_buffer(cpmem, 1, eba);
+	ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 0, eba);
+	ipu_cpmem_set_buffer(ipu_plane->ipu_ch, 1, eba);
 
 	/* cache offsets for subsequent pageflips */
 	ipu_plane->x = x;
@@ -97,7 +95,6 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc,
 		       uint32_t src_x, uint32_t src_y,
 		       uint32_t src_w, uint32_t src_h)
 {
-	struct ipu_ch_param __iomem *cpmem;
 	struct device *dev = ipu_plane->base.dev->dev;
 	int ret;
 
@@ -175,10 +172,9 @@ int ipu_plane_mode_set(struct ipu_plane *ipu_plane, struct drm_crtc *crtc,
 		return ret;
 	}
 
-	cpmem = ipu_get_cpmem(ipu_plane->ipu_ch);
-	ipu_ch_param_zero(cpmem);
-	ipu_cpmem_set_resolution(cpmem, src_w, src_h);
-	ret = ipu_cpmem_set_fmt(cpmem, fb->pixel_format);
+	ipu_cpmem_zero(ipu_plane->ipu_ch);
+	ipu_cpmem_set_resolution(ipu_plane->ipu_ch, src_w, src_h);
+	ret = ipu_cpmem_set_fmt(ipu_plane->ipu_ch, fb->pixel_format);
 	if (ret < 0) {
 		dev_err(dev, "unsupported pixel format 0x%08x\n",
 			fb->pixel_format);
include/linux/platform_data/imx-ipu-v3.h +37 -153

208 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Acked-by on v1 22/43
#35 lore raw

Re: [PATCH 22/43] imx-drm: ipu-v3: Add ipu-cpmem unit

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 8 lines

Move channel parameter memory setup functions and macros into a new submodule ipu-cpmem. In the process, cleanup arguments to the functions to take a channel pointer instead of a pointer into cpmem for that channel. That allows the structure of the parameter memory to be private to ipu-cpmem.c.

I like the move of cpmem handling code into its own submodule.

regards
Philipp

#36 lore raw

PATCH 23/43 imx-drm: ipu-cpmem: Add ipu_cpmem_set_block_mode()

In reply to Steve Longerbeam

Adds ipu_cpmem_set_block_mode().

---
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c |    6 ++++++
 include/linux/platform_data/imx-ipu-v3.h   |    1 +
 2 files changed, 7 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +6 -0
index 06471ee..c7910cc 100644
@@ -258,6 +258,12 @@ void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize)
 };
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_burstsize);
 
+void ipu_cpmem_set_block_mode(struct ipuv3_channel *ch)
+{
+	ipu_ch_param_write_field(ch, IPU_FIELD_BM, 1);
+}
+EXPORT_SYMBOL_GPL(ipu_cpmem_set_block_mode);
+
 int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
 			     const struct ipu_rgb *rgb)
 {
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 91986ed..beb2e4b 100644
@@ -229,6 +229,7 @@ void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
 void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf);
 void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
+void ipu_cpmem_set_block_mode(struct ipuv3_channel *ch);
 int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
 			     const struct ipu_rgb *rgb);
 int ipu_cpmem_set_format_passthrough(struct ipuv3_channel *ch, int width);
Signature · 1 line
1.7.9.5
#37 lore raw

PATCH 24/43 imx-drm: ipu-cpmem: Add ipu_cpmem_set_axi_id()

In reply to Steve Longerbeam

Adds ipu_cpmem_set_axi_id() to set which AXI bus master the channel will use to transfer data onto AXI bus.

---
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c |    7 +++++++
 include/linux/platform_data/imx-ipu-v3.h   |    1 +
 2 files changed, 8 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +7 -0
index c7910cc..4d5a9fe 100644
@@ -252,6 +252,13 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride)
 };
 EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan);
 
+void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id)
+{
+	id &= 0x3;
+	ipu_ch_param_write_field(ch, IPU_FIELD_ID, id);
+}
+EXPORT_SYMBOL_GPL(ipu_cpmem_set_axi_id);
+
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize)
 {
 	ipu_ch_param_write_field(ch, IPU_FIELD_NPB, burstsize - 1);
include/linux/platform_data/imx-ipu-v3.h +1 -0
index beb2e4b..6486217 100644
@@ -228,6 +228,7 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride);
 void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch);
 void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf);
 void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
+void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id);
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
 void ipu_cpmem_set_block_mode(struct ipuv3_channel *ch);
 int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
Signature · 1 line
1.7.9.5
#38 lore raw

PATCH 25/43 imx-drm: ipu-cpmem: Add ipu_cpmem_set_rotation()

In reply to Steve Longerbeam

Adds ipu_cpmem_set_rotation().

---
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c |    9 +++++++++
 include/linux/platform_data/imx-ipu-v3.h   |    2 ++
 2 files changed, 11 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +9 -0
index 4d5a9fe..bd76a38 100644
@@ -64,6 +64,7 @@ struct ipu_cpmem {
 #define IPU_FIELD_BNDM		IPU_CPMEM_WORD(0, 114, 3)
 #define IPU_FIELD_BM		IPU_CPMEM_WORD(0, 117, 2)
 #define IPU_FIELD_ROT		IPU_CPMEM_WORD(0, 119, 1)
+#define IPU_FIELD_ROT_HF_VF	IPU_CPMEM_WORD(0, 119, 3)
 #define IPU_FIELD_HF		IPU_CPMEM_WORD(0, 120, 1)
 #define IPU_FIELD_VF		IPU_CPMEM_WORD(0, 121, 1)
 #define IPU_FIELD_THE		IPU_CPMEM_WORD(0, 122, 1)
@@ -271,6 +272,14 @@ void ipu_cpmem_set_block_mode(struct ipuv3_channel *ch)
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_block_mode);
 
+void ipu_cpmem_set_rotation(struct ipuv3_channel *ch,
+			    enum ipu_rotate_mode rot)
+{
+	u32 temp_rot = bitrev8(rot) >> 5;
+	ipu_ch_param_write_field(ch, IPU_FIELD_ROT_HF_VF, temp_rot);
+}
+EXPORT_SYMBOL_GPL(ipu_cpmem_set_rotation);
+
 int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
 			     const struct ipu_rgb *rgb)
 {
include/linux/platform_data/imx-ipu-v3.h +2 -0
index 6486217..53aab16 100644
@@ -231,6 +231,8 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride);
 void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id);
 void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize);
 void ipu_cpmem_set_block_mode(struct ipuv3_channel *ch);
+void ipu_cpmem_set_rotation(struct ipuv3_channel *ch,
+			    enum ipu_rotate_mode rot);
 int ipu_cpmem_set_format_rgb(struct ipuv3_channel *ch,
 			     const struct ipu_rgb *rgb);
 int ipu_cpmem_set_format_passthrough(struct ipuv3_channel *ch, int width);
Signature · 1 line
1.7.9.5
#39 lore raw

PATCH 26/43 imx-drm: ipu-cpmem: Add second buffer support to ipu_cpmem_set_image()

In reply to Steve Longerbeam

Add a second buffer physaddr to struct ipu_image, for double-buffering support.

---
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c |   32 ++++++++++++++--------------
 include/linux/platform_data/imx-ipu-v3.h   |    3 ++-
 2 files changed, 18 insertions(+), 17 deletions(-)
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +16 -16
index bd76a38..70e90b40 100644
@@ -535,7 +535,7 @@ EXPORT_SYMBOL_GPL(ipu_cpmem_set_fmt);
 int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image)
 {
 	struct v4l2_pix_format *pix = &image->pix;
-	int y_offset, u_offset, v_offset;
+	int offset, y_offset, u_offset, v_offset;
 
 	pr_debug("%s: resolution: %dx%d stride: %d\n",
 		 __func__, pix->width, pix->height,
@@ -557,30 +557,30 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image)
 
 		ipu_cpmem_set_yuv_planar_full(ch, pix->pixelformat,
 				pix->bytesperline, u_offset, v_offset);
-		ipu_cpmem_set_buffer(ch, 0, image->phys + y_offset);
+		ipu_cpmem_set_buffer(ch, 0, image->phys0 + y_offset);
+		ipu_cpmem_set_buffer(ch, 1, image->phys1 + y_offset);
 		break;
 	case V4L2_PIX_FMT_UYVY:
 	case V4L2_PIX_FMT_YUYV:
-		ipu_cpmem_set_buffer(ch, 0, image->phys +
-				     image->rect.left * 2 +
-				     image->rect.top * image->pix.bytesperline);
+	case V4L2_PIX_FMT_RGB565:
+		offset = image->rect.left * 2 +
+			image->rect.top * pix->bytesperline;
+		ipu_cpmem_set_buffer(ch, 0, image->phys0 + offset);
+		ipu_cpmem_set_buffer(ch, 1, image->phys1 + offset);
 		break;
 	case V4L2_PIX_FMT_RGB32:
 	case V4L2_PIX_FMT_BGR32:
-		ipu_cpmem_set_buffer(ch, 0, image->phys +
-				     image->rect.left * 4 +
-				     image->rect.top * image->pix.bytesperline);
-		break;
-	case V4L2_PIX_FMT_RGB565:
-		ipu_cpmem_set_buffer(ch, 0, image->phys +
-				     image->rect.left * 2 +
-				     image->rect.top * image->pix.bytesperline);
+		offset = image->rect.left * 4 +
+			image->rect.top * pix->bytesperline;
+		ipu_cpmem_set_buffer(ch, 0, image->phys0 + offset);
+		ipu_cpmem_set_buffer(ch, 1, image->phys1 + offset);
 		break;
 	case V4L2_PIX_FMT_RGB24:
 	case V4L2_PIX_FMT_BGR24:
-		ipu_cpmem_set_buffer(ch, 0, image->phys +
-				     image->rect.left * 3 +
-				     image->rect.top * image->pix.bytesperline);
+		offset = image->rect.left * 3 +
+			image->rect.top * pix->bytesperline;
+		ipu_cpmem_set_buffer(ch, 0, image->phys0 + offset);
+		ipu_cpmem_set_buffer(ch, 1, image->phys1 + offset);
 		break;
 	default:
 		return -EINVAL;
include/linux/platform_data/imx-ipu-v3.h +2 -1
index 53aab16..4575657 100644
@@ -219,7 +219,8 @@ struct ipu_rgb {
 struct ipu_image {
 	struct v4l2_pix_format pix;
 	struct v4l2_rect rect;
-	dma_addr_t phys;
+	dma_addr_t phys0;
+	dma_addr_t phys1;
 };
 
 void ipu_cpmem_zero(struct ipuv3_channel *ch);
Signature · 1 line
1.7.9.5
#40 lore raw

PATCH 27/43 imx-drm: ipu-v3: Add more planar formats support

In reply to Steve Longerbeam

Adds support for the following planar and partial-planar formats:

YUV422
NV12
NV21
NV16
NV61

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   26 +++++
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c  |  146 +++++++++++++++++++++++++--
 2 files changed, 166 insertions(+), 6 deletions(-)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +26 -0
index b9d759d..2ee6370 100644
@@ -80,6 +80,12 @@ enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc)
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YVU422:
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV16:
+	case DRM_FORMAT_NV61:
 		return IPUV3_COLORSPACE_YUV;
 	default:
 		return IPUV3_COLORSPACE_UNKNOWN;
@@ -92,8 +98,13 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 	switch (pixelformat) {
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
+	case V4L2_PIX_FMT_YUV422P:
 	case V4L2_PIX_FMT_UYVY:
 	case V4L2_PIX_FMT_YUYV:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
 		return IPUV3_COLORSPACE_YUV;
 	case V4L2_PIX_FMT_RGB32:
 	case V4L2_PIX_FMT_BGR32:
@@ -112,6 +123,11 @@ bool ipu_pixelformat_is_planar(u32 pixelformat)
 	switch (pixelformat) {
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
+	case V4L2_PIX_FMT_YUV422P:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
 		return true;
 	}
 
@@ -137,6 +153,11 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
 	switch (pixelformat) {
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
+	case V4L2_PIX_FMT_YUV422P:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
 		/*
 		 * for the planar YUV formats, the stride passed to
 		 * cpmem must be the stride in bytes of the Y plane.
@@ -170,10 +191,15 @@ int ipu_bits_per_pixel(u32 pixelformat)
 	switch (pixelformat) {
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
+	case V4L2_PIX_FMT_NV12:
+	case V4L2_PIX_FMT_NV21:
 		return 12;
+	case V4L2_PIX_FMT_YUV422P:
 	case V4L2_PIX_FMT_RGB565:
 	case V4L2_PIX_FMT_YUYV:
 	case V4L2_PIX_FMT_UYVY:
+	case V4L2_PIX_FMT_NV16:
+	case V4L2_PIX_FMT_NV61:
 		return 16;
 	case V4L2_PIX_FMT_BGR24:
 	case V4L2_PIX_FMT_RGB24:
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +140 -6

190 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#41 lore raw

PATCH 28/43 imx-drm: ipu-cpmem: Add ipu_cpmem_dump()

In reply to Steve Longerbeam

Adds ipu_cpmem_dump() which dumps a channel's cpmem to debug.

---
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c |   63 ++++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h   |    1 +
 2 files changed, 64 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c +63 -0
index 1ee5e11..b1d7f60 100644
@@ -724,6 +724,69 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image)
 }
 EXPORT_SYMBOL_GPL(ipu_cpmem_set_image);
 
+void ipu_cpmem_dump(struct ipuv3_channel *ch)
+{
+	struct ipu_ch_param __iomem *p = ipu_get_cpmem(ch);
+	struct ipu_soc *ipu = ch->ipu;
+	int chno = ch->num;
+
+	dev_dbg(ipu->dev, "ch %d word 0 - %08X %08X %08X %08X %08X\n", chno,
+		readl(&p->word[0].data[0]),
+		readl(&p->word[0].data[1]),
+		readl(&p->word[0].data[2]),
+		readl(&p->word[0].data[3]),
+		readl(&p->word[0].data[4]));
+	dev_dbg(ipu->dev, "ch %d word 1 - %08X %08X %08X %08X %08X\n", chno,
+		readl(&p->word[1].data[0]),
+		readl(&p->word[1].data[1]),
+		readl(&p->word[1].data[2]),
+		readl(&p->word[1].data[3]),
+		readl(&p->word[1].data[4]));
+	dev_dbg(ipu->dev, "PFS 0x%x, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_PFS));
+	dev_dbg(ipu->dev, "BPP 0x%x, ",
+		ipu_ch_param_read_field(ch, IPU_FIELD_BPP));
+	dev_dbg(ipu->dev, "NPB 0x%x\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_NPB));
+
+	dev_dbg(ipu->dev, "FW %d, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_FW));
+	dev_dbg(ipu->dev, "FH %d, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_FH));
+	dev_dbg(ipu->dev, "EBA0 0x%x\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_EBA0) << 3);
+	dev_dbg(ipu->dev, "EBA1 0x%x\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_EBA1) << 3);
+	dev_dbg(ipu->dev, "Stride %d\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_SL));
+	dev_dbg(ipu->dev, "scan_order %d\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_SO));
+	dev_dbg(ipu->dev, "uv_stride %d\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_SLUV));
+	dev_dbg(ipu->dev, "u_offset 0x%x\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_UBO) << 3);
+	dev_dbg(ipu->dev, "v_offset 0x%x\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_VBO) << 3);
+
+	dev_dbg(ipu->dev, "Width0 %d+1, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_WID0));
+	dev_dbg(ipu->dev, "Width1 %d+1, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_WID1));
+	dev_dbg(ipu->dev, "Width2 %d+1, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_WID2));
+	dev_dbg(ipu->dev, "Width3 %d+1, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_WID3));
+	dev_dbg(ipu->dev, "Offset0 %d, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_OFS0));
+	dev_dbg(ipu->dev, "Offset1 %d, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_OFS1));
+	dev_dbg(ipu->dev, "Offset2 %d, ",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_OFS2));
+	dev_dbg(ipu->dev, "Offset3 %d\n",
+		 ipu_ch_param_read_field(ch, IPU_FIELD_OFS3));
+}
+EXPORT_SYMBOL_GPL(ipu_cpmem_dump);
+
 int ipu_cpmem_init(struct ipu_soc *ipu, struct device *dev, unsigned long base)
 {
 	struct ipu_cpmem *cpmem;
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 4575657..811b93b 100644
@@ -245,6 +245,7 @@ void ipu_cpmem_set_yuv_planar(struct ipuv3_channel *ch,
 			      u32 pixel_format, int stride, int height);
 int ipu_cpmem_set_fmt(struct ipuv3_channel *ch, u32 drm_fourcc);
 int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image);
+void ipu_cpmem_dump(struct ipuv3_channel *ch);
 
 /* Channel linking functions */
 int ipu_link_prp_enc_rot_enc(struct ipu_soc *ipu);
Signature · 1 line
1.7.9.5
#42 lore raw

PATCH 29/43 imx-drm: ipu-v3: Add ipu_dump()

In reply to Steve Longerbeam

Adds ipu_dump() which dumps IPU register state to debug.

---
 drivers/staging/imx-drm/ipu-v3/ipu-common.c |   41 +++++++++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h    |    1 +
 2 files changed, 42 insertions(+)
drivers/staging/imx-drm/ipu-v3/ipu-common.c +41 -0
index 2ee6370..1526cec 100644
@@ -1326,6 +1326,47 @@ static void ipu_irq_exit(struct ipu_soc *ipu)
 	irq_domain_remove(ipu->domain);
 }
 
+void ipu_dump(struct ipu_soc *ipu)
+{
+	int i;
+	dev_dbg(ipu->dev, "IPU_CONF = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_CONF));
+	dev_dbg(ipu->dev, "IDMAC_CONF = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_CONF));
+	dev_dbg(ipu->dev, "IDMAC_CHA_EN1 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_CHA_EN(0)));
+	dev_dbg(ipu->dev, "IDMAC_CHA_EN2 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_CHA_EN(32)));
+	dev_dbg(ipu->dev, "IDMAC_CHA_PRI1 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_CHA_PRI(0)));
+	dev_dbg(ipu->dev, "IDMAC_CHA_PRI2 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_CHA_PRI(32)));
+	dev_dbg(ipu->dev, "IDMAC_BAND_EN1 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_BAND_EN(0)));
+	dev_dbg(ipu->dev, "IDMAC_BAND_EN2 = \t0x%08X\n",
+		ipu_idmac_read(ipu, IDMAC_BAND_EN(32)));
+	dev_dbg(ipu->dev, "IPU_CHA_DB_MODE_SEL0 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(0)));
+	dev_dbg(ipu->dev, "IPU_CHA_DB_MODE_SEL1 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_CHA_DB_MODE_SEL(32)));
+	dev_dbg(ipu->dev, "IPU_CHA_TRB_MODE_SEL0 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_CHA_TRB_MODE_SEL(0)));
+	dev_dbg(ipu->dev, "IPU_CHA_TRB_MODE_SEL1 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_CHA_TRB_MODE_SEL(32)));
+	dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW1 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_FS_PROC_FLOW1));
+	dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW2 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_FS_PROC_FLOW2));
+	dev_dbg(ipu->dev, "IPU_FS_PROC_FLOW3 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_FS_PROC_FLOW3));
+	dev_dbg(ipu->dev, "IPU_FS_DISP_FLOW1 = \t0x%08X\n",
+		ipu_cm_read(ipu, IPU_FS_DISP_FLOW1));
+	for (i = 0; i < 15; i++)
+		dev_dbg(ipu->dev, "IPU_INT_CTRL(%d) = \t%08X\n", i,
+			ipu_cm_read(ipu, IPU_INT_CTRL(i)));
+}
+EXPORT_SYMBOL_GPL(ipu_dump);
+
 static int ipu_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *of_id =
include/linux/platform_data/imx-ipu-v3.h +1 -0
index 811b93b..1698d5d 100644
@@ -185,6 +185,7 @@ int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
  * IPU Common functions
  */
 int ipu_get_num(struct ipu_soc *ipu);
+void ipu_dump(struct ipu_soc *ipu);
 
 /*
  * IPU Image DMA Controller (idmac) functions
Signature · 1 line
1.7.9.5
#43 lore raw

PATCH 30/43 ARM: dts: imx6: add pin groups for imx6q/dl for IPU1 CSI0

In reply to Steve Longerbeam
---
 arch/arm/boot/dts/imx6qdl.dtsi |   52 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +52 -0
index 04c978c..d793cd6 100644
@@ -664,6 +664,58 @@
 			iomuxc: iomuxc@020e0000 {
 				compatible = "fsl,imx6dl-iomuxc", "fsl,imx6q-iomuxc";
 				reg = <0x020e0000 0x4000>;
+
+				ipu1 {
+					pinctrl_ipu1_csi0_d4_d7: ipu1-csi0-d4-d7 {
+						fsl,pins = <
+							MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04 0x80000000
+							MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05 0x80000000
+							MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06 0x80000000
+							MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07 0x80000000
+						>;
+					};
+					pinctrl_ipu1_csi0_1: ipu1-csi0-1 {
+						fsl,pins = <
+							MX6QDL_PAD_CSI0_DAT8__IPU1_CSI0_DATA08 0x80000000
+							MX6QDL_PAD_CSI0_DAT9__IPU1_CSI0_DATA09 0x80000000
+							MX6QDL_PAD_CSI0_DAT10__IPU1_CSI0_DATA10 0x80000000
+							MX6QDL_PAD_CSI0_DAT11__IPU1_CSI0_DATA11 0x80000000
+							MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12 0x80000000
+							MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13 0x80000000
+							MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14 0x80000000
+							MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15 0x80000000
+							MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16 0x80000000
+							MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17 0x80000000
+							MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18 0x80000000
+							MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19 0x80000000
+							MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC 0x80000000
+							MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK 0x80000000
+							MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC 0x80000000
+						>;
+					};
+
+					pinctrl_ipu1_csi0_2: ipu1-csi0-2 {
+						fsl,pins = <
+							MX6QDL_PAD_CSI0_DAT12__IPU1_CSI0_DATA12  0x80000000
+							MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13  0x80000000
+							MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14  0x80000000
+							MX6QDL_PAD_CSI0_DAT15__IPU1_CSI0_DATA15  0x80000000
+							MX6QDL_PAD_CSI0_DAT16__IPU1_CSI0_DATA16  0x80000000
+							MX6QDL_PAD_CSI0_DAT17__IPU1_CSI0_DATA17  0x80000000
+							MX6QDL_PAD_CSI0_DAT18__IPU1_CSI0_DATA18  0x80000000
+							MX6QDL_PAD_CSI0_DAT19__IPU1_CSI0_DATA19  0x80000000
+							MX6QDL_PAD_CSI0_MCLK__IPU1_CSI0_HSYNC    0x80000000
+							MX6QDL_PAD_CSI0_PIXCLK__IPU1_CSI0_PIXCLK 0x80000000
+							MX6QDL_PAD_CSI0_VSYNC__IPU1_CSI0_VSYNC   0x80000000
+						>;
+					};
+
+					pinctrl_ipu1_csi0_data_en: ipu1-csi0-data-en {
+						fsl,pins = <
+							MX6QDL_PAD_CSI0_DATA_EN__IPU1_CSI0_DATA_EN 0x80000000
+						>;
+					};
+				};
 			};
 
 			ldb: ldb@020e0008 {
Signature · 1 line
1.7.9.5
maintainer
#44 lore raw

Re: [PATCH 30/43] ARM: dts: imx6: add pin groups for imx6q/dl for IPU1 CSI0

Quoted 14 lines · Steve Longerbeam
---
 arch/arm/boot/dts/imx6qdl.dtsi |   52 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +0 -0
index 04c978c..d793cd6 100644
@@ -664,6 +664,58 @@
 			iomuxc: iomuxc@020e0000 {
 				compatible = "fsl,imx6dl-iomuxc", "fsl,imx6q-iomuxc";
 				reg = <0x020e0000 0x4000>;

arch/arm/boot/dts/imx6qdl.dtsi line 676

Quoted 10 lines
arch/arm/boot/dts/imx6qdl.dtsi +10 -0
+
+				ipu1 {
+					pinctrl_ipu1_csi0_d4_d7: ipu1-csi0-d4-d7 {
+						fsl,pins = <
+							MX6QDL_PAD_CSI0_DAT4__IPU1_CSI0_DATA04 0x80000000
+							MX6QDL_PAD_CSI0_DAT5__IPU1_CSI0_DATA05 0x80000000
+							MX6QDL_PAD_CSI0_DAT6__IPU1_CSI0_DATA06 0x80000000
+							MX6QDL_PAD_CSI0_DAT7__IPU1_CSI0_DATA07 0x80000000
+						>;
+					};

We no longer have the pinctrl groups in the SoC dts files. Please put them into the boards instead.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#45 lore raw

PATCH 31/43 ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node

In reply to Steve Longerbeam

Add mode device info to the MIPI CSI2 receiver node: compatible string, interrupt sources, clocks.

---
 arch/arm/boot/dts/imx6qdl.dtsi |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6qdl.dtsi +6 -1
index d793cd6..00130a8 100644
@@ -1011,8 +1011,13 @@
 				status = "disabled";
 			};
 
-			mipi_csi: mipi@021dc000 {
+			mipi_csi2: mipi@021dc000 {
+				compatible = "fsl,imx6-mipi-csi2";
 				reg = <0x021dc000 0x4000>;
+				interrupts = <0 100 0x04>, <0 101 0x04>;
+				clocks = <&clks 138>, <&clks 208>;
+				clock-names = "dphy_clk", "cfg_clk";
+				status = "disabled";
 			};
 
 			mipi_dsi: mipi@021e0000 {
Signature · 1 line
1.7.9.5
#46 lore raw

Re: [PATCH 31/43] ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 13 lines

Add mode device info to the MIPI CSI2 receiver node: compatible string, interrupt sources, clocks.

---
 arch/arm/boot/dts/imx6qdl.dtsi |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6qdl.dtsi +0 -0
index d793cd6..00130a8 100644

arch/arm/boot/dts/imx6qdl.dtsi line 1018

Quoted 9 lines
arch/arm/boot/dts/imx6qdl.dtsi +4 -1
@@ -1011,8 +1011,13 @@
 				status = "disabled";
 			};
 
-			mipi_csi: mipi@021dc000 {
+			mipi_csi2: mipi@021dc000 {
+				compatible = "fsl,imx6-mipi-csi2";
 				reg = <0x021dc000 0x4000>;
+				interrupts = <0 100 0x04>, <0 101 0x04>;
+				clocks = <&clks 138>, <&clks 208>;

clk 138 is hsi_tx_clk_root, gated by the mipi_core_cfg gate bit. All MIPI CSI input clocks are also gated by mipi_core_cfg, so this will work just as well. But maybe add a comment?

arch/arm/boot/dts/imx6qdl.dtsi line 1019

Quoted 1 line
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
+				clock-names = "dphy_clk", "cfg_clk";

It is a bit confusing, though.

The i.MX6DL and i.MX6Q TRMs lists the following gateable input clocks, all gated by the mipi_core_cfg bit:
- ac_clk_125m from ahb_clk_root,
- ips_clk and ips_clk_s from ipg_clk_root
- cfg_clk and pll_refclk from video_27m_clk_root

Which one is "dphy_clk"?

regards
Philipp

#47 lore raw

PATCH 32/43 ARM: dts: imx: sabrelite: add video capture ports and endpoints

In reply to Steve Longerbeam

Defines the host v4l2-capture device node and an OV5642 camera sensor node on i2c2. The host capture device is a child of ipu1. An OV5642 parallel-bus endpoint is defined that connects to the host parallel-bus endpoint on CSI0, using the OF graph bindings described in Documentation/devicetree/bindings/media/video-interfaces.txt.

Note there is a pin conflict with GPIO6. This pin functions as a power input pin to the OV5642, but ENET requires it to wake-up the ARM cores on normal RX and TX packet done events (see 6261c4c8). So by default, capture is disabled, enable by uncommenting __OV5642_CAPTURE__ macro. Ethernet will still work just not quite as well.

---
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi           |   91 ++++++++++++++++++++
 2 files changed, 92 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index abc3080..90d19f8 100644
@@ -90,6 +90,7 @@ nvidia	NVIDIA
 nxp	NXP Semiconductors
 onnn	ON Semiconductor Corp.
 opencores	OpenCores.org
+ovti	OmniVision Technologies, Inc
 panasonic	Panasonic Corporation
 phytec	PHYTEC Messtechnik GmbH
 picochip	Picochip Ltd
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +91 -0

127 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#48 lore raw

Re: [PATCH 32/43] ARM: dts: imx: sabrelite: add video capture ports and endpoints

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:
[...]

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi line 485

Quoted 5 lines

+&ipu1 {

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +4 -0
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";

I'm not happy with adding the simple-bus compatible to the ipu device tree node just to instantiate a virtual subdevice. See my comment in the following mail. I think it would be better to create this platform device from code, not from the device tree if something is connected to ipu port@0 or port@1, see below.

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi line 496

Quoted 11 lines
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +11 -0
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_1
+			&pinctrl_ipu1_csi0_data_en
+		>;
+
+		/* CSI0 */
+		port@0 {

That port really is a property of the IPU itself. I have left space for ports 0 and 1 when specifying the IPU output interfaces as port 2 (DI0) and 3 (DI1).

regards
Philipp

#49 lore raw

Re: [PATCH 32/43] ARM: dts: imx: sabrelite: add video capture ports and endpoints

Am Mittwoch, den 11.06.2014, 13:38 +0200 schrieb Philipp Zabel:

Quoted 14 lines

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:
[...]

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi line 485

Quoted 5 lines

+&ipu1 {

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +4 -0
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";

I'm not happy with adding the simple-bus compatible to the ipu device tree node just to instantiate a virtual subdevice. See my comment in the following mail. I think it would be better to create this platform device from code, not from the device tree if something is connected to ipu port@0 or port@1, see below.

Quoted 15 lines

arch/arm/boot/dts/imx6qdl-sabrelite.dtsi line 496

Quoted 11 lines
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi +11 -0
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_1
+			&pinctrl_ipu1_csi0_data_en
+		>;
+
+		/* CSI0 */
+		port@0 {

That port really is a property of the IPU itself. I have left space for ports 0 and 1 when specifying the IPU output interfaces as port 2 (DI0) and 3 (DI1).

Shawn Guo's for-next tree contains the CSI ports in 1fbf4ad8e1983732aa6a1de10da0bfcc7384f626

regards
Philipp

#50 lore raw

PATCH 33/43 ARM: dts: imx6-sabresd: add video capture ports and endpoints

In reply to Steve Longerbeam

Defines the host v4l2-capture device node and two camera sensors:
parallel-bus OV5642 and MIPI CSI-2 OV5640. The host capture device is a child of ipu1. The MIPI CSI-2 receiver device is also defined.

The OV5642 is connected to the host parallel-bus endpoint on CSI0, and the OV5640 is connected to the host MIPI CSI-2 endpoint on CSI1, over virtual channel 0.

---
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi |  116 ++++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
arch/arm/boot/dts/imx6qdl-sabresd.dtsi +116 -0
index 0d816d3..2a932bb 100644
@@ -164,6 +164,30 @@
 			0x0000 /* 5:Default */
 		>;
        };
+
+	camera: ov5642@3c {
+		compatible = "ovti,ov5642";
+		clocks = <&clks 201>;
+		clock-names = "xclk";
+		reg = <0x3c>;
+		xclk = <24000000>;
+		DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+		AVDD-supply = <&vgen5_reg>;  /* 2.8v, rev C board is VGEN3
+						rev B board is VGEN5 */
+		DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+		pwdn-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;   /* SD1_DAT0 */
+		reset-gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>; /* SD1_DAT1 */
+
+		port {
+			/* With 1 endpoint per port no need for addresses. */
+			ov5642_1: endpoint {
+				remote-endpoint = <&csi0>;
+				bus-width = <12>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
 };
 
 &i2c2 {
@@ -270,6 +294,32 @@
 			};
 		};
 	};
+
+	mipi_camera: ov5640@3c {
+		compatible = "ovti,ov5640_mipi";
+		reg = <0x3c>;
+		clocks = <&clks 201>;
+		clock-names = "xclk";
+		xclk = <24000000>;
+		DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+		AVDD-supply = <&vgen5_reg>;  /* 2.8v, rev C board is VGEN3
+						rev B board is VGEN5 */
+		DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+		pwdn-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; /* SD1_DAT2 */
+		reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; /* SD1_CLK */
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			ov5640_1: endpoint@1 {
+				reg = <1>;
+				remote-endpoint = <&csi1_vc0>;
+				data-lanes = <0 1>;
+				clock-lanes = <2>;
+			};
+		};
+	};
 };
 
 &i2c3 {
@@ -303,6 +353,10 @@
 				MX6QDL_PAD_ENET_TXD1__GPIO1_IO29 0x80000000
 				MX6QDL_PAD_EIM_D22__GPIO3_IO22  0x80000000
 				MX6QDL_PAD_ENET_CRS_DV__GPIO1_IO25 0x80000000
+				MX6QDL_PAD_SD1_DAT0__GPIO1_IO16 0x80000000
+				MX6QDL_PAD_SD1_DAT1__GPIO1_IO17 0x80000000
+				MX6QDL_PAD_SD1_DAT2__GPIO1_IO19 0x80000000
+				MX6QDL_PAD_SD1_CLK__GPIO1_IO20 0x80000000
 			>;
 		};
 
@@ -496,3 +550,65 @@
 	wp-gpios = <&gpio2 1 0>;
 	status = "okay";
 };
+
+&mipi_csi2 {
+	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	/* Incoming port from sensor */
+	port {
+		mipi_csi2_0: endpoint {
+			remote-endpoint = <&ov5640_1>;
+			data-lanes = <0 1>;
+			clock-lanes = <2>;
+		};
+	};
+};
+
+&ipu1 { /* IPU1 */
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_2
+		>;
+
+		/* CSI0 */
+		port@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			/* Parallel bus */
+			csi0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&ov5642_1>;
+				bus-width = <8>;
+				data-shift = <12>; /* Lines 19:12 used */
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+
+		/* CSI1 */
+		port@1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+
+			/* MIPI CSI-2 virtual channel 0 */
+			csi1_vc0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&ov5640_1>;
+				data-lanes = <0 1>;
+				clock-lanes = <2>;
+			};
+		};
+	};
+};
Signature · 1 line
1.7.9.5
#51 lore raw

PATCH 34/43 ARM: dts: imx6-sabreauto: add video capture ports and endpoints

In reply to Steve Longerbeam

Defines the host v4l2-capture device node and the ADV7180 decoder sensor. The host capture device is a child of ipu1. The ADV7180 is connected to the host parallel-bus endpoint on CSI0.

On the sabreauto, two analog video inputs are routed to the ADV7180, composite on Ain1, and composite on Ain3. Those inputs are defined via inputs and input-names under the host endpoint node on CSI0.

Regulators and port expanders are defined which are required for the ADV7180 (power pin is via port expander gpio on i2c3). The reset pin to the port expander chip (MAX7310) is controlled by a gpio, so define the reset-gpios property to control it.

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

---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi |  149 ++++++++++++++++++++++++++++++
 1 file changed, 149 insertions(+)
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +149 -0
index 009abd6..27ac698 100644
@@ -17,6 +17,39 @@
 		reg = <0x10000000 0x80000000>;
 	};
 
+	regulators {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		reg_2p5v: regulator@0 {
+			compatible = "regulator-fixed";
+			reg = <0>;
+			regulator-name = "2P5V";
+			regulator-min-microvolt = <2500000>;
+			regulator-max-microvolt = <2500000>;
+			regulator-always-on;
+		};
+
+		reg_3p3v: regulator@1 {
+			compatible = "regulator-fixed";
+			reg = <1>;
+			regulator-name = "3P3V";
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			regulator-always-on;
+		};
+
+		reg_2p8v: regulator@2 {
+			compatible = "regulator-fixed";
+			reg = <2>;
+			regulator-name = "2P8V";
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
+			regulator-always-on;
+		};
+	};
+
 	leds {
 		compatible = "gpio-leds";
 		pinctrl-names = "default";
@@ -43,6 +76,66 @@
 		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@1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+
+			camera: adv7180@21 {
+				compatible = "adi,adv7180";
+				reg = <0x21>;
+				DOVDD-supply = <&reg_3p3v>;
+				AVDD-supply = <&reg_3p3v>;
+				DVDD-supply = <&reg_3p3v>;
+				PVDD-supply = <&reg_3p3v>;
+				pwdn-gpio = <&port_exp_b 2 0>;
+				interrupt-parent = <&gpio1>;
+				interrupts = <27 0x8>;
+
+				port {
+					adv7180_1: endpoint {
+						remote-endpoint = <&csi0>;
+						bus-width = <16>;
+					};
+				};
+			};
+
+			port_exp_a: gpio_pca953x@30 {
+				compatible = "maxim,max7310";
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x30>;
+				reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
+			};
+
+			port_exp_b: gpio_pca953x@32 {
+				compatible = "maxim,max7310";
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x32>;
+				reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
+			};
+
+			port_exp_c: gpio_pca953x@34 {
+				compatible = "maxim,max7310";
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x34>;
+				reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
+			};
+		};
+	};
 };
 
 &ecspi1 {
@@ -182,6 +275,13 @@
 	};
 };
 
+&i2c3 {
+	status = "okay";
+	clock-frequency = <400000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c3>;
+};
+
 &iomuxc {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_hog>;
@@ -192,6 +292,7 @@
 				MX6QDL_PAD_NANDF_CS2__GPIO6_IO15 0x80000000
 				MX6QDL_PAD_SD2_DAT2__GPIO1_IO13  0x80000000
 				MX6QDL_PAD_GPIO_18__SD3_VSELECT 0x17059
+				MX6QDL_PAD_SD2_DAT0__GPIO1_IO15 0x80000000
 			>;
 		};
 
@@ -265,6 +366,19 @@
 			>;
 		};
 
+		pinctrl_i2c3: i2c3grp {
+			fsl,pins = <
+				MX6QDL_PAD_GPIO_3__I2C3_SCL	0x4001b8b1
+				MX6QDL_PAD_EIM_D18__I2C3_SDA	0x4001b8b1
+			>;
+		};
+
+		pinctrl_i2c3mux: i2c3muxgrp {
+			fsl,pins = <
+				MX6QDL_PAD_EIM_A24__GPIO5_IO04 0x80000000
+			>;
+		};
+
 		pinctrl_pwm3: pwm1grp {
 			fsl,pins = <
 				MX6QDL_PAD_SD4_DAT1__PWM3_OUT		0x1b0b1
@@ -456,3 +570,38 @@
 				0x0000c000 0x1404a38e 0x00000000>;
 	};
 };
+
+&ipu1 {
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_d4_d7
+			&pinctrl_ipu1_csi0_1
+		>;
+
+		/* CSI0 */
+		port@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			/* Parallel bus */
+			csi0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&adv7180_1>;
+				bus-width = <16>;
+				data-shift = <4>; /* Lines 19:4 used */
+
+				inputs = <0x00 0x02>;
+				input-names = "ADV7180 Composite on Ain1",
+						"ADV7180 Composite on Ain3";
+			};
+		};
+	};
+};
Signature · 1 line
1.7.9.5
#52 lore raw

PATCH 35/43 ARM: dts: imx6qdl: Add simple-bus to ipu compatibility

In reply to Steve Longerbeam

The IPU can have child devices now, so add "simple-bus" to compatible list to ensure creation of the children.

---
 .../bindings/staging/imx-drm/fsl-imx-drm.txt       |    6 ++++--
 arch/arm/boot/dts/imx6q.dtsi                       |    2 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |    2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +4 -2
index 3be5ce7..dc759e4 100644
@@ -21,7 +21,9 @@ Freescale i.MX IPUv3
 ====================
 
 Required properties:
-- compatible: Should be "fsl,<chip>-ipu"
+- compatible: Should be "fsl,<chip>-ipu". The IPU can also have child
+  devices, so also must include "simple-bus" to ensure creation of the
+  children.
 - reg: should be register base and length as documented in the
   datasheet
 - interrupts: Should contain sync interrupt and error interrupt,
@@ -39,7 +41,7 @@ example:
 ipu: ipu@18000000 {
 	#address-cells = <1>;
 	#size-cells = <0>;
-	compatible = "fsl,imx53-ipu";
+	compatible = "fsl,imx53-ipu", "simple-bus";
 	reg = <0x18000000 0x080000000>;
 	interrupts = <11 10>;
 	resets = <&src 2>;
arch/arm/boot/dts/imx6q.dtsi +1 -1
index c7544f0..50e2a32 100644
@@ -149,7 +149,7 @@
 		ipu2: ipu@02800000 {
 			#address-cells = <1>;
 			#size-cells = <0>;
-			compatible = "fsl,imx6q-ipu";
+			compatible = "fsl,imx6q-ipu", "simple-bus";
 			reg = <0x02800000 0x400000>;
 			interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>,
 				     <0 7 IRQ_TYPE_LEVEL_HIGH>;
arch/arm/boot/dts/imx6qdl.dtsi +1 -1
index 00130a8..089a84a 100644
@@ -1096,7 +1096,7 @@
 		ipu1: ipu@02400000 {
 			#address-cells = <1>;
 			#size-cells = <0>;
-			compatible = "fsl,imx6q-ipu";
+			compatible = "fsl,imx6q-ipu", "simple-bus";
 			reg = <0x02400000 0x400000>;
 			interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>,
 				     <0 5 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
1.7.9.5
#53 lore raw

Re: [PATCH 35/43] ARM: dts: imx6qdl: Add simple-bus to ipu compatibility

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 15 lines

The IPU can have child devices now, so add "simple-bus" to compatible list to ensure creation of the children.

---
 .../bindings/staging/imx-drm/fsl-imx-drm.txt       |    6 ++++--
 arch/arm/boot/dts/imx6q.dtsi                       |    2 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |    2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +0 -0
index 3be5ce7..dc759e4 100644

Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt Freescale i.MX IPUv3 · line 26

Quoted 7 lines
Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +3 -1
@@ -21,7 +21,9 @@ Freescale i.MX IPUv3
 ====================
 
 Required properties:
-- compatible: Should be "fsl,<chip>-ipu"
+- compatible: Should be "fsl,<chip>-ipu". The IPU can also have child
+  devices, so also must include "simple-bus" to ensure creation of the
+  children.

This would be ok if the submodules (CSI, SMFC, IC, DC, DP, etc.) were listed as subnodes (which I don't think is a good idea). As it stands, this is a misuse of simple-bus, as the IPU does not provide access to the subdevices you are going to add through a simple MMIO mapping.

regards
Philipp

#54 lore raw

PATCH 36/43 gpio: pca953x: Add reset-gpios property

In reply to Steve Longerbeam

Add optional reset-gpios property. If present, de-assert the specified reset gpio pin to bring the chip out of reset.

---
 drivers/gpio/gpio-pca953x.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpio/gpio-pca953x.c +26 -0
index d550d8e..6e212f7 100644
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #ifdef CONFIG_OF_GPIO
 #include <linux/of_platform.h>
+#include <linux/of_gpio.h>
 #endif
 
 #define PCA953X_INPUT		0
@@ -98,6 +99,11 @@ struct pca953x_chip {
 	struct gpio_chip gpio_chip;
 	const char *const *names;
 	int	chip_type;
+
+#ifdef CONFIG_OF_GPIO
+	enum of_gpio_flags reset_gpio_flags;
+	int reset_gpio;
+#endif
 };
 
 static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val,
@@ -735,6 +741,26 @@ static int pca953x_probe(struct i2c_client *client,
 		/* If I2C node has no interrupts property, disable GPIO interrupts */
 		if (of_find_property(client->dev.of_node, "interrupts", NULL) == NULL)
 			irq_base = -1;
+
+		/* see if we need to de-assert a reset pin */
+		ret = of_get_named_gpio_flags(client->dev.of_node,
+					      "reset-gpios", 0,
+					      &chip->reset_gpio_flags);
+		if (gpio_is_valid(ret)) {
+			chip->reset_gpio = ret;
+			ret = devm_gpio_request_one(&client->dev,
+						    chip->reset_gpio,
+						    GPIOF_DIR_OUT,
+						    "pca953x_reset");
+			if (ret == 0) {
+				/* bring chip out of reset */
+				dev_info(&client->dev, "releasing reset\n");
+				gpio_set_value(chip->reset_gpio,
+					       (chip->reset_gpio_flags ==
+						OF_GPIO_ACTIVE_LOW) ? 1 : 0);
+			}
+		} else if (ret == -EPROBE_DEFER)
+			return ret;
 #endif
 	}
 
Signature · 1 line
1.7.9.5
#55 lore raw

Re: [PATCH 36/43] gpio: pca953x: Add reset-gpios property

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:
[...]

Quoted 9 lines

static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val,

drivers/gpio/gpio-pca953x.c +4 -0
@@ -735,6 +741,26 @@ static int pca953x_probe(struct i2c_client *client,
 		/* If I2C node has no interrupts property, disable GPIO interrupts */
 		if (of_find_property(client->dev.of_node, "interrupts", NULL) == NULL)
 			irq_base = -1;
+
+		/* see if we need to de-assert a reset pin */
+		ret = of_get_named_gpio_flags(client->dev.of_node,
+					      "reset-gpios", 0,

drivers/gpio/gpio-pca953x.c static int pca953x_probe(struct i2c_client *client, · line 757

Quoted 10 lines
drivers/gpio/gpio-pca953x.c +10 -0
+					      &chip->reset_gpio_flags);
+		if (gpio_is_valid(ret)) {
+			chip->reset_gpio = ret;
+			ret = devm_gpio_request_one(&client->dev,
+						    chip->reset_gpio,
+						    GPIOF_DIR_OUT,
+						    "pca953x_reset");
+			if (ret == 0) {
+				/* bring chip out of reset */
+				dev_info(&client->dev, "releasing reset\n");

I think dev_dbg would be more appropriate.

drivers/gpio/gpio-pca953x.c static int pca953x_probe(struct i2c_client *client, · line 761

Quoted 4 lines
drivers/gpio/gpio-pca953x.c +4 -0
+				gpio_set_value(chip->reset_gpio,
+					       (chip->reset_gpio_flags ==
+						OF_GPIO_ACTIVE_LOW) ? 1 : 0);
+			}

You could use the gpiod API (include/gpio/consumer.h) here and have it do the polarity handling automatically.

regards
Philipp

#56 lore raw

PATCH 37/43 ARM: imx6q: clk: Add video 27m clock

In reply to Steve Longerbeam

Adds a 27MHz clock that is a fixed /20 from the pll3_pfd1_540m clock. The MIPI CSI2 receiver depends on this clock for its D-PHY operation. Based on ENGR00275483-1 from Freescale.

---
 .../devicetree/bindings/clock/imx6q-clock.txt      |    1 +
 arch/arm/mach-imx/clk-imx6q.c                      |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/imx6q-clock.txt +1 -0
index 6aab72b..32dc74f 100644
@@ -220,6 +220,7 @@ clocks and IDs.
 	lvds2_sel		205
 	lvds1_gate		206
 	lvds2_gate		207
+	video_27m		208
 
 Examples:
 
arch/arm/mach-imx/clk-imx6q.c +2 -1
index 2b4d6ac..ca87984 100644
@@ -107,7 +107,7 @@ enum mx6q_clks {
 	sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref, usbphy1_gate,
 	usbphy2_gate, pll4_post_div, pll5_post_div, pll5_video_div, eim_slow,
 	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa, pll4_audio_div,
-	lvds1_sel, lvds2_sel, lvds1_gate, lvds2_gate, clk_max
+	lvds1_sel, lvds2_sel, lvds1_gate, lvds2_gate, video_27m, clk_max
 };
 
 static struct clk *clk[clk_max];
@@ -226,6 +226,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	clk[pll3_80m]  = imx_clk_fixed_factor("pll3_80m",  "pll3_usb_otg",   1, 6);
 	clk[pll3_60m]  = imx_clk_fixed_factor("pll3_60m",  "pll3_usb_otg",   1, 8);
 	clk[twd]       = imx_clk_fixed_factor("twd",       "arm",            1, 2);
+	clk[video_27m] = imx_clk_fixed_factor("video_27m", "pll3_pfd1_540m", 1, 20);
 
 	clk[pll4_post_div] = clk_register_divider_table(NULL, "pll4_post_div", "pll4_audio", CLK_SET_RATE_PARENT, base + 0x70, 19, 2, 0, post_div_table, &imx_ccm_lock);
 	clk[pll4_audio_div] = clk_register_divider(NULL, "pll4_audio_div", "pll4_post_div", CLK_SET_RATE_PARENT, base + 0x170, 15, 1, 0, &imx_ccm_lock);
Signature · 1 line
1.7.9.5
#57 lore raw

PATCH 38/43 media: imx6: Add device tree binding documentation

In reply to Steve Longerbeam

Add device tree binding documentation for i.MX6 media devices.

---
 Documentation/devicetree/bindings/media/imx6.txt |  433 ++++++++++++++++++++++
 1 file changed, 433 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/imx6.txt
Documentation/devicetree/bindings/media/imx6.txt new file +433 -0
new file mode 100644
index 0000000..0a4d170
@@ -0,0 +1,433 @@
+Freescale i.MX6 Video Capture
+
+v4l2-capture node
+-----------------
+
+This is the imx6 camera host interface node, and must be a child node
+of ipu1 and/or ipu2. The host node does not require reg or interrupt
+properties because it uses the facilities of its parent IPU. Only a
+compatible property is required.
+
+Required properties:
+- compatible	: "fsl,imx6-v4l2-capture";
+
+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";
+- reg           : physical base address and length of the register set;
+- clocks	: the MIPI CSI-2 receiver requires two clocks: hsi_tx
+                  (the DPHY clock, 138) and video_27m (208);
+- clock-names	: must contain "dphy_clk" followed by "cfg_clk";
+
+Optional properties:
+- interrupts	: must contain two level-triggered interrupts,
+                  in order: 100 and 101;
+
+
+Device tree nodes of the image sensors' controlled directly by the imx6
+camera host interface driver must be child nodes of their corresponding
+I2C bus controller node. The data link of these image sensors must be
+specified using the common video interfaces bindings, defined in
+video-interfaces.txt.
+
+The port nodes correspond to the IPU CSI to which sensor endpoints are
+connected, so the reg property specifies the CSI number (0 or 1).
+
+The reg property for endpoint nodes are ignored except for MIPI CSI-2
+endpoints, in which case the reg property specifies the virtual
+channel number the remote sensor is transmitting data over.
+
+Video capture is supported with the following imx6-based reference
+platforms:
+
+
+SabreLite with OV5642
+---------------------
+
+The OV5642 module is connected to CSI0 on IPU1 (the first IPU on imx6
+quad SabreLite). It's i2c bus connects to i2c bus 2, so the ov5642
+sensor node must be a child of i2c2.
+
+OV5642 Required properties:
+- compatible	: "ovti,ov5642";
+- clocks        : the OV5642 system clock (cko2, 200);
+- clock-names	: must be "xclk";
+- reg           : must be 0x3c;
+- xclk          : the system clock frequency, must be 24000000;
+- reset-gpios   : must be <&gpio1 8 0>;
+- pwdn-gpios    : must be <&gpio1 6 0>;
+
+OV5642 Endpoint Required properties:
+- remote-endpoint : must connect to camera interface endpoint on CSI0;
+- bus-width       : must be 12;
+- hsync-active    : must be 1;
+- vsync-active    : must be 1;
+
+The following is an example devicetree configuration for SabreLite:
+
+&i2c2 {
+	status = "okay";
+	clock-frequency = <100000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c2>;
+
+	camera: ov5642@3c {
+		compatible = "ovti,ov5642";
+		clocks = <&clks 200>;
+		clock-names = "xclk";
+		reg = <0x3c>;
+		xclk = <24000000>;
+		reset-gpios = <&gpio1 8 0>;
+		pwdn-gpios = <&gpio1 6 0>;
+		gp-gpios = <&gpio1 16 0>;
+
+		port {
+			ov5642_1: endpoint {
+				remote-endpoint = <&csi0>;
+				bus-width = <12>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
+};
+
+&ipu1 {
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_1
+			&pinctrl_ipu1_csi0_data_en
+		>;
+
+		/* CSI0 */
+		port@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			/* Parallel bus */
+			csi0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&ov5642_1>;
+				bus-width = <12>;
+				data-shift = <8>; /* Lines 19:8 used */
+				hsync-active = <1>;
+				vync-active = <1>;
+			};
+		};
+	};
+};
+
+
+
+SabreAuto with ADV7180
+----------------------
+
+On the SabreAuto, an on-board ADV7180 SD decoder is connected via a
+parallel bus on IPU1 CSI0.
+
+Two analog video inputs are routed to the ADV7180 on the SabreAuto,
+composite on Ain1, and composite on Ain3. Those inputs are defined
+via inputs and input-names properties under the host endpoint node
+on CSI0.
+
+Regulators and port expanders are required for the ADV7180 (power pin
+is via port expander gpio on i2c3). The reset pin to the port expander
+chip (MAX7310) is controlled by a gpio, so a reset-gpios property must
+be defined under the port expander node to control it.
+
+The sabreauto uses a steering pin to select between the SDA signal on
+i2c3 bus, and a data-in pin for an SPI NOR chip. i2cmux can be used to
+control this steering pin. Idle state of the i2cmux selects SPI NOR.
+This is not 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).
+
+Host Interface Endpoint Required Properties:
+- inputs        : list of input mux values, must be 0x00 followed by
+                  0x02 on SabreAuto;
+- input-names   : names of the inputs;
+
+ADV7180 Required properties:
+- compatible    : "adi,adv7180";
+- reg           : must be 0x21;
+
+ADV7180 Optional properties:
+- DOVDD-supply  : DOVDD regulator supply;
+- AVDD-supply   : AVDD regulator supply;
+- DVDD-supply   : DVDD regulator supply;
+- PVDD-supply   : PVDD regulator supply;
+- pwdn-gpio     : gpio to control ADV7180 power pin, must be
+                  <&port_exp_b 2 0> on SabreAuto;
+- interrupts    : interrupt from ADV7180, must be <27 0x8> on SabreAuto;
+- interrupt-parent : must be <&gpio1> on SabreAuto;
+
+ADV7180 Endpoint Required properties:
+- remote-endpoint : must connect to camera interface endpoint on CSI0;
+- bus-width       : must be 16;
+
+
+The following is an example devicetree configuration for SabreAuto:
+
+/ {
+	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@1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+
+			camera: adv7180@21 {
+				compatible = "adi,adv7180";
+				reg = <0x21>;
+				DOVDD-supply = <&reg_3p3v>;
+				AVDD-supply = <&reg_3p3v>;
+				DVDD-supply = <&reg_3p3v>;
+				PVDD-supply = <&reg_3p3v>;
+				pwdn-gpio = <&port_exp_b 2 0>;
+				interrupt-parent = <&gpio1>;
+				interrupts = <27 0x8>;
+
+				port {
+					adv7180_1: endpoint {
+						remote-endpoint = <&csi0>;
+						bus-width = <16>;
+					};
+				};
+			};
+
+			port_exp_b: gpio_pca953x@32 {
+				compatible = "maxim,max7310";
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x32>;
+				reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
+			};
+
+		};
+	};
+};
+
+&ipu1 {
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_d4_d7
+			&pinctrl_ipu1_csi0_1
+		>;
+
+		/* CSI0 */
+		port@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			/* Parallel bus */
+			csi0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&adv7180_1>;
+				bus-width = <16>;
+				data-shift = <4>; /* Lines 19:4 used */
+
+				inputs = <0x00 0x02>;
+				input-names = "ADV7180 Composite on Ain1",
+						"ADV7180 Composite on Ain3";
+			};
+		};
+	};
+};
+
+
+
+SabreSD with OV5642 and MIPI CSI-2 OV5640
+-----------------------------------------
+
+On the SabreSD, two camera sensors are supported: a parallel interface
+OV5642 on IPU1 CSI0, and a MIPI CSi-2 OV5640 on IPU1 CSI1. The OV5642
+connects to i2c bus 1 (i2c1) and the OV5640 to i2c bus 2 (i2c2).
+
+The mipi_csi2 receiver node must be enabled and connected via
+remote-endpoint to the OV5640 MIPI CSI-2 endpoint.
+
+OV5642 properties are as described above on SabreLite.
+
+OV5640 Required properties:
+- compatible	: "ovti,ov5640_mipi";
+- clocks        : the OV5640 system clock (cko, 201);
+- clock-names	: must be "xclk";
+- reg           : must be 0x3c;
+- xclk          : the system clock frequency, must be 24000000;
+- reset-gpios   : must be <&gpio1 20 1>;
+- pwdn-gpios    : must be <&gpio1 19 0>;
+
+OV5640 Optional properties:
+- DOVDD-supply  : DOVDD regulator supply;
+- AVDD-supply   : AVDD regulator supply;
+- DVDD-supply   : DVDD regulator supply;
+
+OV5640 MIPI CSI-2 Endpoint Required properties:
+- remote-endpoint : must connect to camera interface virtual channel 0
+                    endpoint on CSI1;
+- reg             : must be 1;
+- data-lanes      : must be <0 1>;
+- clock-lanes     : must be <2>;
+
+
+The following is an example devicetree configuration for SabreSD:
+
+&i2c1 {
+	clock-frequency = <100000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c1>;
+	status = "okay";
+
+	camera: ov5642@3c {
+		compatible = "ovti,ov5642";
+		clocks = <&clks 201>;
+		clock-names = "xclk";
+		reg = <0x3c>;
+		xclk = <24000000>;
+		DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+		AVDD-supply = <&vgen5_reg>;  /* 2.8v, rev C board is VGEN3
+						rev B board is VGEN5 */
+		DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+		pwdn-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;   /* SD1_DAT0 */
+		reset-gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>; /* SD1_DAT1 */
+
+		port {
+			ov5642_1: endpoint {
+				remote-endpoint = <&csi0>;
+				bus-width = <12>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
+};
+
+&i2c2 {
+	clock-frequency = <100000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c2>;
+	status = "okay";
+
+	mipi_camera: ov5640@3c {
+		compatible = "ovti,ov5640_mipi";
+		reg = <0x3c>;
+		clocks = <&clks 201>;
+		clock-names = "xclk";
+		xclk = <24000000>;
+		DOVDD-supply = <&vgen4_reg>; /* 1.8v */
+		AVDD-supply = <&vgen5_reg>;  /* 2.8v, rev C board is VGEN3
+						rev B board is VGEN5 */
+		DVDD-supply = <&vgen2_reg>;  /* 1.5v*/
+		pwdn-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; /* SD1_DAT2 */
+		reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>; /* SD1_CLK */
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			ov5640_1: endpoint@1 {
+				reg = <1>;
+				remote-endpoint = <&csi1_vc0>;
+				data-lanes = <0 1>;
+				clock-lanes = <2>;
+			};
+		};
+	};
+};
+
+&mipi_csi2 {
+	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	port {
+		mipi_csi2_0: endpoint {
+			remote-endpoint = <&ov5640_1>;
+			data-lanes = <0 1>;
+			clock-lanes = <2>;
+		};
+	};
+};
+
+&ipu1 { /* IPU1 */
+	status = "okay";
+
+	v4l2-capture {
+		compatible = "fsl,imx6-v4l2-capture";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "okay";
+		pinctrl-names = "default";
+		pinctrl-0 = <
+			&pinctrl_ipu1_csi0_2
+		>;
+
+		/* CSI0 */
+		port@0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0>;
+
+			/* Parallel bus */
+			csi0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&ov5642_1>;
+				bus-width = <8>;
+				data-shift = <12>; /* Lines 19:12 used */
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+
+		/* CSI1 */
+		port@1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <1>;
+
+			/* MIPI CSI-2 virtual channel 0 */
+			csi1_vc0: endpoint@0 {
+				reg = <0>;
+				remote-endpoint = <&ov5640_1>;
+				data-lanes = <0 1>;
+				clock-lanes = <2>;
+			};
+		};
+	};
+};
+
+
Signature · 1 line
1.7.9.5
#58 lore raw

PATCH 39/43 media: Add new camera interface driver for i.MX6

In reply to Steve Longerbeam

This is a V4L2 camera interface driver for i.MX6. See Documentation/video4linux/mx6_camera.txt.

---
 Documentation/video4linux/mx6_camera.txt         |  188 ++
 drivers/staging/media/Kconfig                    |    2 +
 drivers/staging/media/Makefile                   |    1 +
 drivers/staging/media/imx6/Kconfig               |   25 +
 drivers/staging/media/imx6/Makefile              |    1 +
 drivers/staging/media/imx6/capture/Kconfig       |   11 +
 drivers/staging/media/imx6/capture/Makefile      |    4 +
 drivers/staging/media/imx6/capture/mipi-csi2.c   |  322 ++++
 drivers/staging/media/imx6/capture/mx6-camif.c   | 2235 ++++++++++++++++++++++
 drivers/staging/media/imx6/capture/mx6-camif.h   |  197 ++
 drivers/staging/media/imx6/capture/mx6-encode.c  |  775 ++++++++
 drivers/staging/media/imx6/capture/mx6-preview.c |  748 ++++++++
 include/media/imx6.h                             |   18 +
 13 files changed, 4527 insertions(+)
 create mode 100644 Documentation/video4linux/mx6_camera.txt
 create mode 100644 drivers/staging/media/imx6/Kconfig
 create mode 100644 drivers/staging/media/imx6/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/Kconfig
 create mode 100644 drivers/staging/media/imx6/capture/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/mipi-csi2.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.h
 create mode 100644 drivers/staging/media/imx6/capture/mx6-encode.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-preview.c
 create mode 100644 include/media/imx6.h
Documentation/video4linux/mx6_camera.txt new file +188 -0
new file mode 100644
index 0000000..d712f91
@@ -0,0 +1,188 @@
+                         i.MX6 Video Capture Driver
+                         ==========================
+
+Introduction
+------------
+
+The Freescale i.MX6 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 subunits:
+
+- Image DMA Controller (IDMAC)
+- Camera Serial Interface (CSI)
+- Image Converter (IC)
+- Sensor Multi-FIFO Controller (SMFC)
+- Image Rotator (IRT)
+- Video De-Interlace Controller (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.
+
+The CSI is the frontend capture unit that interfaces directly with
+capture devices over Parallel, BT.656, and MIPI CSI-2 busses.
+
+The IC handles color-space conversion, resizing, and rotation
+operations.
+
+The SMFC is used to send image frames directly to memory, bypassing the
+IC. The SMFC is used when no color-space conversion or resizing is
+required, i.e. the requested V4L2 formats and color-space are identical
+to raw frames from the capture device.
+
+The IRT carries out 90 and 270 degree image rotation operations.
+
+Finally, the VDIC handles the conversion of interlaced video to
+progressive, with support for different motion compensation modes (low
+and high).
+
+For more info, refer to the latest versions of the i.MX6 reference
+manuals listed under References.
+
+
+Features
+--------
+
+Some of the features of this driver include:
+
+- Supports parallel, BT.565, and MIPI CSI-2 interfaces.
+
+- Camera Preview mode.
+
+- Multiple subdev sensors can be registered and controlled by a single
+  interface driver instance. Input enumeration will list every registered
+  sensor's inputs and input names, and setting an input will switch to
+  a different sensor if the input index is handled by a different sensor.
+
+- Simultaneous streaming from two separate sensors is possible with two
+  interface driver instances, each instance controlling a different
+  sensor. This is currently possible with the SabreSD reference board
+  with OV5642 and MIPI CSI-2 OV5640 sensors.
+
+- Separate rotation control for both streaming and preview. Streaming
+  rotation control is via main video device node, and preview rotation
+  control via subdevice node.
+
+- Scaling and color-space conversion for both streaming and preview.
+
+- Many pixel formats supported (RGB, packed and planar YUV, partial
+  planar YUV).
+
+- Full device-tree support using OF graph bindings.
+
+- Analog decoder input video source hot-swap support (during streaming)
+  via decoder status change subdev notification.
+
+- MMAP, USERPTR, and DMABUF importer/exporter buffers supported.
+
+- De-interlacing is supported via simple even/odd line interleaving
+  which is a facility of the IDMAC. The VDIC is not yet supported, but
+  plans are in the works to allow more advanced motion compensation.
+
+
+
+Usage Notes
+-----------
+
+The i.MX6 capture driver is a standardized driver that supports the
+following community V4L2 tools:
+
+- v4l2-ctl
+- v4l2-cap
+- v4l2src gstreamer plugin
+
+
+The following platforms have been tested:
+
+
+SabreLite with parallel-interface OV5642
+----------------------------------------
+
+This platform requires the OmniVision OV5642 module with a parallel
+camera interface from Boundary Devices for the SabreLite
+(http://boundarydevices.com/products/nit6x_5mp/).
+
+There is a pin conflict between OV5642 and ethernet devices on this
+platform, so by default video capture is disabled in the device tree. To
+enable video capture, edit arch/arm/boot/dts/imx6qdl-sabrelite.dtsi and
+uncomment the macro __OV5642_CAPTURE__.
+
+
+SabreAuto with ADV7180 decoder
+------------------------------
+
+This platform accepts Composite Video analog inputs on Ain1 (connector
+J42) and Ain3 (connector J43).
+
+To switch to Ain1:
+
+# v4l2-ctl -i0
+
+To switch to Ain3:
+
+# v4l2-ctl -i1
+
+
+SabreSD with MIPI CSI-2 OV5640
+------------------------------
+
+The default device tree for SabreSD includes endpoints 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. The OV5640 module connects to
+MIPI connector J5 (sorry I don't have the compatible module part number
+or URL).
+
+Inputs are registered for both the OV5642 and OV5640, and by default the
+OV5642 is selected. To switch to the OV5640:
+
+# v4l2-ctl -i1
+
+
+Preview Notes
+-------------
+
+Preview accepts a framebuffer physaddr via standard VIDIOC_S_FBUF. The
+driver is agnostic about the source of this framebuffer, it could come
+from a DRM-based background or overlay plane, or from legacy fbdev.
+
+Preview is implemented as a sub-device, and exports controls to
+allow preview horizontal/vertical flip and rotation settings independent
+of the same settings for streaming. These controls are available on
+/dev/v4l-subdev0.
+
+
+Known Issues
+------------
+
+There is one currently known issue. 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/imx6/capture/
+include/media/imx6.h
+
+
+References
+----------
+
+[1] "i.MX 6Dual/6Quad Applications Processor Reference Manual"
+[2] "i.MX 6Solo/6DualLite Applications Processor Reference Manual"
+
+
+Authors
+-------
+Steve Longerbeam <[email protected]>
+Dmitry Eremin-Solenikov <[email protected]>
+Jiada Wang <[email protected]>
+Vladimir Zapolskiy <[email protected]>
+
+Copyright (C) 2012-2014 Mentor Graphics Inc.
drivers/staging/media/Kconfig +2 -0
index a9f2e63..fd94c05 100644
@@ -31,6 +31,8 @@ source "drivers/staging/media/dt3155v4l/Kconfig"
 
 source "drivers/staging/media/go7007/Kconfig"
 
+source "drivers/staging/media/imx6/Kconfig"
+
 source "drivers/staging/media/msi3101/Kconfig"
 
 source "drivers/staging/media/omap24xx/Kconfig"
drivers/staging/media/Makefile +1 -0
index 8e2c5d2..6faee43 100644
@@ -5,6 +5,7 @@ obj-$(CONFIG_LIRC_STAGING)	+= lirc/
 obj-$(CONFIG_SOLO6X10)		+= solo6x10/
 obj-$(CONFIG_VIDEO_DT3155)	+= dt3155v4l/
 obj-$(CONFIG_VIDEO_GO7007)	+= go7007/
+obj-$(CONFIG_VIDEO_IMX6)	+= imx6/
 obj-$(CONFIG_USB_MSI3101)	+= msi3101/
 obj-$(CONFIG_VIDEO_DM365_VPFE)	+= davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)	+= omap4iss/
drivers/staging/media/imx6/Kconfig new file +25 -0
new file mode 100644
index 0000000..6d94f3f
@@ -0,0 +1,25 @@
+config VIDEO_IMX6
+	tristate "i.MX6 V4L2 devices"
+	depends on VIDEO_V4L2 && ARCH_MXC && DRM_IMX_IPUV3_CORE
+	default y
+	---help---
+	  Say yes here to enable support for video4linux capture for
+	  the i.MX6 SOC.
+
+config VIDEO_IMX6_CAMERA
+	tristate "i.MX6 Camera Interface driver"
+	depends on VIDEO_IMX6 && VIDEO_DEV && I2C
+	select VIDEOBUF2_DMA_CONTIG
+	default y
+	---help---
+	  A video4linux capture driver for i.MX6 SOC. Some of the
+	  features of this driver include simultaneous streaming
+	  and preview (overlay) support, MIPI CSI-2 sensor support,
+	  separate rotation control for both streaming and preview,
+	  scaling and colorspace conversion, simultaneous capture
+	  from separate sensors, dmabuf importer/exporter, and full
+	  devicetree support.
+
+if VIDEO_IMX6_CAMERA
+source "drivers/staging/media/imx6/capture/Kconfig"
+endif
drivers/staging/media/imx6/Makefile new file +1 -0
new file mode 100644
index 0000000..e0ed058
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_IMX6_CAMERA) += capture/
drivers/staging/media/imx6/capture/Kconfig new file +11 -0
new file mode 100644
index 0000000..ee4f017
@@ -0,0 +1,11 @@
+menu "i.MX6 Camera Sensors"
+
+config IMX6_MIPI_CSI2
+       tristate "MIPI CSI2 Receiver Driver"
+       depends on VIDEO_IMX6_CAMERA
+       default y
+       ---help---
+         MIPI CSI-2 Receiver driver support. This driver is required
+	 for sensor drivers with a MIPI CSI2 interface.
+
+endmenu
drivers/staging/media/imx6/capture/Makefile new file +4 -0
new file mode 100644
index 0000000..832d75d
@@ -0,0 +1,4 @@
+mx6-camera-objs := mx6-camif.o mx6-encode.o mx6-preview.o
+
+obj-$(CONFIG_VIDEO_IMX6_CAMERA) += mx6-camera.o
+obj-$(CONFIG_IMX6_MIPI_CSI2) += mipi-csi2.o
drivers/staging/media/imx6/capture/mipi-csi2.c new file +322 -0

322 lines not on this page · raw message

drivers/staging/media/imx6/capture/mx6-camif.c new file +2235 -0

2,235 lines not on this page · raw message

drivers/staging/media/imx6/capture/mx6-camif.h new file +197 -0

197 lines not on this page · raw message

drivers/staging/media/imx6/capture/mx6-encode.c new file +775 -0

2 lines not on this page · raw message

drivers/staging/media/imx6/capture/mx6-preview.c new file +748 -0

748 lines not on this page · raw message

include/media/imx6.h new file +18 -0
new file mode 100644
index 0000000..232378b

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#59 lore raw

Re: [PATCH 39/43] media: Add new camera interface driver for i.MX6

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 2 lines

This is a V4L2 camera interface driver for i.MX6. See Documentation/video4linux/mx6_camera.txt.

The CSI and ICs part are not i.MX6 specific. The only difference between i.MX5 and i.MX6DL (besides register offsets and some minor changes) are external to the IPU: the input multiplexers and the MIPI CSI-2 support.

Can you split the mipi-csi2 driver into a separate patch?

Quoted 16 lines
---
 Documentation/video4linux/mx6_camera.txt         |  188 ++
 drivers/staging/media/Kconfig                    |    2 +
 drivers/staging/media/Makefile                   |    1 +
 drivers/staging/media/imx6/Kconfig               |   25 +
 drivers/staging/media/imx6/Makefile              |    1 +
 drivers/staging/media/imx6/capture/Kconfig       |   11 +
 drivers/staging/media/imx6/capture/Makefile      |    4 +
 drivers/staging/media/imx6/capture/mipi-csi2.c   |  322 ++++
 drivers/staging/media/imx6/capture/mx6-camif.c   | 2235 ++++++++++++++++++++++
 drivers/staging/media/imx6/capture/mx6-camif.h   |  197 ++
Quoted 2 lines
 drivers/staging/media/imx6/capture/mx6-encode.c  |  775 ++++++++
 drivers/staging/media/imx6/capture/mx6-preview.c |  748 ++++++++

Except for the v4l2_controls, these two drivers are nearly the same. The same is true for the encoder/preview helper functions in mx6-camif.c.

To me it seems that it would be better to handle the IC as its own v4l2_subdev supporting the encoder and preview roles, use the media controller API to handle the connections between CSI/SMFC/IC, and have a single CSI v4l2_subdev for each CSI instead of duplicating the same code with minor differences.

[...]

drivers/staging/media/imx6/capture/mipi-csi2.c line 96

Quoted 6 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +6 -0
+static void __mx6csi2_enable(struct mx6csi2_dev *csi2, bool enable)
+{
+	if (enable) {
+		mx6csi2_write(csi2, 0xffffffff, CSI2_PHY_SHUTDOWNZ);
+		mx6csi2_write(csi2, 0xffffffff, CSI2_DPHY_RSTZ);
+		mx6csi2_write(csi2, 0xffffffff, CSI2_RESETN);

I know the Freescale does this, but according to the documentation only the LSB is the reset/shutdown bit. Doesn't writing 0x1 work here?

Quoted 14 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +14 -0
+	} else {
+		mx6csi2_write(csi2, 0x0, CSI2_PHY_SHUTDOWNZ);
+		mx6csi2_write(csi2, 0x0, CSI2_DPHY_RSTZ);
+		mx6csi2_write(csi2, 0x0, CSI2_RESETN);
+	}
+}
+
+static void mx6csi2_reset(struct mx6csi2_dev *csi2)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&csi2->lock, flags);
+
+	__mx6csi2_enable(csi2, false);

drivers/staging/media/imx6/capture/mipi-csi2.c line 129

Quoted 10 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +10 -0
+
+	mx6csi2_write(csi2, 0x00000001, CSI2_PHY_TST_CTRL0);
+	mx6csi2_write(csi2, 0x00000000, CSI2_PHY_TST_CTRL1);
+	mx6csi2_write(csi2, 0x00000000, CSI2_PHY_TST_CTRL0);
+	mx6csi2_write(csi2, 0x00000002, CSI2_PHY_TST_CTRL0);
+	mx6csi2_write(csi2, 0x00010044, CSI2_PHY_TST_CTRL1);
+	mx6csi2_write(csi2, 0x00000000, CSI2_PHY_TST_CTRL0);
+	mx6csi2_write(csi2, 0x00000014, CSI2_PHY_TST_CTRL1);
+	mx6csi2_write(csi2, 0x00000002, CSI2_PHY_TST_CTRL0);
+	mx6csi2_write(csi2, 0x00000000, CSI2_PHY_TST_CTRL0);

A comment documenting that this writes 0x14 to D-PHY register 0x44 using the 8-bit test interface would be nice. Even nicer would be to know what this actually does, but I don't have the D-PHY documentation.

Or how about

#define PHY_CTRL0_TESTCLR            BIT(0)
#define PHY_CTRL0_TESTCLK            BIT(1)
#define PHY_CTRL1_TESTEN             BIT(16)
Quoted 6 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +6 -0
+	__mx6csi2_enable(csi2, true);
+
+	spin_unlock_irqrestore(&csi2->lock, flags);
+}
+
+static int mx6csi2_dphy_wait(struct mx6csi2_dev *csi2)

drivers/staging/media/imx6/capture/mipi-csi2.c line 146

Quoted 10 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +10 -0
+{
+	u32 reg;
+	int i;
+
+	/* wait for mipi sensor ready */
+	for (i = 0; i < 50; i++) {
+		reg = mx6csi2_read(csi2, CSI2_PHY_STATE);
+		if (reg != 0x200)
+			break;
+		usleep_range(10000, 10001);

This is very specific. I'd use a broader range here.

[...]

drivers/staging/media/imx6/capture/mipi-csi2.c line 287

Quoted 12 lines
drivers/staging/media/imx6/capture/mipi-csi2.c new file +12 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+	if (!res || csi2->intr1 < 0 || csi2->intr2 < 0) {
+		v4l2_err(&csi2->sd, "failed to get platform resources\n");
+		return -ENODEV;
+	}
+
+	csi2->base = devm_ioremap(&pdev->dev, res->start, PAGE_SIZE);
+	if (!csi2->base) {
+		v4l2_err(&csi2->sd, "failed to map CSI-2 registers\n");
+		return -ENOMEM;
+	}

This can be shortened with devm_ioremap_resource, which also already handles the error message.

[...]

Quoted 7 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +7 -0
+/*
+ * Turn current sensor power on/off according to power_count.
+ */
+static int sensor_set_power(struct mx6cam_dev *dev, int on)
+{
+	struct mx6cam_endpoint *ep = dev->ep;
+	struct v4l2_subdev *sd = ep->sd;

drivers/staging/media/imx6/capture/mx6-camif.c line 429

Quoted 10 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +10 -0
+	int ret;
+
+	if (on && ep->power_count++ > 0)
+		return 0;
+	else if (!on && (ep->power_count == 0 || --ep->power_count > 0))
+		return 0;
+
+	ret = v4l2_subdev_call(sd, core, s_power, on);
+	return ret != -ENOIOCTLCMD ? ret : 0;
+}

All of this assumes a single sensor device connected to the CSI endpoint. If there are further multiplexers, FPGA devices, or other encoders in the chain, this will only power up the last element.

[...]

drivers/staging/media/imx6/capture/mx6-camif.c line 1094

Quoted 2 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +2 -0
+static int vidioc_g_input(struct file *file, void *priv, unsigned int *index)
+static int vidioc_s_input(struct file *file, void *priv, unsigned int index)

These also limit the input path to a very simple linear list of options. Any use case a bit more complicated than single sensors each connected directly to parallel CSI or MIPI CSI-2 ports can't be described by this.

Granted, the most complicated cases I've seen in the wild so far are either two cameras and an external multiplexer on the same parallel bus and a single FPGA with two outputs connected to both CSIs. Still, using the media controller API here would be much more future proof. Imagine, for example, eight MIPI CSI-2 cameras connected to a CSI-2 multiplexer and that connected to the i.MX6 CSI2 input.

Quoted 1 line

+static int vidioc_querybuf(struct file *file, void *priv,

[...]

drivers/staging/media/imx6/capture/mx6-camif.c line 1371

Quoted 10 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +10 -0
+static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
+{
+	struct mx6cam_ctx *ctx = file2ctx(file);
+	struct vb2_queue *vq = &ctx->dev->buffer_queue;
+
+	if (!ctx->io_allowed)
+		return -EBUSY;
+
+	return vb2_qbuf(vq, buf);
+}

What is up the the io_allowed handling here? If not for that, you could just use the vb2_ioctl_* helpers for a lot of these.

[...]

drivers/staging/media/imx6/capture/mx6-camif.c line 1748

Quoted 2 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +2 -0
+static unsigned int mx6cam_poll(struct file *file,
+				 struct poll_table_struct *wait)

vb2_fop_poll

Quoted 1 line

+static int mx6cam_mmap(struct file *file, struct vm_area_struct *vma)

vb2_fop_mmap

[...]

drivers/staging/media/imx6/capture/mx6-camif.c line 1890

Quoted 9 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +9 -0
+static int mx6cam_add_csi2_receiver(struct mx6cam_dev *dev)
+{
+	struct platform_device *pdev;
+	struct device_node *node;
+	int ret = -EPROBE_DEFER;
+
+	node = of_find_compatible_node(NULL, NULL, "fsl,imx6-mipi-csi2");
+	if (!node)
+		return 0;

Why not connect the mipi-csi2 node to the ipu csi input port via OF graph bindings?

Quoted 37 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +37 -0
+/* parse inputs property from v4l2_of_endpoint node */
+static int mx6cam_parse_inputs(struct mx6cam_dev *dev,
+			       struct device_node *node,
+			       int next_input,
+			       struct mx6cam_endpoint *ep)
+{
+	struct mx6cam_sensor_input *epinput = &ep->sensor_input;
+	int ret, i;
+
+	for (i = 0; i < MX6CAM_MAX_INPUTS; i++) {
+		const char *input_name;
+		u32 val;
+
+		ret = of_property_read_u32_index(node, "inputs", i, &val);
+		if (ret)
+			break;
+
+		epinput->value[i] = val;
+
+		ret = of_property_read_string_index(node, "input-names", i,
+						    &input_name);
+		if (!ret)
+			strncpy(epinput->name[i], input_name,
+				sizeof(epinput->name[i]));
+		else
+			snprintf(epinput->name[i], sizeof(epinput->name[i]),
+				 "%s-%d", ep->sd->name, i);
+
+		val = 0;
+		ret = of_property_read_u32_index(node, "input-caps", i, &val);
+		epinput->caps[i] = val;
+	}
+
+	epinput->num = i;
+
+	/* if no inputs provided just assume a single input */
+	if (epinput->num == 0) {

drivers/staging/media/imx6/capture/mx6-camif.c line 1972

Quoted 10 lines
drivers/staging/media/imx6/capture/mx6-camif.c new file +10 -0
+		epinput->num = 1;
+		epinput->caps[0] = 0;
+		strncpy(epinput->name[0], ep->sd->name,
+			sizeof(epinput->name[0]));
+	}
+
+	epinput->first = next_input;
+	epinput->last = next_input + epinput->num - 1;
+	return epinput->last + 1;
+}

I don't see why this is necessary when all possible input paths are already described via the OF graph bindings.

regards
Philipp

#60 lore raw

PATCH 40/43 media: imx6: Add support for MIPI CSI-2 OV5640

In reply to Steve Longerbeam

This driver is based on ov5640_mipi.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily for code cleanup and converted from int-device to subdev.

---
 drivers/staging/media/imx6/capture/Kconfig       |    8 +
 drivers/staging/media/imx6/capture/Makefile      |    1 +
 drivers/staging/media/imx6/capture/ov5640-mipi.c | 2158 ++++++++++++++++++++++
 3 files changed, 2167 insertions(+)
 create mode 100644 drivers/staging/media/imx6/capture/ov5640-mipi.c
drivers/staging/media/imx6/capture/Kconfig +8 -0
index ee4f017..6d81e3f 100644
@@ -8,4 +8,12 @@ config IMX6_MIPI_CSI2
          MIPI CSI-2 Receiver driver support. This driver is required
 	 for sensor drivers with a MIPI CSI2 interface.
 
+config IMX6_CAMERA_OV5640_MIPI
+       tristate "OmniVision OV5640 MIPI CSI-2 camera support"
+       depends on VIDEO_IMX6_CAMERA
+       select IMX6_MIPI_CSI2
+       default y
+       ---help---
+         MIPI CSI-2 OV5640 Camera support.
+
 endmenu
drivers/staging/media/imx6/capture/Makefile +1 -0
index 832d75d..6aaa4cc 100644
@@ -2,3 +2,4 @@ mx6-camera-objs := mx6-camif.o mx6-encode.o mx6-preview.o
 
 obj-$(CONFIG_VIDEO_IMX6_CAMERA) += mx6-camera.o
 obj-$(CONFIG_IMX6_MIPI_CSI2) += mipi-csi2.o
+obj-$(CONFIG_IMX6_CAMERA_OV5640_MIPI) += ov5640-mipi.o
drivers/staging/media/imx6/capture/ov5640-mipi.c new file +2158 -0

2,158 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#61 lore raw

Re: [PATCH 40/43] media: imx6: Add support for MIPI CSI-2 OV5640

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

drivers/staging/media/imx6/capture/ov5640-mipi.c line 2131

Quoted 2 lines
drivers/staging/media/imx6/capture/ov5640-mipi.c new file +2 -0
+static const struct i2c_device_id ov5640_id[] = {
+	{"ov5640_mipi", 0},

Is there really a different ov5640_mipi chip as opposed to ov5640? I suspect this could be well configured in the OF graph endpoint.

regards
Philipp

#62 lore raw

PATCH 41/43 media: imx6: Add support for Parallel OV5642

In reply to Steve Longerbeam

This driver is based on ov5642.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily for code cleanup and converted from int-device to subdev.

---
 drivers/staging/media/imx6/capture/Kconfig  |    7 +
 drivers/staging/media/imx6/capture/Makefile |    1 +
 drivers/staging/media/imx6/capture/ov5642.c | 4258 +++++++++++++++++++++++++++
 3 files changed, 4266 insertions(+)
 create mode 100644 drivers/staging/media/imx6/capture/ov5642.c
drivers/staging/media/imx6/capture/Kconfig +7 -0
index 6d81e3f..5e6a610 100644
@@ -8,6 +8,13 @@ config IMX6_MIPI_CSI2
          MIPI CSI-2 Receiver driver support. This driver is required
 	 for sensor drivers with a MIPI CSI2 interface.
 
+config IMX6_CAMERA_OV5642
+       tristate "OmniVision OV5642 Parallel camera support"
+       depends on VIDEO_IMX6_CAMERA
+       default y
+       ---help---
+         Parallel interface OV5642 camera support.
+
 config IMX6_CAMERA_OV5640_MIPI
        tristate "OmniVision OV5640 MIPI CSI-2 camera support"
        depends on VIDEO_IMX6_CAMERA
drivers/staging/media/imx6/capture/Makefile +1 -0
index 6aaa4cc..bcb2c16 100644
@@ -3,3 +3,4 @@ mx6-camera-objs := mx6-camif.o mx6-encode.o mx6-preview.o
 obj-$(CONFIG_VIDEO_IMX6_CAMERA) += mx6-camera.o
 obj-$(CONFIG_IMX6_MIPI_CSI2) += mipi-csi2.o
 obj-$(CONFIG_IMX6_CAMERA_OV5640_MIPI) += ov5640-mipi.o
+obj-$(CONFIG_IMX6_CAMERA_OV5642) += ov5642.o
drivers/staging/media/imx6/capture/ov5642.c new file +4258 -0

2,983 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#63 lore raw

PATCH 42/43 media: imx6: Add support for ADV7180 Video Decoder

In reply to Steve Longerbeam

This driver is based on adv7180.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily for code cleanup and converted from int-device to subdev.

---
 drivers/staging/media/imx6/capture/Kconfig   |    7 +
 drivers/staging/media/imx6/capture/Makefile  |    1 +
 drivers/staging/media/imx6/capture/adv7180.c | 1298 ++++++++++++++++++++++++++
 3 files changed, 1306 insertions(+)
 create mode 100644 drivers/staging/media/imx6/capture/adv7180.c
drivers/staging/media/imx6/capture/Kconfig +7 -0
index 5e6a610..ee4ed8a 100644
@@ -23,4 +23,11 @@ config IMX6_CAMERA_OV5640_MIPI
        ---help---
          MIPI CSI-2 OV5640 Camera support.
 
+config IMX6_CAMERA_ADV7180
+       tristate "Analog Devices ADV7180 Video Decoder support"
+       depends on VIDEO_IMX6_CAMERA
+       default y
+       ---help---
+         Analog Devices ADV7180 Video Decoder support.
+
 endmenu
drivers/staging/media/imx6/capture/Makefile +1 -0
index bcb2c16..d6b456c 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_VIDEO_IMX6_CAMERA) += mx6-camera.o
 obj-$(CONFIG_IMX6_MIPI_CSI2) += mipi-csi2.o
 obj-$(CONFIG_IMX6_CAMERA_OV5640_MIPI) += ov5640-mipi.o
 obj-$(CONFIG_IMX6_CAMERA_OV5642) += ov5642.o
+obj-$(CONFIG_IMX6_CAMERA_ADV7180) += adv7180.o
drivers/staging/media/imx6/capture/adv7180.c new file +1298 -0

1,298 lines not on this page · raw message

Signature · 1 line
1.7.9.5
reviewer
#64 lore raw

Re: [PATCH 42/43] media: imx6: Add support for ADV7180 Video Decoder

Hi Steve,

Quoted 9 lines · Steve Longerbeam

This driver is based on adv7180.c from Freescale imx_3.10.17_1.0.0_beta branch, modified heavily for code cleanup and converted from int-device to subdev.

---
 drivers/staging/media/imx6/capture/Kconfig   |    7 +
 drivers/staging/media/imx6/capture/Makefile  |    1 +
 drivers/staging/media/imx6/capture/adv7180.c | 1298 ++++++++++++++++++++++++++

We should use drivers/media/i2c/adv7180.c instead, right?

#65 lore raw

PATCH 43/43 ARM: imx_v6_v7_defconfig: Enable video4linux drivers

In reply to Steve Longerbeam

Enable imx6 staging v4l2 drivers as modules. For video capture on the SabreAuto, the ADV7180 video decoder also requires the i2c-mux-gpio and the max7310 port expander.

---
 arch/arm/configs/imx_v6_v7_defconfig |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/configs/imx_v6_v7_defconfig +4 -0
index 09e9743..cd1099d 100644
@@ -148,6 +148,7 @@ CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MXC_RNGA=y
 # CONFIG_I2C_COMPAT is not set
 CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MUX_GPIO=m
 # CONFIG_I2C_HELPER_AUTO is not set
 CONFIG_I2C_ALGOPCF=m
 CONFIG_I2C_ALGOPCA=m
@@ -156,6 +157,7 @@ CONFIG_SPI=y
 CONFIG_SPI_IMX=y
 CONFIG_GPIO_SYSFS=y
 CONFIG_GPIO_MC9S08DZ60=y
+CONFIG_GPIO_PCA953X=m
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_IMX2_WDT=y
@@ -238,6 +240,8 @@ CONFIG_DMADEVICES=y
 CONFIG_IMX_SDMA=y
 CONFIG_MXS_DMA=y
 CONFIG_STAGING=y
+CONFIG_STAGING_MEDIA=y
+CONFIG_VIDEO_IMX6=m
 CONFIG_DRM_IMX=y
 CONFIG_DRM_IMX_FB_HELPER=y
 CONFIG_DRM_IMX_PARALLEL_DISPLAY=y
Signature · 1 line
1.7.9.5
#66 lore raw
In reply to Steve Longerbeam

Hi Steve!

Quoted 26 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Quoted 7 lines

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Quoted 4 lines

Usage notes are found in Documentation/video4linux/mx6_camera.txt for the above three reference platforms.

The driver source is under drivers/staging/media/imx6/capture/.

Thank you for this patch series! Much appreciated that this hardware is finally going to supported with a proper driver.

I did a quick scan of the driver and I noticed a few things that need to be fixed: instead of implementing g/s_crop, implement g/s_selection:
new drivers should implement the selection API and they will get the crop API for free.

You should use the vb2 helper functions (vb2_fop_*, vb2_ioctl_*) unless there is a good reason not to do it. Those functions should simplify the code and they give you proper 'streaming ownership'. See also the example code Documentation/video4linux/v4l2-pci-skeleton.c.

Finally you should run the v4l2-compliance test tool and fix any failures.

That tool is part of git://linuxtv.org/v4l-utils.git. Always compile from that repository to be sure you use the latest code.

Test first with 'v4l2-compliance'. When all issues are fixed, then test with 'v4l2-compliance -s' to test actual streaming behavior as well.

When you post v2 of this patch series I want to see the output of 'v4l2-compliance -s'! New drivers should pass v4l2-compliance. However, this is a staging driver so I won't be that strict, but it seems to be the intention that this driver will become a mainline driver, so I would recommend to fix any issues now rather than later.

If you have questions about v4l2-compliance it it might be easiest to set up an irc session where we go through them. In that case mail me so we can set up a time and date to do that. I'm in timezone UTC+2.

Regards,

Hans

Quoted 117 lines

Steve Longerbeam (43):
imx-drm: ipu-v3: Move imx-ipu-v3.h to include/linux/platform_data/
ARM: dts: imx6qdl: Add ipu aliases
imx-drm: ipu-v3: Add ipu_get_num()
imx-drm: ipu-v3: Add solo/dual-lite IPU device type
imx-drm: ipu-v3: Map IOMUXC registers
imx-drm: ipu-v3: Add functions to set CSI/IC source muxes
imx-drm: ipu-v3: Rename and add IDMAC channels
imx-drm: ipu-v3: Add units required for video capture
imx-drm: ipu-v3: Add ipu_mbus_code_to_colorspace()
imx-drm: ipu-v3: Add rotation mode conversion utilities
imx-drm: ipu-v3: Add helper function checking if pixfmt is planar
imx-drm: ipu-v3: Move IDMAC channel names to imx-ipu-v3.h
imx-drm: ipu-v3: Add ipu_idmac_buffer_is_ready()
imx-drm: ipu-v3: Add ipu_idmac_clear_buffer()
imx-drm: ipu-v3: Add ipu_idmac_current_buffer()
imx-drm: ipu-v3: Add __ipu_idmac_reset_current_buffer()
imx-drm: ipu-v3: Add ipu_stride_to_bytes()
imx-drm: ipu-v3: Add ipu_idmac_enable_watermark()
imx-drm: ipu-v3: Add ipu_idmac_lock_enable()
imx-drm: ipu-v3: Add idmac channel linking support
imx-drm: ipu-v3: Add ipu_bits_per_pixel()
imx-drm: ipu-v3: Add ipu-cpmem unit
imx-drm: ipu-cpmem: Add ipu_cpmem_set_block_mode()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_axi_id()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_rotation()
imx-drm: ipu-cpmem: Add second buffer support to ipu_cpmem_set_image()
imx-drm: ipu-v3: Add more planar formats support
imx-drm: ipu-cpmem: Add ipu_cpmem_dump()
imx-drm: ipu-v3: Add ipu_dump()
ARM: dts: imx6: add pin groups for imx6q/dl for IPU1 CSI0
ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node
ARM: dts: imx: sabrelite: add video capture ports and endpoints
ARM: dts: imx6-sabresd: add video capture ports and endpoints
ARM: dts: imx6-sabreauto: add video capture ports and endpoints
ARM: dts: imx6qdl: Add simple-bus to ipu compatibility
gpio: pca953x: Add reset-gpios property
ARM: imx6q: clk: Add video 27m clock
media: imx6: Add device tree binding documentation
media: Add new camera interface driver for i.MX6
media: imx6: Add support for MIPI CSI-2 OV5640
media: imx6: Add support for Parallel OV5642
media: imx6: Add support for ADV7180 Video Decoder
ARM: imx_v6_v7_defconfig: Enable video4linux drivers

 .../devicetree/bindings/clock/imx6q-clock.txt      |    1 +
 Documentation/devicetree/bindings/media/imx6.txt   |  433 ++
 .../bindings/staging/imx-drm/fsl-imx-drm.txt       |    6 +-
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 Documentation/video4linux/mx6_camera.txt           |  188 +
 arch/arm/boot/dts/imx6q.dtsi                       |    3 +-
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |  149 +
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi           |   91 +
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |  116 +
 arch/arm/boot/dts/imx6qdl.dtsi                     |   62 +-
 arch/arm/configs/imx_v6_v7_defconfig               |    4 +
 arch/arm/mach-imx/clk-imx6q.c                      |    3 +-
 drivers/gpio/gpio-pca953x.c                        |   26 +
 drivers/staging/imx-drm/imx-hdmi.c                 |    2 +-
 drivers/staging/imx-drm/imx-tve.c                  |    2 +-
 drivers/staging/imx-drm/ipu-v3/Makefile            |    3 +-
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h        |  326 --
 drivers/staging/imx-drm/ipu-v3/ipu-common.c        | 1151 ++++--
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c         |  814 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c           |  821 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c          |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dp.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c            |  835 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c           |  103 +
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h           |  126 +-
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c          |  348 ++
 drivers/staging/imx-drm/ipuv3-crtc.c               |    2 +-
 drivers/staging/imx-drm/ipuv3-plane.c              |   18 +-
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/imx6/Kconfig                 |   25 +
 drivers/staging/media/imx6/Makefile                |    1 +
 drivers/staging/media/imx6/capture/Kconfig         |   33 +
 drivers/staging/media/imx6/capture/Makefile        |    7 +
 drivers/staging/media/imx6/capture/adv7180.c       | 1298 ++++++
 drivers/staging/media/imx6/capture/mipi-csi2.c     |  322 ++
 drivers/staging/media/imx6/capture/mx6-camif.c     | 2235 ++++++++++
 drivers/staging/media/imx6/capture/mx6-camif.h     |  197 +
 drivers/staging/media/imx6/capture/mx6-encode.c    |  775 ++++
 drivers/staging/media/imx6/capture/mx6-preview.c   |  748 ++++
 drivers/staging/media/imx6/capture/ov5640-mipi.c   | 2158 ++++++++++
 drivers/staging/media/imx6/capture/ov5642.c        | 4258 ++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h           |  425 ++
 include/media/imx6.h                               |   18 +
 46 files changed, 17340 insertions(+), 805 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/imx6.txt
 create mode 100644 Documentation/video4linux/mx6_camera.txt
 delete mode 100644 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
 create mode 100644 drivers/staging/media/imx6/Kconfig
 create mode 100644 drivers/staging/media/imx6/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/Kconfig
 create mode 100644 drivers/staging/media/imx6/capture/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/adv7180.c
 create mode 100644 drivers/staging/media/imx6/capture/mipi-csi2.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.h
 create mode 100644 drivers/staging/media/imx6/capture/mx6-encode.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-preview.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5640-mipi.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5642.c
 create mode 100644 include/linux/platform_data/imx-ipu-v3.h
 create mode 100644 include/media/imx6.h
#67 lore raw

I forgot to mention that I CC-ed David Peverley who was/is also working on a proper i.MX6 v4l2 driver. I'm sure he'll be interested in this as well.

Regards,

Hans

Quoted 202 lines · Hans Verkuil

Hi Steve!

Quoted 26 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Quoted 7 lines

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Quoted 4 lines

Usage notes are found in Documentation/video4linux/mx6_camera.txt for the above three reference platforms.

The driver source is under drivers/staging/media/imx6/capture/.

Thank you for this patch series! Much appreciated that this hardware is finally going to supported with a proper driver.

I did a quick scan of the driver and I noticed a few things that need to be fixed: instead of implementing g/s_crop, implement g/s_selection:
new drivers should implement the selection API and they will get the crop API for free.

You should use the vb2 helper functions (vb2_fop_*, vb2_ioctl_*) unless there is a good reason not to do it. Those functions should simplify the code and they give you proper 'streaming ownership'. See also the example code Documentation/video4linux/v4l2-pci-skeleton.c.

Finally you should run the v4l2-compliance test tool and fix any failures.

That tool is part of git://linuxtv.org/v4l-utils.git. Always compile from that repository to be sure you use the latest code.

Test first with 'v4l2-compliance'. When all issues are fixed, then test with 'v4l2-compliance -s' to test actual streaming behavior as well.

When you post v2 of this patch series I want to see the output of 'v4l2-compliance -s'! New drivers should pass v4l2-compliance. However, this is a staging driver so I won't be that strict, but it seems to be the intention that this driver will become a mainline driver, so I would recommend to fix any issues now rather than later.

If you have questions about v4l2-compliance it it might be easiest to set up an irc session where we go through them. In that case mail me so we can set up a time and date to do that. I'm in timezone UTC+2.

Regards,

Hans

Quoted 108 lines

Steve Longerbeam (43):
imx-drm: ipu-v3: Move imx-ipu-v3.h to include/linux/platform_data/
ARM: dts: imx6qdl: Add ipu aliases
imx-drm: ipu-v3: Add ipu_get_num()
imx-drm: ipu-v3: Add solo/dual-lite IPU device type
imx-drm: ipu-v3: Map IOMUXC registers
imx-drm: ipu-v3: Add functions to set CSI/IC source muxes
imx-drm: ipu-v3: Rename and add IDMAC channels
imx-drm: ipu-v3: Add units required for video capture
imx-drm: ipu-v3: Add ipu_mbus_code_to_colorspace()
imx-drm: ipu-v3: Add rotation mode conversion utilities
imx-drm: ipu-v3: Add helper function checking if pixfmt is planar
imx-drm: ipu-v3: Move IDMAC channel names to imx-ipu-v3.h
imx-drm: ipu-v3: Add ipu_idmac_buffer_is_ready()
imx-drm: ipu-v3: Add ipu_idmac_clear_buffer()
imx-drm: ipu-v3: Add ipu_idmac_current_buffer()
imx-drm: ipu-v3: Add __ipu_idmac_reset_current_buffer()
imx-drm: ipu-v3: Add ipu_stride_to_bytes()
imx-drm: ipu-v3: Add ipu_idmac_enable_watermark()
imx-drm: ipu-v3: Add ipu_idmac_lock_enable()
imx-drm: ipu-v3: Add idmac channel linking support
imx-drm: ipu-v3: Add ipu_bits_per_pixel()
imx-drm: ipu-v3: Add ipu-cpmem unit
imx-drm: ipu-cpmem: Add ipu_cpmem_set_block_mode()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_axi_id()
imx-drm: ipu-cpmem: Add ipu_cpmem_set_rotation()
imx-drm: ipu-cpmem: Add second buffer support to ipu_cpmem_set_image()
imx-drm: ipu-v3: Add more planar formats support
imx-drm: ipu-cpmem: Add ipu_cpmem_dump()
imx-drm: ipu-v3: Add ipu_dump()
ARM: dts: imx6: add pin groups for imx6q/dl for IPU1 CSI0
ARM: dts: imx6qdl: Flesh out MIPI CSI2 receiver node
ARM: dts: imx: sabrelite: add video capture ports and endpoints
ARM: dts: imx6-sabresd: add video capture ports and endpoints
ARM: dts: imx6-sabreauto: add video capture ports and endpoints
ARM: dts: imx6qdl: Add simple-bus to ipu compatibility
gpio: pca953x: Add reset-gpios property
ARM: imx6q: clk: Add video 27m clock
media: imx6: Add device tree binding documentation
media: Add new camera interface driver for i.MX6
media: imx6: Add support for MIPI CSI-2 OV5640
media: imx6: Add support for Parallel OV5642
media: imx6: Add support for ADV7180 Video Decoder
ARM: imx_v6_v7_defconfig: Enable video4linux drivers

 .../devicetree/bindings/clock/imx6q-clock.txt      |    1 +
 Documentation/devicetree/bindings/media/imx6.txt   |  433 ++
 .../bindings/staging/imx-drm/fsl-imx-drm.txt       |    6 +-
 .../devicetree/bindings/vendor-prefixes.txt        |    1 +
 Documentation/video4linux/mx6_camera.txt           |  188 +
 arch/arm/boot/dts/imx6q.dtsi                       |    3 +-
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |  149 +
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi           |   91 +
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |  116 +
 arch/arm/boot/dts/imx6qdl.dtsi                     |   62 +-
 arch/arm/configs/imx_v6_v7_defconfig               |    4 +
 arch/arm/mach-imx/clk-imx6q.c                      |    3 +-
 drivers/gpio/gpio-pca953x.c                        |   26 +
 drivers/staging/imx-drm/imx-hdmi.c                 |    2 +-
 drivers/staging/imx-drm/imx-tve.c                  |    2 +-
 drivers/staging/imx-drm/ipu-v3/Makefile            |    3 +-
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h        |  326 --
 drivers/staging/imx-drm/ipu-v3/ipu-common.c        | 1151 ++++--
 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c         |  814 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-csi.c           |  821 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c          |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dp.c            |    2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-ic.c            |  835 ++++
 drivers/staging/imx-drm/ipu-v3/ipu-irt.c           |  103 +
 drivers/staging/imx-drm/ipu-v3/ipu-prv.h           |  126 +-
 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c          |  348 ++
 drivers/staging/imx-drm/ipuv3-crtc.c               |    2 +-
 drivers/staging/imx-drm/ipuv3-plane.c              |   18 +-
 drivers/staging/media/Kconfig                      |    2 +
 drivers/staging/media/Makefile                     |    1 +
 drivers/staging/media/imx6/Kconfig                 |   25 +
 drivers/staging/media/imx6/Makefile                |    1 +
 drivers/staging/media/imx6/capture/Kconfig         |   33 +
 drivers/staging/media/imx6/capture/Makefile        |    7 +
 drivers/staging/media/imx6/capture/adv7180.c       | 1298 ++++++
 drivers/staging/media/imx6/capture/mipi-csi2.c     |  322 ++
 drivers/staging/media/imx6/capture/mx6-camif.c     | 2235 ++++++++++
 drivers/staging/media/imx6/capture/mx6-camif.h     |  197 +
 drivers/staging/media/imx6/capture/mx6-encode.c    |  775 ++++
 drivers/staging/media/imx6/capture/mx6-preview.c   |  748 ++++
 drivers/staging/media/imx6/capture/ov5640-mipi.c   | 2158 ++++++++++
 drivers/staging/media/imx6/capture/ov5642.c        | 4258 ++++++++++++++++++++
 include/linux/platform_data/imx-ipu-v3.h           |  425 ++
 include/media/imx6.h                               |   18 +
 46 files changed, 17340 insertions(+), 805 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/imx6.txt
 create mode 100644 Documentation/video4linux/mx6_camera.txt
 delete mode 100644 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-cpmem.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-csi.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-ic.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-irt.c
 create mode 100644 drivers/staging/imx-drm/ipu-v3/ipu-smfc.c
 create mode 100644 drivers/staging/media/imx6/Kconfig
 create mode 100644 drivers/staging/media/imx6/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/Kconfig
 create mode 100644 drivers/staging/media/imx6/capture/Makefile
 create mode 100644 drivers/staging/media/imx6/capture/adv7180.c
 create mode 100644 drivers/staging/media/imx6/capture/mipi-csi2.c
Quoted 9 lines
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-camif.h
 create mode 100644 drivers/staging/media/imx6/capture/mx6-encode.c
 create mode 100644 drivers/staging/media/imx6/capture/mx6-preview.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5640-mipi.c
 create mode 100644 drivers/staging/media/imx6/capture/ov5642.c
 create mode 100644 include/linux/platform_data/imx-ipu-v3.h
 create mode 100644 include/media/imx6.h

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#68 lore raw
In reply to Hans Verkuil
Quoted 29 lines · Hans Verkuil

Hi Steve!

Quoted 26 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Quoted 8 lines
Quoted 7 lines

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Hello Hans!

Ok, V4L2_EVENT_SOURCE_CHANGE looks promising.

But v4l2-framework.txt states that v4l2 events are passed to userland. So I want to make sure this framework will also work internally; that is, the decoder subdev (adv7180) can generate this event and it can be subscribed by the capture host driver. That it can be passed to userland is fine and would be useful, it's not necessary in this case.

Quoted 4 lines
Quoted 4 lines

Usage notes are found in Documentation/video4linux/mx6_camera.txt for the above three reference platforms.

Quoted 8 lines
Quoted 1 line

The driver source is under drivers/staging/media/imx6/capture/.

Thank you for this patch series! Much appreciated that this hardware is finally going to supported with a proper driver.

I did a quick scan of the driver and I noticed a few things that need to be fixed: instead of implementing g/s_crop, implement g/s_selection:
new drivers should implement the selection API and they will get the crop API for free.

Ok, I'll look into g/s_selection for v2 patches.

Quoted 5 lines

You should use the vb2 helper functions (vb2_fop_*, vb2_ioctl_*) unless there is a good reason not to do it. Those functions should simplify the code and they give you proper 'streaming ownership'. See also the example code Documentation/video4linux/v4l2-pci-skeleton.c.

Ok, ditto.

Quoted 6 lines

Finally you should run the v4l2-compliance test tool and fix any failures.

That tool is part of git://linuxtv.org/v4l-utils.git. Always compile from that repository to be sure you use the latest code.

Quoted 8 lines

Test first with 'v4l2-compliance'. When all issues are fixed, then test with 'v4l2-compliance -s' to test actual streaming behavior as well.

When you post v2 of this patch series I want to see the output of 'v4l2-compliance -s'! New drivers should pass v4l2-compliance. However, this is a staging driver so I won't be that strict, but it seems to be the intention that this driver will become a mainline driver, so I would recommend to fix any issues now rather than later.

Very cool, I'll make sure all v4l2-compliance issues are resolved. I can start that before issuing the v2 patches.

Quoted 4 lines

If you have questions about v4l2-compliance it it might be easiest to set up an irc session where we go through them. In that case mail me so we can set up a time and date to do that. I'm in timezone UTC+2.

Thanks for the offer. Give me a few days to compose v2 patches and I'll start looking at v4l2-compliance.

Steve

#69 lore raw
Quoted 37 lines · Steve Longerbeam
Quoted 36 lines · Hans Verkuil

Hi Steve!

Quoted 33 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

Quoted 8 lines
Quoted 1 line

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Hello Hans!

Ok, V4L2_EVENT_SOURCE_CHANGE looks promising.

But v4l2-framework.txt states that v4l2 events are passed to userland. So I want to make sure this framework will also work internally; that is, the decoder subdev (adv7180) can generate this event and it can be subscribed by the capture host driver. That it can be passed to userland is fine and would be useful, it's not necessary in this case.

A subdevice can notify its parent device through v4l2_subdev_notify (see v4l2-device.h). It would be nice if the event API and this notify mechanism were unified or at least be more similar.

It's on my TODO list, but it is fairly far down that list.

Let me know if you are interested to improve this situation. I should be able to give some pointers.

Regards,

Hans

Quoted 51 lines
Quoted 5 lines
Quoted 5 lines

Usage notes are found in Documentation/video4linux/mx6_camera.txt for the above three reference platforms.

Quoted 8 lines
Quoted 1 line

The driver source is under drivers/staging/media/imx6/capture/.

Thank you for this patch series! Much appreciated that this hardware is finally going to supported with a proper driver.

I did a quick scan of the driver and I noticed a few things that need to be fixed: instead of implementing g/s_crop, implement g/s_selection:
new drivers should implement the selection API and they will get the crop API for free.

Ok, I'll look into g/s_selection for v2 patches.

Quoted 5 lines

You should use the vb2 helper functions (vb2_fop_*, vb2_ioctl_*) unless there is a good reason not to do it. Those functions should simplify the code and they give you proper 'streaming ownership'. See also the example code Documentation/video4linux/v4l2-pci-skeleton.c.

Ok, ditto.

Quoted 6 lines

Finally you should run the v4l2-compliance test tool and fix any failures.

That tool is part of git://linuxtv.org/v4l-utils.git. Always compile from that repository to be sure you use the latest code.

Quoted 8 lines

Test first with 'v4l2-compliance'. When all issues are fixed, then test with 'v4l2-compliance -s' to test actual streaming behavior as well.

When you post v2 of this patch series I want to see the output of 'v4l2-compliance -s'! New drivers should pass v4l2-compliance. However, this is a staging driver so I won't be that strict, but it seems to be the intention that this driver will become a mainline driver, so I would recommend to fix any issues now rather than later.

Very cool, I'll make sure all v4l2-compliance issues are resolved. I can start that before issuing the v2 patches.

Quoted 4 lines

If you have questions about v4l2-compliance it it might be easiest to set up an irc session where we go through them. In that case mail me so we can set up a time and date to do that. I'm in timezone UTC+2.

Thanks for the offer. Give me a few days to compose v2 patches and I'll start looking at v4l2-compliance.

Steve

#70 lore raw
Quoted 50 lines · Hans Verkuil
Quoted 41 lines · Steve Longerbeam
Quoted 29 lines · Hans Verkuil

Hi Steve!

Quoted 26 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Quoted 8 lines
Quoted 7 lines

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Hello Hans!

Quoted 7 lines

Ok, V4L2_EVENT_SOURCE_CHANGE looks promising.

But v4l2-framework.txt states that v4l2 events are passed to userland. So I want to make sure this framework will also work internally; that is, the decoder subdev (adv7180) can generate this event and it can be subscribed by the capture host driver. That it can be passed to userland is fine and would be useful, it's not necessary in this case.

Quoted 10 lines

A subdevice can notify its parent device through v4l2_subdev_notify (see v4l2-device.h). It would be nice if the event API and this notify mechanism were unified or at least be more similar.

It's on my TODO list, but it is fairly far down that list.

Let me know if you are interested to improve this situation. I should be able to give some pointers.

Hi Hans,

It doesn't look possible for subdev's to queue events, since events require a v4l2 fh context, so it looks like subdev notifications should stick around.

But perhaps subdev notification can be modified to send a struct v4l2_event, rather than a u32 notification value. Then at least notify and events can share event types instead of duplicating them (such as what I caused by introducing this similar decoder status change notification).

Something like:

/* Send an event to v4l2_device. */
static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
struct v4l2_event *ev, void *arg)

{
        if (sd && sd->v4l2_dev && sd->v4l2_dev->notify)
                sd->v4l2_dev->notify(sd, ev, arg);
}

Then the parent is free to consume this event internally, and/or queue it off to userland via v4l2_event_queue().

Notification values could then completely disappear, replaced with new (or existing) event types.

Is that what you had in mind, or something completely different?

Steve

#71 lore raw
Quoted 85 lines · Steve Longerbeam
Quoted 50 lines · Hans Verkuil
Quoted 41 lines · Steve Longerbeam
Quoted 29 lines · Hans Verkuil

Hi Steve!

Quoted 26 lines · Steve Longerbeam

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Quoted 8 lines
Quoted 7 lines

There is an existing adv7180 subdev driver under drivers/media/i2c, but it needs some extra functionality to work on the sabreauto. It will need OF graph bindings support and gpio for a power-on pin on the sabreauto. It would also need to send a new subdev notification to take advantage of decoder status change handling provided by the host driver. This feature makes it possible to correctly handle "hot" (while streaming) signal lock/unlock and autodetected video standard changes.

A new V4L2_EVENT_SOURCE_CHANGE event has just been added for that.

Hello Hans!

Quoted 7 lines

Ok, V4L2_EVENT_SOURCE_CHANGE looks promising.

But v4l2-framework.txt states that v4l2 events are passed to userland. So I want to make sure this framework will also work internally; that is, the decoder subdev (adv7180) can generate this event and it can be subscribed by the capture host driver. That it can be passed to userland is fine and would be useful, it's not necessary in this case.

Quoted 10 lines

A subdevice can notify its parent device through v4l2_subdev_notify (see v4l2-device.h). It would be nice if the event API and this notify mechanism were unified or at least be more similar.

It's on my TODO list, but it is fairly far down that list.

Let me know if you are interested to improve this situation. I should be able to give some pointers.

Hi Hans,

It doesn't look possible for subdev's to queue events, since events require a v4l2 fh context, so it looks like subdev notifications should stick around.

But perhaps subdev notification can be modified to send a struct v4l2_event, rather than a u32 notification value. Then at least notify and events can share event types instead of duplicating them (such as what I caused by introducing this similar decoder status change notification).

Something like:

/* Send an event to v4l2_device. */
static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
struct v4l2_event *ev, void *arg)

{
        if (sd && sd->v4l2_dev && sd->v4l2_dev->notify)
                sd->v4l2_dev->notify(sd, ev, arg);
}
Quoted 7 lines

Then the parent is free to consume this event internally, and/or queue it off to userland via v4l2_event_queue().

Notification values could then completely disappear, replaced with new (or existing) event types.

Is that what you had in mind, or something completely different?

That is what I had in mind, although the 'arg' argument can be dropped, since that will be part of the event payload.

There is another notifier function as well in v4l2-ctrls.h: v4l2_ctrl_notify(). This should also switch to using v4l2_subdev_notify(). Instead of setting a notify callback it should set a v4l2_subdev pointer: that will allow it to call v4l2_subdev_notify().

Where things get tricky is with the event payload: there is no problem if it is one of the standard events, but for kernel-internal events it is not quite clear how those should be defined. Ideally you would like to be able to add new structs inside the v4l2_event union, but you don't want those to be part of the public API either.

I'm thinking something like this:

// Range for events that are internal to the kernel #define V4L2_EVENT_INTERNAL_START 0x04000000

And internal events and associated payload structs are defined in v4l2-event.h.

Add this macro to v4l2-event.h:

#define V4L2_EVENT_CAST(ev, type) ((type *)(&(ev)->u))

Now you should be able to do something like this:

In v4l2-event.h:

#define V4L2_EVENT_INT_FOO (V4L2_EVENT_INTERNAL_START + 0)

struct v4l2_event_int_foo {
	u32 val;
};

In the driver:

	struct v4l2_event ev;
	struct v4l2_event_int_foo *f = V4L2_EVENT_CAST(&ev, struct v4l2_event_int_foo);

	f->val = 10;

	// Or alternatively:
	*V4L2_EVENT_CAST(&ev, u32) = 10;

It's the best I can come up with.

It would be nice to use the same v4l2_event struct for all notifications, it's much more unified and elegant.

Regards,

Hans

#72 lore raw
In reply to Steve Longerbeam

Hi Steve,

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 9 lines

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

That's quite a series to digest! I'll quickly go over the points that jumped at me and then look at the core code (especially 08/43 and 39/43) in detail.

Quoted 6 lines

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

The move out of staging is now merged into drm-next with c1a6e9fe82b46159af8cc4cf34fb51ee47862f05.
After this is merged into mainline, there should be no need to push i.MX capture support through staging. It would be helpful if you could rebase on top of that.

Quoted 2 lines

- Adds the device tree nodes and OF graph bindings for video capture support on sabrelite, sabresd, and sabreauto reference platforms.

I disagree with the way you organized the device tree, I'll comment in the relevant patches.

Quoted 5 lines

The new i.MX6 capture host interface driver is at patch 39.

To support the sensors found on the sabrelite, sabresd, and sabreauto, three patches add sensor subdev's for parallel OV5642, MIPI CSI-2 OV5640, and the ADV7180 decoder chip, beginning at patch 40.

Please don't introduce i.MX6-only sensor drivers. Those should live under drivers/media/i2c and not be i.MX specific.

regards
Philipp

#73 lore raw
Quoted 24 lines · Philipp Zabel

Hi Steve,

Am Samstag, den 07.06.2014, 14:56 -0700 schrieb Steve Longerbeam:

Quoted 9 lines

Hi all,

This patch set adds video capture support for the Freescale i.MX6 SOC.

It is a from-scratch standardized driver that works with community v4l2 utilities, such as v4l2-ctl, v4l2-cap, and the v4l2src gstreamer plugin. It uses the latest v4l2 interfaces (subdev, videobuf2). Please see Documentation/video4linux/mx6_camera.txt for it's full list of features!

That's quite a series to digest! I'll quickly go over the points that jumped at me and then look at the core code (especially 08/43 and 39/43) in detail.

Quoted 6 lines

The first 38 patches:

- prepare the ipu-v3 driver for video capture support. The current driver contains only video display functionality to support the imx DRM drivers. At some point ipu-v3 should be moved out from under staging/imx-drm since it will no longer only support DRM.

Quoted 6 lines

The move out of staging is now merged into drm-next with c1a6e9fe82b46159af8cc4cf34fb51ee47862f05.
After this is merged into mainline, there should be no need to push i.MX capture support through staging. It would be helpful if you could rebase on top of that.

Hi Philipp and Sascha,

First of all, thanks for the detailed review.

I think it's obvious that this patch set should be split into two: first, the changes to IPU core driver submitted to drm-next, and the capture driver to media-tree.

Or, do you prefer I submit the IPU core patches to your own pengutronix git tree, and we can correspond on one of your internal mailing lists? I can then leave it to you to push those changes to drm-next.

I agree with most of your feedback, and most is specific to the IPU core changes. We can discuss those in detail elsewhere, but just in summary here, some of your comments seem to conflict:

1. Regarding the input muxes to the CSI and IC, Philipp you acked those functions but would like to see these muxes as v4l2 subdevs and configured in the DT, but Sascha, you had a comment that this should be a job for mediactrl.

2. Philipp, you would like to see CSI, IC, and SMFC units moved out of IPU core and become v4l2 subdevs. I agree with that, but drm-next has ipu-smfc as part of IPU core, and SMFC is most definitely v4l2 capture specific.

Steve

#74 lore raw

Hi Steve,

[Added Russell to Cc: because of the question how to send IPU core
patches to drm-next]

Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:

Quoted 3 lines

Hi Philipp and Sascha,

First of all, thanks for the detailed review.

You are welcome. I am tasked to prepare our own capture drivers for mainline submission, but they are not quite there yet. I'd be very interested in getting this worked out together, especially since we seem to be interested in orthogonal features (we had no use for the preview and and encoder IC tasks or MIPI CSI-2 so far, but we need media controller support and mem2mem scaling via the post-processor IC task).
I'm going to post our current series as is, if only to illustrate my point of view.

Quoted 3 lines

I think it's obvious that this patch set should be split into two: first, the changes to IPU core driver submitted to drm-next, and the capture driver to media-tree.

I agree.

Quoted 2 lines

Or, do you prefer I submit the IPU core patches to your own pengutronix git tree, and we can correspond on one of your internal mailing lists?

Why would we move discussion to an internal mailing list? Since we are sitting right inbetween dri-devel and linux-media with the IPU core code, I think either mailing list is an appropriate place for discussing these patches, depending on the context.

Quoted 1 line

I can then leave it to you to push those changes to drm-next.

I think a central place to collect IPU core patches before sending them off to drm-next is a good idea. I offer to do the collecting in my tree. I also know Russell volunteered to collect and send off imx-drm patches towards staging. Russell, I'm not sure if this offer extends to non-DRM IPU core patches to be submitted to drm-next? (And if yes, whether you'd rather keep at it or have this taken off your hands.)

Quoted 2 lines

I agree with most of your feedback, and most is specific to the IPU core changes.

Excellent. For the core changes, rebasing them onto next and then integrating some remaining changes from our patchset shouldn't be a problem.
The big issue I have with the media parts is the missing media controller support and the code organization around the IC tasks instead of around hardware submodules.

Quoted 7 lines

We can discuss those in detail elsewhere, but just in summary here,
some of your comments seem to conflict:

1. Regarding the input muxes to the CSI and IC, Philipp you acked those functions but would like to see these muxes as v4l2 subdevs and configured in the DT, but Sascha, you had a comment that this should be a job for mediactrl.

No conflict here, there are different multiplexers to talk about.

First, there are two external multiplexers controlled by IOMUXC (on i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and IPU_CSI0/1_MUX. They are not part of the IPU.
They each sit between a set of parallel input pads and the CSI2IPU gasket on one side and one CSI on the other side.
In my opinion, these should be handled by separate v4l2_subdev drivers and their connections described in the device tree. The links between subdevices can then be controlled via the media controller framework. This is what my comments on patches 05/43 and 08/43 are about.

Second, there are the CSI0/1_DATA_SOURCE muxes and the CSI_SEL/IC_INPUT muxes controlled by the IPU_CONF register. These should not be described in the device tree. Just as CSI and IC, they are an IPU internal detail.

The CSI0/1_DATA_SOURCE, if I understand correctly, muxes not the data bus, but the 8-bit mct_di bus which carries the MIPI channel id and data type. This should be controlled by the CSI subdevice driver directly when choosing its input format.

The CSI_SEL/IC_INPUT multiplexer selects the input to the IC to come from either CSI0, CSI1, or the VDI. Each of those subunits would fit the media entity abstraction well. This multiplexer should be controlled by the media controller framework.

I acked the CSI/IC source mux functions in patch 06/43 because I think those functions are in the right place and useful in the above scenario.

Quoted 3 lines

2. Philipp, you would like to see CSI, IC, and SMFC units moved out of IPU core and become v4l2 subdevs. I agree with that, but drm-next has ipu-smfc as part of IPU core, and SMFC is most definitely v4l2 capture specific.

About the CSI I'm just a tiny bit conflicted myself, that seems to show.

Quoted 1 line

From an organizational standpoint, with all the other register access

code in gpu/ipu-v3, having the ipu-csi code in there too looks nice and as expected. On the other hand, this should really be only used by one v4l2_subdev driver. When I look at it this way, I see a driver that is split in two parts, wasting exported symbol space for no very good reason.

The IC I'd like to describe as a v4l2_subdev. But I'd also like to use the IC from the DRM driver. So the IC core code has to stay in gpu/ipu-v3. I'd just like to pool all V4L2 code that uses this into a IC v4l2_subdev driver if possible. The only use we have for the IC currently is

The SMFC code is small and, more importantly, its functionality is limited enough that it doesn't warrant its own v4l2_subdev. I see not enough reason to move this away from the other IPU core code, since the v4l2_device capture driver that uses it certainly is not the right place to map SMFC registers directly.

So the CSI only is a special case because the code in ipu-csi.c aligns so well with a single v4l2_subdev driver.

regards
Philipp

#75 lore raw
Quoted 8 lines · Philipp Zabel

Hi Steve,

[Added Russell to Cc: because of the question how to send IPU core
patches to drm-next]

Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:

Quoted 2 lines

Hi Philipp and Sascha,

Quoted 8 lines
Quoted 1 line

First of all, thanks for the detailed review.

You are welcome. I am tasked to prepare our own capture drivers for mainline submission, but they are not quite there yet. I'd be very interested in getting this worked out together, especially since we seem to be interested in orthogonal features (we had no use for the preview and and encoder IC tasks or MIPI CSI-2 so far, but we need media controller support

Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the capture path is nice too, since it allows userland to select arbitrary user resolutions, pixel format color space, and also rotation controls. The capture driver decides whether to include the IC in the capture pipeline based on user format and rotation control. I.e. if user colorspace is different from what the sensor can output, IC CSC is required. If user resolution is different from the selected capture cropping rectangle, IC resizer is required, and finally if user requests rotation, the IC rotation unit is required. If none of those are true, the capture driver decides to exclude the IC from the pipeline and send raw sensor frames (well, after cropping anyway) directly to memory via the SMFC.

So in our driver, the decision to link the IC in a pipeline is made internally by the driver and is not a decision exported to userland.

My plan was to add media device framework support, but only after basic video capture is in place. Our driver is full featured in terms of basic capture support, and it works on all three reference platforms. But I agree it needs to convert subdev's to media entities and allow some of them to be linked via the media controller API.

But only some linkages make sense to me. As I explain above, if the IC were to be made a media entity, I think it's linkage should be made internally by the capture driver, and this should not be controllable by userspace.

Quoted 1 line

and mem2mem scaling via the post-processor IC task).

Heh, we have a mem2mem driver as well, and it also uses IC post-processor task. It uses banding and striping to support resized output frames larger than 1024x1024. It also makes use of IC rotation and CSC.

But again this is not converted to a media entity. And again, if IC were to be made a standalone media entity, then the mem2mem device would _always_ require the IC post-processor be linked to it, since the essential feature of mem2mem is to make use of IC post-processor task for CSC, resize, and rotation operations.

So as you can see I'm confused about where allowing control of media entity linking would make sense.

Quoted 2 lines

I'm going to post our current series as is, if only to illustrate my point of view.

I see them thanks. I'll study them.

Quoted 44 lines
Quoted 4 lines

I think it's obvious that this patch set should be split into two: first, the changes to IPU core driver submitted to drm-next, and the capture driver to media-tree.

I agree.

Quoted 2 lines

Or, do you prefer I submit the IPU core patches to your own pengutronix git tree, and we can correspond on one of your internal mailing lists?

Why would we move discussion to an internal mailing list? Since we are sitting right inbetween dri-devel and linux-media with the IPU core code, I think either mailing list is an appropriate place for discussing these patches, depending on the context.

Quoted 1 line

I can then leave it to you to push those changes to drm-next.

I think a central place to collect IPU core patches before sending them off to drm-next is a good idea. I offer to do the collecting in my tree. I also know Russell volunteered to collect and send off imx-drm patches towards staging. Russell, I'm not sure if this offer extends to non-DRM IPU core patches to be submitted to drm-next? (And if yes, whether you'd rather keep at it or have this taken off your hands.)

Quoted 2 lines

I agree with most of your feedback, and most is specific to the IPU core changes.

Excellent. For the core changes, rebasing them onto next and then integrating some remaining changes from our patchset shouldn't be a problem.
The big issue I have with the media parts is the missing media controller support and the code organization around the IC tasks instead of around hardware submodules.

Quoted 7 lines

We can discuss those in detail elsewhere, but just in summary here,
some of your comments seem to conflict:

1. Regarding the input muxes to the CSI and IC, Philipp you acked those functions but would like to see these muxes as v4l2 subdevs and configured in the DT, but Sascha, you had a comment that this should be a job for mediactrl.

No conflict here, there are different multiplexers to talk about.

Quoted 8 lines

First, there are two external multiplexers controlled by IOMUXC (on i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and IPU_CSI0/1_MUX. They are not part of the IPU.
They each sit between a set of parallel input pads and the CSI2IPU gasket on one side and one CSI on the other side.
In my opinion, these should be handled by separate v4l2_subdev drivers and their connections described in the device tree. The links between subdevices can then be controlled via the media controller framework.

right, this is one place where subdev linking makes sense to me. I.e. linking sensors to CSI ports.

But you don't mean to allow userspace to make this link arbitrarily, correct? You mean the driver uses the mediactrl framework to implement the links defined in the device tree. Maybe that's where I was confused.

Quoted 6 lines

This is what my comments on patches 05/43 and 08/43 are about.

Second, there are the CSI0/1_DATA_SOURCE muxes and the CSI_SEL/IC_INPUT muxes controlled by the IPU_CONF register. These should not be described in the device tree. Just as CSI and IC, they are an IPU internal detail.

agreed.

Quoted 4 lines

The CSI0/1_DATA_SOURCE, if I understand correctly, muxes not the data bus, but the 8-bit mct_di bus which carries the MIPI channel id and data type. This should be controlled by the CSI subdevice driver directly when choosing its input format.

it's input/sink pad media bus format, agreed.

Quoted 5 lines

The CSI_SEL/IC_INPUT multiplexer selects the input to the IC to come from either CSI0, CSI1, or the VDI. Each of those subunits would fit the media entity abstraction well. This multiplexer should be controlled by the media controller framework.

agreed.

Quoted 10 lines

I acked the CSI/IC source mux functions in patch 06/43 because I think those functions are in the right place and useful in the above scenario.

Quoted 3 lines

2. Philipp, you would like to see CSI, IC, and SMFC units moved out of IPU core and become v4l2 subdevs. I agree with that, but drm-next has ipu-smfc as part of IPU core, and SMFC is most definitely v4l2 capture specific.

About the CSI I'm just a tiny bit conflicted myself, that seems to show.

Quoted 7 lines

From an organizational standpoint, with all the other register access code in gpu/ipu-v3, having the ipu-csi code in there too looks nice and as expected.
On the other hand, this should really be only used by one v4l2_subdev driver. When I look at it this way, I see a driver that is split in two parts, wasting exported symbol space for no very good reason.

I agree about making CSI a subdev, but I also think we can keep all of the register access in IPU core as well. The CSI subdev would be a wrapper around the ipu-csi APIs. I agree it's more use of symbol space, but we might be able to simplify the ipu-csi API.

Quoted 6 lines

The IC I'd like to describe as a v4l2_subdev. But I'd also like to use the IC from the DRM driver. So the IC core code has to stay in gpu/ipu-v3. I'd just like to pool all V4L2 code that uses this into a IC v4l2_subdev driver if possible. The only use we have for the IC currently is

is mem2mem? And you would like to see an IC pads linked with mem2mem pads. Well, something like this:

input frame from userspace ---> m2m ---> IC-PP ---> m2m ---> to userspace

Quoted 9 lines

The SMFC code is small and, more importantly, its functionality is limited enough that it doesn't warrant its own v4l2_subdev. I see not enough reason to move this away from the other IPU core code, since the v4l2_device capture driver that uses it certainly is not the right place to map SMFC registers directly.

So the CSI only is a special case because the code in ipu-csi.c aligns so well with a single v4l2_subdev driver.

Ok, in summary I'm aligned with everything you said. Only that I am still pondering about which media entity links make sense, and who should be allowed to make those links.

So how should we proceed? I would argue to use our capture driver as a base, since it is fully functional and fairly full-featured. It's just missing the media framework.

Steve

#76 lore raw
Quoted 39 lines · Steve Longerbeam
Quoted 8 lines · Philipp Zabel

Hi Steve,

[Added Russell to Cc: because of the question how to send IPU core
patches to drm-next]

Am Mittwoch, den 11.06.2014, 18:04 -0700 schrieb Steve Longerbeam:

Quoted 2 lines

Hi Philipp and Sascha,

Quoted 8 lines
Quoted 1 line

First of all, thanks for the detailed review.

You are welcome. I am tasked to prepare our own capture drivers for mainline submission, but they are not quite there yet. I'd be very interested in getting this worked out together, especially since we seem to be interested in orthogonal features (we had no use for the preview and and encoder IC tasks or MIPI CSI-2 so far, but we need media controller support

Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the capture path is nice too, since it allows userland to select arbitrary user resolutions, pixel format color space, and also rotation controls. The capture driver decides whether to include the IC in the capture pipeline based on user format and rotation control. I.e. if user colorspace is different from what the sensor can output, IC CSC is required. If user resolution is different from the selected capture cropping rectangle, IC resizer is required, and finally if user requests rotation, the IC rotation unit is required. If none of those are true, the capture driver decides to exclude the IC from the pipeline and send raw sensor frames (well, after cropping anyway) directly to memory via the SMFC.

So in our driver, the decision to link the IC in a pipeline is made internally by the driver and is not a decision exported to userland.

My plan was to add media device framework support, but only after basic video capture is in place. Our driver is full featured in terms of basic capture support, and it works on all three reference platforms. But I agree it needs to convert subdev's to media entities and allow some of them to be linked via the media controller API.

Quoted 4 lines

But only some linkages make sense to me. As I explain above, if the IC were to be made a media entity, I think it's linkage should be made internally by the capture driver, and this should not be controllable by userspace.

What if 2 cameras on different CSIs on the same IPU want to use the IC. Is it 1st come 1st server? Or, both routed to memory, and a separate memory convert? Is the 1st pipeline shut down and restarted in this mode?

#77 lore raw
In reply to Steve Longerbeam

Am Donnerstag, den 12.06.2014, 14:05 -0700 schrieb Steve Longerbeam:

Quoted 3 lines

Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the capture path is nice too, since it allows userland to select arbitrary user resolutions, pixel format color space, and also rotation controls.

No question about that. It's just that mostly everyone around here seems to want to capture at least 1080p, or 10-bit grayscale. I hope Freescale drops the 1024-pixel output limitation in their next SoC ...

Quoted 9 lines

The
capture driver decides whether to include the IC in the capture pipeline based on user format and rotation control. I.e. if user colorspace is different from what the sensor can output, IC CSC is required. If user resolution is different from the selected capture cropping rectangle, IC resizer is required, and finally if user requests rotation, the IC rotation unit is required. If none of those are true, the capture driver decides to exclude the IC from the pipeline and send raw sensor frames (well, after cropping anyway) directly to memory via the SMFC.

That is too much magic for my taste. Especially since whether or not you can use the IC not only depends on the current video format, but also on whether the other CSI or the MEM_VDIC_MEM path are using the IC at the moment.
Since this can change dynamically, it throws a wrench into GStreamer's static capability negotiation, for example. I'd rather have userspace select which CSI should be routed through the IC with media-ctl and then reflect the possible conversions in the respective video_dev's capabilities.

Quoted 2 lines

So in our driver, the decision to link the IC in a pipeline is made internally by the driver and is not a decision exported to userland.

This is exactly the point I am worried about. You lose flexibility and need all sorts of clever conditional code in the driver. It'd be much cleaner to just let userspace control the mux.

Quoted 5 lines

My plan was to add media device framework support, but only after basic video capture is in place. Our driver is full featured in terms of basic capture support, and it works on all three reference platforms. But I agree it needs to convert subdev's to media entities and allow some of them to be linked via the media controller API.

Alright, so we agree that using the media controller API internally is a good idea ...

Quoted 3 lines

But only some linkages make sense to me. As I explain above, if the IC were to be made a media entity, I think it's linkage should be made internally by the capture driver, and this should not be controllable by userspace.

... but we disagree on whether to export the control to userspace. For more complicated pipelines in front of the CSIs we'll need media-ctl anyway, so using that same API for the internal components, makes sense. It also allows userspace to get a clear and stable picture of the available features for any given multiplexer setting.

Quoted 3 lines

Heh, we have a mem2mem driver as well, and it also uses IC post-processor task. It uses banding and striping to support resized output frames larger than 1024x1024. It also makes use of IC rotation and CSC.

Of course :)

Quoted 5 lines

But again this is not converted to a media entity. And again, if IC were to be made a standalone media entity, then the mem2mem device would _always_ require the IC post-processor be linked to it, since the essential feature of mem2mem is to make use of IC post-processor task for CSC, resize, and rotation operations.

Since the three IC tasks are transparently time-multiplexed, the IC media entity representation could have input and output pads for each of them.
The preprocessing (encoding, viewfinder) tasks share an input pad that would be connected to either CSI0, CSI1, or VDI output pad. These links should control the IC mux. The encoding task output pad would represent IDMAC channel 20/CB0 or channel 48/CB8, depending on whether the rotator is active. Since rotation requires tight integration between IC and IDMAC, I don't think the IRT should be represented as a separate media entity.
The viewfinder task output pad would correspond to channel 21/CB1 or channel 49/CB9, and maybe in the future control whether to send that data off to the DMFC or to memory.
The postprocessing input and output pads would go straight to memory and are not configurable, so I see no need to describe IC-PP as media entity.

I'm not quite sure about the VDIC, but I guess that also should be configurable from userspace as one input to IC. For the deinterlacer to work, IC_INPUT needs to be set, so while this is active there is no way to route CSI0/1 through the IC directly.

[...]

Quoted 5 lines
Quoted 5 lines

No conflict here, there are different multiplexers to talk about.

First, there are two external multiplexers controlled by IOMUXC (on i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and IPU_CSI0/1_MUX. They are not part of the IPU.

[...]

Quoted 6 lines

right, this is one place where subdev linking makes sense to me. I.e. linking sensors to CSI ports.

But you don't mean to allow userspace to make this link arbitrarily, correct? You mean the driver uses the mediactrl framework to implement the links defined in the device tree. Maybe that's where I was confused.

No, this is exactly what I mean. In my opinion, using media-ctl to throw the switches is much better than letting the driver decide depending on the old S_INPUT API. Especially since this gives userspace a unified API when there are input multiplexers (or any other subdevices configurable on the pad level) external to the SoC.
Also, pad format configuration of the CSI subdev exported to userspace may be useful to control the compander in the CSI.

[...]

Quoted 8 lines
Quoted 7 lines

From an organizational standpoint, with all the other register access code in gpu/ipu-v3, having the ipu-csi code in there too looks nice and as expected.
On the other hand, this should really be only used by one v4l2_subdev driver. When I look at it this way, I see a driver that is split in two parts, wasting exported symbol space for no very good reason.

Quoted 4 lines

I agree about making CSI a subdev, but I also think we can keep all of the register access in IPU core as well. The CSI subdev would be a wrapper around the ipu-csi APIs. I agree it's more use of symbol space, but we might be able to simplify the ipu-csi API.

So be it. In any case, this decision could be changed later with little effort and without any externally visible changes, if deemed necessary, as long as the CSI v4l2_subdev driver is the only consumer of this API.

Quoted 10 lines
Quoted 5 lines

The IC I'd like to describe as a v4l2_subdev. But I'd also like to use the IC from the DRM driver. So the IC core code has to stay in gpu/ipu-v3. I'd just like to pool all V4L2 code that uses this into a IC v4l2_subdev driver if possible. The only use we have for the IC currently is

is mem2mem? And you would like to see an IC pads linked with mem2mem pads. Well, something like this:

input frame from userspace ---> m2m ---> IC-PP ---> m2m ---> to userspace

As long as there is no internal video bus switch somewhere, the usefulness of this is debatable. You see we also implemented this by directly calling the IPU IC API, and I'm fine with this.

[...]

Quoted 3 lines

Ok, in summary I'm aligned with everything you said. Only that I am still pondering about which media entity links make sense, and who should be allowed to make those links.

At least the decision whether to route the CSI0/1 into the IC preprocessing input should be handled by userspace, as this changes the capabilities of the corresponding video_dev.

Quoted 3 lines

So how should we proceed? I would argue to use our capture driver as a base, since it is fully functional and fairly full-featured. It's just missing the media framework.

Initially, I don't care as much about a full featureset as I do about getting the userspace API and device tree bindings right, since those won't be easy to change later.
Pending rework into CSI/IC subdevices and agreement on the userspace facing API, I think your patchset can be a good base.

regards
Philipp

#78 lore raw
Quoted 8 lines · Philipp Zabel

Am Donnerstag, den 12.06.2014, 14:05 -0700 schrieb Steve Longerbeam:

Quoted 3 lines

Ok. Yes, we definitely need preview and MIPI CSI-2, and adding IC to the capture path is nice too, since it allows userland to select arbitrary user resolutions, pixel format color space, and also rotation controls.

No question about that. It's just that mostly everyone around here seems to want to capture at least 1080p, or 10-bit grayscale. I hope Freescale drops the 1024-pixel output limitation in their next SoC ...

yeah that would be nice.

Quoted 11 lines
Quoted 10 lines

The
capture driver decides whether to include the IC in the capture pipeline based on user format and rotation control. I.e. if user colorspace is different from what the sensor can output, IC CSC is required. If user resolution is different from the selected capture cropping rectangle, IC resizer is required, and finally if user requests rotation, the IC rotation unit is required. If none of those are true, the capture driver decides to exclude the IC from the pipeline and send raw sensor frames (well, after cropping anyway) directly to memory via the SMFC.

Quoted 4 lines

That is too much magic for my taste. Especially since whether or not you can use the IC not only depends on the current video format, but also on whether the other CSI or the MEM_VDIC_MEM path are using the IC at the moment.

Right. Our current capture driver just returns -EBUSY if the IC PRPENC task is currently in use by the other CSI.

But I have come around, I agree with you now that, if we are to make the capture driver a media device that is controlling an IC entity, that the links to/from the IC need to be controlled by media controller API. I guess I've been thinking too much in terms of "classical" V4L2.

Quoted 5 lines

Since this can change dynamically, it throws a wrench into GStreamer's static capability negotiation, for example. I'd rather have userspace select which CSI should be routed through the IC with media-ctl and then reflect the possible conversions in the respective video_dev's capabilities.

yes, the capabilities will change dynamically depending on the current video pipeline that has been setup.

Quoted 7 lines
Quoted 3 lines

So in our driver, the decision to link the IC in a pipeline is made internally by the driver and is not a decision exported to userland.

This is exactly the point I am worried about. You lose flexibility and need all sorts of clever conditional code in the driver. It'd be much cleaner to just let userspace control the mux.

the conditionals weren't actually that clever. But like I said, I was thinking in terms of classic V4L2 where internal video blocks are used or not depending on user requested format. I agree now that IC usage should be part of media control.

Quoted 32 lines
Quoted 6 lines

My plan was to add media device framework support, but only after basic video capture is in place. Our driver is full featured in terms of basic capture support, and it works on all three reference platforms. But I agree it needs to convert subdev's to media entities and allow some of them to be linked via the media controller API.

Alright, so we agree that using the media controller API internally is a good idea ...

Quoted 3 lines

But only some linkages make sense to me. As I explain above, if the IC were to be made a media entity, I think it's linkage should be made internally by the capture driver, and this should not be controllable by userspace.

... but we disagree on whether to export the control to userspace. For more complicated pipelines in front of the CSIs we'll need media-ctl anyway, so using that same API for the internal components, makes sense. It also allows userspace to get a clear and stable picture of the available features for any given multiplexer setting.

Quoted 3 lines

Heh, we have a mem2mem driver as well, and it also uses IC post-processor task. It uses banding and striping to support resized output frames larger than 1024x1024. It also makes use of IC rotation and CSC.

Of course :)

Quoted 5 lines

But again this is not converted to a media entity. And again, if IC were to be made a standalone media entity, then the mem2mem device would _always_ require the IC post-processor be linked to it, since the essential feature of mem2mem is to make use of IC post-processor task for CSC, resize, and rotation operations.

Quoted 13 lines

Since the three IC tasks are transparently time-multiplexed, the IC media entity representation could have input and output pads for each of them.
The preprocessing (encoding, viewfinder) tasks share an input pad that would be connected to either CSI0, CSI1, or VDI output pad. These links should control the IC mux. The encoding task output pad would represent IDMAC channel 20/CB0 or channel 48/CB8, depending on whether the rotator is active. Since rotation requires tight integration between IC and IDMAC, I don't think the IRT should be represented as a separate media entity.
The viewfinder task output pad would correspond to channel 21/CB1 or channel 49/CB9, and maybe in the future control whether to send that data off to the DMFC or to memory.

right. Currently we don't attempt to use the direct IC-PRPVF --> DMFC path. Viewfinder code looks much like PRPENC (like you or Sascha pointed out earlier), it just transfers scaled/CSC/rotated frames to a framebuffer addr in memory provided by s_fbuf.

Quoted 3 lines

The postprocessing input and output pads would go straight to memory and are not configurable, so I see no need to describe IC-PP as media entity.

er, now I'm being your own best advocate! :) If IC-PP I/O is going to be described by pads, then I think IC-PP would have to be described as a media entity.

For mem2mem device, the sink and source links to IC-PP would have to marked as immutable (always enabled).

Quoted 6 lines

I'm not quite sure about the VDIC, but I guess that also should be configurable from userspace as one input to IC. For the deinterlacer to work, IC_INPUT needs to be set, so while this is active there is no way to route CSI0/1 through the IC directly.

sounds right. But there's too much to think about already.

Btw we have tried to implement direct CSI --> VDIC --> IC path without success. Freescale's BSP does not use the VDIC in this way, but rather as mem --> VDIC --> mem, i.e. a kind of post-processing after capture. I'm a bit vague about this since I haven't looked at VDIC yet in much detail.

Quoted 46 lines

[...]

Quoted 5 lines
Quoted 5 lines

No conflict here, there are different multiplexers to talk about.

First, there are two external multiplexers controlled by IOMUXC (on i.MX6, these don't exist on i.MX5): MIPI_IPU1/2_MUX on i.MX6Q and IPU_CSI0/1_MUX. They are not part of the IPU.

[...]

Quoted 6 lines

right, this is one place where subdev linking makes sense to me. I.e. linking sensors to CSI ports.

But you don't mean to allow userspace to make this link arbitrarily, correct? You mean the driver uses the mediactrl framework to implement the links defined in the device tree. Maybe that's where I was confused.

No, this is exactly what I mean. In my opinion, using media-ctl to throw the switches is much better than letting the driver decide depending on the old S_INPUT API. Especially since this gives userspace a unified API when there are input multiplexers (or any other subdevices configurable on the pad level) external to the SoC.
Also, pad format configuration of the CSI subdev exported to userspace may be useful to control the compander in the CSI.

[...]

Quoted 8 lines
Quoted 7 lines

From an organizational standpoint, with all the other register access code in gpu/ipu-v3, having the ipu-csi code in there too looks nice and as expected.
On the other hand, this should really be only used by one v4l2_subdev driver. When I look at it this way, I see a driver that is split in two parts, wasting exported symbol space for no very good reason.

Quoted 4 lines

I agree about making CSI a subdev, but I also think we can keep all of the register access in IPU core as well. The CSI subdev would be a wrapper around the ipu-csi APIs. I agree it's more use of symbol space, but we might be able to simplify the ipu-csi API.

So be it. In any case, this decision could be changed later with little effort and without any externally visible changes, if deemed necessary, as long as the CSI v4l2_subdev driver is the only consumer of this API.

Quoted 6 lines
Quoted 5 lines

The IC I'd like to describe as a v4l2_subdev. But I'd also like to use the IC from the DRM driver. So the IC core code has to stay in gpu/ipu-v3. I'd just like to pool all V4L2 code that uses this into a IC v4l2_subdev driver if possible. The only use we have for the IC currently is

Quoted 8 lines
Quoted 4 lines

is mem2mem? And you would like to see an IC pads linked with mem2mem pads. Well, something like this:

input frame from userspace ---> m2m ---> IC-PP ---> m2m ---> to userspace

As long as there is no internal video bus switch somewhere, the usefulness of this is debatable. You see we also implemented this by directly calling the IPU IC API, and I'm fine with this.

well, as I said above I think if we are going to make the IC a media entity we might as well make mem2mem a media device and include IC-PP as an entity with immutable links to it.

Steve

Quoted 23 lines

[...]

Quoted 3 lines

Ok, in summary I'm aligned with everything you said. Only that I am still pondering about which media entity links make sense, and who should be allowed to make those links.

At least the decision whether to route the CSI0/1 into the IC preprocessing input should be handled by userspace, as this changes the capabilities of the corresponding video_dev.

Quoted 3 lines

So how should we proceed? I would argue to use our capture driver as a base, since it is fully functional and fairly full-featured. It's just missing the media framework.

Initially, I don't care as much about a full featureset as I do about getting the userspace API and device tree bindings right, since those won't be easy to change later.
Pending rework into CSI/IC subdevices and agreement on the userspace facing API, I think your patchset can be a good base.

regards
Philipp