Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Sunplus spca504(abc) spca533 spca536 library |
| 3 | * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr |
| 4 | * |
| 5 | * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 23 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 24 | #define MODULE_NAME "sunplus" |
| 25 | |
| 26 | #include "gspca.h" |
| 27 | #include "jpeg.h" |
| 28 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 29 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
| 30 | MODULE_DESCRIPTION("GSPCA/SPCA5xx USB Camera Driver"); |
| 31 | MODULE_LICENSE("GPL"); |
| 32 | |
| 33 | /* specific webcam descriptor */ |
| 34 | struct sd { |
| 35 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
| 36 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 37 | struct v4l2_ctrl *jpegqual; |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 38 | #define QUALITY_MIN 70 |
| 39 | #define QUALITY_MAX 95 |
| 40 | #define QUALITY_DEF 85 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 41 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 42 | bool autogain; |
| 43 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 44 | u8 bridge; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 45 | #define BRIDGE_SPCA504 0 |
| 46 | #define BRIDGE_SPCA504B 1 |
| 47 | #define BRIDGE_SPCA504C 2 |
| 48 | #define BRIDGE_SPCA533 3 |
| 49 | #define BRIDGE_SPCA536 4 |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 50 | u8 subtype; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 51 | #define AiptekMiniPenCam13 1 |
| 52 | #define LogitechClickSmart420 2 |
| 53 | #define LogitechClickSmart820 3 |
| 54 | #define MegapixV4 4 |
Johannes Goerner | af5f88c | 2009-07-09 03:28:46 -0300 | [diff] [blame] | 55 | #define MegaImageVI 5 |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 56 | |
Jean-François Moine | 9a731a3 | 2010-06-04 05:26:42 -0300 | [diff] [blame] | 57 | u8 jpeg_hdr[JPEG_HDR_SZ]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 58 | }; |
| 59 | |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 60 | static const struct v4l2_pix_format vga_mode[] = { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 61 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 62 | .bytesperline = 320, |
| 63 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
| 64 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 65 | .priv = 2}, |
| 66 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 67 | .bytesperline = 640, |
| 68 | .sizeimage = 640 * 480 * 3 / 8 + 590, |
| 69 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 70 | .priv = 1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 71 | }; |
| 72 | |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 73 | static const struct v4l2_pix_format custom_mode[] = { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 74 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 75 | .bytesperline = 320, |
| 76 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
| 77 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 78 | .priv = 2}, |
| 79 | {464, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 80 | .bytesperline = 464, |
| 81 | .sizeimage = 464 * 480 * 3 / 8 + 590, |
| 82 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 83 | .priv = 1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 84 | }; |
| 85 | |
Jean-Francois Moine | cc611b8 | 2008-12-29 07:49:41 -0300 | [diff] [blame] | 86 | static const struct v4l2_pix_format vga_mode2[] = { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 87 | {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 88 | .bytesperline = 176, |
| 89 | .sizeimage = 176 * 144 * 3 / 8 + 590, |
| 90 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 91 | .priv = 4}, |
| 92 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 93 | .bytesperline = 320, |
| 94 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
| 95 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 96 | .priv = 3}, |
| 97 | {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 98 | .bytesperline = 352, |
| 99 | .sizeimage = 352 * 288 * 3 / 8 + 590, |
| 100 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 101 | .priv = 2}, |
| 102 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 103 | .bytesperline = 640, |
| 104 | .sizeimage = 640 * 480 * 3 / 8 + 590, |
| 105 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 106 | .priv = 1}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | #define SPCA50X_OFFSET_DATA 10 |
| 110 | #define SPCA504_PCCAM600_OFFSET_SNAPSHOT 3 |
| 111 | #define SPCA504_PCCAM600_OFFSET_COMPRESS 4 |
| 112 | #define SPCA504_PCCAM600_OFFSET_MODE 5 |
| 113 | #define SPCA504_PCCAM600_OFFSET_DATA 14 |
| 114 | /* Frame packet header offsets for the spca533 */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 115 | #define SPCA533_OFFSET_DATA 16 |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 116 | #define SPCA533_OFFSET_FRAMSEQ 15 |
| 117 | /* Frame packet header offsets for the spca536 */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 118 | #define SPCA536_OFFSET_DATA 4 |
| 119 | #define SPCA536_OFFSET_FRAMSEQ 1 |
| 120 | |
| 121 | struct cmd { |
| 122 | u8 req; |
| 123 | u16 val; |
| 124 | u16 idx; |
| 125 | }; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 126 | |
| 127 | /* Initialisation data for the Creative PC-CAM 600 */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 128 | static const struct cmd spca504_pccam600_init_data[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 129 | /* {0xa0, 0x0000, 0x0503}, * capture mode */ |
| 130 | {0x00, 0x0000, 0x2000}, |
| 131 | {0x00, 0x0013, 0x2301}, |
| 132 | {0x00, 0x0003, 0x2000}, |
| 133 | {0x00, 0x0001, 0x21ac}, |
| 134 | {0x00, 0x0001, 0x21a6}, |
| 135 | {0x00, 0x0000, 0x21a7}, /* brightness */ |
| 136 | {0x00, 0x0020, 0x21a8}, /* contrast */ |
| 137 | {0x00, 0x0001, 0x21ac}, /* sat/hue */ |
| 138 | {0x00, 0x0000, 0x21ad}, /* hue */ |
| 139 | {0x00, 0x001a, 0x21ae}, /* saturation */ |
| 140 | {0x00, 0x0002, 0x21a3}, /* gamma */ |
| 141 | {0x30, 0x0154, 0x0008}, |
| 142 | {0x30, 0x0004, 0x0006}, |
| 143 | {0x30, 0x0258, 0x0009}, |
| 144 | {0x30, 0x0004, 0x0000}, |
| 145 | {0x30, 0x0093, 0x0004}, |
| 146 | {0x30, 0x0066, 0x0005}, |
| 147 | {0x00, 0x0000, 0x2000}, |
| 148 | {0x00, 0x0013, 0x2301}, |
| 149 | {0x00, 0x0003, 0x2000}, |
| 150 | {0x00, 0x0013, 0x2301}, |
| 151 | {0x00, 0x0003, 0x2000}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | /* Creative PC-CAM 600 specific open data, sent before using the |
| 155 | * generic initialisation data from spca504_open_data. |
| 156 | */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 157 | static const struct cmd spca504_pccam600_open_data[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 158 | {0x00, 0x0001, 0x2501}, |
| 159 | {0x20, 0x0500, 0x0001}, /* snapshot mode */ |
| 160 | {0x00, 0x0003, 0x2880}, |
| 161 | {0x00, 0x0001, 0x2881}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | /* Initialisation data for the logitech clicksmart 420 */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 165 | static const struct cmd spca504A_clicksmart420_init_data[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 166 | /* {0xa0, 0x0000, 0x0503}, * capture mode */ |
| 167 | {0x00, 0x0000, 0x2000}, |
| 168 | {0x00, 0x0013, 0x2301}, |
| 169 | {0x00, 0x0003, 0x2000}, |
| 170 | {0x00, 0x0001, 0x21ac}, |
| 171 | {0x00, 0x0001, 0x21a6}, |
| 172 | {0x00, 0x0000, 0x21a7}, /* brightness */ |
| 173 | {0x00, 0x0020, 0x21a8}, /* contrast */ |
| 174 | {0x00, 0x0001, 0x21ac}, /* sat/hue */ |
| 175 | {0x00, 0x0000, 0x21ad}, /* hue */ |
| 176 | {0x00, 0x001a, 0x21ae}, /* saturation */ |
| 177 | {0x00, 0x0002, 0x21a3}, /* gamma */ |
| 178 | {0x30, 0x0004, 0x000a}, |
| 179 | {0xb0, 0x0001, 0x0000}, |
| 180 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 181 | {0xa1, 0x0080, 0x0001}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 182 | {0x30, 0x0049, 0x0000}, |
| 183 | {0x30, 0x0060, 0x0005}, |
| 184 | {0x0c, 0x0004, 0x0000}, |
| 185 | {0x00, 0x0000, 0x0000}, |
| 186 | {0x00, 0x0000, 0x2000}, |
| 187 | {0x00, 0x0013, 0x2301}, |
| 188 | {0x00, 0x0003, 0x2000}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | /* clicksmart 420 open data ? */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 192 | static const struct cmd spca504A_clicksmart420_open_data[] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 193 | {0x00, 0x0001, 0x2501}, |
| 194 | {0x20, 0x0502, 0x0000}, |
| 195 | {0x06, 0x0000, 0x0000}, |
| 196 | {0x00, 0x0004, 0x2880}, |
| 197 | {0x00, 0x0001, 0x2881}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 198 | |
| 199 | {0xa0, 0x0000, 0x0503}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 200 | }; |
| 201 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 202 | static const u8 qtable_creative_pccam[2][64] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 203 | { /* Q-table Y-components */ |
| 204 | 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, |
| 205 | 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, |
| 206 | 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11, |
| 207 | 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13, |
| 208 | 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17, |
| 209 | 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c, |
| 210 | 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e, |
| 211 | 0x16, 0x1c, 0x1d, 0x1d, 0x22, 0x1e, 0x1f, 0x1e}, |
| 212 | { /* Q-table C-components */ |
| 213 | 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 214 | 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, |
| 215 | 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 216 | 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 217 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 218 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 219 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 220 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} |
| 221 | }; |
| 222 | |
| 223 | /* FIXME: This Q-table is identical to the Creative PC-CAM one, |
| 224 | * except for one byte. Possibly a typo? |
| 225 | * NWG: 18/05/2003. |
| 226 | */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 227 | static const u8 qtable_spca504_default[2][64] = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 228 | { /* Q-table Y-components */ |
| 229 | 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, |
| 230 | 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, |
| 231 | 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11, |
| 232 | 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13, |
| 233 | 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17, |
| 234 | 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c, |
| 235 | 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e, |
| 236 | 0x16, 0x1c, 0x1d, 0x1d, 0x1d /* 0x22 */ , 0x1e, 0x1f, 0x1e, |
| 237 | }, |
| 238 | { /* Q-table C-components */ |
| 239 | 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 240 | 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, |
| 241 | 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 242 | 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 243 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 244 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 245 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, |
| 246 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} |
| 247 | }; |
| 248 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 249 | /* read <len> bytes to gspca_dev->usb_buf */ |
| 250 | static void reg_r(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 251 | u8 req, |
| 252 | u16 index, |
| 253 | u16 len) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 254 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 255 | int ret; |
| 256 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 257 | #ifdef GSPCA_DEBUG |
| 258 | if (len > USB_BUF_SZ) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 259 | pr_err("reg_r: buffer overflow\n"); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 260 | return; |
| 261 | } |
| 262 | #endif |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 263 | if (gspca_dev->usb_err < 0) |
| 264 | return; |
| 265 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 266 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 267 | req, |
| 268 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 269 | 0, /* value */ |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 270 | index, |
| 271 | len ? gspca_dev->usb_buf : NULL, len, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 272 | 500); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 273 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 274 | pr_err("reg_r err %d\n", ret); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 275 | gspca_dev->usb_err = ret; |
| 276 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 277 | } |
| 278 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 279 | /* write one byte */ |
| 280 | static void reg_w_1(struct gspca_dev *gspca_dev, |
| 281 | u8 req, |
| 282 | u16 value, |
| 283 | u16 index, |
| 284 | u16 byte) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 285 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 286 | int ret; |
| 287 | |
| 288 | if (gspca_dev->usb_err < 0) |
| 289 | return; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 290 | gspca_dev->usb_buf[0] = byte; |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 291 | ret = usb_control_msg(gspca_dev->dev, |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 292 | usb_sndctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 293 | req, |
| 294 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 295 | value, index, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 296 | gspca_dev->usb_buf, 1, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 297 | 500); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 298 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 299 | pr_err("reg_w_1 err %d\n", ret); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 300 | gspca_dev->usb_err = ret; |
| 301 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 302 | } |
| 303 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 304 | /* write req / index / value */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 305 | static void reg_w_riv(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 306 | u8 req, u16 index, u16 value) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 307 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 308 | struct usb_device *dev = gspca_dev->dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 309 | int ret; |
| 310 | |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 311 | if (gspca_dev->usb_err < 0) |
| 312 | return; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 313 | ret = usb_control_msg(dev, |
| 314 | usb_sndctrlpipe(dev, 0), |
| 315 | req, |
Jean-Francois Moine | bf7f0b9 | 2008-07-03 11:09:12 -0300 | [diff] [blame] | 316 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 317 | value, index, NULL, 0, 500); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 318 | if (ret < 0) { |
Joe Perches | 133a9fe | 2011-08-21 19:56:57 -0300 | [diff] [blame] | 319 | pr_err("reg_w_riv err %d\n", ret); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 320 | gspca_dev->usb_err = ret; |
| 321 | return; |
| 322 | } |
| 323 | PDEBUG(D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x", |
| 324 | req, index, value); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 325 | } |
| 326 | |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 327 | static void write_vector(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 328 | const struct cmd *data, int ncmds) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 329 | { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 330 | while (--ncmds >= 0) { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 331 | reg_w_riv(gspca_dev, data->req, data->idx, data->val); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 332 | data++; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 333 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 334 | } |
| 335 | |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 336 | static void setup_qtable(struct gspca_dev *gspca_dev, |
| 337 | const u8 qtable[2][64]) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 338 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 339 | int i; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 340 | |
| 341 | /* loop over y components */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 342 | for (i = 0; i < 64; i++) |
Jean-François Moine | 780e312 | 2010-10-19 04:29:10 -0300 | [diff] [blame] | 343 | reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 344 | |
| 345 | /* loop over c components */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 346 | for (i = 0; i < 64; i++) |
| 347 | reg_w_riv(gspca_dev, 0x00, 0x2840 + i, qtable[1][i]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 351 | u8 req, u16 idx, u16 val) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 352 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 353 | reg_w_riv(gspca_dev, req, idx, val); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 354 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
| 355 | PDEBUG(D_FRAM, "before wait 0x%04x", gspca_dev->usb_buf[0]); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 356 | reg_w_riv(gspca_dev, req, idx, val); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 357 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 358 | msleep(200); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 359 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
| 360 | PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 361 | } |
| 362 | |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 363 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 364 | static void spca504_read_info(struct gspca_dev *gspca_dev) |
| 365 | { |
| 366 | int i; |
| 367 | u8 info[6]; |
| 368 | |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 369 | for (i = 0; i < 6; i++) { |
| 370 | reg_r(gspca_dev, 0, i, 1); |
| 371 | info[i] = gspca_dev->usb_buf[0]; |
| 372 | } |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 373 | PDEBUG(D_STREAM, |
| 374 | "Read info: %d %d %d %d %d %d." |
| 375 | " Should be 1,0,2,2,0,0", |
| 376 | info[0], info[1], info[2], |
| 377 | info[3], info[4], info[5]); |
| 378 | } |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 379 | #endif |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 380 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 381 | static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 382 | u8 req, |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 383 | u16 idx, u16 val, u8 endcode, u8 count) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 384 | { |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 385 | u16 status; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 386 | |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 387 | reg_w_riv(gspca_dev, req, idx, val); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 388 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 389 | if (gspca_dev->usb_err < 0) |
| 390 | return; |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 391 | PDEBUG(D_FRAM, "Status 0x%02x Need 0x%02x", |
| 392 | gspca_dev->usb_buf[0], endcode); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 393 | if (!count) |
| 394 | return; |
| 395 | count = 200; |
| 396 | while (--count > 0) { |
| 397 | msleep(10); |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 398 | /* gsmart mini2 write a each wait setting 1 ms is enough */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 399 | /* reg_w_riv(gspca_dev, req, idx, val); */ |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 400 | reg_r(gspca_dev, 0x01, 0x0001, 1); |
| 401 | status = gspca_dev->usb_buf[0]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 402 | if (status == endcode) { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 403 | PDEBUG(D_FRAM, "status 0x%04x after wait %d", |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 404 | status, 200 - count); |
| 405 | break; |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 410 | static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 411 | { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 412 | int count = 10; |
| 413 | |
| 414 | while (--count > 0) { |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 415 | reg_r(gspca_dev, 0x21, 0, 1); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 416 | if ((gspca_dev->usb_buf[0] & 0x01) == 0) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 417 | break; |
| 418 | msleep(10); |
| 419 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) |
| 423 | { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 424 | int count = 50; |
| 425 | |
| 426 | while (--count > 0) { |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 427 | reg_r(gspca_dev, 0x21, 1, 1); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 428 | if (gspca_dev->usb_buf[0] != 0) { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 429 | reg_w_1(gspca_dev, 0x21, 0, 1, 0); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 430 | reg_r(gspca_dev, 0x21, 1, 1); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 431 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 432 | break; |
| 433 | } |
| 434 | msleep(10); |
| 435 | } |
| 436 | } |
| 437 | |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 438 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 439 | static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) |
| 440 | { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 441 | u8 *data; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 442 | |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 443 | data = gspca_dev->usb_buf; |
| 444 | reg_r(gspca_dev, 0x20, 0, 5); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 445 | PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d", |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 446 | data[0], data[1], data[2], data[3], data[4]); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 447 | reg_r(gspca_dev, 0x23, 0, 64); |
| 448 | reg_r(gspca_dev, 0x23, 1, 64); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 449 | } |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 450 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 451 | |
| 452 | static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) |
| 453 | { |
| 454 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 455 | u8 Size; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 456 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 457 | Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 458 | switch (sd->bridge) { |
| 459 | case BRIDGE_SPCA533: |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 460 | reg_w_riv(gspca_dev, 0x31, 0, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 461 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 462 | spca504B_PollingDataReady(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 463 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 464 | spca50x_GetFirmware(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 465 | #endif |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 466 | reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */ |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 467 | reg_r(gspca_dev, 0x24, 8, 1); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 468 | |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 469 | reg_w_1(gspca_dev, 0x25, 0, 4, Size); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 470 | reg_r(gspca_dev, 0x25, 4, 1); /* size */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 471 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 472 | |
| 473 | /* Init the cam width height with some values get on init ? */ |
Jean-Francois Moine | 07d1c69 | 2010-01-10 04:32:11 -0300 | [diff] [blame] | 474 | reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 475 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 476 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 477 | break; |
| 478 | default: |
| 479 | /* case BRIDGE_SPCA504B: */ |
| 480 | /* case BRIDGE_SPCA536: */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 481 | reg_w_1(gspca_dev, 0x25, 0, 4, Size); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 482 | reg_r(gspca_dev, 0x25, 4, 1); /* size */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 483 | reg_w_1(gspca_dev, 0x27, 0, 0, 6); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 484 | reg_r(gspca_dev, 0x27, 0, 1); /* type */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 485 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 486 | break; |
| 487 | case BRIDGE_SPCA504: |
| 488 | Size += 3; |
| 489 | if (sd->subtype == AiptekMiniPenCam13) { |
| 490 | /* spca504a aiptek */ |
| 491 | spca504A_acknowledged_command(gspca_dev, |
| 492 | 0x08, Size, 0, |
| 493 | 0x80 | (Size & 0x0f), 1); |
| 494 | spca504A_acknowledged_command(gspca_dev, |
| 495 | 1, 3, 0, 0x9f, 0); |
| 496 | } else { |
| 497 | spca504_acknowledged_command(gspca_dev, 0x08, Size, 0); |
| 498 | } |
| 499 | break; |
| 500 | case BRIDGE_SPCA504C: |
| 501 | /* capture mode */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 502 | reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00); |
| 503 | reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f)); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 504 | break; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | static void spca504_wait_status(struct gspca_dev *gspca_dev) |
| 509 | { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 510 | int cnt; |
| 511 | |
| 512 | cnt = 256; |
| 513 | while (--cnt > 0) { |
| 514 | /* With this we get the status, when return 0 it's all ok */ |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 515 | reg_r(gspca_dev, 0x06, 0x00, 1); |
| 516 | if (gspca_dev->usb_buf[0] == 0) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 517 | return; |
| 518 | msleep(10); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | static void spca504B_setQtable(struct gspca_dev *gspca_dev) |
| 523 | { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 524 | reg_w_1(gspca_dev, 0x26, 0, 0, 3); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 525 | reg_r(gspca_dev, 0x26, 0, 1); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 526 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 527 | } |
| 528 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 529 | static void setbrightness(struct gspca_dev *gspca_dev, s32 val) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 530 | { |
| 531 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 532 | u16 reg; |
| 533 | |
| 534 | reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7; |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 535 | reg_w_riv(gspca_dev, 0x00, reg, val); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 536 | } |
| 537 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 538 | static void setcontrast(struct gspca_dev *gspca_dev, s32 val) |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 539 | { |
| 540 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 541 | u16 reg; |
| 542 | |
| 543 | reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8; |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 544 | reg_w_riv(gspca_dev, 0x00, reg, val); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 545 | } |
| 546 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 547 | static void setcolors(struct gspca_dev *gspca_dev, s32 val) |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 548 | { |
| 549 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 550 | u16 reg; |
| 551 | |
| 552 | reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae; |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 553 | reg_w_riv(gspca_dev, 0x00, reg, val); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static void init_ctl_reg(struct gspca_dev *gspca_dev) |
| 557 | { |
| 558 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 559 | int pollreg = 1; |
| 560 | |
| 561 | switch (sd->bridge) { |
| 562 | case BRIDGE_SPCA504: |
| 563 | case BRIDGE_SPCA504C: |
| 564 | pollreg = 0; |
| 565 | /* fall thru */ |
| 566 | default: |
| 567 | /* case BRIDGE_SPCA533: */ |
| 568 | /* case BRIDGE_SPCA504B: */ |
Jean-Francois Moine | 07d1c69 | 2010-01-10 04:32:11 -0300 | [diff] [blame] | 569 | reg_w_riv(gspca_dev, 0, 0x21ad, 0x00); /* hue */ |
| 570 | reg_w_riv(gspca_dev, 0, 0x21ac, 0x01); /* sat/hue */ |
| 571 | reg_w_riv(gspca_dev, 0, 0x21a3, 0x00); /* gamma */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 572 | break; |
| 573 | case BRIDGE_SPCA536: |
Jean-Francois Moine | 07d1c69 | 2010-01-10 04:32:11 -0300 | [diff] [blame] | 574 | reg_w_riv(gspca_dev, 0, 0x20f5, 0x40); |
| 575 | reg_w_riv(gspca_dev, 0, 0x20f4, 0x01); |
| 576 | reg_w_riv(gspca_dev, 0, 0x2089, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 577 | break; |
| 578 | } |
| 579 | if (pollreg) |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 580 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | /* this function is called at probe time */ |
| 584 | static int sd_config(struct gspca_dev *gspca_dev, |
| 585 | const struct usb_device_id *id) |
| 586 | { |
| 587 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 588 | struct cam *cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 589 | |
| 590 | cam = &gspca_dev->cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 591 | |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 592 | sd->bridge = id->driver_info >> 8; |
| 593 | sd->subtype = id->driver_info; |
| 594 | |
| 595 | if (sd->subtype == AiptekMiniPenCam13) { |
Jean-François Moine | 780e312 | 2010-10-19 04:29:10 -0300 | [diff] [blame] | 596 | |
| 597 | /* try to get the firmware as some cam answer 2.0.1.2.2 |
| 598 | * and should be a spca504b then overwrite that setting */ |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 599 | reg_r(gspca_dev, 0x20, 0, 1); |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 600 | switch (gspca_dev->usb_buf[0]) { |
| 601 | case 1: |
| 602 | break; /* (right bridge/subtype) */ |
| 603 | case 2: |
| 604 | sd->bridge = BRIDGE_SPCA504B; |
| 605 | sd->subtype = 0; |
| 606 | break; |
| 607 | default: |
| 608 | return -ENODEV; |
| 609 | } |
| 610 | } |
| 611 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 612 | switch (sd->bridge) { |
| 613 | default: |
| 614 | /* case BRIDGE_SPCA504B: */ |
| 615 | /* case BRIDGE_SPCA504: */ |
| 616 | /* case BRIDGE_SPCA536: */ |
| 617 | cam->cam_mode = vga_mode; |
Jean-François Moine | 780e312 | 2010-10-19 04:29:10 -0300 | [diff] [blame] | 618 | cam->nmodes = ARRAY_SIZE(vga_mode); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 619 | break; |
| 620 | case BRIDGE_SPCA533: |
| 621 | cam->cam_mode = custom_mode; |
Johannes Goerner | af5f88c | 2009-07-09 03:28:46 -0300 | [diff] [blame] | 622 | if (sd->subtype == MegaImageVI) /* 320x240 only */ |
| 623 | cam->nmodes = ARRAY_SIZE(custom_mode) - 1; |
| 624 | else |
| 625 | cam->nmodes = ARRAY_SIZE(custom_mode); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 626 | break; |
| 627 | case BRIDGE_SPCA504C: |
| 628 | cam->cam_mode = vga_mode2; |
Mauro Carvalho Chehab | d6f76b9 | 2009-07-22 00:02:29 -0300 | [diff] [blame] | 629 | cam->nmodes = ARRAY_SIZE(vga_mode2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 630 | break; |
| 631 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 632 | return 0; |
| 633 | } |
| 634 | |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 635 | /* this function is called at probe and resume time */ |
| 636 | static int sd_init(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 637 | { |
| 638 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 639 | |
| 640 | switch (sd->bridge) { |
| 641 | case BRIDGE_SPCA504B: |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 642 | reg_w_riv(gspca_dev, 0x1d, 0x00, 0); |
Jean-Francois Moine | 07d1c69 | 2010-01-10 04:32:11 -0300 | [diff] [blame] | 643 | reg_w_riv(gspca_dev, 0x00, 0x2306, 0x01); |
| 644 | reg_w_riv(gspca_dev, 0x00, 0x0d04, 0x00); |
| 645 | reg_w_riv(gspca_dev, 0x00, 0x2000, 0x00); |
| 646 | reg_w_riv(gspca_dev, 0x00, 0x2301, 0x13); |
| 647 | reg_w_riv(gspca_dev, 0x00, 0x2306, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 648 | /* fall thru */ |
| 649 | case BRIDGE_SPCA533: |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 650 | spca504B_PollingDataReady(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 651 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 652 | spca50x_GetFirmware(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 653 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 654 | break; |
| 655 | case BRIDGE_SPCA536: |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 656 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 657 | spca50x_GetFirmware(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 658 | #endif |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 659 | reg_r(gspca_dev, 0x00, 0x5002, 1); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 660 | reg_w_1(gspca_dev, 0x24, 0, 0, 0); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 661 | reg_r(gspca_dev, 0x24, 0, 1); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 662 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 663 | reg_w_riv(gspca_dev, 0x34, 0, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 664 | spca504B_WaitCmdStatus(gspca_dev); |
| 665 | break; |
| 666 | case BRIDGE_SPCA504C: /* pccam600 */ |
| 667 | PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)"); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 668 | reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000); |
| 669 | reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001); /* reset */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 670 | spca504_wait_status(gspca_dev); |
| 671 | if (sd->subtype == LogitechClickSmart420) |
| 672 | write_vector(gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 673 | spca504A_clicksmart420_open_data, |
| 674 | ARRAY_SIZE(spca504A_clicksmart420_open_data)); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 675 | else |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 676 | write_vector(gspca_dev, spca504_pccam600_open_data, |
| 677 | ARRAY_SIZE(spca504_pccam600_open_data)); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 678 | setup_qtable(gspca_dev, qtable_creative_pccam); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 679 | break; |
| 680 | default: |
| 681 | /* case BRIDGE_SPCA504: */ |
| 682 | PDEBUG(D_STREAM, "Opening SPCA504"); |
| 683 | if (sd->subtype == AiptekMiniPenCam13) { |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 684 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 685 | spca504_read_info(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 686 | #endif |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 687 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 688 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ |
| 689 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 690 | 8, 3, 0x9e, 1); |
Uwe Kleine-König | b27d63d | 2010-07-01 20:48:44 +0200 | [diff] [blame] | 691 | /* Twice sequential need status 0xff->0x9e->0x9d */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 692 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 693 | 8, 3, 0x9e, 0); |
| 694 | |
| 695 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 696 | 0, 0, 0x9d, 1); |
| 697 | /******************************/ |
| 698 | /* spca504a aiptek */ |
| 699 | spca504A_acknowledged_command(gspca_dev, 0x08, |
| 700 | 6, 0, 0x86, 1); |
| 701 | /* reg_write (dev, 0, 0x2000, 0); */ |
| 702 | /* reg_write (dev, 0, 0x2883, 1); */ |
| 703 | /* spca504A_acknowledged_command (gspca_dev, 0x08, |
| 704 | 6, 0, 0x86, 1); */ |
| 705 | /* spca504A_acknowledged_command (gspca_dev, 0x24, |
| 706 | 0, 0, 0x9D, 1); */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 707 | reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05); |
| 708 | /* L92 sno1t.txt */ |
| 709 | reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 710 | spca504A_acknowledged_command(gspca_dev, 0x01, |
| 711 | 0x0f, 0, 0xff, 0); |
| 712 | } |
| 713 | /* setup qtable */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 714 | reg_w_riv(gspca_dev, 0, 0x2000, 0); |
| 715 | reg_w_riv(gspca_dev, 0, 0x2883, 1); |
| 716 | setup_qtable(gspca_dev, qtable_spca504_default); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 717 | break; |
| 718 | } |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 719 | return gspca_dev->usb_err; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 720 | } |
| 721 | |
Jean-Francois Moine | 72ab97c | 2008-09-20 06:39:08 -0300 | [diff] [blame] | 722 | static int sd_start(struct gspca_dev *gspca_dev) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 723 | { |
| 724 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 725 | int enable; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 726 | |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 727 | /* create the JPEG header */ |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 728 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
| 729 | 0x22); /* JPEG 411 */ |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 730 | jpeg_set_qual(sd->jpeg_hdr, v4l2_ctrl_g_ctrl(sd->jpegqual)); |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 731 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 732 | if (sd->bridge == BRIDGE_SPCA504B) |
| 733 | spca504B_setQtable(gspca_dev); |
| 734 | spca504B_SetSizeType(gspca_dev); |
| 735 | switch (sd->bridge) { |
| 736 | default: |
| 737 | /* case BRIDGE_SPCA504B: */ |
| 738 | /* case BRIDGE_SPCA533: */ |
| 739 | /* case BRIDGE_SPCA536: */ |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 740 | switch (sd->subtype) { |
| 741 | case MegapixV4: |
| 742 | case LogitechClickSmart820: |
| 743 | case MegaImageVI: |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 744 | reg_w_riv(gspca_dev, 0xf0, 0, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 745 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | 8295d99 | 2008-09-03 17:12:19 -0300 | [diff] [blame] | 746 | reg_r(gspca_dev, 0xf0, 4, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 747 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 748 | break; |
| 749 | default: |
Jean-Francois Moine | 07d1c69 | 2010-01-10 04:32:11 -0300 | [diff] [blame] | 750 | reg_w_riv(gspca_dev, 0x31, 0x0004, 0x00); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 751 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 752 | spca504B_PollingDataReady(gspca_dev); |
| 753 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 754 | } |
| 755 | break; |
| 756 | case BRIDGE_SPCA504: |
| 757 | if (sd->subtype == AiptekMiniPenCam13) { |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 758 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 759 | spca504_read_info(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 760 | #endif |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 761 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 762 | /* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */ |
| 763 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 764 | 8, 3, 0x9e, 1); |
Uwe Kleine-König | b27d63d | 2010-07-01 20:48:44 +0200 | [diff] [blame] | 765 | /* Twice sequential need status 0xff->0x9e->0x9d */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 766 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 767 | 8, 3, 0x9e, 0); |
| 768 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 769 | 0, 0, 0x9d, 1); |
| 770 | } else { |
| 771 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 772 | #ifdef GSPCA_DEBUG |
Jean-Francois Moine | 6f08126 | 2010-01-10 14:39:24 -0300 | [diff] [blame] | 773 | spca504_read_info(gspca_dev); |
Jean-François Moine | cf25220 | 2011-05-17 05:32:39 -0300 | [diff] [blame] | 774 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 775 | spca504_acknowledged_command(gspca_dev, 0x24, 8, 3); |
| 776 | spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); |
| 777 | } |
| 778 | spca504B_SetSizeType(gspca_dev); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 779 | reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05); |
| 780 | /* L92 sno1t.txt */ |
| 781 | reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 782 | break; |
| 783 | case BRIDGE_SPCA504C: |
| 784 | if (sd->subtype == LogitechClickSmart420) { |
| 785 | write_vector(gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 786 | spca504A_clicksmart420_init_data, |
| 787 | ARRAY_SIZE(spca504A_clicksmart420_init_data)); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 788 | } else { |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 789 | write_vector(gspca_dev, spca504_pccam600_init_data, |
| 790 | ARRAY_SIZE(spca504_pccam600_init_data)); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 791 | } |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 792 | enable = (sd->autogain ? 0x04 : 0x01); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 793 | reg_w_riv(gspca_dev, 0x0c, 0x0000, enable); |
| 794 | /* auto exposure */ |
| 795 | reg_w_riv(gspca_dev, 0xb0, 0x0000, enable); |
| 796 | /* auto whiteness */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 797 | |
| 798 | /* set default exposure compensation and whiteness balance */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 799 | reg_w_riv(gspca_dev, 0x30, 0x0001, 800); /* ~ 20 fps */ |
| 800 | reg_w_riv(gspca_dev, 0x30, 0x0002, 1600); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 801 | spca504B_SetSizeType(gspca_dev); |
| 802 | break; |
| 803 | } |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 804 | init_ctl_reg(gspca_dev); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 805 | return gspca_dev->usb_err; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | static void sd_stopN(struct gspca_dev *gspca_dev) |
| 809 | { |
| 810 | struct sd *sd = (struct sd *) gspca_dev; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 811 | |
| 812 | switch (sd->bridge) { |
| 813 | default: |
| 814 | /* case BRIDGE_SPCA533: */ |
| 815 | /* case BRIDGE_SPCA536: */ |
| 816 | /* case BRIDGE_SPCA504B: */ |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 817 | reg_w_riv(gspca_dev, 0x31, 0, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 818 | spca504B_WaitCmdStatus(gspca_dev); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 819 | spca504B_PollingDataReady(gspca_dev); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 820 | break; |
| 821 | case BRIDGE_SPCA504: |
| 822 | case BRIDGE_SPCA504C: |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 823 | reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 824 | |
| 825 | if (sd->subtype == AiptekMiniPenCam13) { |
| 826 | /* spca504a aiptek */ |
| 827 | /* spca504A_acknowledged_command(gspca_dev, 0x08, |
| 828 | 6, 0, 0x86, 1); */ |
| 829 | spca504A_acknowledged_command(gspca_dev, 0x24, |
| 830 | 0x00, 0x00, 0x9d, 1); |
| 831 | spca504A_acknowledged_command(gspca_dev, 0x01, |
| 832 | 0x0f, 0x00, 0xff, 1); |
| 833 | } else { |
| 834 | spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); |
Jean-Francois Moine | ecb7768 | 2009-12-02 14:39:53 -0300 | [diff] [blame] | 835 | reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 836 | } |
| 837 | break; |
| 838 | } |
| 839 | } |
| 840 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 841 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 842 | u8 *data, /* isoc packet */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 843 | int len) /* iso packet length */ |
| 844 | { |
| 845 | struct sd *sd = (struct sd *) gspca_dev; |
| 846 | int i, sof = 0; |
Jean-Francois Moine | 2e1794b | 2009-08-31 06:15:22 -0300 | [diff] [blame] | 847 | static u8 ffd9[] = {0xff, 0xd9}; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 848 | |
| 849 | /* frames are jpeg 4.1.1 without 0xff escape */ |
| 850 | switch (sd->bridge) { |
| 851 | case BRIDGE_SPCA533: |
| 852 | if (data[0] == 0xff) { |
| 853 | if (data[1] != 0x01) { /* drop packet */ |
| 854 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ |
| 855 | return; |
| 856 | } |
| 857 | sof = 1; |
| 858 | data += SPCA533_OFFSET_DATA; |
| 859 | len -= SPCA533_OFFSET_DATA; |
| 860 | } else { |
| 861 | data += 1; |
| 862 | len -= 1; |
| 863 | } |
| 864 | break; |
| 865 | case BRIDGE_SPCA536: |
| 866 | if (data[0] == 0xff) { |
| 867 | sof = 1; |
| 868 | data += SPCA536_OFFSET_DATA; |
| 869 | len -= SPCA536_OFFSET_DATA; |
| 870 | } else { |
| 871 | data += 2; |
| 872 | len -= 2; |
| 873 | } |
| 874 | break; |
| 875 | default: |
| 876 | /* case BRIDGE_SPCA504: */ |
| 877 | /* case BRIDGE_SPCA504B: */ |
| 878 | switch (data[0]) { |
| 879 | case 0xfe: /* start of frame */ |
| 880 | sof = 1; |
| 881 | data += SPCA50X_OFFSET_DATA; |
| 882 | len -= SPCA50X_OFFSET_DATA; |
| 883 | break; |
| 884 | case 0xff: /* drop packet */ |
| 885 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ |
| 886 | return; |
| 887 | default: |
| 888 | data += 1; |
| 889 | len -= 1; |
| 890 | break; |
| 891 | } |
| 892 | break; |
| 893 | case BRIDGE_SPCA504C: |
| 894 | switch (data[0]) { |
| 895 | case 0xfe: /* start of frame */ |
| 896 | sof = 1; |
| 897 | data += SPCA504_PCCAM600_OFFSET_DATA; |
| 898 | len -= SPCA504_PCCAM600_OFFSET_DATA; |
| 899 | break; |
| 900 | case 0xff: /* drop packet */ |
| 901 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ |
| 902 | return; |
| 903 | default: |
| 904 | data += 1; |
| 905 | len -= 1; |
| 906 | break; |
| 907 | } |
| 908 | break; |
| 909 | } |
| 910 | if (sof) { /* start of frame */ |
Jean-Francois Moine | 76dd272 | 2009-11-13 09:21:03 -0300 | [diff] [blame] | 911 | gspca_frame_add(gspca_dev, LAST_PACKET, |
| 912 | ffd9, 2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 913 | |
| 914 | /* put the JPEG header in the new frame */ |
Jean-Francois Moine | 76dd272 | 2009-11-13 09:21:03 -0300 | [diff] [blame] | 915 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
Jean-Francois Moine | 71cb276 | 2009-03-03 05:33:41 -0300 | [diff] [blame] | 916 | sd->jpeg_hdr, JPEG_HDR_SZ); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | /* add 0x00 after 0xff */ |
Jean-Francois Moine | 59746e1 | 2009-04-23 14:33:00 -0300 | [diff] [blame] | 920 | i = 0; |
| 921 | do { |
| 922 | if (data[i] == 0xff) { |
Jean-Francois Moine | 76dd272 | 2009-11-13 09:21:03 -0300 | [diff] [blame] | 923 | gspca_frame_add(gspca_dev, INTER_PACKET, |
Jean-Francois Moine | 59746e1 | 2009-04-23 14:33:00 -0300 | [diff] [blame] | 924 | data, i + 1); |
| 925 | len -= i; |
| 926 | data += i; |
| 927 | *data = 0x00; |
| 928 | i = 0; |
| 929 | } |
| 930 | i++; |
| 931 | } while (i < len); |
Jean-Francois Moine | 76dd272 | 2009-11-13 09:21:03 -0300 | [diff] [blame] | 932 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 933 | } |
| 934 | |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 935 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, |
| 936 | struct v4l2_jpegcompression *jcomp) |
| 937 | { |
| 938 | struct sd *sd = (struct sd *) gspca_dev; |
| 939 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 940 | v4l2_ctrl_s_ctrl(sd->jpegqual, jcomp->quality); |
| 941 | return 0; |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, |
| 945 | struct v4l2_jpegcompression *jcomp) |
| 946 | { |
| 947 | struct sd *sd = (struct sd *) gspca_dev; |
| 948 | |
| 949 | memset(jcomp, 0, sizeof *jcomp); |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 950 | jcomp->quality = v4l2_ctrl_g_ctrl(sd->jpegqual); |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 951 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT |
| 952 | | V4L2_JPEG_MARKER_DQT; |
| 953 | return 0; |
| 954 | } |
| 955 | |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 956 | static int sd_s_ctrl(struct v4l2_ctrl *ctrl) |
| 957 | { |
| 958 | struct gspca_dev *gspca_dev = |
| 959 | container_of(ctrl->handler, struct gspca_dev, ctrl_handler); |
| 960 | struct sd *sd = (struct sd *)gspca_dev; |
| 961 | |
| 962 | gspca_dev->usb_err = 0; |
| 963 | |
| 964 | if (!gspca_dev->streaming) |
| 965 | return 0; |
| 966 | |
| 967 | switch (ctrl->id) { |
| 968 | case V4L2_CID_BRIGHTNESS: |
| 969 | setbrightness(gspca_dev, ctrl->val); |
| 970 | break; |
| 971 | case V4L2_CID_CONTRAST: |
| 972 | setcontrast(gspca_dev, ctrl->val); |
| 973 | break; |
| 974 | case V4L2_CID_SATURATION: |
| 975 | setcolors(gspca_dev, ctrl->val); |
| 976 | break; |
| 977 | case V4L2_CID_AUTOGAIN: |
| 978 | sd->autogain = ctrl->val; |
| 979 | break; |
| 980 | case V4L2_CID_JPEG_COMPRESSION_QUALITY: |
| 981 | jpeg_set_qual(sd->jpeg_hdr, ctrl->val); |
| 982 | break; |
| 983 | } |
| 984 | return gspca_dev->usb_err; |
| 985 | } |
| 986 | |
| 987 | static const struct v4l2_ctrl_ops sd_ctrl_ops = { |
| 988 | .s_ctrl = sd_s_ctrl, |
| 989 | }; |
| 990 | |
| 991 | static int sd_init_controls(struct gspca_dev *gspca_dev) |
| 992 | { |
| 993 | struct sd *sd = (struct sd *)gspca_dev; |
| 994 | struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; |
| 995 | |
| 996 | gspca_dev->vdev.ctrl_handler = hdl; |
| 997 | v4l2_ctrl_handler_init(hdl, 5); |
| 998 | v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 999 | V4L2_CID_BRIGHTNESS, -128, 127, 1, 0); |
| 1000 | v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1001 | V4L2_CID_CONTRAST, 0, 255, 1, 0x20); |
| 1002 | v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1003 | V4L2_CID_SATURATION, 0, 255, 1, 0x1a); |
| 1004 | v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1005 | V4L2_CID_AUTOGAIN, 0, 1, 1, 1); |
| 1006 | sd->jpegqual = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, |
| 1007 | V4L2_CID_JPEG_COMPRESSION_QUALITY, |
| 1008 | QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF); |
| 1009 | |
| 1010 | if (hdl->error) { |
| 1011 | pr_err("Could not initialize controls\n"); |
| 1012 | return hdl->error; |
| 1013 | } |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1017 | /* sub-driver description */ |
Jean-Francois Moine | a5ae206 | 2008-07-04 11:16:16 -0300 | [diff] [blame] | 1018 | static const struct sd_desc sd_desc = { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1019 | .name = MODULE_NAME, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1020 | .config = sd_config, |
Jean-Francois Moine | 012d6b0 | 2008-09-03 17:12:16 -0300 | [diff] [blame] | 1021 | .init = sd_init, |
Hans Verkuil | ed5cd6b | 2012-05-16 08:49:10 -0300 | [diff] [blame] | 1022 | .init_controls = sd_init_controls, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1023 | .start = sd_start, |
| 1024 | .stopN = sd_stopN, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1025 | .pkt_scan = sd_pkt_scan, |
Jean-Francois Moine | 77ac0ba | 2009-03-02 06:40:52 -0300 | [diff] [blame] | 1026 | .get_jcomp = sd_get_jcomp, |
| 1027 | .set_jcomp = sd_set_jcomp, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1028 | }; |
| 1029 | |
| 1030 | /* -- module initialisation -- */ |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 1031 | #define BS(bridge, subtype) \ |
| 1032 | .driver_info = (BRIDGE_ ## bridge << 8) \ |
| 1033 | | (subtype) |
Jean-François Moine | 95c967c | 2011-01-13 05:20:29 -0300 | [diff] [blame] | 1034 | static const struct usb_device_id device_table[] = { |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 1035 | {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)}, |
| 1036 | {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)}, |
| 1037 | {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)}, |
| 1038 | {USB_DEVICE(0x0458, 0x7006), BS(SPCA504B, 0)}, |
| 1039 | {USB_DEVICE(0x0461, 0x0821), BS(SPCA533, 0)}, |
| 1040 | {USB_DEVICE(0x046d, 0x0905), BS(SPCA533, LogitechClickSmart820)}, |
| 1041 | {USB_DEVICE(0x046d, 0x0960), BS(SPCA504C, LogitechClickSmart420)}, |
| 1042 | {USB_DEVICE(0x0471, 0x0322), BS(SPCA504B, 0)}, |
| 1043 | {USB_DEVICE(0x04a5, 0x3003), BS(SPCA504B, 0)}, |
| 1044 | {USB_DEVICE(0x04a5, 0x3008), BS(SPCA533, 0)}, |
| 1045 | {USB_DEVICE(0x04a5, 0x300a), BS(SPCA533, 0)}, |
| 1046 | {USB_DEVICE(0x04f1, 0x1001), BS(SPCA504B, 0)}, |
| 1047 | {USB_DEVICE(0x04fc, 0x500c), BS(SPCA504B, 0)}, |
| 1048 | {USB_DEVICE(0x04fc, 0x504a), BS(SPCA504, AiptekMiniPenCam13)}, |
| 1049 | {USB_DEVICE(0x04fc, 0x504b), BS(SPCA504B, 0)}, |
| 1050 | {USB_DEVICE(0x04fc, 0x5330), BS(SPCA533, 0)}, |
| 1051 | {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)}, |
| 1052 | {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)}, |
Jean-Francois Moine | d41592a | 2009-12-13 14:11:07 -0300 | [diff] [blame] | 1053 | {USB_DEVICE(0x052b, 0x1507), BS(SPCA533, MegapixV4)}, |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 1054 | {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)}, |
Johannes Goerner | af5f88c | 2009-07-09 03:28:46 -0300 | [diff] [blame] | 1055 | {USB_DEVICE(0x052b, 0x1803), BS(SPCA533, MegaImageVI)}, |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 1056 | {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)}, |
| 1057 | {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)}, |
| 1058 | {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)}, |
| 1059 | {USB_DEVICE(0x055f, 0xc211), BS(SPCA536, 0)}, |
| 1060 | {USB_DEVICE(0x055f, 0xc230), BS(SPCA533, 0)}, |
| 1061 | {USB_DEVICE(0x055f, 0xc232), BS(SPCA533, 0)}, |
| 1062 | {USB_DEVICE(0x055f, 0xc360), BS(SPCA536, 0)}, |
| 1063 | {USB_DEVICE(0x055f, 0xc420), BS(SPCA504, 0)}, |
| 1064 | {USB_DEVICE(0x055f, 0xc430), BS(SPCA533, 0)}, |
| 1065 | {USB_DEVICE(0x055f, 0xc440), BS(SPCA533, 0)}, |
| 1066 | {USB_DEVICE(0x055f, 0xc520), BS(SPCA504, 0)}, |
| 1067 | {USB_DEVICE(0x055f, 0xc530), BS(SPCA533, 0)}, |
| 1068 | {USB_DEVICE(0x055f, 0xc540), BS(SPCA533, 0)}, |
| 1069 | {USB_DEVICE(0x055f, 0xc630), BS(SPCA533, 0)}, |
| 1070 | {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)}, |
| 1071 | {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)}, |
| 1072 | {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)}, |
| 1073 | {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)}, |
| 1074 | {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)}, |
| 1075 | {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)}, |
| 1076 | {USB_DEVICE(0x0733, 0x2221), BS(SPCA533, 0)}, |
| 1077 | {USB_DEVICE(0x0733, 0x3261), BS(SPCA536, 0)}, |
| 1078 | {USB_DEVICE(0x0733, 0x3281), BS(SPCA536, 0)}, |
| 1079 | {USB_DEVICE(0x08ca, 0x0104), BS(SPCA533, 0)}, |
| 1080 | {USB_DEVICE(0x08ca, 0x0106), BS(SPCA533, 0)}, |
| 1081 | {USB_DEVICE(0x08ca, 0x2008), BS(SPCA504B, 0)}, |
| 1082 | {USB_DEVICE(0x08ca, 0x2010), BS(SPCA533, 0)}, |
| 1083 | {USB_DEVICE(0x08ca, 0x2016), BS(SPCA504B, 0)}, |
| 1084 | {USB_DEVICE(0x08ca, 0x2018), BS(SPCA504B, 0)}, |
| 1085 | {USB_DEVICE(0x08ca, 0x2020), BS(SPCA533, 0)}, |
| 1086 | {USB_DEVICE(0x08ca, 0x2022), BS(SPCA533, 0)}, |
| 1087 | {USB_DEVICE(0x08ca, 0x2024), BS(SPCA536, 0)}, |
| 1088 | {USB_DEVICE(0x08ca, 0x2028), BS(SPCA533, 0)}, |
| 1089 | {USB_DEVICE(0x08ca, 0x2040), BS(SPCA536, 0)}, |
| 1090 | {USB_DEVICE(0x08ca, 0x2042), BS(SPCA536, 0)}, |
| 1091 | {USB_DEVICE(0x08ca, 0x2050), BS(SPCA536, 0)}, |
| 1092 | {USB_DEVICE(0x08ca, 0x2060), BS(SPCA536, 0)}, |
| 1093 | {USB_DEVICE(0x0d64, 0x0303), BS(SPCA536, 0)}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1094 | {} |
| 1095 | }; |
| 1096 | MODULE_DEVICE_TABLE(usb, device_table); |
| 1097 | |
| 1098 | /* -- device connect -- */ |
| 1099 | static int sd_probe(struct usb_interface *intf, |
| 1100 | const struct usb_device_id *id) |
| 1101 | { |
| 1102 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
| 1103 | THIS_MODULE); |
| 1104 | } |
| 1105 | |
| 1106 | static struct usb_driver sd_driver = { |
| 1107 | .name = MODULE_NAME, |
| 1108 | .id_table = device_table, |
| 1109 | .probe = sd_probe, |
| 1110 | .disconnect = gspca_disconnect, |
Jean-Francois Moine | 6a70974 | 2008-09-03 16:48:10 -0300 | [diff] [blame] | 1111 | #ifdef CONFIG_PM |
| 1112 | .suspend = gspca_suspend, |
| 1113 | .resume = gspca_resume, |
| 1114 | #endif |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1115 | }; |
| 1116 | |
Greg Kroah-Hartman | ecb3b2b | 2011-11-18 09:46:12 -0800 | [diff] [blame] | 1117 | module_usb_driver(sd_driver); |