add IPU3 CIO2 CSI2 driver
Subsystems (3)
Yong Zhi
maintainerv7 cover add IPU3 CIO2 CSI2 driver
Hi,
This is patch series(version 7) of Intel IPU3 CIO2 driver, the driver exposes V4L2, V4L2 sub-device and Media controller interfaces to the user space.
This series was tested on Kaby Lake based platform with 2 sensor configurations, media topology was pasted at end for reference.
Link to user space implementation:
<URL:https://chromium.googlesource.com/chromiumos/platform/arc-camera/+/master>
===========
= history =
===========
version 7:
- cio2_subdev_open(): Assign variable at init time. (Sakari)
- cio2_subdev_get_fmt(): Retrieve subdev fmt from subdev not sensor. (Sakari)
- cio2_fbpt_rearrange(): Use in-place swapping of FBPT entries and queue buffers. (implemented by Sakari).
version 6:
- Replaced NUM_FORMATS with ARRAY_SIZE(formats). (Sakari)
- cio2_fbpt_rearrange(): skip fbpt re-arrange when not needed.
- cio2_resume(): move cio2_fbpt_rearrange() to cio2_suspend() to avoid mem alloc at resume time.(Sakari)
- cio2_pci_probe(): call cio2_fbpt_init_dummy() before v4l2_device_register().(Sakari)
- Fixed checkpatch.pl reported checks with --strict option.
- Added static keyword to cio2_queue_init().
- cio2_buffer_done(): assign ns in variable initialization.(Sakari)
- cio2_notifier_bound(): create hard link between cio2 queues and CSI-2 port.(Sakari)
- cio2_notifier_unbount(): remove obsolete comments.(Sakari)
- cio2_notifier_init(): return error when no subdevs found.(Sakari)
- cio2_find_queue_by_sensor_node(): remove the function (Tomasz Figa)
- ipu3-cio2.h:
Change CIO2_QUEUES 4 to match IPU3 capability.(Sakari)
Remove un-used "other_entries" in struct cio2_fbpt_entry.(Sakari)
- pixfmt-srggb10-ipu3.rst: Changed tabularcolumns to 4.(Sakari)
- Enable x86 32bit build (Sakari)
version 5:
- cio2_vb2_start_streaming():
- cio2_vb2_stop_streaming(): removed redundant call of csi2 sub-dev for s_stream.
- cio2_vb2_buf_queue(): disabled interrupts for the duration of the buf queue, to prevent this code from being pre-empted, as suggested by Tomasz Figa, to mitigate the effects of race conditions around vb2 buf queuing code. Switched to a finite loop to check for the first free buffer and errored out, when there are no buffers available. Removed calls to vb2_plane_vaddr() Maintain correct buf queued count, in error cases.
- Implemented system sleep pm ops to support cio2 driver suspend/resume.
- Made the v4l2 buffer and SOF event use sequence from same source.
- cio2_vb2_queue_setup(): remove validating pixelformat suggested by Tomasz Figa.
- cio2_v4l2_g_fmt()/cio2_v4l2_s_fmt(): seperated formats on sub-dev and video device suggested by Sakari Ailus.
- cio2_v4l2_try_fmt(): seperated video node and subdev format in the get_fmt, try_fmt and set_fmt callbacks.
- cio2_queue_event_sof(): added comments suggested by Hans Verkuil
- cio2_queue_init(): re-ordered q->subdev_pads settings. remove 4 lines for quantization init.
- cio2_subdev_get_fmt(): get colorspace/xfer_func/ycbcr_enc/quantization from sensor suggested by Hans Verkuil.
- cio2_fbpt_entry_init_buf(): stored offset of the first sg_list entry to remove calls to vb2_plane_vaddr().
- cio2_subdev_open(): added new callback to intialize the try format.
- cio2_subdev_video_ops(): removed empty implementation suggested by Sakari Ailus.
- cio2_notifier_init(): added fwnode binding support for subdevices using v4l2_async_notifier_parse_fwnode_endpoints()
Patch series v15 Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS is needed for the fwnode binding code to compile.
https://www.mail-archive.com/[email protected]/msg120239.html
This also requires the following patch (v1) for the fwnode binding to work
https://patchwork.kernel.org/patch/9986445/
- cio2_notifier_complete(): removed redundant call of fwnode_graph_get_remote_endpoint() and fwnode_graph_parse_endpoint().
- Switched to Multi Plane APIs suggested by Tomasz Figa.
User space changes supporting multi plane APIs can be found here
https://chromium-review.googlesource.com/c/chromiumos/platform/arc-camera/+/683802
- ipu3-cio.h: moved macros out of struct cio2_fbpt_entry suggested by Hans Verkuil.
- cio2_hw_mbus_to_mipicode(): replaced with cio2_find_format().
- cio2_pci_probe(): cleaned up goto logic on error conditions suggested by Tomasz Figa.
- Fixed v4l2_compliance test failures
added 3 dummy function to pass v4l2_compliance test.
- Extended format example in pixfmt-srggb10-ipu3.rst to show DMA word boundary.
version 4:
- add cio2_video_link_validate() for video entity suggested by Sakari Ailus
- cio2_notifier_complete(): fix comments suggested by Sakari Ailus
- cio2_vb2_buf_queue(): fix the forever loop suggested by Tomasz Figa
- cio2_v4l2_querycap(): use vdev device_caps commented by Hans Verkuil
- cio2_vb2_buf_init(): allocate LOP table per page suggested by Tomasz Figa
- cio2_hw_init(): call cio2_csi2_calc_timing() earlier suggested by Tomasz Figa
- cio2_csi2_calc_timing(): add defalt settings for rx term/settle
- cio2_vb2_queue_setup(): remove num_planes checking suggested by Tomasz Figa
- cio2_buffer_done(): remove setting b->vbb.flags to V4L2_BUF_FLAG_DONE and memset of vbb.timecode, also move vb2_set_plane_payload() to cio2_vb2_buf_queue() suggested by Sakari Ailus
- cio2_queue_init(): export VB2_DMABUF io_modes suggested by Tomasz Figa
- cio2_vb2_return_all_buffers(): remove state from param list suggested by Tomasz Figa
- cio2_vb2_buf_queue(): use vb2_is_streaming() instead of vb2_start_streaming_called() suggested by Tomasz Figa
- cio2_pci_probe(): replace hard-coded linux driver version suggested by Hans Verkuil
- ipu3-cio2.h: re-order the reg macros suggested by Sakari Ailus
- ipu3-cio2.h: add inline vb2q_to_cio2_queue() suggested by Sakari Ailus
- ipu3-cio2.h: add comments for CIO2_INT_IOC suggested by Tomasz Figa
- ipu3-cio2.h: adjust PBM watermark threshold from 53 to 48 (internal bugfix)
- run v4l2_compliance suggested by Hans Verkuil
Todo list:
- fix possible racy code in cio2_vb2_buf_queue()
- fix v4l2_compliance test failure
- switch to v4l2_pix_format_mplane API if future needs arise
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
Media device topology:
localhost bin # ./media-ctl -d /dev/media0 -p
Media controller API version 4.14.0
Media device information
------------------------
driver ipu3-cio2
model Intel IPU3 CIO2
serial
bus info PCI:0000:00:14.3 hw revision 0x0 driver version 4.14.0
Device topology
- entity 1: ipu3-csi2:0 (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[fmt:SGRBG10_1X10/1936x1096 field:none]
<- "ov13858 8-0010":0 []
pad1: Source
[fmt:SGRBG10_1X10/1936x1096 field:none]
-> "ipu3-cio2:0":0 [ENABLED,IMMUTABLE]- entity 4: ipu3-cio2:0 (1 pad, 1 link)
type Node subtype V4L flags 0 device node name /dev/video0
pad0: Sink
<- "ipu3-csi2:0":1 [ENABLED,IMMUTABLE]
- entity 10: ipu3-csi2:1 (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:SRGGB10_1X10/1280x720 field:none]
<- "ov5670 10-0036":0 []
pad1: Source
[fmt:SRGGB10_1X10/1280x720 field:none]
-> "ipu3-cio2:1":0 [ENABLED,IMMUTABLE]- entity 13: ipu3-cio2:1 (1 pad, 1 link)
type Node subtype V4L flags 0 device node name /dev/video1
pad0: Sink
<- "ipu3-csi2:1":1 [ENABLED,IMMUTABLE]
- entity 19: ipu3-csi2:2 (2 pads, 1 link)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev2
pad0: Sink
[fmt:SGRBG10_1X10/1936x1096 field:none]
pad1: Source
[fmt:SGRBG10_1X10/1936x1096 field:none]
-> "ipu3-cio2:2":0 [ENABLED,IMMUTABLE]- entity 22: ipu3-cio2:2 (1 pad, 1 link)
type Node subtype V4L flags 0 device node name /dev/video2
pad0: Sink
<- "ipu3-csi2:2":1 [ENABLED,IMMUTABLE]
- entity 28: ipu3-csi2:3 (2 pads, 1 link)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev3
pad0: Sink
[fmt:SGRBG10_1X10/1936x1096 field:none]
pad1: Source
[fmt:SGRBG10_1X10/1936x1096 field:none]
-> "ipu3-cio2:3":0 [ENABLED,IMMUTABLE]- entity 31: ipu3-cio2:3 (1 pad, 1 link)
type Node subtype V4L flags 0 device node name /dev/video3
pad0: Sink
<- "ipu3-csi2:3":1 [ENABLED,IMMUTABLE]
- entity 37: ov13858 8-0010 (1 pad, 1 link) type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev4
pad0: Source
[fmt:SGRBG10_1X10/4224x3136 field:none] -> "ipu3-csi2:0":0 []
- entity 39: dw9714 8-000c (0 pad, 0 link) type V4L2 subdev subtype Lens flags 0 device node name /dev/v4l-subdev5
- entity 40: ov5670 10-0036 (1 pad, 1 link) type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev6
pad0: Source
[fmt:SGRBG10_1X10/2592x1944 field:none] -> "ipu3-csi2:1":0 []
localhost bin # ./v4l2-compliance -d /dev/video0
v4l2-compliance SHA : not available
Driver Info:
Driver name : ipu3-cio2 Card type : Intel IPU3 CIO2 Bus info : PCI:0000:00:14.3
Driver version: 4.14.0
Capabilities : 0x84201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Test input 0:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
Test input 0:
Total: 43, Succeeded: 43, Failed: 0, Warnings: 0
Note:
Same results with other 3 video nodes.
Running v4l2_compliance test with -f option will fail, we can only run stream test with the help of media controller to link, configure and enable the sub-dev/pads first.
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 | 335 ++++ drivers/media/pci/Kconfig | 2 + drivers/media/pci/Makefile | 3 +- drivers/media/pci/intel/Makefile | 5 + drivers/media/pci/intel/ipu3/Kconfig | 19 + drivers/media/pci/intel/ipu3/Makefile | 1 + drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2053 ++++++++++++++++++++ drivers/media/pci/intel/ipu3/ipu3-cio2.h | 449 +++++ drivers/media/v4l2-core/v4l2-ioctl.c | 4 + include/uapi/linux/videodev2.h | 6 + 11 files changed, 2877 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
Yong Zhi
maintainerPATCH v7 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 | 6 ++++++ 2 files changed, 10 insertions(+)
drivers/media/v4l2-core/v4l2-ioctl.c +4 -0
@@ -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 +6 -0
@@ -668,6 +668,12 @@ 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 */ +/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */ +#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
Yong Zhi
maintainerPATCH v7 2/3 doc-rst: add IPU3 raw10 bayer pixel format definitions
In reply to Yong ZhiThe 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 | 335 +++++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100644 Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst
Documentation/media/uapi/v4l/pixfmt-rgb.rst +1 -0
@@ -16,6 +16,7 @@ RGB Formats pixfmt-srggb10p pixfmt-srggb10alaw8 pixfmt-srggb10dpcm8 + pixfmt-srggb10-ipu3 pixfmt-srggb12 pixfmt-srggb12p pixfmt-srggb16
Documentation/media/uapi/v4l/pixfmt-srggb10-ipu3.rst new file +335 -0
335 lines not on this page · raw message
Signature · 1 line
2.7.4
Yong Zhi
maintainerPATCH v7 3/3 intel-ipu3: cio2: Add new MIPI-CSI2 driver
In reply to Yong ZhiThis 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 | 19 + drivers/media/pci/intel/ipu3/Makefile | 1 + drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2053 ++++++++++++++++++++++++++++++ drivers/media/pci/intel/ipu3/ipu3-cio2.h | 449 +++++++ 7 files changed, 2531 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
@@ -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
@@ -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
@@ -0,0 +1,5 @@ +# +# Makefile for the IPU3 cio2 and ImGU drivers +# + +obj-y += ipu3/
drivers/media/pci/intel/ipu3/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +config VIDEO_IPU3_CIO2 + tristate "Intel ipu3-cio2 driver" + depends on VIDEO_V4L2 && PCI + depends on VIDEO_V4L2_SUBDEV_API + depends on X86 || COMPILE_TEST + 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
@@ -0,0 +1 @@ +obj-$(CONFIG_VIDEO_IPU3_CIO2) += ipu3-cio2.o
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +2053 -0
2,053 lines not on this page · raw message
drivers/media/pci/intel/ipu3/ipu3-cio2.h new file +449 -0
449 lines not on this page · raw message
Signature · 1 line
2.7.4
Sakari Ailus
maintainerRe: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Yong,
Thanks for the update!
I took a final glance, there are a few matters that still need to be addressed but then I think we're done. Please see below.
Then we'll need an entry in the MAINTAINERS file in the kernel root directory. Could you add an entry for this driver in v8?
On Thu, Nov 02, 2017 at 03:00:01PM -0500, Yong Zhi wrote:
...
drivers/media/pci/intel/ipu3/ipu3-cio2.c line 303
Quoted 11 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +11
-0+static int cio2_fbpt_rearrange (struct cio2_device *cio2,struct cio2_queue *q) +{ +unsigned int i, j; + +for (i =0 , j = q->bufs_first; i <CIO2_MAX_BUFFERS ; + i++, j = (j +1 ) %CIO2_MAX_BUFFERS ) +if (q->bufs[j]) +break ; + +if (i ==CIO2_MAX_BUFFERS ) +return 0 ;
You always return 0. The return type could be void.
You could also move this function just above the function using it (it's a single location).
Quoted 20 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +20
-0+ +if (j) { +arrange (q->fbpt,sizeof (struct cio2_fbpt_entry ) *CIO2_MAX_LOPS , +CIO2_MAX_BUFFERS , j); +arrange (q->bufs,sizeof (struct cio2_buffer *), +CIO2_MAX_BUFFERS , j); + } + +/* +* DMA clears the valid bit when accessing the buffer. +* When stopping stream in suspend callback, some of the buffers +* may be in invalid state. After resume, when DMA meets the invalid +* buffer, it will halt and stop receiving new data. +* To avoid DMA halting, set the valid bit for all buffers in FBPT. +*/ +for (i =0 ; i <CIO2_MAX_BUFFERS ; i++) +cio2_fbpt_entry_enable (cio2, q->fbpt + i *CIO2_MAX_LOPS ); + +return 0 ; +}
...
Quoted 30 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +30
-0+static int cio2_vb2_start_streaming (struct vb2_queue *vq,unsigned int count) +{ +struct cio2_queue *q =vb2q_to_cio2_queue (vq); +struct cio2_device *cio2 =vb2_get_drv_priv (vq); +int r; + + cio2->cur_queue = q; +atomic_set (&q->frame_sequence,0 ); + + r =pm_runtime_get_sync (&cio2->pci_dev->dev); +if (r <0 ) { +dev_info (&cio2->pci_dev->dev,"failed to set power %d\n" , r); +pm_runtime_put (&cio2->pci_dev->dev); +return r; + } + + r =media_pipeline_start (&q->vdev.entity, &q->pipe); +if (r) + goto fail_pipeline; + + r =cio2_hw_init (cio2, q); +if (r) + goto fail_hw; + +/* Start streaming on sensor */ + r =v4l2_subdev_call (q->sensor, video, s_stream,1 ); +if (r) + goto fail_csi2_subdev; + + cio2->streaming = true;
drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1105
Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +10
-0+ +return 0 ; + +fail_csi2_subdev: +cio2_hw_exit (cio2, q); +fail_hw: +media_pipeline_stop (&q->vdev.entity); +fail_pipeline: +dev_dbg (&cio2->pci_dev->dev,"failed to start streaming (%d)\n" , r); +cio2_vb2_return_all_buffers (q);
I believe there should be
pm_runtime_put(&cio2->pci_dev->dev);
here. You should also add a label and use goto from where you do pm_runtime_put() in error handling in this function in order to make this cleaner.
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +return r; +}
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
RE: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Sakari, Yong,
Quoted 55 lines
Subject: Re: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Yong,
Thanks for the update!
I took a final glance, there are a few matters that still need to be addressed but then I think we're done. Please see below.
Then we'll need an entry in the
MAINTAINERSfile in the kernel root directory. Could you add an entry for this driver in v8?On Thu, Nov 02, 2017 at 03:00:01PM -0500, Yong Zhi wrote:
...drivers/media/pci/intel/ipu3/ipu3-cio2.c line 303
Quoted 11 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +11
-0+static int cio2_fbpt_rearrange (struct cio2_device *cio2,struct +cio2_queue *q) { +unsigned int i, j; + +for (i =0 , j = q->bufs_first; i <CIO2_MAX_BUFFERS ; + i++, j = (j +1 ) %CIO2_MAX_BUFFERS ) +if (q->bufs[j]) +break ; + +if (i ==CIO2_MAX_BUFFERS ) +return 0 ;You always return 0. The return type could be void.
You could also move this function just above the function using it (it's a single location).
drivers/media/pci/intel/ipu3/ipu3-cio2.c
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +if (j) { + arrange(q->fbpt, sizeof(struct cio2_fbpt_entry) *
CIO2_MAX_LOPS,Quoted 17 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+ CIO2_MAX_BUFFERS, j); +arrange (q->bufs,sizeof (struct cio2_buffer *), +CIO2_MAX_BUFFERS , j); + } + +/* +* DMA clears the valid bit when accessing the buffer. +* When stopping stream in suspend callback, some of the buffers +* may be in invalid state. After resume, when DMA meets the invalid +* buffer, it will halt and stop receiving new data. +* To avoid DMA halting, set the valid bit for all buffers in FBPT. +*/ +for (i =0 ; i <CIO2_MAX_BUFFERS ; i++) +cio2_fbpt_entry_enable (cio2, q->fbpt + i *CIO2_MAX_LOPS ); + +return 0 ; +}...
Quoted 13 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1078
Quoted 13 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +13
-0+static int cio2_vb2_start_streaming (struct vb2_queue *vq,unsigned +int count) { +struct cio2_queue *q =vb2q_to_cio2_queue (vq); +struct cio2_device *cio2 =vb2_get_drv_priv (vq); +int r; + + cio2->cur_queue = q; +atomic_set (&q->frame_sequence,0 ); + + r =pm_runtime_get_sync (&cio2->pci_dev->dev); +if (r <0 ) { +dev_info (&cio2->pci_dev->dev,"failed to set power %d\n" , r); +pm_runtime_put (&cio2->pci_dev->dev);
Shouldn't we use pm_runtime_put_noidle() here, so the usage_count gets decremented?
Quoted 45 lines
Quoted 17 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+return r; + } + + r =media_pipeline_start (&q->vdev.entity, &q->pipe); +if (r) + goto fail_pipeline; + + r =cio2_hw_init (cio2, q); +if (r) + goto fail_hw; + +/* Start streaming on sensor */ + r =v4l2_subdev_call (q->sensor, video, s_stream,1 ); +if (r) + goto fail_csi2_subdev; + + cio2->streaming = true;drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1105
Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +10
-0+ +return 0 ; + +fail_csi2_subdev: +cio2_hw_exit (cio2, q); +fail_hw: +media_pipeline_stop (&q->vdev.entity); +fail_pipeline: +dev_dbg (&cio2->pci_dev->dev,"failed to start streaming (%d)\n" , r); +cio2_vb2_return_all_buffers (q);I believe there should be
pm_runtime_put(&cio2->pci_dev->dev);here. You should also add a label and use goto from where you do
pm_runtime_put()in error handling in this function in order to make this cleaner.drivers/media/pci/intel/ipu3/ipu3-cio2.c line 413
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +return r; +}--
Kind regards,Sakari Ailus
[email protected]
Sakari Ailus
maintainerRe: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Rajmohan,
Quoted 57 lines · Rajmohan
Hi Sakari, Yong,
Quoted 55 lines
Subject: Re: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Yong,
Thanks for the update!
I took a final glance, there are a few matters that still need to be addressed but then I think we're done. Please see below.
Then we'll need an entry in the
MAINTAINERSfile in the kernel root directory. Could you add an entry for this driver in v8?On Thu, Nov 02, 2017 at 03:00:01PM -0500, Yong Zhi wrote:
...drivers/media/pci/intel/ipu3/ipu3-cio2.c line 303
Quoted 11 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +11
-0+static int cio2_fbpt_rearrange (struct cio2_device *cio2,struct +cio2_queue *q) { +unsigned int i, j; + +for (i =0 , j = q->bufs_first; i <CIO2_MAX_BUFFERS ; + i++, j = (j +1 ) %CIO2_MAX_BUFFERS ) +if (q->bufs[j]) +break ; + +if (i ==CIO2_MAX_BUFFERS ) +return 0 ;You always return 0. The return type could be void.
You could also move this function just above the function using it (it's a single location).
drivers/media/pci/intel/ipu3/ipu3-cio2.c
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +if (j) { + arrange(q->fbpt, sizeof(struct cio2_fbpt_entry) *
CIO2_MAX_LOPS,Quoted 17 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+ CIO2_MAX_BUFFERS, j); +arrange (q->bufs,sizeof (struct cio2_buffer *), +CIO2_MAX_BUFFERS , j); + } + +/* +* DMA clears the valid bit when accessing the buffer. +* When stopping stream in suspend callback, some of the buffers +* may be in invalid state. After resume, when DMA meets the invalid +* buffer, it will halt and stop receiving new data. +* To avoid DMA halting, set the valid bit for all buffers in FBPT. +*/ +for (i =0 ; i <CIO2_MAX_BUFFERS ; i++) +cio2_fbpt_entry_enable (cio2, q->fbpt + i *CIO2_MAX_LOPS ); + +return 0 ; +}...
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +5
-0+static int cio2_vb2_start_streaming (struct vb2_queue *vq,unsigned +int count) { +struct cio2_queue *q =vb2q_to_cio2_queue (vq); +struct cio2_device *cio2 =vb2_get_drv_priv (vq); +int r;Quoted 8 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1078
Quoted 8 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +8
-0+ + cio2->cur_queue = q; +atomic_set (&q->frame_sequence,0 ); + + r =pm_runtime_get_sync (&cio2->pci_dev->dev); +if (r <0 ) { +dev_info (&cio2->pci_dev->dev,"failed to set power %d\n" , r); +pm_runtime_put (&cio2->pci_dev->dev);Shouldn't we use
pm_runtime_put_noidle()here, so theusage_countgets decremented?
Yeah, pm_runtime_put_noidle() would be perhaps more appropriate. The difference is that the noidle variant won't suspend the device (but it was already suspended to begin with as resuming failed).
Quoted 46 lines
Quoted 46 lines
Quoted 18 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+return r; + } + + r =media_pipeline_start (&q->vdev.entity, &q->pipe); +if (r) + goto fail_pipeline; + + r =cio2_hw_init (cio2, q); +if (r) + goto fail_hw; + +/* Start streaming on sensor */ + r =v4l2_subdev_call (q->sensor, video, s_stream,1 ); +if (r) + goto fail_csi2_subdev; + + cio2->streaming = true;drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1105
Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +10
-0+ +return 0 ; + +fail_csi2_subdev: +cio2_hw_exit (cio2, q); +fail_hw: +media_pipeline_stop (&q->vdev.entity); +fail_pipeline: +dev_dbg (&cio2->pci_dev->dev,"failed to start streaming (%d)\n" , r); +cio2_vb2_return_all_buffers (q);I believe there should be
pm_runtime_put(&cio2->pci_dev->dev);here. You should also add a label and use goto from where you do
pm_runtime_put()in error handling in this function in order to make this cleaner.drivers/media/pci/intel/ipu3/ipu3-cio2.c line 413
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +return r; +}--
Kind regards,Sakari Ailus
[email protected]
Signature · 2 lines
Sakari Ailus [email protected]
RE: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Sakari,
Quoted 89 lines
-----Original Message-----
From: Sakari Ailus [mailto:[email protected]]
Sent: Monday, November 06, 2017 3:38 PM
To: Mani, Rajmohan <[email protected]>
Cc: Zhi, Yong <[email protected]>; [email protected]; Zheng, Jian Xu <[email protected]>; [email protected]; Toivonen, Tuukka <[email protected]>; Yang, Hyungwoo <[email protected]>; Rapolu, Chiranjeevi <[email protected]>; Hu, Jerry W <[email protected]>; Vijaykumar, Ramya <[email protected]>
Subject: Re: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driverHi Rajmohan,
Quoted 13 lines · Rajmohan
Hi Sakari, Yong,
Quoted 11 lines
Subject: Re: [PATCH v7 3/3] intel-ipu3: cio2: Add new MIPI-CSI2 driver
Hi Yong,
Thanks for the update!
I took a final glance, there are a few matters that still need to be addressed but then I think we're done. Please see below.
Then we'll need an entry in the
MAINTAINERSfile in the kernel rootdirectory.
Quoted 45 lines
Quoted 45 lines
Could you add an entry for this driver in v8?
On Thu, Nov 02, 2017 at 03:00:01PM -0500, Yong Zhi wrote:
...drivers/media/pci/intel/ipu3/ipu3-cio2.c line 303
Quoted 11 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +11
-0+static int cio2_fbpt_rearrange (struct cio2_device *cio2,struct +cio2_queue *q) { +unsigned int i, j; + +for (i =0 , j = q->bufs_first; i <CIO2_MAX_BUFFERS ; + i++, j = (j +1 ) %CIO2_MAX_BUFFERS ) +if (q->bufs[j]) +break ; + +if (i ==CIO2_MAX_BUFFERS ) +return 0 ;You always return 0. The return type could be void.
You could also move this function just above the function using it (it's a single location).
drivers/media/pci/intel/ipu3/ipu3-cio2.c
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +if (j) { + arrange(q->fbpt, sizeof(struct cio2_fbpt_entry) *
CIO2_MAX_LOPS,Quoted 17 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+ CIO2_MAX_BUFFERS, j); +arrange (q->bufs,sizeof (struct cio2_buffer *), +CIO2_MAX_BUFFERS , j); + } + +/* +* DMA clears the valid bit when accessing the buffer. +* When stopping stream in suspend callback, some of the buffers +* may be in invalid state. After resume, when DMA meets the invalid +* buffer, it will halt and stop receiving new data. +* To avoid DMA halting, set the valid bit for all buffers in FBPT. +*/ +for (i =0 ; i <CIO2_MAX_BUFFERS ; i++) +cio2_fbpt_entry_enable (cio2, q->fbpt + i *CIO2_MAX_LOPS ); + +return 0 ; +}...
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +5
-0+static int cio2_vb2_start_streaming (struct vb2_queue *vq, +unsigned int count) { +struct cio2_queue *q =vb2q_to_cio2_queue (vq); +struct cio2_device *cio2 =vb2_get_drv_priv (vq); +int r;Quoted 8 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1078
Quoted 8 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +8
-0+ + cio2->cur_queue = q; +atomic_set (&q->frame_sequence,0 ); + + r =pm_runtime_get_sync (&cio2->pci_dev->dev); +if (r <0 ) { +dev_info (&cio2->pci_dev->dev,"failed to set power %d\n" , r); +pm_runtime_put (&cio2->pci_dev->dev);Shouldn't we use
pm_runtime_put_noidle()here, so theusage_countgets
Quoted 6 lines
decremented?
Yeah,
pm_runtime_put_noidle()would be perhaps more appropriate. The difference is that the noidle variant won't suspend the device (but it was already suspended to begin with as resuming failed).
Thanks for confirming.
Quoted 50 lines
Quoted 44 lines
Quoted 44 lines
Quoted 18 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +17
-0+return r; + } + + r =media_pipeline_start (&q->vdev.entity, &q->pipe); +if (r) + goto fail_pipeline; + + r =cio2_hw_init (cio2, q); +if (r) + goto fail_hw; + +/* Start streaming on sensor */ + r =v4l2_subdev_call (q->sensor, video, s_stream,1 ); +if (r) + goto fail_csi2_subdev; + + cio2->streaming = true;drivers/media/pci/intel/ipu3/ipu3-cio2.c line 1105
Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +10
-0+ +return 0 ; + +fail_csi2_subdev: +cio2_hw_exit (cio2, q); +fail_hw: +media_pipeline_stop (&q->vdev.entity); +fail_pipeline: +dev_dbg (&cio2->pci_dev->dev,"failed to start streaming (%d)\n" , r); +cio2_vb2_return_all_buffers (q);I believe there should be
pm_runtime_put(&cio2->pci_dev->dev);here. You should also add a label and use goto from where you do
pm_runtime_put()in error handling in this function in order to make this cleaner.drivers/media/pci/intel/ipu3/ipu3-cio2.c line 413
Quoted 3 lines
drivers/media/pci/intel/ipu3/ipu3-cio2.c new file +3
-0+ +return r; +}--
Kind regards,Quoted 2 lines
Quoted 2 lines
Sakari Ailus
[email protected]--
Sakari Ailus
[email protected]