Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1 | /* |
| 2 | * SPCA505 chip based cameras initialization data |
| 3 | * |
| 4 | * V4L2 by Jean-Francis Moine <http://moinejf.free.fr> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #define MODULE_NAME "spca505" |
| 23 | |
| 24 | #include "gspca.h" |
| 25 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 26 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
| 27 | MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver"); |
| 28 | MODULE_LICENSE("GPL"); |
| 29 | |
| 30 | /* specific webcam descriptor */ |
| 31 | struct sd { |
| 32 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
| 33 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 34 | u8 brightness; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 35 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 36 | u8 subtype; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 37 | #define IntelPCCameraPro 0 |
| 38 | #define Nxultra 1 |
| 39 | }; |
| 40 | |
| 41 | /* V4L2 controls supported by the driver */ |
| 42 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); |
| 43 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); |
| 44 | |
| 45 | static struct ctrl sd_ctrls[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 46 | { |
| 47 | { |
| 48 | .id = V4L2_CID_BRIGHTNESS, |
| 49 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 50 | .name = "Brightness", |
| 51 | .minimum = 0, |
| 52 | .maximum = 255, |
| 53 | .step = 1, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 54 | #define BRIGHTNESS_DEF 127 |
| 55 | .default_value = BRIGHTNESS_DEF, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 56 | }, |
| 57 | .set = sd_setbrightness, |
| 58 | .get = sd_getbrightness, |
| 59 | }, |
| 60 | }; |
| 61 | |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 62 | static const struct v4l2_pix_format vga_mode[] = { |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 63 | {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame] | 64 | .bytesperline = 160, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 65 | .sizeimage = 160 * 120 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 66 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 67 | .priv = 5}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 68 | {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame] | 69 | .bytesperline = 176, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 70 | .sizeimage = 176 * 144 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 71 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 72 | .priv = 4}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 73 | {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame] | 74 | .bytesperline = 320, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 75 | .sizeimage = 320 * 240 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 76 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 77 | .priv = 2}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 78 | {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame] | 79 | .bytesperline = 352, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 80 | .sizeimage = 352 * 288 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 81 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 82 | .priv = 1}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 83 | {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame] | 84 | .bytesperline = 640, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 85 | .sizeimage = 640 * 480 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 86 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 87 | .priv = 0}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | #define SPCA50X_OFFSET_DATA 10 |
| 91 | |
| 92 | #define SPCA50X_REG_USB 0x02 /* spca505 501 */ |
| 93 | |
| 94 | #define SPCA50X_USB_CTRL 0x00 /* spca505 */ |
| 95 | #define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */ |
| 96 | #define SPCA50X_REG_GLOBAL 0x03 /* spca505 */ |
| 97 | #define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */ |
| 98 | #define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */ |
| 99 | |
| 100 | #define SPCA50X_GLOBAL_MISC1 0x01 /* 505 */ |
| 101 | #define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */ |
| 102 | #define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */ |
| 103 | |
| 104 | /* |
| 105 | * Data to initialize a SPCA505. Common to the CCD and external modes |
| 106 | */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 107 | static const u8 spca505_init_data[][3] = { |
| 108 | /* bmRequest,value,index */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 109 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3}, |
| 110 | /* Sensor reset */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 111 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3}, |
| 112 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 113 | /* Block USB reset */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 114 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL, SPCA50X_GLOBAL_MISC0}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 115 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 116 | {0x05, 0x01, 0x10}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 117 | /* Maybe power down some stuff */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 118 | {0x05, 0x0f, 0x11}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 119 | |
| 120 | /* Setup internal CCD ? */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 121 | {0x06, 0x10, 0x08}, |
| 122 | {0x06, 0x00, 0x09}, |
| 123 | {0x06, 0x00, 0x0a}, |
| 124 | {0x06, 0x00, 0x0b}, |
| 125 | {0x06, 0x10, 0x0c}, |
| 126 | {0x06, 0x00, 0x0d}, |
| 127 | {0x06, 0x00, 0x0e}, |
| 128 | {0x06, 0x00, 0x0f}, |
| 129 | {0x06, 0x10, 0x10}, |
| 130 | {0x06, 0x02, 0x11}, |
| 131 | {0x06, 0x00, 0x12}, |
| 132 | {0x06, 0x04, 0x13}, |
| 133 | {0x06, 0x02, 0x14}, |
| 134 | {0x06, 0x8a, 0x51}, |
| 135 | {0x06, 0x40, 0x52}, |
| 136 | {0x06, 0xb6, 0x53}, |
| 137 | {0x06, 0x3d, 0x54}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 138 | {} |
| 139 | }; |
| 140 | |
| 141 | /* |
| 142 | * Data to initialize the camera using the internal CCD |
| 143 | */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 144 | static const u8 spca505_open_data_ccd[][3] = { |
| 145 | /* bmRequest,value,index */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 146 | /* Internal CCD data set */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 147 | {0x03, 0x04, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 148 | /* This could be a reset */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 149 | {0x03, 0x00, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 150 | |
| 151 | /* Setup compression and image registers. 0x6 and 0x7 seem to be |
| 152 | related to H&V hold, and are resolution mode specific */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 153 | {0x04, 0x10, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 154 | /* DIFF(0x50), was (0x10) */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 155 | {0x04, 0x00, 0x04}, |
| 156 | {0x04, 0x00, 0x05}, |
| 157 | {0x04, 0x20, 0x06}, |
| 158 | {0x04, 0x20, 0x07}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 159 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 160 | {0x08, 0x0a, 0x00}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 161 | /* DIFF (0x4a), was (0xa) */ |
| 162 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 163 | {0x05, 0x00, 0x10}, |
| 164 | {0x05, 0x00, 0x11}, |
| 165 | {0x05, 0x00, 0x00}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 166 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 167 | {0x05, 0x00, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 168 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 169 | {0x05, 0x00, 0x02}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 170 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 171 | {0x05, 0x00, 0x03}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 172 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 173 | {0x05, 0x00, 0x04}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 174 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 175 | {0x05, 0x80, 0x05}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 176 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 177 | {0x05, 0xe0, 0x06}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 178 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 179 | {0x05, 0x20, 0x07}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 180 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 181 | {0x05, 0xa0, 0x08}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 182 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 183 | {0x05, 0x0, 0x12}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 184 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 185 | {0x05, 0x02, 0x0f}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 186 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 187 | {0x05, 0x10, 0x46}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 188 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 189 | {0x05, 0x8, 0x4a}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 190 | /* DIFF not written */ |
| 191 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 192 | {0x03, 0x08, 0x03}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 193 | /* DIFF (0x3,0x28,0x3) */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 194 | {0x03, 0x08, 0x01}, |
| 195 | {0x03, 0x0c, 0x03}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 196 | /* DIFF not written */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 197 | {0x03, 0x21, 0x00}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 198 | /* DIFF (0x39) */ |
| 199 | |
| 200 | /* Extra block copied from init to hopefully ensure CCD is in a sane state */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 201 | {0x06, 0x10, 0x08}, |
| 202 | {0x06, 0x00, 0x09}, |
| 203 | {0x06, 0x00, 0x0a}, |
| 204 | {0x06, 0x00, 0x0b}, |
| 205 | {0x06, 0x10, 0x0c}, |
| 206 | {0x06, 0x00, 0x0d}, |
| 207 | {0x06, 0x00, 0x0e}, |
| 208 | {0x06, 0x00, 0x0f}, |
| 209 | {0x06, 0x10, 0x10}, |
| 210 | {0x06, 0x02, 0x11}, |
| 211 | {0x06, 0x00, 0x12}, |
| 212 | {0x06, 0x04, 0x13}, |
| 213 | {0x06, 0x02, 0x14}, |
| 214 | {0x06, 0x8a, 0x51}, |
| 215 | {0x06, 0x40, 0x52}, |
| 216 | {0x06, 0xb6, 0x53}, |
| 217 | {0x06, 0x3d, 0x54}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 218 | /* End of extra block */ |
| 219 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 220 | {0x06, 0x3f, 0x1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 221 | /* Block skipped */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 222 | {0x06, 0x10, 0x02}, |
| 223 | {0x06, 0x64, 0x07}, |
| 224 | {0x06, 0x10, 0x08}, |
| 225 | {0x06, 0x00, 0x09}, |
| 226 | {0x06, 0x00, 0x0a}, |
| 227 | {0x06, 0x00, 0x0b}, |
| 228 | {0x06, 0x10, 0x0c}, |
| 229 | {0x06, 0x00, 0x0d}, |
| 230 | {0x06, 0x00, 0x0e}, |
| 231 | {0x06, 0x00, 0x0f}, |
| 232 | {0x06, 0x10, 0x10}, |
| 233 | {0x06, 0x02, 0x11}, |
| 234 | {0x06, 0x00, 0x12}, |
| 235 | {0x06, 0x04, 0x13}, |
| 236 | {0x06, 0x02, 0x14}, |
| 237 | {0x06, 0x8a, 0x51}, |
| 238 | {0x06, 0x40, 0x52}, |
| 239 | {0x06, 0xb6, 0x53}, |
| 240 | {0x06, 0x3d, 0x54}, |
| 241 | {0x06, 0x60, 0x57}, |
| 242 | {0x06, 0x20, 0x58}, |
| 243 | {0x06, 0x15, 0x59}, |
| 244 | {0x06, 0x05, 0x5a}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 245 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 246 | {0x05, 0x01, 0xc0}, |
| 247 | {0x05, 0x10, 0xcb}, |
| 248 | {0x05, 0x80, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 249 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 250 | {0x05, 0x0, 0xc2}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 251 | /* 4 was 0 */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 252 | {0x05, 0x00, 0xca}, |
| 253 | {0x05, 0x80, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 254 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 255 | {0x05, 0x04, 0xc2}, |
| 256 | {0x05, 0x00, 0xca}, |
| 257 | {0x05, 0x0, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 258 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 259 | {0x05, 0x00, 0xc2}, |
| 260 | {0x05, 0x00, 0xca}, |
| 261 | {0x05, 0x40, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 262 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 263 | {0x05, 0x17, 0xc2}, |
| 264 | {0x05, 0x00, 0xca}, |
| 265 | {0x05, 0x80, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 266 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 267 | {0x05, 0x06, 0xc2}, |
| 268 | {0x05, 0x00, 0xca}, |
| 269 | {0x05, 0x80, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 270 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 271 | {0x05, 0x04, 0xc2}, |
| 272 | {0x05, 0x00, 0xca}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 273 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 274 | {0x03, 0x4c, 0x3}, |
| 275 | {0x03, 0x18, 0x1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 276 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 277 | {0x06, 0x70, 0x51}, |
| 278 | {0x06, 0xbe, 0x53}, |
| 279 | {0x06, 0x71, 0x57}, |
| 280 | {0x06, 0x20, 0x58}, |
| 281 | {0x06, 0x05, 0x59}, |
| 282 | {0x06, 0x15, 0x5a}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 283 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 284 | {0x04, 0x00, 0x08}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 285 | /* Compress = OFF (0x1 to turn on) */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 286 | {0x04, 0x12, 0x09}, |
| 287 | {0x04, 0x21, 0x0a}, |
| 288 | {0x04, 0x10, 0x0b}, |
| 289 | {0x04, 0x21, 0x0c}, |
| 290 | {0x04, 0x05, 0x00}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 291 | /* was 5 (Image Type ? ) */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 292 | {0x04, 0x00, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 293 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 294 | {0x06, 0x3f, 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 295 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 296 | {0x04, 0x00, 0x04}, |
| 297 | {0x04, 0x00, 0x05}, |
| 298 | {0x04, 0x40, 0x06}, |
| 299 | {0x04, 0x40, 0x07}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 300 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 301 | {0x06, 0x1c, 0x17}, |
| 302 | {0x06, 0xe2, 0x19}, |
| 303 | {0x06, 0x1c, 0x1b}, |
| 304 | {0x06, 0xe2, 0x1d}, |
| 305 | {0x06, 0xaa, 0x1f}, |
| 306 | {0x06, 0x70, 0x20}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 307 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 308 | {0x05, 0x01, 0x10}, |
| 309 | {0x05, 0x00, 0x11}, |
| 310 | {0x05, 0x01, 0x00}, |
| 311 | {0x05, 0x05, 0x01}, |
| 312 | {0x05, 0x00, 0xc1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 313 | /* */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 314 | {0x05, 0x00, 0xc2}, |
| 315 | {0x05, 0x00, 0xca}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 316 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 317 | {0x06, 0x70, 0x51}, |
| 318 | {0x06, 0xbe, 0x53}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 319 | {} |
| 320 | }; |
| 321 | |
| 322 | /* |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 323 | * Made by Tomasz Zablocki (skalamandra@poczta.onet.pl) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 324 | * SPCA505b chip based cameras initialization data |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 325 | */ |
| 326 | /* jfm */ |
| 327 | #define initial_brightness 0x7f /* 0x0(white)-0xff(black) */ |
| 328 | /* #define initial_brightness 0x0 //0x0(white)-0xff(black) */ |
| 329 | /* |
| 330 | * Data to initialize a SPCA505. Common to the CCD and external modes |
| 331 | */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 332 | static const u8 spca505b_init_data[][3] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 333 | /* start */ |
| 334 | {0x02, 0x00, 0x00}, /* init */ |
| 335 | {0x02, 0x00, 0x01}, |
| 336 | {0x02, 0x00, 0x02}, |
| 337 | {0x02, 0x00, 0x03}, |
| 338 | {0x02, 0x00, 0x04}, |
| 339 | {0x02, 0x00, 0x05}, |
| 340 | {0x02, 0x00, 0x06}, |
| 341 | {0x02, 0x00, 0x07}, |
| 342 | {0x02, 0x00, 0x08}, |
| 343 | {0x02, 0x00, 0x09}, |
| 344 | {0x03, 0x00, 0x00}, |
| 345 | {0x03, 0x00, 0x01}, |
| 346 | {0x03, 0x00, 0x02}, |
| 347 | {0x03, 0x00, 0x03}, |
| 348 | {0x03, 0x00, 0x04}, |
| 349 | {0x03, 0x00, 0x05}, |
| 350 | {0x03, 0x00, 0x06}, |
| 351 | {0x04, 0x00, 0x00}, |
| 352 | {0x04, 0x00, 0x02}, |
| 353 | {0x04, 0x00, 0x04}, |
| 354 | {0x04, 0x00, 0x05}, |
| 355 | {0x04, 0x00, 0x06}, |
| 356 | {0x04, 0x00, 0x07}, |
| 357 | {0x04, 0x00, 0x08}, |
| 358 | {0x04, 0x00, 0x09}, |
| 359 | {0x04, 0x00, 0x0a}, |
| 360 | {0x04, 0x00, 0x0b}, |
| 361 | {0x04, 0x00, 0x0c}, |
| 362 | {0x07, 0x00, 0x00}, |
| 363 | {0x07, 0x00, 0x03}, |
| 364 | {0x08, 0x00, 0x00}, |
| 365 | {0x08, 0x00, 0x01}, |
| 366 | {0x08, 0x00, 0x02}, |
| 367 | {0x00, 0x01, 0x00}, |
| 368 | {0x00, 0x01, 0x01}, |
| 369 | {0x00, 0x01, 0x34}, |
| 370 | {0x00, 0x01, 0x35}, |
| 371 | {0x06, 0x18, 0x08}, |
| 372 | {0x06, 0xfc, 0x09}, |
| 373 | {0x06, 0xfc, 0x0a}, |
| 374 | {0x06, 0xfc, 0x0b}, |
| 375 | {0x06, 0x18, 0x0c}, |
| 376 | {0x06, 0xfc, 0x0d}, |
| 377 | {0x06, 0xfc, 0x0e}, |
| 378 | {0x06, 0xfc, 0x0f}, |
| 379 | {0x06, 0x18, 0x10}, |
| 380 | {0x06, 0xfe, 0x12}, |
| 381 | {0x06, 0x00, 0x11}, |
| 382 | {0x06, 0x00, 0x14}, |
| 383 | {0x06, 0x00, 0x13}, |
| 384 | {0x06, 0x28, 0x51}, |
| 385 | {0x06, 0xff, 0x53}, |
| 386 | {0x02, 0x00, 0x08}, |
| 387 | |
| 388 | {0x03, 0x00, 0x03}, |
| 389 | {0x03, 0x10, 0x03}, |
| 390 | {} |
| 391 | }; |
| 392 | |
| 393 | /* |
| 394 | * Data to initialize the camera using the internal CCD |
| 395 | */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 396 | static const u8 spca505b_open_data_ccd[][3] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 397 | |
| 398 | /* {0x02,0x00,0x00}, */ |
| 399 | {0x03, 0x04, 0x01}, /* rst */ |
| 400 | {0x03, 0x00, 0x01}, |
| 401 | {0x03, 0x00, 0x00}, |
| 402 | {0x03, 0x21, 0x00}, |
| 403 | {0x03, 0x00, 0x04}, |
| 404 | {0x03, 0x00, 0x03}, |
| 405 | {0x03, 0x18, 0x03}, |
| 406 | {0x03, 0x08, 0x01}, |
| 407 | {0x03, 0x1c, 0x03}, |
| 408 | {0x03, 0x5c, 0x03}, |
| 409 | {0x03, 0x5c, 0x03}, |
| 410 | {0x03, 0x18, 0x01}, |
| 411 | |
| 412 | /* same as 505 */ |
| 413 | {0x04, 0x10, 0x01}, |
| 414 | {0x04, 0x00, 0x04}, |
| 415 | {0x04, 0x00, 0x05}, |
| 416 | {0x04, 0x20, 0x06}, |
| 417 | {0x04, 0x20, 0x07}, |
| 418 | |
| 419 | {0x08, 0x0a, 0x00}, |
| 420 | |
| 421 | {0x05, 0x00, 0x10}, |
| 422 | {0x05, 0x00, 0x11}, |
| 423 | {0x05, 0x00, 0x12}, |
| 424 | {0x05, 0x6f, 0x00}, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 425 | {0x05, (u8) (initial_brightness >> 6), 0x00}, |
| 426 | {0x05, (u8) (initial_brightness << 2), 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 427 | {0x05, 0x00, 0x02}, |
| 428 | {0x05, 0x01, 0x03}, |
| 429 | {0x05, 0x00, 0x04}, |
| 430 | {0x05, 0x03, 0x05}, |
| 431 | {0x05, 0xe0, 0x06}, |
| 432 | {0x05, 0x20, 0x07}, |
| 433 | {0x05, 0xa0, 0x08}, |
| 434 | {0x05, 0x00, 0x12}, |
| 435 | {0x05, 0x02, 0x0f}, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 436 | {0x05, 0x80, 0x14}, /* max exposure off (0=on) */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 437 | {0x05, 0x01, 0xb0}, |
| 438 | {0x05, 0x01, 0xbf}, |
| 439 | {0x03, 0x02, 0x06}, |
| 440 | {0x05, 0x10, 0x46}, |
| 441 | {0x05, 0x08, 0x4a}, |
| 442 | |
| 443 | {0x06, 0x00, 0x01}, |
| 444 | {0x06, 0x10, 0x02}, |
| 445 | {0x06, 0x64, 0x07}, |
| 446 | {0x06, 0x18, 0x08}, |
| 447 | {0x06, 0xfc, 0x09}, |
| 448 | {0x06, 0xfc, 0x0a}, |
| 449 | {0x06, 0xfc, 0x0b}, |
| 450 | {0x04, 0x00, 0x01}, |
| 451 | {0x06, 0x18, 0x0c}, |
| 452 | {0x06, 0xfc, 0x0d}, |
| 453 | {0x06, 0xfc, 0x0e}, |
| 454 | {0x06, 0xfc, 0x0f}, |
| 455 | {0x06, 0x11, 0x10}, /* contrast */ |
| 456 | {0x06, 0x00, 0x11}, |
| 457 | {0x06, 0xfe, 0x12}, |
| 458 | {0x06, 0x00, 0x13}, |
| 459 | {0x06, 0x00, 0x14}, |
| 460 | {0x06, 0x9d, 0x51}, |
| 461 | {0x06, 0x40, 0x52}, |
| 462 | {0x06, 0x7c, 0x53}, |
| 463 | {0x06, 0x40, 0x54}, |
| 464 | {0x06, 0x02, 0x57}, |
| 465 | {0x06, 0x03, 0x58}, |
| 466 | {0x06, 0x15, 0x59}, |
| 467 | {0x06, 0x05, 0x5a}, |
| 468 | {0x06, 0x03, 0x56}, |
| 469 | {0x06, 0x02, 0x3f}, |
| 470 | {0x06, 0x00, 0x40}, |
| 471 | {0x06, 0x39, 0x41}, |
| 472 | {0x06, 0x69, 0x42}, |
| 473 | {0x06, 0x87, 0x43}, |
| 474 | {0x06, 0x9e, 0x44}, |
| 475 | {0x06, 0xb1, 0x45}, |
| 476 | {0x06, 0xbf, 0x46}, |
| 477 | {0x06, 0xcc, 0x47}, |
| 478 | {0x06, 0xd5, 0x48}, |
| 479 | {0x06, 0xdd, 0x49}, |
| 480 | {0x06, 0xe3, 0x4a}, |
| 481 | {0x06, 0xe8, 0x4b}, |
| 482 | {0x06, 0xed, 0x4c}, |
| 483 | {0x06, 0xf2, 0x4d}, |
| 484 | {0x06, 0xf7, 0x4e}, |
| 485 | {0x06, 0xfc, 0x4f}, |
| 486 | {0x06, 0xff, 0x50}, |
| 487 | |
| 488 | {0x05, 0x01, 0xc0}, |
| 489 | {0x05, 0x10, 0xcb}, |
| 490 | {0x05, 0x40, 0xc1}, |
| 491 | {0x05, 0x04, 0xc2}, |
| 492 | {0x05, 0x00, 0xca}, |
| 493 | {0x05, 0x40, 0xc1}, |
| 494 | {0x05, 0x09, 0xc2}, |
| 495 | {0x05, 0x00, 0xca}, |
| 496 | {0x05, 0xc0, 0xc1}, |
| 497 | {0x05, 0x09, 0xc2}, |
| 498 | {0x05, 0x00, 0xca}, |
| 499 | {0x05, 0x40, 0xc1}, |
| 500 | {0x05, 0x59, 0xc2}, |
| 501 | {0x05, 0x00, 0xca}, |
| 502 | {0x04, 0x00, 0x01}, |
| 503 | {0x05, 0x80, 0xc1}, |
| 504 | {0x05, 0xec, 0xc2}, |
| 505 | {0x05, 0x0, 0xca}, |
| 506 | |
| 507 | {0x06, 0x02, 0x57}, |
| 508 | {0x06, 0x01, 0x58}, |
| 509 | {0x06, 0x15, 0x59}, |
| 510 | {0x06, 0x0a, 0x5a}, |
| 511 | {0x06, 0x01, 0x57}, |
| 512 | {0x06, 0x8a, 0x03}, |
| 513 | {0x06, 0x0a, 0x6c}, |
| 514 | {0x06, 0x30, 0x01}, |
| 515 | {0x06, 0x20, 0x02}, |
| 516 | {0x06, 0x00, 0x03}, |
| 517 | |
| 518 | {0x05, 0x8c, 0x25}, |
| 519 | |
| 520 | {0x06, 0x4d, 0x51}, /* maybe saturation (4d) */ |
| 521 | {0x06, 0x84, 0x53}, /* making green (84) */ |
| 522 | {0x06, 0x00, 0x57}, /* sharpness (1) */ |
| 523 | {0x06, 0x18, 0x08}, |
| 524 | {0x06, 0xfc, 0x09}, |
| 525 | {0x06, 0xfc, 0x0a}, |
| 526 | {0x06, 0xfc, 0x0b}, |
| 527 | {0x06, 0x18, 0x0c}, /* maybe hue (18) */ |
| 528 | {0x06, 0xfc, 0x0d}, |
| 529 | {0x06, 0xfc, 0x0e}, |
| 530 | {0x06, 0xfc, 0x0f}, |
| 531 | {0x06, 0x18, 0x10}, /* maybe contrast (18) */ |
| 532 | |
| 533 | {0x05, 0x01, 0x02}, |
| 534 | |
| 535 | {0x04, 0x00, 0x08}, /* compression */ |
| 536 | {0x04, 0x12, 0x09}, |
| 537 | {0x04, 0x21, 0x0a}, |
| 538 | {0x04, 0x10, 0x0b}, |
| 539 | {0x04, 0x21, 0x0c}, |
| 540 | {0x04, 0x1d, 0x00}, /* imagetype (1d) */ |
| 541 | {0x04, 0x41, 0x01}, /* hardware snapcontrol */ |
| 542 | |
| 543 | {0x04, 0x00, 0x04}, |
| 544 | {0x04, 0x00, 0x05}, |
| 545 | {0x04, 0x10, 0x06}, |
| 546 | {0x04, 0x10, 0x07}, |
| 547 | {0x04, 0x40, 0x06}, |
| 548 | {0x04, 0x40, 0x07}, |
| 549 | {0x04, 0x00, 0x04}, |
| 550 | {0x04, 0x00, 0x05}, |
| 551 | |
| 552 | {0x06, 0x1c, 0x17}, |
| 553 | {0x06, 0xe2, 0x19}, |
| 554 | {0x06, 0x1c, 0x1b}, |
| 555 | {0x06, 0xe2, 0x1d}, |
| 556 | {0x06, 0x5f, 0x1f}, |
| 557 | {0x06, 0x32, 0x20}, |
| 558 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 559 | {0x05, (u8) (initial_brightness >> 6), 0x00}, |
| 560 | {0x05, (u8) (initial_brightness << 2), 0x01}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 561 | {0x05, 0x06, 0xc1}, |
| 562 | {0x05, 0x58, 0xc2}, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 563 | {0x05, 0x00, 0xca}, |
| 564 | {0x05, 0x00, 0x11}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 565 | {} |
| 566 | }; |
| 567 | |
| 568 | static int reg_write(struct usb_device *dev, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 569 | u16 req, u16 index, u16 value) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 570 | { |
| 571 | int ret; |
| 572 | |
| 573 | ret = usb_control_msg(dev, |
| 574 | usb_sndctrlpipe(dev, 0), |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 575 | req, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 576 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 577 | value, index, NULL, 0, 500); |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 578 | PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", |
| 579 | req, index, value, ret); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 580 | if (ret < 0) |
| 581 | PDEBUG(D_ERR, "reg write: error %d", ret); |
| 582 | return ret; |
| 583 | } |
| 584 | |
| 585 | /* returns: negative is error, pos or zero is data */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 586 | static int reg_read(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 587 | u16 req, /* bRequest */ |
| 588 | u16 index) /* wIndex */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 589 | { |
| 590 | int ret; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 591 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 592 | ret = usb_control_msg(gspca_dev->dev, |
| 593 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 594 | req, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 595 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 596 | 0, /* value */ |
| 597 | index, |
| 598 | gspca_dev->usb_buf, 2, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 599 | 500); /* timeout */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 600 | if (ret < 0) |
| 601 | return ret; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 602 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | static int write_vector(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 606 | const u8 data[][3]) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 607 | { |
| 608 | struct usb_device *dev = gspca_dev->dev; |
| 609 | int ret, i = 0; |
| 610 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 611 | while (data[i][0] != 0) { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 612 | ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 613 | if (ret < 0) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 614 | return ret; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 615 | i++; |
| 616 | } |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | /* this function is called at probe time */ |
| 621 | static int sd_config(struct gspca_dev *gspca_dev, |
| 622 | const struct usb_device_id *id) |
| 623 | { |
| 624 | struct sd *sd = (struct sd *) gspca_dev; |
| 625 | struct cam *cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 626 | |
| 627 | cam = &gspca_dev->cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 628 | cam->cam_mode = vga_mode; |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 629 | sd->subtype = id->driver_info; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 630 | if (sd->subtype != IntelPCCameraPro) |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 631 | cam->nmodes = ARRAY_SIZE(vga_mode); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 632 | else /* no 640x480 for IntelPCCameraPro */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 633 | cam->nmodes = ARRAY_SIZE(vga_mode) - 1; |
| 634 | sd->brightness = BRIGHTNESS_DEF; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 635 | |
| 636 | if (sd->subtype == Nxultra) { |
| 637 | if (write_vector(gspca_dev, spca505b_init_data)) |
| 638 | return -EIO; |
| 639 | } else { |
| 640 | if (write_vector(gspca_dev, spca505_init_data)) |
| 641 | return -EIO; |
| 642 | } |
| 643 | return 0; |
| 644 | } |
| 645 | |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 646 | /* this function is called at probe and resume time */ |
| 647 | static int sd_init(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 648 | { |
| 649 | struct sd *sd = (struct sd *) gspca_dev; |
| 650 | int ret; |
| 651 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 652 | if (sd->subtype == Nxultra) |
| 653 | write_vector(gspca_dev, spca505b_open_data_ccd); |
| 654 | else |
| 655 | write_vector(gspca_dev, spca505_open_data_ccd); |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 656 | ret = reg_read(gspca_dev, 0x06, 0x16); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 657 | |
| 658 | if (ret < 0) { |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 659 | PDEBUG(D_ERR|D_CONF, |
| 660 | "register read failed err: %d", |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 661 | ret); |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 662 | return ret; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 663 | } |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 664 | if (ret != 0x0101) { |
| 665 | PDEBUG(D_ERR|D_CONF, |
| 666 | "After vector read returns 0x%04x should be 0x0101", |
| 667 | ret); |
| 668 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 669 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 670 | ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a); |
| 671 | if (ret < 0) |
| 672 | return ret; |
| 673 | reg_write(gspca_dev->dev, 0x05, 0xc2, 18); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 674 | return 0; |
| 675 | } |
| 676 | |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 677 | static int sd_start(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 678 | { |
| 679 | struct usb_device *dev = gspca_dev->dev; |
| 680 | int ret; |
| 681 | |
| 682 | /* necessary because without it we can see stream |
| 683 | * only once after loading module */ |
| 684 | /* stopping usb registers Tomasz change */ |
| 685 | reg_write(dev, 0x02, 0x0, 0x0); |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 686 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 687 | case 0: |
| 688 | reg_write(dev, 0x04, 0x00, 0x00); |
| 689 | reg_write(dev, 0x04, 0x06, 0x10); |
| 690 | reg_write(dev, 0x04, 0x07, 0x10); |
| 691 | break; |
| 692 | case 1: |
| 693 | reg_write(dev, 0x04, 0x00, 0x01); |
| 694 | reg_write(dev, 0x04, 0x06, 0x1a); |
| 695 | reg_write(dev, 0x04, 0x07, 0x1a); |
| 696 | break; |
| 697 | case 2: |
| 698 | reg_write(dev, 0x04, 0x00, 0x02); |
| 699 | reg_write(dev, 0x04, 0x06, 0x1c); |
| 700 | reg_write(dev, 0x04, 0x07, 0x1d); |
| 701 | break; |
| 702 | case 4: |
| 703 | reg_write(dev, 0x04, 0x00, 0x04); |
| 704 | reg_write(dev, 0x04, 0x06, 0x34); |
| 705 | reg_write(dev, 0x04, 0x07, 0x34); |
| 706 | break; |
| 707 | default: |
| 708 | /* case 5: */ |
| 709 | reg_write(dev, 0x04, 0x00, 0x05); |
| 710 | reg_write(dev, 0x04, 0x06, 0x40); |
| 711 | reg_write(dev, 0x04, 0x07, 0x40); |
| 712 | break; |
| 713 | } |
| 714 | /* Enable ISO packet machine - should we do this here or in ISOC init ? */ |
| 715 | ret = reg_write(dev, SPCA50X_REG_USB, |
| 716 | SPCA50X_USB_CTRL, |
| 717 | SPCA50X_CUSB_ENABLE); |
| 718 | |
| 719 | /* reg_write(dev, 0x5, 0x0, 0x0); */ |
| 720 | /* reg_write(dev, 0x5, 0x0, 0x1); */ |
| 721 | /* reg_write(dev, 0x5, 0x11, 0x2); */ |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 722 | return ret; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static void sd_stopN(struct gspca_dev *gspca_dev) |
| 726 | { |
| 727 | /* Disable ISO packet machine */ |
| 728 | reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); |
| 729 | } |
| 730 | |
Jean-Francois Moine | 98522a7 | 2008-11-18 06:33:08 -0300 | [diff] [blame] | 731 | /* called on streamoff with alt 0 and on disconnect */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 732 | static void sd_stop0(struct gspca_dev *gspca_dev) |
| 733 | { |
Jean-Francois Moine | 98522a7 | 2008-11-18 06:33:08 -0300 | [diff] [blame] | 734 | if (!gspca_dev->present) |
| 735 | return; |
| 736 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 737 | /* This maybe reset or power control */ |
| 738 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 739 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x00); |
| 740 | reg_write(gspca_dev->dev, 0x03, 0x00, 0x01); |
| 741 | reg_write(gspca_dev->dev, 0x05, 0x10, 0x01); |
| 742 | reg_write(gspca_dev->dev, 0x05, 0x11, 0x0f); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 743 | } |
| 744 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 745 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
| 746 | struct gspca_frame *frame, /* target */ |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 747 | u8 *data, /* isoc packet */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 748 | int len) /* iso packet length */ |
| 749 | { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 750 | switch (data[0]) { |
| 751 | case 0: /* start of frame */ |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 752 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
| 753 | data, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 754 | data += SPCA50X_OFFSET_DATA; |
| 755 | len -= SPCA50X_OFFSET_DATA; |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 756 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
| 757 | data, len); |
| 758 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 759 | case 0xff: /* drop */ |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 760 | break; |
| 761 | default: |
| 762 | data += 1; |
| 763 | len -= 1; |
Jean-Francois Moine | 01b988b | 2008-07-30 05:33:11 -0300 | [diff] [blame] | 764 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 765 | data, len); |
| 766 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 767 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | static void setbrightness(struct gspca_dev *gspca_dev) |
| 771 | { |
| 772 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 773 | u8 brightness = sd->brightness; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 774 | |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 775 | reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6); |
| 776 | reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 777 | |
| 778 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 779 | |
| 780 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
| 781 | { |
| 782 | struct sd *sd = (struct sd *) gspca_dev; |
| 783 | |
| 784 | sd->brightness = val; |
| 785 | if (gspca_dev->streaming) |
| 786 | setbrightness(gspca_dev); |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 790 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) |
| 791 | { |
| 792 | struct sd *sd = (struct sd *) gspca_dev; |
| 793 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 794 | *val = sd->brightness; |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | /* sub-driver description */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 799 | static const struct sd_desc sd_desc = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 800 | .name = MODULE_NAME, |
| 801 | .ctrls = sd_ctrls, |
| 802 | .nctrls = ARRAY_SIZE(sd_ctrls), |
| 803 | .config = sd_config, |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 804 | .init = sd_init, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 805 | .start = sd_start, |
| 806 | .stopN = sd_stopN, |
| 807 | .stop0 = sd_stop0, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 808 | .pkt_scan = sd_pkt_scan, |
| 809 | }; |
| 810 | |
| 811 | /* -- module initialisation -- */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 812 | static const __devinitdata struct usb_device_id device_table[] = { |
Jean-Francois Moine | 87581aa | 2008-07-26 14:30:01 -0300 | [diff] [blame] | 813 | {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, |
| 814 | {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 815 | /*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 816 | {} |
| 817 | }; |
| 818 | MODULE_DEVICE_TABLE(usb, device_table); |
| 819 | |
| 820 | /* -- device connect -- */ |
| 821 | static int sd_probe(struct usb_interface *intf, |
| 822 | const struct usb_device_id *id) |
| 823 | { |
Jean-Francois Moine | 956e42d | 2008-07-01 10:03:42 -0300 | [diff] [blame] | 824 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 825 | THIS_MODULE); |
| 826 | } |
| 827 | |
| 828 | static struct usb_driver sd_driver = { |
| 829 | .name = MODULE_NAME, |
| 830 | .id_table = device_table, |
| 831 | .probe = sd_probe, |
| 832 | .disconnect = gspca_disconnect, |
Jean-Francois Moine | 6a70974 | 2008-09-03 16:48:10 -0300 | [diff] [blame] | 833 | #ifdef CONFIG_PM |
| 834 | .suspend = gspca_suspend, |
| 835 | .resume = gspca_resume, |
| 836 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 837 | }; |
| 838 | |
| 839 | /* -- module insert / remove -- */ |
| 840 | static int __init sd_mod_init(void) |
| 841 | { |
Alexey Klimov | f69e952 | 2009-01-01 13:02:07 -0300 | [diff] [blame] | 842 | int ret; |
Jean-Francois Moine | 16631aed | 2009-01-22 14:56:42 -0300 | [diff] [blame^] | 843 | |
Alexey Klimov | f69e952 | 2009-01-01 13:02:07 -0300 | [diff] [blame] | 844 | ret = usb_register(&sd_driver); |
| 845 | if (ret < 0) |
Alexey Klimov | e6b1484 | 2009-01-01 13:04:58 -0300 | [diff] [blame] | 846 | return ret; |
Jean-Francois Moine | 10b0e96 | 2008-07-22 05:35:10 -0300 | [diff] [blame] | 847 | PDEBUG(D_PROBE, "registered"); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 848 | return 0; |
| 849 | } |
| 850 | static void __exit sd_mod_exit(void) |
| 851 | { |
| 852 | usb_deregister(&sd_driver); |
| 853 | PDEBUG(D_PROBE, "deregistered"); |
| 854 | } |
| 855 | |
| 856 | module_init(sd_mod_init); |
| 857 | module_exit(sd_mod_exit); |