diff options
Diffstat (limited to 'drivers/media/usb')
86 files changed, 2820 insertions, 2499 deletions
diff --git a/drivers/media/usb/Kconfig b/drivers/media/usb/Kconfig index 6746994d03fe..0a7d520636a9 100644 --- a/drivers/media/usb/Kconfig +++ b/drivers/media/usb/Kconfig | |||
@@ -21,7 +21,6 @@ endif | |||
21 | 21 | ||
22 | if MEDIA_ANALOG_TV_SUPPORT | 22 | if MEDIA_ANALOG_TV_SUPPORT |
23 | comment "Analog TV USB devices" | 23 | comment "Analog TV USB devices" |
24 | source "drivers/media/usb/au0828/Kconfig" | ||
25 | source "drivers/media/usb/pvrusb2/Kconfig" | 24 | source "drivers/media/usb/pvrusb2/Kconfig" |
26 | source "drivers/media/usb/hdpvr/Kconfig" | 25 | source "drivers/media/usb/hdpvr/Kconfig" |
27 | source "drivers/media/usb/tlg2300/Kconfig" | 26 | source "drivers/media/usb/tlg2300/Kconfig" |
@@ -31,6 +30,7 @@ endif | |||
31 | 30 | ||
32 | if (MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT) | 31 | if (MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT) |
33 | comment "Analog/digital TV USB devices" | 32 | comment "Analog/digital TV USB devices" |
33 | source "drivers/media/usb/au0828/Kconfig" | ||
34 | source "drivers/media/usb/cx231xx/Kconfig" | 34 | source "drivers/media/usb/cx231xx/Kconfig" |
35 | source "drivers/media/usb/tm6000/Kconfig" | 35 | source "drivers/media/usb/tm6000/Kconfig" |
36 | endif | 36 | endif |
diff --git a/drivers/media/usb/au0828/Kconfig b/drivers/media/usb/au0828/Kconfig index 1766c0ce93be..953a37c613b1 100644 --- a/drivers/media/usb/au0828/Kconfig +++ b/drivers/media/usb/au0828/Kconfig | |||
@@ -1,17 +1,28 @@ | |||
1 | 1 | ||
2 | config VIDEO_AU0828 | 2 | config VIDEO_AU0828 |
3 | tristate "Auvitek AU0828 support" | 3 | tristate "Auvitek AU0828 support" |
4 | depends on I2C && INPUT && DVB_CORE && USB && VIDEO_V4L2 | 4 | depends on I2C && INPUT && DVB_CORE && USB |
5 | select I2C_ALGOBIT | 5 | select I2C_ALGOBIT |
6 | select VIDEO_TVEEPROM | 6 | select VIDEO_TVEEPROM |
7 | select VIDEOBUF_VMALLOC | 7 | select VIDEOBUF_VMALLOC |
8 | select DVB_AU8522_DTV if MEDIA_SUBDRV_AUTOSELECT | 8 | select DVB_AU8522_DTV if MEDIA_SUBDRV_AUTOSELECT |
9 | select DVB_AU8522_V4L if MEDIA_SUBDRV_AUTOSELECT | ||
10 | select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT | 9 | select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT |
11 | select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT | 10 | select MEDIA_TUNER_MXL5007T if MEDIA_SUBDRV_AUTOSELECT |
12 | select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT | 11 | select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT |
13 | ---help--- | 12 | ---help--- |
14 | This is a video4linux driver for Auvitek's USB device. | 13 | This is a hybrid analog/digital tv capture driver for |
14 | Auvitek's AU0828 USB device. | ||
15 | 15 | ||
16 | To compile this driver as a module, choose M here: the | 16 | To compile this driver as a module, choose M here: the |
17 | module will be called au0828 | 17 | module will be called au0828 |
18 | |||
19 | config VIDEO_AU0828_V4L2 | ||
20 | bool "Auvitek AU0828 v4l2 analog video support" | ||
21 | depends on VIDEO_AU0828 && VIDEO_V4L2 | ||
22 | select DVB_AU8522_V4L if MEDIA_SUBDRV_AUTOSELECT | ||
23 | default y | ||
24 | ---help--- | ||
25 | This is a video4linux driver for Auvitek's USB device. | ||
26 | |||
27 | Choose Y here to include support for v4l2 analog video | ||
28 | capture within the au0828 driver. | ||
diff --git a/drivers/media/usb/au0828/Makefile b/drivers/media/usb/au0828/Makefile index 98cc20cc0ffb..be3bdf698022 100644 --- a/drivers/media/usb/au0828/Makefile +++ b/drivers/media/usb/au0828/Makefile | |||
@@ -1,4 +1,8 @@ | |||
1 | au0828-objs := au0828-core.o au0828-i2c.o au0828-cards.o au0828-dvb.o au0828-video.o au0828-vbi.o | 1 | au0828-objs := au0828-core.o au0828-i2c.o au0828-cards.o au0828-dvb.o |
2 | |||
3 | ifeq ($(CONFIG_VIDEO_AU0828_V4L2),y) | ||
4 | au0828-objs += au0828-video.o au0828-vbi.o | ||
5 | endif | ||
2 | 6 | ||
3 | obj-$(CONFIG_VIDEO_AU0828) += au0828.o | 7 | obj-$(CONFIG_VIDEO_AU0828) += au0828.o |
4 | 8 | ||
diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c index 0cb7c28dcb17..dd32decb237d 100644 --- a/drivers/media/usb/au0828/au0828-cards.c +++ b/drivers/media/usb/au0828/au0828-cards.c | |||
@@ -169,7 +169,9 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) | |||
169 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ | 169 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ |
170 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ | 170 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ |
171 | case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */ | 171 | case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and analog video */ |
172 | case 72261: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and analog video */ | 172 | case 72261: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ |
173 | case 72271: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ | ||
174 | case 72281: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and analog video */ | ||
173 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */ | 175 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and analog video */ |
174 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ | 176 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ |
175 | break; | 177 | break; |
@@ -183,16 +185,15 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) | |||
183 | __func__, tv.model); | 185 | __func__, tv.model); |
184 | } | 186 | } |
185 | 187 | ||
188 | void au0828_card_analog_fe_setup(struct au0828_dev *dev); | ||
189 | |||
186 | void au0828_card_setup(struct au0828_dev *dev) | 190 | void au0828_card_setup(struct au0828_dev *dev) |
187 | { | 191 | { |
188 | static u8 eeprom[256]; | 192 | static u8 eeprom[256]; |
189 | struct tuner_setup tun_setup; | ||
190 | struct v4l2_subdev *sd; | ||
191 | unsigned int mode_mask = T_ANALOG_TV; | ||
192 | 193 | ||
193 | dprintk(1, "%s()\n", __func__); | 194 | dprintk(1, "%s()\n", __func__); |
194 | 195 | ||
195 | memcpy(&dev->board, &au0828_boards[dev->boardnr], sizeof(dev->board)); | 196 | dev->board = au0828_boards[dev->boardnr]; |
196 | 197 | ||
197 | if (dev->i2c_rc == 0) { | 198 | if (dev->i2c_rc == 0) { |
198 | dev->i2c_client.addr = 0xa0 >> 1; | 199 | dev->i2c_client.addr = 0xa0 >> 1; |
@@ -209,6 +210,16 @@ void au0828_card_setup(struct au0828_dev *dev) | |||
209 | break; | 210 | break; |
210 | } | 211 | } |
211 | 212 | ||
213 | au0828_card_analog_fe_setup(dev); | ||
214 | } | ||
215 | |||
216 | void au0828_card_analog_fe_setup(struct au0828_dev *dev) | ||
217 | { | ||
218 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
219 | struct tuner_setup tun_setup; | ||
220 | struct v4l2_subdev *sd; | ||
221 | unsigned int mode_mask = T_ANALOG_TV; | ||
222 | |||
212 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) { | 223 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) { |
213 | /* Load the analog demodulator driver (note this would need to | 224 | /* Load the analog demodulator driver (note this would need to |
214 | be abstracted out if we ever need to support a different | 225 | be abstracted out if we ever need to support a different |
@@ -234,6 +245,7 @@ void au0828_card_setup(struct au0828_dev *dev) | |||
234 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, | 245 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, |
235 | &tun_setup); | 246 | &tun_setup); |
236 | } | 247 | } |
248 | #endif | ||
237 | } | 249 | } |
238 | 250 | ||
239 | /* | 251 | /* |
@@ -333,6 +345,8 @@ struct usb_device_id au0828_usb_id_table[] = { | |||
333 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 345 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
334 | { USB_DEVICE(0x2040, 0x7213), | 346 | { USB_DEVICE(0x2040, 0x7213), |
335 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 347 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
348 | { USB_DEVICE(0x2040, 0x7270), | ||
349 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
336 | { }, | 350 | { }, |
337 | }; | 351 | }; |
338 | 352 | ||
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 745a80a798c8..1e6f40ef1c6b 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c | |||
@@ -134,13 +134,17 @@ static void au0828_usb_disconnect(struct usb_interface *interface) | |||
134 | /* Digital TV */ | 134 | /* Digital TV */ |
135 | au0828_dvb_unregister(dev); | 135 | au0828_dvb_unregister(dev); |
136 | 136 | ||
137 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
137 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) | 138 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) |
138 | au0828_analog_unregister(dev); | 139 | au0828_analog_unregister(dev); |
140 | #endif | ||
139 | 141 | ||
140 | /* I2C */ | 142 | /* I2C */ |
141 | au0828_i2c_unregister(dev); | 143 | au0828_i2c_unregister(dev); |
142 | 144 | ||
145 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
143 | v4l2_device_unregister(&dev->v4l2_dev); | 146 | v4l2_device_unregister(&dev->v4l2_dev); |
147 | #endif | ||
144 | 148 | ||
145 | usb_set_intfdata(interface, NULL); | 149 | usb_set_intfdata(interface, NULL); |
146 | 150 | ||
@@ -155,7 +159,10 @@ static void au0828_usb_disconnect(struct usb_interface *interface) | |||
155 | static int au0828_usb_probe(struct usb_interface *interface, | 159 | static int au0828_usb_probe(struct usb_interface *interface, |
156 | const struct usb_device_id *id) | 160 | const struct usb_device_id *id) |
157 | { | 161 | { |
158 | int ifnum, retval; | 162 | int ifnum; |
163 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
164 | int retval; | ||
165 | #endif | ||
159 | struct au0828_dev *dev; | 166 | struct au0828_dev *dev; |
160 | struct usb_device *usbdev = interface_to_usbdev(interface); | 167 | struct usb_device *usbdev = interface_to_usbdev(interface); |
161 | 168 | ||
@@ -194,6 +201,7 @@ static int au0828_usb_probe(struct usb_interface *interface, | |||
194 | dev->usbdev = usbdev; | 201 | dev->usbdev = usbdev; |
195 | dev->boardnr = id->driver_info; | 202 | dev->boardnr = id->driver_info; |
196 | 203 | ||
204 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
197 | /* Create the v4l2_device */ | 205 | /* Create the v4l2_device */ |
198 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | 206 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
199 | if (retval) { | 207 | if (retval) { |
@@ -203,6 +211,7 @@ static int au0828_usb_probe(struct usb_interface *interface, | |||
203 | kfree(dev); | 211 | kfree(dev); |
204 | return -EIO; | 212 | return -EIO; |
205 | } | 213 | } |
214 | #endif | ||
206 | 215 | ||
207 | /* Power Up the bridge */ | 216 | /* Power Up the bridge */ |
208 | au0828_write(dev, REG_600, 1 << 4); | 217 | au0828_write(dev, REG_600, 1 << 4); |
@@ -216,9 +225,11 @@ static int au0828_usb_probe(struct usb_interface *interface, | |||
216 | /* Setup */ | 225 | /* Setup */ |
217 | au0828_card_setup(dev); | 226 | au0828_card_setup(dev); |
218 | 227 | ||
228 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
219 | /* Analog TV */ | 229 | /* Analog TV */ |
220 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) | 230 | if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) |
221 | au0828_analog_register(dev, interface); | 231 | au0828_analog_register(dev, interface); |
232 | #endif | ||
222 | 233 | ||
223 | /* Digital TV */ | 234 | /* Digital TV */ |
224 | au0828_dvb_register(dev); | 235 | au0828_dvb_register(dev); |
diff --git a/drivers/media/usb/au0828/au0828-i2c.c b/drivers/media/usb/au0828/au0828-i2c.c index 4ded17fe1957..17ec3651b10e 100644 --- a/drivers/media/usb/au0828/au0828-i2c.c +++ b/drivers/media/usb/au0828/au0828-i2c.c | |||
@@ -364,12 +364,9 @@ int au0828_i2c_register(struct au0828_dev *dev) | |||
364 | { | 364 | { |
365 | dprintk(1, "%s()\n", __func__); | 365 | dprintk(1, "%s()\n", __func__); |
366 | 366 | ||
367 | memcpy(&dev->i2c_adap, &au0828_i2c_adap_template, | 367 | dev->i2c_adap = au0828_i2c_adap_template; |
368 | sizeof(dev->i2c_adap)); | 368 | dev->i2c_algo = au0828_i2c_algo_template; |
369 | memcpy(&dev->i2c_algo, &au0828_i2c_algo_template, | 369 | dev->i2c_client = au0828_i2c_client_template; |
370 | sizeof(dev->i2c_algo)); | ||
371 | memcpy(&dev->i2c_client, &au0828_i2c_client_template, | ||
372 | sizeof(dev->i2c_client)); | ||
373 | 370 | ||
374 | dev->i2c_adap.dev.parent = &dev->usbdev->dev; | 371 | dev->i2c_adap.dev.parent = &dev->usbdev->dev; |
375 | 372 | ||
@@ -378,7 +375,11 @@ int au0828_i2c_register(struct au0828_dev *dev) | |||
378 | 375 | ||
379 | dev->i2c_adap.algo = &dev->i2c_algo; | 376 | dev->i2c_adap.algo = &dev->i2c_algo; |
380 | dev->i2c_adap.algo_data = dev; | 377 | dev->i2c_adap.algo_data = dev; |
378 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
381 | i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); | 379 | i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); |
380 | #else | ||
381 | i2c_set_adapdata(&dev->i2c_adap, dev); | ||
382 | #endif | ||
382 | i2c_add_adapter(&dev->i2c_adap); | 383 | i2c_add_adapter(&dev->i2c_adap); |
383 | 384 | ||
384 | dev->i2c_client.adapter = &dev->i2c_adap; | 385 | dev->i2c_client.adapter = &dev->i2c_adap; |
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 45387aab10c7..8b9e8268e911 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c | |||
@@ -304,7 +304,7 @@ static inline void buffer_filled(struct au0828_dev *dev, | |||
304 | 304 | ||
305 | buf->vb.state = VIDEOBUF_DONE; | 305 | buf->vb.state = VIDEOBUF_DONE; |
306 | buf->vb.field_count++; | 306 | buf->vb.field_count++; |
307 | do_gettimeofday(&buf->vb.ts); | 307 | v4l2_get_timestamp(&buf->vb.ts); |
308 | 308 | ||
309 | dev->isoc_ctl.buf = NULL; | 309 | dev->isoc_ctl.buf = NULL; |
310 | 310 | ||
@@ -321,7 +321,7 @@ static inline void vbi_buffer_filled(struct au0828_dev *dev, | |||
321 | 321 | ||
322 | buf->vb.state = VIDEOBUF_DONE; | 322 | buf->vb.state = VIDEOBUF_DONE; |
323 | buf->vb.field_count++; | 323 | buf->vb.field_count++; |
324 | do_gettimeofday(&buf->vb.ts); | 324 | v4l2_get_timestamp(&buf->vb.ts); |
325 | 325 | ||
326 | dev->isoc_ctl.vbi_buf = NULL; | 326 | dev->isoc_ctl.vbi_buf = NULL; |
327 | 327 | ||
diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index 66a56ef7bbe4..e579ff69ca4a 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h | |||
@@ -199,8 +199,10 @@ struct au0828_dev { | |||
199 | struct au0828_dvb dvb; | 199 | struct au0828_dvb dvb; |
200 | struct work_struct restart_streaming; | 200 | struct work_struct restart_streaming; |
201 | 201 | ||
202 | #ifdef CONFIG_VIDEO_AU0828_V4L2 | ||
202 | /* Analog */ | 203 | /* Analog */ |
203 | struct v4l2_device v4l2_dev; | 204 | struct v4l2_device v4l2_dev; |
205 | #endif | ||
204 | int users; | 206 | int users; |
205 | unsigned int resources; /* resources in use */ | 207 | unsigned int resources; /* resources in use */ |
206 | struct video_device *vdev; | 208 | struct video_device *vdev; |
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c index 95b5d6e7cdc4..be1719283609 100644 --- a/drivers/media/usb/cpia2/cpia2_usb.c +++ b/drivers/media/usb/cpia2/cpia2_usb.c | |||
@@ -328,7 +328,7 @@ static void cpia2_usb_complete(struct urb *urb) | |||
328 | continue; | 328 | continue; |
329 | } | 329 | } |
330 | DBG("Start of frame pattern found\n"); | 330 | DBG("Start of frame pattern found\n"); |
331 | do_gettimeofday(&cam->workbuff->timestamp); | 331 | v4l2_get_timestamp(&cam->workbuff->timestamp); |
332 | cam->workbuff->seq = cam->frame_count++; | 332 | cam->workbuff->seq = cam->frame_count++; |
333 | cam->workbuff->data[0] = 0xFF; | 333 | cam->workbuff->data[0] = 0xFF; |
334 | cam->workbuff->data[1] = 0xD8; | 334 | cam->workbuff->data[1] = 0xD8; |
diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c index aeb9d2275725..d5d42b6e94be 100644 --- a/drivers/media/usb/cpia2/cpia2_v4l.c +++ b/drivers/media/usb/cpia2/cpia2_v4l.c | |||
@@ -825,6 +825,8 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) | |||
825 | else | 825 | else |
826 | buf->flags = 0; | 826 | buf->flags = 0; |
827 | 827 | ||
828 | buf->flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
829 | |||
828 | switch (cam->buffers[buf->index].status) { | 830 | switch (cam->buffers[buf->index].status) { |
829 | case FRAME_EMPTY: | 831 | case FRAME_EMPTY: |
830 | case FRAME_ERROR: | 832 | case FRAME_ERROR: |
@@ -943,7 +945,8 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | |||
943 | 945 | ||
944 | buf->index = frame; | 946 | buf->index = frame; |
945 | buf->bytesused = cam->buffers[buf->index].length; | 947 | buf->bytesused = cam->buffers[buf->index].length; |
946 | buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE; | 948 | buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE |
949 | | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
947 | buf->field = V4L2_FIELD_NONE; | 950 | buf->field = V4L2_FIELD_NONE; |
948 | buf->timestamp = cam->buffers[buf->index].timestamp; | 951 | buf->timestamp = cam->buffers[buf->index].timestamp; |
949 | buf->sequence = cam->buffers[buf->index].seq; | 952 | buf->sequence = cam->buffers[buf->index].seq; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c index b024e5197a75..28688dbcb609 100644 --- a/drivers/media/usb/cx231xx/cx231xx-417.c +++ b/drivers/media/usb/cx231xx/cx231xx-417.c | |||
@@ -1291,7 +1291,7 @@ static void buffer_copy(struct cx231xx *dev, char *data, int len, struct urb *ur | |||
1291 | 1291 | ||
1292 | buf->vb.state = VIDEOBUF_DONE; | 1292 | buf->vb.state = VIDEOBUF_DONE; |
1293 | buf->vb.field_count++; | 1293 | buf->vb.field_count++; |
1294 | do_gettimeofday(&buf->vb.ts); | 1294 | v4l2_get_timestamp(&buf->vb.ts); |
1295 | list_del(&buf->vb.queue); | 1295 | list_del(&buf->vb.queue); |
1296 | wake_up(&buf->vb.done); | 1296 | wake_up(&buf->vb.done); |
1297 | dma_q->mpeg_buffer_completed = 0; | 1297 | dma_q->mpeg_buffer_completed = 0; |
@@ -1327,7 +1327,7 @@ static void buffer_filled(char *data, int len, struct urb *urb, | |||
1327 | memcpy(vbuf, data, len); | 1327 | memcpy(vbuf, data, len); |
1328 | buf->vb.state = VIDEOBUF_DONE; | 1328 | buf->vb.state = VIDEOBUF_DONE; |
1329 | buf->vb.field_count++; | 1329 | buf->vb.field_count++; |
1330 | do_gettimeofday(&buf->vb.ts); | 1330 | v4l2_get_timestamp(&buf->vb.ts); |
1331 | list_del(&buf->vb.queue); | 1331 | list_del(&buf->vb.queue); |
1332 | wake_up(&buf->vb.done); | 1332 | wake_up(&buf->vb.done); |
1333 | 1333 | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index bbed1e40eeda..8d529565f163 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c | |||
@@ -603,6 +603,33 @@ struct cx231xx_board cx231xx_boards[] = { | |||
603 | .gpio = NULL, | 603 | .gpio = NULL, |
604 | } }, | 604 | } }, |
605 | }, | 605 | }, |
606 | [CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2] = { | ||
607 | .name = "Elgato Video Capture V2", | ||
608 | .tuner_type = TUNER_ABSENT, | ||
609 | .decoder = CX231XX_AVDECODER, | ||
610 | .output_mode = OUT_MODE_VIP11, | ||
611 | .demod_xfer_mode = 0, | ||
612 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
613 | .agc_analog_digital_select_gpio = 0x0c, | ||
614 | .gpio_pin_status_mask = 0x4001000, | ||
615 | .norm = V4L2_STD_NTSC, | ||
616 | .no_alt_vanc = 1, | ||
617 | .external_av = 1, | ||
618 | .dont_use_port_3 = 1, | ||
619 | .input = {{ | ||
620 | .type = CX231XX_VMUX_COMPOSITE1, | ||
621 | .vmux = CX231XX_VIN_2_1, | ||
622 | .amux = CX231XX_AMUX_LINE_IN, | ||
623 | .gpio = NULL, | ||
624 | }, { | ||
625 | .type = CX231XX_VMUX_SVIDEO, | ||
626 | .vmux = CX231XX_VIN_1_1 | | ||
627 | (CX231XX_VIN_1_2 << 8) | | ||
628 | CX25840_SVIDEO_ON, | ||
629 | .amux = CX231XX_AMUX_LINE_IN, | ||
630 | .gpio = NULL, | ||
631 | } }, | ||
632 | }, | ||
606 | }; | 633 | }; |
607 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); | 634 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); |
608 | 635 | ||
@@ -642,6 +669,8 @@ struct usb_device_id cx231xx_id_table[] = { | |||
642 | .driver_info = CX231XX_BOARD_KWORLD_UB430_USB_HYBRID}, | 669 | .driver_info = CX231XX_BOARD_KWORLD_UB430_USB_HYBRID}, |
643 | {USB_DEVICE(0x1f4d, 0x0237), | 670 | {USB_DEVICE(0x1f4d, 0x0237), |
644 | .driver_info = CX231XX_BOARD_ICONBIT_U100}, | 671 | .driver_info = CX231XX_BOARD_ICONBIT_U100}, |
672 | {USB_DEVICE(0x0fd9, 0x0037), | ||
673 | .driver_info = CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2}, | ||
645 | {}, | 674 | {}, |
646 | }; | 675 | }; |
647 | 676 | ||
@@ -707,7 +736,7 @@ static void cx231xx_sleep_s5h1432(struct cx231xx *dev) | |||
707 | 736 | ||
708 | static inline void cx231xx_set_model(struct cx231xx *dev) | 737 | static inline void cx231xx_set_model(struct cx231xx *dev) |
709 | { | 738 | { |
710 | memcpy(&dev->board, &cx231xx_boards[dev->model], sizeof(dev->board)); | 739 | dev->board = cx231xx_boards[dev->model]; |
711 | } | 740 | } |
712 | 741 | ||
713 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, | 742 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, |
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c index ac7db52f404f..46e3892557c2 100644 --- a/drivers/media/usb/cx231xx/cx231xx-vbi.c +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c | |||
@@ -530,7 +530,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev, | |||
530 | 530 | ||
531 | buf->vb.state = VIDEOBUF_DONE; | 531 | buf->vb.state = VIDEOBUF_DONE; |
532 | buf->vb.field_count++; | 532 | buf->vb.field_count++; |
533 | do_gettimeofday(&buf->vb.ts); | 533 | v4l2_get_timestamp(&buf->vb.ts); |
534 | 534 | ||
535 | dev->vbi_mode.bulk_ctl.buf = NULL; | 535 | dev->vbi_mode.bulk_ctl.buf = NULL; |
536 | 536 | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index fedf7852a355..06376d904c9f 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c | |||
@@ -235,7 +235,7 @@ static inline void buffer_filled(struct cx231xx *dev, | |||
235 | cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | 235 | cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); |
236 | buf->vb.state = VIDEOBUF_DONE; | 236 | buf->vb.state = VIDEOBUF_DONE; |
237 | buf->vb.field_count++; | 237 | buf->vb.field_count++; |
238 | do_gettimeofday(&buf->vb.ts); | 238 | v4l2_get_timestamp(&buf->vb.ts); |
239 | 239 | ||
240 | if (dev->USE_ISO) | 240 | if (dev->USE_ISO) |
241 | dev->video_mode.isoc_ctl.buf = NULL; | 241 | dev->video_mode.isoc_ctl.buf = NULL; |
@@ -1751,6 +1751,7 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1751 | 0x02, | 1751 | 0x02, |
1752 | (u16)reg->reg, 1, | 1752 | (u16)reg->reg, 1, |
1753 | value, 1, 2); | 1753 | value, 1, 2); |
1754 | break; | ||
1754 | case 0x322: | 1755 | case 0x322: |
1755 | ret = | 1756 | ret = |
1756 | cx231xx_write_i2c_master(dev, | 1757 | cx231xx_write_i2c_master(dev, |
@@ -2627,8 +2628,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) | |||
2627 | dev->name, video_device_node_name(dev->vdev)); | 2628 | dev->name, video_device_node_name(dev->vdev)); |
2628 | 2629 | ||
2629 | /* Initialize VBI template */ | 2630 | /* Initialize VBI template */ |
2630 | memcpy(&cx231xx_vbi_template, &cx231xx_video_template, | 2631 | cx231xx_vbi_template = cx231xx_video_template; |
2631 | sizeof(cx231xx_vbi_template)); | ||
2632 | strcpy(cx231xx_vbi_template.name, "cx231xx-vbi"); | 2632 | strcpy(cx231xx_vbi_template.name, "cx231xx-vbi"); |
2633 | 2633 | ||
2634 | /* Allocate and fill vbi video_device struct */ | 2634 | /* Allocate and fill vbi video_device struct */ |
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h index a89d020de948..3e11462be0d0 100644 --- a/drivers/media/usb/cx231xx/cx231xx.h +++ b/drivers/media/usb/cx231xx/cx231xx.h | |||
@@ -68,6 +68,7 @@ | |||
68 | #define CX231XX_BOARD_ICONBIT_U100 13 | 68 | #define CX231XX_BOARD_ICONBIT_U100 13 |
69 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL 14 | 69 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL 14 |
70 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC 15 | 70 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC 15 |
71 | #define CX231XX_BOARD_ELGATO_VIDEO_CAPTURE_V2 16 | ||
71 | 72 | ||
72 | /* Limits minimum and default number of buffers */ | 73 | /* Limits minimum and default number of buffers */ |
73 | #define CX231XX_MIN_BUF 4 | 74 | #define CX231XX_MIN_BUF 4 |
diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig b/drivers/media/usb/dvb-usb-v2/Kconfig index 7a622dbe9b6d..692224d97d06 100644 --- a/drivers/media/usb/dvb-usb-v2/Kconfig +++ b/drivers/media/usb/dvb-usb-v2/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config DVB_USB_V2 | 1 | config DVB_USB_V2 |
2 | tristate "Support for various USB DVB devices v2" | 2 | tristate "Support for various USB DVB devices v2" |
3 | depends on DVB_CORE && USB && I2C && RC_CORE | 3 | depends on DVB_CORE && USB && I2C |
4 | help | 4 | help |
5 | By enabling this you will be able to choose the various supported | 5 | By enabling this you will be able to choose the various supported |
6 | USB1.1 and USB2.0 DVB devices. | 6 | USB1.1 and USB2.0 DVB devices. |
@@ -113,6 +113,7 @@ config DVB_USB_IT913X | |||
113 | config DVB_USB_LME2510 | 113 | config DVB_USB_LME2510 |
114 | tristate "LME DM04/QQBOX DVB-S USB2.0 support" | 114 | tristate "LME DM04/QQBOX DVB-S USB2.0 support" |
115 | depends on DVB_USB_V2 | 115 | depends on DVB_USB_V2 |
116 | depends on RC_CORE | ||
116 | select DVB_TDA10086 if MEDIA_SUBDRV_AUTOSELECT | 117 | select DVB_TDA10086 if MEDIA_SUBDRV_AUTOSELECT |
117 | select DVB_TDA826X if MEDIA_SUBDRV_AUTOSELECT | 118 | select DVB_TDA826X if MEDIA_SUBDRV_AUTOSELECT |
118 | select DVB_STV0288 if MEDIA_SUBDRV_AUTOSELECT | 119 | select DVB_STV0288 if MEDIA_SUBDRV_AUTOSELECT |
@@ -120,6 +121,7 @@ config DVB_USB_LME2510 | |||
120 | select DVB_STV0299 if MEDIA_SUBDRV_AUTOSELECT | 121 | select DVB_STV0299 if MEDIA_SUBDRV_AUTOSELECT |
121 | select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT | 122 | select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT |
122 | select DVB_M88RS2000 if MEDIA_SUBDRV_AUTOSELECT | 123 | select DVB_M88RS2000 if MEDIA_SUBDRV_AUTOSELECT |
124 | select DVB_TS2020 if MEDIA_SUBDRV_AUTOSELECT | ||
123 | help | 125 | help |
124 | Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 | 126 | Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 |
125 | 127 | ||
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c index 943d93423705..b86d0f27a398 100644 --- a/drivers/media/usb/dvb-usb-v2/af9015.c +++ b/drivers/media/usb/dvb-usb-v2/af9015.c | |||
@@ -1156,6 +1156,7 @@ error: | |||
1156 | return ret; | 1156 | return ret; |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
1159 | struct af9015_rc_setup { | 1160 | struct af9015_rc_setup { |
1160 | unsigned int id; | 1161 | unsigned int id; |
1161 | char *rc_codes; | 1162 | char *rc_codes; |
@@ -1312,6 +1313,9 @@ static int af9015_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | |||
1312 | 1313 | ||
1313 | return 0; | 1314 | return 0; |
1314 | } | 1315 | } |
1316 | #else | ||
1317 | #define af9015_get_rc_config NULL | ||
1318 | #endif | ||
1315 | 1319 | ||
1316 | /* interface 0 is used by DVB-T receiver and | 1320 | /* interface 0 is used by DVB-T receiver and |
1317 | interface 1 is for remote controller (HID) */ | 1321 | interface 1 is for remote controller (HID) */ |
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 61ae7f9d0b27..f11cc42454f0 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c | |||
@@ -209,10 +209,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
209 | if (msg[0].len > 40 || msg[1].len > 40) { | 209 | if (msg[0].len > 40 || msg[1].len > 40) { |
210 | /* TODO: correct limits > 40 */ | 210 | /* TODO: correct limits > 40 */ |
211 | ret = -EOPNOTSUPP; | 211 | ret = -EOPNOTSUPP; |
212 | } else if (msg[0].addr == state->af9033_config[0].i2c_addr) { | 212 | } else if ((msg[0].addr == state->af9033_config[0].i2c_addr) || |
213 | /* integrated demod */ | 213 | (msg[0].addr == state->af9033_config[1].i2c_addr)) { |
214 | /* demod access via firmware interface */ | ||
214 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | | 215 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | |
215 | msg[0].buf[2]; | 216 | msg[0].buf[2]; |
217 | |||
218 | if (msg[0].addr == state->af9033_config[1].i2c_addr) | ||
219 | reg |= 0x100000; | ||
220 | |||
216 | ret = af9035_rd_regs(d, reg, &msg[1].buf[0], | 221 | ret = af9035_rd_regs(d, reg, &msg[1].buf[0], |
217 | msg[1].len); | 222 | msg[1].len); |
218 | } else { | 223 | } else { |
@@ -220,6 +225,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
220 | u8 buf[5 + msg[0].len]; | 225 | u8 buf[5 + msg[0].len]; |
221 | struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), | 226 | struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), |
222 | buf, msg[1].len, msg[1].buf }; | 227 | buf, msg[1].len, msg[1].buf }; |
228 | req.mbox |= ((msg[0].addr & 0x80) >> 3); | ||
223 | buf[0] = msg[1].len; | 229 | buf[0] = msg[1].len; |
224 | buf[1] = msg[0].addr << 1; | 230 | buf[1] = msg[0].addr << 1; |
225 | buf[2] = 0x00; /* reg addr len */ | 231 | buf[2] = 0x00; /* reg addr len */ |
@@ -232,10 +238,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
232 | if (msg[0].len > 40) { | 238 | if (msg[0].len > 40) { |
233 | /* TODO: correct limits > 40 */ | 239 | /* TODO: correct limits > 40 */ |
234 | ret = -EOPNOTSUPP; | 240 | ret = -EOPNOTSUPP; |
235 | } else if (msg[0].addr == state->af9033_config[0].i2c_addr) { | 241 | } else if ((msg[0].addr == state->af9033_config[0].i2c_addr) || |
236 | /* integrated demod */ | 242 | (msg[0].addr == state->af9033_config[1].i2c_addr)) { |
243 | /* demod access via firmware interface */ | ||
237 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | | 244 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | |
238 | msg[0].buf[2]; | 245 | msg[0].buf[2]; |
246 | |||
247 | if (msg[0].addr == state->af9033_config[1].i2c_addr) | ||
248 | reg |= 0x100000; | ||
249 | |||
239 | ret = af9035_wr_regs(d, reg, &msg[0].buf[3], | 250 | ret = af9035_wr_regs(d, reg, &msg[0].buf[3], |
240 | msg[0].len - 3); | 251 | msg[0].len - 3); |
241 | } else { | 252 | } else { |
@@ -243,6 +254,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
243 | u8 buf[5 + msg[0].len]; | 254 | u8 buf[5 + msg[0].len]; |
244 | struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, | 255 | struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, |
245 | 0, NULL }; | 256 | 0, NULL }; |
257 | req.mbox |= ((msg[0].addr & 0x80) >> 3); | ||
246 | buf[0] = msg[0].len; | 258 | buf[0] = msg[0].len; |
247 | buf[1] = msg[0].addr << 1; | 259 | buf[1] = msg[0].addr << 1; |
248 | buf[2] = 0x00; /* reg addr len */ | 260 | buf[2] = 0x00; /* reg addr len */ |
@@ -313,12 +325,57 @@ static int af9035_download_firmware(struct dvb_usb_device *d, | |||
313 | struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; | 325 | struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; |
314 | struct usb_req req_fw_dl = { CMD_FW_DL, 0, 0, wbuf, 0, NULL }; | 326 | struct usb_req req_fw_dl = { CMD_FW_DL, 0, 0, wbuf, 0, NULL }; |
315 | struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ; | 327 | struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ; |
316 | u8 hdr_core; | 328 | u8 hdr_core, tmp; |
317 | u16 hdr_addr, hdr_data_len, hdr_checksum; | 329 | u16 hdr_addr, hdr_data_len, hdr_checksum; |
318 | #define MAX_DATA 58 | 330 | #define MAX_DATA 58 |
319 | #define HDR_SIZE 7 | 331 | #define HDR_SIZE 7 |
320 | 332 | ||
321 | /* | 333 | /* |
334 | * In case of dual tuner configuration we need to do some extra | ||
335 | * initialization in order to download firmware to slave demod too, | ||
336 | * which is done by master demod. | ||
337 | * Master feeds also clock and controls power via GPIO. | ||
338 | */ | ||
339 | ret = af9035_rd_reg(d, EEPROM_DUAL_MODE, &tmp); | ||
340 | if (ret < 0) | ||
341 | goto err; | ||
342 | |||
343 | if (tmp) { | ||
344 | /* configure gpioh1, reset & power slave demod */ | ||
345 | ret = af9035_wr_reg_mask(d, 0x00d8b0, 0x01, 0x01); | ||
346 | if (ret < 0) | ||
347 | goto err; | ||
348 | |||
349 | ret = af9035_wr_reg_mask(d, 0x00d8b1, 0x01, 0x01); | ||
350 | if (ret < 0) | ||
351 | goto err; | ||
352 | |||
353 | ret = af9035_wr_reg_mask(d, 0x00d8af, 0x00, 0x01); | ||
354 | if (ret < 0) | ||
355 | goto err; | ||
356 | |||
357 | usleep_range(10000, 50000); | ||
358 | |||
359 | ret = af9035_wr_reg_mask(d, 0x00d8af, 0x01, 0x01); | ||
360 | if (ret < 0) | ||
361 | goto err; | ||
362 | |||
363 | /* tell the slave I2C address */ | ||
364 | ret = af9035_rd_reg(d, EEPROM_2ND_DEMOD_ADDR, &tmp); | ||
365 | if (ret < 0) | ||
366 | goto err; | ||
367 | |||
368 | ret = af9035_wr_reg(d, 0x00417f, tmp); | ||
369 | if (ret < 0) | ||
370 | goto err; | ||
371 | |||
372 | /* enable clock out */ | ||
373 | ret = af9035_wr_reg_mask(d, 0x00d81a, 0x01, 0x01); | ||
374 | if (ret < 0) | ||
375 | goto err; | ||
376 | } | ||
377 | |||
378 | /* | ||
322 | * Thanks to Daniel Glöckner <daniel-gl@gmx.net> about that info! | 379 | * Thanks to Daniel Glöckner <daniel-gl@gmx.net> about that info! |
323 | * | 380 | * |
324 | * byte 0: MCS 51 core | 381 | * byte 0: MCS 51 core |
@@ -380,6 +437,10 @@ static int af9035_download_firmware(struct dvb_usb_device *d, | |||
380 | __func__, fw->size - i); | 437 | __func__, fw->size - i); |
381 | } | 438 | } |
382 | 439 | ||
440 | /* print warn if firmware is bad, continue and see what happens */ | ||
441 | if (i) | ||
442 | dev_warn(&d->udev->dev, "%s: bad firmware\n", KBUILD_MODNAME); | ||
443 | |||
383 | /* firmware loaded, request boot */ | 444 | /* firmware loaded, request boot */ |
384 | req.cmd = CMD_FW_BOOT; | 445 | req.cmd = CMD_FW_BOOT; |
385 | ret = af9035_ctrl_msg(d, &req); | 446 | ret = af9035_ctrl_msg(d, &req); |
@@ -489,14 +550,28 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
489 | u8 tmp; | 550 | u8 tmp; |
490 | u16 tmp16; | 551 | u16 tmp16; |
491 | 552 | ||
553 | /* demod I2C "address" */ | ||
554 | state->af9033_config[0].i2c_addr = 0x38; | ||
555 | |||
492 | /* check if there is dual tuners */ | 556 | /* check if there is dual tuners */ |
493 | ret = af9035_rd_reg(d, EEPROM_DUAL_MODE, &tmp); | 557 | ret = af9035_rd_reg(d, EEPROM_DUAL_MODE, &tmp); |
494 | if (ret < 0) | 558 | if (ret < 0) |
495 | goto err; | 559 | goto err; |
496 | 560 | ||
497 | state->dual_mode = tmp; | 561 | state->dual_mode = tmp; |
498 | dev_dbg(&d->udev->dev, "%s: dual mode=%d\n", | 562 | dev_dbg(&d->udev->dev, "%s: dual mode=%d\n", __func__, |
499 | __func__, state->dual_mode); | 563 | state->dual_mode); |
564 | |||
565 | if (state->dual_mode) { | ||
566 | /* read 2nd demodulator I2C address */ | ||
567 | ret = af9035_rd_reg(d, EEPROM_2ND_DEMOD_ADDR, &tmp); | ||
568 | if (ret < 0) | ||
569 | goto err; | ||
570 | |||
571 | state->af9033_config[1].i2c_addr = tmp; | ||
572 | dev_dbg(&d->udev->dev, "%s: 2nd demod I2C addr=%02x\n", | ||
573 | __func__, tmp); | ||
574 | } | ||
500 | 575 | ||
501 | for (i = 0; i < state->dual_mode + 1; i++) { | 576 | for (i = 0; i < state->dual_mode + 1; i++) { |
502 | /* tuner */ | 577 | /* tuner */ |
@@ -514,6 +589,7 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
514 | case AF9033_TUNER_MXL5007T: | 589 | case AF9033_TUNER_MXL5007T: |
515 | case AF9033_TUNER_TDA18218: | 590 | case AF9033_TUNER_TDA18218: |
516 | case AF9033_TUNER_FC2580: | 591 | case AF9033_TUNER_FC2580: |
592 | case AF9033_TUNER_FC0012: | ||
517 | state->af9033_config[i].spec_inv = 1; | 593 | state->af9033_config[i].spec_inv = 1; |
518 | break; | 594 | break; |
519 | default: | 595 | default: |
@@ -522,6 +598,18 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
522 | KBUILD_MODNAME, tmp); | 598 | KBUILD_MODNAME, tmp); |
523 | } | 599 | } |
524 | 600 | ||
601 | /* disable dual mode if driver does not support it */ | ||
602 | if (i == 1) | ||
603 | switch (tmp) { | ||
604 | case AF9033_TUNER_FC0012: | ||
605 | break; | ||
606 | default: | ||
607 | state->dual_mode = false; | ||
608 | dev_info(&d->udev->dev, "%s: driver does not " \ | ||
609 | "support 2nd tuner and will " \ | ||
610 | "disable it", KBUILD_MODNAME); | ||
611 | } | ||
612 | |||
525 | /* tuner IF frequency */ | 613 | /* tuner IF frequency */ |
526 | ret = af9035_rd_reg(d, EEPROM_1_IFFREQ_L + eeprom_shift, &tmp); | 614 | ret = af9035_rd_reg(d, EEPROM_1_IFFREQ_L + eeprom_shift, &tmp); |
527 | if (ret < 0) | 615 | if (ret < 0) |
@@ -730,6 +818,12 @@ static int af9035_frontend_callback(void *adapter_priv, int component, | |||
730 | return 0; | 818 | return 0; |
731 | } | 819 | } |
732 | 820 | ||
821 | static int af9035_get_adapter_count(struct dvb_usb_device *d) | ||
822 | { | ||
823 | struct state *state = d_to_priv(d); | ||
824 | return state->dual_mode + 1; | ||
825 | } | ||
826 | |||
733 | static int af9035_frontend_attach(struct dvb_usb_adapter *adap) | 827 | static int af9035_frontend_attach(struct dvb_usb_adapter *adap) |
734 | { | 828 | { |
735 | struct state *state = adap_to_priv(adap); | 829 | struct state *state = adap_to_priv(adap); |
@@ -751,15 +845,14 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap) | |||
751 | if (ret < 0) | 845 | if (ret < 0) |
752 | goto err; | 846 | goto err; |
753 | 847 | ||
754 | ret = af9035_wr_reg(d, 0x00d81a, | 848 | ret = af9035_wr_reg(d, 0x00d81a, state->dual_mode); |
755 | state->dual_mode); | ||
756 | if (ret < 0) | 849 | if (ret < 0) |
757 | goto err; | 850 | goto err; |
758 | } | 851 | } |
759 | 852 | ||
760 | /* attach demodulator */ | 853 | /* attach demodulator */ |
761 | adap->fe[0] = dvb_attach(af9033_attach, | 854 | adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id], |
762 | &state->af9033_config[adap->id], &d->i2c_adap); | 855 | &d->i2c_adap); |
763 | if (adap->fe[0] == NULL) { | 856 | if (adap->fe[0] == NULL) { |
764 | ret = -ENODEV; | 857 | ret = -ENODEV; |
765 | goto err; | 858 | goto err; |
@@ -785,13 +878,22 @@ static const struct fc0011_config af9035_fc0011_config = { | |||
785 | .i2c_address = 0x60, | 878 | .i2c_address = 0x60, |
786 | }; | 879 | }; |
787 | 880 | ||
788 | static struct mxl5007t_config af9035_mxl5007t_config = { | 881 | static struct mxl5007t_config af9035_mxl5007t_config[] = { |
789 | .xtal_freq_hz = MxL_XTAL_24_MHZ, | 882 | { |
790 | .if_freq_hz = MxL_IF_4_57_MHZ, | 883 | .xtal_freq_hz = MxL_XTAL_24_MHZ, |
791 | .invert_if = 0, | 884 | .if_freq_hz = MxL_IF_4_57_MHZ, |
792 | .loop_thru_enable = 0, | 885 | .invert_if = 0, |
793 | .clk_out_enable = 0, | 886 | .loop_thru_enable = 0, |
794 | .clk_out_amp = MxL_CLKOUT_AMP_0_94V, | 887 | .clk_out_enable = 0, |
888 | .clk_out_amp = MxL_CLKOUT_AMP_0_94V, | ||
889 | }, { | ||
890 | .xtal_freq_hz = MxL_XTAL_24_MHZ, | ||
891 | .if_freq_hz = MxL_IF_4_57_MHZ, | ||
892 | .invert_if = 0, | ||
893 | .loop_thru_enable = 1, | ||
894 | .clk_out_enable = 1, | ||
895 | .clk_out_amp = MxL_CLKOUT_AMP_0_94V, | ||
896 | } | ||
795 | }; | 897 | }; |
796 | 898 | ||
797 | static struct tda18218_config af9035_tda18218_config = { | 899 | static struct tda18218_config af9035_tda18218_config = { |
@@ -804,12 +906,32 @@ static const struct fc2580_config af9035_fc2580_config = { | |||
804 | .clock = 16384000, | 906 | .clock = 16384000, |
805 | }; | 907 | }; |
806 | 908 | ||
909 | static const struct fc0012_config af9035_fc0012_config[] = { | ||
910 | { | ||
911 | .i2c_address = 0x63, | ||
912 | .xtal_freq = FC_XTAL_36_MHZ, | ||
913 | .dual_master = true, | ||
914 | .loop_through = true, | ||
915 | .clock_out = true, | ||
916 | }, { | ||
917 | .i2c_address = 0x63 | 0x80, /* I2C bus select hack */ | ||
918 | .xtal_freq = FC_XTAL_36_MHZ, | ||
919 | .dual_master = true, | ||
920 | } | ||
921 | }; | ||
922 | |||
807 | static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | 923 | static int af9035_tuner_attach(struct dvb_usb_adapter *adap) |
808 | { | 924 | { |
809 | struct state *state = adap_to_priv(adap); | 925 | struct state *state = adap_to_priv(adap); |
810 | struct dvb_usb_device *d = adap_to_d(adap); | 926 | struct dvb_usb_device *d = adap_to_d(adap); |
811 | int ret; | 927 | int ret; |
812 | struct dvb_frontend *fe; | 928 | struct dvb_frontend *fe; |
929 | struct i2c_msg msg[1]; | ||
930 | u8 tuner_addr; | ||
931 | /* | ||
932 | * XXX: Hack used in that function: we abuse unused I2C address bit [7] | ||
933 | * to carry info about used I2C bus for dual tuner configuration. | ||
934 | */ | ||
813 | 935 | ||
814 | switch (state->af9033_config[adap->id].tuner) { | 936 | switch (state->af9033_config[adap->id].tuner) { |
815 | case AF9033_TUNER_TUA9001: | 937 | case AF9033_TUNER_TUA9001: |
@@ -842,46 +964,59 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
842 | &d->i2c_adap, &af9035_fc0011_config); | 964 | &d->i2c_adap, &af9035_fc0011_config); |
843 | break; | 965 | break; |
844 | case AF9033_TUNER_MXL5007T: | 966 | case AF9033_TUNER_MXL5007T: |
845 | ret = af9035_wr_reg(d, 0x00d8e0, 1); | 967 | if (adap->id == 0) { |
846 | if (ret < 0) | 968 | ret = af9035_wr_reg(d, 0x00d8e0, 1); |
847 | goto err; | 969 | if (ret < 0) |
848 | ret = af9035_wr_reg(d, 0x00d8e1, 1); | 970 | goto err; |
849 | if (ret < 0) | ||
850 | goto err; | ||
851 | ret = af9035_wr_reg(d, 0x00d8df, 0); | ||
852 | if (ret < 0) | ||
853 | goto err; | ||
854 | 971 | ||
855 | msleep(30); | 972 | ret = af9035_wr_reg(d, 0x00d8e1, 1); |
973 | if (ret < 0) | ||
974 | goto err; | ||
856 | 975 | ||
857 | ret = af9035_wr_reg(d, 0x00d8df, 1); | 976 | ret = af9035_wr_reg(d, 0x00d8df, 0); |
858 | if (ret < 0) | 977 | if (ret < 0) |
859 | goto err; | 978 | goto err; |
860 | 979 | ||
861 | msleep(300); | 980 | msleep(30); |
862 | 981 | ||
863 | ret = af9035_wr_reg(d, 0x00d8c0, 1); | 982 | ret = af9035_wr_reg(d, 0x00d8df, 1); |
864 | if (ret < 0) | 983 | if (ret < 0) |
865 | goto err; | 984 | goto err; |
866 | ret = af9035_wr_reg(d, 0x00d8c1, 1); | 985 | |
867 | if (ret < 0) | 986 | msleep(300); |
868 | goto err; | 987 | |
869 | ret = af9035_wr_reg(d, 0x00d8bf, 0); | 988 | ret = af9035_wr_reg(d, 0x00d8c0, 1); |
870 | if (ret < 0) | 989 | if (ret < 0) |
871 | goto err; | 990 | goto err; |
872 | ret = af9035_wr_reg(d, 0x00d8b4, 1); | 991 | |
873 | if (ret < 0) | 992 | ret = af9035_wr_reg(d, 0x00d8c1, 1); |
874 | goto err; | 993 | if (ret < 0) |
875 | ret = af9035_wr_reg(d, 0x00d8b5, 1); | 994 | goto err; |
876 | if (ret < 0) | 995 | |
877 | goto err; | 996 | ret = af9035_wr_reg(d, 0x00d8bf, 0); |
878 | ret = af9035_wr_reg(d, 0x00d8b3, 1); | 997 | if (ret < 0) |
879 | if (ret < 0) | 998 | goto err; |
880 | goto err; | 999 | |
1000 | ret = af9035_wr_reg(d, 0x00d8b4, 1); | ||
1001 | if (ret < 0) | ||
1002 | goto err; | ||
1003 | |||
1004 | ret = af9035_wr_reg(d, 0x00d8b5, 1); | ||
1005 | if (ret < 0) | ||
1006 | goto err; | ||
1007 | |||
1008 | ret = af9035_wr_reg(d, 0x00d8b3, 1); | ||
1009 | if (ret < 0) | ||
1010 | goto err; | ||
1011 | |||
1012 | tuner_addr = 0x60; | ||
1013 | } else { | ||
1014 | tuner_addr = 0x60 | 0x80; /* I2C bus hack */ | ||
1015 | } | ||
881 | 1016 | ||
882 | /* attach tuner */ | 1017 | /* attach tuner */ |
883 | fe = dvb_attach(mxl5007t_attach, adap->fe[0], | 1018 | fe = dvb_attach(mxl5007t_attach, adap->fe[0], &d->i2c_adap, |
884 | &d->i2c_adap, 0x60, &af9035_mxl5007t_config); | 1019 | tuner_addr, &af9035_mxl5007t_config[adap->id]); |
885 | break; | 1020 | break; |
886 | case AF9033_TUNER_TDA18218: | 1021 | case AF9033_TUNER_TDA18218: |
887 | /* attach tuner */ | 1022 | /* attach tuner */ |
@@ -907,6 +1042,46 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
907 | fe = dvb_attach(fc2580_attach, adap->fe[0], | 1042 | fe = dvb_attach(fc2580_attach, adap->fe[0], |
908 | &d->i2c_adap, &af9035_fc2580_config); | 1043 | &d->i2c_adap, &af9035_fc2580_config); |
909 | break; | 1044 | break; |
1045 | case AF9033_TUNER_FC0012: | ||
1046 | /* | ||
1047 | * AF9035 gpiot2 = FC0012 enable | ||
1048 | * XXX: there seems to be something on gpioh8 too, but on my | ||
1049 | * my test I didn't find any difference. | ||
1050 | */ | ||
1051 | |||
1052 | if (adap->id == 0) { | ||
1053 | /* configure gpiot2 as output and high */ | ||
1054 | ret = af9035_wr_reg_mask(d, 0xd8eb, 0x01, 0x01); | ||
1055 | if (ret < 0) | ||
1056 | goto err; | ||
1057 | |||
1058 | ret = af9035_wr_reg_mask(d, 0xd8ec, 0x01, 0x01); | ||
1059 | if (ret < 0) | ||
1060 | goto err; | ||
1061 | |||
1062 | ret = af9035_wr_reg_mask(d, 0xd8ed, 0x01, 0x01); | ||
1063 | if (ret < 0) | ||
1064 | goto err; | ||
1065 | } else { | ||
1066 | /* | ||
1067 | * FIXME: That belongs for the FC0012 driver. | ||
1068 | * Write 02 to FC0012 master tuner register 0d directly | ||
1069 | * in order to make slave tuner working. | ||
1070 | */ | ||
1071 | msg[0].addr = 0x63; | ||
1072 | msg[0].flags = 0; | ||
1073 | msg[0].len = 2; | ||
1074 | msg[0].buf = "\x0d\x02"; | ||
1075 | ret = i2c_transfer(&d->i2c_adap, msg, 1); | ||
1076 | if (ret < 0) | ||
1077 | goto err; | ||
1078 | } | ||
1079 | |||
1080 | usleep_range(10000, 50000); | ||
1081 | |||
1082 | fe = dvb_attach(fc0012_attach, adap->fe[0], &d->i2c_adap, | ||
1083 | &af9035_fc0012_config[adap->id]); | ||
1084 | break; | ||
910 | default: | 1085 | default: |
911 | fe = NULL; | 1086 | fe = NULL; |
912 | } | 1087 | } |
@@ -945,8 +1120,8 @@ static int af9035_init(struct dvb_usb_device *d) | |||
945 | { 0x00dd8a, (frame_size >> 0) & 0xff, 0xff}, | 1120 | { 0x00dd8a, (frame_size >> 0) & 0xff, 0xff}, |
946 | { 0x00dd8b, (frame_size >> 8) & 0xff, 0xff}, | 1121 | { 0x00dd8b, (frame_size >> 8) & 0xff, 0xff}, |
947 | { 0x00dd0d, packet_size, 0xff }, | 1122 | { 0x00dd0d, packet_size, 0xff }, |
948 | { 0x80f9a3, 0x00, 0x01 }, | 1123 | { 0x80f9a3, state->dual_mode, 0x01 }, |
949 | { 0x80f9cd, 0x00, 0x01 }, | 1124 | { 0x80f9cd, state->dual_mode, 0x01 }, |
950 | { 0x80f99d, 0x00, 0x01 }, | 1125 | { 0x80f99d, 0x00, 0x01 }, |
951 | { 0x80f9a4, 0x00, 0x01 }, | 1126 | { 0x80f9a4, 0x00, 0x01 }, |
952 | }; | 1127 | }; |
@@ -971,6 +1146,7 @@ err: | |||
971 | return ret; | 1146 | return ret; |
972 | } | 1147 | } |
973 | 1148 | ||
1149 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
974 | static int af9035_rc_query(struct dvb_usb_device *d) | 1150 | static int af9035_rc_query(struct dvb_usb_device *d) |
975 | { | 1151 | { |
976 | unsigned int key; | 1152 | unsigned int key; |
@@ -1045,6 +1221,9 @@ err: | |||
1045 | 1221 | ||
1046 | return ret; | 1222 | return ret; |
1047 | } | 1223 | } |
1224 | #else | ||
1225 | #define af9035_get_rc_config NULL | ||
1226 | #endif | ||
1048 | 1227 | ||
1049 | /* interface 0 is used by DVB-T receiver and | 1228 | /* interface 0 is used by DVB-T receiver and |
1050 | interface 1 is for remote controller (HID) */ | 1229 | interface 1 is for remote controller (HID) */ |
@@ -1068,7 +1247,7 @@ static const struct dvb_usb_device_properties af9035_props = { | |||
1068 | .init = af9035_init, | 1247 | .init = af9035_init, |
1069 | .get_rc_config = af9035_get_rc_config, | 1248 | .get_rc_config = af9035_get_rc_config, |
1070 | 1249 | ||
1071 | .num_adapters = 1, | 1250 | .get_adapter_count = af9035_get_adapter_count, |
1072 | .adapter = { | 1251 | .adapter = { |
1073 | { | 1252 | { |
1074 | .stream = DVB_USB_STREAM_BULK(0x84, 6, 87 * 188), | 1253 | .stream = DVB_USB_STREAM_BULK(0x84, 6, 87 * 188), |
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h index 75ef1ec13fbf..29f3eec22c2c 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.h +++ b/drivers/media/usb/dvb-usb-v2/af9035.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "af9033.h" | 26 | #include "af9033.h" |
27 | #include "tua9001.h" | 27 | #include "tua9001.h" |
28 | #include "fc0011.h" | 28 | #include "fc0011.h" |
29 | #include "fc0012.h" | ||
29 | #include "mxl5007t.h" | 30 | #include "mxl5007t.h" |
30 | #include "tda18218.h" | 31 | #include "tda18218.h" |
31 | #include "fc2580.h" | 32 | #include "fc2580.h" |
@@ -53,7 +54,6 @@ struct usb_req { | |||
53 | struct state { | 54 | struct state { |
54 | u8 seq; /* packet sequence number */ | 55 | u8 seq; /* packet sequence number */ |
55 | bool dual_mode; | 56 | bool dual_mode; |
56 | |||
57 | struct af9033_config af9033_config[2]; | 57 | struct af9033_config af9033_config[2]; |
58 | }; | 58 | }; |
59 | 59 | ||
@@ -91,6 +91,7 @@ u32 clock_lut_it9135[] = { | |||
91 | /* EEPROM locations */ | 91 | /* EEPROM locations */ |
92 | #define EEPROM_IR_MODE 0x430d | 92 | #define EEPROM_IR_MODE 0x430d |
93 | #define EEPROM_DUAL_MODE 0x4326 | 93 | #define EEPROM_DUAL_MODE 0x4326 |
94 | #define EEPROM_2ND_DEMOD_ADDR 0x4327 | ||
94 | #define EEPROM_IR_TYPE 0x4329 | 95 | #define EEPROM_IR_TYPE 0x4329 |
95 | #define EEPROM_1_IFFREQ_L 0x432d | 96 | #define EEPROM_1_IFFREQ_L 0x432d |
96 | #define EEPROM_1_IFFREQ_H 0x432e | 97 | #define EEPROM_1_IFFREQ_H 0x432e |
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c index d05c5b563dac..a20d691d0b63 100644 --- a/drivers/media/usb/dvb-usb-v2/anysee.c +++ b/drivers/media/usb/dvb-usb-v2/anysee.c | |||
@@ -1019,6 +1019,7 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap) | |||
1019 | return ret; | 1019 | return ret; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
1022 | static int anysee_rc_query(struct dvb_usb_device *d) | 1023 | static int anysee_rc_query(struct dvb_usb_device *d) |
1023 | { | 1024 | { |
1024 | u8 buf[] = {CMD_GET_IR_CODE}; | 1025 | u8 buf[] = {CMD_GET_IR_CODE}; |
@@ -1054,6 +1055,9 @@ static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | |||
1054 | 1055 | ||
1055 | return 0; | 1056 | return 0; |
1056 | } | 1057 | } |
1058 | #else | ||
1059 | #define anysee_get_rc_config NULL | ||
1060 | #endif | ||
1057 | 1061 | ||
1058 | static int anysee_ci_read_attribute_mem(struct dvb_ca_en50221 *ci, int slot, | 1062 | static int anysee_ci_read_attribute_mem(struct dvb_ca_en50221 *ci, int slot, |
1059 | int addr) | 1063 | int addr) |
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c index d75dbf27e99e..70ec80d8be71 100644 --- a/drivers/media/usb/dvb-usb-v2/az6007.c +++ b/drivers/media/usb/dvb-usb-v2/az6007.c | |||
@@ -189,6 +189,7 @@ static int az6007_streaming_ctrl(struct dvb_frontend *fe, int onoff) | |||
189 | return az6007_write(d, 0xbc, onoff, 0, NULL, 0); | 189 | return az6007_write(d, 0xbc, onoff, 0, NULL, 0); |
190 | } | 190 | } |
191 | 191 | ||
192 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
192 | /* remote control stuff (does not work with my box) */ | 193 | /* remote control stuff (does not work with my box) */ |
193 | static int az6007_rc_query(struct dvb_usb_device *d) | 194 | static int az6007_rc_query(struct dvb_usb_device *d) |
194 | { | 195 | { |
@@ -215,6 +216,20 @@ static int az6007_rc_query(struct dvb_usb_device *d) | |||
215 | return 0; | 216 | return 0; |
216 | } | 217 | } |
217 | 218 | ||
219 | static int az6007_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | ||
220 | { | ||
221 | pr_debug("Getting az6007 Remote Control properties\n"); | ||
222 | |||
223 | rc->allowed_protos = RC_BIT_NEC; | ||
224 | rc->query = az6007_rc_query; | ||
225 | rc->interval = 400; | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | #else | ||
230 | #define az6007_get_rc_config NULL | ||
231 | #endif | ||
232 | |||
218 | static int az6007_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, | 233 | static int az6007_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, |
219 | int slot, | 234 | int slot, |
220 | int address) | 235 | int address) |
@@ -822,17 +837,6 @@ static void az6007_usb_disconnect(struct usb_interface *intf) | |||
822 | dvb_usbv2_disconnect(intf); | 837 | dvb_usbv2_disconnect(intf); |
823 | } | 838 | } |
824 | 839 | ||
825 | static int az6007_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | ||
826 | { | ||
827 | pr_debug("Getting az6007 Remote Control properties\n"); | ||
828 | |||
829 | rc->allowed_protos = RC_BIT_NEC; | ||
830 | rc->query = az6007_rc_query; | ||
831 | rc->interval = 400; | ||
832 | |||
833 | return 0; | ||
834 | } | ||
835 | |||
836 | static int az6007_download_firmware(struct dvb_usb_device *d, | 840 | static int az6007_download_firmware(struct dvb_usb_device *d, |
837 | const struct firmware *fw) | 841 | const struct firmware *fw) |
838 | { | 842 | { |
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h index 059291b892b8..3cac8bd0b116 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h | |||
@@ -347,6 +347,7 @@ struct dvb_usb_adapter { | |||
347 | * @props: device properties | 347 | * @props: device properties |
348 | * @name: device name | 348 | * @name: device name |
349 | * @rc_map: name of rc codes table | 349 | * @rc_map: name of rc codes table |
350 | * @rc_polling_active: set when RC polling is active | ||
350 | * @udev: pointer to the device's struct usb_device | 351 | * @udev: pointer to the device's struct usb_device |
351 | * @intf: pointer to the device's usb interface | 352 | * @intf: pointer to the device's usb interface |
352 | * @rc: remote controller configuration | 353 | * @rc: remote controller configuration |
@@ -364,7 +365,7 @@ struct dvb_usb_device { | |||
364 | const struct dvb_usb_device_properties *props; | 365 | const struct dvb_usb_device_properties *props; |
365 | const char *name; | 366 | const char *name; |
366 | const char *rc_map; | 367 | const char *rc_map; |
367 | 368 | bool rc_polling_active; | |
368 | struct usb_device *udev; | 369 | struct usb_device *udev; |
369 | struct usb_interface *intf; | 370 | struct usb_interface *intf; |
370 | struct dvb_usb_rc rc; | 371 | struct dvb_usb_rc rc; |
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 671b4fa232b4..086792055912 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | |||
@@ -102,6 +102,7 @@ static int dvb_usbv2_i2c_exit(struct dvb_usb_device *d) | |||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
105 | static void dvb_usb_read_remote_control(struct work_struct *work) | 106 | static void dvb_usb_read_remote_control(struct work_struct *work) |
106 | { | 107 | { |
107 | struct dvb_usb_device *d = container_of(work, | 108 | struct dvb_usb_device *d = container_of(work, |
@@ -112,13 +113,16 @@ static void dvb_usb_read_remote_control(struct work_struct *work) | |||
112 | * When the parameter has been set to 1 via sysfs while the | 113 | * When the parameter has been set to 1 via sysfs while the |
113 | * driver was running, or when bulk mode is enabled after IR init. | 114 | * driver was running, or when bulk mode is enabled after IR init. |
114 | */ | 115 | */ |
115 | if (dvb_usbv2_disable_rc_polling || d->rc.bulk_mode) | 116 | if (dvb_usbv2_disable_rc_polling || d->rc.bulk_mode) { |
117 | d->rc_polling_active = false; | ||
116 | return; | 118 | return; |
119 | } | ||
117 | 120 | ||
118 | ret = d->rc.query(d); | 121 | ret = d->rc.query(d); |
119 | if (ret < 0) { | 122 | if (ret < 0) { |
120 | dev_err(&d->udev->dev, "%s: rc.query() failed=%d\n", | 123 | dev_err(&d->udev->dev, "%s: rc.query() failed=%d\n", |
121 | KBUILD_MODNAME, ret); | 124 | KBUILD_MODNAME, ret); |
125 | d->rc_polling_active = false; | ||
122 | return; /* stop polling */ | 126 | return; /* stop polling */ |
123 | } | 127 | } |
124 | 128 | ||
@@ -182,6 +186,7 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d) | |||
182 | d->rc.interval); | 186 | d->rc.interval); |
183 | schedule_delayed_work(&d->rc_query_work, | 187 | schedule_delayed_work(&d->rc_query_work, |
184 | msecs_to_jiffies(d->rc.interval)); | 188 | msecs_to_jiffies(d->rc.interval)); |
189 | d->rc_polling_active = true; | ||
185 | } | 190 | } |
186 | 191 | ||
187 | return 0; | 192 | return 0; |
@@ -202,6 +207,10 @@ static int dvb_usbv2_remote_exit(struct dvb_usb_device *d) | |||
202 | 207 | ||
203 | return 0; | 208 | return 0; |
204 | } | 209 | } |
210 | #else | ||
211 | #define dvb_usbv2_remote_init(args...) 0 | ||
212 | #define dvb_usbv2_remote_exit(args...) | ||
213 | #endif | ||
205 | 214 | ||
206 | static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buf, | 215 | static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buf, |
207 | size_t len) | 216 | size_t len) |
@@ -959,7 +968,7 @@ int dvb_usbv2_suspend(struct usb_interface *intf, pm_message_t msg) | |||
959 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 968 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
960 | 969 | ||
961 | /* stop remote controller poll */ | 970 | /* stop remote controller poll */ |
962 | if (d->rc.query && !d->rc.bulk_mode) | 971 | if (d->rc_polling_active) |
963 | cancel_delayed_work_sync(&d->rc_query_work); | 972 | cancel_delayed_work_sync(&d->rc_query_work); |
964 | 973 | ||
965 | for (i = MAX_NO_OF_ADAPTER_PER_DEVICE - 1; i >= 0; i--) { | 974 | for (i = MAX_NO_OF_ADAPTER_PER_DEVICE - 1; i >= 0; i--) { |
@@ -1006,7 +1015,7 @@ static int dvb_usbv2_resume_common(struct dvb_usb_device *d) | |||
1006 | } | 1015 | } |
1007 | 1016 | ||
1008 | /* start remote controller poll */ | 1017 | /* start remote controller poll */ |
1009 | if (d->rc.query && !d->rc.bulk_mode) | 1018 | if (d->rc_polling_active) |
1010 | schedule_delayed_work(&d->rc_query_work, | 1019 | schedule_delayed_work(&d->rc_query_work, |
1011 | msecs_to_jiffies(d->rc.interval)); | 1020 | msecs_to_jiffies(d->rc.interval)); |
1012 | 1021 | ||
diff --git a/drivers/media/usb/dvb-usb-v2/it913x.c b/drivers/media/usb/dvb-usb-v2/it913x.c index 47204280b8b3..833847995c65 100644 --- a/drivers/media/usb/dvb-usb-v2/it913x.c +++ b/drivers/media/usb/dvb-usb-v2/it913x.c | |||
@@ -308,7 +308,7 @@ static struct i2c_algorithm it913x_i2c_algo = { | |||
308 | }; | 308 | }; |
309 | 309 | ||
310 | /* Callbacks for DVB USB */ | 310 | /* Callbacks for DVB USB */ |
311 | #define IT913X_POLL 250 | 311 | #if IS_ENABLED(CONFIG_RC_CORE) |
312 | static int it913x_rc_query(struct dvb_usb_device *d) | 312 | static int it913x_rc_query(struct dvb_usb_device *d) |
313 | { | 313 | { |
314 | u8 ibuf[4]; | 314 | u8 ibuf[4]; |
@@ -334,6 +334,25 @@ static int it913x_rc_query(struct dvb_usb_device *d) | |||
334 | return ret; | 334 | return ret; |
335 | } | 335 | } |
336 | 336 | ||
337 | static int it913x_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | ||
338 | { | ||
339 | struct it913x_state *st = d->priv; | ||
340 | |||
341 | if (st->proprietary_ir == false) { | ||
342 | rc->map_name = NULL; | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | rc->allowed_protos = RC_BIT_NEC; | ||
347 | rc->query = it913x_rc_query; | ||
348 | rc->interval = 250; | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | #else | ||
353 | #define it913x_get_rc_config NULL | ||
354 | #endif | ||
355 | |||
337 | /* Firmware sets raw */ | 356 | /* Firmware sets raw */ |
338 | static const char fw_it9135_v1[] = FW_IT9135_V1; | 357 | static const char fw_it9135_v1[] = FW_IT9135_V1; |
339 | static const char fw_it9135_v2[] = FW_IT9135_V2; | 358 | static const char fw_it9135_v2[] = FW_IT9135_V2; |
@@ -643,7 +662,8 @@ static int it913x_frontend_attach(struct dvb_usb_adapter *adap) | |||
643 | struct it913x_state *st = d->priv; | 662 | struct it913x_state *st = d->priv; |
644 | int ret = 0; | 663 | int ret = 0; |
645 | u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5); | 664 | u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5); |
646 | u16 ep_size = adap->stream.buf_size / 4; | 665 | u16 ep_size = (adap->pid_filtering) ? TS_BUFFER_SIZE_PID / 4 : |
666 | TS_BUFFER_SIZE_MAX / 4; | ||
647 | u8 pkt_size = 0x80; | 667 | u8 pkt_size = 0x80; |
648 | 668 | ||
649 | if (d->udev->speed != USB_SPEED_HIGH) | 669 | if (d->udev->speed != USB_SPEED_HIGH) |
@@ -695,22 +715,6 @@ static int it913x_frontend_attach(struct dvb_usb_adapter *adap) | |||
695 | } | 715 | } |
696 | 716 | ||
697 | /* DVB USB Driver */ | 717 | /* DVB USB Driver */ |
698 | static int it913x_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) | ||
699 | { | ||
700 | struct it913x_state *st = d->priv; | ||
701 | |||
702 | if (st->proprietary_ir == false) { | ||
703 | rc->map_name = NULL; | ||
704 | return 0; | ||
705 | } | ||
706 | |||
707 | rc->allowed_protos = RC_BIT_NEC; | ||
708 | rc->query = it913x_rc_query; | ||
709 | rc->interval = 250; | ||
710 | |||
711 | return 0; | ||
712 | } | ||
713 | |||
714 | static int it913x_get_adapter_count(struct dvb_usb_device *d) | 718 | static int it913x_get_adapter_count(struct dvb_usb_device *d) |
715 | { | 719 | { |
716 | struct it913x_state *st = d->priv; | 720 | struct it913x_state *st = d->priv; |
@@ -779,6 +783,18 @@ static const struct usb_device_id it913x_id_table[] = { | |||
779 | { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006, | 783 | { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006, |
780 | &it913x_properties, "ITE 9135(9006) Generic", | 784 | &it913x_properties, "ITE 9135(9006) Generic", |
781 | RC_MAP_IT913X_V1) }, | 785 | RC_MAP_IT913X_V1) }, |
786 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_1835, | ||
787 | &it913x_properties, "Avermedia A835B(1835)", | ||
788 | RC_MAP_IT913X_V2) }, | ||
789 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_2835, | ||
790 | &it913x_properties, "Avermedia A835B(2835)", | ||
791 | RC_MAP_IT913X_V2) }, | ||
792 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_3835, | ||
793 | &it913x_properties, "Avermedia A835B(3835)", | ||
794 | RC_MAP_IT913X_V2) }, | ||
795 | { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835, | ||
796 | &it913x_properties, "Avermedia A835B(4835)", | ||
797 | RC_MAP_IT913X_V2) }, | ||
782 | {} /* Terminating entry */ | 798 | {} /* Terminating entry */ |
783 | }; | 799 | }; |
784 | 800 | ||
@@ -797,7 +813,7 @@ module_usb_driver(it913x_driver); | |||
797 | 813 | ||
798 | MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); | 814 | MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); |
799 | MODULE_DESCRIPTION("it913x USB 2 Driver"); | 815 | MODULE_DESCRIPTION("it913x USB 2 Driver"); |
800 | MODULE_VERSION("1.32"); | 816 | MODULE_VERSION("1.33"); |
801 | MODULE_LICENSE("GPL"); | 817 | MODULE_LICENSE("GPL"); |
802 | MODULE_FIRMWARE(FW_IT9135_V1); | 818 | MODULE_FIRMWARE(FW_IT9135_V1); |
803 | MODULE_FIRMWARE(FW_IT9135_V2); | 819 | MODULE_FIRMWARE(FW_IT9135_V2); |
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c index 6427ac359f21..f30c58cecbba 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c | |||
@@ -81,6 +81,7 @@ | |||
81 | #include "dvb-pll.h" | 81 | #include "dvb-pll.h" |
82 | #include "z0194a.h" | 82 | #include "z0194a.h" |
83 | #include "m88rs2000.h" | 83 | #include "m88rs2000.h" |
84 | #include "ts2020.h" | ||
84 | 85 | ||
85 | 86 | ||
86 | #define LME2510_C_S7395 "dvb-usb-lme2510c-s7395.fw"; | 87 | #define LME2510_C_S7395 "dvb-usb-lme2510c-s7395.fw"; |
@@ -626,8 +627,8 @@ static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
626 | gate = 5; | 627 | gate = 5; |
627 | 628 | ||
628 | for (i = 0; i < num; i++) { | 629 | for (i = 0; i < num; i++) { |
629 | read_o = 1 & (msg[i].flags & I2C_M_RD); | 630 | read_o = msg[i].flags & I2C_M_RD; |
630 | read = i+1 < num && (msg[i+1].flags & I2C_M_RD); | 631 | read = i + 1 < num && msg[i + 1].flags & I2C_M_RD; |
631 | read |= read_o; | 632 | read |= read_o; |
632 | gate = (msg[i].addr == st->i2c_tuner_addr) | 633 | gate = (msg[i].addr == st->i2c_tuner_addr) |
633 | ? (read) ? st->i2c_tuner_gate_r | 634 | ? (read) ? st->i2c_tuner_gate_r |
@@ -640,7 +641,8 @@ static int lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
640 | else | 641 | else |
641 | obuf[1] = msg[i].len + read + 1; | 642 | obuf[1] = msg[i].len + read + 1; |
642 | 643 | ||
643 | obuf[2] = msg[i].addr; | 644 | obuf[2] = msg[i].addr << 1; |
645 | |||
644 | if (read) { | 646 | if (read) { |
645 | if (read_o) | 647 | if (read_o) |
646 | len = 3; | 648 | len = 3; |
@@ -894,27 +896,27 @@ static int lme2510_kill_urb(struct usb_data_stream *stream) | |||
894 | } | 896 | } |
895 | 897 | ||
896 | static struct tda10086_config tda10086_config = { | 898 | static struct tda10086_config tda10086_config = { |
897 | .demod_address = 0x1c, | 899 | .demod_address = 0x0e, |
898 | .invert = 0, | 900 | .invert = 0, |
899 | .diseqc_tone = 1, | 901 | .diseqc_tone = 1, |
900 | .xtal_freq = TDA10086_XTAL_16M, | 902 | .xtal_freq = TDA10086_XTAL_16M, |
901 | }; | 903 | }; |
902 | 904 | ||
903 | static struct stv0288_config lme_config = { | 905 | static struct stv0288_config lme_config = { |
904 | .demod_address = 0xd0, | 906 | .demod_address = 0x68, |
905 | .min_delay_ms = 15, | 907 | .min_delay_ms = 15, |
906 | .inittab = s7395_inittab, | 908 | .inittab = s7395_inittab, |
907 | }; | 909 | }; |
908 | 910 | ||
909 | static struct ix2505v_config lme_tuner = { | 911 | static struct ix2505v_config lme_tuner = { |
910 | .tuner_address = 0xc0, | 912 | .tuner_address = 0x60, |
911 | .min_delay_ms = 100, | 913 | .min_delay_ms = 100, |
912 | .tuner_gain = 0x0, | 914 | .tuner_gain = 0x0, |
913 | .tuner_chargepump = 0x3, | 915 | .tuner_chargepump = 0x3, |
914 | }; | 916 | }; |
915 | 917 | ||
916 | static struct stv0299_config sharp_z0194_config = { | 918 | static struct stv0299_config sharp_z0194_config = { |
917 | .demod_address = 0xd0, | 919 | .demod_address = 0x68, |
918 | .inittab = sharp_z0194a_inittab, | 920 | .inittab = sharp_z0194a_inittab, |
919 | .mclk = 88000000UL, | 921 | .mclk = 88000000UL, |
920 | .invert = 0, | 922 | .invert = 0, |
@@ -943,11 +945,15 @@ static int dm04_rs2000_set_ts_param(struct dvb_frontend *fe, | |||
943 | } | 945 | } |
944 | 946 | ||
945 | static struct m88rs2000_config m88rs2000_config = { | 947 | static struct m88rs2000_config m88rs2000_config = { |
946 | .demod_addr = 0xd0, | 948 | .demod_addr = 0x68, |
947 | .tuner_addr = 0xc0, | ||
948 | .set_ts_params = dm04_rs2000_set_ts_param, | 949 | .set_ts_params = dm04_rs2000_set_ts_param, |
949 | }; | 950 | }; |
950 | 951 | ||
952 | static struct ts2020_config ts2020_config = { | ||
953 | .tuner_address = 0x60, | ||
954 | .clk_out_div = 7, | ||
955 | }; | ||
956 | |||
951 | static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, | 957 | static int dm04_lme2510_set_voltage(struct dvb_frontend *fe, |
952 | fe_sec_voltage_t voltage) | 958 | fe_sec_voltage_t voltage) |
953 | { | 959 | { |
@@ -1049,7 +1055,7 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) | |||
1049 | info("TUN Found Frontend TDA10086"); | 1055 | info("TUN Found Frontend TDA10086"); |
1050 | st->i2c_tuner_gate_w = 4; | 1056 | st->i2c_tuner_gate_w = 4; |
1051 | st->i2c_tuner_gate_r = 4; | 1057 | st->i2c_tuner_gate_r = 4; |
1052 | st->i2c_tuner_addr = 0xc0; | 1058 | st->i2c_tuner_addr = 0x60; |
1053 | st->tuner_config = TUNER_LG; | 1059 | st->tuner_config = TUNER_LG; |
1054 | if (st->dvb_usb_lme2510_firmware != TUNER_LG) { | 1060 | if (st->dvb_usb_lme2510_firmware != TUNER_LG) { |
1055 | st->dvb_usb_lme2510_firmware = TUNER_LG; | 1061 | st->dvb_usb_lme2510_firmware = TUNER_LG; |
@@ -1065,7 +1071,7 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) | |||
1065 | info("FE Found Stv0299"); | 1071 | info("FE Found Stv0299"); |
1066 | st->i2c_tuner_gate_w = 4; | 1072 | st->i2c_tuner_gate_w = 4; |
1067 | st->i2c_tuner_gate_r = 5; | 1073 | st->i2c_tuner_gate_r = 5; |
1068 | st->i2c_tuner_addr = 0xc0; | 1074 | st->i2c_tuner_addr = 0x60; |
1069 | st->tuner_config = TUNER_S0194; | 1075 | st->tuner_config = TUNER_S0194; |
1070 | if (st->dvb_usb_lme2510_firmware != TUNER_S0194) { | 1076 | if (st->dvb_usb_lme2510_firmware != TUNER_S0194) { |
1071 | st->dvb_usb_lme2510_firmware = TUNER_S0194; | 1077 | st->dvb_usb_lme2510_firmware = TUNER_S0194; |
@@ -1082,7 +1088,7 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) | |||
1082 | info("FE Found Stv0288"); | 1088 | info("FE Found Stv0288"); |
1083 | st->i2c_tuner_gate_w = 4; | 1089 | st->i2c_tuner_gate_w = 4; |
1084 | st->i2c_tuner_gate_r = 5; | 1090 | st->i2c_tuner_gate_r = 5; |
1085 | st->i2c_tuner_addr = 0xc0; | 1091 | st->i2c_tuner_addr = 0x60; |
1086 | st->tuner_config = TUNER_S7395; | 1092 | st->tuner_config = TUNER_S7395; |
1087 | if (st->dvb_usb_lme2510_firmware != TUNER_S7395) { | 1093 | if (st->dvb_usb_lme2510_firmware != TUNER_S7395) { |
1088 | st->dvb_usb_lme2510_firmware = TUNER_S7395; | 1094 | st->dvb_usb_lme2510_firmware = TUNER_S7395; |
@@ -1097,9 +1103,11 @@ static int dm04_lme2510_frontend_attach(struct dvb_usb_adapter *adap) | |||
1097 | 1103 | ||
1098 | if (adap->fe[0]) { | 1104 | if (adap->fe[0]) { |
1099 | info("FE Found M88RS2000"); | 1105 | info("FE Found M88RS2000"); |
1106 | dvb_attach(ts2020_attach, adap->fe[0], &ts2020_config, | ||
1107 | &d->i2c_adap); | ||
1100 | st->i2c_tuner_gate_w = 5; | 1108 | st->i2c_tuner_gate_w = 5; |
1101 | st->i2c_tuner_gate_r = 5; | 1109 | st->i2c_tuner_gate_r = 5; |
1102 | st->i2c_tuner_addr = 0xc0; | 1110 | st->i2c_tuner_addr = 0x60; |
1103 | st->tuner_config = TUNER_RS2000; | 1111 | st->tuner_config = TUNER_RS2000; |
1104 | st->fe_set_voltage = | 1112 | st->fe_set_voltage = |
1105 | adap->fe[0]->ops.set_voltage; | 1113 | adap->fe[0]->ops.set_voltage; |
@@ -1144,7 +1152,7 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap) | |||
1144 | 1152 | ||
1145 | switch (st->tuner_config) { | 1153 | switch (st->tuner_config) { |
1146 | case TUNER_LG: | 1154 | case TUNER_LG: |
1147 | if (dvb_attach(tda826x_attach, adap->fe[0], 0xc0, | 1155 | if (dvb_attach(tda826x_attach, adap->fe[0], 0x60, |
1148 | &d->i2c_adap, 1)) | 1156 | &d->i2c_adap, 1)) |
1149 | ret = st->tuner_config; | 1157 | ret = st->tuner_config; |
1150 | break; | 1158 | break; |
@@ -1154,7 +1162,7 @@ static int dm04_lme2510_tuner(struct dvb_usb_adapter *adap) | |||
1154 | ret = st->tuner_config; | 1162 | ret = st->tuner_config; |
1155 | break; | 1163 | break; |
1156 | case TUNER_S0194: | 1164 | case TUNER_S0194: |
1157 | if (dvb_attach(dvb_pll_attach , adap->fe[0], 0xc0, | 1165 | if (dvb_attach(dvb_pll_attach , adap->fe[0], 0x60, |
1158 | &d->i2c_adap, DVB_PLL_OPERA1)) | 1166 | &d->i2c_adap, DVB_PLL_OPERA1)) |
1159 | ret = st->tuner_config; | 1167 | ret = st->tuner_config; |
1160 | break; | 1168 | break; |
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index a4c302d0aa37..d98387a3c95e 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c | |||
@@ -835,6 +835,11 @@ static struct tua9001_config rtl2832u_tua9001_config = { | |||
835 | .i2c_addr = 0x60, | 835 | .i2c_addr = 0x60, |
836 | }; | 836 | }; |
837 | 837 | ||
838 | static const struct fc0012_config rtl2832u_fc0012_config = { | ||
839 | .i2c_address = 0x63, /* 0xc6 >> 1 */ | ||
840 | .xtal_freq = FC_XTAL_28_8_MHZ, | ||
841 | }; | ||
842 | |||
838 | static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | 843 | static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) |
839 | { | 844 | { |
840 | int ret; | 845 | int ret; |
@@ -847,7 +852,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
847 | switch (priv->tuner) { | 852 | switch (priv->tuner) { |
848 | case TUNER_RTL2832_FC0012: | 853 | case TUNER_RTL2832_FC0012: |
849 | fe = dvb_attach(fc0012_attach, adap->fe[0], | 854 | fe = dvb_attach(fc0012_attach, adap->fe[0], |
850 | &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); | 855 | &d->i2c_adap, &rtl2832u_fc0012_config); |
851 | 856 | ||
852 | /* since fc0012 includs reading the signal strength delegate | 857 | /* since fc0012 includs reading the signal strength delegate |
853 | * that to the tuner driver */ | 858 | * that to the tuner driver */ |
@@ -1120,7 +1125,7 @@ err: | |||
1120 | return ret; | 1125 | return ret; |
1121 | } | 1126 | } |
1122 | 1127 | ||
1123 | 1128 | #if IS_ENABLED(CONFIG_RC_CORE) | |
1124 | static int rtl2831u_rc_query(struct dvb_usb_device *d) | 1129 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
1125 | { | 1130 | { |
1126 | int ret, i; | 1131 | int ret, i; |
@@ -1203,7 +1208,11 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d, | |||
1203 | 1208 | ||
1204 | return 0; | 1209 | return 0; |
1205 | } | 1210 | } |
1211 | #else | ||
1212 | #define rtl2831u_get_rc_config NULL | ||
1213 | #endif | ||
1206 | 1214 | ||
1215 | #if IS_ENABLED(CONFIG_RC_CORE) | ||
1207 | static int rtl2832u_rc_query(struct dvb_usb_device *d) | 1216 | static int rtl2832u_rc_query(struct dvb_usb_device *d) |
1208 | { | 1217 | { |
1209 | int ret, i; | 1218 | int ret, i; |
@@ -1275,6 +1284,9 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d, | |||
1275 | 1284 | ||
1276 | return 0; | 1285 | return 0; |
1277 | } | 1286 | } |
1287 | #else | ||
1288 | #define rtl2832u_get_rc_config NULL | ||
1289 | #endif | ||
1278 | 1290 | ||
1279 | static const struct dvb_usb_device_properties rtl2831u_props = { | 1291 | static const struct dvb_usb_device_properties rtl2831u_props = { |
1280 | .driver_name = KBUILD_MODNAME, | 1292 | .driver_name = KBUILD_MODNAME, |
@@ -1333,13 +1345,13 @@ static const struct usb_device_id rtl28xxu_id_table[] = { | |||
1333 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, | 1345 | { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, |
1334 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, | 1346 | &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, |
1335 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1, | 1347 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1, |
1336 | &rtl2832u_props, "Terratec Cinergy T Stick Black", NULL) }, | 1348 | &rtl2832u_props, "TerraTec Cinergy T Stick Black", NULL) }, |
1337 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT, | 1349 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT, |
1338 | &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, | 1350 | &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) }, |
1339 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, | 1351 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK, |
1340 | &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) }, | 1352 | &rtl2832u_props, "TerraTec NOXON DAB Stick", NULL) }, |
1341 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2, | 1353 | { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2, |
1342 | &rtl2832u_props, "NOXON DAB/DAB+ USB dongle (rev 2)", NULL) }, | 1354 | &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 2)", NULL) }, |
1343 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, | 1355 | { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, |
1344 | &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, | 1356 | &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, |
1345 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, | 1357 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, |
@@ -1352,6 +1364,14 @@ static const struct usb_device_id rtl28xxu_id_table[] = { | |||
1352 | &rtl2832u_props, "Dexatek DK mini DVB-T Dongle", NULL) }, | 1364 | &rtl2832u_props, "Dexatek DK mini DVB-T Dongle", NULL) }, |
1353 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d7, | 1365 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00d7, |
1354 | &rtl2832u_props, "TerraTec Cinergy T Stick+", NULL) }, | 1366 | &rtl2832u_props, "TerraTec Cinergy T Stick+", NULL) }, |
1367 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd3a8, | ||
1368 | &rtl2832u_props, "ASUS My Cinema-U3100Mini Plus V2", NULL) }, | ||
1369 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd393, | ||
1370 | &rtl2832u_props, "GIGABYTE U7300", NULL) }, | ||
1371 | { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1104, | ||
1372 | &rtl2832u_props, "Digivox Micro Hd", NULL) }, | ||
1373 | { DVB_USB_DEVICE(USB_VID_COMPRO, 0x0620, | ||
1374 | &rtl2832u_props, "Compro VideoMate U620F", NULL) }, | ||
1355 | { } | 1375 | { } |
1356 | }; | 1376 | }; |
1357 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); | 1377 | MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); |
diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig index fa0b2931d305..c5d95662e2e1 100644 --- a/drivers/media/usb/dvb-usb/Kconfig +++ b/drivers/media/usb/dvb-usb/Kconfig | |||
@@ -202,8 +202,12 @@ config DVB_USB_TTUSB2 | |||
202 | select DVB_TDA10086 if MEDIA_SUBDRV_AUTOSELECT | 202 | select DVB_TDA10086 if MEDIA_SUBDRV_AUTOSELECT |
203 | select DVB_LNBP21 if MEDIA_SUBDRV_AUTOSELECT | 203 | select DVB_LNBP21 if MEDIA_SUBDRV_AUTOSELECT |
204 | select DVB_TDA826X if MEDIA_SUBDRV_AUTOSELECT | 204 | select DVB_TDA826X if MEDIA_SUBDRV_AUTOSELECT |
205 | select DVB_TDA10023 if MEDIA_SUBDRV_AUTOSELECT | ||
206 | select DVB_TDA10048 if MEDIA_SUBDRV_AUTOSELECT | ||
207 | select MEDIA_TUNER_TDA827X if MEDIA_SUBDRV_AUTOSELECT | ||
205 | help | 208 | help |
206 | Say Y here to support the Pinnacle 400e DVB-S USB2.0 receiver. The | 209 | Say Y here to support the Pinnacle 400e DVB-S USB2.0 receiver and |
210 | the TechnoTrend CT-3650 CI DVB-C/T USB2.0 receiver. The | ||
207 | firmware protocol used by this module is similar to the one used by the | 211 | firmware protocol used by this module is similar to the one used by the |
208 | old ttusb-driver - that's why the module is called dvb-usb-ttusb2. | 212 | old ttusb-driver - that's why the module is called dvb-usb-ttusb2. |
209 | 213 | ||
@@ -267,9 +271,11 @@ config DVB_USB_DW2102 | |||
267 | select DVB_MT312 if MEDIA_SUBDRV_AUTOSELECT | 271 | select DVB_MT312 if MEDIA_SUBDRV_AUTOSELECT |
268 | select DVB_ZL10039 if MEDIA_SUBDRV_AUTOSELECT | 272 | select DVB_ZL10039 if MEDIA_SUBDRV_AUTOSELECT |
269 | select DVB_DS3000 if MEDIA_SUBDRV_AUTOSELECT | 273 | select DVB_DS3000 if MEDIA_SUBDRV_AUTOSELECT |
274 | select DVB_TS2020 if MEDIA_SUBDRV_AUTOSELECT | ||
270 | select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT | 275 | select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT |
271 | select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT | 276 | select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT |
272 | select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT | 277 | select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT |
278 | select DVB_M88RS2000 if MEDIA_SUBDRV_AUTOSELECT | ||
273 | help | 279 | help |
274 | Say Y here to support the DvbWorld, TeVii, Prof DVB-S/S2 USB2.0 | 280 | Say Y here to support the DvbWorld, TeVii, Prof DVB-S/S2 USB2.0 |
275 | receivers. | 281 | receivers. |
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c index 19b5ed2825d7..bf2a908d74cf 100644 --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c | |||
@@ -561,10 +561,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | |||
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | if (mutex_lock_interruptible(&adap->dev->usb_mutex) < 0) { | 564 | mutex_lock(&adap->dev->usb_mutex); |
565 | err("could not acquire lock"); | ||
566 | return -EINTR; | ||
567 | } | ||
568 | 565 | ||
569 | st->buf[0] = REQUEST_ENABLE_VIDEO; | 566 | st->buf[0] = REQUEST_ENABLE_VIDEO; |
570 | /* this bit gives a kind of command, | 567 | /* this bit gives a kind of command, |
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c index 169196ec2d4e..1adf325012f7 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c | |||
@@ -38,41 +38,41 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs) | |||
38 | 38 | ||
39 | memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties)); | 39 | memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties)); |
40 | 40 | ||
41 | for (o = 0; o < adap->props.num_frontends; o++) { | 41 | for (o = 0; o < adap->props.num_frontends; o++) { |
42 | struct dvb_usb_adapter_fe_properties *props = &adap->props.fe[o]; | 42 | struct dvb_usb_adapter_fe_properties *props = &adap->props.fe[o]; |
43 | /* speed - when running at FULL speed we need a HW PID filter */ | 43 | /* speed - when running at FULL speed we need a HW PID filter */ |
44 | if (d->udev->speed == USB_SPEED_FULL && !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { | 44 | if (d->udev->speed == USB_SPEED_FULL && !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { |
45 | err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); | 45 | err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); |
46 | return -ENODEV; | 46 | return -ENODEV; |
47 | } | 47 | } |
48 | 48 | ||
49 | if ((d->udev->speed == USB_SPEED_FULL && props->caps & DVB_USB_ADAP_HAS_PID_FILTER) || | 49 | if ((d->udev->speed == USB_SPEED_FULL && props->caps & DVB_USB_ADAP_HAS_PID_FILTER) || |
50 | (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { | 50 | (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { |
51 | info("will use the device's hardware PID filter (table count: %d).", props->pid_filter_count); | 51 | info("will use the device's hardware PID filter (table count: %d).", props->pid_filter_count); |
52 | adap->fe_adap[o].pid_filtering = 1; | 52 | adap->fe_adap[o].pid_filtering = 1; |
53 | adap->fe_adap[o].max_feed_count = props->pid_filter_count; | 53 | adap->fe_adap[o].max_feed_count = props->pid_filter_count; |
54 | } else { | 54 | } else { |
55 | info("will pass the complete MPEG2 transport stream to the software demuxer."); | 55 | info("will pass the complete MPEG2 transport stream to the software demuxer."); |
56 | adap->fe_adap[o].pid_filtering = 0; | 56 | adap->fe_adap[o].pid_filtering = 0; |
57 | adap->fe_adap[o].max_feed_count = 255; | 57 | adap->fe_adap[o].max_feed_count = 255; |
58 | } | 58 | } |
59 | 59 | ||
60 | if (!adap->fe_adap[o].pid_filtering && | 60 | if (!adap->fe_adap[o].pid_filtering && |
61 | dvb_usb_force_pid_filter_usage && | 61 | dvb_usb_force_pid_filter_usage && |
62 | props->caps & DVB_USB_ADAP_HAS_PID_FILTER) { | 62 | props->caps & DVB_USB_ADAP_HAS_PID_FILTER) { |
63 | info("pid filter enabled by module option."); | 63 | info("pid filter enabled by module option."); |
64 | adap->fe_adap[o].pid_filtering = 1; | 64 | adap->fe_adap[o].pid_filtering = 1; |
65 | adap->fe_adap[o].max_feed_count = props->pid_filter_count; | 65 | adap->fe_adap[o].max_feed_count = props->pid_filter_count; |
66 | } | 66 | } |
67 | 67 | ||
68 | if (props->size_of_priv > 0) { | 68 | if (props->size_of_priv > 0) { |
69 | adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL); | 69 | adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL); |
70 | if (adap->fe_adap[o].priv == NULL) { | 70 | if (adap->fe_adap[o].priv == NULL) { |
71 | err("no memory for priv for adapter %d fe %d.", n, o); | 71 | err("no memory for priv for adapter %d fe %d.", n, o); |
72 | return -ENOMEM; | 72 | return -ENOMEM; |
73 | } | ||
73 | } | 74 | } |
74 | } | 75 | } |
75 | } | ||
76 | 76 | ||
77 | if (adap->props.size_of_priv > 0) { | 77 | if (adap->props.size_of_priv > 0) { |
78 | adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL); | 78 | adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL); |
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c index 9382895b1b88..9578a6761f1b 100644 --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* DVB USB framework compliant Linux driver for the | 1 | /* DVB USB framework compliant Linux driver for the |
2 | * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, | 2 | * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, |
3 | * TeVii S600, S630, S650, S660, S480, | 3 | * TeVii S600, S630, S650, S660, S480, S421, S632 |
4 | * Prof 1100, 7500, | 4 | * Prof 1100, 7500, |
5 | * Geniatech SU3000 Cards | 5 | * Geniatech SU3000 Cards |
6 | * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by) | 6 | * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
@@ -22,11 +22,14 @@ | |||
22 | #include "tda1002x.h" | 22 | #include "tda1002x.h" |
23 | #include "mt312.h" | 23 | #include "mt312.h" |
24 | #include "zl10039.h" | 24 | #include "zl10039.h" |
25 | #include "ts2020.h" | ||
25 | #include "ds3000.h" | 26 | #include "ds3000.h" |
26 | #include "stv0900.h" | 27 | #include "stv0900.h" |
27 | #include "stv6110.h" | 28 | #include "stv6110.h" |
28 | #include "stb6100.h" | 29 | #include "stb6100.h" |
29 | #include "stb6100_proc.h" | 30 | #include "stb6100_proc.h" |
31 | #include "m88rs2000.h" | ||
32 | #include "ts2020.h" | ||
30 | 33 | ||
31 | #ifndef USB_PID_DW2102 | 34 | #ifndef USB_PID_DW2102 |
32 | #define USB_PID_DW2102 0x2102 | 35 | #define USB_PID_DW2102 0x2102 |
@@ -68,6 +71,14 @@ | |||
68 | #define USB_PID_PROF_1100 0xb012 | 71 | #define USB_PID_PROF_1100 0xb012 |
69 | #endif | 72 | #endif |
70 | 73 | ||
74 | #ifndef USB_PID_TEVII_S421 | ||
75 | #define USB_PID_TEVII_S421 0xd421 | ||
76 | #endif | ||
77 | |||
78 | #ifndef USB_PID_TEVII_S632 | ||
79 | #define USB_PID_TEVII_S632 0xd632 | ||
80 | #endif | ||
81 | |||
71 | #define DW210X_READ_MSG 0 | 82 | #define DW210X_READ_MSG 0 |
72 | #define DW210X_WRITE_MSG 1 | 83 | #define DW210X_WRITE_MSG 1 |
73 | 84 | ||
@@ -80,6 +91,15 @@ | |||
80 | #define DW2102_RC_QUERY (0x1a00) | 91 | #define DW2102_RC_QUERY (0x1a00) |
81 | #define DW2102_LED_CTRL (0x1b00) | 92 | #define DW2102_LED_CTRL (0x1b00) |
82 | 93 | ||
94 | #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" | ||
95 | #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" | ||
96 | #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" | ||
97 | #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" | ||
98 | #define S630_FIRMWARE "dvb-usb-s630.fw" | ||
99 | #define S660_FIRMWARE "dvb-usb-s660.fw" | ||
100 | #define P1100_FIRMWARE "dvb-usb-p1100.fw" | ||
101 | #define P7500_FIRMWARE "dvb-usb-p7500.fw" | ||
102 | |||
83 | #define err_str "did not find the firmware file. (%s) " \ | 103 | #define err_str "did not find the firmware file. (%s) " \ |
84 | "Please see linux/Documentation/dvb/ for more details " \ | 104 | "Please see linux/Documentation/dvb/ for more details " \ |
85 | "on firmware-problems." | 105 | "on firmware-problems." |
@@ -534,7 +554,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
534 | } | 554 | } |
535 | /*case 0x55: cx24116 | 555 | /*case 0x55: cx24116 |
536 | case 0x6a: stv0903 | 556 | case 0x6a: stv0903 |
537 | case 0x68: ds3000, stv0903 | 557 | case 0x68: ds3000, stv0903, rs2000 |
538 | case 0x60: ts2020, stv6110, stb6100 | 558 | case 0x60: ts2020, stv6110, stb6100 |
539 | case 0xa0: eeprom */ | 559 | case 0xa0: eeprom */ |
540 | default: { | 560 | default: { |
@@ -932,6 +952,17 @@ static struct ds3000_config dw2104_ds3000_config = { | |||
932 | .demod_address = 0x68, | 952 | .demod_address = 0x68, |
933 | }; | 953 | }; |
934 | 954 | ||
955 | static struct ts2020_config dw2104_ts2020_config = { | ||
956 | .tuner_address = 0x60, | ||
957 | .clk_out_div = 1, | ||
958 | }; | ||
959 | |||
960 | static struct ds3000_config s660_ds3000_config = { | ||
961 | .demod_address = 0x68, | ||
962 | .ci_mode = 1, | ||
963 | .set_lock_led = dw210x_led_ctrl, | ||
964 | }; | ||
965 | |||
935 | static struct stv0900_config dw2104a_stv0900_config = { | 966 | static struct stv0900_config dw2104a_stv0900_config = { |
936 | .demod_address = 0x6a, | 967 | .demod_address = 0x6a, |
937 | .demod_mode = 0, | 968 | .demod_mode = 0, |
@@ -981,6 +1012,30 @@ static struct stv0900_config prof_7500_stv0900_config = { | |||
981 | static struct ds3000_config su3000_ds3000_config = { | 1012 | static struct ds3000_config su3000_ds3000_config = { |
982 | .demod_address = 0x68, | 1013 | .demod_address = 0x68, |
983 | .ci_mode = 1, | 1014 | .ci_mode = 1, |
1015 | .set_lock_led = dw210x_led_ctrl, | ||
1016 | }; | ||
1017 | |||
1018 | static u8 m88rs2000_inittab[] = { | ||
1019 | DEMOD_WRITE, 0x9a, 0x30, | ||
1020 | DEMOD_WRITE, 0x00, 0x01, | ||
1021 | WRITE_DELAY, 0x19, 0x00, | ||
1022 | DEMOD_WRITE, 0x00, 0x00, | ||
1023 | DEMOD_WRITE, 0x9a, 0xb0, | ||
1024 | DEMOD_WRITE, 0x81, 0xc1, | ||
1025 | DEMOD_WRITE, 0x81, 0x81, | ||
1026 | DEMOD_WRITE, 0x86, 0xc6, | ||
1027 | DEMOD_WRITE, 0x9a, 0x30, | ||
1028 | DEMOD_WRITE, 0xf0, 0x80, | ||
1029 | DEMOD_WRITE, 0xf1, 0xbf, | ||
1030 | DEMOD_WRITE, 0xb0, 0x45, | ||
1031 | DEMOD_WRITE, 0xb2, 0x01, | ||
1032 | DEMOD_WRITE, 0x9a, 0xb0, | ||
1033 | 0xff, 0xaa, 0xff | ||
1034 | }; | ||
1035 | |||
1036 | static struct m88rs2000_config s421_m88rs2000_config = { | ||
1037 | .demod_addr = 0x68, | ||
1038 | .inittab = m88rs2000_inittab, | ||
984 | }; | 1039 | }; |
985 | 1040 | ||
986 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) | 1041 | static int dw2104_frontend_attach(struct dvb_usb_adapter *d) |
@@ -1033,6 +1088,8 @@ static int dw2104_frontend_attach(struct dvb_usb_adapter *d) | |||
1033 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, | 1088 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, |
1034 | &d->dev->i2c_adap); | 1089 | &d->dev->i2c_adap); |
1035 | if (d->fe_adap[0].fe != NULL) { | 1090 | if (d->fe_adap[0].fe != NULL) { |
1091 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, | ||
1092 | &dw2104_ts2020_config, &d->dev->i2c_adap); | ||
1036 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; | 1093 | d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; |
1037 | info("Attached DS3000!\n"); | 1094 | info("Attached DS3000!\n"); |
1038 | return 0; | 1095 | return 0; |
@@ -1139,12 +1196,15 @@ static int ds3000_frontend_attach(struct dvb_usb_adapter *d) | |||
1139 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; | 1196 | struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; |
1140 | u8 obuf[] = {7, 1}; | 1197 | u8 obuf[] = {7, 1}; |
1141 | 1198 | ||
1142 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, | 1199 | d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config, |
1143 | &d->dev->i2c_adap); | 1200 | &d->dev->i2c_adap); |
1144 | 1201 | ||
1145 | if (d->fe_adap[0].fe == NULL) | 1202 | if (d->fe_adap[0].fe == NULL) |
1146 | return -EIO; | 1203 | return -EIO; |
1147 | 1204 | ||
1205 | dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config, | ||
1206 | &d->dev->i2c_adap); | ||
1207 | |||
1148 | st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; | 1208 | st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; |
1149 | d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; | 1209 | d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; |
1150 | 1210 | ||
@@ -1182,6 +1242,14 @@ static int su3000_frontend_attach(struct dvb_usb_adapter *d) | |||
1182 | err("command 0x0e transfer failed."); | 1242 | err("command 0x0e transfer failed."); |
1183 | 1243 | ||
1184 | obuf[0] = 0xe; | 1244 | obuf[0] = 0xe; |
1245 | obuf[1] = 0x02; | ||
1246 | obuf[2] = 1; | ||
1247 | |||
1248 | if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) | ||
1249 | err("command 0x0e transfer failed."); | ||
1250 | msleep(300); | ||
1251 | |||
1252 | obuf[0] = 0xe; | ||
1185 | obuf[1] = 0x83; | 1253 | obuf[1] = 0x83; |
1186 | obuf[2] = 0; | 1254 | obuf[2] = 0; |
1187 | 1255 | ||
@@ -1205,9 +1273,40 @@ static int su3000_frontend_attach(struct dvb_usb_adapter *d) | |||
1205 | if (d->fe_adap[0].fe == NULL) | 1273 | if (d->fe_adap[0].fe == NULL) |
1206 | return -EIO; | 1274 | return -EIO; |
1207 | 1275 | ||
1208 | info("Attached DS3000!\n"); | 1276 | if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, |
1277 | &dw2104_ts2020_config, | ||
1278 | &d->dev->i2c_adap)) { | ||
1279 | info("Attached DS3000/TS2020!\n"); | ||
1280 | return 0; | ||
1281 | } | ||
1209 | 1282 | ||
1210 | return 0; | 1283 | info("Failed to attach DS3000/TS2020!\n"); |
1284 | return -EIO; | ||
1285 | } | ||
1286 | |||
1287 | static int m88rs2000_frontend_attach(struct dvb_usb_adapter *d) | ||
1288 | { | ||
1289 | u8 obuf[] = { 0x51 }; | ||
1290 | u8 ibuf[] = { 0 }; | ||
1291 | |||
1292 | if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) | ||
1293 | err("command 0x51 transfer failed."); | ||
1294 | |||
1295 | d->fe_adap[0].fe = dvb_attach(m88rs2000_attach, &s421_m88rs2000_config, | ||
1296 | &d->dev->i2c_adap); | ||
1297 | |||
1298 | if (d->fe_adap[0].fe == NULL) | ||
1299 | return -EIO; | ||
1300 | |||
1301 | if (dvb_attach(ts2020_attach, d->fe_adap[0].fe, | ||
1302 | &dw2104_ts2020_config, | ||
1303 | &d->dev->i2c_adap)) { | ||
1304 | info("Attached RS2000/TS2020!\n"); | ||
1305 | return 0; | ||
1306 | } | ||
1307 | |||
1308 | info("Failed to attach RS2000/TS2020!\n"); | ||
1309 | return -EIO; | ||
1211 | } | 1310 | } |
1212 | 1311 | ||
1213 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) | 1312 | static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) |
@@ -1447,6 +1546,8 @@ enum dw2102_table_entry { | |||
1447 | TEVII_S480_1, | 1546 | TEVII_S480_1, |
1448 | TEVII_S480_2, | 1547 | TEVII_S480_2, |
1449 | X3M_SPC1400HD, | 1548 | X3M_SPC1400HD, |
1549 | TEVII_S421, | ||
1550 | TEVII_S632, | ||
1450 | }; | 1551 | }; |
1451 | 1552 | ||
1452 | static struct usb_device_id dw2102_table[] = { | 1553 | static struct usb_device_id dw2102_table[] = { |
@@ -1465,6 +1566,8 @@ static struct usb_device_id dw2102_table[] = { | |||
1465 | [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, | 1566 | [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, |
1466 | [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, | 1567 | [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, |
1467 | [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, | 1568 | [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, |
1569 | [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)}, | ||
1570 | [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)}, | ||
1468 | { } | 1571 | { } |
1469 | }; | 1572 | }; |
1470 | 1573 | ||
@@ -1478,13 +1581,12 @@ static int dw2102_load_firmware(struct usb_device *dev, | |||
1478 | u8 reset; | 1581 | u8 reset; |
1479 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; | 1582 | u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; |
1480 | const struct firmware *fw; | 1583 | const struct firmware *fw; |
1481 | const char *fw_2101 = "dvb-usb-dw2101.fw"; | ||
1482 | 1584 | ||
1483 | switch (dev->descriptor.idProduct) { | 1585 | switch (dev->descriptor.idProduct) { |
1484 | case 0x2101: | 1586 | case 0x2101: |
1485 | ret = request_firmware(&fw, fw_2101, &dev->dev); | 1587 | ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); |
1486 | if (ret != 0) { | 1588 | if (ret != 0) { |
1487 | err(err_str, fw_2101); | 1589 | err(err_str, DW2101_FIRMWARE); |
1488 | return ret; | 1590 | return ret; |
1489 | } | 1591 | } |
1490 | break; | 1592 | break; |
@@ -1586,7 +1688,7 @@ static int dw2102_load_firmware(struct usb_device *dev, | |||
1586 | static struct dvb_usb_device_properties dw2102_properties = { | 1688 | static struct dvb_usb_device_properties dw2102_properties = { |
1587 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1689 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1588 | .usb_ctrl = DEVICE_SPECIFIC, | 1690 | .usb_ctrl = DEVICE_SPECIFIC, |
1589 | .firmware = "dvb-usb-dw2102.fw", | 1691 | .firmware = DW2102_FIRMWARE, |
1590 | .no_reconnect = 1, | 1692 | .no_reconnect = 1, |
1591 | 1693 | ||
1592 | .i2c_algo = &dw2102_serit_i2c_algo, | 1694 | .i2c_algo = &dw2102_serit_i2c_algo, |
@@ -1641,7 +1743,7 @@ static struct dvb_usb_device_properties dw2102_properties = { | |||
1641 | static struct dvb_usb_device_properties dw2104_properties = { | 1743 | static struct dvb_usb_device_properties dw2104_properties = { |
1642 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1744 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1643 | .usb_ctrl = DEVICE_SPECIFIC, | 1745 | .usb_ctrl = DEVICE_SPECIFIC, |
1644 | .firmware = "dvb-usb-dw2104.fw", | 1746 | .firmware = DW2104_FIRMWARE, |
1645 | .no_reconnect = 1, | 1747 | .no_reconnect = 1, |
1646 | 1748 | ||
1647 | .i2c_algo = &dw2104_i2c_algo, | 1749 | .i2c_algo = &dw2104_i2c_algo, |
@@ -1691,7 +1793,7 @@ static struct dvb_usb_device_properties dw2104_properties = { | |||
1691 | static struct dvb_usb_device_properties dw3101_properties = { | 1793 | static struct dvb_usb_device_properties dw3101_properties = { |
1692 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1794 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1693 | .usb_ctrl = DEVICE_SPECIFIC, | 1795 | .usb_ctrl = DEVICE_SPECIFIC, |
1694 | .firmware = "dvb-usb-dw3101.fw", | 1796 | .firmware = DW3101_FIRMWARE, |
1695 | .no_reconnect = 1, | 1797 | .no_reconnect = 1, |
1696 | 1798 | ||
1697 | .i2c_algo = &dw3101_i2c_algo, | 1799 | .i2c_algo = &dw3101_i2c_algo, |
@@ -1739,7 +1841,7 @@ static struct dvb_usb_device_properties s6x0_properties = { | |||
1739 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1841 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1740 | .usb_ctrl = DEVICE_SPECIFIC, | 1842 | .usb_ctrl = DEVICE_SPECIFIC, |
1741 | .size_of_priv = sizeof(struct s6x0_state), | 1843 | .size_of_priv = sizeof(struct s6x0_state), |
1742 | .firmware = "dvb-usb-s630.fw", | 1844 | .firmware = S630_FIRMWARE, |
1743 | .no_reconnect = 1, | 1845 | .no_reconnect = 1, |
1744 | 1846 | ||
1745 | .i2c_algo = &s6x0_i2c_algo, | 1847 | .i2c_algo = &s6x0_i2c_algo, |
@@ -1814,6 +1916,19 @@ static struct dvb_usb_device_description d7500 = { | |||
1814 | {NULL}, | 1916 | {NULL}, |
1815 | }; | 1917 | }; |
1816 | 1918 | ||
1919 | struct dvb_usb_device_properties *s421; | ||
1920 | static struct dvb_usb_device_description d421 = { | ||
1921 | "TeVii S421 PCI", | ||
1922 | {&dw2102_table[TEVII_S421], NULL}, | ||
1923 | {NULL}, | ||
1924 | }; | ||
1925 | |||
1926 | static struct dvb_usb_device_description d632 = { | ||
1927 | "TeVii S632 USB", | ||
1928 | {&dw2102_table[TEVII_S632], NULL}, | ||
1929 | {NULL}, | ||
1930 | }; | ||
1931 | |||
1817 | static struct dvb_usb_device_properties su3000_properties = { | 1932 | static struct dvb_usb_device_properties su3000_properties = { |
1818 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | 1933 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
1819 | .usb_ctrl = DEVICE_SPECIFIC, | 1934 | .usb_ctrl = DEVICE_SPECIFIC, |
@@ -1879,7 +1994,7 @@ static int dw2102_probe(struct usb_interface *intf, | |||
1879 | return -ENOMEM; | 1994 | return -ENOMEM; |
1880 | /* copy default structure */ | 1995 | /* copy default structure */ |
1881 | /* fill only different fields */ | 1996 | /* fill only different fields */ |
1882 | p1100->firmware = "dvb-usb-p1100.fw"; | 1997 | p1100->firmware = P1100_FIRMWARE; |
1883 | p1100->devices[0] = d1100; | 1998 | p1100->devices[0] = d1100; |
1884 | p1100->rc.legacy.rc_map_table = rc_map_tbs_table; | 1999 | p1100->rc.legacy.rc_map_table = rc_map_tbs_table; |
1885 | p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); | 2000 | p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
@@ -1891,7 +2006,7 @@ static int dw2102_probe(struct usb_interface *intf, | |||
1891 | kfree(p1100); | 2006 | kfree(p1100); |
1892 | return -ENOMEM; | 2007 | return -ENOMEM; |
1893 | } | 2008 | } |
1894 | s660->firmware = "dvb-usb-s660.fw"; | 2009 | s660->firmware = S660_FIRMWARE; |
1895 | s660->num_device_descs = 3; | 2010 | s660->num_device_descs = 3; |
1896 | s660->devices[0] = d660; | 2011 | s660->devices[0] = d660; |
1897 | s660->devices[1] = d480_1; | 2012 | s660->devices[1] = d480_1; |
@@ -1905,12 +2020,26 @@ static int dw2102_probe(struct usb_interface *intf, | |||
1905 | kfree(s660); | 2020 | kfree(s660); |
1906 | return -ENOMEM; | 2021 | return -ENOMEM; |
1907 | } | 2022 | } |
1908 | p7500->firmware = "dvb-usb-p7500.fw"; | 2023 | p7500->firmware = P7500_FIRMWARE; |
1909 | p7500->devices[0] = d7500; | 2024 | p7500->devices[0] = d7500; |
1910 | p7500->rc.legacy.rc_map_table = rc_map_tbs_table; | 2025 | p7500->rc.legacy.rc_map_table = rc_map_tbs_table; |
1911 | p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); | 2026 | p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); |
1912 | p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; | 2027 | p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; |
1913 | 2028 | ||
2029 | |||
2030 | s421 = kmemdup(&su3000_properties, | ||
2031 | sizeof(struct dvb_usb_device_properties), GFP_KERNEL); | ||
2032 | if (!s421) { | ||
2033 | kfree(p1100); | ||
2034 | kfree(s660); | ||
2035 | kfree(p7500); | ||
2036 | return -ENOMEM; | ||
2037 | } | ||
2038 | s421->num_device_descs = 2; | ||
2039 | s421->devices[0] = d421; | ||
2040 | s421->devices[1] = d632; | ||
2041 | s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach; | ||
2042 | |||
1914 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, | 2043 | if (0 == dvb_usb_device_init(intf, &dw2102_properties, |
1915 | THIS_MODULE, NULL, adapter_nr) || | 2044 | THIS_MODULE, NULL, adapter_nr) || |
1916 | 0 == dvb_usb_device_init(intf, &dw2104_properties, | 2045 | 0 == dvb_usb_device_init(intf, &dw2104_properties, |
@@ -1925,6 +2054,8 @@ static int dw2102_probe(struct usb_interface *intf, | |||
1925 | THIS_MODULE, NULL, adapter_nr) || | 2054 | THIS_MODULE, NULL, adapter_nr) || |
1926 | 0 == dvb_usb_device_init(intf, p7500, | 2055 | 0 == dvb_usb_device_init(intf, p7500, |
1927 | THIS_MODULE, NULL, adapter_nr) || | 2056 | THIS_MODULE, NULL, adapter_nr) || |
2057 | 0 == dvb_usb_device_init(intf, s421, | ||
2058 | THIS_MODULE, NULL, adapter_nr) || | ||
1928 | 0 == dvb_usb_device_init(intf, &su3000_properties, | 2059 | 0 == dvb_usb_device_init(intf, &su3000_properties, |
1929 | THIS_MODULE, NULL, adapter_nr)) | 2060 | THIS_MODULE, NULL, adapter_nr)) |
1930 | return 0; | 2061 | return 0; |
@@ -1943,9 +2074,17 @@ module_usb_driver(dw2102_driver); | |||
1943 | 2074 | ||
1944 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); | 2075 | MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); |
1945 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," | 2076 | MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," |
1946 | " DVB-C 3101 USB2.0," | 2077 | " DVB-C 3101 USB2.0," |
1947 | " TeVii S600, S630, S650, S660, S480," | 2078 | " TeVii S600, S630, S650, S660, S480, S421, S632" |
1948 | " Prof 1100, 7500 USB2.0," | 2079 | " Prof 1100, 7500 USB2.0," |
1949 | " Geniatech SU3000 devices"); | 2080 | " Geniatech SU3000 devices"); |
1950 | MODULE_VERSION("0.1"); | 2081 | MODULE_VERSION("0.1"); |
1951 | MODULE_LICENSE("GPL"); | 2082 | MODULE_LICENSE("GPL"); |
2083 | MODULE_FIRMWARE(DW2101_FIRMWARE); | ||
2084 | MODULE_FIRMWARE(DW2102_FIRMWARE); | ||
2085 | MODULE_FIRMWARE(DW2104_FIRMWARE); | ||
2086 | MODULE_FIRMWARE(DW3101_FIRMWARE); | ||
2087 | MODULE_FIRMWARE(S630_FIRMWARE); | ||
2088 | MODULE_FIRMWARE(S660_FIRMWARE); | ||
2089 | MODULE_FIRMWARE(P1100_FIRMWARE); | ||
2090 | MODULE_FIRMWARE(P7500_FIRMWARE); | ||
diff --git a/drivers/media/usb/dvb-usb/friio-fe.c b/drivers/media/usb/dvb-usb/friio-fe.c index 90a70c66a96e..d56f927fc31a 100644 --- a/drivers/media/usb/dvb-usb/friio-fe.c +++ b/drivers/media/usb/dvb-usb/friio-fe.c | |||
@@ -421,11 +421,10 @@ struct dvb_frontend *jdvbt90502_attach(struct dvb_usb_device *d) | |||
421 | 421 | ||
422 | /* setup the state */ | 422 | /* setup the state */ |
423 | state->i2c = &d->i2c_adap; | 423 | state->i2c = &d->i2c_adap; |
424 | memcpy(&state->config, &friio_fe_config, sizeof(friio_fe_config)); | 424 | state->config = friio_fe_config; |
425 | 425 | ||
426 | /* create dvb_frontend */ | 426 | /* create dvb_frontend */ |
427 | memcpy(&state->frontend.ops, &jdvbt90502_ops, | 427 | state->frontend.ops = jdvbt90502_ops; |
428 | sizeof(jdvbt90502_ops)); | ||
429 | state->frontend.demodulator_priv = state; | 428 | state->frontend.demodulator_priv = state; |
430 | 429 | ||
431 | if (jdvbt90502_init(&state->frontend) < 0) | 430 | if (jdvbt90502_init(&state->frontend) < 0) |
diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c index 661bb75be955..92afeb20650f 100644 --- a/drivers/media/usb/dvb-usb/m920x.c +++ b/drivers/media/usb/dvb-usb/m920x.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include "qt1010.h" | 16 | #include "qt1010.h" |
17 | #include "tda1004x.h" | 17 | #include "tda1004x.h" |
18 | #include "tda827x.h" | 18 | #include "tda827x.h" |
19 | #include "mt2060.h" | ||
19 | 20 | ||
20 | #include <media/tuner.h> | 21 | #include <media/tuner.h> |
21 | #include "tuner-simple.h" | 22 | #include "tuner-simple.h" |
@@ -63,23 +64,33 @@ static inline int m920x_write(struct usb_device *udev, u8 request, | |||
63 | return ret; | 64 | return ret; |
64 | } | 65 | } |
65 | 66 | ||
67 | static inline int m920x_write_seq(struct usb_device *udev, u8 request, | ||
68 | struct m920x_inits *seq) | ||
69 | { | ||
70 | int ret; | ||
71 | while (seq->address) { | ||
72 | ret = m920x_write(udev, request, seq->data, seq->address); | ||
73 | if (ret != 0) | ||
74 | return ret; | ||
75 | |||
76 | seq++; | ||
77 | } | ||
78 | |||
79 | return ret; | ||
80 | } | ||
81 | |||
66 | static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) | 82 | static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq) |
67 | { | 83 | { |
68 | int ret = 0, i, epi, flags = 0; | 84 | int ret = 0, i, epi, flags = 0; |
69 | int adap_enabled[M9206_MAX_ADAPTERS] = { 0 }; | 85 | int adap_enabled[M9206_MAX_ADAPTERS] = { 0 }; |
70 | 86 | ||
71 | /* Remote controller init. */ | 87 | /* Remote controller init. */ |
72 | if (d->props.rc.legacy.rc_query) { | 88 | if (d->props.rc.legacy.rc_query || d->props.rc.core.rc_query) { |
73 | deb("Initialising remote control\n"); | 89 | deb("Initialising remote control\n"); |
74 | while (rc_seq->address) { | 90 | ret = m920x_write_seq(d->udev, M9206_CORE, rc_seq); |
75 | if ((ret = m920x_write(d->udev, M9206_CORE, | 91 | if (ret != 0) { |
76 | rc_seq->data, | 92 | deb("Initialising remote control failed\n"); |
77 | rc_seq->address)) != 0) { | 93 | return ret; |
78 | deb("Initialising remote control failed\n"); | ||
79 | return ret; | ||
80 | } | ||
81 | |||
82 | rc_seq++; | ||
83 | } | 94 | } |
84 | 95 | ||
85 | deb("Initialising remote control success\n"); | 96 | deb("Initialising remote control success\n"); |
@@ -130,9 +141,50 @@ static int m920x_init_ep(struct usb_interface *intf) | |||
130 | alt->desc.bAlternateSetting); | 141 | alt->desc.bAlternateSetting); |
131 | } | 142 | } |
132 | 143 | ||
133 | static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 144 | static inline void m920x_parse_rc_state(struct dvb_usb_device *d, u8 rc_state, |
145 | int *state) | ||
134 | { | 146 | { |
135 | struct m920x_state *m = d->priv; | 147 | struct m920x_state *m = d->priv; |
148 | |||
149 | switch (rc_state) { | ||
150 | case 0x80: | ||
151 | *state = REMOTE_NO_KEY_PRESSED; | ||
152 | break; | ||
153 | |||
154 | case 0x88: /* framing error or "invalid code" */ | ||
155 | case 0x99: | ||
156 | case 0xc0: | ||
157 | case 0xd8: | ||
158 | *state = REMOTE_NO_KEY_PRESSED; | ||
159 | m->rep_count = 0; | ||
160 | break; | ||
161 | |||
162 | case 0x93: | ||
163 | case 0x92: | ||
164 | case 0x83: /* pinnacle PCTV310e */ | ||
165 | case 0x82: | ||
166 | m->rep_count = 0; | ||
167 | *state = REMOTE_KEY_PRESSED; | ||
168 | break; | ||
169 | |||
170 | case 0x91: | ||
171 | case 0x81: /* pinnacle PCTV310e */ | ||
172 | /* prevent immediate auto-repeat */ | ||
173 | if (++m->rep_count > 2) | ||
174 | *state = REMOTE_KEY_REPEAT; | ||
175 | else | ||
176 | *state = REMOTE_NO_KEY_PRESSED; | ||
177 | break; | ||
178 | |||
179 | default: | ||
180 | deb("Unexpected rc state %02x\n", rc_state); | ||
181 | *state = REMOTE_NO_KEY_PRESSED; | ||
182 | break; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | ||
187 | { | ||
136 | int i, ret = 0; | 188 | int i, ret = 0; |
137 | u8 *rc_state; | 189 | u8 *rc_state; |
138 | 190 | ||
@@ -140,51 +192,22 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
140 | if (!rc_state) | 192 | if (!rc_state) |
141 | return -ENOMEM; | 193 | return -ENOMEM; |
142 | 194 | ||
143 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) | 195 | ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, |
196 | rc_state, 1); | ||
197 | if (ret != 0) | ||
144 | goto out; | 198 | goto out; |
145 | 199 | ||
146 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) | 200 | ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, |
201 | rc_state + 1, 1); | ||
202 | if (ret != 0) | ||
147 | goto out; | 203 | goto out; |
148 | 204 | ||
205 | m920x_parse_rc_state(d, rc_state[0], state); | ||
206 | |||
149 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) | 207 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) |
150 | if (rc5_data(&d->props.rc.legacy.rc_map_table[i]) == rc_state[1]) { | 208 | if (rc5_data(&d->props.rc.legacy.rc_map_table[i]) == rc_state[1]) { |
151 | *event = d->props.rc.legacy.rc_map_table[i].keycode; | 209 | *event = d->props.rc.legacy.rc_map_table[i].keycode; |
152 | 210 | goto out; | |
153 | switch(rc_state[0]) { | ||
154 | case 0x80: | ||
155 | *state = REMOTE_NO_KEY_PRESSED; | ||
156 | goto out; | ||
157 | |||
158 | case 0x88: /* framing error or "invalid code" */ | ||
159 | case 0x99: | ||
160 | case 0xc0: | ||
161 | case 0xd8: | ||
162 | *state = REMOTE_NO_KEY_PRESSED; | ||
163 | m->rep_count = 0; | ||
164 | goto out; | ||
165 | |||
166 | case 0x93: | ||
167 | case 0x92: | ||
168 | case 0x83: /* pinnacle PCTV310e */ | ||
169 | case 0x82: | ||
170 | m->rep_count = 0; | ||
171 | *state = REMOTE_KEY_PRESSED; | ||
172 | goto out; | ||
173 | |||
174 | case 0x91: | ||
175 | case 0x81: /* pinnacle PCTV310e */ | ||
176 | /* prevent immediate auto-repeat */ | ||
177 | if (++m->rep_count > 2) | ||
178 | *state = REMOTE_KEY_REPEAT; | ||
179 | else | ||
180 | *state = REMOTE_NO_KEY_PRESSED; | ||
181 | goto out; | ||
182 | |||
183 | default: | ||
184 | deb("Unexpected rc state %02x\n", rc_state[0]); | ||
185 | *state = REMOTE_NO_KEY_PRESSED; | ||
186 | goto out; | ||
187 | } | ||
188 | } | 211 | } |
189 | 212 | ||
190 | if (rc_state[1] != 0) | 213 | if (rc_state[1] != 0) |
@@ -197,6 +220,38 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
197 | return ret; | 220 | return ret; |
198 | } | 221 | } |
199 | 222 | ||
223 | static int m920x_rc_core_query(struct dvb_usb_device *d) | ||
224 | { | ||
225 | int ret = 0; | ||
226 | u8 *rc_state; | ||
227 | int state; | ||
228 | |||
229 | rc_state = kmalloc(2, GFP_KERNEL); | ||
230 | if (!rc_state) | ||
231 | return -ENOMEM; | ||
232 | |||
233 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, &rc_state[0], 1)) != 0) | ||
234 | goto out; | ||
235 | |||
236 | if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, &rc_state[1], 1)) != 0) | ||
237 | goto out; | ||
238 | |||
239 | deb("state=0x%02x keycode=0x%02x\n", rc_state[0], rc_state[1]); | ||
240 | |||
241 | m920x_parse_rc_state(d, rc_state[0], &state); | ||
242 | |||
243 | if (state == REMOTE_NO_KEY_PRESSED) | ||
244 | rc_keyup(d->rc_dev); | ||
245 | else if (state == REMOTE_KEY_REPEAT) | ||
246 | rc_repeat(d->rc_dev); | ||
247 | else | ||
248 | rc_keydown(d->rc_dev, rc_state[1], 0); | ||
249 | |||
250 | out: | ||
251 | kfree(rc_state); | ||
252 | return ret; | ||
253 | } | ||
254 | |||
200 | /* I2C */ | 255 | /* I2C */ |
201 | static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) | 256 | static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) |
202 | { | 257 | { |
@@ -496,6 +551,12 @@ static struct qt1010_config m920x_qt1010_config = { | |||
496 | .i2c_address = 0x62 | 551 | .i2c_address = 0x62 |
497 | }; | 552 | }; |
498 | 553 | ||
554 | static struct mt2060_config m920x_mt2060_config = { | ||
555 | .i2c_address = 0x60, /* 0xc0 */ | ||
556 | .clock_out = 0, | ||
557 | }; | ||
558 | |||
559 | |||
499 | /* Callbacks for DVB USB */ | 560 | /* Callbacks for DVB USB */ |
500 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | 561 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) |
501 | { | 562 | { |
@@ -510,6 +571,37 @@ static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | |||
510 | return 0; | 571 | return 0; |
511 | } | 572 | } |
512 | 573 | ||
574 | static int m920x_mt352_frontend_attach_vp7049(struct dvb_usb_adapter *adap) | ||
575 | { | ||
576 | struct m920x_inits vp7049_fe_init_seq[] = { | ||
577 | /* XXX without these commands the frontend cannot be detected, | ||
578 | * they must be sent BEFORE the frontend is attached */ | ||
579 | { 0xff28, 0x00 }, | ||
580 | { 0xff23, 0x00 }, | ||
581 | { 0xff28, 0x00 }, | ||
582 | { 0xff23, 0x00 }, | ||
583 | { 0xff21, 0x20 }, | ||
584 | { 0xff21, 0x60 }, | ||
585 | { 0xff28, 0x00 }, | ||
586 | { 0xff22, 0x00 }, | ||
587 | { 0xff20, 0x30 }, | ||
588 | { 0xff20, 0x20 }, | ||
589 | { 0xff20, 0x30 }, | ||
590 | { } /* terminating entry */ | ||
591 | }; | ||
592 | int ret; | ||
593 | |||
594 | deb("%s\n", __func__); | ||
595 | |||
596 | ret = m920x_write_seq(adap->dev->udev, M9206_CORE, vp7049_fe_init_seq); | ||
597 | if (ret != 0) { | ||
598 | deb("Initialization of vp7049 frontend failed."); | ||
599 | return ret; | ||
600 | } | ||
601 | |||
602 | return m920x_mt352_frontend_attach(adap); | ||
603 | } | ||
604 | |||
513 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) | 605 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) |
514 | { | 606 | { |
515 | deb("%s\n",__func__); | 607 | deb("%s\n",__func__); |
@@ -574,6 +666,18 @@ static int m920x_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) | |||
574 | return 0; | 666 | return 0; |
575 | } | 667 | } |
576 | 668 | ||
669 | static int m920x_mt2060_tuner_attach(struct dvb_usb_adapter *adap) | ||
670 | { | ||
671 | deb("%s\n", __func__); | ||
672 | |||
673 | if (dvb_attach(mt2060_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, | ||
674 | &m920x_mt2060_config, 1220) == NULL) | ||
675 | return -ENODEV; | ||
676 | |||
677 | return 0; | ||
678 | } | ||
679 | |||
680 | |||
577 | /* device-specific initialization */ | 681 | /* device-specific initialization */ |
578 | static struct m920x_inits megasky_rc_init [] = { | 682 | static struct m920x_inits megasky_rc_init [] = { |
579 | { M9206_RC_INIT2, 0xa8 }, | 683 | { M9206_RC_INIT2, 0xa8 }, |
@@ -591,7 +695,7 @@ static struct m920x_inits tvwalkertwin_rc_init [] = { | |||
591 | }; | 695 | }; |
592 | 696 | ||
593 | static struct m920x_inits pinnacle310e_init[] = { | 697 | static struct m920x_inits pinnacle310e_init[] = { |
594 | /* without these the tuner don't work */ | 698 | /* without these the tuner doesn't work */ |
595 | { 0xff20, 0x9b }, | 699 | { 0xff20, 0x9b }, |
596 | { 0xff22, 0x70 }, | 700 | { 0xff22, 0x70 }, |
597 | 701 | ||
@@ -602,6 +706,15 @@ static struct m920x_inits pinnacle310e_init[] = { | |||
602 | { } /* terminating entry */ | 706 | { } /* terminating entry */ |
603 | }; | 707 | }; |
604 | 708 | ||
709 | static struct m920x_inits vp7049_rc_init[] = { | ||
710 | { 0xff28, 0x00 }, | ||
711 | { 0xff23, 0x00 }, | ||
712 | { 0xff21, 0x70 }, | ||
713 | { M9206_RC_INIT2, 0x00 }, | ||
714 | { M9206_RC_INIT1, 0xff }, | ||
715 | { } /* terminating entry */ | ||
716 | }; | ||
717 | |||
605 | /* ir keymaps */ | 718 | /* ir keymaps */ |
606 | static struct rc_map_table rc_map_megasky_table[] = { | 719 | static struct rc_map_table rc_map_megasky_table[] = { |
607 | { 0x0012, KEY_POWER }, | 720 | { 0x0012, KEY_POWER }, |
@@ -704,6 +817,7 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties; | |||
704 | static struct dvb_usb_device_properties tvwalkertwin_properties; | 817 | static struct dvb_usb_device_properties tvwalkertwin_properties; |
705 | static struct dvb_usb_device_properties dposh_properties; | 818 | static struct dvb_usb_device_properties dposh_properties; |
706 | static struct dvb_usb_device_properties pinnacle_pctv310e_properties; | 819 | static struct dvb_usb_device_properties pinnacle_pctv310e_properties; |
820 | static struct dvb_usb_device_properties vp7049_properties; | ||
707 | 821 | ||
708 | static int m920x_probe(struct usb_interface *intf, | 822 | static int m920x_probe(struct usb_interface *intf, |
709 | const struct usb_device_id *id) | 823 | const struct usb_device_id *id) |
@@ -756,6 +870,13 @@ static int m920x_probe(struct usb_interface *intf, | |||
756 | goto found; | 870 | goto found; |
757 | } | 871 | } |
758 | 872 | ||
873 | ret = dvb_usb_device_init(intf, &vp7049_properties, | ||
874 | THIS_MODULE, &d, adapter_nr); | ||
875 | if (ret == 0) { | ||
876 | rc_init_seq = vp7049_rc_init; | ||
877 | goto found; | ||
878 | } | ||
879 | |||
759 | return ret; | 880 | return ret; |
760 | } else { | 881 | } else { |
761 | /* Another interface on a multi-tuner device */ | 882 | /* Another interface on a multi-tuner device */ |
@@ -787,6 +908,7 @@ static struct usb_device_id m920x_table [] = { | |||
787 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) }, | 908 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) }, |
788 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) }, | 909 | { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) }, |
789 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_PINNACLE_PCTV310E) }, | 910 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_PINNACLE_PCTV310E) }, |
911 | { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_TWINHAN_VP7049) }, | ||
790 | { } /* Terminating entry */ | 912 | { } /* Terminating entry */ |
791 | }; | 913 | }; |
792 | MODULE_DEVICE_TABLE (usb, m920x_table); | 914 | MODULE_DEVICE_TABLE (usb, m920x_table); |
@@ -1079,6 +1201,61 @@ static struct dvb_usb_device_properties pinnacle_pctv310e_properties = { | |||
1079 | } | 1201 | } |
1080 | }; | 1202 | }; |
1081 | 1203 | ||
1204 | static struct dvb_usb_device_properties vp7049_properties = { | ||
1205 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
1206 | |||
1207 | .usb_ctrl = DEVICE_SPECIFIC, | ||
1208 | .firmware = "dvb-usb-vp7049-0.95.fw", | ||
1209 | .download_firmware = m920x_firmware_download, | ||
1210 | |||
1211 | .rc.core = { | ||
1212 | .rc_interval = 150, | ||
1213 | .rc_codes = RC_MAP_TWINHAN_VP1027_DVBS, | ||
1214 | .rc_query = m920x_rc_core_query, | ||
1215 | .allowed_protos = RC_TYPE_UNKNOWN, | ||
1216 | }, | ||
1217 | |||
1218 | .size_of_priv = sizeof(struct m920x_state), | ||
1219 | |||
1220 | .identify_state = m920x_identify_state, | ||
1221 | .num_adapters = 1, | ||
1222 | .adapter = {{ | ||
1223 | .num_frontends = 1, | ||
1224 | .fe = {{ | ||
1225 | |||
1226 | .caps = DVB_USB_ADAP_HAS_PID_FILTER | | ||
1227 | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, | ||
1228 | |||
1229 | .pid_filter_count = 8, | ||
1230 | .pid_filter = m920x_pid_filter, | ||
1231 | .pid_filter_ctrl = m920x_pid_filter_ctrl, | ||
1232 | |||
1233 | .frontend_attach = m920x_mt352_frontend_attach_vp7049, | ||
1234 | .tuner_attach = m920x_mt2060_tuner_attach, | ||
1235 | |||
1236 | .stream = { | ||
1237 | .type = USB_BULK, | ||
1238 | .count = 8, | ||
1239 | .endpoint = 0x81, | ||
1240 | .u = { | ||
1241 | .bulk = { | ||
1242 | .buffersize = 512, | ||
1243 | } | ||
1244 | } | ||
1245 | }, | ||
1246 | } }, | ||
1247 | } }, | ||
1248 | .i2c_algo = &m920x_i2c_algo, | ||
1249 | |||
1250 | .num_device_descs = 1, | ||
1251 | .devices = { | ||
1252 | { "DTV-DVB UDTT7049", | ||
1253 | { &m920x_table[7], NULL }, | ||
1254 | { NULL }, | ||
1255 | } | ||
1256 | } | ||
1257 | }; | ||
1258 | |||
1082 | static struct usb_driver m920x_driver = { | 1259 | static struct usb_driver m920x_driver = { |
1083 | .name = "dvb_usb_m920x", | 1260 | .name = "dvb_usb_m920x", |
1084 | .probe = m920x_probe, | 1261 | .probe = m920x_probe, |
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c index bcdac225ebe1..2ce3d19c58ef 100644 --- a/drivers/media/usb/dvb-usb/ttusb2.c +++ b/drivers/media/usb/dvb-usb/ttusb2.c | |||
@@ -620,6 +620,8 @@ static struct usb_device_id ttusb2_table [] = { | |||
620 | USB_PID_TECHNOTREND_CONNECT_S2400) }, | 620 | USB_PID_TECHNOTREND_CONNECT_S2400) }, |
621 | { USB_DEVICE(USB_VID_TECHNOTREND, | 621 | { USB_DEVICE(USB_VID_TECHNOTREND, |
622 | USB_PID_TECHNOTREND_CONNECT_CT3650) }, | 622 | USB_PID_TECHNOTREND_CONNECT_CT3650) }, |
623 | { USB_DEVICE(USB_VID_TECHNOTREND, | ||
624 | USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) }, | ||
623 | {} /* Terminating entry */ | 625 | {} /* Terminating entry */ |
624 | }; | 626 | }; |
625 | MODULE_DEVICE_TABLE (usb, ttusb2_table); | 627 | MODULE_DEVICE_TABLE (usb, ttusb2_table); |
@@ -721,12 +723,16 @@ static struct dvb_usb_device_properties ttusb2_properties_s2400 = { | |||
721 | 723 | ||
722 | .generic_bulk_ctrl_endpoint = 0x01, | 724 | .generic_bulk_ctrl_endpoint = 0x01, |
723 | 725 | ||
724 | .num_device_descs = 1, | 726 | .num_device_descs = 2, |
725 | .devices = { | 727 | .devices = { |
726 | { "Technotrend TT-connect S-2400", | 728 | { "Technotrend TT-connect S-2400", |
727 | { &ttusb2_table[2], NULL }, | 729 | { &ttusb2_table[2], NULL }, |
728 | { NULL }, | 730 | { NULL }, |
729 | }, | 731 | }, |
732 | { "Technotrend TT-connect S-2400 (8kB EEPROM)", | ||
733 | { &ttusb2_table[4], NULL }, | ||
734 | { NULL }, | ||
735 | }, | ||
730 | } | 736 | } |
731 | }; | 737 | }; |
732 | 738 | ||
diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig index 7a5bd61bd3bb..c754a80a8d8b 100644 --- a/drivers/media/usb/em28xx/Kconfig +++ b/drivers/media/usb/em28xx/Kconfig | |||
@@ -3,7 +3,7 @@ config VIDEO_EM28XX | |||
3 | depends on VIDEO_DEV && I2C | 3 | depends on VIDEO_DEV && I2C |
4 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
5 | select VIDEO_TVEEPROM | 5 | select VIDEO_TVEEPROM |
6 | select VIDEOBUF_VMALLOC | 6 | select VIDEOBUF2_VMALLOC |
7 | select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT | 7 | select VIDEO_SAA711X if MEDIA_SUBDRV_AUTOSELECT |
8 | select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT | 8 | select VIDEO_TVP5150 if MEDIA_SUBDRV_AUTOSELECT |
9 | select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT | 9 | select VIDEO_MSP3400 if MEDIA_SUBDRV_AUTOSELECT |
@@ -34,6 +34,7 @@ config VIDEO_EM28XX_DVB | |||
34 | tristate "DVB/ATSC Support for em28xx based TV cards" | 34 | tristate "DVB/ATSC Support for em28xx based TV cards" |
35 | depends on VIDEO_EM28XX && DVB_CORE | 35 | depends on VIDEO_EM28XX && DVB_CORE |
36 | select DVB_LGDT330X if MEDIA_SUBDRV_AUTOSELECT | 36 | select DVB_LGDT330X if MEDIA_SUBDRV_AUTOSELECT |
37 | select DVB_LGDT3305 if MEDIA_SUBDRV_AUTOSELECT | ||
37 | select DVB_ZL10353 if MEDIA_SUBDRV_AUTOSELECT | 38 | select DVB_ZL10353 if MEDIA_SUBDRV_AUTOSELECT |
38 | select DVB_TDA10023 if MEDIA_SUBDRV_AUTOSELECT | 39 | select DVB_TDA10023 if MEDIA_SUBDRV_AUTOSELECT |
39 | select DVB_S921 if MEDIA_SUBDRV_AUTOSELECT | 40 | select DVB_S921 if MEDIA_SUBDRV_AUTOSELECT |
@@ -43,7 +44,10 @@ config VIDEO_EM28XX_DVB | |||
43 | select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT | 44 | select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT |
44 | select DVB_TDA10071 if MEDIA_SUBDRV_AUTOSELECT | 45 | select DVB_TDA10071 if MEDIA_SUBDRV_AUTOSELECT |
45 | select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT | 46 | select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT |
46 | select VIDEOBUF_DVB | 47 | select DVB_MT352 if MEDIA_SUBDRV_AUTOSELECT |
48 | select DVB_S5H1409 if MEDIA_SUBDRV_AUTOSELECT | ||
49 | select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT | ||
50 | select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT | ||
47 | ---help--- | 51 | ---help--- |
48 | This adds support for DVB cards based on the | 52 | This adds support for DVB cards based on the |
49 | Empiatech em28xx chips. | 53 | Empiatech em28xx chips. |
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 619bffbab3bc..54a03b20de6e 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c | |||
@@ -6,6 +6,7 @@ | |||
6 | Markus Rechberger <mrechberger@gmail.com> | 6 | Markus Rechberger <mrechberger@gmail.com> |
7 | Mauro Carvalho Chehab <mchehab@infradead.org> | 7 | Mauro Carvalho Chehab <mchehab@infradead.org> |
8 | Sascha Sommer <saschasommer@freenet.de> | 8 | Sascha Sommer <saschasommer@freenet.de> |
9 | Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
9 | 10 | ||
10 | This program is free software; you can redistribute it and/or modify | 11 | This program is free software; you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License as published by | 12 | it under the terms of the GNU General Public License as published by |
@@ -56,10 +57,16 @@ module_param(disable_usb_speed_check, int, 0444); | |||
56 | MODULE_PARM_DESC(disable_usb_speed_check, | 57 | MODULE_PARM_DESC(disable_usb_speed_check, |
57 | "override min bandwidth requirement of 480M bps"); | 58 | "override min bandwidth requirement of 480M bps"); |
58 | 59 | ||
59 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 60 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
60 | module_param_array(card, int, NULL, 0444); | 61 | module_param_array(card, int, NULL, 0444); |
61 | MODULE_PARM_DESC(card, "card type"); | 62 | MODULE_PARM_DESC(card, "card type"); |
62 | 63 | ||
64 | static int usb_xfer_mode = -1; | ||
65 | module_param(usb_xfer_mode, int, 0444); | ||
66 | MODULE_PARM_DESC(usb_xfer_mode, | ||
67 | "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)"); | ||
68 | |||
69 | |||
63 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */ | 70 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */ |
64 | static unsigned long em28xx_devused; | 71 | static unsigned long em28xx_devused; |
65 | 72 | ||
@@ -486,7 +493,7 @@ struct em28xx_board em28xx_boards[] = { | |||
486 | .input = { { | 493 | .input = { { |
487 | .type = EM28XX_VMUX_TELEVISION, | 494 | .type = EM28XX_VMUX_TELEVISION, |
488 | .vmux = SAA7115_COMPOSITE2, | 495 | .vmux = SAA7115_COMPOSITE2, |
489 | .amux = EM28XX_AMUX_LINE_IN, | 496 | .amux = EM28XX_AMUX_VIDEO, |
490 | }, { | 497 | }, { |
491 | .type = EM28XX_VMUX_COMPOSITE1, | 498 | .type = EM28XX_VMUX_COMPOSITE1, |
492 | .vmux = SAA7115_COMPOSITE0, | 499 | .vmux = SAA7115_COMPOSITE0, |
@@ -2073,6 +2080,8 @@ struct usb_device_id em28xx_id_table[] = { | |||
2073 | .driver_info = EM2884_BOARD_TERRATEC_H5 }, | 2080 | .driver_info = EM2884_BOARD_TERRATEC_H5 }, |
2074 | { USB_DEVICE(0x0ccd, 0x10ad), /* H5 Rev. 2 */ | 2081 | { USB_DEVICE(0x0ccd, 0x10ad), /* H5 Rev. 2 */ |
2075 | .driver_info = EM2884_BOARD_TERRATEC_H5 }, | 2082 | .driver_info = EM2884_BOARD_TERRATEC_H5 }, |
2083 | { USB_DEVICE(0x0ccd, 0x10b6), /* H5 Rev. 3 */ | ||
2084 | .driver_info = EM2884_BOARD_TERRATEC_H5 }, | ||
2076 | { USB_DEVICE(0x0ccd, 0x0084), | 2085 | { USB_DEVICE(0x0ccd, 0x0084), |
2077 | .driver_info = EM2860_BOARD_TERRATEC_AV350 }, | 2086 | .driver_info = EM2860_BOARD_TERRATEC_AV350 }, |
2078 | { USB_DEVICE(0x0ccd, 0x0096), | 2087 | { USB_DEVICE(0x0ccd, 0x0096), |
@@ -2905,7 +2914,7 @@ static void request_module_async(struct work_struct *work) | |||
2905 | 2914 | ||
2906 | if (dev->board.has_dvb) | 2915 | if (dev->board.has_dvb) |
2907 | request_module("em28xx-dvb"); | 2916 | request_module("em28xx-dvb"); |
2908 | if (dev->board.ir_codes && !disable_ir) | 2917 | if ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir) |
2909 | request_module("em28xx-rc"); | 2918 | request_module("em28xx-rc"); |
2910 | #endif /* CONFIG_MODULES */ | 2919 | #endif /* CONFIG_MODULES */ |
2911 | } | 2920 | } |
@@ -2934,6 +2943,8 @@ void em28xx_release_resources(struct em28xx *dev) | |||
2934 | 2943 | ||
2935 | em28xx_i2c_unregister(dev); | 2944 | em28xx_i2c_unregister(dev); |
2936 | 2945 | ||
2946 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
2947 | |||
2937 | v4l2_device_unregister(&dev->v4l2_dev); | 2948 | v4l2_device_unregister(&dev->v4l2_dev); |
2938 | 2949 | ||
2939 | usb_put_dev(dev->udev); | 2950 | usb_put_dev(dev->udev); |
@@ -2950,9 +2961,14 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
2950 | struct usb_interface *interface, | 2961 | struct usb_interface *interface, |
2951 | int minor) | 2962 | int minor) |
2952 | { | 2963 | { |
2964 | struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler; | ||
2953 | int retval; | 2965 | int retval; |
2966 | static const char *default_chip_name = "em28xx"; | ||
2967 | const char *chip_name = default_chip_name; | ||
2954 | 2968 | ||
2955 | dev->udev = udev; | 2969 | dev->udev = udev; |
2970 | mutex_init(&dev->vb_queue_lock); | ||
2971 | mutex_init(&dev->vb_vbi_queue_lock); | ||
2956 | mutex_init(&dev->ctrl_urb_lock); | 2972 | mutex_init(&dev->ctrl_urb_lock); |
2957 | spin_lock_init(&dev->slock); | 2973 | spin_lock_init(&dev->slock); |
2958 | 2974 | ||
@@ -2978,51 +2994,62 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
2978 | 2994 | ||
2979 | switch (dev->chip_id) { | 2995 | switch (dev->chip_id) { |
2980 | case CHIP_ID_EM2800: | 2996 | case CHIP_ID_EM2800: |
2981 | em28xx_info("chip ID is em2800\n"); | 2997 | chip_name = "em2800"; |
2982 | break; | 2998 | break; |
2983 | case CHIP_ID_EM2710: | 2999 | case CHIP_ID_EM2710: |
2984 | em28xx_info("chip ID is em2710\n"); | 3000 | chip_name = "em2710"; |
2985 | break; | 3001 | break; |
2986 | case CHIP_ID_EM2750: | 3002 | case CHIP_ID_EM2750: |
2987 | em28xx_info("chip ID is em2750\n"); | 3003 | chip_name = "em2750"; |
2988 | break; | 3004 | break; |
2989 | case CHIP_ID_EM2820: | 3005 | case CHIP_ID_EM2820: |
2990 | em28xx_info("chip ID is em2820 (or em2710)\n"); | 3006 | chip_name = "em2710/2820"; |
2991 | break; | 3007 | break; |
2992 | case CHIP_ID_EM2840: | 3008 | case CHIP_ID_EM2840: |
2993 | em28xx_info("chip ID is em2840\n"); | 3009 | chip_name = "em2840"; |
2994 | break; | 3010 | break; |
2995 | case CHIP_ID_EM2860: | 3011 | case CHIP_ID_EM2860: |
2996 | em28xx_info("chip ID is em2860\n"); | 3012 | chip_name = "em2860"; |
2997 | break; | 3013 | break; |
2998 | case CHIP_ID_EM2870: | 3014 | case CHIP_ID_EM2870: |
2999 | em28xx_info("chip ID is em2870\n"); | 3015 | chip_name = "em2870"; |
3000 | dev->wait_after_write = 0; | 3016 | dev->wait_after_write = 0; |
3001 | break; | 3017 | break; |
3002 | case CHIP_ID_EM2874: | 3018 | case CHIP_ID_EM2874: |
3003 | em28xx_info("chip ID is em2874\n"); | 3019 | chip_name = "em2874"; |
3004 | dev->reg_gpio_num = EM2874_R80_GPIO; | 3020 | dev->reg_gpio_num = EM2874_R80_GPIO; |
3005 | dev->wait_after_write = 0; | 3021 | dev->wait_after_write = 0; |
3006 | break; | 3022 | break; |
3007 | case CHIP_ID_EM28174: | 3023 | case CHIP_ID_EM28174: |
3008 | em28xx_info("chip ID is em28174\n"); | 3024 | chip_name = "em28174"; |
3009 | dev->reg_gpio_num = EM2874_R80_GPIO; | 3025 | dev->reg_gpio_num = EM2874_R80_GPIO; |
3010 | dev->wait_after_write = 0; | 3026 | dev->wait_after_write = 0; |
3011 | break; | 3027 | break; |
3012 | case CHIP_ID_EM2883: | 3028 | case CHIP_ID_EM2883: |
3013 | em28xx_info("chip ID is em2882/em2883\n"); | 3029 | chip_name = "em2882/3"; |
3014 | dev->wait_after_write = 0; | 3030 | dev->wait_after_write = 0; |
3015 | break; | 3031 | break; |
3016 | case CHIP_ID_EM2884: | 3032 | case CHIP_ID_EM2884: |
3017 | em28xx_info("chip ID is em2884\n"); | 3033 | chip_name = "em2884"; |
3018 | dev->reg_gpio_num = EM2874_R80_GPIO; | 3034 | dev->reg_gpio_num = EM2874_R80_GPIO; |
3019 | dev->wait_after_write = 0; | 3035 | dev->wait_after_write = 0; |
3020 | break; | 3036 | break; |
3021 | default: | 3037 | default: |
3022 | em28xx_info("em28xx chip ID = %d\n", dev->chip_id); | 3038 | printk(KERN_INFO DRIVER_NAME |
3039 | ": unknown em28xx chip ID (%d)\n", dev->chip_id); | ||
3023 | } | 3040 | } |
3024 | } | 3041 | } |
3025 | 3042 | ||
3043 | if (chip_name != default_chip_name) | ||
3044 | printk(KERN_INFO DRIVER_NAME | ||
3045 | ": chip ID is %s\n", chip_name); | ||
3046 | |||
3047 | /* | ||
3048 | * For em2820/em2710, the name may change latter, after checking | ||
3049 | * if the device has a sensor (so, it is em2710) or not. | ||
3050 | */ | ||
3051 | snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno); | ||
3052 | |||
3026 | if (dev->is_audio_only) { | 3053 | if (dev->is_audio_only) { |
3027 | retval = em28xx_audio_setup(dev); | 3054 | retval = em28xx_audio_setup(dev); |
3028 | if (retval) | 3055 | if (retval) |
@@ -3039,6 +3066,14 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3039 | 3066 | ||
3040 | em28xx_pre_card_setup(dev); | 3067 | em28xx_pre_card_setup(dev); |
3041 | 3068 | ||
3069 | if (dev->chip_id == CHIP_ID_EM2820) { | ||
3070 | if (dev->board.is_webcam) | ||
3071 | chip_name = "em2710"; | ||
3072 | else | ||
3073 | chip_name = "em2820"; | ||
3074 | snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno); | ||
3075 | } | ||
3076 | |||
3042 | if (!dev->board.is_em2800) { | 3077 | if (!dev->board.is_em2800) { |
3043 | /* Resets I2C speed */ | 3078 | /* Resets I2C speed */ |
3044 | retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed); | 3079 | retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed); |
@@ -3056,6 +3091,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3056 | return retval; | 3091 | return retval; |
3057 | } | 3092 | } |
3058 | 3093 | ||
3094 | v4l2_ctrl_handler_init(hdl, 4); | ||
3095 | dev->v4l2_dev.ctrl_handler = hdl; | ||
3096 | |||
3059 | /* register i2c bus */ | 3097 | /* register i2c bus */ |
3060 | retval = em28xx_i2c_register(dev); | 3098 | retval = em28xx_i2c_register(dev); |
3061 | if (retval < 0) { | 3099 | if (retval < 0) { |
@@ -3081,6 +3119,18 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3081 | __func__, retval); | 3119 | __func__, retval); |
3082 | goto fail; | 3120 | goto fail; |
3083 | } | 3121 | } |
3122 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | ||
3123 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | ||
3124 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); | ||
3125 | v4l2_ctrl_new_std(hdl, &em28xx_ctrl_ops, | ||
3126 | V4L2_CID_AUDIO_VOLUME, 0, 0x1f, 1, 0x1f); | ||
3127 | } else { | ||
3128 | /* install the em28xx notify callback */ | ||
3129 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_MUTE), | ||
3130 | em28xx_ctrl_notify, dev); | ||
3131 | v4l2_ctrl_notify(v4l2_ctrl_find(hdl, V4L2_CID_AUDIO_VOLUME), | ||
3132 | em28xx_ctrl_notify, dev); | ||
3133 | } | ||
3084 | 3134 | ||
3085 | /* wake i2c devices */ | 3135 | /* wake i2c devices */ |
3086 | em28xx_wake_i2c(dev); | 3136 | em28xx_wake_i2c(dev); |
@@ -3110,6 +3160,11 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3110 | msleep(3); | 3160 | msleep(3); |
3111 | } | 3161 | } |
3112 | 3162 | ||
3163 | v4l2_ctrl_handler_setup(&dev->ctrl_handler); | ||
3164 | retval = dev->ctrl_handler.error; | ||
3165 | if (retval) | ||
3166 | goto fail; | ||
3167 | |||
3113 | retval = em28xx_register_analog_devices(dev); | 3168 | retval = em28xx_register_analog_devices(dev); |
3114 | if (retval < 0) { | 3169 | if (retval < 0) { |
3115 | goto fail; | 3170 | goto fail; |
@@ -3122,6 +3177,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, | |||
3122 | 3177 | ||
3123 | fail: | 3178 | fail: |
3124 | em28xx_i2c_unregister(dev); | 3179 | em28xx_i2c_unregister(dev); |
3180 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
3125 | 3181 | ||
3126 | unregister_dev: | 3182 | unregister_dev: |
3127 | v4l2_device_unregister(&dev->v4l2_dev); | 3183 | v4l2_device_unregister(&dev->v4l2_dev); |
@@ -3143,7 +3199,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3143 | struct em28xx *dev = NULL; | 3199 | struct em28xx *dev = NULL; |
3144 | int retval; | 3200 | int retval; |
3145 | bool has_audio = false, has_video = false, has_dvb = false; | 3201 | bool has_audio = false, has_video = false, has_dvb = false; |
3146 | int i, nr; | 3202 | int i, nr, try_bulk; |
3147 | const int ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 3203 | const int ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
3148 | char *speed; | 3204 | char *speed; |
3149 | 3205 | ||
@@ -3183,9 +3239,10 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3183 | } | 3239 | } |
3184 | 3240 | ||
3185 | /* compute alternate max packet sizes */ | 3241 | /* compute alternate max packet sizes */ |
3186 | dev->alt_max_pkt_size = kmalloc(sizeof(dev->alt_max_pkt_size[0]) * | 3242 | dev->alt_max_pkt_size_isoc = |
3243 | kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) * | ||
3187 | interface->num_altsetting, GFP_KERNEL); | 3244 | interface->num_altsetting, GFP_KERNEL); |
3188 | if (dev->alt_max_pkt_size == NULL) { | 3245 | if (dev->alt_max_pkt_size_isoc == NULL) { |
3189 | em28xx_errdev("out of memory!\n"); | 3246 | em28xx_errdev("out of memory!\n"); |
3190 | kfree(dev); | 3247 | kfree(dev); |
3191 | retval = -ENOMEM; | 3248 | retval = -ENOMEM; |
@@ -3208,25 +3265,67 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3208 | if (udev->speed == USB_SPEED_HIGH) | 3265 | if (udev->speed == USB_SPEED_HIGH) |
3209 | size = size * hb_mult(sizedescr); | 3266 | size = size * hb_mult(sizedescr); |
3210 | 3267 | ||
3211 | if (usb_endpoint_xfer_isoc(e) && | 3268 | if (usb_endpoint_dir_in(e)) { |
3212 | usb_endpoint_dir_in(e)) { | ||
3213 | switch (e->bEndpointAddress) { | 3269 | switch (e->bEndpointAddress) { |
3214 | case EM28XX_EP_AUDIO: | 3270 | case 0x82: |
3215 | has_audio = true; | ||
3216 | break; | ||
3217 | case EM28XX_EP_ANALOG: | ||
3218 | has_video = true; | 3271 | has_video = true; |
3219 | dev->alt_max_pkt_size[i] = size; | 3272 | if (usb_endpoint_xfer_isoc(e)) { |
3273 | dev->analog_ep_isoc = | ||
3274 | e->bEndpointAddress; | ||
3275 | dev->alt_max_pkt_size_isoc[i] = size; | ||
3276 | } else if (usb_endpoint_xfer_bulk(e)) { | ||
3277 | dev->analog_ep_bulk = | ||
3278 | e->bEndpointAddress; | ||
3279 | } | ||
3220 | break; | 3280 | break; |
3221 | case EM28XX_EP_DIGITAL: | 3281 | case 0x83: |
3222 | has_dvb = true; | 3282 | if (usb_endpoint_xfer_isoc(e)) { |
3223 | if (size > dev->dvb_max_pkt_size) { | 3283 | has_audio = true; |
3224 | dev->dvb_max_pkt_size = size; | 3284 | } else { |
3225 | dev->dvb_alt = i; | 3285 | printk(KERN_INFO DRIVER_NAME |
3286 | ": error: skipping audio endpoint 0x83, because it uses bulk transfers !\n"); | ||
3287 | } | ||
3288 | break; | ||
3289 | case 0x84: | ||
3290 | if (has_video && | ||
3291 | (usb_endpoint_xfer_bulk(e))) { | ||
3292 | dev->analog_ep_bulk = | ||
3293 | e->bEndpointAddress; | ||
3294 | } else { | ||
3295 | has_dvb = true; | ||
3296 | if (usb_endpoint_xfer_isoc(e)) { | ||
3297 | dev->dvb_ep_isoc = e->bEndpointAddress; | ||
3298 | if (size > dev->dvb_max_pkt_size_isoc) { | ||
3299 | dev->dvb_max_pkt_size_isoc = size; | ||
3300 | dev->dvb_alt_isoc = i; | ||
3301 | } | ||
3302 | } else { | ||
3303 | dev->dvb_ep_bulk = e->bEndpointAddress; | ||
3304 | } | ||
3226 | } | 3305 | } |
3227 | break; | 3306 | break; |
3228 | } | 3307 | } |
3229 | } | 3308 | } |
3309 | /* NOTE: | ||
3310 | * Old logic with support for isoc transfers only was: | ||
3311 | * 0x82 isoc => analog | ||
3312 | * 0x83 isoc => audio | ||
3313 | * 0x84 isoc => digital | ||
3314 | * | ||
3315 | * New logic with support for bulk transfers | ||
3316 | * 0x82 isoc => analog | ||
3317 | * 0x82 bulk => analog | ||
3318 | * 0x83 isoc* => audio | ||
3319 | * 0x84 isoc => digital | ||
3320 | * 0x84 bulk => analog or digital** | ||
3321 | * (*: audio should always be isoc) | ||
3322 | * (**: analog, if ep 0x82 is isoc, otherwise digital) | ||
3323 | * | ||
3324 | * The new logic preserves backwards compatibility and | ||
3325 | * reflects the endpoint configurations we have seen | ||
3326 | * so far. But there might be devices for which this | ||
3327 | * logic is not sufficient... | ||
3328 | */ | ||
3230 | } | 3329 | } |
3231 | } | 3330 | } |
3232 | 3331 | ||
@@ -3261,19 +3360,6 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3261 | ifnum, | 3360 | ifnum, |
3262 | interface->altsetting->desc.bInterfaceNumber); | 3361 | interface->altsetting->desc.bInterfaceNumber); |
3263 | 3362 | ||
3264 | if (has_audio) | ||
3265 | printk(KERN_INFO DRIVER_NAME | ||
3266 | ": Audio Vendor Class interface %i found\n", | ||
3267 | ifnum); | ||
3268 | if (has_video) | ||
3269 | printk(KERN_INFO DRIVER_NAME | ||
3270 | ": Video interface %i found\n", | ||
3271 | ifnum); | ||
3272 | if (has_dvb) | ||
3273 | printk(KERN_INFO DRIVER_NAME | ||
3274 | ": DVB interface %i found\n", | ||
3275 | ifnum); | ||
3276 | |||
3277 | /* | 3363 | /* |
3278 | * Make sure we have 480 Mbps of bandwidth, otherwise things like | 3364 | * Make sure we have 480 Mbps of bandwidth, otherwise things like |
3279 | * video stream wouldn't likely work, since 12 Mbps is generally | 3365 | * video stream wouldn't likely work, since 12 Mbps is generally |
@@ -3287,7 +3373,6 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3287 | goto err_free; | 3373 | goto err_free; |
3288 | } | 3374 | } |
3289 | 3375 | ||
3290 | snprintf(dev->name, sizeof(dev->name), "em28xx #%d", nr); | ||
3291 | dev->devno = nr; | 3376 | dev->devno = nr; |
3292 | dev->model = id->driver_info; | 3377 | dev->model = id->driver_info; |
3293 | dev->alt = -1; | 3378 | dev->alt = -1; |
@@ -3304,6 +3389,24 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3304 | } | 3389 | } |
3305 | } | 3390 | } |
3306 | 3391 | ||
3392 | if (has_audio) | ||
3393 | printk(KERN_INFO DRIVER_NAME | ||
3394 | ": Audio interface %i found %s\n", | ||
3395 | ifnum, | ||
3396 | dev->has_audio_class ? "(USB Audio Class)" : "(Vendor Class)"); | ||
3397 | if (has_video) | ||
3398 | printk(KERN_INFO DRIVER_NAME | ||
3399 | ": Video interface %i found:%s%s\n", | ||
3400 | ifnum, | ||
3401 | dev->analog_ep_bulk ? " bulk" : "", | ||
3402 | dev->analog_ep_isoc ? " isoc" : ""); | ||
3403 | if (has_dvb) | ||
3404 | printk(KERN_INFO DRIVER_NAME | ||
3405 | ": DVB interface %i found:%s%s\n", | ||
3406 | ifnum, | ||
3407 | dev->dvb_ep_bulk ? " bulk" : "", | ||
3408 | dev->dvb_ep_isoc ? " isoc" : ""); | ||
3409 | |||
3307 | dev->num_alt = interface->num_altsetting; | 3410 | dev->num_alt = interface->num_altsetting; |
3308 | 3411 | ||
3309 | if ((unsigned)card[nr] < em28xx_bcount) | 3412 | if ((unsigned)card[nr] < em28xx_bcount) |
@@ -3312,6 +3415,9 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3312 | /* save our data pointer in this interface device */ | 3415 | /* save our data pointer in this interface device */ |
3313 | usb_set_intfdata(interface, dev); | 3416 | usb_set_intfdata(interface, dev); |
3314 | 3417 | ||
3418 | /* initialize videobuf2 stuff */ | ||
3419 | em28xx_vb2_setup(dev); | ||
3420 | |||
3315 | /* allocate device struct */ | 3421 | /* allocate device struct */ |
3316 | mutex_init(&dev->lock); | 3422 | mutex_init(&dev->lock); |
3317 | mutex_lock(&dev->lock); | 3423 | mutex_lock(&dev->lock); |
@@ -3320,13 +3426,46 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
3320 | goto unlock_and_free; | 3426 | goto unlock_and_free; |
3321 | } | 3427 | } |
3322 | 3428 | ||
3429 | if (usb_xfer_mode < 0) { | ||
3430 | if (dev->board.is_webcam) | ||
3431 | try_bulk = 1; | ||
3432 | else | ||
3433 | try_bulk = 0; | ||
3434 | } else { | ||
3435 | try_bulk = usb_xfer_mode > 0; | ||
3436 | } | ||
3437 | |||
3438 | /* Select USB transfer types to use */ | ||
3439 | if (has_video) { | ||
3440 | if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk)) | ||
3441 | dev->analog_xfer_bulk = 1; | ||
3442 | em28xx_info("analog set to %s mode.\n", | ||
3443 | dev->analog_xfer_bulk ? "bulk" : "isoc"); | ||
3444 | } | ||
3323 | if (has_dvb) { | 3445 | if (has_dvb) { |
3324 | /* pre-allocate DVB isoc transfer buffers */ | 3446 | if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk)) |
3325 | retval = em28xx_alloc_isoc(dev, EM28XX_DIGITAL_MODE, | 3447 | dev->dvb_xfer_bulk = 1; |
3326 | EM28XX_DVB_MAX_PACKETS, | 3448 | |
3327 | EM28XX_DVB_NUM_BUFS, | 3449 | em28xx_info("dvb set to %s mode.\n", |
3328 | dev->dvb_max_pkt_size); | 3450 | dev->dvb_xfer_bulk ? "bulk" : "isoc"); |
3451 | |||
3452 | /* pre-allocate DVB usb transfer buffers */ | ||
3453 | if (dev->dvb_xfer_bulk) { | ||
3454 | retval = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, | ||
3455 | dev->dvb_xfer_bulk, | ||
3456 | EM28XX_DVB_NUM_BUFS, | ||
3457 | 512, | ||
3458 | EM28XX_DVB_BULK_PACKET_MULTIPLIER); | ||
3459 | } else { | ||
3460 | retval = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE, | ||
3461 | dev->dvb_xfer_bulk, | ||
3462 | EM28XX_DVB_NUM_BUFS, | ||
3463 | dev->dvb_max_pkt_size_isoc, | ||
3464 | EM28XX_DVB_NUM_ISOC_PACKETS); | ||
3465 | } | ||
3329 | if (retval) { | 3466 | if (retval) { |
3467 | printk(DRIVER_NAME | ||
3468 | ": Failed to pre-allocate USB transfer buffers for DVB.\n"); | ||
3330 | goto unlock_and_free; | 3469 | goto unlock_and_free; |
3331 | } | 3470 | } |
3332 | } | 3471 | } |
@@ -3344,7 +3483,7 @@ unlock_and_free: | |||
3344 | mutex_unlock(&dev->lock); | 3483 | mutex_unlock(&dev->lock); |
3345 | 3484 | ||
3346 | err_free: | 3485 | err_free: |
3347 | kfree(dev->alt_max_pkt_size); | 3486 | kfree(dev->alt_max_pkt_size_isoc); |
3348 | kfree(dev); | 3487 | kfree(dev); |
3349 | 3488 | ||
3350 | err: | 3489 | err: |
@@ -3370,6 +3509,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
3370 | if (!dev) | 3509 | if (!dev) |
3371 | return; | 3510 | return; |
3372 | 3511 | ||
3512 | dev->disconnected = 1; | ||
3513 | |||
3373 | if (dev->is_audio_only) { | 3514 | if (dev->is_audio_only) { |
3374 | mutex_lock(&dev->lock); | 3515 | mutex_lock(&dev->lock); |
3375 | em28xx_close_extension(dev); | 3516 | em28xx_close_extension(dev); |
@@ -3381,35 +3522,28 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
3381 | 3522 | ||
3382 | flush_request_modules(dev); | 3523 | flush_request_modules(dev); |
3383 | 3524 | ||
3384 | /* wait until all current v4l2 io is finished then deallocate | ||
3385 | resources */ | ||
3386 | mutex_lock(&dev->lock); | 3525 | mutex_lock(&dev->lock); |
3387 | 3526 | ||
3388 | v4l2_device_disconnect(&dev->v4l2_dev); | 3527 | v4l2_device_disconnect(&dev->v4l2_dev); |
3389 | 3528 | ||
3390 | if (dev->users) { | 3529 | if (dev->users) { |
3391 | em28xx_warn | 3530 | em28xx_warn("device %s is open! Deregistration and memory deallocation are deferred on close.\n", |
3392 | ("device %s is open! Deregistration and memory " | 3531 | video_device_node_name(dev->vdev)); |
3393 | "deallocation are deferred on close.\n", | 3532 | |
3394 | video_device_node_name(dev->vdev)); | 3533 | em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); |
3395 | 3534 | em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); | |
3396 | dev->state |= DEV_MISCONFIGURED; | ||
3397 | em28xx_uninit_isoc(dev, dev->mode); | ||
3398 | dev->state |= DEV_DISCONNECTED; | ||
3399 | } else { | ||
3400 | dev->state |= DEV_DISCONNECTED; | ||
3401 | em28xx_release_resources(dev); | ||
3402 | } | 3535 | } |
3403 | 3536 | ||
3404 | /* free DVB isoc buffers */ | 3537 | em28xx_close_extension(dev); |
3405 | em28xx_uninit_isoc(dev, EM28XX_DIGITAL_MODE); | 3538 | /* NOTE: must be called BEFORE the resources are released */ |
3406 | 3539 | ||
3407 | mutex_unlock(&dev->lock); | 3540 | if (!dev->users) |
3541 | em28xx_release_resources(dev); | ||
3408 | 3542 | ||
3409 | em28xx_close_extension(dev); | 3543 | mutex_unlock(&dev->lock); |
3410 | 3544 | ||
3411 | if (!dev->users) { | 3545 | if (!dev->users) { |
3412 | kfree(dev->alt_max_pkt_size); | 3546 | kfree(dev->alt_max_pkt_size_isoc); |
3413 | kfree(dev); | 3547 | kfree(dev); |
3414 | } | 3548 | } |
3415 | } | 3549 | } |
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index bed07a6c33f8..aaedd11791f2 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c | |||
@@ -5,6 +5,7 @@ | |||
5 | Markus Rechberger <mrechberger@gmail.com> | 5 | Markus Rechberger <mrechberger@gmail.com> |
6 | Mauro Carvalho Chehab <mchehab@infradead.org> | 6 | Mauro Carvalho Chehab <mchehab@infradead.org> |
7 | Sascha Sommer <saschasommer@freenet.de> | 7 | Sascha Sommer <saschasommer@freenet.de> |
8 | Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
8 | 9 | ||
9 | This program is free software; you can redistribute it and/or modify | 10 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | 11 | it under the terms of the GNU General Public License as published by |
@@ -76,7 +77,7 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
76 | int ret; | 77 | int ret; |
77 | int pipe = usb_rcvctrlpipe(dev->udev, 0); | 78 | int pipe = usb_rcvctrlpipe(dev->udev, 0); |
78 | 79 | ||
79 | if (dev->state & DEV_DISCONNECTED) | 80 | if (dev->disconnected) |
80 | return -ENODEV; | 81 | return -ENODEV; |
81 | 82 | ||
82 | if (len > URB_MAX_CTRL_SIZE) | 83 | if (len > URB_MAX_CTRL_SIZE) |
@@ -100,7 +101,7 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
100 | if (reg_debug) | 101 | if (reg_debug) |
101 | printk(" failed!\n"); | 102 | printk(" failed!\n"); |
102 | mutex_unlock(&dev->ctrl_urb_lock); | 103 | mutex_unlock(&dev->ctrl_urb_lock); |
103 | return ret; | 104 | return usb_translate_errors(ret); |
104 | } | 105 | } |
105 | 106 | ||
106 | if (len) | 107 | if (len) |
@@ -152,7 +153,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
152 | int ret; | 153 | int ret; |
153 | int pipe = usb_sndctrlpipe(dev->udev, 0); | 154 | int pipe = usb_sndctrlpipe(dev->udev, 0); |
154 | 155 | ||
155 | if (dev->state & DEV_DISCONNECTED) | 156 | if (dev->disconnected) |
156 | return -ENODEV; | 157 | return -ENODEV; |
157 | 158 | ||
158 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) | 159 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) |
@@ -181,6 +182,9 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
181 | 0x0000, reg, dev->urb_buf, len, HZ); | 182 | 0x0000, reg, dev->urb_buf, len, HZ); |
182 | mutex_unlock(&dev->ctrl_urb_lock); | 183 | mutex_unlock(&dev->ctrl_urb_lock); |
183 | 184 | ||
185 | if (ret < 0) | ||
186 | return usb_translate_errors(ret); | ||
187 | |||
184 | if (dev->wait_after_write) | 188 | if (dev->wait_after_write) |
185 | msleep(dev->wait_after_write); | 189 | msleep(dev->wait_after_write); |
186 | 190 | ||
@@ -729,22 +733,24 @@ static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, | |||
729 | return em28xx_write_regs(dev, EM28XX_R2B_YMAX, &ymax, 1); | 733 | return em28xx_write_regs(dev, EM28XX_R2B_YMAX, &ymax, 1); |
730 | } | 734 | } |
731 | 735 | ||
732 | static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, | 736 | static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, |
733 | u16 width, u16 height) | 737 | u16 width, u16 height) |
734 | { | 738 | { |
735 | u8 cwidth = width; | 739 | u8 cwidth = width >> 2; |
736 | u8 cheight = height; | 740 | u8 cheight = height >> 2; |
737 | u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); | 741 | u8 overflow = (height >> 9 & 0x02) | (width >> 10 & 0x01); |
742 | /* NOTE: size limit: 2047x1023 = 2MPix */ | ||
738 | 743 | ||
739 | em28xx_coredbg("em28xx Area Set: (%d,%d)\n", | 744 | em28xx_coredbg("capture area set to (%d,%d): %dx%d\n", |
740 | (width | (overflow & 2) << 7), | 745 | hstart, vstart, |
741 | (height | (overflow & 1) << 8)); | 746 | ((overflow & 2) << 9 | cwidth << 2), |
747 | ((overflow & 1) << 10 | cheight << 2)); | ||
742 | 748 | ||
743 | em28xx_write_regs(dev, EM28XX_R1C_HSTART, &hstart, 1); | 749 | em28xx_write_regs(dev, EM28XX_R1C_HSTART, &hstart, 1); |
744 | em28xx_write_regs(dev, EM28XX_R1D_VSTART, &vstart, 1); | 750 | em28xx_write_regs(dev, EM28XX_R1D_VSTART, &vstart, 1); |
745 | em28xx_write_regs(dev, EM28XX_R1E_CWIDTH, &cwidth, 1); | 751 | em28xx_write_regs(dev, EM28XX_R1E_CWIDTH, &cwidth, 1); |
746 | em28xx_write_regs(dev, EM28XX_R1F_CHEIGHT, &cheight, 1); | 752 | em28xx_write_regs(dev, EM28XX_R1F_CHEIGHT, &cheight, 1); |
747 | return em28xx_write_regs(dev, EM28XX_R1B_OFLOW, &overflow, 1); | 753 | em28xx_write_regs(dev, EM28XX_R1B_OFLOW, &overflow, 1); |
748 | } | 754 | } |
749 | 755 | ||
750 | static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) | 756 | static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) |
@@ -797,28 +803,30 @@ int em28xx_resolution_set(struct em28xx *dev) | |||
797 | it out, we end up with the same format as the rest of the VBI | 803 | it out, we end up with the same format as the rest of the VBI |
798 | region */ | 804 | region */ |
799 | if (em28xx_vbi_supported(dev) == 1) | 805 | if (em28xx_vbi_supported(dev) == 1) |
800 | em28xx_capture_area_set(dev, 0, 2, width >> 2, height >> 2); | 806 | em28xx_capture_area_set(dev, 0, 2, width, height); |
801 | else | 807 | else |
802 | em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2); | 808 | em28xx_capture_area_set(dev, 0, 0, width, height); |
803 | 809 | ||
804 | return em28xx_scaler_set(dev, dev->hscale, dev->vscale); | 810 | return em28xx_scaler_set(dev, dev->hscale, dev->vscale); |
805 | } | 811 | } |
806 | 812 | ||
813 | /* Set USB alternate setting for analog video */ | ||
807 | int em28xx_set_alternate(struct em28xx *dev) | 814 | int em28xx_set_alternate(struct em28xx *dev) |
808 | { | 815 | { |
809 | int errCode, prev_alt = dev->alt; | 816 | int errCode; |
810 | int i; | 817 | int i; |
811 | unsigned int min_pkt_size = dev->width * 2 + 4; | 818 | unsigned int min_pkt_size = dev->width * 2 + 4; |
812 | 819 | ||
813 | /* | 820 | /* NOTE: for isoc transfers, only alt settings > 0 are allowed |
814 | * alt = 0 is used only for control messages, so, only values | 821 | bulk transfers seem to work only with alt=0 ! */ |
815 | * greater than 0 can be used for streaming. | 822 | dev->alt = 0; |
816 | */ | 823 | if ((alt > 0) && (alt < dev->num_alt)) { |
817 | if (alt && alt < dev->num_alt) { | ||
818 | em28xx_coredbg("alternate forced to %d\n", dev->alt); | 824 | em28xx_coredbg("alternate forced to %d\n", dev->alt); |
819 | dev->alt = alt; | 825 | dev->alt = alt; |
820 | goto set_alt; | 826 | goto set_alt; |
821 | } | 827 | } |
828 | if (dev->analog_xfer_bulk) | ||
829 | goto set_alt; | ||
822 | 830 | ||
823 | /* When image size is bigger than a certain value, | 831 | /* When image size is bigger than a certain value, |
824 | the frame size should be increased, otherwise, only | 832 | the frame size should be increased, otherwise, only |
@@ -829,30 +837,38 @@ int em28xx_set_alternate(struct em28xx *dev) | |||
829 | 837 | ||
830 | for (i = 0; i < dev->num_alt; i++) { | 838 | for (i = 0; i < dev->num_alt; i++) { |
831 | /* stop when the selected alt setting offers enough bandwidth */ | 839 | /* stop when the selected alt setting offers enough bandwidth */ |
832 | if (dev->alt_max_pkt_size[i] >= min_pkt_size) { | 840 | if (dev->alt_max_pkt_size_isoc[i] >= min_pkt_size) { |
833 | dev->alt = i; | 841 | dev->alt = i; |
834 | break; | 842 | break; |
835 | /* otherwise make sure that we end up with the maximum bandwidth | 843 | /* otherwise make sure that we end up with the maximum bandwidth |
836 | because the min_pkt_size equation might be wrong... | 844 | because the min_pkt_size equation might be wrong... |
837 | */ | 845 | */ |
838 | } else if (dev->alt_max_pkt_size[i] > | 846 | } else if (dev->alt_max_pkt_size_isoc[i] > |
839 | dev->alt_max_pkt_size[dev->alt]) | 847 | dev->alt_max_pkt_size_isoc[dev->alt]) |
840 | dev->alt = i; | 848 | dev->alt = i; |
841 | } | 849 | } |
842 | 850 | ||
843 | set_alt: | 851 | set_alt: |
844 | if (dev->alt != prev_alt) { | 852 | /* NOTE: for bulk transfers, we need to call usb_set_interface() |
853 | * even if the previous settings were the same. Otherwise streaming | ||
854 | * fails with all urbs having status = -EOVERFLOW ! */ | ||
855 | if (dev->analog_xfer_bulk) { | ||
856 | dev->max_pkt_size = 512; /* USB 2.0 spec */ | ||
857 | dev->packet_multiplier = EM28XX_BULK_PACKET_MULTIPLIER; | ||
858 | } else { /* isoc */ | ||
845 | em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | 859 | em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", |
846 | min_pkt_size, dev->alt); | 860 | min_pkt_size, dev->alt); |
847 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; | 861 | dev->max_pkt_size = |
848 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", | 862 | dev->alt_max_pkt_size_isoc[dev->alt]; |
849 | dev->alt, dev->max_pkt_size); | 863 | dev->packet_multiplier = EM28XX_NUM_ISOC_PACKETS; |
850 | errCode = usb_set_interface(dev->udev, 0, dev->alt); | 864 | } |
851 | if (errCode < 0) { | 865 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", |
852 | em28xx_errdev("cannot change alternate number to %d (error=%i)\n", | 866 | dev->alt, dev->max_pkt_size); |
853 | dev->alt, errCode); | 867 | errCode = usb_set_interface(dev->udev, 0, dev->alt); |
854 | return errCode; | 868 | if (errCode < 0) { |
855 | } | 869 | em28xx_errdev("cannot change alternate number to %d (error=%i)\n", |
870 | dev->alt, errCode); | ||
871 | return errCode; | ||
856 | } | 872 | } |
857 | return 0; | 873 | return 0; |
858 | } | 874 | } |
@@ -919,7 +935,7 @@ EXPORT_SYMBOL_GPL(em28xx_set_mode); | |||
919 | ------------------------------------------------------------------*/ | 935 | ------------------------------------------------------------------*/ |
920 | 936 | ||
921 | /* | 937 | /* |
922 | * IRQ callback, called by URB callback | 938 | * URB completion handler for isoc/bulk transfers |
923 | */ | 939 | */ |
924 | static void em28xx_irq_callback(struct urb *urb) | 940 | static void em28xx_irq_callback(struct urb *urb) |
925 | { | 941 | { |
@@ -941,11 +957,12 @@ static void em28xx_irq_callback(struct urb *urb) | |||
941 | 957 | ||
942 | /* Copy data from URB */ | 958 | /* Copy data from URB */ |
943 | spin_lock(&dev->slock); | 959 | spin_lock(&dev->slock); |
944 | dev->isoc_ctl.isoc_copy(dev, urb); | 960 | dev->usb_ctl.urb_data_copy(dev, urb); |
945 | spin_unlock(&dev->slock); | 961 | spin_unlock(&dev->slock); |
946 | 962 | ||
947 | /* Reset urb buffers */ | 963 | /* Reset urb buffers */ |
948 | for (i = 0; i < urb->number_of_packets; i++) { | 964 | for (i = 0; i < urb->number_of_packets; i++) { |
965 | /* isoc only (bulk: number_of_packets = 0) */ | ||
949 | urb->iso_frame_desc[i].status = 0; | 966 | urb->iso_frame_desc[i].status = 0; |
950 | urb->iso_frame_desc[i].actual_length = 0; | 967 | urb->iso_frame_desc[i].actual_length = 0; |
951 | } | 968 | } |
@@ -961,49 +978,50 @@ static void em28xx_irq_callback(struct urb *urb) | |||
961 | /* | 978 | /* |
962 | * Stop and Deallocate URBs | 979 | * Stop and Deallocate URBs |
963 | */ | 980 | */ |
964 | void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode) | 981 | void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode) |
965 | { | 982 | { |
966 | struct urb *urb; | 983 | struct urb *urb; |
967 | struct em28xx_usb_isoc_bufs *isoc_bufs; | 984 | struct em28xx_usb_bufs *usb_bufs; |
968 | int i; | 985 | int i; |
969 | 986 | ||
970 | em28xx_isocdbg("em28xx: called em28xx_uninit_isoc in mode %d\n", mode); | 987 | em28xx_isocdbg("em28xx: called em28xx_uninit_usb_xfer in mode %d\n", |
988 | mode); | ||
971 | 989 | ||
972 | if (mode == EM28XX_DIGITAL_MODE) | 990 | if (mode == EM28XX_DIGITAL_MODE) |
973 | isoc_bufs = &dev->isoc_ctl.digital_bufs; | 991 | usb_bufs = &dev->usb_ctl.digital_bufs; |
974 | else | 992 | else |
975 | isoc_bufs = &dev->isoc_ctl.analog_bufs; | 993 | usb_bufs = &dev->usb_ctl.analog_bufs; |
976 | 994 | ||
977 | for (i = 0; i < isoc_bufs->num_bufs; i++) { | 995 | for (i = 0; i < usb_bufs->num_bufs; i++) { |
978 | urb = isoc_bufs->urb[i]; | 996 | urb = usb_bufs->urb[i]; |
979 | if (urb) { | 997 | if (urb) { |
980 | if (!irqs_disabled()) | 998 | if (!irqs_disabled()) |
981 | usb_kill_urb(urb); | 999 | usb_kill_urb(urb); |
982 | else | 1000 | else |
983 | usb_unlink_urb(urb); | 1001 | usb_unlink_urb(urb); |
984 | 1002 | ||
985 | if (isoc_bufs->transfer_buffer[i]) { | 1003 | if (usb_bufs->transfer_buffer[i]) { |
986 | usb_free_coherent(dev->udev, | 1004 | usb_free_coherent(dev->udev, |
987 | urb->transfer_buffer_length, | 1005 | urb->transfer_buffer_length, |
988 | isoc_bufs->transfer_buffer[i], | 1006 | usb_bufs->transfer_buffer[i], |
989 | urb->transfer_dma); | 1007 | urb->transfer_dma); |
990 | } | 1008 | } |
991 | usb_free_urb(urb); | 1009 | usb_free_urb(urb); |
992 | isoc_bufs->urb[i] = NULL; | 1010 | usb_bufs->urb[i] = NULL; |
993 | } | 1011 | } |
994 | isoc_bufs->transfer_buffer[i] = NULL; | 1012 | usb_bufs->transfer_buffer[i] = NULL; |
995 | } | 1013 | } |
996 | 1014 | ||
997 | kfree(isoc_bufs->urb); | 1015 | kfree(usb_bufs->urb); |
998 | kfree(isoc_bufs->transfer_buffer); | 1016 | kfree(usb_bufs->transfer_buffer); |
999 | 1017 | ||
1000 | isoc_bufs->urb = NULL; | 1018 | usb_bufs->urb = NULL; |
1001 | isoc_bufs->transfer_buffer = NULL; | 1019 | usb_bufs->transfer_buffer = NULL; |
1002 | isoc_bufs->num_bufs = 0; | 1020 | usb_bufs->num_bufs = 0; |
1003 | 1021 | ||
1004 | em28xx_capture_start(dev, 0); | 1022 | em28xx_capture_start(dev, 0); |
1005 | } | 1023 | } |
1006 | EXPORT_SYMBOL_GPL(em28xx_uninit_isoc); | 1024 | EXPORT_SYMBOL_GPL(em28xx_uninit_usb_xfer); |
1007 | 1025 | ||
1008 | /* | 1026 | /* |
1009 | * Stop URBs | 1027 | * Stop URBs |
@@ -1012,7 +1030,7 @@ void em28xx_stop_urbs(struct em28xx *dev) | |||
1012 | { | 1030 | { |
1013 | int i; | 1031 | int i; |
1014 | struct urb *urb; | 1032 | struct urb *urb; |
1015 | struct em28xx_usb_isoc_bufs *isoc_bufs = &dev->isoc_ctl.digital_bufs; | 1033 | struct em28xx_usb_bufs *isoc_bufs = &dev->usb_ctl.digital_bufs; |
1016 | 1034 | ||
1017 | em28xx_isocdbg("em28xx: called em28xx_stop_urbs\n"); | 1035 | em28xx_isocdbg("em28xx: called em28xx_stop_urbs\n"); |
1018 | 1036 | ||
@@ -1033,10 +1051,10 @@ EXPORT_SYMBOL_GPL(em28xx_stop_urbs); | |||
1033 | /* | 1051 | /* |
1034 | * Allocate URBs | 1052 | * Allocate URBs |
1035 | */ | 1053 | */ |
1036 | int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode, | 1054 | int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, |
1037 | int max_packets, int num_bufs, int max_pkt_size) | 1055 | int num_bufs, int max_pkt_size, int packet_multiplier) |
1038 | { | 1056 | { |
1039 | struct em28xx_usb_isoc_bufs *isoc_bufs; | 1057 | struct em28xx_usb_bufs *usb_bufs; |
1040 | int i; | 1058 | int i; |
1041 | int sb_size, pipe; | 1059 | int sb_size, pipe; |
1042 | struct urb *urb; | 1060 | struct urb *urb; |
@@ -1044,140 +1062,180 @@ int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode, | |||
1044 | 1062 | ||
1045 | em28xx_isocdbg("em28xx: called em28xx_alloc_isoc in mode %d\n", mode); | 1063 | em28xx_isocdbg("em28xx: called em28xx_alloc_isoc in mode %d\n", mode); |
1046 | 1064 | ||
1047 | if (mode == EM28XX_DIGITAL_MODE) | 1065 | /* Check mode and if we have an endpoint for the selected |
1048 | isoc_bufs = &dev->isoc_ctl.digital_bufs; | 1066 | transfer type, select buffer */ |
1049 | else | 1067 | if (mode == EM28XX_DIGITAL_MODE) { |
1050 | isoc_bufs = &dev->isoc_ctl.analog_bufs; | 1068 | if ((xfer_bulk && !dev->dvb_ep_bulk) || |
1069 | (!xfer_bulk && !dev->dvb_ep_isoc)) { | ||
1070 | em28xx_errdev("no endpoint for DVB mode and transfer type %d\n", | ||
1071 | xfer_bulk > 0); | ||
1072 | return -EINVAL; | ||
1073 | } | ||
1074 | usb_bufs = &dev->usb_ctl.digital_bufs; | ||
1075 | } else if (mode == EM28XX_ANALOG_MODE) { | ||
1076 | if ((xfer_bulk && !dev->analog_ep_bulk) || | ||
1077 | (!xfer_bulk && !dev->analog_ep_isoc)) { | ||
1078 | em28xx_errdev("no endpoint for analog mode and transfer type %d\n", | ||
1079 | xfer_bulk > 0); | ||
1080 | return -EINVAL; | ||
1081 | } | ||
1082 | usb_bufs = &dev->usb_ctl.analog_bufs; | ||
1083 | } else { | ||
1084 | em28xx_errdev("invalid mode selected\n"); | ||
1085 | return -EINVAL; | ||
1086 | } | ||
1051 | 1087 | ||
1052 | /* De-allocates all pending stuff */ | 1088 | /* De-allocates all pending stuff */ |
1053 | em28xx_uninit_isoc(dev, mode); | 1089 | em28xx_uninit_usb_xfer(dev, mode); |
1054 | 1090 | ||
1055 | isoc_bufs->num_bufs = num_bufs; | 1091 | usb_bufs->num_bufs = num_bufs; |
1056 | 1092 | ||
1057 | isoc_bufs->urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | 1093 | usb_bufs->urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); |
1058 | if (!isoc_bufs->urb) { | 1094 | if (!usb_bufs->urb) { |
1059 | em28xx_errdev("cannot alloc memory for usb buffers\n"); | 1095 | em28xx_errdev("cannot alloc memory for usb buffers\n"); |
1060 | return -ENOMEM; | 1096 | return -ENOMEM; |
1061 | } | 1097 | } |
1062 | 1098 | ||
1063 | isoc_bufs->transfer_buffer = kzalloc(sizeof(void *)*num_bufs, | 1099 | usb_bufs->transfer_buffer = kzalloc(sizeof(void *)*num_bufs, |
1064 | GFP_KERNEL); | 1100 | GFP_KERNEL); |
1065 | if (!isoc_bufs->transfer_buffer) { | 1101 | if (!usb_bufs->transfer_buffer) { |
1066 | em28xx_errdev("cannot allocate memory for usb transfer\n"); | 1102 | em28xx_errdev("cannot allocate memory for usb transfer\n"); |
1067 | kfree(isoc_bufs->urb); | 1103 | kfree(usb_bufs->urb); |
1068 | return -ENOMEM; | 1104 | return -ENOMEM; |
1069 | } | 1105 | } |
1070 | 1106 | ||
1071 | isoc_bufs->max_pkt_size = max_pkt_size; | 1107 | usb_bufs->max_pkt_size = max_pkt_size; |
1072 | isoc_bufs->num_packets = max_packets; | 1108 | if (xfer_bulk) |
1073 | dev->isoc_ctl.vid_buf = NULL; | 1109 | usb_bufs->num_packets = 0; |
1074 | dev->isoc_ctl.vbi_buf = NULL; | 1110 | else |
1111 | usb_bufs->num_packets = packet_multiplier; | ||
1112 | dev->usb_ctl.vid_buf = NULL; | ||
1113 | dev->usb_ctl.vbi_buf = NULL; | ||
1075 | 1114 | ||
1076 | sb_size = isoc_bufs->num_packets * isoc_bufs->max_pkt_size; | 1115 | sb_size = packet_multiplier * usb_bufs->max_pkt_size; |
1077 | 1116 | ||
1078 | /* allocate urbs and transfer buffers */ | 1117 | /* allocate urbs and transfer buffers */ |
1079 | for (i = 0; i < isoc_bufs->num_bufs; i++) { | 1118 | for (i = 0; i < usb_bufs->num_bufs; i++) { |
1080 | urb = usb_alloc_urb(isoc_bufs->num_packets, GFP_KERNEL); | 1119 | urb = usb_alloc_urb(usb_bufs->num_packets, GFP_KERNEL); |
1081 | if (!urb) { | 1120 | if (!urb) { |
1082 | em28xx_err("cannot alloc isoc_ctl.urb %i\n", i); | 1121 | em28xx_err("cannot alloc usb_ctl.urb %i\n", i); |
1083 | em28xx_uninit_isoc(dev, mode); | 1122 | em28xx_uninit_usb_xfer(dev, mode); |
1084 | return -ENOMEM; | 1123 | return -ENOMEM; |
1085 | } | 1124 | } |
1086 | isoc_bufs->urb[i] = urb; | 1125 | usb_bufs->urb[i] = urb; |
1087 | 1126 | ||
1088 | isoc_bufs->transfer_buffer[i] = usb_alloc_coherent(dev->udev, | 1127 | usb_bufs->transfer_buffer[i] = usb_alloc_coherent(dev->udev, |
1089 | sb_size, GFP_KERNEL, &urb->transfer_dma); | 1128 | sb_size, GFP_KERNEL, &urb->transfer_dma); |
1090 | if (!isoc_bufs->transfer_buffer[i]) { | 1129 | if (!usb_bufs->transfer_buffer[i]) { |
1091 | em28xx_err("unable to allocate %i bytes for transfer" | 1130 | em28xx_err("unable to allocate %i bytes for transfer" |
1092 | " buffer %i%s\n", | 1131 | " buffer %i%s\n", |
1093 | sb_size, i, | 1132 | sb_size, i, |
1094 | in_interrupt() ? " while in int" : ""); | 1133 | in_interrupt() ? " while in int" : ""); |
1095 | em28xx_uninit_isoc(dev, mode); | 1134 | em28xx_uninit_usb_xfer(dev, mode); |
1096 | return -ENOMEM; | 1135 | return -ENOMEM; |
1097 | } | 1136 | } |
1098 | memset(isoc_bufs->transfer_buffer[i], 0, sb_size); | 1137 | memset(usb_bufs->transfer_buffer[i], 0, sb_size); |
1099 | 1138 | ||
1100 | /* FIXME: this is a hack - should be | 1139 | if (xfer_bulk) { /* bulk */ |
1101 | 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK' | 1140 | pipe = usb_rcvbulkpipe(dev->udev, |
1102 | should also be using 'desc.bInterval' | 1141 | mode == EM28XX_ANALOG_MODE ? |
1103 | */ | 1142 | dev->analog_ep_bulk : |
1104 | pipe = usb_rcvisocpipe(dev->udev, | 1143 | dev->dvb_ep_bulk); |
1105 | mode == EM28XX_ANALOG_MODE ? | 1144 | usb_fill_bulk_urb(urb, dev->udev, pipe, |
1106 | EM28XX_EP_ANALOG : EM28XX_EP_DIGITAL); | 1145 | usb_bufs->transfer_buffer[i], sb_size, |
1107 | 1146 | em28xx_irq_callback, dev); | |
1108 | usb_fill_int_urb(urb, dev->udev, pipe, | 1147 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; |
1109 | isoc_bufs->transfer_buffer[i], sb_size, | 1148 | } else { /* isoc */ |
1110 | em28xx_irq_callback, dev, 1); | 1149 | pipe = usb_rcvisocpipe(dev->udev, |
1111 | 1150 | mode == EM28XX_ANALOG_MODE ? | |
1112 | urb->number_of_packets = isoc_bufs->num_packets; | 1151 | dev->analog_ep_isoc : |
1113 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | 1152 | dev->dvb_ep_isoc); |
1114 | 1153 | usb_fill_int_urb(urb, dev->udev, pipe, | |
1115 | k = 0; | 1154 | usb_bufs->transfer_buffer[i], sb_size, |
1116 | for (j = 0; j < isoc_bufs->num_packets; j++) { | 1155 | em28xx_irq_callback, dev, 1); |
1117 | urb->iso_frame_desc[j].offset = k; | 1156 | urb->transfer_flags = URB_ISO_ASAP | |
1118 | urb->iso_frame_desc[j].length = | 1157 | URB_NO_TRANSFER_DMA_MAP; |
1119 | isoc_bufs->max_pkt_size; | 1158 | k = 0; |
1120 | k += isoc_bufs->max_pkt_size; | 1159 | for (j = 0; j < usb_bufs->num_packets; j++) { |
1160 | urb->iso_frame_desc[j].offset = k; | ||
1161 | urb->iso_frame_desc[j].length = | ||
1162 | usb_bufs->max_pkt_size; | ||
1163 | k += usb_bufs->max_pkt_size; | ||
1164 | } | ||
1121 | } | 1165 | } |
1166 | |||
1167 | urb->number_of_packets = usb_bufs->num_packets; | ||
1122 | } | 1168 | } |
1123 | 1169 | ||
1124 | return 0; | 1170 | return 0; |
1125 | } | 1171 | } |
1126 | EXPORT_SYMBOL_GPL(em28xx_alloc_isoc); | 1172 | EXPORT_SYMBOL_GPL(em28xx_alloc_urbs); |
1127 | 1173 | ||
1128 | /* | 1174 | /* |
1129 | * Allocate URBs and start IRQ | 1175 | * Allocate URBs and start IRQ |
1130 | */ | 1176 | */ |
1131 | int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode, | 1177 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, |
1132 | int max_packets, int num_bufs, int max_pkt_size, | 1178 | int xfer_bulk, int num_bufs, int max_pkt_size, |
1133 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb)) | 1179 | int packet_multiplier, |
1180 | int (*urb_data_copy) (struct em28xx *dev, struct urb *urb)) | ||
1134 | { | 1181 | { |
1135 | struct em28xx_dmaqueue *dma_q = &dev->vidq; | 1182 | struct em28xx_dmaqueue *dma_q = &dev->vidq; |
1136 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; | 1183 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; |
1137 | struct em28xx_usb_isoc_bufs *isoc_bufs; | 1184 | struct em28xx_usb_bufs *usb_bufs; |
1138 | int i; | 1185 | int i; |
1139 | int rc; | 1186 | int rc; |
1140 | int alloc; | 1187 | int alloc; |
1141 | 1188 | ||
1142 | em28xx_isocdbg("em28xx: called em28xx_init_isoc in mode %d\n", mode); | 1189 | em28xx_isocdbg("em28xx: called em28xx_init_usb_xfer in mode %d\n", |
1190 | mode); | ||
1143 | 1191 | ||
1144 | dev->isoc_ctl.isoc_copy = isoc_copy; | 1192 | dev->usb_ctl.urb_data_copy = urb_data_copy; |
1145 | 1193 | ||
1146 | if (mode == EM28XX_DIGITAL_MODE) { | 1194 | if (mode == EM28XX_DIGITAL_MODE) { |
1147 | isoc_bufs = &dev->isoc_ctl.digital_bufs; | 1195 | usb_bufs = &dev->usb_ctl.digital_bufs; |
1148 | /* no need to free/alloc isoc buffers in digital mode */ | 1196 | /* no need to free/alloc usb buffers in digital mode */ |
1149 | alloc = 0; | 1197 | alloc = 0; |
1150 | } else { | 1198 | } else { |
1151 | isoc_bufs = &dev->isoc_ctl.analog_bufs; | 1199 | usb_bufs = &dev->usb_ctl.analog_bufs; |
1152 | alloc = 1; | 1200 | alloc = 1; |
1153 | } | 1201 | } |
1154 | 1202 | ||
1155 | if (alloc) { | 1203 | if (alloc) { |
1156 | rc = em28xx_alloc_isoc(dev, mode, max_packets, | 1204 | rc = em28xx_alloc_urbs(dev, mode, xfer_bulk, num_bufs, |
1157 | num_bufs, max_pkt_size); | 1205 | max_pkt_size, packet_multiplier); |
1158 | if (rc) | 1206 | if (rc) |
1159 | return rc; | 1207 | return rc; |
1160 | } | 1208 | } |
1161 | 1209 | ||
1210 | if (xfer_bulk) { | ||
1211 | rc = usb_clear_halt(dev->udev, usb_bufs->urb[0]->pipe); | ||
1212 | if (rc < 0) { | ||
1213 | em28xx_err("failed to clear USB bulk endpoint stall/halt condition (error=%i)\n", | ||
1214 | rc); | ||
1215 | em28xx_uninit_usb_xfer(dev, mode); | ||
1216 | return rc; | ||
1217 | } | ||
1218 | } | ||
1219 | |||
1162 | init_waitqueue_head(&dma_q->wq); | 1220 | init_waitqueue_head(&dma_q->wq); |
1163 | init_waitqueue_head(&vbi_dma_q->wq); | 1221 | init_waitqueue_head(&vbi_dma_q->wq); |
1164 | 1222 | ||
1165 | em28xx_capture_start(dev, 1); | 1223 | em28xx_capture_start(dev, 1); |
1166 | 1224 | ||
1167 | /* submit urbs and enables IRQ */ | 1225 | /* submit urbs and enables IRQ */ |
1168 | for (i = 0; i < isoc_bufs->num_bufs; i++) { | 1226 | for (i = 0; i < usb_bufs->num_bufs; i++) { |
1169 | rc = usb_submit_urb(isoc_bufs->urb[i], GFP_ATOMIC); | 1227 | rc = usb_submit_urb(usb_bufs->urb[i], GFP_ATOMIC); |
1170 | if (rc) { | 1228 | if (rc) { |
1171 | em28xx_err("submit of urb %i failed (error=%i)\n", i, | 1229 | em28xx_err("submit of urb %i failed (error=%i)\n", i, |
1172 | rc); | 1230 | rc); |
1173 | em28xx_uninit_isoc(dev, mode); | 1231 | em28xx_uninit_usb_xfer(dev, mode); |
1174 | return rc; | 1232 | return rc; |
1175 | } | 1233 | } |
1176 | } | 1234 | } |
1177 | 1235 | ||
1178 | return 0; | 1236 | return 0; |
1179 | } | 1237 | } |
1180 | EXPORT_SYMBOL_GPL(em28xx_init_isoc); | 1238 | EXPORT_SYMBOL_GPL(em28xx_init_usb_xfer); |
1181 | 1239 | ||
1182 | /* | 1240 | /* |
1183 | * em28xx_wake_i2c() | 1241 | * em28xx_wake_i2c() |
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 63f2e7070c00..a81ec2e8cc9b 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c | |||
@@ -10,6 +10,8 @@ | |||
10 | 10 | ||
11 | (c) 2008 Aidan Thornton <makosoft@googlemail.com> | 11 | (c) 2008 Aidan Thornton <makosoft@googlemail.com> |
12 | 12 | ||
13 | (c) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
14 | |||
13 | Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by: | 15 | Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by: |
14 | (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> | 16 | (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> |
15 | (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] | 17 | (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] |
@@ -25,7 +27,9 @@ | |||
25 | 27 | ||
26 | #include "em28xx.h" | 28 | #include "em28xx.h" |
27 | #include <media/v4l2-common.h> | 29 | #include <media/v4l2-common.h> |
28 | #include <media/videobuf-vmalloc.h> | 30 | #include <dvb_demux.h> |
31 | #include <dvb_net.h> | ||
32 | #include <dmxdev.h> | ||
29 | #include <media/tuner.h> | 33 | #include <media/tuner.h> |
30 | #include "tuner-simple.h" | 34 | #include "tuner-simple.h" |
31 | #include <linux/gpio.h> | 35 | #include <linux/gpio.h> |
@@ -124,34 +128,47 @@ static inline void print_err_status(struct em28xx *dev, | |||
124 | } | 128 | } |
125 | } | 129 | } |
126 | 130 | ||
127 | static inline int em28xx_dvb_isoc_copy(struct em28xx *dev, struct urb *urb) | 131 | static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb) |
128 | { | 132 | { |
129 | int i; | 133 | int xfer_bulk, num_packets, i; |
130 | 134 | ||
131 | if (!dev) | 135 | if (!dev) |
132 | return 0; | 136 | return 0; |
133 | 137 | ||
134 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | 138 | if (dev->disconnected) |
135 | return 0; | 139 | return 0; |
136 | 140 | ||
137 | if (urb->status < 0) { | 141 | if (urb->status < 0) |
138 | print_err_status(dev, -1, urb->status); | 142 | print_err_status(dev, -1, urb->status); |
139 | if (urb->status == -ENOENT) | ||
140 | return 0; | ||
141 | } | ||
142 | 143 | ||
143 | for (i = 0; i < urb->number_of_packets; i++) { | 144 | xfer_bulk = usb_pipebulk(urb->pipe); |
144 | int status = urb->iso_frame_desc[i].status; | ||
145 | 145 | ||
146 | if (status < 0) { | 146 | if (xfer_bulk) /* bulk */ |
147 | print_err_status(dev, i, status); | 147 | num_packets = 1; |
148 | if (urb->iso_frame_desc[i].status != -EPROTO) | 148 | else /* isoc */ |
149 | continue; | 149 | num_packets = urb->number_of_packets; |
150 | } | ||
151 | 150 | ||
152 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + | 151 | for (i = 0; i < num_packets; i++) { |
153 | urb->iso_frame_desc[i].offset, | 152 | if (xfer_bulk) { |
154 | urb->iso_frame_desc[i].actual_length); | 153 | if (urb->status < 0) { |
154 | print_err_status(dev, i, urb->status); | ||
155 | if (urb->status != -EPROTO) | ||
156 | continue; | ||
157 | } | ||
158 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer, | ||
159 | urb->actual_length); | ||
160 | } else { | ||
161 | if (urb->iso_frame_desc[i].status < 0) { | ||
162 | print_err_status(dev, i, | ||
163 | urb->iso_frame_desc[i].status); | ||
164 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
165 | continue; | ||
166 | } | ||
167 | dvb_dmx_swfilter(&dev->dvb->demux, | ||
168 | urb->transfer_buffer + | ||
169 | urb->iso_frame_desc[i].offset, | ||
170 | urb->iso_frame_desc[i].actual_length); | ||
171 | } | ||
155 | } | 172 | } |
156 | 173 | ||
157 | return 0; | 174 | return 0; |
@@ -161,24 +178,40 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb) | |||
161 | { | 178 | { |
162 | int rc; | 179 | int rc; |
163 | struct em28xx *dev = dvb->adapter.priv; | 180 | struct em28xx *dev = dvb->adapter.priv; |
164 | int max_dvb_packet_size; | 181 | int dvb_max_packet_size, packet_multiplier, dvb_alt; |
182 | |||
183 | if (dev->dvb_xfer_bulk) { | ||
184 | if (!dev->dvb_ep_bulk) | ||
185 | return -ENODEV; | ||
186 | dvb_max_packet_size = 512; /* USB 2.0 spec */ | ||
187 | packet_multiplier = EM28XX_DVB_BULK_PACKET_MULTIPLIER; | ||
188 | dvb_alt = 0; | ||
189 | } else { /* isoc */ | ||
190 | if (!dev->dvb_ep_isoc) | ||
191 | return -ENODEV; | ||
192 | dvb_max_packet_size = dev->dvb_max_pkt_size_isoc; | ||
193 | if (dvb_max_packet_size < 0) | ||
194 | return dvb_max_packet_size; | ||
195 | packet_multiplier = EM28XX_DVB_NUM_ISOC_PACKETS; | ||
196 | dvb_alt = dev->dvb_alt_isoc; | ||
197 | } | ||
165 | 198 | ||
166 | usb_set_interface(dev->udev, 0, dev->dvb_alt); | 199 | usb_set_interface(dev->udev, 0, dvb_alt); |
167 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); | 200 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
168 | if (rc < 0) | 201 | if (rc < 0) |
169 | return rc; | 202 | return rc; |
170 | 203 | ||
171 | max_dvb_packet_size = dev->dvb_max_pkt_size; | ||
172 | if (max_dvb_packet_size < 0) | ||
173 | return max_dvb_packet_size; | ||
174 | dprintk(1, "Using %d buffers each with %d x %d bytes\n", | 204 | dprintk(1, "Using %d buffers each with %d x %d bytes\n", |
175 | EM28XX_DVB_NUM_BUFS, | 205 | EM28XX_DVB_NUM_BUFS, |
176 | EM28XX_DVB_MAX_PACKETS, | 206 | packet_multiplier, |
177 | max_dvb_packet_size); | 207 | dvb_max_packet_size); |
178 | 208 | ||
179 | return em28xx_init_isoc(dev, EM28XX_DIGITAL_MODE, | 209 | return em28xx_init_usb_xfer(dev, EM28XX_DIGITAL_MODE, |
180 | EM28XX_DVB_MAX_PACKETS, EM28XX_DVB_NUM_BUFS, | 210 | dev->dvb_xfer_bulk, |
181 | max_dvb_packet_size, em28xx_dvb_isoc_copy); | 211 | EM28XX_DVB_NUM_BUFS, |
212 | dvb_max_packet_size, | ||
213 | packet_multiplier, | ||
214 | em28xx_dvb_urb_data_copy); | ||
182 | } | 215 | } |
183 | 216 | ||
184 | static int em28xx_stop_streaming(struct em28xx_dvb *dvb) | 217 | static int em28xx_stop_streaming(struct em28xx_dvb *dvb) |
@@ -714,7 +747,8 @@ static struct tda18271_config em28xx_cxd2820r_tda18271_config = { | |||
714 | }; | 747 | }; |
715 | 748 | ||
716 | static const struct tda10071_config em28xx_tda10071_config = { | 749 | static const struct tda10071_config em28xx_tda10071_config = { |
717 | .i2c_address = 0x55, /* (0xaa >> 1) */ | 750 | .demod_i2c_addr = 0x55, /* (0xaa >> 1) */ |
751 | .tuner_i2c_addr = 0x14, | ||
718 | .i2c_wr_max = 64, | 752 | .i2c_wr_max = 64, |
719 | .ts_mode = TDA10071_TS_SERIAL, | 753 | .ts_mode = TDA10071_TS_SERIAL, |
720 | .spec_inv = 0, | 754 | .spec_inv = 0, |
@@ -1288,7 +1322,7 @@ static int em28xx_dvb_fini(struct em28xx *dev) | |||
1288 | if (dev->dvb) { | 1322 | if (dev->dvb) { |
1289 | struct em28xx_dvb *dvb = dev->dvb; | 1323 | struct em28xx_dvb *dvb = dev->dvb; |
1290 | 1324 | ||
1291 | if (dev->state & DEV_DISCONNECTED) { | 1325 | if (dev->disconnected) { |
1292 | /* We cannot tell the device to sleep | 1326 | /* We cannot tell the device to sleep |
1293 | * once it has been unplugged. */ | 1327 | * once it has been unplugged. */ |
1294 | if (dvb->fe[0]) | 1328 | if (dvb->fe[0]) |
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c index 1683bd9d51ee..8532c1d4fd46 100644 --- a/drivers/media/usb/em28xx/em28xx-i2c.c +++ b/drivers/media/usb/em28xx/em28xx-i2c.c | |||
@@ -50,15 +50,18 @@ do { \ | |||
50 | } while (0) | 50 | } while (0) |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * em2800_i2c_send_max4() | 53 | * em2800_i2c_send_bytes() |
54 | * send up to 4 bytes to the i2c device | 54 | * send up to 4 bytes to the em2800 i2c device |
55 | */ | 55 | */ |
56 | static int em2800_i2c_send_max4(struct em28xx *dev, unsigned char addr, | 56 | static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) |
57 | char *buf, int len) | ||
58 | { | 57 | { |
59 | int ret; | 58 | int ret; |
60 | int write_timeout; | 59 | int write_timeout; |
61 | unsigned char b2[6]; | 60 | u8 b2[6]; |
61 | |||
62 | if (len < 1 || len > 4) | ||
63 | return -EOPNOTSUPP; | ||
64 | |||
62 | BUG_ON(len < 1 || len > 4); | 65 | BUG_ON(len < 1 || len > 4); |
63 | b2[5] = 0x80 + len - 1; | 66 | b2[5] = 0x80 + len - 1; |
64 | b2[4] = addr; | 67 | b2[4] = addr; |
@@ -70,165 +73,212 @@ static int em2800_i2c_send_max4(struct em28xx *dev, unsigned char addr, | |||
70 | if (len > 3) | 73 | if (len > 3) |
71 | b2[0] = buf[3]; | 74 | b2[0] = buf[3]; |
72 | 75 | ||
76 | /* trigger write */ | ||
73 | ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); | 77 | ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); |
74 | if (ret != 2 + len) { | 78 | if (ret != 2 + len) { |
75 | em28xx_warn("writing to i2c device failed (error=%i)\n", ret); | 79 | em28xx_warn("failed to trigger write to i2c address 0x%x " |
76 | return -EIO; | 80 | "(error=%i)\n", addr, ret); |
81 | return (ret < 0) ? ret : -EIO; | ||
77 | } | 82 | } |
78 | for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; | 83 | /* wait for completion */ |
84 | for (write_timeout = EM2800_I2C_XFER_TIMEOUT; write_timeout > 0; | ||
79 | write_timeout -= 5) { | 85 | write_timeout -= 5) { |
80 | ret = dev->em28xx_read_reg(dev, 0x05); | 86 | ret = dev->em28xx_read_reg(dev, 0x05); |
81 | if (ret == 0x80 + len - 1) | 87 | if (ret == 0x80 + len - 1) { |
82 | return len; | 88 | return len; |
89 | } else if (ret == 0x94 + len - 1) { | ||
90 | return -ENODEV; | ||
91 | } else if (ret < 0) { | ||
92 | em28xx_warn("failed to get i2c transfer status from " | ||
93 | "bridge register (error=%i)\n", ret); | ||
94 | return ret; | ||
95 | } | ||
83 | msleep(5); | 96 | msleep(5); |
84 | } | 97 | } |
85 | em28xx_warn("i2c write timed out\n"); | 98 | em28xx_warn("write to i2c device at 0x%x timed out\n", addr); |
86 | return -EIO; | 99 | return -EIO; |
87 | } | 100 | } |
88 | 101 | ||
89 | /* | 102 | /* |
90 | * em2800_i2c_send_bytes() | 103 | * em2800_i2c_recv_bytes() |
91 | */ | 104 | * read up to 4 bytes from the em2800 i2c device |
92 | static int em2800_i2c_send_bytes(void *data, unsigned char addr, char *buf, | ||
93 | short len) | ||
94 | { | ||
95 | char *bufPtr = buf; | ||
96 | int ret; | ||
97 | int wrcount = 0; | ||
98 | int count; | ||
99 | int maxLen = 4; | ||
100 | struct em28xx *dev = (struct em28xx *)data; | ||
101 | while (len > 0) { | ||
102 | count = (len > maxLen) ? maxLen : len; | ||
103 | ret = em2800_i2c_send_max4(dev, addr, bufPtr, count); | ||
104 | if (ret > 0) { | ||
105 | len -= count; | ||
106 | bufPtr += count; | ||
107 | wrcount += count; | ||
108 | } else | ||
109 | return (ret < 0) ? ret : -EFAULT; | ||
110 | } | ||
111 | return wrcount; | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * em2800_i2c_check_for_device() | ||
116 | * check if there is a i2c_device at the supplied address | ||
117 | */ | 105 | */ |
118 | static int em2800_i2c_check_for_device(struct em28xx *dev, unsigned char addr) | 106 | static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len) |
119 | { | 107 | { |
120 | char msg; | 108 | u8 buf2[4]; |
121 | int ret; | 109 | int ret; |
122 | int write_timeout; | 110 | int read_timeout; |
123 | msg = addr; | 111 | int i; |
124 | ret = dev->em28xx_write_regs(dev, 0x04, &msg, 1); | 112 | |
125 | if (ret < 0) { | 113 | if (len < 1 || len > 4) |
126 | em28xx_warn("setting i2c device address failed (error=%i)\n", | 114 | return -EOPNOTSUPP; |
127 | ret); | 115 | |
128 | return ret; | 116 | /* trigger read */ |
129 | } | 117 | buf2[1] = 0x84 + len - 1; |
130 | msg = 0x84; | 118 | buf2[0] = addr; |
131 | ret = dev->em28xx_write_regs(dev, 0x05, &msg, 1); | 119 | ret = dev->em28xx_write_regs(dev, 0x04, buf2, 2); |
132 | if (ret < 0) { | 120 | if (ret != 2) { |
133 | em28xx_warn("preparing i2c read failed (error=%i)\n", ret); | 121 | em28xx_warn("failed to trigger read from i2c address 0x%x " |
134 | return ret; | 122 | "(error=%i)\n", addr, ret); |
123 | return (ret < 0) ? ret : -EIO; | ||
135 | } | 124 | } |
136 | for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; | ||
137 | write_timeout -= 5) { | ||
138 | unsigned reg = dev->em28xx_read_reg(dev, 0x5); | ||
139 | 125 | ||
140 | if (reg == 0x94) | 126 | /* wait for completion */ |
127 | for (read_timeout = EM2800_I2C_XFER_TIMEOUT; read_timeout > 0; | ||
128 | read_timeout -= 5) { | ||
129 | ret = dev->em28xx_read_reg(dev, 0x05); | ||
130 | if (ret == 0x84 + len - 1) { | ||
131 | break; | ||
132 | } else if (ret == 0x94 + len - 1) { | ||
141 | return -ENODEV; | 133 | return -ENODEV; |
142 | else if (reg == 0x84) | 134 | } else if (ret < 0) { |
143 | return 0; | 135 | em28xx_warn("failed to get i2c transfer status from " |
136 | "bridge register (error=%i)\n", ret); | ||
137 | return ret; | ||
138 | } | ||
144 | msleep(5); | 139 | msleep(5); |
145 | } | 140 | } |
146 | return -ENODEV; | 141 | if (ret != 0x84 + len - 1) |
142 | em28xx_warn("read from i2c device at 0x%x timed out\n", addr); | ||
143 | |||
144 | /* get the received message */ | ||
145 | ret = dev->em28xx_read_reg_req_len(dev, 0x00, 4-len, buf2, len); | ||
146 | if (ret != len) { | ||
147 | em28xx_warn("reading from i2c device at 0x%x failed: " | ||
148 | "couldn't get the received message from the bridge " | ||
149 | "(error=%i)\n", addr, ret); | ||
150 | return (ret < 0) ? ret : -EIO; | ||
151 | } | ||
152 | for (i = 0; i < len; i++) | ||
153 | buf[i] = buf2[len - 1 - i]; | ||
154 | |||
155 | return ret; | ||
147 | } | 156 | } |
148 | 157 | ||
149 | /* | 158 | /* |
150 | * em2800_i2c_recv_bytes() | 159 | * em2800_i2c_check_for_device() |
151 | * read from the i2c device | 160 | * check if there is an i2c device at the supplied address |
152 | */ | 161 | */ |
153 | static int em2800_i2c_recv_bytes(struct em28xx *dev, unsigned char addr, | 162 | static int em2800_i2c_check_for_device(struct em28xx *dev, u8 addr) |
154 | char *buf, int len) | ||
155 | { | 163 | { |
164 | u8 buf; | ||
156 | int ret; | 165 | int ret; |
157 | /* check for the device and set i2c read address */ | 166 | |
158 | ret = em2800_i2c_check_for_device(dev, addr); | 167 | ret = em2800_i2c_recv_bytes(dev, addr, &buf, 1); |
159 | if (ret) { | 168 | if (ret == 1) |
160 | em28xx_warn | 169 | return 0; |
161 | ("preparing read at i2c address 0x%x failed (error=%i)\n", | 170 | return (ret < 0) ? ret : -EIO; |
162 | addr, ret); | ||
163 | return ret; | ||
164 | } | ||
165 | ret = dev->em28xx_read_reg_req_len(dev, 0x0, 0x3, buf, len); | ||
166 | if (ret < 0) { | ||
167 | em28xx_warn("reading from i2c device at 0x%x failed (error=%i)", | ||
168 | addr, ret); | ||
169 | return ret; | ||
170 | } | ||
171 | return ret; | ||
172 | } | 171 | } |
173 | 172 | ||
174 | /* | 173 | /* |
175 | * em28xx_i2c_send_bytes() | 174 | * em28xx_i2c_send_bytes() |
176 | */ | 175 | */ |
177 | static int em28xx_i2c_send_bytes(void *data, unsigned char addr, char *buf, | 176 | static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf, |
178 | short len, int stop) | 177 | u16 len, int stop) |
179 | { | 178 | { |
180 | int wrcount = 0; | ||
181 | struct em28xx *dev = (struct em28xx *)data; | ||
182 | int write_timeout, ret; | 179 | int write_timeout, ret; |
183 | 180 | ||
184 | wrcount = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); | 181 | if (len < 1 || len > 64) |
182 | return -EOPNOTSUPP; | ||
183 | /* NOTE: limited by the USB ctrl message constraints | ||
184 | * Zero length reads always succeed, even if no device is connected */ | ||
185 | |||
186 | /* Write to i2c device */ | ||
187 | ret = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); | ||
188 | if (ret != len) { | ||
189 | if (ret < 0) { | ||
190 | em28xx_warn("writing to i2c device at 0x%x failed " | ||
191 | "(error=%i)\n", addr, ret); | ||
192 | return ret; | ||
193 | } else { | ||
194 | em28xx_warn("%i bytes write to i2c device at 0x%x " | ||
195 | "requested, but %i bytes written\n", | ||
196 | len, addr, ret); | ||
197 | return -EIO; | ||
198 | } | ||
199 | } | ||
185 | 200 | ||
186 | /* Seems to be required after a write */ | 201 | /* Check success of the i2c operation */ |
187 | for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; | 202 | for (write_timeout = EM2800_I2C_XFER_TIMEOUT; write_timeout > 0; |
188 | write_timeout -= 5) { | 203 | write_timeout -= 5) { |
189 | ret = dev->em28xx_read_reg(dev, 0x05); | 204 | ret = dev->em28xx_read_reg(dev, 0x05); |
190 | if (!ret) | 205 | if (ret == 0) { /* success */ |
191 | break; | 206 | return len; |
207 | } else if (ret == 0x10) { | ||
208 | return -ENODEV; | ||
209 | } else if (ret < 0) { | ||
210 | em28xx_warn("failed to read i2c transfer status from " | ||
211 | "bridge (error=%i)\n", ret); | ||
212 | return ret; | ||
213 | } | ||
192 | msleep(5); | 214 | msleep(5); |
215 | /* NOTE: do we really have to wait for success ? | ||
216 | Never seen anything else than 0x00 or 0x10 | ||
217 | (even with high payload) ... */ | ||
193 | } | 218 | } |
194 | 219 | em28xx_warn("write to i2c device at 0x%x timed out\n", addr); | |
195 | return wrcount; | 220 | return -EIO; |
196 | } | 221 | } |
197 | 222 | ||
198 | /* | 223 | /* |
199 | * em28xx_i2c_recv_bytes() | 224 | * em28xx_i2c_recv_bytes() |
200 | * read a byte from the i2c device | 225 | * read a byte from the i2c device |
201 | */ | 226 | */ |
202 | static int em28xx_i2c_recv_bytes(struct em28xx *dev, unsigned char addr, | 227 | static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len) |
203 | char *buf, int len) | ||
204 | { | 228 | { |
205 | int ret; | 229 | int ret; |
230 | |||
231 | if (len < 1 || len > 64) | ||
232 | return -EOPNOTSUPP; | ||
233 | /* NOTE: limited by the USB ctrl message constraints | ||
234 | * Zero length reads always succeed, even if no device is connected */ | ||
235 | |||
236 | /* Read data from i2c device */ | ||
206 | ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); | 237 | ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len); |
238 | if (ret != len) { | ||
239 | if (ret < 0) { | ||
240 | em28xx_warn("reading from i2c device at 0x%x failed " | ||
241 | "(error=%i)\n", addr, ret); | ||
242 | return ret; | ||
243 | } else { | ||
244 | em28xx_warn("%i bytes requested from i2c device at " | ||
245 | "0x%x, but %i bytes received\n", | ||
246 | len, addr, ret); | ||
247 | return -EIO; | ||
248 | } | ||
249 | } | ||
250 | |||
251 | /* Check success of the i2c operation */ | ||
252 | ret = dev->em28xx_read_reg(dev, 0x05); | ||
207 | if (ret < 0) { | 253 | if (ret < 0) { |
208 | em28xx_warn("reading i2c device failed (error=%i)\n", ret); | 254 | em28xx_warn("failed to read i2c transfer status from " |
255 | "bridge (error=%i)\n", ret); | ||
209 | return ret; | 256 | return ret; |
210 | } | 257 | } |
211 | if (dev->em28xx_read_reg(dev, 0x5) != 0) | 258 | if (ret > 0) { |
212 | return -ENODEV; | 259 | if (ret == 0x10) { |
213 | return ret; | 260 | return -ENODEV; |
261 | } else { | ||
262 | em28xx_warn("unknown i2c error (status=%i)\n", ret); | ||
263 | return -EIO; | ||
264 | } | ||
265 | } | ||
266 | return len; | ||
214 | } | 267 | } |
215 | 268 | ||
216 | /* | 269 | /* |
217 | * em28xx_i2c_check_for_device() | 270 | * em28xx_i2c_check_for_device() |
218 | * check if there is a i2c_device at the supplied address | 271 | * check if there is a i2c_device at the supplied address |
219 | */ | 272 | */ |
220 | static int em28xx_i2c_check_for_device(struct em28xx *dev, unsigned char addr) | 273 | static int em28xx_i2c_check_for_device(struct em28xx *dev, u16 addr) |
221 | { | 274 | { |
222 | int ret; | 275 | int ret; |
276 | u8 buf; | ||
223 | 277 | ||
224 | ret = dev->em28xx_read_reg_req(dev, 2, addr); | 278 | ret = em28xx_i2c_recv_bytes(dev, addr, &buf, 1); |
225 | if (ret < 0) { | 279 | if (ret == 1) |
226 | em28xx_warn("reading from i2c device failed (error=%i)\n", ret); | 280 | return 0; |
227 | return ret; | 281 | return (ret < 0) ? ret : -EIO; |
228 | } | ||
229 | if (dev->em28xx_read_reg(dev, 0x5) != 0) | ||
230 | return -ENODEV; | ||
231 | return 0; | ||
232 | } | 282 | } |
233 | 283 | ||
234 | /* | 284 | /* |
@@ -253,11 +303,11 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
253 | rc = em2800_i2c_check_for_device(dev, addr); | 303 | rc = em2800_i2c_check_for_device(dev, addr); |
254 | else | 304 | else |
255 | rc = em28xx_i2c_check_for_device(dev, addr); | 305 | rc = em28xx_i2c_check_for_device(dev, addr); |
256 | if (rc < 0) { | 306 | if (rc == -ENODEV) { |
257 | dprintk2(2, " no device\n"); | 307 | if (i2c_debug >= 2) |
308 | printk(" no device\n"); | ||
258 | return rc; | 309 | return rc; |
259 | } | 310 | } |
260 | |||
261 | } else if (msgs[i].flags & I2C_M_RD) { | 311 | } else if (msgs[i].flags & I2C_M_RD) { |
262 | /* read bytes */ | 312 | /* read bytes */ |
263 | if (dev->board.is_em2800) | 313 | if (dev->board.is_em2800) |
@@ -288,16 +338,16 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
288 | msgs[i].len, | 338 | msgs[i].len, |
289 | i == num - 1); | 339 | i == num - 1); |
290 | } | 340 | } |
291 | if (rc < 0) | 341 | if (rc < 0) { |
292 | goto err; | 342 | if (i2c_debug >= 2) |
343 | printk(" ERROR: %i\n", rc); | ||
344 | return rc; | ||
345 | } | ||
293 | if (i2c_debug >= 2) | 346 | if (i2c_debug >= 2) |
294 | printk("\n"); | 347 | printk("\n"); |
295 | } | 348 | } |
296 | 349 | ||
297 | return num; | 350 | return num; |
298 | err: | ||
299 | dprintk2(2, " ERROR: %i\n", rc); | ||
300 | return rc; | ||
301 | } | 351 | } |
302 | 352 | ||
303 | /* based on linux/sunrpc/svcauth.h and linux/hash.h | 353 | /* based on linux/sunrpc/svcauth.h and linux/hash.h |
@@ -329,7 +379,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
329 | { | 379 | { |
330 | unsigned char buf, *p = eedata; | 380 | unsigned char buf, *p = eedata; |
331 | struct em28xx_eeprom *em_eeprom = (void *)eedata; | 381 | struct em28xx_eeprom *em_eeprom = (void *)eedata; |
332 | int i, err, size = len, block; | 382 | int i, err, size = len, block, block_max; |
333 | 383 | ||
334 | if (dev->chip_id == CHIP_ID_EM2874 || | 384 | if (dev->chip_id == CHIP_ID_EM2874 || |
335 | dev->chip_id == CHIP_ID_EM28174 || | 385 | dev->chip_id == CHIP_ID_EM28174 || |
@@ -362,9 +412,15 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
362 | dev->name, err); | 412 | dev->name, err); |
363 | return err; | 413 | return err; |
364 | } | 414 | } |
415 | |||
416 | if (dev->board.is_em2800) | ||
417 | block_max = 4; | ||
418 | else | ||
419 | block_max = 64; | ||
420 | |||
365 | while (size > 0) { | 421 | while (size > 0) { |
366 | if (size > 16) | 422 | if (size > block_max) |
367 | block = 16; | 423 | block = block_max; |
368 | else | 424 | else |
369 | block = size; | 425 | block = size; |
370 | 426 | ||
@@ -449,7 +505,11 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
449 | */ | 505 | */ |
450 | static u32 functionality(struct i2c_adapter *adap) | 506 | static u32 functionality(struct i2c_adapter *adap) |
451 | { | 507 | { |
452 | return I2C_FUNC_SMBUS_EMUL; | 508 | struct em28xx *dev = adap->algo_data; |
509 | u32 func_flags = I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; | ||
510 | if (dev->board.is_em2800) | ||
511 | func_flags &= ~I2C_FUNC_SMBUS_WRITE_BLOCK_DATA; | ||
512 | return func_flags; | ||
453 | } | 513 | } |
454 | 514 | ||
455 | static struct i2c_algorithm em28xx_algo = { | 515 | static struct i2c_algorithm em28xx_algo = { |
@@ -474,6 +534,7 @@ static struct i2c_client em28xx_client_template = { | |||
474 | * incomplete list of known devices | 534 | * incomplete list of known devices |
475 | */ | 535 | */ |
476 | static char *i2c_devs[128] = { | 536 | static char *i2c_devs[128] = { |
537 | [0x3e >> 1] = "remote IR sensor", | ||
477 | [0x4a >> 1] = "saa7113h", | 538 | [0x4a >> 1] = "saa7113h", |
478 | [0x52 >> 1] = "drxk", | 539 | [0x52 >> 1] = "drxk", |
479 | [0x60 >> 1] = "remote IR sensor", | 540 | [0x60 >> 1] = "remote IR sensor", |
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c index 660bf803c9e4..1bef990b3f18 100644 --- a/drivers/media/usb/em28xx/em28xx-input.c +++ b/drivers/media/usb/em28xx/em28xx-input.c | |||
@@ -40,11 +40,6 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | |||
40 | 40 | ||
41 | #define MODULE_NAME "em28xx" | 41 | #define MODULE_NAME "em28xx" |
42 | 42 | ||
43 | #define i2cdprintk(fmt, arg...) \ | ||
44 | if (ir_debug) { \ | ||
45 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \ | ||
46 | } | ||
47 | |||
48 | #define dprintk(fmt, arg...) \ | 43 | #define dprintk(fmt, arg...) \ |
49 | if (ir_debug) { \ | 44 | if (ir_debug) { \ |
50 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \ | 45 | printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \ |
@@ -57,8 +52,8 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | |||
57 | struct em28xx_ir_poll_result { | 52 | struct em28xx_ir_poll_result { |
58 | unsigned int toggle_bit:1; | 53 | unsigned int toggle_bit:1; |
59 | unsigned int read_count:7; | 54 | unsigned int read_count:7; |
60 | u8 rc_address; | 55 | |
61 | u8 rc_data[4]; /* 1 byte on em2860/2880, 4 on em2874 */ | 56 | u32 scancode; |
62 | }; | 57 | }; |
63 | 58 | ||
64 | struct em28xx_IR { | 59 | struct em28xx_IR { |
@@ -67,12 +62,17 @@ struct em28xx_IR { | |||
67 | char name[32]; | 62 | char name[32]; |
68 | char phys[32]; | 63 | char phys[32]; |
69 | 64 | ||
70 | /* poll external decoder */ | 65 | /* poll decoder */ |
71 | int polling; | 66 | int polling; |
72 | struct delayed_work work; | 67 | struct delayed_work work; |
73 | unsigned int full_code:1; | 68 | unsigned int full_code:1; |
74 | unsigned int last_readcount; | 69 | unsigned int last_readcount; |
70 | u64 rc_type; | ||
75 | 71 | ||
72 | /* i2c slave address of external device (if used) */ | ||
73 | u16 i2c_dev_addr; | ||
74 | |||
75 | int (*get_key_i2c)(struct i2c_client *, u32 *); | ||
76 | int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); | 76 | int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); |
77 | }; | 77 | }; |
78 | 78 | ||
@@ -80,21 +80,16 @@ struct em28xx_IR { | |||
80 | I2C IR based get keycodes - should be used with ir-kbd-i2c | 80 | I2C IR based get keycodes - should be used with ir-kbd-i2c |
81 | **********************************************************/ | 81 | **********************************************************/ |
82 | 82 | ||
83 | static int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 83 | static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, u32 *ir_key) |
84 | { | 84 | { |
85 | unsigned char b; | 85 | unsigned char b; |
86 | 86 | ||
87 | /* poll IR chip */ | 87 | /* poll IR chip */ |
88 | if (1 != i2c_master_recv(ir->c, &b, 1)) { | 88 | if (1 != i2c_master_recv(i2c_dev, &b, 1)) |
89 | i2cdprintk("read error\n"); | ||
90 | return -EIO; | 89 | return -EIO; |
91 | } | ||
92 | 90 | ||
93 | /* it seems that 0xFE indicates that a button is still hold | 91 | /* it seems that 0xFE indicates that a button is still hold |
94 | down, while 0xff indicates that no button is hold | 92 | down, while 0xff indicates that no button is hold down. */ |
95 | down. 0xfe sequences are sometimes interrupted by 0xFF */ | ||
96 | |||
97 | i2cdprintk("key %02x\n", b); | ||
98 | 93 | ||
99 | if (b == 0xff) | 94 | if (b == 0xff) |
100 | return 0; | 95 | return 0; |
@@ -104,18 +99,17 @@ static int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
104 | return 1; | 99 | return 1; |
105 | 100 | ||
106 | *ir_key = b; | 101 | *ir_key = b; |
107 | *ir_raw = b; | ||
108 | return 1; | 102 | return 1; |
109 | } | 103 | } |
110 | 104 | ||
111 | static int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 105 | static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, u32 *ir_key) |
112 | { | 106 | { |
113 | unsigned char buf[2]; | 107 | unsigned char buf[2]; |
114 | u16 code; | 108 | u16 code; |
115 | int size; | 109 | int size; |
116 | 110 | ||
117 | /* poll IR chip */ | 111 | /* poll IR chip */ |
118 | size = i2c_master_recv(ir->c, buf, sizeof(buf)); | 112 | size = i2c_master_recv(i2c_dev, buf, sizeof(buf)); |
119 | 113 | ||
120 | if (size != 2) | 114 | if (size != 2) |
121 | return -EIO; | 115 | return -EIO; |
@@ -124,8 +118,6 @@ static int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
124 | if (buf[1] == 0xff) | 118 | if (buf[1] == 0xff) |
125 | return 0; | 119 | return 0; |
126 | 120 | ||
127 | ir->old = buf[1]; | ||
128 | |||
129 | /* | 121 | /* |
130 | * Rearranges bits to the right order. | 122 | * Rearranges bits to the right order. |
131 | * The bit order were determined experimentally by using | 123 | * The bit order were determined experimentally by using |
@@ -148,65 +140,51 @@ static int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
148 | ((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010 */ | 140 | ((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010 */ |
149 | ((buf[1] & 0x80) ? 0x0100 : 0); /* 0000 0001 */ | 141 | ((buf[1] & 0x80) ? 0x0100 : 0); /* 0000 0001 */ |
150 | 142 | ||
151 | i2cdprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x%02x)\n", | ||
152 | code, buf[1], buf[0]); | ||
153 | |||
154 | /* return key */ | 143 | /* return key */ |
155 | *ir_key = code; | 144 | *ir_key = code; |
156 | *ir_raw = code; | ||
157 | return 1; | 145 | return 1; |
158 | } | 146 | } |
159 | 147 | ||
160 | static int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | 148 | static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev, |
161 | u32 *ir_raw) | 149 | u32 *ir_key) |
162 | { | 150 | { |
163 | unsigned char buf[3]; | 151 | unsigned char buf[3]; |
164 | 152 | ||
165 | /* poll IR chip */ | 153 | /* poll IR chip */ |
166 | 154 | ||
167 | if (3 != i2c_master_recv(ir->c, buf, 3)) { | 155 | if (3 != i2c_master_recv(i2c_dev, buf, 3)) |
168 | i2cdprintk("read error\n"); | ||
169 | return -EIO; | 156 | return -EIO; |
170 | } | ||
171 | 157 | ||
172 | i2cdprintk("key %02x\n", buf[2]&0x3f); | ||
173 | if (buf[0] != 0x00) | 158 | if (buf[0] != 0x00) |
174 | return 0; | 159 | return 0; |
175 | 160 | ||
176 | *ir_key = buf[2]&0x3f; | 161 | *ir_key = buf[2]&0x3f; |
177 | *ir_raw = buf[2]&0x3f; | ||
178 | 162 | ||
179 | return 1; | 163 | return 1; |
180 | } | 164 | } |
181 | 165 | ||
182 | static int em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key, | 166 | static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev, |
183 | u32 *ir_raw) | 167 | u32 *ir_key) |
184 | { | 168 | { |
185 | unsigned char subaddr, keydetect, key; | 169 | unsigned char subaddr, keydetect, key; |
186 | 170 | ||
187 | struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, .buf = &subaddr, .len = 1}, | 171 | struct i2c_msg msg[] = { { .addr = i2c_dev->addr, .flags = 0, .buf = &subaddr, .len = 1}, |
188 | 172 | { .addr = i2c_dev->addr, .flags = I2C_M_RD, .buf = &keydetect, .len = 1} }; | |
189 | { .addr = ir->c->addr, .flags = I2C_M_RD, .buf = &keydetect, .len = 1} }; | ||
190 | 173 | ||
191 | subaddr = 0x10; | 174 | subaddr = 0x10; |
192 | if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { | 175 | if (2 != i2c_transfer(i2c_dev->adapter, msg, 2)) |
193 | i2cdprintk("read error\n"); | ||
194 | return -EIO; | 176 | return -EIO; |
195 | } | ||
196 | if (keydetect == 0x00) | 177 | if (keydetect == 0x00) |
197 | return 0; | 178 | return 0; |
198 | 179 | ||
199 | subaddr = 0x00; | 180 | subaddr = 0x00; |
200 | msg[1].buf = &key; | 181 | msg[1].buf = &key; |
201 | if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { | 182 | if (2 != i2c_transfer(i2c_dev->adapter, msg, 2)) |
202 | i2cdprintk("read error\n"); | 183 | return -EIO; |
203 | return -EIO; | ||
204 | } | ||
205 | if (key == 0x00) | 184 | if (key == 0x00) |
206 | return 0; | 185 | return 0; |
207 | 186 | ||
208 | *ir_key = key; | 187 | *ir_key = key; |
209 | *ir_raw = key; | ||
210 | return 1; | 188 | return 1; |
211 | } | 189 | } |
212 | 190 | ||
@@ -236,11 +214,8 @@ static int default_polling_getkey(struct em28xx_IR *ir, | |||
236 | /* Infrared read count (Reg 0x45[6:0] */ | 214 | /* Infrared read count (Reg 0x45[6:0] */ |
237 | poll_result->read_count = (msg[0] & 0x7f); | 215 | poll_result->read_count = (msg[0] & 0x7f); |
238 | 216 | ||
239 | /* Remote Control Address (Reg 0x46) */ | 217 | /* Remote Control Address/Data (Regs 0x46/0x47) */ |
240 | poll_result->rc_address = msg[1]; | 218 | poll_result->scancode = msg[1] << 8 | msg[2]; |
241 | |||
242 | /* Remote Control Data (Reg 0x47) */ | ||
243 | poll_result->rc_data[0] = msg[2]; | ||
244 | 219 | ||
245 | return 0; | 220 | return 0; |
246 | } | 221 | } |
@@ -266,13 +241,35 @@ static int em2874_polling_getkey(struct em28xx_IR *ir, | |||
266 | /* Infrared read count (Reg 0x51[6:0] */ | 241 | /* Infrared read count (Reg 0x51[6:0] */ |
267 | poll_result->read_count = (msg[0] & 0x7f); | 242 | poll_result->read_count = (msg[0] & 0x7f); |
268 | 243 | ||
269 | /* Remote Control Address (Reg 0x52) */ | 244 | /* |
270 | poll_result->rc_address = msg[1]; | 245 | * Remote Control Address (Reg 0x52) |
271 | 246 | * Remote Control Data (Reg 0x53-0x55) | |
272 | /* Remote Control Data (Reg 0x53-55) */ | 247 | */ |
273 | poll_result->rc_data[0] = msg[2]; | 248 | switch (ir->rc_type) { |
274 | poll_result->rc_data[1] = msg[3]; | 249 | case RC_BIT_RC5: |
275 | poll_result->rc_data[2] = msg[4]; | 250 | poll_result->scancode = msg[1] << 8 | msg[2]; |
251 | break; | ||
252 | case RC_BIT_NEC: | ||
253 | if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */ | ||
254 | poll_result->scancode = (msg[1] << 24) | | ||
255 | (msg[2] << 16) | | ||
256 | (msg[3] << 8) | | ||
257 | msg[4]; | ||
258 | else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */ | ||
259 | poll_result->scancode = (msg[1] << 16) | | ||
260 | (msg[2] << 8) | | ||
261 | msg[3]; | ||
262 | else /* Normal NEC */ | ||
263 | poll_result->scancode = msg[1] << 8 | msg[3]; | ||
264 | break; | ||
265 | case RC_BIT_RC6_0: | ||
266 | poll_result->scancode = msg[1] << 8 | msg[2]; | ||
267 | break; | ||
268 | default: | ||
269 | poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) | | ||
270 | (msg[3] << 8) | msg[4]; | ||
271 | break; | ||
272 | } | ||
276 | 273 | ||
277 | return 0; | 274 | return 0; |
278 | } | 275 | } |
@@ -281,6 +278,28 @@ static int em2874_polling_getkey(struct em28xx_IR *ir, | |||
281 | Polling code for em28xx | 278 | Polling code for em28xx |
282 | **********************************************************/ | 279 | **********************************************************/ |
283 | 280 | ||
281 | static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir) | ||
282 | { | ||
283 | static u32 ir_key; | ||
284 | int rc; | ||
285 | struct i2c_client client; | ||
286 | |||
287 | client.adapter = &ir->dev->i2c_adap; | ||
288 | client.addr = ir->i2c_dev_addr; | ||
289 | |||
290 | rc = ir->get_key_i2c(&client, &ir_key); | ||
291 | if (rc < 0) { | ||
292 | dprintk("ir->get_key_i2c() failed: %d\n", rc); | ||
293 | return rc; | ||
294 | } | ||
295 | |||
296 | if (rc) { | ||
297 | dprintk("%s: keycode = 0x%04x\n", __func__, ir_key); | ||
298 | rc_keydown(ir->rc, ir_key, 0); | ||
299 | } | ||
300 | return 0; | ||
301 | } | ||
302 | |||
284 | static void em28xx_ir_handle_key(struct em28xx_IR *ir) | 303 | static void em28xx_ir_handle_key(struct em28xx_IR *ir) |
285 | { | 304 | { |
286 | int result; | 305 | int result; |
@@ -289,22 +308,21 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir) | |||
289 | /* read the registers containing the IR status */ | 308 | /* read the registers containing the IR status */ |
290 | result = ir->get_key(ir, &poll_result); | 309 | result = ir->get_key(ir, &poll_result); |
291 | if (unlikely(result < 0)) { | 310 | if (unlikely(result < 0)) { |
292 | dprintk("ir->get_key() failed %d\n", result); | 311 | dprintk("ir->get_key() failed: %d\n", result); |
293 | return; | 312 | return; |
294 | } | 313 | } |
295 | 314 | ||
296 | if (unlikely(poll_result.read_count != ir->last_readcount)) { | 315 | if (unlikely(poll_result.read_count != ir->last_readcount)) { |
297 | dprintk("%s: toggle: %d, count: %d, key 0x%02x%02x\n", __func__, | 316 | dprintk("%s: toggle: %d, count: %d, key 0x%04x\n", __func__, |
298 | poll_result.toggle_bit, poll_result.read_count, | 317 | poll_result.toggle_bit, poll_result.read_count, |
299 | poll_result.rc_address, poll_result.rc_data[0]); | 318 | poll_result.scancode); |
300 | if (ir->full_code) | 319 | if (ir->full_code) |
301 | rc_keydown(ir->rc, | 320 | rc_keydown(ir->rc, |
302 | poll_result.rc_address << 8 | | 321 | poll_result.scancode, |
303 | poll_result.rc_data[0], | ||
304 | poll_result.toggle_bit); | 322 | poll_result.toggle_bit); |
305 | else | 323 | else |
306 | rc_keydown(ir->rc, | 324 | rc_keydown(ir->rc, |
307 | poll_result.rc_data[0], | 325 | poll_result.scancode & 0xff, |
308 | poll_result.toggle_bit); | 326 | poll_result.toggle_bit); |
309 | 327 | ||
310 | if (ir->dev->chip_id == CHIP_ID_EM2874 || | 328 | if (ir->dev->chip_id == CHIP_ID_EM2874 || |
@@ -324,7 +342,10 @@ static void em28xx_ir_work(struct work_struct *work) | |||
324 | { | 342 | { |
325 | struct em28xx_IR *ir = container_of(work, struct em28xx_IR, work.work); | 343 | struct em28xx_IR *ir = container_of(work, struct em28xx_IR, work.work); |
326 | 344 | ||
327 | em28xx_ir_handle_key(ir); | 345 | if (ir->i2c_dev_addr) /* external i2c device */ |
346 | em28xx_i2c_ir_handle_key(ir); | ||
347 | else /* internal device */ | ||
348 | em28xx_ir_handle_key(ir); | ||
328 | schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); | 349 | schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); |
329 | } | 350 | } |
330 | 351 | ||
@@ -345,93 +366,107 @@ static void em28xx_ir_stop(struct rc_dev *rc) | |||
345 | cancel_delayed_work_sync(&ir->work); | 366 | cancel_delayed_work_sync(&ir->work); |
346 | } | 367 | } |
347 | 368 | ||
348 | static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) | 369 | static int em2860_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) |
349 | { | 370 | { |
350 | int rc = 0; | ||
351 | struct em28xx_IR *ir = rc_dev->priv; | 371 | struct em28xx_IR *ir = rc_dev->priv; |
352 | struct em28xx *dev = ir->dev; | 372 | struct em28xx *dev = ir->dev; |
353 | u8 ir_config = EM2874_IR_RC5; | ||
354 | |||
355 | /* Adjust xclk based o IR table for RC5/NEC tables */ | ||
356 | 373 | ||
374 | /* Adjust xclk based on IR table for RC5/NEC tables */ | ||
357 | if (*rc_type & RC_BIT_RC5) { | 375 | if (*rc_type & RC_BIT_RC5) { |
358 | dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; | 376 | dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; |
359 | ir->full_code = 1; | 377 | ir->full_code = 1; |
360 | *rc_type = RC_BIT_RC5; | 378 | *rc_type = RC_BIT_RC5; |
361 | } else if (*rc_type & RC_BIT_NEC) { | 379 | } else if (*rc_type & RC_BIT_NEC) { |
362 | dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; | 380 | dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; |
363 | ir_config = EM2874_IR_NEC; | ||
364 | ir->full_code = 1; | 381 | ir->full_code = 1; |
365 | *rc_type = RC_BIT_NEC; | 382 | *rc_type = RC_BIT_NEC; |
366 | } else if (*rc_type != RC_BIT_UNKNOWN) | 383 | } else if (*rc_type & RC_BIT_UNKNOWN) { |
367 | rc = -EINVAL; | 384 | *rc_type = RC_BIT_UNKNOWN; |
385 | } else { | ||
386 | *rc_type = ir->rc_type; | ||
387 | return -EINVAL; | ||
388 | } | ||
389 | em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, | ||
390 | EM28XX_XCLK_IR_RC5_MODE); | ||
391 | |||
392 | ir->rc_type = *rc_type; | ||
368 | 393 | ||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | static int em2874_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) | ||
398 | { | ||
399 | struct em28xx_IR *ir = rc_dev->priv; | ||
400 | struct em28xx *dev = ir->dev; | ||
401 | u8 ir_config = EM2874_IR_RC5; | ||
402 | |||
403 | /* Adjust xclk and set type based on IR table for RC5/NEC/RC6 tables */ | ||
404 | if (*rc_type & RC_BIT_RC5) { | ||
405 | dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; | ||
406 | ir->full_code = 1; | ||
407 | *rc_type = RC_BIT_RC5; | ||
408 | } else if (*rc_type & RC_BIT_NEC) { | ||
409 | dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; | ||
410 | ir_config = EM2874_IR_NEC | EM2874_IR_NEC_NO_PARITY; | ||
411 | ir->full_code = 1; | ||
412 | *rc_type = RC_BIT_NEC; | ||
413 | } else if (*rc_type & RC_BIT_RC6_0) { | ||
414 | dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; | ||
415 | ir_config = EM2874_IR_RC6_MODE_0; | ||
416 | ir->full_code = 1; | ||
417 | *rc_type = RC_BIT_RC6_0; | ||
418 | } else if (*rc_type & RC_BIT_UNKNOWN) { | ||
419 | *rc_type = RC_BIT_UNKNOWN; | ||
420 | } else { | ||
421 | *rc_type = ir->rc_type; | ||
422 | return -EINVAL; | ||
423 | } | ||
424 | em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1); | ||
369 | em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, | 425 | em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, |
370 | EM28XX_XCLK_IR_RC5_MODE); | 426 | EM28XX_XCLK_IR_RC5_MODE); |
371 | 427 | ||
428 | ir->rc_type = *rc_type; | ||
429 | |||
430 | return 0; | ||
431 | } | ||
432 | static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) | ||
433 | { | ||
434 | struct em28xx_IR *ir = rc_dev->priv; | ||
435 | struct em28xx *dev = ir->dev; | ||
436 | |||
372 | /* Setup the proper handler based on the chip */ | 437 | /* Setup the proper handler based on the chip */ |
373 | switch (dev->chip_id) { | 438 | switch (dev->chip_id) { |
374 | case CHIP_ID_EM2860: | 439 | case CHIP_ID_EM2860: |
375 | case CHIP_ID_EM2883: | 440 | case CHIP_ID_EM2883: |
376 | ir->get_key = default_polling_getkey; | 441 | return em2860_ir_change_protocol(rc_dev, rc_type); |
377 | break; | ||
378 | case CHIP_ID_EM2884: | 442 | case CHIP_ID_EM2884: |
379 | case CHIP_ID_EM2874: | 443 | case CHIP_ID_EM2874: |
380 | case CHIP_ID_EM28174: | 444 | case CHIP_ID_EM28174: |
381 | ir->get_key = em2874_polling_getkey; | 445 | return em2874_ir_change_protocol(rc_dev, rc_type); |
382 | em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1); | ||
383 | break; | ||
384 | default: | 446 | default: |
385 | printk("Unrecognized em28xx chip id 0x%02x: IR not supported\n", | 447 | printk("Unrecognized em28xx chip id 0x%02x: IR not supported\n", |
386 | dev->chip_id); | 448 | dev->chip_id); |
387 | rc = -EINVAL; | 449 | return -EINVAL; |
388 | } | 450 | } |
389 | |||
390 | return rc; | ||
391 | } | 451 | } |
392 | 452 | ||
393 | static void em28xx_register_i2c_ir(struct em28xx *dev) | 453 | static int em28xx_probe_i2c_ir(struct em28xx *dev) |
394 | { | 454 | { |
455 | int i = 0; | ||
395 | /* Leadtek winfast tv USBII deluxe can find a non working IR-device */ | 456 | /* Leadtek winfast tv USBII deluxe can find a non working IR-device */ |
396 | /* at address 0x18, so if that address is needed for another board in */ | 457 | /* at address 0x18, so if that address is needed for another board in */ |
397 | /* the future, please put it after 0x1f. */ | 458 | /* the future, please put it after 0x1f. */ |
398 | struct i2c_board_info info; | ||
399 | const unsigned short addr_list[] = { | 459 | const unsigned short addr_list[] = { |
400 | 0x1f, 0x30, 0x47, I2C_CLIENT_END | 460 | 0x1f, 0x30, 0x47, I2C_CLIENT_END |
401 | }; | 461 | }; |
402 | 462 | ||
403 | memset(&info, 0, sizeof(struct i2c_board_info)); | 463 | while (addr_list[i] != I2C_CLIENT_END) { |
404 | memset(&dev->init_data, 0, sizeof(dev->init_data)); | 464 | if (i2c_probe_func_quick_read(&dev->i2c_adap, addr_list[i]) == 1) |
405 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); | 465 | return addr_list[i]; |
406 | 466 | i++; | |
407 | /* detect & configure */ | ||
408 | switch (dev->model) { | ||
409 | case EM2800_BOARD_TERRATEC_CINERGY_200: | ||
410 | case EM2820_BOARD_TERRATEC_CINERGY_250: | ||
411 | dev->init_data.ir_codes = RC_MAP_EM_TERRATEC; | ||
412 | dev->init_data.get_key = em28xx_get_key_terratec; | ||
413 | dev->init_data.name = "i2c IR (EM28XX Terratec)"; | ||
414 | break; | ||
415 | case EM2820_BOARD_PINNACLE_USB_2: | ||
416 | dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY; | ||
417 | dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey; | ||
418 | dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)"; | ||
419 | break; | ||
420 | case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: | ||
421 | dev->init_data.ir_codes = RC_MAP_HAUPPAUGE; | ||
422 | dev->init_data.get_key = em28xx_get_key_em_haup; | ||
423 | dev->init_data.name = "i2c IR (EM2840 Hauppauge)"; | ||
424 | break; | ||
425 | case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: | ||
426 | dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE; | ||
427 | dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe; | ||
428 | dev->init_data.name = "i2c IR (EM2820 Winfast TV USBII Deluxe)"; | ||
429 | break; | ||
430 | } | 467 | } |
431 | 468 | ||
432 | if (dev->init_data.name) | 469 | return -ENODEV; |
433 | info.platform_data = &dev->init_data; | ||
434 | i2c_new_probed_device(&dev->i2c_adap, &info, addr_list, NULL); | ||
435 | } | 470 | } |
436 | 471 | ||
437 | /********************************************************** | 472 | /********************************************************** |
@@ -527,8 +562,21 @@ static int em28xx_ir_init(struct em28xx *dev) | |||
527 | struct rc_dev *rc; | 562 | struct rc_dev *rc; |
528 | int err = -ENOMEM; | 563 | int err = -ENOMEM; |
529 | u64 rc_type; | 564 | u64 rc_type; |
565 | u16 i2c_rc_dev_addr = 0; | ||
566 | |||
567 | if (dev->board.has_snapshot_button) | ||
568 | em28xx_register_snapshot_button(dev); | ||
569 | |||
570 | if (dev->board.has_ir_i2c) { | ||
571 | i2c_rc_dev_addr = em28xx_probe_i2c_ir(dev); | ||
572 | if (!i2c_rc_dev_addr) { | ||
573 | dev->board.has_ir_i2c = 0; | ||
574 | em28xx_warn("No i2c IR remote control device found.\n"); | ||
575 | return -ENODEV; | ||
576 | } | ||
577 | } | ||
530 | 578 | ||
531 | if (dev->board.ir_codes == NULL) { | 579 | if (dev->board.ir_codes == NULL && !dev->board.has_ir_i2c) { |
532 | /* No remote control support */ | 580 | /* No remote control support */ |
533 | em28xx_warn("Remote control support is not available for " | 581 | em28xx_warn("Remote control support is not available for " |
534 | "this card.\n"); | 582 | "this card.\n"); |
@@ -538,35 +586,77 @@ static int em28xx_ir_init(struct em28xx *dev) | |||
538 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); | 586 | ir = kzalloc(sizeof(*ir), GFP_KERNEL); |
539 | rc = rc_allocate_device(); | 587 | rc = rc_allocate_device(); |
540 | if (!ir || !rc) | 588 | if (!ir || !rc) |
541 | goto err_out_free; | 589 | goto error; |
542 | 590 | ||
543 | /* record handles to ourself */ | 591 | /* record handles to ourself */ |
544 | ir->dev = dev; | 592 | ir->dev = dev; |
545 | dev->ir = ir; | 593 | dev->ir = ir; |
546 | ir->rc = rc; | 594 | ir->rc = rc; |
547 | 595 | ||
548 | /* | ||
549 | * em2874 supports more protocols. For now, let's just announce | ||
550 | * the two protocols that were already tested | ||
551 | */ | ||
552 | rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; | ||
553 | rc->priv = ir; | 596 | rc->priv = ir; |
554 | rc->change_protocol = em28xx_ir_change_protocol; | ||
555 | rc->open = em28xx_ir_start; | 597 | rc->open = em28xx_ir_start; |
556 | rc->close = em28xx_ir_stop; | 598 | rc->close = em28xx_ir_stop; |
557 | 599 | ||
558 | /* By default, keep protocol field untouched */ | 600 | if (dev->board.has_ir_i2c) { /* external i2c device */ |
559 | rc_type = RC_BIT_UNKNOWN; | 601 | switch (dev->model) { |
560 | err = em28xx_ir_change_protocol(rc, &rc_type); | 602 | case EM2800_BOARD_TERRATEC_CINERGY_200: |
561 | if (err) | 603 | case EM2820_BOARD_TERRATEC_CINERGY_250: |
562 | goto err_out_free; | 604 | rc->map_name = RC_MAP_EM_TERRATEC; |
605 | ir->get_key_i2c = em28xx_get_key_terratec; | ||
606 | break; | ||
607 | case EM2820_BOARD_PINNACLE_USB_2: | ||
608 | rc->map_name = RC_MAP_PINNACLE_GREY; | ||
609 | ir->get_key_i2c = em28xx_get_key_pinnacle_usb_grey; | ||
610 | break; | ||
611 | case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: | ||
612 | rc->map_name = RC_MAP_HAUPPAUGE; | ||
613 | ir->get_key_i2c = em28xx_get_key_em_haup; | ||
614 | rc->allowed_protos = RC_BIT_RC5; | ||
615 | break; | ||
616 | case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: | ||
617 | rc->map_name = RC_MAP_WINFAST_USBII_DELUXE; | ||
618 | ir->get_key_i2c = em28xx_get_key_winfast_usbii_deluxe; | ||
619 | break; | ||
620 | default: | ||
621 | err = -ENODEV; | ||
622 | goto error; | ||
623 | } | ||
624 | |||
625 | ir->i2c_dev_addr = i2c_rc_dev_addr; | ||
626 | } else { /* internal device */ | ||
627 | switch (dev->chip_id) { | ||
628 | case CHIP_ID_EM2860: | ||
629 | case CHIP_ID_EM2883: | ||
630 | rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; | ||
631 | ir->get_key = default_polling_getkey; | ||
632 | break; | ||
633 | case CHIP_ID_EM2884: | ||
634 | case CHIP_ID_EM2874: | ||
635 | case CHIP_ID_EM28174: | ||
636 | ir->get_key = em2874_polling_getkey; | ||
637 | rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC | | ||
638 | RC_BIT_RC6_0; | ||
639 | break; | ||
640 | default: | ||
641 | err = -ENODEV; | ||
642 | goto error; | ||
643 | } | ||
644 | |||
645 | rc->change_protocol = em28xx_ir_change_protocol; | ||
646 | rc->map_name = dev->board.ir_codes; | ||
647 | |||
648 | /* By default, keep protocol field untouched */ | ||
649 | rc_type = RC_BIT_UNKNOWN; | ||
650 | err = em28xx_ir_change_protocol(rc, &rc_type); | ||
651 | if (err) | ||
652 | goto error; | ||
653 | } | ||
563 | 654 | ||
564 | /* This is how often we ask the chip for IR information */ | 655 | /* This is how often we ask the chip for IR information */ |
565 | ir->polling = 100; /* ms */ | 656 | ir->polling = 100; /* ms */ |
566 | 657 | ||
567 | /* init input device */ | 658 | /* init input device */ |
568 | snprintf(ir->name, sizeof(ir->name), "em28xx IR (%s)", | 659 | snprintf(ir->name, sizeof(ir->name), "em28xx IR (%s)", dev->name); |
569 | dev->name); | ||
570 | 660 | ||
571 | usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); | 661 | usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); |
572 | strlcat(ir->phys, "/input0", sizeof(ir->phys)); | 662 | strlcat(ir->phys, "/input0", sizeof(ir->phys)); |
@@ -578,28 +668,17 @@ static int em28xx_ir_init(struct em28xx *dev) | |||
578 | rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); | 668 | rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor); |
579 | rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct); | 669 | rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct); |
580 | rc->dev.parent = &dev->udev->dev; | 670 | rc->dev.parent = &dev->udev->dev; |
581 | rc->map_name = dev->board.ir_codes; | ||
582 | rc->driver_name = MODULE_NAME; | 671 | rc->driver_name = MODULE_NAME; |
583 | 672 | ||
584 | /* all done */ | 673 | /* all done */ |
585 | err = rc_register_device(rc); | 674 | err = rc_register_device(rc); |
586 | if (err) | 675 | if (err) |
587 | goto err_out_stop; | 676 | goto error; |
588 | |||
589 | em28xx_register_i2c_ir(dev); | ||
590 | |||
591 | #if defined(CONFIG_MODULES) && defined(MODULE) | ||
592 | if (dev->board.has_ir_i2c) | ||
593 | request_module("ir-kbd-i2c"); | ||
594 | #endif | ||
595 | if (dev->board.has_snapshot_button) | ||
596 | em28xx_register_snapshot_button(dev); | ||
597 | 677 | ||
598 | return 0; | 678 | return 0; |
599 | 679 | ||
600 | err_out_stop: | 680 | error: |
601 | dev->ir = NULL; | 681 | dev->ir = NULL; |
602 | err_out_free: | ||
603 | rc_free_device(rc); | 682 | rc_free_device(rc); |
604 | kfree(ir); | 683 | kfree(ir); |
605 | return err; | 684 | return err; |
diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index 6ff368297f6e..885089e22bcd 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h | |||
@@ -13,9 +13,9 @@ | |||
13 | #define EM_GPO_3 (1 << 3) | 13 | #define EM_GPO_3 (1 << 3) |
14 | 14 | ||
15 | /* em28xx endpoints */ | 15 | /* em28xx endpoints */ |
16 | #define EM28XX_EP_ANALOG 0x82 | 16 | /* 0x82: (always ?) analog */ |
17 | #define EM28XX_EP_AUDIO 0x83 | 17 | #define EM28XX_EP_AUDIO 0x83 |
18 | #define EM28XX_EP_DIGITAL 0x84 | 18 | /* 0x84: digital or analog */ |
19 | 19 | ||
20 | /* em2800 registers */ | 20 | /* em2800 registers */ |
21 | #define EM2800_R08_AUDIOSRC 0x08 | 21 | #define EM2800_R08_AUDIOSRC 0x08 |
@@ -177,6 +177,7 @@ | |||
177 | 177 | ||
178 | /* em2874 IR config register (0x50) */ | 178 | /* em2874 IR config register (0x50) */ |
179 | #define EM2874_IR_NEC 0x00 | 179 | #define EM2874_IR_NEC 0x00 |
180 | #define EM2874_IR_NEC_NO_PARITY 0x01 | ||
180 | #define EM2874_IR_RC5 0x04 | 181 | #define EM2874_IR_RC5 0x04 |
181 | #define EM2874_IR_RC6_MODE_0 0x08 | 182 | #define EM2874_IR_RC6_MODE_0 0x08 |
182 | #define EM2874_IR_RC6_MODE_6A 0x0b | 183 | #define EM2874_IR_RC6_MODE_6A 0x0b |
diff --git a/drivers/media/usb/em28xx/em28xx-vbi.c b/drivers/media/usb/em28xx/em28xx-vbi.c index 2b4c9cba2d67..39f39c527c13 100644 --- a/drivers/media/usb/em28xx/em28xx-vbi.c +++ b/drivers/media/usb/em28xx/em28xx-vbi.c | |||
@@ -41,105 +41,72 @@ MODULE_PARM_DESC(vbi_debug, "enable debug messages [vbi]"); | |||
41 | 41 | ||
42 | /* ------------------------------------------------------------------ */ | 42 | /* ------------------------------------------------------------------ */ |
43 | 43 | ||
44 | static void | 44 | static int vbi_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, |
45 | free_buffer(struct videobuf_queue *vq, struct em28xx_buffer *buf) | 45 | unsigned int *nbuffers, unsigned int *nplanes, |
46 | unsigned int sizes[], void *alloc_ctxs[]) | ||
46 | { | 47 | { |
47 | struct em28xx_fh *fh = vq->priv_data; | 48 | struct em28xx *dev = vb2_get_drv_priv(vq); |
48 | struct em28xx *dev = fh->dev; | 49 | unsigned long size; |
49 | unsigned long flags = 0; | ||
50 | if (in_interrupt()) | ||
51 | BUG(); | ||
52 | |||
53 | /* We used to wait for the buffer to finish here, but this didn't work | ||
54 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
55 | videobuf_queue_cancel marked it as finished for us. | ||
56 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
57 | |||
58 | This should be safe; by the time we get here, the buffer isn't | ||
59 | queued anymore. If we ever start marking the buffers as | ||
60 | VIDEOBUF_ACTIVE, it won't be, though. | ||
61 | */ | ||
62 | spin_lock_irqsave(&dev->slock, flags); | ||
63 | if (dev->isoc_ctl.vbi_buf == buf) | ||
64 | dev->isoc_ctl.vbi_buf = NULL; | ||
65 | spin_unlock_irqrestore(&dev->slock, flags); | ||
66 | 50 | ||
67 | videobuf_vmalloc_free(&buf->vb); | 51 | if (fmt) |
68 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 52 | size = fmt->fmt.pix.sizeimage; |
69 | } | 53 | else |
54 | size = dev->vbi_width * dev->vbi_height * 2; | ||
70 | 55 | ||
71 | static int | 56 | if (0 == *nbuffers) |
72 | vbi_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | 57 | *nbuffers = 32; |
73 | { | 58 | if (*nbuffers < 2) |
74 | struct em28xx_fh *fh = q->priv_data; | 59 | *nbuffers = 2; |
75 | struct em28xx *dev = fh->dev; | 60 | if (*nbuffers > 32) |
61 | *nbuffers = 32; | ||
76 | 62 | ||
77 | *size = dev->vbi_width * dev->vbi_height * 2; | 63 | *nplanes = 1; |
64 | sizes[0] = size; | ||
78 | 65 | ||
79 | if (0 == *count) | ||
80 | *count = vbibufs; | ||
81 | if (*count < 2) | ||
82 | *count = 2; | ||
83 | if (*count > 32) | ||
84 | *count = 32; | ||
85 | return 0; | 66 | return 0; |
86 | } | 67 | } |
87 | 68 | ||
88 | static int | 69 | static int vbi_buffer_prepare(struct vb2_buffer *vb) |
89 | vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | ||
90 | enum v4l2_field field) | ||
91 | { | 70 | { |
92 | struct em28xx_fh *fh = q->priv_data; | 71 | struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); |
93 | struct em28xx *dev = fh->dev; | ||
94 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | 72 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); |
95 | int rc = 0; | 73 | unsigned long size; |
96 | 74 | ||
97 | buf->vb.size = dev->vbi_width * dev->vbi_height * 2; | 75 | size = dev->vbi_width * dev->vbi_height * 2; |
98 | 76 | ||
99 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | 77 | if (vb2_plane_size(vb, 0) < size) { |
78 | printk(KERN_INFO "%s data will not fit into plane (%lu < %lu)\n", | ||
79 | __func__, vb2_plane_size(vb, 0), size); | ||
100 | return -EINVAL; | 80 | return -EINVAL; |
101 | |||
102 | buf->vb.width = dev->vbi_width; | ||
103 | buf->vb.height = dev->vbi_height; | ||
104 | buf->vb.field = field; | ||
105 | |||
106 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
107 | rc = videobuf_iolock(q, &buf->vb, NULL); | ||
108 | if (rc < 0) | ||
109 | goto fail; | ||
110 | } | 81 | } |
82 | vb2_set_plane_payload(&buf->vb, 0, size); | ||
111 | 83 | ||
112 | buf->vb.state = VIDEOBUF_PREPARED; | ||
113 | return 0; | 84 | return 0; |
114 | |||
115 | fail: | ||
116 | free_buffer(q, buf); | ||
117 | return rc; | ||
118 | } | 85 | } |
119 | 86 | ||
120 | static void | 87 | static void |
121 | vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | 88 | vbi_buffer_queue(struct vb2_buffer *vb) |
122 | { | ||
123 | struct em28xx_buffer *buf = container_of(vb, | ||
124 | struct em28xx_buffer, | ||
125 | vb); | ||
126 | struct em28xx_fh *fh = vq->priv_data; | ||
127 | struct em28xx *dev = fh->dev; | ||
128 | struct em28xx_dmaqueue *vbiq = &dev->vbiq; | ||
129 | |||
130 | buf->vb.state = VIDEOBUF_QUEUED; | ||
131 | list_add_tail(&buf->vb.queue, &vbiq->active); | ||
132 | } | ||
133 | |||
134 | static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
135 | { | 89 | { |
90 | struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
136 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | 91 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); |
137 | free_buffer(q, buf); | 92 | struct em28xx_dmaqueue *vbiq = &dev->vbiq; |
93 | unsigned long flags = 0; | ||
94 | |||
95 | buf->mem = vb2_plane_vaddr(vb, 0); | ||
96 | buf->length = vb2_plane_size(vb, 0); | ||
97 | |||
98 | spin_lock_irqsave(&dev->slock, flags); | ||
99 | list_add_tail(&buf->list, &vbiq->active); | ||
100 | spin_unlock_irqrestore(&dev->slock, flags); | ||
138 | } | 101 | } |
139 | 102 | ||
140 | struct videobuf_queue_ops em28xx_vbi_qops = { | 103 | |
141 | .buf_setup = vbi_setup, | 104 | struct vb2_ops em28xx_vbi_qops = { |
142 | .buf_prepare = vbi_prepare, | 105 | .queue_setup = vbi_queue_setup, |
143 | .buf_queue = vbi_queue, | 106 | .buf_prepare = vbi_buffer_prepare, |
144 | .buf_release = vbi_release, | 107 | .buf_queue = vbi_buffer_queue, |
108 | .start_streaming = em28xx_start_analog_streaming, | ||
109 | .stop_streaming = em28xx_stop_vbi_streaming, | ||
110 | .wait_prepare = vb2_ops_wait_prepare, | ||
111 | .wait_finish = vb2_ops_wait_finish, | ||
145 | }; | 112 | }; |
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 1e553d357380..32bd7de5dec1 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -6,6 +6,7 @@ | |||
6 | Markus Rechberger <mrechberger@gmail.com> | 6 | Markus Rechberger <mrechberger@gmail.com> |
7 | Mauro Carvalho Chehab <mchehab@infradead.org> | 7 | Mauro Carvalho Chehab <mchehab@infradead.org> |
8 | Sascha Sommer <saschasommer@freenet.de> | 8 | Sascha Sommer <saschasommer@freenet.de> |
9 | Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
9 | 10 | ||
10 | Some parts based on SN9C10x PC Camera Controllers GPL driver made | 11 | Some parts based on SN9C10x PC Camera Controllers GPL driver made |
11 | by Luca Risolia <luca.risolia@studio.unibo.it> | 12 | by Luca Risolia <luca.risolia@studio.unibo.it> |
@@ -39,6 +40,7 @@ | |||
39 | #include "em28xx.h" | 40 | #include "em28xx.h" |
40 | #include <media/v4l2-common.h> | 41 | #include <media/v4l2-common.h> |
41 | #include <media/v4l2-ioctl.h> | 42 | #include <media/v4l2-ioctl.h> |
43 | #include <media/v4l2-event.h> | ||
42 | #include <media/v4l2-chip-ident.h> | 44 | #include <media/v4l2-chip-ident.h> |
43 | #include <media/msp3400.h> | 45 | #include <media/msp3400.h> |
44 | #include <media/tuner.h> | 46 | #include <media/tuner.h> |
@@ -74,9 +76,9 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
74 | MODULE_LICENSE("GPL"); | 76 | MODULE_LICENSE("GPL"); |
75 | MODULE_VERSION(EM28XX_VERSION); | 77 | MODULE_VERSION(EM28XX_VERSION); |
76 | 78 | ||
77 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 79 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
78 | static unsigned int vbi_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 80 | static unsigned int vbi_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
79 | static unsigned int radio_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 81 | static unsigned int radio_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U }; |
80 | 82 | ||
81 | module_param_array(video_nr, int, NULL, 0444); | 83 | module_param_array(video_nr, int, NULL, 0444); |
82 | module_param_array(vbi_nr, int, NULL, 0444); | 84 | module_param_array(vbi_nr, int, NULL, 0444); |
@@ -124,101 +126,50 @@ static struct em28xx_fmt format[] = { | |||
124 | }, | 126 | }, |
125 | }; | 127 | }; |
126 | 128 | ||
127 | /* supported controls */ | ||
128 | /* Common to all boards */ | ||
129 | static struct v4l2_queryctrl ac97_qctrl[] = { | ||
130 | { | ||
131 | .id = V4L2_CID_AUDIO_VOLUME, | ||
132 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
133 | .name = "Volume", | ||
134 | .minimum = 0x0, | ||
135 | .maximum = 0x1f, | ||
136 | .step = 0x1, | ||
137 | .default_value = 0x1f, | ||
138 | .flags = V4L2_CTRL_FLAG_SLIDER, | ||
139 | }, { | ||
140 | .id = V4L2_CID_AUDIO_MUTE, | ||
141 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
142 | .name = "Mute", | ||
143 | .minimum = 0, | ||
144 | .maximum = 1, | ||
145 | .step = 1, | ||
146 | .default_value = 1, | ||
147 | .flags = 0, | ||
148 | } | ||
149 | }; | ||
150 | |||
151 | /* ------------------------------------------------------------------ | 129 | /* ------------------------------------------------------------------ |
152 | DMA and thread functions | 130 | DMA and thread functions |
153 | ------------------------------------------------------------------*/ | 131 | ------------------------------------------------------------------*/ |
154 | 132 | ||
155 | /* | 133 | /* |
156 | * Announces that a buffer were filled and request the next | 134 | * Finish the current buffer |
157 | */ | 135 | */ |
158 | static inline void buffer_filled(struct em28xx *dev, | 136 | static inline void finish_buffer(struct em28xx *dev, |
159 | struct em28xx_dmaqueue *dma_q, | 137 | struct em28xx_buffer *buf) |
160 | struct em28xx_buffer *buf) | ||
161 | { | 138 | { |
162 | /* Advice that buffer was filled */ | 139 | em28xx_isocdbg("[%p/%d] wakeup\n", buf, buf->top_field); |
163 | em28xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | ||
164 | buf->vb.state = VIDEOBUF_DONE; | ||
165 | buf->vb.field_count++; | ||
166 | do_gettimeofday(&buf->vb.ts); | ||
167 | 140 | ||
168 | dev->isoc_ctl.vid_buf = NULL; | 141 | buf->vb.v4l2_buf.sequence = dev->field_count++; |
142 | buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; | ||
143 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); | ||
169 | 144 | ||
170 | list_del(&buf->vb.queue); | 145 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); |
171 | wake_up(&buf->vb.done); | ||
172 | } | ||
173 | |||
174 | static inline void vbi_buffer_filled(struct em28xx *dev, | ||
175 | struct em28xx_dmaqueue *dma_q, | ||
176 | struct em28xx_buffer *buf) | ||
177 | { | ||
178 | /* Advice that buffer was filled */ | ||
179 | em28xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | ||
180 | |||
181 | buf->vb.state = VIDEOBUF_DONE; | ||
182 | buf->vb.field_count++; | ||
183 | do_gettimeofday(&buf->vb.ts); | ||
184 | |||
185 | dev->isoc_ctl.vbi_buf = NULL; | ||
186 | |||
187 | list_del(&buf->vb.queue); | ||
188 | wake_up(&buf->vb.done); | ||
189 | } | 146 | } |
190 | 147 | ||
191 | /* | 148 | /* |
192 | * Identify the buffer header type and properly handles | 149 | * Copy picture data from USB buffer to videobuf buffer |
193 | */ | 150 | */ |
194 | static void em28xx_copy_video(struct em28xx *dev, | 151 | static void em28xx_copy_video(struct em28xx *dev, |
195 | struct em28xx_dmaqueue *dma_q, | ||
196 | struct em28xx_buffer *buf, | 152 | struct em28xx_buffer *buf, |
197 | unsigned char *p, | 153 | unsigned char *usb_buf, |
198 | unsigned char *outp, unsigned long len) | 154 | unsigned long len) |
199 | { | 155 | { |
200 | void *fieldstart, *startwrite, *startread; | 156 | void *fieldstart, *startwrite, *startread; |
201 | int linesdone, currlinedone, offset, lencopy, remain; | 157 | int linesdone, currlinedone, offset, lencopy, remain; |
202 | int bytesperline = dev->width << 1; | 158 | int bytesperline = dev->width << 1; |
203 | 159 | ||
204 | if (dma_q->pos + len > buf->vb.size) | 160 | if (buf->pos + len > buf->length) |
205 | len = buf->vb.size - dma_q->pos; | 161 | len = buf->length - buf->pos; |
206 | 162 | ||
207 | startread = p; | 163 | startread = usb_buf; |
208 | remain = len; | 164 | remain = len; |
209 | 165 | ||
210 | if (dev->progressive) | 166 | if (dev->progressive || buf->top_field) |
211 | fieldstart = outp; | 167 | fieldstart = buf->vb_buf; |
212 | else { | 168 | else /* interlaced mode, even nr. of lines */ |
213 | /* Interlaces two half frames */ | 169 | fieldstart = buf->vb_buf + bytesperline; |
214 | if (buf->top_field) | ||
215 | fieldstart = outp; | ||
216 | else | ||
217 | fieldstart = outp + bytesperline; | ||
218 | } | ||
219 | 170 | ||
220 | linesdone = dma_q->pos / bytesperline; | 171 | linesdone = buf->pos / bytesperline; |
221 | currlinedone = dma_q->pos % bytesperline; | 172 | currlinedone = buf->pos % bytesperline; |
222 | 173 | ||
223 | if (dev->progressive) | 174 | if (dev->progressive) |
224 | offset = linesdone * bytesperline + currlinedone; | 175 | offset = linesdone * bytesperline + currlinedone; |
@@ -229,11 +180,12 @@ static void em28xx_copy_video(struct em28xx *dev, | |||
229 | lencopy = bytesperline - currlinedone; | 180 | lencopy = bytesperline - currlinedone; |
230 | lencopy = lencopy > remain ? remain : lencopy; | 181 | lencopy = lencopy > remain ? remain : lencopy; |
231 | 182 | ||
232 | if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { | 183 | if ((char *)startwrite + lencopy > (char *)buf->vb_buf + buf->length) { |
233 | em28xx_isocdbg("Overflow of %zi bytes past buffer end (1)\n", | 184 | em28xx_isocdbg("Overflow of %zi bytes past buffer end (1)\n", |
234 | ((char *)startwrite + lencopy) - | 185 | ((char *)startwrite + lencopy) - |
235 | ((char *)outp + buf->vb.size)); | 186 | ((char *)buf->vb_buf + buf->length)); |
236 | remain = (char *)outp + buf->vb.size - (char *)startwrite; | 187 | remain = (char *)buf->vb_buf + buf->length - |
188 | (char *)startwrite; | ||
237 | lencopy = remain; | 189 | lencopy = remain; |
238 | } | 190 | } |
239 | if (lencopy <= 0) | 191 | if (lencopy <= 0) |
@@ -243,21 +195,24 @@ static void em28xx_copy_video(struct em28xx *dev, | |||
243 | remain -= lencopy; | 195 | remain -= lencopy; |
244 | 196 | ||
245 | while (remain > 0) { | 197 | while (remain > 0) { |
246 | startwrite += lencopy + bytesperline; | 198 | if (dev->progressive) |
199 | startwrite += lencopy; | ||
200 | else | ||
201 | startwrite += lencopy + bytesperline; | ||
247 | startread += lencopy; | 202 | startread += lencopy; |
248 | if (bytesperline > remain) | 203 | if (bytesperline > remain) |
249 | lencopy = remain; | 204 | lencopy = remain; |
250 | else | 205 | else |
251 | lencopy = bytesperline; | 206 | lencopy = bytesperline; |
252 | 207 | ||
253 | if ((char *)startwrite + lencopy > (char *)outp + | 208 | if ((char *)startwrite + lencopy > (char *)buf->vb_buf + |
254 | buf->vb.size) { | 209 | buf->length) { |
255 | em28xx_isocdbg("Overflow of %zi bytes past buffer end" | 210 | em28xx_isocdbg("Overflow of %zi bytes past buffer end" |
256 | "(2)\n", | 211 | "(2)\n", |
257 | ((char *)startwrite + lencopy) - | 212 | ((char *)startwrite + lencopy) - |
258 | ((char *)outp + buf->vb.size)); | 213 | ((char *)buf->vb_buf + buf->length)); |
259 | lencopy = remain = (char *)outp + buf->vb.size - | 214 | lencopy = remain = (char *)buf->vb_buf + buf->length - |
260 | (char *)startwrite; | 215 | (char *)startwrite; |
261 | } | 216 | } |
262 | if (lencopy <= 0) | 217 | if (lencopy <= 0) |
263 | break; | 218 | break; |
@@ -267,57 +222,29 @@ static void em28xx_copy_video(struct em28xx *dev, | |||
267 | remain -= lencopy; | 222 | remain -= lencopy; |
268 | } | 223 | } |
269 | 224 | ||
270 | dma_q->pos += len; | 225 | buf->pos += len; |
271 | } | 226 | } |
272 | 227 | ||
228 | /* | ||
229 | * Copy VBI data from USB buffer to videobuf buffer | ||
230 | */ | ||
273 | static void em28xx_copy_vbi(struct em28xx *dev, | 231 | static void em28xx_copy_vbi(struct em28xx *dev, |
274 | struct em28xx_dmaqueue *dma_q, | 232 | struct em28xx_buffer *buf, |
275 | struct em28xx_buffer *buf, | 233 | unsigned char *usb_buf, |
276 | unsigned char *p, | 234 | unsigned long len) |
277 | unsigned char *outp, unsigned long len) | ||
278 | { | 235 | { |
279 | void *startwrite, *startread; | 236 | unsigned int offset; |
280 | int offset; | ||
281 | int bytesperline; | ||
282 | |||
283 | if (dev == NULL) { | ||
284 | em28xx_isocdbg("dev is null\n"); | ||
285 | return; | ||
286 | } | ||
287 | bytesperline = dev->vbi_width; | ||
288 | 237 | ||
289 | if (dma_q == NULL) { | 238 | if (buf->pos + len > buf->length) |
290 | em28xx_isocdbg("dma_q is null\n"); | 239 | len = buf->length - buf->pos; |
291 | return; | ||
292 | } | ||
293 | if (buf == NULL) { | ||
294 | return; | ||
295 | } | ||
296 | if (p == NULL) { | ||
297 | em28xx_isocdbg("p is null\n"); | ||
298 | return; | ||
299 | } | ||
300 | if (outp == NULL) { | ||
301 | em28xx_isocdbg("outp is null\n"); | ||
302 | return; | ||
303 | } | ||
304 | |||
305 | if (dma_q->pos + len > buf->vb.size) | ||
306 | len = buf->vb.size - dma_q->pos; | ||
307 | |||
308 | startread = p; | ||
309 | |||
310 | startwrite = outp + dma_q->pos; | ||
311 | offset = dma_q->pos; | ||
312 | 240 | ||
241 | offset = buf->pos; | ||
313 | /* Make sure the bottom field populates the second half of the frame */ | 242 | /* Make sure the bottom field populates the second half of the frame */ |
314 | if (buf->top_field == 0) { | 243 | if (buf->top_field == 0) |
315 | startwrite += bytesperline * dev->vbi_height; | 244 | offset += dev->vbi_width * dev->vbi_height; |
316 | offset += bytesperline * dev->vbi_height; | ||
317 | } | ||
318 | 245 | ||
319 | memcpy(startwrite, startread, len); | 246 | memcpy(buf->vb_buf + offset, usb_buf, len); |
320 | dma_q->pos += len; | 247 | buf->pos += len; |
321 | } | 248 | } |
322 | 249 | ||
323 | static inline void print_err_status(struct em28xx *dev, | 250 | static inline void print_err_status(struct em28xx *dev, |
@@ -360,470 +287,444 @@ static inline void print_err_status(struct em28xx *dev, | |||
360 | } | 287 | } |
361 | 288 | ||
362 | /* | 289 | /* |
363 | * video-buf generic routine to get the next available buffer | 290 | * get the next available buffer from dma queue |
364 | */ | 291 | */ |
365 | static inline void get_next_buf(struct em28xx_dmaqueue *dma_q, | 292 | static inline struct em28xx_buffer *get_next_buf(struct em28xx *dev, |
366 | struct em28xx_buffer **buf) | 293 | struct em28xx_dmaqueue *dma_q) |
367 | { | 294 | { |
368 | struct em28xx *dev = container_of(dma_q, struct em28xx, vidq); | 295 | struct em28xx_buffer *buf; |
369 | char *outp; | ||
370 | 296 | ||
371 | if (list_empty(&dma_q->active)) { | 297 | if (list_empty(&dma_q->active)) { |
372 | em28xx_isocdbg("No active queue to serve\n"); | 298 | em28xx_isocdbg("No active queue to serve\n"); |
373 | dev->isoc_ctl.vid_buf = NULL; | 299 | return NULL; |
374 | *buf = NULL; | ||
375 | return; | ||
376 | } | 300 | } |
377 | 301 | ||
378 | /* Get the next buffer */ | 302 | /* Get the next buffer */ |
379 | *buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue); | 303 | buf = list_entry(dma_q->active.next, struct em28xx_buffer, list); |
380 | |||
381 | /* Cleans up buffer - Useful for testing for frame/URB loss */ | 304 | /* Cleans up buffer - Useful for testing for frame/URB loss */ |
382 | outp = videobuf_to_vmalloc(&(*buf)->vb); | 305 | list_del(&buf->list); |
383 | memset(outp, 0, (*buf)->vb.size); | 306 | buf->pos = 0; |
307 | buf->vb_buf = buf->mem; | ||
384 | 308 | ||
385 | dev->isoc_ctl.vid_buf = *buf; | 309 | return buf; |
386 | |||
387 | return; | ||
388 | } | 310 | } |
389 | 311 | ||
390 | /* | 312 | /* |
391 | * video-buf generic routine to get the next available VBI buffer | 313 | * Finish the current buffer if completed and prepare for the next field |
392 | */ | 314 | */ |
393 | static inline void vbi_get_next_buf(struct em28xx_dmaqueue *dma_q, | 315 | static struct em28xx_buffer * |
394 | struct em28xx_buffer **buf) | 316 | finish_field_prepare_next(struct em28xx *dev, |
395 | { | 317 | struct em28xx_buffer *buf, |
396 | struct em28xx *dev = container_of(dma_q, struct em28xx, vbiq); | 318 | struct em28xx_dmaqueue *dma_q) |
397 | char *outp; | 319 | { |
398 | 320 | if (dev->progressive || dev->top_field) { /* Brand new frame */ | |
399 | if (list_empty(&dma_q->active)) { | 321 | if (buf != NULL) |
400 | em28xx_isocdbg("No active queue to serve\n"); | 322 | finish_buffer(dev, buf); |
401 | dev->isoc_ctl.vbi_buf = NULL; | 323 | buf = get_next_buf(dev, dma_q); |
402 | *buf = NULL; | 324 | } |
403 | return; | 325 | if (buf != NULL) { |
326 | buf->top_field = dev->top_field; | ||
327 | buf->pos = 0; | ||
404 | } | 328 | } |
405 | 329 | ||
406 | /* Get the next buffer */ | 330 | return buf; |
407 | *buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue); | ||
408 | /* Cleans up buffer - Useful for testing for frame/URB loss */ | ||
409 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
410 | memset(outp, 0x00, (*buf)->vb.size); | ||
411 | |||
412 | dev->isoc_ctl.vbi_buf = *buf; | ||
413 | |||
414 | return; | ||
415 | } | 331 | } |
416 | 332 | ||
417 | /* | 333 | /* |
418 | * Controls the isoc copy of each urb packet | 334 | * Process data packet according to the em2710/em2750/em28xx frame data format |
419 | */ | 335 | */ |
420 | static inline int em28xx_isoc_copy(struct em28xx *dev, struct urb *urb) | 336 | static inline void process_frame_data_em28xx(struct em28xx *dev, |
337 | unsigned char *data_pkt, | ||
338 | unsigned int data_len) | ||
421 | { | 339 | { |
422 | struct em28xx_buffer *buf; | 340 | struct em28xx_buffer *buf = dev->usb_ctl.vid_buf; |
341 | struct em28xx_buffer *vbi_buf = dev->usb_ctl.vbi_buf; | ||
423 | struct em28xx_dmaqueue *dma_q = &dev->vidq; | 342 | struct em28xx_dmaqueue *dma_q = &dev->vidq; |
424 | unsigned char *outp = NULL; | 343 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; |
425 | int i, len = 0, rc = 1; | ||
426 | unsigned char *p; | ||
427 | |||
428 | if (!dev) | ||
429 | return 0; | ||
430 | |||
431 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
432 | return 0; | ||
433 | |||
434 | if (urb->status < 0) { | ||
435 | print_err_status(dev, -1, urb->status); | ||
436 | if (urb->status == -ENOENT) | ||
437 | return 0; | ||
438 | } | ||
439 | |||
440 | buf = dev->isoc_ctl.vid_buf; | ||
441 | if (buf != NULL) | ||
442 | outp = videobuf_to_vmalloc(&buf->vb); | ||
443 | |||
444 | for (i = 0; i < urb->number_of_packets; i++) { | ||
445 | int status = urb->iso_frame_desc[i].status; | ||
446 | 344 | ||
447 | if (status < 0) { | 345 | /* capture type 0 = vbi start |
448 | print_err_status(dev, i, status); | 346 | capture type 1 = vbi in progress |
449 | if (urb->iso_frame_desc[i].status != -EPROTO) | 347 | capture type 2 = video start |
450 | continue; | 348 | capture type 3 = video in progress */ |
349 | if (data_len >= 4) { | ||
350 | /* NOTE: Headers are always 4 bytes and | ||
351 | * never split across packets */ | ||
352 | if (data_pkt[0] == 0x88 && data_pkt[1] == 0x88 && | ||
353 | data_pkt[2] == 0x88 && data_pkt[3] == 0x88) { | ||
354 | /* Continuation */ | ||
355 | data_pkt += 4; | ||
356 | data_len -= 4; | ||
357 | } else if (data_pkt[0] == 0x33 && data_pkt[1] == 0x95) { | ||
358 | /* Field start (VBI mode) */ | ||
359 | dev->capture_type = 0; | ||
360 | dev->vbi_read = 0; | ||
361 | em28xx_isocdbg("VBI START HEADER !!!\n"); | ||
362 | dev->top_field = !(data_pkt[2] & 1); | ||
363 | data_pkt += 4; | ||
364 | data_len -= 4; | ||
365 | } else if (data_pkt[0] == 0x22 && data_pkt[1] == 0x5a) { | ||
366 | /* Field start (VBI disabled) */ | ||
367 | dev->capture_type = 2; | ||
368 | em28xx_isocdbg("VIDEO START HEADER !!!\n"); | ||
369 | dev->top_field = !(data_pkt[2] & 1); | ||
370 | data_pkt += 4; | ||
371 | data_len -= 4; | ||
451 | } | 372 | } |
373 | } | ||
374 | /* NOTE: With bulk transfers, intermediate data packets | ||
375 | * have no continuation header */ | ||
452 | 376 | ||
453 | len = urb->iso_frame_desc[i].actual_length - 4; | 377 | if (dev->capture_type == 0) { |
378 | vbi_buf = finish_field_prepare_next(dev, vbi_buf, vbi_dma_q); | ||
379 | dev->usb_ctl.vbi_buf = vbi_buf; | ||
380 | dev->capture_type = 1; | ||
381 | } | ||
454 | 382 | ||
455 | if (urb->iso_frame_desc[i].actual_length <= 0) { | 383 | if (dev->capture_type == 1) { |
456 | /* em28xx_isocdbg("packet %d is empty",i); - spammy */ | 384 | int vbi_size = dev->vbi_width * dev->vbi_height; |
457 | continue; | 385 | int vbi_data_len = ((dev->vbi_read + data_len) > vbi_size) ? |
458 | } | 386 | (vbi_size - dev->vbi_read) : data_len; |
459 | if (urb->iso_frame_desc[i].actual_length > | ||
460 | dev->max_pkt_size) { | ||
461 | em28xx_isocdbg("packet bigger than packet size"); | ||
462 | continue; | ||
463 | } | ||
464 | 387 | ||
465 | p = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 388 | /* Copy VBI data */ |
389 | if (vbi_buf != NULL) | ||
390 | em28xx_copy_vbi(dev, vbi_buf, data_pkt, vbi_data_len); | ||
391 | dev->vbi_read += vbi_data_len; | ||
466 | 392 | ||
467 | /* FIXME: incomplete buffer checks where removed to make | 393 | if (vbi_data_len < data_len) { |
468 | logic simpler. Impacts of those changes should be evaluated | 394 | /* Continue with copying video data */ |
469 | */ | 395 | dev->capture_type = 2; |
470 | if (p[0] == 0x33 && p[1] == 0x95 && p[2] == 0x00) { | 396 | data_pkt += vbi_data_len; |
471 | em28xx_isocdbg("VBI HEADER!!!\n"); | 397 | data_len -= vbi_data_len; |
472 | /* FIXME: Should add vbi copy */ | ||
473 | continue; | ||
474 | } | 398 | } |
475 | if (p[0] == 0x22 && p[1] == 0x5a) { | 399 | } |
476 | em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2], | ||
477 | len, (p[2] & 1) ? "odd" : "even"); | ||
478 | |||
479 | if (dev->progressive || !(p[2] & 1)) { | ||
480 | if (buf != NULL) | ||
481 | buffer_filled(dev, dma_q, buf); | ||
482 | get_next_buf(dma_q, &buf); | ||
483 | if (buf == NULL) | ||
484 | outp = NULL; | ||
485 | else | ||
486 | outp = videobuf_to_vmalloc(&buf->vb); | ||
487 | } | ||
488 | |||
489 | if (buf != NULL) { | ||
490 | if (p[2] & 1) | ||
491 | buf->top_field = 0; | ||
492 | else | ||
493 | buf->top_field = 1; | ||
494 | } | ||
495 | 400 | ||
496 | dma_q->pos = 0; | 401 | if (dev->capture_type == 2) { |
497 | } | 402 | buf = finish_field_prepare_next(dev, buf, dma_q); |
498 | if (buf != NULL) { | 403 | dev->usb_ctl.vid_buf = buf; |
499 | if (p[0] != 0x88 && p[0] != 0x22) { | 404 | dev->capture_type = 3; |
500 | em28xx_isocdbg("frame is not complete\n"); | ||
501 | len += 4; | ||
502 | } else { | ||
503 | p += 4; | ||
504 | } | ||
505 | em28xx_copy_video(dev, dma_q, buf, p, outp, len); | ||
506 | } | ||
507 | } | 405 | } |
508 | return rc; | 406 | |
407 | if (dev->capture_type == 3 && buf != NULL && data_len > 0) | ||
408 | em28xx_copy_video(dev, buf, data_pkt, data_len); | ||
509 | } | 409 | } |
510 | 410 | ||
511 | /* Version of isoc handler that takes into account a mixture of video and | 411 | /* Processes and copies the URB data content (video and VBI data) */ |
512 | VBI data */ | 412 | static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb) |
513 | static inline int em28xx_isoc_copy_vbi(struct em28xx *dev, struct urb *urb) | ||
514 | { | 413 | { |
515 | struct em28xx_buffer *buf, *vbi_buf; | 414 | int xfer_bulk, num_packets, i; |
516 | struct em28xx_dmaqueue *dma_q = &dev->vidq; | 415 | unsigned char *usb_data_pkt; |
517 | struct em28xx_dmaqueue *vbi_dma_q = &dev->vbiq; | 416 | unsigned int usb_data_len; |
518 | unsigned char *outp = NULL; | ||
519 | unsigned char *vbioutp = NULL; | ||
520 | int i, len = 0, rc = 1; | ||
521 | unsigned char *p; | ||
522 | int vbi_size; | ||
523 | 417 | ||
524 | if (!dev) | 418 | if (!dev) |
525 | return 0; | 419 | return 0; |
526 | 420 | ||
527 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | 421 | if (dev->disconnected) |
528 | return 0; | 422 | return 0; |
529 | 423 | ||
530 | if (urb->status < 0) { | 424 | if (urb->status < 0) |
531 | print_err_status(dev, -1, urb->status); | 425 | print_err_status(dev, -1, urb->status); |
532 | if (urb->status == -ENOENT) | ||
533 | return 0; | ||
534 | } | ||
535 | 426 | ||
536 | buf = dev->isoc_ctl.vid_buf; | 427 | xfer_bulk = usb_pipebulk(urb->pipe); |
537 | if (buf != NULL) | ||
538 | outp = videobuf_to_vmalloc(&buf->vb); | ||
539 | 428 | ||
540 | vbi_buf = dev->isoc_ctl.vbi_buf; | 429 | if (xfer_bulk) /* bulk */ |
541 | if (vbi_buf != NULL) | 430 | num_packets = 1; |
542 | vbioutp = videobuf_to_vmalloc(&vbi_buf->vb); | 431 | else /* isoc */ |
432 | num_packets = urb->number_of_packets; | ||
543 | 433 | ||
544 | for (i = 0; i < urb->number_of_packets; i++) { | 434 | for (i = 0; i < num_packets; i++) { |
545 | int status = urb->iso_frame_desc[i].status; | 435 | if (xfer_bulk) { /* bulk */ |
436 | usb_data_len = urb->actual_length; | ||
546 | 437 | ||
547 | if (status < 0) { | 438 | usb_data_pkt = urb->transfer_buffer; |
548 | print_err_status(dev, i, status); | 439 | } else { /* isoc */ |
549 | if (urb->iso_frame_desc[i].status != -EPROTO) | 440 | if (urb->iso_frame_desc[i].status < 0) { |
441 | print_err_status(dev, i, | ||
442 | urb->iso_frame_desc[i].status); | ||
443 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
444 | continue; | ||
445 | } | ||
446 | |||
447 | usb_data_len = urb->iso_frame_desc[i].actual_length; | ||
448 | if (usb_data_len > dev->max_pkt_size) { | ||
449 | em28xx_isocdbg("packet bigger than packet size"); | ||
550 | continue; | 450 | continue; |
551 | } | 451 | } |
552 | 452 | ||
553 | len = urb->iso_frame_desc[i].actual_length; | 453 | usb_data_pkt = urb->transfer_buffer + |
554 | if (urb->iso_frame_desc[i].actual_length <= 0) { | 454 | urb->iso_frame_desc[i].offset; |
555 | /* em28xx_isocdbg("packet %d is empty",i); - spammy */ | ||
556 | continue; | ||
557 | } | ||
558 | if (urb->iso_frame_desc[i].actual_length > | ||
559 | dev->max_pkt_size) { | ||
560 | em28xx_isocdbg("packet bigger than packet size"); | ||
561 | continue; | ||
562 | } | 455 | } |
563 | 456 | ||
564 | p = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 457 | if (usb_data_len == 0) { |
565 | 458 | /* NOTE: happens very often with isoc transfers */ | |
566 | /* capture type 0 = vbi start | 459 | /* em28xx_usbdbg("packet %d is empty",i); - spammy */ |
567 | capture type 1 = video start | 460 | continue; |
568 | capture type 2 = video in progress */ | ||
569 | if (p[0] == 0x33 && p[1] == 0x95) { | ||
570 | dev->capture_type = 0; | ||
571 | dev->vbi_read = 0; | ||
572 | em28xx_isocdbg("VBI START HEADER!!!\n"); | ||
573 | dev->cur_field = p[2]; | ||
574 | p += 4; | ||
575 | len -= 4; | ||
576 | } else if (p[0] == 0x88 && p[1] == 0x88 && | ||
577 | p[2] == 0x88 && p[3] == 0x88) { | ||
578 | /* continuation */ | ||
579 | p += 4; | ||
580 | len -= 4; | ||
581 | } else if (p[0] == 0x22 && p[1] == 0x5a) { | ||
582 | /* start video */ | ||
583 | p += 4; | ||
584 | len -= 4; | ||
585 | } | 461 | } |
586 | 462 | ||
587 | vbi_size = dev->vbi_width * dev->vbi_height; | 463 | process_frame_data_em28xx(dev, usb_data_pkt, usb_data_len); |
588 | 464 | } | |
589 | if (dev->capture_type == 0) { | 465 | return 1; |
590 | if (dev->vbi_read >= vbi_size) { | 466 | } |
591 | /* We've already read all the VBI data, so | ||
592 | treat the rest as video */ | ||
593 | em28xx_isocdbg("dev->vbi_read > vbi_size\n"); | ||
594 | } else if ((dev->vbi_read + len) < vbi_size) { | ||
595 | /* This entire frame is VBI data */ | ||
596 | if (dev->vbi_read == 0 && | ||
597 | (!(dev->cur_field & 1))) { | ||
598 | /* Brand new frame */ | ||
599 | if (vbi_buf != NULL) | ||
600 | vbi_buffer_filled(dev, | ||
601 | vbi_dma_q, | ||
602 | vbi_buf); | ||
603 | vbi_get_next_buf(vbi_dma_q, &vbi_buf); | ||
604 | if (vbi_buf == NULL) | ||
605 | vbioutp = NULL; | ||
606 | else | ||
607 | vbioutp = videobuf_to_vmalloc( | ||
608 | &vbi_buf->vb); | ||
609 | } | ||
610 | |||
611 | if (dev->vbi_read == 0) { | ||
612 | vbi_dma_q->pos = 0; | ||
613 | if (vbi_buf != NULL) { | ||
614 | if (dev->cur_field & 1) | ||
615 | vbi_buf->top_field = 0; | ||
616 | else | ||
617 | vbi_buf->top_field = 1; | ||
618 | } | ||
619 | } | ||
620 | |||
621 | dev->vbi_read += len; | ||
622 | em28xx_copy_vbi(dev, vbi_dma_q, vbi_buf, p, | ||
623 | vbioutp, len); | ||
624 | } else { | ||
625 | /* Some of this frame is VBI data and some is | ||
626 | video data */ | ||
627 | int vbi_data_len = vbi_size - dev->vbi_read; | ||
628 | dev->vbi_read += vbi_data_len; | ||
629 | em28xx_copy_vbi(dev, vbi_dma_q, vbi_buf, p, | ||
630 | vbioutp, vbi_data_len); | ||
631 | dev->capture_type = 1; | ||
632 | p += vbi_data_len; | ||
633 | len -= vbi_data_len; | ||
634 | } | ||
635 | } | ||
636 | 467 | ||
637 | if (dev->capture_type == 1) { | ||
638 | dev->capture_type = 2; | ||
639 | if (dev->progressive || !(dev->cur_field & 1)) { | ||
640 | if (buf != NULL) | ||
641 | buffer_filled(dev, dma_q, buf); | ||
642 | get_next_buf(dma_q, &buf); | ||
643 | if (buf == NULL) | ||
644 | outp = NULL; | ||
645 | else | ||
646 | outp = videobuf_to_vmalloc(&buf->vb); | ||
647 | } | ||
648 | if (buf != NULL) { | ||
649 | if (dev->cur_field & 1) | ||
650 | buf->top_field = 0; | ||
651 | else | ||
652 | buf->top_field = 1; | ||
653 | } | ||
654 | 468 | ||
655 | dma_q->pos = 0; | 469 | static int get_ressource(enum v4l2_buf_type f_type) |
656 | } | 470 | { |
471 | switch (f_type) { | ||
472 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
473 | return EM28XX_RESOURCE_VIDEO; | ||
474 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
475 | return EM28XX_RESOURCE_VBI; | ||
476 | default: | ||
477 | BUG(); | ||
478 | return 0; | ||
479 | } | ||
480 | } | ||
657 | 481 | ||
658 | if (buf != NULL && dev->capture_type == 2) { | 482 | /* Usage lock check functions */ |
659 | if (len >= 4 && p[0] == 0x88 && p[1] == 0x88 && | 483 | static int res_get(struct em28xx *dev, enum v4l2_buf_type f_type) |
660 | p[2] == 0x88 && p[3] == 0x88) { | 484 | { |
661 | p += 4; | 485 | int res_type = get_ressource(f_type); |
662 | len -= 4; | ||
663 | } | ||
664 | if (len >= 4 && p[0] == 0x22 && p[1] == 0x5a) { | ||
665 | em28xx_isocdbg("Video frame %d, len=%i, %s\n", | ||
666 | p[2], len, (p[2] & 1) ? | ||
667 | "odd" : "even"); | ||
668 | p += 4; | ||
669 | len -= 4; | ||
670 | } | ||
671 | 486 | ||
672 | if (len > 0) | 487 | /* is it free? */ |
673 | em28xx_copy_video(dev, dma_q, buf, p, outp, | 488 | if (dev->resources & res_type) { |
674 | len); | 489 | /* no, someone else uses it */ |
675 | } | 490 | return -EBUSY; |
676 | } | 491 | } |
677 | return rc; | 492 | |
493 | /* it's free, grab it */ | ||
494 | dev->resources |= res_type; | ||
495 | em28xx_videodbg("res: get %d\n", res_type); | ||
496 | return 0; | ||
678 | } | 497 | } |
679 | 498 | ||
499 | static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type) | ||
500 | { | ||
501 | int res_type = get_ressource(f_type); | ||
502 | |||
503 | dev->resources &= ~res_type; | ||
504 | em28xx_videodbg("res: put %d\n", res_type); | ||
505 | } | ||
680 | 506 | ||
681 | /* ------------------------------------------------------------------ | 507 | /* ------------------------------------------------------------------ |
682 | Videobuf operations | 508 | Videobuf2 operations |
683 | ------------------------------------------------------------------*/ | 509 | ------------------------------------------------------------------*/ |
684 | 510 | ||
685 | static int | 511 | static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, |
686 | buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | 512 | unsigned int *nbuffers, unsigned int *nplanes, |
513 | unsigned int sizes[], void *alloc_ctxs[]) | ||
687 | { | 514 | { |
688 | struct em28xx_fh *fh = vq->priv_data; | 515 | struct em28xx *dev = vb2_get_drv_priv(vq); |
689 | struct em28xx *dev = fh->dev; | 516 | unsigned long size; |
690 | struct v4l2_frequency f; | ||
691 | 517 | ||
692 | *size = (fh->dev->width * fh->dev->height * dev->format->depth + 7) | 518 | if (fmt) |
693 | >> 3; | 519 | size = fmt->fmt.pix.sizeimage; |
694 | 520 | else | |
695 | if (0 == *count) | 521 | size = (dev->width * dev->height * dev->format->depth + 7) >> 3; |
696 | *count = EM28XX_DEF_BUF; | ||
697 | 522 | ||
698 | if (*count < EM28XX_MIN_BUF) | 523 | if (size == 0) |
699 | *count = EM28XX_MIN_BUF; | 524 | return -EINVAL; |
700 | 525 | ||
701 | /* Ask tuner to go to analog or radio mode */ | 526 | if (0 == *nbuffers) |
702 | memset(&f, 0, sizeof(f)); | 527 | *nbuffers = 32; |
703 | f.frequency = dev->ctl_freq; | ||
704 | f.type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
705 | 528 | ||
706 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); | 529 | *nplanes = 1; |
530 | sizes[0] = size; | ||
707 | 531 | ||
708 | return 0; | 532 | return 0; |
709 | } | 533 | } |
710 | 534 | ||
711 | /* This is called *without* dev->slock held; please keep it that way */ | 535 | static int |
712 | static void free_buffer(struct videobuf_queue *vq, struct em28xx_buffer *buf) | 536 | buffer_prepare(struct vb2_buffer *vb) |
713 | { | 537 | { |
714 | struct em28xx_fh *fh = vq->priv_data; | 538 | struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); |
715 | struct em28xx *dev = fh->dev; | 539 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); |
716 | unsigned long flags = 0; | 540 | unsigned long size; |
717 | if (in_interrupt()) | ||
718 | BUG(); | ||
719 | 541 | ||
720 | /* We used to wait for the buffer to finish here, but this didn't work | 542 | em28xx_videodbg("%s, field=%d\n", __func__, vb->v4l2_buf.field); |
721 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
722 | videobuf_queue_cancel marked it as finished for us. | ||
723 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
724 | 543 | ||
725 | This should be safe; by the time we get here, the buffer isn't | 544 | size = (dev->width * dev->height * dev->format->depth + 7) >> 3; |
726 | queued anymore. If we ever start marking the buffers as | ||
727 | VIDEOBUF_ACTIVE, it won't be, though. | ||
728 | */ | ||
729 | spin_lock_irqsave(&dev->slock, flags); | ||
730 | if (dev->isoc_ctl.vid_buf == buf) | ||
731 | dev->isoc_ctl.vid_buf = NULL; | ||
732 | spin_unlock_irqrestore(&dev->slock, flags); | ||
733 | 545 | ||
734 | videobuf_vmalloc_free(&buf->vb); | 546 | if (vb2_plane_size(vb, 0) < size) { |
735 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 547 | em28xx_videodbg("%s data will not fit into plane (%lu < %lu)\n", |
548 | __func__, vb2_plane_size(vb, 0), size); | ||
549 | return -EINVAL; | ||
550 | } | ||
551 | vb2_set_plane_payload(&buf->vb, 0, size); | ||
552 | |||
553 | return 0; | ||
736 | } | 554 | } |
737 | 555 | ||
738 | static int | 556 | int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) |
739 | buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
740 | enum v4l2_field field) | ||
741 | { | 557 | { |
742 | struct em28xx_fh *fh = vq->priv_data; | 558 | struct em28xx *dev = vb2_get_drv_priv(vq); |
743 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | 559 | struct v4l2_frequency f; |
744 | struct em28xx *dev = fh->dev; | 560 | int rc = 0; |
745 | int rc = 0, urb_init = 0; | ||
746 | 561 | ||
747 | buf->vb.size = (fh->dev->width * fh->dev->height * dev->format->depth | 562 | em28xx_videodbg("%s\n", __func__); |
748 | + 7) >> 3; | ||
749 | 563 | ||
750 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | 564 | /* Make sure streaming is not already in progress for this type |
751 | return -EINVAL; | 565 | of filehandle (e.g. video, vbi) */ |
566 | rc = res_get(dev, vq->type); | ||
567 | if (rc) | ||
568 | return rc; | ||
569 | |||
570 | if (dev->streaming_users++ == 0) { | ||
571 | /* First active streaming user, so allocate all the URBs */ | ||
752 | 572 | ||
753 | buf->vb.width = dev->width; | 573 | /* Allocate the USB bandwidth */ |
754 | buf->vb.height = dev->height; | 574 | em28xx_set_alternate(dev); |
755 | buf->vb.field = field; | 575 | |
576 | /* Needed, since GPIO might have disabled power of | ||
577 | some i2c device | ||
578 | */ | ||
579 | em28xx_wake_i2c(dev); | ||
756 | 580 | ||
757 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 581 | dev->capture_type = -1; |
758 | rc = videobuf_iolock(vq, &buf->vb, NULL); | 582 | rc = em28xx_init_usb_xfer(dev, EM28XX_ANALOG_MODE, |
583 | dev->analog_xfer_bulk, | ||
584 | EM28XX_NUM_BUFS, | ||
585 | dev->max_pkt_size, | ||
586 | dev->packet_multiplier, | ||
587 | em28xx_urb_data_copy); | ||
759 | if (rc < 0) | 588 | if (rc < 0) |
760 | goto fail; | 589 | goto fail; |
761 | } | ||
762 | 590 | ||
763 | if (!dev->isoc_ctl.analog_bufs.num_bufs) | 591 | /* |
764 | urb_init = 1; | 592 | * djh: it's not clear whether this code is still needed. I'm |
593 | * leaving it in here for now entirely out of concern for | ||
594 | * backward compatibility (the old code did it) | ||
595 | */ | ||
765 | 596 | ||
766 | if (urb_init) { | 597 | /* Ask tuner to go to analog or radio mode */ |
767 | if (em28xx_vbi_supported(dev) == 1) | 598 | memset(&f, 0, sizeof(f)); |
768 | rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE, | 599 | f.frequency = dev->ctl_freq; |
769 | EM28XX_NUM_PACKETS, | 600 | if (vq->owner && vq->owner->vdev->vfl_type == VFL_TYPE_RADIO) |
770 | EM28XX_NUM_BUFS, | 601 | f.type = V4L2_TUNER_RADIO; |
771 | dev->max_pkt_size, | ||
772 | em28xx_isoc_copy_vbi); | ||
773 | else | 602 | else |
774 | rc = em28xx_init_isoc(dev, EM28XX_ANALOG_MODE, | 603 | f.type = V4L2_TUNER_ANALOG_TV; |
775 | EM28XX_NUM_PACKETS, | 604 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f); |
776 | EM28XX_NUM_BUFS, | ||
777 | dev->max_pkt_size, | ||
778 | em28xx_isoc_copy); | ||
779 | if (rc < 0) | ||
780 | goto fail; | ||
781 | } | 605 | } |
782 | 606 | ||
783 | buf->vb.state = VIDEOBUF_PREPARED; | ||
784 | return 0; | ||
785 | |||
786 | fail: | 607 | fail: |
787 | free_buffer(vq, buf); | ||
788 | return rc; | 608 | return rc; |
789 | } | 609 | } |
790 | 610 | ||
791 | static void | 611 | static int em28xx_stop_streaming(struct vb2_queue *vq) |
792 | buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
793 | { | 612 | { |
794 | struct em28xx_buffer *buf = container_of(vb, | 613 | struct em28xx *dev = vb2_get_drv_priv(vq); |
795 | struct em28xx_buffer, | 614 | struct em28xx_dmaqueue *vidq = &dev->vidq; |
796 | vb); | 615 | unsigned long flags = 0; |
797 | struct em28xx_fh *fh = vq->priv_data; | 616 | |
798 | struct em28xx *dev = fh->dev; | 617 | em28xx_videodbg("%s\n", __func__); |
799 | struct em28xx_dmaqueue *vidq = &dev->vidq; | 618 | |
619 | res_free(dev, vq->type); | ||
620 | |||
621 | if (dev->streaming_users-- == 1) { | ||
622 | /* Last active user, so shutdown all the URBS */ | ||
623 | em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); | ||
624 | } | ||
800 | 625 | ||
801 | buf->vb.state = VIDEOBUF_QUEUED; | 626 | spin_lock_irqsave(&dev->slock, flags); |
802 | list_add_tail(&buf->vb.queue, &vidq->active); | 627 | while (!list_empty(&vidq->active)) { |
628 | struct em28xx_buffer *buf; | ||
629 | buf = list_entry(vidq->active.next, struct em28xx_buffer, list); | ||
630 | list_del(&buf->list); | ||
631 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
632 | } | ||
633 | dev->usb_ctl.vid_buf = NULL; | ||
634 | spin_unlock_irqrestore(&dev->slock, flags); | ||
803 | 635 | ||
636 | return 0; | ||
804 | } | 637 | } |
805 | 638 | ||
806 | static void buffer_release(struct videobuf_queue *vq, | 639 | int em28xx_stop_vbi_streaming(struct vb2_queue *vq) |
807 | struct videobuf_buffer *vb) | ||
808 | { | 640 | { |
809 | struct em28xx_buffer *buf = container_of(vb, | 641 | struct em28xx *dev = vb2_get_drv_priv(vq); |
810 | struct em28xx_buffer, | 642 | struct em28xx_dmaqueue *vbiq = &dev->vbiq; |
811 | vb); | 643 | unsigned long flags = 0; |
812 | struct em28xx_fh *fh = vq->priv_data; | 644 | |
813 | struct em28xx *dev = (struct em28xx *)fh->dev; | 645 | em28xx_videodbg("%s\n", __func__); |
814 | 646 | ||
815 | em28xx_isocdbg("em28xx: called buffer_release\n"); | 647 | res_free(dev, vq->type); |
816 | 648 | ||
817 | free_buffer(vq, buf); | 649 | if (dev->streaming_users-- == 1) { |
650 | /* Last active user, so shutdown all the URBS */ | ||
651 | em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); | ||
652 | } | ||
653 | |||
654 | spin_lock_irqsave(&dev->slock, flags); | ||
655 | while (!list_empty(&vbiq->active)) { | ||
656 | struct em28xx_buffer *buf; | ||
657 | buf = list_entry(vbiq->active.next, struct em28xx_buffer, list); | ||
658 | list_del(&buf->list); | ||
659 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); | ||
660 | } | ||
661 | dev->usb_ctl.vbi_buf = NULL; | ||
662 | spin_unlock_irqrestore(&dev->slock, flags); | ||
663 | |||
664 | return 0; | ||
818 | } | 665 | } |
819 | 666 | ||
820 | static struct videobuf_queue_ops em28xx_video_qops = { | 667 | static void |
821 | .buf_setup = buffer_setup, | 668 | buffer_queue(struct vb2_buffer *vb) |
669 | { | ||
670 | struct em28xx *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
671 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | ||
672 | struct em28xx_dmaqueue *vidq = &dev->vidq; | ||
673 | unsigned long flags = 0; | ||
674 | |||
675 | em28xx_videodbg("%s\n", __func__); | ||
676 | buf->mem = vb2_plane_vaddr(vb, 0); | ||
677 | buf->length = vb2_plane_size(vb, 0); | ||
678 | |||
679 | spin_lock_irqsave(&dev->slock, flags); | ||
680 | list_add_tail(&buf->list, &vidq->active); | ||
681 | spin_unlock_irqrestore(&dev->slock, flags); | ||
682 | } | ||
683 | |||
684 | static struct vb2_ops em28xx_video_qops = { | ||
685 | .queue_setup = queue_setup, | ||
822 | .buf_prepare = buffer_prepare, | 686 | .buf_prepare = buffer_prepare, |
823 | .buf_queue = buffer_queue, | 687 | .buf_queue = buffer_queue, |
824 | .buf_release = buffer_release, | 688 | .start_streaming = em28xx_start_analog_streaming, |
689 | .stop_streaming = em28xx_stop_streaming, | ||
690 | .wait_prepare = vb2_ops_wait_prepare, | ||
691 | .wait_finish = vb2_ops_wait_finish, | ||
825 | }; | 692 | }; |
826 | 693 | ||
694 | int em28xx_vb2_setup(struct em28xx *dev) | ||
695 | { | ||
696 | int rc; | ||
697 | struct vb2_queue *q; | ||
698 | |||
699 | /* Setup Videobuf2 for Video capture */ | ||
700 | q = &dev->vb_vidq; | ||
701 | q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
702 | q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF; | ||
703 | q->drv_priv = dev; | ||
704 | q->buf_struct_size = sizeof(struct em28xx_buffer); | ||
705 | q->ops = &em28xx_video_qops; | ||
706 | q->mem_ops = &vb2_vmalloc_memops; | ||
707 | |||
708 | rc = vb2_queue_init(q); | ||
709 | if (rc < 0) | ||
710 | return rc; | ||
711 | |||
712 | /* Setup Videobuf2 for VBI capture */ | ||
713 | q = &dev->vb_vbiq; | ||
714 | q->type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
715 | q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR; | ||
716 | q->drv_priv = dev; | ||
717 | q->buf_struct_size = sizeof(struct em28xx_buffer); | ||
718 | q->ops = &em28xx_vbi_qops; | ||
719 | q->mem_ops = &vb2_vmalloc_memops; | ||
720 | |||
721 | rc = vb2_queue_init(q); | ||
722 | if (rc < 0) | ||
723 | return rc; | ||
724 | |||
725 | return 0; | ||
726 | } | ||
727 | |||
827 | /********************* v4l2 interface **************************************/ | 728 | /********************* v4l2 interface **************************************/ |
828 | 729 | ||
829 | static void video_mux(struct em28xx *dev, int index) | 730 | static void video_mux(struct em28xx *dev, int index) |
@@ -856,143 +757,54 @@ static void video_mux(struct em28xx *dev, int index) | |||
856 | em28xx_audio_analog_set(dev); | 757 | em28xx_audio_analog_set(dev); |
857 | } | 758 | } |
858 | 759 | ||
859 | /* Usage lock check functions */ | 760 | void em28xx_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv) |
860 | static int res_get(struct em28xx_fh *fh, unsigned int bit) | ||
861 | { | ||
862 | struct em28xx *dev = fh->dev; | ||
863 | |||
864 | if (fh->resources & bit) | ||
865 | /* have it already allocated */ | ||
866 | return 1; | ||
867 | |||
868 | /* is it free? */ | ||
869 | if (dev->resources & bit) { | ||
870 | /* no, someone else uses it */ | ||
871 | return 0; | ||
872 | } | ||
873 | /* it's free, grab it */ | ||
874 | fh->resources |= bit; | ||
875 | dev->resources |= bit; | ||
876 | em28xx_videodbg("res: get %d\n", bit); | ||
877 | return 1; | ||
878 | } | ||
879 | |||
880 | static int res_check(struct em28xx_fh *fh, unsigned int bit) | ||
881 | { | ||
882 | return fh->resources & bit; | ||
883 | } | ||
884 | |||
885 | static int res_locked(struct em28xx *dev, unsigned int bit) | ||
886 | { | ||
887 | return dev->resources & bit; | ||
888 | } | ||
889 | |||
890 | static void res_free(struct em28xx_fh *fh, unsigned int bits) | ||
891 | { | 761 | { |
892 | struct em28xx *dev = fh->dev; | 762 | struct em28xx *dev = priv; |
893 | |||
894 | BUG_ON((fh->resources & bits) != bits); | ||
895 | |||
896 | fh->resources &= ~bits; | ||
897 | dev->resources &= ~bits; | ||
898 | em28xx_videodbg("res: put %d\n", bits); | ||
899 | } | ||
900 | |||
901 | static int get_ressource(struct em28xx_fh *fh) | ||
902 | { | ||
903 | switch (fh->type) { | ||
904 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
905 | return EM28XX_RESOURCE_VIDEO; | ||
906 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
907 | return EM28XX_RESOURCE_VBI; | ||
908 | default: | ||
909 | BUG(); | ||
910 | return 0; | ||
911 | } | ||
912 | } | ||
913 | |||
914 | /* | ||
915 | * ac97_queryctrl() | ||
916 | * return the ac97 supported controls | ||
917 | */ | ||
918 | static int ac97_queryctrl(struct v4l2_queryctrl *qc) | ||
919 | { | ||
920 | int i; | ||
921 | 763 | ||
922 | for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++) { | 764 | /* |
923 | if (qc->id && qc->id == ac97_qctrl[i].id) { | 765 | * In the case of non-AC97 volume controls, we still need |
924 | memcpy(qc, &(ac97_qctrl[i]), sizeof(*qc)); | 766 | * to do some setups at em28xx, in order to mute/unmute |
925 | return 0; | 767 | * and to adjust audio volume. However, the value ranges |
926 | } | 768 | * should be checked by the corresponding V4L subdriver. |
927 | } | 769 | */ |
928 | |||
929 | /* Control is not ac97 related */ | ||
930 | return 1; | ||
931 | } | ||
932 | |||
933 | /* | ||
934 | * ac97_get_ctrl() | ||
935 | * return the current values for ac97 mute and volume | ||
936 | */ | ||
937 | static int ac97_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl) | ||
938 | { | ||
939 | switch (ctrl->id) { | 770 | switch (ctrl->id) { |
940 | case V4L2_CID_AUDIO_MUTE: | 771 | case V4L2_CID_AUDIO_MUTE: |
941 | ctrl->value = dev->mute; | 772 | dev->mute = ctrl->val; |
942 | return 0; | 773 | em28xx_audio_analog_set(dev); |
774 | break; | ||
943 | case V4L2_CID_AUDIO_VOLUME: | 775 | case V4L2_CID_AUDIO_VOLUME: |
944 | ctrl->value = dev->volume; | 776 | dev->volume = ctrl->val; |
945 | return 0; | 777 | em28xx_audio_analog_set(dev); |
946 | default: | 778 | break; |
947 | /* Control is not ac97 related */ | ||
948 | return 1; | ||
949 | } | 779 | } |
950 | } | 780 | } |
951 | 781 | ||
952 | /* | 782 | static int em28xx_s_ctrl(struct v4l2_ctrl *ctrl) |
953 | * ac97_set_ctrl() | ||
954 | * set values for ac97 mute and volume | ||
955 | */ | ||
956 | static int ac97_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) | ||
957 | { | 783 | { |
958 | int i; | 784 | struct em28xx *dev = container_of(ctrl->handler, struct em28xx, ctrl_handler); |
959 | |||
960 | for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++) | ||
961 | if (ctrl->id == ac97_qctrl[i].id) | ||
962 | goto handle; | ||
963 | |||
964 | /* Announce that hasn't handle it */ | ||
965 | return 1; | ||
966 | |||
967 | handle: | ||
968 | if (ctrl->value < ac97_qctrl[i].minimum || | ||
969 | ctrl->value > ac97_qctrl[i].maximum) | ||
970 | return -ERANGE; | ||
971 | 785 | ||
972 | switch (ctrl->id) { | 786 | switch (ctrl->id) { |
973 | case V4L2_CID_AUDIO_MUTE: | 787 | case V4L2_CID_AUDIO_MUTE: |
974 | dev->mute = ctrl->value; | 788 | dev->mute = ctrl->val; |
975 | break; | 789 | break; |
976 | case V4L2_CID_AUDIO_VOLUME: | 790 | case V4L2_CID_AUDIO_VOLUME: |
977 | dev->volume = ctrl->value; | 791 | dev->volume = ctrl->val; |
978 | break; | 792 | break; |
979 | } | 793 | } |
980 | 794 | ||
981 | return em28xx_audio_analog_set(dev); | 795 | return em28xx_audio_analog_set(dev); |
982 | } | 796 | } |
983 | 797 | ||
798 | const struct v4l2_ctrl_ops em28xx_ctrl_ops = { | ||
799 | .s_ctrl = em28xx_s_ctrl, | ||
800 | }; | ||
801 | |||
984 | static int check_dev(struct em28xx *dev) | 802 | static int check_dev(struct em28xx *dev) |
985 | { | 803 | { |
986 | if (dev->state & DEV_DISCONNECTED) { | 804 | if (dev->disconnected) { |
987 | em28xx_errdev("v4l2 ioctl: device not present\n"); | 805 | em28xx_errdev("v4l2 ioctl: device not present\n"); |
988 | return -ENODEV; | 806 | return -ENODEV; |
989 | } | 807 | } |
990 | |||
991 | if (dev->state & DEV_MISCONFIGURED) { | ||
992 | em28xx_errdev("v4l2 ioctl: device is misconfigured; " | ||
993 | "close and open it again\n"); | ||
994 | return -EIO; | ||
995 | } | ||
996 | return 0; | 808 | return 0; |
997 | } | 809 | } |
998 | 810 | ||
@@ -1072,8 +884,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
1072 | /* the em2800 can only scale down to 50% */ | 884 | /* the em2800 can only scale down to 50% */ |
1073 | height = height > (3 * maxh / 4) ? maxh : maxh / 2; | 885 | height = height > (3 * maxh / 4) ? maxh : maxh / 2; |
1074 | width = width > (3 * maxw / 4) ? maxw : maxw / 2; | 886 | width = width > (3 * maxw / 4) ? maxw : maxw / 2; |
1075 | /* MaxPacketSize for em2800 is too small to capture at full resolution | 887 | /* |
1076 | * use half of maxw as the scaler can only scale to 50% */ | 888 | * MaxPacketSize for em2800 is too small to capture at full |
889 | * resolution use half of maxw as the scaler can only scale | ||
890 | * to 50% | ||
891 | */ | ||
1077 | if (width == maxw && height == maxh) | 892 | if (width == maxw && height == maxh) |
1078 | width /= 2; | 893 | width /= 2; |
1079 | } else { | 894 | } else { |
@@ -1091,7 +906,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
1091 | f->fmt.pix.width = width; | 906 | f->fmt.pix.width = width; |
1092 | f->fmt.pix.height = height; | 907 | f->fmt.pix.height = height; |
1093 | f->fmt.pix.pixelformat = fmt->fourcc; | 908 | f->fmt.pix.pixelformat = fmt->fourcc; |
1094 | f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; | 909 | f->fmt.pix.bytesperline = (width * fmt->depth + 7) >> 3; |
1095 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; | 910 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; |
1096 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 911 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
1097 | if (dev->progressive) | 912 | if (dev->progressive) |
@@ -1119,7 +934,6 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, | |||
1119 | /* set new image size */ | 934 | /* set new image size */ |
1120 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | 935 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); |
1121 | 936 | ||
1122 | em28xx_set_alternate(dev); | ||
1123 | em28xx_resolution_set(dev); | 937 | em28xx_resolution_set(dev); |
1124 | 938 | ||
1125 | return 0; | 939 | return 0; |
@@ -1128,21 +942,13 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc, | |||
1128 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | 942 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, |
1129 | struct v4l2_format *f) | 943 | struct v4l2_format *f) |
1130 | { | 944 | { |
1131 | struct em28xx_fh *fh = priv; | 945 | struct em28xx *dev = video_drvdata(file); |
1132 | struct em28xx *dev = fh->dev; | ||
1133 | int rc; | ||
1134 | 946 | ||
1135 | rc = check_dev(dev); | 947 | if (dev->streaming_users > 0) |
1136 | if (rc < 0) | 948 | return -EBUSY; |
1137 | return rc; | ||
1138 | 949 | ||
1139 | vidioc_try_fmt_vid_cap(file, priv, f); | 950 | vidioc_try_fmt_vid_cap(file, priv, f); |
1140 | 951 | ||
1141 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | ||
1142 | em28xx_errdev("%s queue busy\n", __func__); | ||
1143 | return -EBUSY; | ||
1144 | } | ||
1145 | |||
1146 | return em28xx_set_video_format(dev, f->fmt.pix.pixelformat, | 952 | return em28xx_set_video_format(dev, f->fmt.pix.pixelformat, |
1147 | f->fmt.pix.width, f->fmt.pix.height); | 953 | f->fmt.pix.width, f->fmt.pix.height); |
1148 | } | 954 | } |
@@ -1153,6 +959,8 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
1153 | struct em28xx *dev = fh->dev; | 959 | struct em28xx *dev = fh->dev; |
1154 | int rc; | 960 | int rc; |
1155 | 961 | ||
962 | if (dev->board.is_webcam) | ||
963 | return -ENOTTY; | ||
1156 | rc = check_dev(dev); | 964 | rc = check_dev(dev); |
1157 | if (rc < 0) | 965 | if (rc < 0) |
1158 | return rc; | 966 | return rc; |
@@ -1168,6 +976,8 @@ static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *norm) | |||
1168 | struct em28xx *dev = fh->dev; | 976 | struct em28xx *dev = fh->dev; |
1169 | int rc; | 977 | int rc; |
1170 | 978 | ||
979 | if (dev->board.is_webcam) | ||
980 | return -ENOTTY; | ||
1171 | rc = check_dev(dev); | 981 | rc = check_dev(dev); |
1172 | if (rc < 0) | 982 | if (rc < 0) |
1173 | return rc; | 983 | return rc; |
@@ -1184,15 +994,22 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
1184 | struct v4l2_format f; | 994 | struct v4l2_format f; |
1185 | int rc; | 995 | int rc; |
1186 | 996 | ||
997 | if (dev->board.is_webcam) | ||
998 | return -ENOTTY; | ||
999 | if (*norm == dev->norm) | ||
1000 | return 0; | ||
1187 | rc = check_dev(dev); | 1001 | rc = check_dev(dev); |
1188 | if (rc < 0) | 1002 | if (rc < 0) |
1189 | return rc; | 1003 | return rc; |
1190 | 1004 | ||
1005 | if (dev->streaming_users > 0) | ||
1006 | return -EBUSY; | ||
1007 | |||
1191 | dev->norm = *norm; | 1008 | dev->norm = *norm; |
1192 | 1009 | ||
1193 | /* Adjusts width/height, if needed */ | 1010 | /* Adjusts width/height, if needed */ |
1194 | f.fmt.pix.width = dev->width; | 1011 | f.fmt.pix.width = 720; |
1195 | f.fmt.pix.height = dev->height; | 1012 | f.fmt.pix.height = (*norm & V4L2_STD_525_60) ? 480 : 576; |
1196 | vidioc_try_fmt_vid_cap(file, priv, &f); | 1013 | vidioc_try_fmt_vid_cap(file, priv, &f); |
1197 | 1014 | ||
1198 | /* set new image size */ | 1015 | /* set new image size */ |
@@ -1216,6 +1033,7 @@ static int vidioc_g_parm(struct file *file, void *priv, | |||
1216 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1033 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1217 | return -EINVAL; | 1034 | return -EINVAL; |
1218 | 1035 | ||
1036 | p->parm.capture.readbuffers = EM28XX_MIN_BUF; | ||
1219 | if (dev->board.is_webcam) | 1037 | if (dev->board.is_webcam) |
1220 | rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0, | 1038 | rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0, |
1221 | video, g_parm, p); | 1039 | video, g_parm, p); |
@@ -1233,11 +1051,12 @@ static int vidioc_s_parm(struct file *file, void *priv, | |||
1233 | struct em28xx *dev = fh->dev; | 1051 | struct em28xx *dev = fh->dev; |
1234 | 1052 | ||
1235 | if (!dev->board.is_webcam) | 1053 | if (!dev->board.is_webcam) |
1236 | return -EINVAL; | 1054 | return -ENOTTY; |
1237 | 1055 | ||
1238 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1056 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1239 | return -EINVAL; | 1057 | return -EINVAL; |
1240 | 1058 | ||
1059 | p->parm.capture.readbuffers = EM28XX_MIN_BUF; | ||
1241 | return v4l2_device_call_until_err(&dev->v4l2_dev, 0, video, s_parm, p); | 1060 | return v4l2_device_call_until_err(&dev->v4l2_dev, 0, video, s_parm, p); |
1242 | } | 1061 | } |
1243 | 1062 | ||
@@ -1276,6 +1095,9 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1276 | i->type = V4L2_INPUT_TYPE_TUNER; | 1095 | i->type = V4L2_INPUT_TYPE_TUNER; |
1277 | 1096 | ||
1278 | i->std = dev->vdev->tvnorms; | 1097 | i->std = dev->vdev->tvnorms; |
1098 | /* webcams do not have the STD API */ | ||
1099 | if (dev->board.is_webcam) | ||
1100 | i->capabilities = 0; | ||
1279 | 1101 | ||
1280 | return 0; | 1102 | return 0; |
1281 | } | 1103 | } |
@@ -1375,131 +1197,6 @@ static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio | |||
1375 | return 0; | 1197 | return 0; |
1376 | } | 1198 | } |
1377 | 1199 | ||
1378 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
1379 | struct v4l2_queryctrl *qc) | ||
1380 | { | ||
1381 | struct em28xx_fh *fh = priv; | ||
1382 | struct em28xx *dev = fh->dev; | ||
1383 | int id = qc->id; | ||
1384 | int rc; | ||
1385 | |||
1386 | rc = check_dev(dev); | ||
1387 | if (rc < 0) | ||
1388 | return rc; | ||
1389 | |||
1390 | memset(qc, 0, sizeof(*qc)); | ||
1391 | |||
1392 | qc->id = id; | ||
1393 | |||
1394 | /* enumerate AC97 controls */ | ||
1395 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | ||
1396 | rc = ac97_queryctrl(qc); | ||
1397 | if (!rc) | ||
1398 | return 0; | ||
1399 | } | ||
1400 | |||
1401 | /* enumerate V4L2 device controls */ | ||
1402 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc); | ||
1403 | |||
1404 | if (qc->type) | ||
1405 | return 0; | ||
1406 | else | ||
1407 | return -EINVAL; | ||
1408 | } | ||
1409 | |||
1410 | /* | ||
1411 | * FIXME: This is an indirect way to check if a control exists at a | ||
1412 | * subdev. Instead of that hack, maybe the better would be to change all | ||
1413 | * subdevs to return -ENOIOCTLCMD, if an ioctl is not supported. | ||
1414 | */ | ||
1415 | static int check_subdev_ctrl(struct em28xx *dev, int id) | ||
1416 | { | ||
1417 | struct v4l2_queryctrl qc; | ||
1418 | |||
1419 | memset(&qc, 0, sizeof(qc)); | ||
1420 | qc.id = id; | ||
1421 | |||
1422 | /* enumerate V4L2 device controls */ | ||
1423 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, &qc); | ||
1424 | |||
1425 | if (qc.type) | ||
1426 | return 0; | ||
1427 | else | ||
1428 | return -EINVAL; | ||
1429 | } | ||
1430 | |||
1431 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
1432 | struct v4l2_control *ctrl) | ||
1433 | { | ||
1434 | struct em28xx_fh *fh = priv; | ||
1435 | struct em28xx *dev = fh->dev; | ||
1436 | int rc; | ||
1437 | |||
1438 | rc = check_dev(dev); | ||
1439 | if (rc < 0) | ||
1440 | return rc; | ||
1441 | rc = 0; | ||
1442 | |||
1443 | /* Set an AC97 control */ | ||
1444 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) | ||
1445 | rc = ac97_get_ctrl(dev, ctrl); | ||
1446 | else | ||
1447 | rc = 1; | ||
1448 | |||
1449 | /* It were not an AC97 control. Sends it to the v4l2 dev interface */ | ||
1450 | if (rc == 1) { | ||
1451 | if (check_subdev_ctrl(dev, ctrl->id)) | ||
1452 | return -EINVAL; | ||
1453 | |||
1454 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl); | ||
1455 | rc = 0; | ||
1456 | } | ||
1457 | |||
1458 | return rc; | ||
1459 | } | ||
1460 | |||
1461 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
1462 | struct v4l2_control *ctrl) | ||
1463 | { | ||
1464 | struct em28xx_fh *fh = priv; | ||
1465 | struct em28xx *dev = fh->dev; | ||
1466 | int rc; | ||
1467 | |||
1468 | rc = check_dev(dev); | ||
1469 | if (rc < 0) | ||
1470 | return rc; | ||
1471 | |||
1472 | /* Set an AC97 control */ | ||
1473 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) | ||
1474 | rc = ac97_set_ctrl(dev, ctrl); | ||
1475 | else | ||
1476 | rc = 1; | ||
1477 | |||
1478 | /* It isn't an AC97 control. Sends it to the v4l2 dev interface */ | ||
1479 | if (rc == 1) { | ||
1480 | rc = check_subdev_ctrl(dev, ctrl->id); | ||
1481 | if (!rc) | ||
1482 | v4l2_device_call_all(&dev->v4l2_dev, 0, | ||
1483 | core, s_ctrl, ctrl); | ||
1484 | /* | ||
1485 | * In the case of non-AC97 volume controls, we still need | ||
1486 | * to do some setups at em28xx, in order to mute/unmute | ||
1487 | * and to adjust audio volume. However, the value ranges | ||
1488 | * should be checked by the corresponding V4L subdriver. | ||
1489 | */ | ||
1490 | switch (ctrl->id) { | ||
1491 | case V4L2_CID_AUDIO_MUTE: | ||
1492 | dev->mute = ctrl->value; | ||
1493 | rc = em28xx_audio_analog_set(dev); | ||
1494 | break; | ||
1495 | case V4L2_CID_AUDIO_VOLUME: | ||
1496 | dev->volume = ctrl->value; | ||
1497 | rc = em28xx_audio_analog_set(dev); | ||
1498 | } | ||
1499 | } | ||
1500 | return (rc < 0) ? rc : 0; | ||
1501 | } | ||
1502 | |||
1503 | static int vidioc_g_tuner(struct file *file, void *priv, | 1200 | static int vidioc_g_tuner(struct file *file, void *priv, |
1504 | struct v4l2_tuner *t) | 1201 | struct v4l2_tuner *t) |
1505 | { | 1202 | { |
@@ -1515,7 +1212,6 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
1515 | return -EINVAL; | 1212 | return -EINVAL; |
1516 | 1213 | ||
1517 | strcpy(t->name, "Tuner"); | 1214 | strcpy(t->name, "Tuner"); |
1518 | t->type = V4L2_TUNER_ANALOG_TV; | ||
1519 | 1215 | ||
1520 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); | 1216 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); |
1521 | return 0; | 1217 | return 0; |
@@ -1545,7 +1241,9 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
1545 | struct em28xx_fh *fh = priv; | 1241 | struct em28xx_fh *fh = priv; |
1546 | struct em28xx *dev = fh->dev; | 1242 | struct em28xx *dev = fh->dev; |
1547 | 1243 | ||
1548 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1244 | if (0 != f->tuner) |
1245 | return -EINVAL; | ||
1246 | |||
1549 | f->frequency = dev->ctl_freq; | 1247 | f->frequency = dev->ctl_freq; |
1550 | return 0; | 1248 | return 0; |
1551 | } | 1249 | } |
@@ -1564,13 +1262,9 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1564 | if (0 != f->tuner) | 1262 | if (0 != f->tuner) |
1565 | return -EINVAL; | 1263 | return -EINVAL; |
1566 | 1264 | ||
1567 | if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) | ||
1568 | return -EINVAL; | ||
1569 | if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) | ||
1570 | return -EINVAL; | ||
1571 | |||
1572 | dev->ctl_freq = f->frequency; | ||
1573 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f); | 1265 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f); |
1266 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f); | ||
1267 | dev->ctl_freq = f->frequency; | ||
1574 | 1268 | ||
1575 | return 0; | 1269 | return 0; |
1576 | } | 1270 | } |
@@ -1596,6 +1290,14 @@ static int vidioc_g_chip_ident(struct file *file, void *priv, | |||
1596 | 1290 | ||
1597 | chip->ident = V4L2_IDENT_NONE; | 1291 | chip->ident = V4L2_IDENT_NONE; |
1598 | chip->revision = 0; | 1292 | chip->revision = 0; |
1293 | if (chip->match.type == V4L2_CHIP_MATCH_HOST) { | ||
1294 | if (v4l2_chip_match_host(&chip->match)) | ||
1295 | chip->ident = V4L2_IDENT_NONE; | ||
1296 | return 0; | ||
1297 | } | ||
1298 | if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER && | ||
1299 | chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) | ||
1300 | return -EINVAL; | ||
1599 | 1301 | ||
1600 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip); | 1302 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_chip_ident, chip); |
1601 | 1303 | ||
@@ -1704,72 +1406,10 @@ static int vidioc_cropcap(struct file *file, void *priv, | |||
1704 | return 0; | 1406 | return 0; |
1705 | } | 1407 | } |
1706 | 1408 | ||
1707 | static int vidioc_streamon(struct file *file, void *priv, | ||
1708 | enum v4l2_buf_type type) | ||
1709 | { | ||
1710 | struct em28xx_fh *fh = priv; | ||
1711 | struct em28xx *dev = fh->dev; | ||
1712 | int rc = -EINVAL; | ||
1713 | |||
1714 | rc = check_dev(dev); | ||
1715 | if (rc < 0) | ||
1716 | return rc; | ||
1717 | |||
1718 | if (unlikely(type != fh->type)) | ||
1719 | return -EINVAL; | ||
1720 | |||
1721 | em28xx_videodbg("vidioc_streamon fh=%p t=%d fh->res=%d dev->res=%d\n", | ||
1722 | fh, type, fh->resources, dev->resources); | ||
1723 | |||
1724 | if (unlikely(!res_get(fh, get_ressource(fh)))) | ||
1725 | return -EBUSY; | ||
1726 | |||
1727 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1728 | rc = videobuf_streamon(&fh->vb_vidq); | ||
1729 | else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) | ||
1730 | rc = videobuf_streamon(&fh->vb_vbiq); | ||
1731 | |||
1732 | return rc; | ||
1733 | } | ||
1734 | |||
1735 | static int vidioc_streamoff(struct file *file, void *priv, | ||
1736 | enum v4l2_buf_type type) | ||
1737 | { | ||
1738 | struct em28xx_fh *fh = priv; | ||
1739 | struct em28xx *dev = fh->dev; | ||
1740 | int rc; | ||
1741 | |||
1742 | rc = check_dev(dev); | ||
1743 | if (rc < 0) | ||
1744 | return rc; | ||
1745 | |||
1746 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
1747 | fh->type != V4L2_BUF_TYPE_VBI_CAPTURE) | ||
1748 | return -EINVAL; | ||
1749 | if (type != fh->type) | ||
1750 | return -EINVAL; | ||
1751 | |||
1752 | em28xx_videodbg("vidioc_streamoff fh=%p t=%d fh->res=%d dev->res=%d\n", | ||
1753 | fh, type, fh->resources, dev->resources); | ||
1754 | |||
1755 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
1756 | if (res_check(fh, EM28XX_RESOURCE_VIDEO)) { | ||
1757 | videobuf_streamoff(&fh->vb_vidq); | ||
1758 | res_free(fh, EM28XX_RESOURCE_VIDEO); | ||
1759 | } | ||
1760 | } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
1761 | if (res_check(fh, EM28XX_RESOURCE_VBI)) { | ||
1762 | videobuf_streamoff(&fh->vb_vbiq); | ||
1763 | res_free(fh, EM28XX_RESOURCE_VBI); | ||
1764 | } | ||
1765 | } | ||
1766 | |||
1767 | return 0; | ||
1768 | } | ||
1769 | |||
1770 | static int vidioc_querycap(struct file *file, void *priv, | 1409 | static int vidioc_querycap(struct file *file, void *priv, |
1771 | struct v4l2_capability *cap) | 1410 | struct v4l2_capability *cap) |
1772 | { | 1411 | { |
1412 | struct video_device *vdev = video_devdata(file); | ||
1773 | struct em28xx_fh *fh = priv; | 1413 | struct em28xx_fh *fh = priv; |
1774 | struct em28xx *dev = fh->dev; | 1414 | struct em28xx *dev = fh->dev; |
1775 | 1415 | ||
@@ -1777,20 +1417,26 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
1777 | strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); | 1417 | strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); |
1778 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | 1418 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); |
1779 | 1419 | ||
1780 | cap->capabilities = | 1420 | if (vdev->vfl_type == VFL_TYPE_GRABBER) |
1781 | V4L2_CAP_SLICED_VBI_CAPTURE | | 1421 | cap->device_caps = V4L2_CAP_READWRITE | |
1782 | V4L2_CAP_VIDEO_CAPTURE | | 1422 | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; |
1783 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; | 1423 | else if (vdev->vfl_type == VFL_TYPE_RADIO) |
1784 | 1424 | cap->device_caps = V4L2_CAP_RADIO; | |
1785 | if (dev->vbi_dev) | 1425 | else |
1786 | cap->capabilities |= V4L2_CAP_VBI_CAPTURE; | 1426 | cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE; |
1787 | 1427 | ||
1788 | if (dev->audio_mode.has_audio) | 1428 | if (dev->audio_mode.has_audio) |
1789 | cap->capabilities |= V4L2_CAP_AUDIO; | 1429 | cap->device_caps |= V4L2_CAP_AUDIO; |
1790 | 1430 | ||
1791 | if (dev->tuner_type != TUNER_ABSENT) | 1431 | if (dev->tuner_type != TUNER_ABSENT) |
1792 | cap->capabilities |= V4L2_CAP_TUNER; | 1432 | cap->device_caps |= V4L2_CAP_TUNER; |
1793 | 1433 | ||
1434 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS | | ||
1435 | V4L2_CAP_READWRITE | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; | ||
1436 | if (dev->vbi_dev) | ||
1437 | cap->capabilities |= V4L2_CAP_VBI_CAPTURE; | ||
1438 | if (dev->radio_dev) | ||
1439 | cap->capabilities |= V4L2_CAP_RADIO; | ||
1794 | return 0; | 1440 | return 0; |
1795 | } | 1441 | } |
1796 | 1442 | ||
@@ -1845,46 +1491,6 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, | |||
1845 | return 0; | 1491 | return 0; |
1846 | } | 1492 | } |
1847 | 1493 | ||
1848 | /* Sliced VBI ioctls */ | ||
1849 | static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | ||
1850 | struct v4l2_format *f) | ||
1851 | { | ||
1852 | struct em28xx_fh *fh = priv; | ||
1853 | struct em28xx *dev = fh->dev; | ||
1854 | int rc; | ||
1855 | |||
1856 | rc = check_dev(dev); | ||
1857 | if (rc < 0) | ||
1858 | return rc; | ||
1859 | |||
1860 | f->fmt.sliced.service_set = 0; | ||
1861 | v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced); | ||
1862 | |||
1863 | if (f->fmt.sliced.service_set == 0) | ||
1864 | rc = -EINVAL; | ||
1865 | |||
1866 | return rc; | ||
1867 | } | ||
1868 | |||
1869 | static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, | ||
1870 | struct v4l2_format *f) | ||
1871 | { | ||
1872 | struct em28xx_fh *fh = priv; | ||
1873 | struct em28xx *dev = fh->dev; | ||
1874 | int rc; | ||
1875 | |||
1876 | rc = check_dev(dev); | ||
1877 | if (rc < 0) | ||
1878 | return rc; | ||
1879 | |||
1880 | v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced); | ||
1881 | |||
1882 | if (f->fmt.sliced.service_set == 0) | ||
1883 | return -EINVAL; | ||
1884 | |||
1885 | return 0; | ||
1886 | } | ||
1887 | |||
1888 | /* RAW VBI ioctls */ | 1494 | /* RAW VBI ioctls */ |
1889 | 1495 | ||
1890 | static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, | 1496 | static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, |
@@ -1900,6 +1506,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, | |||
1900 | format->fmt.vbi.sampling_rate = 6750000 * 4 / 2; | 1506 | format->fmt.vbi.sampling_rate = 6750000 * 4 / 2; |
1901 | format->fmt.vbi.count[0] = dev->vbi_height; | 1507 | format->fmt.vbi.count[0] = dev->vbi_height; |
1902 | format->fmt.vbi.count[1] = dev->vbi_height; | 1508 | format->fmt.vbi.count[1] = dev->vbi_height; |
1509 | memset(format->fmt.vbi.reserved, 0, sizeof(format->fmt.vbi.reserved)); | ||
1903 | 1510 | ||
1904 | /* Varies by video standard (NTSC, PAL, etc.) */ | 1511 | /* Varies by video standard (NTSC, PAL, etc.) */ |
1905 | if (dev->norm & V4L2_STD_525_60) { | 1512 | if (dev->norm & V4L2_STD_525_60) { |
@@ -1928,6 +1535,7 @@ static int vidioc_s_fmt_vbi_cap(struct file *file, void *priv, | |||
1928 | format->fmt.vbi.sampling_rate = 6750000 * 4 / 2; | 1535 | format->fmt.vbi.sampling_rate = 6750000 * 4 / 2; |
1929 | format->fmt.vbi.count[0] = dev->vbi_height; | 1536 | format->fmt.vbi.count[0] = dev->vbi_height; |
1930 | format->fmt.vbi.count[1] = dev->vbi_height; | 1537 | format->fmt.vbi.count[1] = dev->vbi_height; |
1538 | memset(format->fmt.vbi.reserved, 0, sizeof(format->fmt.vbi.reserved)); | ||
1931 | 1539 | ||
1932 | /* Varies by video standard (NTSC, PAL, etc.) */ | 1540 | /* Varies by video standard (NTSC, PAL, etc.) */ |
1933 | if (dev->norm & V4L2_STD_525_60) { | 1541 | if (dev->norm & V4L2_STD_525_60) { |
@@ -1943,100 +1551,10 @@ static int vidioc_s_fmt_vbi_cap(struct file *file, void *priv, | |||
1943 | return 0; | 1551 | return 0; |
1944 | } | 1552 | } |
1945 | 1553 | ||
1946 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1947 | struct v4l2_requestbuffers *rb) | ||
1948 | { | ||
1949 | struct em28xx_fh *fh = priv; | ||
1950 | struct em28xx *dev = fh->dev; | ||
1951 | int rc; | ||
1952 | |||
1953 | rc = check_dev(dev); | ||
1954 | if (rc < 0) | ||
1955 | return rc; | ||
1956 | |||
1957 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1958 | return videobuf_reqbufs(&fh->vb_vidq, rb); | ||
1959 | else | ||
1960 | return videobuf_reqbufs(&fh->vb_vbiq, rb); | ||
1961 | } | ||
1962 | |||
1963 | static int vidioc_querybuf(struct file *file, void *priv, | ||
1964 | struct v4l2_buffer *b) | ||
1965 | { | ||
1966 | struct em28xx_fh *fh = priv; | ||
1967 | struct em28xx *dev = fh->dev; | ||
1968 | int rc; | ||
1969 | |||
1970 | rc = check_dev(dev); | ||
1971 | if (rc < 0) | ||
1972 | return rc; | ||
1973 | |||
1974 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1975 | return videobuf_querybuf(&fh->vb_vidq, b); | ||
1976 | else { | ||
1977 | /* FIXME: I'm not sure yet whether this is a bug in zvbi or | ||
1978 | the videobuf framework, but we probably shouldn't be | ||
1979 | returning a buffer larger than that which was asked for. | ||
1980 | At a minimum, it causes a crash in zvbi since it does | ||
1981 | a memcpy based on the source buffer length */ | ||
1982 | int result = videobuf_querybuf(&fh->vb_vbiq, b); | ||
1983 | b->length = dev->vbi_width * dev->vbi_height * 2; | ||
1984 | |||
1985 | return result; | ||
1986 | } | ||
1987 | } | ||
1988 | |||
1989 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1990 | { | ||
1991 | struct em28xx_fh *fh = priv; | ||
1992 | struct em28xx *dev = fh->dev; | ||
1993 | int rc; | ||
1994 | |||
1995 | rc = check_dev(dev); | ||
1996 | if (rc < 0) | ||
1997 | return rc; | ||
1998 | |||
1999 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2000 | return videobuf_qbuf(&fh->vb_vidq, b); | ||
2001 | else | ||
2002 | return videobuf_qbuf(&fh->vb_vbiq, b); | ||
2003 | } | ||
2004 | |||
2005 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
2006 | { | ||
2007 | struct em28xx_fh *fh = priv; | ||
2008 | struct em28xx *dev = fh->dev; | ||
2009 | int rc; | ||
2010 | |||
2011 | rc = check_dev(dev); | ||
2012 | if (rc < 0) | ||
2013 | return rc; | ||
2014 | |||
2015 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2016 | return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & | ||
2017 | O_NONBLOCK); | ||
2018 | else | ||
2019 | return videobuf_dqbuf(&fh->vb_vbiq, b, file->f_flags & | ||
2020 | O_NONBLOCK); | ||
2021 | } | ||
2022 | |||
2023 | /* ----------------------------------------------------------- */ | 1554 | /* ----------------------------------------------------------- */ |
2024 | /* RADIO ESPECIFIC IOCTLS */ | 1555 | /* RADIO ESPECIFIC IOCTLS */ |
2025 | /* ----------------------------------------------------------- */ | 1556 | /* ----------------------------------------------------------- */ |
2026 | 1557 | ||
2027 | static int radio_querycap(struct file *file, void *priv, | ||
2028 | struct v4l2_capability *cap) | ||
2029 | { | ||
2030 | struct em28xx *dev = ((struct em28xx_fh *)priv)->dev; | ||
2031 | |||
2032 | strlcpy(cap->driver, "em28xx", sizeof(cap->driver)); | ||
2033 | strlcpy(cap->card, em28xx_boards[dev->model].name, sizeof(cap->card)); | ||
2034 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | ||
2035 | |||
2036 | cap->capabilities = V4L2_CAP_TUNER; | ||
2037 | return 0; | ||
2038 | } | ||
2039 | |||
2040 | static int radio_g_tuner(struct file *file, void *priv, | 1558 | static int radio_g_tuner(struct file *file, void *priv, |
2041 | struct v4l2_tuner *t) | 1559 | struct v4l2_tuner *t) |
2042 | { | 1560 | { |
@@ -2053,26 +1571,6 @@ static int radio_g_tuner(struct file *file, void *priv, | |||
2053 | return 0; | 1571 | return 0; |
2054 | } | 1572 | } |
2055 | 1573 | ||
2056 | static int radio_enum_input(struct file *file, void *priv, | ||
2057 | struct v4l2_input *i) | ||
2058 | { | ||
2059 | if (i->index != 0) | ||
2060 | return -EINVAL; | ||
2061 | strcpy(i->name, "Radio"); | ||
2062 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
2063 | |||
2064 | return 0; | ||
2065 | } | ||
2066 | |||
2067 | static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
2068 | { | ||
2069 | if (unlikely(a->index)) | ||
2070 | return -EINVAL; | ||
2071 | |||
2072 | strcpy(a->name, "Radio"); | ||
2073 | return 0; | ||
2074 | } | ||
2075 | |||
2076 | static int radio_s_tuner(struct file *file, void *priv, | 1574 | static int radio_s_tuner(struct file *file, void *priv, |
2077 | struct v4l2_tuner *t) | 1575 | struct v4l2_tuner *t) |
2078 | { | 1576 | { |
@@ -2086,48 +1584,16 @@ static int radio_s_tuner(struct file *file, void *priv, | |||
2086 | return 0; | 1584 | return 0; |
2087 | } | 1585 | } |
2088 | 1586 | ||
2089 | static int radio_s_audio(struct file *file, void *fh, | ||
2090 | const struct v4l2_audio *a) | ||
2091 | { | ||
2092 | return 0; | ||
2093 | } | ||
2094 | |||
2095 | static int radio_s_input(struct file *file, void *fh, unsigned int i) | ||
2096 | { | ||
2097 | return 0; | ||
2098 | } | ||
2099 | |||
2100 | static int radio_queryctrl(struct file *file, void *priv, | ||
2101 | struct v4l2_queryctrl *qc) | ||
2102 | { | ||
2103 | int i; | ||
2104 | |||
2105 | if (qc->id < V4L2_CID_BASE || | ||
2106 | qc->id >= V4L2_CID_LASTP1) | ||
2107 | return -EINVAL; | ||
2108 | |||
2109 | for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++) { | ||
2110 | if (qc->id && qc->id == ac97_qctrl[i].id) { | ||
2111 | memcpy(qc, &(ac97_qctrl[i]), sizeof(*qc)); | ||
2112 | return 0; | ||
2113 | } | ||
2114 | } | ||
2115 | |||
2116 | return -EINVAL; | ||
2117 | } | ||
2118 | |||
2119 | /* | 1587 | /* |
2120 | * em28xx_v4l2_open() | 1588 | * em28xx_v4l2_open() |
2121 | * inits the device and starts isoc transfer | 1589 | * inits the device and starts isoc transfer |
2122 | */ | 1590 | */ |
2123 | static int em28xx_v4l2_open(struct file *filp) | 1591 | static int em28xx_v4l2_open(struct file *filp) |
2124 | { | 1592 | { |
2125 | int errCode = 0, radio = 0; | ||
2126 | struct video_device *vdev = video_devdata(filp); | 1593 | struct video_device *vdev = video_devdata(filp); |
2127 | struct em28xx *dev = video_drvdata(filp); | 1594 | struct em28xx *dev = video_drvdata(filp); |
2128 | enum v4l2_buf_type fh_type = 0; | 1595 | enum v4l2_buf_type fh_type = 0; |
2129 | struct em28xx_fh *fh; | 1596 | struct em28xx_fh *fh; |
2130 | enum v4l2_field field; | ||
2131 | 1597 | ||
2132 | switch (vdev->vfl_type) { | 1598 | switch (vdev->vfl_type) { |
2133 | case VFL_TYPE_GRABBER: | 1599 | case VFL_TYPE_GRABBER: |
@@ -2136,9 +1602,6 @@ static int em28xx_v4l2_open(struct file *filp) | |||
2136 | case VFL_TYPE_VBI: | 1602 | case VFL_TYPE_VBI: |
2137 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | 1603 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; |
2138 | break; | 1604 | break; |
2139 | case VFL_TYPE_RADIO: | ||
2140 | radio = 1; | ||
2141 | break; | ||
2142 | } | 1605 | } |
2143 | 1606 | ||
2144 | em28xx_videodbg("open dev=%s type=%s users=%d\n", | 1607 | em28xx_videodbg("open dev=%s type=%s users=%d\n", |
@@ -2154,14 +1617,13 @@ static int em28xx_v4l2_open(struct file *filp) | |||
2154 | mutex_unlock(&dev->lock); | 1617 | mutex_unlock(&dev->lock); |
2155 | return -ENOMEM; | 1618 | return -ENOMEM; |
2156 | } | 1619 | } |
1620 | v4l2_fh_init(&fh->fh, vdev); | ||
2157 | fh->dev = dev; | 1621 | fh->dev = dev; |
2158 | fh->radio = radio; | ||
2159 | fh->type = fh_type; | 1622 | fh->type = fh_type; |
2160 | filp->private_data = fh; | 1623 | filp->private_data = fh; |
2161 | 1624 | ||
2162 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | 1625 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { |
2163 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); | 1626 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); |
2164 | em28xx_set_alternate(dev); | ||
2165 | em28xx_resolution_set(dev); | 1627 | em28xx_resolution_set(dev); |
2166 | 1628 | ||
2167 | /* Needed, since GPIO might have disabled power of | 1629 | /* Needed, since GPIO might have disabled power of |
@@ -2170,31 +1632,18 @@ static int em28xx_v4l2_open(struct file *filp) | |||
2170 | em28xx_wake_i2c(dev); | 1632 | em28xx_wake_i2c(dev); |
2171 | 1633 | ||
2172 | } | 1634 | } |
2173 | if (fh->radio) { | 1635 | |
1636 | if (vdev->vfl_type == VFL_TYPE_RADIO) { | ||
2174 | em28xx_videodbg("video_open: setting radio device\n"); | 1637 | em28xx_videodbg("video_open: setting radio device\n"); |
2175 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); | 1638 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); |
2176 | } | 1639 | } |
2177 | 1640 | ||
2178 | dev->users++; | 1641 | dev->users++; |
2179 | 1642 | ||
2180 | if (dev->progressive) | ||
2181 | field = V4L2_FIELD_NONE; | ||
2182 | else | ||
2183 | field = V4L2_FIELD_INTERLACED; | ||
2184 | |||
2185 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, | ||
2186 | NULL, &dev->slock, | ||
2187 | V4L2_BUF_TYPE_VIDEO_CAPTURE, field, | ||
2188 | sizeof(struct em28xx_buffer), fh, &dev->lock); | ||
2189 | |||
2190 | videobuf_queue_vmalloc_init(&fh->vb_vbiq, &em28xx_vbi_qops, | ||
2191 | NULL, &dev->slock, | ||
2192 | V4L2_BUF_TYPE_VBI_CAPTURE, | ||
2193 | V4L2_FIELD_SEQ_TB, | ||
2194 | sizeof(struct em28xx_buffer), fh, &dev->lock); | ||
2195 | mutex_unlock(&dev->lock); | 1643 | mutex_unlock(&dev->lock); |
1644 | v4l2_fh_add(&fh->fh); | ||
2196 | 1645 | ||
2197 | return errCode; | 1646 | return 0; |
2198 | } | 1647 | } |
2199 | 1648 | ||
2200 | /* | 1649 | /* |
@@ -2248,25 +1697,16 @@ static int em28xx_v4l2_close(struct file *filp) | |||
2248 | em28xx_videodbg("users=%d\n", dev->users); | 1697 | em28xx_videodbg("users=%d\n", dev->users); |
2249 | 1698 | ||
2250 | mutex_lock(&dev->lock); | 1699 | mutex_lock(&dev->lock); |
2251 | if (res_check(fh, EM28XX_RESOURCE_VIDEO)) { | 1700 | vb2_fop_release(filp); |
2252 | videobuf_stop(&fh->vb_vidq); | ||
2253 | res_free(fh, EM28XX_RESOURCE_VIDEO); | ||
2254 | } | ||
2255 | |||
2256 | if (res_check(fh, EM28XX_RESOURCE_VBI)) { | ||
2257 | videobuf_stop(&fh->vb_vbiq); | ||
2258 | res_free(fh, EM28XX_RESOURCE_VBI); | ||
2259 | } | ||
2260 | 1701 | ||
2261 | if (dev->users == 1) { | 1702 | if (dev->users == 1) { |
2262 | /* the device is already disconnect, | 1703 | /* the device is already disconnect, |
2263 | free the remaining resources */ | 1704 | free the remaining resources */ |
2264 | if (dev->state & DEV_DISCONNECTED) { | 1705 | if (dev->disconnected) { |
2265 | em28xx_release_resources(dev); | 1706 | em28xx_release_resources(dev); |
2266 | kfree(dev->alt_max_pkt_size); | 1707 | kfree(dev->alt_max_pkt_size_isoc); |
2267 | mutex_unlock(&dev->lock); | 1708 | mutex_unlock(&dev->lock); |
2268 | kfree(dev); | 1709 | kfree(dev); |
2269 | kfree(fh); | ||
2270 | return 0; | 1710 | return 0; |
2271 | } | 1711 | } |
2272 | 1712 | ||
@@ -2274,7 +1714,6 @@ static int em28xx_v4l2_close(struct file *filp) | |||
2274 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); | 1714 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); |
2275 | 1715 | ||
2276 | /* do this before setting alternate! */ | 1716 | /* do this before setting alternate! */ |
2277 | em28xx_uninit_isoc(dev, EM28XX_ANALOG_MODE); | ||
2278 | em28xx_set_mode(dev, EM28XX_SUSPEND); | 1717 | em28xx_set_mode(dev, EM28XX_SUSPEND); |
2279 | 1718 | ||
2280 | /* set alternate 0 */ | 1719 | /* set alternate 0 */ |
@@ -2287,129 +1726,18 @@ static int em28xx_v4l2_close(struct file *filp) | |||
2287 | } | 1726 | } |
2288 | } | 1727 | } |
2289 | 1728 | ||
2290 | videobuf_mmap_free(&fh->vb_vidq); | ||
2291 | videobuf_mmap_free(&fh->vb_vbiq); | ||
2292 | kfree(fh); | ||
2293 | dev->users--; | 1729 | dev->users--; |
2294 | mutex_unlock(&dev->lock); | 1730 | mutex_unlock(&dev->lock); |
2295 | return 0; | 1731 | return 0; |
2296 | } | 1732 | } |
2297 | 1733 | ||
2298 | /* | ||
2299 | * em28xx_v4l2_read() | ||
2300 | * will allocate buffers when called for the first time | ||
2301 | */ | ||
2302 | static ssize_t | ||
2303 | em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count, | ||
2304 | loff_t *pos) | ||
2305 | { | ||
2306 | struct em28xx_fh *fh = filp->private_data; | ||
2307 | struct em28xx *dev = fh->dev; | ||
2308 | int rc; | ||
2309 | |||
2310 | rc = check_dev(dev); | ||
2311 | if (rc < 0) | ||
2312 | return rc; | ||
2313 | |||
2314 | if (mutex_lock_interruptible(&dev->lock)) | ||
2315 | return -ERESTARTSYS; | ||
2316 | /* FIXME: read() is not prepared to allow changing the video | ||
2317 | resolution while streaming. Seems a bug at em28xx_set_fmt | ||
2318 | */ | ||
2319 | |||
2320 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
2321 | if (res_locked(dev, EM28XX_RESOURCE_VIDEO)) | ||
2322 | rc = -EBUSY; | ||
2323 | else | ||
2324 | rc = videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0, | ||
2325 | filp->f_flags & O_NONBLOCK); | ||
2326 | } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2327 | if (!res_get(fh, EM28XX_RESOURCE_VBI)) | ||
2328 | rc = -EBUSY; | ||
2329 | else | ||
2330 | rc = videobuf_read_stream(&fh->vb_vbiq, buf, count, pos, 0, | ||
2331 | filp->f_flags & O_NONBLOCK); | ||
2332 | } | ||
2333 | mutex_unlock(&dev->lock); | ||
2334 | |||
2335 | return rc; | ||
2336 | } | ||
2337 | |||
2338 | /* | ||
2339 | * em28xx_poll() | ||
2340 | * will allocate buffers when called for the first time | ||
2341 | */ | ||
2342 | static unsigned int em28xx_poll(struct file *filp, poll_table *wait) | ||
2343 | { | ||
2344 | struct em28xx_fh *fh = filp->private_data; | ||
2345 | struct em28xx *dev = fh->dev; | ||
2346 | int rc; | ||
2347 | |||
2348 | rc = check_dev(dev); | ||
2349 | if (rc < 0) | ||
2350 | return rc; | ||
2351 | |||
2352 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
2353 | if (!res_get(fh, EM28XX_RESOURCE_VIDEO)) | ||
2354 | return POLLERR; | ||
2355 | return videobuf_poll_stream(filp, &fh->vb_vidq, wait); | ||
2356 | } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2357 | if (!res_get(fh, EM28XX_RESOURCE_VBI)) | ||
2358 | return POLLERR; | ||
2359 | return videobuf_poll_stream(filp, &fh->vb_vbiq, wait); | ||
2360 | } else { | ||
2361 | return POLLERR; | ||
2362 | } | ||
2363 | } | ||
2364 | |||
2365 | static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait) | ||
2366 | { | ||
2367 | struct em28xx_fh *fh = filp->private_data; | ||
2368 | struct em28xx *dev = fh->dev; | ||
2369 | unsigned int res; | ||
2370 | |||
2371 | mutex_lock(&dev->lock); | ||
2372 | res = em28xx_poll(filp, wait); | ||
2373 | mutex_unlock(&dev->lock); | ||
2374 | return res; | ||
2375 | } | ||
2376 | |||
2377 | /* | ||
2378 | * em28xx_v4l2_mmap() | ||
2379 | */ | ||
2380 | static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | ||
2381 | { | ||
2382 | struct em28xx_fh *fh = filp->private_data; | ||
2383 | struct em28xx *dev = fh->dev; | ||
2384 | int rc; | ||
2385 | |||
2386 | rc = check_dev(dev); | ||
2387 | if (rc < 0) | ||
2388 | return rc; | ||
2389 | |||
2390 | if (mutex_lock_interruptible(&dev->lock)) | ||
2391 | return -ERESTARTSYS; | ||
2392 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2393 | rc = videobuf_mmap_mapper(&fh->vb_vidq, vma); | ||
2394 | else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) | ||
2395 | rc = videobuf_mmap_mapper(&fh->vb_vbiq, vma); | ||
2396 | mutex_unlock(&dev->lock); | ||
2397 | |||
2398 | em28xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", | ||
2399 | (unsigned long)vma->vm_start, | ||
2400 | (unsigned long)vma->vm_end-(unsigned long)vma->vm_start, | ||
2401 | rc); | ||
2402 | |||
2403 | return rc; | ||
2404 | } | ||
2405 | |||
2406 | static const struct v4l2_file_operations em28xx_v4l_fops = { | 1734 | static const struct v4l2_file_operations em28xx_v4l_fops = { |
2407 | .owner = THIS_MODULE, | 1735 | .owner = THIS_MODULE, |
2408 | .open = em28xx_v4l2_open, | 1736 | .open = em28xx_v4l2_open, |
2409 | .release = em28xx_v4l2_close, | 1737 | .release = em28xx_v4l2_close, |
2410 | .read = em28xx_v4l2_read, | 1738 | .read = vb2_fop_read, |
2411 | .poll = em28xx_v4l2_poll, | 1739 | .poll = vb2_fop_poll, |
2412 | .mmap = em28xx_v4l2_mmap, | 1740 | .mmap = vb2_fop_mmap, |
2413 | .unlocked_ioctl = video_ioctl2, | 1741 | .unlocked_ioctl = video_ioctl2, |
2414 | }; | 1742 | }; |
2415 | 1743 | ||
@@ -2420,19 +1748,20 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2420 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1748 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
2421 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1749 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
2422 | .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, | 1750 | .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, |
1751 | .vidioc_try_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, | ||
2423 | .vidioc_s_fmt_vbi_cap = vidioc_s_fmt_vbi_cap, | 1752 | .vidioc_s_fmt_vbi_cap = vidioc_s_fmt_vbi_cap, |
2424 | .vidioc_enum_framesizes = vidioc_enum_framesizes, | 1753 | .vidioc_enum_framesizes = vidioc_enum_framesizes, |
2425 | .vidioc_g_audio = vidioc_g_audio, | 1754 | .vidioc_g_audio = vidioc_g_audio, |
2426 | .vidioc_s_audio = vidioc_s_audio, | 1755 | .vidioc_s_audio = vidioc_s_audio, |
2427 | .vidioc_cropcap = vidioc_cropcap, | 1756 | .vidioc_cropcap = vidioc_cropcap, |
2428 | .vidioc_g_fmt_sliced_vbi_cap = vidioc_g_fmt_sliced_vbi_cap, | 1757 | |
2429 | .vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap, | 1758 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
2430 | .vidioc_s_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap, | 1759 | .vidioc_create_bufs = vb2_ioctl_create_bufs, |
2431 | 1760 | .vidioc_prepare_buf = vb2_ioctl_prepare_buf, | |
2432 | .vidioc_reqbufs = vidioc_reqbufs, | 1761 | .vidioc_querybuf = vb2_ioctl_querybuf, |
2433 | .vidioc_querybuf = vidioc_querybuf, | 1762 | .vidioc_qbuf = vb2_ioctl_qbuf, |
2434 | .vidioc_qbuf = vidioc_qbuf, | 1763 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
2435 | .vidioc_dqbuf = vidioc_dqbuf, | 1764 | |
2436 | .vidioc_g_std = vidioc_g_std, | 1765 | .vidioc_g_std = vidioc_g_std, |
2437 | .vidioc_querystd = vidioc_querystd, | 1766 | .vidioc_querystd = vidioc_querystd, |
2438 | .vidioc_s_std = vidioc_s_std, | 1767 | .vidioc_s_std = vidioc_s_std, |
@@ -2441,15 +1770,14 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2441 | .vidioc_enum_input = vidioc_enum_input, | 1770 | .vidioc_enum_input = vidioc_enum_input, |
2442 | .vidioc_g_input = vidioc_g_input, | 1771 | .vidioc_g_input = vidioc_g_input, |
2443 | .vidioc_s_input = vidioc_s_input, | 1772 | .vidioc_s_input = vidioc_s_input, |
2444 | .vidioc_queryctrl = vidioc_queryctrl, | 1773 | .vidioc_streamon = vb2_ioctl_streamon, |
2445 | .vidioc_g_ctrl = vidioc_g_ctrl, | 1774 | .vidioc_streamoff = vb2_ioctl_streamoff, |
2446 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2447 | .vidioc_streamon = vidioc_streamon, | ||
2448 | .vidioc_streamoff = vidioc_streamoff, | ||
2449 | .vidioc_g_tuner = vidioc_g_tuner, | 1775 | .vidioc_g_tuner = vidioc_g_tuner, |
2450 | .vidioc_s_tuner = vidioc_s_tuner, | 1776 | .vidioc_s_tuner = vidioc_s_tuner, |
2451 | .vidioc_g_frequency = vidioc_g_frequency, | 1777 | .vidioc_g_frequency = vidioc_g_frequency, |
2452 | .vidioc_s_frequency = vidioc_s_frequency, | 1778 | .vidioc_s_frequency = vidioc_s_frequency, |
1779 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1780 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
2453 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1781 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2454 | .vidioc_g_register = vidioc_g_register, | 1782 | .vidioc_g_register = vidioc_g_register, |
2455 | .vidioc_s_register = vidioc_s_register, | 1783 | .vidioc_s_register = vidioc_s_register, |
@@ -2459,11 +1787,10 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
2459 | 1787 | ||
2460 | static const struct video_device em28xx_video_template = { | 1788 | static const struct video_device em28xx_video_template = { |
2461 | .fops = &em28xx_v4l_fops, | 1789 | .fops = &em28xx_v4l_fops, |
2462 | .release = video_device_release, | 1790 | .release = video_device_release_empty, |
2463 | .ioctl_ops = &video_ioctl_ops, | 1791 | .ioctl_ops = &video_ioctl_ops, |
2464 | 1792 | ||
2465 | .tvnorms = V4L2_STD_ALL, | 1793 | .tvnorms = V4L2_STD_ALL, |
2466 | .current_norm = V4L2_STD_PAL, | ||
2467 | }; | 1794 | }; |
2468 | 1795 | ||
2469 | static const struct v4l2_file_operations radio_fops = { | 1796 | static const struct v4l2_file_operations radio_fops = { |
@@ -2474,18 +1801,13 @@ static const struct v4l2_file_operations radio_fops = { | |||
2474 | }; | 1801 | }; |
2475 | 1802 | ||
2476 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 1803 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
2477 | .vidioc_querycap = radio_querycap, | 1804 | .vidioc_querycap = vidioc_querycap, |
2478 | .vidioc_g_tuner = radio_g_tuner, | 1805 | .vidioc_g_tuner = radio_g_tuner, |
2479 | .vidioc_enum_input = radio_enum_input, | ||
2480 | .vidioc_g_audio = radio_g_audio, | ||
2481 | .vidioc_s_tuner = radio_s_tuner, | 1806 | .vidioc_s_tuner = radio_s_tuner, |
2482 | .vidioc_s_audio = radio_s_audio, | ||
2483 | .vidioc_s_input = radio_s_input, | ||
2484 | .vidioc_queryctrl = radio_queryctrl, | ||
2485 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
2486 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2487 | .vidioc_g_frequency = vidioc_g_frequency, | 1807 | .vidioc_g_frequency = vidioc_g_frequency, |
2488 | .vidioc_s_frequency = vidioc_s_frequency, | 1808 | .vidioc_s_frequency = vidioc_s_frequency, |
1809 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1810 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
2489 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1811 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
2490 | .vidioc_g_register = vidioc_g_register, | 1812 | .vidioc_g_register = vidioc_g_register, |
2491 | .vidioc_s_register = vidioc_s_register, | 1813 | .vidioc_s_register = vidioc_s_register, |
@@ -2514,9 +1836,11 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
2514 | 1836 | ||
2515 | *vfd = *template; | 1837 | *vfd = *template; |
2516 | vfd->v4l2_dev = &dev->v4l2_dev; | 1838 | vfd->v4l2_dev = &dev->v4l2_dev; |
2517 | vfd->release = video_device_release; | ||
2518 | vfd->debug = video_debug; | 1839 | vfd->debug = video_debug; |
2519 | vfd->lock = &dev->lock; | 1840 | vfd->lock = &dev->lock; |
1841 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
1842 | if (dev->board.is_webcam) | ||
1843 | vfd->tvnorms = 0; | ||
2520 | 1844 | ||
2521 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", | 1845 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", |
2522 | dev->name, type_name); | 1846 | dev->name, type_name); |
@@ -2527,7 +1851,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
2527 | 1851 | ||
2528 | int em28xx_register_analog_devices(struct em28xx *dev) | 1852 | int em28xx_register_analog_devices(struct em28xx *dev) |
2529 | { | 1853 | { |
2530 | u8 val; | 1854 | u8 val; |
2531 | int ret; | 1855 | int ret; |
2532 | unsigned int maxw; | 1856 | unsigned int maxw; |
2533 | 1857 | ||
@@ -2535,7 +1859,7 @@ int em28xx_register_analog_devices(struct em28xx *dev) | |||
2535 | dev->name, EM28XX_VERSION); | 1859 | dev->name, EM28XX_VERSION); |
2536 | 1860 | ||
2537 | /* set default norm */ | 1861 | /* set default norm */ |
2538 | dev->norm = em28xx_video_template.current_norm; | 1862 | dev->norm = V4L2_STD_PAL; |
2539 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm); | 1863 | v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm); |
2540 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; | 1864 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; |
2541 | 1865 | ||
@@ -2543,10 +1867,10 @@ int em28xx_register_analog_devices(struct em28xx *dev) | |||
2543 | dev->format = &format[0]; | 1867 | dev->format = &format[0]; |
2544 | 1868 | ||
2545 | maxw = norm_maxw(dev); | 1869 | maxw = norm_maxw(dev); |
2546 | /* MaxPacketSize for em2800 is too small to capture at full resolution | 1870 | /* MaxPacketSize for em2800 is too small to capture at full resolution |
2547 | * use half of maxw as the scaler can only scale to 50% */ | 1871 | * use half of maxw as the scaler can only scale to 50% */ |
2548 | if (dev->board.is_em2800) | 1872 | if (dev->board.is_em2800) |
2549 | maxw /= 2; | 1873 | maxw /= 2; |
2550 | 1874 | ||
2551 | em28xx_set_video_format(dev, format[0].fourcc, | 1875 | em28xx_set_video_format(dev, format[0].fourcc, |
2552 | maxw, norm_maxh(dev)); | 1876 | maxw, norm_maxh(dev)); |
@@ -2572,6 +1896,8 @@ int em28xx_register_analog_devices(struct em28xx *dev) | |||
2572 | em28xx_errdev("cannot allocate video_device.\n"); | 1896 | em28xx_errdev("cannot allocate video_device.\n"); |
2573 | return -ENODEV; | 1897 | return -ENODEV; |
2574 | } | 1898 | } |
1899 | dev->vdev->queue = &dev->vb_vidq; | ||
1900 | dev->vdev->queue->lock = &dev->vb_queue_lock; | ||
2575 | 1901 | ||
2576 | /* register v4l2 video video_device */ | 1902 | /* register v4l2 video video_device */ |
2577 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | 1903 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, |
@@ -2587,6 +1913,9 @@ int em28xx_register_analog_devices(struct em28xx *dev) | |||
2587 | dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, | 1913 | dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, |
2588 | "vbi"); | 1914 | "vbi"); |
2589 | 1915 | ||
1916 | dev->vbi_dev->queue = &dev->vb_vbiq; | ||
1917 | dev->vbi_dev->queue->lock = &dev->vb_vbi_queue_lock; | ||
1918 | |||
2590 | /* register v4l2 vbi video_device */ | 1919 | /* register v4l2 vbi video_device */ |
2591 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | 1920 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, |
2592 | vbi_nr[dev->devno]); | 1921 | vbi_nr[dev->devno]); |
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 86e90d86da6d..5f0b2c59e846 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -4,6 +4,7 @@ | |||
4 | Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> | 4 | Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> |
5 | Ludovico Cavedon <cavedon@sssup.it> | 5 | Ludovico Cavedon <cavedon@sssup.it> |
6 | Mauro Carvalho Chehab <mchehab@infradead.org> | 6 | Mauro Carvalho Chehab <mchehab@infradead.org> |
7 | Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> | ||
7 | 8 | ||
8 | Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de> | 9 | Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de> |
9 | 10 | ||
@@ -30,13 +31,12 @@ | |||
30 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
31 | #include <linux/videodev2.h> | 32 | #include <linux/videodev2.h> |
32 | 33 | ||
33 | #include <media/videobuf-vmalloc.h> | 34 | #include <media/videobuf2-vmalloc.h> |
34 | #include <media/v4l2-device.h> | 35 | #include <media/v4l2-device.h> |
36 | #include <media/v4l2-ctrls.h> | ||
37 | #include <media/v4l2-fh.h> | ||
35 | #include <media/ir-kbd-i2c.h> | 38 | #include <media/ir-kbd-i2c.h> |
36 | #include <media/rc-core.h> | 39 | #include <media/rc-core.h> |
37 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) | ||
38 | #include <media/videobuf-dvb.h> | ||
39 | #endif | ||
40 | #include "tuner-xc2028.h" | 40 | #include "tuner-xc2028.h" |
41 | #include "xc5000.h" | 41 | #include "xc5000.h" |
42 | #include "em28xx-reg.h" | 42 | #include "em28xx-reg.h" |
@@ -157,12 +157,18 @@ | |||
157 | #define EM28XX_NUM_BUFS 5 | 157 | #define EM28XX_NUM_BUFS 5 |
158 | #define EM28XX_DVB_NUM_BUFS 5 | 158 | #define EM28XX_DVB_NUM_BUFS 5 |
159 | 159 | ||
160 | /* number of packets for each buffer | 160 | /* isoc transfers: number of packets for each buffer |
161 | windows requests only 64 packets .. so we better do the same | 161 | windows requests only 64 packets .. so we better do the same |
162 | this is what I found out for all alternate numbers there! | 162 | this is what I found out for all alternate numbers there! |
163 | */ | 163 | */ |
164 | #define EM28XX_NUM_PACKETS 64 | 164 | #define EM28XX_NUM_ISOC_PACKETS 64 |
165 | #define EM28XX_DVB_MAX_PACKETS 64 | 165 | #define EM28XX_DVB_NUM_ISOC_PACKETS 64 |
166 | |||
167 | /* bulk transfers: transfer buffer size = packet size * packet multiplier | ||
168 | USB 2.0 spec says bulk packet size is always 512 bytes | ||
169 | */ | ||
170 | #define EM28XX_BULK_PACKET_MULTIPLIER 384 | ||
171 | #define EM28XX_DVB_BULK_PACKET_MULTIPLIER 384 | ||
166 | 172 | ||
167 | #define EM28XX_INTERLACED_DEFAULT 1 | 173 | #define EM28XX_INTERLACED_DEFAULT 1 |
168 | 174 | ||
@@ -187,12 +193,8 @@ | |||
187 | Interval: 125us | 193 | Interval: 125us |
188 | */ | 194 | */ |
189 | 195 | ||
190 | /* time to wait when stopping the isoc transfer */ | ||
191 | #define EM28XX_URB_TIMEOUT \ | ||
192 | msecs_to_jiffies(EM28XX_NUM_BUFS * EM28XX_NUM_PACKETS) | ||
193 | |||
194 | /* time in msecs to wait for i2c writes to finish */ | 196 | /* time in msecs to wait for i2c writes to finish */ |
195 | #define EM2800_I2C_WRITE_TIMEOUT 20 | 197 | #define EM2800_I2C_XFER_TIMEOUT 20 |
196 | 198 | ||
197 | enum em28xx_mode { | 199 | enum em28xx_mode { |
198 | EM28XX_SUSPEND, | 200 | EM28XX_SUSPEND, |
@@ -203,7 +205,7 @@ enum em28xx_mode { | |||
203 | 205 | ||
204 | struct em28xx; | 206 | struct em28xx; |
205 | 207 | ||
206 | struct em28xx_usb_isoc_bufs { | 208 | struct em28xx_usb_bufs { |
207 | /* max packet size of isoc transaction */ | 209 | /* max packet size of isoc transaction */ |
208 | int max_pkt_size; | 210 | int max_pkt_size; |
209 | 211 | ||
@@ -213,26 +215,26 @@ struct em28xx_usb_isoc_bufs { | |||
213 | /* number of allocated urbs */ | 215 | /* number of allocated urbs */ |
214 | int num_bufs; | 216 | int num_bufs; |
215 | 217 | ||
216 | /* urb for isoc transfers */ | 218 | /* urb for isoc/bulk transfers */ |
217 | struct urb **urb; | 219 | struct urb **urb; |
218 | 220 | ||
219 | /* transfer buffers for isoc transfer */ | 221 | /* transfer buffers for isoc/bulk transfer */ |
220 | char **transfer_buffer; | 222 | char **transfer_buffer; |
221 | }; | 223 | }; |
222 | 224 | ||
223 | struct em28xx_usb_isoc_ctl { | 225 | struct em28xx_usb_ctl { |
224 | /* isoc transfer buffers for analog mode */ | 226 | /* isoc/bulk transfer buffers for analog mode */ |
225 | struct em28xx_usb_isoc_bufs analog_bufs; | 227 | struct em28xx_usb_bufs analog_bufs; |
226 | 228 | ||
227 | /* isoc transfer buffers for digital mode */ | 229 | /* isoc/bulk transfer buffers for digital mode */ |
228 | struct em28xx_usb_isoc_bufs digital_bufs; | 230 | struct em28xx_usb_bufs digital_bufs; |
229 | 231 | ||
230 | /* Stores already requested buffers */ | 232 | /* Stores already requested buffers */ |
231 | struct em28xx_buffer *vid_buf; | 233 | struct em28xx_buffer *vid_buf; |
232 | struct em28xx_buffer *vbi_buf; | 234 | struct em28xx_buffer *vbi_buf; |
233 | 235 | ||
234 | /* isoc urb callback */ | 236 | /* copy data from URB */ |
235 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb); | 237 | int (*urb_data_copy) (struct em28xx *dev, struct urb *urb); |
236 | 238 | ||
237 | }; | 239 | }; |
238 | 240 | ||
@@ -247,19 +249,26 @@ struct em28xx_fmt { | |||
247 | /* buffer for one video frame */ | 249 | /* buffer for one video frame */ |
248 | struct em28xx_buffer { | 250 | struct em28xx_buffer { |
249 | /* common v4l buffer stuff -- must be first */ | 251 | /* common v4l buffer stuff -- must be first */ |
250 | struct videobuf_buffer vb; | 252 | struct vb2_buffer vb; |
253 | struct list_head list; | ||
251 | 254 | ||
252 | struct list_head frame; | 255 | void *mem; |
256 | unsigned int length; | ||
253 | int top_field; | 257 | int top_field; |
258 | |||
259 | /* counter to control buffer fill */ | ||
260 | unsigned int pos; | ||
261 | /* NOTE; in interlaced mode, this value is reset to zero at | ||
262 | * the start of each new field (not frame !) */ | ||
263 | |||
264 | /* pointer to vmalloc memory address in vb */ | ||
265 | char *vb_buf; | ||
254 | }; | 266 | }; |
255 | 267 | ||
256 | struct em28xx_dmaqueue { | 268 | struct em28xx_dmaqueue { |
257 | struct list_head active; | 269 | struct list_head active; |
258 | 270 | ||
259 | wait_queue_head_t wq; | 271 | wait_queue_head_t wq; |
260 | |||
261 | /* Counters to control buffer fill */ | ||
262 | int pos; | ||
263 | }; | 272 | }; |
264 | 273 | ||
265 | /* inputs */ | 274 | /* inputs */ |
@@ -430,13 +439,6 @@ struct em28xx_eeprom { | |||
430 | u8 string_idx_table; | 439 | u8 string_idx_table; |
431 | }; | 440 | }; |
432 | 441 | ||
433 | /* device states */ | ||
434 | enum em28xx_dev_state { | ||
435 | DEV_INITIALIZED = 0x01, | ||
436 | DEV_DISCONNECTED = 0x02, | ||
437 | DEV_MISCONFIGURED = 0x04, | ||
438 | }; | ||
439 | |||
440 | #define EM28XX_AUDIO_BUFS 5 | 442 | #define EM28XX_AUDIO_BUFS 5 |
441 | #define EM28XX_NUM_AUDIO_PACKETS 64 | 443 | #define EM28XX_NUM_AUDIO_PACKETS 64 |
442 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | 444 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ |
@@ -469,12 +471,8 @@ struct em28xx_audio { | |||
469 | struct em28xx; | 471 | struct em28xx; |
470 | 472 | ||
471 | struct em28xx_fh { | 473 | struct em28xx_fh { |
474 | struct v4l2_fh fh; | ||
472 | struct em28xx *dev; | 475 | struct em28xx *dev; |
473 | int radio; | ||
474 | unsigned int resources; | ||
475 | |||
476 | struct videobuf_queue vb_vidq; | ||
477 | struct videobuf_queue vb_vbiq; | ||
478 | 476 | ||
479 | enum v4l2_buf_type type; | 477 | enum v4l2_buf_type type; |
480 | }; | 478 | }; |
@@ -487,9 +485,14 @@ struct em28xx { | |||
487 | int devno; /* marks the number of this device */ | 485 | int devno; /* marks the number of this device */ |
488 | enum em28xx_chip_id chip_id; | 486 | enum em28xx_chip_id chip_id; |
489 | 487 | ||
488 | unsigned char disconnected:1; /* device has been diconnected */ | ||
489 | |||
490 | int audio_ifnum; | 490 | int audio_ifnum; |
491 | 491 | ||
492 | struct v4l2_device v4l2_dev; | 492 | struct v4l2_device v4l2_dev; |
493 | struct v4l2_ctrl_handler ctrl_handler; | ||
494 | /* provides ac97 mute and volume overrides */ | ||
495 | struct v4l2_ctrl_handler ac97_ctrl_handler; | ||
493 | struct em28xx_board board; | 496 | struct em28xx_board board; |
494 | 497 | ||
495 | /* Webcam specific fields */ | 498 | /* Webcam specific fields */ |
@@ -497,7 +500,7 @@ struct em28xx { | |||
497 | int sensor_xres, sensor_yres; | 500 | int sensor_xres, sensor_yres; |
498 | int sensor_xtal; | 501 | int sensor_xtal; |
499 | 502 | ||
500 | /* Allows progressive (e. g. non-interlaced) mode */ | 503 | /* Progressive (non-interlaced) mode */ |
501 | int progressive; | 504 | int progressive; |
502 | 505 | ||
503 | /* Vinmode/Vinctl used at the driver */ | 506 | /* Vinmode/Vinctl used at the driver */ |
@@ -532,6 +535,7 @@ struct em28xx { | |||
532 | struct i2c_client i2c_client; | 535 | struct i2c_client i2c_client; |
533 | /* video for linux */ | 536 | /* video for linux */ |
534 | int users; /* user count for exclusive use */ | 537 | int users; /* user count for exclusive use */ |
538 | int streaming_users; /* Number of actively streaming users */ | ||
535 | struct video_device *vdev; /* video for linux device struct */ | 539 | struct video_device *vdev; /* video for linux device struct */ |
536 | v4l2_std_id norm; /* selected tv norm */ | 540 | v4l2_std_id norm; /* selected tv norm */ |
537 | int ctl_freq; /* selected frequency */ | 541 | int ctl_freq; /* selected frequency */ |
@@ -554,13 +558,10 @@ struct em28xx { | |||
554 | 558 | ||
555 | struct em28xx_audio adev; | 559 | struct em28xx_audio adev; |
556 | 560 | ||
557 | /* states */ | 561 | /* capture state tracking */ |
558 | enum em28xx_dev_state state; | ||
559 | |||
560 | /* vbi related state tracking */ | ||
561 | int capture_type; | 562 | int capture_type; |
563 | unsigned char top_field:1; | ||
562 | int vbi_read; | 564 | int vbi_read; |
563 | unsigned char cur_field; | ||
564 | unsigned int vbi_width; | 565 | unsigned int vbi_width; |
565 | unsigned int vbi_height; /* lines per field */ | 566 | unsigned int vbi_height; /* lines per field */ |
566 | 567 | ||
@@ -574,6 +575,12 @@ struct em28xx { | |||
574 | struct video_device *vbi_dev; | 575 | struct video_device *vbi_dev; |
575 | struct video_device *radio_dev; | 576 | struct video_device *radio_dev; |
576 | 577 | ||
578 | /* Videobuf2 */ | ||
579 | struct vb2_queue vb_vidq; | ||
580 | struct vb2_queue vb_vbiq; | ||
581 | struct mutex vb_queue_lock; | ||
582 | struct mutex vb_vbi_queue_lock; | ||
583 | |||
577 | /* resources in use */ | 584 | /* resources in use */ |
578 | unsigned int resources; | 585 | unsigned int resources; |
579 | 586 | ||
@@ -582,17 +589,31 @@ struct em28xx { | |||
582 | /* Isoc control struct */ | 589 | /* Isoc control struct */ |
583 | struct em28xx_dmaqueue vidq; | 590 | struct em28xx_dmaqueue vidq; |
584 | struct em28xx_dmaqueue vbiq; | 591 | struct em28xx_dmaqueue vbiq; |
585 | struct em28xx_usb_isoc_ctl isoc_ctl; | 592 | struct em28xx_usb_ctl usb_ctl; |
586 | spinlock_t slock; | 593 | spinlock_t slock; |
587 | 594 | ||
595 | unsigned int field_count; | ||
596 | unsigned int vbi_field_count; | ||
597 | |||
588 | /* usb transfer */ | 598 | /* usb transfer */ |
589 | struct usb_device *udev; /* the usb device */ | 599 | struct usb_device *udev; /* the usb device */ |
590 | int alt; /* alternate */ | 600 | u8 analog_ep_isoc; /* address of isoc endpoint for analog */ |
591 | int max_pkt_size; /* max packet size of isoc transaction */ | 601 | u8 analog_ep_bulk; /* address of bulk endpoint for analog */ |
592 | int num_alt; /* Number of alternative settings */ | 602 | u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ |
593 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | 603 | u8 dvb_ep_bulk; /* address of bulk endpoint for DVC */ |
594 | int dvb_alt; /* alternate for DVB */ | 604 | int alt; /* alternate setting */ |
595 | unsigned int dvb_max_pkt_size; /* wMaxPacketSize for DVB */ | 605 | int max_pkt_size; /* max packet size of the selected ep at alt */ |
606 | int packet_multiplier; /* multiplier for wMaxPacketSize, used for | ||
607 | URB buffer size definition */ | ||
608 | int num_alt; /* number of alternative settings */ | ||
609 | unsigned int *alt_max_pkt_size_isoc; /* array of isoc wMaxPacketSize */ | ||
610 | unsigned int analog_xfer_bulk:1; /* use bulk instead of isoc | ||
611 | transfers for analog */ | ||
612 | int dvb_alt_isoc; /* alternate setting for DVB isoc transfers */ | ||
613 | unsigned int dvb_max_pkt_size_isoc; /* isoc max packet size of the | ||
614 | selected DVB ep at dvb_alt */ | ||
615 | unsigned int dvb_xfer_bulk:1; /* use bulk instead of isoc | ||
616 | transfers for DVB */ | ||
596 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ | 617 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ |
597 | 618 | ||
598 | /* helper funcs that call usb_control_msg */ | 619 | /* helper funcs that call usb_control_msg */ |
@@ -619,9 +640,6 @@ struct em28xx { | |||
619 | struct delayed_work sbutton_query_work; | 640 | struct delayed_work sbutton_query_work; |
620 | 641 | ||
621 | struct em28xx_dvb *dvb; | 642 | struct em28xx_dvb *dvb; |
622 | |||
623 | /* I2C keyboard data */ | ||
624 | struct IR_i2c_init_data init_data; | ||
625 | }; | 643 | }; |
626 | 644 | ||
627 | struct em28xx_ops { | 645 | struct em28xx_ops { |
@@ -666,12 +684,14 @@ int em28xx_vbi_supported(struct em28xx *dev); | |||
666 | int em28xx_set_outfmt(struct em28xx *dev); | 684 | int em28xx_set_outfmt(struct em28xx *dev); |
667 | int em28xx_resolution_set(struct em28xx *dev); | 685 | int em28xx_resolution_set(struct em28xx *dev); |
668 | int em28xx_set_alternate(struct em28xx *dev); | 686 | int em28xx_set_alternate(struct em28xx *dev); |
669 | int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode, | 687 | int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, |
670 | int max_packets, int num_bufs, int max_pkt_size); | 688 | int num_bufs, int max_pkt_size, int packet_multiplier); |
671 | int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode, | 689 | int em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, |
672 | int max_packets, int num_bufs, int max_pkt_size, | 690 | int xfer_bulk, |
673 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb)); | 691 | int num_bufs, int max_pkt_size, int packet_multiplier, |
674 | void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode); | 692 | int (*urb_data_copy) |
693 | (struct em28xx *dev, struct urb *urb)); | ||
694 | void em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode); | ||
675 | void em28xx_stop_urbs(struct em28xx *dev); | 695 | void em28xx_stop_urbs(struct em28xx *dev); |
676 | int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev); | 696 | int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev); |
677 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); | 697 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); |
@@ -683,8 +703,13 @@ void em28xx_init_extension(struct em28xx *dev); | |||
683 | void em28xx_close_extension(struct em28xx *dev); | 703 | void em28xx_close_extension(struct em28xx *dev); |
684 | 704 | ||
685 | /* Provided by em28xx-video.c */ | 705 | /* Provided by em28xx-video.c */ |
706 | int em28xx_vb2_setup(struct em28xx *dev); | ||
686 | int em28xx_register_analog_devices(struct em28xx *dev); | 707 | int em28xx_register_analog_devices(struct em28xx *dev); |
687 | void em28xx_release_analog_resources(struct em28xx *dev); | 708 | void em28xx_release_analog_resources(struct em28xx *dev); |
709 | void em28xx_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv); | ||
710 | int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count); | ||
711 | int em28xx_stop_vbi_streaming(struct vb2_queue *vq); | ||
712 | extern const struct v4l2_ctrl_ops em28xx_ctrl_ops; | ||
688 | 713 | ||
689 | /* Provided by em28xx-cards.c */ | 714 | /* Provided by em28xx-cards.c */ |
690 | extern int em2800_variant_detect(struct usb_device *udev, int model); | 715 | extern int em2800_variant_detect(struct usb_device *udev, int model); |
@@ -695,7 +720,7 @@ int em28xx_tuner_callback(void *ptr, int component, int command, int arg); | |||
695 | void em28xx_release_resources(struct em28xx *dev); | 720 | void em28xx_release_resources(struct em28xx *dev); |
696 | 721 | ||
697 | /* Provided by em28xx-vbi.c */ | 722 | /* Provided by em28xx-vbi.c */ |
698 | extern struct videobuf_queue_ops em28xx_vbi_qops; | 723 | extern struct vb2_ops em28xx_vbi_qops; |
699 | 724 | ||
700 | /* printk macros */ | 725 | /* printk macros */ |
701 | 726 | ||
diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c index b3ba47d4d6a2..1dcdd9f95f1c 100644 --- a/drivers/media/usb/gspca/cpia1.c +++ b/drivers/media/usb/gspca/cpia1.c | |||
@@ -541,7 +541,7 @@ static int do_command(struct gspca_dev *gspca_dev, u16 command, | |||
541 | /* test button press */ | 541 | /* test button press */ |
542 | a = ((gspca_dev->usb_buf[1] & 0x02) == 0); | 542 | a = ((gspca_dev->usb_buf[1] & 0x02) == 0); |
543 | if (a != sd->params.qx3.button) { | 543 | if (a != sd->params.qx3.button) { |
544 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 544 | #if IS_ENABLED(CONFIG_INPUT) |
545 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, a); | 545 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, a); |
546 | input_sync(gspca_dev->input_dev); | 546 | input_sync(gspca_dev->input_dev); |
547 | #endif | 547 | #endif |
@@ -1640,7 +1640,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1640 | /* Update the camera status */ | 1640 | /* Update the camera status */ |
1641 | do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); | 1641 | do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); |
1642 | 1642 | ||
1643 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 1643 | #if IS_ENABLED(CONFIG_INPUT) |
1644 | /* If the last button state is pressed, release it now! */ | 1644 | /* If the last button state is pressed, release it now! */ |
1645 | if (sd->params.qx3.button) { | 1645 | if (sd->params.qx3.button) { |
1646 | /* The camera latch will hold the pressed state until we reset | 1646 | /* The camera latch will hold the pressed state until we reset |
@@ -1869,7 +1869,7 @@ static const struct sd_desc sd_desc = { | |||
1869 | .stopN = sd_stopN, | 1869 | .stopN = sd_stopN, |
1870 | .dq_callback = sd_dq_callback, | 1870 | .dq_callback = sd_dq_callback, |
1871 | .pkt_scan = sd_pkt_scan, | 1871 | .pkt_scan = sd_pkt_scan, |
1872 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 1872 | #if IS_ENABLED(CONFIG_INPUT) |
1873 | .other_input = 1, | 1873 | .other_input = 1, |
1874 | #endif | 1874 | #endif |
1875 | }; | 1875 | }; |
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index e0a431bb0d42..3564bdbb2ea3 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | #include "gspca.h" | 45 | #include "gspca.h" |
46 | 46 | ||
47 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 47 | #if IS_ENABLED(CONFIG_INPUT) |
48 | #include <linux/input.h> | 48 | #include <linux/input.h> |
49 | #include <linux/usb/input.h> | 49 | #include <linux/usb/input.h> |
50 | #endif | 50 | #endif |
@@ -118,7 +118,7 @@ static const struct vm_operations_struct gspca_vm_ops = { | |||
118 | /* | 118 | /* |
119 | * Input and interrupt endpoint handling functions | 119 | * Input and interrupt endpoint handling functions |
120 | */ | 120 | */ |
121 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 121 | #if IS_ENABLED(CONFIG_INPUT) |
122 | static void int_irq(struct urb *urb) | 122 | static void int_irq(struct urb *urb) |
123 | { | 123 | { |
124 | struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; | 124 | struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; |
@@ -2303,7 +2303,7 @@ int gspca_dev_probe2(struct usb_interface *intf, | |||
2303 | 2303 | ||
2304 | return 0; | 2304 | return 0; |
2305 | out: | 2305 | out: |
2306 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2306 | #if IS_ENABLED(CONFIG_INPUT) |
2307 | if (gspca_dev->input_dev) | 2307 | if (gspca_dev->input_dev) |
2308 | input_unregister_device(gspca_dev->input_dev); | 2308 | input_unregister_device(gspca_dev->input_dev); |
2309 | #endif | 2309 | #endif |
@@ -2348,7 +2348,7 @@ EXPORT_SYMBOL(gspca_dev_probe); | |||
2348 | void gspca_disconnect(struct usb_interface *intf) | 2348 | void gspca_disconnect(struct usb_interface *intf) |
2349 | { | 2349 | { |
2350 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); | 2350 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); |
2351 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2351 | #if IS_ENABLED(CONFIG_INPUT) |
2352 | struct input_dev *input_dev; | 2352 | struct input_dev *input_dev; |
2353 | #endif | 2353 | #endif |
2354 | 2354 | ||
@@ -2360,7 +2360,7 @@ void gspca_disconnect(struct usb_interface *intf) | |||
2360 | gspca_dev->present = 0; | 2360 | gspca_dev->present = 0; |
2361 | destroy_urbs(gspca_dev); | 2361 | destroy_urbs(gspca_dev); |
2362 | 2362 | ||
2363 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2363 | #if IS_ENABLED(CONFIG_INPUT) |
2364 | gspca_input_destroy_urb(gspca_dev); | 2364 | gspca_input_destroy_urb(gspca_dev); |
2365 | input_dev = gspca_dev->input_dev; | 2365 | input_dev = gspca_dev->input_dev; |
2366 | if (input_dev) { | 2366 | if (input_dev) { |
diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h index 352317d7acdb..5559932bf2f5 100644 --- a/drivers/media/usb/gspca/gspca.h +++ b/drivers/media/usb/gspca/gspca.h | |||
@@ -138,7 +138,7 @@ struct sd_desc { | |||
138 | cam_reg_op get_register; | 138 | cam_reg_op get_register; |
139 | #endif | 139 | #endif |
140 | cam_ident_op get_chip_ident; | 140 | cam_ident_op get_chip_ident; |
141 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 141 | #if IS_ENABLED(CONFIG_INPUT) |
142 | cam_int_pkt_op int_pkt_scan; | 142 | cam_int_pkt_op int_pkt_scan; |
143 | /* other_input makes the gspca core create gspca_dev->input even when | 143 | /* other_input makes the gspca core create gspca_dev->input even when |
144 | int_pkt_scan is NULL, for cams with non interrupt driven buttons */ | 144 | int_pkt_scan is NULL, for cams with non interrupt driven buttons */ |
@@ -167,7 +167,7 @@ struct gspca_dev { | |||
167 | struct usb_device *dev; | 167 | struct usb_device *dev; |
168 | struct file *capt_file; /* file doing video capture */ | 168 | struct file *capt_file; /* file doing video capture */ |
169 | /* protected by queue_lock */ | 169 | /* protected by queue_lock */ |
170 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 170 | #if IS_ENABLED(CONFIG_INPUT) |
171 | struct input_dev *input_dev; | 171 | struct input_dev *input_dev; |
172 | char phys[64]; /* physical device path */ | 172 | char phys[64]; /* physical device path */ |
173 | #endif | 173 | #endif |
@@ -190,7 +190,7 @@ struct gspca_dev { | |||
190 | #define USB_BUF_SZ 64 | 190 | #define USB_BUF_SZ 64 |
191 | __u8 *usb_buf; /* buffer for USB exchanges */ | 191 | __u8 *usb_buf; /* buffer for USB exchanges */ |
192 | struct urb *urb[MAX_NURBS]; | 192 | struct urb *urb[MAX_NURBS]; |
193 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 193 | #if IS_ENABLED(CONFIG_INPUT) |
194 | struct urb *int_urb; | 194 | struct urb *int_urb; |
195 | #endif | 195 | #endif |
196 | 196 | ||
diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c index 62ba80d9b998..fdaeeb14453f 100644 --- a/drivers/media/usb/gspca/jl2005bcd.c +++ b/drivers/media/usb/gspca/jl2005bcd.c | |||
@@ -536,20 +536,4 @@ static struct usb_driver sd_driver = { | |||
536 | #endif | 536 | #endif |
537 | }; | 537 | }; |
538 | 538 | ||
539 | /* -- module insert / remove -- */ | 539 | module_usb_driver(sd_driver); |
540 | static int __init sd_mod_init(void) | ||
541 | { | ||
542 | int ret; | ||
543 | |||
544 | ret = usb_register(&sd_driver); | ||
545 | if (ret < 0) | ||
546 | return ret; | ||
547 | return 0; | ||
548 | } | ||
549 | static void __exit sd_mod_exit(void) | ||
550 | { | ||
551 | usb_deregister(&sd_driver); | ||
552 | } | ||
553 | |||
554 | module_init(sd_mod_init); | ||
555 | module_exit(sd_mod_exit); | ||
diff --git a/drivers/media/usb/gspca/konica.c b/drivers/media/usb/gspca/konica.c index bbf91e07e38b..61e25dbf2447 100644 --- a/drivers/media/usb/gspca/konica.c +++ b/drivers/media/usb/gspca/konica.c | |||
@@ -246,7 +246,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
246 | struct sd *sd = (struct sd *) gspca_dev; | 246 | struct sd *sd = (struct sd *) gspca_dev; |
247 | 247 | ||
248 | konica_stream_off(gspca_dev); | 248 | konica_stream_off(gspca_dev); |
249 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 249 | #if IS_ENABLED(CONFIG_INPUT) |
250 | /* Don't keep the button in the pressed state "forever" if it was | 250 | /* Don't keep the button in the pressed state "forever" if it was |
251 | pressed when streaming is stopped */ | 251 | pressed when streaming is stopped */ |
252 | if (sd->snapshot_pressed) { | 252 | if (sd->snapshot_pressed) { |
@@ -345,7 +345,7 @@ static void sd_isoc_irq(struct urb *urb) | |||
345 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); | 345 | gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); |
346 | gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0); | 346 | gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0); |
347 | } else { | 347 | } else { |
348 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 348 | #if IS_ENABLED(CONFIG_INPUT) |
349 | u8 button_state = st & 0x40 ? 1 : 0; | 349 | u8 button_state = st & 0x40 ? 1 : 0; |
350 | if (sd->snapshot_pressed != button_state) { | 350 | if (sd->snapshot_pressed != button_state) { |
351 | input_report_key(gspca_dev->input_dev, | 351 | input_report_key(gspca_dev->input_dev, |
@@ -452,7 +452,7 @@ static const struct sd_desc sd_desc = { | |||
452 | .init_controls = sd_init_controls, | 452 | .init_controls = sd_init_controls, |
453 | .start = sd_start, | 453 | .start = sd_start, |
454 | .stopN = sd_stopN, | 454 | .stopN = sd_stopN, |
455 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 455 | #if IS_ENABLED(CONFIG_INPUT) |
456 | .other_input = 1, | 456 | .other_input = 1, |
457 | #endif | 457 | #endif |
458 | }; | 458 | }; |
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c index 9aa09f845ce4..9ad19a7ef81b 100644 --- a/drivers/media/usb/gspca/ov519.c +++ b/drivers/media/usb/gspca/ov519.c | |||
@@ -4238,7 +4238,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
4238 | if (sd->bridge == BRIDGE_W9968CF) | 4238 | if (sd->bridge == BRIDGE_W9968CF) |
4239 | w9968cf_stop0(sd); | 4239 | w9968cf_stop0(sd); |
4240 | 4240 | ||
4241 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 4241 | #if IS_ENABLED(CONFIG_INPUT) |
4242 | /* If the last button state is pressed, release it now! */ | 4242 | /* If the last button state is pressed, release it now! */ |
4243 | if (sd->snapshot_pressed) { | 4243 | if (sd->snapshot_pressed) { |
4244 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | 4244 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); |
@@ -4255,7 +4255,7 @@ static void ov51x_handle_button(struct gspca_dev *gspca_dev, u8 state) | |||
4255 | struct sd *sd = (struct sd *) gspca_dev; | 4255 | struct sd *sd = (struct sd *) gspca_dev; |
4256 | 4256 | ||
4257 | if (sd->snapshot_pressed != state) { | 4257 | if (sd->snapshot_pressed != state) { |
4258 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 4258 | #if IS_ENABLED(CONFIG_INPUT) |
4259 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); | 4259 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, state); |
4260 | input_sync(gspca_dev->input_dev); | 4260 | input_sync(gspca_dev->input_dev); |
4261 | #endif | 4261 | #endif |
@@ -4924,7 +4924,7 @@ static const struct sd_desc sd_desc = { | |||
4924 | .dq_callback = sd_reset_snapshot, | 4924 | .dq_callback = sd_reset_snapshot, |
4925 | .get_jcomp = sd_get_jcomp, | 4925 | .get_jcomp = sd_get_jcomp, |
4926 | .set_jcomp = sd_set_jcomp, | 4926 | .set_jcomp = sd_set_jcomp, |
4927 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 4927 | #if IS_ENABLED(CONFIG_INPUT) |
4928 | .other_input = 1, | 4928 | .other_input = 1, |
4929 | #endif | 4929 | #endif |
4930 | }; | 4930 | }; |
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c index d236d1791f78..3b75097dd34e 100644 --- a/drivers/media/usb/gspca/pac207.c +++ b/drivers/media/usb/gspca/pac207.c | |||
@@ -55,6 +55,11 @@ MODULE_LICENSE("GPL"); | |||
55 | 55 | ||
56 | #define PAC207_AUTOGAIN_DEADZONE 30 | 56 | #define PAC207_AUTOGAIN_DEADZONE 30 |
57 | 57 | ||
58 | /* global parameters */ | ||
59 | static int led_invert; | ||
60 | module_param(led_invert, int, 0644); | ||
61 | MODULE_PARM_DESC(led_invert, "Invert led"); | ||
62 | |||
58 | /* specific webcam descriptor */ | 63 | /* specific webcam descriptor */ |
59 | struct sd { | 64 | struct sd { |
60 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 65 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
@@ -187,10 +192,14 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
187 | /* this function is called at probe and resume time */ | 192 | /* this function is called at probe and resume time */ |
188 | static int sd_init(struct gspca_dev *gspca_dev) | 193 | static int sd_init(struct gspca_dev *gspca_dev) |
189 | { | 194 | { |
190 | pac207_write_reg(gspca_dev, 0x41, 0x00); | 195 | u8 mode; |
191 | /* Bit_0=Image Format, | 196 | |
192 | * Bit_1=LED, | 197 | /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ |
193 | * Bit_2=Compression test mode enable */ | 198 | if (led_invert) |
199 | mode = 0x02; | ||
200 | else | ||
201 | mode = 0x00; | ||
202 | pac207_write_reg(gspca_dev, 0x41, mode); | ||
194 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | 203 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ |
195 | 204 | ||
196 | return gspca_dev->usb_err; | 205 | return gspca_dev->usb_err; |
@@ -303,7 +312,11 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
303 | pac207_write_reg(gspca_dev, 0x02, | 312 | pac207_write_reg(gspca_dev, 0x02, |
304 | v4l2_ctrl_g_ctrl(gspca_dev->exposure)); /* PXCK = 12MHz /n */ | 313 | v4l2_ctrl_g_ctrl(gspca_dev->exposure)); /* PXCK = 12MHz /n */ |
305 | 314 | ||
306 | mode = 0x02; /* Image Format (Bit 0), LED (1), Compr. test mode (2) */ | 315 | /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ |
316 | if (led_invert) | ||
317 | mode = 0x00; | ||
318 | else | ||
319 | mode = 0x02; | ||
307 | if (gspca_dev->width == 176) { /* 176x144 */ | 320 | if (gspca_dev->width == 176) { /* 176x144 */ |
308 | mode |= 0x01; | 321 | mode |= 0x01; |
309 | PDEBUG(D_STREAM, "pac207_start mode 176x144"); | 322 | PDEBUG(D_STREAM, "pac207_start mode 176x144"); |
@@ -325,8 +338,15 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
325 | 338 | ||
326 | static void sd_stopN(struct gspca_dev *gspca_dev) | 339 | static void sd_stopN(struct gspca_dev *gspca_dev) |
327 | { | 340 | { |
341 | u8 mode; | ||
342 | |||
343 | /* mode: Image Format (Bit 0), LED (1), Compr. test mode (2) */ | ||
344 | if (led_invert) | ||
345 | mode = 0x02; | ||
346 | else | ||
347 | mode = 0x00; | ||
328 | pac207_write_reg(gspca_dev, 0x40, 0x00); /* Stop ISO pipe */ | 348 | pac207_write_reg(gspca_dev, 0x40, 0x00); /* Stop ISO pipe */ |
329 | pac207_write_reg(gspca_dev, 0x41, 0x00); /* Turn of LED */ | 349 | pac207_write_reg(gspca_dev, 0x41, mode); /* Turn off LED */ |
330 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | 350 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ |
331 | } | 351 | } |
332 | 352 | ||
@@ -393,7 +413,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
393 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 413 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
394 | } | 414 | } |
395 | 415 | ||
396 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 416 | #if IS_ENABLED(CONFIG_INPUT) |
397 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 417 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
398 | u8 *data, /* interrupt packet data */ | 418 | u8 *data, /* interrupt packet data */ |
399 | int len) /* interrput packet length */ | 419 | int len) /* interrput packet length */ |
@@ -422,7 +442,7 @@ static const struct sd_desc sd_desc = { | |||
422 | .stopN = sd_stopN, | 442 | .stopN = sd_stopN, |
423 | .dq_callback = pac207_do_auto_gain, | 443 | .dq_callback = pac207_do_auto_gain, |
424 | .pkt_scan = sd_pkt_scan, | 444 | .pkt_scan = sd_pkt_scan, |
425 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 445 | #if IS_ENABLED(CONFIG_INPUT) |
426 | .int_pkt_scan = sd_int_pkt_scan, | 446 | .int_pkt_scan = sd_int_pkt_scan, |
427 | #endif | 447 | #endif |
428 | }; | 448 | }; |
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c index 4f5869a98082..add6f725ba50 100644 --- a/drivers/media/usb/gspca/pac7302.c +++ b/drivers/media/usb/gspca/pac7302.c | |||
@@ -890,7 +890,7 @@ static int sd_chip_ident(struct gspca_dev *gspca_dev, | |||
890 | } | 890 | } |
891 | #endif | 891 | #endif |
892 | 892 | ||
893 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 893 | #if IS_ENABLED(CONFIG_INPUT) |
894 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 894 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
895 | u8 *data, /* interrupt packet data */ | 895 | u8 *data, /* interrupt packet data */ |
896 | int len) /* interrput packet length */ | 896 | int len) /* interrput packet length */ |
@@ -936,7 +936,7 @@ static const struct sd_desc sd_desc = { | |||
936 | .set_register = sd_dbg_s_register, | 936 | .set_register = sd_dbg_s_register, |
937 | .get_chip_ident = sd_chip_ident, | 937 | .get_chip_ident = sd_chip_ident, |
938 | #endif | 938 | #endif |
939 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 939 | #if IS_ENABLED(CONFIG_INPUT) |
940 | .int_pkt_scan = sd_int_pkt_scan, | 940 | .int_pkt_scan = sd_int_pkt_scan, |
941 | #endif | 941 | #endif |
942 | }; | 942 | }; |
diff --git a/drivers/media/usb/gspca/pac7311.c b/drivers/media/usb/gspca/pac7311.c index ba3558d3f017..a12dfbf6e051 100644 --- a/drivers/media/usb/gspca/pac7311.c +++ b/drivers/media/usb/gspca/pac7311.c | |||
@@ -621,7 +621,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
621 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 621 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
622 | } | 622 | } |
623 | 623 | ||
624 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 624 | #if IS_ENABLED(CONFIG_INPUT) |
625 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 625 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
626 | u8 *data, /* interrupt packet data */ | 626 | u8 *data, /* interrupt packet data */ |
627 | int len) /* interrupt packet length */ | 627 | int len) /* interrupt packet length */ |
@@ -661,7 +661,7 @@ static const struct sd_desc sd_desc = { | |||
661 | .stopN = sd_stopN, | 661 | .stopN = sd_stopN, |
662 | .pkt_scan = sd_pkt_scan, | 662 | .pkt_scan = sd_pkt_scan, |
663 | .dq_callback = do_autogain, | 663 | .dq_callback = do_autogain, |
664 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 664 | #if IS_ENABLED(CONFIG_INPUT) |
665 | .int_pkt_scan = sd_int_pkt_scan, | 665 | .int_pkt_scan = sd_int_pkt_scan, |
666 | #endif | 666 | #endif |
667 | }; | 667 | }; |
diff --git a/drivers/media/usb/gspca/se401.c b/drivers/media/usb/gspca/se401.c index a33cb78a839c..5f729b8aa2bd 100644 --- a/drivers/media/usb/gspca/se401.c +++ b/drivers/media/usb/gspca/se401.c | |||
@@ -594,7 +594,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, u8 *data, int len) | |||
594 | sd_pkt_scan_janggu(gspca_dev, data, len); | 594 | sd_pkt_scan_janggu(gspca_dev, data, len); |
595 | } | 595 | } |
596 | 596 | ||
597 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 597 | #if IS_ENABLED(CONFIG_INPUT) |
598 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, u8 *data, int len) | 598 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, u8 *data, int len) |
599 | { | 599 | { |
600 | struct sd *sd = (struct sd *)gspca_dev; | 600 | struct sd *sd = (struct sd *)gspca_dev; |
@@ -688,7 +688,7 @@ static const struct sd_desc sd_desc = { | |||
688 | .stopN = sd_stopN, | 688 | .stopN = sd_stopN, |
689 | .dq_callback = sd_dq_callback, | 689 | .dq_callback = sd_dq_callback, |
690 | .pkt_scan = sd_pkt_scan, | 690 | .pkt_scan = sd_pkt_scan, |
691 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 691 | #if IS_ENABLED(CONFIG_INPUT) |
692 | .int_pkt_scan = sd_int_pkt_scan, | 692 | .int_pkt_scan = sd_int_pkt_scan, |
693 | #endif | 693 | #endif |
694 | }; | 694 | }; |
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c index 41f769fe340c..4ec544f4a845 100644 --- a/drivers/media/usb/gspca/sn9c20x.c +++ b/drivers/media/usb/gspca/sn9c20x.c | |||
@@ -2205,7 +2205,7 @@ static void qual_upd(struct work_struct *work) | |||
2205 | mutex_unlock(&gspca_dev->usb_lock); | 2205 | mutex_unlock(&gspca_dev->usb_lock); |
2206 | } | 2206 | } |
2207 | 2207 | ||
2208 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2208 | #if IS_ENABLED(CONFIG_INPUT) |
2209 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 2209 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
2210 | u8 *data, /* interrupt packet */ | 2210 | u8 *data, /* interrupt packet */ |
2211 | int len) /* interrupt packet length */ | 2211 | int len) /* interrupt packet length */ |
@@ -2349,7 +2349,7 @@ static const struct sd_desc sd_desc = { | |||
2349 | .stopN = sd_stopN, | 2349 | .stopN = sd_stopN, |
2350 | .stop0 = sd_stop0, | 2350 | .stop0 = sd_stop0, |
2351 | .pkt_scan = sd_pkt_scan, | 2351 | .pkt_scan = sd_pkt_scan, |
2352 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2352 | #if IS_ENABLED(CONFIG_INPUT) |
2353 | .int_pkt_scan = sd_int_pkt_scan, | 2353 | .int_pkt_scan = sd_int_pkt_scan, |
2354 | #endif | 2354 | #endif |
2355 | .dq_callback = sd_dqcallback, | 2355 | .dq_callback = sd_dqcallback, |
diff --git a/drivers/media/usb/gspca/sonixb.c b/drivers/media/usb/gspca/sonixb.c index 1220340e7602..104ae25275b4 100644 --- a/drivers/media/usb/gspca/sonixb.c +++ b/drivers/media/usb/gspca/sonixb.c | |||
@@ -1400,7 +1400,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
1400 | return -EINVAL; | 1400 | return -EINVAL; |
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 1403 | #if IS_ENABLED(CONFIG_INPUT) |
1404 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 1404 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
1405 | u8 *data, /* interrupt packet data */ | 1405 | u8 *data, /* interrupt packet data */ |
1406 | int len) /* interrupt packet length */ | 1406 | int len) /* interrupt packet length */ |
@@ -1430,7 +1430,7 @@ static const struct sd_desc sd_desc = { | |||
1430 | .pkt_scan = sd_pkt_scan, | 1430 | .pkt_scan = sd_pkt_scan, |
1431 | .querymenu = sd_querymenu, | 1431 | .querymenu = sd_querymenu, |
1432 | .dq_callback = do_autogain, | 1432 | .dq_callback = do_autogain, |
1433 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 1433 | #if IS_ENABLED(CONFIG_INPUT) |
1434 | .int_pkt_scan = sd_int_pkt_scan, | 1434 | .int_pkt_scan = sd_int_pkt_scan, |
1435 | #endif | 1435 | #endif |
1436 | }; | 1436 | }; |
@@ -1448,7 +1448,7 @@ static const struct usb_device_id device_table[] = { | |||
1448 | {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, | 1448 | {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, |
1449 | {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, | 1449 | {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, |
1450 | {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, | 1450 | {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, |
1451 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | 1451 | #if !IS_ENABLED(CONFIG_USB_SN9C102) |
1452 | {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, | 1452 | {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, |
1453 | {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, | 1453 | {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, |
1454 | #endif | 1454 | #endif |
diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c index 36307a9028a9..671d0c6dece3 100644 --- a/drivers/media/usb/gspca/sonixj.c +++ b/drivers/media/usb/gspca/sonixj.c | |||
@@ -3077,7 +3077,7 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
3077 | return -EINVAL; | 3077 | return -EINVAL; |
3078 | } | 3078 | } |
3079 | 3079 | ||
3080 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 3080 | #if IS_ENABLED(CONFIG_INPUT) |
3081 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 3081 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
3082 | u8 *data, /* interrupt packet data */ | 3082 | u8 *data, /* interrupt packet data */ |
3083 | int len) /* interrupt packet length */ | 3083 | int len) /* interrupt packet length */ |
@@ -3109,7 +3109,7 @@ static const struct sd_desc sd_desc = { | |||
3109 | .pkt_scan = sd_pkt_scan, | 3109 | .pkt_scan = sd_pkt_scan, |
3110 | .dq_callback = do_autogain, | 3110 | .dq_callback = do_autogain, |
3111 | .querymenu = sd_querymenu, | 3111 | .querymenu = sd_querymenu, |
3112 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 3112 | #if IS_ENABLED(CONFIG_INPUT) |
3113 | .int_pkt_scan = sd_int_pkt_scan, | 3113 | .int_pkt_scan = sd_int_pkt_scan, |
3114 | #endif | 3114 | #endif |
3115 | }; | 3115 | }; |
diff --git a/drivers/media/usb/gspca/spca561.c b/drivers/media/usb/gspca/spca561.c index cfe71dd6747d..d1db3d8f6522 100644 --- a/drivers/media/usb/gspca/spca561.c +++ b/drivers/media/usb/gspca/spca561.c | |||
@@ -741,7 +741,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
741 | return; | 741 | return; |
742 | } | 742 | } |
743 | 743 | ||
744 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 744 | #if IS_ENABLED(CONFIG_INPUT) |
745 | if (data[0] & 0x20) { | 745 | if (data[0] & 0x20) { |
746 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); | 746 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); |
747 | input_sync(gspca_dev->input_dev); | 747 | input_sync(gspca_dev->input_dev); |
@@ -866,7 +866,7 @@ static const struct sd_desc sd_desc_12a = { | |||
866 | .start = sd_start_12a, | 866 | .start = sd_start_12a, |
867 | .stopN = sd_stopN, | 867 | .stopN = sd_stopN, |
868 | .pkt_scan = sd_pkt_scan, | 868 | .pkt_scan = sd_pkt_scan, |
869 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 869 | #if IS_ENABLED(CONFIG_INPUT) |
870 | .other_input = 1, | 870 | .other_input = 1, |
871 | #endif | 871 | #endif |
872 | }; | 872 | }; |
@@ -879,7 +879,7 @@ static const struct sd_desc sd_desc_72a = { | |||
879 | .stopN = sd_stopN, | 879 | .stopN = sd_stopN, |
880 | .pkt_scan = sd_pkt_scan, | 880 | .pkt_scan = sd_pkt_scan, |
881 | .dq_callback = do_autogain, | 881 | .dq_callback = do_autogain, |
882 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 882 | #if IS_ENABLED(CONFIG_INPUT) |
883 | .other_input = 1, | 883 | .other_input = 1, |
884 | #endif | 884 | #endif |
885 | }; | 885 | }; |
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c index 999ec7764449..657160b4a1f7 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c | |||
@@ -492,7 +492,7 @@ frame_data: | |||
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 495 | #if IS_ENABLED(CONFIG_INPUT) |
496 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 496 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
497 | u8 *data, /* interrupt packet data */ | 497 | u8 *data, /* interrupt packet data */ |
498 | int len) /* interrupt packet length */ | 498 | int len) /* interrupt packet length */ |
@@ -529,7 +529,7 @@ static const struct sd_desc sd_desc = { | |||
529 | .pkt_scan = stv06xx_pkt_scan, | 529 | .pkt_scan = stv06xx_pkt_scan, |
530 | .isoc_init = stv06xx_isoc_init, | 530 | .isoc_init = stv06xx_isoc_init, |
531 | .isoc_nego = stv06xx_isoc_nego, | 531 | .isoc_nego = stv06xx_isoc_nego, |
532 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 532 | #if IS_ENABLED(CONFIG_INPUT) |
533 | .int_pkt_scan = sd_int_pkt_scan, | 533 | .int_pkt_scan = sd_int_pkt_scan, |
534 | #endif | 534 | #endif |
535 | }; | 535 | }; |
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c index 748e1421d6d8..e95fa8997d22 100644 --- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c | |||
@@ -52,9 +52,13 @@ static int vv6410_s_ctrl(struct v4l2_ctrl *ctrl) | |||
52 | 52 | ||
53 | switch (ctrl->id) { | 53 | switch (ctrl->id) { |
54 | case V4L2_CID_HFLIP: | 54 | case V4L2_CID_HFLIP: |
55 | if (!gspca_dev->streaming) | ||
56 | return 0; | ||
55 | err = vv6410_set_hflip(gspca_dev, ctrl->val); | 57 | err = vv6410_set_hflip(gspca_dev, ctrl->val); |
56 | break; | 58 | break; |
57 | case V4L2_CID_VFLIP: | 59 | case V4L2_CID_VFLIP: |
60 | if (!gspca_dev->streaming) | ||
61 | return 0; | ||
58 | err = vv6410_set_vflip(gspca_dev, ctrl->val); | 62 | err = vv6410_set_vflip(gspca_dev, ctrl->val); |
59 | break; | 63 | break; |
60 | case V4L2_CID_GAIN: | 64 | case V4L2_CID_GAIN: |
@@ -94,11 +98,14 @@ static int vv6410_init_controls(struct sd *sd) | |||
94 | { | 98 | { |
95 | struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; | 99 | struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; |
96 | 100 | ||
97 | v4l2_ctrl_handler_init(hdl, 4); | 101 | v4l2_ctrl_handler_init(hdl, 2); |
98 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, | 102 | /* Disable the hardware VFLIP and HFLIP as we currently lack a |
99 | V4L2_CID_HFLIP, 0, 1, 1, 0); | 103 | mechanism to adjust the image offset in such a way that |
100 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, | 104 | we don't need to renegotiate the announced format */ |
101 | V4L2_CID_VFLIP, 0, 1, 1, 0); | 105 | /* v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, */ |
106 | /* V4L2_CID_HFLIP, 0, 1, 1, 0); */ | ||
107 | /* v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, */ | ||
108 | /* V4L2_CID_VFLIP, 0, 1, 1, 0); */ | ||
102 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, | 109 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, |
103 | V4L2_CID_EXPOSURE, 0, 32768, 1, 20000); | 110 | V4L2_CID_EXPOSURE, 0, 32768, 1, 20000); |
104 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, | 111 | v4l2_ctrl_new_std(hdl, &vv6410_ctrl_ops, |
diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c index 8bc6c3ceec2c..e2cc4e5a0ccb 100644 --- a/drivers/media/usb/gspca/t613.c +++ b/drivers/media/usb/gspca/t613.c | |||
@@ -494,7 +494,7 @@ static void setcolors(struct gspca_dev *gspca_dev, s32 val) | |||
494 | 494 | ||
495 | static void setgamma(struct gspca_dev *gspca_dev, s32 val) | 495 | static void setgamma(struct gspca_dev *gspca_dev, s32 val) |
496 | { | 496 | { |
497 | PDEBUG(D_CONF, "Gamma: %d", sd->gamma); | 497 | PDEBUG(D_CONF, "Gamma: %d", val); |
498 | reg_w_ixbuf(gspca_dev, 0x90, | 498 | reg_w_ixbuf(gspca_dev, 0x90, |
499 | gamma_table[val], sizeof gamma_table[0]); | 499 | gamma_table[val], sizeof gamma_table[0]); |
500 | } | 500 | } |
@@ -823,7 +823,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
823 | msleep(20); | 823 | msleep(20); |
824 | reg_w(gspca_dev, 0x0309); | 824 | reg_w(gspca_dev, 0x0309); |
825 | } | 825 | } |
826 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 826 | #if IS_ENABLED(CONFIG_INPUT) |
827 | /* If the last button state is pressed, release it now! */ | 827 | /* If the last button state is pressed, release it now! */ |
828 | if (sd->button_pressed) { | 828 | if (sd->button_pressed) { |
829 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | 829 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); |
@@ -841,7 +841,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
841 | int pkt_type; | 841 | int pkt_type; |
842 | 842 | ||
843 | if (data[0] == 0x5a) { | 843 | if (data[0] == 0x5a) { |
844 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 844 | #if IS_ENABLED(CONFIG_INPUT) |
845 | if (len > 20) { | 845 | if (len > 20) { |
846 | u8 state = (data[20] & 0x80) ? 1 : 0; | 846 | u8 state = (data[20] & 0x80) ? 1 : 0; |
847 | if (sd->button_pressed != state) { | 847 | if (sd->button_pressed != state) { |
@@ -1019,7 +1019,7 @@ static const struct sd_desc sd_desc = { | |||
1019 | .start = sd_start, | 1019 | .start = sd_start, |
1020 | .stopN = sd_stopN, | 1020 | .stopN = sd_stopN, |
1021 | .pkt_scan = sd_pkt_scan, | 1021 | .pkt_scan = sd_pkt_scan, |
1022 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 1022 | #if IS_ENABLED(CONFIG_INPUT) |
1023 | .other_input = 1, | 1023 | .other_input = 1, |
1024 | #endif | 1024 | #endif |
1025 | }; | 1025 | }; |
diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c index d4b23c9bf90c..7eaf64eb867c 100644 --- a/drivers/media/usb/gspca/xirlink_cit.c +++ b/drivers/media/usb/gspca/xirlink_cit.c | |||
@@ -2759,7 +2759,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
2759 | break; | 2759 | break; |
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2762 | #if IS_ENABLED(CONFIG_INPUT) |
2763 | /* If the last button state is pressed, release it now! */ | 2763 | /* If the last button state is pressed, release it now! */ |
2764 | if (sd->button_state) { | 2764 | if (sd->button_state) { |
2765 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); | 2765 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); |
@@ -2914,7 +2914,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
2914 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); | 2914 | gspca_frame_add(gspca_dev, INTER_PACKET, data, len); |
2915 | } | 2915 | } |
2916 | 2916 | ||
2917 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 2917 | #if IS_ENABLED(CONFIG_INPUT) |
2918 | static void cit_check_button(struct gspca_dev *gspca_dev) | 2918 | static void cit_check_button(struct gspca_dev *gspca_dev) |
2919 | { | 2919 | { |
2920 | int new_button_state; | 2920 | int new_button_state; |
@@ -3062,7 +3062,7 @@ static const struct sd_desc sd_desc = { | |||
3062 | .stopN = sd_stopN, | 3062 | .stopN = sd_stopN, |
3063 | .stop0 = sd_stop0, | 3063 | .stop0 = sd_stop0, |
3064 | .pkt_scan = sd_pkt_scan, | 3064 | .pkt_scan = sd_pkt_scan, |
3065 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 3065 | #if IS_ENABLED(CONFIG_INPUT) |
3066 | .dq_callback = cit_check_button, | 3066 | .dq_callback = cit_check_button, |
3067 | .other_input = 1, | 3067 | .other_input = 1, |
3068 | #endif | 3068 | #endif |
@@ -3079,7 +3079,7 @@ static const struct sd_desc sd_desc_isoc_nego = { | |||
3079 | .stopN = sd_stopN, | 3079 | .stopN = sd_stopN, |
3080 | .stop0 = sd_stop0, | 3080 | .stop0 = sd_stop0, |
3081 | .pkt_scan = sd_pkt_scan, | 3081 | .pkt_scan = sd_pkt_scan, |
3082 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 3082 | #if IS_ENABLED(CONFIG_INPUT) |
3083 | .dq_callback = cit_check_button, | 3083 | .dq_callback = cit_check_button, |
3084 | .other_input = 1, | 3084 | .other_input = 1, |
3085 | #endif | 3085 | #endif |
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c index 77c57755e7b4..a8dc421f9f1f 100644 --- a/drivers/media/usb/gspca/zc3xx.c +++ b/drivers/media/usb/gspca/zc3xx.c | |||
@@ -6902,7 +6902,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
6902 | return 0; | 6902 | return 0; |
6903 | } | 6903 | } |
6904 | 6904 | ||
6905 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 6905 | #if IS_ENABLED(CONFIG_INPUT) |
6906 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, | 6906 | static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, |
6907 | u8 *data, /* interrupt packet data */ | 6907 | u8 *data, /* interrupt packet data */ |
6908 | int len) /* interrput packet length */ | 6908 | int len) /* interrput packet length */ |
@@ -6929,7 +6929,7 @@ static const struct sd_desc sd_desc = { | |||
6929 | .pkt_scan = sd_pkt_scan, | 6929 | .pkt_scan = sd_pkt_scan, |
6930 | .get_jcomp = sd_get_jcomp, | 6930 | .get_jcomp = sd_get_jcomp, |
6931 | .set_jcomp = sd_set_jcomp, | 6931 | .set_jcomp = sd_set_jcomp, |
6932 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | 6932 | #if IS_ENABLED(CONFIG_INPUT) |
6933 | .int_pkt_scan = sd_int_pkt_scan, | 6933 | .int_pkt_scan = sd_int_pkt_scan, |
6934 | #endif | 6934 | #endif |
6935 | }; | 6935 | }; |
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c index 84dc26fe80ee..5c6193536399 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c | |||
@@ -391,7 +391,7 @@ static int hdpvr_probe(struct usb_interface *interface, | |||
391 | goto error; | 391 | goto error; |
392 | } | 392 | } |
393 | 393 | ||
394 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 394 | #if IS_ENABLED(CONFIG_I2C) |
395 | retval = hdpvr_register_i2c_adapter(dev); | 395 | retval = hdpvr_register_i2c_adapter(dev); |
396 | if (retval < 0) { | 396 | if (retval < 0) { |
397 | v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); | 397 | v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); |
@@ -419,7 +419,7 @@ static int hdpvr_probe(struct usb_interface *interface, | |||
419 | return 0; | 419 | return 0; |
420 | 420 | ||
421 | reg_fail: | 421 | reg_fail: |
422 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 422 | #if IS_ENABLED(CONFIG_I2C) |
423 | i2c_del_adapter(&dev->i2c_adapter); | 423 | i2c_del_adapter(&dev->i2c_adapter); |
424 | #endif | 424 | #endif |
425 | error: | 425 | error: |
@@ -451,7 +451,7 @@ static void hdpvr_disconnect(struct usb_interface *interface) | |||
451 | mutex_lock(&dev->io_mutex); | 451 | mutex_lock(&dev->io_mutex); |
452 | hdpvr_cancel_queue(dev); | 452 | hdpvr_cancel_queue(dev); |
453 | mutex_unlock(&dev->io_mutex); | 453 | mutex_unlock(&dev->io_mutex); |
454 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 454 | #if IS_ENABLED(CONFIG_I2C) |
455 | i2c_del_adapter(&dev->i2c_adapter); | 455 | i2c_del_adapter(&dev->i2c_adapter); |
456 | #endif | 456 | #endif |
457 | video_unregister_device(dev->video_dev); | 457 | video_unregister_device(dev->video_dev); |
diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c index 031cf024304c..a38f58c4c6bf 100644 --- a/drivers/media/usb/hdpvr/hdpvr-i2c.c +++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c | |||
@@ -13,7 +13,7 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 16 | #if IS_ENABLED(CONFIG_I2C) |
17 | 17 | ||
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
@@ -217,8 +217,7 @@ int hdpvr_register_i2c_adapter(struct hdpvr_device *dev) | |||
217 | 217 | ||
218 | hdpvr_activate_ir(dev); | 218 | hdpvr_activate_ir(dev); |
219 | 219 | ||
220 | memcpy(&dev->i2c_adapter, &hdpvr_i2c_adapter_template, | 220 | dev->i2c_adapter = hdpvr_i2c_adapter_template; |
221 | sizeof(struct i2c_adapter)); | ||
222 | dev->i2c_adapter.dev.parent = &dev->udev->dev; | 221 | dev->i2c_adapter.dev.parent = &dev->udev->dev; |
223 | 222 | ||
224 | i2c_set_adapdata(&dev->i2c_adapter, dev); | 223 | i2c_set_adapdata(&dev->i2c_adapter, dev); |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c index e046fdaec5ae..f7702aeeda3f 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c | |||
@@ -422,8 +422,7 @@ int pvr2_encoder_adjust(struct pvr2_hdw *hdw) | |||
422 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 422 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
423 | "Error from cx2341x module code=%d",ret); | 423 | "Error from cx2341x module code=%d",ret); |
424 | } else { | 424 | } else { |
425 | memcpy(&hdw->enc_cur_state,&hdw->enc_ctl_state, | 425 | hdw->enc_cur_state = hdw->enc_ctl_state; |
426 | sizeof(struct cx2341x_mpeg_params)); | ||
427 | hdw->enc_cur_valid = !0; | 426 | hdw->enc_cur_valid = !0; |
428 | } | 427 | } |
429 | return ret; | 428 | return ret; |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c index 9ab596c78a4e..b5e929f1bf82 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | |||
@@ -649,8 +649,8 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) | |||
649 | } | 649 | } |
650 | 650 | ||
651 | // Configure the adapter and set up everything else related to it. | 651 | // Configure the adapter and set up everything else related to it. |
652 | memcpy(&hdw->i2c_adap,&pvr2_i2c_adap_template,sizeof(hdw->i2c_adap)); | 652 | hdw->i2c_adap = pvr2_i2c_adap_template; |
653 | memcpy(&hdw->i2c_algo,&pvr2_i2c_algo_template,sizeof(hdw->i2c_algo)); | 653 | hdw->i2c_algo = pvr2_i2c_algo_template; |
654 | strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name)); | 654 | strlcpy(hdw->i2c_adap.name,hdw->name,sizeof(hdw->i2c_adap.name)); |
655 | hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev; | 655 | hdw->i2c_adap.dev.parent = &hdw->usb_dev->dev; |
656 | hdw->i2c_adap.algo = &hdw->i2c_algo; | 656 | hdw->i2c_adap.algo = &hdw->i2c_algo; |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 6930676051e7..34c3b6e80e86 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | |||
@@ -1339,7 +1339,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip, | |||
1339 | return; | 1339 | return; |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | memcpy(&dip->devbase,&vdev_template,sizeof(vdev_template)); | 1342 | dip->devbase = vdev_template; |
1343 | dip->devbase.release = pvr2_video_device_release; | 1343 | dip->devbase.release = pvr2_video_device_release; |
1344 | dip->devbase.ioctl_ops = &pvr2_ioctl_ops; | 1344 | dip->devbase.ioctl_ops = &pvr2_ioctl_ops; |
1345 | { | 1345 | { |
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c index 5210239cbaee..5ec15cb1ed26 100644 --- a/drivers/media/usb/pwc/pwc-if.c +++ b/drivers/media/usb/pwc/pwc-if.c | |||
@@ -316,7 +316,8 @@ static void pwc_isoc_handler(struct urb *urb) | |||
316 | struct pwc_frame_buf *fbuf = pdev->fill_buf; | 316 | struct pwc_frame_buf *fbuf = pdev->fill_buf; |
317 | 317 | ||
318 | if (pdev->vsync == 1) { | 318 | if (pdev->vsync == 1) { |
319 | do_gettimeofday(&fbuf->vb.v4l2_buf.timestamp); | 319 | v4l2_get_timestamp( |
320 | &fbuf->vb.v4l2_buf.timestamp); | ||
320 | pdev->vsync = 2; | 321 | pdev->vsync = 2; |
321 | } | 322 | } |
322 | 323 | ||
@@ -1007,7 +1008,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | /* Init video_device structure */ | 1010 | /* Init video_device structure */ |
1010 | memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1011 | pdev->vdev = pwc_template; |
1011 | strcpy(pdev->vdev.name, name); | 1012 | strcpy(pdev->vdev.name, name); |
1012 | pdev->vdev.queue = &pdev->vb_queue; | 1013 | pdev->vdev.queue = &pdev->vb_queue; |
1013 | pdev->vdev.queue->lock = &pdev->vb_queue_lock; | 1014 | pdev->vdev.queue->lock = &pdev->vb_queue_lock; |
diff --git a/drivers/media/usb/pwc/pwc-v4l.c b/drivers/media/usb/pwc/pwc-v4l.c index 545e9bbdeede..aa7449eaca08 100644 --- a/drivers/media/usb/pwc/pwc-v4l.c +++ b/drivers/media/usb/pwc/pwc-v4l.c | |||
@@ -434,19 +434,18 @@ static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) | |||
434 | case V4L2_PIX_FMT_PWC1: | 434 | case V4L2_PIX_FMT_PWC1: |
435 | if (DEVICE_USE_CODEC23(pdev->type)) { | 435 | if (DEVICE_USE_CODEC23(pdev->type)) { |
436 | PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n"); | 436 | PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n"); |
437 | return -EINVAL; | 437 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; |
438 | } | 438 | } |
439 | break; | 439 | break; |
440 | case V4L2_PIX_FMT_PWC2: | 440 | case V4L2_PIX_FMT_PWC2: |
441 | if (DEVICE_USE_CODEC1(pdev->type)) { | 441 | if (DEVICE_USE_CODEC1(pdev->type)) { |
442 | PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n"); | 442 | PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n"); |
443 | return -EINVAL; | 443 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; |
444 | } | 444 | } |
445 | break; | 445 | break; |
446 | default: | 446 | default: |
447 | PWC_DEBUG_IOCTL("Unsupported pixel format\n"); | 447 | PWC_DEBUG_IOCTL("Unsupported pixel format\n"); |
448 | return -EINVAL; | 448 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420; |
449 | |||
450 | } | 449 | } |
451 | 450 | ||
452 | size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height); | 451 | size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height); |
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 8ebec0d7bf59..498c57ea5d32 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c | |||
@@ -593,7 +593,7 @@ static int s2255_got_frame(struct s2255_channel *channel, int jpgsize) | |||
593 | buf = list_entry(dma_q->active.next, | 593 | buf = list_entry(dma_q->active.next, |
594 | struct s2255_buffer, vb.queue); | 594 | struct s2255_buffer, vb.queue); |
595 | list_del(&buf->vb.queue); | 595 | list_del(&buf->vb.queue); |
596 | do_gettimeofday(&buf->vb.ts); | 596 | v4l2_get_timestamp(&buf->vb.ts); |
597 | s2255_fillbuff(channel, buf, jpgsize); | 597 | s2255_fillbuff(channel, buf, jpgsize); |
598 | wake_up(&buf->vb.done); | 598 | wake_up(&buf->vb.done); |
599 | dprintk(2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i); | 599 | dprintk(2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i); |
@@ -629,7 +629,6 @@ static void s2255_fillbuff(struct s2255_channel *channel, | |||
629 | struct s2255_buffer *buf, int jpgsize) | 629 | struct s2255_buffer *buf, int jpgsize) |
630 | { | 630 | { |
631 | int pos = 0; | 631 | int pos = 0; |
632 | struct timeval ts; | ||
633 | const char *tmpbuf; | 632 | const char *tmpbuf; |
634 | char *vbuf = videobuf_to_vmalloc(&buf->vb); | 633 | char *vbuf = videobuf_to_vmalloc(&buf->vb); |
635 | unsigned long last_frame; | 634 | unsigned long last_frame; |
@@ -674,8 +673,7 @@ static void s2255_fillbuff(struct s2255_channel *channel, | |||
674 | /* tell v4l buffer was filled */ | 673 | /* tell v4l buffer was filled */ |
675 | 674 | ||
676 | buf->vb.field_count = channel->frame_count * 2; | 675 | buf->vb.field_count = channel->frame_count * 2; |
677 | do_gettimeofday(&ts); | 676 | v4l2_get_timestamp(&buf->vb.ts); |
678 | buf->vb.ts = ts; | ||
679 | buf->vb.state = VIDEOBUF_DONE; | 677 | buf->vb.state = VIDEOBUF_DONE; |
680 | } | 678 | } |
681 | 679 | ||
diff --git a/drivers/media/usb/sn9c102/sn9c102_core.c b/drivers/media/usb/sn9c102/sn9c102_core.c index 73605864fffa..c957e9aa6077 100644 --- a/drivers/media/usb/sn9c102/sn9c102_core.c +++ b/drivers/media/usb/sn9c102/sn9c102_core.c | |||
@@ -173,7 +173,7 @@ sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, | |||
173 | cam->frame[i].buf.sequence = 0; | 173 | cam->frame[i].buf.sequence = 0; |
174 | cam->frame[i].buf.field = V4L2_FIELD_NONE; | 174 | cam->frame[i].buf.field = V4L2_FIELD_NONE; |
175 | cam->frame[i].buf.memory = V4L2_MEMORY_MMAP; | 175 | cam->frame[i].buf.memory = V4L2_MEMORY_MMAP; |
176 | cam->frame[i].buf.flags = 0; | 176 | cam->frame[i].buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
177 | } | 177 | } |
178 | 178 | ||
179 | return cam->nbuffers; | 179 | return cam->nbuffers; |
@@ -773,7 +773,8 @@ end_of_frame: | |||
773 | img); | 773 | img); |
774 | 774 | ||
775 | if ((*f)->buf.bytesused == 0) | 775 | if ((*f)->buf.bytesused == 0) |
776 | do_gettimeofday(&(*f)->buf.timestamp); | 776 | v4l2_get_timestamp( |
777 | &(*f)->buf.timestamp); | ||
777 | 778 | ||
778 | (*f)->buf.bytesused += img; | 779 | (*f)->buf.bytesused += img; |
779 | 780 | ||
@@ -2826,7 +2827,7 @@ sn9c102_vidioc_querybuf(struct sn9c102_device* cam, void __user * arg) | |||
2826 | b.index >= cam->nbuffers || cam->io != IO_MMAP) | 2827 | b.index >= cam->nbuffers || cam->io != IO_MMAP) |
2827 | return -EINVAL; | 2828 | return -EINVAL; |
2828 | 2829 | ||
2829 | memcpy(&b, &cam->frame[b.index].buf, sizeof(b)); | 2830 | b = cam->frame[b.index].buf; |
2830 | 2831 | ||
2831 | if (cam->frame[b.index].vma_use_count) | 2832 | if (cam->frame[b.index].vma_use_count) |
2832 | b.flags |= V4L2_BUF_FLAG_MAPPED; | 2833 | b.flags |= V4L2_BUF_FLAG_MAPPED; |
@@ -2929,7 +2930,7 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, | |||
2929 | 2930 | ||
2930 | f->state = F_UNUSED; | 2931 | f->state = F_UNUSED; |
2931 | 2932 | ||
2932 | memcpy(&b, &f->buf, sizeof(b)); | 2933 | b = f->buf; |
2933 | if (f->vma_use_count) | 2934 | if (f->vma_use_count) |
2934 | b.flags |= V4L2_BUF_FLAG_MAPPED; | 2935 | b.flags |= V4L2_BUF_FLAG_MAPPED; |
2935 | 2936 | ||
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c index fa3671de02aa..39f1aae209bc 100644 --- a/drivers/media/usb/stk1160/stk1160-video.c +++ b/drivers/media/usb/stk1160/stk1160-video.c | |||
@@ -78,7 +78,7 @@ struct stk1160_buffer *stk1160_next_buffer(struct stk1160 *dev) | |||
78 | unsigned long flags = 0; | 78 | unsigned long flags = 0; |
79 | 79 | ||
80 | /* Current buffer must be NULL when this functions gets called */ | 80 | /* Current buffer must be NULL when this functions gets called */ |
81 | BUG_ON(dev->isoc_ctl.buf); | 81 | WARN_ON(dev->isoc_ctl.buf); |
82 | 82 | ||
83 | spin_lock_irqsave(&dev->buf_lock, flags); | 83 | spin_lock_irqsave(&dev->buf_lock, flags); |
84 | if (!list_empty(&dev->avail_bufs)) { | 84 | if (!list_empty(&dev->avail_bufs)) { |
@@ -101,7 +101,7 @@ void stk1160_buffer_done(struct stk1160 *dev) | |||
101 | buf->vb.v4l2_buf.sequence = dev->field_count >> 1; | 101 | buf->vb.v4l2_buf.sequence = dev->field_count >> 1; |
102 | buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; | 102 | buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; |
103 | buf->vb.v4l2_buf.bytesused = buf->bytesused; | 103 | buf->vb.v4l2_buf.bytesused = buf->bytesused; |
104 | do_gettimeofday(&buf->vb.v4l2_buf.timestamp); | 104 | v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); |
105 | 105 | ||
106 | vb2_set_plane_payload(&buf->vb, 0, buf->bytesused); | 106 | vb2_set_plane_payload(&buf->vb, 0, buf->bytesused); |
107 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); | 107 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); |
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index 5d3c032d733c..4cbab085e348 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | 30 | ||
31 | #include <linux/dmi.h> | ||
31 | #include <linux/usb.h> | 32 | #include <linux/usb.h> |
32 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
33 | #include <linux/vmalloc.h> | 34 | #include <linux/vmalloc.h> |
@@ -38,12 +39,12 @@ | |||
38 | #include "stk-webcam.h" | 39 | #include "stk-webcam.h" |
39 | 40 | ||
40 | 41 | ||
41 | static bool hflip; | 42 | static int hflip = -1; |
42 | module_param(hflip, bool, 0444); | 43 | module_param(hflip, int, 0444); |
43 | MODULE_PARM_DESC(hflip, "Horizontal image flip (mirror). Defaults to 0"); | 44 | MODULE_PARM_DESC(hflip, "Horizontal image flip (mirror). Defaults to 0"); |
44 | 45 | ||
45 | static bool vflip; | 46 | static int vflip = -1; |
46 | module_param(vflip, bool, 0444); | 47 | module_param(vflip, int, 0444); |
47 | MODULE_PARM_DESC(vflip, "Vertical image flip. Defaults to 0"); | 48 | MODULE_PARM_DESC(vflip, "Vertical image flip. Defaults to 0"); |
48 | 49 | ||
49 | static int debug; | 50 | static int debug; |
@@ -62,6 +63,19 @@ static struct usb_device_id stkwebcam_table[] = { | |||
62 | }; | 63 | }; |
63 | MODULE_DEVICE_TABLE(usb, stkwebcam_table); | 64 | MODULE_DEVICE_TABLE(usb, stkwebcam_table); |
64 | 65 | ||
66 | /* The stk webcam laptop module is mounted upside down in some laptops :( */ | ||
67 | static const struct dmi_system_id stk_upside_down_dmi_table[] = { | ||
68 | { | ||
69 | .ident = "ASUS G1", | ||
70 | .matches = { | ||
71 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), | ||
72 | DMI_MATCH(DMI_PRODUCT_NAME, "G1") | ||
73 | } | ||
74 | }, | ||
75 | {} | ||
76 | }; | ||
77 | |||
78 | |||
65 | /* | 79 | /* |
66 | * Basic stuff | 80 | * Basic stuff |
67 | */ | 81 | */ |
@@ -466,6 +480,7 @@ static int stk_setup_siobuf(struct stk_camera *dev, int index) | |||
466 | buf->dev = dev; | 480 | buf->dev = dev; |
467 | buf->v4lbuf.index = index; | 481 | buf->v4lbuf.index = index; |
468 | buf->v4lbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 482 | buf->v4lbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
483 | buf->v4lbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
469 | buf->v4lbuf.field = V4L2_FIELD_NONE; | 484 | buf->v4lbuf.field = V4L2_FIELD_NONE; |
470 | buf->v4lbuf.memory = V4L2_MEMORY_MMAP; | 485 | buf->v4lbuf.memory = V4L2_MEMORY_MMAP; |
471 | buf->v4lbuf.m.offset = 2*index*buf->v4lbuf.length; | 486 | buf->v4lbuf.m.offset = 2*index*buf->v4lbuf.length; |
@@ -816,10 +831,16 @@ static int stk_vidioc_g_ctrl(struct file *filp, | |||
816 | c->value = dev->vsettings.brightness; | 831 | c->value = dev->vsettings.brightness; |
817 | break; | 832 | break; |
818 | case V4L2_CID_HFLIP: | 833 | case V4L2_CID_HFLIP: |
819 | c->value = dev->vsettings.hflip; | 834 | if (dmi_check_system(stk_upside_down_dmi_table)) |
835 | c->value = !dev->vsettings.hflip; | ||
836 | else | ||
837 | c->value = dev->vsettings.hflip; | ||
820 | break; | 838 | break; |
821 | case V4L2_CID_VFLIP: | 839 | case V4L2_CID_VFLIP: |
822 | c->value = dev->vsettings.vflip; | 840 | if (dmi_check_system(stk_upside_down_dmi_table)) |
841 | c->value = !dev->vsettings.vflip; | ||
842 | else | ||
843 | c->value = dev->vsettings.vflip; | ||
823 | break; | 844 | break; |
824 | default: | 845 | default: |
825 | return -EINVAL; | 846 | return -EINVAL; |
@@ -836,10 +857,16 @@ static int stk_vidioc_s_ctrl(struct file *filp, | |||
836 | dev->vsettings.brightness = c->value; | 857 | dev->vsettings.brightness = c->value; |
837 | return stk_sensor_set_brightness(dev, c->value >> 8); | 858 | return stk_sensor_set_brightness(dev, c->value >> 8); |
838 | case V4L2_CID_HFLIP: | 859 | case V4L2_CID_HFLIP: |
839 | dev->vsettings.hflip = c->value; | 860 | if (dmi_check_system(stk_upside_down_dmi_table)) |
861 | dev->vsettings.hflip = !c->value; | ||
862 | else | ||
863 | dev->vsettings.hflip = c->value; | ||
840 | return 0; | 864 | return 0; |
841 | case V4L2_CID_VFLIP: | 865 | case V4L2_CID_VFLIP: |
842 | dev->vsettings.vflip = c->value; | 866 | if (dmi_check_system(stk_upside_down_dmi_table)) |
867 | dev->vsettings.vflip = !c->value; | ||
868 | else | ||
869 | dev->vsettings.vflip = c->value; | ||
843 | return 0; | 870 | return 0; |
844 | default: | 871 | default: |
845 | return -EINVAL; | 872 | return -EINVAL; |
@@ -1113,7 +1140,7 @@ static int stk_vidioc_dqbuf(struct file *filp, | |||
1113 | sbuf->v4lbuf.flags &= ~V4L2_BUF_FLAG_QUEUED; | 1140 | sbuf->v4lbuf.flags &= ~V4L2_BUF_FLAG_QUEUED; |
1114 | sbuf->v4lbuf.flags |= V4L2_BUF_FLAG_DONE; | 1141 | sbuf->v4lbuf.flags |= V4L2_BUF_FLAG_DONE; |
1115 | sbuf->v4lbuf.sequence = ++dev->sequence; | 1142 | sbuf->v4lbuf.sequence = ++dev->sequence; |
1116 | do_gettimeofday(&sbuf->v4lbuf.timestamp); | 1143 | v4l2_get_timestamp(&sbuf->v4lbuf.timestamp); |
1117 | 1144 | ||
1118 | *buf = sbuf->v4lbuf; | 1145 | *buf = sbuf->v4lbuf; |
1119 | return 0; | 1146 | return 0; |
@@ -1275,8 +1302,18 @@ static int stk_camera_probe(struct usb_interface *interface, | |||
1275 | dev->interface = interface; | 1302 | dev->interface = interface; |
1276 | usb_get_intf(interface); | 1303 | usb_get_intf(interface); |
1277 | 1304 | ||
1278 | dev->vsettings.vflip = vflip; | 1305 | if (hflip != -1) |
1279 | dev->vsettings.hflip = hflip; | 1306 | dev->vsettings.hflip = hflip; |
1307 | else if (dmi_check_system(stk_upside_down_dmi_table)) | ||
1308 | dev->vsettings.hflip = 1; | ||
1309 | else | ||
1310 | dev->vsettings.hflip = 0; | ||
1311 | if (vflip != -1) | ||
1312 | dev->vsettings.vflip = vflip; | ||
1313 | else if (dmi_check_system(stk_upside_down_dmi_table)) | ||
1314 | dev->vsettings.vflip = 1; | ||
1315 | else | ||
1316 | dev->vsettings.vflip = 0; | ||
1280 | dev->n_sbufs = 0; | 1317 | dev->n_sbufs = 0; |
1281 | set_present(dev); | 1318 | set_present(dev); |
1282 | 1319 | ||
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c index 3082bfa9b2c5..21723378bb8f 100644 --- a/drivers/media/usb/tlg2300/pd-video.c +++ b/drivers/media/usb/tlg2300/pd-video.c | |||
@@ -212,7 +212,7 @@ static void submit_frame(struct front_face *front) | |||
212 | front->curr_frame = NULL; | 212 | front->curr_frame = NULL; |
213 | vb->state = VIDEOBUF_DONE; | 213 | vb->state = VIDEOBUF_DONE; |
214 | vb->field_count++; | 214 | vb->field_count++; |
215 | do_gettimeofday(&vb->ts); | 215 | v4l2_get_timestamp(&vb->ts); |
216 | 216 | ||
217 | wake_up(&vb->done); | 217 | wake_up(&vb->done); |
218 | } | 218 | } |
diff --git a/drivers/media/usb/tm6000/tm6000-core.c b/drivers/media/usb/tm6000/tm6000-core.c index 22cc0116deb6..7c32353c59db 100644 --- a/drivers/media/usb/tm6000/tm6000-core.c +++ b/drivers/media/usb/tm6000/tm6000-core.c | |||
@@ -40,10 +40,13 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req, | |||
40 | u8 *data = NULL; | 40 | u8 *data = NULL; |
41 | int delay = 5000; | 41 | int delay = 5000; |
42 | 42 | ||
43 | mutex_lock(&dev->usb_lock); | 43 | if (len) { |
44 | |||
45 | if (len) | ||
46 | data = kzalloc(len, GFP_KERNEL); | 44 | data = kzalloc(len, GFP_KERNEL); |
45 | if (!data) | ||
46 | return -ENOMEM; | ||
47 | } | ||
48 | |||
49 | mutex_lock(&dev->usb_lock); | ||
47 | 50 | ||
48 | if (req_type & USB_DIR_IN) | 51 | if (req_type & USB_DIR_IN) |
49 | pipe = usb_rcvctrlpipe(dev->udev, 0); | 52 | pipe = usb_rcvctrlpipe(dev->udev, 0); |
diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c index e1f3f66e1e63..9fc1e940a82b 100644 --- a/drivers/media/usb/tm6000/tm6000-dvb.c +++ b/drivers/media/usb/tm6000/tm6000-dvb.c | |||
@@ -360,8 +360,8 @@ dvb_dmx_err: | |||
360 | dvb_dmx_release(&dvb->demux); | 360 | dvb_dmx_release(&dvb->demux); |
361 | frontend_err: | 361 | frontend_err: |
362 | if (dvb->frontend) { | 362 | if (dvb->frontend) { |
363 | dvb_frontend_detach(dvb->frontend); | ||
364 | dvb_unregister_frontend(dvb->frontend); | 363 | dvb_unregister_frontend(dvb->frontend); |
364 | dvb_frontend_detach(dvb->frontend); | ||
365 | } | 365 | } |
366 | adapter_err: | 366 | adapter_err: |
367 | dvb_unregister_adapter(&dvb->adapter); | 367 | dvb_unregister_adapter(&dvb->adapter); |
@@ -384,8 +384,8 @@ static void unregister_dvb(struct tm6000_core *dev) | |||
384 | 384 | ||
385 | /* mutex_lock(&tm6000_driver.open_close_mutex); */ | 385 | /* mutex_lock(&tm6000_driver.open_close_mutex); */ |
386 | if (dvb->frontend) { | 386 | if (dvb->frontend) { |
387 | dvb_frontend_detach(dvb->frontend); | ||
388 | dvb_unregister_frontend(dvb->frontend); | 387 | dvb_unregister_frontend(dvb->frontend); |
388 | dvb_frontend_detach(dvb->frontend); | ||
389 | } | 389 | } |
390 | 390 | ||
391 | dvb_dmxdev_release(&dvb->dmxdev); | 391 | dvb_dmxdev_release(&dvb->dmxdev); |
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c index f656fd7a39a2..1a6857929c15 100644 --- a/drivers/media/usb/tm6000/tm6000-video.c +++ b/drivers/media/usb/tm6000/tm6000-video.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include <linux/videodev2.h> | 35 | #include <linux/videodev2.h> |
36 | #include <media/v4l2-ioctl.h> | 36 | #include <media/v4l2-ioctl.h> |
37 | #include <media/v4l2-event.h> | ||
37 | #include <media/tuner.h> | 38 | #include <media/tuner.h> |
38 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
39 | #include <linux/kthread.h> | 40 | #include <linux/kthread.h> |
@@ -49,82 +50,20 @@ | |||
49 | #define TM6000_MIN_BUF 4 | 50 | #define TM6000_MIN_BUF 4 |
50 | #define TM6000_DEF_BUF 8 | 51 | #define TM6000_DEF_BUF 8 |
51 | 52 | ||
53 | #define TM6000_NUM_URB_BUF 8 | ||
54 | |||
52 | #define TM6000_MAX_ISO_PACKETS 46 /* Max number of ISO packets */ | 55 | #define TM6000_MAX_ISO_PACKETS 46 /* Max number of ISO packets */ |
53 | 56 | ||
54 | /* Declare static vars that will be used as parameters */ | 57 | /* Declare static vars that will be used as parameters */ |
55 | static unsigned int vid_limit = 16; /* Video memory limit, in Mb */ | 58 | static unsigned int vid_limit = 16; /* Video memory limit, in Mb */ |
56 | static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ | 59 | static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ |
57 | static int radio_nr = -1; /* /dev/radioN, -1 for autodetect */ | 60 | static int radio_nr = -1; /* /dev/radioN, -1 for autodetect */ |
61 | static bool keep_urb; /* keep urb buffers allocated */ | ||
58 | 62 | ||
59 | /* Debug level */ | 63 | /* Debug level */ |
60 | int tm6000_debug; | 64 | int tm6000_debug; |
61 | EXPORT_SYMBOL_GPL(tm6000_debug); | 65 | EXPORT_SYMBOL_GPL(tm6000_debug); |
62 | 66 | ||
63 | static const struct v4l2_queryctrl no_ctrl = { | ||
64 | .name = "42", | ||
65 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
66 | }; | ||
67 | |||
68 | /* supported controls */ | ||
69 | static struct v4l2_queryctrl tm6000_qctrl[] = { | ||
70 | { | ||
71 | .id = V4L2_CID_BRIGHTNESS, | ||
72 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
73 | .name = "Brightness", | ||
74 | .minimum = 0, | ||
75 | .maximum = 255, | ||
76 | .step = 1, | ||
77 | .default_value = 54, | ||
78 | .flags = 0, | ||
79 | }, { | ||
80 | .id = V4L2_CID_CONTRAST, | ||
81 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
82 | .name = "Contrast", | ||
83 | .minimum = 0, | ||
84 | .maximum = 255, | ||
85 | .step = 0x1, | ||
86 | .default_value = 119, | ||
87 | .flags = 0, | ||
88 | }, { | ||
89 | .id = V4L2_CID_SATURATION, | ||
90 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
91 | .name = "Saturation", | ||
92 | .minimum = 0, | ||
93 | .maximum = 255, | ||
94 | .step = 0x1, | ||
95 | .default_value = 112, | ||
96 | .flags = 0, | ||
97 | }, { | ||
98 | .id = V4L2_CID_HUE, | ||
99 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
100 | .name = "Hue", | ||
101 | .minimum = -128, | ||
102 | .maximum = 127, | ||
103 | .step = 0x1, | ||
104 | .default_value = 0, | ||
105 | .flags = 0, | ||
106 | }, | ||
107 | /* --- audio --- */ | ||
108 | { | ||
109 | .id = V4L2_CID_AUDIO_MUTE, | ||
110 | .name = "Mute", | ||
111 | .minimum = 0, | ||
112 | .maximum = 1, | ||
113 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
114 | }, { | ||
115 | .id = V4L2_CID_AUDIO_VOLUME, | ||
116 | .name = "Volume", | ||
117 | .minimum = -15, | ||
118 | .maximum = 15, | ||
119 | .step = 1, | ||
120 | .default_value = 0, | ||
121 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
122 | } | ||
123 | }; | ||
124 | |||
125 | static const unsigned int CTRLS = ARRAY_SIZE(tm6000_qctrl); | ||
126 | static int qctl_regs[ARRAY_SIZE(tm6000_qctrl)]; | ||
127 | |||
128 | static struct tm6000_fmt format[] = { | 67 | static struct tm6000_fmt format[] = { |
129 | { | 68 | { |
130 | .name = "4:2:2, packed, YVY2", | 69 | .name = "4:2:2, packed, YVY2", |
@@ -141,16 +80,6 @@ static struct tm6000_fmt format[] = { | |||
141 | } | 80 | } |
142 | }; | 81 | }; |
143 | 82 | ||
144 | static const struct v4l2_queryctrl *ctrl_by_id(unsigned int id) | ||
145 | { | ||
146 | unsigned int i; | ||
147 | |||
148 | for (i = 0; i < CTRLS; i++) | ||
149 | if (tm6000_qctrl[i].id == id) | ||
150 | return tm6000_qctrl+i; | ||
151 | return NULL; | ||
152 | } | ||
153 | |||
154 | /* ------------------------------------------------------------------ | 83 | /* ------------------------------------------------------------------ |
155 | * DMA and thread functions | 84 | * DMA and thread functions |
156 | * ------------------------------------------------------------------ | 85 | * ------------------------------------------------------------------ |
@@ -191,7 +120,7 @@ static inline void buffer_filled(struct tm6000_core *dev, | |||
191 | dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n", buf, buf->vb.i); | 120 | dprintk(dev, V4L2_DEBUG_ISOC, "[%p/%d] wakeup\n", buf, buf->vb.i); |
192 | buf->vb.state = VIDEOBUF_DONE; | 121 | buf->vb.state = VIDEOBUF_DONE; |
193 | buf->vb.field_count++; | 122 | buf->vb.field_count++; |
194 | do_gettimeofday(&buf->vb.ts); | 123 | v4l2_get_timestamp(&buf->vb.ts); |
195 | 124 | ||
196 | list_del(&buf->vb.queue); | 125 | list_del(&buf->vb.queue); |
197 | wake_up(&buf->vb.done); | 126 | wake_up(&buf->vb.done); |
@@ -538,6 +467,71 @@ static void tm6000_irq_callback(struct urb *urb) | |||
538 | } | 467 | } |
539 | 468 | ||
540 | /* | 469 | /* |
470 | * Allocate URB buffers | ||
471 | */ | ||
472 | static int tm6000_alloc_urb_buffers(struct tm6000_core *dev) | ||
473 | { | ||
474 | int num_bufs = TM6000_NUM_URB_BUF; | ||
475 | int i; | ||
476 | |||
477 | if (dev->urb_buffer != NULL) | ||
478 | return 0; | ||
479 | |||
480 | dev->urb_buffer = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | ||
481 | if (!dev->urb_buffer) { | ||
482 | tm6000_err("cannot allocate memory for urb buffers\n"); | ||
483 | return -ENOMEM; | ||
484 | } | ||
485 | |||
486 | dev->urb_dma = kmalloc(sizeof(dma_addr_t *)*num_bufs, GFP_KERNEL); | ||
487 | if (!dev->urb_dma) { | ||
488 | tm6000_err("cannot allocate memory for urb dma pointers\n"); | ||
489 | return -ENOMEM; | ||
490 | } | ||
491 | |||
492 | for (i = 0; i < num_bufs; i++) { | ||
493 | dev->urb_buffer[i] = usb_alloc_coherent( | ||
494 | dev->udev, dev->urb_size, | ||
495 | GFP_KERNEL, &dev->urb_dma[i]); | ||
496 | if (!dev->urb_buffer[i]) { | ||
497 | tm6000_err("unable to allocate %i bytes for transfer buffer %i\n", | ||
498 | dev->urb_size, i); | ||
499 | return -ENOMEM; | ||
500 | } | ||
501 | memset(dev->urb_buffer[i], 0, dev->urb_size); | ||
502 | } | ||
503 | |||
504 | return 0; | ||
505 | } | ||
506 | |||
507 | /* | ||
508 | * Free URB buffers | ||
509 | */ | ||
510 | static int tm6000_free_urb_buffers(struct tm6000_core *dev) | ||
511 | { | ||
512 | int i; | ||
513 | |||
514 | if (dev->urb_buffer == NULL) | ||
515 | return 0; | ||
516 | |||
517 | for (i = 0; i < TM6000_NUM_URB_BUF; i++) { | ||
518 | if (dev->urb_buffer[i]) { | ||
519 | usb_free_coherent(dev->udev, | ||
520 | dev->urb_size, | ||
521 | dev->urb_buffer[i], | ||
522 | dev->urb_dma[i]); | ||
523 | dev->urb_buffer[i] = NULL; | ||
524 | } | ||
525 | } | ||
526 | kfree(dev->urb_buffer); | ||
527 | kfree(dev->urb_dma); | ||
528 | dev->urb_buffer = NULL; | ||
529 | dev->urb_dma = NULL; | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | /* | ||
541 | * Stop and Deallocate URBs | 535 | * Stop and Deallocate URBs |
542 | */ | 536 | */ |
543 | static void tm6000_uninit_isoc(struct tm6000_core *dev) | 537 | static void tm6000_uninit_isoc(struct tm6000_core *dev) |
@@ -551,18 +545,15 @@ static void tm6000_uninit_isoc(struct tm6000_core *dev) | |||
551 | if (urb) { | 545 | if (urb) { |
552 | usb_kill_urb(urb); | 546 | usb_kill_urb(urb); |
553 | usb_unlink_urb(urb); | 547 | usb_unlink_urb(urb); |
554 | if (dev->isoc_ctl.transfer_buffer[i]) { | ||
555 | usb_free_coherent(dev->udev, | ||
556 | urb->transfer_buffer_length, | ||
557 | dev->isoc_ctl.transfer_buffer[i], | ||
558 | urb->transfer_dma); | ||
559 | } | ||
560 | usb_free_urb(urb); | 548 | usb_free_urb(urb); |
561 | dev->isoc_ctl.urb[i] = NULL; | 549 | dev->isoc_ctl.urb[i] = NULL; |
562 | } | 550 | } |
563 | dev->isoc_ctl.transfer_buffer[i] = NULL; | 551 | dev->isoc_ctl.transfer_buffer[i] = NULL; |
564 | } | 552 | } |
565 | 553 | ||
554 | if (!keep_urb) | ||
555 | tm6000_free_urb_buffers(dev); | ||
556 | |||
566 | kfree(dev->isoc_ctl.urb); | 557 | kfree(dev->isoc_ctl.urb); |
567 | kfree(dev->isoc_ctl.transfer_buffer); | 558 | kfree(dev->isoc_ctl.transfer_buffer); |
568 | 559 | ||
@@ -572,12 +563,13 @@ static void tm6000_uninit_isoc(struct tm6000_core *dev) | |||
572 | } | 563 | } |
573 | 564 | ||
574 | /* | 565 | /* |
575 | * Allocate URBs and start IRQ | 566 | * Assign URBs and start IRQ |
576 | */ | 567 | */ |
577 | static int tm6000_prepare_isoc(struct tm6000_core *dev) | 568 | static int tm6000_prepare_isoc(struct tm6000_core *dev) |
578 | { | 569 | { |
579 | struct tm6000_dmaqueue *dma_q = &dev->vidq; | 570 | struct tm6000_dmaqueue *dma_q = &dev->vidq; |
580 | int i, j, sb_size, pipe, size, max_packets, num_bufs = 8; | 571 | int i, j, sb_size, pipe, size, max_packets; |
572 | int num_bufs = TM6000_NUM_URB_BUF; | ||
581 | struct urb *urb; | 573 | struct urb *urb; |
582 | 574 | ||
583 | /* De-allocates all pending stuff */ | 575 | /* De-allocates all pending stuff */ |
@@ -605,6 +597,7 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) | |||
605 | 597 | ||
606 | max_packets = TM6000_MAX_ISO_PACKETS; | 598 | max_packets = TM6000_MAX_ISO_PACKETS; |
607 | sb_size = max_packets * size; | 599 | sb_size = max_packets * size; |
600 | dev->urb_size = sb_size; | ||
608 | 601 | ||
609 | dev->isoc_ctl.num_bufs = num_bufs; | 602 | dev->isoc_ctl.num_bufs = num_bufs; |
610 | 603 | ||
@@ -627,6 +620,17 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) | |||
627 | max_packets, num_bufs, sb_size, | 620 | max_packets, num_bufs, sb_size, |
628 | dev->isoc_in.maxsize, size); | 621 | dev->isoc_in.maxsize, size); |
629 | 622 | ||
623 | |||
624 | if (!dev->urb_buffer && tm6000_alloc_urb_buffers(dev) < 0) { | ||
625 | tm6000_err("cannot allocate memory for urb buffers\n"); | ||
626 | |||
627 | /* call free, as some buffers might have been allocated */ | ||
628 | tm6000_free_urb_buffers(dev); | ||
629 | kfree(dev->isoc_ctl.urb); | ||
630 | kfree(dev->isoc_ctl.transfer_buffer); | ||
631 | return -ENOMEM; | ||
632 | } | ||
633 | |||
630 | /* allocate urbs and transfer buffers */ | 634 | /* allocate urbs and transfer buffers */ |
631 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { | 635 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { |
632 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); | 636 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); |
@@ -638,17 +642,8 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) | |||
638 | } | 642 | } |
639 | dev->isoc_ctl.urb[i] = urb; | 643 | dev->isoc_ctl.urb[i] = urb; |
640 | 644 | ||
641 | dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->udev, | 645 | urb->transfer_dma = dev->urb_dma[i]; |
642 | sb_size, GFP_KERNEL, &urb->transfer_dma); | 646 | dev->isoc_ctl.transfer_buffer[i] = dev->urb_buffer[i]; |
643 | if (!dev->isoc_ctl.transfer_buffer[i]) { | ||
644 | tm6000_err("unable to allocate %i bytes for transfer" | ||
645 | " buffer %i%s\n", | ||
646 | sb_size, i, | ||
647 | in_interrupt() ? " while in int" : ""); | ||
648 | tm6000_uninit_isoc(dev); | ||
649 | return -ENOMEM; | ||
650 | } | ||
651 | memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size); | ||
652 | 647 | ||
653 | usb_fill_bulk_urb(urb, dev->udev, pipe, | 648 | usb_fill_bulk_urb(urb, dev->udev, pipe, |
654 | dev->isoc_ctl.transfer_buffer[i], sb_size, | 649 | dev->isoc_ctl.transfer_buffer[i], sb_size, |
@@ -879,16 +874,21 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
879 | struct v4l2_capability *cap) | 874 | struct v4l2_capability *cap) |
880 | { | 875 | { |
881 | struct tm6000_core *dev = ((struct tm6000_fh *)priv)->dev; | 876 | struct tm6000_core *dev = ((struct tm6000_fh *)priv)->dev; |
877 | struct video_device *vdev = video_devdata(file); | ||
882 | 878 | ||
883 | strlcpy(cap->driver, "tm6000", sizeof(cap->driver)); | 879 | strlcpy(cap->driver, "tm6000", sizeof(cap->driver)); |
884 | strlcpy(cap->card, "Trident TVMaster TM5600/6000/6010", sizeof(cap->card)); | 880 | strlcpy(cap->card, "Trident TVMaster TM5600/6000/6010", sizeof(cap->card)); |
885 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | 881 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); |
886 | V4L2_CAP_STREAMING | | ||
887 | V4L2_CAP_AUDIO | | ||
888 | V4L2_CAP_READWRITE; | ||
889 | |||
890 | if (dev->tuner_type != TUNER_ABSENT) | 882 | if (dev->tuner_type != TUNER_ABSENT) |
891 | cap->capabilities |= V4L2_CAP_TUNER; | 883 | cap->device_caps |= V4L2_CAP_TUNER; |
884 | if (vdev->vfl_type == VFL_TYPE_GRABBER) | ||
885 | cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE | | ||
886 | V4L2_CAP_STREAMING | | ||
887 | V4L2_CAP_READWRITE; | ||
888 | else | ||
889 | cap->device_caps |= V4L2_CAP_RADIO; | ||
890 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS | | ||
891 | V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; | ||
892 | 892 | ||
893 | return 0; | 893 | return 0; |
894 | } | 894 | } |
@@ -896,7 +896,7 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
896 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | 896 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
897 | struct v4l2_fmtdesc *f) | 897 | struct v4l2_fmtdesc *f) |
898 | { | 898 | { |
899 | if (unlikely(f->index >= ARRAY_SIZE(format))) | 899 | if (f->index >= ARRAY_SIZE(format)) |
900 | return -EINVAL; | 900 | return -EINVAL; |
901 | 901 | ||
902 | strlcpy(f->description, format[f->index].name, sizeof(f->description)); | 902 | strlcpy(f->description, format[f->index].name, sizeof(f->description)); |
@@ -913,10 +913,12 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
913 | f->fmt.pix.height = fh->height; | 913 | f->fmt.pix.height = fh->height; |
914 | f->fmt.pix.field = fh->vb_vidq.field; | 914 | f->fmt.pix.field = fh->vb_vidq.field; |
915 | f->fmt.pix.pixelformat = fh->fmt->fourcc; | 915 | f->fmt.pix.pixelformat = fh->fmt->fourcc; |
916 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
916 | f->fmt.pix.bytesperline = | 917 | f->fmt.pix.bytesperline = |
917 | (f->fmt.pix.width * fh->fmt->depth) >> 3; | 918 | (f->fmt.pix.width * fh->fmt->depth) >> 3; |
918 | f->fmt.pix.sizeimage = | 919 | f->fmt.pix.sizeimage = |
919 | f->fmt.pix.height * f->fmt.pix.bytesperline; | 920 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
921 | f->fmt.pix.priv = 0; | ||
920 | 922 | ||
921 | return 0; | 923 | return 0; |
922 | } | 924 | } |
@@ -947,12 +949,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
947 | 949 | ||
948 | field = f->fmt.pix.field; | 950 | field = f->fmt.pix.field; |
949 | 951 | ||
950 | if (field == V4L2_FIELD_ANY) | 952 | field = V4L2_FIELD_INTERLACED; |
951 | field = V4L2_FIELD_SEQ_TB; | ||
952 | else if (V4L2_FIELD_INTERLACED != field) { | ||
953 | dprintk(dev, V4L2_DEBUG_IOCTL_ARG, "Field type invalid.\n"); | ||
954 | return -EINVAL; | ||
955 | } | ||
956 | 953 | ||
957 | tm6000_get_std_res(dev); | 954 | tm6000_get_std_res(dev); |
958 | 955 | ||
@@ -962,11 +959,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
962 | f->fmt.pix.width &= ~0x01; | 959 | f->fmt.pix.width &= ~0x01; |
963 | 960 | ||
964 | f->fmt.pix.field = field; | 961 | f->fmt.pix.field = field; |
962 | f->fmt.pix.priv = 0; | ||
965 | 963 | ||
966 | f->fmt.pix.bytesperline = | 964 | f->fmt.pix.bytesperline = |
967 | (f->fmt.pix.width * fmt->depth) >> 3; | 965 | (f->fmt.pix.width * fmt->depth) >> 3; |
968 | f->fmt.pix.sizeimage = | 966 | f->fmt.pix.sizeimage = |
969 | f->fmt.pix.height * f->fmt.pix.bytesperline; | 967 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
968 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
970 | 969 | ||
971 | return 0; | 970 | return 0; |
972 | } | 971 | } |
@@ -1141,79 +1140,40 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
1141 | } | 1140 | } |
1142 | 1141 | ||
1143 | /* --- controls ---------------------------------------------- */ | 1142 | /* --- controls ---------------------------------------------- */ |
1144 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
1145 | struct v4l2_queryctrl *qc) | ||
1146 | { | ||
1147 | int i; | ||
1148 | |||
1149 | for (i = 0; i < ARRAY_SIZE(tm6000_qctrl); i++) | ||
1150 | if (qc->id && qc->id == tm6000_qctrl[i].id) { | ||
1151 | memcpy(qc, &(tm6000_qctrl[i]), | ||
1152 | sizeof(*qc)); | ||
1153 | return 0; | ||
1154 | } | ||
1155 | 1143 | ||
1156 | return -EINVAL; | 1144 | static int tm6000_s_ctrl(struct v4l2_ctrl *ctrl) |
1157 | } | ||
1158 | |||
1159 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
1160 | struct v4l2_control *ctrl) | ||
1161 | { | 1145 | { |
1162 | struct tm6000_fh *fh = priv; | 1146 | struct tm6000_core *dev = container_of(ctrl->handler, struct tm6000_core, ctrl_handler); |
1163 | struct tm6000_core *dev = fh->dev; | 1147 | u8 val = ctrl->val; |
1164 | int val; | ||
1165 | 1148 | ||
1166 | /* FIXME: Probably, those won't work! Maybe we need shadow regs */ | ||
1167 | switch (ctrl->id) { | 1149 | switch (ctrl->id) { |
1168 | case V4L2_CID_CONTRAST: | 1150 | case V4L2_CID_CONTRAST: |
1169 | val = tm6000_get_reg(dev, TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, 0); | 1151 | tm6000_set_reg(dev, TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, val); |
1170 | break; | 1152 | return 0; |
1171 | case V4L2_CID_BRIGHTNESS: | 1153 | case V4L2_CID_BRIGHTNESS: |
1172 | val = tm6000_get_reg(dev, TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, 0); | 1154 | tm6000_set_reg(dev, TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, val); |
1173 | return 0; | 1155 | return 0; |
1174 | case V4L2_CID_SATURATION: | 1156 | case V4L2_CID_SATURATION: |
1175 | val = tm6000_get_reg(dev, TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, 0); | 1157 | tm6000_set_reg(dev, TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, val); |
1176 | return 0; | 1158 | return 0; |
1177 | case V4L2_CID_HUE: | 1159 | case V4L2_CID_HUE: |
1178 | val = tm6000_get_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, 0); | 1160 | tm6000_set_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, val); |
1179 | return 0; | ||
1180 | case V4L2_CID_AUDIO_MUTE: | ||
1181 | val = dev->ctl_mute; | ||
1182 | return 0; | ||
1183 | case V4L2_CID_AUDIO_VOLUME: | ||
1184 | val = dev->ctl_volume; | ||
1185 | return 0; | 1161 | return 0; |
1186 | default: | ||
1187 | return -EINVAL; | ||
1188 | } | 1162 | } |
1163 | return -EINVAL; | ||
1164 | } | ||
1189 | 1165 | ||
1190 | if (val < 0) | 1166 | static const struct v4l2_ctrl_ops tm6000_ctrl_ops = { |
1191 | return val; | 1167 | .s_ctrl = tm6000_s_ctrl, |
1192 | 1168 | }; | |
1193 | ctrl->value = val; | ||
1194 | 1169 | ||
1195 | return 0; | 1170 | static int tm6000_radio_s_ctrl(struct v4l2_ctrl *ctrl) |
1196 | } | ||
1197 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
1198 | struct v4l2_control *ctrl) | ||
1199 | { | 1171 | { |
1200 | struct tm6000_fh *fh = priv; | 1172 | struct tm6000_core *dev = container_of(ctrl->handler, |
1201 | struct tm6000_core *dev = fh->dev; | 1173 | struct tm6000_core, radio_ctrl_handler); |
1202 | u8 val = ctrl->value; | 1174 | u8 val = ctrl->val; |
1203 | 1175 | ||
1204 | switch (ctrl->id) { | 1176 | switch (ctrl->id) { |
1205 | case V4L2_CID_CONTRAST: | ||
1206 | tm6000_set_reg(dev, TM6010_REQ07_R08_LUMA_CONTRAST_ADJ, val); | ||
1207 | return 0; | ||
1208 | case V4L2_CID_BRIGHTNESS: | ||
1209 | tm6000_set_reg(dev, TM6010_REQ07_R09_LUMA_BRIGHTNESS_ADJ, val); | ||
1210 | return 0; | ||
1211 | case V4L2_CID_SATURATION: | ||
1212 | tm6000_set_reg(dev, TM6010_REQ07_R0A_CHROMA_SATURATION_ADJ, val); | ||
1213 | return 0; | ||
1214 | case V4L2_CID_HUE: | ||
1215 | tm6000_set_reg(dev, TM6010_REQ07_R0B_CHROMA_HUE_PHASE_ADJ, val); | ||
1216 | return 0; | ||
1217 | case V4L2_CID_AUDIO_MUTE: | 1177 | case V4L2_CID_AUDIO_MUTE: |
1218 | dev->ctl_mute = val; | 1178 | dev->ctl_mute = val; |
1219 | tm6000_tvaudio_set_mute(dev, val); | 1179 | tm6000_tvaudio_set_mute(dev, val); |
@@ -1226,20 +1186,24 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1226 | return -EINVAL; | 1186 | return -EINVAL; |
1227 | } | 1187 | } |
1228 | 1188 | ||
1189 | static const struct v4l2_ctrl_ops tm6000_radio_ctrl_ops = { | ||
1190 | .s_ctrl = tm6000_radio_s_ctrl, | ||
1191 | }; | ||
1192 | |||
1229 | static int vidioc_g_tuner(struct file *file, void *priv, | 1193 | static int vidioc_g_tuner(struct file *file, void *priv, |
1230 | struct v4l2_tuner *t) | 1194 | struct v4l2_tuner *t) |
1231 | { | 1195 | { |
1232 | struct tm6000_fh *fh = priv; | 1196 | struct tm6000_fh *fh = priv; |
1233 | struct tm6000_core *dev = fh->dev; | 1197 | struct tm6000_core *dev = fh->dev; |
1234 | 1198 | ||
1235 | if (unlikely(UNSET == dev->tuner_type)) | 1199 | if (UNSET == dev->tuner_type) |
1236 | return -EINVAL; | 1200 | return -ENOTTY; |
1237 | if (0 != t->index) | 1201 | if (0 != t->index) |
1238 | return -EINVAL; | 1202 | return -EINVAL; |
1239 | 1203 | ||
1240 | strcpy(t->name, "Television"); | 1204 | strcpy(t->name, "Television"); |
1241 | t->type = V4L2_TUNER_ANALOG_TV; | 1205 | t->type = V4L2_TUNER_ANALOG_TV; |
1242 | t->capability = V4L2_TUNER_CAP_NORM; | 1206 | t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO; |
1243 | t->rangehigh = 0xffffffffUL; | 1207 | t->rangehigh = 0xffffffffUL; |
1244 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; | 1208 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; |
1245 | 1209 | ||
@@ -1257,11 +1221,14 @@ static int vidioc_s_tuner(struct file *file, void *priv, | |||
1257 | struct tm6000_core *dev = fh->dev; | 1221 | struct tm6000_core *dev = fh->dev; |
1258 | 1222 | ||
1259 | if (UNSET == dev->tuner_type) | 1223 | if (UNSET == dev->tuner_type) |
1260 | return -EINVAL; | 1224 | return -ENOTTY; |
1261 | if (0 != t->index) | 1225 | if (0 != t->index) |
1262 | return -EINVAL; | 1226 | return -EINVAL; |
1263 | 1227 | ||
1264 | dev->amode = t->audmode; | 1228 | if (t->audmode > V4L2_TUNER_MODE_STEREO) |
1229 | dev->amode = V4L2_TUNER_MODE_STEREO; | ||
1230 | else | ||
1231 | dev->amode = t->audmode; | ||
1265 | dprintk(dev, 3, "audio mode: %x\n", t->audmode); | 1232 | dprintk(dev, 3, "audio mode: %x\n", t->audmode); |
1266 | 1233 | ||
1267 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); | 1234 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); |
@@ -1275,10 +1242,11 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
1275 | struct tm6000_fh *fh = priv; | 1242 | struct tm6000_fh *fh = priv; |
1276 | struct tm6000_core *dev = fh->dev; | 1243 | struct tm6000_core *dev = fh->dev; |
1277 | 1244 | ||
1278 | if (unlikely(UNSET == dev->tuner_type)) | 1245 | if (UNSET == dev->tuner_type) |
1246 | return -ENOTTY; | ||
1247 | if (f->tuner) | ||
1279 | return -EINVAL; | 1248 | return -EINVAL; |
1280 | 1249 | ||
1281 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1282 | f->frequency = dev->freq; | 1250 | f->frequency = dev->freq; |
1283 | 1251 | ||
1284 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f); | 1252 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f); |
@@ -1292,13 +1260,9 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1292 | struct tm6000_fh *fh = priv; | 1260 | struct tm6000_fh *fh = priv; |
1293 | struct tm6000_core *dev = fh->dev; | 1261 | struct tm6000_core *dev = fh->dev; |
1294 | 1262 | ||
1295 | if (unlikely(UNSET == dev->tuner_type)) | 1263 | if (UNSET == dev->tuner_type) |
1296 | return -EINVAL; | 1264 | return -ENOTTY; |
1297 | if (unlikely(f->tuner != 0)) | 1265 | if (f->tuner != 0) |
1298 | return -EINVAL; | ||
1299 | if (0 == fh->radio && V4L2_TUNER_ANALOG_TV != f->type) | ||
1300 | return -EINVAL; | ||
1301 | if (1 == fh->radio && V4L2_TUNER_RADIO != f->type) | ||
1302 | return -EINVAL; | 1266 | return -EINVAL; |
1303 | 1267 | ||
1304 | dev->freq = f->frequency; | 1268 | dev->freq = f->frequency; |
@@ -1307,27 +1271,6 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
1307 | return 0; | 1271 | return 0; |
1308 | } | 1272 | } |
1309 | 1273 | ||
1310 | static int radio_querycap(struct file *file, void *priv, | ||
1311 | struct v4l2_capability *cap) | ||
1312 | { | ||
1313 | struct tm6000_fh *fh = file->private_data; | ||
1314 | struct tm6000_core *dev = fh->dev; | ||
1315 | |||
1316 | strcpy(cap->driver, "tm6000"); | ||
1317 | strlcpy(cap->card, dev->name, sizeof(dev->name)); | ||
1318 | sprintf(cap->bus_info, "USB%04x:%04x", | ||
1319 | le16_to_cpu(dev->udev->descriptor.idVendor), | ||
1320 | le16_to_cpu(dev->udev->descriptor.idProduct)); | ||
1321 | cap->version = dev->dev_type; | ||
1322 | cap->capabilities = V4L2_CAP_TUNER | | ||
1323 | V4L2_CAP_AUDIO | | ||
1324 | V4L2_CAP_RADIO | | ||
1325 | V4L2_CAP_READWRITE | | ||
1326 | V4L2_CAP_STREAMING; | ||
1327 | |||
1328 | return 0; | ||
1329 | } | ||
1330 | |||
1331 | static int radio_g_tuner(struct file *file, void *priv, | 1274 | static int radio_g_tuner(struct file *file, void *priv, |
1332 | struct v4l2_tuner *t) | 1275 | struct v4l2_tuner *t) |
1333 | { | 1276 | { |
@@ -1340,7 +1283,9 @@ static int radio_g_tuner(struct file *file, void *priv, | |||
1340 | memset(t, 0, sizeof(*t)); | 1283 | memset(t, 0, sizeof(*t)); |
1341 | strcpy(t->name, "Radio"); | 1284 | strcpy(t->name, "Radio"); |
1342 | t->type = V4L2_TUNER_RADIO; | 1285 | t->type = V4L2_TUNER_RADIO; |
1286 | t->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | ||
1343 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; | 1287 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; |
1288 | t->audmode = V4L2_TUNER_MODE_STEREO; | ||
1344 | 1289 | ||
1345 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); | 1290 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); |
1346 | 1291 | ||
@@ -1355,95 +1300,14 @@ static int radio_s_tuner(struct file *file, void *priv, | |||
1355 | 1300 | ||
1356 | if (0 != t->index) | 1301 | if (0 != t->index) |
1357 | return -EINVAL; | 1302 | return -EINVAL; |
1303 | if (t->audmode > V4L2_TUNER_MODE_STEREO) | ||
1304 | t->audmode = V4L2_TUNER_MODE_STEREO; | ||
1358 | 1305 | ||
1359 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); | 1306 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); |
1360 | 1307 | ||
1361 | return 0; | 1308 | return 0; |
1362 | } | 1309 | } |
1363 | 1310 | ||
1364 | static int radio_enum_input(struct file *file, void *priv, | ||
1365 | struct v4l2_input *i) | ||
1366 | { | ||
1367 | struct tm6000_fh *fh = priv; | ||
1368 | struct tm6000_core *dev = fh->dev; | ||
1369 | |||
1370 | if (i->index != 0) | ||
1371 | return -EINVAL; | ||
1372 | |||
1373 | if (!dev->rinput.type) | ||
1374 | return -EINVAL; | ||
1375 | |||
1376 | strcpy(i->name, "Radio"); | ||
1377 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1378 | |||
1379 | return 0; | ||
1380 | } | ||
1381 | |||
1382 | static int radio_g_input(struct file *filp, void *priv, unsigned int *i) | ||
1383 | { | ||
1384 | struct tm6000_fh *fh = priv; | ||
1385 | struct tm6000_core *dev = fh->dev; | ||
1386 | |||
1387 | if (dev->input != 5) | ||
1388 | return -EINVAL; | ||
1389 | |||
1390 | *i = dev->input - 5; | ||
1391 | |||
1392 | return 0; | ||
1393 | } | ||
1394 | |||
1395 | static int radio_g_audio(struct file *file, void *priv, | ||
1396 | struct v4l2_audio *a) | ||
1397 | { | ||
1398 | memset(a, 0, sizeof(*a)); | ||
1399 | strcpy(a->name, "Radio"); | ||
1400 | return 0; | ||
1401 | } | ||
1402 | |||
1403 | static int radio_s_audio(struct file *file, void *priv, | ||
1404 | const struct v4l2_audio *a) | ||
1405 | { | ||
1406 | return 0; | ||
1407 | } | ||
1408 | |||
1409 | static int radio_s_input(struct file *filp, void *priv, unsigned int i) | ||
1410 | { | ||
1411 | struct tm6000_fh *fh = priv; | ||
1412 | struct tm6000_core *dev = fh->dev; | ||
1413 | |||
1414 | if (i) | ||
1415 | return -EINVAL; | ||
1416 | |||
1417 | if (!dev->rinput.type) | ||
1418 | return -EINVAL; | ||
1419 | |||
1420 | dev->input = i + 5; | ||
1421 | |||
1422 | return 0; | ||
1423 | } | ||
1424 | |||
1425 | static int radio_s_std(struct file *file, void *fh, v4l2_std_id *norm) | ||
1426 | { | ||
1427 | return 0; | ||
1428 | } | ||
1429 | |||
1430 | static int radio_queryctrl(struct file *file, void *priv, | ||
1431 | struct v4l2_queryctrl *c) | ||
1432 | { | ||
1433 | const struct v4l2_queryctrl *ctrl; | ||
1434 | |||
1435 | if (c->id < V4L2_CID_BASE || | ||
1436 | c->id >= V4L2_CID_LASTP1) | ||
1437 | return -EINVAL; | ||
1438 | if (c->id == V4L2_CID_AUDIO_MUTE) { | ||
1439 | ctrl = ctrl_by_id(c->id); | ||
1440 | *c = *ctrl; | ||
1441 | } else | ||
1442 | *c = no_ctrl; | ||
1443 | |||
1444 | return 0; | ||
1445 | } | ||
1446 | |||
1447 | /* ------------------------------------------------------------------ | 1311 | /* ------------------------------------------------------------------ |
1448 | File operations for the device | 1312 | File operations for the device |
1449 | ------------------------------------------------------------------*/ | 1313 | ------------------------------------------------------------------*/ |
@@ -1454,7 +1318,7 @@ static int __tm6000_open(struct file *file) | |||
1454 | struct tm6000_core *dev = video_drvdata(file); | 1318 | struct tm6000_core *dev = video_drvdata(file); |
1455 | struct tm6000_fh *fh; | 1319 | struct tm6000_fh *fh; |
1456 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1320 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1457 | int i, rc; | 1321 | int rc; |
1458 | int radio = 0; | 1322 | int radio = 0; |
1459 | 1323 | ||
1460 | dprintk(dev, V4L2_DEBUG_OPEN, "tm6000: open called (dev=%s)\n", | 1324 | dprintk(dev, V4L2_DEBUG_OPEN, "tm6000: open called (dev=%s)\n", |
@@ -1486,6 +1350,7 @@ static int __tm6000_open(struct file *file) | |||
1486 | return -ENOMEM; | 1350 | return -ENOMEM; |
1487 | } | 1351 | } |
1488 | 1352 | ||
1353 | v4l2_fh_init(&fh->fh, vdev); | ||
1489 | file->private_data = fh; | 1354 | file->private_data = fh; |
1490 | fh->dev = dev; | 1355 | fh->dev = dev; |
1491 | fh->radio = radio; | 1356 | fh->radio = radio; |
@@ -1514,13 +1379,7 @@ static int __tm6000_open(struct file *file) | |||
1514 | if (rc < 0) | 1379 | if (rc < 0) |
1515 | return rc; | 1380 | return rc; |
1516 | 1381 | ||
1517 | if (dev->mode != TM6000_MODE_ANALOG) { | 1382 | dev->mode = TM6000_MODE_ANALOG; |
1518 | /* Put all controls at a sane state */ | ||
1519 | for (i = 0; i < ARRAY_SIZE(tm6000_qctrl); i++) | ||
1520 | qctl_regs[i] = tm6000_qctrl[i].default_value; | ||
1521 | |||
1522 | dev->mode = TM6000_MODE_ANALOG; | ||
1523 | } | ||
1524 | 1383 | ||
1525 | if (!fh->radio) { | 1384 | if (!fh->radio) { |
1526 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &tm6000_video_qops, | 1385 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &tm6000_video_qops, |
@@ -1530,12 +1389,12 @@ static int __tm6000_open(struct file *file) | |||
1530 | sizeof(struct tm6000_buffer), fh, &dev->lock); | 1389 | sizeof(struct tm6000_buffer), fh, &dev->lock); |
1531 | } else { | 1390 | } else { |
1532 | dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n"); | 1391 | dprintk(dev, V4L2_DEBUG_OPEN, "video_open: setting radio device\n"); |
1533 | dev->input = 5; | ||
1534 | tm6000_set_audio_rinput(dev); | 1392 | tm6000_set_audio_rinput(dev); |
1535 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); | 1393 | v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); |
1536 | tm6000_prepare_isoc(dev); | 1394 | tm6000_prepare_isoc(dev); |
1537 | tm6000_start_thread(dev); | 1395 | tm6000_start_thread(dev); |
1538 | } | 1396 | } |
1397 | v4l2_fh_add(&fh->fh); | ||
1539 | 1398 | ||
1540 | return 0; | 1399 | return 0; |
1541 | } | 1400 | } |
@@ -1576,29 +1435,35 @@ tm6000_read(struct file *file, char __user *data, size_t count, loff_t *pos) | |||
1576 | static unsigned int | 1435 | static unsigned int |
1577 | __tm6000_poll(struct file *file, struct poll_table_struct *wait) | 1436 | __tm6000_poll(struct file *file, struct poll_table_struct *wait) |
1578 | { | 1437 | { |
1438 | unsigned long req_events = poll_requested_events(wait); | ||
1579 | struct tm6000_fh *fh = file->private_data; | 1439 | struct tm6000_fh *fh = file->private_data; |
1580 | struct tm6000_buffer *buf; | 1440 | struct tm6000_buffer *buf; |
1441 | int res = 0; | ||
1581 | 1442 | ||
1443 | if (v4l2_event_pending(&fh->fh)) | ||
1444 | res = POLLPRI; | ||
1445 | else if (req_events & POLLPRI) | ||
1446 | poll_wait(file, &fh->fh.wait, wait); | ||
1582 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) | 1447 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) |
1583 | return POLLERR; | 1448 | return res | POLLERR; |
1584 | 1449 | ||
1585 | if (!!is_res_streaming(fh->dev, fh)) | 1450 | if (!!is_res_streaming(fh->dev, fh)) |
1586 | return POLLERR; | 1451 | return res | POLLERR; |
1587 | 1452 | ||
1588 | if (!is_res_read(fh->dev, fh)) { | 1453 | if (!is_res_read(fh->dev, fh)) { |
1589 | /* streaming capture */ | 1454 | /* streaming capture */ |
1590 | if (list_empty(&fh->vb_vidq.stream)) | 1455 | if (list_empty(&fh->vb_vidq.stream)) |
1591 | return POLLERR; | 1456 | return res | POLLERR; |
1592 | buf = list_entry(fh->vb_vidq.stream.next, struct tm6000_buffer, vb.stream); | 1457 | buf = list_entry(fh->vb_vidq.stream.next, struct tm6000_buffer, vb.stream); |
1593 | } else { | 1458 | poll_wait(file, &buf->vb.done, wait); |
1459 | if (buf->vb.state == VIDEOBUF_DONE || | ||
1460 | buf->vb.state == VIDEOBUF_ERROR) | ||
1461 | return res | POLLIN | POLLRDNORM; | ||
1462 | } else if (req_events & (POLLIN | POLLRDNORM)) { | ||
1594 | /* read() capture */ | 1463 | /* read() capture */ |
1595 | return videobuf_poll_stream(file, &fh->vb_vidq, wait); | 1464 | return res | videobuf_poll_stream(file, &fh->vb_vidq, wait); |
1596 | } | 1465 | } |
1597 | poll_wait(file, &buf->vb.done, wait); | 1466 | return res; |
1598 | if (buf->vb.state == VIDEOBUF_DONE || | ||
1599 | buf->vb.state == VIDEOBUF_ERROR) | ||
1600 | return POLLIN | POLLRDNORM; | ||
1601 | return 0; | ||
1602 | } | 1467 | } |
1603 | 1468 | ||
1604 | static unsigned int tm6000_poll(struct file *file, struct poll_table_struct *wait) | 1469 | static unsigned int tm6000_poll(struct file *file, struct poll_table_struct *wait) |
@@ -1648,7 +1513,8 @@ static int tm6000_release(struct file *file) | |||
1648 | if (!fh->radio) | 1513 | if (!fh->radio) |
1649 | videobuf_mmap_free(&fh->vb_vidq); | 1514 | videobuf_mmap_free(&fh->vb_vidq); |
1650 | } | 1515 | } |
1651 | 1516 | v4l2_fh_del(&fh->fh); | |
1517 | v4l2_fh_exit(&fh->fh); | ||
1652 | kfree(fh); | 1518 | kfree(fh); |
1653 | mutex_unlock(&dev->lock); | 1519 | mutex_unlock(&dev->lock); |
1654 | 1520 | ||
@@ -1688,9 +1554,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1688 | .vidioc_enum_input = vidioc_enum_input, | 1554 | .vidioc_enum_input = vidioc_enum_input, |
1689 | .vidioc_g_input = vidioc_g_input, | 1555 | .vidioc_g_input = vidioc_g_input, |
1690 | .vidioc_s_input = vidioc_s_input, | 1556 | .vidioc_s_input = vidioc_s_input, |
1691 | .vidioc_queryctrl = vidioc_queryctrl, | ||
1692 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1693 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1694 | .vidioc_g_tuner = vidioc_g_tuner, | 1557 | .vidioc_g_tuner = vidioc_g_tuner, |
1695 | .vidioc_s_tuner = vidioc_s_tuner, | 1558 | .vidioc_s_tuner = vidioc_s_tuner, |
1696 | .vidioc_g_frequency = vidioc_g_frequency, | 1559 | .vidioc_g_frequency = vidioc_g_frequency, |
@@ -1701,6 +1564,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1701 | .vidioc_querybuf = vidioc_querybuf, | 1564 | .vidioc_querybuf = vidioc_querybuf, |
1702 | .vidioc_qbuf = vidioc_qbuf, | 1565 | .vidioc_qbuf = vidioc_qbuf, |
1703 | .vidioc_dqbuf = vidioc_dqbuf, | 1566 | .vidioc_dqbuf = vidioc_dqbuf, |
1567 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1568 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1704 | }; | 1569 | }; |
1705 | 1570 | ||
1706 | static struct video_device tm6000_template = { | 1571 | static struct video_device tm6000_template = { |
@@ -1715,25 +1580,19 @@ static struct video_device tm6000_template = { | |||
1715 | static const struct v4l2_file_operations radio_fops = { | 1580 | static const struct v4l2_file_operations radio_fops = { |
1716 | .owner = THIS_MODULE, | 1581 | .owner = THIS_MODULE, |
1717 | .open = tm6000_open, | 1582 | .open = tm6000_open, |
1583 | .poll = v4l2_ctrl_poll, | ||
1718 | .release = tm6000_release, | 1584 | .release = tm6000_release, |
1719 | .unlocked_ioctl = video_ioctl2, | 1585 | .unlocked_ioctl = video_ioctl2, |
1720 | }; | 1586 | }; |
1721 | 1587 | ||
1722 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 1588 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
1723 | .vidioc_querycap = radio_querycap, | 1589 | .vidioc_querycap = vidioc_querycap, |
1724 | .vidioc_g_tuner = radio_g_tuner, | 1590 | .vidioc_g_tuner = radio_g_tuner, |
1725 | .vidioc_enum_input = radio_enum_input, | ||
1726 | .vidioc_g_audio = radio_g_audio, | ||
1727 | .vidioc_s_tuner = radio_s_tuner, | 1591 | .vidioc_s_tuner = radio_s_tuner, |
1728 | .vidioc_s_audio = radio_s_audio, | ||
1729 | .vidioc_s_input = radio_s_input, | ||
1730 | .vidioc_s_std = radio_s_std, | ||
1731 | .vidioc_queryctrl = radio_queryctrl, | ||
1732 | .vidioc_g_input = radio_g_input, | ||
1733 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1734 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1735 | .vidioc_g_frequency = vidioc_g_frequency, | 1592 | .vidioc_g_frequency = vidioc_g_frequency, |
1736 | .vidioc_s_frequency = vidioc_s_frequency, | 1593 | .vidioc_s_frequency = vidioc_s_frequency, |
1594 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1595 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1737 | }; | 1596 | }; |
1738 | 1597 | ||
1739 | static struct video_device tm6000_radio_template = { | 1598 | static struct video_device tm6000_radio_template = { |
@@ -1762,6 +1621,7 @@ static struct video_device *vdev_init(struct tm6000_core *dev, | |||
1762 | vfd->release = video_device_release; | 1621 | vfd->release = video_device_release; |
1763 | vfd->debug = tm6000_debug; | 1622 | vfd->debug = tm6000_debug; |
1764 | vfd->lock = &dev->lock; | 1623 | vfd->lock = &dev->lock; |
1624 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
1765 | 1625 | ||
1766 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); | 1626 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); |
1767 | 1627 | ||
@@ -1771,15 +1631,41 @@ static struct video_device *vdev_init(struct tm6000_core *dev, | |||
1771 | 1631 | ||
1772 | int tm6000_v4l2_register(struct tm6000_core *dev) | 1632 | int tm6000_v4l2_register(struct tm6000_core *dev) |
1773 | { | 1633 | { |
1774 | int ret = -1; | 1634 | int ret = 0; |
1635 | |||
1636 | v4l2_ctrl_handler_init(&dev->ctrl_handler, 6); | ||
1637 | v4l2_ctrl_handler_init(&dev->radio_ctrl_handler, 2); | ||
1638 | v4l2_ctrl_new_std(&dev->radio_ctrl_handler, &tm6000_radio_ctrl_ops, | ||
1639 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0); | ||
1640 | v4l2_ctrl_new_std(&dev->radio_ctrl_handler, &tm6000_radio_ctrl_ops, | ||
1641 | V4L2_CID_AUDIO_VOLUME, -15, 15, 1, 0); | ||
1642 | v4l2_ctrl_new_std(&dev->ctrl_handler, &tm6000_ctrl_ops, | ||
1643 | V4L2_CID_BRIGHTNESS, 0, 255, 1, 54); | ||
1644 | v4l2_ctrl_new_std(&dev->ctrl_handler, &tm6000_ctrl_ops, | ||
1645 | V4L2_CID_CONTRAST, 0, 255, 1, 119); | ||
1646 | v4l2_ctrl_new_std(&dev->ctrl_handler, &tm6000_ctrl_ops, | ||
1647 | V4L2_CID_SATURATION, 0, 255, 1, 112); | ||
1648 | v4l2_ctrl_new_std(&dev->ctrl_handler, &tm6000_ctrl_ops, | ||
1649 | V4L2_CID_HUE, -128, 127, 1, 0); | ||
1650 | v4l2_ctrl_add_handler(&dev->ctrl_handler, | ||
1651 | &dev->radio_ctrl_handler, NULL); | ||
1652 | |||
1653 | if (dev->radio_ctrl_handler.error) | ||
1654 | ret = dev->radio_ctrl_handler.error; | ||
1655 | if (!ret && dev->ctrl_handler.error) | ||
1656 | ret = dev->ctrl_handler.error; | ||
1657 | if (ret) | ||
1658 | goto free_ctrl; | ||
1775 | 1659 | ||
1776 | dev->vfd = vdev_init(dev, &tm6000_template, "video"); | 1660 | dev->vfd = vdev_init(dev, &tm6000_template, "video"); |
1777 | 1661 | ||
1778 | if (!dev->vfd) { | 1662 | if (!dev->vfd) { |
1779 | printk(KERN_INFO "%s: can't register video device\n", | 1663 | printk(KERN_INFO "%s: can't register video device\n", |
1780 | dev->name); | 1664 | dev->name); |
1781 | return -ENOMEM; | 1665 | ret = -ENOMEM; |
1666 | goto free_ctrl; | ||
1782 | } | 1667 | } |
1668 | dev->vfd->ctrl_handler = &dev->ctrl_handler; | ||
1783 | 1669 | ||
1784 | /* init video dma queues */ | 1670 | /* init video dma queues */ |
1785 | INIT_LIST_HEAD(&dev->vidq.active); | 1671 | INIT_LIST_HEAD(&dev->vidq.active); |
@@ -1790,7 +1676,9 @@ int tm6000_v4l2_register(struct tm6000_core *dev) | |||
1790 | if (ret < 0) { | 1676 | if (ret < 0) { |
1791 | printk(KERN_INFO "%s: can't register video device\n", | 1677 | printk(KERN_INFO "%s: can't register video device\n", |
1792 | dev->name); | 1678 | dev->name); |
1793 | return ret; | 1679 | video_device_release(dev->vfd); |
1680 | dev->vfd = NULL; | ||
1681 | goto free_ctrl; | ||
1794 | } | 1682 | } |
1795 | 1683 | ||
1796 | printk(KERN_INFO "%s: registered device %s\n", | 1684 | printk(KERN_INFO "%s: registered device %s\n", |
@@ -1803,15 +1691,17 @@ int tm6000_v4l2_register(struct tm6000_core *dev) | |||
1803 | printk(KERN_INFO "%s: can't register radio device\n", | 1691 | printk(KERN_INFO "%s: can't register radio device\n", |
1804 | dev->name); | 1692 | dev->name); |
1805 | ret = -ENXIO; | 1693 | ret = -ENXIO; |
1806 | return ret; /* FIXME release resource */ | 1694 | goto unreg_video; |
1807 | } | 1695 | } |
1808 | 1696 | ||
1697 | dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; | ||
1809 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | 1698 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, |
1810 | radio_nr); | 1699 | radio_nr); |
1811 | if (ret < 0) { | 1700 | if (ret < 0) { |
1812 | printk(KERN_INFO "%s: can't register radio device\n", | 1701 | printk(KERN_INFO "%s: can't register radio device\n", |
1813 | dev->name); | 1702 | dev->name); |
1814 | return ret; /* FIXME release resource */ | 1703 | video_device_release(dev->radio_dev); |
1704 | goto unreg_video; | ||
1815 | } | 1705 | } |
1816 | 1706 | ||
1817 | printk(KERN_INFO "%s: registered device %s\n", | 1707 | printk(KERN_INFO "%s: registered device %s\n", |
@@ -1820,12 +1710,22 @@ int tm6000_v4l2_register(struct tm6000_core *dev) | |||
1820 | 1710 | ||
1821 | printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); | 1711 | printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); |
1822 | return ret; | 1712 | return ret; |
1713 | |||
1714 | unreg_video: | ||
1715 | video_unregister_device(dev->vfd); | ||
1716 | free_ctrl: | ||
1717 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
1718 | v4l2_ctrl_handler_free(&dev->radio_ctrl_handler); | ||
1719 | return ret; | ||
1823 | } | 1720 | } |
1824 | 1721 | ||
1825 | int tm6000_v4l2_unregister(struct tm6000_core *dev) | 1722 | int tm6000_v4l2_unregister(struct tm6000_core *dev) |
1826 | { | 1723 | { |
1827 | video_unregister_device(dev->vfd); | 1724 | video_unregister_device(dev->vfd); |
1828 | 1725 | ||
1726 | /* if URB buffers are still allocated free them now */ | ||
1727 | tm6000_free_urb_buffers(dev); | ||
1728 | |||
1829 | if (dev->radio_dev) { | 1729 | if (dev->radio_dev) { |
1830 | if (video_is_registered(dev->radio_dev)) | 1730 | if (video_is_registered(dev->radio_dev)) |
1831 | video_unregister_device(dev->radio_dev); | 1731 | video_unregister_device(dev->radio_dev); |
@@ -1851,3 +1751,5 @@ MODULE_PARM_DESC(debug, "activates debug info"); | |||
1851 | module_param(vid_limit, int, 0644); | 1751 | module_param(vid_limit, int, 0644); |
1852 | MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes"); | 1752 | MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes"); |
1853 | 1753 | ||
1754 | module_param(keep_urb, bool, 0); | ||
1755 | MODULE_PARM_DESC(keep_urb, "Keep urb buffers allocated even when the device is closed by the user"); | ||
diff --git a/drivers/media/usb/tm6000/tm6000.h b/drivers/media/usb/tm6000/tm6000.h index 6df418658c9c..08bd0740dd23 100644 --- a/drivers/media/usb/tm6000/tm6000.h +++ b/drivers/media/usb/tm6000/tm6000.h | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | #include <media/v4l2-device.h> | 29 | #include <media/v4l2-device.h> |
30 | #include <media/v4l2-ctrls.h> | ||
31 | #include <media/v4l2-fh.h> | ||
30 | 32 | ||
31 | #include <linux/dvb/frontend.h> | 33 | #include <linux/dvb/frontend.h> |
32 | #include "dvb_demux.h" | 34 | #include "dvb_demux.h" |
@@ -222,6 +224,8 @@ struct tm6000_core { | |||
222 | struct video_device *radio_dev; | 224 | struct video_device *radio_dev; |
223 | struct tm6000_dmaqueue vidq; | 225 | struct tm6000_dmaqueue vidq; |
224 | struct v4l2_device v4l2_dev; | 226 | struct v4l2_device v4l2_dev; |
227 | struct v4l2_ctrl_handler ctrl_handler; | ||
228 | struct v4l2_ctrl_handler radio_ctrl_handler; | ||
225 | 229 | ||
226 | int input; | 230 | int input; |
227 | struct tm6000_input vinput[3]; /* video input */ | 231 | struct tm6000_input vinput[3]; /* video input */ |
@@ -264,6 +268,11 @@ struct tm6000_core { | |||
264 | 268 | ||
265 | spinlock_t slock; | 269 | spinlock_t slock; |
266 | 270 | ||
271 | /* urb dma buffers */ | ||
272 | char **urb_buffer; | ||
273 | dma_addr_t *urb_dma; | ||
274 | unsigned int urb_size; | ||
275 | |||
267 | unsigned long quirks; | 276 | unsigned long quirks; |
268 | }; | 277 | }; |
269 | 278 | ||
@@ -282,6 +291,7 @@ struct tm6000_ops { | |||
282 | }; | 291 | }; |
283 | 292 | ||
284 | struct tm6000_fh { | 293 | struct tm6000_fh { |
294 | struct v4l2_fh fh; | ||
285 | struct tm6000_core *dev; | 295 | struct tm6000_core *dev; |
286 | unsigned int radio; | 296 | unsigned int radio; |
287 | 297 | ||
diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c index 5b682cc4c814..e40718552850 100644 --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | |||
@@ -561,6 +561,13 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, | |||
561 | { | 561 | { |
562 | u16 csum = 0, cc; | 562 | u16 csum = 0, cc; |
563 | int i; | 563 | int i; |
564 | |||
565 | if (len < 4 || len & 0x1) { | ||
566 | pr_warn("%s: muxpack has invalid len %d\n", __func__, len); | ||
567 | numinvalid++; | ||
568 | return; | ||
569 | } | ||
570 | |||
564 | for (i = 0; i < len; i += 2) | 571 | for (i = 0; i < len; i += 2) |
565 | csum ^= le16_to_cpup((__le16 *) (muxpack + i)); | 572 | csum ^= le16_to_cpup((__le16 *) (muxpack + i)); |
566 | if (csum) { | 573 | if (csum) { |
diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c index c9b2042f8bdf..816b1cffab7d 100644 --- a/drivers/media/usb/usbvision/usbvision-core.c +++ b/drivers/media/usb/usbvision/usbvision-core.c | |||
@@ -1169,7 +1169,7 @@ static void usbvision_parse_data(struct usb_usbvision *usbvision) | |||
1169 | 1169 | ||
1170 | if (newstate == parse_state_next_frame) { | 1170 | if (newstate == parse_state_next_frame) { |
1171 | frame->grabstate = frame_state_done; | 1171 | frame->grabstate = frame_state_done; |
1172 | do_gettimeofday(&(frame->timestamp)); | 1172 | v4l2_get_timestamp(&(frame->timestamp)); |
1173 | frame->sequence = usbvision->frame_num; | 1173 | frame->sequence = usbvision->frame_num; |
1174 | 1174 | ||
1175 | spin_lock_irqsave(&usbvision->queue_lock, lock_flags); | 1175 | spin_lock_irqsave(&usbvision->queue_lock, lock_flags); |
diff --git a/drivers/media/usb/usbvision/usbvision-i2c.c b/drivers/media/usb/usbvision/usbvision-i2c.c index 89fec029e924..ba262a32bd3a 100644 --- a/drivers/media/usb/usbvision/usbvision-i2c.c +++ b/drivers/media/usb/usbvision/usbvision-i2c.c | |||
@@ -189,8 +189,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
189 | if (usbvision->registered_i2c) | 189 | if (usbvision->registered_i2c) |
190 | return 0; | 190 | return 0; |
191 | 191 | ||
192 | memcpy(&usbvision->i2c_adap, &i2c_adap_template, | 192 | usbvision->i2c_adap = i2c_adap_template; |
193 | sizeof(struct i2c_adapter)); | ||
194 | 193 | ||
195 | sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name, | 194 | sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name, |
196 | usbvision->dev->bus->busnum, usbvision->dev->devpath); | 195 | usbvision->dev->bus->busnum, usbvision->dev->devpath); |
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index ad7f7448072e..cd1fe78a5532 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c | |||
@@ -761,7 +761,7 @@ static int vidioc_querybuf(struct file *file, | |||
761 | if (vb->index >= usbvision->num_frames) | 761 | if (vb->index >= usbvision->num_frames) |
762 | return -EINVAL; | 762 | return -EINVAL; |
763 | /* Updating the corresponding frame state */ | 763 | /* Updating the corresponding frame state */ |
764 | vb->flags = 0; | 764 | vb->flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
765 | frame = &usbvision->frame[vb->index]; | 765 | frame = &usbvision->frame[vb->index]; |
766 | if (frame->grabstate >= frame_state_ready) | 766 | if (frame->grabstate >= frame_state_ready) |
767 | vb->flags |= V4L2_BUF_FLAG_QUEUED; | 767 | vb->flags |= V4L2_BUF_FLAG_QUEUED; |
@@ -843,7 +843,8 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb) | |||
843 | vb->memory = V4L2_MEMORY_MMAP; | 843 | vb->memory = V4L2_MEMORY_MMAP; |
844 | vb->flags = V4L2_BUF_FLAG_MAPPED | | 844 | vb->flags = V4L2_BUF_FLAG_MAPPED | |
845 | V4L2_BUF_FLAG_QUEUED | | 845 | V4L2_BUF_FLAG_QUEUED | |
846 | V4L2_BUF_FLAG_DONE; | 846 | V4L2_BUF_FLAG_DONE | |
847 | V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | ||
847 | vb->index = f->index; | 848 | vb->index = f->index; |
848 | vb->sequence = f->sequence; | 849 | vb->sequence = f->sequence; |
849 | vb->timestamp = f->timestamp; | 850 | vb->timestamp = f->timestamp; |
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index d5baab17a5ef..61e28dec991d 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c | |||
@@ -1838,7 +1838,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, | |||
1838 | { | 1838 | { |
1839 | int ret = 0; | 1839 | int ret = 0; |
1840 | 1840 | ||
1841 | memcpy(&ctrl->info, info, sizeof(*info)); | 1841 | ctrl->info = *info; |
1842 | INIT_LIST_HEAD(&ctrl->info.mappings); | 1842 | INIT_LIST_HEAD(&ctrl->info.mappings); |
1843 | 1843 | ||
1844 | /* Allocate an array to save control values (cur, def, max, etc.) */ | 1844 | /* Allocate an array to save control values (cur, def, max, etc.) */ |
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 778addc5caff..6c233a54ce40 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c | |||
@@ -115,11 +115,27 @@ static int uvc_buffer_finish(struct vb2_buffer *vb) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static void uvc_wait_prepare(struct vb2_queue *vq) | ||
119 | { | ||
120 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | ||
121 | |||
122 | mutex_unlock(&queue->mutex); | ||
123 | } | ||
124 | |||
125 | static void uvc_wait_finish(struct vb2_queue *vq) | ||
126 | { | ||
127 | struct uvc_video_queue *queue = vb2_get_drv_priv(vq); | ||
128 | |||
129 | mutex_lock(&queue->mutex); | ||
130 | } | ||
131 | |||
118 | static struct vb2_ops uvc_queue_qops = { | 132 | static struct vb2_ops uvc_queue_qops = { |
119 | .queue_setup = uvc_queue_setup, | 133 | .queue_setup = uvc_queue_setup, |
120 | .buf_prepare = uvc_buffer_prepare, | 134 | .buf_prepare = uvc_buffer_prepare, |
121 | .buf_queue = uvc_buffer_queue, | 135 | .buf_queue = uvc_buffer_queue, |
122 | .buf_finish = uvc_buffer_finish, | 136 | .buf_finish = uvc_buffer_finish, |
137 | .wait_prepare = uvc_wait_prepare, | ||
138 | .wait_finish = uvc_wait_finish, | ||
123 | }; | 139 | }; |
124 | 140 | ||
125 | int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, | 141 | int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, |
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 68d59b527492..b2dc32623a71 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c | |||
@@ -315,7 +315,7 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream, | |||
315 | goto done; | 315 | goto done; |
316 | } | 316 | } |
317 | 317 | ||
318 | memcpy(&stream->ctrl, &probe, sizeof probe); | 318 | stream->ctrl = probe; |
319 | stream->cur_format = format; | 319 | stream->cur_format = format; |
320 | stream->cur_frame = frame; | 320 | stream->cur_frame = frame; |
321 | 321 | ||
@@ -387,7 +387,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, | |||
387 | return -EBUSY; | 387 | return -EBUSY; |
388 | } | 388 | } |
389 | 389 | ||
390 | memcpy(&probe, &stream->ctrl, sizeof probe); | 390 | probe = stream->ctrl; |
391 | probe.dwFrameInterval = | 391 | probe.dwFrameInterval = |
392 | uvc_try_frame_interval(stream->cur_frame, interval); | 392 | uvc_try_frame_interval(stream->cur_frame, interval); |
393 | 393 | ||
@@ -398,7 +398,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream, | |||
398 | return ret; | 398 | return ret; |
399 | } | 399 | } |
400 | 400 | ||
401 | memcpy(&stream->ctrl, &probe, sizeof probe); | 401 | stream->ctrl = probe; |
402 | mutex_unlock(&stream->mutex); | 402 | mutex_unlock(&stream->mutex); |
403 | 403 | ||
404 | /* Return the actual frame period. */ | 404 | /* Return the actual frame period. */ |
@@ -501,8 +501,8 @@ static int uvc_v4l2_open(struct file *file) | |||
501 | if (atomic_inc_return(&stream->dev->users) == 1) { | 501 | if (atomic_inc_return(&stream->dev->users) == 1) { |
502 | ret = uvc_status_start(stream->dev); | 502 | ret = uvc_status_start(stream->dev); |
503 | if (ret < 0) { | 503 | if (ret < 0) { |
504 | usb_autopm_put_interface(stream->dev->intf); | ||
505 | atomic_dec(&stream->dev->users); | 504 | atomic_dec(&stream->dev->users); |
505 | usb_autopm_put_interface(stream->dev->intf); | ||
506 | kfree(handle); | 506 | kfree(handle); |
507 | return ret; | 507 | return ret; |
508 | } | 508 | } |
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c index 39edd4442932..74d56df3347f 100644 --- a/drivers/media/usb/zr364xx/zr364xx.c +++ b/drivers/media/usb/zr364xx/zr364xx.c | |||
@@ -501,7 +501,6 @@ static void zr364xx_fillbuff(struct zr364xx_camera *cam, | |||
501 | int jpgsize) | 501 | int jpgsize) |
502 | { | 502 | { |
503 | int pos = 0; | 503 | int pos = 0; |
504 | struct timeval ts; | ||
505 | const char *tmpbuf; | 504 | const char *tmpbuf; |
506 | char *vbuf = videobuf_to_vmalloc(&buf->vb); | 505 | char *vbuf = videobuf_to_vmalloc(&buf->vb); |
507 | unsigned long last_frame; | 506 | unsigned long last_frame; |
@@ -530,8 +529,7 @@ static void zr364xx_fillbuff(struct zr364xx_camera *cam, | |||
530 | /* tell v4l buffer was filled */ | 529 | /* tell v4l buffer was filled */ |
531 | 530 | ||
532 | buf->vb.field_count = cam->frame_count * 2; | 531 | buf->vb.field_count = cam->frame_count * 2; |
533 | do_gettimeofday(&ts); | 532 | v4l2_get_timestamp(&buf->vb.ts); |
534 | buf->vb.ts = ts; | ||
535 | buf->vb.state = VIDEOBUF_DONE; | 533 | buf->vb.state = VIDEOBUF_DONE; |
536 | } | 534 | } |
537 | 535 | ||
@@ -559,7 +557,7 @@ static int zr364xx_got_frame(struct zr364xx_camera *cam, int jpgsize) | |||
559 | goto unlock; | 557 | goto unlock; |
560 | } | 558 | } |
561 | list_del(&buf->vb.queue); | 559 | list_del(&buf->vb.queue); |
562 | do_gettimeofday(&buf->vb.ts); | 560 | v4l2_get_timestamp(&buf->vb.ts); |
563 | DBG("[%p/%d] wakeup\n", buf, buf->vb.i); | 561 | DBG("[%p/%d] wakeup\n", buf, buf->vb.i); |
564 | zr364xx_fillbuff(cam, buf, jpgsize); | 562 | zr364xx_fillbuff(cam, buf, jpgsize); |
565 | wake_up(&buf->vb.done); | 563 | wake_up(&buf->vb.done); |