This source file includes following definitions.
- usbtv_set_regs
- usbtv_probe
- usbtv_disconnect
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 #include "usbtv.h"
46
47 int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
48 {
49 int ret;
50 int pipe = usb_rcvctrlpipe(usbtv->udev, 0);
51 int i;
52
53 for (i = 0; i < size; i++) {
54 u16 index = regs[i][0];
55 u16 value = regs[i][1];
56
57 ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
58 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
59 value, index, NULL, 0, USB_CTRL_GET_TIMEOUT);
60 if (ret < 0)
61 return ret;
62 }
63
64 return 0;
65 }
66
67 static int usbtv_probe(struct usb_interface *intf,
68 const struct usb_device_id *id)
69 {
70 int ret;
71 int size;
72 struct device *dev = &intf->dev;
73 struct usbtv *usbtv;
74 struct usb_host_endpoint *ep;
75
76
77 if (intf->num_altsetting != 2)
78 return -ENODEV;
79 if (intf->altsetting[1].desc.bNumEndpoints != 4)
80 return -ENODEV;
81
82 ep = &intf->altsetting[1].endpoint[0];
83
84
85
86 size = usb_endpoint_maxp(&ep->desc);
87 size = size * usb_endpoint_maxp_mult(&ep->desc);
88
89
90 usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);
91 if (usbtv == NULL)
92 return -ENOMEM;
93 usbtv->dev = dev;
94 usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
95
96 usbtv->iso_size = size;
97
98 usb_set_intfdata(intf, usbtv);
99
100 ret = usbtv_video_init(usbtv);
101 if (ret < 0)
102 goto usbtv_video_fail;
103
104 ret = usbtv_audio_init(usbtv);
105 if (ret < 0)
106 goto usbtv_audio_fail;
107
108
109 v4l2_device_get(&usbtv->v4l2_dev);
110
111 dev_info(dev, "Fushicai USBTV007 Audio-Video Grabber\n");
112 return 0;
113
114 usbtv_audio_fail:
115
116 usb_get_dev(usbtv->udev);
117 usbtv_video_free(usbtv);
118
119 usbtv_video_fail:
120 usb_set_intfdata(intf, NULL);
121 usb_put_dev(usbtv->udev);
122 kfree(usbtv);
123
124 return ret;
125 }
126
127 static void usbtv_disconnect(struct usb_interface *intf)
128 {
129 struct usbtv *usbtv = usb_get_intfdata(intf);
130
131 usb_set_intfdata(intf, NULL);
132
133 if (!usbtv)
134 return;
135
136 usbtv_audio_free(usbtv);
137 usbtv_video_free(usbtv);
138
139 usb_put_dev(usbtv->udev);
140 usbtv->udev = NULL;
141
142
143
144 v4l2_device_put(&usbtv->v4l2_dev);
145 }
146
147 static const struct usb_device_id usbtv_id_table[] = {
148 { USB_DEVICE(0x1b71, 0x3002) },
149 { USB_DEVICE(0x1f71, 0x3301) },
150 { USB_DEVICE(0x1f71, 0x3306) },
151 {}
152 };
153 MODULE_DEVICE_TABLE(usb, usbtv_id_table);
154
155 MODULE_AUTHOR("Lubomir Rintel, Federico Simoncelli");
156 MODULE_DESCRIPTION("Fushicai USBTV007 Audio-Video Grabber Driver");
157 MODULE_LICENSE("Dual BSD/GPL");
158
159 static struct usb_driver usbtv_usb_driver = {
160 .name = "usbtv",
161 .id_table = usbtv_id_table,
162 .probe = usbtv_probe,
163 .disconnect = usbtv_disconnect,
164 };
165
166 module_usb_driver(usbtv_usb_driver);