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