21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #define MODULE_NAME "spca1528"
28 MODULE_AUTHOR(
"Jean-Francois Moine <http://moinejf.free.fr>");
51 .sizeimage = 320 * 240 * 4 / 8 + 590,
56 .sizeimage = 640 * 480 * 3 / 8 + 590,
68 #error "USB buffer too small"
70 struct usb_device *
dev = gspca_dev->
dev;
82 PDEBUG(D_USBI,
"GET %02x 0000 %04x %02x", req, index,
85 pr_err(
"reg_r err %d\n", ret);
90 static void reg_w(
struct gspca_dev *gspca_dev,
95 struct usb_device *dev = gspca_dev->
dev;
100 PDEBUG(D_USBO,
"SET %02x %04x %04x", req, value, index);
107 pr_err(
"reg_w err %d\n", ret);
112 static void reg_wb(
struct gspca_dev *gspca_dev,
118 struct usb_device *dev = gspca_dev->
dev;
123 PDEBUG(D_USBO,
"SET %02x %04x %04x %02x", req, value, index, byte);
131 pr_err(
"reg_w err %d\n", ret);
136 static void wait_status_0(
struct gspca_dev *gspca_dev)
143 reg_r(gspca_dev, 0x21, 0x0000, 1);
144 if (gspca_dev->
usb_buf[0] == 0)
153 static void wait_status_1(
struct gspca_dev *gspca_dev)
159 reg_r(gspca_dev, 0x21, 0x0001, 1);
161 if (gspca_dev->
usb_buf[0] == 1) {
162 reg_wb(gspca_dev, 0x21, 0x0000, 0x0001, 0x00);
163 reg_r(gspca_dev, 0x21, 0x0001, 1);
171 static void setbrightness(
struct gspca_dev *gspca_dev,
s32 val)
173 reg_wb(gspca_dev, 0xc0, 0x0000, 0x00c0, val);
176 static void setcontrast(
struct gspca_dev *gspca_dev,
s32 val)
178 reg_wb(gspca_dev, 0xc1, 0x0000, 0x00c1, val);
181 static void sethue(
struct gspca_dev *gspca_dev,
s32 val)
183 reg_wb(gspca_dev, 0xc2, 0x0000, 0x0000, val);
186 static void setcolor(
struct gspca_dev *gspca_dev,
s32 val)
188 reg_wb(gspca_dev, 0xc3, 0x0000, 0x00c3, val);
191 static void setsharpness(
struct gspca_dev *gspca_dev,
s32 val)
193 reg_wb(gspca_dev, 0xc4, 0x0000, 0x00c4, val);
197 static int sd_config(
struct gspca_dev *gspca_dev,
200 gspca_dev->
cam.cam_mode = vga_mode;
202 gspca_dev->
cam.npkt = 128;
209 static int sd_init(
struct gspca_dev *gspca_dev)
211 reg_w(gspca_dev, 0x00, 0x0001, 0x2067);
212 reg_w(gspca_dev, 0x00, 0x00d0, 0x206b);
213 reg_w(gspca_dev, 0x00, 0x0000, 0x206c);
214 reg_w(gspca_dev, 0x00, 0x0001, 0x2069);
216 reg_w(gspca_dev, 0x00, 0x00c0, 0x206b);
217 reg_w(gspca_dev, 0x00, 0x0000, 0x206c);
218 reg_w(gspca_dev, 0x00, 0x0001, 0x2069);
220 reg_r(gspca_dev, 0x20, 0x0000, 1);
221 reg_r(gspca_dev, 0x20, 0x0000, 5);
222 reg_r(gspca_dev, 0x23, 0x0000, 64);
225 reg_r(gspca_dev, 0x23, 0x0001, 64);
230 static int sd_isoc_init(
struct gspca_dev *gspca_dev)
234 reg_r(gspca_dev, 0x00, 0x2520, 1);
235 wait_status_0(gspca_dev);
236 reg_w(gspca_dev, 0xc5, 0x0003, 0x0000);
237 wait_status_1(gspca_dev);
239 wait_status_0(gspca_dev);
240 mode = gspca_dev->
cam.cam_mode[gspca_dev->
curr_mode].priv;
241 reg_wb(gspca_dev, 0x25, 0x0000, 0x0004, mode);
242 reg_r(gspca_dev, 0x25, 0x0004, 1);
243 reg_wb(gspca_dev, 0x27, 0x0000, 0x0000, 0x06);
244 reg_r(gspca_dev, 0x27, 0x0000, 1);
253 static int sd_start(
struct gspca_dev *gspca_dev)
255 struct sd *
sd = (
struct sd *) gspca_dev;
264 reg_r(gspca_dev, 0x00, 0x2520, 1);
268 wait_status_0(gspca_dev);
269 reg_w(gspca_dev, 0x31, 0x0000, 0x0004);
270 wait_status_1(gspca_dev);
271 wait_status_0(gspca_dev);
278 static void sd_stopN(
struct gspca_dev *gspca_dev)
281 wait_status_0(gspca_dev);
282 reg_w(gspca_dev, 0x31, 0x0000, 0x0000);
283 wait_status_1(gspca_dev);
284 wait_status_0(gspca_dev);
288 static void add_packet(
struct gspca_dev *gspca_dev,
296 if (data[i] == 0xff) {
308 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
312 struct sd *
sd = (
struct sd *) gspca_dev;
313 static const u8 ffd9[] = {0xff, 0xd9};
324 if (data[1] & 0x02) {
326 add_packet(gspca_dev, data + 2, len - 2);
331 if ((data[1] & 1) != sd->
pkt_seq)
336 add_packet(gspca_dev, data + 2, len - 2);
345 struct gspca_dev *gspca_dev =
355 setbrightness(gspca_dev, ctrl->
val);
358 setcontrast(gspca_dev, ctrl->
val);
361 sethue(gspca_dev, ctrl->
val);
364 setcolor(gspca_dev, ctrl->
val);
367 setsharpness(gspca_dev, ctrl->
val);
377 static int sd_init_controls(
struct gspca_dev *gspca_dev)
381 gspca_dev->
vdev.ctrl_handler = hdl;
395 pr_err(
"Could not initialize controls\n");
406 .init_controls = sd_init_controls,
407 .isoc_init = sd_isoc_init,
410 .pkt_scan = sd_pkt_scan,
415 {USB_DEVICE(0x04fc, 0x1528)},
425 if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
432 static struct usb_driver sd_driver = {
434 .id_table = device_table,
438 .suspend = gspca_suspend,
439 .resume = gspca_resume,
440 .reset_resume = gspca_resume,