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