Skip to contentSkip to conversation

add IPU3 CIO2 CSI2 driver

PATCH Superseded Yong Zhi 4 participants 10 messages Jun 13, 2017 – Jun 14, 2017

Subsystems (3)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Yong Zhi

author maintainer
#0 lore raw

v3 cover add IPU3 CIO2 CSI2 driver

This patch adds the driver for the CIO2 device found in some the Skylake and Kaby Kake SoCs. The CIO2 consists of four D-PHY receivers.

The CIO2 driver exposes V4L2, V4L2 sub-device and Media controller interfaces to the user space.

===========
= history =
===========

More soon for next version.

version 3:
- remove cio2_set_power().
- replace dma_alloc_noncoherent() with dma_alloc_coherent().
- apply ffs tricks at possible places.
- change sensor_vc to local variable.
- move ktime_get_ns() a little earlier in the calling order.
- fix multiple assignments(I.e a = b =c)
- define CIO2_PAGE_SIZE for CIO2 PAGE_SIZE, SENSOR_VIR_CH_DFLT for default sensor virtual ch.
- rework cio2_csi2_calc_timing().
- update v4l2 async subdev field name from match.fwnode.fwn to match.fwnode.fwnode.
- cherry-pick internal fix for triggering different irq on SOF and EOF.
- return -ENOMEM for vb2_dma_sg_plane_desc() in cio2_vb2_buf_init().
- add cio2_link_validate() placeholder for vdev.

version 2:
- remove all explicit DMA flush operations
- change dma_free_noncoherent() to dma_free_coherent()
- remove cio2_hw_mipi_lanes()
- replace v4l2_g_ext_ctrls() with v4l2_ctrl_g_ctrl()
in cio2_csi2_calc_timing().
- use ffs() to iterate the port_status in cio2_irq()
- add static inline file_to_cio2_queue() function
- comment dma_wmb(), cio2_rx_timing() and few other places
- use ktime_get_ns() for vb2_buf.timestamp in cio2_buffer_done()
- use of SET_RUNTIME_PM_OPS() macro for cio2_pm_ops
- use BIT() macro for bit difinitions
- remove un-used macros such as CIO2_QUEUE_WIDTH() in ipu3-cio2.h
- move the MODULE_AUTHOR() to the end of the file
- change file path to drivers/media/pci/intel/ipu3

version 1:
- Initial submission
Yong Zhi (3):
videodev2.h, v4l2-ioctl: add IPU3 raw10 color format
doc-rst: add IPU3 raw10 bayer pixel format definitions
intel-ipu3: cio2: Add new MIPI-CSI2 driver

 Documentation/media/uapi/v4l/pixfmt-rgb.rst        |    1 +
 .../media/uapi/v4l/pixfmt-srggb10-ipu3.rst         |   62 +
 drivers/media/pci/Kconfig                          |    2 +
 drivers/media/pci/Makefile                         |    3 +-
 drivers/media/pci/intel/Makefile                   |    5 +
 drivers/media/pci/intel/ipu3/Kconfig               |   17 +
 drivers/media/pci/intel/ipu3/Makefile              |    1 +
 drivers/media/pci/intel/ipu3/ipu3-cio2.c           | 1779 ++++++++++++++++++++
 drivers/media/pci/intel/ipu3/ipu3-cio2.h           |  434 +++++
 drivers/media/v4l2-core/v4l2-ioctl.c               |    4 +
 include/uapi/linux/videodev2.h                     |    5 +
 11 files changed, 2312 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst
 create mode 100644 drivers/media/pci/intel/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/Kconfig
 create mode 100644 drivers/media/pci/intel/ipu3/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.c
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.h
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v3 1/3 videodev2.h, v4l2-ioctl: add IPU3 raw10 color format

Add IPU3 specific formats:

	V4L2_PIX_FMT_IPU3_SBGGR10
	V4L2_PIX_FMT_IPU3_SGBRG10
	V4L2_PIX_FMT_IPU3_SGRBG10
	V4L2_PIX_FMT_IPU3_SRGGB10
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++++
 include/uapi/linux/videodev2.h       | 5 +++++
 2 files changed, 9 insertions(+)
drivers/media/v4l2-core/v4l2-ioctl.c +4 -0
index 4f27cfa..9de6ba0 100644
@@ -1202,6 +1202,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_SGBRG10P:	descr = "10-bit Bayer GBGB/RGRG Packed"; break;
 	case V4L2_PIX_FMT_SGRBG10P:	descr = "10-bit Bayer GRGR/BGBG Packed"; break;
 	case V4L2_PIX_FMT_SRGGB10P:	descr = "10-bit Bayer RGRG/GBGB Packed"; break;
+	case V4L2_PIX_FMT_IPU3_SBGGR10: descr = "10-bit bayer BGGR IPU3 Packed"; break;
+	case V4L2_PIX_FMT_IPU3_SGBRG10: descr = "10-bit bayer GBRG IPU3 Packed"; break;
+	case V4L2_PIX_FMT_IPU3_SGRBG10: descr = "10-bit bayer GRBG IPU3 Packed"; break;
+	case V4L2_PIX_FMT_IPU3_SRGGB10: descr = "10-bit bayer RGGB IPU3 Packed"; break;
 	case V4L2_PIX_FMT_SBGGR10ALAW8:	descr = "8-bit Bayer BGBG/GRGR (A-law)"; break;
 	case V4L2_PIX_FMT_SGBRG10ALAW8:	descr = "8-bit Bayer GBGB/RGRG (A-law)"; break;
 	case V4L2_PIX_FMT_SGRBG10ALAW8:	descr = "8-bit Bayer GRGR/BGBG (A-law)"; break;
include/uapi/linux/videodev2.h +5 -0
index 2b8feb8..7bfa6ad 100644
@@ -663,6 +663,11 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_MT21C    v4l2_fourcc('M', 'T', '2', '1') /* Mediatek compressed block mode  */
 #define V4L2_PIX_FMT_INZI     v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
 
+#define V4L2_PIX_FMT_IPU3_SBGGR10	v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
+#define V4L2_PIX_FMT_IPU3_SGBRG10	v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */
+#define V4L2_PIX_FMT_IPU3_SGRBG10	v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */
+#define V4L2_PIX_FMT_IPU3_SRGGB10	v4l2_fourcc('i', 'p', '3', 'r') /* IPU3 packed 10-bit RGGB bayer */
+
 /* SDR formats - used only for Software Defined Radio devices */
 #define V4L2_SDR_FMT_CU8          v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
 #define V4L2_SDR_FMT_CU16LE       v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v3 1/3] videodev2.h, v4l2-ioctl: add IPU3 raw10 color format

Quoted 6 lines · On Tue, 13 Jun 2017 15:17:14 -0500 Yong Zhi <[email protected]> wrote:

Add IPU3 specific formats:

	V4L2_PIX_FMT_IPU3_SBGGR10
	V4L2_PIX_FMT_IPU3_SGBRG10
	V4L2_PIX_FMT_IPU3_SGRBG10
	V4L2_PIX_FMT_IPU3_SRGGB10

As I said before these are just more bitpacked bayer formats with no reason to encode them as IPUv3 specific names.

Alan

author maintainer
#3 lore raw

RE: [PATCH v3 1/3] videodev2.h, v4l2-ioctl: add IPU3 raw10 color format

Quoted 25 lines

-----Original Message-----
From: Alan Cox [mailto:[email protected]]
Sent: Wednesday, June 14, 2017 6:49 AM
To: Zhi, Yong <[email protected]>
Cc: [email protected]; [email protected]; Zheng, Jian Xu <[email protected]>; [email protected]; Mani, Rajmohan <[email protected]>; Toivonen, Tuukka <[email protected]>; Yang, Hyungwoo <[email protected]>; Mohandass, Divagar <[email protected]>
Subject: Re: [PATCH v3 1/3] videodev2.h, v4l2-ioctl: add IPU3 raw10 color format

Quoted 6 lines · On Tue, 13 Jun 2017 15:17:14 -0500 Yong Zhi <[email protected]> wrote:

Add IPU3 specific formats:

	V4L2_PIX_FMT_IPU3_SBGGR10
	V4L2_PIX_FMT_IPU3_SGBRG10
	V4L2_PIX_FMT_IPU3_SGRBG10
	V4L2_PIX_FMT_IPU3_SRGGB10
Quoted 4 lines

As I said before these are just more bitpacked bayer formats with no reason to encode them as IPUv3 specific names.

Alan

Ack, will update for next version.

#4 lore raw

Re: [PATCH v3 1/3] videodev2.h, v4l2-ioctl: add IPU3 raw10 color format

In reply to Alan Cox
Quoted 5 lines · Alan Cox
Quoted 2 lines · On Tue, 13 Jun 2017 15:17:14 -0500 Yong Zhi <[email protected]> wrote:

Add IPU3 specific formats:

Quoted 7 lines
Quoted 4 lines
	V4L2_PIX_FMT_IPU3_SBGGR10
	V4L2_PIX_FMT_IPU3_SGBRG10
	V4L2_PIX_FMT_IPU3_SGRBG10
	V4L2_PIX_FMT_IPU3_SRGGB10

As I said before these are just more bitpacked bayer formats with no reason to encode them as IPUv3 specific names.

I must have missed that comment --- the format is pretty unusual still. Basically it rams as much pixels into a 256-bit DMA word as there's room and then leaves the rest of the DMA word empty (6 bits in this case).

The newer IPUs do not use this format AFAIK (they do use other unusual formats though). I haven't seen such formats being used by other non-IPU hardware either.

I think I'd keep this IPU specific unless there's an indication the same formats might be used elsewhere. The other packed formats that have been defined in V4L2 are hardware independent.

Cc Hans, too.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
author maintainer
#5 lore raw

PATCH v3 2/3 doc-rst: add IPU3 raw10 bayer pixel format definitions

In reply to Yong Zhi

The formats added by this patch are:

    V4L2_PIX_FMT_IPU3_SBGGR10
    V4L2_PIX_FMT_IPU3_SGBRG10
    V4L2_PIX_FMT_IPU3_SGRBG10
    V4L2_PIX_FMT_IPU3_SRGGB10
---
 Documentation/media/uapi/v4l/pixfmt-rgb.rst        |  1 +
 .../media/uapi/v4l/pixfmt-srggb10-ipu3.rst         | 62 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst
Documentation/media/uapi/v4l/pixfmt-rgb.rst +1 -0
index b0f3513..6900d5c 100644
@@ -16,5 +16,6 @@ RGB Formats
     pixfmt-srggb10p
     pixfmt-srggb10alaw8
     pixfmt-srggb10dpcm8
+    pixfmt-srggb10-ipu3
     pixfmt-srggb12
     pixfmt-srggb16
Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH v3 3/3 intel-ipu3: cio2: Add new MIPI-CSI2 driver

In reply to Yong Zhi

This patch adds CIO2 CSI-2 device driver for
Intel's IPU3 camera sub-system support.

---
 drivers/media/pci/Kconfig                |    2 +
 drivers/media/pci/Makefile               |    3 +-
 drivers/media/pci/intel/Makefile         |    5 +
 drivers/media/pci/intel/ipu3/Kconfig     |   17 +
 drivers/media/pci/intel/ipu3/Makefile    |    1 +
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1779 ++++++++++++++++++++++++++++++
 drivers/media/pci/intel/ipu3/ipu3-cio2.h |  434 ++++++++
 7 files changed, 2240 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/pci/intel/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/Kconfig
 create mode 100644 drivers/media/pci/intel/ipu3/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.c
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.h
drivers/media/pci/Kconfig +2 -0
index da28e68..5932e22 100644
@@ -54,5 +54,7 @@ source "drivers/media/pci/smipcie/Kconfig"
 source "drivers/media/pci/netup_unidvb/Kconfig"
 endif
 
+source "drivers/media/pci/intel/ipu3/Kconfig"
+
 endif #MEDIA_PCI_SUPPORT
 endif #PCI
drivers/media/pci/Makefile +2 -1
index a7e8af0..d8f9843 100644
@@ -13,7 +13,8 @@ obj-y        +=	ttpci/		\
 		ddbridge/	\
 		saa7146/	\
 		smipcie/	\
-		netup_unidvb/
+		netup_unidvb/	\
+		intel/
 
 obj-$(CONFIG_VIDEO_IVTV) += ivtv/
 obj-$(CONFIG_VIDEO_ZORAN) += zoran/
drivers/media/pci/intel/Makefile new file +5 -0
new file mode 100644
index 0000000..745c8b2
@@ -0,0 +1,5 @@
+#
+# Makefile for the IPU3 cio2 and ImGU drivers
+#
+
+obj-y	+= ipu3/
drivers/media/pci/intel/ipu3/Kconfig new file +17 -0
new file mode 100644
index 0000000..2a895d6
@@ -0,0 +1,17 @@
+config VIDEO_IPU3_CIO2
+	tristate "Intel ipu3-cio2 driver"
+	depends on VIDEO_V4L2 && PCI
+	depends on MEDIA_CONTROLLER
+	depends on HAS_DMA
+	depends on ACPI
+	select V4L2_FWNODE
+	select VIDEOBUF2_DMA_SG
+
+	---help---
+	This is the Intel IPU3 CIO2 CSI-2 receiver unit, found in Intel
+	Skylake and Kaby Lake SoCs and used for capturing images and
+	video from a camera sensor.
+
+	Say Y or M here if you have a Skylake/Kaby Lake SoC with MIPI CSI-2
+	connected camera.
+	The module will be called ipu3-cio2.
drivers/media/pci/intel/ipu3/Makefile new file +1 -0
new file mode 100644
index 0000000..20186e3
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_IPU3_CIO2) += ipu3-cio2.o
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +1779 -0

1,779 lines not on this page · raw message

drivers/media/pci/intel/ipu3/ipu3-cio2.h new file +434 -0

434 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

Re: [PATCH 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

Hi Yong,

Quoted 4 lines · Yong Zhi

This patch adds CIO2 CSI-2 device driver for
Intel's IPU3 camera sub-system support.

Quoted 15 lines
---
 drivers/media/pci/Kconfig                |    2 +
 drivers/media/pci/Makefile               |    3 +-
 drivers/media/pci/intel/Makefile         |    5 +
 drivers/media/pci/intel/ipu3/Kconfig     |   17 +
 drivers/media/pci/intel/ipu3/Makefile    |    1 +
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1779 ++++++++++++++++++++++++++++++
 drivers/media/pci/intel/ipu3/ipu3-cio2.h |  434 ++++++++
 7 files changed, 2240 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/pci/intel/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/Kconfig
 create mode 100644 drivers/media/pci/intel/ipu3/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.c
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.h

I quickly checked the code and it doesn't seem to have most of my comments from v2 addressed. It's not a very good practice to send new version without addressing or at least replying to all the comments - it's the best way to lose track of necessary changes. Please make sure that all the comments are taken care of.

Best regards,
Tomasz

author maintainer
#8 lore raw

RE: [PATCH 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

Hi, Tomasz,

Thanks for your code review, still need more time to study and test the solution for the rest of comments, going forward, I will respond to your review first before submitting new version.

Thanks,

Yong

Quoted 45 lines

-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Tomasz Figa
Sent: Tuesday, June 13, 2017 5:01 PM
To: Zhi, Yong <[email protected]>
Cc: [email protected]; Sakari Ailus <[email protected]>; Zheng, Jian Xu <[email protected]>; Mani, Rajmohan <[email protected]>; Toivonen, Tuukka <[email protected]>; Yang, Hyungwoo <[email protected]>; Mohandass, Divagar <[email protected]>
Subject: Re: [PATCH 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

Hi Yong,

Quoted 4 lines · Yong Zhi

This patch adds CIO2 CSI-2 device driver for Intel's IPU3 camera sub-system support.

Quoted 16 lines
---
 drivers/media/pci/Kconfig                |    2 +
 drivers/media/pci/Makefile               |    3 +-
 drivers/media/pci/intel/Makefile         |    5 +
 drivers/media/pci/intel/ipu3/Kconfig     |   17 +
 drivers/media/pci/intel/ipu3/Makefile    |    1 +
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1779
++++++++++++++++++++++++++++++
drivers/media/pci/intel/ipu3/ipu3-cio2.h |  434 ++++++++
 7 files changed, 2240 insertions(+), 1 deletion(-)  create mode
100644 drivers/media/pci/intel/Makefile  create mode 100644
drivers/media/pci/intel/ipu3/Kconfig
 create mode 100644 drivers/media/pci/intel/ipu3/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.c
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.h

I quickly checked the code and it doesn't seem to have most of my comments from v2 addressed. It's not a very good practice to send new version without addressing or at least replying to all the comments - it's the best way to lose track of necessary changes. Please make sure that all the comments are taken care of.

Best regards,
Tomasz

#9 lore raw

Re: [PATCH 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

Quoted 3 lines · Yong

Hi, Tomasz,

Thanks for your code review, still need more time to study and test the solution for the rest of comments, going forward, I will respond to your review first before submitting new version.

Just to clarify, my note was not about addressing all the comments instantly, but rather about not leaving any unaddressed comments in newer patch sets (unless agreed with the reviewers to do that). The default assumption is that next patch set has all comments from previous one addressed. If that's not true, it's going to confuse the reviewers and make them put additional effort into comparing the code manually.

I'd say it's just better to reply on the list that you need a bit more time to address the comments, rather than sending a half-done next patch set. That's just my opinion, though.

Best regards,
Tomasz

Quoted 50 lines

Thanks,

Yong

Quoted 45 lines

-----Original Message-----
From: [email protected] [mailto:linux-media- [email protected]] On Behalf Of Tomasz Figa
Sent: Tuesday, June 13, 2017 5:01 PM
To: Zhi, Yong <[email protected]>
Cc: [email protected]; Sakari Ailus <[email protected]>; Zheng, Jian Xu <[email protected]>; Mani, Rajmohan <[email protected]>; Toivonen, Tuukka <[email protected]>; Yang, Hyungwoo <[email protected]>; Mohandass, Divagar <[email protected]>
Subject: Re: [PATCH 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver

Hi Yong,

Quoted 4 lines · Yong Zhi

This patch adds CIO2 CSI-2 device driver for Intel's IPU3 camera sub-system support.

Quoted 16 lines
---
 drivers/media/pci/Kconfig                |    2 +
 drivers/media/pci/Makefile               |    3 +-
 drivers/media/pci/intel/Makefile         |    5 +
 drivers/media/pci/intel/ipu3/Kconfig     |   17 +
 drivers/media/pci/intel/ipu3/Makefile    |    1 +
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 1779
++++++++++++++++++++++++++++++
drivers/media/pci/intel/ipu3/ipu3-cio2.h |  434 ++++++++
 7 files changed, 2240 insertions(+), 1 deletion(-)  create mode
100644 drivers/media/pci/intel/Makefile  create mode 100644
drivers/media/pci/intel/ipu3/Kconfig
 create mode 100644 drivers/media/pci/intel/ipu3/Makefile
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.c
 create mode 100644 drivers/media/pci/intel/ipu3/ipu3-cio2.h

I quickly checked the code and it doesn't seem to have most of my comments from v2 addressed. It's not a very good practice to send new version without addressing or at least replying to all the comments - it's the best way to lose track of necessary changes. Please make sure that all the comments are taken care of.

Best regards,
Tomasz