Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1 | /* |
Jean-Francois Moine | 5b34e3e | 2009-11-02 10:00:48 -0300 | [diff] [blame] | 2 | * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 3 | * |
Jean-François Moine | b813b0c | 2011-08-10 05:54:34 -0300 | [diff] [blame] | 4 | * Copyright (C) 2009-2011 Jean-François Moine <http://moinejf.free.fr> |
Jean-Francois Moine | 5b34e3e | 2009-11-02 10:00:48 -0300 | [diff] [blame] | 5 | * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 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 | |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 23 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 24 | #define MODULE_NAME "sonixj" |
| 25 | |
Hans de Goede | 9712a8b | 2010-01-31 12:54:29 -0300 | [diff] [blame] | 26 | #include <linux/input.h> |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 27 | #include "gspca.h" |
| 28 | #include "jpeg.h" |
| 29 | |
Jean-François Moine | 27c6f9e | 2010-04-02 06:59:13 -0300 | [diff] [blame] | 30 | MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
| 32 | MODULE_LICENSE("GPL"); |
| 33 | |
| 34 | /* specific webcam descriptor */ |
| 35 | struct sd { |
| 36 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
| 37 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 38 | atomic_t avg_lum; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 39 | struct v4l2_ctrl *brightness; |
| 40 | struct v4l2_ctrl *contrast; |
| 41 | struct v4l2_ctrl *saturation; |
| 42 | struct { /* red/blue balance control cluster */ |
| 43 | struct v4l2_ctrl *red_bal; |
| 44 | struct v4l2_ctrl *blue_bal; |
| 45 | }; |
| 46 | struct { /* hflip/vflip control cluster */ |
| 47 | struct v4l2_ctrl *vflip; |
| 48 | struct v4l2_ctrl *hflip; |
| 49 | }; |
| 50 | struct v4l2_ctrl *gamma; |
| 51 | struct v4l2_ctrl *illum; |
| 52 | struct v4l2_ctrl *sharpness; |
| 53 | struct v4l2_ctrl *freq; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 54 | u32 exposure; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 55 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 56 | struct work_struct work; |
| 57 | struct workqueue_struct *work_thread; |
| 58 | |
| 59 | u32 pktsz; /* (used by pkt_scan) */ |
| 60 | u16 npkt; |
Hans Petter Selasky | 67e27c74 | 2011-05-23 08:09:18 -0300 | [diff] [blame] | 61 | s8 nchg; |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 62 | s8 short_mark; |
| 63 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 64 | u8 quality; /* image quality */ |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 65 | #define QUALITY_MIN 25 |
| 66 | #define QUALITY_MAX 90 |
| 67 | #define QUALITY_DEF 70 |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 68 | |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 69 | u8 reg01; |
| 70 | u8 reg17; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 71 | u8 reg18; |
Jean-Francois Moine | c6c1433 | 2010-12-14 16:15:37 -0300 | [diff] [blame] | 72 | u8 flags; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 73 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 74 | s8 ag_cnt; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 75 | #define AG_CNT_START 13 |
| 76 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 77 | u8 bridge; |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 78 | #define BRIDGE_SN9C102P 0 |
| 79 | #define BRIDGE_SN9C105 1 |
| 80 | #define BRIDGE_SN9C110 2 |
| 81 | #define BRIDGE_SN9C120 3 |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 82 | u8 sensor; /* Type of image sensor chip */ |
Jean-François Moine | 11ce884 | 2010-07-26 06:39:40 -0300 | [diff] [blame] | 83 | u8 i2c_addr; |
| 84 | |
| 85 | u8 jpeg_hdr[JPEG_HDR_SZ]; |
| 86 | }; |
| 87 | enum sensors { |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 88 | SENSOR_ADCM1700, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 89 | SENSOR_GC0307, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 90 | SENSOR_HV7131R, |
| 91 | SENSOR_MI0360, |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 92 | SENSOR_MI0360B, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 93 | SENSOR_MO4000, |
| 94 | SENSOR_MT9V111, |
| 95 | SENSOR_OM6802, |
| 96 | SENSOR_OV7630, |
| 97 | SENSOR_OV7648, |
| 98 | SENSOR_OV7660, |
| 99 | SENSOR_PO1030, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 100 | SENSOR_PO2030N, |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 101 | SENSOR_SOI768, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 102 | SENSOR_SP80708, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 103 | }; |
| 104 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 105 | static void qual_upd(struct work_struct *work); |
| 106 | |
Jean-Francois Moine | b2272a4 | 2010-12-14 16:16:16 -0300 | [diff] [blame] | 107 | /* device flags */ |
Jean-François Moine | 3afef85 | 2011-01-13 06:39:11 -0300 | [diff] [blame] | 108 | #define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */ |
| 109 | #define F_ILLUM 0x02 /* presence of illuminator */ |
Jean-Francois Moine | b2272a4 | 2010-12-14 16:16:16 -0300 | [diff] [blame] | 110 | |
Jean-Francois Moine | 4fd350ee | 2010-12-14 16:16:58 -0300 | [diff] [blame] | 111 | /* sn9c1xx definitions */ |
| 112 | /* register 0x01 */ |
| 113 | #define S_PWR_DN 0x01 /* sensor power down */ |
| 114 | #define S_PDN_INV 0x02 /* inverse pin S_PWR_DN */ |
| 115 | #define V_TX_EN 0x04 /* video transfer enable */ |
| 116 | #define LED 0x08 /* output to pin LED */ |
| 117 | #define SCL_SEL_OD 0x20 /* open-drain mode */ |
| 118 | #define SYS_SEL_48M 0x40 /* system clock 0: 24MHz, 1: 48MHz */ |
| 119 | /* register 0x17 */ |
| 120 | #define MCK_SIZE_MASK 0x1f /* sensor master clock */ |
| 121 | #define SEN_CLK_EN 0x20 /* enable sensor clock */ |
| 122 | #define DEF_EN 0x80 /* defect pixel by 0: soft, 1: hard */ |
| 123 | |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 124 | static const struct v4l2_pix_format cif_mode[] = { |
| 125 | {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 126 | .bytesperline = 352, |
| 127 | .sizeimage = 352 * 288 * 4 / 8 + 590, |
| 128 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 129 | .priv = 0}, |
| 130 | }; |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 131 | static const struct v4l2_pix_format vga_mode[] = { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 132 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 133 | .bytesperline = 160, |
Jean-Francois Moine | 5d05294 | 2008-09-03 16:48:09 -0300 | [diff] [blame] | 134 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 135 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 136 | .priv = 2}, |
| 137 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 138 | .bytesperline = 320, |
| 139 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
| 140 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 141 | .priv = 1}, |
| 142 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 143 | .bytesperline = 640, |
Hans de Goede | a5d1cc3 | 2009-06-18 06:03:20 -0300 | [diff] [blame] | 144 | /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */ |
| 145 | .sizeimage = 640 * 480 * 3 / 4 + 590, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 146 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 147 | .priv = 0}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 148 | }; |
| 149 | |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 150 | static const u8 sn_adcm1700[0x1c] = { |
| 151 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 152 | 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 153 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 154 | 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 155 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 156 | 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42, |
| 157 | /* reg18 reg19 reg1a reg1b */ |
| 158 | 0x06, 0x00, 0x00, 0x00 |
| 159 | }; |
| 160 | |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 161 | static const u8 sn_gc0307[0x1c] = { |
| 162 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 163 | 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00, |
| 164 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 165 | 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 166 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 167 | 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02, |
| 168 | /* reg18 reg19 reg1a reg1b */ |
| 169 | 0x06, 0x00, 0x00, 0x00 |
| 170 | }; |
| 171 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 172 | static const u8 sn_hv7131[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 173 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-François Moine | 19697b5 | 2010-07-14 06:33:51 -0300 | [diff] [blame] | 174 | 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 175 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 176 | 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 177 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 178 | 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 179 | /* reg18 reg19 reg1a reg1b */ |
| 180 | 0x0a, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 181 | }; |
| 182 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 183 | static const u8 sn_mi0360[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 184 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-François Moine | 20c957b | 2011-02-10 13:18:58 -0300 | [diff] [blame] | 185 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 186 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 187 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 188 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 189 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 190 | /* reg18 reg19 reg1a reg1b */ |
| 191 | 0x06, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 192 | }; |
| 193 | |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 194 | static const u8 sn_mi0360b[0x1c] = { |
| 195 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 196 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
| 197 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 198 | 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 199 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 200 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40, |
| 201 | /* reg18 reg19 reg1a reg1b */ |
| 202 | 0x06, 0x00, 0x00, 0x00 |
| 203 | }; |
| 204 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 205 | static const u8 sn_mo4000[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 206 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 207 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 208 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 209 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 210 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 211 | 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 212 | /* reg18 reg19 reg1a reg1b */ |
| 213 | 0x08, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 214 | }; |
| 215 | |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 216 | static const u8 sn_mt9v111[0x1c] = { |
| 217 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 218 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 219 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 220 | 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 221 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 222 | 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40, |
| 223 | /* reg18 reg19 reg1a reg1b */ |
| 224 | 0x06, 0x00, 0x00, 0x00 |
| 225 | }; |
| 226 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 227 | static const u8 sn_om6802[0x1c] = { |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 228 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 229 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19, |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 230 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 231 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 232 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 233 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 234 | /* reg18 reg19 reg1a reg1b */ |
| 235 | 0x05, 0x00, 0x00, 0x00 |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 236 | }; |
| 237 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 238 | static const u8 sn_ov7630[0x1c] = { |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 239 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-François Moine | 0a85c74 | 2010-04-25 14:33:31 -0300 | [diff] [blame] | 240 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 241 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 242 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 243 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 244 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 245 | /* reg18 reg19 reg1a reg1b */ |
| 246 | 0x0b, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 247 | }; |
| 248 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 249 | static const u8 sn_ov7648[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 250 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 251 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 252 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 253 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 254 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 255 | 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 256 | /* reg18 reg19 reg1a reg1b */ |
| 257 | 0x0b, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 258 | }; |
| 259 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 260 | static const u8 sn_ov7660[0x1c] = { |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 261 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
Jean-Francois Moine | c8b9b2ca | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 262 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 263 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | c8b9b2ca | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 264 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 265 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 266 | 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 267 | /* reg18 reg19 reg1a reg1b */ |
| 268 | 0x07, 0x00, 0x00, 0x00 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 269 | }; |
| 270 | |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 271 | static const u8 sn_po1030[0x1c] = { |
| 272 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 273 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 274 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 275 | 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 276 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 277 | 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00, |
| 278 | /* reg18 reg19 reg1a reg1b */ |
| 279 | 0x07, 0x00, 0x00, 0x00 |
| 280 | }; |
| 281 | |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 282 | static const u8 sn_po2030n[0x1c] = { |
| 283 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 284 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
| 285 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 286 | 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 287 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 288 | 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00, |
| 289 | /* reg18 reg19 reg1a reg1b */ |
| 290 | 0x07, 0x00, 0x00, 0x00 |
| 291 | }; |
| 292 | |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 293 | static const u8 sn_soi768[0x1c] = { |
| 294 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 295 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, |
| 296 | /* reg8 reg9 rega regb regc regd rege regf */ |
| 297 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 298 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 299 | 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00, |
| 300 | /* reg18 reg19 reg1a reg1b */ |
| 301 | 0x07, 0x00, 0x00, 0x00 |
| 302 | }; |
| 303 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 304 | static const u8 sn_sp80708[0x1c] = { |
| 305 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
| 306 | 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, |
| 307 | /* reg8 reg9 rega regb regc regd rege regf */ |
Jean-Francois Moine | 98941e4 | 2009-11-02 09:56:59 -0300 | [diff] [blame] | 308 | 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 309 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
| 310 | 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00, |
| 311 | /* reg18 reg19 reg1a reg1b */ |
| 312 | 0x07, 0x00, 0x00, 0x00 |
| 313 | }; |
| 314 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 315 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 316 | static const u8 *sn_tb[] = { |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 317 | [SENSOR_ADCM1700] = sn_adcm1700, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 318 | [SENSOR_GC0307] = sn_gc0307, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 319 | [SENSOR_HV7131R] = sn_hv7131, |
| 320 | [SENSOR_MI0360] = sn_mi0360, |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 321 | [SENSOR_MI0360B] = sn_mi0360b, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 322 | [SENSOR_MO4000] = sn_mo4000, |
| 323 | [SENSOR_MT9V111] = sn_mt9v111, |
| 324 | [SENSOR_OM6802] = sn_om6802, |
| 325 | [SENSOR_OV7630] = sn_ov7630, |
| 326 | [SENSOR_OV7648] = sn_ov7648, |
| 327 | [SENSOR_OV7660] = sn_ov7660, |
| 328 | [SENSOR_PO1030] = sn_po1030, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 329 | [SENSOR_PO2030N] = sn_po2030n, |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 330 | [SENSOR_SOI768] = sn_soi768, |
| 331 | [SENSOR_SP80708] = sn_sp80708, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 332 | }; |
| 333 | |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 334 | /* default gamma table */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 335 | static const u8 gamma_def[17] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 336 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
| 337 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
| 338 | }; |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 339 | /* gamma for sensor ADCM1700 */ |
| 340 | static const u8 gamma_spec_0[17] = { |
| 341 | 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4, |
| 342 | 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5 |
| 343 | }; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 344 | /* gamma for sensors HV7131R and MT9V111 */ |
| 345 | static const u8 gamma_spec_1[17] = { |
| 346 | 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d, |
| 347 | 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5 |
| 348 | }; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 349 | /* gamma for sensor GC0307 */ |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 350 | static const u8 gamma_spec_2[17] = { |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 351 | 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab, |
| 352 | 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb |
| 353 | }; |
| 354 | /* gamma for sensor SP80708 */ |
| 355 | static const u8 gamma_spec_3[17] = { |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 356 | 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab, |
| 357 | 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6 |
| 358 | }; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 359 | |
Jean-Francois Moine | 803f9cc | 2008-10-04 14:17:02 -0300 | [diff] [blame] | 360 | /* color matrix and offsets */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 361 | static const u8 reg84[] = { |
Jean-Francois Moine | 803f9cc | 2008-10-04 14:17:02 -0300 | [diff] [blame] | 362 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ |
| 363 | 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */ |
| 364 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ |
| 365 | 0x00, 0x00, 0x00 /* YUV offsets */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 366 | }; |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 367 | |
| 368 | #define DELAY 0xdd |
| 369 | |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 370 | static const u8 adcm1700_sensor_init[][8] = { |
| 371 | {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 372 | {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 373 | {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 374 | {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 375 | {DELAY, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 376 | {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10}, |
| 377 | {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10}, |
| 378 | {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10}, |
| 379 | {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10}, |
| 380 | {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 381 | {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 382 | {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 383 | {DELAY, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 384 | {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 385 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 386 | {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 387 | {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 388 | {} |
| 389 | }; |
| 390 | static const u8 adcm1700_sensor_param1[][8] = { |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 391 | {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 392 | {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10}, |
| 393 | |
| 394 | {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 395 | {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 396 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 397 | {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 398 | {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 399 | |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 400 | {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 401 | {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 402 | {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 403 | {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 404 | {} |
| 405 | }; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 406 | static const u8 gc0307_sensor_init[][8] = { |
| 407 | {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 408 | {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10}, |
| 409 | {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10}, |
| 410 | {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10}, |
| 411 | {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 412 | {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 413 | {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 414 | {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10}, |
| 415 | {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 416 | {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 417 | {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 418 | {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 419 | {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 420 | {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10}, |
| 421 | {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 422 | {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 423 | {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10}, |
| 424 | {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 425 | {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10}, |
| 426 | {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 427 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 428 | {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 429 | {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10}, |
| 430 | {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10}, |
| 431 | {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10}, |
| 432 | {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10}, |
| 433 | {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10}, |
| 434 | {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10}, |
| 435 | {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10}, |
| 436 | {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10}, |
| 437 | {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10}, |
| 438 | {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10}, |
| 439 | {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 440 | {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10}, |
| 441 | {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10}, |
| 442 | {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10}, |
| 443 | {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10}, |
| 444 | {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10}, |
| 445 | {} |
| 446 | }; |
| 447 | static const u8 gc0307_sensor_param1[][8] = { |
| 448 | {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10}, |
| 449 | {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10}, |
| 450 | {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10}, |
| 451 | {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10}, |
| 452 | /*param3*/ |
| 453 | {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10}, |
| 454 | {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10}, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 455 | {} |
| 456 | }; |
| 457 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 458 | static const u8 hv7131r_sensor_init[][8] = { |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 459 | {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
| 460 | {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10}, |
| 461 | {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10}, |
| 462 | /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
| 463 | {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 464 | {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
| 465 | /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 466 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 467 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 468 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 469 | {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10}, |
| 470 | {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10}, |
| 471 | {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10}, |
| 472 | {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10}, |
| 473 | {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */ |
| 474 | {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] | 475 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 476 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 477 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 478 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 479 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 480 | {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 481 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 482 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 483 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 484 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
| 485 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 486 | {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 487 | {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 488 | /* set sensor clock */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 489 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 490 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 491 | static const u8 mi0360_sensor_init[][8] = { |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 492 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 493 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 494 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 495 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, |
| 496 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
| 497 | {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10}, |
| 498 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 499 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 500 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 501 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 502 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 503 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 504 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 505 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 506 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 507 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 508 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 509 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 510 | {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
| 511 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 512 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 513 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, |
Jean-François Moine | b813b0c | 2011-08-10 05:54:34 -0300 | [diff] [blame] | 514 | {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10}, |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 515 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 516 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, |
| 517 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, |
| 518 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, |
| 519 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, |
| 520 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, |
| 521 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 522 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 523 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, |
| 524 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 525 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 526 | {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
| 527 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
| 528 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, |
| 529 | {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10}, |
| 530 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 531 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 532 | {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */ |
| 533 | {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10}, |
| 534 | {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, |
| 535 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 536 | |
Jean-Francois Moine | 8c2ba44 | 2009-01-13 05:55:40 -0300 | [diff] [blame] | 537 | {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10}, |
| 538 | {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */ |
| 539 | /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */ |
| 540 | /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ |
| 541 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ |
| 542 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 543 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 544 | }; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 545 | static const u8 mi0360b_sensor_init[][8] = { |
| 546 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 547 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 548 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/ |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 549 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 550 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/ |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 551 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, |
| 552 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
| 553 | {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 554 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 555 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 556 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 557 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 558 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 559 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 560 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 561 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 562 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 563 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 564 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 565 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 566 | {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
| 567 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 568 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 569 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, |
| 570 | {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10}, |
| 571 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 572 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, |
| 573 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, |
| 574 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, |
| 575 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, |
| 576 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, |
| 577 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 578 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 579 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, |
| 580 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, |
| 581 | |
| 582 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
| 583 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
| 584 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, |
| 585 | {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, |
| 586 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, |
| 587 | {} |
| 588 | }; |
| 589 | static const u8 mi0360b_sensor_param1[][8] = { |
| 590 | {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 591 | {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10}, |
| 592 | {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10}, |
| 593 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ |
| 594 | |
| 595 | {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10}, |
| 596 | {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10}, |
| 597 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ |
| 598 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
| 599 | {} |
| 600 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 601 | static const u8 mo4000_sensor_init[][8] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 602 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 603 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 604 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 605 | {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 606 | {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 607 | {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 608 | {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 609 | {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10}, |
| 610 | {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 611 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 612 | {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 613 | {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 614 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 615 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 616 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 617 | {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 618 | {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 619 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, |
| 620 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 621 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 622 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 623 | }; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 624 | static const u8 mt9v111_sensor_init[][8] = { |
| 625 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 626 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 627 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 628 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ |
| 629 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ |
| 630 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ |
| 631 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ |
| 632 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ |
| 633 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ |
| 634 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ |
| 635 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ |
| 636 | {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */ |
| 637 | {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */ |
| 638 | {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */ |
| 639 | {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */ |
| 640 | {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */ |
| 641 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */ |
| 642 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 643 | {} |
| 644 | }; |
| 645 | static const u8 mt9v111_sensor_param1[][8] = { |
Jean-François Moine | 8046322 | 2011-02-10 07:44:59 -0300 | [diff] [blame] | 646 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xad, 0x10}, /* G1 and B gains */ |
| 647 | {0xd1, 0x5c, 0x2d, 0x00, 0xad, 0x00, 0x33, 0x10}, /* R and G2 gains */ |
| 648 | {0xb1, 0x5c, 0x06, 0x00, 0x40, 0x00, 0x00, 0x10}, /* vert blanking */ |
| 649 | {0xb1, 0x5c, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10}, /* horiz blanking */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 650 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ |
| 651 | {} |
| 652 | }; |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 653 | static const u8 om6802_init0[2][8] = { |
| 654 | /*fixme: variable*/ |
| 655 | {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10}, |
| 656 | {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10}, |
| 657 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 658 | static const u8 om6802_sensor_init[][8] = { |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 659 | {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10}, |
| 660 | /* factory mode */ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 661 | {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 662 | /* output raw RGB */ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 663 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 664 | /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */ |
| 665 | {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 666 | /* auto-exposure speed (0) / white balance mode (auto RGB) */ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 667 | /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 668 | * set color mode */ |
| 669 | /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10}, |
| 670 | * max AGC value in AE */ |
| 671 | /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 672 | * preset AGC */ |
| 673 | /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 674 | * preset brightness */ |
| 675 | /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 676 | * preset contrast */ |
| 677 | /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10}, |
| 678 | * preset gamma */ |
| 679 | {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 680 | /* luminance mode (0x4f -> AutoExpo on) */ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 681 | {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10}, |
| 682 | /* preset shutter */ |
| 683 | /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 684 | * auto frame rate */ |
| 685 | /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 686 | {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 687 | {} |
| 688 | }; |
| 689 | static const u8 om6802_sensor_param1[][8] = { |
| 690 | {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, |
| 691 | {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, |
| 692 | {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 693 | {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 694 | {} |
| 695 | }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 696 | static const u8 ov7630_sensor_init[][8] = { |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 697 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 698 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 699 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 700 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 701 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 702 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 703 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 704 | /* win: i2c_r from 00 to 80 */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 705 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, |
| 706 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, |
Hans de Goede | cc7b5b5 | 2009-06-18 05:14:42 -0300 | [diff] [blame] | 707 | /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30) |
| 708 | 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */ |
| 709 | {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10}, |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 710 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, |
| 711 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, |
| 712 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 713 | {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10}, |
| 714 | {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10}, |
| 715 | {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10}, |
| 716 | {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10}, |
| 717 | {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10}, |
| 718 | {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 719 | {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 720 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 721 | {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10}, |
| 722 | {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 723 | {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10}, |
| 724 | {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10}, |
| 725 | {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10}, |
| 726 | {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10}, |
| 727 | {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10}, |
| 728 | {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10}, |
| 729 | {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10}, |
| 730 | {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10}, |
| 731 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, |
| 732 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
Jean-François Moine | bdd2b93 | 2010-04-25 14:23:39 -0300 | [diff] [blame] | 733 | {} |
| 734 | }; |
| 735 | static const u8 ov7630_sensor_param1[][8] = { |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 736 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 737 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, |
| 738 | /*fixme: + 0x12, 0x04*/ |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 739 | /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN |
| 740 | * set by setvflip */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 741 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
| 742 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 743 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 744 | /* */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 745 | /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
| 746 | /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 747 | /* */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 748 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 91de65a | 2008-09-03 17:12:18 -0300 | [diff] [blame] | 749 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 750 | {} |
| 751 | }; |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 752 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 753 | static const u8 ov7648_sensor_init[][8] = { |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 754 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 755 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 756 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 757 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 758 | {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10}, |
| 759 | {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10}, |
| 760 | {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10}, |
| 761 | {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10}, |
| 762 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 763 | {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10}, |
| 764 | {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10}, |
| 765 | {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10}, |
| 766 | {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10}, |
| 767 | {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10}, |
| 768 | {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10}, |
| 769 | {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10}, |
| 770 | {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10}, |
| 771 | {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10}, |
| 772 | {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10}, |
| 773 | {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10}, |
| 774 | {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10}, |
| 775 | {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10}, |
| 776 | |
| 777 | {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, |
| 778 | /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ |
| 779 | /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 780 | /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 781 | {} |
| 782 | }; |
| 783 | static const u8 ov7648_sensor_param1[][8] = { |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 784 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 785 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN |
| 786 | * set by setvflip */ |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 787 | {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 788 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
| 789 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 790 | /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */ |
| 791 | /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */ |
| 792 | /*...*/ |
| 793 | {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */ |
| 794 | /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 795 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 796 | /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 797 | /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 798 | /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */ |
| 799 | |
| 800 | {} |
| 801 | }; |
| 802 | |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 803 | static const u8 ov7660_sensor_init[][8] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 804 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 805 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 806 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 807 | /* Outformat = rawRGB */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 808 | {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 809 | {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 810 | /* GAIN BLUE RED VREF */ |
| 811 | {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10}, |
| 812 | /* COM 1 BAVE GEAVE AECHH */ |
| 813 | {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */ |
| 814 | {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] | 815 | {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 816 | /* AECH CLKRC COM7 COM8 */ |
| 817 | {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */ |
| 818 | {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10}, |
| 819 | /* HSTART HSTOP VSTRT VSTOP */ |
| 820 | {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */ |
| 821 | {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */ |
| 822 | {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10}, |
| 823 | /* BOS GBOS GROS ROS (BGGR offset) */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 824 | /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */ |
| 825 | {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 826 | /* AEW AEB VPT BBIAS */ |
| 827 | {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10}, |
| 828 | /* GbBIAS RSVD EXHCH EXHCL */ |
| 829 | {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10}, |
| 830 | /* RBIAS ADVFL ASDVFH YAVE */ |
| 831 | {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10}, |
| 832 | /* HSYST HSYEN HREF */ |
| 833 | {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */ |
| 834 | {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10}, |
| 835 | /* ADC ACOM OFON TSLB */ |
| 836 | {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10}, |
| 837 | /* COM11 COM12 COM13 COM14 */ |
| 838 | {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10}, |
| 839 | /* EDGE COM15 COM16 COM17 */ |
| 840 | {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */ |
| 841 | {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */ |
| 842 | {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */ |
| 843 | {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */ |
| 844 | {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */ |
| 845 | {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */ |
| 846 | {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */ |
| 847 | {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */ |
| 848 | {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */ |
| 849 | {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10}, |
| 850 | /* LCC1 LCC2 LCC3 LCC4 */ |
| 851 | {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 852 | {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 853 | {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 854 | /* band gap reference [0:3] DBLV */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 855 | {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */ |
| 856 | {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */ |
| 857 | {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */ |
| 858 | {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */ |
| 859 | {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */ |
| 860 | {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */ |
| 861 | {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */ |
| 862 | {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */ |
| 863 | {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 864 | {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 865 | /* not in all ms-win traces*/ |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 866 | {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 867 | {} |
| 868 | }; |
| 869 | static const u8 ov7660_sensor_param1[][8] = { |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 870 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 871 | /* bits[3..0]reserved */ |
| 872 | {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 873 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 874 | /* VREF vertical frame ctrl */ |
| 875 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 876 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */ |
| 877 | {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */ |
| 878 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */ |
| 879 | {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */ |
| 880 | /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 881 | /****** (some exchanges in the win trace) ******/ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 882 | /*fixme:param2*/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 883 | {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 884 | {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */ |
| 885 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */ |
| 886 | {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */ |
| 887 | /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 888 | /****** (some exchanges in the win trace) ******/ |
Jean-Francois Moine | 738608a | 2008-07-28 06:41:51 -0300 | [diff] [blame] | 889 | /******!! startsensor KO if changed !!****/ |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 890 | /*fixme: param3*/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 891 | {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 892 | {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10}, |
| 893 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 894 | {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 895 | {} |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 896 | }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 897 | |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 898 | static const u8 po1030_sensor_init[][8] = { |
| 899 | /* the sensor registers are described in m5602/m5602_po1030.h */ |
| 900 | {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 901 | {DELAY, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */ |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 902 | {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 903 | {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 904 | {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10}, |
| 905 | {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10}, |
| 906 | {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10}, |
| 907 | {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10}, |
| 908 | {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */ |
| 909 | {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10}, |
| 910 | {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10}, |
| 911 | {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10}, |
| 912 | {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10}, |
| 913 | {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 914 | {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */ |
| 915 | {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10}, |
| 916 | {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */ |
| 917 | {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10}, |
| 918 | {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10}, |
| 919 | {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10}, |
| 920 | {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 921 | {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10}, |
| 922 | {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10}, |
| 923 | {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10}, |
| 924 | {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10}, |
| 925 | {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */ |
| 926 | {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 927 | {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10}, |
| 928 | |
| 929 | {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10}, |
| 930 | {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 931 | {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 932 | {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 933 | {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10}, |
| 934 | {} |
| 935 | }; |
| 936 | static const u8 po1030_sensor_param1[][8] = { |
| 937 | /* from ms-win traces - these values change with auto gain/expo/wb.. */ |
| 938 | {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 939 | {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 940 | /* mean values */ |
| 941 | {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */ |
| 942 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */ |
| 943 | {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */ |
| 944 | |
| 945 | {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */ |
| 946 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */ |
| 947 | {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10}, |
| 948 | /* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */ |
| 949 | {} |
| 950 | }; |
| 951 | |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 952 | static const u8 po2030n_sensor_init[][8] = { |
| 953 | {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10}, |
| 954 | {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 955 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 956 | {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10}, |
| 957 | {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 958 | {DELAY, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 959 | {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10}, |
| 960 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 961 | {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10}, |
| 962 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 963 | {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10}, |
| 964 | {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10}, |
| 965 | {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10}, |
| 966 | {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10}, |
| 967 | {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 968 | {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 969 | {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 970 | {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 971 | {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 972 | {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 973 | {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 974 | {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 975 | {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 976 | {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 977 | {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 978 | {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10}, |
| 979 | {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10}, |
| 980 | {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 981 | {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 982 | {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 983 | {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 984 | {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 985 | {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 986 | {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 987 | {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 988 | {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 989 | {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 990 | {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 991 | {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 992 | {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10}, |
| 993 | {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10}, |
| 994 | {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 995 | {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 996 | {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10}, |
| 997 | {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10}, |
| 998 | {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10}, |
| 999 | {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10}, |
| 1000 | {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10}, |
| 1001 | {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10}, |
| 1002 | {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10}, |
| 1003 | {} |
| 1004 | }; |
| 1005 | static const u8 po2030n_sensor_param1[][8] = { |
| 1006 | {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10}, |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 1007 | {DELAY, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1008 | {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10}, |
| 1009 | {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, |
Jean-François Moine | 41f0932 | 2011-11-30 06:20:07 -0300 | [diff] [blame] | 1010 | {0xd1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x40, 0x10}, /* RGBG gains */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1011 | /*param2*/ |
| 1012 | {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1013 | {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 1014 | {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10}, |
| 1015 | {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 1016 | {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10}, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1017 | {} |
| 1018 | }; |
| 1019 | |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1020 | static const u8 soi768_sensor_init[][8] = { |
| 1021 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 1022 | {DELAY, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */ |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1023 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1024 | {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1025 | {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 1026 | {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1027 | {} |
| 1028 | }; |
| 1029 | static const u8 soi768_sensor_param1[][8] = { |
| 1030 | {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 1031 | {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1032 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1033 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1034 | {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10}, |
| 1035 | /* */ |
| 1036 | /* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
| 1037 | /* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */ |
| 1038 | {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1039 | /* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
| 1040 | {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10}, |
| 1041 | /* the next sequence should be used for auto gain */ |
| 1042 | {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10}, |
| 1043 | /* global gain ? : 07 - change with 0x15 at the end */ |
| 1044 | {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */ |
| 1045 | {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10}, |
Jean-François Moine | 2458df4 | 2011-08-10 05:47:34 -0300 | [diff] [blame] | 1046 | {0xb1, 0x21, 0x2d, 0x63, 0x03, 0x00, 0x00, 0x10}, |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1047 | /* exposure ? : 0200 - change with 0x1e at the end */ |
| 1048 | {} |
| 1049 | }; |
| 1050 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1051 | static const u8 sp80708_sensor_init[][8] = { |
| 1052 | {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10}, |
| 1053 | {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10}, |
| 1054 | {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1055 | {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
| 1056 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 1057 | {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
| 1058 | {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10}, |
| 1059 | {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10}, |
| 1060 | {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10}, |
| 1061 | {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1062 | {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 1063 | {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10}, |
| 1064 | {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 1065 | {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 1066 | {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10}, |
| 1067 | {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10}, |
| 1068 | {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 1069 | {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 1070 | {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10}, |
| 1071 | {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10}, |
| 1072 | {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10}, |
| 1073 | {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10}, |
| 1074 | {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 1075 | {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10}, |
| 1076 | {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10}, |
| 1077 | {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10}, |
| 1078 | {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 1079 | {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10}, |
| 1080 | {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10}, |
| 1081 | {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10}, |
| 1082 | {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10}, |
| 1083 | {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10}, |
| 1084 | {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
| 1085 | {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10}, |
| 1086 | {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10}, |
| 1087 | {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10}, |
| 1088 | {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10}, |
| 1089 | {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1090 | {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10}, |
| 1091 | {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10}, |
| 1092 | {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 1093 | {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 1094 | {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10}, |
| 1095 | {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10}, |
| 1096 | {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10}, |
| 1097 | {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10}, |
| 1098 | {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10}, |
| 1099 | {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10}, |
| 1100 | {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1101 | {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1102 | {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1103 | {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1104 | {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1105 | {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1106 | {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10}, |
| 1107 | {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
| 1108 | {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10}, |
| 1109 | {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10}, |
| 1110 | {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10}, |
| 1111 | {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10}, |
| 1112 | {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 1113 | {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1114 | {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1115 | {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10}, |
| 1116 | {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 1117 | {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 1118 | {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10}, |
| 1119 | {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 1120 | {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10}, |
| 1121 | {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10}, |
| 1122 | {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10}, |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 1123 | {} |
| 1124 | }; |
| 1125 | static const u8 sp80708_sensor_param1[][8] = { |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1126 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 1127 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| 1128 | {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10}, |
| 1129 | {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10}, |
| 1130 | {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10}, |
| 1131 | {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, |
| 1132 | {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10}, |
| 1133 | {} |
| 1134 | }; |
| 1135 | |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 1136 | static const u8 (*sensor_init[])[8] = { |
| 1137 | [SENSOR_ADCM1700] = adcm1700_sensor_init, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1138 | [SENSOR_GC0307] = gc0307_sensor_init, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 1139 | [SENSOR_HV7131R] = hv7131r_sensor_init, |
| 1140 | [SENSOR_MI0360] = mi0360_sensor_init, |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1141 | [SENSOR_MI0360B] = mi0360b_sensor_init, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 1142 | [SENSOR_MO4000] = mo4000_sensor_init, |
| 1143 | [SENSOR_MT9V111] = mt9v111_sensor_init, |
| 1144 | [SENSOR_OM6802] = om6802_sensor_init, |
| 1145 | [SENSOR_OV7630] = ov7630_sensor_init, |
| 1146 | [SENSOR_OV7648] = ov7648_sensor_init, |
| 1147 | [SENSOR_OV7660] = ov7660_sensor_init, |
| 1148 | [SENSOR_PO1030] = po1030_sensor_init, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1149 | [SENSOR_PO2030N] = po2030n_sensor_init, |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1150 | [SENSOR_SOI768] = soi768_sensor_init, |
Jean-François Moine | 9c33afc | 2010-03-17 15:25:32 -0300 | [diff] [blame] | 1151 | [SENSOR_SP80708] = sp80708_sensor_init, |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 1152 | }; |
| 1153 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1154 | /* read <len> bytes to gspca_dev->usb_buf */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1155 | static void reg_r(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1156 | u16 value, int len) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1157 | { |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1158 | int ret; |
| 1159 | |
| 1160 | if (gspca_dev->usb_err < 0) |
| 1161 | return; |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1162 | if (len > USB_BUF_SZ) { |
Theodore Kilgore | c93396e | 2013-02-04 13:17:55 -0300 | [diff] [blame] | 1163 | PERR("reg_r: buffer overflow\n"); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1164 | return; |
| 1165 | } |
Theodore Kilgore | c93396e | 2013-02-04 13:17:55 -0300 | [diff] [blame] | 1166 | |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1167 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1168 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1169 | 0, |
| 1170 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1171 | value, 0, |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1172 | gspca_dev->usb_buf, len, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1173 | 500); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1174 | PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1175 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1176 | pr_err("reg_r err %d\n", ret); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1177 | gspca_dev->usb_err = ret; |
| 1178 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1179 | } |
| 1180 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1181 | static void reg_w1(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1182 | u16 value, |
| 1183 | u8 data) |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1184 | { |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1185 | int ret; |
| 1186 | |
| 1187 | if (gspca_dev->usb_err < 0) |
| 1188 | return; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1189 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1190 | gspca_dev->usb_buf[0] = data; |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1191 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1192 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1193 | 0x08, |
| 1194 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1195 | value, |
| 1196 | 0, |
| 1197 | gspca_dev->usb_buf, 1, |
| 1198 | 500); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1199 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1200 | pr_err("reg_w1 err %d\n", ret); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1201 | gspca_dev->usb_err = ret; |
| 1202 | } |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1203 | } |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1204 | static void reg_w(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1205 | u16 value, |
| 1206 | const u8 *buffer, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1207 | int len) |
| 1208 | { |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1209 | int ret; |
| 1210 | |
| 1211 | if (gspca_dev->usb_err < 0) |
| 1212 | return; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1213 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1214 | value, buffer[0], buffer[1]); |
Theodore Kilgore | c93396e | 2013-02-04 13:17:55 -0300 | [diff] [blame] | 1215 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1216 | if (len > USB_BUF_SZ) { |
Theodore Kilgore | c93396e | 2013-02-04 13:17:55 -0300 | [diff] [blame] | 1217 | PERR("reg_w: buffer overflow\n"); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1218 | return; |
Jean-Francois Moine | bf7f0b9 | 2008-07-03 11:09:12 -0300 | [diff] [blame] | 1219 | } |
Theodore Kilgore | c93396e | 2013-02-04 13:17:55 -0300 | [diff] [blame] | 1220 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1221 | memcpy(gspca_dev->usb_buf, buffer, len); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1222 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 1223 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1224 | 0x08, |
| 1225 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1226 | value, 0, |
| 1227 | gspca_dev->usb_buf, len, |
| 1228 | 500); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1229 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1230 | pr_err("reg_w err %d\n", ret); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1231 | gspca_dev->usb_err = ret; |
| 1232 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1233 | } |
| 1234 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1235 | /* I2C write 1 byte */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1236 | 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] | 1237 | { |
| 1238 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1239 | int ret; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1240 | |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1241 | if (gspca_dev->usb_err < 0) |
| 1242 | return; |
Jean-François Moine | cfd23c8 | 2010-04-25 14:27:39 -0300 | [diff] [blame] | 1243 | PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val); |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame] | 1244 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 1245 | case SENSOR_ADCM1700: |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1246 | case SENSOR_OM6802: |
| 1247 | case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame] | 1248 | gspca_dev->usb_buf[0] = 0x80 | (2 << 4); |
| 1249 | break; |
| 1250 | default: /* i2c command = a1 (400 kHz) */ |
| 1251 | gspca_dev->usb_buf[0] = 0x81 | (2 << 4); |
| 1252 | break; |
| 1253 | } |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1254 | gspca_dev->usb_buf[1] = sd->i2c_addr; |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1255 | gspca_dev->usb_buf[2] = reg; |
| 1256 | gspca_dev->usb_buf[3] = val; |
| 1257 | gspca_dev->usb_buf[4] = 0; |
| 1258 | gspca_dev->usb_buf[5] = 0; |
| 1259 | gspca_dev->usb_buf[6] = 0; |
| 1260 | gspca_dev->usb_buf[7] = 0x10; |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1261 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1262 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1263 | 0x08, |
| 1264 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1265 | 0x08, /* value = i2c */ |
| 1266 | 0, |
| 1267 | gspca_dev->usb_buf, 8, |
| 1268 | 500); |
Hans de Goede | 2bffebc | 2012-12-21 11:17:42 -0300 | [diff] [blame] | 1269 | msleep(2); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1270 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1271 | pr_err("i2c_w1 err %d\n", ret); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1272 | gspca_dev->usb_err = ret; |
| 1273 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1274 | } |
| 1275 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1276 | /* I2C write 8 bytes */ |
| 1277 | static void i2c_w8(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1278 | const u8 *buffer) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1279 | { |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1280 | int ret; |
| 1281 | |
| 1282 | if (gspca_dev->usb_err < 0) |
| 1283 | return; |
Jean-François Moine | cfd23c8 | 2010-04-25 14:27:39 -0300 | [diff] [blame] | 1284 | PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..", |
| 1285 | buffer[2], buffer[3]); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1286 | memcpy(gspca_dev->usb_buf, buffer, 8); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1287 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1288 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 1289 | 0x08, |
| 1290 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 1291 | 0x08, 0, /* value, index */ |
| 1292 | gspca_dev->usb_buf, 8, |
| 1293 | 500); |
Jean-Francois Moine | 8d768e1 | 2008-09-21 03:28:55 -0300 | [diff] [blame] | 1294 | msleep(2); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1295 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1296 | pr_err("i2c_w8 err %d\n", ret); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1297 | gspca_dev->usb_err = ret; |
| 1298 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1299 | } |
| 1300 | |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1301 | /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */ |
| 1302 | static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1303 | { |
| 1304 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1305 | u8 mode[8]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1306 | |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame] | 1307 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 1308 | case SENSOR_ADCM1700: |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1309 | case SENSOR_OM6802: |
| 1310 | case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */ |
Jean-Francois Moine | a782636 | 2009-11-02 09:21:06 -0300 | [diff] [blame] | 1311 | mode[0] = 0x80 | 0x10; |
| 1312 | break; |
| 1313 | default: /* i2c command = 91 (400 kHz) */ |
| 1314 | mode[0] = 0x81 | 0x10; |
| 1315 | break; |
| 1316 | } |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1317 | mode[1] = sd->i2c_addr; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1318 | mode[2] = reg; |
| 1319 | mode[3] = 0; |
| 1320 | mode[4] = 0; |
| 1321 | mode[5] = 0; |
| 1322 | mode[6] = 0; |
| 1323 | mode[7] = 0x10; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1324 | i2c_w8(gspca_dev, mode); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1325 | msleep(2); |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1326 | mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1327 | mode[2] = 0; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1328 | i2c_w8(gspca_dev, mode); |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1329 | msleep(2); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1330 | reg_r(gspca_dev, 0x0a, 5); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1331 | } |
| 1332 | |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 1333 | static void i2c_w_seq(struct gspca_dev *gspca_dev, |
| 1334 | const u8 (*data)[8]) |
| 1335 | { |
| 1336 | while ((*data)[0] != 0) { |
Németh Márton | ccbc5df | 2010-10-18 07:00:48 -0300 | [diff] [blame] | 1337 | if ((*data)[0] != DELAY) |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 1338 | i2c_w8(gspca_dev, *data); |
| 1339 | else |
| 1340 | msleep((*data)[1]); |
| 1341 | data++; |
| 1342 | } |
| 1343 | } |
| 1344 | |
Jean-François Moine | a79cc7b | 2010-10-29 08:10:37 -0300 | [diff] [blame] | 1345 | /* check the ID of the hv7131 sensor */ |
| 1346 | /* this sequence is needed because it activates the sensor */ |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1347 | static void hv7131r_probe(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1348 | { |
Jean-François Moine | a79cc7b | 2010-10-29 08:10:37 -0300 | [diff] [blame] | 1349 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1350 | msleep(10); |
Jean-François Moine | a79cc7b | 2010-10-29 08:10:37 -0300 | [diff] [blame] | 1351 | reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1352 | msleep(10); |
Jean-François Moine | a79cc7b | 2010-10-29 08:10:37 -0300 | [diff] [blame] | 1353 | i2c_r(gspca_dev, 0, 5); /* read sensor id */ |
| 1354 | if (gspca_dev->usb_buf[0] == 0x02 /* chip ID (02 is R) */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1355 | && gspca_dev->usb_buf[1] == 0x09 |
Jean-François Moine | a79cc7b | 2010-10-29 08:10:37 -0300 | [diff] [blame] | 1356 | && gspca_dev->usb_buf[2] == 0x01) { |
| 1357 | PDEBUG(D_PROBE, "Sensor HV7131R found"); |
Jean-Francois Moine | 7fb101a | 2009-10-22 06:27:14 -0300 | [diff] [blame] | 1358 | return; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1359 | } |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1360 | pr_warn("Erroneous HV7131R ID 0x%02x 0x%02x 0x%02x\n", |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1361 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1], |
| 1362 | gspca_dev->usb_buf[2]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1363 | } |
| 1364 | |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1365 | static void mi0360_probe(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1366 | { |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1367 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1368 | int i, j; |
Jean-Francois Moine | 92e8c91 | 2009-02-02 16:25:38 -0300 | [diff] [blame] | 1369 | u16 val = 0; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1370 | static const u8 probe_tb[][4][8] = { |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1371 | { /* mi0360 */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1372 | {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
| 1373 | {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1374 | {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1375 | {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10} |
| 1376 | }, |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1377 | { /* mt9v111 */ |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1378 | {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, |
| 1379 | {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1380 | {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 1381 | {} |
| 1382 | }, |
| 1383 | }; |
| 1384 | |
| 1385 | for (i = 0; i < ARRAY_SIZE(probe_tb); i++) { |
| 1386 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1387 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1388 | for (j = 0; j < 3; j++) |
| 1389 | i2c_w8(gspca_dev, probe_tb[i][j]); |
| 1390 | msleep(2); |
| 1391 | reg_r(gspca_dev, 0x0a, 5); |
| 1392 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
| 1393 | if (probe_tb[i][3][0] != 0) |
| 1394 | i2c_w8(gspca_dev, probe_tb[i][3]); |
| 1395 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1396 | reg_w1(gspca_dev, 0x17, 0x42); |
| 1397 | if (val != 0xffff) |
| 1398 | break; |
| 1399 | } |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1400 | if (gspca_dev->usb_err < 0) |
| 1401 | return; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1402 | switch (val) { |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1403 | case 0x8221: |
| 1404 | PDEBUG(D_PROBE, "Sensor mi0360b"); |
| 1405 | sd->sensor = SENSOR_MI0360B; |
| 1406 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1407 | case 0x823a: |
| 1408 | PDEBUG(D_PROBE, "Sensor mt9v111"); |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1409 | sd->sensor = SENSOR_MT9V111; |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1410 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1411 | case 0x8243: |
| 1412 | PDEBUG(D_PROBE, "Sensor mi0360"); |
Jean-Francois Moine | 65c5259 | 2009-02-01 14:26:51 -0300 | [diff] [blame] | 1413 | break; |
| 1414 | default: |
| 1415 | PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val); |
| 1416 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1417 | } |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1418 | } |
| 1419 | |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1420 | static void ov7630_probe(struct gspca_dev *gspca_dev) |
| 1421 | { |
| 1422 | struct sd *sd = (struct sd *) gspca_dev; |
| 1423 | u16 val; |
| 1424 | |
| 1425 | /* check ov76xx */ |
| 1426 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1427 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1428 | sd->i2c_addr = 0x21; |
| 1429 | i2c_r(gspca_dev, 0x0a, 2); |
| 1430 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
| 1431 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1432 | reg_w1(gspca_dev, 0x17, 0x42); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1433 | if (gspca_dev->usb_err < 0) |
| 1434 | return; |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 1435 | if (val == 0x7628) { /* soi768 */ |
| 1436 | sd->sensor = SENSOR_SOI768; |
| 1437 | /*fixme: only valid for 0c45:613e?*/ |
| 1438 | gspca_dev->cam.input_flags = |
| 1439 | V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP; |
| 1440 | PDEBUG(D_PROBE, "Sensor soi768"); |
| 1441 | return; |
| 1442 | } |
| 1443 | PDEBUG(D_PROBE, "Sensor ov%04x", val); |
| 1444 | } |
| 1445 | |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1446 | static void ov7648_probe(struct gspca_dev *gspca_dev) |
| 1447 | { |
| 1448 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1449 | u16 val; |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1450 | |
| 1451 | /* check ov76xx */ |
| 1452 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1453 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1454 | sd->i2c_addr = 0x21; |
| 1455 | i2c_r(gspca_dev, 0x0a, 2); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1456 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1457 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1458 | reg_w1(gspca_dev, 0x17, 0x42); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1459 | if ((val & 0xff00) == 0x7600) { /* ov76xx */ |
| 1460 | PDEBUG(D_PROBE, "Sensor ov%04x", val); |
| 1461 | return; |
| 1462 | } |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1463 | |
| 1464 | /* check po1030 */ |
| 1465 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1466 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1467 | sd->i2c_addr = 0x6e; |
| 1468 | i2c_r(gspca_dev, 0x00, 2); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1469 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
| 1470 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1471 | reg_w1(gspca_dev, 0x17, 0x42); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1472 | if (gspca_dev->usb_err < 0) |
| 1473 | return; |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1474 | if (val == 0x1030) { /* po1030 */ |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1475 | PDEBUG(D_PROBE, "Sensor po1030"); |
| 1476 | sd->sensor = SENSOR_PO1030; |
| 1477 | return; |
| 1478 | } |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1479 | pr_err("Unknown sensor %04x\n", val); |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 1480 | } |
| 1481 | |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1482 | /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */ |
| 1483 | static void po2030n_probe(struct gspca_dev *gspca_dev) |
| 1484 | { |
| 1485 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1486 | u16 val; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1487 | |
| 1488 | /* check gc0307 */ |
| 1489 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1490 | reg_w1(gspca_dev, 0x01, 0x08); |
| 1491 | reg_w1(gspca_dev, 0x02, 0x22); |
| 1492 | sd->i2c_addr = 0x21; |
| 1493 | i2c_r(gspca_dev, 0x00, 1); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1494 | val = gspca_dev->usb_buf[4]; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1495 | reg_w1(gspca_dev, 0x01, 0x29); /* reset */ |
| 1496 | reg_w1(gspca_dev, 0x17, 0x42); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1497 | if (val == 0x99) { /* gc0307 (?) */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1498 | PDEBUG(D_PROBE, "Sensor gc0307"); |
| 1499 | sd->sensor = SENSOR_GC0307; |
| 1500 | return; |
| 1501 | } |
| 1502 | |
| 1503 | /* check po2030n */ |
| 1504 | reg_w1(gspca_dev, 0x17, 0x62); |
| 1505 | reg_w1(gspca_dev, 0x01, 0x0a); |
| 1506 | sd->i2c_addr = 0x6e; |
| 1507 | i2c_r(gspca_dev, 0x00, 2); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1508 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1509 | reg_w1(gspca_dev, 0x01, 0x29); |
| 1510 | reg_w1(gspca_dev, 0x17, 0x42); |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1511 | if (gspca_dev->usb_err < 0) |
| 1512 | return; |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1513 | if (val == 0x2030) { |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1514 | PDEBUG(D_PROBE, "Sensor po2030n"); |
| 1515 | /* sd->sensor = SENSOR_PO2030N; */ |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1516 | } else { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 1517 | pr_err("Unknown sensor ID %04x\n", val); |
Jean-François Moine | e3302ca | 2010-04-25 14:41:51 -0300 | [diff] [blame] | 1518 | } |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1519 | } |
| 1520 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1521 | /* this function is called at probe time */ |
| 1522 | static int sd_config(struct gspca_dev *gspca_dev, |
| 1523 | const struct usb_device_id *id) |
| 1524 | { |
| 1525 | struct sd *sd = (struct sd *) gspca_dev; |
| 1526 | struct cam *cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1527 | |
Jean-Francois Moine | eac8f5f | 2010-01-12 07:12:43 -0300 | [diff] [blame] | 1528 | sd->bridge = id->driver_info >> 16; |
Jean-Francois Moine | c6c1433 | 2010-12-14 16:15:37 -0300 | [diff] [blame] | 1529 | sd->sensor = id->driver_info >> 8; |
| 1530 | sd->flags = id->driver_info; |
Jean-Francois Moine | eac8f5f | 2010-01-12 07:12:43 -0300 | [diff] [blame] | 1531 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1532 | cam = &gspca_dev->cam; |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 1533 | if (sd->sensor == SENSOR_ADCM1700) { |
| 1534 | cam->cam_mode = cif_mode; |
| 1535 | cam->nmodes = ARRAY_SIZE(cif_mode); |
| 1536 | } else { |
| 1537 | cam->cam_mode = vga_mode; |
| 1538 | cam->nmodes = ARRAY_SIZE(vga_mode); |
| 1539 | } |
Jean-Francois Moine | 49cb6b0 | 2009-04-25 13:29:01 -0300 | [diff] [blame] | 1540 | cam->npkt = 24; /* 24 packets per ISOC message */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 1541 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1542 | sd->ag_cnt = -1; |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 1543 | sd->quality = QUALITY_DEF; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1544 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 1545 | INIT_WORK(&sd->work, qual_upd); |
| 1546 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1547 | return 0; |
| 1548 | } |
| 1549 | |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 1550 | /* this function is called at probe and resume time */ |
| 1551 | static int sd_init(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1552 | { |
| 1553 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1554 | const u8 *sn9c1xx; |
Jean-François Moine | e6a92a7 | 2011-02-10 07:52:58 -0300 | [diff] [blame] | 1555 | u8 regGpio[] = { 0x29, 0x70 }; /* no audio */ |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1556 | u8 regF1; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1557 | |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1558 | /* setup a selector by bridge */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1559 | reg_w1(gspca_dev, 0xf1, 0x01); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1560 | reg_r(gspca_dev, 0x00, 1); |
Jean-Francois Moine | 4f67f3a | 2010-12-14 16:15:00 -0300 | [diff] [blame] | 1561 | reg_w1(gspca_dev, 0xf1, 0x00); |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1562 | reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1563 | regF1 = gspca_dev->usb_buf[0]; |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1564 | if (gspca_dev->usb_err < 0) |
| 1565 | return gspca_dev->usb_err; |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 1566 | PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); |
Jean-François Moine | e6a92a7 | 2011-02-10 07:52:58 -0300 | [diff] [blame] | 1567 | if (gspca_dev->audio) |
| 1568 | regGpio[1] |= 0x04; /* with audio */ |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1569 | switch (sd->bridge) { |
| 1570 | case BRIDGE_SN9C102P: |
Hans de Goede | 3647fea | 2008-07-15 05:36:30 -0300 | [diff] [blame] | 1571 | case BRIDGE_SN9C105: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1572 | if (regF1 != 0x11) |
| 1573 | return -ENODEV; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1574 | break; |
| 1575 | default: |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 1576 | /* case BRIDGE_SN9C110: */ |
Hans de Goede | e530a5e | 2011-01-06 15:23:55 -0300 | [diff] [blame] | 1577 | /* case BRIDGE_SN9C120: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1578 | if (regF1 != 0x12) |
| 1579 | return -ENODEV; |
Hans de Goede | e530a5e | 2011-01-06 15:23:55 -0300 | [diff] [blame] | 1580 | } |
| 1581 | |
| 1582 | switch (sd->sensor) { |
| 1583 | case SENSOR_MI0360: |
| 1584 | mi0360_probe(gspca_dev); |
| 1585 | break; |
| 1586 | case SENSOR_OV7630: |
| 1587 | ov7630_probe(gspca_dev); |
| 1588 | break; |
| 1589 | case SENSOR_OV7648: |
| 1590 | ov7648_probe(gspca_dev); |
| 1591 | break; |
| 1592 | case SENSOR_PO2030N: |
| 1593 | po2030n_probe(gspca_dev); |
| 1594 | break; |
| 1595 | } |
| 1596 | |
| 1597 | switch (sd->bridge) { |
| 1598 | case BRIDGE_SN9C102P: |
| 1599 | reg_w1(gspca_dev, 0x02, regGpio[1]); |
| 1600 | break; |
Jean-François Moine | 336d23e | 2011-02-10 08:00:40 -0300 | [diff] [blame] | 1601 | default: |
Hans de Goede | e530a5e | 2011-01-06 15:23:55 -0300 | [diff] [blame] | 1602 | reg_w(gspca_dev, 0x01, regGpio, 2); |
| 1603 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1604 | } |
| 1605 | |
Hans de Goede | 9712a8b | 2010-01-31 12:54:29 -0300 | [diff] [blame] | 1606 | /* Note we do not disable the sensor clock here (power saving mode), |
| 1607 | as that also disables the button on the cam. */ |
| 1608 | reg_w1(gspca_dev, 0xf1, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1609 | |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1610 | /* set the i2c address */ |
| 1611 | sn9c1xx = sn_tb[sd->sensor]; |
| 1612 | sd->i2c_addr = sn9c1xx[9]; |
| 1613 | |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 1614 | return gspca_dev->usb_err; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1615 | } |
| 1616 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1617 | static int sd_s_ctrl(struct v4l2_ctrl *ctrl); |
| 1618 | |
| 1619 | static const struct v4l2_ctrl_ops sd_ctrl_ops = { |
| 1620 | .s_ctrl = sd_s_ctrl, |
| 1621 | }; |
| 1622 | |
| 1623 | /* this function is called at probe time */ |
| 1624 | static int sd_init_controls(struct gspca_dev *gspca_dev) |
| 1625 | { |
| 1626 | struct sd *sd = (struct sd *) gspca_dev; |
| 1627 | struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; |
| 1628 | |
| 1629 | gspca_dev->vdev.ctrl_handler = hdl; |
| 1630 | v4l2_ctrl_handler_init(hdl, 14); |
| 1631 | |
| 1632 | sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1633 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); |
| 1634 | #define CONTRAST_MAX 127 |
| 1635 | sd->contrast = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1636 | V4L2_CID_CONTRAST, 0, CONTRAST_MAX, 1, 20); |
| 1637 | #define COLORS_DEF 25 |
| 1638 | sd->saturation = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1639 | V4L2_CID_SATURATION, 0, 40, 1, COLORS_DEF); |
| 1640 | sd->red_bal = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1641 | V4L2_CID_RED_BALANCE, 24, 40, 1, 32); |
| 1642 | sd->blue_bal = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1643 | V4L2_CID_BLUE_BALANCE, 24, 40, 1, 32); |
| 1644 | #define GAMMA_DEF 20 |
| 1645 | sd->gamma = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1646 | V4L2_CID_GAMMA, 0, 40, 1, GAMMA_DEF); |
| 1647 | |
| 1648 | if (sd->sensor == SENSOR_OM6802) |
| 1649 | sd->sharpness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1650 | V4L2_CID_SHARPNESS, 0, 255, 1, 16); |
| 1651 | else |
| 1652 | sd->sharpness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1653 | V4L2_CID_SHARPNESS, 0, 255, 1, 90); |
| 1654 | |
| 1655 | if (sd->flags & F_ILLUM) |
| 1656 | sd->illum = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1657 | V4L2_CID_ILLUMINATORS_1, 0, 1, 1, 0); |
| 1658 | |
| 1659 | if (sd->sensor == SENSOR_PO2030N) { |
| 1660 | gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1661 | V4L2_CID_EXPOSURE, 500, 1500, 1, 1024); |
| 1662 | gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1663 | V4L2_CID_GAIN, 4, 49, 1, 15); |
| 1664 | sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1665 | V4L2_CID_HFLIP, 0, 1, 1, 0); |
| 1666 | } |
| 1667 | |
| 1668 | if (sd->sensor != SENSOR_ADCM1700 && sd->sensor != SENSOR_OV7660 && |
| 1669 | sd->sensor != SENSOR_PO1030 && sd->sensor != SENSOR_SOI768 && |
| 1670 | sd->sensor != SENSOR_SP80708) |
| 1671 | gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1672 | V4L2_CID_AUTOGAIN, 0, 1, 1, 1); |
| 1673 | |
| 1674 | if (sd->sensor == SENSOR_HV7131R || sd->sensor == SENSOR_OV7630 || |
| 1675 | sd->sensor == SENSOR_OV7648 || sd->sensor == SENSOR_PO2030N) |
| 1676 | sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1677 | V4L2_CID_VFLIP, 0, 1, 1, 0); |
| 1678 | |
| 1679 | if (sd->sensor == SENSOR_OV7630 || sd->sensor == SENSOR_OV7648 || |
| 1680 | sd->sensor == SENSOR_OV7660) |
| 1681 | sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, |
| 1682 | V4L2_CID_POWER_LINE_FREQUENCY, |
| 1683 | V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0, |
| 1684 | V4L2_CID_POWER_LINE_FREQUENCY_50HZ); |
| 1685 | |
| 1686 | if (hdl->error) { |
| 1687 | pr_err("Could not initialize controls\n"); |
| 1688 | return hdl->error; |
| 1689 | } |
| 1690 | |
| 1691 | v4l2_ctrl_cluster(2, &sd->red_bal); |
| 1692 | if (sd->sensor == SENSOR_PO2030N) { |
| 1693 | v4l2_ctrl_cluster(2, &sd->vflip); |
| 1694 | v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); |
| 1695 | } |
| 1696 | |
| 1697 | return 0; |
| 1698 | } |
| 1699 | |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1700 | static u32 expo_adjust(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1701 | u32 expo) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1702 | { |
| 1703 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1704 | |
| 1705 | switch (sd->sensor) { |
Jean-François Moine | c26b12d | 2010-04-02 07:08:39 -0300 | [diff] [blame] | 1706 | case SENSOR_GC0307: { |
| 1707 | int a, b; |
| 1708 | |
| 1709 | /* expo = 0..255 -> a = 19..43 */ |
| 1710 | a = 19 + expo * 25 / 256; |
| 1711 | i2c_w1(gspca_dev, 0x68, a); |
| 1712 | a -= 12; |
| 1713 | b = a * a * 4; /* heuristic */ |
| 1714 | i2c_w1(gspca_dev, 0x03, b >> 8); |
| 1715 | i2c_w1(gspca_dev, 0x04, b); |
| 1716 | break; |
| 1717 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1718 | case SENSOR_HV7131R: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1719 | u8 Expodoit[] = |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1720 | { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1721 | |
| 1722 | Expodoit[3] = expo >> 16; |
| 1723 | Expodoit[4] = expo >> 8; |
| 1724 | Expodoit[5] = expo; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1725 | i2c_w8(gspca_dev, Expodoit); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1726 | break; |
| 1727 | } |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1728 | case SENSOR_MI0360: |
| 1729 | case SENSOR_MI0360B: { |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1730 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1731 | { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1732 | static const u8 doit[] = /* update sensor */ |
| 1733 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; |
| 1734 | static const u8 sensorgo[] = /* sensor on */ |
| 1735 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1736 | |
| 1737 | if (expo > 0x0635) |
| 1738 | expo = 0x0635; |
| 1739 | else if (expo < 0x0001) |
| 1740 | expo = 0x0001; |
| 1741 | expoMi[3] = expo >> 8; |
| 1742 | expoMi[4] = expo; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1743 | i2c_w8(gspca_dev, expoMi); |
| 1744 | i2c_w8(gspca_dev, doit); |
| 1745 | i2c_w8(gspca_dev, sensorgo); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1746 | break; |
| 1747 | } |
| 1748 | case SENSOR_MO4000: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1749 | u8 expoMof[] = |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1750 | { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1751 | u8 expoMo10[] = |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1752 | { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1753 | static const u8 gainMo[] = |
| 1754 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1755 | |
| 1756 | if (expo > 0x1fff) |
| 1757 | expo = 0x1fff; |
| 1758 | else if (expo < 0x0001) |
| 1759 | expo = 0x0001; |
| 1760 | expoMof[3] = (expo & 0x03fc) >> 2; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1761 | i2c_w8(gspca_dev, expoMof); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1762 | expoMo10[3] = ((expo & 0x1c00) >> 10) |
| 1763 | | ((expo & 0x0003) << 4); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 1764 | i2c_w8(gspca_dev, expoMo10); |
| 1765 | i2c_w8(gspca_dev, gainMo); |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1766 | PDEBUG(D_FRAM, "set exposure %d", |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1767 | ((expoMo10[3] & 0x07) << 10) |
| 1768 | | (expoMof[3] << 2) |
| 1769 | | ((expoMo10[3] & 0x30) >> 4)); |
| 1770 | break; |
| 1771 | } |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1772 | case SENSOR_MT9V111: { |
| 1773 | u8 expo_c1[] = |
| 1774 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
| 1775 | |
Jean-François Moine | 2220367 | 2011-02-10 07:49:32 -0300 | [diff] [blame] | 1776 | if (expo > 0x0390) |
| 1777 | expo = 0x0390; |
| 1778 | else if (expo < 0x0060) |
| 1779 | expo = 0x0060; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1780 | expo_c1[3] = expo >> 8; |
| 1781 | expo_c1[4] = expo; |
| 1782 | i2c_w8(gspca_dev, expo_c1); |
| 1783 | break; |
| 1784 | } |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1785 | case SENSOR_OM6802: { |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1786 | u8 gainOm[] = |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1787 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1788 | /* preset AGC - works when AutoExpo = off */ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1789 | |
| 1790 | if (expo > 0x03ff) |
| 1791 | expo = 0x03ff; |
| 1792 | if (expo < 0x0001) |
| 1793 | expo = 0x0001; |
| 1794 | gainOm[3] = expo >> 2; |
| 1795 | i2c_w8(gspca_dev, gainOm); |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1796 | reg_w1(gspca_dev, 0x96, expo >> 5); |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 1797 | PDEBUG(D_FRAM, "set exposure %d", gainOm[3]); |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1798 | break; |
| 1799 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1800 | } |
| 1801 | return expo; |
| 1802 | } |
| 1803 | |
| 1804 | static void setbrightness(struct gspca_dev *gspca_dev) |
| 1805 | { |
| 1806 | struct sd *sd = (struct sd *) gspca_dev; |
| 1807 | unsigned int expo; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1808 | int brightness = sd->brightness->val; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1809 | u8 k2; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1810 | |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1811 | k2 = (brightness - 0x80) >> 2; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1812 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 1813 | case SENSOR_ADCM1700: |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 1814 | if (k2 > 0x1f) |
| 1815 | k2 = 0; /* only positive Y offset */ |
| 1816 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1817 | case SENSOR_HV7131R: |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1818 | expo = brightness << 12; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1819 | if (expo > 0x002dc6c0) |
| 1820 | expo = 0x002dc6c0; |
| 1821 | else if (expo < 0x02a0) |
| 1822 | expo = 0x02a0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1823 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1824 | break; |
| 1825 | case SENSOR_MI0360: |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1826 | case SENSOR_MO4000: |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1827 | expo = brightness << 4; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1828 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1829 | break; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1830 | case SENSOR_MI0360B: |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1831 | expo = brightness << 2; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1832 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1833 | break; |
Jean-François Moine | c26b12d | 2010-04-02 07:08:39 -0300 | [diff] [blame] | 1834 | case SENSOR_GC0307: |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1835 | expo = brightness; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1836 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1837 | return; /* don't set the Y offset */ |
Jean-François Moine | 2220367 | 2011-02-10 07:49:32 -0300 | [diff] [blame] | 1838 | case SENSOR_MT9V111: |
| 1839 | expo = brightness << 2; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1840 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-François Moine | 2220367 | 2011-02-10 07:49:32 -0300 | [diff] [blame] | 1841 | return; /* don't set the Y offset */ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 1842 | case SENSOR_OM6802: |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1843 | expo = brightness << 2; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1844 | sd->exposure = expo_adjust(gspca_dev, expo); |
Jean-François Moine | b813b0c | 2011-08-10 05:54:34 -0300 | [diff] [blame] | 1845 | return; /* Y offset already set */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1846 | } |
| 1847 | |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1848 | reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | static void setcontrast(struct gspca_dev *gspca_dev) |
| 1852 | { |
| 1853 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1854 | u8 k2; |
| 1855 | u8 contrast[6]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1856 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1857 | k2 = sd->contrast->val * 37 / (CONTRAST_MAX + 1) |
Jean-François Moine | abe8cee | 2011-08-10 05:13:45 -0300 | [diff] [blame] | 1858 | + 37; /* 37..73 */ |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1859 | contrast[0] = (k2 + 1) / 2; /* red */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1860 | contrast[1] = 0; |
Jean-Francois Moine | 91bd341 | 2008-11-23 14:47:50 -0300 | [diff] [blame] | 1861 | contrast[2] = k2; /* green */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1862 | contrast[3] = 0; |
Jean-François Moine | abe8cee | 2011-08-10 05:13:45 -0300 | [diff] [blame] | 1863 | contrast[4] = k2 / 5; /* blue */ |
Jean-Francois Moine | 577cbf4 | 2008-12-05 06:18:37 -0300 | [diff] [blame] | 1864 | contrast[5] = 0; |
| 1865 | reg_w(gspca_dev, 0x84, contrast, sizeof contrast); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | static void setcolors(struct gspca_dev *gspca_dev) |
| 1869 | { |
| 1870 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1871 | int i, v, colors; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1872 | const s16 *uv; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 1873 | u8 reg8a[12]; /* U & V gains */ |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1874 | static const s16 uv_com[6] = { /* same as reg84 in signed decimal */ |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1875 | -24, -38, 64, /* UR UG UB */ |
| 1876 | 62, -51, -9 /* VR VG VB */ |
| 1877 | }; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1878 | static const s16 uv_mi0360b[6] = { |
| 1879 | -20, -38, 64, /* UR UG UB */ |
| 1880 | 60, -51, -9 /* VR VG VB */ |
| 1881 | }; |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 1882 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1883 | colors = sd->saturation->val; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1884 | if (sd->sensor == SENSOR_MI0360B) |
| 1885 | uv = uv_mi0360b; |
| 1886 | else |
| 1887 | uv = uv_com; |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1888 | for (i = 0; i < 6; i++) { |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1889 | v = uv[i] * colors / COLORS_DEF; |
Jean-Francois Moine | bd08883 | 2008-12-02 06:58:57 -0300 | [diff] [blame] | 1890 | reg8a[i * 2] = v; |
| 1891 | reg8a[i * 2 + 1] = (v >> 8) & 0x0f; |
Jean-Francois Moine | d55b83d | 2008-09-03 16:48:01 -0300 | [diff] [blame] | 1892 | } |
Jean-Francois Moine | bd08883 | 2008-12-02 06:58:57 -0300 | [diff] [blame] | 1893 | reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a); |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 1894 | } |
| 1895 | |
| 1896 | static void setredblue(struct gspca_dev *gspca_dev) |
| 1897 | { |
| 1898 | struct sd *sd = (struct sd *) gspca_dev; |
| 1899 | |
Jean-François Moine | 41f0932 | 2011-11-30 06:20:07 -0300 | [diff] [blame] | 1900 | if (sd->sensor == SENSOR_PO2030N) { |
| 1901 | u8 rg1b[] = /* red green1 blue (no g2) */ |
| 1902 | {0xc1, 0x6e, 0x16, 0x00, 0x40, 0x00, 0x00, 0x10}; |
| 1903 | |
| 1904 | /* 0x40 = normal value = gain x 1 */ |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1905 | rg1b[3] = sd->red_bal->val * 2; |
| 1906 | rg1b[5] = sd->blue_bal->val * 2; |
Jean-François Moine | 41f0932 | 2011-11-30 06:20:07 -0300 | [diff] [blame] | 1907 | i2c_w8(gspca_dev, rg1b); |
| 1908 | return; |
| 1909 | } |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1910 | reg_w1(gspca_dev, 0x05, sd->red_bal->val); |
Jean-Francois Moine | 9c5f70f | 2008-09-03 16:48:04 -0300 | [diff] [blame] | 1911 | /* reg_w1(gspca_dev, 0x07, 32); */ |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1912 | reg_w1(gspca_dev, 0x06, sd->blue_bal->val); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1913 | } |
| 1914 | |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1915 | static void setgamma(struct gspca_dev *gspca_dev) |
| 1916 | { |
| 1917 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1918 | int i, val; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1919 | u8 gamma[17]; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1920 | const u8 *gamma_base; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1921 | static const u8 delta[17] = { |
| 1922 | 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a, |
| 1923 | 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00 |
| 1924 | }; |
| 1925 | |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1926 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 1927 | case SENSOR_ADCM1700: |
| 1928 | gamma_base = gamma_spec_0; |
| 1929 | break; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1930 | case SENSOR_HV7131R: |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 1931 | case SENSOR_MI0360B: |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1932 | case SENSOR_MT9V111: |
| 1933 | gamma_base = gamma_spec_1; |
| 1934 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1935 | case SENSOR_GC0307: |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1936 | gamma_base = gamma_spec_2; |
| 1937 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 1938 | case SENSOR_SP80708: |
| 1939 | gamma_base = gamma_spec_3; |
| 1940 | break; |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1941 | default: |
| 1942 | gamma_base = gamma_def; |
| 1943 | break; |
| 1944 | } |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 1945 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1946 | val = sd->gamma->val; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1947 | for (i = 0; i < sizeof gamma; i++) |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 1948 | gamma[i] = gamma_base[i] |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 1949 | + delta[i] * (val - GAMMA_DEF) / 32; |
Jean-Francois Moine | 592f4eb | 2009-01-15 08:01:32 -0300 | [diff] [blame] | 1950 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); |
| 1951 | } |
| 1952 | |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1953 | static void setexposure(struct gspca_dev *gspca_dev) |
| 1954 | { |
| 1955 | struct sd *sd = (struct sd *) gspca_dev; |
| 1956 | |
| 1957 | if (sd->sensor == SENSOR_PO2030N) { |
| 1958 | u8 rexpo[] = /* 1a: expo H, 1b: expo M */ |
| 1959 | {0xa1, 0x6e, 0x1a, 0x00, 0x40, 0x00, 0x00, 0x10}; |
| 1960 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1961 | rexpo[3] = gspca_dev->exposure->val >> 8; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1962 | i2c_w8(gspca_dev, rexpo); |
| 1963 | msleep(6); |
| 1964 | rexpo[2] = 0x1b; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1965 | rexpo[3] = gspca_dev->exposure->val; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1966 | i2c_w8(gspca_dev, rexpo); |
| 1967 | } |
| 1968 | } |
| 1969 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1970 | static void setautogain(struct gspca_dev *gspca_dev) |
| 1971 | { |
| 1972 | struct sd *sd = (struct sd *) gspca_dev; |
| 1973 | |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1974 | switch (sd->sensor) { |
| 1975 | case SENSOR_OV7630: |
| 1976 | case SENSOR_OV7648: { |
| 1977 | u8 comb; |
| 1978 | |
| 1979 | if (sd->sensor == SENSOR_OV7630) |
| 1980 | comb = 0xc0; |
| 1981 | else |
| 1982 | comb = 0xa0; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1983 | if (gspca_dev->autogain->val) |
Hans de Goede | 1fec747 | 2009-06-18 06:05:07 -0300 | [diff] [blame] | 1984 | comb |= 0x03; |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 1985 | i2c_w1(&sd->gspca_dev, 0x13, comb); |
| 1986 | return; |
| 1987 | } |
| 1988 | } |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 1989 | if (gspca_dev->autogain->val) |
Jean-Francois Moine | f50ba1b | 2008-09-03 17:12:14 -0300 | [diff] [blame] | 1990 | sd->ag_cnt = AG_CNT_START; |
| 1991 | else |
| 1992 | sd->ag_cnt = -1; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 1993 | } |
| 1994 | |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 1995 | static void setgain(struct gspca_dev *gspca_dev) |
| 1996 | { |
| 1997 | struct sd *sd = (struct sd *) gspca_dev; |
| 1998 | |
| 1999 | if (sd->sensor == SENSOR_PO2030N) { |
| 2000 | u8 rgain[] = /* 15: gain */ |
| 2001 | {0xa1, 0x6e, 0x15, 0x00, 0x40, 0x00, 0x00, 0x15}; |
| 2002 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2003 | rgain[3] = gspca_dev->gain->val; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2004 | i2c_w8(gspca_dev, rgain); |
| 2005 | } |
| 2006 | } |
| 2007 | |
Németh Márton | 76ad3b6 | 2010-10-19 03:33:47 -0300 | [diff] [blame] | 2008 | static void sethvflip(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 2009 | { |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2010 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 2011 | u8 comn; |
| 2012 | |
Jean-François Moine | f6b22e5 | 2010-02-18 04:12:06 -0300 | [diff] [blame] | 2013 | switch (sd->sensor) { |
| 2014 | case SENSOR_HV7131R: |
| 2015 | comn = 0x18; /* clkdiv = 1, ablcen = 1 */ |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2016 | if (sd->vflip->val) |
Jean-François Moine | f6b22e5 | 2010-02-18 04:12:06 -0300 | [diff] [blame] | 2017 | comn |= 0x01; |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2018 | i2c_w1(gspca_dev, 0x01, comn); /* sctra */ |
Jean-François Moine | f6b22e5 | 2010-02-18 04:12:06 -0300 | [diff] [blame] | 2019 | break; |
| 2020 | case SENSOR_OV7630: |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 2021 | comn = 0x02; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2022 | if (!sd->vflip->val) |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 2023 | comn |= 0x80; |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2024 | i2c_w1(gspca_dev, 0x75, comn); |
Jean-François Moine | f6b22e5 | 2010-02-18 04:12:06 -0300 | [diff] [blame] | 2025 | break; |
Németh Márton | 76ad3b6 | 2010-10-19 03:33:47 -0300 | [diff] [blame] | 2026 | case SENSOR_OV7648: |
Jean-Francois Moine | 2797ba2 | 2009-02-05 15:12:24 -0300 | [diff] [blame] | 2027 | comn = 0x06; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2028 | if (sd->vflip->val) |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 2029 | comn |= 0x80; |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2030 | i2c_w1(gspca_dev, 0x75, comn); |
Jean-François Moine | f6b22e5 | 2010-02-18 04:12:06 -0300 | [diff] [blame] | 2031 | break; |
Németh Márton | 76ad3b6 | 2010-10-19 03:33:47 -0300 | [diff] [blame] | 2032 | case SENSOR_PO2030N: |
| 2033 | /* Reg. 0x1E: Timing Generator Control Register 2 (Tgcontrol2) |
| 2034 | * (reset value: 0x0A) |
| 2035 | * bit7: HM: Horizontal Mirror: 0: disable, 1: enable |
| 2036 | * bit6: VM: Vertical Mirror: 0: disable, 1: enable |
| 2037 | * bit5: ST: Shutter Selection: 0: electrical, 1: mechanical |
| 2038 | * bit4: FT: Single Frame Transfer: 0: disable, 1: enable |
| 2039 | * bit3-0: X |
| 2040 | */ |
| 2041 | comn = 0x0a; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2042 | if (sd->hflip->val) |
Németh Márton | 76ad3b6 | 2010-10-19 03:33:47 -0300 | [diff] [blame] | 2043 | comn |= 0x80; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2044 | if (sd->vflip->val) |
Németh Márton | 76ad3b6 | 2010-10-19 03:33:47 -0300 | [diff] [blame] | 2045 | comn |= 0x40; |
| 2046 | i2c_w1(&sd->gspca_dev, 0x1e, comn); |
| 2047 | break; |
Hans de Goede | f800952 | 2009-06-18 14:29:20 -0300 | [diff] [blame] | 2048 | } |
Jean-Francois Moine | 6c86274 | 2008-09-08 04:57:26 -0300 | [diff] [blame] | 2049 | } |
| 2050 | |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2051 | static void setsharpness(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2052 | { |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2053 | struct sd *sd = (struct sd *) gspca_dev; |
| 2054 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2055 | reg_w1(gspca_dev, 0x99, sd->sharpness->val); |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2056 | } |
| 2057 | |
Jean-François Moine | 3afef85 | 2011-01-13 06:39:11 -0300 | [diff] [blame] | 2058 | static void setillum(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 2059 | { |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2060 | struct sd *sd = (struct sd *) gspca_dev; |
| 2061 | |
Jean-François Moine | a63d601 | 2011-01-13 07:56:00 -0300 | [diff] [blame] | 2062 | switch (sd->sensor) { |
| 2063 | case SENSOR_ADCM1700: |
| 2064 | reg_w1(gspca_dev, 0x02, /* gpio */ |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2065 | sd->illum->val ? 0x64 : 0x60); |
Jean-François Moine | a63d601 | 2011-01-13 07:56:00 -0300 | [diff] [blame] | 2066 | break; |
| 2067 | case SENSOR_MT9V111: |
Jean-François Moine | 5c95606 | 2011-02-10 08:03:24 -0300 | [diff] [blame] | 2068 | reg_w1(gspca_dev, 0x02, |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2069 | sd->illum->val ? 0x77 : 0x74); |
Jean-François Moine | 5c95606 | 2011-02-10 08:03:24 -0300 | [diff] [blame] | 2070 | /* should have been: */ |
| 2071 | /* 0x55 : 0x54); * 370i */ |
| 2072 | /* 0x66 : 0x64); * Clip */ |
Jean-François Moine | a63d601 | 2011-01-13 07:56:00 -0300 | [diff] [blame] | 2073 | break; |
| 2074 | } |
Jean-Francois Moine | 0cae896 | 2008-10-17 07:48:24 -0300 | [diff] [blame] | 2075 | } |
| 2076 | |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2077 | static void setfreq(struct gspca_dev *gspca_dev) |
| 2078 | { |
| 2079 | struct sd *sd = (struct sd *) gspca_dev; |
| 2080 | |
| 2081 | if (sd->sensor == SENSOR_OV7660) { |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 2082 | u8 com8; |
| 2083 | |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 2084 | com8 = 0xdf; /* auto gain/wb/expo */ |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2085 | switch (sd->freq->val) { |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2086 | case 0: /* Banding filter disabled */ |
Jean-Francois Moine | 47f7f6f | 2009-08-25 06:14:54 -0300 | [diff] [blame] | 2087 | i2c_w1(gspca_dev, 0x13, com8 | 0x20); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2088 | break; |
| 2089 | case 1: /* 50 hz */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 2090 | i2c_w1(gspca_dev, 0x13, com8); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2091 | i2c_w1(gspca_dev, 0x3b, 0x0a); |
| 2092 | break; |
| 2093 | case 2: /* 60 hz */ |
Jean-Francois Moine | d8f400e | 2009-07-08 06:33:44 -0300 | [diff] [blame] | 2094 | i2c_w1(gspca_dev, 0x13, com8); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2095 | i2c_w1(gspca_dev, 0x3b, 0x02); |
| 2096 | break; |
| 2097 | } |
| 2098 | } else { |
| 2099 | u8 reg2a = 0, reg2b = 0, reg2d = 0; |
| 2100 | |
| 2101 | /* Get reg2a / reg2d base values */ |
| 2102 | switch (sd->sensor) { |
| 2103 | case SENSOR_OV7630: |
| 2104 | reg2a = 0x08; |
| 2105 | reg2d = 0x01; |
| 2106 | break; |
| 2107 | case SENSOR_OV7648: |
| 2108 | reg2a = 0x11; |
| 2109 | reg2d = 0x81; |
| 2110 | break; |
| 2111 | } |
| 2112 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2113 | switch (sd->freq->val) { |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2114 | case 0: /* Banding filter disabled */ |
| 2115 | break; |
| 2116 | case 1: /* 50 hz (filter on and framerate adj) */ |
| 2117 | reg2a |= 0x80; |
| 2118 | reg2b = 0xac; |
| 2119 | reg2d |= 0x04; |
| 2120 | break; |
| 2121 | case 2: /* 60 hz (filter on, no framerate adj) */ |
| 2122 | reg2a |= 0x80; |
| 2123 | reg2d |= 0x04; |
| 2124 | break; |
| 2125 | } |
| 2126 | i2c_w1(gspca_dev, 0x2a, reg2a); |
| 2127 | i2c_w1(gspca_dev, 0x2b, reg2b); |
| 2128 | i2c_w1(gspca_dev, 0x2d, reg2d); |
| 2129 | } |
| 2130 | } |
| 2131 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2132 | static void setjpegqual(struct gspca_dev *gspca_dev) |
| 2133 | { |
| 2134 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2135 | |
Jean-François Moine | dccdccc | 2011-02-10 07:30:03 -0300 | [diff] [blame] | 2136 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2137 | #if USB_BUF_SZ < 64 |
| 2138 | #error "No room enough in usb_buf for quantization table" |
| 2139 | #endif |
Jean-François Moine | dccdccc | 2011-02-10 07:30:03 -0300 | [diff] [blame] | 2140 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64); |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2141 | usb_control_msg(gspca_dev->dev, |
| 2142 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 2143 | 0x08, |
| 2144 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 2145 | 0x0100, 0, |
| 2146 | gspca_dev->usb_buf, 64, |
| 2147 | 500); |
Jean-François Moine | dccdccc | 2011-02-10 07:30:03 -0300 | [diff] [blame] | 2148 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64); |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2149 | usb_control_msg(gspca_dev->dev, |
| 2150 | usb_sndctrlpipe(gspca_dev->dev, 0), |
| 2151 | 0x08, |
| 2152 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
| 2153 | 0x0140, 0, |
| 2154 | gspca_dev->usb_buf, 64, |
| 2155 | 500); |
| 2156 | |
| 2157 | sd->reg18 ^= 0x40; |
| 2158 | reg_w1(gspca_dev, 0x18, sd->reg18); |
| 2159 | } |
| 2160 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2161 | /* JPEG quality update */ |
| 2162 | /* This function is executed from a work queue. */ |
| 2163 | static void qual_upd(struct work_struct *work) |
| 2164 | { |
| 2165 | struct sd *sd = container_of(work, struct sd, work); |
| 2166 | struct gspca_dev *gspca_dev = &sd->gspca_dev; |
| 2167 | |
Hans de Goede | 844db45 | 2012-09-09 07:30:02 -0300 | [diff] [blame] | 2168 | /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */ |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2169 | mutex_lock(&gspca_dev->usb_lock); |
| 2170 | PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality); |
Hans de Goede | 844db45 | 2012-09-09 07:30:02 -0300 | [diff] [blame] | 2171 | gspca_dev->usb_err = 0; |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2172 | setjpegqual(gspca_dev); |
| 2173 | mutex_unlock(&gspca_dev->usb_lock); |
| 2174 | } |
| 2175 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2176 | /* -- start the camera -- */ |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 2177 | static int sd_start(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2178 | { |
| 2179 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2180 | int i; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2181 | u8 reg01, reg17; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2182 | u8 reg0102[2]; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2183 | const u8 *sn9c1xx; |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2184 | const u8 (*init)[8]; |
Jean-Francois Moine | 4f67f3a | 2010-12-14 16:15:00 -0300 | [diff] [blame] | 2185 | const u8 *reg9a; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2186 | int mode; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2187 | static const u8 reg9a_def[] = |
| 2188 | {0x00, 0x40, 0x20, 0x00, 0x00, 0x00}; |
| 2189 | static const u8 reg9a_spec[] = |
| 2190 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; |
| 2191 | static const u8 regd4[] = {0x60, 0x00, 0x00}; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2192 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
| 2193 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2194 | static const u8 CA_adcm1700[] = |
| 2195 | { 0x14, 0xec, 0x0a, 0xf6 }; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2196 | static const u8 CA_po2030n[] = |
| 2197 | { 0x1e, 0xe2, 0x14, 0xec }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2198 | static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2199 | static const u8 CE_gc0307[] = |
| 2200 | { 0x32, 0xce, 0x2d, 0xd3 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2201 | static const u8 CE_ov76xx[] = |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 2202 | { 0x32, 0xdd, 0x32, 0xdd }; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2203 | static const u8 CE_po2030n[] = |
| 2204 | { 0x14, 0xe7, 0x1e, 0xdd }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2205 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2206 | /* create the JPEG header */ |
Ondrej Zary | 1966bc2 | 2013-08-30 17:54:23 -0300 | [diff] [blame] | 2207 | jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height, |
| 2208 | gspca_dev->pixfmt.width, |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2209 | 0x21); /* JPEG 422 */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2210 | |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2211 | /* initialize the bridge */ |
| 2212 | sn9c1xx = sn_tb[sd->sensor]; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2213 | |
| 2214 | /* sensor clock already enabled in sd_init */ |
| 2215 | /* reg_w1(gspca_dev, 0xf1, 0x00); */ |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2216 | reg01 = sn9c1xx[1]; |
Jean-François Moine | 3afef85 | 2011-01-13 06:39:11 -0300 | [diff] [blame] | 2217 | if (sd->flags & F_PDN_INV) |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2218 | reg01 ^= S_PDN_INV; /* power down inverted */ |
| 2219 | reg_w1(gspca_dev, 0x01, reg01); |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2220 | |
| 2221 | /* configure gpio */ |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2222 | reg0102[0] = reg01; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2223 | reg0102[1] = sn9c1xx[2]; |
| 2224 | if (gspca_dev->audio) |
| 2225 | reg0102[1] |= 0x04; /* keep the audio connection */ |
| 2226 | reg_w(gspca_dev, 0x01, reg0102, 2); |
| 2227 | reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); |
| 2228 | reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); |
| 2229 | switch (sd->sensor) { |
| 2230 | case SENSOR_GC0307: |
| 2231 | case SENSOR_OV7660: |
| 2232 | case SENSOR_PO1030: |
| 2233 | case SENSOR_PO2030N: |
| 2234 | case SENSOR_SOI768: |
| 2235 | case SENSOR_SP80708: |
| 2236 | reg9a = reg9a_spec; |
| 2237 | break; |
| 2238 | default: |
| 2239 | reg9a = reg9a_def; |
| 2240 | break; |
| 2241 | } |
| 2242 | reg_w(gspca_dev, 0x9a, reg9a, 6); |
| 2243 | |
| 2244 | reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); |
| 2245 | |
| 2246 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
| 2247 | |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2248 | reg17 = sn9c1xx[0x17]; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2249 | switch (sd->sensor) { |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2250 | case SENSOR_GC0307: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2251 | msleep(50); /*fixme: is it useful? */ |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2252 | break; |
| 2253 | case SENSOR_OM6802: |
| 2254 | msleep(10); |
| 2255 | reg_w1(gspca_dev, 0x02, 0x73); |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2256 | reg17 |= SEN_CLK_EN; |
| 2257 | reg_w1(gspca_dev, 0x17, reg17); |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2258 | reg_w1(gspca_dev, 0x01, 0x22); |
| 2259 | msleep(100); |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2260 | reg01 = SCL_SEL_OD | S_PDN_INV; |
Luiz Ramos | d1520c5 | 2011-07-14 23:08:39 -0300 | [diff] [blame] | 2261 | reg17 &= ~MCK_SIZE_MASK; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2262 | reg17 |= 0x04; /* clock / 4 */ |
| 2263 | break; |
| 2264 | } |
| 2265 | reg01 |= SYS_SEL_48M; |
| 2266 | reg_w1(gspca_dev, 0x01, reg01); |
| 2267 | reg17 |= SEN_CLK_EN; |
| 2268 | reg_w1(gspca_dev, 0x17, reg17); |
| 2269 | reg01 &= ~S_PWR_DN; /* sensor power on */ |
| 2270 | reg_w1(gspca_dev, 0x01, reg01); |
Jean-François Moine | b4b0107 | 2011-11-30 05:58:20 -0300 | [diff] [blame] | 2271 | reg01 &= ~SCL_SEL_OD; /* remove open-drain mode */ |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2272 | reg_w1(gspca_dev, 0x01, reg01); |
| 2273 | |
| 2274 | switch (sd->sensor) { |
| 2275 | case SENSOR_HV7131R: |
| 2276 | hv7131r_probe(gspca_dev); /*fixme: is it useful? */ |
| 2277 | break; |
| 2278 | case SENSOR_OM6802: |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2279 | msleep(10); |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2280 | reg_w1(gspca_dev, 0x01, reg01); |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2281 | i2c_w8(gspca_dev, om6802_init0[0]); |
| 2282 | i2c_w8(gspca_dev, om6802_init0[1]); |
| 2283 | msleep(15); |
| 2284 | reg_w1(gspca_dev, 0x02, 0x71); |
| 2285 | msleep(150); |
| 2286 | break; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2287 | case SENSOR_SP80708: |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2288 | msleep(100); |
| 2289 | reg_w1(gspca_dev, 0x02, 0x62); |
| 2290 | break; |
Jean-Francois Moine | 5e68f40 | 2010-12-14 16:14:10 -0300 | [diff] [blame] | 2291 | } |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2292 | |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2293 | /* initialize the sensor */ |
| 2294 | i2c_w_seq(gspca_dev, sensor_init[sd->sensor]); |
| 2295 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2296 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); |
| 2297 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); |
| 2298 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); |
| 2299 | reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]); |
| 2300 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2301 | if (sd->sensor == SENSOR_ADCM1700) { |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2302 | reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */ |
| 2303 | reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2304 | } else { |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2305 | reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */ |
| 2306 | reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2307 | } |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2308 | reg_w1(gspca_dev, 0xc6, 0x00); |
| 2309 | reg_w1(gspca_dev, 0xc7, 0x00); |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2310 | if (sd->sensor == SENSOR_ADCM1700) { |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2311 | reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */ |
| 2312 | reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2313 | } else { |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2314 | reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */ |
| 2315 | reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */ |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2316 | } |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2317 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2318 | switch (sd->sensor) { |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2319 | case SENSOR_OM6802: |
| 2320 | /* case SENSOR_OV7648: * fixme: sometimes */ |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 2321 | break; |
Jean-Francois Moine | 568788a | 2008-07-15 11:46:06 -0300 | [diff] [blame] | 2322 | default: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2323 | reg17 |= DEF_EN; |
Jean-Francois Moine | 568788a | 2008-07-15 11:46:06 -0300 | [diff] [blame] | 2324 | break; |
| 2325 | } |
Jean-Francois Moine | 8f47a3c | 2008-07-29 14:14:04 -0300 | [diff] [blame] | 2326 | reg_w1(gspca_dev, 0x17, reg17); |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2327 | |
| 2328 | reg_w1(gspca_dev, 0x05, 0x00); /* red */ |
| 2329 | reg_w1(gspca_dev, 0x07, 0x00); /* green */ |
| 2330 | reg_w1(gspca_dev, 0x06, 0x00); /* blue */ |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2331 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
Jean-Francois Moine | b083b92 | 2009-02-01 14:20:07 -0300 | [diff] [blame] | 2332 | |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 2333 | setgamma(gspca_dev); |
| 2334 | |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2335 | /*fixme: 8 times with all zeroes and 1 or 2 times with normal values */ |
Jean-Francois Moine | 05b809c | 2008-09-03 16:47:59 -0300 | [diff] [blame] | 2336 | for (i = 0; i < 8; i++) |
| 2337 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 2338 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2339 | case SENSOR_ADCM1700: |
Jean-Francois Moine | c8b9b2ca | 2009-04-26 14:46:12 -0300 | [diff] [blame] | 2340 | case SENSOR_OV7660: |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 2341 | case SENSOR_SP80708: |
| 2342 | reg_w1(gspca_dev, 0x9a, 0x05); |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2343 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2344 | case SENSOR_GC0307: |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2345 | case SENSOR_MT9V111: |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2346 | case SENSOR_MI0360B: |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2347 | reg_w1(gspca_dev, 0x9a, 0x07); |
| 2348 | break; |
Jean-François Moine | 0a85c74 | 2010-04-25 14:33:31 -0300 | [diff] [blame] | 2349 | case SENSOR_OV7630: |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2350 | case SENSOR_OV7648: |
| 2351 | reg_w1(gspca_dev, 0x9a, 0x0a); |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 2352 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2353 | case SENSOR_PO2030N: |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2354 | case SENSOR_SOI768: |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2355 | reg_w1(gspca_dev, 0x9a, 0x06); |
| 2356 | break; |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 2357 | default: |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2358 | reg_w1(gspca_dev, 0x9a, 0x08); |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 2359 | break; |
| 2360 | } |
Jean-François Moine | 72b667e | 2010-10-02 04:35:25 -0300 | [diff] [blame] | 2361 | setsharpness(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2362 | |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2363 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
Jean-Francois Moine | 878b35a | 2009-12-30 04:53:07 -0300 | [diff] [blame] | 2364 | reg_w1(gspca_dev, 0x05, 0x20); /* red */ |
| 2365 | reg_w1(gspca_dev, 0x07, 0x20); /* green */ |
| 2366 | reg_w1(gspca_dev, 0x06, 0x20); /* blue */ |
Jean-Francois Moine | 23a9827 | 2009-11-02 09:10:25 -0300 | [diff] [blame] | 2367 | |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2368 | init = NULL; |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2369 | mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2370 | reg01 |= SYS_SEL_48M | V_TX_EN; |
| 2371 | reg17 &= ~MCK_SIZE_MASK; |
| 2372 | reg17 |= 0x02; /* clock / 2 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2373 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2374 | case SENSOR_ADCM1700: |
| 2375 | init = adcm1700_sensor_param1; |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2376 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2377 | case SENSOR_GC0307: |
| 2378 | init = gc0307_sensor_param1; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2379 | break; |
| 2380 | case SENSOR_HV7131R: |
| 2381 | case SENSOR_MI0360: |
Jean-François Moine | b813b0c | 2011-08-10 05:54:34 -0300 | [diff] [blame] | 2382 | if (!mode) |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2383 | reg01 &= ~SYS_SEL_48M; /* 640x480: clk 24Mhz */ |
| 2384 | reg17 &= ~MCK_SIZE_MASK; |
| 2385 | reg17 |= 0x01; /* clock / 1 */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2386 | break; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2387 | case SENSOR_MI0360B: |
| 2388 | init = mi0360b_sensor_param1; |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2389 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2390 | case SENSOR_MO4000: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2391 | if (mode) { /* if 320x240 */ |
| 2392 | reg01 &= ~SYS_SEL_48M; /* clk 24Mz */ |
| 2393 | reg17 &= ~MCK_SIZE_MASK; |
| 2394 | reg17 |= 0x01; /* clock / 1 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2395 | } |
| 2396 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 2397 | case SENSOR_MT9V111: |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2398 | init = mt9v111_sensor_param1; |
Jean-Francois Moine | 0fbe057 | 2009-01-30 12:14:02 -0300 | [diff] [blame] | 2399 | break; |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 2400 | case SENSOR_OM6802: |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2401 | init = om6802_sensor_param1; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2402 | if (!mode) { /* if 640x480 */ |
| 2403 | reg17 &= ~MCK_SIZE_MASK; |
Jean-François Moine | aa777a8 | 2010-12-28 07:39:13 -0300 | [diff] [blame] | 2404 | reg17 |= 0x04; /* clock / 4 */ |
Jean-François Moine | 822f6e2 | 2011-08-09 15:13:50 -0300 | [diff] [blame] | 2405 | } else { |
| 2406 | reg01 &= ~SYS_SEL_48M; /* clk 24Mz */ |
| 2407 | reg17 &= ~MCK_SIZE_MASK; |
| 2408 | reg17 |= 0x02; /* clock / 2 */ |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2409 | } |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 2410 | break; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2411 | case SENSOR_OV7630: |
Jean-François Moine | bdd2b93 | 2010-04-25 14:23:39 -0300 | [diff] [blame] | 2412 | init = ov7630_sensor_param1; |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2413 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2414 | case SENSOR_OV7648: |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2415 | init = ov7648_sensor_param1; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2416 | reg17 &= ~MCK_SIZE_MASK; |
| 2417 | reg17 |= 0x01; /* clock / 1 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2418 | break; |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 2419 | case SENSOR_OV7660: |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2420 | init = ov7660_sensor_param1; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2421 | break; |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 2422 | case SENSOR_PO1030: |
| 2423 | init = po1030_sensor_param1; |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 2424 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2425 | case SENSOR_PO2030N: |
| 2426 | init = po2030n_sensor_param1; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2427 | break; |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2428 | case SENSOR_SOI768: |
| 2429 | init = soi768_sensor_param1; |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2430 | break; |
Jean-François Moine | 0303a90 | 2010-10-21 04:05:15 -0300 | [diff] [blame] | 2431 | case SENSOR_SP80708: |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2432 | init = sp80708_sensor_param1; |
Jean-Francois Moine | 5e31dc8 | 2009-02-01 13:59:42 -0300 | [diff] [blame] | 2433 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2434 | } |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2435 | |
| 2436 | /* more sensor initialization - param1 */ |
| 2437 | if (init != NULL) { |
| 2438 | i2c_w_seq(gspca_dev, init); |
| 2439 | /* init = NULL; */ |
| 2440 | } |
| 2441 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 2442 | reg_w(gspca_dev, 0xc0, C0, 6); |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2443 | switch (sd->sensor) { |
| 2444 | case SENSOR_ADCM1700: |
| 2445 | case SENSOR_GC0307: |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2446 | case SENSOR_SOI768: |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2447 | reg_w(gspca_dev, 0xca, CA_adcm1700, 4); |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2448 | break; |
| 2449 | case SENSOR_PO2030N: |
| 2450 | reg_w(gspca_dev, 0xca, CA_po2030n, 4); |
| 2451 | break; |
| 2452 | default: |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2453 | reg_w(gspca_dev, 0xca, CA, 4); |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2454 | break; |
| 2455 | } |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2456 | switch (sd->sensor) { |
Jean-Francois Moine | 6467757 | 2009-12-20 12:31:28 -0300 | [diff] [blame] | 2457 | case SENSOR_ADCM1700: |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2458 | case SENSOR_OV7630: |
| 2459 | case SENSOR_OV7648: |
Jean-Francois Moine | 674cbc6 | 2008-10-02 08:06:59 -0300 | [diff] [blame] | 2460 | case SENSOR_OV7660: |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2461 | case SENSOR_SOI768: |
Jean-Francois Moine | 6ab0b17 | 2008-09-03 16:47:34 -0300 | [diff] [blame] | 2462 | reg_w(gspca_dev, 0xce, CE_ov76xx, 4); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2463 | break; |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2464 | case SENSOR_GC0307: |
| 2465 | reg_w(gspca_dev, 0xce, CE_gc0307, 4); |
| 2466 | break; |
| 2467 | case SENSOR_PO2030N: |
| 2468 | reg_w(gspca_dev, 0xce, CE_po2030n, 4); |
| 2469 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2470 | default: |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 2471 | reg_w(gspca_dev, 0xce, CE, 4); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2472 | /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */ |
| 2473 | break; |
| 2474 | } |
| 2475 | |
| 2476 | /* here change size mode 0 -> VGA; 1 -> CIF */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 2477 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; |
| 2478 | reg_w1(gspca_dev, 0x18, sd->reg18); |
| 2479 | setjpegqual(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2480 | |
Jean-Francois Moine | 6001761 | 2008-07-18 08:46:19 -0300 | [diff] [blame] | 2481 | reg_w1(gspca_dev, 0x17, reg17); |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2482 | reg_w1(gspca_dev, 0x01, reg01); |
| 2483 | sd->reg01 = reg01; |
| 2484 | sd->reg17 = reg17; |
Jean-Francois Moine | 3fccb77 | 2009-11-02 09:54:04 -0300 | [diff] [blame] | 2485 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2486 | sd->pktsz = sd->npkt = 0; |
| 2487 | sd->nchg = sd->short_mark = 0; |
| 2488 | sd->work_thread = create_singlethread_workqueue(MODULE_NAME); |
| 2489 | |
Jean-François Moine | 4bf8b67 | 2010-09-25 06:12:44 -0300 | [diff] [blame] | 2490 | return gspca_dev->usb_err; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2491 | } |
| 2492 | |
| 2493 | static void sd_stopN(struct gspca_dev *gspca_dev) |
| 2494 | { |
| 2495 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2496 | static const u8 stophv7131[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2497 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2498 | static const u8 stopmi0360[] = |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2499 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2500 | static const u8 stopov7648[] = |
Jean-Francois Moine | 6270330 | 2008-11-11 08:42:56 -0300 | [diff] [blame] | 2501 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2502 | static const u8 stopsoi768[] = |
| 2503 | { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 }; |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2504 | u8 reg01; |
| 2505 | u8 reg17; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2506 | |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2507 | reg01 = sd->reg01; |
| 2508 | reg17 = sd->reg17 & ~SEN_CLK_EN; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2509 | switch (sd->sensor) { |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2510 | case SENSOR_ADCM1700: |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2511 | case SENSOR_GC0307: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2512 | case SENSOR_PO2030N: |
| 2513 | case SENSOR_SP80708: |
| 2514 | reg01 |= LED; |
| 2515 | reg_w1(gspca_dev, 0x01, reg01); |
| 2516 | reg01 &= ~(LED | V_TX_EN); |
| 2517 | reg_w1(gspca_dev, 0x01, reg01); |
| 2518 | /* reg_w1(gspca_dev, 0x02, 0x??); * LED off ? */ |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2519 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2520 | case SENSOR_HV7131R: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2521 | reg01 &= ~V_TX_EN; |
| 2522 | reg_w1(gspca_dev, 0x01, reg01); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 2523 | i2c_w8(gspca_dev, stophv7131); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2524 | break; |
| 2525 | case SENSOR_MI0360: |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2526 | case SENSOR_MI0360B: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2527 | reg01 &= ~V_TX_EN; |
| 2528 | reg_w1(gspca_dev, 0x01, reg01); |
| 2529 | /* reg_w1(gspca_dev, 0x02, 0x40); * LED off ? */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 2530 | i2c_w8(gspca_dev, stopmi0360); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2531 | break; |
Jean-Francois Moine | 3ef2c5b | 2009-01-29 04:59:45 -0300 | [diff] [blame] | 2532 | case SENSOR_MT9V111: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2533 | case SENSOR_OM6802: |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 2534 | case SENSOR_PO1030: |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2535 | reg01 &= ~V_TX_EN; |
| 2536 | reg_w1(gspca_dev, 0x01, reg01); |
| 2537 | break; |
| 2538 | case SENSOR_OV7630: |
| 2539 | case SENSOR_OV7648: |
| 2540 | reg01 &= ~V_TX_EN; |
| 2541 | reg_w1(gspca_dev, 0x01, reg01); |
| 2542 | i2c_w8(gspca_dev, stopov7648); |
| 2543 | break; |
| 2544 | case SENSOR_OV7660: |
| 2545 | reg01 &= ~V_TX_EN; |
| 2546 | reg_w1(gspca_dev, 0x01, reg01); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2547 | break; |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2548 | case SENSOR_SOI768: |
| 2549 | i2c_w8(gspca_dev, stopsoi768); |
Jean-François Moine | 03ed2a1 | 2010-04-25 14:45:43 -0300 | [diff] [blame] | 2550 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2551 | } |
Jean-Francois Moine | 0e4d413 | 2010-12-14 16:17:40 -0300 | [diff] [blame] | 2552 | |
| 2553 | reg01 |= SCL_SEL_OD; |
| 2554 | reg_w1(gspca_dev, 0x01, reg01); |
| 2555 | reg01 |= S_PWR_DN; /* sensor power down */ |
| 2556 | reg_w1(gspca_dev, 0x01, reg01); |
| 2557 | reg_w1(gspca_dev, 0x17, reg17); |
| 2558 | reg01 &= ~SYS_SEL_48M; /* clock 24MHz */ |
| 2559 | reg_w1(gspca_dev, 0x01, reg01); |
| 2560 | reg01 |= LED; |
| 2561 | reg_w1(gspca_dev, 0x01, reg01); |
Hans de Goede | 9712a8b | 2010-01-31 12:54:29 -0300 | [diff] [blame] | 2562 | /* Don't disable sensor clock as that disables the button on the cam */ |
| 2563 | /* reg_w1(gspca_dev, 0xf1, 0x01); */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2564 | } |
| 2565 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2566 | /* called on streamoff with alt==0 and on disconnect */ |
| 2567 | /* the usb_lock is held at entry - restore on exit */ |
| 2568 | static void sd_stop0(struct gspca_dev *gspca_dev) |
| 2569 | { |
| 2570 | struct sd *sd = (struct sd *) gspca_dev; |
| 2571 | |
| 2572 | if (sd->work_thread != NULL) { |
| 2573 | mutex_unlock(&gspca_dev->usb_lock); |
| 2574 | destroy_workqueue(sd->work_thread); |
| 2575 | mutex_lock(&gspca_dev->usb_lock); |
| 2576 | sd->work_thread = NULL; |
| 2577 | } |
| 2578 | } |
| 2579 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2580 | static void do_autogain(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2581 | { |
| 2582 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2583 | int delta; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2584 | int expotimes; |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2585 | u8 luma_mean = 130; |
| 2586 | u8 luma_delta = 20; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2587 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2588 | /* Thanks S., without your advice, autobright should not work :) */ |
| 2589 | if (sd->ag_cnt < 0) |
| 2590 | return; |
| 2591 | if (--sd->ag_cnt >= 0) |
| 2592 | return; |
| 2593 | sd->ag_cnt = AG_CNT_START; |
| 2594 | |
| 2595 | delta = atomic_read(&sd->avg_lum); |
| 2596 | PDEBUG(D_FRAM, "mean lum %d", delta); |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2597 | |
| 2598 | if (sd->sensor == SENSOR_PO2030N) { |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2599 | gspca_expo_autogain(gspca_dev, delta, luma_mean, luma_delta, |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2600 | 15, 1024); |
| 2601 | return; |
| 2602 | } |
| 2603 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2604 | if (delta < luma_mean - luma_delta || |
| 2605 | delta > luma_mean + luma_delta) { |
| 2606 | switch (sd->sensor) { |
Jean-François Moine | c26b12d | 2010-04-02 07:08:39 -0300 | [diff] [blame] | 2607 | case SENSOR_GC0307: |
| 2608 | expotimes = sd->exposure; |
| 2609 | expotimes += (luma_mean - delta) >> 6; |
| 2610 | if (expotimes < 0) |
| 2611 | expotimes = 0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2612 | sd->exposure = expo_adjust(gspca_dev, |
Jean-François Moine | c26b12d | 2010-04-02 07:08:39 -0300 | [diff] [blame] | 2613 | (unsigned int) expotimes); |
| 2614 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2615 | case SENSOR_HV7131R: |
| 2616 | expotimes = sd->exposure >> 8; |
| 2617 | expotimes += (luma_mean - delta) >> 4; |
| 2618 | if (expotimes < 0) |
| 2619 | expotimes = 0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2620 | sd->exposure = expo_adjust(gspca_dev, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2621 | (unsigned int) (expotimes << 8)); |
| 2622 | break; |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 2623 | case SENSOR_OM6802: |
Jean-François Moine | 2220367 | 2011-02-10 07:49:32 -0300 | [diff] [blame] | 2624 | case SENSOR_MT9V111: |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 2625 | expotimes = sd->exposure; |
| 2626 | expotimes += (luma_mean - delta) >> 2; |
| 2627 | if (expotimes < 0) |
| 2628 | expotimes = 0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2629 | sd->exposure = expo_adjust(gspca_dev, |
Amauri Magagna | 46b4f2a | 2009-10-17 07:21:29 -0300 | [diff] [blame] | 2630 | (unsigned int) expotimes); |
| 2631 | setredblue(gspca_dev); |
| 2632 | break; |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2633 | default: |
| 2634 | /* case SENSOR_MO4000: */ |
| 2635 | /* case SENSOR_MI0360: */ |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2636 | /* case SENSOR_MI0360B: */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2637 | expotimes = sd->exposure; |
| 2638 | expotimes += (luma_mean - delta) >> 6; |
| 2639 | if (expotimes < 0) |
| 2640 | expotimes = 0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2641 | sd->exposure = expo_adjust(gspca_dev, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2642 | (unsigned int) expotimes); |
Jean-Francois Moine | 403123d | 2008-11-26 04:46:15 -0300 | [diff] [blame] | 2643 | setredblue(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2644 | break; |
| 2645 | } |
| 2646 | } |
| 2647 | } |
| 2648 | |
Jean-François Moine | 0f77f40 | 2011-02-10 07:01:30 -0300 | [diff] [blame] | 2649 | /* set the average luminosity from an isoc marker */ |
| 2650 | static void set_lum(struct sd *sd, |
| 2651 | u8 *data) |
| 2652 | { |
| 2653 | int avg_lum; |
| 2654 | |
| 2655 | /* w0 w1 w2 |
| 2656 | * w3 w4 w5 |
| 2657 | * w6 w7 w8 |
| 2658 | */ |
| 2659 | avg_lum = (data[27] << 8) + data[28] /* w3 */ |
| 2660 | |
| 2661 | + (data[31] << 8) + data[32] /* w5 */ |
| 2662 | |
| 2663 | + (data[23] << 8) + data[24] /* w1 */ |
| 2664 | |
| 2665 | + (data[35] << 8) + data[36] /* w7 */ |
| 2666 | |
| 2667 | + (data[29] << 10) + (data[30] << 2); /* w4 * 4 */ |
| 2668 | avg_lum >>= 10; |
| 2669 | atomic_set(&sd->avg_lum, avg_lum); |
| 2670 | } |
| 2671 | |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2672 | /* scan the URB packets */ |
| 2673 | /* This function is run at interrupt level. */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2674 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 9881918 | 2009-01-19 07:37:33 -0300 | [diff] [blame] | 2675 | u8 *data, /* isoc packet */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2676 | int len) /* iso packet length */ |
| 2677 | { |
| 2678 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2679 | int i, new_qual; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2680 | |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2681 | /* |
| 2682 | * A frame ends on the marker |
| 2683 | * ff ff 00 c4 c4 96 .. |
| 2684 | * which is 62 bytes long and is followed by various information |
| 2685 | * including statuses and luminosity. |
| 2686 | * |
| 2687 | * A marker may be splitted on two packets. |
| 2688 | * |
| 2689 | * The 6th byte of a marker contains the bits: |
| 2690 | * 0x08: USB full |
| 2691 | * 0xc0: frame sequence |
| 2692 | * When the bit 'USB full' is set, the frame must be discarded; |
| 2693 | * this is also the case when the 2 bytes before the marker are |
| 2694 | * not the JPEG end of frame ('ff d9'). |
| 2695 | */ |
| 2696 | |
Jean-François Moine | 788ab1b | 2012-05-02 04:05:18 -0300 | [diff] [blame] | 2697 | /* count the packets and their size */ |
| 2698 | sd->npkt++; |
| 2699 | sd->pktsz += len; |
| 2700 | |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2701 | /*fixme: assumption about the following code: |
| 2702 | * - there can be only one marker in a packet |
| 2703 | */ |
| 2704 | |
| 2705 | /* skip the remaining bytes of a short marker */ |
| 2706 | i = sd->short_mark; |
| 2707 | if (i != 0) { |
| 2708 | sd->short_mark = 0; |
| 2709 | if (i < 0 /* if 'ff' at end of previous packet */ |
| 2710 | && data[0] == 0xff |
| 2711 | && data[1] == 0x00) |
| 2712 | goto marker_found; |
| 2713 | if (data[0] == 0xff && data[1] == 0xff) { |
| 2714 | i = 0; |
| 2715 | goto marker_found; |
| 2716 | } |
| 2717 | len -= i; |
| 2718 | if (len <= 0) |
| 2719 | return; |
| 2720 | data += i; |
| 2721 | } |
| 2722 | |
| 2723 | /* search backwards if there is a marker in the packet */ |
| 2724 | for (i = len - 1; --i >= 0; ) { |
| 2725 | if (data[i] != 0xff) { |
| 2726 | i--; |
| 2727 | continue; |
| 2728 | } |
| 2729 | if (data[i + 1] == 0xff) { |
| 2730 | |
| 2731 | /* (there may be 'ff ff' inside a marker) */ |
| 2732 | if (i + 2 >= len || data[i + 2] == 0x00) |
| 2733 | goto marker_found; |
| 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | /* no marker found */ |
| 2738 | /* add the JPEG header if first fragment */ |
| 2739 | if (data[len - 1] == 0xff) |
| 2740 | sd->short_mark = -1; |
| 2741 | if (gspca_dev->last_packet_type == LAST_PACKET) |
Jean-François Moine | a95bd64 | 2010-10-01 07:54:30 -0300 | [diff] [blame] | 2742 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
| 2743 | sd->jpeg_hdr, JPEG_HDR_SZ); |
Jean-François Moine | a95bd64 | 2010-10-01 07:54:30 -0300 | [diff] [blame] | 2744 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2745 | return; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2746 | |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2747 | /* marker found */ |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2748 | /* if some error, discard the frame and decrease the quality */ |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2749 | marker_found: |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2750 | new_qual = 0; |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2751 | if (i > 2) { |
| 2752 | if (data[i - 2] != 0xff || data[i - 1] != 0xd9) { |
| 2753 | gspca_dev->last_packet_type = DISCARD_PACKET; |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2754 | new_qual = -3; |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2755 | } |
| 2756 | } else if (i + 6 < len) { |
| 2757 | if (data[i + 6] & 0x08) { |
| 2758 | gspca_dev->last_packet_type = DISCARD_PACKET; |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2759 | new_qual = -5; |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2760 | } |
| 2761 | } |
Jean-François Moine | a95bd64 | 2010-10-01 07:54:30 -0300 | [diff] [blame] | 2762 | |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2763 | gspca_frame_add(gspca_dev, LAST_PACKET, data, i); |
| 2764 | |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2765 | /* compute the filling rate and a new JPEG quality */ |
| 2766 | if (new_qual == 0) { |
| 2767 | int r; |
| 2768 | |
| 2769 | r = (sd->pktsz * 100) / |
| 2770 | (sd->npkt * |
| 2771 | gspca_dev->urb[0]->iso_frame_desc[0].length); |
| 2772 | if (r >= 85) |
| 2773 | new_qual = -3; |
| 2774 | else if (r < 75) |
| 2775 | new_qual = 2; |
| 2776 | } |
| 2777 | if (new_qual != 0) { |
| 2778 | sd->nchg += new_qual; |
| 2779 | if (sd->nchg < -6 || sd->nchg >= 12) { |
| 2780 | sd->nchg = 0; |
| 2781 | new_qual += sd->quality; |
| 2782 | if (new_qual < QUALITY_MIN) |
| 2783 | new_qual = QUALITY_MIN; |
| 2784 | else if (new_qual > QUALITY_MAX) |
| 2785 | new_qual = QUALITY_MAX; |
| 2786 | if (new_qual != sd->quality) { |
| 2787 | sd->quality = new_qual; |
| 2788 | queue_work(sd->work_thread, &sd->work); |
| 2789 | } |
| 2790 | } |
| 2791 | } else { |
| 2792 | sd->nchg = 0; |
| 2793 | } |
| 2794 | sd->pktsz = sd->npkt = 0; |
| 2795 | |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2796 | /* if the marker is smaller than 62 bytes, |
| 2797 | * memorize the number of bytes to skip in the next packet */ |
| 2798 | if (i + 62 > len) { /* no more usable data */ |
| 2799 | sd->short_mark = i + 62 - len; |
| 2800 | return; |
| 2801 | } |
Jean-François Moine | 0f77f40 | 2011-02-10 07:01:30 -0300 | [diff] [blame] | 2802 | if (sd->ag_cnt >= 0) |
Jean-François Moine | a4a3076 | 2011-02-10 07:15:24 -0300 | [diff] [blame] | 2803 | set_lum(sd, data + i); |
| 2804 | |
| 2805 | /* if more data, start a new frame */ |
| 2806 | i += 62; |
| 2807 | if (i < len) { |
| 2808 | data += i; |
| 2809 | len -= i; |
| 2810 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
| 2811 | sd->jpeg_hdr, JPEG_HDR_SZ); |
| 2812 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
| 2813 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2814 | } |
| 2815 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2816 | static int sd_s_ctrl(struct v4l2_ctrl *ctrl) |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2817 | { |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2818 | struct gspca_dev *gspca_dev = |
| 2819 | container_of(ctrl->handler, struct gspca_dev, ctrl_handler); |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2820 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2821 | gspca_dev->usb_err = 0; |
Jean-François Moine | a7705c0 | 2012-02-27 06:57:04 -0300 | [diff] [blame] | 2822 | |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2823 | if (!gspca_dev->streaming) |
| 2824 | return 0; |
| 2825 | |
| 2826 | switch (ctrl->id) { |
| 2827 | case V4L2_CID_BRIGHTNESS: |
| 2828 | setbrightness(gspca_dev); |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2829 | break; |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2830 | case V4L2_CID_CONTRAST: |
| 2831 | setcontrast(gspca_dev); |
| 2832 | break; |
| 2833 | case V4L2_CID_SATURATION: |
| 2834 | setcolors(gspca_dev); |
| 2835 | break; |
| 2836 | case V4L2_CID_RED_BALANCE: |
| 2837 | setredblue(gspca_dev); |
| 2838 | break; |
| 2839 | case V4L2_CID_GAMMA: |
| 2840 | setgamma(gspca_dev); |
| 2841 | break; |
| 2842 | case V4L2_CID_AUTOGAIN: |
| 2843 | setautogain(gspca_dev); |
| 2844 | setexposure(gspca_dev); |
| 2845 | setgain(gspca_dev); |
| 2846 | break; |
| 2847 | case V4L2_CID_VFLIP: |
| 2848 | sethvflip(gspca_dev); |
| 2849 | break; |
| 2850 | case V4L2_CID_SHARPNESS: |
| 2851 | setsharpness(gspca_dev); |
| 2852 | break; |
| 2853 | case V4L2_CID_ILLUMINATORS_1: |
| 2854 | setillum(gspca_dev); |
| 2855 | break; |
| 2856 | case V4L2_CID_POWER_LINE_FREQUENCY: |
| 2857 | setfreq(gspca_dev); |
| 2858 | break; |
| 2859 | default: |
| 2860 | return -EINVAL; |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2861 | } |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2862 | return gspca_dev->usb_err; |
Hans de Goede | 37c6dbe | 2009-06-18 07:35:36 -0300 | [diff] [blame] | 2863 | } |
| 2864 | |
Peter Senna Tschudin | f11ef42 | 2013-01-24 19:29:08 -0300 | [diff] [blame] | 2865 | #if IS_ENABLED(CONFIG_INPUT) |
Hans de Goede | 9712a8b | 2010-01-31 12:54:29 -0300 | [diff] [blame] | 2866 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
| 2867 | u8 *data, /* interrupt packet data */ |
| 2868 | int len) /* interrupt packet length */ |
| 2869 | { |
| 2870 | int ret = -EINVAL; |
| 2871 | |
| 2872 | if (len == 1 && data[0] == 1) { |
| 2873 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); |
| 2874 | input_sync(gspca_dev->input_dev); |
| 2875 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); |
| 2876 | input_sync(gspca_dev->input_dev); |
| 2877 | ret = 0; |
| 2878 | } |
| 2879 | |
| 2880 | return ret; |
| 2881 | } |
| 2882 | #endif |
| 2883 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2884 | /* sub-driver description */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 2885 | static const struct sd_desc sd_desc = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2886 | .name = MODULE_NAME, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2887 | .config = sd_config, |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 2888 | .init = sd_init, |
Hans Verkuil | c1f07ab | 2013-02-11 06:31:12 -0300 | [diff] [blame] | 2889 | .init_controls = sd_init_controls, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2890 | .start = sd_start, |
| 2891 | .stopN = sd_stopN, |
Jean-François Moine | b96cfc3 | 2011-02-10 07:38:58 -0300 | [diff] [blame] | 2892 | .stop0 = sd_stop0, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2893 | .pkt_scan = sd_pkt_scan, |
Jean-Francois Moine | cebf3b6 | 2008-08-03 07:52:53 -0300 | [diff] [blame] | 2894 | .dq_callback = do_autogain, |
Peter Senna Tschudin | f11ef42 | 2013-01-24 19:29:08 -0300 | [diff] [blame] | 2895 | #if IS_ENABLED(CONFIG_INPUT) |
Hans de Goede | 9712a8b | 2010-01-31 12:54:29 -0300 | [diff] [blame] | 2896 | .int_pkt_scan = sd_int_pkt_scan, |
| 2897 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2898 | }; |
| 2899 | |
| 2900 | /* -- module initialisation -- */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2901 | #define BS(bridge, sensor) \ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 2902 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
Jean-Francois Moine | c6c1433 | 2010-12-14 16:15:37 -0300 | [diff] [blame] | 2903 | | (SENSOR_ ## sensor << 8) |
| 2904 | #define BSF(bridge, sensor, flags) \ |
| 2905 | .driver_info = (BRIDGE_ ## bridge << 16) \ |
| 2906 | | (SENSOR_ ## sensor << 8) \ |
| 2907 | | (flags) |
Jean-François Moine | 95c967c | 2011-01-13 05:20:29 -0300 | [diff] [blame] | 2908 | static const struct usb_device_id device_table[] = { |
Jean-Francois Moine | f9798ef | 2012-05-28 14:05:25 -0300 | [diff] [blame] | 2909 | {USB_DEVICE(0x0458, 0x7025), BSF(SN9C120, MI0360B, F_PDN_INV)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2910 | {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, |
Jean-François Moine | 3afef85 | 2011-01-13 06:39:11 -0300 | [diff] [blame] | 2911 | {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)}, |
| 2912 | {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2913 | {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, |
| 2914 | {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, |
| 2915 | {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, |
| 2916 | {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)}, |
| 2917 | {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)}, |
| 2918 | /* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */ |
| 2919 | {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)}, |
| 2920 | /* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */ |
| 2921 | /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ |
| 2922 | {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, |
| 2923 | /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ |
Jean-François Moine | 3afef85 | 2011-01-13 06:39:11 -0300 | [diff] [blame] | 2924 | {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)}, |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2925 | /* or MT9V111 */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2926 | /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ |
| 2927 | /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ |
| 2928 | /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */ |
Warren Bosworth Focke | c4f95d8 | 2010-05-07 15:40:04 -0300 | [diff] [blame] | 2929 | {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2930 | {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)}, |
| 2931 | /* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */ |
| 2932 | /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ |
Jean-François Moine | 6804675 | 2010-05-07 15:35:08 -0300 | [diff] [blame] | 2933 | /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2934 | {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2935 | {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, |
| 2936 | {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2937 | {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ |
Jean-François Moine | 860e7f4 | 2010-09-13 06:40:17 -0300 | [diff] [blame] | 2938 | {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2939 | /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ |
| 2940 | {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/ |
| 2941 | {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/ |
| 2942 | {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/ |
| 2943 | {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/ |
| 2944 | /* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */ |
| 2945 | /* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */ |
| 2946 | /* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */ |
| 2947 | {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/ |
Jean-Francois Moine | d2d16e9 | 2008-09-03 16:47:23 -0300 | [diff] [blame] | 2948 | /*bw600.inf:*/ |
Jean-Francois Moine | b8c8a5b | 2009-11-23 06:46:35 -0300 | [diff] [blame] | 2949 | {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/ |
Alexander Goncharov | 2a3b501 | 2010-09-13 06:58:16 -0300 | [diff] [blame] | 2950 | {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2951 | {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)}, |
| 2952 | {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)}, |
| 2953 | /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2954 | {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)}, |
Jean-François Moine | a067db8 | 2010-10-01 07:51:24 -0300 | [diff] [blame] | 2955 | /* or MT9V111 / MI0360B */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2956 | /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ |
| 2957 | {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, |
| 2958 | {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2959 | {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2960 | {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, |
| 2961 | {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, |
Jean-François Moine | ad98c0f | 2010-03-18 05:15:30 -0300 | [diff] [blame] | 2962 | {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ |
Jean-François Moine | 6804675 | 2010-05-07 15:35:08 -0300 | [diff] [blame] | 2963 | /* or GC0305 / GC0307 */ |
Jean-Francois Moine | d5aa385 | 2009-11-07 06:10:08 -0300 | [diff] [blame] | 2964 | {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ |
| 2965 | {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ |
Jean-François Moine | a63d601 | 2011-01-13 07:56:00 -0300 | [diff] [blame] | 2966 | {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)}, |
Hans de Goede | e48d38f | 2011-01-06 16:21:57 -0300 | [diff] [blame] | 2967 | /* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2968 | {} |
| 2969 | }; |
| 2970 | MODULE_DEVICE_TABLE(usb, device_table); |
| 2971 | |
| 2972 | /* -- device connect -- */ |
| 2973 | static int sd_probe(struct usb_interface *intf, |
| 2974 | const struct usb_device_id *id) |
| 2975 | { |
| 2976 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
| 2977 | THIS_MODULE); |
| 2978 | } |
| 2979 | |
| 2980 | static struct usb_driver sd_driver = { |
| 2981 | .name = MODULE_NAME, |
| 2982 | .id_table = device_table, |
| 2983 | .probe = sd_probe, |
| 2984 | .disconnect = gspca_disconnect, |
Jean-Francois Moine | 6a70974 | 2008-09-03 16:48:10 -0300 | [diff] [blame] | 2985 | #ifdef CONFIG_PM |
| 2986 | .suspend = gspca_suspend, |
| 2987 | .resume = gspca_resume, |
Hans de Goede | 8bb5896 | 2012-06-30 06:44:47 -0300 | [diff] [blame] | 2988 | .reset_resume = gspca_resume, |
Jean-Francois Moine | 6a70974 | 2008-09-03 16:48:10 -0300 | [diff] [blame] | 2989 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 2990 | }; |
| 2991 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 2992 | module_usb_driver(sd_driver); |