xref: /openbmc/linux/drivers/media/i2c/ov5670.c (revision bbc6071c)
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 
325de35c9bSChiranjeevi Rapolu /* vertical-timings from sensor */
335de35c9bSChiranjeevi Rapolu #define OV5670_REG_VTS			0x380e
345de35c9bSChiranjeevi Rapolu #define OV5670_VTS_30FPS		0x0808 /* default for 30 fps */
355de35c9bSChiranjeevi Rapolu #define OV5670_VTS_MAX			0xffff
365de35c9bSChiranjeevi Rapolu 
375de35c9bSChiranjeevi Rapolu /* horizontal-timings from sensor */
385de35c9bSChiranjeevi Rapolu #define OV5670_REG_HTS			0x380c
39f1425381SChiranjeevi Rapolu 
40f1425381SChiranjeevi Rapolu /*
41f1425381SChiranjeevi Rapolu  * Pixels-per-line(PPL) = Time-per-line * pixel-rate
42f1425381SChiranjeevi Rapolu  * In OV5670, Time-per-line = HTS/SCLK.
43f1425381SChiranjeevi Rapolu  * HTS is fixed for all resolutions, not recommended to change.
44f1425381SChiranjeevi Rapolu  */
45f1425381SChiranjeevi Rapolu #define OV5670_FIXED_PPL		2724	/* Pixels per line */
465de35c9bSChiranjeevi Rapolu 
475de35c9bSChiranjeevi Rapolu /* Exposure controls from sensor */
485de35c9bSChiranjeevi Rapolu #define OV5670_REG_EXPOSURE		0x3500
495de35c9bSChiranjeevi Rapolu #define	OV5670_EXPOSURE_MIN		4
505de35c9bSChiranjeevi Rapolu #define	OV5670_EXPOSURE_STEP		1
515de35c9bSChiranjeevi Rapolu 
525de35c9bSChiranjeevi Rapolu /* Analog gain controls from sensor */
535de35c9bSChiranjeevi Rapolu #define OV5670_REG_ANALOG_GAIN		0x3508
545de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_MIN			0
555de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_MAX			8191
565de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_STEP		1
575de35c9bSChiranjeevi Rapolu #define	ANALOG_GAIN_DEFAULT		128
585de35c9bSChiranjeevi Rapolu 
595de35c9bSChiranjeevi Rapolu /* Digital gain controls from sensor */
605de35c9bSChiranjeevi Rapolu #define OV5670_REG_R_DGTL_GAIN		0x5032
615de35c9bSChiranjeevi Rapolu #define OV5670_REG_G_DGTL_GAIN		0x5034
625de35c9bSChiranjeevi Rapolu #define OV5670_REG_B_DGTL_GAIN		0x5036
635de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_MIN		0
645de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_MAX		4095
655de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_STEP		1
665de35c9bSChiranjeevi Rapolu #define OV5670_DGTL_GAIN_DEFAULT	1024
675de35c9bSChiranjeevi Rapolu 
685de35c9bSChiranjeevi Rapolu /* Test Pattern Control */
695de35c9bSChiranjeevi Rapolu #define OV5670_REG_TEST_PATTERN		0x4303
705de35c9bSChiranjeevi Rapolu #define OV5670_TEST_PATTERN_ENABLE	BIT(3)
715de35c9bSChiranjeevi Rapolu #define OV5670_REG_TEST_PATTERN_CTRL	0x4320
725de35c9bSChiranjeevi Rapolu 
735de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_08BIT		1
745de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_16BIT		2
755de35c9bSChiranjeevi Rapolu #define OV5670_REG_VALUE_24BIT		3
765de35c9bSChiranjeevi Rapolu 
775de35c9bSChiranjeevi Rapolu /* Initial number of frames to skip to avoid possible garbage */
785de35c9bSChiranjeevi Rapolu #define OV5670_NUM_OF_SKIP_FRAMES	2
795de35c9bSChiranjeevi Rapolu 
805de35c9bSChiranjeevi Rapolu struct ov5670_reg {
815de35c9bSChiranjeevi Rapolu 	u16 address;
825de35c9bSChiranjeevi Rapolu 	u8 val;
835de35c9bSChiranjeevi Rapolu };
845de35c9bSChiranjeevi Rapolu 
855de35c9bSChiranjeevi Rapolu struct ov5670_reg_list {
865de35c9bSChiranjeevi Rapolu 	u32 num_of_regs;
875de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg *regs;
885de35c9bSChiranjeevi Rapolu };
895de35c9bSChiranjeevi Rapolu 
905de35c9bSChiranjeevi Rapolu struct ov5670_link_freq_config {
915de35c9bSChiranjeevi Rapolu 	u32 pixel_rate;
925de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list reg_list;
935de35c9bSChiranjeevi Rapolu };
945de35c9bSChiranjeevi Rapolu 
95cf9ab879SJacopo Mondi static const char * const ov5670_supply_names[] = {
96cf9ab879SJacopo Mondi 	"avdd",		/* Analog power */
97cf9ab879SJacopo Mondi 	"dvdd",		/* Digital power */
98cf9ab879SJacopo Mondi 	"dovdd",	/* Digital output power */
99cf9ab879SJacopo Mondi };
100cf9ab879SJacopo Mondi 
101cf9ab879SJacopo Mondi #define OV5670_NUM_SUPPLIES ARRAY_SIZE(ov5670_supply_names)
102cf9ab879SJacopo Mondi 
1035de35c9bSChiranjeevi Rapolu struct ov5670_mode {
1045de35c9bSChiranjeevi Rapolu 	/* Frame width in pixels */
1055de35c9bSChiranjeevi Rapolu 	u32 width;
1065de35c9bSChiranjeevi Rapolu 
1075de35c9bSChiranjeevi Rapolu 	/* Frame height in pixels */
1085de35c9bSChiranjeevi Rapolu 	u32 height;
1095de35c9bSChiranjeevi Rapolu 
110ed351ad9SChiranjeevi Rapolu 	/* Default vertical timining size */
111ed351ad9SChiranjeevi Rapolu 	u32 vts_def;
112ed351ad9SChiranjeevi Rapolu 
113ed351ad9SChiranjeevi Rapolu 	/* Min vertical timining size */
114ed351ad9SChiranjeevi Rapolu 	u32 vts_min;
1155de35c9bSChiranjeevi Rapolu 
1165de35c9bSChiranjeevi Rapolu 	/* Link frequency needed for this resolution */
1175de35c9bSChiranjeevi Rapolu 	u32 link_freq_index;
1185de35c9bSChiranjeevi Rapolu 
1195de35c9bSChiranjeevi Rapolu 	/* Sensor register settings for this resolution */
1205de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list reg_list;
1215de35c9bSChiranjeevi Rapolu };
1225de35c9bSChiranjeevi Rapolu 
1235de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mipi_data_rate_840mbps[] = {
1245de35c9bSChiranjeevi Rapolu 	{0x0300, 0x04},
1255de35c9bSChiranjeevi Rapolu 	{0x0301, 0x00},
1265de35c9bSChiranjeevi Rapolu 	{0x0302, 0x84},
1275de35c9bSChiranjeevi Rapolu 	{0x0303, 0x00},
1285de35c9bSChiranjeevi Rapolu 	{0x0304, 0x03},
1295de35c9bSChiranjeevi Rapolu 	{0x0305, 0x01},
1305de35c9bSChiranjeevi Rapolu 	{0x0306, 0x01},
1315de35c9bSChiranjeevi Rapolu 	{0x030a, 0x00},
1325de35c9bSChiranjeevi Rapolu 	{0x030b, 0x00},
1335de35c9bSChiranjeevi Rapolu 	{0x030c, 0x00},
1345de35c9bSChiranjeevi Rapolu 	{0x030d, 0x26},
1355de35c9bSChiranjeevi Rapolu 	{0x030e, 0x00},
1365de35c9bSChiranjeevi Rapolu 	{0x030f, 0x06},
1375de35c9bSChiranjeevi Rapolu 	{0x0312, 0x01},
1385de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
1395de35c9bSChiranjeevi Rapolu };
1405de35c9bSChiranjeevi Rapolu 
1415de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_2592x1944_regs[] = {
1425de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
1435de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
1445de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
1455de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
1465de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
1475de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
1485de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
1495de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
1505de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
1515de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
1525de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
1535de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
1545de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
1555de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
1565de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
1575de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
1585de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
1595de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
1605de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
1615de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
1625de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
1635de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
1645de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
1655de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
1665de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
1675de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
1685de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
1695de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
1705de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
1715de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
1725de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
1735de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
1745de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
1755de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
1765de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
1775de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
1785de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
1795de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
1805de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
1815de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
1825de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
1835de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
1845de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
1855de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
1865de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
1875de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
1885de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
1895de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
1905de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
1915de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
1925de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
1935de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
1945de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
1955de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
1965de35c9bSChiranjeevi Rapolu 	{0x366e, 0x10},
1975de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
1985de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
1995de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
2005de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
2015de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
2025de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
2035de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
2045de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
2055de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
2065de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
2075de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
2085de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
2095de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
2105de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
2115de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
2125de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
2135de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
2145de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
2155de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
2165de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
2175de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
2185de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
2195de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
2205de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
2215de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
2225de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
2235de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
2245de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
2255de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
2265de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
2275de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
2285de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
2295de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
2305de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
2315de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
2325de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
2335de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
2345de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
2355de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
2365de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
2375de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
2385de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
2395de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
2405de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
2415de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
2425de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
2435de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
2445de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
2455de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
2465de35c9bSChiranjeevi Rapolu 	{0x3808, 0x0a},
2475de35c9bSChiranjeevi Rapolu 	{0x3809, 0x20},
2485de35c9bSChiranjeevi Rapolu 	{0x380a, 0x07},
2495de35c9bSChiranjeevi Rapolu 	{0x380b, 0x98},
2505de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
2515de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
2525de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
2535de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
2545de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
2555de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
2565de35c9bSChiranjeevi Rapolu 	{0x3814, 0x01},
2575de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
2585de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
2595de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
2605de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
2615de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
2625de35c9bSChiranjeevi Rapolu 	{0x3820, 0x84},
2635de35c9bSChiranjeevi Rapolu 	{0x3821, 0x46},
2645de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
2655de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
2665de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
2675de35c9bSChiranjeevi Rapolu 	{0x382a, 0x01},
2685de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
2695de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
2705de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
2715de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
2725de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
2735de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
2745de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
2755de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
2765de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
2775de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
2785de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
2795de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
2805de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
2815de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
2825de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
2835de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
2845de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
2855de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
2865de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
2875de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
2885de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
2895de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
2905de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
2915de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
2925de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
2935de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
2945de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
2955de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
2965de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
2975de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
2985de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
2995de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
3005de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
3015de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
3025de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
3035de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
3045de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
3055de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
3065de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
3075de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
3085de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
3095de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
3105de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
3115de35c9bSChiranjeevi Rapolu 	{0x4009, 0x0d},
3125de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
3135de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
3145de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
3155de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
3165de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
3175de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
3185de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
3195de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
3205de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
3215de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
3225de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
3235de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
3245de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
3255de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
3265de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
3275de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
3285de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
3295de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
3305de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
3315de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
3325de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
3335de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
3345de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
3355de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
3365de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
3375de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
3385de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
3395de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
3405de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
3415de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
3425de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
3435de35c9bSChiranjeevi Rapolu 	{0x4508, 0xaa},
3445de35c9bSChiranjeevi Rapolu 	{0x4509, 0xaa},
3455de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
3465de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
3475de35c9bSChiranjeevi Rapolu 	{0x4600, 0x01},
3485de35c9bSChiranjeevi Rapolu 	{0x4601, 0x03},
3495de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
3505de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
3515de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
3525de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
3535de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
3545de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
3555de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
3565de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
3575de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
3585de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
3595de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
3605de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
3615de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
3625de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
3635de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
3645de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
3655de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
3665de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
3675de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
3685de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
3695de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
3705de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
3715de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
3725de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
3735de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
3745de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
3755de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
3765de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
3775de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
3785de35c9bSChiranjeevi Rapolu 	{0x4017, 0x08},
3795de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
3805de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
3815de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
3825de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
3835de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
3845de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
3855de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
3865de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
3875de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
3885de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
3895de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
3905de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
3915de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
3925de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
3935de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
3945de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
3955de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
3965de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
3975de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
3985de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
3995de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
4005de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
40199cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
40299cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
40399cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
40499cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
4055de35c9bSChiranjeevi Rapolu };
4065de35c9bSChiranjeevi Rapolu 
4075de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_1296x972_regs[] = {
4085de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
4095de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
4105de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
4115de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
4125de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
4135de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
4145de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
4155de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
4165de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
4175de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
4185de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
4195de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
4205de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
4215de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
4225de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
4235de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
4245de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
4255de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
4265de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
4275de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
4285de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
4295de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
4305de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
4315de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
4325de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
4335de35c9bSChiranjeevi Rapolu 	{0x3508, 0x07},
4345de35c9bSChiranjeevi Rapolu 	{0x3509, 0x80},
4355de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
4365de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
4375de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
4385de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
4395de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
4405de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
4415de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
4425de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
4435de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
4445de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
4455de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
4465de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
4475de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
4485de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
4495de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
4505de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
4515de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
4525de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
4535de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
4545de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
4555de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
4565de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
4575de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
4585de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
4595de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
4605de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
4615de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
4625de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
4635de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
4645de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
4655de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
4665de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
4675de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
4685de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
4695de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
4705de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
4715de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
4725de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
4735de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
4745de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
4755de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
4765de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
4775de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
4785de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
4795de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
4805de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
4815de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
4825de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
4835de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
4845de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
4855de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
4865de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
4875de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
4885de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
4895de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
4905de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
4915de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
4925de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
4935de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
4945de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
4955de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
4965de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
4975de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
4985de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
4995de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
5005de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
5015de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
5025de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
5035de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
5045de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
5055de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
5065de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
5075de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
5085de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
5095de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
5105de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
5115de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
5125de35c9bSChiranjeevi Rapolu 	{0x3808, 0x05},
5135de35c9bSChiranjeevi Rapolu 	{0x3809, 0x10},
5145de35c9bSChiranjeevi Rapolu 	{0x380a, 0x03},
5155de35c9bSChiranjeevi Rapolu 	{0x380b, 0xcc},
5165de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
5175de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
5185de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
5195de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
5205de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
5215de35c9bSChiranjeevi Rapolu 	{0x3813, 0x04},
5225de35c9bSChiranjeevi Rapolu 	{0x3814, 0x03},
5235de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
5245de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
5255de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
5265de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
5275de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
5285de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
5295de35c9bSChiranjeevi Rapolu 	{0x3821, 0x47},
5305de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
5315de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
5325de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
5335de35c9bSChiranjeevi Rapolu 	{0x382a, 0x03},
5345de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
5355de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
5365de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
5375de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
5385de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
5395de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
5405de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
5415de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
5425de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
5435de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
5445de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
5455de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
5465de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
5475de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
5485de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
5495de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
5505de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
5515de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
5525de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
5535de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
5545de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
5555de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
5565de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
5575de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
5585de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
5595de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
5605de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
5615de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
5625de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
5635de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
5645de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
5655de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
5665de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
5675de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
5685de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
5695de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
5705de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
5715de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
5725de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
5735de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
5745de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
5755de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
5765de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
5775de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
5785de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
5795de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
5805de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
5815de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
5825de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
5835de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
5845de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
5855de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
5865de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
5875de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
5885de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
5895de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
5905de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
5915de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
5925de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
5935de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
5945de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
5955de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
5965de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
5975de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
5985de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
5995de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
6005de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
6015de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
6025de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
6035de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
6045de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
6055de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
6065de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
6075de35c9bSChiranjeevi Rapolu 	{0x4502, 0x48},
6085de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
6095de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
6105de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
6115de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
6125de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
6135de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
6145de35c9bSChiranjeevi Rapolu 	{0x4601, 0x81},
6155de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
6165de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
6175de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
6185de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
6195de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
6205de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
6215de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
6225de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
6235de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
6245de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
6255de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
6265de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
6275de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
6285de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
6295de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
6305de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
6315de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
6325de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
6335de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
6345de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
6355de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
6365de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
6375de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
6385de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
6395de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
6405de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
6415de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
6425de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
6435de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
6445de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
6455de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
6465de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
6475de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
6485de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
6495de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
6505de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
6515de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
6525de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
6535de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
6545de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
6555de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
6565de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
6575de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
6585de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
6595de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
6605de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
6615de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
6625de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
6635de35c9bSChiranjeevi Rapolu 	{0x5791, 0x04},
6645de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
6655de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
6665de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
66799cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
66899cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
66999cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
67099cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
6715de35c9bSChiranjeevi Rapolu };
6725de35c9bSChiranjeevi Rapolu 
6735de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_648x486_regs[] = {
6745de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
6755de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
6765de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
6775de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
6785de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
6795de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
6805de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
6815de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
6825de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
6835de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
6845de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
6855de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
6865de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
6875de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
6885de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
6895de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
6905de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
6915de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
6925de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
6935de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
6945de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
6955de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
6965de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
6975de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
6985de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
6995de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
7005de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
7015de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
7025de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
7035de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
7045de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
7055de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
7065de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
7075de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
7085de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
7095de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
7105de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
7115de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
7125de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
7135de35c9bSChiranjeevi Rapolu 	{0x3623, 0x04},
7145de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
7155de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
7165de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
7175de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
7185de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
7195de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
7205de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
7215de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
7225de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
7235de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
7245de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
7255de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
7265de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
7275de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
7285de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
7295de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
7305de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
7315de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
7325de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
7335de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
7345de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
7355de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
7365de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
7375de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
7385de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
7395de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
7405de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
7415de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
7425de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
7435de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
7445de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
7455de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
7465de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
7475de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
7485de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
7495de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
7505de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
7515de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
7525de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
7535de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
7545de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
7555de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
7565de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
7575de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
7585de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
7595de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
7605de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
7615de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
7625de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
7635de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
7645de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
7655de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
7665de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
7675de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
7685de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
7695de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
7705de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
7715de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
7725de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
7735de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
7745de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
7755de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
7765de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
7775de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
7785de35c9bSChiranjeevi Rapolu 	{0x3808, 0x02},
7795de35c9bSChiranjeevi Rapolu 	{0x3809, 0x88},
7805de35c9bSChiranjeevi Rapolu 	{0x380a, 0x01},
7815de35c9bSChiranjeevi Rapolu 	{0x380b, 0xe6},
7825de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
7835de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
7845de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
7855de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
7865de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
7875de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
7885de35c9bSChiranjeevi Rapolu 	{0x3814, 0x07},
7895de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
7905de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
7915de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
7925de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
7935de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
7945de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
7955de35c9bSChiranjeevi Rapolu 	{0x3821, 0xc6},
7965de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
7975de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
7985de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
7995de35c9bSChiranjeevi Rapolu 	{0x382a, 0x07},
8005de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
8015de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
8025de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
8035de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
8045de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
8055de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
8065de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
8075de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
8085de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
8095de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
8105de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
8115de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
8125de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
8135de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
8145de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
8155de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
8165de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
8175de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
8185de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
8195de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
8205de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
8215de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
8225de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
8235de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
8245de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
8255de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
8265de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
8275de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
8285de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
8295de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
8305de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
8315de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
8325de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
8335de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
8345de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
8355de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
8365de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
8375de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
8385de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
8395de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
8405de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
8415de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
8425de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
8435de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
8445de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
8455de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
8465de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
8475de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
8485de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
8495de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
8505de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
8515de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
8525de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
8535de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
8545de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
8555de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
8565de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
8575de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
8585de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
8595de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
8605de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
8615de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
8625de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
8635de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
8645de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
8655de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
8665de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
8675de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
8685de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
8695de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
8705de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
8715de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
8725de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
8735de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
8745de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
8755de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
8765de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
8775de35c9bSChiranjeevi Rapolu 	{0x450a, 0x02},
8785de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
8795de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
8805de35c9bSChiranjeevi Rapolu 	{0x4601, 0x40},
8815de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
8825de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
8835de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
8845de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
8855de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
8865de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
8875de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
8885de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
8895de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
8905de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
8915de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
8925de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
8935de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
8945de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
8955de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
8965de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
8975de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
8985de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
8995de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
9005de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
9015de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
9025de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
9035de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
9045de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
9055de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
9065de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
9075de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
9085de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
9095de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
9105de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
9115de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
9125de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
9135de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
9145de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
9155de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
9165de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
9175de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
9185de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
9195de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
9205de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
9215de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
9225de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
9235de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
9245de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
9255de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
9265de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
9275de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
9285de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
9295de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
9305de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
9315de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
9325de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
93399cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
93499cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
93599cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
93699cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
9375de35c9bSChiranjeevi Rapolu };
9385de35c9bSChiranjeevi Rapolu 
9395de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_2560x1440_regs[] = {
9405de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
9415de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
9425de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
9435de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
9445de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
9455de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
9465de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
9475de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
9485de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
9495de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
9505de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
9515de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
9525de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
9535de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
9545de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
9555de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
9565de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
9575de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
9585de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
9595de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
9605de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
9615de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
9625de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
9635de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
9645de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
9655de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
9665de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
9675de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
9685de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
9695de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
9705de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
9715de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
9725de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
9735de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
9745de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
9755de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
9765de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
9775de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
9785de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
9795de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
9805de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
9815de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
9825de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
9835de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
9845de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
9855de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
9865de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
9875de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
9885de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
9895de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
9905de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
9915de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
9925de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
9935de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
9945de35c9bSChiranjeevi Rapolu 	{0x366e, 0x10},
9955de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
9965de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
9975de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
9985de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
9995de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
10005de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
10015de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
10025de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
10035de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
10045de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
10055de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
10065de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
10075de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
10085de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
10095de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
10105de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
10115de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
10125de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
10135de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
10145de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
10155de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
10165de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
10175de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
10185de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
10195de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
10205de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
10215de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
10225de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
10235de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
10245de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
10255de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
10265de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
10275de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
10285de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
10295de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
10305de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
10315de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
10325de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
10335de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
10345de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
10355de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
10365de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
10375de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
10385de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
10395de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
10405de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
10415de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
10425de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
10435de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
10445de35c9bSChiranjeevi Rapolu 	{0x3808, 0x0a},
10455de35c9bSChiranjeevi Rapolu 	{0x3809, 0x00},
10465de35c9bSChiranjeevi Rapolu 	{0x380a, 0x05},
10475de35c9bSChiranjeevi Rapolu 	{0x380b, 0xa0},
10485de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
10495de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
10505de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
10515de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
10525de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
10535de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
10545de35c9bSChiranjeevi Rapolu 	{0x3814, 0x01},
10555de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
10565de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
10575de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
10585de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
10595de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
10605de35c9bSChiranjeevi Rapolu 	{0x3820, 0x84},
10615de35c9bSChiranjeevi Rapolu 	{0x3821, 0x46},
10625de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
10635de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
10645de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
10655de35c9bSChiranjeevi Rapolu 	{0x382a, 0x01},
10665de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
10675de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
10685de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
10695de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
10705de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
10715de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
10725de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
10735de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
10745de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
10755de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
10765de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
10775de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
10785de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
10795de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
10805de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
10815de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
10825de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
10835de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
10845de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
10855de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
10865de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
10875de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
10885de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
10895de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
10905de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
10915de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
10925de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
10935de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
10945de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
10955de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
10965de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
10975de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
10985de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
10995de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
11005de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
11015de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
11025de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
11035de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
11045de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
11055de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
11065de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
11075de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
11085de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
11095de35c9bSChiranjeevi Rapolu 	{0x4009, 0x0d},
11105de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
11115de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
11125de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
11135de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
11145de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
11155de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
11165de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
11175de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
11185de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
11195de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
11205de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
11215de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
11225de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
11235de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
11245de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
11255de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
11265de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
11275de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
11285de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
11295de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
11305de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
11315de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
11325de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
11335de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
11345de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
11355de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
11365de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
11375de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
11385de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
11395de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
11405de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
11415de35c9bSChiranjeevi Rapolu 	{0x4508, 0xaa},
11425de35c9bSChiranjeevi Rapolu 	{0x4509, 0xaa},
11435de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
11445de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
11455de35c9bSChiranjeevi Rapolu 	{0x4600, 0x01},
11465de35c9bSChiranjeevi Rapolu 	{0x4601, 0x00},
11475de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
11485de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
11495de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
11505de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
11515de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
11525de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
11535de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
11545de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
11555de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
11565de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
11575de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
11585de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
11595de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
11605de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
11615de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
11625de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
11635de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
11645de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
11655de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
11665de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
11675de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
11685de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
11695de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
11705de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
11715de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
11725de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
11735de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
11745de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
11755de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
11765de35c9bSChiranjeevi Rapolu 	{0x4017, 0x08},
11775de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
11785de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
11795de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
11805de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
11815de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
11825de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
11835de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
11845de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
11855de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
11865de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
11875de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
11885de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
11895de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
11905de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
11915de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
11925de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
11935de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
11945de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
11955de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
11965de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
11975de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
119899cd1242SChiranjeevi Rapolu 	{0x5794, 0xa3},
119999cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
120099cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
120199cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
12025de35c9bSChiranjeevi Rapolu };
12035de35c9bSChiranjeevi Rapolu 
12045de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_1280x720_regs[] = {
12055de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
12065de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
12075de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
12085de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
12095de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
12105de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
12115de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
12125de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
12135de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
12145de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
12155de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
12165de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
12175de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
12185de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
12195de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
12205de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
12215de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
12225de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
12235de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
12245de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
12255de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
12265de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
12275de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
12285de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
12295de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
12305de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
12315de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
12325de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
12335de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
12345de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
12355de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
12365de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
12375de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
12385de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
12395de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
12405de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
12415de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
12425de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
12435de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
12445de35c9bSChiranjeevi Rapolu 	{0x3623, 0x00},
12455de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
12465de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
12475de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
12485de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
12495de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
12505de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
12515de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
12525de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
12535de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
12545de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
12555de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
12565de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
12575de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
12585de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
12595de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
12605de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
12615de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
12625de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
12635de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
12645de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
12655de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
12665de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
12675de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
12685de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
12695de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
12705de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
12715de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
12725de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
12735de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
12745de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
12755de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
12765de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
12775de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
12785de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
12795de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
12805de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
12815de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
12825de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
12835de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
12845de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
12855de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
12865de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
12875de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
12885de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
12895de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
12905de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
12915de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
12925de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
12935de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
12945de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
12955de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
12965de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
12975de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
12985de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
12995de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
13005de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
13015de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
13025de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
13035de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
13045de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
13055de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
13065de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
13075de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
13085de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
13095de35c9bSChiranjeevi Rapolu 	{0x3808, 0x05},
13105de35c9bSChiranjeevi Rapolu 	{0x3809, 0x00},
13115de35c9bSChiranjeevi Rapolu 	{0x380a, 0x02},
13125de35c9bSChiranjeevi Rapolu 	{0x380b, 0xd0},
13135de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
13145de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
13155de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
13165de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
13175de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
13185de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
13195de35c9bSChiranjeevi Rapolu 	{0x3814, 0x03},
13205de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
13215de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
13225de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
13235de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
13245de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
13255de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
13265de35c9bSChiranjeevi Rapolu 	{0x3821, 0x47},
13275de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
13285de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
13295de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
13305de35c9bSChiranjeevi Rapolu 	{0x382a, 0x03},
13315de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
13325de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
13335de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
13345de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
13355de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
13365de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
13375de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
13385de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
13395de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
13405de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
13415de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
13425de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
13435de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
13445de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
13455de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
13465de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
13475de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
13485de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
13495de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
13505de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
13515de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
13525de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
13535de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
13545de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
13555de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
13565de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
13575de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
13585de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
13595de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
13605de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
13615de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
13625de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
13635de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
13645de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
13655de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
13665de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
13675de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
13685de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
13695de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
13705de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
13715de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
13725de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
13735de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
13745de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
13755de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
13765de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
13775de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
13785de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
13795de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
13805de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
13815de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
13825de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
13835de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
13845de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
13855de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
13865de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
13875de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
13885de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
13895de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
13905de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
13915de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
13925de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
13935de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
13945de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
13955de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
13965de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
13975de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
13985de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
13995de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
14005de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
14015de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
14025de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
14035de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
14045de35c9bSChiranjeevi Rapolu 	{0x4502, 0x48},
14055de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
14065de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
14075de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
14085de35c9bSChiranjeevi Rapolu 	{0x450a, 0x00},
14095de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
14105de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
14115de35c9bSChiranjeevi Rapolu 	{0x4601, 0x80},
14125de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
14135de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
14145de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
14155de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
14165de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
14175de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
14185de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
14195de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
14205de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
14215de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
14225de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
14235de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
14245de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
14255de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
14265de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
14275de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
14285de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
14295de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
14305de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
14315de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
14325de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
14335de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
14345de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
14355de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
14365de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
14375de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
14385de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
14395de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
14405de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
14415de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
14425de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
14435de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
14445de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
14455de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
14465de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
14475de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
14485de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
14495de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
14505de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
14515de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
14525de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
14535de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
14545de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
14555de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
14565de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
14575de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
14585de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
14595de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
14605de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
14615de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
14625de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
14635de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
146499cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
146599cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
146699cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
146799cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
14685de35c9bSChiranjeevi Rapolu };
14695de35c9bSChiranjeevi Rapolu 
14705de35c9bSChiranjeevi Rapolu static const struct ov5670_reg mode_640x360_regs[] = {
14715de35c9bSChiranjeevi Rapolu 	{0x3000, 0x00},
14725de35c9bSChiranjeevi Rapolu 	{0x3002, 0x21},
14735de35c9bSChiranjeevi Rapolu 	{0x3005, 0xf0},
14745de35c9bSChiranjeevi Rapolu 	{0x3007, 0x00},
14755de35c9bSChiranjeevi Rapolu 	{0x3015, 0x0f},
14765de35c9bSChiranjeevi Rapolu 	{0x3018, 0x32},
14775de35c9bSChiranjeevi Rapolu 	{0x301a, 0xf0},
14785de35c9bSChiranjeevi Rapolu 	{0x301b, 0xf0},
14795de35c9bSChiranjeevi Rapolu 	{0x301c, 0xf0},
14805de35c9bSChiranjeevi Rapolu 	{0x301d, 0xf0},
14815de35c9bSChiranjeevi Rapolu 	{0x301e, 0xf0},
14825de35c9bSChiranjeevi Rapolu 	{0x3030, 0x00},
14835de35c9bSChiranjeevi Rapolu 	{0x3031, 0x0a},
14845de35c9bSChiranjeevi Rapolu 	{0x303c, 0xff},
14855de35c9bSChiranjeevi Rapolu 	{0x303e, 0xff},
14865de35c9bSChiranjeevi Rapolu 	{0x3040, 0xf0},
14875de35c9bSChiranjeevi Rapolu 	{0x3041, 0x00},
14885de35c9bSChiranjeevi Rapolu 	{0x3042, 0xf0},
14895de35c9bSChiranjeevi Rapolu 	{0x3106, 0x11},
14905de35c9bSChiranjeevi Rapolu 	{0x3500, 0x00},
14915de35c9bSChiranjeevi Rapolu 	{0x3501, 0x80},
14925de35c9bSChiranjeevi Rapolu 	{0x3502, 0x00},
14935de35c9bSChiranjeevi Rapolu 	{0x3503, 0x04},
14945de35c9bSChiranjeevi Rapolu 	{0x3504, 0x03},
14955de35c9bSChiranjeevi Rapolu 	{0x3505, 0x83},
14965de35c9bSChiranjeevi Rapolu 	{0x3508, 0x04},
14975de35c9bSChiranjeevi Rapolu 	{0x3509, 0x00},
14985de35c9bSChiranjeevi Rapolu 	{0x350e, 0x04},
14995de35c9bSChiranjeevi Rapolu 	{0x350f, 0x00},
15005de35c9bSChiranjeevi Rapolu 	{0x3510, 0x00},
15015de35c9bSChiranjeevi Rapolu 	{0x3511, 0x02},
15025de35c9bSChiranjeevi Rapolu 	{0x3512, 0x00},
15035de35c9bSChiranjeevi Rapolu 	{0x3601, 0xc8},
15045de35c9bSChiranjeevi Rapolu 	{0x3610, 0x88},
15055de35c9bSChiranjeevi Rapolu 	{0x3612, 0x48},
15065de35c9bSChiranjeevi Rapolu 	{0x3614, 0x5b},
15075de35c9bSChiranjeevi Rapolu 	{0x3615, 0x96},
15085de35c9bSChiranjeevi Rapolu 	{0x3621, 0xd0},
15095de35c9bSChiranjeevi Rapolu 	{0x3622, 0x00},
15105de35c9bSChiranjeevi Rapolu 	{0x3623, 0x04},
15115de35c9bSChiranjeevi Rapolu 	{0x3633, 0x13},
15125de35c9bSChiranjeevi Rapolu 	{0x3634, 0x13},
15135de35c9bSChiranjeevi Rapolu 	{0x3635, 0x13},
15145de35c9bSChiranjeevi Rapolu 	{0x3636, 0x13},
15155de35c9bSChiranjeevi Rapolu 	{0x3645, 0x13},
15165de35c9bSChiranjeevi Rapolu 	{0x3646, 0x82},
15175de35c9bSChiranjeevi Rapolu 	{0x3650, 0x00},
15185de35c9bSChiranjeevi Rapolu 	{0x3652, 0xff},
15195de35c9bSChiranjeevi Rapolu 	{0x3655, 0x20},
15205de35c9bSChiranjeevi Rapolu 	{0x3656, 0xff},
15215de35c9bSChiranjeevi Rapolu 	{0x365a, 0xff},
15225de35c9bSChiranjeevi Rapolu 	{0x365e, 0xff},
15235de35c9bSChiranjeevi Rapolu 	{0x3668, 0x00},
15245de35c9bSChiranjeevi Rapolu 	{0x366a, 0x07},
15255de35c9bSChiranjeevi Rapolu 	{0x366e, 0x08},
15265de35c9bSChiranjeevi Rapolu 	{0x366d, 0x00},
15275de35c9bSChiranjeevi Rapolu 	{0x366f, 0x80},
15285de35c9bSChiranjeevi Rapolu 	{0x3700, 0x28},
15295de35c9bSChiranjeevi Rapolu 	{0x3701, 0x10},
15305de35c9bSChiranjeevi Rapolu 	{0x3702, 0x3a},
15315de35c9bSChiranjeevi Rapolu 	{0x3703, 0x19},
15325de35c9bSChiranjeevi Rapolu 	{0x3704, 0x10},
15335de35c9bSChiranjeevi Rapolu 	{0x3705, 0x00},
15345de35c9bSChiranjeevi Rapolu 	{0x3706, 0x66},
15355de35c9bSChiranjeevi Rapolu 	{0x3707, 0x08},
15365de35c9bSChiranjeevi Rapolu 	{0x3708, 0x34},
15375de35c9bSChiranjeevi Rapolu 	{0x3709, 0x40},
15385de35c9bSChiranjeevi Rapolu 	{0x370a, 0x01},
15395de35c9bSChiranjeevi Rapolu 	{0x370b, 0x1b},
15405de35c9bSChiranjeevi Rapolu 	{0x3714, 0x24},
15415de35c9bSChiranjeevi Rapolu 	{0x371a, 0x3e},
15425de35c9bSChiranjeevi Rapolu 	{0x3733, 0x00},
15435de35c9bSChiranjeevi Rapolu 	{0x3734, 0x00},
15445de35c9bSChiranjeevi Rapolu 	{0x373a, 0x05},
15455de35c9bSChiranjeevi Rapolu 	{0x373b, 0x06},
15465de35c9bSChiranjeevi Rapolu 	{0x373c, 0x0a},
15475de35c9bSChiranjeevi Rapolu 	{0x373f, 0xa0},
15485de35c9bSChiranjeevi Rapolu 	{0x3755, 0x00},
15495de35c9bSChiranjeevi Rapolu 	{0x3758, 0x00},
15505de35c9bSChiranjeevi Rapolu 	{0x375b, 0x0e},
15515de35c9bSChiranjeevi Rapolu 	{0x3766, 0x5f},
15525de35c9bSChiranjeevi Rapolu 	{0x3768, 0x00},
15535de35c9bSChiranjeevi Rapolu 	{0x3769, 0x22},
15545de35c9bSChiranjeevi Rapolu 	{0x3773, 0x08},
15555de35c9bSChiranjeevi Rapolu 	{0x3774, 0x1f},
15565de35c9bSChiranjeevi Rapolu 	{0x3776, 0x06},
15575de35c9bSChiranjeevi Rapolu 	{0x37a0, 0x88},
15585de35c9bSChiranjeevi Rapolu 	{0x37a1, 0x5c},
15595de35c9bSChiranjeevi Rapolu 	{0x37a7, 0x88},
15605de35c9bSChiranjeevi Rapolu 	{0x37a8, 0x70},
15615de35c9bSChiranjeevi Rapolu 	{0x37aa, 0x88},
15625de35c9bSChiranjeevi Rapolu 	{0x37ab, 0x48},
15635de35c9bSChiranjeevi Rapolu 	{0x37b3, 0x66},
15645de35c9bSChiranjeevi Rapolu 	{0x37c2, 0x04},
15655de35c9bSChiranjeevi Rapolu 	{0x37c5, 0x00},
15665de35c9bSChiranjeevi Rapolu 	{0x37c8, 0x00},
15675de35c9bSChiranjeevi Rapolu 	{0x3800, 0x00},
15685de35c9bSChiranjeevi Rapolu 	{0x3801, 0x0c},
15695de35c9bSChiranjeevi Rapolu 	{0x3802, 0x00},
15705de35c9bSChiranjeevi Rapolu 	{0x3803, 0x04},
15715de35c9bSChiranjeevi Rapolu 	{0x3804, 0x0a},
15725de35c9bSChiranjeevi Rapolu 	{0x3805, 0x33},
15735de35c9bSChiranjeevi Rapolu 	{0x3806, 0x07},
15745de35c9bSChiranjeevi Rapolu 	{0x3807, 0xa3},
15755de35c9bSChiranjeevi Rapolu 	{0x3808, 0x02},
15765de35c9bSChiranjeevi Rapolu 	{0x3809, 0x80},
15775de35c9bSChiranjeevi Rapolu 	{0x380a, 0x01},
15785de35c9bSChiranjeevi Rapolu 	{0x380b, 0x68},
15795de35c9bSChiranjeevi Rapolu 	{0x380c, 0x06},
15805de35c9bSChiranjeevi Rapolu 	{0x380d, 0x90},
15815de35c9bSChiranjeevi Rapolu 	{0x380e, 0x08},
15825de35c9bSChiranjeevi Rapolu 	{0x380f, 0x08},
15835de35c9bSChiranjeevi Rapolu 	{0x3811, 0x04},
15845de35c9bSChiranjeevi Rapolu 	{0x3813, 0x02},
15855de35c9bSChiranjeevi Rapolu 	{0x3814, 0x07},
15865de35c9bSChiranjeevi Rapolu 	{0x3815, 0x01},
15875de35c9bSChiranjeevi Rapolu 	{0x3816, 0x00},
15885de35c9bSChiranjeevi Rapolu 	{0x3817, 0x00},
15895de35c9bSChiranjeevi Rapolu 	{0x3818, 0x00},
15905de35c9bSChiranjeevi Rapolu 	{0x3819, 0x00},
15915de35c9bSChiranjeevi Rapolu 	{0x3820, 0x94},
15925de35c9bSChiranjeevi Rapolu 	{0x3821, 0xc6},
15935de35c9bSChiranjeevi Rapolu 	{0x3822, 0x48},
15945de35c9bSChiranjeevi Rapolu 	{0x3826, 0x00},
15955de35c9bSChiranjeevi Rapolu 	{0x3827, 0x08},
15965de35c9bSChiranjeevi Rapolu 	{0x382a, 0x07},
15975de35c9bSChiranjeevi Rapolu 	{0x382b, 0x01},
15985de35c9bSChiranjeevi Rapolu 	{0x3830, 0x08},
15995de35c9bSChiranjeevi Rapolu 	{0x3836, 0x02},
16005de35c9bSChiranjeevi Rapolu 	{0x3837, 0x00},
16015de35c9bSChiranjeevi Rapolu 	{0x3838, 0x10},
16025de35c9bSChiranjeevi Rapolu 	{0x3841, 0xff},
16035de35c9bSChiranjeevi Rapolu 	{0x3846, 0x48},
16045de35c9bSChiranjeevi Rapolu 	{0x3861, 0x00},
16055de35c9bSChiranjeevi Rapolu 	{0x3862, 0x04},
16065de35c9bSChiranjeevi Rapolu 	{0x3863, 0x06},
16075de35c9bSChiranjeevi Rapolu 	{0x3a11, 0x01},
16085de35c9bSChiranjeevi Rapolu 	{0x3a12, 0x78},
16095de35c9bSChiranjeevi Rapolu 	{0x3b00, 0x00},
16105de35c9bSChiranjeevi Rapolu 	{0x3b02, 0x00},
16115de35c9bSChiranjeevi Rapolu 	{0x3b03, 0x00},
16125de35c9bSChiranjeevi Rapolu 	{0x3b04, 0x00},
16135de35c9bSChiranjeevi Rapolu 	{0x3b05, 0x00},
16145de35c9bSChiranjeevi Rapolu 	{0x3c00, 0x89},
16155de35c9bSChiranjeevi Rapolu 	{0x3c01, 0xab},
16165de35c9bSChiranjeevi Rapolu 	{0x3c02, 0x01},
16175de35c9bSChiranjeevi Rapolu 	{0x3c03, 0x00},
16185de35c9bSChiranjeevi Rapolu 	{0x3c04, 0x00},
16195de35c9bSChiranjeevi Rapolu 	{0x3c05, 0x03},
16205de35c9bSChiranjeevi Rapolu 	{0x3c06, 0x00},
16215de35c9bSChiranjeevi Rapolu 	{0x3c07, 0x05},
16225de35c9bSChiranjeevi Rapolu 	{0x3c0c, 0x00},
16235de35c9bSChiranjeevi Rapolu 	{0x3c0d, 0x00},
16245de35c9bSChiranjeevi Rapolu 	{0x3c0e, 0x00},
16255de35c9bSChiranjeevi Rapolu 	{0x3c0f, 0x00},
16265de35c9bSChiranjeevi Rapolu 	{0x3c40, 0x00},
16275de35c9bSChiranjeevi Rapolu 	{0x3c41, 0xa3},
16285de35c9bSChiranjeevi Rapolu 	{0x3c43, 0x7d},
16295de35c9bSChiranjeevi Rapolu 	{0x3c45, 0xd7},
16305de35c9bSChiranjeevi Rapolu 	{0x3c47, 0xfc},
16315de35c9bSChiranjeevi Rapolu 	{0x3c50, 0x05},
16325de35c9bSChiranjeevi Rapolu 	{0x3c52, 0xaa},
16335de35c9bSChiranjeevi Rapolu 	{0x3c54, 0x71},
16345de35c9bSChiranjeevi Rapolu 	{0x3c56, 0x80},
16355de35c9bSChiranjeevi Rapolu 	{0x3d85, 0x17},
16365de35c9bSChiranjeevi Rapolu 	{0x3f03, 0x00},
16375de35c9bSChiranjeevi Rapolu 	{0x3f0a, 0x00},
16385de35c9bSChiranjeevi Rapolu 	{0x3f0b, 0x00},
16395de35c9bSChiranjeevi Rapolu 	{0x4001, 0x60},
16405de35c9bSChiranjeevi Rapolu 	{0x4009, 0x05},
16415de35c9bSChiranjeevi Rapolu 	{0x4020, 0x00},
16425de35c9bSChiranjeevi Rapolu 	{0x4021, 0x00},
16435de35c9bSChiranjeevi Rapolu 	{0x4022, 0x00},
16445de35c9bSChiranjeevi Rapolu 	{0x4023, 0x00},
16455de35c9bSChiranjeevi Rapolu 	{0x4024, 0x00},
16465de35c9bSChiranjeevi Rapolu 	{0x4025, 0x00},
16475de35c9bSChiranjeevi Rapolu 	{0x4026, 0x00},
16485de35c9bSChiranjeevi Rapolu 	{0x4027, 0x00},
16495de35c9bSChiranjeevi Rapolu 	{0x4028, 0x00},
16505de35c9bSChiranjeevi Rapolu 	{0x4029, 0x00},
16515de35c9bSChiranjeevi Rapolu 	{0x402a, 0x00},
16525de35c9bSChiranjeevi Rapolu 	{0x402b, 0x00},
16535de35c9bSChiranjeevi Rapolu 	{0x402c, 0x00},
16545de35c9bSChiranjeevi Rapolu 	{0x402d, 0x00},
16555de35c9bSChiranjeevi Rapolu 	{0x402e, 0x00},
16565de35c9bSChiranjeevi Rapolu 	{0x402f, 0x00},
16575de35c9bSChiranjeevi Rapolu 	{0x4040, 0x00},
16585de35c9bSChiranjeevi Rapolu 	{0x4041, 0x03},
16595de35c9bSChiranjeevi Rapolu 	{0x4042, 0x00},
16605de35c9bSChiranjeevi Rapolu 	{0x4043, 0x7A},
16615de35c9bSChiranjeevi Rapolu 	{0x4044, 0x00},
16625de35c9bSChiranjeevi Rapolu 	{0x4045, 0x7A},
16635de35c9bSChiranjeevi Rapolu 	{0x4046, 0x00},
16645de35c9bSChiranjeevi Rapolu 	{0x4047, 0x7A},
16655de35c9bSChiranjeevi Rapolu 	{0x4048, 0x00},
16665de35c9bSChiranjeevi Rapolu 	{0x4049, 0x7A},
16675de35c9bSChiranjeevi Rapolu 	{0x4307, 0x30},
16685de35c9bSChiranjeevi Rapolu 	{0x4500, 0x58},
16695de35c9bSChiranjeevi Rapolu 	{0x4501, 0x04},
16705de35c9bSChiranjeevi Rapolu 	{0x4502, 0x40},
16715de35c9bSChiranjeevi Rapolu 	{0x4503, 0x10},
16725de35c9bSChiranjeevi Rapolu 	{0x4508, 0x55},
16735de35c9bSChiranjeevi Rapolu 	{0x4509, 0x55},
16745de35c9bSChiranjeevi Rapolu 	{0x450a, 0x02},
16755de35c9bSChiranjeevi Rapolu 	{0x450b, 0x00},
16765de35c9bSChiranjeevi Rapolu 	{0x4600, 0x00},
16775de35c9bSChiranjeevi Rapolu 	{0x4601, 0x40},
16785de35c9bSChiranjeevi Rapolu 	{0x4700, 0xa4},
16795de35c9bSChiranjeevi Rapolu 	{0x4800, 0x4c},
16805de35c9bSChiranjeevi Rapolu 	{0x4816, 0x53},
16815de35c9bSChiranjeevi Rapolu 	{0x481f, 0x40},
16825de35c9bSChiranjeevi Rapolu 	{0x4837, 0x13},
16835de35c9bSChiranjeevi Rapolu 	{0x5000, 0x56},
16845de35c9bSChiranjeevi Rapolu 	{0x5001, 0x01},
16855de35c9bSChiranjeevi Rapolu 	{0x5002, 0x28},
16865de35c9bSChiranjeevi Rapolu 	{0x5004, 0x0c},
16875de35c9bSChiranjeevi Rapolu 	{0x5006, 0x0c},
16885de35c9bSChiranjeevi Rapolu 	{0x5007, 0xe0},
16895de35c9bSChiranjeevi Rapolu 	{0x5008, 0x01},
16905de35c9bSChiranjeevi Rapolu 	{0x5009, 0xb0},
16915de35c9bSChiranjeevi Rapolu 	{0x5901, 0x00},
16925de35c9bSChiranjeevi Rapolu 	{0x5a01, 0x00},
16935de35c9bSChiranjeevi Rapolu 	{0x5a03, 0x00},
16945de35c9bSChiranjeevi Rapolu 	{0x5a04, 0x0c},
16955de35c9bSChiranjeevi Rapolu 	{0x5a05, 0xe0},
16965de35c9bSChiranjeevi Rapolu 	{0x5a06, 0x09},
16975de35c9bSChiranjeevi Rapolu 	{0x5a07, 0xb0},
16985de35c9bSChiranjeevi Rapolu 	{0x5a08, 0x06},
16995de35c9bSChiranjeevi Rapolu 	{0x5e00, 0x00},
17005de35c9bSChiranjeevi Rapolu 	{0x3734, 0x40},
17015de35c9bSChiranjeevi Rapolu 	{0x5b00, 0x01},
17025de35c9bSChiranjeevi Rapolu 	{0x5b01, 0x10},
17035de35c9bSChiranjeevi Rapolu 	{0x5b02, 0x01},
17045de35c9bSChiranjeevi Rapolu 	{0x5b03, 0xdb},
17055de35c9bSChiranjeevi Rapolu 	{0x3d8c, 0x71},
17065de35c9bSChiranjeevi Rapolu 	{0x3d8d, 0xea},
17075de35c9bSChiranjeevi Rapolu 	{0x4017, 0x10},
17085de35c9bSChiranjeevi Rapolu 	{0x3618, 0x2a},
17095de35c9bSChiranjeevi Rapolu 	{0x5780, 0x3e},
17105de35c9bSChiranjeevi Rapolu 	{0x5781, 0x0f},
17115de35c9bSChiranjeevi Rapolu 	{0x5782, 0x44},
17125de35c9bSChiranjeevi Rapolu 	{0x5783, 0x02},
17135de35c9bSChiranjeevi Rapolu 	{0x5784, 0x01},
17145de35c9bSChiranjeevi Rapolu 	{0x5785, 0x01},
17155de35c9bSChiranjeevi Rapolu 	{0x5786, 0x00},
17165de35c9bSChiranjeevi Rapolu 	{0x5787, 0x04},
17175de35c9bSChiranjeevi Rapolu 	{0x5788, 0x02},
17185de35c9bSChiranjeevi Rapolu 	{0x5789, 0x0f},
17195de35c9bSChiranjeevi Rapolu 	{0x578a, 0xfd},
17205de35c9bSChiranjeevi Rapolu 	{0x578b, 0xf5},
17215de35c9bSChiranjeevi Rapolu 	{0x578c, 0xf5},
17225de35c9bSChiranjeevi Rapolu 	{0x578d, 0x03},
17235de35c9bSChiranjeevi Rapolu 	{0x578e, 0x08},
17245de35c9bSChiranjeevi Rapolu 	{0x578f, 0x0c},
17255de35c9bSChiranjeevi Rapolu 	{0x5790, 0x08},
17265de35c9bSChiranjeevi Rapolu 	{0x5791, 0x06},
17275de35c9bSChiranjeevi Rapolu 	{0x5792, 0x00},
17285de35c9bSChiranjeevi Rapolu 	{0x5793, 0x52},
17295de35c9bSChiranjeevi Rapolu 	{0x5794, 0xa3},
173099cd1242SChiranjeevi Rapolu 	{0x3503, 0x00},
173199cd1242SChiranjeevi Rapolu 	{0x5045, 0x05},
173299cd1242SChiranjeevi Rapolu 	{0x4003, 0x40},
173399cd1242SChiranjeevi Rapolu 	{0x5048, 0x40}
17345de35c9bSChiranjeevi Rapolu };
17355de35c9bSChiranjeevi Rapolu 
17365de35c9bSChiranjeevi Rapolu static const char * const ov5670_test_pattern_menu[] = {
17375de35c9bSChiranjeevi Rapolu 	"Disabled",
17385de35c9bSChiranjeevi Rapolu 	"Vertical Color Bar Type 1",
17395de35c9bSChiranjeevi Rapolu };
17405de35c9bSChiranjeevi Rapolu 
17415de35c9bSChiranjeevi Rapolu /* Supported link frequencies */
1742f1425381SChiranjeevi Rapolu #define OV5670_LINK_FREQ_422MHZ		422400000
1743f1425381SChiranjeevi Rapolu #define OV5670_LINK_FREQ_422MHZ_INDEX	0
17445de35c9bSChiranjeevi Rapolu static const struct ov5670_link_freq_config link_freq_configs[] = {
17455de35c9bSChiranjeevi Rapolu 	{
17465de35c9bSChiranjeevi Rapolu 		/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
1747f1425381SChiranjeevi Rapolu 		.pixel_rate = (OV5670_LINK_FREQ_422MHZ * 2 * 2) / 10,
17485de35c9bSChiranjeevi Rapolu 		.reg_list = {
17495de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mipi_data_rate_840mbps),
17505de35c9bSChiranjeevi Rapolu 			.regs = mipi_data_rate_840mbps,
17515de35c9bSChiranjeevi Rapolu 		}
17525de35c9bSChiranjeevi Rapolu 	}
17535de35c9bSChiranjeevi Rapolu };
17545de35c9bSChiranjeevi Rapolu 
17555de35c9bSChiranjeevi Rapolu static const s64 link_freq_menu_items[] = {
1756f1425381SChiranjeevi Rapolu 	OV5670_LINK_FREQ_422MHZ
17575de35c9bSChiranjeevi Rapolu };
17585de35c9bSChiranjeevi Rapolu 
17595de35c9bSChiranjeevi Rapolu /*
17605de35c9bSChiranjeevi Rapolu  * OV5670 sensor supports following resolutions with full FOV:
17615de35c9bSChiranjeevi Rapolu  * 4:3  ==> {2592x1944, 1296x972, 648x486}
17625de35c9bSChiranjeevi Rapolu  * 16:9 ==> {2560x1440, 1280x720, 640x360}
17635de35c9bSChiranjeevi Rapolu  */
17645de35c9bSChiranjeevi Rapolu static const struct ov5670_mode supported_modes[] = {
17655de35c9bSChiranjeevi Rapolu 	{
17665de35c9bSChiranjeevi Rapolu 		.width = 2592,
17675de35c9bSChiranjeevi Rapolu 		.height = 1944,
1768ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1769ed351ad9SChiranjeevi Rapolu 		.vts_min = OV5670_VTS_30FPS,
17705de35c9bSChiranjeevi Rapolu 		.reg_list = {
17715de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_2592x1944_regs),
17725de35c9bSChiranjeevi Rapolu 			.regs = mode_2592x1944_regs,
17735de35c9bSChiranjeevi Rapolu 		},
1774f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
17755de35c9bSChiranjeevi Rapolu 	},
17765de35c9bSChiranjeevi Rapolu 	{
17775de35c9bSChiranjeevi Rapolu 		.width = 1296,
17785de35c9bSChiranjeevi Rapolu 		.height = 972,
1779ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1780ed351ad9SChiranjeevi Rapolu 		.vts_min = 996,
17815de35c9bSChiranjeevi Rapolu 		.reg_list = {
17825de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_1296x972_regs),
17835de35c9bSChiranjeevi Rapolu 			.regs = mode_1296x972_regs,
17845de35c9bSChiranjeevi Rapolu 		},
1785f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
17865de35c9bSChiranjeevi Rapolu 	},
17875de35c9bSChiranjeevi Rapolu 	{
17885de35c9bSChiranjeevi Rapolu 		.width = 648,
17895de35c9bSChiranjeevi Rapolu 		.height = 486,
1790ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1791ed351ad9SChiranjeevi Rapolu 		.vts_min = 516,
17925de35c9bSChiranjeevi Rapolu 		.reg_list = {
17935de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_648x486_regs),
17945de35c9bSChiranjeevi Rapolu 			.regs = mode_648x486_regs,
17955de35c9bSChiranjeevi Rapolu 		},
1796f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
17975de35c9bSChiranjeevi Rapolu 	},
17985de35c9bSChiranjeevi Rapolu 	{
17995de35c9bSChiranjeevi Rapolu 		.width = 2560,
18005de35c9bSChiranjeevi Rapolu 		.height = 1440,
1801ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1802ed351ad9SChiranjeevi Rapolu 		.vts_min = OV5670_VTS_30FPS,
18035de35c9bSChiranjeevi Rapolu 		.reg_list = {
18045de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_2560x1440_regs),
18055de35c9bSChiranjeevi Rapolu 			.regs = mode_2560x1440_regs,
18065de35c9bSChiranjeevi Rapolu 		},
1807f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18085de35c9bSChiranjeevi Rapolu 	},
18095de35c9bSChiranjeevi Rapolu 	{
18105de35c9bSChiranjeevi Rapolu 		.width = 1280,
18115de35c9bSChiranjeevi Rapolu 		.height = 720,
1812ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1813ed351ad9SChiranjeevi Rapolu 		.vts_min = 1020,
18145de35c9bSChiranjeevi Rapolu 		.reg_list = {
18155de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
18165de35c9bSChiranjeevi Rapolu 			.regs = mode_1280x720_regs,
18175de35c9bSChiranjeevi Rapolu 		},
1818f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18195de35c9bSChiranjeevi Rapolu 	},
18205de35c9bSChiranjeevi Rapolu 	{
18215de35c9bSChiranjeevi Rapolu 		.width = 640,
18225de35c9bSChiranjeevi Rapolu 		.height = 360,
1823ed351ad9SChiranjeevi Rapolu 		.vts_def = OV5670_VTS_30FPS,
1824ed351ad9SChiranjeevi Rapolu 		.vts_min = 510,
18255de35c9bSChiranjeevi Rapolu 		.reg_list = {
18265de35c9bSChiranjeevi Rapolu 			.num_of_regs = ARRAY_SIZE(mode_640x360_regs),
18275de35c9bSChiranjeevi Rapolu 			.regs = mode_640x360_regs,
18285de35c9bSChiranjeevi Rapolu 		},
1829f1425381SChiranjeevi Rapolu 		.link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
18305de35c9bSChiranjeevi Rapolu 	}
18315de35c9bSChiranjeevi Rapolu };
18325de35c9bSChiranjeevi Rapolu 
18335de35c9bSChiranjeevi Rapolu struct ov5670 {
18345de35c9bSChiranjeevi Rapolu 	struct v4l2_subdev sd;
18355de35c9bSChiranjeevi Rapolu 	struct media_pad pad;
18365de35c9bSChiranjeevi Rapolu 
18375de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl_handler ctrl_handler;
18385de35c9bSChiranjeevi Rapolu 	/* V4L2 Controls */
18395de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *link_freq;
18405de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *pixel_rate;
18415de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *vblank;
18425de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *hblank;
18435de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl *exposure;
18445de35c9bSChiranjeevi Rapolu 
18455de35c9bSChiranjeevi Rapolu 	/* Current mode */
18465de35c9bSChiranjeevi Rapolu 	const struct ov5670_mode *cur_mode;
18475de35c9bSChiranjeevi Rapolu 
18488004c91eSJacopo Mondi 	/* xvclk input clock */
18498004c91eSJacopo Mondi 	struct clk *xvclk;
18508004c91eSJacopo Mondi 
1851cf9ab879SJacopo Mondi 	/* Regulators */
1852cf9ab879SJacopo Mondi 	struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES];
1853cf9ab879SJacopo Mondi 
18540a844ab7SJacopo Mondi 	/* Power-down and reset gpios. */
18550a844ab7SJacopo Mondi 	struct gpio_desc *pwdn_gpio; /* PWDNB pin. */
18560a844ab7SJacopo Mondi 	struct gpio_desc *reset_gpio; /* XSHUTDOWN pin. */
18570a844ab7SJacopo Mondi 
18585de35c9bSChiranjeevi Rapolu 	/* To serialize asynchronus callbacks */
18595de35c9bSChiranjeevi Rapolu 	struct mutex mutex;
18605de35c9bSChiranjeevi Rapolu 
18615de35c9bSChiranjeevi Rapolu 	/* Streaming on/off */
18625de35c9bSChiranjeevi Rapolu 	bool streaming;
18631e583b56SSakari Ailus 	/* True if the device has been identified */
18641e583b56SSakari Ailus 	bool identified;
18655de35c9bSChiranjeevi Rapolu };
18665de35c9bSChiranjeevi Rapolu 
18675de35c9bSChiranjeevi Rapolu #define to_ov5670(_sd)	container_of(_sd, struct ov5670, sd)
18685de35c9bSChiranjeevi Rapolu 
18695de35c9bSChiranjeevi Rapolu /* Read registers up to 4 at a time */
18705de35c9bSChiranjeevi Rapolu static int ov5670_read_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
18715de35c9bSChiranjeevi Rapolu 			   u32 *val)
18725de35c9bSChiranjeevi Rapolu {
18735de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
18745de35c9bSChiranjeevi Rapolu 	struct i2c_msg msgs[2];
18755de35c9bSChiranjeevi Rapolu 	u8 *data_be_p;
1876baa6f19bSMauro Carvalho Chehab 	__be32 data_be = 0;
1877baa6f19bSMauro Carvalho Chehab 	__be16 reg_addr_be = cpu_to_be16(reg);
18785de35c9bSChiranjeevi Rapolu 	int ret;
18795de35c9bSChiranjeevi Rapolu 
18805de35c9bSChiranjeevi Rapolu 	if (len > 4)
18815de35c9bSChiranjeevi Rapolu 		return -EINVAL;
18825de35c9bSChiranjeevi Rapolu 
18835de35c9bSChiranjeevi Rapolu 	data_be_p = (u8 *)&data_be;
18845de35c9bSChiranjeevi Rapolu 	/* Write register address */
18855de35c9bSChiranjeevi Rapolu 	msgs[0].addr = client->addr;
18865de35c9bSChiranjeevi Rapolu 	msgs[0].flags = 0;
18875de35c9bSChiranjeevi Rapolu 	msgs[0].len = 2;
18885de35c9bSChiranjeevi Rapolu 	msgs[0].buf = (u8 *)&reg_addr_be;
18895de35c9bSChiranjeevi Rapolu 
18905de35c9bSChiranjeevi Rapolu 	/* Read data from register */
18915de35c9bSChiranjeevi Rapolu 	msgs[1].addr = client->addr;
18925de35c9bSChiranjeevi Rapolu 	msgs[1].flags = I2C_M_RD;
18935de35c9bSChiranjeevi Rapolu 	msgs[1].len = len;
18945de35c9bSChiranjeevi Rapolu 	msgs[1].buf = &data_be_p[4 - len];
18955de35c9bSChiranjeevi Rapolu 
18965de35c9bSChiranjeevi Rapolu 	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
18975de35c9bSChiranjeevi Rapolu 	if (ret != ARRAY_SIZE(msgs))
18985de35c9bSChiranjeevi Rapolu 		return -EIO;
18995de35c9bSChiranjeevi Rapolu 
19005de35c9bSChiranjeevi Rapolu 	*val = be32_to_cpu(data_be);
19015de35c9bSChiranjeevi Rapolu 
19025de35c9bSChiranjeevi Rapolu 	return 0;
19035de35c9bSChiranjeevi Rapolu }
19045de35c9bSChiranjeevi Rapolu 
19055de35c9bSChiranjeevi Rapolu /* Write registers up to 4 at a time */
19065de35c9bSChiranjeevi Rapolu static int ov5670_write_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
19075de35c9bSChiranjeevi Rapolu 			    u32 val)
19085de35c9bSChiranjeevi Rapolu {
19095de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
19105de35c9bSChiranjeevi Rapolu 	int buf_i;
19115de35c9bSChiranjeevi Rapolu 	int val_i;
19125de35c9bSChiranjeevi Rapolu 	u8 buf[6];
19135de35c9bSChiranjeevi Rapolu 	u8 *val_p;
1914baa6f19bSMauro Carvalho Chehab 	__be32 tmp;
19155de35c9bSChiranjeevi Rapolu 
19165de35c9bSChiranjeevi Rapolu 	if (len > 4)
19175de35c9bSChiranjeevi Rapolu 		return -EINVAL;
19185de35c9bSChiranjeevi Rapolu 
19195de35c9bSChiranjeevi Rapolu 	buf[0] = reg >> 8;
19205de35c9bSChiranjeevi Rapolu 	buf[1] = reg & 0xff;
19215de35c9bSChiranjeevi Rapolu 
1922baa6f19bSMauro Carvalho Chehab 	tmp = cpu_to_be32(val);
1923baa6f19bSMauro Carvalho Chehab 	val_p = (u8 *)&tmp;
19245de35c9bSChiranjeevi Rapolu 	buf_i = 2;
19255de35c9bSChiranjeevi Rapolu 	val_i = 4 - len;
19265de35c9bSChiranjeevi Rapolu 
19275de35c9bSChiranjeevi Rapolu 	while (val_i < 4)
19285de35c9bSChiranjeevi Rapolu 		buf[buf_i++] = val_p[val_i++];
19295de35c9bSChiranjeevi Rapolu 
19305de35c9bSChiranjeevi Rapolu 	if (i2c_master_send(client, buf, len + 2) != len + 2)
19315de35c9bSChiranjeevi Rapolu 		return -EIO;
19325de35c9bSChiranjeevi Rapolu 
19335de35c9bSChiranjeevi Rapolu 	return 0;
19345de35c9bSChiranjeevi Rapolu }
19355de35c9bSChiranjeevi Rapolu 
19365de35c9bSChiranjeevi Rapolu /* Write a list of registers */
19375de35c9bSChiranjeevi Rapolu static int ov5670_write_regs(struct ov5670 *ov5670,
19385de35c9bSChiranjeevi Rapolu 			     const struct ov5670_reg *regs, unsigned int len)
19395de35c9bSChiranjeevi Rapolu {
19405de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
19415de35c9bSChiranjeevi Rapolu 	unsigned int i;
19425de35c9bSChiranjeevi Rapolu 	int ret;
19435de35c9bSChiranjeevi Rapolu 
19445de35c9bSChiranjeevi Rapolu 	for (i = 0; i < len; i++) {
19455de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, regs[i].address, 1, regs[i].val);
19465de35c9bSChiranjeevi Rapolu 		if (ret) {
19475de35c9bSChiranjeevi Rapolu 			dev_err_ratelimited(
19485de35c9bSChiranjeevi Rapolu 				&client->dev,
19495de35c9bSChiranjeevi Rapolu 				"Failed to write reg 0x%4.4x. error = %d\n",
19505de35c9bSChiranjeevi Rapolu 				regs[i].address, ret);
19515de35c9bSChiranjeevi Rapolu 
19525de35c9bSChiranjeevi Rapolu 			return ret;
19535de35c9bSChiranjeevi Rapolu 		}
19545de35c9bSChiranjeevi Rapolu 	}
19555de35c9bSChiranjeevi Rapolu 
19565de35c9bSChiranjeevi Rapolu 	return 0;
19575de35c9bSChiranjeevi Rapolu }
19585de35c9bSChiranjeevi Rapolu 
19595de35c9bSChiranjeevi Rapolu static int ov5670_write_reg_list(struct ov5670 *ov5670,
19605de35c9bSChiranjeevi Rapolu 				 const struct ov5670_reg_list *r_list)
19615de35c9bSChiranjeevi Rapolu {
19625de35c9bSChiranjeevi Rapolu 	return ov5670_write_regs(ov5670, r_list->regs, r_list->num_of_regs);
19635de35c9bSChiranjeevi Rapolu }
19645de35c9bSChiranjeevi Rapolu 
19655de35c9bSChiranjeevi Rapolu static int ov5670_update_digital_gain(struct ov5670 *ov5670, u32 d_gain)
19665de35c9bSChiranjeevi Rapolu {
19675de35c9bSChiranjeevi Rapolu 	int ret;
19685de35c9bSChiranjeevi Rapolu 
19695de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_R_DGTL_GAIN,
19705de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_16BIT, d_gain);
19715de35c9bSChiranjeevi Rapolu 	if (ret)
19725de35c9bSChiranjeevi Rapolu 		return ret;
19735de35c9bSChiranjeevi Rapolu 
19745de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_G_DGTL_GAIN,
19755de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_16BIT, d_gain);
19765de35c9bSChiranjeevi Rapolu 	if (ret)
19775de35c9bSChiranjeevi Rapolu 		return ret;
19785de35c9bSChiranjeevi Rapolu 
19795de35c9bSChiranjeevi Rapolu 	return ov5670_write_reg(ov5670, OV5670_REG_B_DGTL_GAIN,
19805de35c9bSChiranjeevi Rapolu 				OV5670_REG_VALUE_16BIT, d_gain);
19815de35c9bSChiranjeevi Rapolu }
19825de35c9bSChiranjeevi Rapolu 
19835de35c9bSChiranjeevi Rapolu static int ov5670_enable_test_pattern(struct ov5670 *ov5670, u32 pattern)
19845de35c9bSChiranjeevi Rapolu {
19855de35c9bSChiranjeevi Rapolu 	u32 val;
19865de35c9bSChiranjeevi Rapolu 	int ret;
19875de35c9bSChiranjeevi Rapolu 
19885de35c9bSChiranjeevi Rapolu 	/* Set the bayer order that we support */
19895de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN_CTRL,
19905de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, 0);
19915de35c9bSChiranjeevi Rapolu 	if (ret)
19925de35c9bSChiranjeevi Rapolu 		return ret;
19935de35c9bSChiranjeevi Rapolu 
19945de35c9bSChiranjeevi Rapolu 	ret = ov5670_read_reg(ov5670, OV5670_REG_TEST_PATTERN,
19955de35c9bSChiranjeevi Rapolu 			      OV5670_REG_VALUE_08BIT, &val);
19965de35c9bSChiranjeevi Rapolu 	if (ret)
19975de35c9bSChiranjeevi Rapolu 		return ret;
19985de35c9bSChiranjeevi Rapolu 
19995de35c9bSChiranjeevi Rapolu 	if (pattern)
20005de35c9bSChiranjeevi Rapolu 		val |= OV5670_TEST_PATTERN_ENABLE;
20015de35c9bSChiranjeevi Rapolu 	else
20025de35c9bSChiranjeevi Rapolu 		val &= ~OV5670_TEST_PATTERN_ENABLE;
20035de35c9bSChiranjeevi Rapolu 
20045de35c9bSChiranjeevi Rapolu 	return ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN,
20055de35c9bSChiranjeevi Rapolu 				OV5670_REG_VALUE_08BIT, val);
20065de35c9bSChiranjeevi Rapolu }
20075de35c9bSChiranjeevi Rapolu 
20085de35c9bSChiranjeevi Rapolu /* Initialize control handlers */
20095de35c9bSChiranjeevi Rapolu static int ov5670_set_ctrl(struct v4l2_ctrl *ctrl)
20105de35c9bSChiranjeevi Rapolu {
20115de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = container_of(ctrl->handler,
20125de35c9bSChiranjeevi Rapolu 					     struct ov5670, ctrl_handler);
20135de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
20145de35c9bSChiranjeevi Rapolu 	s64 max;
20155de35c9bSChiranjeevi Rapolu 	int ret = 0;
20165de35c9bSChiranjeevi Rapolu 
20175de35c9bSChiranjeevi Rapolu 	/* Propagate change of current control to all related controls */
20185de35c9bSChiranjeevi Rapolu 	switch (ctrl->id) {
20195de35c9bSChiranjeevi Rapolu 	case V4L2_CID_VBLANK:
20205de35c9bSChiranjeevi Rapolu 		/* Update max exposure while meeting expected vblanking */
20215de35c9bSChiranjeevi Rapolu 		max = ov5670->cur_mode->height + ctrl->val - 8;
20225de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(ov5670->exposure,
20235de35c9bSChiranjeevi Rapolu 					 ov5670->exposure->minimum, max,
20245de35c9bSChiranjeevi Rapolu 					 ov5670->exposure->step, max);
20255de35c9bSChiranjeevi Rapolu 		break;
20265de35c9bSChiranjeevi Rapolu 	}
20275de35c9bSChiranjeevi Rapolu 
20285de35c9bSChiranjeevi Rapolu 	/* V4L2 controls values will be applied only when power is already up */
20294d471563SSakari Ailus 	if (!pm_runtime_get_if_in_use(&client->dev))
20305de35c9bSChiranjeevi Rapolu 		return 0;
20315de35c9bSChiranjeevi Rapolu 
20325de35c9bSChiranjeevi Rapolu 	switch (ctrl->id) {
20335de35c9bSChiranjeevi Rapolu 	case V4L2_CID_ANALOGUE_GAIN:
20345de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_ANALOG_GAIN,
20355de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_16BIT, ctrl->val);
20365de35c9bSChiranjeevi Rapolu 		break;
20375de35c9bSChiranjeevi Rapolu 	case V4L2_CID_DIGITAL_GAIN:
20385de35c9bSChiranjeevi Rapolu 		ret = ov5670_update_digital_gain(ov5670, ctrl->val);
20395de35c9bSChiranjeevi Rapolu 		break;
20405de35c9bSChiranjeevi Rapolu 	case V4L2_CID_EXPOSURE:
20415de35c9bSChiranjeevi Rapolu 		/* 4 least significant bits of expsoure are fractional part */
20425de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_EXPOSURE,
20435de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_24BIT, ctrl->val << 4);
20445de35c9bSChiranjeevi Rapolu 		break;
20455de35c9bSChiranjeevi Rapolu 	case V4L2_CID_VBLANK:
20465de35c9bSChiranjeevi Rapolu 		/* Update VTS that meets expected vertical blanking */
20475de35c9bSChiranjeevi Rapolu 		ret = ov5670_write_reg(ov5670, OV5670_REG_VTS,
20485de35c9bSChiranjeevi Rapolu 				       OV5670_REG_VALUE_16BIT,
20495de35c9bSChiranjeevi Rapolu 				       ov5670->cur_mode->height + ctrl->val);
20505de35c9bSChiranjeevi Rapolu 		break;
20515de35c9bSChiranjeevi Rapolu 	case V4L2_CID_TEST_PATTERN:
20525de35c9bSChiranjeevi Rapolu 		ret = ov5670_enable_test_pattern(ov5670, ctrl->val);
20535de35c9bSChiranjeevi Rapolu 		break;
20545de35c9bSChiranjeevi Rapolu 	default:
20555de35c9bSChiranjeevi Rapolu 		dev_info(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n",
20565de35c9bSChiranjeevi Rapolu 			 __func__, ctrl->id, ctrl->val);
20575de35c9bSChiranjeevi Rapolu 		break;
205805ad2b6dSkbuild test robot 	}
20595de35c9bSChiranjeevi Rapolu 
20605de35c9bSChiranjeevi Rapolu 	pm_runtime_put(&client->dev);
20615de35c9bSChiranjeevi Rapolu 
20625de35c9bSChiranjeevi Rapolu 	return ret;
20635de35c9bSChiranjeevi Rapolu }
20645de35c9bSChiranjeevi Rapolu 
20655de35c9bSChiranjeevi Rapolu static const struct v4l2_ctrl_ops ov5670_ctrl_ops = {
20665de35c9bSChiranjeevi Rapolu 	.s_ctrl = ov5670_set_ctrl,
20675de35c9bSChiranjeevi Rapolu };
20685de35c9bSChiranjeevi Rapolu 
20695de35c9bSChiranjeevi Rapolu /* Initialize control handlers */
20705de35c9bSChiranjeevi Rapolu static int ov5670_init_controls(struct ov5670 *ov5670)
20715de35c9bSChiranjeevi Rapolu {
2072eba08021SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2073eba08021SJacopo Mondi 	struct v4l2_fwnode_device_properties props;
20745de35c9bSChiranjeevi Rapolu 	struct v4l2_ctrl_handler *ctrl_hdlr;
20755de35c9bSChiranjeevi Rapolu 	s64 vblank_max;
20765de35c9bSChiranjeevi Rapolu 	s64 vblank_def;
2077ed351ad9SChiranjeevi Rapolu 	s64 vblank_min;
20785de35c9bSChiranjeevi Rapolu 	s64 exposure_max;
20795de35c9bSChiranjeevi Rapolu 	int ret;
20805de35c9bSChiranjeevi Rapolu 
20815de35c9bSChiranjeevi Rapolu 	ctrl_hdlr = &ov5670->ctrl_handler;
2082eba08021SJacopo Mondi 	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
20835de35c9bSChiranjeevi Rapolu 	if (ret)
20845de35c9bSChiranjeevi Rapolu 		return ret;
20855de35c9bSChiranjeevi Rapolu 
20865de35c9bSChiranjeevi Rapolu 	ctrl_hdlr->lock = &ov5670->mutex;
20875de35c9bSChiranjeevi Rapolu 	ov5670->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
20885de35c9bSChiranjeevi Rapolu 						   &ov5670_ctrl_ops,
20895de35c9bSChiranjeevi Rapolu 						   V4L2_CID_LINK_FREQ,
20905de35c9bSChiranjeevi Rapolu 						   0, 0, link_freq_menu_items);
20915de35c9bSChiranjeevi Rapolu 	if (ov5670->link_freq)
20925de35c9bSChiranjeevi Rapolu 		ov5670->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
20935de35c9bSChiranjeevi Rapolu 
20945de35c9bSChiranjeevi Rapolu 	/* By default, V4L2_CID_PIXEL_RATE is read only */
20955de35c9bSChiranjeevi Rapolu 	ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2096dc1eb7c9SJacopo Mondi 					       V4L2_CID_PIXEL_RATE,
2097dc1eb7c9SJacopo Mondi 					       link_freq_configs[0].pixel_rate,
20985de35c9bSChiranjeevi Rapolu 					       link_freq_configs[0].pixel_rate,
20995de35c9bSChiranjeevi Rapolu 					       1,
21005de35c9bSChiranjeevi Rapolu 					       link_freq_configs[0].pixel_rate);
21015de35c9bSChiranjeevi Rapolu 
21025de35c9bSChiranjeevi Rapolu 	vblank_max = OV5670_VTS_MAX - ov5670->cur_mode->height;
2103ed351ad9SChiranjeevi Rapolu 	vblank_def = ov5670->cur_mode->vts_def - ov5670->cur_mode->height;
2104ed351ad9SChiranjeevi Rapolu 	vblank_min = ov5670->cur_mode->vts_min - ov5670->cur_mode->height;
21055de35c9bSChiranjeevi Rapolu 	ov5670->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2106ed351ad9SChiranjeevi Rapolu 					   V4L2_CID_VBLANK, vblank_min,
21075de35c9bSChiranjeevi Rapolu 					   vblank_max, 1, vblank_def);
21085de35c9bSChiranjeevi Rapolu 
21095de35c9bSChiranjeevi Rapolu 	ov5670->hblank = v4l2_ctrl_new_std(
21105de35c9bSChiranjeevi Rapolu 				ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_HBLANK,
2111f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width,
2112f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width, 1,
2113f1425381SChiranjeevi Rapolu 				OV5670_FIXED_PPL - ov5670->cur_mode->width);
2114f1425381SChiranjeevi Rapolu 	if (ov5670->hblank)
2115f1425381SChiranjeevi Rapolu 		ov5670->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
21165de35c9bSChiranjeevi Rapolu 
21175de35c9bSChiranjeevi Rapolu 	/* Get min, max, step, default from sensor */
21185de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
21195de35c9bSChiranjeevi Rapolu 			  ANALOG_GAIN_MIN, ANALOG_GAIN_MAX, ANALOG_GAIN_STEP,
21205de35c9bSChiranjeevi Rapolu 			  ANALOG_GAIN_DEFAULT);
21215de35c9bSChiranjeevi Rapolu 
21225de35c9bSChiranjeevi Rapolu 	/* Digital gain */
21235de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
21245de35c9bSChiranjeevi Rapolu 			  OV5670_DGTL_GAIN_MIN, OV5670_DGTL_GAIN_MAX,
21255de35c9bSChiranjeevi Rapolu 			  OV5670_DGTL_GAIN_STEP, OV5670_DGTL_GAIN_DEFAULT);
21265de35c9bSChiranjeevi Rapolu 
21275de35c9bSChiranjeevi Rapolu 	/* Get min, max, step, default from sensor */
2128ed351ad9SChiranjeevi Rapolu 	exposure_max = ov5670->cur_mode->vts_def - 8;
21295de35c9bSChiranjeevi Rapolu 	ov5670->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
21305de35c9bSChiranjeevi Rapolu 					     V4L2_CID_EXPOSURE,
21315de35c9bSChiranjeevi Rapolu 					     OV5670_EXPOSURE_MIN,
21325de35c9bSChiranjeevi Rapolu 					     exposure_max, OV5670_EXPOSURE_STEP,
21335de35c9bSChiranjeevi Rapolu 					     exposure_max);
21345de35c9bSChiranjeevi Rapolu 
21355de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov5670_ctrl_ops,
21365de35c9bSChiranjeevi Rapolu 				     V4L2_CID_TEST_PATTERN,
21375de35c9bSChiranjeevi Rapolu 				     ARRAY_SIZE(ov5670_test_pattern_menu) - 1,
21385de35c9bSChiranjeevi Rapolu 				     0, 0, ov5670_test_pattern_menu);
21395de35c9bSChiranjeevi Rapolu 
21405de35c9bSChiranjeevi Rapolu 	if (ctrl_hdlr->error) {
21415de35c9bSChiranjeevi Rapolu 		ret = ctrl_hdlr->error;
21425de35c9bSChiranjeevi Rapolu 		goto error;
21435de35c9bSChiranjeevi Rapolu 	}
21445de35c9bSChiranjeevi Rapolu 
2145eba08021SJacopo Mondi 	ret = v4l2_fwnode_device_parse(&client->dev, &props);
2146eba08021SJacopo Mondi 	if (ret)
2147eba08021SJacopo Mondi 		goto error;
2148eba08021SJacopo Mondi 
2149eba08021SJacopo Mondi 	ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov5670_ctrl_ops,
2150eba08021SJacopo Mondi 					      &props);
2151eba08021SJacopo Mondi 	if (ret)
2152eba08021SJacopo Mondi 		goto error;
2153eba08021SJacopo Mondi 
21545de35c9bSChiranjeevi Rapolu 	ov5670->sd.ctrl_handler = ctrl_hdlr;
21555de35c9bSChiranjeevi Rapolu 
21565de35c9bSChiranjeevi Rapolu 	return 0;
21575de35c9bSChiranjeevi Rapolu 
21585de35c9bSChiranjeevi Rapolu error:
21595de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(ctrl_hdlr);
21605de35c9bSChiranjeevi Rapolu 
21615de35c9bSChiranjeevi Rapolu 	return ret;
21625de35c9bSChiranjeevi Rapolu }
21635de35c9bSChiranjeevi Rapolu 
2164*bbc6071cSJacopo Mondi static int ov5670_init_cfg(struct v4l2_subdev *sd,
2165*bbc6071cSJacopo Mondi 			   struct v4l2_subdev_state *state)
2166*bbc6071cSJacopo Mondi {
2167*bbc6071cSJacopo Mondi 	struct v4l2_mbus_framefmt *fmt =
2168*bbc6071cSJacopo Mondi 				v4l2_subdev_get_try_format(sd, state, 0);
2169*bbc6071cSJacopo Mondi 	const struct ov5670_mode *default_mode = &supported_modes[0];
2170*bbc6071cSJacopo Mondi 
2171*bbc6071cSJacopo Mondi 	fmt->width = default_mode->width;
2172*bbc6071cSJacopo Mondi 	fmt->height = default_mode->height;
2173*bbc6071cSJacopo Mondi 	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
2174*bbc6071cSJacopo Mondi 	fmt->field = V4L2_FIELD_NONE;
2175*bbc6071cSJacopo Mondi 	fmt->colorspace = V4L2_COLORSPACE_SRGB;
2176*bbc6071cSJacopo Mondi 	fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SRGB);
2177*bbc6071cSJacopo Mondi 	fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
2178*bbc6071cSJacopo Mondi 	fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SRGB);
2179*bbc6071cSJacopo Mondi 
2180*bbc6071cSJacopo Mondi 	return 0;
2181*bbc6071cSJacopo Mondi }
2182*bbc6071cSJacopo Mondi 
21835de35c9bSChiranjeevi Rapolu static int ov5670_enum_mbus_code(struct v4l2_subdev *sd,
21840d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
21855de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_mbus_code_enum *code)
21865de35c9bSChiranjeevi Rapolu {
21875de35c9bSChiranjeevi Rapolu 	/* Only one bayer order GRBG is supported */
21885de35c9bSChiranjeevi Rapolu 	if (code->index > 0)
21895de35c9bSChiranjeevi Rapolu 		return -EINVAL;
21905de35c9bSChiranjeevi Rapolu 
21915de35c9bSChiranjeevi Rapolu 	code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
21925de35c9bSChiranjeevi Rapolu 
21935de35c9bSChiranjeevi Rapolu 	return 0;
21945de35c9bSChiranjeevi Rapolu }
21955de35c9bSChiranjeevi Rapolu 
21965de35c9bSChiranjeevi Rapolu static int ov5670_enum_frame_size(struct v4l2_subdev *sd,
21970d346d2aSTomi Valkeinen 				  struct v4l2_subdev_state *sd_state,
21985de35c9bSChiranjeevi Rapolu 				  struct v4l2_subdev_frame_size_enum *fse)
21995de35c9bSChiranjeevi Rapolu {
22005de35c9bSChiranjeevi Rapolu 	if (fse->index >= ARRAY_SIZE(supported_modes))
22015de35c9bSChiranjeevi Rapolu 		return -EINVAL;
22025de35c9bSChiranjeevi Rapolu 
22035de35c9bSChiranjeevi Rapolu 	if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
22045de35c9bSChiranjeevi Rapolu 		return -EINVAL;
22055de35c9bSChiranjeevi Rapolu 
22065de35c9bSChiranjeevi Rapolu 	fse->min_width = supported_modes[fse->index].width;
22075de35c9bSChiranjeevi Rapolu 	fse->max_width = fse->min_width;
22085de35c9bSChiranjeevi Rapolu 	fse->min_height = supported_modes[fse->index].height;
22095de35c9bSChiranjeevi Rapolu 	fse->max_height = fse->min_height;
22105de35c9bSChiranjeevi Rapolu 
22115de35c9bSChiranjeevi Rapolu 	return 0;
22125de35c9bSChiranjeevi Rapolu }
22135de35c9bSChiranjeevi Rapolu 
22145de35c9bSChiranjeevi Rapolu static void ov5670_update_pad_format(const struct ov5670_mode *mode,
22155de35c9bSChiranjeevi Rapolu 				     struct v4l2_subdev_format *fmt)
22165de35c9bSChiranjeevi Rapolu {
22175de35c9bSChiranjeevi Rapolu 	fmt->format.width = mode->width;
22185de35c9bSChiranjeevi Rapolu 	fmt->format.height = mode->height;
22195de35c9bSChiranjeevi Rapolu 	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
22205de35c9bSChiranjeevi Rapolu 	fmt->format.field = V4L2_FIELD_NONE;
22215de35c9bSChiranjeevi Rapolu }
22225de35c9bSChiranjeevi Rapolu 
22235de35c9bSChiranjeevi Rapolu static int ov5670_do_get_pad_format(struct ov5670 *ov5670,
22240d346d2aSTomi Valkeinen 				    struct v4l2_subdev_state *sd_state,
22255de35c9bSChiranjeevi Rapolu 				    struct v4l2_subdev_format *fmt)
22265de35c9bSChiranjeevi Rapolu {
22275de35c9bSChiranjeevi Rapolu 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
22280d346d2aSTomi Valkeinen 		fmt->format = *v4l2_subdev_get_try_format(&ov5670->sd,
22290d346d2aSTomi Valkeinen 							  sd_state,
22305de35c9bSChiranjeevi Rapolu 							  fmt->pad);
22315de35c9bSChiranjeevi Rapolu 	else
22325de35c9bSChiranjeevi Rapolu 		ov5670_update_pad_format(ov5670->cur_mode, fmt);
22335de35c9bSChiranjeevi Rapolu 
22345de35c9bSChiranjeevi Rapolu 	return 0;
22355de35c9bSChiranjeevi Rapolu }
22365de35c9bSChiranjeevi Rapolu 
22375de35c9bSChiranjeevi Rapolu static int ov5670_get_pad_format(struct v4l2_subdev *sd,
22380d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
22395de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_format *fmt)
22405de35c9bSChiranjeevi Rapolu {
22415de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
22425de35c9bSChiranjeevi Rapolu 	int ret;
22435de35c9bSChiranjeevi Rapolu 
22445de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
22450d346d2aSTomi Valkeinen 	ret = ov5670_do_get_pad_format(ov5670, sd_state, fmt);
22465de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
22475de35c9bSChiranjeevi Rapolu 
22485de35c9bSChiranjeevi Rapolu 	return ret;
22495de35c9bSChiranjeevi Rapolu }
22505de35c9bSChiranjeevi Rapolu 
22515de35c9bSChiranjeevi Rapolu static int ov5670_set_pad_format(struct v4l2_subdev *sd,
22520d346d2aSTomi Valkeinen 				 struct v4l2_subdev_state *sd_state,
22535de35c9bSChiranjeevi Rapolu 				 struct v4l2_subdev_format *fmt)
22545de35c9bSChiranjeevi Rapolu {
22555de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
22565de35c9bSChiranjeevi Rapolu 	const struct ov5670_mode *mode;
22575de35c9bSChiranjeevi Rapolu 	s32 vblank_def;
22585de35c9bSChiranjeevi Rapolu 	s32 h_blank;
22595de35c9bSChiranjeevi Rapolu 
22605de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
22615de35c9bSChiranjeevi Rapolu 
22625de35c9bSChiranjeevi Rapolu 	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
22635de35c9bSChiranjeevi Rapolu 
2264d2dc57b1SSakari Ailus 	mode = v4l2_find_nearest_size(supported_modes,
2265d2dc57b1SSakari Ailus 				      ARRAY_SIZE(supported_modes),
2266d2dc57b1SSakari Ailus 				      width, height,
2267894de53bSSakari Ailus 				      fmt->format.width, fmt->format.height);
22685de35c9bSChiranjeevi Rapolu 	ov5670_update_pad_format(mode, fmt);
22695de35c9bSChiranjeevi Rapolu 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
22700d346d2aSTomi Valkeinen 		*v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format;
22715de35c9bSChiranjeevi Rapolu 	} else {
22725de35c9bSChiranjeevi Rapolu 		ov5670->cur_mode = mode;
22735de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl(ov5670->link_freq, mode->link_freq_index);
22745de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl_int64(
22755de35c9bSChiranjeevi Rapolu 			ov5670->pixel_rate,
22765de35c9bSChiranjeevi Rapolu 			link_freq_configs[mode->link_freq_index].pixel_rate);
22775de35c9bSChiranjeevi Rapolu 		/* Update limits and set FPS to default */
2278ed351ad9SChiranjeevi Rapolu 		vblank_def = ov5670->cur_mode->vts_def -
2279ed351ad9SChiranjeevi Rapolu 			     ov5670->cur_mode->height;
22805de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(
2281ed351ad9SChiranjeevi Rapolu 			ov5670->vblank,
2282ed351ad9SChiranjeevi Rapolu 			ov5670->cur_mode->vts_min - ov5670->cur_mode->height,
22835de35c9bSChiranjeevi Rapolu 			OV5670_VTS_MAX - ov5670->cur_mode->height, 1,
22845de35c9bSChiranjeevi Rapolu 			vblank_def);
22855de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_s_ctrl(ov5670->vblank, vblank_def);
2286f1425381SChiranjeevi Rapolu 		h_blank = OV5670_FIXED_PPL - ov5670->cur_mode->width;
22875de35c9bSChiranjeevi Rapolu 		__v4l2_ctrl_modify_range(ov5670->hblank, h_blank, h_blank, 1,
22885de35c9bSChiranjeevi Rapolu 					 h_blank);
22895de35c9bSChiranjeevi Rapolu 	}
22905de35c9bSChiranjeevi Rapolu 
22915de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
22925de35c9bSChiranjeevi Rapolu 
22935de35c9bSChiranjeevi Rapolu 	return 0;
22945de35c9bSChiranjeevi Rapolu }
22955de35c9bSChiranjeevi Rapolu 
22965de35c9bSChiranjeevi Rapolu static int ov5670_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
22975de35c9bSChiranjeevi Rapolu {
22985de35c9bSChiranjeevi Rapolu 	*frames = OV5670_NUM_OF_SKIP_FRAMES;
22995de35c9bSChiranjeevi Rapolu 
23005de35c9bSChiranjeevi Rapolu 	return 0;
23015de35c9bSChiranjeevi Rapolu }
23025de35c9bSChiranjeevi Rapolu 
23031e583b56SSakari Ailus /* Verify chip ID */
23041e583b56SSakari Ailus static int ov5670_identify_module(struct ov5670 *ov5670)
23051e583b56SSakari Ailus {
23061e583b56SSakari Ailus 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
23071e583b56SSakari Ailus 	int ret;
23081e583b56SSakari Ailus 	u32 val;
23091e583b56SSakari Ailus 
23101e583b56SSakari Ailus 	if (ov5670->identified)
23111e583b56SSakari Ailus 		return 0;
23121e583b56SSakari Ailus 
23131e583b56SSakari Ailus 	ret = ov5670_read_reg(ov5670, OV5670_REG_CHIP_ID,
23141e583b56SSakari Ailus 			      OV5670_REG_VALUE_24BIT, &val);
23151e583b56SSakari Ailus 	if (ret)
23161e583b56SSakari Ailus 		return ret;
23171e583b56SSakari Ailus 
23181e583b56SSakari Ailus 	if (val != OV5670_CHIP_ID) {
23191e583b56SSakari Ailus 		dev_err(&client->dev, "chip id mismatch: %x!=%x\n",
23201e583b56SSakari Ailus 			OV5670_CHIP_ID, val);
23211e583b56SSakari Ailus 		return -ENXIO;
23221e583b56SSakari Ailus 	}
23231e583b56SSakari Ailus 
23241e583b56SSakari Ailus 	ov5670->identified = true;
23251e583b56SSakari Ailus 
23261e583b56SSakari Ailus 	return 0;
23271e583b56SSakari Ailus }
23281e583b56SSakari Ailus 
23295de35c9bSChiranjeevi Rapolu /* Prepare streaming by writing default values and customized values */
23305de35c9bSChiranjeevi Rapolu static int ov5670_start_streaming(struct ov5670 *ov5670)
23315de35c9bSChiranjeevi Rapolu {
23325de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
23335de35c9bSChiranjeevi Rapolu 	const struct ov5670_reg_list *reg_list;
23345de35c9bSChiranjeevi Rapolu 	int link_freq_index;
23355de35c9bSChiranjeevi Rapolu 	int ret;
23365de35c9bSChiranjeevi Rapolu 
23371e583b56SSakari Ailus 	ret = ov5670_identify_module(ov5670);
23381e583b56SSakari Ailus 	if (ret)
23391e583b56SSakari Ailus 		return ret;
23401e583b56SSakari Ailus 
23415de35c9bSChiranjeevi Rapolu 	/* Get out of from software reset */
23425de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_SOFTWARE_RST,
23435de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_SOFTWARE_RST);
23445de35c9bSChiranjeevi Rapolu 	if (ret) {
23455de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set powerup registers\n",
23465de35c9bSChiranjeevi Rapolu 			__func__);
23475de35c9bSChiranjeevi Rapolu 		return ret;
23485de35c9bSChiranjeevi Rapolu 	}
23495de35c9bSChiranjeevi Rapolu 
23505de35c9bSChiranjeevi Rapolu 	/* Setup PLL */
23515de35c9bSChiranjeevi Rapolu 	link_freq_index = ov5670->cur_mode->link_freq_index;
23525de35c9bSChiranjeevi Rapolu 	reg_list = &link_freq_configs[link_freq_index].reg_list;
23535de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg_list(ov5670, reg_list);
23545de35c9bSChiranjeevi Rapolu 	if (ret) {
23555de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set plls\n", __func__);
23565de35c9bSChiranjeevi Rapolu 		return ret;
23575de35c9bSChiranjeevi Rapolu 	}
23585de35c9bSChiranjeevi Rapolu 
23595de35c9bSChiranjeevi Rapolu 	/* Apply default values of current mode */
23605de35c9bSChiranjeevi Rapolu 	reg_list = &ov5670->cur_mode->reg_list;
23615de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg_list(ov5670, reg_list);
23625de35c9bSChiranjeevi Rapolu 	if (ret) {
23635de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set mode\n", __func__);
23645de35c9bSChiranjeevi Rapolu 		return ret;
23655de35c9bSChiranjeevi Rapolu 	}
23665de35c9bSChiranjeevi Rapolu 
23675de35c9bSChiranjeevi Rapolu 	ret = __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
23685de35c9bSChiranjeevi Rapolu 	if (ret)
23695de35c9bSChiranjeevi Rapolu 		return ret;
23705de35c9bSChiranjeevi Rapolu 
23715de35c9bSChiranjeevi Rapolu 	/* Write stream on list */
23725de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
23735de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_MODE_STREAMING);
23745de35c9bSChiranjeevi Rapolu 	if (ret) {
23755de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set stream\n", __func__);
23765de35c9bSChiranjeevi Rapolu 		return ret;
23775de35c9bSChiranjeevi Rapolu 	}
23785de35c9bSChiranjeevi Rapolu 
23795de35c9bSChiranjeevi Rapolu 	return 0;
23805de35c9bSChiranjeevi Rapolu }
23815de35c9bSChiranjeevi Rapolu 
23825de35c9bSChiranjeevi Rapolu static int ov5670_stop_streaming(struct ov5670 *ov5670)
23835de35c9bSChiranjeevi Rapolu {
23845de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
23855de35c9bSChiranjeevi Rapolu 	int ret;
23865de35c9bSChiranjeevi Rapolu 
23875de35c9bSChiranjeevi Rapolu 	ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
23885de35c9bSChiranjeevi Rapolu 			       OV5670_REG_VALUE_08BIT, OV5670_MODE_STANDBY);
23895de35c9bSChiranjeevi Rapolu 	if (ret)
23905de35c9bSChiranjeevi Rapolu 		dev_err(&client->dev, "%s failed to set stream\n", __func__);
23915de35c9bSChiranjeevi Rapolu 
23925de35c9bSChiranjeevi Rapolu 	/* Return success even if it was an error, as there is nothing the
23935de35c9bSChiranjeevi Rapolu 	 * caller can do about it.
23945de35c9bSChiranjeevi Rapolu 	 */
23955de35c9bSChiranjeevi Rapolu 	return 0;
23965de35c9bSChiranjeevi Rapolu }
23975de35c9bSChiranjeevi Rapolu 
23985de35c9bSChiranjeevi Rapolu static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
23995de35c9bSChiranjeevi Rapolu {
24005de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
24015de35c9bSChiranjeevi Rapolu 	struct i2c_client *client = v4l2_get_subdevdata(sd);
24025de35c9bSChiranjeevi Rapolu 	int ret = 0;
24035de35c9bSChiranjeevi Rapolu 
24045de35c9bSChiranjeevi Rapolu 	mutex_lock(&ov5670->mutex);
24055de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming == enable)
24065de35c9bSChiranjeevi Rapolu 		goto unlock_and_return;
24075de35c9bSChiranjeevi Rapolu 
24085de35c9bSChiranjeevi Rapolu 	if (enable) {
2409f151c230SMauro Carvalho Chehab 		ret = pm_runtime_resume_and_get(&client->dev);
2410f151c230SMauro Carvalho Chehab 		if (ret < 0)
24115de35c9bSChiranjeevi Rapolu 			goto unlock_and_return;
24125de35c9bSChiranjeevi Rapolu 
24135de35c9bSChiranjeevi Rapolu 		ret = ov5670_start_streaming(ov5670);
24145de35c9bSChiranjeevi Rapolu 		if (ret)
24155de35c9bSChiranjeevi Rapolu 			goto error;
24165de35c9bSChiranjeevi Rapolu 	} else {
24175de35c9bSChiranjeevi Rapolu 		ret = ov5670_stop_streaming(ov5670);
24185de35c9bSChiranjeevi Rapolu 		pm_runtime_put(&client->dev);
24195de35c9bSChiranjeevi Rapolu 	}
24203eefbc69SChiranjeevi Rapolu 	ov5670->streaming = enable;
24215de35c9bSChiranjeevi Rapolu 	goto unlock_and_return;
24225de35c9bSChiranjeevi Rapolu 
24235de35c9bSChiranjeevi Rapolu error:
24245de35c9bSChiranjeevi Rapolu 	pm_runtime_put(&client->dev);
24255de35c9bSChiranjeevi Rapolu 
24265de35c9bSChiranjeevi Rapolu unlock_and_return:
24275de35c9bSChiranjeevi Rapolu 	mutex_unlock(&ov5670->mutex);
24285de35c9bSChiranjeevi Rapolu 
24295de35c9bSChiranjeevi Rapolu 	return ret;
24305de35c9bSChiranjeevi Rapolu }
24315de35c9bSChiranjeevi Rapolu 
243262ab1e32SJacopo Mondi static int __maybe_unused ov5670_runtime_resume(struct device *dev)
243362ab1e32SJacopo Mondi {
243462ab1e32SJacopo Mondi 	struct i2c_client *client = to_i2c_client(dev);
243562ab1e32SJacopo Mondi 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
243662ab1e32SJacopo Mondi 	struct ov5670 *ov5670 = to_ov5670(sd);
243762ab1e32SJacopo Mondi 	unsigned long delay_us;
243862ab1e32SJacopo Mondi 	int ret;
243962ab1e32SJacopo Mondi 
244062ab1e32SJacopo Mondi 	ret = clk_prepare_enable(ov5670->xvclk);
244162ab1e32SJacopo Mondi 	if (ret)
244262ab1e32SJacopo Mondi 		return ret;
244362ab1e32SJacopo Mondi 
244462ab1e32SJacopo Mondi 	ret = regulator_bulk_enable(OV5670_NUM_SUPPLIES, ov5670->supplies);
244562ab1e32SJacopo Mondi 	if (ret) {
244662ab1e32SJacopo Mondi 		clk_disable_unprepare(ov5670->xvclk);
244762ab1e32SJacopo Mondi 		return ret;
244862ab1e32SJacopo Mondi 	}
244962ab1e32SJacopo Mondi 
245062ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->pwdn_gpio, 0);
245162ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->reset_gpio, 0);
245262ab1e32SJacopo Mondi 
245362ab1e32SJacopo Mondi 	/* 8192 * 2 clock pulses before the first SCCB transaction. */
245462ab1e32SJacopo Mondi 	delay_us = DIV_ROUND_UP(8192 * 2 * 1000,
245562ab1e32SJacopo Mondi 				DIV_ROUND_UP(OV5670_XVCLK_FREQ, 1000));
245662ab1e32SJacopo Mondi 	fsleep(delay_us);
245762ab1e32SJacopo Mondi 
245862ab1e32SJacopo Mondi 	return 0;
245962ab1e32SJacopo Mondi }
246062ab1e32SJacopo Mondi 
246162ab1e32SJacopo Mondi static int __maybe_unused ov5670_runtime_suspend(struct device *dev)
246262ab1e32SJacopo Mondi {
246362ab1e32SJacopo Mondi 	struct i2c_client *client = to_i2c_client(dev);
246462ab1e32SJacopo Mondi 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
246562ab1e32SJacopo Mondi 	struct ov5670 *ov5670 = to_ov5670(sd);
246662ab1e32SJacopo Mondi 
246762ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->reset_gpio, 1);
246862ab1e32SJacopo Mondi 	gpiod_set_value_cansleep(ov5670->pwdn_gpio, 1);
246962ab1e32SJacopo Mondi 	regulator_bulk_disable(OV5670_NUM_SUPPLIES, ov5670->supplies);
247062ab1e32SJacopo Mondi 	clk_disable_unprepare(ov5670->xvclk);
247162ab1e32SJacopo Mondi 
247262ab1e32SJacopo Mondi 	return 0;
247362ab1e32SJacopo Mondi }
247462ab1e32SJacopo Mondi 
24755de35c9bSChiranjeevi Rapolu static int __maybe_unused ov5670_suspend(struct device *dev)
24765de35c9bSChiranjeevi Rapolu {
2477bf396557SKrzysztof Kozlowski 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
24785de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
24795de35c9bSChiranjeevi Rapolu 
24805de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming)
24815de35c9bSChiranjeevi Rapolu 		ov5670_stop_streaming(ov5670);
24825de35c9bSChiranjeevi Rapolu 
24835de35c9bSChiranjeevi Rapolu 	return 0;
24845de35c9bSChiranjeevi Rapolu }
24855de35c9bSChiranjeevi Rapolu 
24865de35c9bSChiranjeevi Rapolu static int __maybe_unused ov5670_resume(struct device *dev)
24875de35c9bSChiranjeevi Rapolu {
2488bf396557SKrzysztof Kozlowski 	struct v4l2_subdev *sd = dev_get_drvdata(dev);
24895de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
24905de35c9bSChiranjeevi Rapolu 	int ret;
24915de35c9bSChiranjeevi Rapolu 
24925de35c9bSChiranjeevi Rapolu 	if (ov5670->streaming) {
24935de35c9bSChiranjeevi Rapolu 		ret = ov5670_start_streaming(ov5670);
24945de35c9bSChiranjeevi Rapolu 		if (ret) {
24955de35c9bSChiranjeevi Rapolu 			ov5670_stop_streaming(ov5670);
24965de35c9bSChiranjeevi Rapolu 			return ret;
24975de35c9bSChiranjeevi Rapolu 		}
24985de35c9bSChiranjeevi Rapolu 	}
24995de35c9bSChiranjeevi Rapolu 
25005de35c9bSChiranjeevi Rapolu 	return 0;
25015de35c9bSChiranjeevi Rapolu }
25025de35c9bSChiranjeevi Rapolu 
2503dce6dd44SRicardo Ribalda static const struct v4l2_subdev_core_ops ov5670_core_ops = {
2504dce6dd44SRicardo Ribalda 	.log_status = v4l2_ctrl_subdev_log_status,
2505dce6dd44SRicardo Ribalda 	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
2506dce6dd44SRicardo Ribalda 	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
2507dce6dd44SRicardo Ribalda };
2508dce6dd44SRicardo Ribalda 
25095de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_video_ops ov5670_video_ops = {
25105de35c9bSChiranjeevi Rapolu 	.s_stream = ov5670_set_stream,
25115de35c9bSChiranjeevi Rapolu };
25125de35c9bSChiranjeevi Rapolu 
25135de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_pad_ops ov5670_pad_ops = {
2514*bbc6071cSJacopo Mondi 	.init_cfg = ov5670_init_cfg,
25155de35c9bSChiranjeevi Rapolu 	.enum_mbus_code = ov5670_enum_mbus_code,
25165de35c9bSChiranjeevi Rapolu 	.get_fmt = ov5670_get_pad_format,
25175de35c9bSChiranjeevi Rapolu 	.set_fmt = ov5670_set_pad_format,
25185de35c9bSChiranjeevi Rapolu 	.enum_frame_size = ov5670_enum_frame_size,
25195de35c9bSChiranjeevi Rapolu };
25205de35c9bSChiranjeevi Rapolu 
25215de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_sensor_ops ov5670_sensor_ops = {
25225de35c9bSChiranjeevi Rapolu 	.g_skip_frames = ov5670_get_skip_frames,
25235de35c9bSChiranjeevi Rapolu };
25245de35c9bSChiranjeevi Rapolu 
25255de35c9bSChiranjeevi Rapolu static const struct v4l2_subdev_ops ov5670_subdev_ops = {
2526dce6dd44SRicardo Ribalda 	.core = &ov5670_core_ops,
25275de35c9bSChiranjeevi Rapolu 	.video = &ov5670_video_ops,
25285de35c9bSChiranjeevi Rapolu 	.pad = &ov5670_pad_ops,
25295de35c9bSChiranjeevi Rapolu 	.sensor = &ov5670_sensor_ops,
25305de35c9bSChiranjeevi Rapolu };
25315de35c9bSChiranjeevi Rapolu 
25325de35c9bSChiranjeevi Rapolu static const struct media_entity_operations ov5670_subdev_entity_ops = {
25335de35c9bSChiranjeevi Rapolu 	.link_validate = v4l2_subdev_link_validate,
25345de35c9bSChiranjeevi Rapolu };
25355de35c9bSChiranjeevi Rapolu 
2536cf9ab879SJacopo Mondi static int ov5670_regulators_probe(struct ov5670 *ov5670)
2537cf9ab879SJacopo Mondi {
2538cf9ab879SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2539cf9ab879SJacopo Mondi 	unsigned int i;
2540cf9ab879SJacopo Mondi 
2541cf9ab879SJacopo Mondi 	for (i = 0; i < OV5670_NUM_SUPPLIES; i++)
2542cf9ab879SJacopo Mondi 		ov5670->supplies[i].supply = ov5670_supply_names[i];
2543cf9ab879SJacopo Mondi 
2544cf9ab879SJacopo Mondi 	return devm_regulator_bulk_get(&client->dev, OV5670_NUM_SUPPLIES,
2545cf9ab879SJacopo Mondi 				       ov5670->supplies);
2546cf9ab879SJacopo Mondi }
2547cf9ab879SJacopo Mondi 
25480a844ab7SJacopo Mondi static int ov5670_gpio_probe(struct ov5670 *ov5670)
25490a844ab7SJacopo Mondi {
25500a844ab7SJacopo Mondi 	struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
25510a844ab7SJacopo Mondi 
25520a844ab7SJacopo Mondi 	ov5670->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown",
25530a844ab7SJacopo Mondi 						    GPIOD_OUT_LOW);
25540a844ab7SJacopo Mondi 	if (IS_ERR(ov5670->pwdn_gpio))
25550a844ab7SJacopo Mondi 		return PTR_ERR(ov5670->pwdn_gpio);
25560a844ab7SJacopo Mondi 
25570a844ab7SJacopo Mondi 	ov5670->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
25580a844ab7SJacopo Mondi 						     GPIOD_OUT_LOW);
25590a844ab7SJacopo Mondi 	if (IS_ERR(ov5670->reset_gpio))
25600a844ab7SJacopo Mondi 		return PTR_ERR(ov5670->reset_gpio);
25610a844ab7SJacopo Mondi 
25620a844ab7SJacopo Mondi 	return 0;
25630a844ab7SJacopo Mondi }
25640a844ab7SJacopo Mondi 
25655de35c9bSChiranjeevi Rapolu static int ov5670_probe(struct i2c_client *client)
25665de35c9bSChiranjeevi Rapolu {
25675de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670;
25685de35c9bSChiranjeevi Rapolu 	const char *err_msg;
25695de35c9bSChiranjeevi Rapolu 	u32 input_clk = 0;
25701e583b56SSakari Ailus 	bool full_power;
25715de35c9bSChiranjeevi Rapolu 	int ret;
25725de35c9bSChiranjeevi Rapolu 
25735de35c9bSChiranjeevi Rapolu 	ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL);
25745de35c9bSChiranjeevi Rapolu 	if (!ov5670) {
25755de35c9bSChiranjeevi Rapolu 		ret = -ENOMEM;
25765de35c9bSChiranjeevi Rapolu 		err_msg = "devm_kzalloc() error";
25775de35c9bSChiranjeevi Rapolu 		goto error_print;
25785de35c9bSChiranjeevi Rapolu 	}
25795de35c9bSChiranjeevi Rapolu 
25808004c91eSJacopo Mondi 	ov5670->xvclk = devm_clk_get(&client->dev, NULL);
25818004c91eSJacopo Mondi 	if (!IS_ERR_OR_NULL(ov5670->xvclk))
25828004c91eSJacopo Mondi 		input_clk = clk_get_rate(ov5670->xvclk);
25838004c91eSJacopo Mondi 	else if (PTR_ERR(ov5670->xvclk) == -ENOENT)
25848004c91eSJacopo Mondi 		device_property_read_u32(&client->dev, "clock-frequency",
25858004c91eSJacopo Mondi 					 &input_clk);
25868004c91eSJacopo Mondi 	else
25878004c91eSJacopo Mondi 		return dev_err_probe(&client->dev, PTR_ERR(ov5670->xvclk),
25888004c91eSJacopo Mondi 				     "error getting clock\n");
25898004c91eSJacopo Mondi 
25908004c91eSJacopo Mondi 	if (input_clk != OV5670_XVCLK_FREQ) {
25918004c91eSJacopo Mondi 		dev_err(&client->dev,
25928004c91eSJacopo Mondi 			"Unsupported clock frequency %u\n", input_clk);
25938004c91eSJacopo Mondi 		return -EINVAL;
25948004c91eSJacopo Mondi 	}
25958004c91eSJacopo Mondi 
25965de35c9bSChiranjeevi Rapolu 	/* Initialize subdev */
25975de35c9bSChiranjeevi Rapolu 	v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
25985de35c9bSChiranjeevi Rapolu 
2599cf9ab879SJacopo Mondi 	ret = ov5670_regulators_probe(ov5670);
2600cf9ab879SJacopo Mondi 	if (ret) {
2601cf9ab879SJacopo Mondi 		err_msg = "Regulators probe failed";
2602cf9ab879SJacopo Mondi 		goto error_print;
2603cf9ab879SJacopo Mondi 	}
2604cf9ab879SJacopo Mondi 
26050a844ab7SJacopo Mondi 	ret = ov5670_gpio_probe(ov5670);
26060a844ab7SJacopo Mondi 	if (ret) {
26070a844ab7SJacopo Mondi 		err_msg = "GPIO probe failed";
26080a844ab7SJacopo Mondi 		goto error_print;
26090a844ab7SJacopo Mondi 	}
26100a844ab7SJacopo Mondi 
26111e583b56SSakari Ailus 	full_power = acpi_dev_state_d0(&client->dev);
26121e583b56SSakari Ailus 	if (full_power) {
261362ab1e32SJacopo Mondi 		ret = ov5670_runtime_resume(&client->dev);
261462ab1e32SJacopo Mondi 		if (ret) {
261562ab1e32SJacopo Mondi 			err_msg = "Power up failed";
261662ab1e32SJacopo Mondi 			goto error_print;
261762ab1e32SJacopo Mondi 		}
261862ab1e32SJacopo Mondi 
26195de35c9bSChiranjeevi Rapolu 		/* Check module identity */
26205de35c9bSChiranjeevi Rapolu 		ret = ov5670_identify_module(ov5670);
26215de35c9bSChiranjeevi Rapolu 		if (ret) {
26225de35c9bSChiranjeevi Rapolu 			err_msg = "ov5670_identify_module() error";
262362ab1e32SJacopo Mondi 			goto error_power_off;
26245de35c9bSChiranjeevi Rapolu 		}
26251e583b56SSakari Ailus 	}
26265de35c9bSChiranjeevi Rapolu 
26275de35c9bSChiranjeevi Rapolu 	mutex_init(&ov5670->mutex);
26285de35c9bSChiranjeevi Rapolu 
26295de35c9bSChiranjeevi Rapolu 	/* Set default mode to max resolution */
26305de35c9bSChiranjeevi Rapolu 	ov5670->cur_mode = &supported_modes[0];
26315de35c9bSChiranjeevi Rapolu 
26325de35c9bSChiranjeevi Rapolu 	ret = ov5670_init_controls(ov5670);
26335de35c9bSChiranjeevi Rapolu 	if (ret) {
26345de35c9bSChiranjeevi Rapolu 		err_msg = "ov5670_init_controls() error";
26355de35c9bSChiranjeevi Rapolu 		goto error_mutex_destroy;
26365de35c9bSChiranjeevi Rapolu 	}
26375de35c9bSChiranjeevi Rapolu 
2638dce6dd44SRicardo Ribalda 	ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
2639dce6dd44SRicardo Ribalda 			    V4L2_SUBDEV_FL_HAS_EVENTS;
26405de35c9bSChiranjeevi Rapolu 	ov5670->sd.entity.ops = &ov5670_subdev_entity_ops;
26415de35c9bSChiranjeevi Rapolu 	ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
26425de35c9bSChiranjeevi Rapolu 
26435de35c9bSChiranjeevi Rapolu 	/* Source pad initialization */
26445de35c9bSChiranjeevi Rapolu 	ov5670->pad.flags = MEDIA_PAD_FL_SOURCE;
26455de35c9bSChiranjeevi Rapolu 	ret = media_entity_pads_init(&ov5670->sd.entity, 1, &ov5670->pad);
26465de35c9bSChiranjeevi Rapolu 	if (ret) {
26475de35c9bSChiranjeevi Rapolu 		err_msg = "media_entity_pads_init() error";
26485de35c9bSChiranjeevi Rapolu 		goto error_handler_free;
26495de35c9bSChiranjeevi Rapolu 	}
26505de35c9bSChiranjeevi Rapolu 
26515de35c9bSChiranjeevi Rapolu 	ov5670->streaming = false;
26525de35c9bSChiranjeevi Rapolu 
26531e583b56SSakari Ailus 	/* Set the device's state to active if it's in D0 state. */
26541e583b56SSakari Ailus 	if (full_power)
26555de35c9bSChiranjeevi Rapolu 		pm_runtime_set_active(&client->dev);
26565de35c9bSChiranjeevi Rapolu 	pm_runtime_enable(&client->dev);
265762ab1e32SJacopo Mondi 
265862ab1e32SJacopo Mondi 	/* Async register for subdev */
265962ab1e32SJacopo Mondi 	ret = v4l2_async_register_subdev_sensor(&ov5670->sd);
266062ab1e32SJacopo Mondi 	if (ret < 0) {
266162ab1e32SJacopo Mondi 		err_msg = "v4l2_async_register_subdev() error";
266262ab1e32SJacopo Mondi 		goto error_pm_disable;
266362ab1e32SJacopo Mondi 	}
266462ab1e32SJacopo Mondi 
2665d508fffbSSakari Ailus 	pm_runtime_idle(&client->dev);
26665de35c9bSChiranjeevi Rapolu 
26675de35c9bSChiranjeevi Rapolu 	return 0;
26685de35c9bSChiranjeevi Rapolu 
266962ab1e32SJacopo Mondi error_pm_disable:
267062ab1e32SJacopo Mondi 	pm_runtime_disable(&client->dev);
267162ab1e32SJacopo Mondi 
26725de35c9bSChiranjeevi Rapolu 	media_entity_cleanup(&ov5670->sd.entity);
26735de35c9bSChiranjeevi Rapolu 
26745de35c9bSChiranjeevi Rapolu error_handler_free:
26755de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(ov5670->sd.ctrl_handler);
26765de35c9bSChiranjeevi Rapolu 
26775de35c9bSChiranjeevi Rapolu error_mutex_destroy:
26785de35c9bSChiranjeevi Rapolu 	mutex_destroy(&ov5670->mutex);
26795de35c9bSChiranjeevi Rapolu 
268062ab1e32SJacopo Mondi error_power_off:
268162ab1e32SJacopo Mondi 	if (full_power)
268262ab1e32SJacopo Mondi 		ov5670_runtime_suspend(&client->dev);
268362ab1e32SJacopo Mondi 
26845de35c9bSChiranjeevi Rapolu error_print:
26855de35c9bSChiranjeevi Rapolu 	dev_err(&client->dev, "%s: %s %d\n", __func__, err_msg, ret);
26865de35c9bSChiranjeevi Rapolu 
26875de35c9bSChiranjeevi Rapolu 	return ret;
26885de35c9bSChiranjeevi Rapolu }
26895de35c9bSChiranjeevi Rapolu 
2690ed5c2f5fSUwe Kleine-König static void ov5670_remove(struct i2c_client *client)
26915de35c9bSChiranjeevi Rapolu {
26925de35c9bSChiranjeevi Rapolu 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
26935de35c9bSChiranjeevi Rapolu 	struct ov5670 *ov5670 = to_ov5670(sd);
26945de35c9bSChiranjeevi Rapolu 
26955de35c9bSChiranjeevi Rapolu 	v4l2_async_unregister_subdev(sd);
26965de35c9bSChiranjeevi Rapolu 	media_entity_cleanup(&sd->entity);
26975de35c9bSChiranjeevi Rapolu 	v4l2_ctrl_handler_free(sd->ctrl_handler);
26985de35c9bSChiranjeevi Rapolu 	mutex_destroy(&ov5670->mutex);
26995de35c9bSChiranjeevi Rapolu 
27005de35c9bSChiranjeevi Rapolu 	pm_runtime_disable(&client->dev);
270162ab1e32SJacopo Mondi 	ov5670_runtime_suspend(&client->dev);
27025de35c9bSChiranjeevi Rapolu }
27035de35c9bSChiranjeevi Rapolu 
27045de35c9bSChiranjeevi Rapolu static const struct dev_pm_ops ov5670_pm_ops = {
27055de35c9bSChiranjeevi Rapolu 	SET_SYSTEM_SLEEP_PM_OPS(ov5670_suspend, ov5670_resume)
270662ab1e32SJacopo Mondi 	SET_RUNTIME_PM_OPS(ov5670_runtime_suspend, ov5670_runtime_resume, NULL)
27075de35c9bSChiranjeevi Rapolu };
27085de35c9bSChiranjeevi Rapolu 
27095de35c9bSChiranjeevi Rapolu #ifdef CONFIG_ACPI
27105de35c9bSChiranjeevi Rapolu static const struct acpi_device_id ov5670_acpi_ids[] = {
27115de35c9bSChiranjeevi Rapolu 	{ "INT3479" },
27125de35c9bSChiranjeevi Rapolu 	{ /* sentinel */ }
27135de35c9bSChiranjeevi Rapolu };
27145de35c9bSChiranjeevi Rapolu 
27155de35c9bSChiranjeevi Rapolu MODULE_DEVICE_TABLE(acpi, ov5670_acpi_ids);
27165de35c9bSChiranjeevi Rapolu #endif
27175de35c9bSChiranjeevi Rapolu 
27185635500aSJacopo Mondi static const struct of_device_id ov5670_of_ids[] = {
27195635500aSJacopo Mondi 	{ .compatible = "ovti,ov5670" },
27205635500aSJacopo Mondi 	{ /* sentinel */ }
27215635500aSJacopo Mondi };
27225635500aSJacopo Mondi MODULE_DEVICE_TABLE(of, ov5670_of_ids);
27235635500aSJacopo Mondi 
27245de35c9bSChiranjeevi Rapolu static struct i2c_driver ov5670_i2c_driver = {
27255de35c9bSChiranjeevi Rapolu 	.driver = {
27265de35c9bSChiranjeevi Rapolu 		.name = "ov5670",
27275de35c9bSChiranjeevi Rapolu 		.pm = &ov5670_pm_ops,
27285de35c9bSChiranjeevi Rapolu 		.acpi_match_table = ACPI_PTR(ov5670_acpi_ids),
27295635500aSJacopo Mondi 		.of_match_table = ov5670_of_ids,
27305de35c9bSChiranjeevi Rapolu 	},
27315de35c9bSChiranjeevi Rapolu 	.probe_new = ov5670_probe,
27325de35c9bSChiranjeevi Rapolu 	.remove = ov5670_remove,
27331e583b56SSakari Ailus 	.flags = I2C_DRV_ACPI_WAIVE_D0_PROBE,
27345de35c9bSChiranjeevi Rapolu };
27355de35c9bSChiranjeevi Rapolu 
27365de35c9bSChiranjeevi Rapolu module_i2c_driver(ov5670_i2c_driver);
27375de35c9bSChiranjeevi Rapolu 
27385de35c9bSChiranjeevi Rapolu MODULE_AUTHOR("Rapolu, Chiranjeevi <chiranjeevi.rapolu@intel.com>");
27395fcec420SSakari Ailus MODULE_AUTHOR("Yang, Hyungwoo");
27405de35c9bSChiranjeevi Rapolu MODULE_DESCRIPTION("Omnivision ov5670 sensor driver");
27415de35c9bSChiranjeevi Rapolu MODULE_LICENSE("GPL v2");
2742