Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Sonix sn9c102p sn9c105 sn9c120 (jpeg) library |
| 3 | * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr |
| 4 | * |
| 5 | * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #define MODULE_NAME "sonixj" |
| 23 | |
| 24 | #include "gspca.h" |
| 25 | #include "jpeg.h" |
| 26 | |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 27 | #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) |
| 28 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 29 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
| 30 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
| 31 | MODULE_LICENSE("GPL"); |
| 32 | |
| 33 | /* specific webcam descriptor */ |
| 34 | struct sd { |
| 35 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
| 36 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 37 | atomic_t avg_lum; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 38 | u32 exposure; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 39 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 40 | u16 brightness; |
| 41 | u8 contrast; |
| 42 | u8 colors; |
| 43 | u8 autogain; |
| 44 | u8 blue; |
| 45 | u8 red; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 46 | u8 gamma; |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 47 | u8 vflip; /* ov7630/ov7648 only */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 48 | u8 infrared; /* mt9v111 only */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 49 | u8 freq; /* ov76xx only */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 50 | u8 quality; /* image quality */ |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 51 | #define QUALITY_MIN 60 |
| 52 | #define QUALITY_MAX 95 |
| 53 | #define QUALITY_DEF 80 |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 54 | u8 jpegqual; /* webcam quality */ |
| 55 | |
| 56 | u8 reg18; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 57 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 58 | s8 ag_cnt; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 59 | #define AG_CNT_START 13 |
| 60 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 61 | u8 bridge; |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 62 | #define BRIDGE_SN9C102P 0 |
| 63 | #define BRIDGE_SN9C105 1 |
| 64 | #define BRIDGE_SN9C110 2 |
| 65 | #define BRIDGE_SN9C120 3 |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 66 | u8 sensor; /* Type of image sensor chip */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 67 | #define SENSOR_HV7131R 0 |
| 68 | #define SENSOR_MI0360 1 |
| 69 | #define SENSOR_MO4000 2 |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 70 | #define SENSOR_MT9V111 3 |
| 71 | #define SENSOR_OM6802 4 |
| 72 | #define SENSOR_OV7630 5 |
| 73 | #define SENSOR_OV7648 6 |
| 74 | #define SENSOR_OV7660 7 |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 75 | #define SENSOR_SP80708 8 |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 76 | u8 i2c_base; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 77 | |
| 78 | u8 *jpeg_hdr; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /* V4L2 controls supported by the driver */ |
| 82 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); |
| 83 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); |
| 84 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); |
| 85 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); |
| 86 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); |
| 87 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 88 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); |
| 89 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); |
| 90 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); |
| 91 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 92 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); |
| 93 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 94 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
| 95 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 96 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); |
| 97 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 98 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); |
| 99 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 100 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); |
| 101 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 102 | |
| 103 | static struct ctrl sd_ctrls[] = { |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 104 | #define BRIGHTNESS_IDX 0 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 105 | { |
| 106 | { |
| 107 | .id = V4L2_CID_BRIGHTNESS, |
| 108 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 109 | .name = "Brightness", |
| 110 | .minimum = 0, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 111 | #define BRIGHTNESS_MAX 0xffff |
| 112 | .maximum = BRIGHTNESS_MAX, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 113 | .step = 1, |
Jean-Francois Moine | b1b056a | 2008-11-25 04:47:09 -0300 | [diff] [blame] | 114 | #define BRIGHTNESS_DEF 0x8000 |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 115 | .default_value = BRIGHTNESS_DEF, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 116 | }, |
| 117 | .set = sd_setbrightness, |
| 118 | .get = sd_getbrightness, |
| 119 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 120 | #define CONTRAST_IDX 1 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 121 | { |
| 122 | { |
| 123 | .id = V4L2_CID_CONTRAST, |
| 124 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 125 | .name = "Contrast", |
| 126 | .minimum = 0, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 127 | #define CONTRAST_MAX 127 |
| 128 | .maximum = CONTRAST_MAX, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 129 | .step = 1, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 130 | #define CONTRAST_DEF 63 |
| 131 | .default_value = CONTRAST_DEF, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 132 | }, |
| 133 | .set = sd_setcontrast, |
| 134 | .get = sd_getcontrast, |
| 135 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 136 | #define COLOR_IDX 2 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 137 | { |
| 138 | { |
| 139 | .id = V4L2_CID_SATURATION, |
| 140 | .type = V4L2_CTRL_TYPE_INTEGER, |
Hans de Goede | 3fb4a57 | 2009-06-18 14:31:36 -0300 | [diff] [blame] | 141 | .name = "Saturation", |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 142 | .minimum = 0, |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 143 | .maximum = 40, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 144 | .step = 1, |
Hans de Goede | 3fb4a57 | 2009-06-18 14:31:36 -0300 | [diff] [blame] | 145 | #define COLOR_DEF 25 |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 146 | .default_value = COLOR_DEF, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 147 | }, |
| 148 | .set = sd_setcolors, |
| 149 | .get = sd_getcolors, |
| 150 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 151 | #define BLUE_BALANCE_IDX 3 |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 152 | { |
| 153 | { |
| 154 | .id = V4L2_CID_BLUE_BALANCE, |
| 155 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 156 | .name = "Blue Balance", |
| 157 | .minimum = 24, |
| 158 | .maximum = 40, |
| 159 | .step = 1, |
| 160 | #define BLUE_BALANCE_DEF 32 |
| 161 | .default_value = BLUE_BALANCE_DEF, |
| 162 | }, |
| 163 | .set = sd_setblue_balance, |
| 164 | .get = sd_getblue_balance, |
| 165 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 166 | #define RED_BALANCE_IDX 4 |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 167 | { |
| 168 | { |
| 169 | .id = V4L2_CID_RED_BALANCE, |
| 170 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 171 | .name = "Red Balance", |
| 172 | .minimum = 24, |
| 173 | .maximum = 40, |
| 174 | .step = 1, |
| 175 | #define RED_BALANCE_DEF 32 |
| 176 | .default_value = RED_BALANCE_DEF, |
| 177 | }, |
| 178 | .set = sd_setred_balance, |
| 179 | .get = sd_getred_balance, |
| 180 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 181 | #define GAMMA_IDX 5 |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 182 | { |
| 183 | { |
| 184 | .id = V4L2_CID_GAMMA, |
| 185 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 186 | .name = "Gamma", |
| 187 | .minimum = 0, |
| 188 | .maximum = 40, |
| 189 | .step = 1, |
| 190 | #define GAMMA_DEF 20 |
| 191 | .default_value = GAMMA_DEF, |
| 192 | }, |
| 193 | .set = sd_setgamma, |
| 194 | .get = sd_getgamma, |
| 195 | }, |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 196 | #define AUTOGAIN_IDX 6 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 197 | { |
| 198 | { |
| 199 | .id = V4L2_CID_AUTOGAIN, |
| 200 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 201 | .name = "Auto Gain", |
| 202 | .minimum = 0, |
| 203 | .maximum = 1, |
| 204 | .step = 1, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 205 | #define AUTOGAIN_DEF 1 |
| 206 | .default_value = AUTOGAIN_DEF, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 207 | }, |
| 208 | .set = sd_setautogain, |
| 209 | .get = sd_getautogain, |
| 210 | }, |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 211 | /* ov7630/ov7648 only */ |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 212 | #define VFLIP_IDX 7 |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 213 | { |
| 214 | { |
| 215 | .id = V4L2_CID_VFLIP, |
| 216 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 217 | .name = "Vflip", |
| 218 | .minimum = 0, |
| 219 | .maximum = 1, |
| 220 | .step = 1, |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 221 | #define VFLIP_DEF 0 |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 222 | .default_value = VFLIP_DEF, |
| 223 | }, |
| 224 | .set = sd_setvflip, |
| 225 | .get = sd_getvflip, |
| 226 | }, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 227 | /* mt9v111 only */ |
Hans de Goede | 9764398 | 2009-06-18 05:08:11 -0300 | [diff] [blame] | 228 | #define INFRARED_IDX 8 |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 229 | { |
| 230 | { |
| 231 | .id = V4L2_CID_INFRARED, |
| 232 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 233 | .name = "Infrared", |
| 234 | .minimum = 0, |
| 235 | .maximum = 1, |
| 236 | .step = 1, |
| 237 | #define INFRARED_DEF 0 |
| 238 | .default_value = INFRARED_DEF, |
| 239 | }, |
| 240 | .set = sd_setinfrared, |
| 241 | .get = sd_getinfrared, |
| 242 | }, |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 243 | /* ov7630/ov7648/ov7660 only */ |
| 244 | #define FREQ_IDX 9 |
| 245 | { |
| 246 | { |
| 247 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
| 248 | .type = V4L2_CTRL_TYPE_MENU, |
| 249 | .name = "Light frequency filter", |
| 250 | .minimum = 0, |
| 251 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ |
| 252 | .step = 1, |
| 253 | #define FREQ_DEF 2 |
| 254 | .default_value = FREQ_DEF, |
| 255 | }, |
| 256 | .set = sd_setfreq, |
| 257 | .get = sd_getfreq, |
| 258 | }, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 259 | }; |
| 260 | |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 261 | /* table of the disabled controls */ |
| 262 | static __u32 ctrl_dis[] = { |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 263 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 264 | /* SENSOR_HV7131R 0 */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 265 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 266 | /* SENSOR_MI0360 1 */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 267 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 268 | /* SENSOR_MO4000 2 */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 269 | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 270 | /* SENSOR_MT9V111 3 */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 271 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 272 | /* SENSOR_OM6802 4 */ |
Hans de Goede | 1fec747c | 2009-06-18 06:05:07 -0300 | [diff] [blame] | 273 | (1 << INFRARED_IDX), |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 274 | /* SENSOR_OV7630 5 */ |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 275 | (1 << INFRARED_IDX), |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 276 | /* SENSOR_OV7648 6 */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 277 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 278 | /* SENSOR_OV7660 7 */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 279 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | |
| 280 | (1 << FREQ_IDX), /* SENSOR_SP80708 8 */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 281 | }; |
| 282 | |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 283 | static const struct v4l2_pix_format vga_mode[] = { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 284 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 285 | .bytesperline = 160, |
Jean-Francois Moine | 5d05294 | 2008-09-03 16:48:09 -0300 | [diff] [blame] | 286 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 287 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 288 | .priv = 2}, |
| 289 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 290 | .bytesperline = 320, |
| 291 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
| 292 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 293 | .priv = 1}, |
| 294 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 295 | .bytesperline = 640, |
Hans de Goede | a5d1cc3 | 2009-06-18 06:03:20 -0300 | [diff] [blame] | 296 | /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */ |
| 297 | .sizeimage = 640 * 480 * 3 / 4 + 590, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 298 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 299 | .priv = 0}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 300 | }; |
| 301 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 302 | /*Data from sn9c102p+hv7131r */ |
| 303 | static const u8 sn_hv7131[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 304 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 305 | 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 306 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 307 | 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, |
| 308 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 309 | 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 310 | /* reg18 reg19 reg1a reg1b */ |
| 311 | 0x0a, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 312 | }; |
| 313 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 314 | static const u8 sn_mi0360[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 315 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 316 | 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 317 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 318 | 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, |
| 319 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 320 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 321 | /* reg18 reg19 reg1a reg1b */ |
| 322 | 0x06, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 323 | }; |
| 324 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 325 | static const u8 sn_mo4000[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 326 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 327 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 328 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 329 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 330 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 331 | 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 332 | /* reg18 reg19 reg1a reg1b */ |
| 333 | 0x08, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 334 | }; |
| 335 | |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 336 | static const u8 sn_mt9v111[0x1c] = { |
| 337 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 338 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 339 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 340 | 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 341 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 342 | 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40, |
| 343 | /* reg18 reg19 reg1a reg1b */ |
| 344 | 0x06, 0x00, 0x00, 0x00 |
| 345 | }; |
| 346 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 347 | static const u8 sn_om6802[0x1c] = { |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 348 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 349 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19, |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 350 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 351 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 352 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 353 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 354 | /* reg18 reg19 reg1a reg1b */ |
| 355 | 0x05, 0x00, 0x00, 0x00 |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 356 | }; |
| 357 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 358 | static const u8 sn_ov7630[0x1c] = { |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 359 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 360 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20, |
| 361 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 362 | 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10, |
| 363 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 364 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 365 | /* reg18 reg19 reg1a reg1b */ |
| 366 | 0x0b, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 367 | }; |
| 368 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 369 | static const u8 sn_ov7648[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 370 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 371 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 372 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 373 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 374 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 375 | 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 376 | /* reg18 reg19 reg1a reg1b */ |
| 377 | 0x0b, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 378 | }; |
| 379 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 380 | static const u8 sn_ov7660[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 381 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 382 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 383 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 384 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 385 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 386 | 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 387 | /* reg18 reg19 reg1a reg1b */ |
| 388 | 0x07, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 389 | }; |
| 390 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 391 | static const u8 sn_sp80708[0x1c] = { |
| 392 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 393 | 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 394 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 395 | 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 396 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 397 | 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00, |
| 398 | /* reg18 reg19 reg1a reg1b */ |
| 399 | 0x07, 0x00, 0x00, 0x00 |
| 400 | }; |
| 401 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 402 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 403 | static const u8 *sn_tb[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 404 | sn_hv7131, |
| 405 | sn_mi0360, |
| 406 | sn_mo4000, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 407 | sn_mt9v111, |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 408 | sn_om6802, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 409 | sn_ov7630, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 410 | sn_ov7648, |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 411 | sn_ov7660, |
| 412 | sn_sp80708 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 413 | }; |
| 414 | |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 415 | /* default gamma table */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 416 | static const u8 gamma_def[17] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 417 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
| 418 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
| 419 | }; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 420 | /* gamma for sensors HV7131R and MT9V111 */ |
| 421 | static const u8 gamma_spec_1[17] = { |
| 422 | 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d, |
| 423 | 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5 |
| 424 | }; |
| 425 | /* gamma for sensor SP80708 */ |
| 426 | static const u8 gamma_spec_2[17] = { |
| 427 | 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab, |
| 428 | 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6 |
| 429 | }; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 430 | |
Jean-Francois Moine | 803f9cc | 2008-10-04 14:17:02 -0300 | [diff] [blame] | 431 | /* color matrix and offsets */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 432 | static const u8 reg84[] = { |
Jean-Francois Moine | 803f9cc | 2008-10-04 14:17:02 -0300 | [diff] [blame] | 433 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ |
| 434 | 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */ |
| 435 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ |
| 436 | 0x00, 0x00, 0x00 /* YUV offsets */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 437 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 438 | static const u8 hv7131r_sensor_init[][8] = { |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 439 | {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
| 440 | {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10}, |
| 441 | {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10}, |
| 442 | /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
| 443 | {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 444 | {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
| 445 | /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 446 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 447 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 448 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 449 | {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10}, |
| 450 | {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10}, |
| 451 | {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10}, |
| 452 | {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10}, |
| 453 | {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */ |
| 454 | {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 455 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 456 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 457 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 458 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 459 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 460 | {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 461 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 462 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 463 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 464 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
| 465 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 466 | {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 467 | {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 468 | /* set sensor clock */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 469 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 470 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 471 | static const u8 mi0360_sensor_init[][8] = { |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 472 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 473 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 474 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 475 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, |
| 476 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
| 477 | {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10}, |
| 478 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 479 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 480 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 481 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 482 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 483 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 484 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 485 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 486 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 487 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 488 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 489 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 490 | {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
| 491 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 492 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 493 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 494 | {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 495 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 496 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, |
| 497 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, |
| 498 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, |
| 499 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, |
| 500 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, |
| 501 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 502 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 503 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, |
| 504 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 505 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 506 | {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
| 507 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
| 508 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, |
| 509 | {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10}, |
| 510 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 511 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 512 | {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */ |
| 513 | {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10}, |
| 514 | {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, |
| 515 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 516 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 517 | {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10}, |
| 518 | {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */ |
| 519 | /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */ |
| 520 | /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ |
| 521 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ |
| 522 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 523 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 524 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 525 | static const u8 mo4000_sensor_init[][8] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 526 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 527 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 528 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 529 | {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 530 | {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 531 | {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 532 | {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 533 | {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10}, |
| 534 | {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 535 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 536 | {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 537 | {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 538 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 539 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 540 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 541 | {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 542 | {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 543 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 544 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 545 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 546 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 547 | }; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 548 | static const u8 mt9v111_sensor_init[][8] = { |
| 549 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 550 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 551 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 552 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ |
| 553 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ |
| 554 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ |
Jean-Francois Moine | 2687a2f | 2009-02-01 14:48:55 -0300 | [diff] [blame] | 555 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, |
| 556 | {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10}, |
| 557 | {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10}, |
| 558 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 559 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ |
Jean-Francois Moine | 2687a2f | 2009-02-01 14:48:55 -0300 | [diff] [blame] | 560 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, |
| 561 | {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10}, |
| 562 | {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10}, |
| 563 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, |
| 564 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 565 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ |
Jean-Francois Moine | 2687a2f | 2009-02-01 14:48:55 -0300 | [diff] [blame] | 566 | {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 567 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ |
| 568 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ |
| 569 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ |
| 570 | {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */ |
| 571 | {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */ |
| 572 | {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */ |
| 573 | {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */ |
| 574 | {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */ |
| 575 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */ |
| 576 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 577 | /*******/ |
| 578 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 579 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 2687a2f | 2009-02-01 14:48:55 -0300 | [diff] [blame] | 580 | {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 581 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */ |
| 582 | {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */ |
| 583 | /*******/ |
| 584 | {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */ |
| 585 | {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */ |
| 586 | {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */ |
| 587 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ |
| 588 | {} |
| 589 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 590 | static const u8 om6802_sensor_init[][8] = { |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 591 | {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10}, |
| 592 | {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10}, |
| 593 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
| 594 | {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 595 | /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */ |
| 596 | {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 597 | /* white balance & auto-exposure */ |
| 598 | /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 599 | * set color mode */ |
| 600 | /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10}, |
| 601 | * max AGC value in AE */ |
| 602 | /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 603 | * preset AGC */ |
| 604 | /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 605 | * preset brightness */ |
| 606 | /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 607 | * preset contrast */ |
| 608 | /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10}, |
| 609 | * preset gamma */ |
| 610 | {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
| 611 | /* luminance mode (0x4f = AE) */ |
| 612 | {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10}, |
| 613 | /* preset shutter */ |
| 614 | /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 615 | * auto frame rate */ |
| 616 | /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */ |
| 617 | |
| 618 | /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */ |
| 619 | /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */ |
| 620 | /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */ |
| 621 | /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */ |
| 622 | {} |
| 623 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 624 | static const u8 ov7630_sensor_init[][8] = { |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 625 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 626 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 627 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 628 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 629 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 630 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 631 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 632 | /* win: i2c_r from 00 to 80 */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 633 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, |
| 634 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, |
Hans de Goede | cc7b5b5 | 2009-06-18 05:14:42 -0300 | [diff] [blame] | 635 | /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30) |
| 636 | 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */ |
| 637 | {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10}, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 638 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, |
| 639 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, |
| 640 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 641 | {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10}, |
| 642 | {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10}, |
| 643 | {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10}, |
| 644 | {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10}, |
| 645 | {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10}, |
| 646 | {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 647 | {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 648 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 649 | {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10}, |
| 650 | {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 651 | {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10}, |
| 652 | {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10}, |
| 653 | {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10}, |
| 654 | {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 655 | {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10}, |
| 656 | {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10}, |
| 657 | {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10}, |
| 658 | {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10}, |
| 659 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, |
| 660 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 661 | /* */ |
| 662 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 663 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 664 | /*fixme: + 0x12, 0x04*/ |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 665 | /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN |
| 666 | * set by setvflip */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 667 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
| 668 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 669 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 670 | /* */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 671 | /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
| 672 | /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 673 | /* */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 674 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 91de65a | 2008-09-03 17:12:18 -0300 | [diff] [blame] | 675 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 676 | {} |
| 677 | }; |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 678 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 679 | static const u8 ov7648_sensor_init[][8] = { |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 680 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 681 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 682 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 683 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 684 | {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, |
| 685 | {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, |
| 686 | {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10}, |
| 687 | {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10}, |
| 688 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 689 | {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10}, |
| 690 | {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10}, |
| 691 | {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10}, |
| 692 | {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10}, |
| 693 | {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10}, |
| 694 | {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10}, |
| 695 | {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10}, |
| 696 | {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10}, |
| 697 | {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10}, |
| 698 | {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10}, |
| 699 | {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10}, |
| 700 | {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10}, |
| 701 | {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10}, |
| 702 | |
| 703 | {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, |
| 704 | /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ |
| 705 | /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 706 | /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 707 | /*...*/ |
| 708 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 709 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN |
| 710 | * set by setvflip */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 711 | {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 712 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
| 713 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 714 | /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */ |
| 715 | /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */ |
| 716 | /*...*/ |
| 717 | {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */ |
| 718 | /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 719 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 720 | /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 721 | /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 722 | /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */ |
| 723 | |
| 724 | {} |
| 725 | }; |
| 726 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 727 | static const u8 ov7660_sensor_init[][8] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 728 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 729 | {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 730 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 731 | /* Outformat = rawRGB */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 732 | {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 733 | {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 734 | /* GAIN BLUE RED VREF */ |
| 735 | {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10}, |
| 736 | /* COM 1 BAVE GEAVE AECHH */ |
| 737 | {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */ |
| 738 | {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */ |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 739 | {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 740 | /* AECH CLKRC COM7 COM8 */ |
| 741 | {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */ |
| 742 | {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10}, |
| 743 | /* HSTART HSTOP VSTRT VSTOP */ |
| 744 | {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */ |
| 745 | {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */ |
| 746 | {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10}, |
| 747 | /* BOS GBOS GROS ROS (BGGR offset) */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 748 | /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */ |
| 749 | {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 750 | /* AEW AEB VPT BBIAS */ |
| 751 | {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10}, |
| 752 | /* GbBIAS RSVD EXHCH EXHCL */ |
| 753 | {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10}, |
| 754 | /* RBIAS ADVFL ASDVFH YAVE */ |
| 755 | {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10}, |
| 756 | /* HSYST HSYEN HREF */ |
| 757 | {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */ |
| 758 | {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10}, |
| 759 | /* ADC ACOM OFON TSLB */ |
| 760 | {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10}, |
| 761 | /* COM11 COM12 COM13 COM14 */ |
| 762 | {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10}, |
| 763 | /* EDGE COM15 COM16 COM17 */ |
| 764 | {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */ |
| 765 | {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */ |
| 766 | {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */ |
| 767 | {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */ |
| 768 | {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */ |
| 769 | {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */ |
| 770 | {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */ |
| 771 | {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */ |
| 772 | {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */ |
| 773 | {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10}, |
| 774 | /* LCC1 LCC2 LCC3 LCC4 */ |
| 775 | {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 776 | {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 777 | {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 778 | /* band gap reference [0:3] DBLV */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 779 | {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */ |
| 780 | {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */ |
| 781 | {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */ |
| 782 | {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */ |
| 783 | {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */ |
| 784 | {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */ |
| 785 | {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */ |
| 786 | {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */ |
| 787 | {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 788 | {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */ |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 789 | {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 790 | /****** (some exchanges in the win trace) ******/ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 791 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 792 | /* bits[3..0]reserved */ |
| 793 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 794 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 795 | /* VREF vertical frame ctrl */ |
| 796 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 797 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */ |
| 798 | {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */ |
| 799 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */ |
| 800 | {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */ |
| 801 | /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 802 | /****** (some exchanges in the win trace) ******/ |
| 803 | {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 804 | {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */ |
| 805 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */ |
| 806 | {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */ |
| 807 | /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 808 | /****** (some exchanges in the win trace) ******/ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 809 | /******!! startsensor KO if changed !!****/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 810 | {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 811 | {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10}, |
| 812 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 813 | {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 814 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 815 | }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 816 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 817 | static const u8 sp80708_sensor_init[][8] = { |
| 818 | {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10}, |
| 819 | {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10}, |
| 820 | {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 821 | {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
| 822 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 823 | {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
| 824 | {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10}, |
| 825 | {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10}, |
| 826 | {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10}, |
| 827 | {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 828 | {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 829 | {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 830 | {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 831 | {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 832 | {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10}, |
| 833 | {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 834 | {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 835 | {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 836 | {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10}, |
| 837 | {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10}, |
| 838 | {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10}, |
| 839 | {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10}, |
| 840 | {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 841 | {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10}, |
| 842 | {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10}, |
| 843 | {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10}, |
| 844 | {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 845 | {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10}, |
| 846 | {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10}, |
| 847 | {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10}, |
| 848 | {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10}, |
| 849 | {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10}, |
| 850 | {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
| 851 | {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10}, |
| 852 | {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10}, |
| 853 | {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10}, |
| 854 | {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10}, |
| 855 | {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 856 | {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10}, |
| 857 | {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10}, |
| 858 | {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 859 | {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 860 | {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10}, |
| 861 | {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 862 | {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10}, |
| 863 | {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10}, |
| 864 | {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 865 | {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 866 | {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 867 | {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 868 | {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 869 | {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 870 | {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 871 | {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 872 | {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10}, |
| 873 | {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
| 874 | {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10}, |
| 875 | {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10}, |
| 876 | {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10}, |
| 877 | {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10}, |
| 878 | {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 879 | {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 880 | {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 881 | {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10}, |
| 882 | {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 883 | {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 884 | {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 885 | {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 886 | {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 887 | {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 888 | {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10}, |
| 889 | /********/ |
| 890 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 891 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 892 | {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 893 | {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10}, |
| 894 | {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10}, |
| 895 | {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 896 | {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10}, |
| 897 | {} |
| 898 | }; |
| 899 | |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 900 | static const u8 (*sensor_init[9])[8] = { |
| 901 | hv7131r_sensor_init, /* HV7131R 0 */ |
| 902 | mi0360_sensor_init, /* MI0360 1 */ |
| 903 | mo4000_sensor_init, /* MO4000 2 */ |
| 904 | mt9v111_sensor_init, /* MT9V111 3 */ |
| 905 | om6802_sensor_init, /* OM6802 4 */ |
| 906 | ov7630_sensor_init, /* OV7630 5 */ |
| 907 | ov7648_sensor_init, /* OV7648 6 */ |
| 908 | ov7660_sensor_init, /* OV7660 7 */ |
| 909 | sp80708_sensor_init, /* SP80708 8 */ |
| 910 | }; |
| 911 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 912 | /* read <len> bytes to gspca_dev->usb_buf */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 913 | static void reg_r(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 914 | u16 value, int len) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 915 | { |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 916 | #ifdef GSPCA_DEBUG |
| 917 | if (len > USB_BUF_SZ) { |
| 918 | err("reg_r: buffer overflow"); |
| 919 | return; |
| 920 | } |
| 921 | #endif |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 922 | usb_control_msg(gspca_dev->dev, |
| 923 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 924 | 0, |
| 925 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 926 | value, 0, |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 927 | gspca_dev->usb_buf, len, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 928 | 500); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 929 | PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 930 | } |
| 931 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 932 | static void reg_w1(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 933 | u16 value, |
| 934 | u8 data) |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 935 | { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 936 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 937 | gspca_dev->usb_buf[0] = data; |
| 938 | usb_control_msg(gspca_dev->dev, |
| 939 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 940 | 0x08, |
| 941 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 942 | value, |
| 943 | 0, |
| 944 | gspca_dev->usb_buf, 1, |
| 945 | 500); |
| 946 | } |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 947 | static void reg_w(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 948 | u16 value, |
| 949 | const u8 *buffer, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 950 | int len) |
| 951 | { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 952 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 953 | value, buffer[0], buffer[1]); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 954 | #ifdef GSPCA_DEBUG |
| 955 | if (len > USB_BUF_SZ) { |
| 956 | err("reg_w: buffer overflow"); |
| 957 | return; |
Jean-Francois Moine | bf7f0b9 | 2008-07-03 11:09:12 -0300 | [diff] [blame] | 958 | } |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 959 | #endif |
| 960 | memcpy(gspca_dev->usb_buf, buffer, len); |
| 961 | usb_control_msg(gspca_dev->dev, |
| 962 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 963 | 0x08, |
| 964 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 965 | value, 0, |
| 966 | gspca_dev->usb_buf, len, |
| 967 | 500); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 968 | } |
| 969 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 970 | /* I2C write 1 byte */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 971 | static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 972 | { |
| 973 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 974 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 975 | PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val); |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 976 | switch (sd->sensor) { |
| 977 | case SENSOR_OM6802: /* i2c command = a0 (100 kHz) */ |
| 978 | gspca_dev->usb_buf[0] = 0x80 | (2 << 4); |
| 979 | break; |
| 980 | default: /* i2c command = a1 (400 kHz) */ |
| 981 | gspca_dev->usb_buf[0] = 0x81 | (2 << 4); |
| 982 | break; |
| 983 | } |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 984 | gspca_dev->usb_buf[1] = sd->i2c_base; |
| 985 | gspca_dev->usb_buf[2] = reg; |
| 986 | gspca_dev->usb_buf[3] = val; |
| 987 | gspca_dev->usb_buf[4] = 0; |
| 988 | gspca_dev->usb_buf[5] = 0; |
| 989 | gspca_dev->usb_buf[6] = 0; |
| 990 | gspca_dev->usb_buf[7] = 0x10; |
| 991 | usb_control_msg(gspca_dev->dev, |
| 992 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 993 | 0x08, |
| 994 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 995 | 0x08, /* value = i2c */ |
| 996 | 0, |
| 997 | gspca_dev->usb_buf, 8, |
| 998 | 500); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 999 | } |
| 1000 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1001 | /* I2C write 8 bytes */ |
| 1002 | static void i2c_w8(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1003 | const u8 *buffer) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1004 | { |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1005 | memcpy(gspca_dev->usb_buf, buffer, 8); |
| 1006 | usb_control_msg(gspca_dev->dev, |
| 1007 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1008 | 0x08, |
| 1009 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1010 | 0x08, 0, /* value, index */ |
| 1011 | gspca_dev->usb_buf, 8, |
| 1012 | 500); |
Jean-Francois Moine | 8d768e1 | 2008-09-21 03:28:55 -0300 | [diff] [blame] | 1013 | msleep(2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1014 | } |
| 1015 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1016 | /* read 5 bytes in gspca_dev->usb_buf */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1017 | static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1018 | { |
| 1019 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1020 | u8 mode[8]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1021 | |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 1022 | switch (sd->sensor) { |
| 1023 | case SENSOR_OM6802: /* i2c command = 90 (100 kHz) */ |
| 1024 | mode[0] = 0x80 | 0x10; |
| 1025 | break; |
| 1026 | default: /* i2c command = 91 (400 kHz) */ |
| 1027 | mode[0] = 0x81 | 0x10; |
| 1028 | break; |
| 1029 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1030 | mode[1] = sd->i2c_base; |
| 1031 | mode[2] = reg; |
| 1032 | mode[3] = 0; |
| 1033 | mode[4] = 0; |
| 1034 | mode[5] = 0; |
| 1035 | mode[6] = 0; |
| 1036 | mode[7] = 0x10; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1037 | i2c_w8(gspca_dev, mode); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1038 | msleep(2); |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 1039 | mode[0] = (mode[0] & 0x81) | (5 << 4) | 0x02; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1040 | mode[2] = 0; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1041 | i2c_w8(gspca_dev, mode); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1042 | msleep(2); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1043 | reg_r(gspca_dev, 0x0a, 5); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1044 | } |
| 1045 | |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 1046 | static void i2c_w_seq(struct gspca_dev *gspca_dev, |
| 1047 | const u8 (*data)[8]) |
| 1048 | { |
| 1049 | while ((*data)[0] != 0) { |
| 1050 | if ((*data)[0] != 0xdd) |
| 1051 | i2c_w8(gspca_dev, *data); |
| 1052 | else |
| 1053 | msleep((*data)[1]); |
| 1054 | data++; |
| 1055 | } |
| 1056 | } |
| 1057 | |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1058 | static void hv7131r_probe(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1059 | { |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1060 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1061 | msleep(10); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1062 | reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1063 | msleep(10); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1064 | i2c_r5(gspca_dev, 0); /* read sensor id */ |
| 1065 | if (gspca_dev->usb_buf[0] == 0x02 |
| 1066 | && gspca_dev->usb_buf[1] == 0x09 |
| 1067 | && gspca_dev->usb_buf[2] == 0x01 |
| 1068 | && gspca_dev->usb_buf[3] == 0x00 |
| 1069 | && gspca_dev->usb_buf[4] == 0x00) { |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1070 | PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found"); |
| 1071 | return; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1072 | } |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1073 | PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found", |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1074 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], |
| 1075 | gspca_dev->usb_buf[2]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1076 | } |
| 1077 | |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1078 | static void mi0360_probe(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1079 | { |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1080 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1081 | int i, j; |
Jean-Francois Moine | 92e8c91 | 2009-02-02 16:25:38 -0300 | [diff] [blame] | 1082 | u16 val = 0; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1083 | static const u8 probe_tb[][4][8] = { |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1084 | { /* mi0360 */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1085 | {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 1086 | {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1087 | {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1088 | {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10} |
| 1089 | }, |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1090 | { /* mt9v111 */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1091 | {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, |
| 1092 | {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1093 | {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1094 | {} |
| 1095 | }, |
| 1096 | }; |
| 1097 | |
| 1098 | for (i = 0; i < ARRAY_SIZE(probe_tb); i++) { |
| 1099 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1100 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1101 | for (j = 0; j < 3; j++) |
| 1102 | i2c_w8(gspca_dev, probe_tb[i][j]); |
| 1103 | msleep(2); |
| 1104 | reg_r(gspca_dev, 0x0a, 5); |
| 1105 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
| 1106 | if (probe_tb[i][3][0] != 0) |
| 1107 | i2c_w8(gspca_dev, probe_tb[i][3]); |
| 1108 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1109 | reg_w1(gspca_dev, 0x17, 0x42); |
| 1110 | if (val != 0xffff) |
| 1111 | break; |
| 1112 | } |
| 1113 | switch (val) { |
| 1114 | case 0x823a: |
| 1115 | PDEBUG(D_PROBE, "Sensor mt9v111"); |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1116 | sd->sensor = SENSOR_MT9V111; |
| 1117 | sd->i2c_base = 0x5c; |
| 1118 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1119 | case 0x8243: |
| 1120 | PDEBUG(D_PROBE, "Sensor mi0360"); |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1121 | break; |
| 1122 | default: |
| 1123 | PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val); |
| 1124 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1125 | } |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1126 | } |
| 1127 | |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1128 | static void configure_gpio(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1129 | const u8 *sn9c1xx) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1130 | { |
| 1131 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1132 | const u8 *reg9a; |
| 1133 | static const u8 reg9a_def[] = |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1134 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; |
| 1135 | static const u8 reg9a_spec[] = |
| 1136 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1137 | static const u8 regd4[] = {0x60, 0x00, 0x00}; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1138 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1139 | reg_w1(gspca_dev, 0xf1, 0x00); |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 1140 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1141 | |
| 1142 | /* configure gpio */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1143 | reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); |
| 1144 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1145 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */ |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1146 | switch (sd->sensor) { |
| 1147 | case SENSOR_OV7660: |
| 1148 | case SENSOR_SP80708: |
| 1149 | reg9a = reg9a_spec; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1150 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1151 | default: |
| 1152 | reg9a = reg9a_def; |
| 1153 | break; |
| 1154 | } |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1155 | reg_w(gspca_dev, 0x9a, reg9a, 6); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1156 | |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1157 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1158 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1159 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1160 | |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1161 | switch (sd->sensor) { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1162 | case SENSOR_MT9V111: |
| 1163 | reg_w1(gspca_dev, 0x01, 0x61); |
| 1164 | reg_w1(gspca_dev, 0x17, 0x61); |
| 1165 | reg_w1(gspca_dev, 0x01, 0x60); |
| 1166 | reg_w1(gspca_dev, 0x01, 0x40); |
| 1167 | break; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1168 | case SENSOR_OM6802: |
Jean-Francois Moine | 4f30f6c | 2008-09-03 16:48:05 -0300 | [diff] [blame] | 1169 | reg_w1(gspca_dev, 0x02, 0x71); |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1170 | reg_w1(gspca_dev, 0x01, 0x42); |
| 1171 | reg_w1(gspca_dev, 0x17, 0x64); |
| 1172 | reg_w1(gspca_dev, 0x01, 0x42); |
| 1173 | break; |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 1174 | case SENSOR_OV7630: |
| 1175 | reg_w1(gspca_dev, 0x01, 0x61); |
| 1176 | reg_w1(gspca_dev, 0x17, 0xe2); |
| 1177 | reg_w1(gspca_dev, 0x01, 0x60); |
| 1178 | reg_w1(gspca_dev, 0x01, 0x40); |
| 1179 | break; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1180 | case SENSOR_OV7648: |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1181 | reg_w1(gspca_dev, 0x01, 0x63); |
| 1182 | reg_w1(gspca_dev, 0x17, 0x20); |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1183 | reg_w1(gspca_dev, 0x01, 0x62); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1184 | reg_w1(gspca_dev, 0x01, 0x42); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1185 | break; |
Jean-Francois Moine | 91de65a | 2008-09-03 17:12:18 -0300 | [diff] [blame] | 1186 | case SENSOR_OV7660: |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1187 | case SENSOR_SP80708: |
| 1188 | reg_w1(gspca_dev, 0x01, 0x63); |
| 1189 | reg_w1(gspca_dev, 0x17, 0x20); |
| 1190 | reg_w1(gspca_dev, 0x01, 0x62); |
| 1191 | reg_w1(gspca_dev, 0x01, 0x42); |
Jean-Francois Moine | 1f78a97 | 2009-08-29 07:11:58 -0300 | [diff] [blame] | 1192 | msleep(100); |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1193 | reg_w1(gspca_dev, 0x02, 0x62); |
| 1194 | break; |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1195 | /* case SENSOR_HV7131R: */ |
| 1196 | /* case SENSOR_MI0360: */ |
| 1197 | /* case SENSOR_MO4000: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1198 | default: |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1199 | reg_w1(gspca_dev, 0x01, 0x43); |
| 1200 | reg_w1(gspca_dev, 0x17, 0x61); |
| 1201 | reg_w1(gspca_dev, 0x01, 0x42); |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1202 | if (sd->sensor == SENSOR_HV7131R) |
| 1203 | hv7131r_probe(gspca_dev); |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1204 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1205 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1206 | } |
| 1207 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1208 | /* this function is called at probe time */ |
| 1209 | static int sd_config(struct gspca_dev *gspca_dev, |
| 1210 | const struct usb_device_id *id) |
| 1211 | { |
| 1212 | struct sd *sd = (struct sd *) gspca_dev; |
| 1213 | struct cam *cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1214 | |
| 1215 | cam = &gspca_dev->cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1216 | cam->cam_mode = vga_mode; |
| 1217 | cam->nmodes = ARRAY_SIZE(vga_mode); |
Jean-Francois Moine | 49cb6b0 | 2009-04-25 13:29:01 -0300 | [diff] [blame] | 1218 | cam->npkt = 24; /* 24 packets per ISOC message */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 1219 | |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 1220 | sd->bridge = id->driver_info >> 16; |
| 1221 | sd->sensor = id->driver_info >> 8; |
| 1222 | sd->i2c_base = id->driver_info; |
| 1223 | |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 1224 | sd->brightness = BRIGHTNESS_DEF; |
| 1225 | sd->contrast = CONTRAST_DEF; |
| 1226 | sd->colors = COLOR_DEF; |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1227 | sd->blue = BLUE_BALANCE_DEF; |
| 1228 | sd->red = RED_BALANCE_DEF; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1229 | sd->gamma = GAMMA_DEF; |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 1230 | sd->autogain = AUTOGAIN_DEF; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1231 | sd->ag_cnt = -1; |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 1232 | sd->vflip = VFLIP_DEF; |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 1233 | sd->infrared = INFRARED_DEF; |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1234 | sd->freq = FREQ_DEF; |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 1235 | sd->quality = QUALITY_DEF; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1236 | sd->jpegqual = 80; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1237 | |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1238 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1239 | return 0; |
| 1240 | } |
| 1241 | |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 1242 | /* this function is called at probe and resume time */ |
| 1243 | static int sd_init(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1244 | { |
| 1245 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1246 | u8 regGpio[] = { 0x29, 0x74 }; |
| 1247 | u8 regF1; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1248 | |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1249 | /* setup a selector by bridge */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1250 | reg_w1(gspca_dev, 0xf1, 0x01); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1251 | reg_r(gspca_dev, 0x00, 1); |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1252 | reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]); |
| 1253 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1254 | regF1 = gspca_dev->usb_buf[0]; |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1255 | PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1256 | switch (sd->bridge) { |
| 1257 | case BRIDGE_SN9C102P: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1258 | if (regF1 != 0x11) |
| 1259 | return -ENODEV; |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1260 | reg_w1(gspca_dev, 0x02, regGpio[1]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1261 | break; |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1262 | case BRIDGE_SN9C105: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1263 | if (regF1 != 0x11) |
| 1264 | return -ENODEV; |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1265 | if (sd->sensor == SENSOR_MI0360) |
| 1266 | mi0360_probe(gspca_dev); |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1267 | reg_w(gspca_dev, 0x01, regGpio, 2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1268 | break; |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1269 | case BRIDGE_SN9C120: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1270 | if (regF1 != 0x12) |
| 1271 | return -ENODEV; |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1272 | if (sd->sensor == SENSOR_MI0360) |
| 1273 | mi0360_probe(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1274 | regGpio[1] = 0x70; |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1275 | reg_w(gspca_dev, 0x01, regGpio, 2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1276 | break; |
| 1277 | default: |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1278 | /* case BRIDGE_SN9C110: */ |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1279 | /* case BRIDGE_SN9C325: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1280 | if (regF1 != 0x12) |
| 1281 | return -ENODEV; |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1282 | reg_w1(gspca_dev, 0x02, 0x62); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1283 | break; |
| 1284 | } |
| 1285 | |
Jean-Francois Moine | 759aa3c | 2008-09-03 16:48:03 -0300 | [diff] [blame] | 1286 | reg_w1(gspca_dev, 0xf1, 0x01); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1287 | |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1291 | static u32 setexposure(struct gspca_dev *gspca_dev, |
| 1292 | u32 expo) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1293 | { |
| 1294 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1295 | |
| 1296 | switch (sd->sensor) { |
| 1297 | case SENSOR_HV7131R: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1298 | u8 Expodoit[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1299 | { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 }; |
| 1300 | |
| 1301 | Expodoit[3] = expo >> 16; |
| 1302 | Expodoit[4] = expo >> 8; |
| 1303 | Expodoit[5] = expo; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1304 | i2c_w8(gspca_dev, Expodoit); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1305 | break; |
| 1306 | } |
| 1307 | case SENSOR_MI0360: { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1308 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1309 | { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1310 | static const u8 doit[] = /* update sensor */ |
| 1311 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; |
| 1312 | static const u8 sensorgo[] = /* sensor on */ |
| 1313 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1314 | |
| 1315 | if (expo > 0x0635) |
| 1316 | expo = 0x0635; |
| 1317 | else if (expo < 0x0001) |
| 1318 | expo = 0x0001; |
| 1319 | expoMi[3] = expo >> 8; |
| 1320 | expoMi[4] = expo; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1321 | i2c_w8(gspca_dev, expoMi); |
| 1322 | i2c_w8(gspca_dev, doit); |
| 1323 | i2c_w8(gspca_dev, sensorgo); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1324 | break; |
| 1325 | } |
| 1326 | case SENSOR_MO4000: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1327 | u8 expoMof[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1328 | { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1329 | u8 expoMo10[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1330 | { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1331 | static const u8 gainMo[] = |
| 1332 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1333 | |
| 1334 | if (expo > 0x1fff) |
| 1335 | expo = 0x1fff; |
| 1336 | else if (expo < 0x0001) |
| 1337 | expo = 0x0001; |
| 1338 | expoMof[3] = (expo & 0x03fc) >> 2; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1339 | i2c_w8(gspca_dev, expoMof); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1340 | expoMo10[3] = ((expo & 0x1c00) >> 10) |
| 1341 | | ((expo & 0x0003) << 4); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1342 | i2c_w8(gspca_dev, expoMo10); |
| 1343 | i2c_w8(gspca_dev, gainMo); |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1344 | PDEBUG(D_FRAM, "set exposure %d", |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1345 | ((expoMo10[3] & 0x07) << 10) |
| 1346 | | (expoMof[3] << 2) |
| 1347 | | ((expoMo10[3] & 0x30) >> 4)); |
| 1348 | break; |
| 1349 | } |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1350 | case SENSOR_MT9V111: { |
| 1351 | u8 expo_c1[] = |
| 1352 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
| 1353 | |
| 1354 | if (expo > 0x0280) |
| 1355 | expo = 0x0280; |
| 1356 | else if (expo < 0x0040) |
| 1357 | expo = 0x0040; |
| 1358 | expo_c1[3] = expo >> 8; |
| 1359 | expo_c1[4] = expo; |
| 1360 | i2c_w8(gspca_dev, expo_c1); |
| 1361 | break; |
| 1362 | } |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1363 | case SENSOR_OM6802: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1364 | u8 gainOm[] = |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1365 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
| 1366 | |
| 1367 | if (expo > 0x03ff) |
| 1368 | expo = 0x03ff; |
| 1369 | if (expo < 0x0001) |
| 1370 | expo = 0x0001; |
| 1371 | gainOm[3] = expo >> 2; |
| 1372 | i2c_w8(gspca_dev, gainOm); |
Jean-Francois Moine | d55b83d | 2008-09-03 16:48:01 -0300 | [diff] [blame] | 1373 | reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f); |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1374 | PDEBUG(D_FRAM, "set exposure %d", gainOm[3]); |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1375 | break; |
| 1376 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1377 | } |
| 1378 | return expo; |
| 1379 | } |
| 1380 | |
| 1381 | static void setbrightness(struct gspca_dev *gspca_dev) |
| 1382 | { |
| 1383 | struct sd *sd = (struct sd *) gspca_dev; |
| 1384 | unsigned int expo; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1385 | u8 k2; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1386 | |
Jean-Francois Moine | b1b056a | 2008-11-25 04:47:09 -0300 | [diff] [blame] | 1387 | k2 = ((int) sd->brightness - 0x8000) >> 10; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1388 | switch (sd->sensor) { |
| 1389 | case SENSOR_HV7131R: |
| 1390 | expo = sd->brightness << 4; |
| 1391 | if (expo > 0x002dc6c0) |
| 1392 | expo = 0x002dc6c0; |
| 1393 | else if (expo < 0x02a0) |
| 1394 | expo = 0x02a0; |
| 1395 | sd->exposure = setexposure(gspca_dev, expo); |
| 1396 | break; |
| 1397 | case SENSOR_MI0360: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1398 | case SENSOR_MO4000: |
| 1399 | expo = sd->brightness >> 4; |
| 1400 | sd->exposure = setexposure(gspca_dev, expo); |
| 1401 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1402 | case SENSOR_MT9V111: |
| 1403 | expo = sd->brightness >> 8; |
| 1404 | sd->exposure = setexposure(gspca_dev, expo); |
| 1405 | break; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1406 | case SENSOR_OM6802: |
| 1407 | expo = sd->brightness >> 6; |
| 1408 | sd->exposure = setexposure(gspca_dev, expo); |
Jean-Francois Moine | b1b056a | 2008-11-25 04:47:09 -0300 | [diff] [blame] | 1409 | k2 = sd->brightness >> 11; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1410 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1411 | } |
| 1412 | |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1413 | if (sd->sensor != SENSOR_MT9V111) |
| 1414 | reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | static void setcontrast(struct gspca_dev *gspca_dev) |
| 1418 | { |
| 1419 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1420 | u8 k2; |
| 1421 | u8 contrast[6]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1422 | |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1423 | k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ |
| 1424 | contrast[0] = (k2 + 1) / 2; /* red */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1425 | contrast[1] = 0; |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1426 | contrast[2] = k2; /* green */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1427 | contrast[3] = 0; |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1428 | contrast[4] = (k2 + 1) / 5; /* blue */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1429 | contrast[5] = 0; |
| 1430 | reg_w(gspca_dev, 0x84, contrast, sizeof contrast); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1431 | } |
| 1432 | |
| 1433 | static void setcolors(struct gspca_dev *gspca_dev) |
| 1434 | { |
| 1435 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1436 | int i, v; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1437 | u8 reg8a[12]; /* U & V gains */ |
| 1438 | static s16 uv[6] = { /* same as reg84 in signed decimal */ |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1439 | -24, -38, 64, /* UR UG UB */ |
| 1440 | 62, -51, -9 /* VR VG VB */ |
| 1441 | }; |
| 1442 | for (i = 0; i < 6; i++) { |
| 1443 | v = uv[i] * sd->colors / COLOR_DEF; |
Jean-Francois Moine | bd08883 | 2008-12-02 06:58:57 -0300 | [diff] [blame] | 1444 | reg8a[i * 2] = v; |
| 1445 | reg8a[i * 2 + 1] = (v >> 8) & 0x0f; |
Jean-Francois Moine | d55b83d | 2008-09-03 16:48:01 -0300 | [diff] [blame] | 1446 | } |
Jean-Francois Moine | bd08883 | 2008-12-02 06:58:57 -0300 | [diff] [blame] | 1447 | reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a); |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1448 | } |
| 1449 | |
| 1450 | static void setredblue(struct gspca_dev *gspca_dev) |
| 1451 | { |
| 1452 | struct sd *sd = (struct sd *) gspca_dev; |
| 1453 | |
| 1454 | reg_w1(gspca_dev, 0x05, sd->red); |
Jean-Francois Moine | 9c5f70f | 2008-09-03 16:48:04 -0300 | [diff] [blame] | 1455 | /* reg_w1(gspca_dev, 0x07, 32); */ |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1456 | reg_w1(gspca_dev, 0x06, sd->blue); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1457 | } |
| 1458 | |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1459 | static void setgamma(struct gspca_dev *gspca_dev) |
| 1460 | { |
| 1461 | struct sd *sd = (struct sd *) gspca_dev; |
| 1462 | int i; |
| 1463 | u8 gamma[17]; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1464 | const u8 *gamma_base; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1465 | static const u8 delta[17] = { |
| 1466 | 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a, |
| 1467 | 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00 |
| 1468 | }; |
| 1469 | |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1470 | switch (sd->sensor) { |
| 1471 | case SENSOR_HV7131R: |
| 1472 | case SENSOR_MT9V111: |
| 1473 | gamma_base = gamma_spec_1; |
| 1474 | break; |
| 1475 | case SENSOR_SP80708: |
| 1476 | gamma_base = gamma_spec_2; |
| 1477 | break; |
| 1478 | default: |
| 1479 | gamma_base = gamma_def; |
| 1480 | break; |
| 1481 | } |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1482 | |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1483 | for (i = 0; i < sizeof gamma; i++) |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1484 | gamma[i] = gamma_base[i] |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1485 | + delta[i] * (sd->gamma - GAMMA_DEF) / 32; |
| 1486 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); |
| 1487 | } |
| 1488 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1489 | static void setautogain(struct gspca_dev *gspca_dev) |
| 1490 | { |
| 1491 | struct sd *sd = (struct sd *) gspca_dev; |
| 1492 | |
Jean-Francois Moine | f50ba1b | 2008-09-03 17:12:14 -0300 | [diff] [blame] | 1493 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
| 1494 | return; |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1495 | switch (sd->sensor) { |
| 1496 | case SENSOR_OV7630: |
| 1497 | case SENSOR_OV7648: { |
| 1498 | u8 comb; |
| 1499 | |
| 1500 | if (sd->sensor == SENSOR_OV7630) |
| 1501 | comb = 0xc0; |
| 1502 | else |
| 1503 | comb = 0xa0; |
| 1504 | if (sd->autogain) |
Hans de Goede | 1fec747c | 2009-06-18 06:05:07 -0300 | [diff] [blame] | 1505 | comb |= 0x03; |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1506 | i2c_w1(&sd->gspca_dev, 0x13, comb); |
| 1507 | return; |
| 1508 | } |
| 1509 | } |
Jean-Francois Moine | f50ba1b | 2008-09-03 17:12:14 -0300 | [diff] [blame] | 1510 | if (sd->autogain) |
| 1511 | sd->ag_cnt = AG_CNT_START; |
| 1512 | else |
| 1513 | sd->ag_cnt = -1; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1514 | } |
| 1515 | |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1516 | /* ov7630/ov7648 only */ |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 1517 | static void setvflip(struct sd *sd) |
| 1518 | { |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1519 | u8 comn; |
| 1520 | |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 1521 | if (sd->sensor == SENSOR_OV7630) { |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1522 | comn = 0x02; |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 1523 | if (!sd->vflip) |
| 1524 | comn |= 0x80; |
| 1525 | } else { |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1526 | comn = 0x06; |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 1527 | if (sd->vflip) |
| 1528 | comn |= 0x80; |
| 1529 | } |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1530 | i2c_w1(&sd->gspca_dev, 0x75, comn); |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 1531 | } |
| 1532 | |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 1533 | static void setinfrared(struct sd *sd) |
| 1534 | { |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 1535 | if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX)) |
| 1536 | return; |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 1537 | /*fixme: different sequence for StarCam Clip and StarCam 370i */ |
| 1538 | /* Clip */ |
| 1539 | i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ |
| 1540 | sd->infrared ? 0x66 : 0x64); |
| 1541 | } |
| 1542 | |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1543 | static void setfreq(struct gspca_dev *gspca_dev) |
| 1544 | { |
| 1545 | struct sd *sd = (struct sd *) gspca_dev; |
| 1546 | |
Jean-Francois Moine | 2795493 | 2009-07-08 05:21:50 -0300 | [diff] [blame] | 1547 | if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) |
| 1548 | return; |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1549 | if (sd->sensor == SENSOR_OV7660) { |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 1550 | u8 com8; |
| 1551 | |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 1552 | com8 = 0xdf; /* auto gain/wb/expo */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1553 | switch (sd->freq) { |
| 1554 | case 0: /* Banding filter disabled */ |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 1555 | i2c_w1(gspca_dev, 0x13, com8 | 0x20); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1556 | break; |
| 1557 | case 1: /* 50 hz */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 1558 | i2c_w1(gspca_dev, 0x13, com8); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1559 | i2c_w1(gspca_dev, 0x3b, 0x0a); |
| 1560 | break; |
| 1561 | case 2: /* 60 hz */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 1562 | i2c_w1(gspca_dev, 0x13, com8); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1563 | i2c_w1(gspca_dev, 0x3b, 0x02); |
| 1564 | break; |
| 1565 | } |
| 1566 | } else { |
| 1567 | u8 reg2a = 0, reg2b = 0, reg2d = 0; |
| 1568 | |
| 1569 | /* Get reg2a / reg2d base values */ |
| 1570 | switch (sd->sensor) { |
| 1571 | case SENSOR_OV7630: |
| 1572 | reg2a = 0x08; |
| 1573 | reg2d = 0x01; |
| 1574 | break; |
| 1575 | case SENSOR_OV7648: |
| 1576 | reg2a = 0x11; |
| 1577 | reg2d = 0x81; |
| 1578 | break; |
| 1579 | } |
| 1580 | |
| 1581 | switch (sd->freq) { |
| 1582 | case 0: /* Banding filter disabled */ |
| 1583 | break; |
| 1584 | case 1: /* 50 hz (filter on and framerate adj) */ |
| 1585 | reg2a |= 0x80; |
| 1586 | reg2b = 0xac; |
| 1587 | reg2d |= 0x04; |
| 1588 | break; |
| 1589 | case 2: /* 60 hz (filter on, no framerate adj) */ |
| 1590 | reg2a |= 0x80; |
| 1591 | reg2d |= 0x04; |
| 1592 | break; |
| 1593 | } |
| 1594 | i2c_w1(gspca_dev, 0x2a, reg2a); |
| 1595 | i2c_w1(gspca_dev, 0x2b, reg2b); |
| 1596 | i2c_w1(gspca_dev, 0x2d, reg2d); |
| 1597 | } |
| 1598 | } |
| 1599 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1600 | static void setjpegqual(struct gspca_dev *gspca_dev) |
| 1601 | { |
| 1602 | struct sd *sd = (struct sd *) gspca_dev; |
| 1603 | int i, sc; |
| 1604 | |
| 1605 | if (sd->jpegqual < 50) |
| 1606 | sc = 5000 / sd->jpegqual; |
| 1607 | else |
| 1608 | sc = 200 - sd->jpegqual * 2; |
| 1609 | #if USB_BUF_SZ < 64 |
| 1610 | #error "No room enough in usb_buf for quantization table" |
| 1611 | #endif |
| 1612 | for (i = 0; i < 64; i++) |
| 1613 | gspca_dev->usb_buf[i] = |
| 1614 | (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100; |
| 1615 | usb_control_msg(gspca_dev->dev, |
| 1616 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1617 | 0x08, |
| 1618 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1619 | 0x0100, 0, |
| 1620 | gspca_dev->usb_buf, 64, |
| 1621 | 500); |
| 1622 | for (i = 0; i < 64; i++) |
| 1623 | gspca_dev->usb_buf[i] = |
| 1624 | (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100; |
| 1625 | usb_control_msg(gspca_dev->dev, |
| 1626 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1627 | 0x08, |
| 1628 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1629 | 0x0140, 0, |
| 1630 | gspca_dev->usb_buf, 64, |
| 1631 | 500); |
| 1632 | |
| 1633 | sd->reg18 ^= 0x40; |
| 1634 | reg_w1(gspca_dev, 0x18, sd->reg18); |
| 1635 | } |
| 1636 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1637 | /* -- start the camera -- */ |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 1638 | static int sd_start(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1639 | { |
| 1640 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1641 | int i; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1642 | u8 reg1, reg17; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1643 | const u8 *sn9c1xx; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1644 | int mode; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1645 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
| 1646 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
| 1647 | static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
| 1648 | static const u8 CE_ov76xx[] = |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1649 | { 0x32, 0xdd, 0x32, 0xdd }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1650 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1651 | /* create the JPEG header */ |
| 1652 | sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL); |
Julia Lawall | 3eb0237 | 2009-07-19 07:09:32 -0300 | [diff] [blame] | 1653 | if (!sd->jpeg_hdr) |
| 1654 | return -ENOMEM; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1655 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
| 1656 | 0x21); /* JPEG 422 */ |
| 1657 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
| 1658 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1659 | sn9c1xx = sn_tb[(int) sd->sensor]; |
| 1660 | configure_gpio(gspca_dev, sn9c1xx); |
| 1661 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1662 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); |
| 1663 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); |
| 1664 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); |
| 1665 | reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]); |
| 1666 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
| 1667 | reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */ |
| 1668 | reg_w1(gspca_dev, 0xd3, 0x50); |
| 1669 | reg_w1(gspca_dev, 0xc6, 0x00); |
| 1670 | reg_w1(gspca_dev, 0xc7, 0x00); |
| 1671 | reg_w1(gspca_dev, 0xc8, 0x50); |
| 1672 | reg_w1(gspca_dev, 0xc9, 0x3c); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1673 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1674 | switch (sd->sensor) { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1675 | case SENSOR_MT9V111: |
| 1676 | reg17 = 0xe0; |
| 1677 | break; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1678 | case SENSOR_OV7630: |
| 1679 | reg17 = 0xe2; |
| 1680 | break; |
| 1681 | case SENSOR_OV7648: |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1682 | reg17 = 0x20; |
Jean-Francois Moine | 568788a | 2008-07-15 11:46:06 -0300 | [diff] [blame] | 1683 | break; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1684 | case SENSOR_OV7660: |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1685 | reg17 = 0xa0; |
| 1686 | break; |
Jean-Francois Moine | 568788a | 2008-07-15 11:46:06 -0300 | [diff] [blame] | 1687 | default: |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1688 | reg17 = 0x60; |
Jean-Francois Moine | 568788a | 2008-07-15 11:46:06 -0300 | [diff] [blame] | 1689 | break; |
| 1690 | } |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1691 | reg_w1(gspca_dev, 0x17, reg17); |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1692 | /* set reg1 was here */ |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1693 | reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */ |
| 1694 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ |
| 1695 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1696 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1697 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1698 | setgamma(gspca_dev); |
| 1699 | |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 1700 | for (i = 0; i < 8; i++) |
| 1701 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1702 | switch (sd->sensor) { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1703 | case SENSOR_MT9V111: |
| 1704 | reg_w1(gspca_dev, 0x9a, 0x07); |
| 1705 | reg_w1(gspca_dev, 0x99, 0x59); |
| 1706 | break; |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1707 | case SENSOR_OV7648: |
| 1708 | reg_w1(gspca_dev, 0x9a, 0x0a); |
| 1709 | reg_w1(gspca_dev, 0x99, 0x60); |
| 1710 | break; |
Jean-Francois Moine | c8b9b2c | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 1711 | case SENSOR_OV7660: |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1712 | case SENSOR_SP80708: |
| 1713 | reg_w1(gspca_dev, 0x9a, 0x05); |
| 1714 | reg_w1(gspca_dev, 0x99, 0x59); |
| 1715 | break; |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1716 | default: |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1717 | reg_w1(gspca_dev, 0x9a, 0x08); |
| 1718 | reg_w1(gspca_dev, 0x99, 0x59); |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1719 | break; |
| 1720 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1721 | |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 1722 | /* initialize the sensor */ |
| 1723 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); |
| 1724 | |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 1725 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1726 | if (mode) |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1727 | reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1728 | else |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1729 | reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */ |
| 1730 | reg17 = 0x61; /* 0x:20: enable sensor clock */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1731 | switch (sd->sensor) { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1732 | case SENSOR_MO4000: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1733 | if (mode) { |
| 1734 | /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */ |
| 1735 | reg1 = 0x06; /* clk 24Mz */ |
| 1736 | } else { |
| 1737 | reg17 = 0x22; /* 640 MCKSIZE */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1738 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1739 | } |
| 1740 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1741 | case SENSOR_MT9V111: |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1742 | if (mode) { |
| 1743 | reg1 = 0x04; /* 320 clk 48Mhz */ |
| 1744 | } else { |
| 1745 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
Jean-Francois Moine | 2687a2f | 2009-02-01 14:48:55 -0300 | [diff] [blame] | 1746 | reg17 = 0xc2; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1747 | } |
Jean-Francois Moine | 0fbe057 | 2009-01-30 12:14:02 -0300 | [diff] [blame] | 1748 | break; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1749 | case SENSOR_OM6802: |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1750 | reg17 = 0x64; /* 640 MCKSIZE */ |
| 1751 | break; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1752 | case SENSOR_OV7630: |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 1753 | setvflip(sd); |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1754 | reg17 = 0xe2; |
Jean-Francois Moine | 5b064da | 2008-09-03 16:48:08 -0300 | [diff] [blame] | 1755 | reg1 = 0x44; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1756 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1757 | case SENSOR_OV7648: |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1758 | reg17 = 0x21; |
| 1759 | /* reg1 = 0x42; * 42 - 46? */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1760 | break; |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1761 | case SENSOR_OV7660: |
Jean-Francois Moine | daa5cb4 | 2008-12-02 15:00:57 -0300 | [diff] [blame] | 1762 | if (sd->bridge == BRIDGE_SN9C120) { |
| 1763 | if (mode) { /* 320x240 - 160x120 */ |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1764 | reg17 = 0xa2; |
| 1765 | reg1 = 0x44; /* 48 Mhz, video trf eneble */ |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1766 | } |
Jean-Francois Moine | daa5cb4 | 2008-12-02 15:00:57 -0300 | [diff] [blame] | 1767 | } else { |
| 1768 | reg17 = 0x22; |
| 1769 | reg1 = 0x06; /* 24 Mhz, video trf eneble |
| 1770 | * inverse power down */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1771 | } |
| 1772 | break; |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1773 | default: |
| 1774 | /* case SENSOR_SP80708: */ |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1775 | if (mode) { |
| 1776 | /*?? reg1 = 0x04; * 320 clk 48Mhz */ |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1777 | } else { |
| 1778 | reg1 = 0x46; /* 640 clk 48Mz */ |
| 1779 | reg17 = 0xa2; |
| 1780 | } |
| 1781 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1782 | } |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1783 | reg_w(gspca_dev, 0xc0, C0, 6); |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1784 | reg_w(gspca_dev, 0xca, CA, 4); |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1785 | switch (sd->sensor) { |
| 1786 | case SENSOR_OV7630: |
| 1787 | case SENSOR_OV7648: |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 1788 | case SENSOR_OV7660: |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 1789 | reg_w(gspca_dev, 0xce, CE_ov76xx, 4); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1790 | break; |
| 1791 | default: |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1792 | reg_w(gspca_dev, 0xce, CE, 4); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1793 | /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */ |
| 1794 | break; |
| 1795 | } |
| 1796 | |
| 1797 | /* here change size mode 0 -> VGA; 1 -> CIF */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1798 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; |
| 1799 | reg_w1(gspca_dev, 0x18, sd->reg18); |
| 1800 | setjpegqual(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1801 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1802 | reg_w1(gspca_dev, 0x17, reg17); |
Jean-Francois Moine | 1432f30 | 2008-11-21 04:34:15 -0300 | [diff] [blame] | 1803 | reg_w1(gspca_dev, 0x01, reg1); |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 1804 | switch (sd->sensor) { |
Jean-Francois Moine | 79a9098 | 2008-10-05 04:21:24 -0300 | [diff] [blame] | 1805 | case SENSOR_OV7630: |
| 1806 | setvflip(sd); |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 1807 | break; |
| 1808 | } |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1809 | setbrightness(gspca_dev); |
| 1810 | setcontrast(gspca_dev); |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1811 | setautogain(gspca_dev); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 1812 | setfreq(gspca_dev); |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 1813 | return 0; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | static void sd_stopN(struct gspca_dev *gspca_dev) |
| 1817 | { |
| 1818 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1819 | static const u8 stophv7131[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1820 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1821 | static const u8 stopmi0360[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1822 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1823 | static const u8 stopov7648[] = |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1824 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1825 | u8 data; |
| 1826 | const u8 *sn9c1xx; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1827 | |
| 1828 | data = 0x0b; |
| 1829 | switch (sd->sensor) { |
| 1830 | case SENSOR_HV7131R: |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1831 | i2c_w8(gspca_dev, stophv7131); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1832 | data = 0x2b; |
| 1833 | break; |
| 1834 | case SENSOR_MI0360: |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1835 | i2c_w8(gspca_dev, stopmi0360); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1836 | data = 0x29; |
| 1837 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1838 | case SENSOR_OV7648: |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1839 | i2c_w8(gspca_dev, stopov7648); |
| 1840 | /* fall thru */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1841 | case SENSOR_MT9V111: |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 1842 | case SENSOR_OV7630: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1843 | data = 0x29; |
| 1844 | break; |
| 1845 | default: |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1846 | /* case SENSOR_MO4000: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1847 | /* case SENSOR_OV7660: */ |
| 1848 | break; |
| 1849 | } |
| 1850 | sn9c1xx = sn_tb[(int) sd->sensor]; |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1851 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
| 1852 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); |
| 1853 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
| 1854 | reg_w1(gspca_dev, 0x01, data); |
Jean-Francois Moine | 759aa3c | 2008-09-03 16:48:03 -0300 | [diff] [blame] | 1855 | reg_w1(gspca_dev, 0xf1, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1856 | } |
| 1857 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1858 | static void sd_stop0(struct gspca_dev *gspca_dev) |
| 1859 | { |
| 1860 | struct sd *sd = (struct sd *) gspca_dev; |
| 1861 | |
| 1862 | kfree(sd->jpeg_hdr); |
| 1863 | } |
| 1864 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1865 | static void do_autogain(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1866 | { |
| 1867 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1868 | int delta; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1869 | int expotimes; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1870 | u8 luma_mean = 130; |
| 1871 | u8 luma_delta = 20; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1872 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1873 | /* Thanks S., without your advice, autobright should not work :) */ |
| 1874 | if (sd->ag_cnt < 0) |
| 1875 | return; |
| 1876 | if (--sd->ag_cnt >= 0) |
| 1877 | return; |
| 1878 | sd->ag_cnt = AG_CNT_START; |
| 1879 | |
| 1880 | delta = atomic_read(&sd->avg_lum); |
| 1881 | PDEBUG(D_FRAM, "mean lum %d", delta); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1882 | if (delta < luma_mean - luma_delta || |
| 1883 | delta > luma_mean + luma_delta) { |
| 1884 | switch (sd->sensor) { |
| 1885 | case SENSOR_HV7131R: |
| 1886 | expotimes = sd->exposure >> 8; |
| 1887 | expotimes += (luma_mean - delta) >> 4; |
| 1888 | if (expotimes < 0) |
| 1889 | expotimes = 0; |
| 1890 | sd->exposure = setexposure(gspca_dev, |
| 1891 | (unsigned int) (expotimes << 8)); |
| 1892 | break; |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 1893 | case SENSOR_OM6802: |
| 1894 | expotimes = sd->exposure; |
| 1895 | expotimes += (luma_mean - delta) >> 2; |
| 1896 | if (expotimes < 0) |
| 1897 | expotimes = 0; |
| 1898 | sd->exposure = setexposure(gspca_dev, |
| 1899 | (unsigned int) expotimes); |
| 1900 | setredblue(gspca_dev); |
| 1901 | break; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1902 | default: |
| 1903 | /* case SENSOR_MO4000: */ |
| 1904 | /* case SENSOR_MI0360: */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1905 | /* case SENSOR_MT9V111: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1906 | expotimes = sd->exposure; |
| 1907 | expotimes += (luma_mean - delta) >> 6; |
| 1908 | if (expotimes < 0) |
| 1909 | expotimes = 0; |
| 1910 | sd->exposure = setexposure(gspca_dev, |
| 1911 | (unsigned int) expotimes); |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1912 | setredblue(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1913 | break; |
| 1914 | } |
| 1915 | } |
| 1916 | } |
| 1917 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1918 | /* scan the URB packets */ |
| 1919 | /* This function is run at interrupt level. */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1920 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
| 1921 | struct gspca_frame *frame, /* target */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1922 | u8 *data, /* isoc packet */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1923 | int len) /* iso packet length */ |
| 1924 | { |
| 1925 | struct sd *sd = (struct sd *) gspca_dev; |
| 1926 | int sof, avg_lum; |
| 1927 | |
| 1928 | sof = len - 64; |
| 1929 | if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) { |
| 1930 | |
| 1931 | /* end of frame */ |
| 1932 | gspca_frame_add(gspca_dev, LAST_PACKET, |
| 1933 | frame, data, sof + 2); |
| 1934 | if (sd->ag_cnt < 0) |
| 1935 | return; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1936 | /* w1 w2 w3 */ |
| 1937 | /* w4 w5 w6 */ |
| 1938 | /* w7 w8 */ |
| 1939 | /* w4 */ |
| 1940 | avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6; |
| 1941 | /* w6 */ |
| 1942 | avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6; |
| 1943 | /* w2 */ |
| 1944 | avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6; |
| 1945 | /* w8 */ |
| 1946 | avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6; |
| 1947 | /* w5 */ |
| 1948 | avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4; |
| 1949 | avg_lum >>= 4; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1950 | atomic_set(&sd->avg_lum, avg_lum); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1951 | return; |
| 1952 | } |
| 1953 | if (gspca_dev->last_packet_type == LAST_PACKET) { |
| 1954 | |
| 1955 | /* put the JPEG 422 header */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 1956 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
| 1957 | sd->jpeg_hdr, JPEG_HDR_SZ); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1958 | } |
| 1959 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
| 1960 | } |
| 1961 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1962 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
| 1963 | { |
| 1964 | struct sd *sd = (struct sd *) gspca_dev; |
| 1965 | |
| 1966 | sd->brightness = val; |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1967 | if (gspca_dev->streaming) |
| 1968 | setbrightness(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1969 | return 0; |
| 1970 | } |
| 1971 | |
| 1972 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) |
| 1973 | { |
| 1974 | struct sd *sd = (struct sd *) gspca_dev; |
| 1975 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1976 | *val = sd->brightness; |
| 1977 | return 0; |
| 1978 | } |
| 1979 | |
| 1980 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) |
| 1981 | { |
| 1982 | struct sd *sd = (struct sd *) gspca_dev; |
| 1983 | |
| 1984 | sd->contrast = val; |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1985 | if (gspca_dev->streaming) |
| 1986 | setcontrast(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1987 | return 0; |
| 1988 | } |
| 1989 | |
| 1990 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) |
| 1991 | { |
| 1992 | struct sd *sd = (struct sd *) gspca_dev; |
| 1993 | |
| 1994 | *val = sd->contrast; |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
| 1998 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) |
| 1999 | { |
| 2000 | struct sd *sd = (struct sd *) gspca_dev; |
| 2001 | |
| 2002 | sd->colors = val; |
| 2003 | if (gspca_dev->streaming) |
| 2004 | setcolors(gspca_dev); |
| 2005 | return 0; |
| 2006 | } |
| 2007 | |
| 2008 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) |
| 2009 | { |
| 2010 | struct sd *sd = (struct sd *) gspca_dev; |
| 2011 | |
| 2012 | *val = sd->colors; |
| 2013 | return 0; |
| 2014 | } |
| 2015 | |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 2016 | static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val) |
| 2017 | { |
| 2018 | struct sd *sd = (struct sd *) gspca_dev; |
| 2019 | |
| 2020 | sd->blue = val; |
| 2021 | if (gspca_dev->streaming) |
| 2022 | setredblue(gspca_dev); |
| 2023 | return 0; |
| 2024 | } |
| 2025 | |
| 2026 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val) |
| 2027 | { |
| 2028 | struct sd *sd = (struct sd *) gspca_dev; |
| 2029 | |
| 2030 | *val = sd->blue; |
| 2031 | return 0; |
| 2032 | } |
| 2033 | |
| 2034 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val) |
| 2035 | { |
| 2036 | struct sd *sd = (struct sd *) gspca_dev; |
| 2037 | |
| 2038 | sd->red = val; |
| 2039 | if (gspca_dev->streaming) |
| 2040 | setredblue(gspca_dev); |
| 2041 | return 0; |
| 2042 | } |
| 2043 | |
| 2044 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val) |
| 2045 | { |
| 2046 | struct sd *sd = (struct sd *) gspca_dev; |
| 2047 | |
| 2048 | *val = sd->red; |
| 2049 | return 0; |
| 2050 | } |
| 2051 | |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 2052 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val) |
| 2053 | { |
| 2054 | struct sd *sd = (struct sd *) gspca_dev; |
| 2055 | |
| 2056 | sd->gamma = val; |
| 2057 | if (gspca_dev->streaming) |
| 2058 | setgamma(gspca_dev); |
| 2059 | return 0; |
| 2060 | } |
| 2061 | |
| 2062 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) |
| 2063 | { |
| 2064 | struct sd *sd = (struct sd *) gspca_dev; |
| 2065 | |
| 2066 | *val = sd->gamma; |
| 2067 | return 0; |
| 2068 | } |
| 2069 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2070 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
| 2071 | { |
| 2072 | struct sd *sd = (struct sd *) gspca_dev; |
| 2073 | |
| 2074 | sd->autogain = val; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2075 | if (gspca_dev->streaming) |
| 2076 | setautogain(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2077 | return 0; |
| 2078 | } |
| 2079 | |
| 2080 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) |
| 2081 | { |
| 2082 | struct sd *sd = (struct sd *) gspca_dev; |
| 2083 | |
| 2084 | *val = sd->autogain; |
| 2085 | return 0; |
| 2086 | } |
| 2087 | |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 2088 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) |
| 2089 | { |
| 2090 | struct sd *sd = (struct sd *) gspca_dev; |
| 2091 | |
| 2092 | sd->vflip = val; |
Jean-Francois Moine | 79a9098 | 2008-10-05 04:21:24 -0300 | [diff] [blame] | 2093 | if (gspca_dev->streaming) |
| 2094 | setvflip(sd); |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 2095 | return 0; |
| 2096 | } |
| 2097 | |
| 2098 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) |
| 2099 | { |
| 2100 | struct sd *sd = (struct sd *) gspca_dev; |
| 2101 | |
| 2102 | *val = sd->vflip; |
| 2103 | return 0; |
| 2104 | } |
| 2105 | |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 2106 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val) |
| 2107 | { |
| 2108 | struct sd *sd = (struct sd *) gspca_dev; |
| 2109 | |
| 2110 | sd->infrared = val; |
| 2111 | if (gspca_dev->streaming) |
| 2112 | setinfrared(sd); |
| 2113 | return 0; |
| 2114 | } |
| 2115 | |
| 2116 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) |
| 2117 | { |
| 2118 | struct sd *sd = (struct sd *) gspca_dev; |
| 2119 | |
| 2120 | *val = sd->infrared; |
| 2121 | return 0; |
| 2122 | } |
| 2123 | |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2124 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) |
| 2125 | { |
| 2126 | struct sd *sd = (struct sd *) gspca_dev; |
| 2127 | |
| 2128 | sd->freq = val; |
| 2129 | if (gspca_dev->streaming) |
| 2130 | setfreq(gspca_dev); |
| 2131 | return 0; |
| 2132 | } |
| 2133 | |
| 2134 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) |
| 2135 | { |
| 2136 | struct sd *sd = (struct sd *) gspca_dev; |
| 2137 | |
| 2138 | *val = sd->freq; |
| 2139 | return 0; |
| 2140 | } |
| 2141 | |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 2142 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, |
| 2143 | struct v4l2_jpegcompression *jcomp) |
| 2144 | { |
| 2145 | struct sd *sd = (struct sd *) gspca_dev; |
| 2146 | |
| 2147 | if (jcomp->quality < QUALITY_MIN) |
| 2148 | sd->quality = QUALITY_MIN; |
| 2149 | else if (jcomp->quality > QUALITY_MAX) |
| 2150 | sd->quality = QUALITY_MAX; |
| 2151 | else |
| 2152 | sd->quality = jcomp->quality; |
| 2153 | if (gspca_dev->streaming) |
| 2154 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
| 2155 | return 0; |
| 2156 | } |
| 2157 | |
| 2158 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, |
| 2159 | struct v4l2_jpegcompression *jcomp) |
| 2160 | { |
| 2161 | struct sd *sd = (struct sd *) gspca_dev; |
| 2162 | |
| 2163 | memset(jcomp, 0, sizeof *jcomp); |
| 2164 | jcomp->quality = sd->quality; |
| 2165 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT |
| 2166 | | V4L2_JPEG_MARKER_DQT; |
| 2167 | return 0; |
| 2168 | } |
| 2169 | |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2170 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
| 2171 | struct v4l2_querymenu *menu) |
| 2172 | { |
| 2173 | switch (menu->id) { |
| 2174 | case V4L2_CID_POWER_LINE_FREQUENCY: |
| 2175 | switch (menu->index) { |
| 2176 | case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ |
| 2177 | strcpy((char *) menu->name, "NoFliker"); |
| 2178 | return 0; |
| 2179 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ |
| 2180 | strcpy((char *) menu->name, "50 Hz"); |
| 2181 | return 0; |
| 2182 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ |
| 2183 | strcpy((char *) menu->name, "60 Hz"); |
| 2184 | return 0; |
| 2185 | } |
| 2186 | break; |
| 2187 | } |
| 2188 | return -EINVAL; |
| 2189 | } |
| 2190 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2191 | /* sub-driver description */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 2192 | static const struct sd_desc sd_desc = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2193 | .name = MODULE_NAME, |
| 2194 | .ctrls = sd_ctrls, |
| 2195 | .nctrls = ARRAY_SIZE(sd_ctrls), |
| 2196 | .config = sd_config, |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 2197 | .init = sd_init, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2198 | .start = sd_start, |
| 2199 | .stopN = sd_stopN, |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2200 | .stop0 = sd_stop0, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2201 | .pkt_scan = sd_pkt_scan, |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2202 | .dq_callback = do_autogain, |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 2203 | .get_jcomp = sd_get_jcomp, |
| 2204 | .set_jcomp = sd_set_jcomp, |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2205 | .querymenu = sd_querymenu, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2206 | }; |
| 2207 | |
| 2208 | /* -- module initialisation -- */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2209 | #define BSI(bridge, sensor, i2c_addr) \ |
| 2210 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
| 2211 | | (SENSOR_ ## sensor << 8) \ |
| 2212 | | (i2c_addr) |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 2213 | static const __devinitdata struct usb_device_id device_table[] = { |
Hans de Goede | 222a07f | 2008-09-03 17:12:20 -0300 | [diff] [blame] | 2214 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2215 | {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)}, |
Jean-Francois Moine | 7b53739 | 2008-09-07 11:56:49 -0300 | [diff] [blame] | 2216 | {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)}, |
Jean-Francois Moine | a08d81a | 2008-11-22 04:53:31 -0300 | [diff] [blame] | 2217 | #endif |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2218 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, |
| 2219 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, |
| 2220 | {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)}, |
Jean-Francois Moine | 7e21fda | 2008-11-10 04:45:51 -0300 | [diff] [blame] | 2221 | {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)}, |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2222 | {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)}, |
Jean-Francois Moine | 3319dc9 | 2008-12-01 14:44:02 -0300 | [diff] [blame] | 2223 | {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)}, |
Jani Monoses | f8eaaf4f | 2009-05-07 03:32:27 -0300 | [diff] [blame] | 2224 | {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2225 | /* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x21)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2226 | {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2227 | /* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x21)}, */ |
| 2228 | /* {USB_DEVICE(0x0c45, 0x607b), BSI(SN9C102P, OV7660, 0x21)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2229 | {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2230 | /* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x21)}, */ |
Jean-Francois Moine | 661ab25 | 2009-01-29 16:03:19 -0300 | [diff] [blame] | 2231 | {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2232 | /* {USB_DEVICE(0x0c45, 0x60c2), BSI(SN9C105, P1030xC, 0x??)}, */ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 2233 | /* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6802, 0x34)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2234 | /* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */ |
| 2235 | {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)}, |
| 2236 | /* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */ |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2237 | /* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x21)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2238 | {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)}, |
Jean-Francois Moine | 3c41cb7 | 2008-09-10 02:57:09 -0300 | [diff] [blame] | 2239 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
Jean-Francois Moine | f077b0a | 2009-09-01 14:52:04 -0300 | [diff] [blame] | 2240 | {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)}, |
Jean-Francois Moine | 3c41cb7 | 2008-09-10 02:57:09 -0300 | [diff] [blame] | 2241 | {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)}, |
| 2242 | #endif |
Jean-Francois Moine | ceec80e | 2009-05-09 06:21:35 -0300 | [diff] [blame] | 2243 | {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/ |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2244 | /* {USB_DEVICE(0x0c45, 0x6102), BSI(SN9C120, P1030xC, ??)}, */ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 2245 | /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6802, 0x34)}, */ |
Jean-Francois Moine | ceec80e | 2009-05-09 06:21:35 -0300 | [diff] [blame] | 2246 | {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/ |
| 2247 | {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/ |
| 2248 | {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/ |
| 2249 | {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/ |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 2250 | /* {USB_DEVICE(0x0c45, 0x610f), BSI(SN9C120, S5K53BEB, 0x??)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2251 | /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ |
| 2252 | /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 2253 | {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C120, OM6802, 0x34)}, /*sn9c325?*/ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 2254 | /*bw600.inf:*/ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 2255 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2256 | {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)}, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2257 | {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)}, |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2258 | /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */ |
Hans de Goede | 222a07f | 2008-09-03 17:12:20 -0300 | [diff] [blame] | 2259 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2260 | {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, |
Hans de Goede | 222a07f | 2008-09-03 17:12:20 -0300 | [diff] [blame] | 2261 | #endif |
Denis Loginov | 6baefab | 2009-07-28 03:39:10 -0300 | [diff] [blame] | 2262 | /* {USB_DEVICE(0x0c45, 0x6132), BSI(SN9C120, OV7670, 0x21)}, */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2263 | {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, |
Jean-Francois Moine | 821ced2 | 2008-11-11 07:10:11 -0300 | [diff] [blame] | 2264 | {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)}, |
Hans de Goede | 222a07f | 2008-09-03 17:12:20 -0300 | [diff] [blame] | 2265 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2266 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, |
Jean-Francois Moine | 8d97770 | 2009-02-19 15:34:48 -0300 | [diff] [blame] | 2267 | #endif |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2268 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, |
Hans de Goede | cc7b5b5 | 2009-06-18 05:14:42 -0300 | [diff] [blame] | 2269 | {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)}, |
Denis Loginov | 6baefab | 2009-07-28 03:39:10 -0300 | [diff] [blame] | 2270 | /* {USB_DEVICE(0x0c45, 0x6142), BSI(SN9C120, PO2030N, ??)}, *sn9c120b*/ |
| 2271 | {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, /*sn9c120b*/ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame^] | 2272 | {USB_DEVICE(0x0c45, 0x6148), BSI(SN9C120, OM6802, 0x34)}, /*sn9c120b*/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2273 | {} |
| 2274 | }; |
| 2275 | MODULE_DEVICE_TABLE(usb, device_table); |
| 2276 | |
| 2277 | /* -- device connect -- */ |
| 2278 | static int sd_probe(struct usb_interface *intf, |
| 2279 | const struct usb_device_id *id) |
| 2280 | { |
| 2281 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
| 2282 | THIS_MODULE); |
| 2283 | } |
| 2284 | |
| 2285 | static struct usb_driver sd_driver = { |
| 2286 | .name = MODULE_NAME, |
| 2287 | .id_table = device_table, |
| 2288 | .probe = sd_probe, |
| 2289 | .disconnect = gspca_disconnect, |
Jean-Francois Moine | 6a70974 | 2008-09-03 16:48:10 -0300 | [diff] [blame] | 2290 | #ifdef CONFIG_PM |
| 2291 | .suspend = gspca_suspend, |
| 2292 | .resume = gspca_resume, |
| 2293 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2294 | }; |
| 2295 | |
| 2296 | /* -- module insert / remove -- */ |
| 2297 | static int __init sd_mod_init(void) |
| 2298 | { |
Alexey Klimov | f69e952 | 2009-01-01 13:02:07 -0300 | [diff] [blame] | 2299 | int ret; |
| 2300 | ret = usb_register(&sd_driver); |
| 2301 | if (ret < 0) |
Alexey Klimov | e6b1484 | 2009-01-01 13:04:58 -0300 | [diff] [blame] | 2302 | return ret; |
Jean-Francois Moine | 10b0e96 | 2008-07-22 05:35:10 -0300 | [diff] [blame] | 2303 | info("registered"); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2304 | return 0; |
| 2305 | } |
| 2306 | static void __exit sd_mod_exit(void) |
| 2307 | { |
| 2308 | usb_deregister(&sd_driver); |
| 2309 | info("deregistered"); |
| 2310 | } |
| 2311 | |
| 2312 | module_init(sd_mod_init); |
| 2313 | module_exit(sd_mod_exit); |