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