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