14 #include <linux/kernel.h>
15 #include <linux/errno.h>
17 #include <linux/slab.h>
18 #include <linux/module.h>
23 #include <linux/i2c.h>
25 #include <linux/videodev2.h>
45 "1=S-Video / 2=Composite");
50 "1=RCA front / 2=S/PDIF");
52 static bool boost_audio;
79 static void challenge(
u8 *
bytes)
84 for (idx = 0; idx < 32; ++
idx) {
87 bytes[(idx >> 3) + 3] = bytes[(idx >> 2) & 0x3];
91 bytes[2] += bytes[3] * 4 + bytes[4] + bytes[5];
92 bytes[4] += bytes[(idx & 0x1) * 2] * 9 + 9;
96 bytes[0] += 7*idx + 4;
97 bytes[6] += bytes[3] * 3;
100 bytes[3 - (idx >> 3)] = bytes[idx >> 2];
101 bytes[5] += bytes[6] * 3;
102 for (i = 0; i < 3; i++)
103 bytes[3] *= bytes[3] + 1;
106 for (i = 0; i < 3; i++)
107 bytes[1] *= bytes[6] + 1;
108 for (i = 0; i < 3; i++) {
111 tmp64 <<= bytes[7] & 0x0f;
128 char *print_buf = kzalloc(5*buf_size+1,
GFP_KERNEL);
137 usb_rcvctrlpipe(dev->
udev, 0),
138 rcv_request, 0x80 | request_type,
144 "unexpected answer of status request, len %d\n", ret);
152 "Status request returned, len %d: %s\n",
163 dev->
options.brightness = 0x80;
166 dev->
options.saturation = 0x40;
203 usb_sndctrlpipe(dev->
udev, 0),
204 0xd1, 0x00 | request_type,
209 "magic request returned %d\n", ret);
223 if (device_authorization(dev))
232 buf[0] = 0x03; buf[1] = 0x03; buf[2] = 0x00; buf[3] = 0x00;
234 usb_sndctrlpipe(dev->
udev, 0),
240 "control request returned %d\n", ret);
246 "no valid video signal or device init failed\n");
254 usb_sndctrlpipe(dev->
udev, 0),
255 0xd4, 0x38, 0, 0, buf, 1,
258 "control request returned %d\n", ret);
261 buf[0] = boost_audio;
263 usb_sndctrlpipe(dev->
udev, 0),
264 0xd5, 0x38, 0, 0, buf, 1,
267 "control request returned %d\n", ret);
296 struct usb_host_interface *iface_desc;
306 dev_err(&interface->dev,
"Out of memory\n");
314 dev_err(&interface->dev,
"v4l2_device_register failed\n");
338 dev->
options = hdpvr_default_options;
341 dev->
options.video_input = default_video_input;
344 dev->
options.audio_input = default_audio_input;
354 iface_desc = interface->cur_altsetting;
355 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++
i) {
356 endpoint = &iface_desc->endpoint[
i].desc;
359 usb_endpoint_is_bulk_in(endpoint)) {
374 if (hdpvr_device_init(dev)) {
383 "allocating transfer buffers failed\n");
394 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
420 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
434 static void hdpvr_disconnect(
struct usb_interface *interface)
436 struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface));
452 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
460 static struct usb_driver hdpvr_usb_driver = {
462 .probe = hdpvr_probe,
463 .disconnect = hdpvr_disconnect,
464 .id_table = hdpvr_table,