18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (C) 2018 Intel Corporation
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <asm/unaligned.h>
58c2ecf20Sopenharmony_ci#include <linux/acpi.h>
68c2ecf20Sopenharmony_ci#include <linux/i2c.h>
78c2ecf20Sopenharmony_ci#include <linux/module.h>
88c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h>
98c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h>
108c2ecf20Sopenharmony_ci#include <media/v4l2-device.h>
118c2ecf20Sopenharmony_ci#include <media/v4l2-event.h>
128c2ecf20Sopenharmony_ci#include <media/v4l2-fwnode.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define IMX319_REG_MODE_SELECT		0x0100
158c2ecf20Sopenharmony_ci#define IMX319_MODE_STANDBY		0x00
168c2ecf20Sopenharmony_ci#define IMX319_MODE_STREAMING		0x01
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* Chip ID */
198c2ecf20Sopenharmony_ci#define IMX319_REG_CHIP_ID		0x0016
208c2ecf20Sopenharmony_ci#define IMX319_CHIP_ID			0x0319
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* V_TIMING internal */
238c2ecf20Sopenharmony_ci#define IMX319_REG_FLL			0x0340
248c2ecf20Sopenharmony_ci#define IMX319_FLL_MAX			0xffff
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Exposure control */
278c2ecf20Sopenharmony_ci#define IMX319_REG_EXPOSURE		0x0202
288c2ecf20Sopenharmony_ci#define IMX319_EXPOSURE_MIN		1
298c2ecf20Sopenharmony_ci#define IMX319_EXPOSURE_STEP		1
308c2ecf20Sopenharmony_ci#define IMX319_EXPOSURE_DEFAULT		0x04f6
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/*
338c2ecf20Sopenharmony_ci *  the digital control register for all color control looks like:
348c2ecf20Sopenharmony_ci *  +-----------------+------------------+
358c2ecf20Sopenharmony_ci *  |      [7:0]      |       [15:8]     |
368c2ecf20Sopenharmony_ci *  +-----------------+------------------+
378c2ecf20Sopenharmony_ci *  |	  0x020f      |       0x020e     |
388c2ecf20Sopenharmony_ci *  --------------------------------------
398c2ecf20Sopenharmony_ci *  it is used to calculate the digital gain times value(integral + fractional)
408c2ecf20Sopenharmony_ci *  the [15:8] bits is the fractional part and [7:0] bits is the integral
418c2ecf20Sopenharmony_ci *  calculation equation is:
428c2ecf20Sopenharmony_ci *      gain value (unit: times) = REG[15:8] + REG[7:0]/0x100
438c2ecf20Sopenharmony_ci *  Only value in 0x0100 ~ 0x0FFF range is allowed.
448c2ecf20Sopenharmony_ci *  Analog gain use 10 bits in the registers and allowed range is 0 ~ 960
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ci/* Analog gain control */
478c2ecf20Sopenharmony_ci#define IMX319_REG_ANALOG_GAIN		0x0204
488c2ecf20Sopenharmony_ci#define IMX319_ANA_GAIN_MIN		0
498c2ecf20Sopenharmony_ci#define IMX319_ANA_GAIN_MAX		960
508c2ecf20Sopenharmony_ci#define IMX319_ANA_GAIN_STEP		1
518c2ecf20Sopenharmony_ci#define IMX319_ANA_GAIN_DEFAULT		0
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* Digital gain control */
548c2ecf20Sopenharmony_ci#define IMX319_REG_DPGA_USE_GLOBAL_GAIN	0x3ff9
558c2ecf20Sopenharmony_ci#define IMX319_REG_DIG_GAIN_GLOBAL	0x020e
568c2ecf20Sopenharmony_ci#define IMX319_DGTL_GAIN_MIN		256
578c2ecf20Sopenharmony_ci#define IMX319_DGTL_GAIN_MAX		4095
588c2ecf20Sopenharmony_ci#define IMX319_DGTL_GAIN_STEP		1
598c2ecf20Sopenharmony_ci#define IMX319_DGTL_GAIN_DEFAULT	256
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Test Pattern Control */
628c2ecf20Sopenharmony_ci#define IMX319_REG_TEST_PATTERN		0x0600
638c2ecf20Sopenharmony_ci#define IMX319_TEST_PATTERN_DISABLED		0
648c2ecf20Sopenharmony_ci#define IMX319_TEST_PATTERN_SOLID_COLOR		1
658c2ecf20Sopenharmony_ci#define IMX319_TEST_PATTERN_COLOR_BARS		2
668c2ecf20Sopenharmony_ci#define IMX319_TEST_PATTERN_GRAY_COLOR_BARS	3
678c2ecf20Sopenharmony_ci#define IMX319_TEST_PATTERN_PN9			4
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/* Flip Control */
708c2ecf20Sopenharmony_ci#define IMX319_REG_ORIENTATION		0x0101
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* default link frequency and external clock */
738c2ecf20Sopenharmony_ci#define IMX319_LINK_FREQ_DEFAULT	482400000
748c2ecf20Sopenharmony_ci#define IMX319_EXT_CLK			19200000
758c2ecf20Sopenharmony_ci#define IMX319_LINK_FREQ_INDEX		0
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistruct imx319_reg {
788c2ecf20Sopenharmony_ci	u16 address;
798c2ecf20Sopenharmony_ci	u8 val;
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistruct imx319_reg_list {
838c2ecf20Sopenharmony_ci	u32 num_of_regs;
848c2ecf20Sopenharmony_ci	const struct imx319_reg *regs;
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/* Mode : resolution and related config&values */
888c2ecf20Sopenharmony_cistruct imx319_mode {
898c2ecf20Sopenharmony_ci	/* Frame width */
908c2ecf20Sopenharmony_ci	u32 width;
918c2ecf20Sopenharmony_ci	/* Frame height */
928c2ecf20Sopenharmony_ci	u32 height;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	/* V-timing */
958c2ecf20Sopenharmony_ci	u32 fll_def;
968c2ecf20Sopenharmony_ci	u32 fll_min;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	/* H-timing */
998c2ecf20Sopenharmony_ci	u32 llp;
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	/* index of link frequency */
1028c2ecf20Sopenharmony_ci	u32 link_freq_index;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	/* Default register values */
1058c2ecf20Sopenharmony_ci	struct imx319_reg_list reg_list;
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistruct imx319_hwcfg {
1098c2ecf20Sopenharmony_ci	u32 ext_clk;			/* sensor external clk */
1108c2ecf20Sopenharmony_ci	s64 *link_freqs;		/* CSI-2 link frequencies */
1118c2ecf20Sopenharmony_ci	unsigned int nr_of_link_freqs;
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistruct imx319 {
1158c2ecf20Sopenharmony_ci	struct v4l2_subdev sd;
1168c2ecf20Sopenharmony_ci	struct media_pad pad;
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	struct v4l2_ctrl_handler ctrl_handler;
1198c2ecf20Sopenharmony_ci	/* V4L2 Controls */
1208c2ecf20Sopenharmony_ci	struct v4l2_ctrl *link_freq;
1218c2ecf20Sopenharmony_ci	struct v4l2_ctrl *pixel_rate;
1228c2ecf20Sopenharmony_ci	struct v4l2_ctrl *vblank;
1238c2ecf20Sopenharmony_ci	struct v4l2_ctrl *hblank;
1248c2ecf20Sopenharmony_ci	struct v4l2_ctrl *exposure;
1258c2ecf20Sopenharmony_ci	struct v4l2_ctrl *vflip;
1268c2ecf20Sopenharmony_ci	struct v4l2_ctrl *hflip;
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	/* Current mode */
1298c2ecf20Sopenharmony_ci	const struct imx319_mode *cur_mode;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	struct imx319_hwcfg *hwcfg;
1328c2ecf20Sopenharmony_ci	s64 link_def_freq;	/* CSI-2 link default frequency */
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci	/*
1358c2ecf20Sopenharmony_ci	 * Mutex for serialized access:
1368c2ecf20Sopenharmony_ci	 * Protect sensor set pad format and start/stop streaming safely.
1378c2ecf20Sopenharmony_ci	 * Protect access to sensor v4l2 controls.
1388c2ecf20Sopenharmony_ci	 */
1398c2ecf20Sopenharmony_ci	struct mutex mutex;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	/* Streaming on/off */
1428c2ecf20Sopenharmony_ci	bool streaming;
1438c2ecf20Sopenharmony_ci};
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistatic const struct imx319_reg imx319_global_regs[] = {
1468c2ecf20Sopenharmony_ci	{ 0x0136, 0x13 },
1478c2ecf20Sopenharmony_ci	{ 0x0137, 0x33 },
1488c2ecf20Sopenharmony_ci	{ 0x3c7e, 0x05 },
1498c2ecf20Sopenharmony_ci	{ 0x3c7f, 0x07 },
1508c2ecf20Sopenharmony_ci	{ 0x4d39, 0x0b },
1518c2ecf20Sopenharmony_ci	{ 0x4d41, 0x33 },
1528c2ecf20Sopenharmony_ci	{ 0x4d43, 0x0c },
1538c2ecf20Sopenharmony_ci	{ 0x4d49, 0x89 },
1548c2ecf20Sopenharmony_ci	{ 0x4e05, 0x0b },
1558c2ecf20Sopenharmony_ci	{ 0x4e0d, 0x33 },
1568c2ecf20Sopenharmony_ci	{ 0x4e0f, 0x0c },
1578c2ecf20Sopenharmony_ci	{ 0x4e15, 0x89 },
1588c2ecf20Sopenharmony_ci	{ 0x4e49, 0x2a },
1598c2ecf20Sopenharmony_ci	{ 0x4e51, 0x33 },
1608c2ecf20Sopenharmony_ci	{ 0x4e53, 0x0c },
1618c2ecf20Sopenharmony_ci	{ 0x4e59, 0x89 },
1628c2ecf20Sopenharmony_ci	{ 0x5601, 0x4f },
1638c2ecf20Sopenharmony_ci	{ 0x560b, 0x45 },
1648c2ecf20Sopenharmony_ci	{ 0x562f, 0x0a },
1658c2ecf20Sopenharmony_ci	{ 0x5643, 0x0a },
1668c2ecf20Sopenharmony_ci	{ 0x5645, 0x0c },
1678c2ecf20Sopenharmony_ci	{ 0x56ef, 0x51 },
1688c2ecf20Sopenharmony_ci	{ 0x586f, 0x33 },
1698c2ecf20Sopenharmony_ci	{ 0x5873, 0x89 },
1708c2ecf20Sopenharmony_ci	{ 0x5905, 0x33 },
1718c2ecf20Sopenharmony_ci	{ 0x5907, 0x89 },
1728c2ecf20Sopenharmony_ci	{ 0x590d, 0x33 },
1738c2ecf20Sopenharmony_ci	{ 0x590f, 0x89 },
1748c2ecf20Sopenharmony_ci	{ 0x5915, 0x33 },
1758c2ecf20Sopenharmony_ci	{ 0x5917, 0x89 },
1768c2ecf20Sopenharmony_ci	{ 0x5969, 0x1c },
1778c2ecf20Sopenharmony_ci	{ 0x596b, 0x72 },
1788c2ecf20Sopenharmony_ci	{ 0x5971, 0x33 },
1798c2ecf20Sopenharmony_ci	{ 0x5973, 0x89 },
1808c2ecf20Sopenharmony_ci	{ 0x5975, 0x33 },
1818c2ecf20Sopenharmony_ci	{ 0x5977, 0x89 },
1828c2ecf20Sopenharmony_ci	{ 0x5979, 0x1c },
1838c2ecf20Sopenharmony_ci	{ 0x597b, 0x72 },
1848c2ecf20Sopenharmony_ci	{ 0x5985, 0x33 },
1858c2ecf20Sopenharmony_ci	{ 0x5987, 0x89 },
1868c2ecf20Sopenharmony_ci	{ 0x5999, 0x1c },
1878c2ecf20Sopenharmony_ci	{ 0x599b, 0x72 },
1888c2ecf20Sopenharmony_ci	{ 0x59a5, 0x33 },
1898c2ecf20Sopenharmony_ci	{ 0x59a7, 0x89 },
1908c2ecf20Sopenharmony_ci	{ 0x7485, 0x08 },
1918c2ecf20Sopenharmony_ci	{ 0x7487, 0x0c },
1928c2ecf20Sopenharmony_ci	{ 0x7489, 0xc7 },
1938c2ecf20Sopenharmony_ci	{ 0x748b, 0x8b },
1948c2ecf20Sopenharmony_ci	{ 0x9004, 0x09 },
1958c2ecf20Sopenharmony_ci	{ 0x9200, 0x6a },
1968c2ecf20Sopenharmony_ci	{ 0x9201, 0x22 },
1978c2ecf20Sopenharmony_ci	{ 0x9202, 0x6a },
1988c2ecf20Sopenharmony_ci	{ 0x9203, 0x23 },
1998c2ecf20Sopenharmony_ci	{ 0x9204, 0x5f },
2008c2ecf20Sopenharmony_ci	{ 0x9205, 0x23 },
2018c2ecf20Sopenharmony_ci	{ 0x9206, 0x5f },
2028c2ecf20Sopenharmony_ci	{ 0x9207, 0x24 },
2038c2ecf20Sopenharmony_ci	{ 0x9208, 0x5f },
2048c2ecf20Sopenharmony_ci	{ 0x9209, 0x26 },
2058c2ecf20Sopenharmony_ci	{ 0x920a, 0x5f },
2068c2ecf20Sopenharmony_ci	{ 0x920b, 0x27 },
2078c2ecf20Sopenharmony_ci	{ 0x920c, 0x5f },
2088c2ecf20Sopenharmony_ci	{ 0x920d, 0x29 },
2098c2ecf20Sopenharmony_ci	{ 0x920e, 0x5f },
2108c2ecf20Sopenharmony_ci	{ 0x920f, 0x2a },
2118c2ecf20Sopenharmony_ci	{ 0x9210, 0x5f },
2128c2ecf20Sopenharmony_ci	{ 0x9211, 0x2c },
2138c2ecf20Sopenharmony_ci	{ 0xbc22, 0x1a },
2148c2ecf20Sopenharmony_ci	{ 0xf01f, 0x04 },
2158c2ecf20Sopenharmony_ci	{ 0xf021, 0x03 },
2168c2ecf20Sopenharmony_ci	{ 0xf023, 0x02 },
2178c2ecf20Sopenharmony_ci	{ 0xf03d, 0x05 },
2188c2ecf20Sopenharmony_ci	{ 0xf03f, 0x03 },
2198c2ecf20Sopenharmony_ci	{ 0xf041, 0x02 },
2208c2ecf20Sopenharmony_ci	{ 0xf0af, 0x04 },
2218c2ecf20Sopenharmony_ci	{ 0xf0b1, 0x03 },
2228c2ecf20Sopenharmony_ci	{ 0xf0b3, 0x02 },
2238c2ecf20Sopenharmony_ci	{ 0xf0cd, 0x05 },
2248c2ecf20Sopenharmony_ci	{ 0xf0cf, 0x03 },
2258c2ecf20Sopenharmony_ci	{ 0xf0d1, 0x02 },
2268c2ecf20Sopenharmony_ci	{ 0xf13f, 0x04 },
2278c2ecf20Sopenharmony_ci	{ 0xf141, 0x03 },
2288c2ecf20Sopenharmony_ci	{ 0xf143, 0x02 },
2298c2ecf20Sopenharmony_ci	{ 0xf15d, 0x05 },
2308c2ecf20Sopenharmony_ci	{ 0xf15f, 0x03 },
2318c2ecf20Sopenharmony_ci	{ 0xf161, 0x02 },
2328c2ecf20Sopenharmony_ci	{ 0xf1cf, 0x04 },
2338c2ecf20Sopenharmony_ci	{ 0xf1d1, 0x03 },
2348c2ecf20Sopenharmony_ci	{ 0xf1d3, 0x02 },
2358c2ecf20Sopenharmony_ci	{ 0xf1ed, 0x05 },
2368c2ecf20Sopenharmony_ci	{ 0xf1ef, 0x03 },
2378c2ecf20Sopenharmony_ci	{ 0xf1f1, 0x02 },
2388c2ecf20Sopenharmony_ci	{ 0xf287, 0x04 },
2398c2ecf20Sopenharmony_ci	{ 0xf289, 0x03 },
2408c2ecf20Sopenharmony_ci	{ 0xf28b, 0x02 },
2418c2ecf20Sopenharmony_ci	{ 0xf2a5, 0x05 },
2428c2ecf20Sopenharmony_ci	{ 0xf2a7, 0x03 },
2438c2ecf20Sopenharmony_ci	{ 0xf2a9, 0x02 },
2448c2ecf20Sopenharmony_ci	{ 0xf2b7, 0x04 },
2458c2ecf20Sopenharmony_ci	{ 0xf2b9, 0x03 },
2468c2ecf20Sopenharmony_ci	{ 0xf2bb, 0x02 },
2478c2ecf20Sopenharmony_ci	{ 0xf2d5, 0x05 },
2488c2ecf20Sopenharmony_ci	{ 0xf2d7, 0x03 },
2498c2ecf20Sopenharmony_ci	{ 0xf2d9, 0x02 },
2508c2ecf20Sopenharmony_ci};
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_cistatic const struct imx319_reg_list imx319_global_setting = {
2538c2ecf20Sopenharmony_ci	.num_of_regs = ARRAY_SIZE(imx319_global_regs),
2548c2ecf20Sopenharmony_ci	.regs = imx319_global_regs,
2558c2ecf20Sopenharmony_ci};
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_3264x2448_regs[] = {
2588c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
2598c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
2608c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
2618c2ecf20Sopenharmony_ci	{ 0x0342, 0x0f },
2628c2ecf20Sopenharmony_ci	{ 0x0343, 0x80 },
2638c2ecf20Sopenharmony_ci	{ 0x0340, 0x0c },
2648c2ecf20Sopenharmony_ci	{ 0x0341, 0xaa },
2658c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
2668c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
2678c2ecf20Sopenharmony_ci	{ 0x0346, 0x00 },
2688c2ecf20Sopenharmony_ci	{ 0x0347, 0x00 },
2698c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
2708c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
2718c2ecf20Sopenharmony_ci	{ 0x034a, 0x09 },
2728c2ecf20Sopenharmony_ci	{ 0x034b, 0x9f },
2738c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
2748c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
2758c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
2768c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
2778c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
2788c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
2798c2ecf20Sopenharmony_ci	{ 0x0900, 0x00 },
2808c2ecf20Sopenharmony_ci	{ 0x0901, 0x11 },
2818c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
2828c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
2838c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
2848c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
2858c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
2868c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x01 },
2878c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
2888c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
2898c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
2908c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
2918c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
2928c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
2938c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
2948c2ecf20Sopenharmony_ci	{ 0x0409, 0x08 },
2958c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
2968c2ecf20Sopenharmony_ci	{ 0x040b, 0x08 },
2978c2ecf20Sopenharmony_ci	{ 0x040c, 0x0c },
2988c2ecf20Sopenharmony_ci	{ 0x040d, 0xc0 },
2998c2ecf20Sopenharmony_ci	{ 0x040e, 0x09 },
3008c2ecf20Sopenharmony_ci	{ 0x040f, 0x90 },
3018c2ecf20Sopenharmony_ci	{ 0x034c, 0x0c },
3028c2ecf20Sopenharmony_ci	{ 0x034d, 0xc0 },
3038c2ecf20Sopenharmony_ci	{ 0x034e, 0x09 },
3048c2ecf20Sopenharmony_ci	{ 0x034f, 0x90 },
3058c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
3068c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
3078c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
3088c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
3098c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
3108c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
3118c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
3128c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
3138c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
3148c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
3158c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
3168c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
3178c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
3188c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
3198c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
3208c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
3218c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
3228c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
3238c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
3248c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
3258c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
3268c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
3278c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
3288c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
3298c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
3308c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
3318c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
3328c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
3338c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
3348c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
3358c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
3368c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
3378c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
3388c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
3398c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
3408c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
3418c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
3428c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
3438c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
3448c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
3458c2ecf20Sopenharmony_ci	{ 0x3c01, 0x48 },
3468c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
3478c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
3488c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
3498c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
3508c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
3518c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
3528c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
3538c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
3548c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
3558c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
3568c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
3578c2ecf20Sopenharmony_ci	{ 0x3f78, 0x01 },
3588c2ecf20Sopenharmony_ci	{ 0x3f79, 0x18 },
3598c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
3608c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
3618c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
3628c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
3638c2ecf20Sopenharmony_ci	{ 0xa081, 0x00 },
3648c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
3658c2ecf20Sopenharmony_ci	{ 0x0202, 0x0a },
3668c2ecf20Sopenharmony_ci	{ 0x0203, 0x7a },
3678c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
3688c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
3698c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
3708c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
3718c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
3728c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
3738c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
3748c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
3758c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
3768c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
3778c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
3788c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
3798c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
3808c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
3818c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
3828c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
3838c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
3848c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
3858c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
3868c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
3878c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
3888c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
3898c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
3908c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
3918c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
3928c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
3938c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
3948c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
3958c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
3968c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
3978c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
3988c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
3998c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
4008c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
4018c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
4028c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
4038c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
4048c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
4058c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
4068c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
4078c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
4088c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
4098c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
4108c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
4118c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
4128c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
4138c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
4148c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
4158c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
4168c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
4178c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
4188c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
4198c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
4208c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
4218c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
4228c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
4238c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
4248c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
4258c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
4268c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
4278c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
4288c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
4298c2ecf20Sopenharmony_ci};
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_3280x2464_regs[] = {
4328c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
4338c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
4348c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
4358c2ecf20Sopenharmony_ci	{ 0x0342, 0x0f },
4368c2ecf20Sopenharmony_ci	{ 0x0343, 0x80 },
4378c2ecf20Sopenharmony_ci	{ 0x0340, 0x0c },
4388c2ecf20Sopenharmony_ci	{ 0x0341, 0xaa },
4398c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
4408c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
4418c2ecf20Sopenharmony_ci	{ 0x0346, 0x00 },
4428c2ecf20Sopenharmony_ci	{ 0x0347, 0x00 },
4438c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
4448c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
4458c2ecf20Sopenharmony_ci	{ 0x034a, 0x09 },
4468c2ecf20Sopenharmony_ci	{ 0x034b, 0x9f },
4478c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
4488c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
4498c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
4508c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
4518c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
4528c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
4538c2ecf20Sopenharmony_ci	{ 0x0900, 0x00 },
4548c2ecf20Sopenharmony_ci	{ 0x0901, 0x11 },
4558c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
4568c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
4578c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
4588c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
4598c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
4608c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x01 },
4618c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
4628c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
4638c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
4648c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
4658c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
4668c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
4678c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
4688c2ecf20Sopenharmony_ci	{ 0x0409, 0x00 },
4698c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
4708c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
4718c2ecf20Sopenharmony_ci	{ 0x040c, 0x0c },
4728c2ecf20Sopenharmony_ci	{ 0x040d, 0xd0 },
4738c2ecf20Sopenharmony_ci	{ 0x040e, 0x09 },
4748c2ecf20Sopenharmony_ci	{ 0x040f, 0xa0 },
4758c2ecf20Sopenharmony_ci	{ 0x034c, 0x0c },
4768c2ecf20Sopenharmony_ci	{ 0x034d, 0xd0 },
4778c2ecf20Sopenharmony_ci	{ 0x034e, 0x09 },
4788c2ecf20Sopenharmony_ci	{ 0x034f, 0xa0 },
4798c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
4808c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
4818c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
4828c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
4838c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
4848c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
4858c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
4868c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
4878c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
4888c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
4898c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
4908c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
4918c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
4928c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
4938c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
4948c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
4958c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
4968c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
4978c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
4988c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
4998c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
5008c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
5018c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
5028c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
5038c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
5048c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
5058c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
5068c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
5078c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
5088c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
5098c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
5108c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
5118c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
5128c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
5138c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
5148c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
5158c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
5168c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
5178c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
5188c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
5198c2ecf20Sopenharmony_ci	{ 0x3c01, 0x48 },
5208c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
5218c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
5228c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
5238c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
5248c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
5258c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
5268c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
5278c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
5288c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
5298c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
5308c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
5318c2ecf20Sopenharmony_ci	{ 0x3f78, 0x01 },
5328c2ecf20Sopenharmony_ci	{ 0x3f79, 0x18 },
5338c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
5348c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
5358c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
5368c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
5378c2ecf20Sopenharmony_ci	{ 0xa081, 0x00 },
5388c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
5398c2ecf20Sopenharmony_ci	{ 0x0202, 0x0a },
5408c2ecf20Sopenharmony_ci	{ 0x0203, 0x7a },
5418c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
5428c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
5438c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
5448c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
5458c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
5468c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
5478c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
5488c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
5498c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
5508c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
5518c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
5528c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
5538c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
5548c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
5558c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
5568c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
5578c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
5588c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
5598c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
5608c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
5618c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
5628c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
5638c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
5648c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
5658c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
5668c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
5678c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
5688c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
5698c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
5708c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
5718c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
5728c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
5738c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
5748c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
5758c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
5768c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
5778c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
5788c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
5798c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
5808c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
5818c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
5828c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
5838c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
5848c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
5858c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
5868c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
5878c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
5888c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
5898c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
5908c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
5918c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
5928c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
5938c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
5948c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
5958c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
5968c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
5978c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
5988c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
5998c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
6008c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
6018c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
6028c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
6038c2ecf20Sopenharmony_ci};
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1936x1096_regs[] = {
6068c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
6078c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
6088c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
6098c2ecf20Sopenharmony_ci	{ 0x0342, 0x0f },
6108c2ecf20Sopenharmony_ci	{ 0x0343, 0x80 },
6118c2ecf20Sopenharmony_ci	{ 0x0340, 0x0c },
6128c2ecf20Sopenharmony_ci	{ 0x0341, 0xaa },
6138c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
6148c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
6158c2ecf20Sopenharmony_ci	{ 0x0346, 0x02 },
6168c2ecf20Sopenharmony_ci	{ 0x0347, 0xac },
6178c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
6188c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
6198c2ecf20Sopenharmony_ci	{ 0x034a, 0x06 },
6208c2ecf20Sopenharmony_ci	{ 0x034b, 0xf3 },
6218c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
6228c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
6238c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
6248c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
6258c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
6268c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
6278c2ecf20Sopenharmony_ci	{ 0x0900, 0x00 },
6288c2ecf20Sopenharmony_ci	{ 0x0901, 0x11 },
6298c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
6308c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
6318c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
6328c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
6338c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
6348c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x01 },
6358c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
6368c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
6378c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
6388c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
6398c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
6408c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
6418c2ecf20Sopenharmony_ci	{ 0x0408, 0x02 },
6428c2ecf20Sopenharmony_ci	{ 0x0409, 0xa0 },
6438c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
6448c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
6458c2ecf20Sopenharmony_ci	{ 0x040c, 0x07 },
6468c2ecf20Sopenharmony_ci	{ 0x040d, 0x90 },
6478c2ecf20Sopenharmony_ci	{ 0x040e, 0x04 },
6488c2ecf20Sopenharmony_ci	{ 0x040f, 0x48 },
6498c2ecf20Sopenharmony_ci	{ 0x034c, 0x07 },
6508c2ecf20Sopenharmony_ci	{ 0x034d, 0x90 },
6518c2ecf20Sopenharmony_ci	{ 0x034e, 0x04 },
6528c2ecf20Sopenharmony_ci	{ 0x034f, 0x48 },
6538c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
6548c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
6558c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
6568c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
6578c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
6588c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
6598c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
6608c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
6618c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
6628c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
6638c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
6648c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
6658c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
6668c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
6678c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
6688c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
6698c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
6708c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
6718c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
6728c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
6738c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
6748c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
6758c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
6768c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
6778c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
6788c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
6798c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
6808c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
6818c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
6828c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
6838c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
6848c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
6858c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
6868c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
6878c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
6888c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
6898c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
6908c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
6918c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
6928c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
6938c2ecf20Sopenharmony_ci	{ 0x3c01, 0x48 },
6948c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
6958c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
6968c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
6978c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
6988c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
6998c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
7008c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
7018c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
7028c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
7038c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
7048c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
7058c2ecf20Sopenharmony_ci	{ 0x3f78, 0x01 },
7068c2ecf20Sopenharmony_ci	{ 0x3f79, 0x18 },
7078c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
7088c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
7098c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
7108c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
7118c2ecf20Sopenharmony_ci	{ 0xa081, 0x00 },
7128c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
7138c2ecf20Sopenharmony_ci	{ 0x0202, 0x05 },
7148c2ecf20Sopenharmony_ci	{ 0x0203, 0x34 },
7158c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
7168c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
7178c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
7188c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
7198c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
7208c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
7218c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
7228c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
7238c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
7248c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
7258c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
7268c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
7278c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
7288c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
7298c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
7308c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
7318c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
7328c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
7338c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
7348c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
7358c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
7368c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
7378c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
7388c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
7398c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
7408c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
7418c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
7428c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
7438c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
7448c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
7458c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
7468c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
7478c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
7488c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
7498c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
7508c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
7518c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
7528c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
7538c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
7548c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
7558c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
7568c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
7578c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
7588c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
7598c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
7608c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
7618c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
7628c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
7638c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
7648c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
7658c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
7668c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
7678c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
7688c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
7698c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
7708c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
7718c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
7728c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
7738c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
7748c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
7758c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
7768c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
7778c2ecf20Sopenharmony_ci};
7788c2ecf20Sopenharmony_ci
7798c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1920x1080_regs[] = {
7808c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
7818c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
7828c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
7838c2ecf20Sopenharmony_ci	{ 0x0342, 0x0f },
7848c2ecf20Sopenharmony_ci	{ 0x0343, 0x80 },
7858c2ecf20Sopenharmony_ci	{ 0x0340, 0x0c },
7868c2ecf20Sopenharmony_ci	{ 0x0341, 0xaa },
7878c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
7888c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
7898c2ecf20Sopenharmony_ci	{ 0x0346, 0x02 },
7908c2ecf20Sopenharmony_ci	{ 0x0347, 0xb4 },
7918c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
7928c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
7938c2ecf20Sopenharmony_ci	{ 0x034a, 0x06 },
7948c2ecf20Sopenharmony_ci	{ 0x034b, 0xeb },
7958c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
7968c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
7978c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
7988c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
7998c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
8008c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
8018c2ecf20Sopenharmony_ci	{ 0x0900, 0x00 },
8028c2ecf20Sopenharmony_ci	{ 0x0901, 0x11 },
8038c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
8048c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
8058c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
8068c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
8078c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
8088c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x01 },
8098c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
8108c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
8118c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
8128c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
8138c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
8148c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
8158c2ecf20Sopenharmony_ci	{ 0x0408, 0x02 },
8168c2ecf20Sopenharmony_ci	{ 0x0409, 0xa8 },
8178c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
8188c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
8198c2ecf20Sopenharmony_ci	{ 0x040c, 0x07 },
8208c2ecf20Sopenharmony_ci	{ 0x040d, 0x80 },
8218c2ecf20Sopenharmony_ci	{ 0x040e, 0x04 },
8228c2ecf20Sopenharmony_ci	{ 0x040f, 0x38 },
8238c2ecf20Sopenharmony_ci	{ 0x034c, 0x07 },
8248c2ecf20Sopenharmony_ci	{ 0x034d, 0x80 },
8258c2ecf20Sopenharmony_ci	{ 0x034e, 0x04 },
8268c2ecf20Sopenharmony_ci	{ 0x034f, 0x38 },
8278c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
8288c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
8298c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
8308c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
8318c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
8328c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
8338c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
8348c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
8358c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
8368c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
8378c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
8388c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
8398c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
8408c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
8418c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
8428c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
8438c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
8448c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
8458c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
8468c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
8478c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
8488c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
8498c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
8508c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
8518c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
8528c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
8538c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
8548c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
8558c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
8568c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
8578c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
8588c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
8598c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
8608c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
8618c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
8628c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
8638c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
8648c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
8658c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
8668c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
8678c2ecf20Sopenharmony_ci	{ 0x3c01, 0x48 },
8688c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
8698c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
8708c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
8718c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
8728c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
8738c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
8748c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
8758c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
8768c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
8778c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
8788c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
8798c2ecf20Sopenharmony_ci	{ 0x3f78, 0x01 },
8808c2ecf20Sopenharmony_ci	{ 0x3f79, 0x18 },
8818c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
8828c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
8838c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
8848c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
8858c2ecf20Sopenharmony_ci	{ 0xa081, 0x00 },
8868c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
8878c2ecf20Sopenharmony_ci	{ 0x0202, 0x05 },
8888c2ecf20Sopenharmony_ci	{ 0x0203, 0x34 },
8898c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
8908c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
8918c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
8928c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
8938c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
8948c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
8958c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
8968c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
8978c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
8988c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
8998c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
9008c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
9018c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
9028c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
9038c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
9048c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
9058c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
9068c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
9078c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
9088c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
9098c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
9108c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
9118c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
9128c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
9138c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
9148c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
9158c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
9168c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
9178c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
9188c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
9198c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
9208c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
9218c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
9228c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
9238c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
9248c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
9258c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
9268c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
9278c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
9288c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
9298c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
9308c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
9318c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
9328c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
9338c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
9348c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
9358c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
9368c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
9378c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
9388c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
9398c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
9408c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
9418c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
9428c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
9438c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
9448c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
9458c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
9468c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
9478c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
9488c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
9498c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
9508c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
9518c2ecf20Sopenharmony_ci};
9528c2ecf20Sopenharmony_ci
9538c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1640x1232_regs[] = {
9548c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
9558c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
9568c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
9578c2ecf20Sopenharmony_ci	{ 0x0342, 0x08 },
9588c2ecf20Sopenharmony_ci	{ 0x0343, 0x20 },
9598c2ecf20Sopenharmony_ci	{ 0x0340, 0x18 },
9608c2ecf20Sopenharmony_ci	{ 0x0341, 0x2a },
9618c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
9628c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
9638c2ecf20Sopenharmony_ci	{ 0x0346, 0x00 },
9648c2ecf20Sopenharmony_ci	{ 0x0347, 0x00 },
9658c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
9668c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
9678c2ecf20Sopenharmony_ci	{ 0x034a, 0x09 },
9688c2ecf20Sopenharmony_ci	{ 0x034b, 0x9f },
9698c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
9708c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
9718c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
9728c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
9738c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
9748c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
9758c2ecf20Sopenharmony_ci	{ 0x0900, 0x01 },
9768c2ecf20Sopenharmony_ci	{ 0x0901, 0x22 },
9778c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
9788c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
9798c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
9808c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
9818c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
9828c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x02 },
9838c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
9848c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
9858c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
9868c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
9878c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
9888c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
9898c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
9908c2ecf20Sopenharmony_ci	{ 0x0409, 0x00 },
9918c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
9928c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
9938c2ecf20Sopenharmony_ci	{ 0x040c, 0x06 },
9948c2ecf20Sopenharmony_ci	{ 0x040d, 0x68 },
9958c2ecf20Sopenharmony_ci	{ 0x040e, 0x04 },
9968c2ecf20Sopenharmony_ci	{ 0x040f, 0xd0 },
9978c2ecf20Sopenharmony_ci	{ 0x034c, 0x06 },
9988c2ecf20Sopenharmony_ci	{ 0x034d, 0x68 },
9998c2ecf20Sopenharmony_ci	{ 0x034e, 0x04 },
10008c2ecf20Sopenharmony_ci	{ 0x034f, 0xd0 },
10018c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
10028c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
10038c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
10048c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
10058c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
10068c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
10078c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
10088c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
10098c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
10108c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
10118c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
10128c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
10138c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
10148c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
10158c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
10168c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
10178c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
10188c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
10198c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
10208c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
10218c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
10228c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
10238c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
10248c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
10258c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
10268c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
10278c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
10288c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
10298c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
10308c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
10318c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
10328c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
10338c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
10348c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
10358c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
10368c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
10378c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
10388c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
10398c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
10408c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
10418c2ecf20Sopenharmony_ci	{ 0x3c01, 0xba },
10428c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
10438c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
10448c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
10458c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
10468c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
10478c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
10488c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
10498c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
10508c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
10518c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
10528c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
10538c2ecf20Sopenharmony_ci	{ 0x3f78, 0x00 },
10548c2ecf20Sopenharmony_ci	{ 0x3f79, 0x34 },
10558c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
10568c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
10578c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
10588c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
10598c2ecf20Sopenharmony_ci	{ 0xa081, 0x04 },
10608c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
10618c2ecf20Sopenharmony_ci	{ 0x0202, 0x04 },
10628c2ecf20Sopenharmony_ci	{ 0x0203, 0xf6 },
10638c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
10648c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
10658c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
10668c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
10678c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
10688c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
10698c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
10708c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
10718c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
10728c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
10738c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
10748c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
10758c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
10768c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
10778c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
10788c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
10798c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
10808c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
10818c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
10828c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
10838c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
10848c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
10858c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
10868c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
10878c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
10888c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
10898c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
10908c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
10918c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
10928c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
10938c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
10948c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
10958c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
10968c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
10978c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
10988c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
10998c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
11008c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
11018c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
11028c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
11038c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
11048c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
11058c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
11068c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
11078c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
11088c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
11098c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
11108c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
11118c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
11128c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
11138c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
11148c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
11158c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
11168c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
11178c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
11188c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
11198c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
11208c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
11218c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
11228c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
11238c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
11248c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
11258c2ecf20Sopenharmony_ci};
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1640x922_regs[] = {
11288c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
11298c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
11308c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
11318c2ecf20Sopenharmony_ci	{ 0x0342, 0x08 },
11328c2ecf20Sopenharmony_ci	{ 0x0343, 0x20 },
11338c2ecf20Sopenharmony_ci	{ 0x0340, 0x18 },
11348c2ecf20Sopenharmony_ci	{ 0x0341, 0x2a },
11358c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
11368c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
11378c2ecf20Sopenharmony_ci	{ 0x0346, 0x01 },
11388c2ecf20Sopenharmony_ci	{ 0x0347, 0x30 },
11398c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
11408c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
11418c2ecf20Sopenharmony_ci	{ 0x034a, 0x08 },
11428c2ecf20Sopenharmony_ci	{ 0x034b, 0x6f },
11438c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
11448c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
11458c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
11468c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
11478c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
11488c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
11498c2ecf20Sopenharmony_ci	{ 0x0900, 0x01 },
11508c2ecf20Sopenharmony_ci	{ 0x0901, 0x22 },
11518c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
11528c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
11538c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
11548c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
11558c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
11568c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x02 },
11578c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
11588c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
11598c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
11608c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
11618c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
11628c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
11638c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
11648c2ecf20Sopenharmony_ci	{ 0x0409, 0x00 },
11658c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
11668c2ecf20Sopenharmony_ci	{ 0x040b, 0x02 },
11678c2ecf20Sopenharmony_ci	{ 0x040c, 0x06 },
11688c2ecf20Sopenharmony_ci	{ 0x040d, 0x68 },
11698c2ecf20Sopenharmony_ci	{ 0x040e, 0x03 },
11708c2ecf20Sopenharmony_ci	{ 0x040f, 0x9a },
11718c2ecf20Sopenharmony_ci	{ 0x034c, 0x06 },
11728c2ecf20Sopenharmony_ci	{ 0x034d, 0x68 },
11738c2ecf20Sopenharmony_ci	{ 0x034e, 0x03 },
11748c2ecf20Sopenharmony_ci	{ 0x034f, 0x9a },
11758c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
11768c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
11778c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
11788c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
11798c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
11808c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
11818c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
11828c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
11838c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
11848c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
11858c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
11868c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
11878c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
11888c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
11898c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
11908c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
11918c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
11928c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
11938c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
11948c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
11958c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
11968c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
11978c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
11988c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
11998c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
12008c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
12018c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
12028c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
12038c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
12048c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
12058c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
12068c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
12078c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
12088c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
12098c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
12108c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
12118c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
12128c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
12138c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
12148c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
12158c2ecf20Sopenharmony_ci	{ 0x3c01, 0xba },
12168c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
12178c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
12188c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
12198c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
12208c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
12218c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
12228c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
12238c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
12248c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
12258c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
12268c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
12278c2ecf20Sopenharmony_ci	{ 0x3f78, 0x00 },
12288c2ecf20Sopenharmony_ci	{ 0x3f79, 0x34 },
12298c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
12308c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
12318c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
12328c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
12338c2ecf20Sopenharmony_ci	{ 0xa081, 0x04 },
12348c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
12358c2ecf20Sopenharmony_ci	{ 0x0202, 0x04 },
12368c2ecf20Sopenharmony_ci	{ 0x0203, 0xf6 },
12378c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
12388c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
12398c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
12408c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
12418c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
12428c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
12438c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
12448c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
12458c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
12468c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
12478c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
12488c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
12498c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
12508c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
12518c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
12528c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
12538c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
12548c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
12558c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
12568c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
12578c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
12588c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
12598c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
12608c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
12618c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
12628c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
12638c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
12648c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
12658c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
12668c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
12678c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
12688c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
12698c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
12708c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
12718c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
12728c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
12738c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
12748c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
12758c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
12768c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
12778c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
12788c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
12798c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
12808c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
12818c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
12828c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
12838c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
12848c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
12858c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
12868c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
12878c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
12888c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
12898c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
12908c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
12918c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
12928c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
12938c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
12948c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
12958c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
12968c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
12978c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
12988c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
12998c2ecf20Sopenharmony_ci};
13008c2ecf20Sopenharmony_ci
13018c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1296x736_regs[] = {
13028c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
13038c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
13048c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
13058c2ecf20Sopenharmony_ci	{ 0x0342, 0x08 },
13068c2ecf20Sopenharmony_ci	{ 0x0343, 0x20 },
13078c2ecf20Sopenharmony_ci	{ 0x0340, 0x18 },
13088c2ecf20Sopenharmony_ci	{ 0x0341, 0x2a },
13098c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
13108c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
13118c2ecf20Sopenharmony_ci	{ 0x0346, 0x01 },
13128c2ecf20Sopenharmony_ci	{ 0x0347, 0xf0 },
13138c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
13148c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
13158c2ecf20Sopenharmony_ci	{ 0x034a, 0x07 },
13168c2ecf20Sopenharmony_ci	{ 0x034b, 0xaf },
13178c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
13188c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
13198c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
13208c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
13218c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
13228c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
13238c2ecf20Sopenharmony_ci	{ 0x0900, 0x01 },
13248c2ecf20Sopenharmony_ci	{ 0x0901, 0x22 },
13258c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
13268c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
13278c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
13288c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
13298c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
13308c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x02 },
13318c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
13328c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
13338c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
13348c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
13358c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
13368c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
13378c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
13388c2ecf20Sopenharmony_ci	{ 0x0409, 0xac },
13398c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
13408c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
13418c2ecf20Sopenharmony_ci	{ 0x040c, 0x05 },
13428c2ecf20Sopenharmony_ci	{ 0x040d, 0x10 },
13438c2ecf20Sopenharmony_ci	{ 0x040e, 0x02 },
13448c2ecf20Sopenharmony_ci	{ 0x040f, 0xe0 },
13458c2ecf20Sopenharmony_ci	{ 0x034c, 0x05 },
13468c2ecf20Sopenharmony_ci	{ 0x034d, 0x10 },
13478c2ecf20Sopenharmony_ci	{ 0x034e, 0x02 },
13488c2ecf20Sopenharmony_ci	{ 0x034f, 0xe0 },
13498c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
13508c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
13518c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
13528c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
13538c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
13548c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
13558c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
13568c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
13578c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
13588c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
13598c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
13608c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
13618c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
13628c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
13638c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
13648c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
13658c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
13668c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
13678c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
13688c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
13698c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
13708c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
13718c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
13728c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
13738c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
13748c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
13758c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
13768c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
13778c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
13788c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
13798c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
13808c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
13818c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
13828c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
13838c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
13848c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
13858c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
13868c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
13878c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
13888c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
13898c2ecf20Sopenharmony_ci	{ 0x3c01, 0xba },
13908c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
13918c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
13928c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
13938c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
13948c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
13958c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
13968c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
13978c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
13988c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
13998c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
14008c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
14018c2ecf20Sopenharmony_ci	{ 0x3f78, 0x00 },
14028c2ecf20Sopenharmony_ci	{ 0x3f79, 0x34 },
14038c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
14048c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
14058c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
14068c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
14078c2ecf20Sopenharmony_ci	{ 0xa081, 0x04 },
14088c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
14098c2ecf20Sopenharmony_ci	{ 0x0202, 0x04 },
14108c2ecf20Sopenharmony_ci	{ 0x0203, 0xf6 },
14118c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
14128c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
14138c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
14148c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
14158c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
14168c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
14178c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
14188c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
14198c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
14208c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
14218c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
14228c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
14238c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
14248c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
14258c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
14268c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
14278c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
14288c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
14298c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
14308c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
14318c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
14328c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
14338c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
14348c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
14358c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
14368c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
14378c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
14388c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
14398c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
14408c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
14418c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
14428c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
14438c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
14448c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
14458c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
14468c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
14478c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
14488c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
14498c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
14508c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
14518c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
14528c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
14538c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
14548c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
14558c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
14568c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
14578c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
14588c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
14598c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
14608c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
14618c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
14628c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
14638c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
14648c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
14658c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
14668c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
14678c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
14688c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
14698c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
14708c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
14718c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
14728c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
14738c2ecf20Sopenharmony_ci};
14748c2ecf20Sopenharmony_ci
14758c2ecf20Sopenharmony_cistatic const struct imx319_reg mode_1280x720_regs[] = {
14768c2ecf20Sopenharmony_ci	{ 0x0112, 0x0a },
14778c2ecf20Sopenharmony_ci	{ 0x0113, 0x0a },
14788c2ecf20Sopenharmony_ci	{ 0x0114, 0x03 },
14798c2ecf20Sopenharmony_ci	{ 0x0342, 0x08 },
14808c2ecf20Sopenharmony_ci	{ 0x0343, 0x20 },
14818c2ecf20Sopenharmony_ci	{ 0x0340, 0x18 },
14828c2ecf20Sopenharmony_ci	{ 0x0341, 0x2a },
14838c2ecf20Sopenharmony_ci	{ 0x0344, 0x00 },
14848c2ecf20Sopenharmony_ci	{ 0x0345, 0x00 },
14858c2ecf20Sopenharmony_ci	{ 0x0346, 0x02 },
14868c2ecf20Sopenharmony_ci	{ 0x0347, 0x00 },
14878c2ecf20Sopenharmony_ci	{ 0x0348, 0x0c },
14888c2ecf20Sopenharmony_ci	{ 0x0349, 0xcf },
14898c2ecf20Sopenharmony_ci	{ 0x034a, 0x07 },
14908c2ecf20Sopenharmony_ci	{ 0x034b, 0x9f },
14918c2ecf20Sopenharmony_ci	{ 0x0220, 0x00 },
14928c2ecf20Sopenharmony_ci	{ 0x0221, 0x11 },
14938c2ecf20Sopenharmony_ci	{ 0x0381, 0x01 },
14948c2ecf20Sopenharmony_ci	{ 0x0383, 0x01 },
14958c2ecf20Sopenharmony_ci	{ 0x0385, 0x01 },
14968c2ecf20Sopenharmony_ci	{ 0x0387, 0x01 },
14978c2ecf20Sopenharmony_ci	{ 0x0900, 0x01 },
14988c2ecf20Sopenharmony_ci	{ 0x0901, 0x22 },
14998c2ecf20Sopenharmony_ci	{ 0x0902, 0x0a },
15008c2ecf20Sopenharmony_ci	{ 0x3140, 0x02 },
15018c2ecf20Sopenharmony_ci	{ 0x3141, 0x00 },
15028c2ecf20Sopenharmony_ci	{ 0x3f0d, 0x0a },
15038c2ecf20Sopenharmony_ci	{ 0x3f14, 0x01 },
15048c2ecf20Sopenharmony_ci	{ 0x3f3c, 0x02 },
15058c2ecf20Sopenharmony_ci	{ 0x3f4d, 0x01 },
15068c2ecf20Sopenharmony_ci	{ 0x3f4c, 0x01 },
15078c2ecf20Sopenharmony_ci	{ 0x4254, 0x7f },
15088c2ecf20Sopenharmony_ci	{ 0x0401, 0x00 },
15098c2ecf20Sopenharmony_ci	{ 0x0404, 0x00 },
15108c2ecf20Sopenharmony_ci	{ 0x0405, 0x10 },
15118c2ecf20Sopenharmony_ci	{ 0x0408, 0x00 },
15128c2ecf20Sopenharmony_ci	{ 0x0409, 0xb4 },
15138c2ecf20Sopenharmony_ci	{ 0x040a, 0x00 },
15148c2ecf20Sopenharmony_ci	{ 0x040b, 0x00 },
15158c2ecf20Sopenharmony_ci	{ 0x040c, 0x05 },
15168c2ecf20Sopenharmony_ci	{ 0x040d, 0x00 },
15178c2ecf20Sopenharmony_ci	{ 0x040e, 0x02 },
15188c2ecf20Sopenharmony_ci	{ 0x040f, 0xd0 },
15198c2ecf20Sopenharmony_ci	{ 0x034c, 0x05 },
15208c2ecf20Sopenharmony_ci	{ 0x034d, 0x00 },
15218c2ecf20Sopenharmony_ci	{ 0x034e, 0x02 },
15228c2ecf20Sopenharmony_ci	{ 0x034f, 0xd0 },
15238c2ecf20Sopenharmony_ci	{ 0x3261, 0x00 },
15248c2ecf20Sopenharmony_ci	{ 0x3264, 0x00 },
15258c2ecf20Sopenharmony_ci	{ 0x3265, 0x10 },
15268c2ecf20Sopenharmony_ci	{ 0x0301, 0x05 },
15278c2ecf20Sopenharmony_ci	{ 0x0303, 0x04 },
15288c2ecf20Sopenharmony_ci	{ 0x0305, 0x04 },
15298c2ecf20Sopenharmony_ci	{ 0x0306, 0x01 },
15308c2ecf20Sopenharmony_ci	{ 0x0307, 0x92 },
15318c2ecf20Sopenharmony_ci	{ 0x0309, 0x0a },
15328c2ecf20Sopenharmony_ci	{ 0x030b, 0x02 },
15338c2ecf20Sopenharmony_ci	{ 0x030d, 0x02 },
15348c2ecf20Sopenharmony_ci	{ 0x030e, 0x00 },
15358c2ecf20Sopenharmony_ci	{ 0x030f, 0xfa },
15368c2ecf20Sopenharmony_ci	{ 0x0310, 0x00 },
15378c2ecf20Sopenharmony_ci	{ 0x0820, 0x0f },
15388c2ecf20Sopenharmony_ci	{ 0x0821, 0x13 },
15398c2ecf20Sopenharmony_ci	{ 0x0822, 0x33 },
15408c2ecf20Sopenharmony_ci	{ 0x0823, 0x33 },
15418c2ecf20Sopenharmony_ci	{ 0x3e20, 0x01 },
15428c2ecf20Sopenharmony_ci	{ 0x3e37, 0x00 },
15438c2ecf20Sopenharmony_ci	{ 0x3e3b, 0x01 },
15448c2ecf20Sopenharmony_ci	{ 0x38a3, 0x01 },
15458c2ecf20Sopenharmony_ci	{ 0x38a8, 0x00 },
15468c2ecf20Sopenharmony_ci	{ 0x38a9, 0x00 },
15478c2ecf20Sopenharmony_ci	{ 0x38aa, 0x00 },
15488c2ecf20Sopenharmony_ci	{ 0x38ab, 0x00 },
15498c2ecf20Sopenharmony_ci	{ 0x3234, 0x00 },
15508c2ecf20Sopenharmony_ci	{ 0x3fc1, 0x00 },
15518c2ecf20Sopenharmony_ci	{ 0x3235, 0x00 },
15528c2ecf20Sopenharmony_ci	{ 0x3802, 0x00 },
15538c2ecf20Sopenharmony_ci	{ 0x3143, 0x04 },
15548c2ecf20Sopenharmony_ci	{ 0x360a, 0x00 },
15558c2ecf20Sopenharmony_ci	{ 0x0b00, 0x00 },
15568c2ecf20Sopenharmony_ci	{ 0x0106, 0x00 },
15578c2ecf20Sopenharmony_ci	{ 0x0b05, 0x01 },
15588c2ecf20Sopenharmony_ci	{ 0x0b06, 0x01 },
15598c2ecf20Sopenharmony_ci	{ 0x3230, 0x00 },
15608c2ecf20Sopenharmony_ci	{ 0x3602, 0x01 },
15618c2ecf20Sopenharmony_ci	{ 0x3607, 0x01 },
15628c2ecf20Sopenharmony_ci	{ 0x3c00, 0x00 },
15638c2ecf20Sopenharmony_ci	{ 0x3c01, 0xba },
15648c2ecf20Sopenharmony_ci	{ 0x3c02, 0xc8 },
15658c2ecf20Sopenharmony_ci	{ 0x3c03, 0xaa },
15668c2ecf20Sopenharmony_ci	{ 0x3c04, 0x91 },
15678c2ecf20Sopenharmony_ci	{ 0x3c05, 0x54 },
15688c2ecf20Sopenharmony_ci	{ 0x3c06, 0x26 },
15698c2ecf20Sopenharmony_ci	{ 0x3c07, 0x20 },
15708c2ecf20Sopenharmony_ci	{ 0x3c08, 0x51 },
15718c2ecf20Sopenharmony_ci	{ 0x3d80, 0x00 },
15728c2ecf20Sopenharmony_ci	{ 0x3f50, 0x00 },
15738c2ecf20Sopenharmony_ci	{ 0x3f56, 0x00 },
15748c2ecf20Sopenharmony_ci	{ 0x3f57, 0x30 },
15758c2ecf20Sopenharmony_ci	{ 0x3f78, 0x00 },
15768c2ecf20Sopenharmony_ci	{ 0x3f79, 0x34 },
15778c2ecf20Sopenharmony_ci	{ 0x3f7c, 0x00 },
15788c2ecf20Sopenharmony_ci	{ 0x3f7d, 0x00 },
15798c2ecf20Sopenharmony_ci	{ 0x3fba, 0x00 },
15808c2ecf20Sopenharmony_ci	{ 0x3fbb, 0x00 },
15818c2ecf20Sopenharmony_ci	{ 0xa081, 0x04 },
15828c2ecf20Sopenharmony_ci	{ 0xe014, 0x00 },
15838c2ecf20Sopenharmony_ci	{ 0x0202, 0x04 },
15848c2ecf20Sopenharmony_ci	{ 0x0203, 0xf6 },
15858c2ecf20Sopenharmony_ci	{ 0x0224, 0x01 },
15868c2ecf20Sopenharmony_ci	{ 0x0225, 0xf4 },
15878c2ecf20Sopenharmony_ci	{ 0x0204, 0x00 },
15888c2ecf20Sopenharmony_ci	{ 0x0205, 0x00 },
15898c2ecf20Sopenharmony_ci	{ 0x0216, 0x00 },
15908c2ecf20Sopenharmony_ci	{ 0x0217, 0x00 },
15918c2ecf20Sopenharmony_ci	{ 0x020e, 0x01 },
15928c2ecf20Sopenharmony_ci	{ 0x020f, 0x00 },
15938c2ecf20Sopenharmony_ci	{ 0x0210, 0x01 },
15948c2ecf20Sopenharmony_ci	{ 0x0211, 0x00 },
15958c2ecf20Sopenharmony_ci	{ 0x0212, 0x01 },
15968c2ecf20Sopenharmony_ci	{ 0x0213, 0x00 },
15978c2ecf20Sopenharmony_ci	{ 0x0214, 0x01 },
15988c2ecf20Sopenharmony_ci	{ 0x0215, 0x00 },
15998c2ecf20Sopenharmony_ci	{ 0x0218, 0x01 },
16008c2ecf20Sopenharmony_ci	{ 0x0219, 0x00 },
16018c2ecf20Sopenharmony_ci	{ 0x3614, 0x00 },
16028c2ecf20Sopenharmony_ci	{ 0x3616, 0x0d },
16038c2ecf20Sopenharmony_ci	{ 0x3617, 0x56 },
16048c2ecf20Sopenharmony_ci	{ 0xb612, 0x20 },
16058c2ecf20Sopenharmony_ci	{ 0xb613, 0x20 },
16068c2ecf20Sopenharmony_ci	{ 0xb614, 0x20 },
16078c2ecf20Sopenharmony_ci	{ 0xb615, 0x20 },
16088c2ecf20Sopenharmony_ci	{ 0xb616, 0x0a },
16098c2ecf20Sopenharmony_ci	{ 0xb617, 0x0a },
16108c2ecf20Sopenharmony_ci	{ 0xb618, 0x20 },
16118c2ecf20Sopenharmony_ci	{ 0xb619, 0x20 },
16128c2ecf20Sopenharmony_ci	{ 0xb61a, 0x20 },
16138c2ecf20Sopenharmony_ci	{ 0xb61b, 0x20 },
16148c2ecf20Sopenharmony_ci	{ 0xb61c, 0x0a },
16158c2ecf20Sopenharmony_ci	{ 0xb61d, 0x0a },
16168c2ecf20Sopenharmony_ci	{ 0xb666, 0x30 },
16178c2ecf20Sopenharmony_ci	{ 0xb667, 0x30 },
16188c2ecf20Sopenharmony_ci	{ 0xb668, 0x30 },
16198c2ecf20Sopenharmony_ci	{ 0xb669, 0x30 },
16208c2ecf20Sopenharmony_ci	{ 0xb66a, 0x14 },
16218c2ecf20Sopenharmony_ci	{ 0xb66b, 0x14 },
16228c2ecf20Sopenharmony_ci	{ 0xb66c, 0x20 },
16238c2ecf20Sopenharmony_ci	{ 0xb66d, 0x20 },
16248c2ecf20Sopenharmony_ci	{ 0xb66e, 0x20 },
16258c2ecf20Sopenharmony_ci	{ 0xb66f, 0x20 },
16268c2ecf20Sopenharmony_ci	{ 0xb670, 0x10 },
16278c2ecf20Sopenharmony_ci	{ 0xb671, 0x10 },
16288c2ecf20Sopenharmony_ci	{ 0x3237, 0x00 },
16298c2ecf20Sopenharmony_ci	{ 0x3900, 0x00 },
16308c2ecf20Sopenharmony_ci	{ 0x3901, 0x00 },
16318c2ecf20Sopenharmony_ci	{ 0x3902, 0x00 },
16328c2ecf20Sopenharmony_ci	{ 0x3904, 0x00 },
16338c2ecf20Sopenharmony_ci	{ 0x3905, 0x00 },
16348c2ecf20Sopenharmony_ci	{ 0x3906, 0x00 },
16358c2ecf20Sopenharmony_ci	{ 0x3907, 0x00 },
16368c2ecf20Sopenharmony_ci	{ 0x3908, 0x00 },
16378c2ecf20Sopenharmony_ci	{ 0x3909, 0x00 },
16388c2ecf20Sopenharmony_ci	{ 0x3912, 0x00 },
16398c2ecf20Sopenharmony_ci	{ 0x3930, 0x00 },
16408c2ecf20Sopenharmony_ci	{ 0x3931, 0x00 },
16418c2ecf20Sopenharmony_ci	{ 0x3933, 0x00 },
16428c2ecf20Sopenharmony_ci	{ 0x3934, 0x00 },
16438c2ecf20Sopenharmony_ci	{ 0x3935, 0x00 },
16448c2ecf20Sopenharmony_ci	{ 0x3936, 0x00 },
16458c2ecf20Sopenharmony_ci	{ 0x3937, 0x00 },
16468c2ecf20Sopenharmony_ci	{ 0x30ac, 0x00 },
16478c2ecf20Sopenharmony_ci};
16488c2ecf20Sopenharmony_ci
16498c2ecf20Sopenharmony_cistatic const char * const imx319_test_pattern_menu[] = {
16508c2ecf20Sopenharmony_ci	"Disabled",
16518c2ecf20Sopenharmony_ci	"Solid Colour",
16528c2ecf20Sopenharmony_ci	"Eight Vertical Colour Bars",
16538c2ecf20Sopenharmony_ci	"Colour Bars With Fade to Grey",
16548c2ecf20Sopenharmony_ci	"Pseudorandom Sequence (PN9)",
16558c2ecf20Sopenharmony_ci};
16568c2ecf20Sopenharmony_ci
16578c2ecf20Sopenharmony_ci/* supported link frequencies */
16588c2ecf20Sopenharmony_cistatic const s64 link_freq_menu_items[] = {
16598c2ecf20Sopenharmony_ci	IMX319_LINK_FREQ_DEFAULT,
16608c2ecf20Sopenharmony_ci};
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_ci/* Mode configs */
16638c2ecf20Sopenharmony_cistatic const struct imx319_mode supported_modes[] = {
16648c2ecf20Sopenharmony_ci	{
16658c2ecf20Sopenharmony_ci		.width = 3280,
16668c2ecf20Sopenharmony_ci		.height = 2464,
16678c2ecf20Sopenharmony_ci		.fll_def = 3242,
16688c2ecf20Sopenharmony_ci		.fll_min = 3242,
16698c2ecf20Sopenharmony_ci		.llp = 3968,
16708c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
16718c2ecf20Sopenharmony_ci		.reg_list = {
16728c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_3280x2464_regs),
16738c2ecf20Sopenharmony_ci			.regs = mode_3280x2464_regs,
16748c2ecf20Sopenharmony_ci		},
16758c2ecf20Sopenharmony_ci	},
16768c2ecf20Sopenharmony_ci	{
16778c2ecf20Sopenharmony_ci		.width = 3264,
16788c2ecf20Sopenharmony_ci		.height = 2448,
16798c2ecf20Sopenharmony_ci		.fll_def = 3242,
16808c2ecf20Sopenharmony_ci		.fll_min = 3242,
16818c2ecf20Sopenharmony_ci		.llp = 3968,
16828c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
16838c2ecf20Sopenharmony_ci		.reg_list = {
16848c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_3264x2448_regs),
16858c2ecf20Sopenharmony_ci			.regs = mode_3264x2448_regs,
16868c2ecf20Sopenharmony_ci		},
16878c2ecf20Sopenharmony_ci	},
16888c2ecf20Sopenharmony_ci	{
16898c2ecf20Sopenharmony_ci		.width = 1936,
16908c2ecf20Sopenharmony_ci		.height = 1096,
16918c2ecf20Sopenharmony_ci		.fll_def = 3242,
16928c2ecf20Sopenharmony_ci		.fll_min = 3242,
16938c2ecf20Sopenharmony_ci		.llp = 3968,
16948c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
16958c2ecf20Sopenharmony_ci		.reg_list = {
16968c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1936x1096_regs),
16978c2ecf20Sopenharmony_ci			.regs = mode_1936x1096_regs,
16988c2ecf20Sopenharmony_ci		},
16998c2ecf20Sopenharmony_ci	},
17008c2ecf20Sopenharmony_ci	{
17018c2ecf20Sopenharmony_ci		.width = 1920,
17028c2ecf20Sopenharmony_ci		.height = 1080,
17038c2ecf20Sopenharmony_ci		.fll_def = 3242,
17048c2ecf20Sopenharmony_ci		.fll_min = 3242,
17058c2ecf20Sopenharmony_ci		.llp = 3968,
17068c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
17078c2ecf20Sopenharmony_ci		.reg_list = {
17088c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1920x1080_regs),
17098c2ecf20Sopenharmony_ci			.regs = mode_1920x1080_regs,
17108c2ecf20Sopenharmony_ci		},
17118c2ecf20Sopenharmony_ci	},
17128c2ecf20Sopenharmony_ci	{
17138c2ecf20Sopenharmony_ci		.width = 1640,
17148c2ecf20Sopenharmony_ci		.height = 1232,
17158c2ecf20Sopenharmony_ci		.fll_def = 5146,
17168c2ecf20Sopenharmony_ci		.fll_min = 5146,
17178c2ecf20Sopenharmony_ci		.llp = 2500,
17188c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
17198c2ecf20Sopenharmony_ci		.reg_list = {
17208c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1640x1232_regs),
17218c2ecf20Sopenharmony_ci			.regs = mode_1640x1232_regs,
17228c2ecf20Sopenharmony_ci		},
17238c2ecf20Sopenharmony_ci	},
17248c2ecf20Sopenharmony_ci	{
17258c2ecf20Sopenharmony_ci		.width = 1640,
17268c2ecf20Sopenharmony_ci		.height = 922,
17278c2ecf20Sopenharmony_ci		.fll_def = 5146,
17288c2ecf20Sopenharmony_ci		.fll_min = 5146,
17298c2ecf20Sopenharmony_ci		.llp = 2500,
17308c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
17318c2ecf20Sopenharmony_ci		.reg_list = {
17328c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1640x922_regs),
17338c2ecf20Sopenharmony_ci			.regs = mode_1640x922_regs,
17348c2ecf20Sopenharmony_ci		},
17358c2ecf20Sopenharmony_ci	},
17368c2ecf20Sopenharmony_ci	{
17378c2ecf20Sopenharmony_ci		.width = 1296,
17388c2ecf20Sopenharmony_ci		.height = 736,
17398c2ecf20Sopenharmony_ci		.fll_def = 5146,
17408c2ecf20Sopenharmony_ci		.fll_min = 5146,
17418c2ecf20Sopenharmony_ci		.llp = 2500,
17428c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
17438c2ecf20Sopenharmony_ci		.reg_list = {
17448c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1296x736_regs),
17458c2ecf20Sopenharmony_ci			.regs = mode_1296x736_regs,
17468c2ecf20Sopenharmony_ci		},
17478c2ecf20Sopenharmony_ci	},
17488c2ecf20Sopenharmony_ci	{
17498c2ecf20Sopenharmony_ci		.width = 1280,
17508c2ecf20Sopenharmony_ci		.height = 720,
17518c2ecf20Sopenharmony_ci		.fll_def = 5146,
17528c2ecf20Sopenharmony_ci		.fll_min = 5146,
17538c2ecf20Sopenharmony_ci		.llp = 2500,
17548c2ecf20Sopenharmony_ci		.link_freq_index = IMX319_LINK_FREQ_INDEX,
17558c2ecf20Sopenharmony_ci		.reg_list = {
17568c2ecf20Sopenharmony_ci			.num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
17578c2ecf20Sopenharmony_ci			.regs = mode_1280x720_regs,
17588c2ecf20Sopenharmony_ci		},
17598c2ecf20Sopenharmony_ci	},
17608c2ecf20Sopenharmony_ci};
17618c2ecf20Sopenharmony_ci
17628c2ecf20Sopenharmony_cistatic inline struct imx319 *to_imx319(struct v4l2_subdev *_sd)
17638c2ecf20Sopenharmony_ci{
17648c2ecf20Sopenharmony_ci	return container_of(_sd, struct imx319, sd);
17658c2ecf20Sopenharmony_ci}
17668c2ecf20Sopenharmony_ci
17678c2ecf20Sopenharmony_ci/* Get bayer order based on flip setting. */
17688c2ecf20Sopenharmony_cistatic u32 imx319_get_format_code(struct imx319 *imx319)
17698c2ecf20Sopenharmony_ci{
17708c2ecf20Sopenharmony_ci	/*
17718c2ecf20Sopenharmony_ci	 * Only one bayer order is supported.
17728c2ecf20Sopenharmony_ci	 * It depends on the flip settings.
17738c2ecf20Sopenharmony_ci	 */
17748c2ecf20Sopenharmony_ci	u32 code;
17758c2ecf20Sopenharmony_ci	static const u32 codes[2][2] = {
17768c2ecf20Sopenharmony_ci		{ MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10, },
17778c2ecf20Sopenharmony_ci		{ MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10, },
17788c2ecf20Sopenharmony_ci	};
17798c2ecf20Sopenharmony_ci
17808c2ecf20Sopenharmony_ci	lockdep_assert_held(&imx319->mutex);
17818c2ecf20Sopenharmony_ci	code = codes[imx319->vflip->val][imx319->hflip->val];
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_ci	return code;
17848c2ecf20Sopenharmony_ci}
17858c2ecf20Sopenharmony_ci
17868c2ecf20Sopenharmony_ci/* Read registers up to 4 at a time */
17878c2ecf20Sopenharmony_cistatic int imx319_read_reg(struct imx319 *imx319, u16 reg, u32 len, u32 *val)
17888c2ecf20Sopenharmony_ci{
17898c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
17908c2ecf20Sopenharmony_ci	struct i2c_msg msgs[2];
17918c2ecf20Sopenharmony_ci	u8 addr_buf[2];
17928c2ecf20Sopenharmony_ci	u8 data_buf[4] = { 0 };
17938c2ecf20Sopenharmony_ci	int ret;
17948c2ecf20Sopenharmony_ci
17958c2ecf20Sopenharmony_ci	if (len > 4)
17968c2ecf20Sopenharmony_ci		return -EINVAL;
17978c2ecf20Sopenharmony_ci
17988c2ecf20Sopenharmony_ci	put_unaligned_be16(reg, addr_buf);
17998c2ecf20Sopenharmony_ci	/* Write register address */
18008c2ecf20Sopenharmony_ci	msgs[0].addr = client->addr;
18018c2ecf20Sopenharmony_ci	msgs[0].flags = 0;
18028c2ecf20Sopenharmony_ci	msgs[0].len = ARRAY_SIZE(addr_buf);
18038c2ecf20Sopenharmony_ci	msgs[0].buf = addr_buf;
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_ci	/* Read data from register */
18068c2ecf20Sopenharmony_ci	msgs[1].addr = client->addr;
18078c2ecf20Sopenharmony_ci	msgs[1].flags = I2C_M_RD;
18088c2ecf20Sopenharmony_ci	msgs[1].len = len;
18098c2ecf20Sopenharmony_ci	msgs[1].buf = &data_buf[4 - len];
18108c2ecf20Sopenharmony_ci
18118c2ecf20Sopenharmony_ci	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
18128c2ecf20Sopenharmony_ci	if (ret != ARRAY_SIZE(msgs))
18138c2ecf20Sopenharmony_ci		return -EIO;
18148c2ecf20Sopenharmony_ci
18158c2ecf20Sopenharmony_ci	*val = get_unaligned_be32(data_buf);
18168c2ecf20Sopenharmony_ci
18178c2ecf20Sopenharmony_ci	return 0;
18188c2ecf20Sopenharmony_ci}
18198c2ecf20Sopenharmony_ci
18208c2ecf20Sopenharmony_ci/* Write registers up to 4 at a time */
18218c2ecf20Sopenharmony_cistatic int imx319_write_reg(struct imx319 *imx319, u16 reg, u32 len, u32 val)
18228c2ecf20Sopenharmony_ci{
18238c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
18248c2ecf20Sopenharmony_ci	u8 buf[6];
18258c2ecf20Sopenharmony_ci
18268c2ecf20Sopenharmony_ci	if (len > 4)
18278c2ecf20Sopenharmony_ci		return -EINVAL;
18288c2ecf20Sopenharmony_ci
18298c2ecf20Sopenharmony_ci	put_unaligned_be16(reg, buf);
18308c2ecf20Sopenharmony_ci	put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
18318c2ecf20Sopenharmony_ci	if (i2c_master_send(client, buf, len + 2) != len + 2)
18328c2ecf20Sopenharmony_ci		return -EIO;
18338c2ecf20Sopenharmony_ci
18348c2ecf20Sopenharmony_ci	return 0;
18358c2ecf20Sopenharmony_ci}
18368c2ecf20Sopenharmony_ci
18378c2ecf20Sopenharmony_ci/* Write a list of registers */
18388c2ecf20Sopenharmony_cistatic int imx319_write_regs(struct imx319 *imx319,
18398c2ecf20Sopenharmony_ci			     const struct imx319_reg *regs, u32 len)
18408c2ecf20Sopenharmony_ci{
18418c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
18428c2ecf20Sopenharmony_ci	int ret;
18438c2ecf20Sopenharmony_ci	u32 i;
18448c2ecf20Sopenharmony_ci
18458c2ecf20Sopenharmony_ci	for (i = 0; i < len; i++) {
18468c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, regs[i].address, 1, regs[i].val);
18478c2ecf20Sopenharmony_ci		if (ret) {
18488c2ecf20Sopenharmony_ci			dev_err_ratelimited(&client->dev,
18498c2ecf20Sopenharmony_ci					    "write reg 0x%4.4x return err %d",
18508c2ecf20Sopenharmony_ci					    regs[i].address, ret);
18518c2ecf20Sopenharmony_ci			return ret;
18528c2ecf20Sopenharmony_ci		}
18538c2ecf20Sopenharmony_ci	}
18548c2ecf20Sopenharmony_ci
18558c2ecf20Sopenharmony_ci	return 0;
18568c2ecf20Sopenharmony_ci}
18578c2ecf20Sopenharmony_ci
18588c2ecf20Sopenharmony_ci/* Open sub-device */
18598c2ecf20Sopenharmony_cistatic int imx319_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
18608c2ecf20Sopenharmony_ci{
18618c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
18628c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *try_fmt =
18638c2ecf20Sopenharmony_ci		v4l2_subdev_get_try_format(sd, fh->pad, 0);
18648c2ecf20Sopenharmony_ci
18658c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
18668c2ecf20Sopenharmony_ci
18678c2ecf20Sopenharmony_ci	/* Initialize try_fmt */
18688c2ecf20Sopenharmony_ci	try_fmt->width = imx319->cur_mode->width;
18698c2ecf20Sopenharmony_ci	try_fmt->height = imx319->cur_mode->height;
18708c2ecf20Sopenharmony_ci	try_fmt->code = imx319_get_format_code(imx319);
18718c2ecf20Sopenharmony_ci	try_fmt->field = V4L2_FIELD_NONE;
18728c2ecf20Sopenharmony_ci
18738c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
18748c2ecf20Sopenharmony_ci
18758c2ecf20Sopenharmony_ci	return 0;
18768c2ecf20Sopenharmony_ci}
18778c2ecf20Sopenharmony_ci
18788c2ecf20Sopenharmony_cistatic int imx319_set_ctrl(struct v4l2_ctrl *ctrl)
18798c2ecf20Sopenharmony_ci{
18808c2ecf20Sopenharmony_ci	struct imx319 *imx319 = container_of(ctrl->handler,
18818c2ecf20Sopenharmony_ci					     struct imx319, ctrl_handler);
18828c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
18838c2ecf20Sopenharmony_ci	s64 max;
18848c2ecf20Sopenharmony_ci	int ret;
18858c2ecf20Sopenharmony_ci
18868c2ecf20Sopenharmony_ci	/* Propagate change of current control to all related controls */
18878c2ecf20Sopenharmony_ci	switch (ctrl->id) {
18888c2ecf20Sopenharmony_ci	case V4L2_CID_VBLANK:
18898c2ecf20Sopenharmony_ci		/* Update max exposure while meeting expected vblanking */
18908c2ecf20Sopenharmony_ci		max = imx319->cur_mode->height + ctrl->val - 18;
18918c2ecf20Sopenharmony_ci		__v4l2_ctrl_modify_range(imx319->exposure,
18928c2ecf20Sopenharmony_ci					 imx319->exposure->minimum,
18938c2ecf20Sopenharmony_ci					 max, imx319->exposure->step, max);
18948c2ecf20Sopenharmony_ci		break;
18958c2ecf20Sopenharmony_ci	}
18968c2ecf20Sopenharmony_ci
18978c2ecf20Sopenharmony_ci	/*
18988c2ecf20Sopenharmony_ci	 * Applying V4L2 control value only happens
18998c2ecf20Sopenharmony_ci	 * when power is up for streaming
19008c2ecf20Sopenharmony_ci	 */
19018c2ecf20Sopenharmony_ci	if (!pm_runtime_get_if_in_use(&client->dev))
19028c2ecf20Sopenharmony_ci		return 0;
19038c2ecf20Sopenharmony_ci
19048c2ecf20Sopenharmony_ci	switch (ctrl->id) {
19058c2ecf20Sopenharmony_ci	case V4L2_CID_ANALOGUE_GAIN:
19068c2ecf20Sopenharmony_ci		/* Analog gain = 1024/(1024 - ctrl->val) times */
19078c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_ANALOG_GAIN, 2,
19088c2ecf20Sopenharmony_ci				       ctrl->val);
19098c2ecf20Sopenharmony_ci		break;
19108c2ecf20Sopenharmony_ci	case V4L2_CID_DIGITAL_GAIN:
19118c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_DIG_GAIN_GLOBAL, 2,
19128c2ecf20Sopenharmony_ci				       ctrl->val);
19138c2ecf20Sopenharmony_ci		break;
19148c2ecf20Sopenharmony_ci	case V4L2_CID_EXPOSURE:
19158c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_EXPOSURE, 2,
19168c2ecf20Sopenharmony_ci				       ctrl->val);
19178c2ecf20Sopenharmony_ci		break;
19188c2ecf20Sopenharmony_ci	case V4L2_CID_VBLANK:
19198c2ecf20Sopenharmony_ci		/* Update FLL that meets expected vertical blanking */
19208c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_FLL, 2,
19218c2ecf20Sopenharmony_ci				       imx319->cur_mode->height + ctrl->val);
19228c2ecf20Sopenharmony_ci		break;
19238c2ecf20Sopenharmony_ci	case V4L2_CID_TEST_PATTERN:
19248c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_TEST_PATTERN,
19258c2ecf20Sopenharmony_ci				       2, ctrl->val);
19268c2ecf20Sopenharmony_ci		break;
19278c2ecf20Sopenharmony_ci	case V4L2_CID_HFLIP:
19288c2ecf20Sopenharmony_ci	case V4L2_CID_VFLIP:
19298c2ecf20Sopenharmony_ci		ret = imx319_write_reg(imx319, IMX319_REG_ORIENTATION, 1,
19308c2ecf20Sopenharmony_ci				       imx319->hflip->val |
19318c2ecf20Sopenharmony_ci				       imx319->vflip->val << 1);
19328c2ecf20Sopenharmony_ci		break;
19338c2ecf20Sopenharmony_ci	default:
19348c2ecf20Sopenharmony_ci		ret = -EINVAL;
19358c2ecf20Sopenharmony_ci		dev_info(&client->dev, "ctrl(id:0x%x,val:0x%x) is not handled",
19368c2ecf20Sopenharmony_ci			 ctrl->id, ctrl->val);
19378c2ecf20Sopenharmony_ci		break;
19388c2ecf20Sopenharmony_ci	}
19398c2ecf20Sopenharmony_ci
19408c2ecf20Sopenharmony_ci	pm_runtime_put(&client->dev);
19418c2ecf20Sopenharmony_ci
19428c2ecf20Sopenharmony_ci	return ret;
19438c2ecf20Sopenharmony_ci}
19448c2ecf20Sopenharmony_ci
19458c2ecf20Sopenharmony_cistatic const struct v4l2_ctrl_ops imx319_ctrl_ops = {
19468c2ecf20Sopenharmony_ci	.s_ctrl = imx319_set_ctrl,
19478c2ecf20Sopenharmony_ci};
19488c2ecf20Sopenharmony_ci
19498c2ecf20Sopenharmony_cistatic int imx319_enum_mbus_code(struct v4l2_subdev *sd,
19508c2ecf20Sopenharmony_ci				 struct v4l2_subdev_pad_config *cfg,
19518c2ecf20Sopenharmony_ci				 struct v4l2_subdev_mbus_code_enum *code)
19528c2ecf20Sopenharmony_ci{
19538c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
19548c2ecf20Sopenharmony_ci
19558c2ecf20Sopenharmony_ci	if (code->index > 0)
19568c2ecf20Sopenharmony_ci		return -EINVAL;
19578c2ecf20Sopenharmony_ci
19588c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
19598c2ecf20Sopenharmony_ci	code->code = imx319_get_format_code(imx319);
19608c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
19618c2ecf20Sopenharmony_ci
19628c2ecf20Sopenharmony_ci	return 0;
19638c2ecf20Sopenharmony_ci}
19648c2ecf20Sopenharmony_ci
19658c2ecf20Sopenharmony_cistatic int imx319_enum_frame_size(struct v4l2_subdev *sd,
19668c2ecf20Sopenharmony_ci				  struct v4l2_subdev_pad_config *cfg,
19678c2ecf20Sopenharmony_ci				  struct v4l2_subdev_frame_size_enum *fse)
19688c2ecf20Sopenharmony_ci{
19698c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_ci	if (fse->index >= ARRAY_SIZE(supported_modes))
19728c2ecf20Sopenharmony_ci		return -EINVAL;
19738c2ecf20Sopenharmony_ci
19748c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
19758c2ecf20Sopenharmony_ci	if (fse->code != imx319_get_format_code(imx319)) {
19768c2ecf20Sopenharmony_ci		mutex_unlock(&imx319->mutex);
19778c2ecf20Sopenharmony_ci		return -EINVAL;
19788c2ecf20Sopenharmony_ci	}
19798c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
19808c2ecf20Sopenharmony_ci
19818c2ecf20Sopenharmony_ci	fse->min_width = supported_modes[fse->index].width;
19828c2ecf20Sopenharmony_ci	fse->max_width = fse->min_width;
19838c2ecf20Sopenharmony_ci	fse->min_height = supported_modes[fse->index].height;
19848c2ecf20Sopenharmony_ci	fse->max_height = fse->min_height;
19858c2ecf20Sopenharmony_ci
19868c2ecf20Sopenharmony_ci	return 0;
19878c2ecf20Sopenharmony_ci}
19888c2ecf20Sopenharmony_ci
19898c2ecf20Sopenharmony_cistatic void imx319_update_pad_format(struct imx319 *imx319,
19908c2ecf20Sopenharmony_ci				     const struct imx319_mode *mode,
19918c2ecf20Sopenharmony_ci				     struct v4l2_subdev_format *fmt)
19928c2ecf20Sopenharmony_ci{
19938c2ecf20Sopenharmony_ci	fmt->format.width = mode->width;
19948c2ecf20Sopenharmony_ci	fmt->format.height = mode->height;
19958c2ecf20Sopenharmony_ci	fmt->format.code = imx319_get_format_code(imx319);
19968c2ecf20Sopenharmony_ci	fmt->format.field = V4L2_FIELD_NONE;
19978c2ecf20Sopenharmony_ci}
19988c2ecf20Sopenharmony_ci
19998c2ecf20Sopenharmony_cistatic int imx319_do_get_pad_format(struct imx319 *imx319,
20008c2ecf20Sopenharmony_ci				    struct v4l2_subdev_pad_config *cfg,
20018c2ecf20Sopenharmony_ci				    struct v4l2_subdev_format *fmt)
20028c2ecf20Sopenharmony_ci{
20038c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *framefmt;
20048c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd = &imx319->sd;
20058c2ecf20Sopenharmony_ci
20068c2ecf20Sopenharmony_ci	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
20078c2ecf20Sopenharmony_ci		framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
20088c2ecf20Sopenharmony_ci		fmt->format = *framefmt;
20098c2ecf20Sopenharmony_ci	} else {
20108c2ecf20Sopenharmony_ci		imx319_update_pad_format(imx319, imx319->cur_mode, fmt);
20118c2ecf20Sopenharmony_ci	}
20128c2ecf20Sopenharmony_ci
20138c2ecf20Sopenharmony_ci	return 0;
20148c2ecf20Sopenharmony_ci}
20158c2ecf20Sopenharmony_ci
20168c2ecf20Sopenharmony_cistatic int imx319_get_pad_format(struct v4l2_subdev *sd,
20178c2ecf20Sopenharmony_ci				 struct v4l2_subdev_pad_config *cfg,
20188c2ecf20Sopenharmony_ci				 struct v4l2_subdev_format *fmt)
20198c2ecf20Sopenharmony_ci{
20208c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
20218c2ecf20Sopenharmony_ci	int ret;
20228c2ecf20Sopenharmony_ci
20238c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
20248c2ecf20Sopenharmony_ci	ret = imx319_do_get_pad_format(imx319, cfg, fmt);
20258c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
20268c2ecf20Sopenharmony_ci
20278c2ecf20Sopenharmony_ci	return ret;
20288c2ecf20Sopenharmony_ci}
20298c2ecf20Sopenharmony_ci
20308c2ecf20Sopenharmony_cistatic int
20318c2ecf20Sopenharmony_ciimx319_set_pad_format(struct v4l2_subdev *sd,
20328c2ecf20Sopenharmony_ci		      struct v4l2_subdev_pad_config *cfg,
20338c2ecf20Sopenharmony_ci		      struct v4l2_subdev_format *fmt)
20348c2ecf20Sopenharmony_ci{
20358c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
20368c2ecf20Sopenharmony_ci	const struct imx319_mode *mode;
20378c2ecf20Sopenharmony_ci	struct v4l2_mbus_framefmt *framefmt;
20388c2ecf20Sopenharmony_ci	s32 vblank_def;
20398c2ecf20Sopenharmony_ci	s32 vblank_min;
20408c2ecf20Sopenharmony_ci	s64 h_blank;
20418c2ecf20Sopenharmony_ci	u64 pixel_rate;
20428c2ecf20Sopenharmony_ci	u32 height;
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
20458c2ecf20Sopenharmony_ci
20468c2ecf20Sopenharmony_ci	/*
20478c2ecf20Sopenharmony_ci	 * Only one bayer order is supported.
20488c2ecf20Sopenharmony_ci	 * It depends on the flip settings.
20498c2ecf20Sopenharmony_ci	 */
20508c2ecf20Sopenharmony_ci	fmt->format.code = imx319_get_format_code(imx319);
20518c2ecf20Sopenharmony_ci
20528c2ecf20Sopenharmony_ci	mode = v4l2_find_nearest_size(supported_modes,
20538c2ecf20Sopenharmony_ci				      ARRAY_SIZE(supported_modes),
20548c2ecf20Sopenharmony_ci				      width, height,
20558c2ecf20Sopenharmony_ci				      fmt->format.width, fmt->format.height);
20568c2ecf20Sopenharmony_ci	imx319_update_pad_format(imx319, mode, fmt);
20578c2ecf20Sopenharmony_ci	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
20588c2ecf20Sopenharmony_ci		framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
20598c2ecf20Sopenharmony_ci		*framefmt = fmt->format;
20608c2ecf20Sopenharmony_ci	} else {
20618c2ecf20Sopenharmony_ci		imx319->cur_mode = mode;
20628c2ecf20Sopenharmony_ci		pixel_rate = imx319->link_def_freq * 2 * 4;
20638c2ecf20Sopenharmony_ci		do_div(pixel_rate, 10);
20648c2ecf20Sopenharmony_ci		__v4l2_ctrl_s_ctrl_int64(imx319->pixel_rate, pixel_rate);
20658c2ecf20Sopenharmony_ci		/* Update limits and set FPS to default */
20668c2ecf20Sopenharmony_ci		height = imx319->cur_mode->height;
20678c2ecf20Sopenharmony_ci		vblank_def = imx319->cur_mode->fll_def - height;
20688c2ecf20Sopenharmony_ci		vblank_min = imx319->cur_mode->fll_min - height;
20698c2ecf20Sopenharmony_ci		height = IMX319_FLL_MAX - height;
20708c2ecf20Sopenharmony_ci		__v4l2_ctrl_modify_range(imx319->vblank, vblank_min, height, 1,
20718c2ecf20Sopenharmony_ci					 vblank_def);
20728c2ecf20Sopenharmony_ci		__v4l2_ctrl_s_ctrl(imx319->vblank, vblank_def);
20738c2ecf20Sopenharmony_ci		h_blank = mode->llp - imx319->cur_mode->width;
20748c2ecf20Sopenharmony_ci		/*
20758c2ecf20Sopenharmony_ci		 * Currently hblank is not changeable.
20768c2ecf20Sopenharmony_ci		 * So FPS control is done only by vblank.
20778c2ecf20Sopenharmony_ci		 */
20788c2ecf20Sopenharmony_ci		__v4l2_ctrl_modify_range(imx319->hblank, h_blank,
20798c2ecf20Sopenharmony_ci					 h_blank, 1, h_blank);
20808c2ecf20Sopenharmony_ci	}
20818c2ecf20Sopenharmony_ci
20828c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
20838c2ecf20Sopenharmony_ci
20848c2ecf20Sopenharmony_ci	return 0;
20858c2ecf20Sopenharmony_ci}
20868c2ecf20Sopenharmony_ci
20878c2ecf20Sopenharmony_ci/* Start streaming */
20888c2ecf20Sopenharmony_cistatic int imx319_start_streaming(struct imx319 *imx319)
20898c2ecf20Sopenharmony_ci{
20908c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
20918c2ecf20Sopenharmony_ci	const struct imx319_reg_list *reg_list;
20928c2ecf20Sopenharmony_ci	int ret;
20938c2ecf20Sopenharmony_ci
20948c2ecf20Sopenharmony_ci	/* Global Setting */
20958c2ecf20Sopenharmony_ci	reg_list = &imx319_global_setting;
20968c2ecf20Sopenharmony_ci	ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs);
20978c2ecf20Sopenharmony_ci	if (ret) {
20988c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to set global settings");
20998c2ecf20Sopenharmony_ci		return ret;
21008c2ecf20Sopenharmony_ci	}
21018c2ecf20Sopenharmony_ci
21028c2ecf20Sopenharmony_ci	/* Apply default values of current mode */
21038c2ecf20Sopenharmony_ci	reg_list = &imx319->cur_mode->reg_list;
21048c2ecf20Sopenharmony_ci	ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs);
21058c2ecf20Sopenharmony_ci	if (ret) {
21068c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to set mode");
21078c2ecf20Sopenharmony_ci		return ret;
21088c2ecf20Sopenharmony_ci	}
21098c2ecf20Sopenharmony_ci
21108c2ecf20Sopenharmony_ci	/* set digital gain control to all color mode */
21118c2ecf20Sopenharmony_ci	ret = imx319_write_reg(imx319, IMX319_REG_DPGA_USE_GLOBAL_GAIN, 1, 1);
21128c2ecf20Sopenharmony_ci	if (ret)
21138c2ecf20Sopenharmony_ci		return ret;
21148c2ecf20Sopenharmony_ci
21158c2ecf20Sopenharmony_ci	/* Apply customized values from user */
21168c2ecf20Sopenharmony_ci	ret =  __v4l2_ctrl_handler_setup(imx319->sd.ctrl_handler);
21178c2ecf20Sopenharmony_ci	if (ret)
21188c2ecf20Sopenharmony_ci		return ret;
21198c2ecf20Sopenharmony_ci
21208c2ecf20Sopenharmony_ci	return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT,
21218c2ecf20Sopenharmony_ci				1, IMX319_MODE_STREAMING);
21228c2ecf20Sopenharmony_ci}
21238c2ecf20Sopenharmony_ci
21248c2ecf20Sopenharmony_ci/* Stop streaming */
21258c2ecf20Sopenharmony_cistatic int imx319_stop_streaming(struct imx319 *imx319)
21268c2ecf20Sopenharmony_ci{
21278c2ecf20Sopenharmony_ci	return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT,
21288c2ecf20Sopenharmony_ci				1, IMX319_MODE_STANDBY);
21298c2ecf20Sopenharmony_ci}
21308c2ecf20Sopenharmony_ci
21318c2ecf20Sopenharmony_cistatic int imx319_set_stream(struct v4l2_subdev *sd, int enable)
21328c2ecf20Sopenharmony_ci{
21338c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
21348c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(sd);
21358c2ecf20Sopenharmony_ci	int ret = 0;
21368c2ecf20Sopenharmony_ci
21378c2ecf20Sopenharmony_ci	mutex_lock(&imx319->mutex);
21388c2ecf20Sopenharmony_ci	if (imx319->streaming == enable) {
21398c2ecf20Sopenharmony_ci		mutex_unlock(&imx319->mutex);
21408c2ecf20Sopenharmony_ci		return 0;
21418c2ecf20Sopenharmony_ci	}
21428c2ecf20Sopenharmony_ci
21438c2ecf20Sopenharmony_ci	if (enable) {
21448c2ecf20Sopenharmony_ci		ret = pm_runtime_get_sync(&client->dev);
21458c2ecf20Sopenharmony_ci		if (ret < 0) {
21468c2ecf20Sopenharmony_ci			pm_runtime_put_noidle(&client->dev);
21478c2ecf20Sopenharmony_ci			goto err_unlock;
21488c2ecf20Sopenharmony_ci		}
21498c2ecf20Sopenharmony_ci
21508c2ecf20Sopenharmony_ci		/*
21518c2ecf20Sopenharmony_ci		 * Apply default & customized values
21528c2ecf20Sopenharmony_ci		 * and then start streaming.
21538c2ecf20Sopenharmony_ci		 */
21548c2ecf20Sopenharmony_ci		ret = imx319_start_streaming(imx319);
21558c2ecf20Sopenharmony_ci		if (ret)
21568c2ecf20Sopenharmony_ci			goto err_rpm_put;
21578c2ecf20Sopenharmony_ci	} else {
21588c2ecf20Sopenharmony_ci		imx319_stop_streaming(imx319);
21598c2ecf20Sopenharmony_ci		pm_runtime_put(&client->dev);
21608c2ecf20Sopenharmony_ci	}
21618c2ecf20Sopenharmony_ci
21628c2ecf20Sopenharmony_ci	imx319->streaming = enable;
21638c2ecf20Sopenharmony_ci
21648c2ecf20Sopenharmony_ci	/* vflip and hflip cannot change during streaming */
21658c2ecf20Sopenharmony_ci	__v4l2_ctrl_grab(imx319->vflip, enable);
21668c2ecf20Sopenharmony_ci	__v4l2_ctrl_grab(imx319->hflip, enable);
21678c2ecf20Sopenharmony_ci
21688c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
21698c2ecf20Sopenharmony_ci
21708c2ecf20Sopenharmony_ci	return ret;
21718c2ecf20Sopenharmony_ci
21728c2ecf20Sopenharmony_cierr_rpm_put:
21738c2ecf20Sopenharmony_ci	pm_runtime_put(&client->dev);
21748c2ecf20Sopenharmony_cierr_unlock:
21758c2ecf20Sopenharmony_ci	mutex_unlock(&imx319->mutex);
21768c2ecf20Sopenharmony_ci
21778c2ecf20Sopenharmony_ci	return ret;
21788c2ecf20Sopenharmony_ci}
21798c2ecf20Sopenharmony_ci
21808c2ecf20Sopenharmony_cistatic int __maybe_unused imx319_suspend(struct device *dev)
21818c2ecf20Sopenharmony_ci{
21828c2ecf20Sopenharmony_ci	struct i2c_client *client = to_i2c_client(dev);
21838c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd = i2c_get_clientdata(client);
21848c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
21858c2ecf20Sopenharmony_ci
21868c2ecf20Sopenharmony_ci	if (imx319->streaming)
21878c2ecf20Sopenharmony_ci		imx319_stop_streaming(imx319);
21888c2ecf20Sopenharmony_ci
21898c2ecf20Sopenharmony_ci	return 0;
21908c2ecf20Sopenharmony_ci}
21918c2ecf20Sopenharmony_ci
21928c2ecf20Sopenharmony_cistatic int __maybe_unused imx319_resume(struct device *dev)
21938c2ecf20Sopenharmony_ci{
21948c2ecf20Sopenharmony_ci	struct i2c_client *client = to_i2c_client(dev);
21958c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd = i2c_get_clientdata(client);
21968c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
21978c2ecf20Sopenharmony_ci	int ret;
21988c2ecf20Sopenharmony_ci
21998c2ecf20Sopenharmony_ci	if (imx319->streaming) {
22008c2ecf20Sopenharmony_ci		ret = imx319_start_streaming(imx319);
22018c2ecf20Sopenharmony_ci		if (ret)
22028c2ecf20Sopenharmony_ci			goto error;
22038c2ecf20Sopenharmony_ci	}
22048c2ecf20Sopenharmony_ci
22058c2ecf20Sopenharmony_ci	return 0;
22068c2ecf20Sopenharmony_ci
22078c2ecf20Sopenharmony_cierror:
22088c2ecf20Sopenharmony_ci	imx319_stop_streaming(imx319);
22098c2ecf20Sopenharmony_ci	imx319->streaming = 0;
22108c2ecf20Sopenharmony_ci	return ret;
22118c2ecf20Sopenharmony_ci}
22128c2ecf20Sopenharmony_ci
22138c2ecf20Sopenharmony_ci/* Verify chip ID */
22148c2ecf20Sopenharmony_cistatic int imx319_identify_module(struct imx319 *imx319)
22158c2ecf20Sopenharmony_ci{
22168c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
22178c2ecf20Sopenharmony_ci	int ret;
22188c2ecf20Sopenharmony_ci	u32 val;
22198c2ecf20Sopenharmony_ci
22208c2ecf20Sopenharmony_ci	ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val);
22218c2ecf20Sopenharmony_ci	if (ret)
22228c2ecf20Sopenharmony_ci		return ret;
22238c2ecf20Sopenharmony_ci
22248c2ecf20Sopenharmony_ci	if (val != IMX319_CHIP_ID) {
22258c2ecf20Sopenharmony_ci		dev_err(&client->dev, "chip id mismatch: %x!=%x",
22268c2ecf20Sopenharmony_ci			IMX319_CHIP_ID, val);
22278c2ecf20Sopenharmony_ci		return -EIO;
22288c2ecf20Sopenharmony_ci	}
22298c2ecf20Sopenharmony_ci
22308c2ecf20Sopenharmony_ci	return 0;
22318c2ecf20Sopenharmony_ci}
22328c2ecf20Sopenharmony_ci
22338c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_core_ops imx319_subdev_core_ops = {
22348c2ecf20Sopenharmony_ci	.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
22358c2ecf20Sopenharmony_ci	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
22368c2ecf20Sopenharmony_ci};
22378c2ecf20Sopenharmony_ci
22388c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_video_ops imx319_video_ops = {
22398c2ecf20Sopenharmony_ci	.s_stream = imx319_set_stream,
22408c2ecf20Sopenharmony_ci};
22418c2ecf20Sopenharmony_ci
22428c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_pad_ops imx319_pad_ops = {
22438c2ecf20Sopenharmony_ci	.enum_mbus_code = imx319_enum_mbus_code,
22448c2ecf20Sopenharmony_ci	.get_fmt = imx319_get_pad_format,
22458c2ecf20Sopenharmony_ci	.set_fmt = imx319_set_pad_format,
22468c2ecf20Sopenharmony_ci	.enum_frame_size = imx319_enum_frame_size,
22478c2ecf20Sopenharmony_ci};
22488c2ecf20Sopenharmony_ci
22498c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_ops imx319_subdev_ops = {
22508c2ecf20Sopenharmony_ci	.core = &imx319_subdev_core_ops,
22518c2ecf20Sopenharmony_ci	.video = &imx319_video_ops,
22528c2ecf20Sopenharmony_ci	.pad = &imx319_pad_ops,
22538c2ecf20Sopenharmony_ci};
22548c2ecf20Sopenharmony_ci
22558c2ecf20Sopenharmony_cistatic const struct media_entity_operations imx319_subdev_entity_ops = {
22568c2ecf20Sopenharmony_ci	.link_validate = v4l2_subdev_link_validate,
22578c2ecf20Sopenharmony_ci};
22588c2ecf20Sopenharmony_ci
22598c2ecf20Sopenharmony_cistatic const struct v4l2_subdev_internal_ops imx319_internal_ops = {
22608c2ecf20Sopenharmony_ci	.open = imx319_open,
22618c2ecf20Sopenharmony_ci};
22628c2ecf20Sopenharmony_ci
22638c2ecf20Sopenharmony_ci/* Initialize control handlers */
22648c2ecf20Sopenharmony_cistatic int imx319_init_controls(struct imx319 *imx319)
22658c2ecf20Sopenharmony_ci{
22668c2ecf20Sopenharmony_ci	struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
22678c2ecf20Sopenharmony_ci	struct v4l2_ctrl_handler *ctrl_hdlr;
22688c2ecf20Sopenharmony_ci	s64 exposure_max;
22698c2ecf20Sopenharmony_ci	s64 vblank_def;
22708c2ecf20Sopenharmony_ci	s64 vblank_min;
22718c2ecf20Sopenharmony_ci	s64 hblank;
22728c2ecf20Sopenharmony_ci	u64 pixel_rate;
22738c2ecf20Sopenharmony_ci	const struct imx319_mode *mode;
22748c2ecf20Sopenharmony_ci	u32 max;
22758c2ecf20Sopenharmony_ci	int ret;
22768c2ecf20Sopenharmony_ci
22778c2ecf20Sopenharmony_ci	ctrl_hdlr = &imx319->ctrl_handler;
22788c2ecf20Sopenharmony_ci	ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
22798c2ecf20Sopenharmony_ci	if (ret)
22808c2ecf20Sopenharmony_ci		return ret;
22818c2ecf20Sopenharmony_ci
22828c2ecf20Sopenharmony_ci	ctrl_hdlr->lock = &imx319->mutex;
22838c2ecf20Sopenharmony_ci	max = ARRAY_SIZE(link_freq_menu_items) - 1;
22848c2ecf20Sopenharmony_ci	imx319->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx319_ctrl_ops,
22858c2ecf20Sopenharmony_ci						   V4L2_CID_LINK_FREQ, max, 0,
22868c2ecf20Sopenharmony_ci						   link_freq_menu_items);
22878c2ecf20Sopenharmony_ci	if (imx319->link_freq)
22888c2ecf20Sopenharmony_ci		imx319->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
22898c2ecf20Sopenharmony_ci
22908c2ecf20Sopenharmony_ci	/* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
22918c2ecf20Sopenharmony_ci	pixel_rate = imx319->link_def_freq * 2 * 4;
22928c2ecf20Sopenharmony_ci	do_div(pixel_rate, 10);
22938c2ecf20Sopenharmony_ci	/* By default, PIXEL_RATE is read only */
22948c2ecf20Sopenharmony_ci	imx319->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
22958c2ecf20Sopenharmony_ci					       V4L2_CID_PIXEL_RATE, pixel_rate,
22968c2ecf20Sopenharmony_ci					       pixel_rate, 1, pixel_rate);
22978c2ecf20Sopenharmony_ci
22988c2ecf20Sopenharmony_ci	/* Initial vblank/hblank/exposure parameters based on current mode */
22998c2ecf20Sopenharmony_ci	mode = imx319->cur_mode;
23008c2ecf20Sopenharmony_ci	vblank_def = mode->fll_def - mode->height;
23018c2ecf20Sopenharmony_ci	vblank_min = mode->fll_min - mode->height;
23028c2ecf20Sopenharmony_ci	imx319->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
23038c2ecf20Sopenharmony_ci					   V4L2_CID_VBLANK, vblank_min,
23048c2ecf20Sopenharmony_ci					   IMX319_FLL_MAX - mode->height,
23058c2ecf20Sopenharmony_ci					   1, vblank_def);
23068c2ecf20Sopenharmony_ci
23078c2ecf20Sopenharmony_ci	hblank = mode->llp - mode->width;
23088c2ecf20Sopenharmony_ci	imx319->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
23098c2ecf20Sopenharmony_ci					   V4L2_CID_HBLANK, hblank, hblank,
23108c2ecf20Sopenharmony_ci					   1, hblank);
23118c2ecf20Sopenharmony_ci	if (imx319->hblank)
23128c2ecf20Sopenharmony_ci		imx319->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
23138c2ecf20Sopenharmony_ci
23148c2ecf20Sopenharmony_ci	/* fll >= exposure time + adjust parameter (default value is 18) */
23158c2ecf20Sopenharmony_ci	exposure_max = mode->fll_def - 18;
23168c2ecf20Sopenharmony_ci	imx319->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
23178c2ecf20Sopenharmony_ci					     V4L2_CID_EXPOSURE,
23188c2ecf20Sopenharmony_ci					     IMX319_EXPOSURE_MIN, exposure_max,
23198c2ecf20Sopenharmony_ci					     IMX319_EXPOSURE_STEP,
23208c2ecf20Sopenharmony_ci					     IMX319_EXPOSURE_DEFAULT);
23218c2ecf20Sopenharmony_ci
23228c2ecf20Sopenharmony_ci	imx319->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
23238c2ecf20Sopenharmony_ci					  V4L2_CID_HFLIP, 0, 1, 1, 0);
23248c2ecf20Sopenharmony_ci	imx319->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops,
23258c2ecf20Sopenharmony_ci					  V4L2_CID_VFLIP, 0, 1, 1, 0);
23268c2ecf20Sopenharmony_ci
23278c2ecf20Sopenharmony_ci	v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
23288c2ecf20Sopenharmony_ci			  IMX319_ANA_GAIN_MIN, IMX319_ANA_GAIN_MAX,
23298c2ecf20Sopenharmony_ci			  IMX319_ANA_GAIN_STEP, IMX319_ANA_GAIN_DEFAULT);
23308c2ecf20Sopenharmony_ci
23318c2ecf20Sopenharmony_ci	/* Digital gain */
23328c2ecf20Sopenharmony_ci	v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
23338c2ecf20Sopenharmony_ci			  IMX319_DGTL_GAIN_MIN, IMX319_DGTL_GAIN_MAX,
23348c2ecf20Sopenharmony_ci			  IMX319_DGTL_GAIN_STEP, IMX319_DGTL_GAIN_DEFAULT);
23358c2ecf20Sopenharmony_ci
23368c2ecf20Sopenharmony_ci	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx319_ctrl_ops,
23378c2ecf20Sopenharmony_ci				     V4L2_CID_TEST_PATTERN,
23388c2ecf20Sopenharmony_ci				     ARRAY_SIZE(imx319_test_pattern_menu) - 1,
23398c2ecf20Sopenharmony_ci				     0, 0, imx319_test_pattern_menu);
23408c2ecf20Sopenharmony_ci	if (ctrl_hdlr->error) {
23418c2ecf20Sopenharmony_ci		ret = ctrl_hdlr->error;
23428c2ecf20Sopenharmony_ci		dev_err(&client->dev, "control init failed: %d", ret);
23438c2ecf20Sopenharmony_ci		goto error;
23448c2ecf20Sopenharmony_ci	}
23458c2ecf20Sopenharmony_ci
23468c2ecf20Sopenharmony_ci	imx319->sd.ctrl_handler = ctrl_hdlr;
23478c2ecf20Sopenharmony_ci
23488c2ecf20Sopenharmony_ci	return 0;
23498c2ecf20Sopenharmony_ci
23508c2ecf20Sopenharmony_cierror:
23518c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_free(ctrl_hdlr);
23528c2ecf20Sopenharmony_ci
23538c2ecf20Sopenharmony_ci	return ret;
23548c2ecf20Sopenharmony_ci}
23558c2ecf20Sopenharmony_ci
23568c2ecf20Sopenharmony_cistatic struct imx319_hwcfg *imx319_get_hwcfg(struct device *dev)
23578c2ecf20Sopenharmony_ci{
23588c2ecf20Sopenharmony_ci	struct imx319_hwcfg *cfg;
23598c2ecf20Sopenharmony_ci	struct v4l2_fwnode_endpoint bus_cfg = {
23608c2ecf20Sopenharmony_ci		.bus_type = V4L2_MBUS_CSI2_DPHY
23618c2ecf20Sopenharmony_ci	};
23628c2ecf20Sopenharmony_ci	struct fwnode_handle *ep;
23638c2ecf20Sopenharmony_ci	struct fwnode_handle *fwnode = dev_fwnode(dev);
23648c2ecf20Sopenharmony_ci	unsigned int i;
23658c2ecf20Sopenharmony_ci	int ret;
23668c2ecf20Sopenharmony_ci
23678c2ecf20Sopenharmony_ci	if (!fwnode)
23688c2ecf20Sopenharmony_ci		return NULL;
23698c2ecf20Sopenharmony_ci
23708c2ecf20Sopenharmony_ci	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
23718c2ecf20Sopenharmony_ci	if (!ep)
23728c2ecf20Sopenharmony_ci		return NULL;
23738c2ecf20Sopenharmony_ci
23748c2ecf20Sopenharmony_ci	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
23758c2ecf20Sopenharmony_ci	if (ret)
23768c2ecf20Sopenharmony_ci		goto out_err;
23778c2ecf20Sopenharmony_ci
23788c2ecf20Sopenharmony_ci	cfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);
23798c2ecf20Sopenharmony_ci	if (!cfg)
23808c2ecf20Sopenharmony_ci		goto out_err;
23818c2ecf20Sopenharmony_ci
23828c2ecf20Sopenharmony_ci	ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
23838c2ecf20Sopenharmony_ci				       &cfg->ext_clk);
23848c2ecf20Sopenharmony_ci	if (ret) {
23858c2ecf20Sopenharmony_ci		dev_err(dev, "can't get clock frequency");
23868c2ecf20Sopenharmony_ci		goto out_err;
23878c2ecf20Sopenharmony_ci	}
23888c2ecf20Sopenharmony_ci
23898c2ecf20Sopenharmony_ci	dev_dbg(dev, "ext clk: %d", cfg->ext_clk);
23908c2ecf20Sopenharmony_ci	if (cfg->ext_clk != IMX319_EXT_CLK) {
23918c2ecf20Sopenharmony_ci		dev_err(dev, "external clock %d is not supported",
23928c2ecf20Sopenharmony_ci			cfg->ext_clk);
23938c2ecf20Sopenharmony_ci		goto out_err;
23948c2ecf20Sopenharmony_ci	}
23958c2ecf20Sopenharmony_ci
23968c2ecf20Sopenharmony_ci	dev_dbg(dev, "num of link freqs: %d", bus_cfg.nr_of_link_frequencies);
23978c2ecf20Sopenharmony_ci	if (!bus_cfg.nr_of_link_frequencies) {
23988c2ecf20Sopenharmony_ci		dev_warn(dev, "no link frequencies defined");
23998c2ecf20Sopenharmony_ci		goto out_err;
24008c2ecf20Sopenharmony_ci	}
24018c2ecf20Sopenharmony_ci
24028c2ecf20Sopenharmony_ci	cfg->nr_of_link_freqs = bus_cfg.nr_of_link_frequencies;
24038c2ecf20Sopenharmony_ci	cfg->link_freqs = devm_kcalloc(dev,
24048c2ecf20Sopenharmony_ci				       bus_cfg.nr_of_link_frequencies + 1,
24058c2ecf20Sopenharmony_ci				       sizeof(*cfg->link_freqs), GFP_KERNEL);
24068c2ecf20Sopenharmony_ci	if (!cfg->link_freqs)
24078c2ecf20Sopenharmony_ci		goto out_err;
24088c2ecf20Sopenharmony_ci
24098c2ecf20Sopenharmony_ci	for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) {
24108c2ecf20Sopenharmony_ci		cfg->link_freqs[i] = bus_cfg.link_frequencies[i];
24118c2ecf20Sopenharmony_ci		dev_dbg(dev, "link_freq[%d] = %lld", i, cfg->link_freqs[i]);
24128c2ecf20Sopenharmony_ci	}
24138c2ecf20Sopenharmony_ci
24148c2ecf20Sopenharmony_ci	v4l2_fwnode_endpoint_free(&bus_cfg);
24158c2ecf20Sopenharmony_ci	fwnode_handle_put(ep);
24168c2ecf20Sopenharmony_ci	return cfg;
24178c2ecf20Sopenharmony_ci
24188c2ecf20Sopenharmony_ciout_err:
24198c2ecf20Sopenharmony_ci	v4l2_fwnode_endpoint_free(&bus_cfg);
24208c2ecf20Sopenharmony_ci	fwnode_handle_put(ep);
24218c2ecf20Sopenharmony_ci	return NULL;
24228c2ecf20Sopenharmony_ci}
24238c2ecf20Sopenharmony_ci
24248c2ecf20Sopenharmony_cistatic int imx319_probe(struct i2c_client *client)
24258c2ecf20Sopenharmony_ci{
24268c2ecf20Sopenharmony_ci	struct imx319 *imx319;
24278c2ecf20Sopenharmony_ci	int ret;
24288c2ecf20Sopenharmony_ci	u32 i;
24298c2ecf20Sopenharmony_ci
24308c2ecf20Sopenharmony_ci	imx319 = devm_kzalloc(&client->dev, sizeof(*imx319), GFP_KERNEL);
24318c2ecf20Sopenharmony_ci	if (!imx319)
24328c2ecf20Sopenharmony_ci		return -ENOMEM;
24338c2ecf20Sopenharmony_ci
24348c2ecf20Sopenharmony_ci	mutex_init(&imx319->mutex);
24358c2ecf20Sopenharmony_ci
24368c2ecf20Sopenharmony_ci	/* Initialize subdev */
24378c2ecf20Sopenharmony_ci	v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops);
24388c2ecf20Sopenharmony_ci
24398c2ecf20Sopenharmony_ci	/* Check module identity */
24408c2ecf20Sopenharmony_ci	ret = imx319_identify_module(imx319);
24418c2ecf20Sopenharmony_ci	if (ret) {
24428c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to find sensor: %d", ret);
24438c2ecf20Sopenharmony_ci		goto error_probe;
24448c2ecf20Sopenharmony_ci	}
24458c2ecf20Sopenharmony_ci
24468c2ecf20Sopenharmony_ci	imx319->hwcfg = imx319_get_hwcfg(&client->dev);
24478c2ecf20Sopenharmony_ci	if (!imx319->hwcfg) {
24488c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to get hwcfg");
24498c2ecf20Sopenharmony_ci		ret = -ENODEV;
24508c2ecf20Sopenharmony_ci		goto error_probe;
24518c2ecf20Sopenharmony_ci	}
24528c2ecf20Sopenharmony_ci
24538c2ecf20Sopenharmony_ci	imx319->link_def_freq = link_freq_menu_items[IMX319_LINK_FREQ_INDEX];
24548c2ecf20Sopenharmony_ci	for (i = 0; i < imx319->hwcfg->nr_of_link_freqs; i++) {
24558c2ecf20Sopenharmony_ci		if (imx319->hwcfg->link_freqs[i] == imx319->link_def_freq) {
24568c2ecf20Sopenharmony_ci			dev_dbg(&client->dev, "link freq index %d matched", i);
24578c2ecf20Sopenharmony_ci			break;
24588c2ecf20Sopenharmony_ci		}
24598c2ecf20Sopenharmony_ci	}
24608c2ecf20Sopenharmony_ci
24618c2ecf20Sopenharmony_ci	if (i == imx319->hwcfg->nr_of_link_freqs) {
24628c2ecf20Sopenharmony_ci		dev_err(&client->dev, "no link frequency supported");
24638c2ecf20Sopenharmony_ci		ret = -EINVAL;
24648c2ecf20Sopenharmony_ci		goto error_probe;
24658c2ecf20Sopenharmony_ci	}
24668c2ecf20Sopenharmony_ci
24678c2ecf20Sopenharmony_ci	/* Set default mode to max resolution */
24688c2ecf20Sopenharmony_ci	imx319->cur_mode = &supported_modes[0];
24698c2ecf20Sopenharmony_ci
24708c2ecf20Sopenharmony_ci	ret = imx319_init_controls(imx319);
24718c2ecf20Sopenharmony_ci	if (ret) {
24728c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to init controls: %d", ret);
24738c2ecf20Sopenharmony_ci		goto error_probe;
24748c2ecf20Sopenharmony_ci	}
24758c2ecf20Sopenharmony_ci
24768c2ecf20Sopenharmony_ci	/* Initialize subdev */
24778c2ecf20Sopenharmony_ci	imx319->sd.internal_ops = &imx319_internal_ops;
24788c2ecf20Sopenharmony_ci	imx319->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
24798c2ecf20Sopenharmony_ci		V4L2_SUBDEV_FL_HAS_EVENTS;
24808c2ecf20Sopenharmony_ci	imx319->sd.entity.ops = &imx319_subdev_entity_ops;
24818c2ecf20Sopenharmony_ci	imx319->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
24828c2ecf20Sopenharmony_ci
24838c2ecf20Sopenharmony_ci	/* Initialize source pad */
24848c2ecf20Sopenharmony_ci	imx319->pad.flags = MEDIA_PAD_FL_SOURCE;
24858c2ecf20Sopenharmony_ci	ret = media_entity_pads_init(&imx319->sd.entity, 1, &imx319->pad);
24868c2ecf20Sopenharmony_ci	if (ret) {
24878c2ecf20Sopenharmony_ci		dev_err(&client->dev, "failed to init entity pads: %d", ret);
24888c2ecf20Sopenharmony_ci		goto error_handler_free;
24898c2ecf20Sopenharmony_ci	}
24908c2ecf20Sopenharmony_ci
24918c2ecf20Sopenharmony_ci	ret = v4l2_async_register_subdev_sensor_common(&imx319->sd);
24928c2ecf20Sopenharmony_ci	if (ret < 0)
24938c2ecf20Sopenharmony_ci		goto error_media_entity;
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	/*
24968c2ecf20Sopenharmony_ci	 * Device is already turned on by i2c-core with ACPI domain PM.
24978c2ecf20Sopenharmony_ci	 * Enable runtime PM and turn off the device.
24988c2ecf20Sopenharmony_ci	 */
24998c2ecf20Sopenharmony_ci	pm_runtime_set_active(&client->dev);
25008c2ecf20Sopenharmony_ci	pm_runtime_enable(&client->dev);
25018c2ecf20Sopenharmony_ci	pm_runtime_idle(&client->dev);
25028c2ecf20Sopenharmony_ci
25038c2ecf20Sopenharmony_ci	return 0;
25048c2ecf20Sopenharmony_ci
25058c2ecf20Sopenharmony_cierror_media_entity:
25068c2ecf20Sopenharmony_ci	media_entity_cleanup(&imx319->sd.entity);
25078c2ecf20Sopenharmony_ci
25088c2ecf20Sopenharmony_cierror_handler_free:
25098c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_free(imx319->sd.ctrl_handler);
25108c2ecf20Sopenharmony_ci
25118c2ecf20Sopenharmony_cierror_probe:
25128c2ecf20Sopenharmony_ci	mutex_destroy(&imx319->mutex);
25138c2ecf20Sopenharmony_ci
25148c2ecf20Sopenharmony_ci	return ret;
25158c2ecf20Sopenharmony_ci}
25168c2ecf20Sopenharmony_ci
25178c2ecf20Sopenharmony_cistatic int imx319_remove(struct i2c_client *client)
25188c2ecf20Sopenharmony_ci{
25198c2ecf20Sopenharmony_ci	struct v4l2_subdev *sd = i2c_get_clientdata(client);
25208c2ecf20Sopenharmony_ci	struct imx319 *imx319 = to_imx319(sd);
25218c2ecf20Sopenharmony_ci
25228c2ecf20Sopenharmony_ci	v4l2_async_unregister_subdev(sd);
25238c2ecf20Sopenharmony_ci	media_entity_cleanup(&sd->entity);
25248c2ecf20Sopenharmony_ci	v4l2_ctrl_handler_free(sd->ctrl_handler);
25258c2ecf20Sopenharmony_ci
25268c2ecf20Sopenharmony_ci	pm_runtime_disable(&client->dev);
25278c2ecf20Sopenharmony_ci	pm_runtime_set_suspended(&client->dev);
25288c2ecf20Sopenharmony_ci
25298c2ecf20Sopenharmony_ci	mutex_destroy(&imx319->mutex);
25308c2ecf20Sopenharmony_ci
25318c2ecf20Sopenharmony_ci	return 0;
25328c2ecf20Sopenharmony_ci}
25338c2ecf20Sopenharmony_ci
25348c2ecf20Sopenharmony_cistatic const struct dev_pm_ops imx319_pm_ops = {
25358c2ecf20Sopenharmony_ci	SET_SYSTEM_SLEEP_PM_OPS(imx319_suspend, imx319_resume)
25368c2ecf20Sopenharmony_ci};
25378c2ecf20Sopenharmony_ci
25388c2ecf20Sopenharmony_cistatic const struct acpi_device_id imx319_acpi_ids[] = {
25398c2ecf20Sopenharmony_ci	{ "SONY319A" },
25408c2ecf20Sopenharmony_ci	{ /* sentinel */ }
25418c2ecf20Sopenharmony_ci};
25428c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, imx319_acpi_ids);
25438c2ecf20Sopenharmony_ci
25448c2ecf20Sopenharmony_cistatic struct i2c_driver imx319_i2c_driver = {
25458c2ecf20Sopenharmony_ci	.driver = {
25468c2ecf20Sopenharmony_ci		.name = "imx319",
25478c2ecf20Sopenharmony_ci		.pm = &imx319_pm_ops,
25488c2ecf20Sopenharmony_ci		.acpi_match_table = ACPI_PTR(imx319_acpi_ids),
25498c2ecf20Sopenharmony_ci	},
25508c2ecf20Sopenharmony_ci	.probe_new = imx319_probe,
25518c2ecf20Sopenharmony_ci	.remove = imx319_remove,
25528c2ecf20Sopenharmony_ci};
25538c2ecf20Sopenharmony_cimodule_i2c_driver(imx319_i2c_driver);
25548c2ecf20Sopenharmony_ci
25558c2ecf20Sopenharmony_ciMODULE_AUTHOR("Qiu, Tianshu <tian.shu.qiu@intel.com>");
25568c2ecf20Sopenharmony_ciMODULE_AUTHOR("Rapolu, Chiranjeevi <chiranjeevi.rapolu@intel.com>");
25578c2ecf20Sopenharmony_ciMODULE_AUTHOR("Bingbu Cao <bingbu.cao@intel.com>");
25588c2ecf20Sopenharmony_ciMODULE_AUTHOR("Yang, Hyungwoo <hyungwoo.yang@intel.com>");
25598c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Sony imx319 sensor driver");
25608c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
2561