media:imx274 device tree binding file
Subsystems (4)
Leon Luo
maintainerPATCH v7 1/2 media:imx274 device tree binding file
The binding file for imx274 CMOS sensor V4l2 driver
---
v7:
- no changes
v6:
- no changes
v5:
- add 'port' and 'endpoint' information
v4:
- no changes
v3:
- remove redundant properties and references
- document 'reg' property
v2:
- no changes
--- .../devicetree/bindings/media/i2c/imx274.txt | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx274.txt
Documentation/devicetree/bindings/media/i2c/imx274.txt new file +33 -0
@@ -0,0 +1,33 @@ +* Sony 1/2.5-Inch 8.51Mp CMOS Digital Image Sensor + +The Sony imx274 is a 1/2.5-inch CMOS active pixel digital image sensor with +an active array size of 3864H x 2202V. It is programmable through I2C +interface. The I2C address is fixed to 0x1a as per sensor data sheet. +Image data is sent through MIPI CSI-2, which is configured as 4 lanes +at 1440 Mbps. + + +Required Properties: +- compatible: value should be "sony,imx274" for imx274 sensor +- reg: I2C bus address of the device + +Optional Properties: +- reset-gpios: Sensor reset GPIO + +The imx274 device node should contain one 'port' child node with +an 'endpoint' subnode. For further reading on port node refer to +Documentation/devicetree/bindings/media/video-interfaces.txt. + +Example: + sensor@1a { + compatible = "sony,imx274"; + reg = <0x1a>; + #address-cells = <1>; + #size-cells = <0>; + reset-gpios = <&gpio_sensor 0 0>; + port { + sensor_out: endpoint { + remote-endpoint = <&csiss_in>; + }; + }; + };
Signature · 1 line
2.14.0.rc1
Leon Luo
maintainerPATCH v7 2/2 media:imx274 V4l2 driver for Sony imx274 CMOS sensor
The imx274 is a Sony CMOS image sensor that has 1/2.5 image size. It supports up to 3840x2160 (4K) 60fps, 1080p 120fps. The interface is 4-lane MIPI CSI-2 running at 1.44Gbps each.
This driver has been tested on Xilinx ZCU102 platform with a Leopard LI-IMX274MIPI-FMC camera board.
Support for the following features:
-Resolutions: 3840x2160, 1920x1080, 1280x720
-Frame rate: 3840x2160 : 5 – 60fps
1920x1080 : 5 – 120fps
1280x720 : 5 – 120fps-Exposure time: 16 – (frame interval) micro-seconds -Gain: 1x - 180x
-VFLIP: enable/disabledrivers/media/i2c/imx274.c -Test pattern: 12 test patterns
---
v7:
- use __v4l2_ctrl_s_ctrl instead of v4l2_ctrl_s_ctrl to have
clean mutex_lock/mutex_unlock in imx274_s_stream()
- define imx274_tp_regs[] as static, move the test pattern reg
out of imx274_tp_regs[], and define it as a macro IMX274_TEST_PATTERN_REG
v6:
- remove media/v4l2-image-sizes.h from include header
- make the header file alphabetical order
- remove fmt->pad check in imx274_get_fmt,
the V4L2 subdev framework does it already
- change 'struct reg_8 *regs' to 'struct reg_8 regs[n]',
where n is the exact numbers needed for this function
- move MODULE_DEVICE_TABLE(of, imx274_of_id_table); closer
to imx274_of_id_table definition
- remove return check of imx274_write_table in imx274_remove, because it should remove all resources even i2c fails here
- move imx274_load_default before v4l2_async_register_subdev
v5:
- no changes
v4:
- use 32-bit data type to avoid __divdi3 compile error for i386
- clean up OR together error codes
v3:
- clean up header files
- use struct directly instead of alias #define
- use v4l2_ctrl_s_ctrl instead of v4l2_s_ctrl
- revise debug output
- move static helpers closer to their call site
- don't OR toegether error codes
- use closest valid gain value instead of erroring out
- assigne lock to the control handler and omit explicit locking
- acquire mutex lock for imx274_get_fmt
- remove format->pad check in imx274_set_fmt since the pad is always 0
- pass struct v4l2_ctrl pointer in gain/exposure/vlip/test pattern controls
- remove priv->ctrls.vflip->val = val in imx274_set_vflip()
- remove priv->ctrls.test_pattern->val = val in imx274_set_test_pattern()
- remove empty open/close callbacks
- remove empty core ops
- add more error labels in probe
- use v4l2_async_unregister_subdev instead of v4l2_device_unregister_subdev
- use dynamic debug
- split start_stream to two steps: imx274_mode_regs() and imx274_start_stream() frame rate & exposure can be updated
between imx274_mode_regs() & imx274_start_stream()
v2:
- Fix Kconfig to not remove existing options
--- drivers/media/i2c/Kconfig | 7 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx274.c | 1801 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1809 insertions(+) create mode 100644 drivers/media/i2c/imx274.c
drivers/media/i2c/Kconfig +7 -0
@@ -555,6 +555,13 @@ config VIDEO_APTINA_PLL config VIDEO_SMIAPP_PLL tristate +config VIDEO_IMX274 + tristate "Sony IMX274 sensor support" + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + ---help--- + This is a V4L2 sensor-level driver for the Sony IMX274 + CMOS image sensor. + config VIDEO_OV2640 tristate "OmniVision OV2640 sensor support" depends on VIDEO_V4L2 && I2C
drivers/media/i2c/Makefile +1 -0
@@ -92,5 +92,6 @@ obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o obj-$(CONFIG_VIDEO_OV2659) += ov2659.o obj-$(CONFIG_VIDEO_TC358743) += tc358743.o +obj-$(CONFIG_VIDEO_IMX274) += imx274.o obj-$(CONFIG_SDR_MAX2175) += max2175.o
drivers/media/i2c/imx274.c new file +1801 -0
1,801 lines not on this page · raw message
Signature · 1 line
2.14.0.rc1
Re: [PATCH v7 2/2] media:imx274 V4l2 driver for Sony imx274 CMOS sensor
Hi Leon,
One more question below.
On Mon, Oct 02, 2017 at 01:26:49PM -0700, Leon Luo wrote:
...
Quoted 14 lines
drivers/media/i2c/imx274.c new file +14
-0+/* +* imx274_set_frame_interval - Function called when setting frame interval +* @priv: Pointer to device structure +* @frame_interval: Variable for frame interval +* +* Change frame interval by updating VMAX value +* The caller should hold the mutex lock imx274->lock if necessary +* +* Return: 0 on success +*/ +static int imx274_set_frame_interval (struct stimx274 *priv, +struct v4l2_fract frame_interval) +{ +int err;
drivers/media/i2c/imx274.c line 1536
Quoted 10 lines
drivers/media/i2c/imx274.c new file +10
-0+u32 frame_length, req_frame_rate; +u16 svr; +u16 hmax; +u8 reg_val[2 ]; + +dev_dbg (&priv->client->dev,"%s: input frame interval = %d / %d" , + __func__, frame_interval.numerator, + frame_interval.denominator); + +if (frame_interval.denominator ==0 ) {
Shouldn't this be numerator? If numerator is 0, then there will be division by zero below.
Quoted 59 lines
drivers/media/i2c/imx274.c new file +59
-0+ err = -EINVAL ; + goto fail; + } + + req_frame_rate = (u32)(frame_interval.denominator + / frame_interval.numerator); + +/* boundary check */ +if (req_frame_rate > max_frame_rate[priv->mode_index]) { + frame_interval.numerator =1 ; + frame_interval.denominator = + max_frame_rate[priv->mode_index]; + }else if (req_frame_rate <IMX274_MIN_FRAME_RATE ) { + frame_interval.numerator =1 ; + frame_interval.denominator =IMX274_MIN_FRAME_RATE ; + } + +/* +* VMAX = 1/frame_rate x 72M / (SVR+1) / HMAX +* frame_length (i.e. VMAX) = (frame_interval) x 72M /(SVR+1) / HMAX +*/ + +/* SVR */ + err =imx274_read_reg (priv,IMX274_SVR_REG_LSB , ®_val[0 ]); +if (err) + goto fail; + err =imx274_read_reg (priv,IMX274_SVR_REG_MSB , ®_val[1 ]); +if (err) + goto fail; + svr = (reg_val[1 ] <<IMX274_SHIFT_8_BITS ) + reg_val[0 ]; +dev_dbg (&priv->client->dev, +"%s : register SVR = %d\n" , __func__, svr); + +/* HMAX */ + err =imx274_read_reg (priv,IMX274_HMAX_REG_LSB , ®_val[0 ]); +if (err) + goto fail; + err =imx274_read_reg (priv,IMX274_HMAX_REG_MSB , ®_val[1 ]); +if (err) + goto fail; + hmax = (reg_val[1 ] <<IMX274_SHIFT_8_BITS ) + reg_val[0 ]; +dev_dbg (&priv->client->dev, +"%s : register HMAX = %d\n" , __func__, hmax); + + frame_length =IMX274_PIXCLK_CONST1 / (svr +1 ) / hmax + * frame_interval.numerator + / frame_interval.denominator; + + err =imx274_set_frame_length (priv, frame_length); +if (err) + goto fail; + + priv->frame_interval = frame_interval; +return 0 ; + +fail: +dev_err (&priv->client->dev,"%s error = %d\n" , __func__, err); +return err; +}
Signature · 8 lines
Regards, Sakari Ailus e-mail: [email protected] -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Leon Luo
maintainerRe: [PATCH v7 2/2] media:imx274 V4l2 driver for Sony imx274 CMOS sensor
You are right. I will fix it. Thanks.
Regards,
Leon Luo
1130 Cadillac CT
Milpitas, CA 95035
Phone: (510)371-1169
Fax: (408) 217-1960
Email: [email protected]
www.leopardimaging.com
Quoted 102 lines · Sakari Ailus
Hi Leon,
One more question below.
On Mon, Oct 02, 2017 at 01:26:49PM -0700, Leon Luo wrote:
...Quoted 2 lines
+/*
+ *imx274_set_frame_interval- Function called when setting frameinterval
Quoted 12 lines
+ * @priv: Pointer to device structure
+ * @frame_interval: Variable for frame interval
+ *
+ * Change frame interval by updating VMAX value
+ * The caller should hold the mutex lockimx274->lockif necessary
+ *
+ * Return: 0 on success
+ */drivers/media/i2c/imx274.c new file +4
-0+static int imx274_set_frame_interval (struct stimx274 *priv, +struct v4l2_fract frame_interval) +{ +int err;drivers/media/i2c/imx274.c line 1536
Quoted 10 lines
drivers/media/i2c/imx274.c new file +10
-0+u32 frame_length, req_frame_rate; +u16 svr; +u16 hmax; +u8 reg_val[2 ]; + +dev_dbg (&priv->client->dev,"%s: input frame interval = %d / %d" , + __func__, frame_interval.numerator, + frame_interval.denominator); + +if (frame_interval.denominator ==0 ) {Shouldn't this be numerator? If numerator is 0, then there will be division by zero below.
Quoted 10 lines
drivers/media/i2c/imx274.c new file +10
-0+ err = -EINVAL ; + goto fail; + } + + req_frame_rate = (u32)(frame_interval.denominator + / frame_interval.numerator); + +/* boundary check */ +if (req_frame_rate > max_frame_rate[priv->mode_index]) { + frame_interval.numerator =1 ;drivers/media/i2c/imx274.c
Quoted 10 lines
drivers/media/i2c/imx274.c new file +10
-0+ frame_interval.denominator = + max_frame_rate[priv->mode_index]; + }else if (req_frame_rate <IMX274_MIN_FRAME_RATE ) { + frame_interval.numerator =1 ; + frame_interval.denominator =IMX274_MIN_FRAME_RATE ; + } + +/* +* VMAX = 1/frame_rate x 72M / (SVR+1) / HMAX +* frame_length (i.e. VMAX) = (frame_interval) x 72M /(SVR+1) / HMAX
Quoted 29 lines
drivers/media/i2c/imx274.c new file +29
-0+*/ + +/* SVR */ + err =imx274_read_reg (priv,IMX274_SVR_REG_LSB , ®_val[0 ]); +if (err) + goto fail; + err =imx274_read_reg (priv,IMX274_SVR_REG_MSB , ®_val[1 ]); +if (err) + goto fail; + svr = (reg_val[1 ] <<IMX274_SHIFT_8_BITS ) + reg_val[0 ]; +dev_dbg (&priv->client->dev, +"%s : register SVR = %d\n" , __func__, svr); + +/* HMAX */ + err =imx274_read_reg (priv,IMX274_HMAX_REG_LSB , ®_val[0 ]); +if (err) + goto fail; + err =imx274_read_reg (priv,IMX274_HMAX_REG_MSB , ®_val[1 ]); +if (err) + goto fail; + hmax = (reg_val[1 ] <<IMX274_SHIFT_8_BITS ) + reg_val[0 ]; +dev_dbg (&priv->client->dev, +"%s : register HMAX = %d\n" , __func__, hmax); + + frame_length =IMX274_PIXCLK_CONST1 / (svr +1 ) / hmax + * frame_interval.numerator + / frame_interval.denominator; + + err =imx274_set_frame_length (priv, frame_length);drivers/media/i2c/imx274.c line 1595
Quoted 10 lines
drivers/media/i2c/imx274.c new file +10
-0+if (err) + goto fail; + + priv->frame_interval = frame_interval; +return 0 ; + +fail: +dev_err (&priv->client->dev,"%s error = %d\n" , __func__, err); +return err; +}--
Regards,Sakari Ailus
e-mail: [email protected]