Skip to contentSkip to conversation

Initial Allwinner V3s CSI Support

PATCH Superseded Yong Deng 2 participants 13 messages Feb 27, 2018 – Mar 6, 2018

Subsystems (3)

v8 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Yong Deng

author maintainer
#0 lore raw

v8 cover Initial Allwinner V3s CSI Support

This patchset add initial support for Allwinner V3s CSI.

Allwinner V3s SoC features two CSI module. CSI0 is used for MIPI CSI-2 interface and CSI1 is used for parallel interface. This is not documented in datasheet but by test and guess.

This patchset implement a v4l2 framework driver and add a binding documentation for it.

Currently, the driver only support the parallel interface. And has been tested with a BT1120 signal which generating from FPGA. The following fetures are not support with this patchset:
- ISP
- MIPI-CSI2
- Master clock for camera sensor
- Power regulator for the front end IC

Changes in v8:
* Revert to v6 and add 'hack' for PHYS_OFFSET.

Changes in v7:
* Add 'depends on ARM' in Kconfig to avoid built with non-ARM arch.

Changes in v6:
* Add Rob Herring's review tag.
* Fix a NULL pointer dereference by picking Maxime Ripard's patch.
* Add Maxime Ripard's test tag.

Changes in v5:
* Using the new SPDX tags.
* Fix MODULE_LICENSE.
* Add many default cases and warning messages.
* Detail the parallel bus properties
* Fix some spelling and syntax mistakes.

Changes in v4:
* Deal with the CSI 'INNER QUEUE'.
CSI will lookup the next dma buffer for next frame before the the current frame done IRQ triggered. This is not documented but reported by Ond?ej Jirman.
The BSP code has workaround for this too. It skip to mark the first buffer as frame done for VB2 and pass the second buffer to CSI in the first frame done ISR call. Then in second frame done ISR call, it mark the first buffer as frame done for VB2 and pass the third buffer to CSI. And so on. The bad thing is that the first buffer will be written twice and the first frame is dropped even the queued buffer is sufficient.
So, I make some improvement here. Pass the next buffer to CSI just follow starting the CSI. In this case, the first frame will be stored in first buffer, second frame in second buffer. This mothed is used to avoid dropping the first frame, it would also drop frame when lacking of queued buffer.
* Fix: using a wrong mbus_code when getting the supported formats
* Change all fourcc to pixformat
* Change some function names

Changes in v3:
* Get rid of struct sun6i_csi_ops
* Move sun6i-csi to new directory drivers/media/platform/sunxi
* Merge sun6i_csi.c and sun6i_csi_v3s.c into sun6i_csi.c
* Use generic fwnode endpoints parser
* Only support a single subdev to make things simple
* Many complaintion fix

Changes in v2:
* Change sunxi-csi to sun6i-csi
* Rebase to media_tree master branch

Following is the 'v4l2-compliance -s -f' output, I have test this with both interlaced and progressive signal:

# ./v4l2-compliance -s -f
v4l2-compliance SHA   : 6049ea8bd64f9d78ef87ef0c2b3dc9b5de1ca4a1

Driver Info:

        Driver name   : sun6i-video
        Card type     : sun6i-csi
        Bus info      : platform:csi
        Driver version: 4.15.0
        Capabilities  : 0x84200001
                Video Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps   : 0x04200001
                Video Capture
                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 (Not Supported)

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:

Streaming ioctls:
test read/write: OK (Not Supported)
test MMAP: OK
test USERPTR: OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device

Stream using all formats:
test MMAP for Format HM12, Frame Size 1280x720:
Stride 1920, Field None: OK
test MMAP for Format NV12, Frame Size 1280x720:
Stride 1920, Field None: OK
test MMAP for Format NV21, Frame Size 1280x720:
Stride 1920, Field None: OK
test MMAP for Format YU12, Frame Size 1280x720:
Stride 1920, Field None: OK
test MMAP for Format YV12, Frame Size 1280x720:
Stride 1920, Field None: OK
test MMAP for Format NV16, Frame Size 1280x720:
Stride 2560, Field None: OK
test MMAP for Format NV61, Frame Size 1280x720:
Stride 2560, Field None: OK
test MMAP for Format 422P, Frame Size 1280x720:
Stride 2560, Field None: OK

Total: 54, Succeeded: 54, Failed: 0, Warnings: 0

Yong Deng (2):
dt-bindings: media: Add Allwinner V3s Camera Sensor Interface (CSI)
media: V3s: Add support for Allwinner CSI.

 .../devicetree/bindings/media/sun6i-csi.txt        |  59 ++
 MAINTAINERS                                        |   8 +
 drivers/media/platform/Kconfig                     |   1 +
 drivers/media/platform/Makefile                    |   2 +
 drivers/media/platform/sunxi/sun6i-csi/Kconfig     |   9 +
 drivers/media/platform/sunxi/sun6i-csi/Makefile    |   3 +
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 911 +++++++++++++++++++++
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h | 143 ++++
 .../media/platform/sunxi/sun6i-csi/sun6i_csi_reg.h | 196 +++++
 .../media/platform/sunxi/sun6i-csi/sun6i_video.c   | 753 +++++++++++++++++
 .../media/platform/sunxi/sun6i-csi/sun6i_video.h   |  53 ++
 11 files changed, 2138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/sun6i-csi.txt
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/Kconfig
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/Makefile
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_reg.h
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
 create mode 100644 drivers/media/platform/sunxi/sun6i-csi/sun6i_video.h
Signature · 1 line
1.8.3.1
#1 lore raw

cover media: sun6i: Various fixes and improvements

Hi Yong,

Here are a bunch of patches I came up with after testing your last (v8) version of the CSI patches.

There's some improvements (patches 1 and 7) and fixes for regressions found in the v8 compared to the v7 (patches 2, 3, 4 and 5), and one fix that we discussed for the signals polarity for the parallel interface (patch 6).

Feel free to squash them in your serie for the v9. Thanks!
Maxime

Maxime Ripard (7):
media: sun6i: Fill dma_pfn_offset to accomodate for the RAM offset
media: sun6i: Reduce the error level
media: sun6i: Pass the sun6i_csi_dev pointer to our helpers
media: sun6i: Don't emit a warning when the configured format isn't
found
media: sun6i: Support the YUYV format properly
media: sun6i: Invert the polarities
media: sun6i: Expose controls on the v4l2_device

 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 85 ++++++++++++++--------
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h |  2 +
 .../media/platform/sunxi/sun6i-csi/sun6i_video.c   |  6 ++
 3 files changed, 63 insertions(+), 30 deletions(-)
Signature · 1 line
2.14.3
#2 lore raw

PATCH 1/7 media: sun6i: Fill dma_pfn_offset to accomodate for the RAM offset

The CSI controller does its DMA accesses through a DMA bus that has the RAM mapped at the address 0.

The current code removes from the dma_addr_t PHYS_OFFSET, and while it works, this is an abuse of the DMA API.

Instead, fill the dma_pfn_offset field in the struct device that should be used to express such an offset, and the use the dma_addr_t directly as we should.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +13 -8
index 1aaaae238d57..2ec33fb04632 100644
@@ -563,20 +563,15 @@ int sun6i_csi_update_config(struct sun6i_csi *csi,
 void sun6i_csi_update_buf_addr(struct sun6i_csi *csi, dma_addr_t addr)
 {
 	struct sun6i_csi_dev *sdev = sun6i_csi_to_dev(csi);
-	/* transform physical address to bus address */
-#if defined(CONFIG_COMPILE_TEST) && !defined(PHYS_OFFSET)
-#define PHYS_OFFSET 0
-#endif
-	dma_addr_t bus_addr = addr - PHYS_OFFSET;
 
 	regmap_write(sdev->regmap, CSI_CH_F0_BUFA_REG,
-		     (bus_addr + sdev->planar_offset[0]) >> 2);
+		     (addr + sdev->planar_offset[0]) >> 2);
 	if (sdev->planar_offset[1] != -1)
 		regmap_write(sdev->regmap, CSI_CH_F1_BUFA_REG,
-			     (bus_addr + sdev->planar_offset[1]) >> 2);
+			     (addr + sdev->planar_offset[1]) >> 2);
 	if (sdev->planar_offset[2] != -1)
 		regmap_write(sdev->regmap, CSI_CH_F2_BUFA_REG,
-			     (bus_addr + sdev->planar_offset[2]) >> 2);
+			     (addr + sdev->planar_offset[2]) >> 2);
 }
 
 void sun6i_csi_set_stream(struct sun6i_csi *csi, bool enable)
@@ -856,6 +851,14 @@ static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev,
 	return 0;
 }
 
+/*
+ * PHYS_OFFSET isn't available on all architectures. In order to
+ * accomodate for COMPILE_TEST, let's define it to something dumb.
+ */
+#ifndef PHYS_OFFSET
+#define PHYS_OFFSET 0
+#endif
+
 static int sun6i_csi_probe(struct platform_device *pdev)
 {
 	struct sun6i_csi_dev *sdev;
@@ -866,6 +869,8 @@ static int sun6i_csi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	sdev->dev = &pdev->dev;
+	/* The DMA bus has the memory mapped at 0 */
+	sdev->dev->dma_pfn_offset = PHYS_OFFSET >> PAGE_SHIFT;
 
 	ret = sun6i_csi_resource_request(sdev, pdev);
 	if (ret)
Signature · 1 line
2.14.3
#3 lore raw

PATCH 2/7 media: sun6i: Reduce the error level

In reply to Maxime Ripard

The is_format_support function can be called in the standard format negociation path with a sensor, where it's expected to have not exactly the same set of formats available.

Reduce the error logging level when we find a format not supported to not have a lot of spurious messages.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +7 -8
index 2ec33fb04632..b0ac8a188f92 100644
@@ -111,15 +111,14 @@ bool sun6i_csi_is_format_support(struct sun6i_csi *csi,
 			case MEDIA_BUS_FMT_YVYU8_1X16:
 				return true;
 			default:
-				dev_warn(sdev->dev,
-					 "Unsupported mbus code: 0x%x\n",
-					 mbus_code);
+				dev_dbg(sdev->dev, "Unsupported mbus code: 0x%x\n",
+					mbus_code);
 				break;
 			}
 			break;
 		default:
-			dev_warn(sdev->dev, "Unsupported pixformat: 0x%x\n",
-				 pixformat);
+			dev_dbg(sdev->dev, "Unsupported pixformat: 0x%x\n",
+				pixformat);
 			break;
 		}
 		return false;
@@ -175,13 +174,13 @@ bool sun6i_csi_is_format_support(struct sun6i_csi *csi,
 		case MEDIA_BUS_FMT_YVYU8_2X8:
 			return true;
 		default:
-			dev_warn(sdev->dev, "Unsupported mbus code: 0x%x\n",
-				 mbus_code);
+			dev_dbg(sdev->dev, "Unsupported mbus code: 0x%x\n",
+				mbus_code);
 			break;
 		}
 		break;
 	default:
-		dev_warn(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat);
+		dev_dbg(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat);
 		break;
 	}
 
Signature · 1 line
2.14.3
#4 lore raw

PATCH 3/7 media: sun6i: Pass the sun6i_csi_dev pointer to our helpers

In reply to Maxime Ripard

Some helpers need to log some errors for example when we don't support the format passed as an argument. However, we don't currently have a dev pointer available in those functions, preventing us from using any dev_* logging function.

Fix that by passing the sun6i_csi_dev structure as an argument, which itself contains a pointer to our struct device.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +13 -7
index b0ac8a188f92..f10c3bc2a6c5 100644
@@ -225,7 +225,8 @@ int sun6i_csi_set_power(struct sun6i_csi *csi, bool enable)
 	return 0;
 }
 
-static enum csi_input_fmt get_csi_input_format(u32 mbus_code, u32 pixformat)
+static enum csi_input_fmt get_csi_input_format(struct sun6i_csi_dev *sdev,
+					       u32 mbus_code, u32 pixformat)
 {
 	/* bayer */
 	if ((mbus_code & 0xF000) == 0x3000)
@@ -242,11 +243,12 @@ static enum csi_input_fmt get_csi_input_format(u32 mbus_code, u32 pixformat)
 	}
 
 	/* not support YUV420 input format yet */
-	pr_debug("Select YUV422 as default input format of CSI.\n");
+	dev_dbg(sdev->dev, "Select YUV422 as default input format of CSI.\n");
 	return CSI_INPUT_FORMAT_YUV422;
 }
 
-static enum csi_output_fmt get_csi_output_format(u32 pixformat, u32 field)
+static enum csi_output_fmt get_csi_output_format(struct sun6i_csi_dev *sdev,
+						 u32 pixformat, u32 field)
 {
 	bool buf_interlaced = false;
 
@@ -304,7 +306,8 @@ static enum csi_output_fmt get_csi_output_format(u32 pixformat, u32 field)
 	return CSI_FIELD_RAW_8;
 }
 
-static enum csi_input_seq get_csi_input_seq(u32 mbus_code, u32 pixformat)
+static enum csi_input_seq get_csi_input_seq(struct sun6i_csi_dev *sdev,
+					    u32 mbus_code, u32 pixformat)
 {
 
 	switch (pixformat) {
@@ -449,13 +452,16 @@ static void sun6i_csi_set_format(struct sun6i_csi_dev *sdev)
 		 CSI_CH_CFG_HFLIP_EN | CSI_CH_CFG_FIELD_SEL_MASK |
 		 CSI_CH_CFG_INPUT_SEQ_MASK);
 
-	val = get_csi_input_format(csi->config.code, csi->config.pixelformat);
+	val = get_csi_input_format(sdev, csi->config.code,
+				   csi->config.pixelformat);
 	cfg |= CSI_CH_CFG_INPUT_FMT(val);
 
-	val = get_csi_output_format(csi->config.pixelformat, csi->config.field);
+	val = get_csi_output_format(sdev, csi->config.pixelformat,
+				    csi->config.field);
 	cfg |= CSI_CH_CFG_OUTPUT_FMT(val);
 
-	val = get_csi_input_seq(csi->config.code, csi->config.pixelformat);
+	val = get_csi_input_seq(sdev, csi->config.code,
+				csi->config.pixelformat);
 	cfg |= CSI_CH_CFG_INPUT_SEQ(val);
 
 	if (csi->config.field == V4L2_FIELD_TOP)
Signature · 1 line
2.14.3
#5 lore raw

PATCH 4/7 media: sun6i: Don't emit a warning when the configured format isn't found

In reply to Maxime Ripard

Currently the driver will call WARN when a format isn't available, resulting in a kernel backtrace in our logs. This makes it look much more serious than it should be.

Replace the call to the WARN macro to a dev_warn, which will still allow us to log what happened without making it too dramatic.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +7 -4
index f10c3bc2a6c5..9a25aad8b6b1 100644
@@ -299,7 +299,7 @@ static enum csi_output_fmt get_csi_output_format(struct sun6i_csi_dev *sdev,
 		return buf_interlaced ? CSI_FRAME_PLANAR_YUV422 :
 					CSI_FIELD_PLANAR_YUV422;
 	default:
-		WARN(1, "Unsupported pixformat: 0x%x\n", pixformat);
+		dev_warn(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat);
 		break;
 	}
 
@@ -330,7 +330,8 @@ static enum csi_input_seq get_csi_input_seq(struct sun6i_csi_dev *sdev,
 		case MEDIA_BUS_FMT_YVYU8_2X8:
 			return CSI_INPUT_SEQ_YVYU;
 		default:
-			WARN(1, "Unsupported mbus code: 0x%x\n", mbus_code);
+			dev_warn(sdev->dev, "Unsupported mbus code: 0x%x\n",
+				 mbus_code);
 			break;
 		}
 		break;
@@ -351,12 +352,14 @@ static enum csi_input_seq get_csi_input_seq(struct sun6i_csi_dev *sdev,
 		case MEDIA_BUS_FMT_YVYU8_2X8:
 			return CSI_INPUT_SEQ_YUYV;
 		default:
-			WARN(1, "Unsupported mbus code: 0x%x\n", mbus_code);
+			dev_warn(sdev->dev, "Unsupported mbus code: 0x%x\n",
+				 mbus_code);
 			break;
 		}
 		break;
 	default:
-		WARN(1, "Unsupported pixformat: 0x%x\n", pixformat);
+		dev_warn(sdev->dev, "Unsupported pixformat: 0x%x, defaulting to YUYV\n",
+			 pixformat);
 		break;
 	}
 
Signature · 1 line
2.14.3
#6 lore raw

PATCH 5/7 media: sun6i: Support the YUYV format properly

In reply to Maxime Ripard

Currently, if we ever start a capture using the YUYV format, the switch case in the get_csi_input_seq function will not catch it since it considers it the default case.

However, that switch default also calls dev_warn to log an error, which is this case will be either an unsupported format, or the YUYV format.

Obviously, the latter creates a spurious message. Make sure this isn't the case.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +4 -0
index 9a25aad8b6b1..e0b39ea641aa 100644
@@ -357,6 +357,10 @@ static enum csi_input_seq get_csi_input_seq(struct sun6i_csi_dev *sdev,
 			break;
 		}
 		break;
+
+	case V4L2_PIX_FMT_YUYV:
+		return CSI_INPUT_SEQ_YUYV;
+
 	default:
 		dev_warn(sdev->dev, "Unsupported pixformat: 0x%x, defaulting to YUYV\n",
 			 pixformat);
Signature · 1 line
2.14.3
#7 lore raw

PATCH 6/7 media: sun6i: Invert the polarities

In reply to Maxime Ripard

A good look at an oscilloscope and test with a camera have shown that the polarity of all signals are actually reversed compared to the polarity documented in the datasheet for the clock, HSYNC and VSYNC signals.

---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +3 -3
index e0b39ea641aa..a93bc25ff372 100644
@@ -398,12 +398,12 @@ static void sun6i_csi_setup_bus(struct sun6i_csi_dev *sdev)
 		if (flags & V4L2_MBUS_FIELD_EVEN_LOW)
 			cfg |= CSI_IF_CFG_FIELD_POSITIVE;
 
-		if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
+		if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
 			cfg |= CSI_IF_CFG_VREF_POL_POSITIVE;
-		if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
+		if (flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
 			cfg |= CSI_IF_CFG_HREF_POL_POSITIVE;
 
-		if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
+		if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
 			cfg |= CSI_IF_CFG_CLK_POL_FALLING_EDGE;
 		break;
 	case V4L2_MBUS_BT656:
Signature · 1 line
2.14.3
#8 lore raw

PATCH 7/7 media: sun6i: Expose controls on the v4l2_device

In reply to Maxime Ripard
---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c   | 8 ++++++++
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h   | 2 ++
 drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c | 6 ++++++
 3 files changed, 16 insertions(+)
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +8 -0
index a93bc25ff372..26d57e6053df 100644
@@ -729,7 +729,15 @@ static int sun6i_csi_v4l2_init(struct sun6i_csi *csi)
 
 	media_device_init(&csi->media_dev);
 
+	ret = v4l2_ctrl_handler_init(&csi->ctrl_handler, 0);
+	if (ret) {
+		dev_err(csi->dev, "V4L2 controls handler init failed (%d)\n",
+			ret);
+		goto clean_media;
+	}
+
 	csi->v4l2_dev.mdev = &csi->media_dev;
+	csi->v4l2_dev.ctrl_handler = &csi->ctrl_handler;
 	ret = v4l2_device_register(csi->dev, &csi->v4l2_dev);
 	if (ret) {
 		dev_err(csi->dev, "V4L2 device registration failed (%d)\n",
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h +2 -0
index c1a1e3aefaa8..c0e8b14073d1 100644
@@ -8,6 +8,7 @@
 #ifndef __SUN6I_CSI_H__
 #define __SUN6I_CSI_H__
 
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-fwnode.h>
 
@@ -33,6 +34,7 @@ struct sun6i_csi_config {
 
 struct sun6i_csi {
 	struct device			*dev;
+	struct v4l2_ctrl_handler	ctrl_handler;
 	struct v4l2_device		v4l2_dev;
 	struct media_device		media_dev;
 
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c +6 -0
index c74565d15014..bf7c0d1d1d47 100644
@@ -8,6 +8,7 @@
 #include <linux/of.h>
 
 #include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-mc.h>
 #include <media/videobuf2-dma-contig.h>
@@ -497,6 +498,11 @@ static const struct v4l2_ioctl_ops sun6i_video_ioctl_ops = {
 	.vidioc_prepare_buf		= vb2_ioctl_prepare_buf,
 	.vidioc_streamon		= vb2_ioctl_streamon,
 	.vidioc_streamoff		= vb2_ioctl_streamoff,
+
+	.vidioc_log_status		= v4l2_ctrl_log_status,
+	.vidioc_subscribe_event		= v4l2_ctrl_subscribe_event,
+	.vidioc_unsubscribe_event	= v4l2_event_unsubscribe,
+
 };
 
 /* -----------------------------------------------------------------------------
Signature · 1 line
2.14.3
#9 lore raw

PATCH 8/8 media: sun6i: Add g_parm/s_parm ioctl support

In reply to Maxime Ripard

Add a g_parm and s_parm callback in order to be able to control the sensor framerate of the sensor.

---
 .../media/platform/sunxi/sun6i-csi/sun6i_video.c   | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c +29 -0
index bf7c0d1d1d47..bac867004fa0 100644
@@ -478,6 +478,32 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
 	return 0;
 }
 
+static int vidioc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+	struct sun6i_video *video = video_drvdata(file);
+	struct v4l2_subdev *subdev;
+	u32 pad;
+
+	subdev = sun6i_video_remote_subdev(video, &pad);
+	if (subdev == NULL)
+		return -ENXIO;
+
+	return v4l2_g_parm_cap(video_devdata(file), subdev, a);
+}
+
+static int vidioc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+	struct sun6i_video *video = video_drvdata(file);
+	struct v4l2_subdev *subdev;
+	u32 pad;
+
+	subdev = sun6i_video_remote_subdev(video, &pad);
+	if (subdev == NULL)
+		return -ENXIO;
+
+	return v4l2_s_parm_cap(video_devdata(file), subdev, a);
+}
+
 static const struct v4l2_ioctl_ops sun6i_video_ioctl_ops = {
 	.vidioc_querycap		= vidioc_querycap,
 	.vidioc_enum_fmt_vid_cap	= vidioc_enum_fmt_vid_cap,
@@ -489,6 +515,9 @@ static const struct v4l2_ioctl_ops sun6i_video_ioctl_ops = {
 	.vidioc_s_input			= vidioc_s_input,
 	.vidioc_g_input			= vidioc_g_input,
 
+	.vidioc_g_parm			= vidioc_g_parm,
+	.vidioc_s_parm			= vidioc_s_parm,
+
 	.vidioc_reqbufs			= vb2_ioctl_reqbufs,
 	.vidioc_querybuf		= vb2_ioctl_querybuf,
 	.vidioc_qbuf			= vb2_ioctl_qbuf,
Signature · 1 line
2.14.3
#10 lore raw

PATCH 8/8 media: sun6i: Add g_parm/s_parm ioctl support

Quoted 4 lines · Maxime Ripard

Add a g_parm and s_parm callback in order to be able to control the sensor framerate of the sensor.

Hmmm, that patch shouldn't have been there. This is an outdated version based on Hans g_parm/s_parm rework that will not need this anymore.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180305/e5be953a/attachment.sig>
author maintainer
#11 lore raw

cover media: sun6i: Various fixes and improvements

In reply to Maxime Ripard

Hi Maxime,

Quoted 11 lines · On Mon, 5 Mar 2018 10:35:27 +0100 Maxime Ripard <[email protected]>…

Hi Yong,

Here are a bunch of patches I came up with after testing your last (v8) version of the CSI patches.

There's some improvements (patches 1 and 7) and fixes for regressions found in the v8 compared to the v7 (patches 2, 3, 4 and 5), and one fix that we discussed for the signals polarity for the parallel interface (patch 6).

Feel free to squash them in your serie for the v9.

OK. Thank you!

I notice that your responses have not been listed in google group since February.

Quoted 13 lines

Thanks!
Maxime

Maxime Ripard (7):
media: sun6i: Fill dma_pfn_offset to accomodate for the RAM offset
media: sun6i: Reduce the error level
media: sun6i: Pass the sun6i_csi_dev pointer to our helpers
media: sun6i: Don't emit a warning when the configured format isn't
found
media: sun6i: Support the YUYV format properly
media: sun6i: Invert the polarities
media: sun6i: Expose controls on the v4l2_device

Quoted 7 lines
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 85 ++++++++++++++--------
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h |  2 +
 .../media/platform/sunxi/sun6i-csi/sun6i_video.c   |  6 ++
 3 files changed, 63 insertions(+), 30 deletions(-)
Signature · 1 line
2.14.3

Thanks,
Yong

#12 lore raw

cover media: sun6i: Various fixes and improvements

Quoted 10 lines · Yong
Quoted 10 lines

Hi Yong,

Here are a bunch of patches I came up with after testing your last (v8) version of the CSI patches.

There's some improvements (patches 1 and 7) and fixes for regressions found in the v8 compared to the v7 (patches 2, 3, 4 and 5), and one fix that we discussed for the signals polarity for the parallel interface (patch 6).

Quoted 6 lines
Quoted 1 line

Feel free to squash them in your serie for the v9.

OK. Thank you!

I notice that your responses have not been listed in google group since February.

Yeah, I know, apparently I can't change my email address in google groups, or unsubscribe, so I'm not subscribed with my new mail, which means I can't post either.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180306/2f0660be/attachment.sig>