xref: /openbmc/linux/drivers/media/i2c/ov5670.c (revision 4106cd72)
1a1c3bb0eSChiranjeevi Rapolu // SPDX-License-Identifier: GPL-2.0
2a1c3bb0eSChiranjeevi Rapolu // Copyright (c) 2017 Intel Corporation.
35de35c9bSChiranjeevi Rapolu 
462ab1e32SJacopo Mondi #include <asm/unaligned.h>
55de35c9bSChiranjeevi Rapolu #include <linux/acpi.h>
68004c91eSJacopo Mondi #include <linux/clk.h>
762ab1e32SJacopo Mondi #include <linux/delay.h>
80a844ab7SJacopo Mondi #include <linux/gpio/consumer.h>
95de35c9bSChiranjeevi Rapolu #include <linux/i2c.h>
105635500aSJacopo Mondi #include <linux/mod_devicetable.h>
115de35c9bSChiranjeevi Rapolu #include <linux/module.h>
125635500aSJacopo Mondi #include <linux/of.h>
135de35c9bSChiranjeevi Rapolu #include <linux/pm_runtime.h>
14cf9ab879SJacopo Mondi #include <linux/regulator/consumer.h>
155de35c9bSChiranjeevi Rapolu #include <media/v4l2-ctrls.h>
165de35c9bSChiranjeevi Rapolu #include <media/v4l2-device.h>
17dce6dd44SRicardo Ribalda #include <media/v4l2-event.h>
18eba08021SJacopo Mondi #include <media/v4l2-fwnode.h>
195de35c9bSChiranjeevi Rapolu 
208004c91eSJacopo Mondi #define OV5670_XVCLK_FREQ		19200000
218004c91eSJacopo Mondi 
225de35c9bSChiranjeevi Rapolu #define OV5670_REG_CHIP_ID		0x300a
235de35c9bSChiranjeevi Rapolu #define OV5670_CHIP_ID			0x005670
245de35c9bSChiranjeevi Rapolu 
255de35c9bSChiranjeevi Rapolu #define OV5670_REG_MODE_SELECT		0x0100
265de35c9bSChiranjeevi Rapolu #define OV5670_MODE_STANDBY		0x00
275de35c9bSChiranjeevi Rapolu #define OV5670_MODE_STREAMING		0x01
285de35c9bSChiranjeevi Rapolu 
295de35c9bSChiranjeevi Rapolu #define OV5670_REG_SOFTWARE_RST		0x0103
305de35c9bSChiranjeevi Rapolu #define OV5670_SOFTWARE_RST		0x01
315de35c9bSChiranjeevi Rapolu 
32a97b24feSLuca Weiss #define OV5670_MIPI_SC_CTRL0_REG		0x3018
33a97b24feSLuca Weiss #define OV5670_MIPI_SC_CTRL0_LANES(v)		((((v) - 1) << 5) & \
34a97b24feSLuca Weiss 						 GENMASK(7, 5))
35a97b24feSLuca Weiss #define OV5670_MIPI_SC_CTRL0_MIPI_EN		BIT(4)
36a97b24feSLuca Weiss #define OV5670_MIPI_SC_CTRL0_RESERVED		BIT(1)
37a97b24feSLuca Weiss 
385de35c9bSChiranjeevi Rapolu /* vertical-timings from sensor */
395de35c9bSChiranjeevi Rapolu #define OV5670_REG_VTS			0x380e
405de35c9bSChiranjeevi Rapolu #define OV5670_VTS_30FPS		0x0808 /* default for 30 fps */
415de35c9bSChiranjeevi Rapolu #define OV5670_VTS_MAX			0xffff
425de35c9bSChiranjeevi Rapolu 
435de35c9bSChiranjeevi Rapolu /* horizontal-timings from sensor */
445de35c9bSChiranjeevi Rapolu #define OV5670_REG_HTS			0x380c
45f1425381SChiranjeevi Rapolu 
46f1425381SChiranjeevi Rapolu /*
47f1425381SChiranjeevi Rapolu  * Pixels-per-line(PPL) = Time-per-line * pixel-rate
48f1425381SChiranjeevi Rapolu  * In OV5670, Time-per-line = HTS/SCLK.
49f1425381SChiranjeevi Rapolu  * HTS is fixed for all resolutions, not recommended to change.
50f1425381SChiranjeevi Rapolu  */
51f1425381SChiranjeevi Rapolu #define OV5670_FIXED_PPL		2724	/* Pixels per line */
525de35c9bSChiranjeevi Rapolu 
535de35c9bSChiranjeevi Rapolu /* Exposure controls from sensor */
545de35c9bSChiranjeevi Rapolu #define OV5670_REG_EXPOSURE		0x3500
555de35c9bSChiranjeevi Rapolu #define	OV5670_EXPOSURE_MIN		4
565de35c9bSChiranjeevi Rapolu #define	OV5670_EXPOSURE_STEP		1
575de35c9bSChiranjeevi Rapolu 
585de35c9bSChiranjeevi Rapolu /* Analog gain controls from sensor */
595de35c9bSChiranjeevi Rapolu #define OV5670_REG_ANALOG_GAIN		0x3508
605de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_MIN			0
615de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_MAX			8191
625de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_STEP		1
635de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_DEFAULT		128
645de35c9bSChiranjeevi Rapolu 
655de35c9bSChiranjeevi Rapolu /* Digital gain controls from sensor */
665de35c9bSChiranjeevi Rapolu #define OV5670_REG_R_DGTL_GAIN		0x5032
675de35c9bSChiranjeevi Rapolu #define OV5670_REG_G_DGTL_GAIN		0x5034
685de35c9bSChiranjeevi Rapolu #define OV5670_REG_B_DGTL_GAIN		0x5036
695de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_MIN		0
705de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_MAX		4095
715de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_STEP		1
725de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_DEFAULT	1024
735de35c9bSChiranjeevi Rapolu 
745de35c9bSChiranjeevi Rapolu /* Test Pattern Control */
755de35c9bSChiranjeevi Rapolu #define OV5670_REG_TEST_PATTERN		0x4303
765de35c9bSChiranjeevi Rapolu #define OV5670_TEST_PATTERN_ENABLE	BIT(3)
775de35c9bSChiranjeevi Rapolu #define OV5670_REG_TEST_PATTERN_CTRL	0x4320
785de35c9bSChiranjeevi Rapolu 
795de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_08BIT		1
805de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_16BIT		2
815de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_24BIT		3
825de35c9bSChiranjeevi Rapolu 
832eadd98dSJean-Michel Hautbois /* Pixel Array */
842eadd98dSJean-Michel Hautbois #define OV5670_NATIVE_WIDTH		2624
852eadd98dSJean-Michel Hautbois #define OV5670_NATIVE_HEIGHT		1980
862eadd98dSJean-Michel Hautbois 
875de35c9bSChiranjeevi Rapolu /* Initial number of frames to skip to avoid possible garbage */
885de35c9bSChiranjeevi Rapolu #define OV5670_NUM_OF_SKIP_FRAMES	2
895de35c9bSChiranjeevi Rapolu 
905de35c9bSChiranjeevi Rapolu struct ov5670_reg {
915de35c9bSChiranjeevi Rapolu 	u16 address;
925de35c9bSChiranjeevi Rapolu 	u8 val;
935de35c9bSChiranjeevi Rapolu };
945de35c9bSChiranjeevi Rapolu 
955de35c9bSChiranjeevi Rapolu struct ov5670_reg_list {
965de35c9bSChiranjeevi Rapolu 	u32 num_of_regs;
975de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg *regs;
985de35c9bSChiranjeevi Rapolu };
995de35c9bSChiranjeevi Rapolu 
1005de35c9bSChiranjeevi Rapolu struct ov5670_link_freq_config {
1015de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list reg_list;
1025de35c9bSChiranjeevi Rapolu };
1035de35c9bSChiranjeevi Rapolu 
104cf9ab879SJacopo Mondi static const char * const ov5670_supply_names[] = {
105cf9ab879SJacopo Mondi 	"avdd",		/* Analog power */
106cf9ab879SJacopo Mondi 	"dvdd",		/* Digital power */
107cf9ab879SJacopo Mondi 	"dovdd",	/* Digital output power */
108cf9ab879SJacopo Mondi };
109cf9ab879SJacopo Mondi 
110cf9ab879SJacopo Mondi #define OV5670_NUM_SUPPLIES ARRAY_SIZE(ov5670_supply_names)
111cf9ab879SJacopo Mondi 
1125de35c9bSChiranjeevi Rapolu struct ov5670_mode {
1135de35c9bSChiranjeevi Rapolu 	/* Frame width in pixels */
1145de35c9bSChiranjeevi Rapolu 	u32 width;
1155de35c9bSChiranjeevi Rapolu 
1165de35c9bSChiranjeevi Rapolu 	/* Frame height in pixels */
1175de35c9bSChiranjeevi Rapolu 	u32 height;
1185de35c9bSChiranjeevi Rapolu 
119ed351ad9SChiranjeevi Rapolu 	/* Default vertical timining size */
120ed351ad9SChiranjeevi Rapolu 	u32 vts_def;
121ed351ad9SChiranjeevi Rapolu 
122ed351ad9SChiranjeevi Rapolu 	/* Min vertical timining size */
123ed351ad9SChiranjeevi Rapolu 	u32 vts_min;
1245de35c9bSChiranjeevi Rapolu 
1255de35c9bSChiranjeevi Rapolu 	/* Link frequency needed for this resolution */
1265de35c9bSChiranjeevi Rapolu 	u32 link_freq_index;
1275de35c9bSChiranjeevi Rapolu 
1282eadd98dSJean-Michel Hautbois 	/* Analog crop rectangle */
1292eadd98dSJean-Michel Hautbois 	const struct v4l2_rect *analog_crop;
1302eadd98dSJean-Michel Hautbois 
1315de35c9bSChiranjeevi Rapolu 	/* Sensor register settings for this resolution */
1325de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list reg_list;
1335de35c9bSChiranjeevi Rapolu };
1345de35c9bSChiranjeevi Rapolu 
1352eadd98dSJean-Michel Hautbois /*
1362eadd98dSJean-Michel Hautbois  * All the modes supported by the driver are obtained by subsampling the
1372eadd98dSJean-Michel Hautbois  * full pixel array. The below values are reflected in registers from
1382eadd98dSJean-Michel Hautbois  * 0x3800-0x3807 in the modes register-value tables.
1392eadd98dSJean-Michel Hautbois  */
1402eadd98dSJean-Michel Hautbois static const struct v4l2_rect ov5670_analog_crop = {
1412eadd98dSJean-Michel Hautbois 	.left	= 12,
1422eadd98dSJean-Michel Hautbois 	.top	= 4,
1432eadd98dSJean-Michel Hautbois 	.width	= 2600,
1442eadd98dSJean-Michel Hautbois 	.height	= 1952,
1452eadd98dSJean-Michel Hautbois };
1462eadd98dSJean-Michel Hautbois 
1475de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mipi_data_rate_840mbps[] = {
1485de35c9bSChiranjeevi Rapolu 	{0x0300, 0x04},
1495de35c9bSChiranjeevi Rapolu 	{0x0301, 0x00},
1505de35c9bSChiranjeevi Rapolu 	{0x0302, 0x84},
1515de35c9bSChiranjeevi Rapolu 	{0x0303, 0x00},
1525de35c9bSChiranjeevi Rapolu 	{0x0304, 0x03},
1535de35c9bSChiranjeevi Rapolu 	{0x0305, 0x01},
1545de35c9bSChiranjeevi Rapolu 	{0x0306, 0x01},
1555de35c9bSChiranjeevi Rapolu 	{0x030a, 0x00},
1565de35c9bSChiranjeevi Rapolu 	{0x030b, 0x00},
1575de35c9bSChiranjeevi Rapolu 	{0x030c, 0x00},
1585de35c9bSChiranjeevi Rapolu 	{0x030d, 0x26},
1595de35c9bSChiranjeevi Rapolu 	{0x030e, 0x00},
1605de35c9bSChiranjeevi Rapolu 	{0x030f, 0x06},
1615de35c9bSChiranjeevi Rapolu 	{0x0312, 0x01},
1625de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
1635de35c9bSChiranjeevi Rapolu };
1645de35c9bSChiranjeevi Rapolu 
1655de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_2592x1944_regs[] = {
1665de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
1675de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
1685de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
1695de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
1705de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
1715de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
1725de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
1735de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
1745de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
1755de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
1765de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
1775de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
1785de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
1795de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
1805de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
1815de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
1825de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
1835de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
1845de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
1855de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
1865de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
1875de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
1885de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
1895de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
1905de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
1915de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
1925de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
1935de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
1945de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
1955de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
1965de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
1975de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
1985de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
1995de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
2005de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
2015de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
2025de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
2035de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
2045de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
2055de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
2065de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
2075de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
2085de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
2095de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
2105de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
2115de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
2125de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
2135de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
2145de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
2155de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
2165de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
2175de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
2185de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
2195de35c9bSChiranjeevi Rapolu 	{0x366e, 0x10},
2205de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
2215de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
2225de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
2235de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
2245de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
2255de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
2265de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
2275de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
2285de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
2295de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
2305de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
2315de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
2325de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
2335de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
2345de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
2355de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
2365de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
2375de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
2385de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
2395de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
2405de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
2415de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
2425de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
2435de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
2445de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
2455de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
2465de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
2475de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
2485de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
2495de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
2505de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
2515de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
2525de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
2535de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
2545de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
2555de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
2565de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
2575de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
2585de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
2595de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
2605de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
2615de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
2625de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
2635de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
2645de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
2655de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
2665de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
2675de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
2685de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
2695de35c9bSChiranjeevi Rapolu 	{0x3808, 0x0a},
2705de35c9bSChiranjeevi Rapolu 	{0x3809, 0x20},
2715de35c9bSChiranjeevi Rapolu 	{0x380a, 0x07},
2725de35c9bSChiranjeevi Rapolu 	{0x380b, 0x98},
2735de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
2745de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
2755de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
2765de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
2775de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
2785de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
2795de35c9bSChiranjeevi Rapolu 	{0x3814, 0x01},
2805de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
2815de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
2825de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
2835de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
2845de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
2855de35c9bSChiranjeevi Rapolu 	{0x3820, 0x84},
2865de35c9bSChiranjeevi Rapolu 	{0x3821, 0x46},
2875de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
2885de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
2895de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
2905de35c9bSChiranjeevi Rapolu 	{0x382a, 0x01},
2915de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
2925de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
2935de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
2945de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
2955de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
2965de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
2975de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
2985de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
2995de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
3005de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
3015de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
3025de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
3035de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
3045de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
3055de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
3065de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
3075de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
3085de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
3095de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
3105de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
3115de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
3125de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
3135de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
3145de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
3155de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
3165de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
3175de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
3185de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
3195de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
3205de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
3215de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
3225de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
3235de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
3245de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
3255de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
3265de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
3275de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
3285de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
3295de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
3305de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
3315de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
3325de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
3335de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
3345de35c9bSChiranjeevi Rapolu 	{0x4009, 0x0d},
3355de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
3365de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
3375de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
3385de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
3395de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
3405de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
3415de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
3425de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
3435de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
3445de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
3455de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
3465de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
3475de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
3485de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
3495de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
3505de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
3515de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
3525de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
3535de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
3545de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
3555de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
3565de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
3575de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
3585de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
3595de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
3605de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
3615de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
3625de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
3635de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
3645de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
3655de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
3665de35c9bSChiranjeevi Rapolu 	{0x4508, 0xaa},
3675de35c9bSChiranjeevi Rapolu 	{0x4509, 0xaa},
3685de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
3695de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
3705de35c9bSChiranjeevi Rapolu 	{0x4600, 0x01},
3715de35c9bSChiranjeevi Rapolu 	{0x4601, 0x03},
3725de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
3735de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
3745de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
3755de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
3765de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
3775de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
3785de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
3795de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
3805de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
3815de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
3825de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
3835de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
3845de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
3855de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
3865de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
3875de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
3885de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
3895de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
3905de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
3915de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
3925de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
3935de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
3945de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
3955de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
3965de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
3975de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
3985de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
3995de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
4005de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
4015de35c9bSChiranjeevi Rapolu 	{0x4017, 0x08},
4025de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
4035de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
4045de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
4055de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
4065de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
4075de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
4085de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
4095de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
4105de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
4115de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
4125de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
4135de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
4145de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
4155de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
4165de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
4175de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
4185de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
4195de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
4205de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
4215de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
4225de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
4235de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
42499cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
42599cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
42699cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
42799cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
4285de35c9bSChiranjeevi Rapolu };
4295de35c9bSChiranjeevi Rapolu 
4305de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_1296x972_regs[] = {
4315de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
4325de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
4335de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
4345de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
4355de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
4365de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
4375de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
4385de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
4395de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
4405de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
4415de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
4425de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
4435de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
4445de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
4455de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
4465de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
4475de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
4485de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
4495de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
4505de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
4515de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
4525de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
4535de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
4545de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
4555de35c9bSChiranjeevi Rapolu 	{0x3508, 0x07},
4565de35c9bSChiranjeevi Rapolu 	{0x3509, 0x80},
4575de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
4585de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
4595de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
4605de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
4615de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
4625de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
4635de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
4645de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
4655de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
4665de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
4675de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
4685de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
4695de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
4705de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
4715de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
4725de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
4735de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
4745de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
4755de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
4765de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
4775de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
4785de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
4795de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
4805de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
4815de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
4825de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
4835de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
4845de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
4855de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
4865de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
4875de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
4885de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
4895de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
4905de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
4915de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
4925de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
4935de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
4945de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
4955de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
4965de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
4975de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
4985de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
4995de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
5005de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
5015de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
5025de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
5035de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
5045de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
5055de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
5065de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
5075de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
5085de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
5095de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
5105de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
5115de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
5125de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
5135de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
5145de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
5155de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
5165de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
5175de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
5185de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
5195de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
5205de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
5215de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
5225de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
5235de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
5245de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
5255de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
5265de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
5275de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
5285de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
5295de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
5305de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
5315de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
5325de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
5335de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
5345de35c9bSChiranjeevi Rapolu 	{0x3808, 0x05},
5355de35c9bSChiranjeevi Rapolu 	{0x3809, 0x10},
5365de35c9bSChiranjeevi Rapolu 	{0x380a, 0x03},
5375de35c9bSChiranjeevi Rapolu 	{0x380b, 0xcc},
5385de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
5395de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
5405de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
5415de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
5425de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
5435de35c9bSChiranjeevi Rapolu 	{0x3813, 0x04},
5445de35c9bSChiranjeevi Rapolu 	{0x3814, 0x03},
5455de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
5465de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
5475de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
5485de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
5495de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
5505de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
5515de35c9bSChiranjeevi Rapolu 	{0x3821, 0x47},
5525de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
5535de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
5545de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
5555de35c9bSChiranjeevi Rapolu 	{0x382a, 0x03},
5565de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
5575de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
5585de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
5595de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
5605de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
5615de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
5625de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
5635de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
5645de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
5655de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
5665de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
5675de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
5685de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
5695de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
5705de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
5715de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
5725de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
5735de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
5745de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
5755de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
5765de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
5775de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
5785de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
5795de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
5805de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
5815de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
5825de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
5835de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
5845de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
5855de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
5865de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
5875de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
5885de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
5895de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
5905de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
5915de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
5925de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
5935de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
5945de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
5955de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
5965de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
5975de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
5985de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
5995de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
6005de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
6015de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
6025de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
6035de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
6045de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
6055de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
6065de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
6075de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
6085de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
6095de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
6105de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
6115de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
6125de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
6135de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
6145de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
6155de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
6165de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
6175de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
6185de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
6195de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
6205de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
6215de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
6225de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
6235de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
6245de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
6255de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
6265de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
6275de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
6285de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
6295de35c9bSChiranjeevi Rapolu 	{0x4502, 0x48},
6305de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
6315de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
6325de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
6335de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
6345de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
6355de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
6365de35c9bSChiranjeevi Rapolu 	{0x4601, 0x81},
6375de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
6385de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
6395de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
6405de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
6415de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
6425de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
6435de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
6445de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
6455de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
6465de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
6475de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
6485de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
6495de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
6505de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
6515de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
6525de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
6535de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
6545de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
6555de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
6565de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
6575de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
6585de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
6595de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
6605de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
6615de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
6625de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
6635de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
6645de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
6655de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
6665de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
6675de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
6685de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
6695de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
6705de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
6715de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
6725de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
6735de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
6745de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
6755de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
6765de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
6775de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
6785de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
6795de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
6805de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
6815de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
6825de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
6835de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
6845de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
6855de35c9bSChiranjeevi Rapolu 	{0x5791, 0x04},
6865de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
6875de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
6885de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
68999cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
69099cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
69199cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
69299cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
6935de35c9bSChiranjeevi Rapolu };
6945de35c9bSChiranjeevi Rapolu 
6955de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_648x486_regs[] = {
6965de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
6975de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
6985de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
6995de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
7005de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
7015de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
7025de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
7035de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
7045de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
7055de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
7065de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
7075de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
7085de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
7095de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
7105de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
7115de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
7125de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
7135de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
7145de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
7155de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
7165de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
7175de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
7185de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
7195de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
7205de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
7215de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
7225de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
7235de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
7245de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
7255de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
7265de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
7275de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
7285de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
7295de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
7305de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
7315de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
7325de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
7335de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
7345de35c9bSChiranjeevi Rapolu 	{0x3623, 0x04},
7355de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
7365de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
7375de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
7385de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
7395de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
7405de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
7415de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
7425de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
7435de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
7445de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
7455de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
7465de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
7475de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
7485de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
7495de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
7505de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
7515de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
7525de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
7535de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
7545de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
7555de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
7565de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
7575de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
7585de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
7595de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
7605de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
7615de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
7625de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
7635de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
7645de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
7655de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
7665de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
7675de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
7685de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
7695de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
7705de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
7715de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
7725de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
7735de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
7745de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
7755de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
7765de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
7775de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
7785de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
7795de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
7805de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
7815de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
7825de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
7835de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
7845de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
7855de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
7865de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
7875de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
7885de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
7895de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
7905de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
7915de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
7925de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
7935de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
7945de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
7955de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
7965de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
7975de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
7985de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
7995de35c9bSChiranjeevi Rapolu 	{0x3808, 0x02},
8005de35c9bSChiranjeevi Rapolu 	{0x3809, 0x88},
8015de35c9bSChiranjeevi Rapolu 	{0x380a, 0x01},
8025de35c9bSChiranjeevi Rapolu 	{0x380b, 0xe6},
8035de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
8045de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
8055de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
8065de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
8075de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
8085de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
8095de35c9bSChiranjeevi Rapolu 	{0x3814, 0x07},
8105de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
8115de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
8125de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
8135de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
8145de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
8155de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
8165de35c9bSChiranjeevi Rapolu 	{0x3821, 0xc6},
8175de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
8185de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
8195de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
8205de35c9bSChiranjeevi Rapolu 	{0x382a, 0x07},
8215de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
8225de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
8235de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
8245de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
8255de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
8265de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
8275de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
8285de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
8295de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
8305de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
8315de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
8325de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
8335de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
8345de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
8355de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
8365de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
8375de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
8385de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
8395de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
8405de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
8415de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
8425de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
8435de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
8445de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
8455de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
8465de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
8475de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
8485de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
8495de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
8505de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
8515de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
8525de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
8535de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
8545de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
8555de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
8565de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
8575de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
8585de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
8595de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
8605de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
8615de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
8625de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
8635de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
8645de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
8655de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
8665de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
8675de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
8685de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
8695de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
8705de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
8715de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
8725de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
8735de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
8745de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
8755de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
8765de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
8775de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
8785de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
8795de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
8805de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
8815de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
8825de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
8835de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
8845de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
8855de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
8865de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
8875de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
8885de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
8895de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
8905de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
8915de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
8925de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
8935de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
8945de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
8955de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
8965de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
8975de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
8985de35c9bSChiranjeevi Rapolu 	{0x450a, 0x02},
8995de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
9005de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
9015de35c9bSChiranjeevi Rapolu 	{0x4601, 0x40},
9025de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
9035de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
9045de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
9055de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
9065de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
9075de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
9085de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
9095de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
9105de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
9115de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
9125de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
9135de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
9145de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
9155de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
9165de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
9175de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
9185de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
9195de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
9205de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
9215de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
9225de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
9235de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
9245de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
9255de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
9265de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
9275de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
9285de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
9295de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
9305de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
9315de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
9325de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
9335de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
9345de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
9355de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
9365de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
9375de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
9385de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
9395de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
9405de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
9415de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
9425de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
9435de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
9445de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
9455de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
9465de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
9475de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
9485de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
9495de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
9505de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
9515de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
9525de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
9535de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
95499cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
95599cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
95699cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
95799cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
9585de35c9bSChiranjeevi Rapolu };
9595de35c9bSChiranjeevi Rapolu 
9605de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_2560x1440_regs[] = {
9615de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
9625de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
9635de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
9645de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
9655de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
9665de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
9675de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
9685de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
9695de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
9705de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
9715de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
9725de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
9735de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
9745de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
9755de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
9765de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
9775de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
9785de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
9795de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
9805de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
9815de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
9825de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
9835de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
9845de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
9855de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
9865de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
9875de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
9885de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
9895de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
9905de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
9915de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
9925de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
9935de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
9945de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
9955de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
9965de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
9975de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
9985de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
9995de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
10005de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
10015de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
10025de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
10035de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
10045de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
10055de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
10065de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
10075de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
10085de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
10095de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
10105de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
10115de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
10125de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
10135de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
10145de35c9bSChiranjeevi Rapolu 	{0x366e, 0x10},
10155de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
10165de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
10175de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
10185de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
10195de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
10205de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
10215de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
10225de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
10235de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
10245de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
10255de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
10265de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
10275de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
10285de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
10295de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
10305de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
10315de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
10325de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
10335de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
10345de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
10355de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
10365de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
10375de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
10385de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
10395de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
10405de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
10415de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
10425de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
10435de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
10445de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
10455de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
10465de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
10475de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
10485de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
10495de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
10505de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
10515de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
10525de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
10535de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
10545de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
10555de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
10565de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
10575de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
10585de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
10595de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
10605de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
10615de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
10625de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
10635de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
10645de35c9bSChiranjeevi Rapolu 	{0x3808, 0x0a},
10655de35c9bSChiranjeevi Rapolu 	{0x3809, 0x00},
10665de35c9bSChiranjeevi Rapolu 	{0x380a, 0x05},
10675de35c9bSChiranjeevi Rapolu 	{0x380b, 0xa0},
10685de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
10695de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
10705de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
10715de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
10725de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
10735de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
10745de35c9bSChiranjeevi Rapolu 	{0x3814, 0x01},
10755de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
10765de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
10775de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
10785de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
10795de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
10805de35c9bSChiranjeevi Rapolu 	{0x3820, 0x84},
10815de35c9bSChiranjeevi Rapolu 	{0x3821, 0x46},
10825de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
10835de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
10845de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
10855de35c9bSChiranjeevi Rapolu 	{0x382a, 0x01},
10865de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
10875de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
10885de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
10895de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
10905de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
10915de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
10925de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
10935de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
10945de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
10955de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
10965de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
10975de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
10985de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
10995de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
11005de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
11015de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
11025de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
11035de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
11045de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
11055de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
11065de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
11075de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
11085de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
11095de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
11105de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
11115de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
11125de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
11135de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
11145de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
11155de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
11165de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
11175de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
11185de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
11195de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
11205de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
11215de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
11225de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
11235de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
11245de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
11255de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
11265de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
11275de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
11285de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
11295de35c9bSChiranjeevi Rapolu 	{0x4009, 0x0d},
11305de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
11315de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
11325de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
11335de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
11345de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
11355de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
11365de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
11375de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
11385de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
11395de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
11405de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
11415de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
11425de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
11435de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
11445de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
11455de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
11465de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
11475de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
11485de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
11495de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
11505de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
11515de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
11525de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
11535de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
11545de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
11555de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
11565de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
11575de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
11585de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
11595de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
11605de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
11615de35c9bSChiranjeevi Rapolu 	{0x4508, 0xaa},
11625de35c9bSChiranjeevi Rapolu 	{0x4509, 0xaa},
11635de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
11645de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
11655de35c9bSChiranjeevi Rapolu 	{0x4600, 0x01},
11665de35c9bSChiranjeevi Rapolu 	{0x4601, 0x00},
11675de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
11685de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
11695de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
11705de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
11715de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
11725de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
11735de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
11745de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
11755de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
11765de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
11775de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
11785de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
11795de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
11805de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
11815de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
11825de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
11835de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
11845de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
11855de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
11865de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
11875de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
11885de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
11895de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
11905de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
11915de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
11925de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
11935de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
11945de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
11955de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
11965de35c9bSChiranjeevi Rapolu 	{0x4017, 0x08},
11975de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
11985de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
11995de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
12005de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
12015de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
12025de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
12035de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
12045de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
12055de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
12065de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
12075de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
12085de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
12095de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
12105de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
12115de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
12125de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
12135de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
12145de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
12155de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
12165de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
12175de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
121899cd1242SChiranjeevi Rapolu 	{0x5794, 0xa3},
121999cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
122099cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
122199cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
12225de35c9bSChiranjeevi Rapolu };
12235de35c9bSChiranjeevi Rapolu 
12245de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_1280x720_regs[] = {
12255de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
12265de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
12275de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
12285de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
12295de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
12305de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
12315de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
12325de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
12335de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
12345de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
12355de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
12365de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
12375de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
12385de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
12395de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
12405de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
12415de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
12425de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
12435de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
12445de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
12455de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
12465de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
12475de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
12485de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
12495de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
12505de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
12515de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
12525de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
12535de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
12545de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
12555de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
12565de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
12575de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
12585de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
12595de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
12605de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
12615de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
12625de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
12635de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
12645de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
12655de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
12665de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
12675de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
12685de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
12695de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
12705de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
12715de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
12725de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
12735de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
12745de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
12755de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
12765de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
12775de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
12785de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
12795de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
12805de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
12815de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
12825de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
12835de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
12845de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
12855de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
12865de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
12875de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
12885de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
12895de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
12905de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
12915de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
12925de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
12935de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
12945de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
12955de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
12965de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
12975de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
12985de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
12995de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
13005de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
13015de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
13025de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
13035de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
13045de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
13055de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
13065de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
13075de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
13085de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
13095de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
13105de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
13115de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
13125de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
13135de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
13145de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
13155de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
13165de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
13175de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
13185de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
13195de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
13205de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
13215de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
13225de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
13235de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
13245de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
13255de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
13265de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
13275de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
13285de35c9bSChiranjeevi Rapolu 	{0x3808, 0x05},
13295de35c9bSChiranjeevi Rapolu 	{0x3809, 0x00},
13305de35c9bSChiranjeevi Rapolu 	{0x380a, 0x02},
13315de35c9bSChiranjeevi Rapolu 	{0x380b, 0xd0},
13325de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
13335de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
13345de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
13355de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
13365de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
13375de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
13385de35c9bSChiranjeevi Rapolu 	{0x3814, 0x03},
13395de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
13405de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
13415de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
13425de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
13435de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
13445de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
13455de35c9bSChiranjeevi Rapolu 	{0x3821, 0x47},
13465de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
13475de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
13485de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
13495de35c9bSChiranjeevi Rapolu 	{0x382a, 0x03},
13505de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
13515de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
13525de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
13535de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
13545de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
13555de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
13565de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
13575de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
13585de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
13595de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
13605de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
13615de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
13625de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
13635de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
13645de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
13655de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
13665de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
13675de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
13685de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
13695de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
13705de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
13715de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
13725de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
13735de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
13745de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
13755de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
13765de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
13775de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
13785de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
13795de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
13805de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
13815de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
13825de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
13835de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
13845de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
13855de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
13865de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
13875de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
13885de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
13895de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
13905de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
13915de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
13925de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
13935de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
13945de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
13955de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
13965de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
13975de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
13985de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
13995de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
14005de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
14015de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
14025de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
14035de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
14045de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
14055de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
14065de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
14075de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
14085de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
14095de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
14105de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
14115de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
14125de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
14135de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
14145de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
14155de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
14165de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
14175de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
14185de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
14195de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
14205de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
14215de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
14225de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
14235de35c9bSChiranjeevi Rapolu 	{0x4502, 0x48},
14245de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
14255de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
14265de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
14275de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
14285de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
14295de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
14305de35c9bSChiranjeevi Rapolu 	{0x4601, 0x80},
14315de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
14325de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
14335de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
14345de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
14355de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
14365de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
14375de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
14385de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
14395de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
14405de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
14415de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
14425de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
14435de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
14445de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
14455de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
14465de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
14475de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
14485de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
14495de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
14505de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
14515de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
14525de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
14535de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
14545de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
14555de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
14565de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
14575de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
14585de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
14595de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
14605de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
14615de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
14625de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
14635de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
14645de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
14655de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
14665de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
14675de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
14685de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
14695de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
14705de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
14715de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
14725de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
14735de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
14745de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
14755de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
14765de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
14775de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
14785de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
14795de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
14805de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
14815de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
14825de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
148399cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
148499cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
148599cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
148699cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
14875de35c9bSChiranjeevi Rapolu };
14885de35c9bSChiranjeevi Rapolu 
14895de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_640x360_regs[] = {
14905de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
14915de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
14925de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
14935de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
14945de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
14955de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
14965de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
14975de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
14985de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
14995de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
15005de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
15015de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
15025de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
15035de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
15045de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
15055de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
15065de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
15075de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
15085de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
15095de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
15105de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
15115de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
15125de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
15135de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
15145de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
15155de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
15165de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
15175de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
15185de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
15195de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
15205de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
15215de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
15225de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
15235de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
15245de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
15255de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
15265de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
15275de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
15285de35c9bSChiranjeevi Rapolu 	{0x3623, 0x04},
15295de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
15305de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
15315de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
15325de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
15335de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
15345de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
15355de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
15365de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
15375de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
15385de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
15395de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
15405de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
15415de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
15425de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
15435de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
15445de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
15455de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
15465de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
15475de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
15485de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
15495de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
15505de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
15515de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
15525de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
15535de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
15545de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
15555de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
15565de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
15575de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
15585de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
15595de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
15605de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
15615de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
15625de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
15635de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
15645de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
15655de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
15665de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
15675de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
15685de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
15695de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
15705de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
15715de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
15725de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
15735de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
15745de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
15755de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
15765de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
15775de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
15785de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
15795de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
15805de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
15815de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
15825de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
15835de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
15845de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
15855de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
15865de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
15875de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
15885de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
15895de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
15905de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
15915de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
15925de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
15935de35c9bSChiranjeevi Rapolu 	{0x3808, 0x02},
15945de35c9bSChiranjeevi Rapolu 	{0x3809, 0x80},
15955de35c9bSChiranjeevi Rapolu 	{0x380a, 0x01},
15965de35c9bSChiranjeevi Rapolu 	{0x380b, 0x68},
15975de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
15985de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
15995de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
16005de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
16015de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
16025de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
16035de35c9bSChiranjeevi Rapolu 	{0x3814, 0x07},
16045de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
16055de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
16065de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
16075de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
16085de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
16095de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
16105de35c9bSChiranjeevi Rapolu 	{0x3821, 0xc6},
16115de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
16125de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
16135de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
16145de35c9bSChiranjeevi Rapolu 	{0x382a, 0x07},
16155de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
16165de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
16175de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
16185de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
16195de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
16205de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
16215de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
16225de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
16235de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
16245de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
16255de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
16265de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
16275de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
16285de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
16295de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
16305de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
16315de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
16325de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
16335de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
16345de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
16355de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
16365de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
16375de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
16385de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
16395de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
16405de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
16415de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
16425de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
16435de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
16445de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
16455de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
16465de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
16475de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
16485de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
16495de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
16505de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
16515de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
16525de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
16535de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
16545de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
16555de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
16565de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
16575de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
16585de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
16595de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
16605de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
16615de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
16625de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
16635de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
16645de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
16655de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
16665de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
16675de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
16685de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
16695de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
16705de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
16715de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
16725de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
16735de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
16745de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
16755de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
16765de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
16775de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
16785de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
16795de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
16805de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
16815de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
16825de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
16835de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
16845de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
16855de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
16865de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
16875de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
16885de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
16895de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
16905de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
16915de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
16925de35c9bSChiranjeevi Rapolu 	{0x450a, 0x02},
16935de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
16945de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
16955de35c9bSChiranjeevi Rapolu 	{0x4601, 0x40},
16965de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
16975de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
16985de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
16995de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
17005de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
17015de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
17025de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
17035de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
17045de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
17055de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
17065de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
17075de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
17085de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
17095de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
17105de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
17115de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
17125de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
17135de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
17145de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
17155de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
17165de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
17175de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
17185de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
17195de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
17205de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
17215de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
17225de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
17235de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
17245de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
17255de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
17265de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
17275de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
17285de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
17295de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
17305de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
17315de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
17325de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
17335de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
17345de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
17355de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
17365de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
17375de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
17385de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
17395de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
17405de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
17415de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
17425de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
17435de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
17445de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
17455de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
17465de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
17475de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
174899cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
174999cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
175099cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
175199cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
17525de35c9bSChiranjeevi Rapolu };
17535de35c9bSChiranjeevi Rapolu 
17545de35c9bSChiranjeevi Rapolu static const char * const ov5670_test_pattern_menu[] = {
17555de35c9bSChiranjeevi Rapolu 	"Disabled",
17565de35c9bSChiranjeevi Rapolu 	"Vertical Color Bar Type 1",
17575de35c9bSChiranjeevi Rapolu };
17585de35c9bSChiranjeevi Rapolu 
17595de35c9bSChiranjeevi Rapolu /* Supported link frequencies */
1760f1425381SChiranjeevi Rapolu #define OV5670_LINK_FREQ_422MHZ		422400000
1761f1425381SChiranjeevi Rapolu #define OV5670_LINK_FREQ_422MHZ_INDEX	0
17625de35c9bSChiranjeevi Rapolu static const struct ov5670_link_freq_config link_freq_configs[] = {
17635de35c9bSChiranjeevi Rapolu 	{
17645de35c9bSChiranjeevi Rapolu 		.reg_list = {
17655de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mipi_data_rate_840mbps),
17665de35c9bSChiranjeevi Rapolu 			.regs = mipi_data_rate_840mbps,
17675de35c9bSChiranjeevi Rapolu 		}
17685de35c9bSChiranjeevi Rapolu 	}
17695de35c9bSChiranjeevi Rapolu };
17705de35c9bSChiranjeevi Rapolu 
17715de35c9bSChiranjeevi Rapolu static const s64 link_freq_menu_items[] = {
1772f1425381SChiranjeevi Rapolu 	OV5670_LINK_FREQ_422MHZ
17735de35c9bSChiranjeevi Rapolu };
17745de35c9bSChiranjeevi Rapolu 
17755de35c9bSChiranjeevi Rapolu /*
17765de35c9bSChiranjeevi Rapolu  * OV5670 sensor supports following resolutions with full FOV:
17775de35c9bSChiranjeevi Rapolu  * 4:3  ==> {2592x1944, 1296x972, 648x486}
17785de35c9bSChiranjeevi Rapolu  * 16:9 ==> {2560x1440, 1280x720, 640x360}
17795de35c9bSChiranjeevi Rapolu  */
17805de35c9bSChiranjeevi Rapolu static const struct ov5670_mode supported_modes[] = {
17815de35c9bSChiranjeevi Rapolu 	{
17825de35c9bSChiranjeevi Rapolu 		.width = 2592,
17835de35c9bSChiranjeevi Rapolu 		.height = 1944,
1784ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1785ed351ad9SChiranjeevi Rapolu 		.vts_min = OV5670_VTS_30FPS,
17862eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
17872eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
17885de35c9bSChiranjeevi Rapolu 		.reg_list = {
17895de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_2592x1944_regs),
17905de35c9bSChiranjeevi Rapolu 			.regs = mode_2592x1944_regs,
17915de35c9bSChiranjeevi Rapolu 		},
17925de35c9bSChiranjeevi Rapolu 	},
17935de35c9bSChiranjeevi Rapolu 	{
17945de35c9bSChiranjeevi Rapolu 		.width = 1296,
17955de35c9bSChiranjeevi Rapolu 		.height = 972,
1796ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1797ed351ad9SChiranjeevi Rapolu 		.vts_min = 996,
17982eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
17992eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
18005de35c9bSChiranjeevi Rapolu 		.reg_list = {
18015de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_1296x972_regs),
18025de35c9bSChiranjeevi Rapolu 			.regs = mode_1296x972_regs,
18035de35c9bSChiranjeevi Rapolu 		},
18045de35c9bSChiranjeevi Rapolu 	},
18055de35c9bSChiranjeevi Rapolu 	{
18065de35c9bSChiranjeevi Rapolu 		.width = 648,
18075de35c9bSChiranjeevi Rapolu 		.height = 486,
1808ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1809ed351ad9SChiranjeevi Rapolu 		.vts_min = 516,
18102eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18112eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
18125de35c9bSChiranjeevi Rapolu 		.reg_list = {
18135de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_648x486_regs),
18145de35c9bSChiranjeevi Rapolu 			.regs = mode_648x486_regs,
18155de35c9bSChiranjeevi Rapolu 		},
18165de35c9bSChiranjeevi Rapolu 	},
18175de35c9bSChiranjeevi Rapolu 	{
18185de35c9bSChiranjeevi Rapolu 		.width = 2560,
18195de35c9bSChiranjeevi Rapolu 		.height = 1440,
1820ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1821ed351ad9SChiranjeevi Rapolu 		.vts_min = OV5670_VTS_30FPS,
18222eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18232eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
18245de35c9bSChiranjeevi Rapolu 		.reg_list = {
18255de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_2560x1440_regs),
18265de35c9bSChiranjeevi Rapolu 			.regs = mode_2560x1440_regs,
18275de35c9bSChiranjeevi Rapolu 		},
18285de35c9bSChiranjeevi Rapolu 	},
18295de35c9bSChiranjeevi Rapolu 	{
18305de35c9bSChiranjeevi Rapolu 		.width = 1280,
18315de35c9bSChiranjeevi Rapolu 		.height = 720,
1832ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1833ed351ad9SChiranjeevi Rapolu 		.vts_min = 1020,
18342eadd98dSJean-Michel Hautbois 
18352eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18362eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
18375de35c9bSChiranjeevi Rapolu 		.reg_list = {
18385de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
18395de35c9bSChiranjeevi Rapolu 			.regs = mode_1280x720_regs,
18405de35c9bSChiranjeevi Rapolu 		},
18415de35c9bSChiranjeevi Rapolu 	},
18425de35c9bSChiranjeevi Rapolu 	{
18435de35c9bSChiranjeevi Rapolu 		.width = 640,
18445de35c9bSChiranjeevi Rapolu 		.height = 360,
1845ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1846ed351ad9SChiranjeevi Rapolu 		.vts_min = 510,
18472eadd98dSJean-Michel Hautbois 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18482eadd98dSJean-Michel Hautbois 		.analog_crop = &ov5670_analog_crop,
18495de35c9bSChiranjeevi Rapolu 		.reg_list = {
18505de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_640x360_regs),
18515de35c9bSChiranjeevi Rapolu 			.regs = mode_640x360_regs,
18525de35c9bSChiranjeevi Rapolu 		},
18535de35c9bSChiranjeevi Rapolu 	}
18545de35c9bSChiranjeevi Rapolu };
18555de35c9bSChiranjeevi Rapolu 
18565de35c9bSChiranjeevi Rapolu struct ov5670 {
18575de35c9bSChiranjeevi Rapolu 	struct v4l2_subdev sd;
18585de35c9bSChiranjeevi Rapolu 	struct media_pad pad;
1859a97b24feSLuca Weiss 	struct v4l2_fwnode_endpoint endpoint;
18605de35c9bSChiranjeevi Rapolu 
18615de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl_handler ctrl_handler;
18625de35c9bSChiranjeevi Rapolu 	/* V4L2 Controls */
18635de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *link_freq;
18645de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *pixel_rate;
18655de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *vblank;
18665de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *hblank;
18675de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *exposure;
18685de35c9bSChiranjeevi Rapolu 
18695de35c9bSChiranjeevi Rapolu 	/* Current mode */
18705de35c9bSChiranjeevi Rapolu 	const struct ov5670_mode *cur_mode;
18715de35c9bSChiranjeevi Rapolu 
18728004c91eSJacopo Mondi 	/* xvclk input clock */
18738004c91eSJacopo Mondi 	struct clk *xvclk;
18748004c91eSJacopo Mondi 
1875cf9ab879SJacopo Mondi 	/* Regulators */
1876cf9ab879SJacopo Mondi 	struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES];
1877cf9ab879SJacopo Mondi 
18780a844ab7SJacopo Mondi 	/* Power-down and reset gpios. */
18790a844ab7SJacopo Mondi 	struct gpio_desc *pwdn_gpio; /* PWDNB pin. */
18800a844ab7SJacopo Mondi 	struct gpio_desc *reset_gpio; /* XSHUTDOWN pin. */
18810a844ab7SJacopo Mondi 
18825de35c9bSChiranjeevi Rapolu 	/* To serialize asynchronus callbacks */
18835de35c9bSChiranjeevi Rapolu 	struct mutex mutex;
18845de35c9bSChiranjeevi Rapolu 
18855de35c9bSChiranjeevi Rapolu 	/* Streaming on/off */
18865de35c9bSChiranjeevi Rapolu 	bool streaming;
18871e583b56SSakari Ailus 	/* True if the device has been identified */
18881e583b56SSakari Ailus 	bool identified;
18895de35c9bSChiranjeevi Rapolu };
18905de35c9bSChiranjeevi Rapolu 
18915de35c9bSChiranjeevi Rapolu #define to_ov5670(_sd)	container_of(_sd, struct ov5670, sd)
18925de35c9bSChiranjeevi Rapolu 
18935de35c9bSChiranjeevi Rapolu /* Read registers up to 4 at a time */
ov5670_read_reg(struct ov5670 * ov5670,u16 reg,unsigned int len,u32 * val)18945de35c9bSChiranjeevi Rapolu static int ov5670_read_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
18955de35c9bSChiranjeevi Rapolu 			   u32 *val)
18965de35c9bSChiranjeevi Rapolu {
18975de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
18985de35c9bSChiranjeevi Rapolu 	struct i2c_msg msgs[2];
18995de35c9bSChiranjeevi Rapolu 	u8 *data_be_p;
1900baa6f19bSMauro Carvalho Chehab 	__be32 data_be = 0;
1901baa6f19bSMauro Carvalho Chehab 	__be16 reg_addr_be = cpu_to_be16(reg);
19025de35c9bSChiranjeevi Rapolu 	int ret;
19035de35c9bSChiranjeevi Rapolu 
19045de35c9bSChiranjeevi Rapolu 	if (len > 4)
19055de35c9bSChiranjeevi Rapolu 		return -EINVAL;
19065de35c9bSChiranjeevi Rapolu 
19075de35c9bSChiranjeevi Rapolu 	data_be_p = (u8 *)&data_be;
19085de35c9bSChiranjeevi Rapolu 	/* Write register address */
19095de35c9bSChiranjeevi Rapolu 	msgs[0].addr = client->addr;
19105de35c9bSChiranjeevi Rapolu 	msgs[0].flags = 0;
19115de35c9bSChiranjeevi Rapolu 	msgs[0].len = 2;
19125de35c9bSChiranjeevi Rapolu 	msgs[0].buf = (u8 *)&reg_addr_be;
19135de35c9bSChiranjeevi Rapolu 
19145de35c9bSChiranjeevi Rapolu 	/* Read data from register */
19155de35c9bSChiranjeevi Rapolu 	msgs[1].addr = client->addr;
19165de35c9bSChiranjeevi Rapolu 	msgs[1].flags = I2C_M_RD;
19175de35c9bSChiranjeevi Rapolu 	msgs[1].len = len;
19185de35c9bSChiranjeevi Rapolu 	msgs[1].buf = &data_be_p[4 - len];
19195de35c9bSChiranjeevi Rapolu 
19205de35c9bSChiranjeevi Rapolu 	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
19215de35c9bSChiranjeevi Rapolu 	if (ret != ARRAY_SIZE(msgs))
19225de35c9bSChiranjeevi Rapolu 		return -EIO;
19235de35c9bSChiranjeevi Rapolu 
19245de35c9bSChiranjeevi Rapolu 	*val = be32_to_cpu(data_be);
19255de35c9bSChiranjeevi Rapolu 
19265de35c9bSChiranjeevi Rapolu 	return 0;
19275de35c9bSChiranjeevi Rapolu }
19285de35c9bSChiranjeevi Rapolu 
19295de35c9bSChiranjeevi Rapolu /* Write registers up to 4 at a time */
ov5670_write_reg(struct ov5670 * ov5670,u16 reg,unsigned int len,u32 val)19305de35c9bSChiranjeevi Rapolu static int ov5670_write_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
19315de35c9bSChiranjeevi Rapolu 			    u32 val)
19325de35c9bSChiranjeevi Rapolu {
19335de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
19345de35c9bSChiranjeevi Rapolu 	int buf_i;
19355de35c9bSChiranjeevi Rapolu 	int val_i;
19365de35c9bSChiranjeevi Rapolu 	u8 buf[6];
19375de35c9bSChiranjeevi Rapolu 	u8 *val_p;
1938baa6f19bSMauro Carvalho Chehab 	__be32 tmp;
19395de35c9bSChiranjeevi Rapolu 
19405de35c9bSChiranjeevi Rapolu 	if (len > 4)
19415de35c9bSChiranjeevi Rapolu 		return -EINVAL;
19425de35c9bSChiranjeevi Rapolu 
19435de35c9bSChiranjeevi Rapolu 	buf[0] = reg >> 8;
19445de35c9bSChiranjeevi Rapolu 	buf[1] = reg & 0xff;
19455de35c9bSChiranjeevi Rapolu 
1946baa6f19bSMauro Carvalho Chehab 	tmp = cpu_to_be32(val);
1947baa6f19bSMauro Carvalho Chehab 	val_p = (u8 *)&tmp;
19485de35c9bSChiranjeevi Rapolu 	buf_i = 2;
19495de35c9bSChiranjeevi Rapolu 	val_i = 4 - len;
19505de35c9bSChiranjeevi Rapolu 
19515de35c9bSChiranjeevi Rapolu 	while (val_i < 4)
19525de35c9bSChiranjeevi Rapolu 		buf[buf_i++] = val_p[val_i++];
19535de35c9bSChiranjeevi Rapolu 
19545de35c9bSChiranjeevi Rapolu 	if (i2c_master_send(client, buf, len + 2) != len + 2)
19555de35c9bSChiranjeevi Rapolu 		return -EIO;
19565de35c9bSChiranjeevi Rapolu 
19575de35c9bSChiranjeevi Rapolu 	return 0;
19585de35c9bSChiranjeevi Rapolu }
19595de35c9bSChiranjeevi Rapolu 
19605de35c9bSChiranjeevi Rapolu /* Write a list of registers */
ov5670_write_regs(struct ov5670 * ov5670,const struct ov5670_reg * regs,unsigned int len)19615de35c9bSChiranjeevi Rapolu static int ov5670_write_regs(struct ov5670 *ov5670,
19625de35c9bSChiranjeevi Rapolu 			     const struct ov5670_reg *regs, unsigned int len)
19635de35c9bSChiranjeevi Rapolu {
19645de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
19655de35c9bSChiranjeevi Rapolu 	unsigned int i;
19665de35c9bSChiranjeevi Rapolu 	int ret;
19675de35c9bSChiranjeevi Rapolu 
19685de35c9bSChiranjeevi Rapolu 	for (i = 0; i < len; i++) {
19695de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, regs[i].address, 1, regs[i].val);
19705de35c9bSChiranjeevi Rapolu 		if (ret) {
19715de35c9bSChiranjeevi Rapolu 			dev_err_ratelimited(
19725de35c9bSChiranjeevi Rapolu 				&client->dev,
19735de35c9bSChiranjeevi Rapolu 				"Failed to write reg 0x%4.4x. error = %d\n",
19745de35c9bSChiranjeevi Rapolu 				regs[i].address, ret);
19755de35c9bSChiranjeevi Rapolu 
19765de35c9bSChiranjeevi Rapolu 			return ret;
19775de35c9bSChiranjeevi Rapolu 		}
19785de35c9bSChiranjeevi Rapolu 	}
19795de35c9bSChiranjeevi Rapolu 
19805de35c9bSChiranjeevi Rapolu 	return 0;
19815de35c9bSChiranjeevi Rapolu }
19825de35c9bSChiranjeevi Rapolu 
ov5670_write_reg_list(struct ov5670 * ov5670,const struct ov5670_reg_list * r_list)19835de35c9bSChiranjeevi Rapolu static int ov5670_write_reg_list(struct ov5670 *ov5670,
19845de35c9bSChiranjeevi Rapolu 				 const struct ov5670_reg_list *r_list)
19855de35c9bSChiranjeevi Rapolu {
19865de35c9bSChiranjeevi Rapolu 	return ov5670_write_regs(ov5670, r_list->regs, r_list->num_of_regs);
19875de35c9bSChiranjeevi Rapolu }
19885de35c9bSChiranjeevi Rapolu 
ov5670_update_digital_gain(struct ov5670 * ov5670,u32 d_gain)19895de35c9bSChiranjeevi Rapolu static int ov5670_update_digital_gain(struct ov5670 *ov5670, u32 d_gain)
19905de35c9bSChiranjeevi Rapolu {
19915de35c9bSChiranjeevi Rapolu 	int ret;
19925de35c9bSChiranjeevi Rapolu 
19935de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_R_DGTL_GAIN,
19945de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_16BIT, d_gain);
19955de35c9bSChiranjeevi Rapolu 	if (ret)
19965de35c9bSChiranjeevi Rapolu 		return ret;
19975de35c9bSChiranjeevi Rapolu 
19985de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_G_DGTL_GAIN,
19995de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_16BIT, d_gain);
20005de35c9bSChiranjeevi Rapolu 	if (ret)
20015de35c9bSChiranjeevi Rapolu 		return ret;
20025de35c9bSChiranjeevi Rapolu 
20035de35c9bSChiranjeevi Rapolu 	return ov5670_write_reg(ov5670, OV5670_REG_B_DGTL_GAIN,
20045de35c9bSChiranjeevi Rapolu 				OV5670_REG_VALUE_16BIT, d_gain);
20055de35c9bSChiranjeevi Rapolu }
20065de35c9bSChiranjeevi Rapolu 
ov5670_enable_test_pattern(struct ov5670 * ov5670,u32 pattern)20075de35c9bSChiranjeevi Rapolu static int ov5670_enable_test_pattern(struct ov5670 *ov5670, u32 pattern)
20085de35c9bSChiranjeevi Rapolu {
20095de35c9bSChiranjeevi Rapolu 	u32 val;
20105de35c9bSChiranjeevi Rapolu 	int ret;
20115de35c9bSChiranjeevi Rapolu 
20125de35c9bSChiranjeevi Rapolu 	/* Set the bayer order that we support */
20135de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN_CTRL,
20145de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, 0);
20155de35c9bSChiranjeevi Rapolu 	if (ret)
20165de35c9bSChiranjeevi Rapolu 		return ret;
20175de35c9bSChiranjeevi Rapolu 
20185de35c9bSChiranjeevi Rapolu 	ret = ov5670_read_reg(ov5670, OV5670_REG_TEST_PATTERN,
20195de35c9bSChiranjeevi Rapolu 			      OV5670_REG_VALUE_08BIT, &val);
20205de35c9bSChiranjeevi Rapolu 	if (ret)
20215de35c9bSChiranjeevi Rapolu 		return ret;
20225de35c9bSChiranjeevi Rapolu 
20235de35c9bSChiranjeevi Rapolu 	if (pattern)
20245de35c9bSChiranjeevi Rapolu 		val |= OV5670_TEST_PATTERN_ENABLE;
20255de35c9bSChiranjeevi Rapolu 	else
20265de35c9bSChiranjeevi Rapolu 		val &= ~OV5670_TEST_PATTERN_ENABLE;
20275de35c9bSChiranjeevi Rapolu 
20285de35c9bSChiranjeevi Rapolu 	return ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN,
20295de35c9bSChiranjeevi Rapolu 				OV5670_REG_VALUE_08BIT, val);
20305de35c9bSChiranjeevi Rapolu }
20315de35c9bSChiranjeevi Rapolu 
20325de35c9bSChiranjeevi Rapolu /* Initialize control handlers */
ov5670_set_ctrl(struct v4l2_ctrl * ctrl)20335de35c9bSChiranjeevi Rapolu static int ov5670_set_ctrl(struct v4l2_ctrl *ctrl)
20345de35c9bSChiranjeevi Rapolu {
20355de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = container_of(ctrl->handler,
20365de35c9bSChiranjeevi Rapolu 					     struct ov5670, ctrl_handler);
20375de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
20385de35c9bSChiranjeevi Rapolu 	s64 max;
2039c5b6f99cSJacopo Mondi 	int ret;
20405de35c9bSChiranjeevi Rapolu 
20415de35c9bSChiranjeevi Rapolu 	/* Propagate change of current control to all related controls */
20425de35c9bSChiranjeevi Rapolu 	switch (ctrl->id) {
20435de35c9bSChiranjeevi Rapolu 	case V4L2_CID_VBLANK:
20445de35c9bSChiranjeevi Rapolu 		/* Update max exposure while meeting expected vblanking */
20455de35c9bSChiranjeevi Rapolu 		max = ov5670->cur_mode->height + ctrl->val - 8;
20465de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(ov5670->exposure,
20475de35c9bSChiranjeevi Rapolu 					 ov5670->exposure->minimum, max,
20485de35c9bSChiranjeevi Rapolu 					 ov5670->exposure->step, max);
20495de35c9bSChiranjeevi Rapolu 		break;
20505de35c9bSChiranjeevi Rapolu 	}
20515de35c9bSChiranjeevi Rapolu 
20525de35c9bSChiranjeevi Rapolu 	/* V4L2 controls values will be applied only when power is already up */
20534d471563SSakari Ailus 	if (!pm_runtime_get_if_in_use(&client->dev))
20545de35c9bSChiranjeevi Rapolu 		return 0;
20555de35c9bSChiranjeevi Rapolu 
20565de35c9bSChiranjeevi Rapolu 	switch (ctrl->id) {
20575de35c9bSChiranjeevi Rapolu 	case V4L2_CID_ANALOGUE_GAIN:
20585de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_ANALOG_GAIN,
20595de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_16BIT, ctrl->val);
20605de35c9bSChiranjeevi Rapolu 		break;
20615de35c9bSChiranjeevi Rapolu 	case V4L2_CID_DIGITAL_GAIN:
20625de35c9bSChiranjeevi Rapolu 		ret = ov5670_update_digital_gain(ov5670, ctrl->val);
20635de35c9bSChiranjeevi Rapolu 		break;
20645de35c9bSChiranjeevi Rapolu 	case V4L2_CID_EXPOSURE:
20655de35c9bSChiranjeevi Rapolu 		/* 4 least significant bits of expsoure are fractional part */
20665de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_EXPOSURE,
20675de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_24BIT, ctrl->val << 4);
20685de35c9bSChiranjeevi Rapolu 		break;
20695de35c9bSChiranjeevi Rapolu 	case V4L2_CID_VBLANK:
20705de35c9bSChiranjeevi Rapolu 		/* Update VTS that meets expected vertical blanking */
20715de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_VTS,
20725de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_16BIT,
20735de35c9bSChiranjeevi Rapolu 				       ov5670->cur_mode->height + ctrl->val);
20745de35c9bSChiranjeevi Rapolu 		break;
20755de35c9bSChiranjeevi Rapolu 	case V4L2_CID_TEST_PATTERN:
20765de35c9bSChiranjeevi Rapolu 		ret = ov5670_enable_test_pattern(ov5670, ctrl->val);
20775de35c9bSChiranjeevi Rapolu 		break;
2078c5b6f99cSJacopo Mondi 	case V4L2_CID_HBLANK:
2079c5b6f99cSJacopo Mondi 	case V4L2_CID_LINK_FREQ:
2080c5b6f99cSJacopo Mondi 	case V4L2_CID_PIXEL_RATE:
2081c5b6f99cSJacopo Mondi 		ret = 0;
2082c5b6f99cSJacopo Mondi 		break;
20835de35c9bSChiranjeevi Rapolu 	default:
2084c5b6f99cSJacopo Mondi 		ret = -EINVAL;
20855de35c9bSChiranjeevi Rapolu 		dev_info(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n",
20865de35c9bSChiranjeevi Rapolu 			 __func__, ctrl->id, ctrl->val);
20875de35c9bSChiranjeevi Rapolu 		break;
208805ad2b6dSkbuild test robot 	}
20895de35c9bSChiranjeevi Rapolu 
20905de35c9bSChiranjeevi Rapolu 	pm_runtime_put(&client->dev);
20915de35c9bSChiranjeevi Rapolu 
20925de35c9bSChiranjeevi Rapolu 	return ret;
20935de35c9bSChiranjeevi Rapolu }
20945de35c9bSChiranjeevi Rapolu 
20955de35c9bSChiranjeevi Rapolu static const struct v4l2_ctrl_ops ov5670_ctrl_ops = {
20965de35c9bSChiranjeevi Rapolu 	.s_ctrl = ov5670_set_ctrl,
20975de35c9bSChiranjeevi Rapolu };
20985de35c9bSChiranjeevi Rapolu 
20995de35c9bSChiranjeevi Rapolu /* Initialize control handlers */
ov5670_init_controls(struct ov5670 * ov5670)21005de35c9bSChiranjeevi Rapolu static int ov5670_init_controls(struct ov5670 *ov5670)
21015de35c9bSChiranjeevi Rapolu {
2102a97b24feSLuca Weiss 	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
2103a97b24feSLuca Weiss 		&ov5670->endpoint.bus.mipi_csi2;
2104eba08021SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2105eba08021SJacopo Mondi 	struct v4l2_fwnode_device_properties props;
21065de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl_handler *ctrl_hdlr;
2107a97b24feSLuca Weiss 	unsigned int lanes_count;
2108a97b24feSLuca Weiss 	s64 mipi_pixel_rate;
21095de35c9bSChiranjeevi Rapolu 	s64 vblank_max;
21105de35c9bSChiranjeevi Rapolu 	s64 vblank_def;
2111ed351ad9SChiranjeevi Rapolu 	s64 vblank_min;
21125de35c9bSChiranjeevi Rapolu 	s64 exposure_max;
21135de35c9bSChiranjeevi Rapolu 	int ret;
21145de35c9bSChiranjeevi Rapolu 
21155de35c9bSChiranjeevi Rapolu 	ctrl_hdlr = &ov5670->ctrl_handler;
2116eba08021SJacopo Mondi 	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
21175de35c9bSChiranjeevi Rapolu 	if (ret)
21185de35c9bSChiranjeevi Rapolu 		return ret;
21195de35c9bSChiranjeevi Rapolu 
21205de35c9bSChiranjeevi Rapolu 	ctrl_hdlr->lock = &ov5670->mutex;
21215de35c9bSChiranjeevi Rapolu 	ov5670->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
21225de35c9bSChiranjeevi Rapolu 						   &ov5670_ctrl_ops,
21235de35c9bSChiranjeevi Rapolu 						   V4L2_CID_LINK_FREQ,
21245de35c9bSChiranjeevi Rapolu 						   0, 0, link_freq_menu_items);
21255de35c9bSChiranjeevi Rapolu 	if (ov5670->link_freq)
21265de35c9bSChiranjeevi Rapolu 		ov5670->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
21275de35c9bSChiranjeevi Rapolu 
21285de35c9bSChiranjeevi Rapolu 	/* By default, V4L2_CID_PIXEL_RATE is read only */
2129a97b24feSLuca Weiss 	lanes_count = bus_mipi_csi2->num_data_lanes;
2130a97b24feSLuca Weiss 	mipi_pixel_rate = OV5670_LINK_FREQ_422MHZ * 2 * lanes_count / 10;
2131a97b24feSLuca Weiss 
21325de35c9bSChiranjeevi Rapolu 	ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2133dc1eb7c9SJacopo Mondi 					       V4L2_CID_PIXEL_RATE,
2134a97b24feSLuca Weiss 					       mipi_pixel_rate,
2135a97b24feSLuca Weiss 					       mipi_pixel_rate,
21365de35c9bSChiranjeevi Rapolu 					       1,
2137a97b24feSLuca Weiss 					       mipi_pixel_rate);
21385de35c9bSChiranjeevi Rapolu 
21395de35c9bSChiranjeevi Rapolu 	vblank_max = OV5670_VTS_MAX - ov5670->cur_mode->height;
2140ed351ad9SChiranjeevi Rapolu 	vblank_def = ov5670->cur_mode->vts_def - ov5670->cur_mode->height;
2141ed351ad9SChiranjeevi Rapolu 	vblank_min = ov5670->cur_mode->vts_min - ov5670->cur_mode->height;
21425de35c9bSChiranjeevi Rapolu 	ov5670->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2143ed351ad9SChiranjeevi Rapolu 					   V4L2_CID_VBLANK, vblank_min,
21445de35c9bSChiranjeevi Rapolu 					   vblank_max, 1, vblank_def);
21455de35c9bSChiranjeevi Rapolu 
21465de35c9bSChiranjeevi Rapolu 	ov5670->hblank = v4l2_ctrl_new_std(
21475de35c9bSChiranjeevi Rapolu 				ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_HBLANK,
2148f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width,
2149f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width, 1,
2150f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width);
2151f1425381SChiranjeevi Rapolu 	if (ov5670->hblank)
2152f1425381SChiranjeevi Rapolu 		ov5670->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
21535de35c9bSChiranjeevi Rapolu 
21545de35c9bSChiranjeevi Rapolu 	/* Get min, max, step, default from sensor */
21555de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
21565de35c9bSChiranjeevi Rapolu 			  ANALOG_GAIN_MIN, ANALOG_GAIN_MAX, ANALOG_GAIN_STEP,
21575de35c9bSChiranjeevi Rapolu 			  ANALOG_GAIN_DEFAULT);
21585de35c9bSChiranjeevi Rapolu 
21595de35c9bSChiranjeevi Rapolu 	/* Digital gain */
21605de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
21615de35c9bSChiranjeevi Rapolu 			  OV5670_DGTL_GAIN_MIN, OV5670_DGTL_GAIN_MAX,
21625de35c9bSChiranjeevi Rapolu 			  OV5670_DGTL_GAIN_STEP, OV5670_DGTL_GAIN_DEFAULT);
21635de35c9bSChiranjeevi Rapolu 
21645de35c9bSChiranjeevi Rapolu 	/* Get min, max, step, default from sensor */
2165ed351ad9SChiranjeevi Rapolu 	exposure_max = ov5670->cur_mode->vts_def - 8;
21665de35c9bSChiranjeevi Rapolu 	ov5670->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
21675de35c9bSChiranjeevi Rapolu 					     V4L2_CID_EXPOSURE,
21685de35c9bSChiranjeevi Rapolu 					     OV5670_EXPOSURE_MIN,
21695de35c9bSChiranjeevi Rapolu 					     exposure_max, OV5670_EXPOSURE_STEP,
21705de35c9bSChiranjeevi Rapolu 					     exposure_max);
21715de35c9bSChiranjeevi Rapolu 
21725de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov5670_ctrl_ops,
21735de35c9bSChiranjeevi Rapolu 				     V4L2_CID_TEST_PATTERN,
21745de35c9bSChiranjeevi Rapolu 				     ARRAY_SIZE(ov5670_test_pattern_menu) - 1,
21755de35c9bSChiranjeevi Rapolu 				     0, 0, ov5670_test_pattern_menu);
21765de35c9bSChiranjeevi Rapolu 
21775de35c9bSChiranjeevi Rapolu 	if (ctrl_hdlr->error) {
21785de35c9bSChiranjeevi Rapolu 		ret = ctrl_hdlr->error;
21795de35c9bSChiranjeevi Rapolu 		goto error;
21805de35c9bSChiranjeevi Rapolu 	}
21815de35c9bSChiranjeevi Rapolu 
2182eba08021SJacopo Mondi 	ret = v4l2_fwnode_device_parse(&client->dev, &props);
2183eba08021SJacopo Mondi 	if (ret)
2184eba08021SJacopo Mondi 		goto error;
2185eba08021SJacopo Mondi 
2186eba08021SJacopo Mondi 	ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov5670_ctrl_ops,
2187eba08021SJacopo Mondi 					      &props);
2188eba08021SJacopo Mondi 	if (ret)
2189eba08021SJacopo Mondi 		goto error;
2190eba08021SJacopo Mondi 
21915de35c9bSChiranjeevi Rapolu 	ov5670->sd.ctrl_handler = ctrl_hdlr;
21925de35c9bSChiranjeevi Rapolu 
21935de35c9bSChiranjeevi Rapolu 	return 0;
21945de35c9bSChiranjeevi Rapolu 
21955de35c9bSChiranjeevi Rapolu error:
21965de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(ctrl_hdlr);
21975de35c9bSChiranjeevi Rapolu 
21985de35c9bSChiranjeevi Rapolu 	return ret;
21995de35c9bSChiranjeevi Rapolu }
22005de35c9bSChiranjeevi Rapolu 
ov5670_init_cfg(struct v4l2_subdev * sd,struct v4l2_subdev_state * state)2201bbc6071cSJacopo Mondi static int ov5670_init_cfg(struct v4l2_subdev *sd,
2202bbc6071cSJacopo Mondi 			   struct v4l2_subdev_state *state)
2203bbc6071cSJacopo Mondi {
2204bbc6071cSJacopo Mondi 	struct v4l2_mbus_framefmt *fmt =
2205bbc6071cSJacopo Mondi 				v4l2_subdev_get_try_format(sd, state, 0);
2206bbc6071cSJacopo Mondi 	const struct ov5670_mode *default_mode = &supported_modes[0];
22072eadd98dSJean-Michel Hautbois 	struct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, state, 0);
2208bbc6071cSJacopo Mondi 
2209bbc6071cSJacopo Mondi 	fmt->width = default_mode->width;
2210bbc6071cSJacopo Mondi 	fmt->height = default_mode->height;
2211bbc6071cSJacopo Mondi 	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
2212bbc6071cSJacopo Mondi 	fmt->field = V4L2_FIELD_NONE;
2213bbc6071cSJacopo Mondi 	fmt->colorspace = V4L2_COLORSPACE_SRGB;
2214bbc6071cSJacopo Mondi 	fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SRGB);
2215bbc6071cSJacopo Mondi 	fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
2216bbc6071cSJacopo Mondi 	fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SRGB);
2217bbc6071cSJacopo Mondi 
22182eadd98dSJean-Michel Hautbois 	*crop = *default_mode->analog_crop;
22192eadd98dSJean-Michel Hautbois 
2220bbc6071cSJacopo Mondi 	return 0;
2221bbc6071cSJacopo Mondi }
2222bbc6071cSJacopo Mondi 
ov5670_enum_mbus_code(struct v4l2_subdev * sd,struct v4l2_subdev_state * sd_state,struct v4l2_subdev_mbus_code_enum * code)22235de35c9bSChiranjeevi Rapolu static int ov5670_enum_mbus_code(struct v4l2_subdev *sd,
22240d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
22255de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_mbus_code_enum *code)
22265de35c9bSChiranjeevi Rapolu {
22275de35c9bSChiranjeevi Rapolu 	/* Only one bayer order GRBG is supported */
22285de35c9bSChiranjeevi Rapolu 	if (code->index > 0)
22295de35c9bSChiranjeevi Rapolu 		return -EINVAL;
22305de35c9bSChiranjeevi Rapolu 
22315de35c9bSChiranjeevi Rapolu 	code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
22325de35c9bSChiranjeevi Rapolu 
22335de35c9bSChiranjeevi Rapolu 	return 0;
22345de35c9bSChiranjeevi Rapolu }
22355de35c9bSChiranjeevi Rapolu 
ov5670_enum_frame_size(struct v4l2_subdev * sd,struct v4l2_subdev_state * sd_state,struct v4l2_subdev_frame_size_enum * fse)22365de35c9bSChiranjeevi Rapolu static int ov5670_enum_frame_size(struct v4l2_subdev *sd,
22370d346d2aSTomi Valkeinen 				  struct v4l2_subdev_state *sd_state,
22385de35c9bSChiranjeevi Rapolu 				  struct v4l2_subdev_frame_size_enum *fse)
22395de35c9bSChiranjeevi Rapolu {
22405de35c9bSChiranjeevi Rapolu 	if (fse->index >= ARRAY_SIZE(supported_modes))
22415de35c9bSChiranjeevi Rapolu 		return -EINVAL;
22425de35c9bSChiranjeevi Rapolu 
22435de35c9bSChiranjeevi Rapolu 	if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
22445de35c9bSChiranjeevi Rapolu 		return -EINVAL;
22455de35c9bSChiranjeevi Rapolu 
22465de35c9bSChiranjeevi Rapolu 	fse->min_width = supported_modes[fse->index].width;
22475de35c9bSChiranjeevi Rapolu 	fse->max_width = fse->min_width;
22485de35c9bSChiranjeevi Rapolu 	fse->min_height = supported_modes[fse->index].height;
22495de35c9bSChiranjeevi Rapolu 	fse->max_height = fse->min_height;
22505de35c9bSChiranjeevi Rapolu 
22515de35c9bSChiranjeevi Rapolu 	return 0;
22525de35c9bSChiranjeevi Rapolu }
22535de35c9bSChiranjeevi Rapolu 
ov5670_update_pad_format(const struct ov5670_mode * mode,struct v4l2_subdev_format * fmt)22545de35c9bSChiranjeevi Rapolu static void ov5670_update_pad_format(const struct ov5670_mode *mode,
22555de35c9bSChiranjeevi Rapolu 				     struct v4l2_subdev_format *fmt)
22565de35c9bSChiranjeevi Rapolu {
22575de35c9bSChiranjeevi Rapolu 	fmt->format.width = mode->width;
22585de35c9bSChiranjeevi Rapolu 	fmt->format.height = mode->height;
22595de35c9bSChiranjeevi Rapolu 	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
22605de35c9bSChiranjeevi Rapolu 	fmt->format.field = V4L2_FIELD_NONE;
22615de35c9bSChiranjeevi Rapolu }
22625de35c9bSChiranjeevi Rapolu 
ov5670_do_get_pad_format(struct ov5670 * ov5670,struct v4l2_subdev_state * sd_state,struct v4l2_subdev_format * fmt)22635de35c9bSChiranjeevi Rapolu static int ov5670_do_get_pad_format(struct ov5670 *ov5670,
22640d346d2aSTomi Valkeinen 				    struct v4l2_subdev_state *sd_state,
22655de35c9bSChiranjeevi Rapolu 				    struct v4l2_subdev_format *fmt)
22665de35c9bSChiranjeevi Rapolu {
22675de35c9bSChiranjeevi Rapolu 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
22680d346d2aSTomi Valkeinen 		fmt->format = *v4l2_subdev_get_try_format(&ov5670->sd,
22690d346d2aSTomi Valkeinen 							  sd_state,
22705de35c9bSChiranjeevi Rapolu 							  fmt->pad);
22715de35c9bSChiranjeevi Rapolu 	else
22725de35c9bSChiranjeevi Rapolu 		ov5670_update_pad_format(ov5670->cur_mode, fmt);
22735de35c9bSChiranjeevi Rapolu 
22745de35c9bSChiranjeevi Rapolu 	return 0;
22755de35c9bSChiranjeevi Rapolu }
22765de35c9bSChiranjeevi Rapolu 
ov5670_get_pad_format(struct v4l2_subdev * sd,struct v4l2_subdev_state * sd_state,struct v4l2_subdev_format * fmt)22775de35c9bSChiranjeevi Rapolu static int ov5670_get_pad_format(struct v4l2_subdev *sd,
22780d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
22795de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_format *fmt)
22805de35c9bSChiranjeevi Rapolu {
22815de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
22825de35c9bSChiranjeevi Rapolu 	int ret;
22835de35c9bSChiranjeevi Rapolu 
22845de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
22850d346d2aSTomi Valkeinen 	ret = ov5670_do_get_pad_format(ov5670, sd_state, fmt);
22865de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
22875de35c9bSChiranjeevi Rapolu 
22885de35c9bSChiranjeevi Rapolu 	return ret;
22895de35c9bSChiranjeevi Rapolu }
22905de35c9bSChiranjeevi Rapolu 
ov5670_set_pad_format(struct v4l2_subdev * sd,struct v4l2_subdev_state * sd_state,struct v4l2_subdev_format * fmt)22915de35c9bSChiranjeevi Rapolu static int ov5670_set_pad_format(struct v4l2_subdev *sd,
22920d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
22935de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_format *fmt)
22945de35c9bSChiranjeevi Rapolu {
22955de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
2296a97b24feSLuca Weiss 	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
2297a97b24feSLuca Weiss 		&ov5670->endpoint.bus.mipi_csi2;
22985de35c9bSChiranjeevi Rapolu 	const struct ov5670_mode *mode;
2299a97b24feSLuca Weiss 	unsigned int lanes_count;
2300a97b24feSLuca Weiss 	s64 mipi_pixel_rate;
23015de35c9bSChiranjeevi Rapolu 	s32 vblank_def;
2302a97b24feSLuca Weiss 	s64 link_freq;
23035de35c9bSChiranjeevi Rapolu 	s32 h_blank;
23045de35c9bSChiranjeevi Rapolu 
23055de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
23065de35c9bSChiranjeevi Rapolu 
23075de35c9bSChiranjeevi Rapolu 	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
23085de35c9bSChiranjeevi Rapolu 
2309d2dc57b1SSakari Ailus 	mode = v4l2_find_nearest_size(supported_modes,
2310d2dc57b1SSakari Ailus 				      ARRAY_SIZE(supported_modes),
2311d2dc57b1SSakari Ailus 				      width, height,
2312894de53bSSakari Ailus 				      fmt->format.width, fmt->format.height);
23135de35c9bSChiranjeevi Rapolu 	ov5670_update_pad_format(mode, fmt);
23145de35c9bSChiranjeevi Rapolu 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
23150d346d2aSTomi Valkeinen 		*v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format;
23165de35c9bSChiranjeevi Rapolu 	} else {
23175de35c9bSChiranjeevi Rapolu 		ov5670->cur_mode = mode;
23185de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl(ov5670->link_freq, mode->link_freq_index);
2319a97b24feSLuca Weiss 
2320a97b24feSLuca Weiss 		lanes_count = bus_mipi_csi2->num_data_lanes;
2321a97b24feSLuca Weiss 		link_freq = link_freq_menu_items[mode->link_freq_index];
2322a97b24feSLuca Weiss 		/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
2323a97b24feSLuca Weiss 		mipi_pixel_rate = div_s64(link_freq * 2 * lanes_count, 10);
23245de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl_int64(
23255de35c9bSChiranjeevi Rapolu 			ov5670->pixel_rate,
2326a97b24feSLuca Weiss 			mipi_pixel_rate);
23275de35c9bSChiranjeevi Rapolu 		/* Update limits and set FPS to default */
2328ed351ad9SChiranjeevi Rapolu 		vblank_def = ov5670->cur_mode->vts_def -
2329ed351ad9SChiranjeevi Rapolu 			     ov5670->cur_mode->height;
23305de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(
2331ed351ad9SChiranjeevi Rapolu 			ov5670->vblank,
2332ed351ad9SChiranjeevi Rapolu 			ov5670->cur_mode->vts_min - ov5670->cur_mode->height,
23335de35c9bSChiranjeevi Rapolu 			OV5670_VTS_MAX - ov5670->cur_mode->height, 1,
23345de35c9bSChiranjeevi Rapolu 			vblank_def);
23355de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl(ov5670->vblank, vblank_def);
2336f1425381SChiranjeevi Rapolu 		h_blank = OV5670_FIXED_PPL - ov5670->cur_mode->width;
23375de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(ov5670->hblank, h_blank, h_blank, 1,
23385de35c9bSChiranjeevi Rapolu 					 h_blank);
23395de35c9bSChiranjeevi Rapolu 	}
23405de35c9bSChiranjeevi Rapolu 
23415de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
23425de35c9bSChiranjeevi Rapolu 
23435de35c9bSChiranjeevi Rapolu 	return 0;
23445de35c9bSChiranjeevi Rapolu }
23455de35c9bSChiranjeevi Rapolu 
ov5670_get_skip_frames(struct v4l2_subdev * sd,u32 * frames)23465de35c9bSChiranjeevi Rapolu static int ov5670_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
23475de35c9bSChiranjeevi Rapolu {
23485de35c9bSChiranjeevi Rapolu 	*frames = OV5670_NUM_OF_SKIP_FRAMES;
23495de35c9bSChiranjeevi Rapolu 
23505de35c9bSChiranjeevi Rapolu 	return 0;
23515de35c9bSChiranjeevi Rapolu }
23525de35c9bSChiranjeevi Rapolu 
23531e583b56SSakari Ailus /* Verify chip ID */
ov5670_identify_module(struct ov5670 * ov5670)23541e583b56SSakari Ailus static int ov5670_identify_module(struct ov5670 *ov5670)
23551e583b56SSakari Ailus {
23561e583b56SSakari Ailus 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
23571e583b56SSakari Ailus 	int ret;
23581e583b56SSakari Ailus 	u32 val;
23591e583b56SSakari Ailus 
23601e583b56SSakari Ailus 	if (ov5670->identified)
23611e583b56SSakari Ailus 		return 0;
23621e583b56SSakari Ailus 
23631e583b56SSakari Ailus 	ret = ov5670_read_reg(ov5670, OV5670_REG_CHIP_ID,
23641e583b56SSakari Ailus 			      OV5670_REG_VALUE_24BIT, &val);
23651e583b56SSakari Ailus 	if (ret)
23661e583b56SSakari Ailus 		return ret;
23671e583b56SSakari Ailus 
23681e583b56SSakari Ailus 	if (val != OV5670_CHIP_ID) {
23691e583b56SSakari Ailus 		dev_err(&client->dev, "chip id mismatch: %x!=%x\n",
23701e583b56SSakari Ailus 			OV5670_CHIP_ID, val);
23711e583b56SSakari Ailus 		return -ENXIO;
23721e583b56SSakari Ailus 	}
23731e583b56SSakari Ailus 
23741e583b56SSakari Ailus 	ov5670->identified = true;
23751e583b56SSakari Ailus 
23761e583b56SSakari Ailus 	return 0;
23771e583b56SSakari Ailus }
23781e583b56SSakari Ailus 
ov5670_mipi_configure(struct ov5670 * ov5670)2379a97b24feSLuca Weiss static int ov5670_mipi_configure(struct ov5670 *ov5670)
2380a97b24feSLuca Weiss {
2381a97b24feSLuca Weiss 	struct v4l2_mbus_config_mipi_csi2 *bus_mipi_csi2 =
2382a97b24feSLuca Weiss 		&ov5670->endpoint.bus.mipi_csi2;
2383a97b24feSLuca Weiss 	unsigned int lanes_count = bus_mipi_csi2->num_data_lanes;
2384a97b24feSLuca Weiss 
2385a97b24feSLuca Weiss 	return ov5670_write_reg(ov5670, OV5670_MIPI_SC_CTRL0_REG,
2386a97b24feSLuca Weiss 				OV5670_REG_VALUE_08BIT,
2387a97b24feSLuca Weiss 				OV5670_MIPI_SC_CTRL0_LANES(lanes_count) |
2388a97b24feSLuca Weiss 				OV5670_MIPI_SC_CTRL0_MIPI_EN |
2389a97b24feSLuca Weiss 				OV5670_MIPI_SC_CTRL0_RESERVED);
2390a97b24feSLuca Weiss }
2391a97b24feSLuca Weiss 
23925de35c9bSChiranjeevi Rapolu /* Prepare streaming by writing default values and customized values */
ov5670_start_streaming(struct ov5670 * ov5670)23935de35c9bSChiranjeevi Rapolu static int ov5670_start_streaming(struct ov5670 *ov5670)
23945de35c9bSChiranjeevi Rapolu {
23955de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
23965de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list *reg_list;
23975de35c9bSChiranjeevi Rapolu 	int link_freq_index;
23985de35c9bSChiranjeevi Rapolu 	int ret;
23995de35c9bSChiranjeevi Rapolu 
24001e583b56SSakari Ailus 	ret = ov5670_identify_module(ov5670);
24011e583b56SSakari Ailus 	if (ret)
24021e583b56SSakari Ailus 		return ret;
24031e583b56SSakari Ailus 
24045de35c9bSChiranjeevi Rapolu 	/* Get out of from software reset */
24055de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_SOFTWARE_RST,
24065de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_SOFTWARE_RST);
24075de35c9bSChiranjeevi Rapolu 	if (ret) {
24085de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set powerup registers\n",
24095de35c9bSChiranjeevi Rapolu 			__func__);
24105de35c9bSChiranjeevi Rapolu 		return ret;
24115de35c9bSChiranjeevi Rapolu 	}
24125de35c9bSChiranjeevi Rapolu 
24135de35c9bSChiranjeevi Rapolu 	/* Setup PLL */
24145de35c9bSChiranjeevi Rapolu 	link_freq_index = ov5670->cur_mode->link_freq_index;
24155de35c9bSChiranjeevi Rapolu 	reg_list = &link_freq_configs[link_freq_index].reg_list;
24165de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg_list(ov5670, reg_list);
24175de35c9bSChiranjeevi Rapolu 	if (ret) {
24185de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set plls\n", __func__);
24195de35c9bSChiranjeevi Rapolu 		return ret;
24205de35c9bSChiranjeevi Rapolu 	}
24215de35c9bSChiranjeevi Rapolu 
24225de35c9bSChiranjeevi Rapolu 	/* Apply default values of current mode */
24235de35c9bSChiranjeevi Rapolu 	reg_list = &ov5670->cur_mode->reg_list;
24245de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg_list(ov5670, reg_list);
24255de35c9bSChiranjeevi Rapolu 	if (ret) {
24265de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set mode\n", __func__);
24275de35c9bSChiranjeevi Rapolu 		return ret;
24285de35c9bSChiranjeevi Rapolu 	}
24295de35c9bSChiranjeevi Rapolu 
2430a97b24feSLuca Weiss 	ret = ov5670_mipi_configure(ov5670);
2431a97b24feSLuca Weiss 	if (ret) {
2432a97b24feSLuca Weiss 		dev_err(&client->dev, "%s failed to configure MIPI\n", __func__);
2433a97b24feSLuca Weiss 		return ret;
2434a97b24feSLuca Weiss 	}
2435a97b24feSLuca Weiss 
24365de35c9bSChiranjeevi Rapolu 	ret = __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
24375de35c9bSChiranjeevi Rapolu 	if (ret)
24385de35c9bSChiranjeevi Rapolu 		return ret;
24395de35c9bSChiranjeevi Rapolu 
24405de35c9bSChiranjeevi Rapolu 	/* Write stream on list */
24415de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
24425de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_MODE_STREAMING);
24435de35c9bSChiranjeevi Rapolu 	if (ret) {
24445de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set stream\n", __func__);
24455de35c9bSChiranjeevi Rapolu 		return ret;
24465de35c9bSChiranjeevi Rapolu 	}
24475de35c9bSChiranjeevi Rapolu 
24485de35c9bSChiranjeevi Rapolu 	return 0;
24495de35c9bSChiranjeevi Rapolu }
24505de35c9bSChiranjeevi Rapolu 
ov5670_stop_streaming(struct ov5670 * ov5670)24515de35c9bSChiranjeevi Rapolu static int ov5670_stop_streaming(struct ov5670 *ov5670)
24525de35c9bSChiranjeevi Rapolu {
24535de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
24545de35c9bSChiranjeevi Rapolu 	int ret;
24555de35c9bSChiranjeevi Rapolu 
24565de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
24575de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_MODE_STANDBY);
24585de35c9bSChiranjeevi Rapolu 	if (ret)
24595de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set stream\n", __func__);
24605de35c9bSChiranjeevi Rapolu 
24615de35c9bSChiranjeevi Rapolu 	/* Return success even if it was an error, as there is nothing the
24625de35c9bSChiranjeevi Rapolu 	 * caller can do about it.
24635de35c9bSChiranjeevi Rapolu 	 */
24645de35c9bSChiranjeevi Rapolu 	return 0;
24655de35c9bSChiranjeevi Rapolu }
24665de35c9bSChiranjeevi Rapolu 
ov5670_set_stream(struct v4l2_subdev * sd,int enable)24675de35c9bSChiranjeevi Rapolu static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
24685de35c9bSChiranjeevi Rapolu {
24695de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
24705de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(sd);
24715de35c9bSChiranjeevi Rapolu 	int ret = 0;
24725de35c9bSChiranjeevi Rapolu 
24735de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
24745de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming == enable)
24755de35c9bSChiranjeevi Rapolu 		goto unlock_and_return;
24765de35c9bSChiranjeevi Rapolu 
24775de35c9bSChiranjeevi Rapolu 	if (enable) {
2478f151c230SMauro Carvalho Chehab 		ret = pm_runtime_resume_and_get(&client->dev);
2479f151c230SMauro Carvalho Chehab 		if (ret < 0)
24805de35c9bSChiranjeevi Rapolu 			goto unlock_and_return;
24815de35c9bSChiranjeevi Rapolu 
24825de35c9bSChiranjeevi Rapolu 		ret = ov5670_start_streaming(ov5670);
24835de35c9bSChiranjeevi Rapolu 		if (ret)
24845de35c9bSChiranjeevi Rapolu 			goto error;
24855de35c9bSChiranjeevi Rapolu 	} else {
24865de35c9bSChiranjeevi Rapolu 		ret = ov5670_stop_streaming(ov5670);
24875de35c9bSChiranjeevi Rapolu 		pm_runtime_put(&client->dev);
24885de35c9bSChiranjeevi Rapolu 	}
24893eefbc69SChiranjeevi Rapolu 	ov5670->streaming = enable;
24905de35c9bSChiranjeevi Rapolu 	goto unlock_and_return;
24915de35c9bSChiranjeevi Rapolu 
24925de35c9bSChiranjeevi Rapolu error:
24935de35c9bSChiranjeevi Rapolu 	pm_runtime_put(&client->dev);
24945de35c9bSChiranjeevi Rapolu 
24955de35c9bSChiranjeevi Rapolu unlock_and_return:
24965de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
24975de35c9bSChiranjeevi Rapolu 
24985de35c9bSChiranjeevi Rapolu 	return ret;
24995de35c9bSChiranjeevi Rapolu }
25005de35c9bSChiranjeevi Rapolu 
ov5670_runtime_resume(struct device * dev)250162ab1e32SJacopo Mondi static int __maybe_unused ov5670_runtime_resume(struct device *dev)
250262ab1e32SJacopo Mondi {
250362ab1e32SJacopo Mondi 	struct i2c_client *client = to_i2c_client(dev);
250462ab1e32SJacopo Mondi 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
250562ab1e32SJacopo Mondi 	struct ov5670 *ov5670 = to_ov5670(sd);
250662ab1e32SJacopo Mondi 	unsigned long delay_us;
250762ab1e32SJacopo Mondi 	int ret;
250862ab1e32SJacopo Mondi 
250962ab1e32SJacopo Mondi 	ret = clk_prepare_enable(ov5670->xvclk);
251062ab1e32SJacopo Mondi 	if (ret)
251162ab1e32SJacopo Mondi 		return ret;
251262ab1e32SJacopo Mondi 
251362ab1e32SJacopo Mondi 	ret = regulator_bulk_enable(OV5670_NUM_SUPPLIES, ov5670->supplies);
251462ab1e32SJacopo Mondi 	if (ret) {
251562ab1e32SJacopo Mondi 		clk_disable_unprepare(ov5670->xvclk);
251662ab1e32SJacopo Mondi 		return ret;
251762ab1e32SJacopo Mondi 	}
251862ab1e32SJacopo Mondi 
251962ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->pwdn_gpio, 0);
252062ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->reset_gpio, 0);
252162ab1e32SJacopo Mondi 
252262ab1e32SJacopo Mondi 	/* 8192 * 2 clock pulses before the first SCCB transaction. */
252362ab1e32SJacopo Mondi 	delay_us = DIV_ROUND_UP(8192 * 2 * 1000,
252462ab1e32SJacopo Mondi 				DIV_ROUND_UP(OV5670_XVCLK_FREQ, 1000));
252562ab1e32SJacopo Mondi 	fsleep(delay_us);
252662ab1e32SJacopo Mondi 
252762ab1e32SJacopo Mondi 	return 0;
252862ab1e32SJacopo Mondi }
252962ab1e32SJacopo Mondi 
ov5670_runtime_suspend(struct device * dev)253062ab1e32SJacopo Mondi static int __maybe_unused ov5670_runtime_suspend(struct device *dev)
253162ab1e32SJacopo Mondi {
253262ab1e32SJacopo Mondi 	struct i2c_client *client = to_i2c_client(dev);
253362ab1e32SJacopo Mondi 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
253462ab1e32SJacopo Mondi 	struct ov5670 *ov5670 = to_ov5670(sd);
253562ab1e32SJacopo Mondi 
253662ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->reset_gpio, 1);
253762ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->pwdn_gpio, 1);
253862ab1e32SJacopo Mondi 	regulator_bulk_disable(OV5670_NUM_SUPPLIES, ov5670->supplies);
253962ab1e32SJacopo Mondi 	clk_disable_unprepare(ov5670->xvclk);
254062ab1e32SJacopo Mondi 
254162ab1e32SJacopo Mondi 	return 0;
254262ab1e32SJacopo Mondi }
254362ab1e32SJacopo Mondi 
ov5670_suspend(struct device * dev)25445de35c9bSChiranjeevi Rapolu static int __maybe_unused ov5670_suspend(struct device *dev)
25455de35c9bSChiranjeevi Rapolu {
2546bf396557SKrzysztof Kozlowski 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
25475de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
25485de35c9bSChiranjeevi Rapolu 
25495de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming)
25505de35c9bSChiranjeevi Rapolu 		ov5670_stop_streaming(ov5670);
25515de35c9bSChiranjeevi Rapolu 
25525de35c9bSChiranjeevi Rapolu 	return 0;
25535de35c9bSChiranjeevi Rapolu }
25545de35c9bSChiranjeevi Rapolu 
ov5670_resume(struct device * dev)25555de35c9bSChiranjeevi Rapolu static int __maybe_unused ov5670_resume(struct device *dev)
25565de35c9bSChiranjeevi Rapolu {
2557bf396557SKrzysztof Kozlowski 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
25585de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
25595de35c9bSChiranjeevi Rapolu 	int ret;
25605de35c9bSChiranjeevi Rapolu 
25615de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming) {
25625de35c9bSChiranjeevi Rapolu 		ret = ov5670_start_streaming(ov5670);
25635de35c9bSChiranjeevi Rapolu 		if (ret) {
25645de35c9bSChiranjeevi Rapolu 			ov5670_stop_streaming(ov5670);
25655de35c9bSChiranjeevi Rapolu 			return ret;
25665de35c9bSChiranjeevi Rapolu 		}
25675de35c9bSChiranjeevi Rapolu 	}
25685de35c9bSChiranjeevi Rapolu 
25695de35c9bSChiranjeevi Rapolu 	return 0;
25705de35c9bSChiranjeevi Rapolu }
25715de35c9bSChiranjeevi Rapolu 
2572dce6dd44SRicardo Ribalda static const struct v4l2_subdev_core_ops ov5670_core_ops = {
2573dce6dd44SRicardo Ribalda 	.log_status = v4l2_ctrl_subdev_log_status,
2574dce6dd44SRicardo Ribalda 	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
2575dce6dd44SRicardo Ribalda 	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
2576dce6dd44SRicardo Ribalda };
2577dce6dd44SRicardo Ribalda 
25782eadd98dSJean-Michel Hautbois static const struct v4l2_rect *
__ov5670_get_pad_crop(struct ov5670 * sensor,struct v4l2_subdev_state * state,unsigned int pad,enum v4l2_subdev_format_whence which)25792eadd98dSJean-Michel Hautbois __ov5670_get_pad_crop(struct ov5670 *sensor, struct v4l2_subdev_state *state,
25802eadd98dSJean-Michel Hautbois 		      unsigned int pad, enum v4l2_subdev_format_whence which)
25812eadd98dSJean-Michel Hautbois {
25822eadd98dSJean-Michel Hautbois 	const struct ov5670_mode *mode = sensor->cur_mode;
25832eadd98dSJean-Michel Hautbois 
25842eadd98dSJean-Michel Hautbois 	switch (which) {
25852eadd98dSJean-Michel Hautbois 	case V4L2_SUBDEV_FORMAT_TRY:
25862eadd98dSJean-Michel Hautbois 		return v4l2_subdev_get_try_crop(&sensor->sd, state, pad);
25872eadd98dSJean-Michel Hautbois 	case V4L2_SUBDEV_FORMAT_ACTIVE:
25882eadd98dSJean-Michel Hautbois 		return mode->analog_crop;
25892eadd98dSJean-Michel Hautbois 	}
25902eadd98dSJean-Michel Hautbois 
25912eadd98dSJean-Michel Hautbois 	return NULL;
25922eadd98dSJean-Michel Hautbois }
25932eadd98dSJean-Michel Hautbois 
ov5670_get_selection(struct v4l2_subdev * subdev,struct v4l2_subdev_state * state,struct v4l2_subdev_selection * sel)25942eadd98dSJean-Michel Hautbois static int ov5670_get_selection(struct v4l2_subdev *subdev,
25952eadd98dSJean-Michel Hautbois 				struct v4l2_subdev_state *state,
25962eadd98dSJean-Michel Hautbois 				struct v4l2_subdev_selection *sel)
25972eadd98dSJean-Michel Hautbois {
25982eadd98dSJean-Michel Hautbois 	struct ov5670 *sensor = to_ov5670(subdev);
25992eadd98dSJean-Michel Hautbois 
26002eadd98dSJean-Michel Hautbois 	switch (sel->target) {
26012eadd98dSJean-Michel Hautbois 	case V4L2_SEL_TGT_CROP:
26022eadd98dSJean-Michel Hautbois 		mutex_lock(&sensor->mutex);
26032eadd98dSJean-Michel Hautbois 		sel->r = *__ov5670_get_pad_crop(sensor, state, sel->pad,
26042eadd98dSJean-Michel Hautbois 						sel->which);
26052eadd98dSJean-Michel Hautbois 		mutex_unlock(&sensor->mutex);
26062eadd98dSJean-Michel Hautbois 		break;
26072eadd98dSJean-Michel Hautbois 	case V4L2_SEL_TGT_NATIVE_SIZE:
26082eadd98dSJean-Michel Hautbois 	case V4L2_SEL_TGT_CROP_BOUNDS:
26092eadd98dSJean-Michel Hautbois 		sel->r.top = 0;
26102eadd98dSJean-Michel Hautbois 		sel->r.left = 0;
26112eadd98dSJean-Michel Hautbois 		sel->r.width = OV5670_NATIVE_WIDTH;
26122eadd98dSJean-Michel Hautbois 		sel->r.height = OV5670_NATIVE_HEIGHT;
26132eadd98dSJean-Michel Hautbois 		break;
26142eadd98dSJean-Michel Hautbois 	case V4L2_SEL_TGT_CROP_DEFAULT:
26152eadd98dSJean-Michel Hautbois 		sel->r = ov5670_analog_crop;
26162eadd98dSJean-Michel Hautbois 		break;
26172eadd98dSJean-Michel Hautbois 	default:
26182eadd98dSJean-Michel Hautbois 		return -EINVAL;
26192eadd98dSJean-Michel Hautbois 	}
26202eadd98dSJean-Michel Hautbois 
26212eadd98dSJean-Michel Hautbois 	return 0;
26222eadd98dSJean-Michel Hautbois }
26232eadd98dSJean-Michel Hautbois 
26245de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_video_ops ov5670_video_ops = {
26255de35c9bSChiranjeevi Rapolu 	.s_stream = ov5670_set_stream,
26265de35c9bSChiranjeevi Rapolu };
26275de35c9bSChiranjeevi Rapolu 
26285de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_pad_ops ov5670_pad_ops = {
2629bbc6071cSJacopo Mondi 	.init_cfg = ov5670_init_cfg,
26305de35c9bSChiranjeevi Rapolu 	.enum_mbus_code = ov5670_enum_mbus_code,
26315de35c9bSChiranjeevi Rapolu 	.get_fmt = ov5670_get_pad_format,
26325de35c9bSChiranjeevi Rapolu 	.set_fmt = ov5670_set_pad_format,
26335de35c9bSChiranjeevi Rapolu 	.enum_frame_size = ov5670_enum_frame_size,
26342eadd98dSJean-Michel Hautbois 	.get_selection = ov5670_get_selection,
26352eadd98dSJean-Michel Hautbois 	.set_selection = ov5670_get_selection,
26365de35c9bSChiranjeevi Rapolu };
26375de35c9bSChiranjeevi Rapolu 
26385de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_sensor_ops ov5670_sensor_ops = {
26395de35c9bSChiranjeevi Rapolu 	.g_skip_frames = ov5670_get_skip_frames,
26405de35c9bSChiranjeevi Rapolu };
26415de35c9bSChiranjeevi Rapolu 
26425de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_ops ov5670_subdev_ops = {
2643dce6dd44SRicardo Ribalda 	.core = &ov5670_core_ops,
26445de35c9bSChiranjeevi Rapolu 	.video = &ov5670_video_ops,
26455de35c9bSChiranjeevi Rapolu 	.pad = &ov5670_pad_ops,
26465de35c9bSChiranjeevi Rapolu 	.sensor = &ov5670_sensor_ops,
26475de35c9bSChiranjeevi Rapolu };
26485de35c9bSChiranjeevi Rapolu 
26495de35c9bSChiranjeevi Rapolu static const struct media_entity_operations ov5670_subdev_entity_ops = {
26505de35c9bSChiranjeevi Rapolu 	.link_validate = v4l2_subdev_link_validate,
26515de35c9bSChiranjeevi Rapolu };
26525de35c9bSChiranjeevi Rapolu 
ov5670_regulators_probe(struct ov5670 * ov5670)2653cf9ab879SJacopo Mondi static int ov5670_regulators_probe(struct ov5670 *ov5670)
2654cf9ab879SJacopo Mondi {
2655cf9ab879SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2656cf9ab879SJacopo Mondi 	unsigned int i;
2657cf9ab879SJacopo Mondi 
2658cf9ab879SJacopo Mondi 	for (i = 0; i < OV5670_NUM_SUPPLIES; i++)
2659cf9ab879SJacopo Mondi 		ov5670->supplies[i].supply = ov5670_supply_names[i];
2660cf9ab879SJacopo Mondi 
2661cf9ab879SJacopo Mondi 	return devm_regulator_bulk_get(&client->dev, OV5670_NUM_SUPPLIES,
2662cf9ab879SJacopo Mondi 				       ov5670->supplies);
2663cf9ab879SJacopo Mondi }
2664cf9ab879SJacopo Mondi 
ov5670_gpio_probe(struct ov5670 * ov5670)26650a844ab7SJacopo Mondi static int ov5670_gpio_probe(struct ov5670 *ov5670)
26660a844ab7SJacopo Mondi {
26670a844ab7SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
26680a844ab7SJacopo Mondi 
26690a844ab7SJacopo Mondi 	ov5670->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
26700a844ab7SJacopo Mondi 						    GPIOD_OUT_LOW);
26710a844ab7SJacopo Mondi 	if (IS_ERR(ov5670->pwdn_gpio))
26720a844ab7SJacopo Mondi 		return PTR_ERR(ov5670->pwdn_gpio);
26730a844ab7SJacopo Mondi 
26740a844ab7SJacopo Mondi 	ov5670->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
26750a844ab7SJacopo Mondi 						     GPIOD_OUT_LOW);
26760a844ab7SJacopo Mondi 	if (IS_ERR(ov5670->reset_gpio))
26770a844ab7SJacopo Mondi 		return PTR_ERR(ov5670->reset_gpio);
26780a844ab7SJacopo Mondi 
26790a844ab7SJacopo Mondi 	return 0;
26800a844ab7SJacopo Mondi }
26810a844ab7SJacopo Mondi 
ov5670_probe(struct i2c_client * client)26825de35c9bSChiranjeevi Rapolu static int ov5670_probe(struct i2c_client *client)
26835de35c9bSChiranjeevi Rapolu {
2684a97b24feSLuca Weiss 	struct fwnode_handle *handle;
26855de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670;
26865de35c9bSChiranjeevi Rapolu 	u32 input_clk = 0;
26871e583b56SSakari Ailus 	bool full_power;
26885de35c9bSChiranjeevi Rapolu 	int ret;
26895de35c9bSChiranjeevi Rapolu 
26905de35c9bSChiranjeevi Rapolu 	ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL);
26914ed6627bSLuca Weiss 	if (!ov5670)
26924ed6627bSLuca Weiss 		return -ENOMEM;
26935de35c9bSChiranjeevi Rapolu 
269473b41dc5SSakari Ailus 	ov5670->xvclk = devm_clk_get_optional(&client->dev, NULL);
26958004c91eSJacopo Mondi 	if (!IS_ERR_OR_NULL(ov5670->xvclk))
26968004c91eSJacopo Mondi 		input_clk = clk_get_rate(ov5670->xvclk);
2697e004c637SJacopo Mondi 	else if (!ov5670->xvclk || PTR_ERR(ov5670->xvclk) == -ENOENT)
26988004c91eSJacopo Mondi 		device_property_read_u32(&client->dev, "clock-frequency",
26998004c91eSJacopo Mondi 					 &input_clk);
27008004c91eSJacopo Mondi 	else
27018004c91eSJacopo Mondi 		return dev_err_probe(&client->dev, PTR_ERR(ov5670->xvclk),
27028004c91eSJacopo Mondi 				     "error getting clock\n");
27038004c91eSJacopo Mondi 
27048004c91eSJacopo Mondi 	if (input_clk != OV5670_XVCLK_FREQ) {
27058004c91eSJacopo Mondi 		dev_err(&client->dev,
27068004c91eSJacopo Mondi 			"Unsupported clock frequency %u\n", input_clk);
27078004c91eSJacopo Mondi 		return -EINVAL;
27088004c91eSJacopo Mondi 	}
27098004c91eSJacopo Mondi 
27105de35c9bSChiranjeevi Rapolu 	/* Initialize subdev */
27115de35c9bSChiranjeevi Rapolu 	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
27125de35c9bSChiranjeevi Rapolu 
2713cf9ab879SJacopo Mondi 	ret = ov5670_regulators_probe(ov5670);
27144ed6627bSLuca Weiss 	if (ret)
27154ed6627bSLuca Weiss 		return dev_err_probe(&client->dev, ret, "Regulators probe failed\n");
2716cf9ab879SJacopo Mondi 
27170a844ab7SJacopo Mondi 	ret = ov5670_gpio_probe(ov5670);
27184ed6627bSLuca Weiss 	if (ret)
27194ed6627bSLuca Weiss 		return dev_err_probe(&client->dev, ret, "GPIO probe failed\n");
27200a844ab7SJacopo Mondi 
2721a97b24feSLuca Weiss 	/* Graph Endpoint */
2722a97b24feSLuca Weiss 	handle = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL);
2723a97b24feSLuca Weiss 	if (!handle)
2724a97b24feSLuca Weiss 		return dev_err_probe(&client->dev, -ENXIO, "Endpoint for node get failed\n");
2725a97b24feSLuca Weiss 
2726a97b24feSLuca Weiss 	ov5670->endpoint.bus_type = V4L2_MBUS_CSI2_DPHY;
2727a97b24feSLuca Weiss 	ov5670->endpoint.bus.mipi_csi2.num_data_lanes = 2;
2728a97b24feSLuca Weiss 
2729a97b24feSLuca Weiss 	ret = v4l2_fwnode_endpoint_alloc_parse(handle, &ov5670->endpoint);
2730a97b24feSLuca Weiss 	fwnode_handle_put(handle);
2731a97b24feSLuca Weiss 	if (ret)
2732a97b24feSLuca Weiss 		return dev_err_probe(&client->dev, ret, "Endpoint parse failed\n");
2733a97b24feSLuca Weiss 
27341e583b56SSakari Ailus 	full_power = acpi_dev_state_d0(&client->dev);
27351e583b56SSakari Ailus 	if (full_power) {
273662ab1e32SJacopo Mondi 		ret = ov5670_runtime_resume(&client->dev);
2737a97b24feSLuca Weiss 		if (ret) {
2738a97b24feSLuca Weiss 			dev_err_probe(&client->dev, ret, "Power up failed\n");
2739a97b24feSLuca Weiss 			goto error_endpoint;
2740a97b24feSLuca Weiss 		}
274162ab1e32SJacopo Mondi 
27425de35c9bSChiranjeevi Rapolu 		/* Check module identity */
27435de35c9bSChiranjeevi Rapolu 		ret = ov5670_identify_module(ov5670);
27445de35c9bSChiranjeevi Rapolu 		if (ret) {
27454ed6627bSLuca Weiss 			dev_err_probe(&client->dev, ret, "ov5670_identify_module() error\n");
274662ab1e32SJacopo Mondi 			goto error_power_off;
27475de35c9bSChiranjeevi Rapolu 		}
27481e583b56SSakari Ailus 	}
27495de35c9bSChiranjeevi Rapolu 
27505de35c9bSChiranjeevi Rapolu 	mutex_init(&ov5670->mutex);
27515de35c9bSChiranjeevi Rapolu 
27525de35c9bSChiranjeevi Rapolu 	/* Set default mode to max resolution */
27535de35c9bSChiranjeevi Rapolu 	ov5670->cur_mode = &supported_modes[0];
27545de35c9bSChiranjeevi Rapolu 
27555de35c9bSChiranjeevi Rapolu 	ret = ov5670_init_controls(ov5670);
27565de35c9bSChiranjeevi Rapolu 	if (ret) {
27574ed6627bSLuca Weiss 		dev_err_probe(&client->dev, ret, "ov5670_init_controls() error\n");
27585de35c9bSChiranjeevi Rapolu 		goto error_mutex_destroy;
27595de35c9bSChiranjeevi Rapolu 	}
27605de35c9bSChiranjeevi Rapolu 
2761dce6dd44SRicardo Ribalda 	ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
2762dce6dd44SRicardo Ribalda 			    V4L2_SUBDEV_FL_HAS_EVENTS;
27635de35c9bSChiranjeevi Rapolu 	ov5670->sd.entity.ops = &ov5670_subdev_entity_ops;
27645de35c9bSChiranjeevi Rapolu 	ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
27655de35c9bSChiranjeevi Rapolu 
27665de35c9bSChiranjeevi Rapolu 	/* Source pad initialization */
27675de35c9bSChiranjeevi Rapolu 	ov5670->pad.flags = MEDIA_PAD_FL_SOURCE;
27685de35c9bSChiranjeevi Rapolu 	ret = media_entity_pads_init(&ov5670->sd.entity, 1, &ov5670->pad);
27695de35c9bSChiranjeevi Rapolu 	if (ret) {
27704ed6627bSLuca Weiss 		dev_err_probe(&client->dev, ret, "media_entity_pads_init() error\n");
27715de35c9bSChiranjeevi Rapolu 		goto error_handler_free;
27725de35c9bSChiranjeevi Rapolu 	}
27735de35c9bSChiranjeevi Rapolu 
27745de35c9bSChiranjeevi Rapolu 	ov5670->streaming = false;
27755de35c9bSChiranjeevi Rapolu 
27761e583b56SSakari Ailus 	/* Set the device's state to active if it's in D0 state. */
27771e583b56SSakari Ailus 	if (full_power)
27785de35c9bSChiranjeevi Rapolu 		pm_runtime_set_active(&client->dev);
27795de35c9bSChiranjeevi Rapolu 	pm_runtime_enable(&client->dev);
278062ab1e32SJacopo Mondi 
278162ab1e32SJacopo Mondi 	/* Async register for subdev */
278262ab1e32SJacopo Mondi 	ret = v4l2_async_register_subdev_sensor(&ov5670->sd);
278362ab1e32SJacopo Mondi 	if (ret < 0) {
27844ed6627bSLuca Weiss 		dev_err_probe(&client->dev, ret, "v4l2_async_register_subdev() error\n");
278562ab1e32SJacopo Mondi 		goto error_pm_disable;
278662ab1e32SJacopo Mondi 	}
278762ab1e32SJacopo Mondi 
2788d508fffbSSakari Ailus 	pm_runtime_idle(&client->dev);
27895de35c9bSChiranjeevi Rapolu 
27905de35c9bSChiranjeevi Rapolu 	return 0;
27915de35c9bSChiranjeevi Rapolu 
279262ab1e32SJacopo Mondi error_pm_disable:
279362ab1e32SJacopo Mondi 	pm_runtime_disable(&client->dev);
279462ab1e32SJacopo Mondi 
27955de35c9bSChiranjeevi Rapolu 	media_entity_cleanup(&ov5670->sd.entity);
27965de35c9bSChiranjeevi Rapolu 
27975de35c9bSChiranjeevi Rapolu error_handler_free:
27985de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(ov5670->sd.ctrl_handler);
27995de35c9bSChiranjeevi Rapolu 
28005de35c9bSChiranjeevi Rapolu error_mutex_destroy:
28015de35c9bSChiranjeevi Rapolu 	mutex_destroy(&ov5670->mutex);
28025de35c9bSChiranjeevi Rapolu 
280362ab1e32SJacopo Mondi error_power_off:
280462ab1e32SJacopo Mondi 	if (full_power)
280562ab1e32SJacopo Mondi 		ov5670_runtime_suspend(&client->dev);
280662ab1e32SJacopo Mondi 
2807a97b24feSLuca Weiss error_endpoint:
2808a97b24feSLuca Weiss 	v4l2_fwnode_endpoint_free(&ov5670->endpoint);
2809a97b24feSLuca Weiss 
28105de35c9bSChiranjeevi Rapolu 	return ret;
28115de35c9bSChiranjeevi Rapolu }
28125de35c9bSChiranjeevi Rapolu 
ov5670_remove(struct i2c_client * client)2813ed5c2f5fSUwe Kleine-König static void ov5670_remove(struct i2c_client *client)
28145de35c9bSChiranjeevi Rapolu {
28155de35c9bSChiranjeevi Rapolu 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
28165de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
28175de35c9bSChiranjeevi Rapolu 
28185de35c9bSChiranjeevi Rapolu 	v4l2_async_unregister_subdev(sd);
28195de35c9bSChiranjeevi Rapolu 	media_entity_cleanup(&sd->entity);
28205de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(sd->ctrl_handler);
28215de35c9bSChiranjeevi Rapolu 	mutex_destroy(&ov5670->mutex);
28225de35c9bSChiranjeevi Rapolu 
28235de35c9bSChiranjeevi Rapolu 	pm_runtime_disable(&client->dev);
282462ab1e32SJacopo Mondi 	ov5670_runtime_suspend(&client->dev);
2825a97b24feSLuca Weiss 
2826a97b24feSLuca Weiss 	v4l2_fwnode_endpoint_free(&ov5670->endpoint);
28275de35c9bSChiranjeevi Rapolu }
28285de35c9bSChiranjeevi Rapolu 
28295de35c9bSChiranjeevi Rapolu static const struct dev_pm_ops ov5670_pm_ops = {
28305de35c9bSChiranjeevi Rapolu 	SET_SYSTEM_SLEEP_PM_OPS(ov5670_suspend, ov5670_resume)
283162ab1e32SJacopo Mondi 	SET_RUNTIME_PM_OPS(ov5670_runtime_suspend, ov5670_runtime_resume, NULL)
28325de35c9bSChiranjeevi Rapolu };
28335de35c9bSChiranjeevi Rapolu 
28345de35c9bSChiranjeevi Rapolu #ifdef CONFIG_ACPI
28355de35c9bSChiranjeevi Rapolu static const struct acpi_device_id ov5670_acpi_ids[] = {
28365de35c9bSChiranjeevi Rapolu 	{ "INT3479" },
28375de35c9bSChiranjeevi Rapolu 	{ /* sentinel */ }
28385de35c9bSChiranjeevi Rapolu };
28395de35c9bSChiranjeevi Rapolu 
28405de35c9bSChiranjeevi Rapolu MODULE_DEVICE_TABLE(acpi, ov5670_acpi_ids);
28415de35c9bSChiranjeevi Rapolu #endif
28425de35c9bSChiranjeevi Rapolu 
28435635500aSJacopo Mondi static const struct of_device_id ov5670_of_ids[] = {
28445635500aSJacopo Mondi 	{ .compatible = "ovti,ov5670" },
28455635500aSJacopo Mondi 	{ /* sentinel */ }
28465635500aSJacopo Mondi };
28475635500aSJacopo Mondi MODULE_DEVICE_TABLE(of, ov5670_of_ids);
28485635500aSJacopo Mondi 
28495de35c9bSChiranjeevi Rapolu static struct i2c_driver ov5670_i2c_driver = {
28505de35c9bSChiranjeevi Rapolu 	.driver = {
28515de35c9bSChiranjeevi Rapolu 		.name = "ov5670",
28525de35c9bSChiranjeevi Rapolu 		.pm = &ov5670_pm_ops,
28535de35c9bSChiranjeevi Rapolu 		.acpi_match_table = ACPI_PTR(ov5670_acpi_ids),
28545635500aSJacopo Mondi 		.of_match_table = ov5670_of_ids,
28555de35c9bSChiranjeevi Rapolu 	},
2856aaeb31c0SUwe Kleine-König 	.probe = ov5670_probe,
28575de35c9bSChiranjeevi Rapolu 	.remove = ov5670_remove,
28581e583b56SSakari Ailus 	.flags = I2C_DRV_ACPI_WAIVE_D0_PROBE,
28595de35c9bSChiranjeevi Rapolu };
28605de35c9bSChiranjeevi Rapolu 
28615de35c9bSChiranjeevi Rapolu module_i2c_driver(ov5670_i2c_driver);
28625de35c9bSChiranjeevi Rapolu 
2863*4106cd72SSakari Ailus MODULE_AUTHOR("Rapolu, Chiranjeevi");
28645fcec420SSakari Ailus MODULE_AUTHOR("Yang, Hyungwoo");
28655de35c9bSChiranjeevi Rapolu MODULE_DESCRIPTION("Omnivision ov5670 sensor driver");
28665de35c9bSChiranjeevi Rapolu MODULE_LICENSE("GPL v2");
2867