Commit a084ad80684a5b2800d3610e22b4352da88cb749
1 parent
8d2e39ba6b
MLK-10371: ov5640: Rename int-device ov5640 driver to ov564x
There are two ov5640 driver in kernel, one is subdev ov5640 driver, the other is int-device ov5640 driver. Rename int-device ov5640 driver to ov564x. Signed-off-by: Sandor Yu <R01008@freescale.com>
Showing 1 changed file with 2 additions and 2 deletions Inline Diff
drivers/media/platform/mxc/capture/ov5640.c
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved. | 2 | * Copyright (C) 2012-2015 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | /* | 5 | /* |
| 6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
| 10 | 10 | ||
| 11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
| 15 | 15 | ||
| 16 | * You should have received a copy of the GNU General Public License along | 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., | 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
| 22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
| 23 | #include <linux/device.h> | 23 | #include <linux/device.h> |
| 24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
| 25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
| 26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 27 | #include <linux/of_device.h> | 27 | #include <linux/of_device.h> |
| 28 | #include <linux/of_gpio.h> | 28 | #include <linux/of_gpio.h> |
| 29 | #include <linux/pinctrl/consumer.h> | 29 | #include <linux/pinctrl/consumer.h> |
| 30 | #include <linux/regulator/consumer.h> | 30 | #include <linux/regulator/consumer.h> |
| 31 | #include <media/v4l2-chip-ident.h> | 31 | #include <media/v4l2-chip-ident.h> |
| 32 | #include "v4l2-int-device.h" | 32 | #include "v4l2-int-device.h" |
| 33 | #include "mxc_v4l2_capture.h" | 33 | #include "mxc_v4l2_capture.h" |
| 34 | 34 | ||
| 35 | #define OV5640_VOLTAGE_ANALOG 2800000 | 35 | #define OV5640_VOLTAGE_ANALOG 2800000 |
| 36 | #define OV5640_VOLTAGE_DIGITAL_CORE 1500000 | 36 | #define OV5640_VOLTAGE_DIGITAL_CORE 1500000 |
| 37 | #define OV5640_VOLTAGE_DIGITAL_IO 1800000 | 37 | #define OV5640_VOLTAGE_DIGITAL_IO 1800000 |
| 38 | 38 | ||
| 39 | #define MIN_FPS 15 | 39 | #define MIN_FPS 15 |
| 40 | #define MAX_FPS 30 | 40 | #define MAX_FPS 30 |
| 41 | #define DEFAULT_FPS 30 | 41 | #define DEFAULT_FPS 30 |
| 42 | 42 | ||
| 43 | #define OV5640_XCLK_MIN 6000000 | 43 | #define OV5640_XCLK_MIN 6000000 |
| 44 | #define OV5640_XCLK_MAX 24000000 | 44 | #define OV5640_XCLK_MAX 24000000 |
| 45 | 45 | ||
| 46 | #define OV5640_CHIP_ID_HIGH_BYTE 0x300A | 46 | #define OV5640_CHIP_ID_HIGH_BYTE 0x300A |
| 47 | #define OV5640_CHIP_ID_LOW_BYTE 0x300B | 47 | #define OV5640_CHIP_ID_LOW_BYTE 0x300B |
| 48 | 48 | ||
| 49 | enum ov5640_mode { | 49 | enum ov5640_mode { |
| 50 | ov5640_mode_MIN = 0, | 50 | ov5640_mode_MIN = 0, |
| 51 | ov5640_mode_VGA_640_480 = 0, | 51 | ov5640_mode_VGA_640_480 = 0, |
| 52 | ov5640_mode_QVGA_320_240 = 1, | 52 | ov5640_mode_QVGA_320_240 = 1, |
| 53 | ov5640_mode_NTSC_720_480 = 2, | 53 | ov5640_mode_NTSC_720_480 = 2, |
| 54 | ov5640_mode_PAL_720_576 = 3, | 54 | ov5640_mode_PAL_720_576 = 3, |
| 55 | ov5640_mode_720P_1280_720 = 4, | 55 | ov5640_mode_720P_1280_720 = 4, |
| 56 | ov5640_mode_1080P_1920_1080 = 5, | 56 | ov5640_mode_1080P_1920_1080 = 5, |
| 57 | ov5640_mode_QSXGA_2592_1944 = 6, | 57 | ov5640_mode_QSXGA_2592_1944 = 6, |
| 58 | ov5640_mode_QCIF_176_144 = 7, | 58 | ov5640_mode_QCIF_176_144 = 7, |
| 59 | ov5640_mode_XGA_1024_768 = 8, | 59 | ov5640_mode_XGA_1024_768 = 8, |
| 60 | ov5640_mode_MAX = 8 | 60 | ov5640_mode_MAX = 8 |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | enum ov5640_frame_rate { | 63 | enum ov5640_frame_rate { |
| 64 | ov5640_15_fps, | 64 | ov5640_15_fps, |
| 65 | ov5640_30_fps | 65 | ov5640_30_fps |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | static int ov5640_framerates[] = { | 68 | static int ov5640_framerates[] = { |
| 69 | [ov5640_15_fps] = 15, | 69 | [ov5640_15_fps] = 15, |
| 70 | [ov5640_30_fps] = 30, | 70 | [ov5640_30_fps] = 30, |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | struct reg_value { | 73 | struct reg_value { |
| 74 | u16 u16RegAddr; | 74 | u16 u16RegAddr; |
| 75 | u8 u8Val; | 75 | u8 u8Val; |
| 76 | u8 u8Mask; | 76 | u8 u8Mask; |
| 77 | u32 u32Delay_ms; | 77 | u32 u32Delay_ms; |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | struct ov5640_mode_info { | 80 | struct ov5640_mode_info { |
| 81 | enum ov5640_mode mode; | 81 | enum ov5640_mode mode; |
| 82 | u32 width; | 82 | u32 width; |
| 83 | u32 height; | 83 | u32 height; |
| 84 | struct reg_value *init_data_ptr; | 84 | struct reg_value *init_data_ptr; |
| 85 | u32 init_data_size; | 85 | u32 init_data_size; |
| 86 | }; | 86 | }; |
| 87 | 87 | ||
| 88 | /*! | 88 | /*! |
| 89 | * Maintains the information on the current state of the sesor. | 89 | * Maintains the information on the current state of the sesor. |
| 90 | */ | 90 | */ |
| 91 | static struct sensor_data ov5640_data; | 91 | static struct sensor_data ov5640_data; |
| 92 | static int pwn_gpio, rst_gpio; | 92 | static int pwn_gpio, rst_gpio; |
| 93 | static int prev_sysclk; | 93 | static int prev_sysclk; |
| 94 | static int AE_Target = 52, night_mode; | 94 | static int AE_Target = 52, night_mode; |
| 95 | static int prev_HTS; | 95 | static int prev_HTS; |
| 96 | static int AE_high, AE_low; | 96 | static int AE_high, AE_low; |
| 97 | 97 | ||
| 98 | static struct reg_value ov5640_global_init_setting[] = { | 98 | static struct reg_value ov5640_global_init_setting[] = { |
| 99 | {0x3008, 0x42, 0, 0}, | 99 | {0x3008, 0x42, 0, 0}, |
| 100 | {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, | 100 | {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, |
| 101 | {0x3034, 0x1a, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, | 101 | {0x3034, 0x1a, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, |
| 102 | {0x3630, 0x36, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, | 102 | {0x3630, 0x36, 0, 0}, {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, |
| 103 | {0x3633, 0x12, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, | 103 | {0x3633, 0x12, 0, 0}, {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, |
| 104 | {0x3703, 0x5a, 0, 0}, {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, | 104 | {0x3703, 0x5a, 0, 0}, {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, |
| 105 | {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, | 105 | {0x370b, 0x60, 0, 0}, {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, |
| 106 | {0x3906, 0x10, 0, 0}, {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, | 106 | {0x3906, 0x10, 0, 0}, {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, |
| 107 | {0x3600, 0x08, 0, 0}, {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, | 107 | {0x3600, 0x08, 0, 0}, {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, |
| 108 | {0x3620, 0x52, 0, 0}, {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, | 108 | {0x3620, 0x52, 0, 0}, {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, |
| 109 | {0x3a13, 0x43, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, | 109 | {0x3a13, 0x43, 0, 0}, {0x3a18, 0x00, 0, 0}, {0x3a19, 0x7c, 0, 0}, |
| 110 | {0x3635, 0x13, 0, 0}, {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, | 110 | {0x3635, 0x13, 0, 0}, {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, |
| 111 | {0x3622, 0x01, 0, 0}, {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, | 111 | {0x3622, 0x01, 0, 0}, {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, |
| 112 | {0x3c05, 0x98, 0, 0}, {0x3c06, 0x00, 0, 0}, {0x3c07, 0x07, 0, 0}, | 112 | {0x3c05, 0x98, 0, 0}, {0x3c06, 0x00, 0, 0}, {0x3c07, 0x07, 0, 0}, |
| 113 | {0x3c08, 0x00, 0, 0}, {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, | 113 | {0x3c08, 0x00, 0, 0}, {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, |
| 114 | {0x3c0b, 0x40, 0, 0}, {0x3810, 0x00, 0, 0}, {0x3811, 0x10, 0, 0}, | 114 | {0x3c0b, 0x40, 0, 0}, {0x3810, 0x00, 0, 0}, {0x3811, 0x10, 0, 0}, |
| 115 | {0x3812, 0x00, 0, 0}, {0x3708, 0x64, 0, 0}, {0x4001, 0x02, 0, 0}, | 115 | {0x3812, 0x00, 0, 0}, {0x3708, 0x64, 0, 0}, {0x4001, 0x02, 0, 0}, |
| 116 | {0x4005, 0x1a, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, | 116 | {0x4005, 0x1a, 0, 0}, {0x3000, 0x00, 0, 0}, {0x3004, 0xff, 0, 0}, |
| 117 | {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, | 117 | {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, |
| 118 | {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x5000, 0xa7, 0, 0}, | 118 | {0x501f, 0x00, 0, 0}, {0x440e, 0x00, 0, 0}, {0x5000, 0xa7, 0, 0}, |
| 119 | {0x3008, 0x02, 0, 0}, | 119 | {0x3008, 0x02, 0, 0}, |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | static struct reg_value ov5640_init_setting_30fps_VGA[] = { | 122 | static struct reg_value ov5640_init_setting_30fps_VGA[] = { |
| 123 | {0x3008, 0x42, 0, 0}, | 123 | {0x3008, 0x42, 0, 0}, |
| 124 | {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, | 124 | {0x3103, 0x03, 0, 0}, {0x3017, 0xff, 0, 0}, {0x3018, 0xff, 0, 0}, |
| 125 | {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, {0x3036, 0x46, 0, 0}, | 125 | {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, {0x3036, 0x46, 0, 0}, |
| 126 | {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0}, | 126 | {0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0}, |
| 127 | {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, | 127 | {0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0}, |
| 128 | {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, | 128 | {0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0}, |
| 129 | {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, | 129 | {0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0}, |
| 130 | {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0}, | 130 | {0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0}, |
| 131 | {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0}, | 131 | {0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0}, |
| 132 | {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0}, | 132 | {0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0}, |
| 133 | {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0}, | 133 | {0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0}, |
| 134 | {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0}, | 134 | {0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0}, |
| 135 | {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, {0x3622, 0x01, 0, 0}, | 135 | {0x3636, 0x03, 0, 0}, {0x3634, 0x40, 0, 0}, {0x3622, 0x01, 0, 0}, |
| 136 | {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, {0x3c05, 0x98, 0, 0}, | 136 | {0x3c01, 0x34, 0, 0}, {0x3c04, 0x28, 0, 0}, {0x3c05, 0x98, 0, 0}, |
| 137 | {0x3c06, 0x00, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c08, 0x00, 0, 0}, | 137 | {0x3c06, 0x00, 0, 0}, {0x3c07, 0x08, 0, 0}, {0x3c08, 0x00, 0, 0}, |
| 138 | {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, | 138 | {0x3c09, 0x1c, 0, 0}, {0x3c0a, 0x9c, 0, 0}, {0x3c0b, 0x40, 0, 0}, |
| 139 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, | 139 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, |
| 140 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, | 140 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, |
| 141 | {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, | 141 | {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, {0x3804, 0x0a, 0, 0}, |
| 142 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, | 142 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, {0x3807, 0x9b, 0, 0}, |
| 143 | {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, | 143 | {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, {0x380a, 0x01, 0, 0}, |
| 144 | {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, | 144 | {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x68, 0, 0}, |
| 145 | {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, | 145 | {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, {0x3810, 0x00, 0, 0}, |
| 146 | {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, | 146 | {0x3811, 0x10, 0, 0}, {0x3812, 0x00, 0, 0}, {0x3813, 0x06, 0, 0}, |
| 147 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, | 147 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3708, 0x64, 0, 0}, |
| 148 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, | 148 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x03, 0, 0}, |
| 149 | {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, | 149 | {0x3a03, 0xd8, 0, 0}, {0x3a08, 0x01, 0, 0}, {0x3a09, 0x27, 0, 0}, |
| 150 | {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, | 150 | {0x3a0a, 0x00, 0, 0}, {0x3a0b, 0xf6, 0, 0}, {0x3a0e, 0x03, 0, 0}, |
| 151 | {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, | 151 | {0x3a0d, 0x04, 0, 0}, {0x3a14, 0x03, 0, 0}, {0x3a15, 0xd8, 0, 0}, |
| 152 | {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, | 152 | {0x4001, 0x02, 0, 0}, {0x4004, 0x02, 0, 0}, {0x3000, 0x00, 0, 0}, |
| 153 | {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, | 153 | {0x3002, 0x1c, 0, 0}, {0x3004, 0xff, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 154 | {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, | 154 | {0x300e, 0x58, 0, 0}, {0x302e, 0x00, 0, 0}, {0x4300, 0x30, 0, 0}, |
| 155 | {0x501f, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, | 155 | {0x501f, 0x00, 0, 0}, {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, |
| 156 | {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, | 156 | {0x440e, 0x00, 0, 0}, {0x460b, 0x35, 0, 0}, {0x460c, 0x22, 0, 0}, |
| 157 | {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, {0x5000, 0xa7, 0, 0}, | 157 | {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, {0x5000, 0xa7, 0, 0}, |
| 158 | {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, | 158 | {0x5001, 0xa3, 0, 0}, {0x5180, 0xff, 0, 0}, {0x5181, 0xf2, 0, 0}, |
| 159 | {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, | 159 | {0x5182, 0x00, 0, 0}, {0x5183, 0x14, 0, 0}, {0x5184, 0x25, 0, 0}, |
| 160 | {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, {0x5187, 0x09, 0, 0}, | 160 | {0x5185, 0x24, 0, 0}, {0x5186, 0x09, 0, 0}, {0x5187, 0x09, 0, 0}, |
| 161 | {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, {0x518a, 0x54, 0, 0}, | 161 | {0x5188, 0x09, 0, 0}, {0x5189, 0x88, 0, 0}, {0x518a, 0x54, 0, 0}, |
| 162 | {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x50, 0, 0}, | 162 | {0x518b, 0xee, 0, 0}, {0x518c, 0xb2, 0, 0}, {0x518d, 0x50, 0, 0}, |
| 163 | {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, {0x5190, 0x46, 0, 0}, | 163 | {0x518e, 0x34, 0, 0}, {0x518f, 0x6b, 0, 0}, {0x5190, 0x46, 0, 0}, |
| 164 | {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, | 164 | {0x5191, 0xf8, 0, 0}, {0x5192, 0x04, 0, 0}, {0x5193, 0x70, 0, 0}, |
| 165 | {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, | 165 | {0x5194, 0xf0, 0, 0}, {0x5195, 0xf0, 0, 0}, {0x5196, 0x03, 0, 0}, |
| 166 | {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x6c, 0, 0}, | 166 | {0x5197, 0x01, 0, 0}, {0x5198, 0x04, 0, 0}, {0x5199, 0x6c, 0, 0}, |
| 167 | {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x09, 0, 0}, | 167 | {0x519a, 0x04, 0, 0}, {0x519b, 0x00, 0, 0}, {0x519c, 0x09, 0, 0}, |
| 168 | {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, {0x5381, 0x1e, 0, 0}, | 168 | {0x519d, 0x2b, 0, 0}, {0x519e, 0x38, 0, 0}, {0x5381, 0x1e, 0, 0}, |
| 169 | {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, | 169 | {0x5382, 0x5b, 0, 0}, {0x5383, 0x08, 0, 0}, {0x5384, 0x0a, 0, 0}, |
| 170 | {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, {0x5387, 0x7c, 0, 0}, | 170 | {0x5385, 0x7e, 0, 0}, {0x5386, 0x88, 0, 0}, {0x5387, 0x7c, 0, 0}, |
| 171 | {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, {0x538a, 0x01, 0, 0}, | 171 | {0x5388, 0x6c, 0, 0}, {0x5389, 0x10, 0, 0}, {0x538a, 0x01, 0, 0}, |
| 172 | {0x538b, 0x98, 0, 0}, {0x5300, 0x08, 0, 0}, {0x5301, 0x30, 0, 0}, | 172 | {0x538b, 0x98, 0, 0}, {0x5300, 0x08, 0, 0}, {0x5301, 0x30, 0, 0}, |
| 173 | {0x5302, 0x10, 0, 0}, {0x5303, 0x00, 0, 0}, {0x5304, 0x08, 0, 0}, | 173 | {0x5302, 0x10, 0, 0}, {0x5303, 0x00, 0, 0}, {0x5304, 0x08, 0, 0}, |
| 174 | {0x5305, 0x30, 0, 0}, {0x5306, 0x08, 0, 0}, {0x5307, 0x16, 0, 0}, | 174 | {0x5305, 0x30, 0, 0}, {0x5306, 0x08, 0, 0}, {0x5307, 0x16, 0, 0}, |
| 175 | {0x5309, 0x08, 0, 0}, {0x530a, 0x30, 0, 0}, {0x530b, 0x04, 0, 0}, | 175 | {0x5309, 0x08, 0, 0}, {0x530a, 0x30, 0, 0}, {0x530b, 0x04, 0, 0}, |
| 176 | {0x530c, 0x06, 0, 0}, {0x5480, 0x01, 0, 0}, {0x5481, 0x08, 0, 0}, | 176 | {0x530c, 0x06, 0, 0}, {0x5480, 0x01, 0, 0}, {0x5481, 0x08, 0, 0}, |
| 177 | {0x5482, 0x14, 0, 0}, {0x5483, 0x28, 0, 0}, {0x5484, 0x51, 0, 0}, | 177 | {0x5482, 0x14, 0, 0}, {0x5483, 0x28, 0, 0}, {0x5484, 0x51, 0, 0}, |
| 178 | {0x5485, 0x65, 0, 0}, {0x5486, 0x71, 0, 0}, {0x5487, 0x7d, 0, 0}, | 178 | {0x5485, 0x65, 0, 0}, {0x5486, 0x71, 0, 0}, {0x5487, 0x7d, 0, 0}, |
| 179 | {0x5488, 0x87, 0, 0}, {0x5489, 0x91, 0, 0}, {0x548a, 0x9a, 0, 0}, | 179 | {0x5488, 0x87, 0, 0}, {0x5489, 0x91, 0, 0}, {0x548a, 0x9a, 0, 0}, |
| 180 | {0x548b, 0xaa, 0, 0}, {0x548c, 0xb8, 0, 0}, {0x548d, 0xcd, 0, 0}, | 180 | {0x548b, 0xaa, 0, 0}, {0x548c, 0xb8, 0, 0}, {0x548d, 0xcd, 0, 0}, |
| 181 | {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, {0x5490, 0x1d, 0, 0}, | 181 | {0x548e, 0xdd, 0, 0}, {0x548f, 0xea, 0, 0}, {0x5490, 0x1d, 0, 0}, |
| 182 | {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x10, 0, 0}, | 182 | {0x5580, 0x02, 0, 0}, {0x5583, 0x40, 0, 0}, {0x5584, 0x10, 0, 0}, |
| 183 | {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, {0x558b, 0xf8, 0, 0}, | 183 | {0x5589, 0x10, 0, 0}, {0x558a, 0x00, 0, 0}, {0x558b, 0xf8, 0, 0}, |
| 184 | {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, {0x5802, 0x0f, 0, 0}, | 184 | {0x5800, 0x23, 0, 0}, {0x5801, 0x14, 0, 0}, {0x5802, 0x0f, 0, 0}, |
| 185 | {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, {0x5805, 0x26, 0, 0}, | 185 | {0x5803, 0x0f, 0, 0}, {0x5804, 0x12, 0, 0}, {0x5805, 0x26, 0, 0}, |
| 186 | {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, {0x5808, 0x05, 0, 0}, | 186 | {0x5806, 0x0c, 0, 0}, {0x5807, 0x08, 0, 0}, {0x5808, 0x05, 0, 0}, |
| 187 | {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, {0x580b, 0x0d, 0, 0}, | 187 | {0x5809, 0x05, 0, 0}, {0x580a, 0x08, 0, 0}, {0x580b, 0x0d, 0, 0}, |
| 188 | {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, {0x580e, 0x00, 0, 0}, | 188 | {0x580c, 0x08, 0, 0}, {0x580d, 0x03, 0, 0}, {0x580e, 0x00, 0, 0}, |
| 189 | {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, {0x5811, 0x09, 0, 0}, | 189 | {0x580f, 0x00, 0, 0}, {0x5810, 0x03, 0, 0}, {0x5811, 0x09, 0, 0}, |
| 190 | {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x00, 0, 0}, | 190 | {0x5812, 0x07, 0, 0}, {0x5813, 0x03, 0, 0}, {0x5814, 0x00, 0, 0}, |
| 191 | {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, {0x5817, 0x08, 0, 0}, | 191 | {0x5815, 0x01, 0, 0}, {0x5816, 0x03, 0, 0}, {0x5817, 0x08, 0, 0}, |
| 192 | {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, {0x581a, 0x05, 0, 0}, | 192 | {0x5818, 0x0d, 0, 0}, {0x5819, 0x08, 0, 0}, {0x581a, 0x05, 0, 0}, |
| 193 | {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, {0x581d, 0x0e, 0, 0}, | 193 | {0x581b, 0x06, 0, 0}, {0x581c, 0x08, 0, 0}, {0x581d, 0x0e, 0, 0}, |
| 194 | {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, {0x5820, 0x11, 0, 0}, | 194 | {0x581e, 0x29, 0, 0}, {0x581f, 0x17, 0, 0}, {0x5820, 0x11, 0, 0}, |
| 195 | {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, {0x5823, 0x28, 0, 0}, | 195 | {0x5821, 0x11, 0, 0}, {0x5822, 0x15, 0, 0}, {0x5823, 0x28, 0, 0}, |
| 196 | {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, {0x5826, 0x08, 0, 0}, | 196 | {0x5824, 0x46, 0, 0}, {0x5825, 0x26, 0, 0}, {0x5826, 0x08, 0, 0}, |
| 197 | {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, {0x5829, 0x26, 0, 0}, | 197 | {0x5827, 0x26, 0, 0}, {0x5828, 0x64, 0, 0}, {0x5829, 0x26, 0, 0}, |
| 198 | {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, {0x582c, 0x24, 0, 0}, | 198 | {0x582a, 0x24, 0, 0}, {0x582b, 0x22, 0, 0}, {0x582c, 0x24, 0, 0}, |
| 199 | {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, {0x582f, 0x22, 0, 0}, | 199 | {0x582d, 0x24, 0, 0}, {0x582e, 0x06, 0, 0}, {0x582f, 0x22, 0, 0}, |
| 200 | {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, {0x5832, 0x24, 0, 0}, | 200 | {0x5830, 0x40, 0, 0}, {0x5831, 0x42, 0, 0}, {0x5832, 0x24, 0, 0}, |
| 201 | {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, {0x5835, 0x22, 0, 0}, | 201 | {0x5833, 0x26, 0, 0}, {0x5834, 0x24, 0, 0}, {0x5835, 0x22, 0, 0}, |
| 202 | {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, {0x5838, 0x44, 0, 0}, | 202 | {0x5836, 0x22, 0, 0}, {0x5837, 0x26, 0, 0}, {0x5838, 0x44, 0, 0}, |
| 203 | {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, {0x583b, 0x28, 0, 0}, | 203 | {0x5839, 0x24, 0, 0}, {0x583a, 0x26, 0, 0}, {0x583b, 0x28, 0, 0}, |
| 204 | {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, {0x5025, 0x00, 0, 0}, | 204 | {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0}, {0x5025, 0x00, 0, 0}, |
| 205 | {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, {0x3a1b, 0x30, 0, 0}, | 205 | {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0}, {0x3a1b, 0x30, 0, 0}, |
| 206 | {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x14, 0, 0}, | 206 | {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0}, {0x3a1f, 0x14, 0, 0}, |
| 207 | {0x3008, 0x02, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 207 | {0x3008, 0x02, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 208 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 208 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 209 | }; | 209 | }; |
| 210 | 210 | ||
| 211 | static struct reg_value ov5640_setting_30fps_VGA_640_480[] = { | 211 | static struct reg_value ov5640_setting_30fps_VGA_640_480[] = { |
| 212 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 212 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 213 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 213 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 214 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 214 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 215 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 215 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 216 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, | 216 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, |
| 217 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, | 217 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 218 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 218 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 219 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 219 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 220 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 220 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 221 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 221 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 222 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 222 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 223 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 223 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 224 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 224 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 225 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 225 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 226 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, | 226 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| 229 | static struct reg_value ov5640_setting_15fps_VGA_640_480[] = { | 229 | static struct reg_value ov5640_setting_15fps_VGA_640_480[] = { |
| 230 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 230 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 231 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 231 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 232 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 232 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 233 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 233 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 234 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, | 234 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0x80, 0, 0}, |
| 235 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, | 235 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 236 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 236 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 237 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 237 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 238 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 238 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 239 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 239 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 240 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 240 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 241 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 241 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 242 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 242 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 243 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 243 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 244 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, | 244 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, {0x3503, 0x00, 0, 0}, |
| 245 | }; | 245 | }; |
| 246 | 246 | ||
| 247 | static struct reg_value ov5640_setting_30fps_QVGA_320_240[] = { | 247 | static struct reg_value ov5640_setting_30fps_QVGA_320_240[] = { |
| 248 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 248 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 249 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 249 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 250 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 250 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 251 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 251 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 252 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, | 252 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, |
| 253 | {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, | 253 | {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 254 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 254 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 255 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 255 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 256 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 256 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 257 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 257 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 258 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 258 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 259 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 259 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 260 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 260 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 261 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 261 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 262 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 262 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 263 | }; | 263 | }; |
| 264 | 264 | ||
| 265 | static struct reg_value ov5640_setting_15fps_QVGA_320_240[] = { | 265 | static struct reg_value ov5640_setting_15fps_QVGA_320_240[] = { |
| 266 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 266 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 267 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 267 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 268 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 268 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 269 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 269 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 270 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, | 270 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x01, 0, 0}, {0x3809, 0x40, 0, 0}, |
| 271 | {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, | 271 | {0x380a, 0x00, 0, 0}, {0x380b, 0xf0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 272 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 272 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 273 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 273 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 274 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 274 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 275 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 275 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 276 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 276 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 277 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 277 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 278 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 278 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 279 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 279 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 280 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 280 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 281 | }; | 281 | }; |
| 282 | 282 | ||
| 283 | static struct reg_value ov5640_setting_30fps_NTSC_720_480[] = { | 283 | static struct reg_value ov5640_setting_30fps_NTSC_720_480[] = { |
| 284 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 284 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 285 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 285 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 286 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 286 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 287 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, | 287 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, |
| 288 | {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, | 288 | {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, |
| 289 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, | 289 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 290 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 290 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 291 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 291 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 292 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 292 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 293 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 293 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 294 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 294 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 295 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 295 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 296 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 296 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 297 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 297 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 298 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 298 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 299 | }; | 299 | }; |
| 300 | 300 | ||
| 301 | static struct reg_value ov5640_setting_15fps_NTSC_720_480[] = { | 301 | static struct reg_value ov5640_setting_15fps_NTSC_720_480[] = { |
| 302 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 302 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 303 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 303 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 304 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 304 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 305 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, | 305 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, |
| 306 | {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, | 306 | {0x3807, 0xd4, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, |
| 307 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, | 307 | {0x380a, 0x01, 0, 0}, {0x380b, 0xe0, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 308 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 308 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 309 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 309 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 310 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 310 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 311 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 311 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 312 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 312 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 313 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 313 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 314 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 314 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 315 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 315 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 316 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 316 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 317 | }; | 317 | }; |
| 318 | 318 | ||
| 319 | static struct reg_value ov5640_setting_30fps_PAL_720_576[] = { | 319 | static struct reg_value ov5640_setting_30fps_PAL_720_576[] = { |
| 320 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 320 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 321 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 321 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 322 | {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 322 | {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 323 | {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, | 323 | {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 324 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, | 324 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, |
| 325 | {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, | 325 | {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 326 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 326 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 327 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 327 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 328 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 328 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 329 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 329 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 330 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 330 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 331 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 331 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 332 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 332 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 333 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 333 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 334 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 334 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 335 | }; | 335 | }; |
| 336 | 336 | ||
| 337 | static struct reg_value ov5640_setting_15fps_PAL_720_576[] = { | 337 | static struct reg_value ov5640_setting_15fps_PAL_720_576[] = { |
| 338 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 338 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 339 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 339 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 340 | {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 340 | {0x3801, 0x60, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 341 | {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, | 341 | {0x3804, 0x09, 0, 0}, {0x3805, 0x7e, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 342 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, | 342 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x02, 0, 0}, {0x3809, 0xd0, 0, 0}, |
| 343 | {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, | 343 | {0x380a, 0x02, 0, 0}, {0x380b, 0x40, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 344 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 344 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 345 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 345 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 346 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 346 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 347 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 347 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 348 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 348 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 349 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 349 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 350 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 350 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 351 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 351 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 352 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 352 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 353 | }; | 353 | }; |
| 354 | 354 | ||
| 355 | static struct reg_value ov5640_setting_30fps_720P_1280_720[] = { | 355 | static struct reg_value ov5640_setting_30fps_720P_1280_720[] = { |
| 356 | {0x3035, 0x21, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, | 356 | {0x3035, 0x21, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, |
| 357 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, | 357 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, |
| 358 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, | 358 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, |
| 359 | {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, | 359 | {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, |
| 360 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, | 360 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, |
| 361 | {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, | 361 | {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, |
| 362 | {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, | 362 | {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, |
| 363 | {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, | 363 | {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, |
| 364 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, | 364 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, |
| 365 | {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, | 365 | {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, |
| 366 | {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, | 366 | {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, |
| 367 | {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, | 367 | {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, |
| 368 | {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, | 368 | {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, |
| 369 | {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, | 369 | {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, |
| 370 | {0x3503, 0x00, 0, 0}, | 370 | {0x3503, 0x00, 0, 0}, |
| 371 | }; | 371 | }; |
| 372 | 372 | ||
| 373 | static struct reg_value ov5640_setting_15fps_720P_1280_720[] = { | 373 | static struct reg_value ov5640_setting_15fps_720P_1280_720[] = { |
| 374 | {0x3035, 0x41, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, | 374 | {0x3035, 0x41, 0, 0}, {0x3036, 0x69, 0, 0}, {0x3c07, 0x07, 0, 0}, |
| 375 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, | 375 | {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, {0x3814, 0x31, 0, 0}, |
| 376 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, | 376 | {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, {0x3801, 0x00, 0, 0}, |
| 377 | {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, | 377 | {0x3802, 0x00, 0, 0}, {0x3803, 0xfa, 0, 0}, {0x3804, 0x0a, 0, 0}, |
| 378 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, | 378 | {0x3805, 0x3f, 0, 0}, {0x3806, 0x06, 0, 0}, {0x3807, 0xa9, 0, 0}, |
| 379 | {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, | 379 | {0x3808, 0x05, 0, 0}, {0x3809, 0x00, 0, 0}, {0x380a, 0x02, 0, 0}, |
| 380 | {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, | 380 | {0x380b, 0xd0, 0, 0}, {0x380c, 0x07, 0, 0}, {0x380d, 0x64, 0, 0}, |
| 381 | {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, | 381 | {0x380e, 0x02, 0, 0}, {0x380f, 0xe4, 0, 0}, {0x3813, 0x04, 0, 0}, |
| 382 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, | 382 | {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, {0x3709, 0x52, 0, 0}, |
| 383 | {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, | 383 | {0x370c, 0x03, 0, 0}, {0x3a02, 0x02, 0, 0}, {0x3a03, 0xe0, 0, 0}, |
| 384 | {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, | 384 | {0x3a14, 0x02, 0, 0}, {0x3a15, 0xe0, 0, 0}, {0x4004, 0x02, 0, 0}, |
| 385 | {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, | 385 | {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, {0x4713, 0x03, 0, 0}, |
| 386 | {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, | 386 | {0x4407, 0x04, 0, 0}, {0x460b, 0x37, 0, 0}, {0x460c, 0x20, 0, 0}, |
| 387 | {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, | 387 | {0x4837, 0x16, 0, 0}, {0x3824, 0x04, 0, 0}, {0x5001, 0x83, 0, 0}, |
| 388 | {0x3503, 0x00, 0, 0}, | 388 | {0x3503, 0x00, 0, 0}, |
| 389 | }; | 389 | }; |
| 390 | 390 | ||
| 391 | static struct reg_value ov5640_setting_30fps_QCIF_176_144[] = { | 391 | static struct reg_value ov5640_setting_30fps_QCIF_176_144[] = { |
| 392 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 392 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 393 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 393 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 394 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 394 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 395 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 395 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 396 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, | 396 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, |
| 397 | {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, | 397 | {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 398 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 398 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 399 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 399 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 400 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 400 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 401 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 401 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 402 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 402 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 403 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 403 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 404 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 404 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 405 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, | 405 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x11, 0, 0}, |
| 406 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 406 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 407 | }; | 407 | }; |
| 408 | 408 | ||
| 409 | static struct reg_value ov5640_setting_15fps_QCIF_176_144[] = { | 409 | static struct reg_value ov5640_setting_15fps_QCIF_176_144[] = { |
| 410 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 410 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 411 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 411 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 412 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 412 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 413 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 413 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 414 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, | 414 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x00, 0, 0}, {0x3809, 0xb0, 0, 0}, |
| 415 | {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, | 415 | {0x380a, 0x00, 0, 0}, {0x380b, 0x90, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 416 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 416 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 417 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 417 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 418 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 418 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 419 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 419 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 420 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 420 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 421 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 421 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 422 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, | 422 | {0x460c, 0x22, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x02, 0, 0}, |
| 423 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 423 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 424 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 424 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 425 | }; | 425 | }; |
| 426 | 426 | ||
| 427 | static struct reg_value ov5640_setting_30fps_XGA_1024_768[] = { | 427 | static struct reg_value ov5640_setting_30fps_XGA_1024_768[] = { |
| 428 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 428 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 429 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 429 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 430 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 430 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 431 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 431 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 432 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, | 432 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, |
| 433 | {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, | 433 | {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 434 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 434 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 435 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 435 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 436 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 436 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 437 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 437 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 438 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 438 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 439 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 439 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 440 | {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, | 440 | {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, |
| 441 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 441 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 442 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, | 442 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 443 | }; | 443 | }; |
| 444 | 444 | ||
| 445 | static struct reg_value ov5640_setting_15fps_XGA_1024_768[] = { | 445 | static struct reg_value ov5640_setting_15fps_XGA_1024_768[] = { |
| 446 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, | 446 | {0x3c07, 0x08, 0, 0}, {0x3820, 0x41, 0, 0}, {0x3821, 0x07, 0, 0}, |
| 447 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, | 447 | {0x3814, 0x31, 0, 0}, {0x3815, 0x31, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 448 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, | 448 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x04, 0, 0}, |
| 449 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 449 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 450 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, | 450 | {0x3807, 0x9b, 0, 0}, {0x3808, 0x04, 0, 0}, {0x3809, 0x00, 0, 0}, |
| 451 | {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, | 451 | {0x380a, 0x03, 0, 0}, {0x380b, 0x00, 0, 0}, {0x380c, 0x07, 0, 0}, |
| 452 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, | 452 | {0x380d, 0x68, 0, 0}, {0x380e, 0x03, 0, 0}, {0x380f, 0xd8, 0, 0}, |
| 453 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, | 453 | {0x3813, 0x06, 0, 0}, {0x3618, 0x00, 0, 0}, {0x3612, 0x29, 0, 0}, |
| 454 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, | 454 | {0x3709, 0x52, 0, 0}, {0x370c, 0x03, 0, 0}, {0x3a02, 0x0b, 0, 0}, |
| 455 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, | 455 | {0x3a03, 0x88, 0, 0}, {0x3a14, 0x0b, 0, 0}, {0x3a15, 0x88, 0, 0}, |
| 456 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 456 | {0x4004, 0x02, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 457 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, | 457 | {0x4713, 0x03, 0, 0}, {0x4407, 0x04, 0, 0}, {0x460b, 0x35, 0, 0}, |
| 458 | {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, | 458 | {0x460c, 0x20, 0, 0}, {0x4837, 0x22, 0, 0}, {0x3824, 0x01, 0, 0}, |
| 459 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 459 | {0x5001, 0xa3, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 460 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, | 460 | {0x3036, 0x46, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 461 | }; | 461 | }; |
| 462 | 462 | ||
| 463 | 463 | ||
| 464 | static struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = { | 464 | static struct reg_value ov5640_setting_15fps_1080P_1920_1080[] = { |
| 465 | {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, | 465 | {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, |
| 466 | {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, | 466 | {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 467 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0xee, 0, 0}, | 467 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0xee, 0, 0}, |
| 468 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x05, 0, 0}, | 468 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x05, 0, 0}, |
| 469 | {0x3807, 0xc3, 0, 0}, {0x3808, 0x07, 0, 0}, {0x3809, 0x80, 0, 0}, | 469 | {0x3807, 0xc3, 0, 0}, {0x3808, 0x07, 0, 0}, {0x3809, 0x80, 0, 0}, |
| 470 | {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, {0x380c, 0x0b, 0, 0}, | 470 | {0x380a, 0x04, 0, 0}, {0x380b, 0x38, 0, 0}, {0x380c, 0x0b, 0, 0}, |
| 471 | {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, | 471 | {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, |
| 472 | {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, | 472 | {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, |
| 473 | {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, | 473 | {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, |
| 474 | {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, | 474 | {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, |
| 475 | {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 475 | {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 476 | {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, | 476 | {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, |
| 477 | {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, | 477 | {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, |
| 478 | {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 478 | {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 479 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, | 479 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 480 | }; | 480 | }; |
| 481 | 481 | ||
| 482 | static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { | 482 | static struct reg_value ov5640_setting_15fps_QSXGA_2592_1944[] = { |
| 483 | {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, | 483 | {0x3c07, 0x07, 0, 0}, {0x3820, 0x40, 0, 0}, {0x3821, 0x06, 0, 0}, |
| 484 | {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, | 484 | {0x3814, 0x11, 0, 0}, {0x3815, 0x11, 0, 0}, {0x3800, 0x00, 0, 0}, |
| 485 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, | 485 | {0x3801, 0x00, 0, 0}, {0x3802, 0x00, 0, 0}, {0x3803, 0x00, 0, 0}, |
| 486 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, | 486 | {0x3804, 0x0a, 0, 0}, {0x3805, 0x3f, 0, 0}, {0x3806, 0x07, 0, 0}, |
| 487 | {0x3807, 0x9f, 0, 0}, {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, | 487 | {0x3807, 0x9f, 0, 0}, {0x3808, 0x0a, 0, 0}, {0x3809, 0x20, 0, 0}, |
| 488 | {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, | 488 | {0x380a, 0x07, 0, 0}, {0x380b, 0x98, 0, 0}, {0x380c, 0x0b, 0, 0}, |
| 489 | {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, | 489 | {0x380d, 0x1c, 0, 0}, {0x380e, 0x07, 0, 0}, {0x380f, 0xb0, 0, 0}, |
| 490 | {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, | 490 | {0x3813, 0x04, 0, 0}, {0x3618, 0x04, 0, 0}, {0x3612, 0x2b, 0, 0}, |
| 491 | {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, | 491 | {0x3709, 0x12, 0, 0}, {0x370c, 0x00, 0, 0}, {0x3a02, 0x07, 0, 0}, |
| 492 | {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, | 492 | {0x3a03, 0xae, 0, 0}, {0x3a14, 0x07, 0, 0}, {0x3a15, 0xae, 0, 0}, |
| 493 | {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, | 493 | {0x4004, 0x06, 0, 0}, {0x3002, 0x1c, 0, 0}, {0x3006, 0xc3, 0, 0}, |
| 494 | {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, | 494 | {0x4713, 0x02, 0, 0}, {0x4407, 0x0c, 0, 0}, {0x460b, 0x37, 0, 0}, |
| 495 | {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, | 495 | {0x460c, 0x20, 0, 0}, {0x4837, 0x2c, 0, 0}, {0x3824, 0x01, 0, 0}, |
| 496 | {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, | 496 | {0x5001, 0x83, 0, 0}, {0x3034, 0x1a, 0, 0}, {0x3035, 0x21, 0, 0}, |
| 497 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, | 497 | {0x3036, 0x69, 0, 0}, {0x3037, 0x13, 0, 0}, |
| 498 | }; | 498 | }; |
| 499 | 499 | ||
| 500 | static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { | 500 | static struct ov5640_mode_info ov5640_mode_info_data[2][ov5640_mode_MAX + 1] = { |
| 501 | { | 501 | { |
| 502 | {ov5640_mode_VGA_640_480, 640, 480, | 502 | {ov5640_mode_VGA_640_480, 640, 480, |
| 503 | ov5640_setting_15fps_VGA_640_480, | 503 | ov5640_setting_15fps_VGA_640_480, |
| 504 | ARRAY_SIZE(ov5640_setting_15fps_VGA_640_480)}, | 504 | ARRAY_SIZE(ov5640_setting_15fps_VGA_640_480)}, |
| 505 | {ov5640_mode_QVGA_320_240, 320, 240, | 505 | {ov5640_mode_QVGA_320_240, 320, 240, |
| 506 | ov5640_setting_15fps_QVGA_320_240, | 506 | ov5640_setting_15fps_QVGA_320_240, |
| 507 | ARRAY_SIZE(ov5640_setting_15fps_QVGA_320_240)}, | 507 | ARRAY_SIZE(ov5640_setting_15fps_QVGA_320_240)}, |
| 508 | {ov5640_mode_NTSC_720_480, 720, 480, | 508 | {ov5640_mode_NTSC_720_480, 720, 480, |
| 509 | ov5640_setting_15fps_NTSC_720_480, | 509 | ov5640_setting_15fps_NTSC_720_480, |
| 510 | ARRAY_SIZE(ov5640_setting_15fps_NTSC_720_480)}, | 510 | ARRAY_SIZE(ov5640_setting_15fps_NTSC_720_480)}, |
| 511 | {ov5640_mode_PAL_720_576, 720, 576, | 511 | {ov5640_mode_PAL_720_576, 720, 576, |
| 512 | ov5640_setting_15fps_PAL_720_576, | 512 | ov5640_setting_15fps_PAL_720_576, |
| 513 | ARRAY_SIZE(ov5640_setting_15fps_PAL_720_576)}, | 513 | ARRAY_SIZE(ov5640_setting_15fps_PAL_720_576)}, |
| 514 | {ov5640_mode_720P_1280_720, 1280, 720, | 514 | {ov5640_mode_720P_1280_720, 1280, 720, |
| 515 | ov5640_setting_15fps_720P_1280_720, | 515 | ov5640_setting_15fps_720P_1280_720, |
| 516 | ARRAY_SIZE(ov5640_setting_15fps_720P_1280_720)}, | 516 | ARRAY_SIZE(ov5640_setting_15fps_720P_1280_720)}, |
| 517 | {ov5640_mode_1080P_1920_1080, 1920, 1080, | 517 | {ov5640_mode_1080P_1920_1080, 1920, 1080, |
| 518 | ov5640_setting_15fps_1080P_1920_1080, | 518 | ov5640_setting_15fps_1080P_1920_1080, |
| 519 | ARRAY_SIZE(ov5640_setting_15fps_1080P_1920_1080)}, | 519 | ARRAY_SIZE(ov5640_setting_15fps_1080P_1920_1080)}, |
| 520 | {ov5640_mode_QSXGA_2592_1944, 2592, 1944, | 520 | {ov5640_mode_QSXGA_2592_1944, 2592, 1944, |
| 521 | ov5640_setting_15fps_QSXGA_2592_1944, | 521 | ov5640_setting_15fps_QSXGA_2592_1944, |
| 522 | ARRAY_SIZE(ov5640_setting_15fps_QSXGA_2592_1944)}, | 522 | ARRAY_SIZE(ov5640_setting_15fps_QSXGA_2592_1944)}, |
| 523 | {ov5640_mode_QCIF_176_144, 176, 144, | 523 | {ov5640_mode_QCIF_176_144, 176, 144, |
| 524 | ov5640_setting_15fps_QCIF_176_144, | 524 | ov5640_setting_15fps_QCIF_176_144, |
| 525 | ARRAY_SIZE(ov5640_setting_15fps_QCIF_176_144)}, | 525 | ARRAY_SIZE(ov5640_setting_15fps_QCIF_176_144)}, |
| 526 | {ov5640_mode_XGA_1024_768, 1024, 768, | 526 | {ov5640_mode_XGA_1024_768, 1024, 768, |
| 527 | ov5640_setting_15fps_XGA_1024_768, | 527 | ov5640_setting_15fps_XGA_1024_768, |
| 528 | ARRAY_SIZE(ov5640_setting_15fps_XGA_1024_768)}, | 528 | ARRAY_SIZE(ov5640_setting_15fps_XGA_1024_768)}, |
| 529 | }, | 529 | }, |
| 530 | { | 530 | { |
| 531 | {ov5640_mode_VGA_640_480, 640, 480, | 531 | {ov5640_mode_VGA_640_480, 640, 480, |
| 532 | ov5640_setting_30fps_VGA_640_480, | 532 | ov5640_setting_30fps_VGA_640_480, |
| 533 | ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480)}, | 533 | ARRAY_SIZE(ov5640_setting_30fps_VGA_640_480)}, |
| 534 | {ov5640_mode_QVGA_320_240, 320, 240, | 534 | {ov5640_mode_QVGA_320_240, 320, 240, |
| 535 | ov5640_setting_30fps_QVGA_320_240, | 535 | ov5640_setting_30fps_QVGA_320_240, |
| 536 | ARRAY_SIZE(ov5640_setting_30fps_QVGA_320_240)}, | 536 | ARRAY_SIZE(ov5640_setting_30fps_QVGA_320_240)}, |
| 537 | {ov5640_mode_NTSC_720_480, 720, 480, | 537 | {ov5640_mode_NTSC_720_480, 720, 480, |
| 538 | ov5640_setting_30fps_NTSC_720_480, | 538 | ov5640_setting_30fps_NTSC_720_480, |
| 539 | ARRAY_SIZE(ov5640_setting_30fps_NTSC_720_480)}, | 539 | ARRAY_SIZE(ov5640_setting_30fps_NTSC_720_480)}, |
| 540 | {ov5640_mode_PAL_720_576, 720, 576, | 540 | {ov5640_mode_PAL_720_576, 720, 576, |
| 541 | ov5640_setting_30fps_PAL_720_576, | 541 | ov5640_setting_30fps_PAL_720_576, |
| 542 | ARRAY_SIZE(ov5640_setting_30fps_PAL_720_576)}, | 542 | ARRAY_SIZE(ov5640_setting_30fps_PAL_720_576)}, |
| 543 | {ov5640_mode_720P_1280_720, 1280, 720, | 543 | {ov5640_mode_720P_1280_720, 1280, 720, |
| 544 | ov5640_setting_30fps_720P_1280_720, | 544 | ov5640_setting_30fps_720P_1280_720, |
| 545 | ARRAY_SIZE(ov5640_setting_30fps_720P_1280_720)}, | 545 | ARRAY_SIZE(ov5640_setting_30fps_720P_1280_720)}, |
| 546 | {ov5640_mode_1080P_1920_1080, 0, 0, NULL, 0}, | 546 | {ov5640_mode_1080P_1920_1080, 0, 0, NULL, 0}, |
| 547 | {ov5640_mode_QSXGA_2592_1944, 0, 0, NULL, 0}, | 547 | {ov5640_mode_QSXGA_2592_1944, 0, 0, NULL, 0}, |
| 548 | {ov5640_mode_QCIF_176_144, 176, 144, | 548 | {ov5640_mode_QCIF_176_144, 176, 144, |
| 549 | ov5640_setting_30fps_QCIF_176_144, | 549 | ov5640_setting_30fps_QCIF_176_144, |
| 550 | ARRAY_SIZE(ov5640_setting_30fps_QCIF_176_144)}, | 550 | ARRAY_SIZE(ov5640_setting_30fps_QCIF_176_144)}, |
| 551 | {ov5640_mode_XGA_1024_768, 1024, 768, | 551 | {ov5640_mode_XGA_1024_768, 1024, 768, |
| 552 | ov5640_setting_30fps_XGA_1024_768, | 552 | ov5640_setting_30fps_XGA_1024_768, |
| 553 | ARRAY_SIZE(ov5640_setting_30fps_XGA_1024_768)}, | 553 | ARRAY_SIZE(ov5640_setting_30fps_XGA_1024_768)}, |
| 554 | }, | 554 | }, |
| 555 | }; | 555 | }; |
| 556 | 556 | ||
| 557 | static struct regulator *io_regulator; | 557 | static struct regulator *io_regulator; |
| 558 | static struct regulator *core_regulator; | 558 | static struct regulator *core_regulator; |
| 559 | static struct regulator *analog_regulator; | 559 | static struct regulator *analog_regulator; |
| 560 | 560 | ||
| 561 | static int ov5640_probe(struct i2c_client *adapter, | 561 | static int ov5640_probe(struct i2c_client *adapter, |
| 562 | const struct i2c_device_id *device_id); | 562 | const struct i2c_device_id *device_id); |
| 563 | static int ov5640_remove(struct i2c_client *client); | 563 | static int ov5640_remove(struct i2c_client *client); |
| 564 | 564 | ||
| 565 | static s32 ov5640_read_reg(u16 reg, u8 *val); | 565 | static s32 ov5640_read_reg(u16 reg, u8 *val); |
| 566 | static s32 ov5640_write_reg(u16 reg, u8 val); | 566 | static s32 ov5640_write_reg(u16 reg, u8 val); |
| 567 | 567 | ||
| 568 | static const struct i2c_device_id ov5640_id[] = { | 568 | static const struct i2c_device_id ov5640_id[] = { |
| 569 | {"ov564x", 0}, | 569 | {"ov564x", 0}, |
| 570 | {}, | 570 | {}, |
| 571 | }; | 571 | }; |
| 572 | 572 | ||
| 573 | MODULE_DEVICE_TABLE(i2c, ov5640_id); | 573 | MODULE_DEVICE_TABLE(i2c, ov5640_id); |
| 574 | 574 | ||
| 575 | static struct i2c_driver ov5640_i2c_driver = { | 575 | static struct i2c_driver ov5640_i2c_driver = { |
| 576 | .driver = { | 576 | .driver = { |
| 577 | .owner = THIS_MODULE, | 577 | .owner = THIS_MODULE, |
| 578 | .name = "ov5640", | 578 | .name = "ov564x", |
| 579 | }, | 579 | }, |
| 580 | .probe = ov5640_probe, | 580 | .probe = ov5640_probe, |
| 581 | .remove = ov5640_remove, | 581 | .remove = ov5640_remove, |
| 582 | .id_table = ov5640_id, | 582 | .id_table = ov5640_id, |
| 583 | }; | 583 | }; |
| 584 | 584 | ||
| 585 | static inline void ov5640_power_down(int enable) | 585 | static inline void ov5640_power_down(int enable) |
| 586 | { | 586 | { |
| 587 | gpio_set_value(pwn_gpio, enable); | 587 | gpio_set_value(pwn_gpio, enable); |
| 588 | 588 | ||
| 589 | msleep(2); | 589 | msleep(2); |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | static inline void ov5640_reset(void) | 592 | static inline void ov5640_reset(void) |
| 593 | { | 593 | { |
| 594 | /* camera reset */ | 594 | /* camera reset */ |
| 595 | gpio_set_value(rst_gpio, 1); | 595 | gpio_set_value(rst_gpio, 1); |
| 596 | 596 | ||
| 597 | /* camera power down */ | 597 | /* camera power down */ |
| 598 | gpio_set_value(pwn_gpio, 1); | 598 | gpio_set_value(pwn_gpio, 1); |
| 599 | msleep(5); | 599 | msleep(5); |
| 600 | gpio_set_value(pwn_gpio, 0); | 600 | gpio_set_value(pwn_gpio, 0); |
| 601 | msleep(5); | 601 | msleep(5); |
| 602 | gpio_set_value(rst_gpio, 0); | 602 | gpio_set_value(rst_gpio, 0); |
| 603 | msleep(1); | 603 | msleep(1); |
| 604 | gpio_set_value(rst_gpio, 1); | 604 | gpio_set_value(rst_gpio, 1); |
| 605 | msleep(5); | 605 | msleep(5); |
| 606 | gpio_set_value(pwn_gpio, 1); | 606 | gpio_set_value(pwn_gpio, 1); |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | static int ov5640_regulator_enable(struct device *dev) | 609 | static int ov5640_regulator_enable(struct device *dev) |
| 610 | { | 610 | { |
| 611 | int ret = 0; | 611 | int ret = 0; |
| 612 | 612 | ||
| 613 | io_regulator = devm_regulator_get(dev, "DOVDD"); | 613 | io_regulator = devm_regulator_get(dev, "DOVDD"); |
| 614 | if (!IS_ERR(io_regulator)) { | 614 | if (!IS_ERR(io_regulator)) { |
| 615 | regulator_set_voltage(io_regulator, | 615 | regulator_set_voltage(io_regulator, |
| 616 | OV5640_VOLTAGE_DIGITAL_IO, | 616 | OV5640_VOLTAGE_DIGITAL_IO, |
| 617 | OV5640_VOLTAGE_DIGITAL_IO); | 617 | OV5640_VOLTAGE_DIGITAL_IO); |
| 618 | ret = regulator_enable(io_regulator); | 618 | ret = regulator_enable(io_regulator); |
| 619 | if (ret) { | 619 | if (ret) { |
| 620 | dev_err(dev, "set io voltage failed\n"); | 620 | dev_err(dev, "set io voltage failed\n"); |
| 621 | return ret; | 621 | return ret; |
| 622 | } else { | 622 | } else { |
| 623 | dev_dbg(dev, "set io voltage ok\n"); | 623 | dev_dbg(dev, "set io voltage ok\n"); |
| 624 | } | 624 | } |
| 625 | } else { | 625 | } else { |
| 626 | io_regulator = NULL; | 626 | io_regulator = NULL; |
| 627 | dev_warn(dev, "cannot get io voltage\n"); | 627 | dev_warn(dev, "cannot get io voltage\n"); |
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | core_regulator = devm_regulator_get(dev, "DVDD"); | 630 | core_regulator = devm_regulator_get(dev, "DVDD"); |
| 631 | if (!IS_ERR(core_regulator)) { | 631 | if (!IS_ERR(core_regulator)) { |
| 632 | regulator_set_voltage(core_regulator, | 632 | regulator_set_voltage(core_regulator, |
| 633 | OV5640_VOLTAGE_DIGITAL_CORE, | 633 | OV5640_VOLTAGE_DIGITAL_CORE, |
| 634 | OV5640_VOLTAGE_DIGITAL_CORE); | 634 | OV5640_VOLTAGE_DIGITAL_CORE); |
| 635 | ret = regulator_enable(core_regulator); | 635 | ret = regulator_enable(core_regulator); |
| 636 | if (ret) { | 636 | if (ret) { |
| 637 | dev_err(dev, "set core voltage failed\n"); | 637 | dev_err(dev, "set core voltage failed\n"); |
| 638 | return ret; | 638 | return ret; |
| 639 | } else { | 639 | } else { |
| 640 | dev_dbg(dev, "set core voltage ok\n"); | 640 | dev_dbg(dev, "set core voltage ok\n"); |
| 641 | } | 641 | } |
| 642 | } else { | 642 | } else { |
| 643 | core_regulator = NULL; | 643 | core_regulator = NULL; |
| 644 | dev_warn(dev, "cannot get core voltage\n"); | 644 | dev_warn(dev, "cannot get core voltage\n"); |
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | analog_regulator = devm_regulator_get(dev, "AVDD"); | 647 | analog_regulator = devm_regulator_get(dev, "AVDD"); |
| 648 | if (!IS_ERR(analog_regulator)) { | 648 | if (!IS_ERR(analog_regulator)) { |
| 649 | regulator_set_voltage(analog_regulator, | 649 | regulator_set_voltage(analog_regulator, |
| 650 | OV5640_VOLTAGE_ANALOG, | 650 | OV5640_VOLTAGE_ANALOG, |
| 651 | OV5640_VOLTAGE_ANALOG); | 651 | OV5640_VOLTAGE_ANALOG); |
| 652 | ret = regulator_enable(analog_regulator); | 652 | ret = regulator_enable(analog_regulator); |
| 653 | if (ret) { | 653 | if (ret) { |
| 654 | dev_err(dev, "set analog voltage failed\n"); | 654 | dev_err(dev, "set analog voltage failed\n"); |
| 655 | return ret; | 655 | return ret; |
| 656 | } else { | 656 | } else { |
| 657 | dev_dbg(dev, "set analog voltage ok\n"); | 657 | dev_dbg(dev, "set analog voltage ok\n"); |
| 658 | } | 658 | } |
| 659 | } else { | 659 | } else { |
| 660 | analog_regulator = NULL; | 660 | analog_regulator = NULL; |
| 661 | dev_warn(dev, "cannot get analog voltage\n"); | 661 | dev_warn(dev, "cannot get analog voltage\n"); |
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | return ret; | 664 | return ret; |
| 665 | } | 665 | } |
| 666 | 666 | ||
| 667 | static s32 ov5640_write_reg(u16 reg, u8 val) | 667 | static s32 ov5640_write_reg(u16 reg, u8 val) |
| 668 | { | 668 | { |
| 669 | u8 au8Buf[3] = {0}; | 669 | u8 au8Buf[3] = {0}; |
| 670 | 670 | ||
| 671 | au8Buf[0] = reg >> 8; | 671 | au8Buf[0] = reg >> 8; |
| 672 | au8Buf[1] = reg & 0xff; | 672 | au8Buf[1] = reg & 0xff; |
| 673 | au8Buf[2] = val; | 673 | au8Buf[2] = val; |
| 674 | 674 | ||
| 675 | if (i2c_master_send(ov5640_data.i2c_client, au8Buf, 3) < 0) { | 675 | if (i2c_master_send(ov5640_data.i2c_client, au8Buf, 3) < 0) { |
| 676 | pr_err("%s:write reg error:reg=%x,val=%x\n", | 676 | pr_err("%s:write reg error:reg=%x,val=%x\n", |
| 677 | __func__, reg, val); | 677 | __func__, reg, val); |
| 678 | return -1; | 678 | return -1; |
| 679 | } | 679 | } |
| 680 | 680 | ||
| 681 | return 0; | 681 | return 0; |
| 682 | } | 682 | } |
| 683 | 683 | ||
| 684 | static s32 ov5640_read_reg(u16 reg, u8 *val) | 684 | static s32 ov5640_read_reg(u16 reg, u8 *val) |
| 685 | { | 685 | { |
| 686 | u8 au8RegBuf[2] = {0}; | 686 | u8 au8RegBuf[2] = {0}; |
| 687 | u8 u8RdVal = 0; | 687 | u8 u8RdVal = 0; |
| 688 | 688 | ||
| 689 | au8RegBuf[0] = reg >> 8; | 689 | au8RegBuf[0] = reg >> 8; |
| 690 | au8RegBuf[1] = reg & 0xff; | 690 | au8RegBuf[1] = reg & 0xff; |
| 691 | 691 | ||
| 692 | if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { | 692 | if (2 != i2c_master_send(ov5640_data.i2c_client, au8RegBuf, 2)) { |
| 693 | pr_err("%s:write reg error:reg=%x\n", | 693 | pr_err("%s:write reg error:reg=%x\n", |
| 694 | __func__, reg); | 694 | __func__, reg); |
| 695 | return -1; | 695 | return -1; |
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { | 698 | if (1 != i2c_master_recv(ov5640_data.i2c_client, &u8RdVal, 1)) { |
| 699 | pr_err("%s:read reg error:reg=%x,val=%x\n", | 699 | pr_err("%s:read reg error:reg=%x,val=%x\n", |
| 700 | __func__, reg, u8RdVal); | 700 | __func__, reg, u8RdVal); |
| 701 | return -1; | 701 | return -1; |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | *val = u8RdVal; | 704 | *val = u8RdVal; |
| 705 | 705 | ||
| 706 | return u8RdVal; | 706 | return u8RdVal; |
| 707 | } | 707 | } |
| 708 | 708 | ||
| 709 | static void ov5640_soft_reset(void) | 709 | static void ov5640_soft_reset(void) |
| 710 | { | 710 | { |
| 711 | /* sysclk from pad */ | 711 | /* sysclk from pad */ |
| 712 | ov5640_write_reg(0x3103, 0x11); | 712 | ov5640_write_reg(0x3103, 0x11); |
| 713 | 713 | ||
| 714 | /* software reset */ | 714 | /* software reset */ |
| 715 | ov5640_write_reg(0x3008, 0x82); | 715 | ov5640_write_reg(0x3008, 0x82); |
| 716 | 716 | ||
| 717 | /* delay at least 5ms */ | 717 | /* delay at least 5ms */ |
| 718 | msleep(10); | 718 | msleep(10); |
| 719 | } | 719 | } |
| 720 | 720 | ||
| 721 | /* set sensor driver capability | 721 | /* set sensor driver capability |
| 722 | * 0x302c[7:6] - strength | 722 | * 0x302c[7:6] - strength |
| 723 | 00 - 1x | 723 | 00 - 1x |
| 724 | 01 - 2x | 724 | 01 - 2x |
| 725 | 10 - 3x | 725 | 10 - 3x |
| 726 | 11 - 4x | 726 | 11 - 4x |
| 727 | */ | 727 | */ |
| 728 | static int ov5640_driver_capability(int strength) | 728 | static int ov5640_driver_capability(int strength) |
| 729 | { | 729 | { |
| 730 | u8 temp = 0; | 730 | u8 temp = 0; |
| 731 | 731 | ||
| 732 | if (strength > 4 || strength < 1) { | 732 | if (strength > 4 || strength < 1) { |
| 733 | pr_err("The valid driver capability of ov5640 is 1x~4x\n"); | 733 | pr_err("The valid driver capability of ov5640 is 1x~4x\n"); |
| 734 | return -EINVAL; | 734 | return -EINVAL; |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | ov5640_read_reg(0x302c, &temp); | 737 | ov5640_read_reg(0x302c, &temp); |
| 738 | 738 | ||
| 739 | temp &= ~0xc0; /* clear [7:6] */ | 739 | temp &= ~0xc0; /* clear [7:6] */ |
| 740 | temp |= ((strength - 1) << 6); /* set [7:6] */ | 740 | temp |= ((strength - 1) << 6); /* set [7:6] */ |
| 741 | 741 | ||
| 742 | ov5640_write_reg(0x302c, temp); | 742 | ov5640_write_reg(0x302c, temp); |
| 743 | 743 | ||
| 744 | return 0; | 744 | return 0; |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | /* calculate sysclk */ | 747 | /* calculate sysclk */ |
| 748 | static int ov5640_get_sysclk(void) | 748 | static int ov5640_get_sysclk(void) |
| 749 | { | 749 | { |
| 750 | int xvclk = ov5640_data.mclk / 10000; | 750 | int xvclk = ov5640_data.mclk / 10000; |
| 751 | int sysclk; | 751 | int sysclk; |
| 752 | int temp1, temp2; | 752 | int temp1, temp2; |
| 753 | int Multiplier, PreDiv, VCO, SysDiv, Pll_rdiv, Bit_div2x, sclk_rdiv; | 753 | int Multiplier, PreDiv, VCO, SysDiv, Pll_rdiv, Bit_div2x, sclk_rdiv; |
| 754 | int sclk_rdiv_map[] = {1, 2, 4, 8}; | 754 | int sclk_rdiv_map[] = {1, 2, 4, 8}; |
| 755 | u8 regval = 0; | 755 | u8 regval = 0; |
| 756 | 756 | ||
| 757 | temp1 = ov5640_read_reg(0x3034, ®val); | 757 | temp1 = ov5640_read_reg(0x3034, ®val); |
| 758 | temp2 = temp1 & 0x0f; | 758 | temp2 = temp1 & 0x0f; |
| 759 | if (temp2 == 8 || temp2 == 10) { | 759 | if (temp2 == 8 || temp2 == 10) { |
| 760 | Bit_div2x = temp2 / 2; | 760 | Bit_div2x = temp2 / 2; |
| 761 | } else { | 761 | } else { |
| 762 | pr_err("ov5640: unsupported bit mode %d\n", temp2); | 762 | pr_err("ov5640: unsupported bit mode %d\n", temp2); |
| 763 | return -1; | 763 | return -1; |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | temp1 = ov5640_read_reg(0x3035, ®val); | 766 | temp1 = ov5640_read_reg(0x3035, ®val); |
| 767 | SysDiv = temp1 >> 4; | 767 | SysDiv = temp1 >> 4; |
| 768 | if (SysDiv == 0) | 768 | if (SysDiv == 0) |
| 769 | SysDiv = 16; | 769 | SysDiv = 16; |
| 770 | 770 | ||
| 771 | temp1 = ov5640_read_reg(0x3036, ®val); | 771 | temp1 = ov5640_read_reg(0x3036, ®val); |
| 772 | Multiplier = temp1; | 772 | Multiplier = temp1; |
| 773 | temp1 = ov5640_read_reg(0x3037, ®val); | 773 | temp1 = ov5640_read_reg(0x3037, ®val); |
| 774 | PreDiv = temp1 & 0x0f; | 774 | PreDiv = temp1 & 0x0f; |
| 775 | Pll_rdiv = ((temp1 >> 4) & 0x01) + 1; | 775 | Pll_rdiv = ((temp1 >> 4) & 0x01) + 1; |
| 776 | 776 | ||
| 777 | temp1 = ov5640_read_reg(0x3108, ®val); | 777 | temp1 = ov5640_read_reg(0x3108, ®val); |
| 778 | temp2 = temp1 & 0x03; | 778 | temp2 = temp1 & 0x03; |
| 779 | 779 | ||
| 780 | sclk_rdiv = sclk_rdiv_map[temp2]; | 780 | sclk_rdiv = sclk_rdiv_map[temp2]; |
| 781 | VCO = xvclk * Multiplier / PreDiv; | 781 | VCO = xvclk * Multiplier / PreDiv; |
| 782 | sysclk = VCO / SysDiv / Pll_rdiv * 2 / Bit_div2x / sclk_rdiv; | 782 | sysclk = VCO / SysDiv / Pll_rdiv * 2 / Bit_div2x / sclk_rdiv; |
| 783 | 783 | ||
| 784 | return sysclk; | 784 | return sysclk; |
| 785 | } | 785 | } |
| 786 | 786 | ||
| 787 | /* read HTS from register settings */ | 787 | /* read HTS from register settings */ |
| 788 | static int ov5640_get_HTS(void) | 788 | static int ov5640_get_HTS(void) |
| 789 | { | 789 | { |
| 790 | int HTS; | 790 | int HTS; |
| 791 | u8 temp = 0; | 791 | u8 temp = 0; |
| 792 | 792 | ||
| 793 | HTS = ov5640_read_reg(0x380c, &temp); | 793 | HTS = ov5640_read_reg(0x380c, &temp); |
| 794 | HTS = (HTS<<8) + ov5640_read_reg(0x380d, &temp); | 794 | HTS = (HTS<<8) + ov5640_read_reg(0x380d, &temp); |
| 795 | return HTS; | 795 | return HTS; |
| 796 | } | 796 | } |
| 797 | 797 | ||
| 798 | /* read VTS from register settings */ | 798 | /* read VTS from register settings */ |
| 799 | static int ov5640_get_VTS(void) | 799 | static int ov5640_get_VTS(void) |
| 800 | { | 800 | { |
| 801 | int VTS; | 801 | int VTS; |
| 802 | u8 temp = 0; | 802 | u8 temp = 0; |
| 803 | 803 | ||
| 804 | VTS = ov5640_read_reg(0x380e, &temp); | 804 | VTS = ov5640_read_reg(0x380e, &temp); |
| 805 | VTS = (VTS<<8) + ov5640_read_reg(0x380f, &temp); | 805 | VTS = (VTS<<8) + ov5640_read_reg(0x380f, &temp); |
| 806 | 806 | ||
| 807 | return VTS; | 807 | return VTS; |
| 808 | } | 808 | } |
| 809 | 809 | ||
| 810 | /* write VTS to registers */ | 810 | /* write VTS to registers */ |
| 811 | static int ov5640_set_VTS(int VTS) | 811 | static int ov5640_set_VTS(int VTS) |
| 812 | { | 812 | { |
| 813 | int temp; | 813 | int temp; |
| 814 | 814 | ||
| 815 | temp = VTS & 0xff; | 815 | temp = VTS & 0xff; |
| 816 | ov5640_write_reg(0x380f, temp); | 816 | ov5640_write_reg(0x380f, temp); |
| 817 | 817 | ||
| 818 | temp = VTS>>8; | 818 | temp = VTS>>8; |
| 819 | ov5640_write_reg(0x380e, temp); | 819 | ov5640_write_reg(0x380e, temp); |
| 820 | return 0; | 820 | return 0; |
| 821 | } | 821 | } |
| 822 | 822 | ||
| 823 | /* read shutter, in number of line period */ | 823 | /* read shutter, in number of line period */ |
| 824 | static int ov5640_get_shutter(void) | 824 | static int ov5640_get_shutter(void) |
| 825 | { | 825 | { |
| 826 | int shutter; | 826 | int shutter; |
| 827 | u8 regval; | 827 | u8 regval; |
| 828 | 828 | ||
| 829 | shutter = (ov5640_read_reg(0x03500, ®val) & 0x0f); | 829 | shutter = (ov5640_read_reg(0x03500, ®val) & 0x0f); |
| 830 | 830 | ||
| 831 | shutter = (shutter<<8) + ov5640_read_reg(0x3501, ®val); | 831 | shutter = (shutter<<8) + ov5640_read_reg(0x3501, ®val); |
| 832 | shutter = (shutter<<4) + (ov5640_read_reg(0x3502, ®val)>>4); | 832 | shutter = (shutter<<4) + (ov5640_read_reg(0x3502, ®val)>>4); |
| 833 | 833 | ||
| 834 | return shutter; | 834 | return shutter; |
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | /* write shutter, in number of line period */ | 837 | /* write shutter, in number of line period */ |
| 838 | static int ov5640_set_shutter(int shutter) | 838 | static int ov5640_set_shutter(int shutter) |
| 839 | { | 839 | { |
| 840 | int temp; | 840 | int temp; |
| 841 | 841 | ||
| 842 | shutter = shutter & 0xffff; | 842 | shutter = shutter & 0xffff; |
| 843 | temp = shutter & 0x0f; | 843 | temp = shutter & 0x0f; |
| 844 | temp = temp<<4; | 844 | temp = temp<<4; |
| 845 | ov5640_write_reg(0x3502, temp); | 845 | ov5640_write_reg(0x3502, temp); |
| 846 | 846 | ||
| 847 | temp = shutter & 0xfff; | 847 | temp = shutter & 0xfff; |
| 848 | temp = temp>>4; | 848 | temp = temp>>4; |
| 849 | ov5640_write_reg(0x3501, temp); | 849 | ov5640_write_reg(0x3501, temp); |
| 850 | 850 | ||
| 851 | temp = shutter>>12; | 851 | temp = shutter>>12; |
| 852 | ov5640_write_reg(0x3500, temp); | 852 | ov5640_write_reg(0x3500, temp); |
| 853 | 853 | ||
| 854 | return 0; | 854 | return 0; |
| 855 | } | 855 | } |
| 856 | 856 | ||
| 857 | /* read gain, 16 = 1x */ | 857 | /* read gain, 16 = 1x */ |
| 858 | static int ov5640_get_gain16(void) | 858 | static int ov5640_get_gain16(void) |
| 859 | { | 859 | { |
| 860 | int gain16; | 860 | int gain16; |
| 861 | u8 regval; | 861 | u8 regval; |
| 862 | 862 | ||
| 863 | gain16 = ov5640_read_reg(0x350a, ®val) & 0x03; | 863 | gain16 = ov5640_read_reg(0x350a, ®val) & 0x03; |
| 864 | gain16 = (gain16<<8) + ov5640_read_reg(0x350b, ®val); | 864 | gain16 = (gain16<<8) + ov5640_read_reg(0x350b, ®val); |
| 865 | 865 | ||
| 866 | return gain16; | 866 | return gain16; |
| 867 | } | 867 | } |
| 868 | 868 | ||
| 869 | /* write gain, 16 = 1x */ | 869 | /* write gain, 16 = 1x */ |
| 870 | static int ov5640_set_gain16(int gain16) | 870 | static int ov5640_set_gain16(int gain16) |
| 871 | { | 871 | { |
| 872 | int temp; | 872 | int temp; |
| 873 | 873 | ||
| 874 | gain16 = gain16 & 0x3ff; | 874 | gain16 = gain16 & 0x3ff; |
| 875 | temp = gain16 & 0xff; | 875 | temp = gain16 & 0xff; |
| 876 | 876 | ||
| 877 | ov5640_write_reg(0x350b, temp); | 877 | ov5640_write_reg(0x350b, temp); |
| 878 | temp = gain16>>8; | 878 | temp = gain16>>8; |
| 879 | 879 | ||
| 880 | ov5640_write_reg(0x350a, temp); | 880 | ov5640_write_reg(0x350a, temp); |
| 881 | return 0; | 881 | return 0; |
| 882 | } | 882 | } |
| 883 | 883 | ||
| 884 | /* get banding filter value */ | 884 | /* get banding filter value */ |
| 885 | static int ov5640_get_light_freq(void) | 885 | static int ov5640_get_light_freq(void) |
| 886 | { | 886 | { |
| 887 | int temp, temp1, light_frequency; | 887 | int temp, temp1, light_frequency; |
| 888 | u8 regval; | 888 | u8 regval; |
| 889 | 889 | ||
| 890 | temp = ov5640_read_reg(0x3c01, ®val); | 890 | temp = ov5640_read_reg(0x3c01, ®val); |
| 891 | if (temp & 0x80) { | 891 | if (temp & 0x80) { |
| 892 | /* manual */ | 892 | /* manual */ |
| 893 | temp1 = ov5640_read_reg(0x3c00, ®val); | 893 | temp1 = ov5640_read_reg(0x3c00, ®val); |
| 894 | if (temp1 & 0x04) { | 894 | if (temp1 & 0x04) { |
| 895 | /* 50Hz */ | 895 | /* 50Hz */ |
| 896 | light_frequency = 50; | 896 | light_frequency = 50; |
| 897 | } else { | 897 | } else { |
| 898 | /* 60Hz */ | 898 | /* 60Hz */ |
| 899 | light_frequency = 60; | 899 | light_frequency = 60; |
| 900 | } | 900 | } |
| 901 | } else { | 901 | } else { |
| 902 | /* auto */ | 902 | /* auto */ |
| 903 | temp1 = ov5640_read_reg(0x3c0c, ®val); | 903 | temp1 = ov5640_read_reg(0x3c0c, ®val); |
| 904 | if (temp1 & 0x01) { | 904 | if (temp1 & 0x01) { |
| 905 | /* 50Hz */ | 905 | /* 50Hz */ |
| 906 | light_frequency = 50; | 906 | light_frequency = 50; |
| 907 | } else { | 907 | } else { |
| 908 | /* 60Hz */ | 908 | /* 60Hz */ |
| 909 | light_frequency = 60; | 909 | light_frequency = 60; |
| 910 | } | 910 | } |
| 911 | } | 911 | } |
| 912 | 912 | ||
| 913 | return light_frequency; | 913 | return light_frequency; |
| 914 | } | 914 | } |
| 915 | 915 | ||
| 916 | static void ov5640_set_bandingfilter(void) | 916 | static void ov5640_set_bandingfilter(void) |
| 917 | { | 917 | { |
| 918 | int prev_VTS; | 918 | int prev_VTS; |
| 919 | int band_step60, max_band60, band_step50, max_band50; | 919 | int band_step60, max_band60, band_step50, max_band50; |
| 920 | 920 | ||
| 921 | /* read preview PCLK */ | 921 | /* read preview PCLK */ |
| 922 | prev_sysclk = ov5640_get_sysclk(); | 922 | prev_sysclk = ov5640_get_sysclk(); |
| 923 | 923 | ||
| 924 | /* read preview HTS */ | 924 | /* read preview HTS */ |
| 925 | prev_HTS = ov5640_get_HTS(); | 925 | prev_HTS = ov5640_get_HTS(); |
| 926 | 926 | ||
| 927 | /* read preview VTS */ | 927 | /* read preview VTS */ |
| 928 | prev_VTS = ov5640_get_VTS(); | 928 | prev_VTS = ov5640_get_VTS(); |
| 929 | 929 | ||
| 930 | /* calculate banding filter */ | 930 | /* calculate banding filter */ |
| 931 | /* 60Hz */ | 931 | /* 60Hz */ |
| 932 | band_step60 = prev_sysclk * 100/prev_HTS * 100/120; | 932 | band_step60 = prev_sysclk * 100/prev_HTS * 100/120; |
| 933 | ov5640_write_reg(0x3a0a, (band_step60 >> 8)); | 933 | ov5640_write_reg(0x3a0a, (band_step60 >> 8)); |
| 934 | ov5640_write_reg(0x3a0b, (band_step60 & 0xff)); | 934 | ov5640_write_reg(0x3a0b, (band_step60 & 0xff)); |
| 935 | 935 | ||
| 936 | max_band60 = (int)((prev_VTS-4)/band_step60); | 936 | max_band60 = (int)((prev_VTS-4)/band_step60); |
| 937 | ov5640_write_reg(0x3a0d, max_band60); | 937 | ov5640_write_reg(0x3a0d, max_band60); |
| 938 | 938 | ||
| 939 | /* 50Hz */ | 939 | /* 50Hz */ |
| 940 | band_step50 = prev_sysclk * 100/prev_HTS; | 940 | band_step50 = prev_sysclk * 100/prev_HTS; |
| 941 | ov5640_write_reg(0x3a08, (band_step50 >> 8)); | 941 | ov5640_write_reg(0x3a08, (band_step50 >> 8)); |
| 942 | ov5640_write_reg(0x3a09, (band_step50 & 0xff)); | 942 | ov5640_write_reg(0x3a09, (band_step50 & 0xff)); |
| 943 | 943 | ||
| 944 | max_band50 = (int)((prev_VTS-4)/band_step50); | 944 | max_band50 = (int)((prev_VTS-4)/band_step50); |
| 945 | ov5640_write_reg(0x3a0e, max_band50); | 945 | ov5640_write_reg(0x3a0e, max_band50); |
| 946 | } | 946 | } |
| 947 | 947 | ||
| 948 | /* stable in high */ | 948 | /* stable in high */ |
| 949 | static int ov5640_set_AE_target(int target) | 949 | static int ov5640_set_AE_target(int target) |
| 950 | { | 950 | { |
| 951 | int fast_high, fast_low; | 951 | int fast_high, fast_low; |
| 952 | 952 | ||
| 953 | AE_low = target * 23 / 25; /* 0.92 */ | 953 | AE_low = target * 23 / 25; /* 0.92 */ |
| 954 | AE_high = target * 27 / 25; /* 1.08 */ | 954 | AE_high = target * 27 / 25; /* 1.08 */ |
| 955 | fast_high = AE_high << 1; | 955 | fast_high = AE_high << 1; |
| 956 | 956 | ||
| 957 | if (fast_high > 255) | 957 | if (fast_high > 255) |
| 958 | fast_high = 255; | 958 | fast_high = 255; |
| 959 | fast_low = AE_low >> 1; | 959 | fast_low = AE_low >> 1; |
| 960 | 960 | ||
| 961 | ov5640_write_reg(0x3a0f, AE_high); | 961 | ov5640_write_reg(0x3a0f, AE_high); |
| 962 | ov5640_write_reg(0x3a10, AE_low); | 962 | ov5640_write_reg(0x3a10, AE_low); |
| 963 | ov5640_write_reg(0x3a1b, AE_high); | 963 | ov5640_write_reg(0x3a1b, AE_high); |
| 964 | ov5640_write_reg(0x3a1e, AE_low); | 964 | ov5640_write_reg(0x3a1e, AE_low); |
| 965 | ov5640_write_reg(0x3a11, fast_high); | 965 | ov5640_write_reg(0x3a11, fast_high); |
| 966 | ov5640_write_reg(0x3a1f, fast_low); | 966 | ov5640_write_reg(0x3a1f, fast_low); |
| 967 | 967 | ||
| 968 | return 0; | 968 | return 0; |
| 969 | } | 969 | } |
| 970 | 970 | ||
| 971 | /* enable = 0 to turn off night mode | 971 | /* enable = 0 to turn off night mode |
| 972 | enable = 1 to turn on night mode */ | 972 | enable = 1 to turn on night mode */ |
| 973 | static int ov5640_set_night_mode(int enable) | 973 | static int ov5640_set_night_mode(int enable) |
| 974 | { | 974 | { |
| 975 | u8 mode; | 975 | u8 mode; |
| 976 | 976 | ||
| 977 | ov5640_read_reg(0x3a00, &mode); | 977 | ov5640_read_reg(0x3a00, &mode); |
| 978 | 978 | ||
| 979 | if (enable) { | 979 | if (enable) { |
| 980 | /* night mode on */ | 980 | /* night mode on */ |
| 981 | mode |= 0x04; | 981 | mode |= 0x04; |
| 982 | ov5640_write_reg(0x3a00, mode); | 982 | ov5640_write_reg(0x3a00, mode); |
| 983 | } else { | 983 | } else { |
| 984 | /* night mode off */ | 984 | /* night mode off */ |
| 985 | mode &= 0xfb; | 985 | mode &= 0xfb; |
| 986 | ov5640_write_reg(0x3a00, mode); | 986 | ov5640_write_reg(0x3a00, mode); |
| 987 | } | 987 | } |
| 988 | 988 | ||
| 989 | return 0; | 989 | return 0; |
| 990 | } | 990 | } |
| 991 | 991 | ||
| 992 | /* enable = 0 to turn off AEC/AGC | 992 | /* enable = 0 to turn off AEC/AGC |
| 993 | enable = 1 to turn on AEC/AGC */ | 993 | enable = 1 to turn on AEC/AGC */ |
| 994 | static void ov5640_turn_on_AE_AG(int enable) | 994 | static void ov5640_turn_on_AE_AG(int enable) |
| 995 | { | 995 | { |
| 996 | u8 ae_ag_ctrl; | 996 | u8 ae_ag_ctrl; |
| 997 | 997 | ||
| 998 | ov5640_read_reg(0x3503, &ae_ag_ctrl); | 998 | ov5640_read_reg(0x3503, &ae_ag_ctrl); |
| 999 | if (enable) { | 999 | if (enable) { |
| 1000 | /* turn on auto AE/AG */ | 1000 | /* turn on auto AE/AG */ |
| 1001 | ae_ag_ctrl = ae_ag_ctrl & ~(0x03); | 1001 | ae_ag_ctrl = ae_ag_ctrl & ~(0x03); |
| 1002 | } else { | 1002 | } else { |
| 1003 | /* turn off AE/AG */ | 1003 | /* turn off AE/AG */ |
| 1004 | ae_ag_ctrl = ae_ag_ctrl | 0x03; | 1004 | ae_ag_ctrl = ae_ag_ctrl | 0x03; |
| 1005 | } | 1005 | } |
| 1006 | ov5640_write_reg(0x3503, ae_ag_ctrl); | 1006 | ov5640_write_reg(0x3503, ae_ag_ctrl); |
| 1007 | } | 1007 | } |
| 1008 | 1008 | ||
| 1009 | /* download ov5640 settings to sensor through i2c */ | 1009 | /* download ov5640 settings to sensor through i2c */ |
| 1010 | static int ov5640_download_firmware(struct reg_value *pModeSetting, s32 ArySize) | 1010 | static int ov5640_download_firmware(struct reg_value *pModeSetting, s32 ArySize) |
| 1011 | { | 1011 | { |
| 1012 | register u32 Delay_ms = 0; | 1012 | register u32 Delay_ms = 0; |
| 1013 | register u16 RegAddr = 0; | 1013 | register u16 RegAddr = 0; |
| 1014 | register u8 Mask = 0; | 1014 | register u8 Mask = 0; |
| 1015 | register u8 Val = 0; | 1015 | register u8 Val = 0; |
| 1016 | u8 RegVal = 0; | 1016 | u8 RegVal = 0; |
| 1017 | int i, retval = 0; | 1017 | int i, retval = 0; |
| 1018 | 1018 | ||
| 1019 | for (i = 0; i < ArySize; ++i, ++pModeSetting) { | 1019 | for (i = 0; i < ArySize; ++i, ++pModeSetting) { |
| 1020 | Delay_ms = pModeSetting->u32Delay_ms; | 1020 | Delay_ms = pModeSetting->u32Delay_ms; |
| 1021 | RegAddr = pModeSetting->u16RegAddr; | 1021 | RegAddr = pModeSetting->u16RegAddr; |
| 1022 | Val = pModeSetting->u8Val; | 1022 | Val = pModeSetting->u8Val; |
| 1023 | Mask = pModeSetting->u8Mask; | 1023 | Mask = pModeSetting->u8Mask; |
| 1024 | 1024 | ||
| 1025 | if (Mask) { | 1025 | if (Mask) { |
| 1026 | retval = ov5640_read_reg(RegAddr, &RegVal); | 1026 | retval = ov5640_read_reg(RegAddr, &RegVal); |
| 1027 | if (retval < 0) | 1027 | if (retval < 0) |
| 1028 | goto err; | 1028 | goto err; |
| 1029 | 1029 | ||
| 1030 | RegVal &= ~(u8)Mask; | 1030 | RegVal &= ~(u8)Mask; |
| 1031 | Val &= Mask; | 1031 | Val &= Mask; |
| 1032 | Val |= RegVal; | 1032 | Val |= RegVal; |
| 1033 | } | 1033 | } |
| 1034 | 1034 | ||
| 1035 | retval = ov5640_write_reg(RegAddr, Val); | 1035 | retval = ov5640_write_reg(RegAddr, Val); |
| 1036 | if (retval < 0) | 1036 | if (retval < 0) |
| 1037 | goto err; | 1037 | goto err; |
| 1038 | 1038 | ||
| 1039 | if (Delay_ms) | 1039 | if (Delay_ms) |
| 1040 | msleep(Delay_ms); | 1040 | msleep(Delay_ms); |
| 1041 | } | 1041 | } |
| 1042 | err: | 1042 | err: |
| 1043 | return retval; | 1043 | return retval; |
| 1044 | } | 1044 | } |
| 1045 | 1045 | ||
| 1046 | static int ov5640_init_mode(void) | 1046 | static int ov5640_init_mode(void) |
| 1047 | { | 1047 | { |
| 1048 | struct reg_value *pModeSetting = NULL; | 1048 | struct reg_value *pModeSetting = NULL; |
| 1049 | int ArySize = 0, retval = 0; | 1049 | int ArySize = 0, retval = 0; |
| 1050 | 1050 | ||
| 1051 | ov5640_soft_reset(); | 1051 | ov5640_soft_reset(); |
| 1052 | 1052 | ||
| 1053 | pModeSetting = ov5640_global_init_setting; | 1053 | pModeSetting = ov5640_global_init_setting; |
| 1054 | ArySize = ARRAY_SIZE(ov5640_global_init_setting); | 1054 | ArySize = ARRAY_SIZE(ov5640_global_init_setting); |
| 1055 | retval = ov5640_download_firmware(pModeSetting, ArySize); | 1055 | retval = ov5640_download_firmware(pModeSetting, ArySize); |
| 1056 | if (retval < 0) | 1056 | if (retval < 0) |
| 1057 | goto err; | 1057 | goto err; |
| 1058 | 1058 | ||
| 1059 | pModeSetting = ov5640_init_setting_30fps_VGA; | 1059 | pModeSetting = ov5640_init_setting_30fps_VGA; |
| 1060 | ArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA); | 1060 | ArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA); |
| 1061 | retval = ov5640_download_firmware(pModeSetting, ArySize); | 1061 | retval = ov5640_download_firmware(pModeSetting, ArySize); |
| 1062 | if (retval < 0) | 1062 | if (retval < 0) |
| 1063 | goto err; | 1063 | goto err; |
| 1064 | 1064 | ||
| 1065 | /* change driver capability to 2x according to validation board. | 1065 | /* change driver capability to 2x according to validation board. |
| 1066 | * if the image is not stable, please increase the driver strength. | 1066 | * if the image is not stable, please increase the driver strength. |
| 1067 | */ | 1067 | */ |
| 1068 | ov5640_driver_capability(2); | 1068 | ov5640_driver_capability(2); |
| 1069 | ov5640_set_bandingfilter(); | 1069 | ov5640_set_bandingfilter(); |
| 1070 | ov5640_set_AE_target(AE_Target); | 1070 | ov5640_set_AE_target(AE_Target); |
| 1071 | ov5640_set_night_mode(night_mode); | 1071 | ov5640_set_night_mode(night_mode); |
| 1072 | 1072 | ||
| 1073 | /* skip 9 vysnc: start capture at 10th vsync */ | 1073 | /* skip 9 vysnc: start capture at 10th vsync */ |
| 1074 | msleep(300); | 1074 | msleep(300); |
| 1075 | 1075 | ||
| 1076 | /* turn off night mode */ | 1076 | /* turn off night mode */ |
| 1077 | night_mode = 0; | 1077 | night_mode = 0; |
| 1078 | ov5640_data.pix.width = 640; | 1078 | ov5640_data.pix.width = 640; |
| 1079 | ov5640_data.pix.height = 480; | 1079 | ov5640_data.pix.height = 480; |
| 1080 | err: | 1080 | err: |
| 1081 | return retval; | 1081 | return retval; |
| 1082 | } | 1082 | } |
| 1083 | 1083 | ||
| 1084 | /* change to or back to subsampling mode set the mode directly | 1084 | /* change to or back to subsampling mode set the mode directly |
| 1085 | * image size below 1280 * 960 is subsampling mode */ | 1085 | * image size below 1280 * 960 is subsampling mode */ |
| 1086 | static int ov5640_change_mode_direct(enum ov5640_frame_rate frame_rate, | 1086 | static int ov5640_change_mode_direct(enum ov5640_frame_rate frame_rate, |
| 1087 | enum ov5640_mode mode) | 1087 | enum ov5640_mode mode) |
| 1088 | { | 1088 | { |
| 1089 | struct reg_value *pModeSetting = NULL; | 1089 | struct reg_value *pModeSetting = NULL; |
| 1090 | s32 ArySize = 0; | 1090 | s32 ArySize = 0; |
| 1091 | int retval = 0; | 1091 | int retval = 0; |
| 1092 | 1092 | ||
| 1093 | if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { | 1093 | if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { |
| 1094 | pr_err("Wrong ov5640 mode detected!\n"); | 1094 | pr_err("Wrong ov5640 mode detected!\n"); |
| 1095 | return -1; | 1095 | return -1; |
| 1096 | } | 1096 | } |
| 1097 | 1097 | ||
| 1098 | pModeSetting = ov5640_mode_info_data[frame_rate][mode].init_data_ptr; | 1098 | pModeSetting = ov5640_mode_info_data[frame_rate][mode].init_data_ptr; |
| 1099 | ArySize = | 1099 | ArySize = |
| 1100 | ov5640_mode_info_data[frame_rate][mode].init_data_size; | 1100 | ov5640_mode_info_data[frame_rate][mode].init_data_size; |
| 1101 | 1101 | ||
| 1102 | ov5640_data.pix.width = ov5640_mode_info_data[frame_rate][mode].width; | 1102 | ov5640_data.pix.width = ov5640_mode_info_data[frame_rate][mode].width; |
| 1103 | ov5640_data.pix.height = ov5640_mode_info_data[frame_rate][mode].height; | 1103 | ov5640_data.pix.height = ov5640_mode_info_data[frame_rate][mode].height; |
| 1104 | 1104 | ||
| 1105 | if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || | 1105 | if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || |
| 1106 | pModeSetting == NULL || ArySize == 0) | 1106 | pModeSetting == NULL || ArySize == 0) |
| 1107 | return -EINVAL; | 1107 | return -EINVAL; |
| 1108 | 1108 | ||
| 1109 | /* set ov5640 to subsampling mode */ | 1109 | /* set ov5640 to subsampling mode */ |
| 1110 | retval = ov5640_download_firmware(pModeSetting, ArySize); | 1110 | retval = ov5640_download_firmware(pModeSetting, ArySize); |
| 1111 | 1111 | ||
| 1112 | /* turn on AE AG for subsampling mode, in case the firmware didn't */ | 1112 | /* turn on AE AG for subsampling mode, in case the firmware didn't */ |
| 1113 | ov5640_turn_on_AE_AG(1); | 1113 | ov5640_turn_on_AE_AG(1); |
| 1114 | 1114 | ||
| 1115 | /* calculate banding filter */ | 1115 | /* calculate banding filter */ |
| 1116 | ov5640_set_bandingfilter(); | 1116 | ov5640_set_bandingfilter(); |
| 1117 | 1117 | ||
| 1118 | /* set AE target */ | 1118 | /* set AE target */ |
| 1119 | ov5640_set_AE_target(AE_Target); | 1119 | ov5640_set_AE_target(AE_Target); |
| 1120 | 1120 | ||
| 1121 | /* update night mode setting */ | 1121 | /* update night mode setting */ |
| 1122 | ov5640_set_night_mode(night_mode); | 1122 | ov5640_set_night_mode(night_mode); |
| 1123 | 1123 | ||
| 1124 | /* skip 9 vysnc: start capture at 10th vsync */ | 1124 | /* skip 9 vysnc: start capture at 10th vsync */ |
| 1125 | if (mode == ov5640_mode_XGA_1024_768 && frame_rate == ov5640_30_fps) { | 1125 | if (mode == ov5640_mode_XGA_1024_768 && frame_rate == ov5640_30_fps) { |
| 1126 | pr_warning("ov5640: actual frame rate of XGA is 22.5fps\n"); | 1126 | pr_warning("ov5640: actual frame rate of XGA is 22.5fps\n"); |
| 1127 | /* 1/22.5 * 9*/ | 1127 | /* 1/22.5 * 9*/ |
| 1128 | msleep(400); | 1128 | msleep(400); |
| 1129 | return retval; | 1129 | return retval; |
| 1130 | } | 1130 | } |
| 1131 | 1131 | ||
| 1132 | if (frame_rate == ov5640_15_fps) { | 1132 | if (frame_rate == ov5640_15_fps) { |
| 1133 | /* 1/15 * 9*/ | 1133 | /* 1/15 * 9*/ |
| 1134 | msleep(600); | 1134 | msleep(600); |
| 1135 | } else if (frame_rate == ov5640_30_fps) { | 1135 | } else if (frame_rate == ov5640_30_fps) { |
| 1136 | /* 1/30 * 9*/ | 1136 | /* 1/30 * 9*/ |
| 1137 | msleep(300); | 1137 | msleep(300); |
| 1138 | } | 1138 | } |
| 1139 | 1139 | ||
| 1140 | return retval; | 1140 | return retval; |
| 1141 | } | 1141 | } |
| 1142 | 1142 | ||
| 1143 | /* change to scaling mode go through exposure calucation | 1143 | /* change to scaling mode go through exposure calucation |
| 1144 | * image size above 1280 * 960 is scaling mode */ | 1144 | * image size above 1280 * 960 is scaling mode */ |
| 1145 | static int ov5640_change_mode_exposure_calc(enum ov5640_frame_rate frame_rate, | 1145 | static int ov5640_change_mode_exposure_calc(enum ov5640_frame_rate frame_rate, |
| 1146 | enum ov5640_mode mode) | 1146 | enum ov5640_mode mode) |
| 1147 | { | 1147 | { |
| 1148 | int prev_shutter, prev_gain16, average; | 1148 | int prev_shutter, prev_gain16, average; |
| 1149 | int cap_shutter, cap_gain16; | 1149 | int cap_shutter, cap_gain16; |
| 1150 | int cap_sysclk, cap_HTS, cap_VTS; | 1150 | int cap_sysclk, cap_HTS, cap_VTS; |
| 1151 | int light_freq, cap_bandfilt, cap_maxband; | 1151 | int light_freq, cap_bandfilt, cap_maxband; |
| 1152 | long cap_gain16_shutter; | 1152 | long cap_gain16_shutter; |
| 1153 | u8 temp; | 1153 | u8 temp; |
| 1154 | struct reg_value *pModeSetting = NULL; | 1154 | struct reg_value *pModeSetting = NULL; |
| 1155 | s32 ArySize = 0; | 1155 | s32 ArySize = 0; |
| 1156 | int retval = 0; | 1156 | int retval = 0; |
| 1157 | 1157 | ||
| 1158 | /* check if the input mode and frame rate is valid */ | 1158 | /* check if the input mode and frame rate is valid */ |
| 1159 | pModeSetting = | 1159 | pModeSetting = |
| 1160 | ov5640_mode_info_data[frame_rate][mode].init_data_ptr; | 1160 | ov5640_mode_info_data[frame_rate][mode].init_data_ptr; |
| 1161 | ArySize = | 1161 | ArySize = |
| 1162 | ov5640_mode_info_data[frame_rate][mode].init_data_size; | 1162 | ov5640_mode_info_data[frame_rate][mode].init_data_size; |
| 1163 | 1163 | ||
| 1164 | ov5640_data.pix.width = | 1164 | ov5640_data.pix.width = |
| 1165 | ov5640_mode_info_data[frame_rate][mode].width; | 1165 | ov5640_mode_info_data[frame_rate][mode].width; |
| 1166 | ov5640_data.pix.height = | 1166 | ov5640_data.pix.height = |
| 1167 | ov5640_mode_info_data[frame_rate][mode].height; | 1167 | ov5640_mode_info_data[frame_rate][mode].height; |
| 1168 | 1168 | ||
| 1169 | if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || | 1169 | if (ov5640_data.pix.width == 0 || ov5640_data.pix.height == 0 || |
| 1170 | pModeSetting == NULL || ArySize == 0) | 1170 | pModeSetting == NULL || ArySize == 0) |
| 1171 | return -EINVAL; | 1171 | return -EINVAL; |
| 1172 | 1172 | ||
| 1173 | /* read preview shutter */ | 1173 | /* read preview shutter */ |
| 1174 | prev_shutter = ov5640_get_shutter(); | 1174 | prev_shutter = ov5640_get_shutter(); |
| 1175 | 1175 | ||
| 1176 | /* read preview gain */ | 1176 | /* read preview gain */ |
| 1177 | prev_gain16 = ov5640_get_gain16(); | 1177 | prev_gain16 = ov5640_get_gain16(); |
| 1178 | 1178 | ||
| 1179 | /* get average */ | 1179 | /* get average */ |
| 1180 | average = ov5640_read_reg(0x56a1, &temp); | 1180 | average = ov5640_read_reg(0x56a1, &temp); |
| 1181 | 1181 | ||
| 1182 | /* turn off night mode for capture */ | 1182 | /* turn off night mode for capture */ |
| 1183 | ov5640_set_night_mode(0); | 1183 | ov5640_set_night_mode(0); |
| 1184 | 1184 | ||
| 1185 | /* turn off overlay */ | 1185 | /* turn off overlay */ |
| 1186 | ov5640_write_reg(0x3022, 0x06); | 1186 | ov5640_write_reg(0x3022, 0x06); |
| 1187 | 1187 | ||
| 1188 | /* Write capture setting */ | 1188 | /* Write capture setting */ |
| 1189 | retval = ov5640_download_firmware(pModeSetting, ArySize); | 1189 | retval = ov5640_download_firmware(pModeSetting, ArySize); |
| 1190 | if (retval < 0) | 1190 | if (retval < 0) |
| 1191 | goto err; | 1191 | goto err; |
| 1192 | 1192 | ||
| 1193 | /* turn off AE AG when capture image. */ | 1193 | /* turn off AE AG when capture image. */ |
| 1194 | ov5640_turn_on_AE_AG(0); | 1194 | ov5640_turn_on_AE_AG(0); |
| 1195 | 1195 | ||
| 1196 | /* read capture VTS */ | 1196 | /* read capture VTS */ |
| 1197 | cap_VTS = ov5640_get_VTS(); | 1197 | cap_VTS = ov5640_get_VTS(); |
| 1198 | cap_HTS = ov5640_get_HTS(); | 1198 | cap_HTS = ov5640_get_HTS(); |
| 1199 | cap_sysclk = ov5640_get_sysclk(); | 1199 | cap_sysclk = ov5640_get_sysclk(); |
| 1200 | 1200 | ||
| 1201 | /* calculate capture banding filter */ | 1201 | /* calculate capture banding filter */ |
| 1202 | light_freq = ov5640_get_light_freq(); | 1202 | light_freq = ov5640_get_light_freq(); |
| 1203 | if (light_freq == 60) { | 1203 | if (light_freq == 60) { |
| 1204 | /* 60Hz */ | 1204 | /* 60Hz */ |
| 1205 | cap_bandfilt = cap_sysclk * 100 / cap_HTS * 100 / 120; | 1205 | cap_bandfilt = cap_sysclk * 100 / cap_HTS * 100 / 120; |
| 1206 | } else { | 1206 | } else { |
| 1207 | /* 50Hz */ | 1207 | /* 50Hz */ |
| 1208 | cap_bandfilt = cap_sysclk * 100 / cap_HTS; | 1208 | cap_bandfilt = cap_sysclk * 100 / cap_HTS; |
| 1209 | } | 1209 | } |
| 1210 | cap_maxband = (int)((cap_VTS - 4)/cap_bandfilt); | 1210 | cap_maxband = (int)((cap_VTS - 4)/cap_bandfilt); |
| 1211 | /* calculate capture shutter/gain16 */ | 1211 | /* calculate capture shutter/gain16 */ |
| 1212 | if (average > AE_low && average < AE_high) { | 1212 | if (average > AE_low && average < AE_high) { |
| 1213 | /* in stable range */ | 1213 | /* in stable range */ |
| 1214 | cap_gain16_shutter = | 1214 | cap_gain16_shutter = |
| 1215 | prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * | 1215 | prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * |
| 1216 | prev_HTS/cap_HTS * AE_Target / average; | 1216 | prev_HTS/cap_HTS * AE_Target / average; |
| 1217 | } else { | 1217 | } else { |
| 1218 | cap_gain16_shutter = | 1218 | cap_gain16_shutter = |
| 1219 | prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * | 1219 | prev_gain16 * prev_shutter * cap_sysclk/prev_sysclk * |
| 1220 | prev_HTS/cap_HTS; | 1220 | prev_HTS/cap_HTS; |
| 1221 | } | 1221 | } |
| 1222 | 1222 | ||
| 1223 | /* gain to shutter */ | 1223 | /* gain to shutter */ |
| 1224 | if (cap_gain16_shutter < (cap_bandfilt * 16)) { | 1224 | if (cap_gain16_shutter < (cap_bandfilt * 16)) { |
| 1225 | /* shutter < 1/100 */ | 1225 | /* shutter < 1/100 */ |
| 1226 | cap_shutter = cap_gain16_shutter/16; | 1226 | cap_shutter = cap_gain16_shutter/16; |
| 1227 | if (cap_shutter < 1) | 1227 | if (cap_shutter < 1) |
| 1228 | cap_shutter = 1; | 1228 | cap_shutter = 1; |
| 1229 | cap_gain16 = cap_gain16_shutter/cap_shutter; | 1229 | cap_gain16 = cap_gain16_shutter/cap_shutter; |
| 1230 | if (cap_gain16 < 16) | 1230 | if (cap_gain16 < 16) |
| 1231 | cap_gain16 = 16; | 1231 | cap_gain16 = 16; |
| 1232 | } else { | 1232 | } else { |
| 1233 | if (cap_gain16_shutter > (cap_bandfilt*cap_maxband*16)) { | 1233 | if (cap_gain16_shutter > (cap_bandfilt*cap_maxband*16)) { |
| 1234 | /* exposure reach max */ | 1234 | /* exposure reach max */ |
| 1235 | cap_shutter = cap_bandfilt*cap_maxband; | 1235 | cap_shutter = cap_bandfilt*cap_maxband; |
| 1236 | cap_gain16 = cap_gain16_shutter / cap_shutter; | 1236 | cap_gain16 = cap_gain16_shutter / cap_shutter; |
| 1237 | } else { | 1237 | } else { |
| 1238 | /* 1/100 < cap_shutter =< max, cap_shutter = n/100 */ | 1238 | /* 1/100 < cap_shutter =< max, cap_shutter = n/100 */ |
| 1239 | cap_shutter = | 1239 | cap_shutter = |
| 1240 | ((int)(cap_gain16_shutter/16/cap_bandfilt)) | 1240 | ((int)(cap_gain16_shutter/16/cap_bandfilt)) |
| 1241 | * cap_bandfilt; | 1241 | * cap_bandfilt; |
| 1242 | cap_gain16 = cap_gain16_shutter / cap_shutter; | 1242 | cap_gain16 = cap_gain16_shutter / cap_shutter; |
| 1243 | } | 1243 | } |
| 1244 | } | 1244 | } |
| 1245 | 1245 | ||
| 1246 | /* write capture gain */ | 1246 | /* write capture gain */ |
| 1247 | ov5640_set_gain16(cap_gain16); | 1247 | ov5640_set_gain16(cap_gain16); |
| 1248 | 1248 | ||
| 1249 | /* write capture shutter */ | 1249 | /* write capture shutter */ |
| 1250 | if (cap_shutter > (cap_VTS - 4)) { | 1250 | if (cap_shutter > (cap_VTS - 4)) { |
| 1251 | cap_VTS = cap_shutter + 4; | 1251 | cap_VTS = cap_shutter + 4; |
| 1252 | ov5640_set_VTS(cap_VTS); | 1252 | ov5640_set_VTS(cap_VTS); |
| 1253 | } | 1253 | } |
| 1254 | 1254 | ||
| 1255 | ov5640_set_shutter(cap_shutter); | 1255 | ov5640_set_shutter(cap_shutter); |
| 1256 | 1256 | ||
| 1257 | /* skip 2 vysnc: start capture at 3rd vsync | 1257 | /* skip 2 vysnc: start capture at 3rd vsync |
| 1258 | * frame rate of QSXGA and 1080P is 7.5fps: 1/7.5 * 2 | 1258 | * frame rate of QSXGA and 1080P is 7.5fps: 1/7.5 * 2 |
| 1259 | */ | 1259 | */ |
| 1260 | pr_warning("ov5640: the actual frame rate of %s is 7.5fps\n", | 1260 | pr_warning("ov5640: the actual frame rate of %s is 7.5fps\n", |
| 1261 | mode == ov5640_mode_1080P_1920_1080 ? "1080P" : "QSXGA"); | 1261 | mode == ov5640_mode_1080P_1920_1080 ? "1080P" : "QSXGA"); |
| 1262 | msleep(267); | 1262 | msleep(267); |
| 1263 | err: | 1263 | err: |
| 1264 | return retval; | 1264 | return retval; |
| 1265 | } | 1265 | } |
| 1266 | 1266 | ||
| 1267 | static int ov5640_change_mode(enum ov5640_frame_rate frame_rate, | 1267 | static int ov5640_change_mode(enum ov5640_frame_rate frame_rate, |
| 1268 | enum ov5640_mode mode) | 1268 | enum ov5640_mode mode) |
| 1269 | { | 1269 | { |
| 1270 | int retval = 0; | 1270 | int retval = 0; |
| 1271 | 1271 | ||
| 1272 | if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { | 1272 | if (mode > ov5640_mode_MAX || mode < ov5640_mode_MIN) { |
| 1273 | pr_err("Wrong ov5640 mode detected!\n"); | 1273 | pr_err("Wrong ov5640 mode detected!\n"); |
| 1274 | return -1; | 1274 | return -1; |
| 1275 | } | 1275 | } |
| 1276 | 1276 | ||
| 1277 | if (mode == ov5640_mode_1080P_1920_1080 || | 1277 | if (mode == ov5640_mode_1080P_1920_1080 || |
| 1278 | mode == ov5640_mode_QSXGA_2592_1944) { | 1278 | mode == ov5640_mode_QSXGA_2592_1944) { |
| 1279 | /* change to scaling mode go through exposure calucation | 1279 | /* change to scaling mode go through exposure calucation |
| 1280 | * image size above 1280 * 960 is scaling mode */ | 1280 | * image size above 1280 * 960 is scaling mode */ |
| 1281 | retval = ov5640_change_mode_exposure_calc(frame_rate, mode); | 1281 | retval = ov5640_change_mode_exposure_calc(frame_rate, mode); |
| 1282 | } else { | 1282 | } else { |
| 1283 | /* change back to subsampling modem download firmware directly | 1283 | /* change back to subsampling modem download firmware directly |
| 1284 | * image size below 1280 * 960 is subsampling mode */ | 1284 | * image size below 1280 * 960 is subsampling mode */ |
| 1285 | retval = ov5640_change_mode_direct(frame_rate, mode); | 1285 | retval = ov5640_change_mode_direct(frame_rate, mode); |
| 1286 | } | 1286 | } |
| 1287 | 1287 | ||
| 1288 | return retval; | 1288 | return retval; |
| 1289 | } | 1289 | } |
| 1290 | 1290 | ||
| 1291 | /* --------------- IOCTL functions from v4l2_int_ioctl_desc --------------- */ | 1291 | /* --------------- IOCTL functions from v4l2_int_ioctl_desc --------------- */ |
| 1292 | 1292 | ||
| 1293 | static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) | 1293 | static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p) |
| 1294 | { | 1294 | { |
| 1295 | if (s == NULL) { | 1295 | if (s == NULL) { |
| 1296 | pr_err(" ERROR!! no slave device set!\n"); | 1296 | pr_err(" ERROR!! no slave device set!\n"); |
| 1297 | return -1; | 1297 | return -1; |
| 1298 | } | 1298 | } |
| 1299 | 1299 | ||
| 1300 | memset(p, 0, sizeof(*p)); | 1300 | memset(p, 0, sizeof(*p)); |
| 1301 | p->u.bt656.clock_curr = ov5640_data.mclk; | 1301 | p->u.bt656.clock_curr = ov5640_data.mclk; |
| 1302 | pr_debug(" clock_curr=mclk=%d\n", ov5640_data.mclk); | 1302 | pr_debug(" clock_curr=mclk=%d\n", ov5640_data.mclk); |
| 1303 | p->if_type = V4L2_IF_TYPE_BT656; | 1303 | p->if_type = V4L2_IF_TYPE_BT656; |
| 1304 | p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; | 1304 | p->u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT; |
| 1305 | p->u.bt656.clock_min = OV5640_XCLK_MIN; | 1305 | p->u.bt656.clock_min = OV5640_XCLK_MIN; |
| 1306 | p->u.bt656.clock_max = OV5640_XCLK_MAX; | 1306 | p->u.bt656.clock_max = OV5640_XCLK_MAX; |
| 1307 | p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */ | 1307 | p->u.bt656.bt_sync_correct = 1; /* Indicate external vsync */ |
| 1308 | 1308 | ||
| 1309 | return 0; | 1309 | return 0; |
| 1310 | } | 1310 | } |
| 1311 | 1311 | ||
| 1312 | /*! | 1312 | /*! |
| 1313 | * ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl | 1313 | * ioctl_s_power - V4L2 sensor interface handler for VIDIOC_S_POWER ioctl |
| 1314 | * @s: pointer to standard V4L2 device structure | 1314 | * @s: pointer to standard V4L2 device structure |
| 1315 | * @on: indicates power mode (on or off) | 1315 | * @on: indicates power mode (on or off) |
| 1316 | * | 1316 | * |
| 1317 | * Turns the power on or off, depending on the value of on and returns the | 1317 | * Turns the power on or off, depending on the value of on and returns the |
| 1318 | * appropriate error code. | 1318 | * appropriate error code. |
| 1319 | */ | 1319 | */ |
| 1320 | static int ioctl_s_power(struct v4l2_int_device *s, int on) | 1320 | static int ioctl_s_power(struct v4l2_int_device *s, int on) |
| 1321 | { | 1321 | { |
| 1322 | struct sensor_data *sensor = s->priv; | 1322 | struct sensor_data *sensor = s->priv; |
| 1323 | 1323 | ||
| 1324 | if (on && !sensor->on) { | 1324 | if (on && !sensor->on) { |
| 1325 | if (io_regulator) | 1325 | if (io_regulator) |
| 1326 | if (regulator_enable(io_regulator) != 0) | 1326 | if (regulator_enable(io_regulator) != 0) |
| 1327 | return -EIO; | 1327 | return -EIO; |
| 1328 | if (core_regulator) | 1328 | if (core_regulator) |
| 1329 | if (regulator_enable(core_regulator) != 0) | 1329 | if (regulator_enable(core_regulator) != 0) |
| 1330 | return -EIO; | 1330 | return -EIO; |
| 1331 | if (analog_regulator) | 1331 | if (analog_regulator) |
| 1332 | if (regulator_enable(analog_regulator) != 0) | 1332 | if (regulator_enable(analog_regulator) != 0) |
| 1333 | return -EIO; | 1333 | return -EIO; |
| 1334 | /* Make sure power on */ | 1334 | /* Make sure power on */ |
| 1335 | ov5640_power_down(0); | 1335 | ov5640_power_down(0); |
| 1336 | } else if (!on && sensor->on) { | 1336 | } else if (!on && sensor->on) { |
| 1337 | if (analog_regulator) | 1337 | if (analog_regulator) |
| 1338 | regulator_disable(analog_regulator); | 1338 | regulator_disable(analog_regulator); |
| 1339 | if (core_regulator) | 1339 | if (core_regulator) |
| 1340 | regulator_disable(core_regulator); | 1340 | regulator_disable(core_regulator); |
| 1341 | if (io_regulator) | 1341 | if (io_regulator) |
| 1342 | regulator_disable(io_regulator); | 1342 | regulator_disable(io_regulator); |
| 1343 | 1343 | ||
| 1344 | ov5640_power_down(1); | 1344 | ov5640_power_down(1); |
| 1345 | } | 1345 | } |
| 1346 | 1346 | ||
| 1347 | sensor->on = on; | 1347 | sensor->on = on; |
| 1348 | 1348 | ||
| 1349 | return 0; | 1349 | return 0; |
| 1350 | } | 1350 | } |
| 1351 | 1351 | ||
| 1352 | /*! | 1352 | /*! |
| 1353 | * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl | 1353 | * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl |
| 1354 | * @s: pointer to standard V4L2 device structure | 1354 | * @s: pointer to standard V4L2 device structure |
| 1355 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure | 1355 | * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure |
| 1356 | * | 1356 | * |
| 1357 | * Returns the sensor's video CAPTURE parameters. | 1357 | * Returns the sensor's video CAPTURE parameters. |
| 1358 | */ | 1358 | */ |
| 1359 | static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | 1359 | static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) |
| 1360 | { | 1360 | { |
| 1361 | struct sensor_data *sensor = s->priv; | 1361 | struct sensor_data *sensor = s->priv; |
| 1362 | struct v4l2_captureparm *cparm = &a->parm.capture; | 1362 | struct v4l2_captureparm *cparm = &a->parm.capture; |
| 1363 | int ret = 0; | 1363 | int ret = 0; |
| 1364 | 1364 | ||
| 1365 | switch (a->type) { | 1365 | switch (a->type) { |
| 1366 | /* This is the only case currently handled. */ | 1366 | /* This is the only case currently handled. */ |
| 1367 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1367 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 1368 | memset(a, 0, sizeof(*a)); | 1368 | memset(a, 0, sizeof(*a)); |
| 1369 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1369 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1370 | cparm->capability = sensor->streamcap.capability; | 1370 | cparm->capability = sensor->streamcap.capability; |
| 1371 | cparm->timeperframe = sensor->streamcap.timeperframe; | 1371 | cparm->timeperframe = sensor->streamcap.timeperframe; |
| 1372 | cparm->capturemode = sensor->streamcap.capturemode; | 1372 | cparm->capturemode = sensor->streamcap.capturemode; |
| 1373 | ret = 0; | 1373 | ret = 0; |
| 1374 | break; | 1374 | break; |
| 1375 | 1375 | ||
| 1376 | /* These are all the possible cases. */ | 1376 | /* These are all the possible cases. */ |
| 1377 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1377 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
| 1378 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1378 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
| 1379 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1379 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 1380 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1380 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
| 1381 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1381 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
| 1382 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1382 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
| 1383 | ret = -EINVAL; | 1383 | ret = -EINVAL; |
| 1384 | break; | 1384 | break; |
| 1385 | 1385 | ||
| 1386 | default: | 1386 | default: |
| 1387 | pr_debug(" type is unknown - %d\n", a->type); | 1387 | pr_debug(" type is unknown - %d\n", a->type); |
| 1388 | ret = -EINVAL; | 1388 | ret = -EINVAL; |
| 1389 | break; | 1389 | break; |
| 1390 | } | 1390 | } |
| 1391 | 1391 | ||
| 1392 | return ret; | 1392 | return ret; |
| 1393 | } | 1393 | } |
| 1394 | 1394 | ||
| 1395 | /*! | 1395 | /*! |
| 1396 | * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl | 1396 | * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl |
| 1397 | * @s: pointer to standard V4L2 device structure | 1397 | * @s: pointer to standard V4L2 device structure |
| 1398 | * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure | 1398 | * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure |
| 1399 | * | 1399 | * |
| 1400 | * Configures the sensor to use the input parameters, if possible. If | 1400 | * Configures the sensor to use the input parameters, if possible. If |
| 1401 | * not possible, reverts to the old parameters and returns the | 1401 | * not possible, reverts to the old parameters and returns the |
| 1402 | * appropriate error code. | 1402 | * appropriate error code. |
| 1403 | */ | 1403 | */ |
| 1404 | static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) | 1404 | static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a) |
| 1405 | { | 1405 | { |
| 1406 | struct sensor_data *sensor = s->priv; | 1406 | struct sensor_data *sensor = s->priv; |
| 1407 | struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; | 1407 | struct v4l2_fract *timeperframe = &a->parm.capture.timeperframe; |
| 1408 | u32 tgt_fps; /* target frames per secound */ | 1408 | u32 tgt_fps; /* target frames per secound */ |
| 1409 | enum ov5640_frame_rate frame_rate; | 1409 | enum ov5640_frame_rate frame_rate; |
| 1410 | int ret = 0; | 1410 | int ret = 0; |
| 1411 | 1411 | ||
| 1412 | /* Make sure power on */ | 1412 | /* Make sure power on */ |
| 1413 | ov5640_power_down(0); | 1413 | ov5640_power_down(0); |
| 1414 | 1414 | ||
| 1415 | switch (a->type) { | 1415 | switch (a->type) { |
| 1416 | /* This is the only case currently handled. */ | 1416 | /* This is the only case currently handled. */ |
| 1417 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1417 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 1418 | /* Check that the new frame rate is allowed. */ | 1418 | /* Check that the new frame rate is allowed. */ |
| 1419 | if ((timeperframe->numerator == 0) || | 1419 | if ((timeperframe->numerator == 0) || |
| 1420 | (timeperframe->denominator == 0)) { | 1420 | (timeperframe->denominator == 0)) { |
| 1421 | timeperframe->denominator = DEFAULT_FPS; | 1421 | timeperframe->denominator = DEFAULT_FPS; |
| 1422 | timeperframe->numerator = 1; | 1422 | timeperframe->numerator = 1; |
| 1423 | } | 1423 | } |
| 1424 | 1424 | ||
| 1425 | tgt_fps = timeperframe->denominator / | 1425 | tgt_fps = timeperframe->denominator / |
| 1426 | timeperframe->numerator; | 1426 | timeperframe->numerator; |
| 1427 | 1427 | ||
| 1428 | if (tgt_fps > MAX_FPS) { | 1428 | if (tgt_fps > MAX_FPS) { |
| 1429 | timeperframe->denominator = MAX_FPS; | 1429 | timeperframe->denominator = MAX_FPS; |
| 1430 | timeperframe->numerator = 1; | 1430 | timeperframe->numerator = 1; |
| 1431 | } else if (tgt_fps < MIN_FPS) { | 1431 | } else if (tgt_fps < MIN_FPS) { |
| 1432 | timeperframe->denominator = MIN_FPS; | 1432 | timeperframe->denominator = MIN_FPS; |
| 1433 | timeperframe->numerator = 1; | 1433 | timeperframe->numerator = 1; |
| 1434 | } | 1434 | } |
| 1435 | 1435 | ||
| 1436 | /* Actual frame rate we use */ | 1436 | /* Actual frame rate we use */ |
| 1437 | tgt_fps = timeperframe->denominator / | 1437 | tgt_fps = timeperframe->denominator / |
| 1438 | timeperframe->numerator; | 1438 | timeperframe->numerator; |
| 1439 | 1439 | ||
| 1440 | if (tgt_fps == 15) | 1440 | if (tgt_fps == 15) |
| 1441 | frame_rate = ov5640_15_fps; | 1441 | frame_rate = ov5640_15_fps; |
| 1442 | else if (tgt_fps == 30) | 1442 | else if (tgt_fps == 30) |
| 1443 | frame_rate = ov5640_30_fps; | 1443 | frame_rate = ov5640_30_fps; |
| 1444 | else { | 1444 | else { |
| 1445 | pr_err(" The camera frame rate is not supported!\n"); | 1445 | pr_err(" The camera frame rate is not supported!\n"); |
| 1446 | return -EINVAL; | 1446 | return -EINVAL; |
| 1447 | } | 1447 | } |
| 1448 | 1448 | ||
| 1449 | ret = ov5640_change_mode(frame_rate, | 1449 | ret = ov5640_change_mode(frame_rate, |
| 1450 | a->parm.capture.capturemode); | 1450 | a->parm.capture.capturemode); |
| 1451 | if (ret < 0) | 1451 | if (ret < 0) |
| 1452 | return ret; | 1452 | return ret; |
| 1453 | 1453 | ||
| 1454 | sensor->streamcap.timeperframe = *timeperframe; | 1454 | sensor->streamcap.timeperframe = *timeperframe; |
| 1455 | sensor->streamcap.capturemode = a->parm.capture.capturemode; | 1455 | sensor->streamcap.capturemode = a->parm.capture.capturemode; |
| 1456 | 1456 | ||
| 1457 | break; | 1457 | break; |
| 1458 | 1458 | ||
| 1459 | /* These are all the possible cases. */ | 1459 | /* These are all the possible cases. */ |
| 1460 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1460 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
| 1461 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1461 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
| 1462 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1462 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
| 1463 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1463 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
| 1464 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1464 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
| 1465 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1465 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
| 1466 | pr_debug(" type is not " \ | 1466 | pr_debug(" type is not " \ |
| 1467 | "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", | 1467 | "V4L2_BUF_TYPE_VIDEO_CAPTURE but %d\n", |
| 1468 | a->type); | 1468 | a->type); |
| 1469 | ret = -EINVAL; | 1469 | ret = -EINVAL; |
| 1470 | break; | 1470 | break; |
| 1471 | 1471 | ||
| 1472 | default: | 1472 | default: |
| 1473 | pr_debug(" type is unknown - %d\n", a->type); | 1473 | pr_debug(" type is unknown - %d\n", a->type); |
| 1474 | ret = -EINVAL; | 1474 | ret = -EINVAL; |
| 1475 | break; | 1475 | break; |
| 1476 | } | 1476 | } |
| 1477 | 1477 | ||
| 1478 | return ret; | 1478 | return ret; |
| 1479 | } | 1479 | } |
| 1480 | 1480 | ||
| 1481 | /*! | 1481 | /*! |
| 1482 | * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap | 1482 | * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap |
| 1483 | * @s: pointer to standard V4L2 device structure | 1483 | * @s: pointer to standard V4L2 device structure |
| 1484 | * @f: pointer to standard V4L2 v4l2_format structure | 1484 | * @f: pointer to standard V4L2 v4l2_format structure |
| 1485 | * | 1485 | * |
| 1486 | * Returns the sensor's current pixel format in the v4l2_format | 1486 | * Returns the sensor's current pixel format in the v4l2_format |
| 1487 | * parameter. | 1487 | * parameter. |
| 1488 | */ | 1488 | */ |
| 1489 | static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) | 1489 | static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f) |
| 1490 | { | 1490 | { |
| 1491 | struct sensor_data *sensor = s->priv; | 1491 | struct sensor_data *sensor = s->priv; |
| 1492 | 1492 | ||
| 1493 | f->fmt.pix = sensor->pix; | 1493 | f->fmt.pix = sensor->pix; |
| 1494 | 1494 | ||
| 1495 | return 0; | 1495 | return 0; |
| 1496 | } | 1496 | } |
| 1497 | 1497 | ||
| 1498 | /*! | 1498 | /*! |
| 1499 | * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl | 1499 | * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl |
| 1500 | * @s: pointer to standard V4L2 device structure | 1500 | * @s: pointer to standard V4L2 device structure |
| 1501 | * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure | 1501 | * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure |
| 1502 | * | 1502 | * |
| 1503 | * If the requested control is supported, returns the control's current | 1503 | * If the requested control is supported, returns the control's current |
| 1504 | * value from the video_control[] array. Otherwise, returns -EINVAL | 1504 | * value from the video_control[] array. Otherwise, returns -EINVAL |
| 1505 | * if the control is not supported. | 1505 | * if the control is not supported. |
| 1506 | */ | 1506 | */ |
| 1507 | static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) | 1507 | static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) |
| 1508 | { | 1508 | { |
| 1509 | int ret = 0; | 1509 | int ret = 0; |
| 1510 | 1510 | ||
| 1511 | switch (vc->id) { | 1511 | switch (vc->id) { |
| 1512 | case V4L2_CID_BRIGHTNESS: | 1512 | case V4L2_CID_BRIGHTNESS: |
| 1513 | vc->value = ov5640_data.brightness; | 1513 | vc->value = ov5640_data.brightness; |
| 1514 | break; | 1514 | break; |
| 1515 | case V4L2_CID_HUE: | 1515 | case V4L2_CID_HUE: |
| 1516 | vc->value = ov5640_data.hue; | 1516 | vc->value = ov5640_data.hue; |
| 1517 | break; | 1517 | break; |
| 1518 | case V4L2_CID_CONTRAST: | 1518 | case V4L2_CID_CONTRAST: |
| 1519 | vc->value = ov5640_data.contrast; | 1519 | vc->value = ov5640_data.contrast; |
| 1520 | break; | 1520 | break; |
| 1521 | case V4L2_CID_SATURATION: | 1521 | case V4L2_CID_SATURATION: |
| 1522 | vc->value = ov5640_data.saturation; | 1522 | vc->value = ov5640_data.saturation; |
| 1523 | break; | 1523 | break; |
| 1524 | case V4L2_CID_RED_BALANCE: | 1524 | case V4L2_CID_RED_BALANCE: |
| 1525 | vc->value = ov5640_data.red; | 1525 | vc->value = ov5640_data.red; |
| 1526 | break; | 1526 | break; |
| 1527 | case V4L2_CID_BLUE_BALANCE: | 1527 | case V4L2_CID_BLUE_BALANCE: |
| 1528 | vc->value = ov5640_data.blue; | 1528 | vc->value = ov5640_data.blue; |
| 1529 | break; | 1529 | break; |
| 1530 | case V4L2_CID_EXPOSURE: | 1530 | case V4L2_CID_EXPOSURE: |
| 1531 | vc->value = ov5640_data.ae_mode; | 1531 | vc->value = ov5640_data.ae_mode; |
| 1532 | break; | 1532 | break; |
| 1533 | default: | 1533 | default: |
| 1534 | ret = -EINVAL; | 1534 | ret = -EINVAL; |
| 1535 | } | 1535 | } |
| 1536 | 1536 | ||
| 1537 | return ret; | 1537 | return ret; |
| 1538 | } | 1538 | } |
| 1539 | 1539 | ||
| 1540 | /*! | 1540 | /*! |
| 1541 | * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl | 1541 | * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl |
| 1542 | * @s: pointer to standard V4L2 device structure | 1542 | * @s: pointer to standard V4L2 device structure |
| 1543 | * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure | 1543 | * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure |
| 1544 | * | 1544 | * |
| 1545 | * If the requested control is supported, sets the control's current | 1545 | * If the requested control is supported, sets the control's current |
| 1546 | * value in HW (and updates the video_control[] array). Otherwise, | 1546 | * value in HW (and updates the video_control[] array). Otherwise, |
| 1547 | * returns -EINVAL if the control is not supported. | 1547 | * returns -EINVAL if the control is not supported. |
| 1548 | */ | 1548 | */ |
| 1549 | static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) | 1549 | static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc) |
| 1550 | { | 1550 | { |
| 1551 | int retval = 0; | 1551 | int retval = 0; |
| 1552 | 1552 | ||
| 1553 | pr_debug("In ov5640:ioctl_s_ctrl %d\n", | 1553 | pr_debug("In ov5640:ioctl_s_ctrl %d\n", |
| 1554 | vc->id); | 1554 | vc->id); |
| 1555 | 1555 | ||
| 1556 | switch (vc->id) { | 1556 | switch (vc->id) { |
| 1557 | case V4L2_CID_BRIGHTNESS: | 1557 | case V4L2_CID_BRIGHTNESS: |
| 1558 | break; | 1558 | break; |
| 1559 | case V4L2_CID_CONTRAST: | 1559 | case V4L2_CID_CONTRAST: |
| 1560 | break; | 1560 | break; |
| 1561 | case V4L2_CID_SATURATION: | 1561 | case V4L2_CID_SATURATION: |
| 1562 | break; | 1562 | break; |
| 1563 | case V4L2_CID_HUE: | 1563 | case V4L2_CID_HUE: |
| 1564 | break; | 1564 | break; |
| 1565 | case V4L2_CID_AUTO_WHITE_BALANCE: | 1565 | case V4L2_CID_AUTO_WHITE_BALANCE: |
| 1566 | break; | 1566 | break; |
| 1567 | case V4L2_CID_DO_WHITE_BALANCE: | 1567 | case V4L2_CID_DO_WHITE_BALANCE: |
| 1568 | break; | 1568 | break; |
| 1569 | case V4L2_CID_RED_BALANCE: | 1569 | case V4L2_CID_RED_BALANCE: |
| 1570 | break; | 1570 | break; |
| 1571 | case V4L2_CID_BLUE_BALANCE: | 1571 | case V4L2_CID_BLUE_BALANCE: |
| 1572 | break; | 1572 | break; |
| 1573 | case V4L2_CID_GAMMA: | 1573 | case V4L2_CID_GAMMA: |
| 1574 | break; | 1574 | break; |
| 1575 | case V4L2_CID_EXPOSURE: | 1575 | case V4L2_CID_EXPOSURE: |
| 1576 | break; | 1576 | break; |
| 1577 | case V4L2_CID_AUTOGAIN: | 1577 | case V4L2_CID_AUTOGAIN: |
| 1578 | break; | 1578 | break; |
| 1579 | case V4L2_CID_GAIN: | 1579 | case V4L2_CID_GAIN: |
| 1580 | break; | 1580 | break; |
| 1581 | case V4L2_CID_HFLIP: | 1581 | case V4L2_CID_HFLIP: |
| 1582 | break; | 1582 | break; |
| 1583 | case V4L2_CID_VFLIP: | 1583 | case V4L2_CID_VFLIP: |
| 1584 | break; | 1584 | break; |
| 1585 | default: | 1585 | default: |
| 1586 | retval = -EPERM; | 1586 | retval = -EPERM; |
| 1587 | break; | 1587 | break; |
| 1588 | } | 1588 | } |
| 1589 | 1589 | ||
| 1590 | return retval; | 1590 | return retval; |
| 1591 | } | 1591 | } |
| 1592 | 1592 | ||
| 1593 | /*! | 1593 | /*! |
| 1594 | * ioctl_enum_framesizes - V4L2 sensor interface handler for | 1594 | * ioctl_enum_framesizes - V4L2 sensor interface handler for |
| 1595 | * VIDIOC_ENUM_FRAMESIZES ioctl | 1595 | * VIDIOC_ENUM_FRAMESIZES ioctl |
| 1596 | * @s: pointer to standard V4L2 device structure | 1596 | * @s: pointer to standard V4L2 device structure |
| 1597 | * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure | 1597 | * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure |
| 1598 | * | 1598 | * |
| 1599 | * Return 0 if successful, otherwise -EINVAL. | 1599 | * Return 0 if successful, otherwise -EINVAL. |
| 1600 | */ | 1600 | */ |
| 1601 | static int ioctl_enum_framesizes(struct v4l2_int_device *s, | 1601 | static int ioctl_enum_framesizes(struct v4l2_int_device *s, |
| 1602 | struct v4l2_frmsizeenum *fsize) | 1602 | struct v4l2_frmsizeenum *fsize) |
| 1603 | { | 1603 | { |
| 1604 | if (fsize->index > ov5640_mode_MAX) | 1604 | if (fsize->index > ov5640_mode_MAX) |
| 1605 | return -EINVAL; | 1605 | return -EINVAL; |
| 1606 | 1606 | ||
| 1607 | fsize->pixel_format = ov5640_data.pix.pixelformat; | 1607 | fsize->pixel_format = ov5640_data.pix.pixelformat; |
| 1608 | fsize->discrete.width = | 1608 | fsize->discrete.width = |
| 1609 | max(ov5640_mode_info_data[0][fsize->index].width, | 1609 | max(ov5640_mode_info_data[0][fsize->index].width, |
| 1610 | ov5640_mode_info_data[1][fsize->index].width); | 1610 | ov5640_mode_info_data[1][fsize->index].width); |
| 1611 | fsize->discrete.height = | 1611 | fsize->discrete.height = |
| 1612 | max(ov5640_mode_info_data[0][fsize->index].height, | 1612 | max(ov5640_mode_info_data[0][fsize->index].height, |
| 1613 | ov5640_mode_info_data[1][fsize->index].height); | 1613 | ov5640_mode_info_data[1][fsize->index].height); |
| 1614 | return 0; | 1614 | return 0; |
| 1615 | } | 1615 | } |
| 1616 | 1616 | ||
| 1617 | /*! | 1617 | /*! |
| 1618 | * ioctl_enum_frameintervals - V4L2 sensor interface handler for | 1618 | * ioctl_enum_frameintervals - V4L2 sensor interface handler for |
| 1619 | * VIDIOC_ENUM_FRAMEINTERVALS ioctl | 1619 | * VIDIOC_ENUM_FRAMEINTERVALS ioctl |
| 1620 | * @s: pointer to standard V4L2 device structure | 1620 | * @s: pointer to standard V4L2 device structure |
| 1621 | * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure | 1621 | * @fival: standard V4L2 VIDIOC_ENUM_FRAMEINTERVALS ioctl structure |
| 1622 | * | 1622 | * |
| 1623 | * Return 0 if successful, otherwise -EINVAL. | 1623 | * Return 0 if successful, otherwise -EINVAL. |
| 1624 | */ | 1624 | */ |
| 1625 | static int ioctl_enum_frameintervals(struct v4l2_int_device *s, | 1625 | static int ioctl_enum_frameintervals(struct v4l2_int_device *s, |
| 1626 | struct v4l2_frmivalenum *fival) | 1626 | struct v4l2_frmivalenum *fival) |
| 1627 | { | 1627 | { |
| 1628 | int i, j, count; | 1628 | int i, j, count; |
| 1629 | 1629 | ||
| 1630 | if (fival->index < 0 || fival->index > ov5640_mode_MAX) | 1630 | if (fival->index < 0 || fival->index > ov5640_mode_MAX) |
| 1631 | return -EINVAL; | 1631 | return -EINVAL; |
| 1632 | 1632 | ||
| 1633 | if (fival->width == 0 || fival->height == 0 || | 1633 | if (fival->width == 0 || fival->height == 0 || |
| 1634 | fival->pixel_format == 0) { | 1634 | fival->pixel_format == 0) { |
| 1635 | pr_warning("Please assign pixelformat, width and height.\n"); | 1635 | pr_warning("Please assign pixelformat, width and height.\n"); |
| 1636 | return -EINVAL; | 1636 | return -EINVAL; |
| 1637 | } | 1637 | } |
| 1638 | 1638 | ||
| 1639 | fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; | 1639 | fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; |
| 1640 | fival->discrete.numerator = 1; | 1640 | fival->discrete.numerator = 1; |
| 1641 | 1641 | ||
| 1642 | count = 0; | 1642 | count = 0; |
| 1643 | for (i = 0; i < ARRAY_SIZE(ov5640_mode_info_data); i++) { | 1643 | for (i = 0; i < ARRAY_SIZE(ov5640_mode_info_data); i++) { |
| 1644 | for (j = 0; j < (ov5640_mode_MAX + 1); j++) { | 1644 | for (j = 0; j < (ov5640_mode_MAX + 1); j++) { |
| 1645 | if (fival->pixel_format == ov5640_data.pix.pixelformat | 1645 | if (fival->pixel_format == ov5640_data.pix.pixelformat |
| 1646 | && fival->width == ov5640_mode_info_data[i][j].width | 1646 | && fival->width == ov5640_mode_info_data[i][j].width |
| 1647 | && fival->height == ov5640_mode_info_data[i][j].height | 1647 | && fival->height == ov5640_mode_info_data[i][j].height |
| 1648 | && ov5640_mode_info_data[i][j].init_data_ptr != NULL) { | 1648 | && ov5640_mode_info_data[i][j].init_data_ptr != NULL) { |
| 1649 | count++; | 1649 | count++; |
| 1650 | } | 1650 | } |
| 1651 | if (fival->index == (count - 1)) { | 1651 | if (fival->index == (count - 1)) { |
| 1652 | fival->discrete.denominator = | 1652 | fival->discrete.denominator = |
| 1653 | ov5640_framerates[i]; | 1653 | ov5640_framerates[i]; |
| 1654 | return 0; | 1654 | return 0; |
| 1655 | } | 1655 | } |
| 1656 | } | 1656 | } |
| 1657 | } | 1657 | } |
| 1658 | 1658 | ||
| 1659 | return -EINVAL; | 1659 | return -EINVAL; |
| 1660 | } | 1660 | } |
| 1661 | 1661 | ||
| 1662 | /*! | 1662 | /*! |
| 1663 | * ioctl_g_chip_ident - V4L2 sensor interface handler for | 1663 | * ioctl_g_chip_ident - V4L2 sensor interface handler for |
| 1664 | * VIDIOC_DBG_G_CHIP_IDENT ioctl | 1664 | * VIDIOC_DBG_G_CHIP_IDENT ioctl |
| 1665 | * @s: pointer to standard V4L2 device structure | 1665 | * @s: pointer to standard V4L2 device structure |
| 1666 | * @id: pointer to int | 1666 | * @id: pointer to int |
| 1667 | * | 1667 | * |
| 1668 | * Return 0. | 1668 | * Return 0. |
| 1669 | */ | 1669 | */ |
| 1670 | static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) | 1670 | static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id) |
| 1671 | { | 1671 | { |
| 1672 | ((struct v4l2_dbg_chip_ident *)id)->match.type = | 1672 | ((struct v4l2_dbg_chip_ident *)id)->match.type = |
| 1673 | V4L2_CHIP_MATCH_I2C_DRIVER; | 1673 | V4L2_CHIP_MATCH_I2C_DRIVER; |
| 1674 | strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, "ov5640_camera"); | 1674 | strcpy(((struct v4l2_dbg_chip_ident *)id)->match.name, "ov5640_camera"); |
| 1675 | 1675 | ||
| 1676 | return 0; | 1676 | return 0; |
| 1677 | } | 1677 | } |
| 1678 | 1678 | ||
| 1679 | /*! | 1679 | /*! |
| 1680 | * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT | 1680 | * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT |
| 1681 | * @s: pointer to standard V4L2 device structure | 1681 | * @s: pointer to standard V4L2 device structure |
| 1682 | */ | 1682 | */ |
| 1683 | static int ioctl_init(struct v4l2_int_device *s) | 1683 | static int ioctl_init(struct v4l2_int_device *s) |
| 1684 | { | 1684 | { |
| 1685 | 1685 | ||
| 1686 | return 0; | 1686 | return 0; |
| 1687 | } | 1687 | } |
| 1688 | 1688 | ||
| 1689 | /*! | 1689 | /*! |
| 1690 | * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT | 1690 | * ioctl_enum_fmt_cap - V4L2 sensor interface handler for VIDIOC_ENUM_FMT |
| 1691 | * @s: pointer to standard V4L2 device structure | 1691 | * @s: pointer to standard V4L2 device structure |
| 1692 | * @fmt: pointer to standard V4L2 fmt description structure | 1692 | * @fmt: pointer to standard V4L2 fmt description structure |
| 1693 | * | 1693 | * |
| 1694 | * Return 0. | 1694 | * Return 0. |
| 1695 | */ | 1695 | */ |
| 1696 | static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, | 1696 | static int ioctl_enum_fmt_cap(struct v4l2_int_device *s, |
| 1697 | struct v4l2_fmtdesc *fmt) | 1697 | struct v4l2_fmtdesc *fmt) |
| 1698 | { | 1698 | { |
| 1699 | if (fmt->index > ov5640_mode_MAX) | 1699 | if (fmt->index > ov5640_mode_MAX) |
| 1700 | return -EINVAL; | 1700 | return -EINVAL; |
| 1701 | 1701 | ||
| 1702 | fmt->pixelformat = ov5640_data.pix.pixelformat; | 1702 | fmt->pixelformat = ov5640_data.pix.pixelformat; |
| 1703 | 1703 | ||
| 1704 | return 0; | 1704 | return 0; |
| 1705 | } | 1705 | } |
| 1706 | 1706 | ||
| 1707 | /*! | 1707 | /*! |
| 1708 | * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num | 1708 | * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num |
| 1709 | * @s: pointer to standard V4L2 device structure | 1709 | * @s: pointer to standard V4L2 device structure |
| 1710 | * | 1710 | * |
| 1711 | * Initialise the device when slave attaches to the master. | 1711 | * Initialise the device when slave attaches to the master. |
| 1712 | */ | 1712 | */ |
| 1713 | static int ioctl_dev_init(struct v4l2_int_device *s) | 1713 | static int ioctl_dev_init(struct v4l2_int_device *s) |
| 1714 | { | 1714 | { |
| 1715 | struct sensor_data *sensor = s->priv; | 1715 | struct sensor_data *sensor = s->priv; |
| 1716 | u32 tgt_xclk; /* target xclk */ | 1716 | u32 tgt_xclk; /* target xclk */ |
| 1717 | u32 tgt_fps; /* target frames per secound */ | 1717 | u32 tgt_fps; /* target frames per secound */ |
| 1718 | enum ov5640_frame_rate frame_rate; | 1718 | enum ov5640_frame_rate frame_rate; |
| 1719 | int ret; | 1719 | int ret; |
| 1720 | 1720 | ||
| 1721 | ov5640_data.on = true; | 1721 | ov5640_data.on = true; |
| 1722 | 1722 | ||
| 1723 | /* mclk */ | 1723 | /* mclk */ |
| 1724 | tgt_xclk = ov5640_data.mclk; | 1724 | tgt_xclk = ov5640_data.mclk; |
| 1725 | tgt_xclk = min(tgt_xclk, (u32)OV5640_XCLK_MAX); | 1725 | tgt_xclk = min(tgt_xclk, (u32)OV5640_XCLK_MAX); |
| 1726 | tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); | 1726 | tgt_xclk = max(tgt_xclk, (u32)OV5640_XCLK_MIN); |
| 1727 | ov5640_data.mclk = tgt_xclk; | 1727 | ov5640_data.mclk = tgt_xclk; |
| 1728 | 1728 | ||
| 1729 | pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); | 1729 | pr_debug(" Setting mclk to %d MHz\n", tgt_xclk / 1000000); |
| 1730 | clk_set_rate(ov5640_data.sensor_clk, ov5640_data.mclk); | 1730 | clk_set_rate(ov5640_data.sensor_clk, ov5640_data.mclk); |
| 1731 | 1731 | ||
| 1732 | /* Default camera frame rate is set in probe */ | 1732 | /* Default camera frame rate is set in probe */ |
| 1733 | tgt_fps = sensor->streamcap.timeperframe.denominator / | 1733 | tgt_fps = sensor->streamcap.timeperframe.denominator / |
| 1734 | sensor->streamcap.timeperframe.numerator; | 1734 | sensor->streamcap.timeperframe.numerator; |
| 1735 | 1735 | ||
| 1736 | if (tgt_fps == 15) | 1736 | if (tgt_fps == 15) |
| 1737 | frame_rate = ov5640_15_fps; | 1737 | frame_rate = ov5640_15_fps; |
| 1738 | else if (tgt_fps == 30) | 1738 | else if (tgt_fps == 30) |
| 1739 | frame_rate = ov5640_30_fps; | 1739 | frame_rate = ov5640_30_fps; |
| 1740 | else | 1740 | else |
| 1741 | return -EINVAL; /* Only support 15fps or 30fps now. */ | 1741 | return -EINVAL; /* Only support 15fps or 30fps now. */ |
| 1742 | 1742 | ||
| 1743 | ret = ov5640_init_mode(); | 1743 | ret = ov5640_init_mode(); |
| 1744 | return ret; | 1744 | return ret; |
| 1745 | } | 1745 | } |
| 1746 | 1746 | ||
| 1747 | /*! | 1747 | /*! |
| 1748 | * ioctl_dev_exit - V4L2 sensor interface handler for vidioc_int_dev_exit_num | 1748 | * ioctl_dev_exit - V4L2 sensor interface handler for vidioc_int_dev_exit_num |
| 1749 | * @s: pointer to standard V4L2 device structure | 1749 | * @s: pointer to standard V4L2 device structure |
| 1750 | * | 1750 | * |
| 1751 | * Delinitialise the device when slave detaches to the master. | 1751 | * Delinitialise the device when slave detaches to the master. |
| 1752 | */ | 1752 | */ |
| 1753 | static int ioctl_dev_exit(struct v4l2_int_device *s) | 1753 | static int ioctl_dev_exit(struct v4l2_int_device *s) |
| 1754 | { | 1754 | { |
| 1755 | return 0; | 1755 | return 0; |
| 1756 | } | 1756 | } |
| 1757 | 1757 | ||
| 1758 | /*! | 1758 | /*! |
| 1759 | * This structure defines all the ioctls for this module and links them to the | 1759 | * This structure defines all the ioctls for this module and links them to the |
| 1760 | * enumeration. | 1760 | * enumeration. |
| 1761 | */ | 1761 | */ |
| 1762 | static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = { | 1762 | static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = { |
| 1763 | { vidioc_int_dev_init_num, | 1763 | { vidioc_int_dev_init_num, |
| 1764 | (v4l2_int_ioctl_func *)ioctl_dev_init }, | 1764 | (v4l2_int_ioctl_func *)ioctl_dev_init }, |
| 1765 | { vidioc_int_dev_exit_num, | 1765 | { vidioc_int_dev_exit_num, |
| 1766 | ioctl_dev_exit}, | 1766 | ioctl_dev_exit}, |
| 1767 | { vidioc_int_s_power_num, | 1767 | { vidioc_int_s_power_num, |
| 1768 | (v4l2_int_ioctl_func *)ioctl_s_power }, | 1768 | (v4l2_int_ioctl_func *)ioctl_s_power }, |
| 1769 | { vidioc_int_g_ifparm_num, | 1769 | { vidioc_int_g_ifparm_num, |
| 1770 | (v4l2_int_ioctl_func *)ioctl_g_ifparm }, | 1770 | (v4l2_int_ioctl_func *)ioctl_g_ifparm }, |
| 1771 | { vidioc_int_init_num, | 1771 | { vidioc_int_init_num, |
| 1772 | (v4l2_int_ioctl_func *)ioctl_init }, | 1772 | (v4l2_int_ioctl_func *)ioctl_init }, |
| 1773 | { vidioc_int_enum_fmt_cap_num, | 1773 | { vidioc_int_enum_fmt_cap_num, |
| 1774 | (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap }, | 1774 | (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap }, |
| 1775 | { vidioc_int_g_fmt_cap_num, | 1775 | { vidioc_int_g_fmt_cap_num, |
| 1776 | (v4l2_int_ioctl_func *)ioctl_g_fmt_cap }, | 1776 | (v4l2_int_ioctl_func *)ioctl_g_fmt_cap }, |
| 1777 | { vidioc_int_g_parm_num, | 1777 | { vidioc_int_g_parm_num, |
| 1778 | (v4l2_int_ioctl_func *)ioctl_g_parm }, | 1778 | (v4l2_int_ioctl_func *)ioctl_g_parm }, |
| 1779 | { vidioc_int_s_parm_num, | 1779 | { vidioc_int_s_parm_num, |
| 1780 | (v4l2_int_ioctl_func *)ioctl_s_parm }, | 1780 | (v4l2_int_ioctl_func *)ioctl_s_parm }, |
| 1781 | { vidioc_int_g_ctrl_num, | 1781 | { vidioc_int_g_ctrl_num, |
| 1782 | (v4l2_int_ioctl_func *)ioctl_g_ctrl }, | 1782 | (v4l2_int_ioctl_func *)ioctl_g_ctrl }, |
| 1783 | { vidioc_int_s_ctrl_num, | 1783 | { vidioc_int_s_ctrl_num, |
| 1784 | (v4l2_int_ioctl_func *)ioctl_s_ctrl }, | 1784 | (v4l2_int_ioctl_func *)ioctl_s_ctrl }, |
| 1785 | { vidioc_int_enum_framesizes_num, | 1785 | { vidioc_int_enum_framesizes_num, |
| 1786 | (v4l2_int_ioctl_func *)ioctl_enum_framesizes }, | 1786 | (v4l2_int_ioctl_func *)ioctl_enum_framesizes }, |
| 1787 | { vidioc_int_enum_frameintervals_num, | 1787 | { vidioc_int_enum_frameintervals_num, |
| 1788 | (v4l2_int_ioctl_func *)ioctl_enum_frameintervals }, | 1788 | (v4l2_int_ioctl_func *)ioctl_enum_frameintervals }, |
| 1789 | { vidioc_int_g_chip_ident_num, | 1789 | { vidioc_int_g_chip_ident_num, |
| 1790 | (v4l2_int_ioctl_func *)ioctl_g_chip_ident }, | 1790 | (v4l2_int_ioctl_func *)ioctl_g_chip_ident }, |
| 1791 | }; | 1791 | }; |
| 1792 | 1792 | ||
| 1793 | static struct v4l2_int_slave ov5640_slave = { | 1793 | static struct v4l2_int_slave ov5640_slave = { |
| 1794 | .ioctls = ov5640_ioctl_desc, | 1794 | .ioctls = ov5640_ioctl_desc, |
| 1795 | .num_ioctls = ARRAY_SIZE(ov5640_ioctl_desc), | 1795 | .num_ioctls = ARRAY_SIZE(ov5640_ioctl_desc), |
| 1796 | }; | 1796 | }; |
| 1797 | 1797 | ||
| 1798 | static struct v4l2_int_device ov5640_int_device = { | 1798 | static struct v4l2_int_device ov5640_int_device = { |
| 1799 | .module = THIS_MODULE, | 1799 | .module = THIS_MODULE, |
| 1800 | .name = "ov5640", | 1800 | .name = "ov564x", |
| 1801 | .type = v4l2_int_type_slave, | 1801 | .type = v4l2_int_type_slave, |
| 1802 | .u = { | 1802 | .u = { |
| 1803 | .slave = &ov5640_slave, | 1803 | .slave = &ov5640_slave, |
| 1804 | }, | 1804 | }, |
| 1805 | }; | 1805 | }; |
| 1806 | 1806 | ||
| 1807 | /*! | 1807 | /*! |
| 1808 | * ov5640 I2C probe function | 1808 | * ov5640 I2C probe function |
| 1809 | * | 1809 | * |
| 1810 | * @param adapter struct i2c_adapter * | 1810 | * @param adapter struct i2c_adapter * |
| 1811 | * @return Error code indicating success or failure | 1811 | * @return Error code indicating success or failure |
| 1812 | */ | 1812 | */ |
| 1813 | static int ov5640_probe(struct i2c_client *client, | 1813 | static int ov5640_probe(struct i2c_client *client, |
| 1814 | const struct i2c_device_id *id) | 1814 | const struct i2c_device_id *id) |
| 1815 | { | 1815 | { |
| 1816 | struct pinctrl *pinctrl; | 1816 | struct pinctrl *pinctrl; |
| 1817 | struct device *dev = &client->dev; | 1817 | struct device *dev = &client->dev; |
| 1818 | int retval; | 1818 | int retval; |
| 1819 | u8 chip_id_high, chip_id_low; | 1819 | u8 chip_id_high, chip_id_low; |
| 1820 | 1820 | ||
| 1821 | /* ov5640 pinctrl */ | 1821 | /* ov5640 pinctrl */ |
| 1822 | pinctrl = devm_pinctrl_get_select_default(dev); | 1822 | pinctrl = devm_pinctrl_get_select_default(dev); |
| 1823 | if (IS_ERR(pinctrl)) { | 1823 | if (IS_ERR(pinctrl)) { |
| 1824 | dev_err(dev, "setup pinctrl failed\n"); | 1824 | dev_err(dev, "setup pinctrl failed\n"); |
| 1825 | return PTR_ERR(pinctrl); | 1825 | return PTR_ERR(pinctrl); |
| 1826 | } | 1826 | } |
| 1827 | 1827 | ||
| 1828 | /* request power down pin */ | 1828 | /* request power down pin */ |
| 1829 | pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); | 1829 | pwn_gpio = of_get_named_gpio(dev->of_node, "pwn-gpios", 0); |
| 1830 | if (!gpio_is_valid(pwn_gpio)) { | 1830 | if (!gpio_is_valid(pwn_gpio)) { |
| 1831 | dev_err(dev, "no sensor pwdn pin available\n"); | 1831 | dev_err(dev, "no sensor pwdn pin available\n"); |
| 1832 | return -ENODEV; | 1832 | return -ENODEV; |
| 1833 | } | 1833 | } |
| 1834 | retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, | 1834 | retval = devm_gpio_request_one(dev, pwn_gpio, GPIOF_OUT_INIT_HIGH, |
| 1835 | "ov5640_pwdn"); | 1835 | "ov5640_pwdn"); |
| 1836 | if (retval < 0) | 1836 | if (retval < 0) |
| 1837 | return retval; | 1837 | return retval; |
| 1838 | 1838 | ||
| 1839 | /* request reset pin */ | 1839 | /* request reset pin */ |
| 1840 | rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); | 1840 | rst_gpio = of_get_named_gpio(dev->of_node, "rst-gpios", 0); |
| 1841 | if (!gpio_is_valid(rst_gpio)) { | 1841 | if (!gpio_is_valid(rst_gpio)) { |
| 1842 | dev_err(dev, "no sensor reset pin available\n"); | 1842 | dev_err(dev, "no sensor reset pin available\n"); |
| 1843 | return -EINVAL; | 1843 | return -EINVAL; |
| 1844 | } | 1844 | } |
| 1845 | retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, | 1845 | retval = devm_gpio_request_one(dev, rst_gpio, GPIOF_OUT_INIT_HIGH, |
| 1846 | "ov5640_reset"); | 1846 | "ov5640_reset"); |
| 1847 | if (retval < 0) | 1847 | if (retval < 0) |
| 1848 | return retval; | 1848 | return retval; |
| 1849 | 1849 | ||
| 1850 | /* Set initial values for the sensor struct. */ | 1850 | /* Set initial values for the sensor struct. */ |
| 1851 | memset(&ov5640_data, 0, sizeof(ov5640_data)); | 1851 | memset(&ov5640_data, 0, sizeof(ov5640_data)); |
| 1852 | ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); | 1852 | ov5640_data.sensor_clk = devm_clk_get(dev, "csi_mclk"); |
| 1853 | if (IS_ERR(ov5640_data.sensor_clk)) { | 1853 | if (IS_ERR(ov5640_data.sensor_clk)) { |
| 1854 | dev_err(dev, "get mclk failed\n"); | 1854 | dev_err(dev, "get mclk failed\n"); |
| 1855 | return PTR_ERR(ov5640_data.sensor_clk); | 1855 | return PTR_ERR(ov5640_data.sensor_clk); |
| 1856 | } | 1856 | } |
| 1857 | 1857 | ||
| 1858 | retval = of_property_read_u32(dev->of_node, "mclk", | 1858 | retval = of_property_read_u32(dev->of_node, "mclk", |
| 1859 | &ov5640_data.mclk); | 1859 | &ov5640_data.mclk); |
| 1860 | if (retval) { | 1860 | if (retval) { |
| 1861 | dev_err(dev, "mclk frequency is invalid\n"); | 1861 | dev_err(dev, "mclk frequency is invalid\n"); |
| 1862 | return retval; | 1862 | return retval; |
| 1863 | } | 1863 | } |
| 1864 | 1864 | ||
| 1865 | retval = of_property_read_u32(dev->of_node, "mclk_source", | 1865 | retval = of_property_read_u32(dev->of_node, "mclk_source", |
| 1866 | (u32 *) &(ov5640_data.mclk_source)); | 1866 | (u32 *) &(ov5640_data.mclk_source)); |
| 1867 | if (retval) { | 1867 | if (retval) { |
| 1868 | dev_err(dev, "mclk_source invalid\n"); | 1868 | dev_err(dev, "mclk_source invalid\n"); |
| 1869 | return retval; | 1869 | return retval; |
| 1870 | } | 1870 | } |
| 1871 | 1871 | ||
| 1872 | retval = of_property_read_u32(dev->of_node, "csi_id", | 1872 | retval = of_property_read_u32(dev->of_node, "csi_id", |
| 1873 | &(ov5640_data.csi)); | 1873 | &(ov5640_data.csi)); |
| 1874 | if (retval) { | 1874 | if (retval) { |
| 1875 | dev_err(dev, "csi_id invalid\n"); | 1875 | dev_err(dev, "csi_id invalid\n"); |
| 1876 | return retval; | 1876 | return retval; |
| 1877 | } | 1877 | } |
| 1878 | 1878 | ||
| 1879 | clk_prepare_enable(ov5640_data.sensor_clk); | 1879 | clk_prepare_enable(ov5640_data.sensor_clk); |
| 1880 | 1880 | ||
| 1881 | ov5640_data.io_init = ov5640_reset; | 1881 | ov5640_data.io_init = ov5640_reset; |
| 1882 | ov5640_data.i2c_client = client; | 1882 | ov5640_data.i2c_client = client; |
| 1883 | ov5640_data.pix.pixelformat = V4L2_PIX_FMT_YUYV; | 1883 | ov5640_data.pix.pixelformat = V4L2_PIX_FMT_YUYV; |
| 1884 | ov5640_data.pix.width = 640; | 1884 | ov5640_data.pix.width = 640; |
| 1885 | ov5640_data.pix.height = 480; | 1885 | ov5640_data.pix.height = 480; |
| 1886 | ov5640_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | | 1886 | ov5640_data.streamcap.capability = V4L2_MODE_HIGHQUALITY | |
| 1887 | V4L2_CAP_TIMEPERFRAME; | 1887 | V4L2_CAP_TIMEPERFRAME; |
| 1888 | ov5640_data.streamcap.capturemode = 0; | 1888 | ov5640_data.streamcap.capturemode = 0; |
| 1889 | ov5640_data.streamcap.timeperframe.denominator = DEFAULT_FPS; | 1889 | ov5640_data.streamcap.timeperframe.denominator = DEFAULT_FPS; |
| 1890 | ov5640_data.streamcap.timeperframe.numerator = 1; | 1890 | ov5640_data.streamcap.timeperframe.numerator = 1; |
| 1891 | 1891 | ||
| 1892 | ov5640_regulator_enable(&client->dev); | 1892 | ov5640_regulator_enable(&client->dev); |
| 1893 | 1893 | ||
| 1894 | ov5640_reset(); | 1894 | ov5640_reset(); |
| 1895 | 1895 | ||
| 1896 | ov5640_power_down(0); | 1896 | ov5640_power_down(0); |
| 1897 | 1897 | ||
| 1898 | retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); | 1898 | retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high); |
| 1899 | if (retval < 0 || chip_id_high != 0x56) { | 1899 | if (retval < 0 || chip_id_high != 0x56) { |
| 1900 | clk_disable_unprepare(ov5640_data.sensor_clk); | 1900 | clk_disable_unprepare(ov5640_data.sensor_clk); |
| 1901 | pr_warning("camera ov5640 is not found\n"); | 1901 | pr_warning("camera ov5640 is not found\n"); |
| 1902 | return -ENODEV; | 1902 | return -ENODEV; |
| 1903 | } | 1903 | } |
| 1904 | retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); | 1904 | retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); |
| 1905 | if (retval < 0 || chip_id_low != 0x40) { | 1905 | if (retval < 0 || chip_id_low != 0x40) { |
| 1906 | clk_disable_unprepare(ov5640_data.sensor_clk); | 1906 | clk_disable_unprepare(ov5640_data.sensor_clk); |
| 1907 | pr_warning("camera ov5640 is not found\n"); | 1907 | pr_warning("camera ov5640 is not found\n"); |
| 1908 | return -ENODEV; | 1908 | return -ENODEV; |
| 1909 | } | 1909 | } |
| 1910 | 1910 | ||
| 1911 | ov5640_power_down(1); | 1911 | ov5640_power_down(1); |
| 1912 | 1912 | ||
| 1913 | clk_disable_unprepare(ov5640_data.sensor_clk); | 1913 | clk_disable_unprepare(ov5640_data.sensor_clk); |
| 1914 | 1914 | ||
| 1915 | ov5640_int_device.priv = &ov5640_data; | 1915 | ov5640_int_device.priv = &ov5640_data; |
| 1916 | retval = v4l2_int_device_register(&ov5640_int_device); | 1916 | retval = v4l2_int_device_register(&ov5640_int_device); |
| 1917 | 1917 | ||
| 1918 | pr_info("camera ov5640 is found\n"); | 1918 | pr_info("camera ov5640 is found\n"); |
| 1919 | return retval; | 1919 | return retval; |
| 1920 | } | 1920 | } |
| 1921 | 1921 | ||
| 1922 | /*! | 1922 | /*! |
| 1923 | * ov5640 I2C detach function | 1923 | * ov5640 I2C detach function |
| 1924 | * | 1924 | * |
| 1925 | * @param client struct i2c_client * | 1925 | * @param client struct i2c_client * |
| 1926 | * @return Error code indicating success or failure | 1926 | * @return Error code indicating success or failure |
| 1927 | */ | 1927 | */ |
| 1928 | static int ov5640_remove(struct i2c_client *client) | 1928 | static int ov5640_remove(struct i2c_client *client) |
| 1929 | { | 1929 | { |
| 1930 | v4l2_int_device_unregister(&ov5640_int_device); | 1930 | v4l2_int_device_unregister(&ov5640_int_device); |
| 1931 | 1931 | ||
| 1932 | if (analog_regulator) | 1932 | if (analog_regulator) |
| 1933 | regulator_disable(analog_regulator); | 1933 | regulator_disable(analog_regulator); |
| 1934 | 1934 | ||
| 1935 | if (core_regulator) | 1935 | if (core_regulator) |
| 1936 | regulator_disable(core_regulator); | 1936 | regulator_disable(core_regulator); |
| 1937 | 1937 | ||
| 1938 | if (io_regulator) | 1938 | if (io_regulator) |
| 1939 | regulator_disable(io_regulator); | 1939 | regulator_disable(io_regulator); |
| 1940 | 1940 | ||
| 1941 | return 0; | 1941 | return 0; |
| 1942 | } | 1942 | } |
| 1943 | 1943 | ||
| 1944 | module_i2c_driver(ov5640_i2c_driver); | 1944 | module_i2c_driver(ov5640_i2c_driver); |
| 1945 | 1945 | ||
| 1946 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); | 1946 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); |
| 1947 | MODULE_DESCRIPTION("OV5640 Camera Driver"); | 1947 | MODULE_DESCRIPTION("OV5640 Camera Driver"); |
| 1948 | MODULE_LICENSE("GPL"); | 1948 | MODULE_LICENSE("GPL"); |
| 1949 | MODULE_VERSION("1.0"); | 1949 | MODULE_VERSION("1.0"); |
| 1950 | MODULE_ALIAS("CSI"); | 1950 | MODULE_ALIAS("CSI"); |
| 1951 | 1951 |