diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-12-04 02:52:14 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-04 02:52:14 -0500 |
commit | cb9c34e6d090d376b77becaa5d29a65dec7f4272 (patch) | |
tree | 3678abce20d6825aebe3fec218057d4131e13fd6 /drivers/media | |
parent | 470c66239ef0336429b35345f3f615d47341e13b (diff) | |
parent | 061e41fdb5047b1fb161e89664057835935ca1d2 (diff) |
Merge commit 'v2.6.28-rc7' into core/locking
Diffstat (limited to 'drivers/media')
27 files changed, 559 insertions, 231 deletions
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c index 14e627ef6465..c1d92f838ca8 100644 --- a/drivers/media/dvb/dm1105/dm1105.c +++ b/drivers/media/dvb/dm1105/dm1105.c | |||
@@ -376,7 +376,7 @@ static void dm1105dvb_dma_unmap(struct dm1105dvb *dm1105dvb) | |||
376 | pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr); | 376 | pci_free_consistent(dm1105dvb->pdev, 6*DM1105_DMA_BYTES, dm1105dvb->ts_buf, dm1105dvb->dma_addr); |
377 | } | 377 | } |
378 | 378 | ||
379 | static void __devinit dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb) | 379 | static void dm1105dvb_enable_irqs(struct dm1105dvb *dm1105dvb) |
380 | { | 380 | { |
381 | outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK)); | 381 | outb(INTMAK_ALLMASK, dm_io_mem(DM1105_INTMAK)); |
382 | outb(1, dm_io_mem(DM1105_CR)); | 382 | outb(1, dm_io_mem(DM1105_CR)); |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 8557bf12cfb4..7a421e9dba5a 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -585,6 +585,8 @@ restart: | |||
585 | if (fe->ops.set_voltage) | 585 | if (fe->ops.set_voltage) |
586 | fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); | 586 | fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); |
587 | if (fe->ops.tuner_ops.sleep) { | 587 | if (fe->ops.tuner_ops.sleep) { |
588 | if (fe->ops.i2c_gate_ctrl) | ||
589 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
588 | fe->ops.tuner_ops.sleep(fe); | 590 | fe->ops.tuner_ops.sleep(fe); |
589 | if (fe->ops.i2c_gate_ctrl) | 591 | if (fe->ops.i2c_gate_ctrl) |
590 | fe->ops.i2c_gate_ctrl(fe, 0); | 592 | fe->ops.i2c_gate_ctrl(fe, 0); |
@@ -934,7 +936,8 @@ void dtv_property_dump(struct dtv_property *tvp) | |||
934 | int is_legacy_delivery_system(fe_delivery_system_t s) | 936 | int is_legacy_delivery_system(fe_delivery_system_t s) |
935 | { | 937 | { |
936 | if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) || | 938 | if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) || |
937 | (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS)) | 939 | (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS) || |
940 | (s == SYS_ATSC)) | ||
938 | return 1; | 941 | return 1; |
939 | 942 | ||
940 | return 0; | 943 | return 0; |
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index 847d8fdd9ec4..e9ab0249d133 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c | |||
@@ -681,12 +681,6 @@ static int af9015_download_firmware(struct usb_device *udev, | |||
681 | goto error; | 681 | goto error; |
682 | } | 682 | } |
683 | 683 | ||
684 | /* firmware is running, reconnect device in the usb bus */ | ||
685 | req.cmd = RECONNECT_USB; | ||
686 | ret = af9015_rw_udev(udev, &req); | ||
687 | if (ret) | ||
688 | err("reconnect failed: %d", ret); | ||
689 | |||
690 | error: | 684 | error: |
691 | return ret; | 685 | return ret; |
692 | } | 686 | } |
@@ -1208,6 +1202,7 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1208 | .usb_ctrl = DEVICE_SPECIFIC, | 1202 | .usb_ctrl = DEVICE_SPECIFIC, |
1209 | .download_firmware = af9015_download_firmware, | 1203 | .download_firmware = af9015_download_firmware, |
1210 | .firmware = "dvb-usb-af9015.fw", | 1204 | .firmware = "dvb-usb-af9015.fw", |
1205 | .no_reconnect = 1, | ||
1211 | 1206 | ||
1212 | .size_of_priv = sizeof(struct af9015_state), \ | 1207 | .size_of_priv = sizeof(struct af9015_state), \ |
1213 | 1208 | ||
@@ -1306,6 +1301,7 @@ static struct dvb_usb_device_properties af9015_properties[] = { | |||
1306 | .usb_ctrl = DEVICE_SPECIFIC, | 1301 | .usb_ctrl = DEVICE_SPECIFIC, |
1307 | .download_firmware = af9015_download_firmware, | 1302 | .download_firmware = af9015_download_firmware, |
1308 | .firmware = "dvb-usb-af9015.fw", | 1303 | .firmware = "dvb-usb-af9015.fw", |
1304 | .no_reconnect = 1, | ||
1309 | 1305 | ||
1310 | .size_of_priv = sizeof(struct af9015_state), \ | 1306 | .size_of_priv = sizeof(struct af9015_state), \ |
1311 | 1307 | ||
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h index 739193943c17..8b544fe79b0d 100644 --- a/drivers/media/dvb/dvb-usb/dib0700.h +++ b/drivers/media/dvb/dvb-usb/dib0700.h | |||
@@ -22,7 +22,7 @@ extern int dvb_usb_dib0700_debug; | |||
22 | 22 | ||
23 | #define REQUEST_I2C_READ 0x2 | 23 | #define REQUEST_I2C_READ 0x2 |
24 | #define REQUEST_I2C_WRITE 0x3 | 24 | #define REQUEST_I2C_WRITE 0x3 |
25 | #define REQUEST_POLL_RC 0x4 | 25 | #define REQUEST_POLL_RC 0x4 /* deprecated in firmware v1.20 */ |
26 | #define REQUEST_JUMPRAM 0x8 | 26 | #define REQUEST_JUMPRAM 0x8 |
27 | #define REQUEST_SET_CLOCK 0xB | 27 | #define REQUEST_SET_CLOCK 0xB |
28 | #define REQUEST_SET_GPIO 0xC | 28 | #define REQUEST_SET_GPIO 0xC |
@@ -40,11 +40,14 @@ struct dib0700_state { | |||
40 | u16 mt2060_if1[2]; | 40 | u16 mt2060_if1[2]; |
41 | u8 rc_toggle; | 41 | u8 rc_toggle; |
42 | u8 rc_counter; | 42 | u8 rc_counter; |
43 | u8 rc_func_version; | ||
43 | u8 is_dib7000pc; | 44 | u8 is_dib7000pc; |
44 | u8 fw_use_new_i2c_api; | 45 | u8 fw_use_new_i2c_api; |
45 | u8 disable_streaming_master_mode; | 46 | u8 disable_streaming_master_mode; |
46 | }; | 47 | }; |
47 | 48 | ||
49 | extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion, | ||
50 | u32 *romversion, u32 *ramversion, u32 *fwtype); | ||
48 | extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val); | 51 | extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val); |
49 | extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); | 52 | extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); |
50 | extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen); | 53 | extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen); |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c index dd53cee3896d..200b215f4d8b 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c | |||
@@ -19,6 +19,22 @@ MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (defau | |||
19 | 19 | ||
20 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 20 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
21 | 21 | ||
22 | |||
23 | int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion, | ||
24 | u32 *romversion, u32 *ramversion, u32 *fwtype) | ||
25 | { | ||
26 | u8 b[16]; | ||
27 | int ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), | ||
28 | REQUEST_GET_VERSION, | ||
29 | USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, | ||
30 | b, sizeof(b), USB_CTRL_GET_TIMEOUT); | ||
31 | *hwversion = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; | ||
32 | *romversion = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | b[7]; | ||
33 | *ramversion = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11]; | ||
34 | *fwtype = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15]; | ||
35 | return ret; | ||
36 | } | ||
37 | |||
22 | /* expecting rx buffer: request data[0] data[1] ... data[2] */ | 38 | /* expecting rx buffer: request data[0] data[1] ... data[2] */ |
23 | static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) | 39 | static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) |
24 | { | 40 | { |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 0cfccc24b190..f28d3ae59e04 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -38,6 +38,7 @@ static struct mt2060_config bristol_mt2060_config[2] = { | |||
38 | } | 38 | } |
39 | }; | 39 | }; |
40 | 40 | ||
41 | |||
41 | static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { | 42 | static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { |
42 | .band_caps = BAND_VHF | BAND_UHF, | 43 | .band_caps = BAND_VHF | BAND_UHF, |
43 | .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0), | 44 | .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0), |
@@ -451,8 +452,13 @@ static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; | |||
451 | 452 | ||
452 | /* Number of keypresses to ignore before start repeating */ | 453 | /* Number of keypresses to ignore before start repeating */ |
453 | #define RC_REPEAT_DELAY 2 | 454 | #define RC_REPEAT_DELAY 2 |
455 | #define RC_REPEAT_DELAY_V1_20 5 | ||
454 | 456 | ||
455 | static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 457 | |
458 | |||
459 | /* Used by firmware versions < 1.20 (deprecated) */ | ||
460 | static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event, | ||
461 | int *state) | ||
456 | { | 462 | { |
457 | u8 key[4]; | 463 | u8 key[4]; |
458 | int i; | 464 | int i; |
@@ -529,6 +535,137 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
529 | return 0; | 535 | return 0; |
530 | } | 536 | } |
531 | 537 | ||
538 | /* This is the structure of the RC response packet starting in firmware 1.20 */ | ||
539 | struct dib0700_rc_response { | ||
540 | u8 report_id; | ||
541 | u8 data_state; | ||
542 | u8 system_msb; | ||
543 | u8 system_lsb; | ||
544 | u8 data; | ||
545 | u8 not_data; | ||
546 | }; | ||
547 | |||
548 | /* This supports the new IR response format for firmware v1.20 */ | ||
549 | static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event, | ||
550 | int *state) | ||
551 | { | ||
552 | struct dvb_usb_rc_key *keymap = d->props.rc_key_map; | ||
553 | struct dib0700_state *st = d->priv; | ||
554 | struct dib0700_rc_response poll_reply; | ||
555 | u8 buf[6]; | ||
556 | int i; | ||
557 | int status; | ||
558 | int actlen; | ||
559 | int found = 0; | ||
560 | |||
561 | /* Set initial results in case we exit the function early */ | ||
562 | *event = 0; | ||
563 | *state = REMOTE_NO_KEY_PRESSED; | ||
564 | |||
565 | /* Firmware v1.20 provides RC data via bulk endpoint 1 */ | ||
566 | status = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 1), buf, | ||
567 | sizeof(buf), &actlen, 50); | ||
568 | if (status < 0) { | ||
569 | /* No data available (meaning no key press) */ | ||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | if (actlen != sizeof(buf)) { | ||
574 | /* We didn't get back the 6 byte message we expected */ | ||
575 | err("Unexpected RC response size [%d]", actlen); | ||
576 | return -1; | ||
577 | } | ||
578 | |||
579 | poll_reply.report_id = buf[0]; | ||
580 | poll_reply.data_state = buf[1]; | ||
581 | poll_reply.system_msb = buf[2]; | ||
582 | poll_reply.system_lsb = buf[3]; | ||
583 | poll_reply.data = buf[4]; | ||
584 | poll_reply.not_data = buf[5]; | ||
585 | |||
586 | /* | ||
587 | info("rid=%02x ds=%02x sm=%02x sl=%02x d=%02x nd=%02x\n", | ||
588 | poll_reply.report_id, poll_reply.data_state, | ||
589 | poll_reply.system_msb, poll_reply.system_lsb, | ||
590 | poll_reply.data, poll_reply.not_data); | ||
591 | */ | ||
592 | |||
593 | if ((poll_reply.data + poll_reply.not_data) != 0xff) { | ||
594 | /* Key failed integrity check */ | ||
595 | err("key failed integrity check: %02x %02x %02x %02x", | ||
596 | poll_reply.system_msb, poll_reply.system_lsb, | ||
597 | poll_reply.data, poll_reply.not_data); | ||
598 | return -1; | ||
599 | } | ||
600 | |||
601 | /* Find the key in the map */ | ||
602 | for (i = 0; i < d->props.rc_key_map_size; i++) { | ||
603 | if (keymap[i].custom == poll_reply.system_lsb && | ||
604 | keymap[i].data == poll_reply.data) { | ||
605 | *event = keymap[i].event; | ||
606 | found = 1; | ||
607 | break; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | if (found == 0) { | ||
612 | err("Unknown remote controller key: %02x %02x %02x %02x", | ||
613 | poll_reply.system_msb, poll_reply.system_lsb, | ||
614 | poll_reply.data, poll_reply.not_data); | ||
615 | d->last_event = 0; | ||
616 | return 0; | ||
617 | } | ||
618 | |||
619 | if (poll_reply.data_state == 1) { | ||
620 | /* New key hit */ | ||
621 | st->rc_counter = 0; | ||
622 | *event = keymap[i].event; | ||
623 | *state = REMOTE_KEY_PRESSED; | ||
624 | d->last_event = keymap[i].event; | ||
625 | } else if (poll_reply.data_state == 2) { | ||
626 | /* Key repeated */ | ||
627 | st->rc_counter++; | ||
628 | |||
629 | /* prevents unwanted double hits */ | ||
630 | if (st->rc_counter > RC_REPEAT_DELAY_V1_20) { | ||
631 | *event = d->last_event; | ||
632 | *state = REMOTE_KEY_PRESSED; | ||
633 | st->rc_counter = RC_REPEAT_DELAY_V1_20; | ||
634 | } | ||
635 | } else { | ||
636 | err("Unknown data state [%d]", poll_reply.data_state); | ||
637 | } | ||
638 | |||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | ||
643 | { | ||
644 | struct dib0700_state *st = d->priv; | ||
645 | |||
646 | /* Because some people may have improperly named firmware files, | ||
647 | let's figure out whether to use the new firmware call or the legacy | ||
648 | call based on the firmware version embedded in the file */ | ||
649 | if (st->rc_func_version == 0) { | ||
650 | u32 hwver, romver, ramver, fwtype; | ||
651 | int ret = dib0700_get_version(d, &hwver, &romver, &ramver, | ||
652 | &fwtype); | ||
653 | if (ret < 0) { | ||
654 | err("Could not determine version info"); | ||
655 | return -1; | ||
656 | } | ||
657 | if (ramver < 0x10200) | ||
658 | st->rc_func_version = 1; | ||
659 | else | ||
660 | st->rc_func_version = 2; | ||
661 | } | ||
662 | |||
663 | if (st->rc_func_version == 2) | ||
664 | return dib0700_rc_query_v1_20(d, event, state); | ||
665 | else | ||
666 | return dib0700_rc_query_legacy(d, event, state); | ||
667 | } | ||
668 | |||
532 | static struct dvb_usb_rc_key dib0700_rc_keys[] = { | 669 | static struct dvb_usb_rc_key dib0700_rc_keys[] = { |
533 | /* Key codes for the tiny Pinnacle remote*/ | 670 | /* Key codes for the tiny Pinnacle remote*/ |
534 | { 0x07, 0x00, KEY_MUTE }, | 671 | { 0x07, 0x00, KEY_MUTE }, |
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c index 397f51a7b2ad..da93b9e982c0 100644 --- a/drivers/media/dvb/dvb-usb/usb-urb.c +++ b/drivers/media/dvb/dvb-usb/usb-urb.c | |||
@@ -135,7 +135,7 @@ stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]) | |||
135 | 135 | ||
136 | static int usb_bulk_urb_init(struct usb_data_stream *stream) | 136 | static int usb_bulk_urb_init(struct usb_data_stream *stream) |
137 | { | 137 | { |
138 | int i; | 138 | int i, j; |
139 | 139 | ||
140 | if ((i = usb_allocate_stream_buffers(stream,stream->props.count, | 140 | if ((i = usb_allocate_stream_buffers(stream,stream->props.count, |
141 | stream->props.u.bulk.buffersize)) < 0) | 141 | stream->props.u.bulk.buffersize)) < 0) |
@@ -143,9 +143,13 @@ static int usb_bulk_urb_init(struct usb_data_stream *stream) | |||
143 | 143 | ||
144 | /* allocate the URBs */ | 144 | /* allocate the URBs */ |
145 | for (i = 0; i < stream->props.count; i++) { | 145 | for (i = 0; i < stream->props.count; i++) { |
146 | if ((stream->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) | 146 | stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); |
147 | if (!stream->urb_list[i]) { | ||
148 | deb_mem("not enough memory for urb_alloc_urb!.\n"); | ||
149 | for (j = 0; j < i; j++) | ||
150 | usb_free_urb(stream->urb_list[i]); | ||
147 | return -ENOMEM; | 151 | return -ENOMEM; |
148 | 152 | } | |
149 | usb_fill_bulk_urb( stream->urb_list[i], stream->udev, | 153 | usb_fill_bulk_urb( stream->urb_list[i], stream->udev, |
150 | usb_rcvbulkpipe(stream->udev,stream->props.endpoint), | 154 | usb_rcvbulkpipe(stream->udev,stream->props.endpoint), |
151 | stream->buf_list[i], | 155 | stream->buf_list[i], |
@@ -170,9 +174,14 @@ static int usb_isoc_urb_init(struct usb_data_stream *stream) | |||
170 | for (i = 0; i < stream->props.count; i++) { | 174 | for (i = 0; i < stream->props.count; i++) { |
171 | struct urb *urb; | 175 | struct urb *urb; |
172 | int frame_offset = 0; | 176 | int frame_offset = 0; |
173 | if ((stream->urb_list[i] = | 177 | |
174 | usb_alloc_urb(stream->props.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) | 178 | stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); |
179 | if (!stream->urb_list[i]) { | ||
180 | deb_mem("not enough memory for urb_alloc_urb!\n"); | ||
181 | for (j = 0; j < i; j++) | ||
182 | usb_free_urb(stream->urb_list[i]); | ||
175 | return -ENOMEM; | 183 | return -ENOMEM; |
184 | } | ||
176 | 185 | ||
177 | urb = stream->urb_list[i]; | 186 | urb = stream->urb_list[i]; |
178 | 187 | ||
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c index 6f9b77360440..e98d6caf2c23 100644 --- a/drivers/media/dvb/siano/sms-cards.c +++ b/drivers/media/dvb/siano/sms-cards.c | |||
@@ -95,7 +95,7 @@ static struct sms_board sms_boards[] = { | |||
95 | [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { | 95 | [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { |
96 | .name = "Hauppauge WinTV MiniStick", | 96 | .name = "Hauppauge WinTV MiniStick", |
97 | .type = SMS_NOVA_B0, | 97 | .type = SMS_NOVA_B0, |
98 | .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw", | 98 | .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw", |
99 | }, | 99 | }, |
100 | }; | 100 | }; |
101 | 101 | ||
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 66ab0c6e9783..4a3f2b8ea37d 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | |||
@@ -808,6 +808,12 @@ static int ttusb_alloc_iso_urbs(struct ttusb *ttusb) | |||
808 | ISO_BUF_COUNT, | 808 | ISO_BUF_COUNT, |
809 | &ttusb->iso_dma_handle); | 809 | &ttusb->iso_dma_handle); |
810 | 810 | ||
811 | if (!ttusb->iso_buffer) { | ||
812 | dprintk("%s: pci_alloc_consistent - not enough memory\n", | ||
813 | __func__); | ||
814 | return -ENOMEM; | ||
815 | } | ||
816 | |||
811 | memset(ttusb->iso_buffer, 0, | 817 | memset(ttusb->iso_buffer, 0, |
812 | ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT); | 818 | ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT); |
813 | 819 | ||
@@ -1659,7 +1665,14 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
1659 | 1665 | ||
1660 | ttusb_setup_interfaces(ttusb); | 1666 | ttusb_setup_interfaces(ttusb); |
1661 | 1667 | ||
1662 | ttusb_alloc_iso_urbs(ttusb); | 1668 | result = ttusb_alloc_iso_urbs(ttusb); |
1669 | if (result < 0) { | ||
1670 | dprintk("%s: ttusb_alloc_iso_urbs - failed\n", __func__); | ||
1671 | mutex_unlock(&ttusb->semi2c); | ||
1672 | kfree(ttusb); | ||
1673 | return result; | ||
1674 | } | ||
1675 | |||
1663 | if (ttusb_init_controller(ttusb)) | 1676 | if (ttusb_init_controller(ttusb)) |
1664 | printk("ttusb_init_controller: error\n"); | 1677 | printk("ttusb_init_controller: error\n"); |
1665 | 1678 | ||
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index ab33fec8a19f..0aa96df80fc2 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
@@ -1157,6 +1157,12 @@ static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec) | |||
1157 | ISO_BUF_COUNT), | 1157 | ISO_BUF_COUNT), |
1158 | &dec->iso_dma_handle); | 1158 | &dec->iso_dma_handle); |
1159 | 1159 | ||
1160 | if (!dec->iso_buffer) { | ||
1161 | dprintk("%s: pci_alloc_consistent - not enough memory\n", | ||
1162 | __func__); | ||
1163 | return -ENOMEM; | ||
1164 | } | ||
1165 | |||
1160 | memset(dec->iso_buffer, 0, | 1166 | memset(dec->iso_buffer, 0, |
1161 | ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT)); | 1167 | ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT)); |
1162 | 1168 | ||
@@ -1254,6 +1260,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec) | |||
1254 | dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, | 1260 | dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, |
1255 | GFP_ATOMIC, &dec->irq_dma_handle); | 1261 | GFP_ATOMIC, &dec->irq_dma_handle); |
1256 | if(!dec->irq_buffer) { | 1262 | if(!dec->irq_buffer) { |
1263 | usb_free_urb(dec->irq_urb); | ||
1257 | return -ENOMEM; | 1264 | return -ENOMEM; |
1258 | } | 1265 | } |
1259 | usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe, | 1266 | usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe, |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index ac3292d7646c..7a8d49ef646e 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -62,7 +62,7 @@ static int em28xx_isoc_audio_deinit(struct em28xx *dev) | |||
62 | 62 | ||
63 | dprintk("Stopping isoc\n"); | 63 | dprintk("Stopping isoc\n"); |
64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { | 64 | for (i = 0; i < EM28XX_AUDIO_BUFS; i++) { |
65 | usb_kill_urb(dev->adev->urb[i]); | 65 | usb_unlink_urb(dev->adev->urb[i]); |
66 | usb_free_urb(dev->adev->urb[i]); | 66 | usb_free_urb(dev->adev->urb[i]); |
67 | dev->adev->urb[i] = NULL; | 67 | dev->adev->urb[i] = NULL; |
68 | } | 68 | } |
@@ -75,7 +75,6 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
75 | struct em28xx *dev = urb->context; | 75 | struct em28xx *dev = urb->context; |
76 | int i; | 76 | int i; |
77 | unsigned int oldptr; | 77 | unsigned int oldptr; |
78 | unsigned long flags; | ||
79 | int period_elapsed = 0; | 78 | int period_elapsed = 0; |
80 | int status; | 79 | int status; |
81 | unsigned char *cp; | 80 | unsigned char *cp; |
@@ -96,9 +95,21 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
96 | if (!length) | 95 | if (!length) |
97 | continue; | 96 | continue; |
98 | 97 | ||
99 | spin_lock_irqsave(&dev->adev->slock, flags); | ||
100 | |||
101 | oldptr = dev->adev->hwptr_done_capture; | 98 | oldptr = dev->adev->hwptr_done_capture; |
99 | if (oldptr + length >= runtime->buffer_size) { | ||
100 | unsigned int cnt = | ||
101 | runtime->buffer_size - oldptr; | ||
102 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
103 | cnt * stride); | ||
104 | memcpy(runtime->dma_area, cp + cnt * stride, | ||
105 | length * stride - cnt * stride); | ||
106 | } else { | ||
107 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
108 | length * stride); | ||
109 | } | ||
110 | |||
111 | snd_pcm_stream_lock(substream); | ||
112 | |||
102 | dev->adev->hwptr_done_capture += length; | 113 | dev->adev->hwptr_done_capture += length; |
103 | if (dev->adev->hwptr_done_capture >= | 114 | if (dev->adev->hwptr_done_capture >= |
104 | runtime->buffer_size) | 115 | runtime->buffer_size) |
@@ -113,19 +124,7 @@ static void em28xx_audio_isocirq(struct urb *urb) | |||
113 | period_elapsed = 1; | 124 | period_elapsed = 1; |
114 | } | 125 | } |
115 | 126 | ||
116 | spin_unlock_irqrestore(&dev->adev->slock, flags); | 127 | snd_pcm_stream_unlock(substream); |
117 | |||
118 | if (oldptr + length >= runtime->buffer_size) { | ||
119 | unsigned int cnt = | ||
120 | runtime->buffer_size - oldptr; | ||
121 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
122 | cnt * stride); | ||
123 | memcpy(runtime->dma_area, cp + cnt * stride, | ||
124 | length * stride - cnt * stride); | ||
125 | } else { | ||
126 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
127 | length * stride); | ||
128 | } | ||
129 | } | 128 | } |
130 | if (period_elapsed) | 129 | if (period_elapsed) |
131 | snd_pcm_period_elapsed(substream); | 130 | snd_pcm_period_elapsed(substream); |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 5d837c16ee22..15e2b525310d 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -69,19 +69,33 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
69 | int ret, byte; | 69 | int ret, byte; |
70 | 70 | ||
71 | if (dev->state & DEV_DISCONNECTED) | 71 | if (dev->state & DEV_DISCONNECTED) |
72 | return(-ENODEV); | 72 | return -ENODEV; |
73 | |||
74 | if (len > URB_MAX_CTRL_SIZE) | ||
75 | return -EINVAL; | ||
73 | 76 | ||
74 | em28xx_regdbg("req=%02x, reg=%02x ", req, reg); | 77 | em28xx_regdbg("req=%02x, reg=%02x ", req, reg); |
75 | 78 | ||
79 | mutex_lock(&dev->ctrl_urb_lock); | ||
76 | ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, | 80 | ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, |
77 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 81 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
78 | 0x0000, reg, buf, len, HZ); | 82 | 0x0000, reg, dev->urb_buf, len, HZ); |
83 | if (ret < 0) { | ||
84 | if (reg_debug) | ||
85 | printk(" failed!\n"); | ||
86 | mutex_unlock(&dev->ctrl_urb_lock); | ||
87 | return ret; | ||
88 | } | ||
89 | |||
90 | if (len) | ||
91 | memcpy(buf, dev->urb_buf, len); | ||
92 | |||
93 | mutex_unlock(&dev->ctrl_urb_lock); | ||
79 | 94 | ||
80 | if (reg_debug) { | 95 | if (reg_debug) { |
81 | printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); | 96 | printk("%02x values: ", ret); |
82 | for (byte = 0; byte < len; byte++) | 97 | for (byte = 0; byte < len; byte++) |
83 | printk(" %02x", (unsigned char)buf[byte]); | 98 | printk(" %02x", (unsigned char)buf[byte]); |
84 | |||
85 | printk("\n"); | 99 | printk("\n"); |
86 | } | 100 | } |
87 | 101 | ||
@@ -102,16 +116,20 @@ int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg) | |||
102 | 116 | ||
103 | em28xx_regdbg("req=%02x, reg=%02x:", req, reg); | 117 | em28xx_regdbg("req=%02x, reg=%02x:", req, reg); |
104 | 118 | ||
119 | mutex_lock(&dev->ctrl_urb_lock); | ||
105 | ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, | 120 | ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, |
106 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 121 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
107 | 0x0000, reg, &val, 1, HZ); | 122 | 0x0000, reg, dev->urb_buf, 1, HZ); |
108 | 123 | val = dev->urb_buf[0]; | |
109 | if (reg_debug) | 124 | mutex_unlock(&dev->ctrl_urb_lock); |
110 | printk(ret < 0 ? " failed!\n" : | ||
111 | "%02x\n", (unsigned char) val); | ||
112 | 125 | ||
113 | if (ret < 0) | 126 | if (ret < 0) { |
127 | printk(" failed!\n"); | ||
114 | return ret; | 128 | return ret; |
129 | } | ||
130 | |||
131 | if (reg_debug) | ||
132 | printk("%02x\n", (unsigned char) val); | ||
115 | 133 | ||
116 | return val; | 134 | return val; |
117 | } | 135 | } |
@@ -130,19 +148,13 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
130 | { | 148 | { |
131 | int ret; | 149 | int ret; |
132 | 150 | ||
133 | /*usb_control_msg seems to expect a kmalloced buffer */ | ||
134 | unsigned char *bufs; | ||
135 | |||
136 | if (dev->state & DEV_DISCONNECTED) | 151 | if (dev->state & DEV_DISCONNECTED) |
137 | return -ENODEV; | 152 | return -ENODEV; |
138 | 153 | ||
139 | if (len < 1) | 154 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) |
140 | return -EINVAL; | 155 | return -EINVAL; |
141 | 156 | ||
142 | bufs = kmalloc(len, GFP_KERNEL); | ||
143 | |||
144 | em28xx_regdbg("req=%02x reg=%02x:", req, reg); | 157 | em28xx_regdbg("req=%02x reg=%02x:", req, reg); |
145 | |||
146 | if (reg_debug) { | 158 | if (reg_debug) { |
147 | int i; | 159 | int i; |
148 | for (i = 0; i < len; ++i) | 160 | for (i = 0; i < len; ++i) |
@@ -150,16 +162,16 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
150 | printk("\n"); | 162 | printk("\n"); |
151 | } | 163 | } |
152 | 164 | ||
153 | if (!bufs) | 165 | mutex_lock(&dev->ctrl_urb_lock); |
154 | return -ENOMEM; | 166 | memcpy(dev->urb_buf, buf, len); |
155 | memcpy(bufs, buf, len); | ||
156 | ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, | 167 | ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, |
157 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 168 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
158 | 0x0000, reg, bufs, len, HZ); | 169 | 0x0000, reg, dev->urb_buf, len, HZ); |
170 | mutex_unlock(&dev->ctrl_urb_lock); | ||
171 | |||
159 | if (dev->wait_after_write) | 172 | if (dev->wait_after_write) |
160 | msleep(dev->wait_after_write); | 173 | msleep(dev->wait_after_write); |
161 | 174 | ||
162 | kfree(bufs); | ||
163 | return ret; | 175 | return ret; |
164 | } | 176 | } |
165 | 177 | ||
@@ -270,6 +282,8 @@ static int em28xx_set_audio_source(struct em28xx *dev) | |||
270 | break; | 282 | break; |
271 | case EM28XX_AMUX_LINE_IN: | 283 | case EM28XX_AMUX_LINE_IN: |
272 | input = EM28XX_AUDIO_SRC_LINE; | 284 | input = EM28XX_AUDIO_SRC_LINE; |
285 | video = disable; | ||
286 | line = enable; | ||
273 | break; | 287 | break; |
274 | case EM28XX_AMUX_AC97_VIDEO: | 288 | case EM28XX_AMUX_AC97_VIDEO: |
275 | input = EM28XX_AUDIO_SRC_LINE; | 289 | input = EM28XX_AUDIO_SRC_LINE; |
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 3bab56b997fc..2360c61ddca9 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
@@ -337,9 +337,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
337 | /* Check if board has eeprom */ | 337 | /* Check if board has eeprom */ |
338 | err = i2c_master_recv(&dev->i2c_client, &buf, 0); | 338 | err = i2c_master_recv(&dev->i2c_client, &buf, 0); |
339 | if (err < 0) { | 339 | if (err < 0) { |
340 | em28xx_errdev("%s: i2c_master_recv failed! err [%d]\n", | 340 | em28xx_errdev("board has no eeprom\n"); |
341 | __func__, err); | 341 | memset(eedata, 0, len); |
342 | return err; | 342 | return -ENODEV; |
343 | } | 343 | } |
344 | 344 | ||
345 | buf = 0; | 345 | buf = 0; |
@@ -609,14 +609,16 @@ int em28xx_i2c_register(struct em28xx *dev) | |||
609 | dev->i2c_client.adapter = &dev->i2c_adap; | 609 | dev->i2c_client.adapter = &dev->i2c_adap; |
610 | 610 | ||
611 | retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); | 611 | retval = em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); |
612 | if (retval < 0) { | 612 | if ((retval < 0) && (retval != -ENODEV)) { |
613 | em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", | 613 | em28xx_errdev("%s: em28xx_i2_eeprom failed! retval [%d]\n", |
614 | __func__, retval); | 614 | __func__, retval); |
615 | |||
615 | return retval; | 616 | return retval; |
616 | } | 617 | } |
617 | 618 | ||
618 | if (i2c_scan) | 619 | if (i2c_scan) |
619 | em28xx_do_i2c_scan(dev); | 620 | em28xx_do_i2c_scan(dev); |
621 | |||
620 | return 0; | 622 | return 0; |
621 | } | 623 | } |
622 | 624 | ||
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index a1ab2ef45578..610f535a257c 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -73,6 +73,7 @@ MODULE_DESCRIPTION(DRIVER_DESC); | |||
73 | MODULE_LICENSE("GPL"); | 73 | MODULE_LICENSE("GPL"); |
74 | 74 | ||
75 | static LIST_HEAD(em28xx_devlist); | 75 | static LIST_HEAD(em28xx_devlist); |
76 | static DEFINE_MUTEX(em28xx_devlist_mutex); | ||
76 | 77 | ||
77 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 78 | static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; |
78 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; | 79 | static unsigned int video_nr[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET }; |
@@ -1519,7 +1520,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1519 | struct em28xx_fh *fh; | 1520 | struct em28xx_fh *fh; |
1520 | enum v4l2_buf_type fh_type = 0; | 1521 | enum v4l2_buf_type fh_type = 0; |
1521 | 1522 | ||
1522 | lock_kernel(); | 1523 | mutex_lock(&em28xx_devlist_mutex); |
1523 | list_for_each_entry(h, &em28xx_devlist, devlist) { | 1524 | list_for_each_entry(h, &em28xx_devlist, devlist) { |
1524 | if (h->vdev->minor == minor) { | 1525 | if (h->vdev->minor == minor) { |
1525 | dev = h; | 1526 | dev = h; |
@@ -1535,10 +1536,11 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1535 | dev = h; | 1536 | dev = h; |
1536 | } | 1537 | } |
1537 | } | 1538 | } |
1538 | if (NULL == dev) { | 1539 | mutex_unlock(&em28xx_devlist_mutex); |
1539 | unlock_kernel(); | 1540 | if (NULL == dev) |
1540 | return -ENODEV; | 1541 | return -ENODEV; |
1541 | } | 1542 | |
1543 | mutex_lock(&dev->lock); | ||
1542 | 1544 | ||
1543 | em28xx_videodbg("open minor=%d type=%s users=%d\n", | 1545 | em28xx_videodbg("open minor=%d type=%s users=%d\n", |
1544 | minor, v4l2_type_names[fh_type], dev->users); | 1546 | minor, v4l2_type_names[fh_type], dev->users); |
@@ -1547,10 +1549,9 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1547 | fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); | 1549 | fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); |
1548 | if (!fh) { | 1550 | if (!fh) { |
1549 | em28xx_errdev("em28xx-video.c: Out of memory?!\n"); | 1551 | em28xx_errdev("em28xx-video.c: Out of memory?!\n"); |
1550 | unlock_kernel(); | 1552 | mutex_unlock(&dev->lock); |
1551 | return -ENOMEM; | 1553 | return -ENOMEM; |
1552 | } | 1554 | } |
1553 | mutex_lock(&dev->lock); | ||
1554 | fh->dev = dev; | 1555 | fh->dev = dev; |
1555 | fh->radio = radio; | 1556 | fh->radio = radio; |
1556 | fh->type = fh_type; | 1557 | fh->type = fh_type; |
@@ -1584,7 +1585,6 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
1584 | sizeof(struct em28xx_buffer), fh); | 1585 | sizeof(struct em28xx_buffer), fh); |
1585 | 1586 | ||
1586 | mutex_unlock(&dev->lock); | 1587 | mutex_unlock(&dev->lock); |
1587 | unlock_kernel(); | ||
1588 | 1588 | ||
1589 | return errCode; | 1589 | return errCode; |
1590 | } | 1590 | } |
@@ -1871,6 +1871,7 @@ int em28xx_register_extension(struct em28xx_ops *ops) | |||
1871 | { | 1871 | { |
1872 | struct em28xx *dev = NULL; | 1872 | struct em28xx *dev = NULL; |
1873 | 1873 | ||
1874 | mutex_lock(&em28xx_devlist_mutex); | ||
1874 | mutex_lock(&em28xx_extension_devlist_lock); | 1875 | mutex_lock(&em28xx_extension_devlist_lock); |
1875 | list_add_tail(&ops->next, &em28xx_extension_devlist); | 1876 | list_add_tail(&ops->next, &em28xx_extension_devlist); |
1876 | list_for_each_entry(dev, &em28xx_devlist, devlist) { | 1877 | list_for_each_entry(dev, &em28xx_devlist, devlist) { |
@@ -1879,6 +1880,7 @@ int em28xx_register_extension(struct em28xx_ops *ops) | |||
1879 | } | 1880 | } |
1880 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); | 1881 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); |
1881 | mutex_unlock(&em28xx_extension_devlist_lock); | 1882 | mutex_unlock(&em28xx_extension_devlist_lock); |
1883 | mutex_unlock(&em28xx_devlist_mutex); | ||
1882 | return 0; | 1884 | return 0; |
1883 | } | 1885 | } |
1884 | EXPORT_SYMBOL(em28xx_register_extension); | 1886 | EXPORT_SYMBOL(em28xx_register_extension); |
@@ -1887,6 +1889,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops) | |||
1887 | { | 1889 | { |
1888 | struct em28xx *dev = NULL; | 1890 | struct em28xx *dev = NULL; |
1889 | 1891 | ||
1892 | mutex_lock(&em28xx_devlist_mutex); | ||
1890 | list_for_each_entry(dev, &em28xx_devlist, devlist) { | 1893 | list_for_each_entry(dev, &em28xx_devlist, devlist) { |
1891 | if (dev) | 1894 | if (dev) |
1892 | ops->fini(dev); | 1895 | ops->fini(dev); |
@@ -1896,6 +1899,7 @@ void em28xx_unregister_extension(struct em28xx_ops *ops) | |||
1896 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); | 1899 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); |
1897 | list_del(&ops->next); | 1900 | list_del(&ops->next); |
1898 | mutex_unlock(&em28xx_extension_devlist_lock); | 1901 | mutex_unlock(&em28xx_extension_devlist_lock); |
1902 | mutex_unlock(&em28xx_devlist_mutex); | ||
1899 | } | 1903 | } |
1900 | EXPORT_SYMBOL(em28xx_unregister_extension); | 1904 | EXPORT_SYMBOL(em28xx_unregister_extension); |
1901 | 1905 | ||
@@ -1921,6 +1925,60 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
1921 | } | 1925 | } |
1922 | 1926 | ||
1923 | 1927 | ||
1928 | static int register_analog_devices(struct em28xx *dev) | ||
1929 | { | ||
1930 | int ret; | ||
1931 | |||
1932 | /* allocate and fill video video_device struct */ | ||
1933 | dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video"); | ||
1934 | if (!dev->vdev) { | ||
1935 | em28xx_errdev("cannot allocate video_device.\n"); | ||
1936 | return -ENODEV; | ||
1937 | } | ||
1938 | |||
1939 | /* register v4l2 video video_device */ | ||
1940 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | ||
1941 | video_nr[dev->devno]); | ||
1942 | if (ret) { | ||
1943 | em28xx_errdev("unable to register video device (error=%i).\n", | ||
1944 | ret); | ||
1945 | return ret; | ||
1946 | } | ||
1947 | |||
1948 | /* Allocate and fill vbi video_device struct */ | ||
1949 | dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi"); | ||
1950 | |||
1951 | /* register v4l2 vbi video_device */ | ||
1952 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | ||
1953 | vbi_nr[dev->devno]); | ||
1954 | if (ret < 0) { | ||
1955 | em28xx_errdev("unable to register vbi device\n"); | ||
1956 | return ret; | ||
1957 | } | ||
1958 | |||
1959 | if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) { | ||
1960 | dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio"); | ||
1961 | if (!dev->radio_dev) { | ||
1962 | em28xx_errdev("cannot allocate video_device.\n"); | ||
1963 | return -ENODEV; | ||
1964 | } | ||
1965 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | ||
1966 | radio_nr[dev->devno]); | ||
1967 | if (ret < 0) { | ||
1968 | em28xx_errdev("can't register radio device\n"); | ||
1969 | return ret; | ||
1970 | } | ||
1971 | em28xx_info("Registered radio device as /dev/radio%d\n", | ||
1972 | dev->radio_dev->num); | ||
1973 | } | ||
1974 | |||
1975 | em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", | ||
1976 | dev->vdev->num, dev->vbi_dev->num); | ||
1977 | |||
1978 | return 0; | ||
1979 | } | ||
1980 | |||
1981 | |||
1924 | /* | 1982 | /* |
1925 | * em28xx_init_dev() | 1983 | * em28xx_init_dev() |
1926 | * allocates and inits the device structs, registers i2c bus and v4l device | 1984 | * allocates and inits the device structs, registers i2c bus and v4l device |
@@ -1936,6 +1994,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1936 | 1994 | ||
1937 | dev->udev = udev; | 1995 | dev->udev = udev; |
1938 | mutex_init(&dev->lock); | 1996 | mutex_init(&dev->lock); |
1997 | mutex_init(&dev->ctrl_urb_lock); | ||
1939 | spin_lock_init(&dev->slock); | 1998 | spin_lock_init(&dev->slock); |
1940 | init_waitqueue_head(&dev->open); | 1999 | init_waitqueue_head(&dev->open); |
1941 | init_waitqueue_head(&dev->wait_frame); | 2000 | init_waitqueue_head(&dev->wait_frame); |
@@ -1953,8 +2012,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
1953 | errCode = em28xx_config(dev); | 2012 | errCode = em28xx_config(dev); |
1954 | if (errCode) { | 2013 | if (errCode) { |
1955 | em28xx_errdev("error configuring device\n"); | 2014 | em28xx_errdev("error configuring device\n"); |
1956 | em28xx_devused &= ~(1<<dev->devno); | ||
1957 | kfree(dev); | ||
1958 | return -ENOMEM; | 2015 | return -ENOMEM; |
1959 | } | 2016 | } |
1960 | 2017 | ||
@@ -2001,50 +2058,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2001 | return errCode; | 2058 | return errCode; |
2002 | } | 2059 | } |
2003 | 2060 | ||
2004 | list_add_tail(&dev->devlist, &em28xx_devlist); | ||
2005 | |||
2006 | /* allocate and fill video video_device struct */ | ||
2007 | dev->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video"); | ||
2008 | if (NULL == dev->vdev) { | ||
2009 | em28xx_errdev("cannot allocate video_device.\n"); | ||
2010 | goto fail_unreg; | ||
2011 | } | ||
2012 | |||
2013 | /* register v4l2 video video_device */ | ||
2014 | retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | ||
2015 | video_nr[dev->devno]); | ||
2016 | if (retval) { | ||
2017 | em28xx_errdev("unable to register video device (error=%i).\n", | ||
2018 | retval); | ||
2019 | goto fail_unreg; | ||
2020 | } | ||
2021 | |||
2022 | /* Allocate and fill vbi video_device struct */ | ||
2023 | dev->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, "vbi"); | ||
2024 | /* register v4l2 vbi video_device */ | ||
2025 | if (video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | ||
2026 | vbi_nr[dev->devno]) < 0) { | ||
2027 | em28xx_errdev("unable to register vbi device\n"); | ||
2028 | retval = -ENODEV; | ||
2029 | goto fail_unreg; | ||
2030 | } | ||
2031 | |||
2032 | if (em28xx_boards[dev->model].radio.type == EM28XX_RADIO) { | ||
2033 | dev->radio_dev = em28xx_vdev_init(dev, &em28xx_radio_template, "radio"); | ||
2034 | if (NULL == dev->radio_dev) { | ||
2035 | em28xx_errdev("cannot allocate video_device.\n"); | ||
2036 | goto fail_unreg; | ||
2037 | } | ||
2038 | retval = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | ||
2039 | radio_nr[dev->devno]); | ||
2040 | if (retval < 0) { | ||
2041 | em28xx_errdev("can't register radio device\n"); | ||
2042 | goto fail_unreg; | ||
2043 | } | ||
2044 | em28xx_info("Registered radio device as /dev/radio%d\n", | ||
2045 | dev->radio_dev->num); | ||
2046 | } | ||
2047 | |||
2048 | /* init video dma queues */ | 2061 | /* init video dma queues */ |
2049 | INIT_LIST_HEAD(&dev->vidq.active); | 2062 | INIT_LIST_HEAD(&dev->vidq.active); |
2050 | INIT_LIST_HEAD(&dev->vidq.queued); | 2063 | INIT_LIST_HEAD(&dev->vidq.queued); |
@@ -2071,8 +2084,14 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2071 | 2084 | ||
2072 | video_mux(dev, 0); | 2085 | video_mux(dev, 0); |
2073 | 2086 | ||
2074 | em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", | 2087 | mutex_lock(&em28xx_devlist_mutex); |
2075 | dev->vdev->num, dev->vbi_dev->num); | 2088 | list_add_tail(&dev->devlist, &em28xx_devlist); |
2089 | retval = register_analog_devices(dev); | ||
2090 | if (retval < 0) { | ||
2091 | em28xx_release_resources(dev); | ||
2092 | mutex_unlock(&em28xx_devlist_mutex); | ||
2093 | goto fail_reg_devices; | ||
2094 | } | ||
2076 | 2095 | ||
2077 | mutex_lock(&em28xx_extension_devlist_lock); | 2096 | mutex_lock(&em28xx_extension_devlist_lock); |
2078 | if (!list_empty(&em28xx_extension_devlist)) { | 2097 | if (!list_empty(&em28xx_extension_devlist)) { |
@@ -2082,13 +2101,12 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
2082 | } | 2101 | } |
2083 | } | 2102 | } |
2084 | mutex_unlock(&em28xx_extension_devlist_lock); | 2103 | mutex_unlock(&em28xx_extension_devlist_lock); |
2104 | mutex_unlock(&em28xx_devlist_mutex); | ||
2085 | 2105 | ||
2086 | return 0; | 2106 | return 0; |
2087 | 2107 | ||
2088 | fail_unreg: | 2108 | fail_reg_devices: |
2089 | em28xx_release_resources(dev); | ||
2090 | mutex_unlock(&dev->lock); | 2109 | mutex_unlock(&dev->lock); |
2091 | kfree(dev); | ||
2092 | return retval; | 2110 | return retval; |
2093 | } | 2111 | } |
2094 | 2112 | ||
@@ -2231,8 +2249,12 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
2231 | 2249 | ||
2232 | /* allocate device struct */ | 2250 | /* allocate device struct */ |
2233 | retval = em28xx_init_dev(&dev, udev, nr); | 2251 | retval = em28xx_init_dev(&dev, udev, nr); |
2234 | if (retval) | 2252 | if (retval) { |
2253 | em28xx_devused &= ~(1<<dev->devno); | ||
2254 | kfree(dev); | ||
2255 | |||
2235 | return retval; | 2256 | return retval; |
2257 | } | ||
2236 | 2258 | ||
2237 | em28xx_info("Found %s\n", em28xx_boards[dev->model].name); | 2259 | em28xx_info("Found %s\n", em28xx_boards[dev->model].name); |
2238 | 2260 | ||
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 82781178e0a3..5956e9b3062f 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -102,6 +102,9 @@ | |||
102 | #define EM28XX_MIN_BUF 4 | 102 | #define EM28XX_MIN_BUF 4 |
103 | #define EM28XX_DEF_BUF 8 | 103 | #define EM28XX_DEF_BUF 8 |
104 | 104 | ||
105 | /*Limits the max URB message size */ | ||
106 | #define URB_MAX_CTRL_SIZE 80 | ||
107 | |||
105 | /* Params for validated field */ | 108 | /* Params for validated field */ |
106 | #define EM28XX_BOARD_NOT_VALIDATED 1 | 109 | #define EM28XX_BOARD_NOT_VALIDATED 1 |
107 | #define EM28XX_BOARD_VALIDATED 0 | 110 | #define EM28XX_BOARD_VALIDATED 0 |
@@ -430,6 +433,7 @@ struct em28xx { | |||
430 | 433 | ||
431 | /* locks */ | 434 | /* locks */ |
432 | struct mutex lock; | 435 | struct mutex lock; |
436 | struct mutex ctrl_urb_lock; /* protects urb_buf */ | ||
433 | /* spinlock_t queue_lock; */ | 437 | /* spinlock_t queue_lock; */ |
434 | struct list_head inqueue, outqueue; | 438 | struct list_head inqueue, outqueue; |
435 | wait_queue_head_t open, wait_frame, wait_stream; | 439 | wait_queue_head_t open, wait_frame, wait_stream; |
@@ -451,6 +455,8 @@ struct em28xx { | |||
451 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | 455 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ |
452 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ | 456 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ |
453 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ | 457 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ |
458 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ | ||
459 | |||
454 | /* helper funcs that call usb_control_msg */ | 460 | /* helper funcs that call usb_control_msg */ |
455 | int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, | 461 | int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, |
456 | char *buf, int len); | 462 | char *buf, int len); |
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index a9d51ba7c57c..de28354ea5ba 100644 --- a/drivers/media/video/gspca/conex.c +++ b/drivers/media/video/gspca/conex.c | |||
@@ -846,10 +846,13 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | 848 | ||
849 | /* called on streamoff with alt 0 and on disconnect */ | ||
849 | static void sd_stop0(struct gspca_dev *gspca_dev) | 850 | static void sd_stop0(struct gspca_dev *gspca_dev) |
850 | { | 851 | { |
851 | int retry = 50; | 852 | int retry = 50; |
852 | 853 | ||
854 | if (!gspca_dev->present) | ||
855 | return; | ||
853 | reg_w_val(gspca_dev, 0x0000, 0x00); | 856 | reg_w_val(gspca_dev, 0x0000, 0x00); |
854 | reg_r(gspca_dev, 0x0002, 1); | 857 | reg_r(gspca_dev, 0x0002, 1); |
855 | reg_w_val(gspca_dev, 0x0053, 0x00); | 858 | reg_w_val(gspca_dev, 0x0053, 0x00); |
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c index 65d3cbfe6b27..607942fd7970 100644 --- a/drivers/media/video/gspca/finepix.c +++ b/drivers/media/video/gspca/finepix.c | |||
@@ -276,6 +276,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
276 | /* Stop the state machine */ | 276 | /* Stop the state machine */ |
277 | if (dev->state != FPIX_NOP) | 277 | if (dev->state != FPIX_NOP) |
278 | wait_for_completion(&dev->can_close); | 278 | wait_for_completion(&dev->can_close); |
279 | } | ||
280 | |||
281 | /* called on streamoff with alt 0 and disconnect */ | ||
282 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
283 | { | ||
284 | struct usb_fpix *dev = (struct usb_fpix *) gspca_dev; | ||
279 | 285 | ||
280 | usb_free_urb(dev->control_urb); | 286 | usb_free_urb(dev->control_urb); |
281 | dev->control_urb = NULL; | 287 | dev->control_urb = NULL; |
@@ -385,6 +391,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
385 | error: | 391 | error: |
386 | /* Free the ressources */ | 392 | /* Free the ressources */ |
387 | sd_stopN(gspca_dev); | 393 | sd_stopN(gspca_dev); |
394 | sd_stop0(gspca_dev); | ||
388 | return ret; | 395 | return ret; |
389 | } | 396 | } |
390 | 397 | ||
@@ -425,6 +432,7 @@ static const struct sd_desc sd_desc = { | |||
425 | .init = sd_init, | 432 | .init = sd_init, |
426 | .start = sd_start, | 433 | .start = sd_start, |
427 | .stopN = sd_stopN, | 434 | .stopN = sd_stopN, |
435 | .stop0 = sd_stop0, | ||
428 | }; | 436 | }; |
429 | 437 | ||
430 | /* -- device connect -- */ | 438 | /* -- device connect -- */ |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index e48fbfc8ad05..748a87e82e44 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -646,15 +646,14 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev) | |||
646 | { | 646 | { |
647 | gspca_dev->streaming = 0; | 647 | gspca_dev->streaming = 0; |
648 | atomic_set(&gspca_dev->nevent, 0); | 648 | atomic_set(&gspca_dev->nevent, 0); |
649 | if (gspca_dev->present) { | 649 | if (gspca_dev->present |
650 | if (gspca_dev->sd_desc->stopN) | 650 | && gspca_dev->sd_desc->stopN) |
651 | gspca_dev->sd_desc->stopN(gspca_dev); | 651 | gspca_dev->sd_desc->stopN(gspca_dev); |
652 | destroy_urbs(gspca_dev); | 652 | destroy_urbs(gspca_dev); |
653 | gspca_set_alt0(gspca_dev); | 653 | gspca_set_alt0(gspca_dev); |
654 | if (gspca_dev->sd_desc->stop0) | 654 | if (gspca_dev->sd_desc->stop0) |
655 | gspca_dev->sd_desc->stop0(gspca_dev); | 655 | gspca_dev->sd_desc->stop0(gspca_dev); |
656 | PDEBUG(D_STREAM, "stream off OK"); | 656 | PDEBUG(D_STREAM, "stream off OK"); |
657 | } | ||
658 | } | 657 | } |
659 | 658 | ||
660 | static void gspca_set_default_mode(struct gspca_dev *gspca_dev) | 659 | static void gspca_set_default_mode(struct gspca_dev *gspca_dev) |
@@ -863,7 +862,7 @@ static int dev_open(struct inode *inode, struct file *file) | |||
863 | int ret; | 862 | int ret; |
864 | 863 | ||
865 | PDEBUG(D_STREAM, "%s open", current->comm); | 864 | PDEBUG(D_STREAM, "%s open", current->comm); |
866 | gspca_dev = (struct gspca_dev *) video_devdata(file); | 865 | gspca_dev = video_drvdata(file); |
867 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) | 866 | if (mutex_lock_interruptible(&gspca_dev->queue_lock)) |
868 | return -ERESTARTSYS; | 867 | return -ERESTARTSYS; |
869 | if (!gspca_dev->present) { | 868 | if (!gspca_dev->present) { |
@@ -875,6 +874,13 @@ static int dev_open(struct inode *inode, struct file *file) | |||
875 | ret = -EBUSY; | 874 | ret = -EBUSY; |
876 | goto out; | 875 | goto out; |
877 | } | 876 | } |
877 | |||
878 | /* protect the subdriver against rmmod */ | ||
879 | if (!try_module_get(gspca_dev->module)) { | ||
880 | ret = -ENODEV; | ||
881 | goto out; | ||
882 | } | ||
883 | |||
878 | gspca_dev->users++; | 884 | gspca_dev->users++; |
879 | 885 | ||
880 | /* one more user */ | 886 | /* one more user */ |
@@ -884,10 +890,10 @@ static int dev_open(struct inode *inode, struct file *file) | |||
884 | #ifdef GSPCA_DEBUG | 890 | #ifdef GSPCA_DEBUG |
885 | /* activate the v4l2 debug */ | 891 | /* activate the v4l2 debug */ |
886 | if (gspca_debug & D_V4L2) | 892 | if (gspca_debug & D_V4L2) |
887 | gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL | 893 | gspca_dev->vdev->debug |= V4L2_DEBUG_IOCTL |
888 | | V4L2_DEBUG_IOCTL_ARG; | 894 | | V4L2_DEBUG_IOCTL_ARG; |
889 | else | 895 | else |
890 | gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL | 896 | gspca_dev->vdev->debug &= ~(V4L2_DEBUG_IOCTL |
891 | | V4L2_DEBUG_IOCTL_ARG); | 897 | | V4L2_DEBUG_IOCTL_ARG); |
892 | #endif | 898 | #endif |
893 | ret = 0; | 899 | ret = 0; |
@@ -921,6 +927,7 @@ static int dev_close(struct inode *inode, struct file *file) | |||
921 | gspca_dev->memory = GSPCA_MEMORY_NO; | 927 | gspca_dev->memory = GSPCA_MEMORY_NO; |
922 | } | 928 | } |
923 | file->private_data = NULL; | 929 | file->private_data = NULL; |
930 | module_put(gspca_dev->module); | ||
924 | mutex_unlock(&gspca_dev->queue_lock); | 931 | mutex_unlock(&gspca_dev->queue_lock); |
925 | 932 | ||
926 | PDEBUG(D_STREAM, "close done"); | 933 | PDEBUG(D_STREAM, "close done"); |
@@ -1748,11 +1755,6 @@ out: | |||
1748 | return ret; | 1755 | return ret; |
1749 | } | 1756 | } |
1750 | 1757 | ||
1751 | static void dev_release(struct video_device *vfd) | ||
1752 | { | ||
1753 | /* nothing */ | ||
1754 | } | ||
1755 | |||
1756 | static struct file_operations dev_fops = { | 1758 | static struct file_operations dev_fops = { |
1757 | .owner = THIS_MODULE, | 1759 | .owner = THIS_MODULE, |
1758 | .open = dev_open, | 1760 | .open = dev_open, |
@@ -1800,7 +1802,7 @@ static struct video_device gspca_template = { | |||
1800 | .name = "gspca main driver", | 1802 | .name = "gspca main driver", |
1801 | .fops = &dev_fops, | 1803 | .fops = &dev_fops, |
1802 | .ioctl_ops = &dev_ioctl_ops, | 1804 | .ioctl_ops = &dev_ioctl_ops, |
1803 | .release = dev_release, /* mandatory */ | 1805 | .release = video_device_release, |
1804 | .minor = -1, | 1806 | .minor = -1, |
1805 | }; | 1807 | }; |
1806 | 1808 | ||
@@ -1869,17 +1871,18 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
1869 | init_waitqueue_head(&gspca_dev->wq); | 1871 | init_waitqueue_head(&gspca_dev->wq); |
1870 | 1872 | ||
1871 | /* init video stuff */ | 1873 | /* init video stuff */ |
1872 | memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); | 1874 | gspca_dev->vdev = video_device_alloc(); |
1873 | gspca_dev->vdev.parent = &dev->dev; | 1875 | memcpy(gspca_dev->vdev, &gspca_template, sizeof gspca_template); |
1874 | memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); | 1876 | gspca_dev->vdev->parent = &dev->dev; |
1875 | gspca_dev->vdev.fops = &gspca_dev->fops; | 1877 | gspca_dev->module = module; |
1876 | gspca_dev->fops.owner = module; /* module protection */ | ||
1877 | gspca_dev->present = 1; | 1878 | gspca_dev->present = 1; |
1878 | ret = video_register_device(&gspca_dev->vdev, | 1879 | video_set_drvdata(gspca_dev->vdev, gspca_dev); |
1880 | ret = video_register_device(gspca_dev->vdev, | ||
1879 | VFL_TYPE_GRABBER, | 1881 | VFL_TYPE_GRABBER, |
1880 | video_nr); | 1882 | video_nr); |
1881 | if (ret < 0) { | 1883 | if (ret < 0) { |
1882 | err("video_register_device err %d", ret); | 1884 | err("video_register_device err %d", ret); |
1885 | video_device_release(gspca_dev->vdev); | ||
1883 | goto out; | 1886 | goto out; |
1884 | } | 1887 | } |
1885 | 1888 | ||
@@ -1887,7 +1890,8 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
1887 | PDEBUG(D_PROBE, "probe ok"); | 1890 | PDEBUG(D_PROBE, "probe ok"); |
1888 | return 0; | 1891 | return 0; |
1889 | out: | 1892 | out: |
1890 | kref_put(&gspca_dev->kref, gspca_delete); | 1893 | kfree(gspca_dev->usb_buf); |
1894 | kfree(gspca_dev); | ||
1891 | return ret; | 1895 | return ret; |
1892 | } | 1896 | } |
1893 | EXPORT_SYMBOL(gspca_dev_probe); | 1897 | EXPORT_SYMBOL(gspca_dev_probe); |
@@ -1905,7 +1909,7 @@ void gspca_disconnect(struct usb_interface *intf) | |||
1905 | usb_set_intfdata(intf, NULL); | 1909 | usb_set_intfdata(intf, NULL); |
1906 | 1910 | ||
1907 | /* We don't want people trying to open up the device */ | 1911 | /* We don't want people trying to open up the device */ |
1908 | video_unregister_device(&gspca_dev->vdev); | 1912 | video_unregister_device(gspca_dev->vdev); |
1909 | 1913 | ||
1910 | gspca_dev->present = 0; | 1914 | gspca_dev->present = 0; |
1911 | gspca_dev->streaming = 0; | 1915 | gspca_dev->streaming = 0; |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index 1d9dc90b4791..d25e8d69373b 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -97,7 +97,7 @@ struct sd_desc { | |||
97 | cam_pkt_op pkt_scan; | 97 | cam_pkt_op pkt_scan; |
98 | /* optional operations */ | 98 | /* optional operations */ |
99 | cam_v_op stopN; /* called on stream off - main alt */ | 99 | cam_v_op stopN; /* called on stream off - main alt */ |
100 | cam_v_op stop0; /* called on stream off - alt 0 */ | 100 | cam_v_op stop0; /* called on stream off & disconnect - alt 0 */ |
101 | cam_v_op dq_callback; /* called when a frame has been dequeued */ | 101 | cam_v_op dq_callback; /* called when a frame has been dequeued */ |
102 | cam_jpg_op get_jcomp; | 102 | cam_jpg_op get_jcomp; |
103 | cam_jpg_op set_jcomp; | 103 | cam_jpg_op set_jcomp; |
@@ -120,8 +120,8 @@ struct gspca_frame { | |||
120 | }; | 120 | }; |
121 | 121 | ||
122 | struct gspca_dev { | 122 | struct gspca_dev { |
123 | struct video_device vdev; /* !! must be the first item */ | 123 | struct video_device *vdev; |
124 | struct file_operations fops; | 124 | struct module *module; /* subdriver handling the device */ |
125 | struct usb_device *dev; | 125 | struct usb_device *dev; |
126 | struct kref kref; | 126 | struct kref kref; |
127 | struct file *capt_file; /* file doing video capture */ | 127 | struct file *capt_file; /* file doing video capture */ |
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index e5ff9a6199ef..fbd45e235d97 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -749,10 +749,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
749 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ | 749 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ |
750 | } | 750 | } |
751 | 751 | ||
752 | /* called on streamoff with alt 0 and on disconnect */ | ||
752 | static void sd_stop0(struct gspca_dev *gspca_dev) | 753 | static void sd_stop0(struct gspca_dev *gspca_dev) |
753 | { | 754 | { |
754 | struct sd *sd = (struct sd *) gspca_dev; | 755 | struct sd *sd = (struct sd *) gspca_dev; |
755 | 756 | ||
757 | if (!gspca_dev->present) | ||
758 | return; | ||
756 | if (sd->sensor == SENSOR_PAC7302) { | 759 | if (sd->sensor == SENSOR_PAC7302) { |
757 | reg_w(gspca_dev, 0xff, 0x01); | 760 | reg_w(gspca_dev, 0xff, 0x01); |
758 | reg_w(gspca_dev, 0x78, 0x40); | 761 | reg_w(gspca_dev, 0x78, 0x40); |
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c index b742f260c7ca..e29954c1c38c 100644 --- a/drivers/media/video/gspca/spca501.c +++ b/drivers/media/video/gspca/spca501.c | |||
@@ -2022,8 +2022,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
2022 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); | 2022 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | /* called on streamoff with alt 0 and on disconnect */ | ||
2025 | static void sd_stop0(struct gspca_dev *gspca_dev) | 2026 | static void sd_stop0(struct gspca_dev *gspca_dev) |
2026 | { | 2027 | { |
2028 | if (!gspca_dev->present) | ||
2029 | return; | ||
2027 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); | 2030 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); |
2028 | } | 2031 | } |
2029 | 2032 | ||
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c index b345749213cf..895b9fe4018c 100644 --- a/drivers/media/video/gspca/spca505.c +++ b/drivers/media/video/gspca/spca505.c | |||
@@ -742,8 +742,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
742 | reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); | 742 | reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); |
743 | } | 743 | } |
744 | 744 | ||
745 | /* called on streamoff with alt 0 and on disconnect */ | ||
745 | static void sd_stop0(struct gspca_dev *gspca_dev) | 746 | static void sd_stop0(struct gspca_dev *gspca_dev) |
746 | { | 747 | { |
748 | if (!gspca_dev->present) | ||
749 | return; | ||
750 | |||
747 | /* This maybe reset or power control */ | 751 | /* This maybe reset or power control */ |
748 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); | 752 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); |
749 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); | 753 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); |
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c index 020a03c466c1..c3de4e44123d 100644 --- a/drivers/media/video/gspca/spca561.c +++ b/drivers/media/video/gspca/spca561.c | |||
@@ -766,10 +766,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | /* called on streamoff with alt 0 and on disconnect */ | ||
769 | static void sd_stop0(struct gspca_dev *gspca_dev) | 770 | static void sd_stop0(struct gspca_dev *gspca_dev) |
770 | { | 771 | { |
771 | struct sd *sd = (struct sd *) gspca_dev; | 772 | struct sd *sd = (struct sd *) gspca_dev; |
772 | 773 | ||
774 | if (!gspca_dev->present) | ||
775 | return; | ||
773 | if (sd->chip_revision == Rev012A) { | 776 | if (sd->chip_revision == Rev012A) { |
774 | reg_w_val(gspca_dev->dev, 0x8118, 0x29); | 777 | reg_w_val(gspca_dev->dev, 0x8118, 0x29); |
775 | reg_w_val(gspca_dev->dev, 0x8114, 0x08); | 778 | reg_w_val(gspca_dev->dev, 0x8114, 0x08); |
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index be46d9232540..17af353ddd1c 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c | |||
@@ -1633,10 +1633,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1633 | reg_w(dev, 0xa0, 0x09, 0xb003); | 1633 | reg_w(dev, 0xa0, 0x09, 0xb003); |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | /* called on streamoff with alt 0 and on disconnect */ | ||
1636 | static void sd_stop0(struct gspca_dev *gspca_dev) | 1637 | static void sd_stop0(struct gspca_dev *gspca_dev) |
1637 | { | 1638 | { |
1638 | struct usb_device *dev = gspca_dev->dev; | 1639 | struct usb_device *dev = gspca_dev->dev; |
1639 | 1640 | ||
1641 | if (!gspca_dev->present) | ||
1642 | return; | ||
1640 | reg_w(dev, 0x89, 0xffff, 0xffff); | 1643 | reg_w(dev, 0x89, 0xffff, 0xffff); |
1641 | } | 1644 | } |
1642 | 1645 | ||
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index 8b3101d347c3..0befacf49855 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -7336,10 +7336,13 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
7336 | return 0; | 7336 | return 0; |
7337 | } | 7337 | } |
7338 | 7338 | ||
7339 | /* called on streamoff with alt 0 and on disconnect */ | ||
7339 | static void sd_stop0(struct gspca_dev *gspca_dev) | 7340 | static void sd_stop0(struct gspca_dev *gspca_dev) |
7340 | { | 7341 | { |
7341 | struct sd *sd = (struct sd *) gspca_dev; | 7342 | struct sd *sd = (struct sd *) gspca_dev; |
7342 | 7343 | ||
7344 | if (!gspca_dev->present) | ||
7345 | return; | ||
7343 | send_unknown(gspca_dev->dev, sd->sensor); | 7346 | send_unknown(gspca_dev->dev, sd->sensor); |
7344 | } | 7347 | } |
7345 | 7348 | ||
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 5272926db73e..3c3f8cf73108 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -192,7 +192,7 @@ struct s2255_dmaqueue { | |||
192 | #define S2255_FW_FAILED 3 | 192 | #define S2255_FW_FAILED 3 |
193 | #define S2255_FW_DISCONNECTING 4 | 193 | #define S2255_FW_DISCONNECTING 4 |
194 | 194 | ||
195 | #define S2255_FW_MARKER 0x22552f2f | 195 | #define S2255_FW_MARKER cpu_to_le32(0x22552f2f) |
196 | /* 2255 read states */ | 196 | /* 2255 read states */ |
197 | #define S2255_READ_IDLE 0 | 197 | #define S2255_READ_IDLE 0 |
198 | #define S2255_READ_FRAME 1 | 198 | #define S2255_READ_FRAME 1 |
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index b59e47272abf..3720f0e03a16 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * experimental driver for simple i2c audio chips. | 2 | * Driver for simple i2c audio chips. |
3 | * | 3 | * |
4 | * Copyright (c) 2000 Gerd Knorr | 4 | * Copyright (c) 2000 Gerd Knorr |
5 | * based on code by: | 5 | * based on code by: |
@@ -7,6 +7,10 @@ | |||
7 | * Steve VanDeBogart (vandebo@uclink.berkeley.edu) | 7 | * Steve VanDeBogart (vandebo@uclink.berkeley.edu) |
8 | * Greg Alexander (galexand@acm.org) | 8 | * Greg Alexander (galexand@acm.org) |
9 | * | 9 | * |
10 | * Copyright(c) 2005-2008 Mauro Carvalho Chehab | ||
11 | * - Some cleanups, code fixes, etc | ||
12 | * - Convert it to V4L2 API | ||
13 | * | ||
10 | * This code is placed under the terms of the GNU General Public License | 14 | * This code is placed under the terms of the GNU General Public License |
11 | * | 15 | * |
12 | * OPTIONS: | 16 | * OPTIONS: |
@@ -30,6 +34,7 @@ | |||
30 | 34 | ||
31 | #include <media/tvaudio.h> | 35 | #include <media/tvaudio.h> |
32 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
37 | #include <media/v4l2-ioctl.h> | ||
33 | #include <media/v4l2-chip-ident.h> | 38 | #include <media/v4l2-chip-ident.h> |
34 | #include <media/v4l2-i2c-drv-legacy.h> | 39 | #include <media/v4l2-i2c-drv-legacy.h> |
35 | 40 | ||
@@ -58,7 +63,6 @@ typedef int (*checkit)(struct CHIPSTATE*); | |||
58 | typedef int (*initialize)(struct CHIPSTATE*); | 63 | typedef int (*initialize)(struct CHIPSTATE*); |
59 | typedef int (*getmode)(struct CHIPSTATE*); | 64 | typedef int (*getmode)(struct CHIPSTATE*); |
60 | typedef void (*setmode)(struct CHIPSTATE*, int mode); | 65 | typedef void (*setmode)(struct CHIPSTATE*, int mode); |
61 | typedef void (*checkmode)(struct CHIPSTATE*); | ||
62 | 66 | ||
63 | /* i2c command */ | 67 | /* i2c command */ |
64 | typedef struct AUDIOCMD { | 68 | typedef struct AUDIOCMD { |
@@ -79,6 +83,7 @@ struct CHIPDESC { | |||
79 | #define CHIP_HAS_VOLUME 1 | 83 | #define CHIP_HAS_VOLUME 1 |
80 | #define CHIP_HAS_BASSTREBLE 2 | 84 | #define CHIP_HAS_BASSTREBLE 2 |
81 | #define CHIP_HAS_INPUTSEL 4 | 85 | #define CHIP_HAS_INPUTSEL 4 |
86 | #define CHIP_NEED_CHECKMODE 8 | ||
82 | 87 | ||
83 | /* various i2c command sequences */ | 88 | /* various i2c command sequences */ |
84 | audiocmd init; | 89 | audiocmd init; |
@@ -96,23 +101,20 @@ struct CHIPDESC { | |||
96 | getmode getmode; | 101 | getmode getmode; |
97 | setmode setmode; | 102 | setmode setmode; |
98 | 103 | ||
99 | /* check / autoswitch audio after channel switches */ | ||
100 | checkmode checkmode; | ||
101 | |||
102 | /* input switch register + values for v4l inputs */ | 104 | /* input switch register + values for v4l inputs */ |
103 | int inputreg; | 105 | int inputreg; |
104 | int inputmap[4]; | 106 | int inputmap[4]; |
105 | int inputmute; | 107 | int inputmute; |
106 | int inputmask; | 108 | int inputmask; |
107 | }; | 109 | }; |
108 | static struct CHIPDESC chiplist[]; | ||
109 | 110 | ||
110 | /* current state of the chip */ | 111 | /* current state of the chip */ |
111 | struct CHIPSTATE { | 112 | struct CHIPSTATE { |
112 | struct i2c_client *c; | 113 | struct i2c_client *c; |
113 | 114 | ||
114 | /* index into CHIPDESC array */ | 115 | /* chip-specific description - should point to |
115 | int type; | 116 | an entry at CHIPDESC table */ |
117 | struct CHIPDESC *desc; | ||
116 | 118 | ||
117 | /* shadow register set */ | 119 | /* shadow register set */ |
118 | audiocmd shadow; | 120 | audiocmd shadow; |
@@ -152,7 +154,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
152 | { | 154 | { |
153 | unsigned char buffer[2]; | 155 | unsigned char buffer[2]; |
154 | 156 | ||
155 | if (-1 == subaddr) { | 157 | if (subaddr < 0) { |
156 | v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", | 158 | v4l_dbg(1, debug, chip->c, "%s: chip_write: 0x%x\n", |
157 | chip->c->name, val); | 159 | chip->c->name, val); |
158 | chip->shadow.bytes[1] = val; | 160 | chip->shadow.bytes[1] = val; |
@@ -163,6 +165,13 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
163 | return -1; | 165 | return -1; |
164 | } | 166 | } |
165 | } else { | 167 | } else { |
168 | if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
169 | v4l_info(chip->c, | ||
170 | "Tried to access a non-existent register: %d\n", | ||
171 | subaddr); | ||
172 | return -EINVAL; | ||
173 | } | ||
174 | |||
166 | v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", | 175 | v4l_dbg(1, debug, chip->c, "%s: chip_write: reg%d=0x%x\n", |
167 | chip->c->name, subaddr, val); | 176 | chip->c->name, subaddr, val); |
168 | chip->shadow.bytes[subaddr+1] = val; | 177 | chip->shadow.bytes[subaddr+1] = val; |
@@ -177,12 +186,20 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
177 | return 0; | 186 | return 0; |
178 | } | 187 | } |
179 | 188 | ||
180 | static int chip_write_masked(struct CHIPSTATE *chip, int subaddr, int val, int mask) | 189 | static int chip_write_masked(struct CHIPSTATE *chip, |
190 | int subaddr, int val, int mask) | ||
181 | { | 191 | { |
182 | if (mask != 0) { | 192 | if (mask != 0) { |
183 | if (-1 == subaddr) { | 193 | if (subaddr < 0) { |
184 | val = (chip->shadow.bytes[1] & ~mask) | (val & mask); | 194 | val = (chip->shadow.bytes[1] & ~mask) | (val & mask); |
185 | } else { | 195 | } else { |
196 | if (subaddr + 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
197 | v4l_info(chip->c, | ||
198 | "Tried to access a non-existent register: %d\n", | ||
199 | subaddr); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
186 | val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); | 203 | val = (chip->shadow.bytes[subaddr+1] & ~mask) | (val & mask); |
187 | } | 204 | } |
188 | } | 205 | } |
@@ -228,6 +245,15 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
228 | if (0 == cmd->count) | 245 | if (0 == cmd->count) |
229 | return 0; | 246 | return 0; |
230 | 247 | ||
248 | if (cmd->count + cmd->bytes[0] - 1 >= ARRAY_SIZE(chip->shadow.bytes)) { | ||
249 | v4l_info(chip->c, | ||
250 | "Tried to access a non-existent register range: %d to %d\n", | ||
251 | cmd->bytes[0] + 1, cmd->bytes[0] + cmd->count - 1); | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | /* FIXME: it seems that the shadow bytes are wrong bellow !*/ | ||
256 | |||
231 | /* update our shadow register set; print bytes if (debug > 0) */ | 257 | /* update our shadow register set; print bytes if (debug > 0) */ |
232 | v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", | 258 | v4l_dbg(1, debug, chip->c, "%s: chip_cmd(%s): reg=%d, data:", |
233 | chip->c->name, name,cmd->bytes[0]); | 259 | chip->c->name, name,cmd->bytes[0]); |
@@ -263,7 +289,8 @@ static void chip_thread_wake(unsigned long data) | |||
263 | static int chip_thread(void *data) | 289 | static int chip_thread(void *data) |
264 | { | 290 | { |
265 | struct CHIPSTATE *chip = data; | 291 | struct CHIPSTATE *chip = data; |
266 | struct CHIPDESC *desc = chiplist + chip->type; | 292 | struct CHIPDESC *desc = chip->desc; |
293 | int mode; | ||
267 | 294 | ||
268 | v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); | 295 | v4l_dbg(1, debug, chip->c, "%s: thread started\n", chip->c->name); |
269 | set_freezable(); | 296 | set_freezable(); |
@@ -282,7 +309,26 @@ static int chip_thread(void *data) | |||
282 | continue; | 309 | continue; |
283 | 310 | ||
284 | /* have a look what's going on */ | 311 | /* have a look what's going on */ |
285 | desc->checkmode(chip); | 312 | mode = desc->getmode(chip); |
313 | if (mode == chip->prevmode) | ||
314 | continue; | ||
315 | |||
316 | /* chip detected a new audio mode - set it */ | ||
317 | v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", | ||
318 | chip->c->name); | ||
319 | |||
320 | chip->prevmode = mode; | ||
321 | |||
322 | if (mode & V4L2_TUNER_MODE_STEREO) | ||
323 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | ||
324 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) | ||
325 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | ||
326 | else if (mode & V4L2_TUNER_MODE_LANG1) | ||
327 | desc->setmode(chip, V4L2_TUNER_MODE_LANG1); | ||
328 | else if (mode & V4L2_TUNER_MODE_LANG2) | ||
329 | desc->setmode(chip, V4L2_TUNER_MODE_LANG2); | ||
330 | else | ||
331 | desc->setmode(chip, V4L2_TUNER_MODE_MONO); | ||
286 | 332 | ||
287 | /* schedule next check */ | 333 | /* schedule next check */ |
288 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 334 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
@@ -292,29 +338,6 @@ static int chip_thread(void *data) | |||
292 | return 0; | 338 | return 0; |
293 | } | 339 | } |
294 | 340 | ||
295 | static void generic_checkmode(struct CHIPSTATE *chip) | ||
296 | { | ||
297 | struct CHIPDESC *desc = chiplist + chip->type; | ||
298 | int mode = desc->getmode(chip); | ||
299 | |||
300 | if (mode == chip->prevmode) | ||
301 | return; | ||
302 | |||
303 | v4l_dbg(1, debug, chip->c, "%s: thread checkmode\n", chip->c->name); | ||
304 | chip->prevmode = mode; | ||
305 | |||
306 | if (mode & V4L2_TUNER_MODE_STEREO) | ||
307 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); | ||
308 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) | ||
309 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); | ||
310 | else if (mode & V4L2_TUNER_MODE_LANG1) | ||
311 | desc->setmode(chip,V4L2_TUNER_MODE_LANG1); | ||
312 | else if (mode & V4L2_TUNER_MODE_LANG2) | ||
313 | desc->setmode(chip,V4L2_TUNER_MODE_LANG2); | ||
314 | else | ||
315 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); | ||
316 | } | ||
317 | |||
318 | /* ---------------------------------------------------------------------- */ | 341 | /* ---------------------------------------------------------------------- */ |
319 | /* audio chip descriptions - defines+functions for tda9840 */ | 342 | /* audio chip descriptions - defines+functions for tda9840 */ |
320 | 343 | ||
@@ -777,7 +800,7 @@ static struct tda9874a_MODES { | |||
777 | char *name; | 800 | char *name; |
778 | audiocmd cmd; | 801 | audiocmd cmd; |
779 | } tda9874a_modelist[9] = { | 802 | } tda9874a_modelist[9] = { |
780 | { "A2, B/G", | 803 | { "A2, B/G", /* default */ |
781 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, | 804 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x77,0xA0,0x00, 0x00,0x00 }} }, |
782 | { "A2, M (Korea)", | 805 | { "A2, M (Korea)", |
783 | { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, | 806 | { 9, { TDA9874A_C1FRA, 0x5D,0xC0,0x00, 0x62,0x6A,0xAA, 0x20,0x22 }} }, |
@@ -791,7 +814,7 @@ static struct tda9874a_MODES { | |||
791 | { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, | 814 | { 9, { TDA9874A_C1FRA, 0x7D,0x00,0x00, 0x88,0x8A,0xAA, 0x08,0x33 }} }, |
792 | { "NICAM, B/G", | 815 | { "NICAM, B/G", |
793 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, | 816 | { 9, { TDA9874A_C1FRA, 0x72,0x95,0x55, 0x79,0xEA,0xAA, 0x08,0x33 }} }, |
794 | { "NICAM, D/K", /* default */ | 817 | { "NICAM, D/K", |
795 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, | 818 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x08,0x33 }} }, |
796 | { "NICAM, L", | 819 | { "NICAM, L", |
797 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } | 820 | { 9, { TDA9874A_C1FRA, 0x87,0x6A,0xAA, 0x79,0xEA,0xAA, 0x09,0x33 }} } |
@@ -981,7 +1004,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip) | |||
981 | { | 1004 | { |
982 | if (tda9874a_SIF > 2) | 1005 | if (tda9874a_SIF > 2) |
983 | tda9874a_SIF = 1; | 1006 | tda9874a_SIF = 1; |
984 | if (tda9874a_STD > 8) | 1007 | if (tda9874a_STD >= ARRAY_SIZE(tda9874a_modelist)) |
985 | tda9874a_STD = 0; | 1008 | tda9874a_STD = 0; |
986 | if(tda9874a_AMSEL > 1) | 1009 | if(tda9874a_AMSEL > 1) |
987 | tda9874a_AMSEL = 0; | 1010 | tda9874a_AMSEL = 0; |
@@ -1089,7 +1112,7 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; } | |||
1089 | 1112 | ||
1090 | static int tda8425_initialize(struct CHIPSTATE *chip) | 1113 | static int tda8425_initialize(struct CHIPSTATE *chip) |
1091 | { | 1114 | { |
1092 | struct CHIPDESC *desc = chiplist + chip->type; | 1115 | struct CHIPDESC *desc = chip->desc; |
1093 | int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, | 1116 | int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1, |
1094 | /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; | 1117 | /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF}; |
1095 | 1118 | ||
@@ -1259,27 +1282,28 @@ static struct CHIPDESC chiplist[] = { | |||
1259 | .addr_lo = I2C_ADDR_TDA9840 >> 1, | 1282 | .addr_lo = I2C_ADDR_TDA9840 >> 1, |
1260 | .addr_hi = I2C_ADDR_TDA9840 >> 1, | 1283 | .addr_hi = I2C_ADDR_TDA9840 >> 1, |
1261 | .registers = 5, | 1284 | .registers = 5, |
1285 | .flags = CHIP_NEED_CHECKMODE, | ||
1262 | 1286 | ||
1287 | /* callbacks */ | ||
1263 | .checkit = tda9840_checkit, | 1288 | .checkit = tda9840_checkit, |
1264 | .getmode = tda9840_getmode, | 1289 | .getmode = tda9840_getmode, |
1265 | .setmode = tda9840_setmode, | 1290 | .setmode = tda9840_setmode, |
1266 | .checkmode = generic_checkmode, | ||
1267 | 1291 | ||
1268 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN | 1292 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN |
1269 | /* ,TDA9840_SW, TDA9840_MONO */} } | 1293 | /* ,TDA9840_SW, TDA9840_MONO */} } |
1270 | }, | 1294 | }, |
1271 | { | 1295 | { |
1272 | .name = "tda9873h", | 1296 | .name = "tda9873h", |
1273 | .checkit = tda9873_checkit, | ||
1274 | .insmodopt = &tda9873, | 1297 | .insmodopt = &tda9873, |
1275 | .addr_lo = I2C_ADDR_TDA985x_L >> 1, | 1298 | .addr_lo = I2C_ADDR_TDA985x_L >> 1, |
1276 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, | 1299 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, |
1277 | .registers = 3, | 1300 | .registers = 3, |
1278 | .flags = CHIP_HAS_INPUTSEL, | 1301 | .flags = CHIP_HAS_INPUTSEL | CHIP_NEED_CHECKMODE, |
1279 | 1302 | ||
1303 | /* callbacks */ | ||
1304 | .checkit = tda9873_checkit, | ||
1280 | .getmode = tda9873_getmode, | 1305 | .getmode = tda9873_getmode, |
1281 | .setmode = tda9873_setmode, | 1306 | .setmode = tda9873_setmode, |
1282 | .checkmode = generic_checkmode, | ||
1283 | 1307 | ||
1284 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, | 1308 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, |
1285 | .inputreg = TDA9873_SW, | 1309 | .inputreg = TDA9873_SW, |
@@ -1290,15 +1314,16 @@ static struct CHIPDESC chiplist[] = { | |||
1290 | }, | 1314 | }, |
1291 | { | 1315 | { |
1292 | .name = "tda9874h/a", | 1316 | .name = "tda9874h/a", |
1293 | .checkit = tda9874a_checkit, | ||
1294 | .initialize = tda9874a_initialize, | ||
1295 | .insmodopt = &tda9874a, | 1317 | .insmodopt = &tda9874a, |
1296 | .addr_lo = I2C_ADDR_TDA9874 >> 1, | 1318 | .addr_lo = I2C_ADDR_TDA9874 >> 1, |
1297 | .addr_hi = I2C_ADDR_TDA9874 >> 1, | 1319 | .addr_hi = I2C_ADDR_TDA9874 >> 1, |
1320 | .flags = CHIP_NEED_CHECKMODE, | ||
1298 | 1321 | ||
1322 | /* callbacks */ | ||
1323 | .initialize = tda9874a_initialize, | ||
1324 | .checkit = tda9874a_checkit, | ||
1299 | .getmode = tda9874a_getmode, | 1325 | .getmode = tda9874a_getmode, |
1300 | .setmode = tda9874a_setmode, | 1326 | .setmode = tda9874a_setmode, |
1301 | .checkmode = generic_checkmode, | ||
1302 | }, | 1327 | }, |
1303 | { | 1328 | { |
1304 | .name = "tda9850", | 1329 | .name = "tda9850", |
@@ -1324,10 +1349,11 @@ static struct CHIPDESC chiplist[] = { | |||
1324 | .rightreg = TDA9855_VR, | 1349 | .rightreg = TDA9855_VR, |
1325 | .bassreg = TDA9855_BA, | 1350 | .bassreg = TDA9855_BA, |
1326 | .treblereg = TDA9855_TR, | 1351 | .treblereg = TDA9855_TR, |
1352 | |||
1353 | /* callbacks */ | ||
1327 | .volfunc = tda9855_volume, | 1354 | .volfunc = tda9855_volume, |
1328 | .bassfunc = tda9855_bass, | 1355 | .bassfunc = tda9855_bass, |
1329 | .treblefunc = tda9855_treble, | 1356 | .treblefunc = tda9855_treble, |
1330 | |||
1331 | .getmode = tda985x_getmode, | 1357 | .getmode = tda985x_getmode, |
1332 | .setmode = tda985x_setmode, | 1358 | .setmode = tda985x_setmode, |
1333 | 1359 | ||
@@ -1348,6 +1374,8 @@ static struct CHIPDESC chiplist[] = { | |||
1348 | .rightreg = TEA6300_VL, | 1374 | .rightreg = TEA6300_VL, |
1349 | .bassreg = TEA6300_BA, | 1375 | .bassreg = TEA6300_BA, |
1350 | .treblereg = TEA6300_TR, | 1376 | .treblereg = TEA6300_TR, |
1377 | |||
1378 | /* callbacks */ | ||
1351 | .volfunc = tea6300_shift10, | 1379 | .volfunc = tea6300_shift10, |
1352 | .bassfunc = tea6300_shift12, | 1380 | .bassfunc = tea6300_shift12, |
1353 | .treblefunc = tea6300_shift12, | 1381 | .treblefunc = tea6300_shift12, |
@@ -1358,7 +1386,6 @@ static struct CHIPDESC chiplist[] = { | |||
1358 | }, | 1386 | }, |
1359 | { | 1387 | { |
1360 | .name = "tea6320", | 1388 | .name = "tea6320", |
1361 | .initialize = tea6320_initialize, | ||
1362 | .insmodopt = &tea6320, | 1389 | .insmodopt = &tea6320, |
1363 | .addr_lo = I2C_ADDR_TEA6300 >> 1, | 1390 | .addr_lo = I2C_ADDR_TEA6300 >> 1, |
1364 | .addr_hi = I2C_ADDR_TEA6300 >> 1, | 1391 | .addr_hi = I2C_ADDR_TEA6300 >> 1, |
@@ -1369,6 +1396,9 @@ static struct CHIPDESC chiplist[] = { | |||
1369 | .rightreg = TEA6320_V, | 1396 | .rightreg = TEA6320_V, |
1370 | .bassreg = TEA6320_BA, | 1397 | .bassreg = TEA6320_BA, |
1371 | .treblereg = TEA6320_TR, | 1398 | .treblereg = TEA6320_TR, |
1399 | |||
1400 | /* callbacks */ | ||
1401 | .initialize = tea6320_initialize, | ||
1372 | .volfunc = tea6320_volume, | 1402 | .volfunc = tea6320_volume, |
1373 | .bassfunc = tea6320_shift11, | 1403 | .bassfunc = tea6320_shift11, |
1374 | .treblefunc = tea6320_shift11, | 1404 | .treblefunc = tea6320_shift11, |
@@ -1401,16 +1431,18 @@ static struct CHIPDESC chiplist[] = { | |||
1401 | .rightreg = TDA8425_VR, | 1431 | .rightreg = TDA8425_VR, |
1402 | .bassreg = TDA8425_BA, | 1432 | .bassreg = TDA8425_BA, |
1403 | .treblereg = TDA8425_TR, | 1433 | .treblereg = TDA8425_TR, |
1434 | |||
1435 | /* callbacks */ | ||
1436 | .initialize = tda8425_initialize, | ||
1404 | .volfunc = tda8425_shift10, | 1437 | .volfunc = tda8425_shift10, |
1405 | .bassfunc = tda8425_shift12, | 1438 | .bassfunc = tda8425_shift12, |
1406 | .treblefunc = tda8425_shift12, | 1439 | .treblefunc = tda8425_shift12, |
1440 | .setmode = tda8425_setmode, | ||
1407 | 1441 | ||
1408 | .inputreg = TDA8425_S1, | 1442 | .inputreg = TDA8425_S1, |
1409 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, | 1443 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, |
1410 | .inputmute = TDA8425_S1_OFF, | 1444 | .inputmute = TDA8425_S1_OFF, |
1411 | 1445 | ||
1412 | .setmode = tda8425_setmode, | ||
1413 | .initialize = tda8425_initialize, | ||
1414 | }, | 1446 | }, |
1415 | { | 1447 | { |
1416 | .name = "pic16c54 (PV951)", | 1448 | .name = "pic16c54 (PV951)", |
@@ -1434,10 +1466,11 @@ static struct CHIPDESC chiplist[] = { | |||
1434 | .addr_lo = I2C_ADDR_TDA9840 >> 1, | 1466 | .addr_lo = I2C_ADDR_TDA9840 >> 1, |
1435 | .addr_hi = I2C_ADDR_TDA9840 >> 1, | 1467 | .addr_hi = I2C_ADDR_TDA9840 >> 1, |
1436 | .registers = 2, | 1468 | .registers = 2, |
1469 | .flags = CHIP_NEED_CHECKMODE, | ||
1437 | 1470 | ||
1471 | /* callbacks */ | ||
1438 | .getmode = ta8874z_getmode, | 1472 | .getmode = ta8874z_getmode, |
1439 | .setmode = ta8874z_setmode, | 1473 | .setmode = ta8874z_setmode, |
1440 | .checkmode = generic_checkmode, | ||
1441 | 1474 | ||
1442 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, | 1475 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, |
1443 | }, | 1476 | }, |
@@ -1481,6 +1514,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1481 | } | 1514 | } |
1482 | if (desc->name == NULL) { | 1515 | if (desc->name == NULL) { |
1483 | v4l_dbg(1, debug, client, "no matching chip description found\n"); | 1516 | v4l_dbg(1, debug, client, "no matching chip description found\n"); |
1517 | kfree(chip); | ||
1484 | return -EIO; | 1518 | return -EIO; |
1485 | } | 1519 | } |
1486 | v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); | 1520 | v4l_info(client, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name); |
@@ -1494,7 +1528,7 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1494 | /* fill required data structures */ | 1528 | /* fill required data structures */ |
1495 | if (!id) | 1529 | if (!id) |
1496 | strlcpy(client->name, desc->name, I2C_NAME_SIZE); | 1530 | strlcpy(client->name, desc->name, I2C_NAME_SIZE); |
1497 | chip->type = desc-chiplist; | 1531 | chip->desc = desc; |
1498 | chip->shadow.count = desc->registers+1; | 1532 | chip->shadow.count = desc->registers+1; |
1499 | chip->prevmode = -1; | 1533 | chip->prevmode = -1; |
1500 | chip->audmode = V4L2_TUNER_MODE_LANG1; | 1534 | chip->audmode = V4L2_TUNER_MODE_LANG1; |
@@ -1506,20 +1540,49 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1506 | chip_cmd(chip,"init",&desc->init); | 1540 | chip_cmd(chip,"init",&desc->init); |
1507 | 1541 | ||
1508 | if (desc->flags & CHIP_HAS_VOLUME) { | 1542 | if (desc->flags & CHIP_HAS_VOLUME) { |
1509 | chip->left = desc->leftinit ? desc->leftinit : 65535; | 1543 | if (!desc->volfunc) { |
1510 | chip->right = desc->rightinit ? desc->rightinit : 65535; | 1544 | /* This shouldn't be happen. Warn user, but keep working |
1511 | chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); | 1545 | without volume controls |
1512 | chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); | 1546 | */ |
1547 | v4l_info(chip->c, "volume callback undefined!\n"); | ||
1548 | desc->flags &= ~CHIP_HAS_VOLUME; | ||
1549 | } else { | ||
1550 | chip->left = desc->leftinit ? desc->leftinit : 65535; | ||
1551 | chip->right = desc->rightinit ? desc->rightinit : 65535; | ||
1552 | chip_write(chip, desc->leftreg, | ||
1553 | desc->volfunc(chip->left)); | ||
1554 | chip_write(chip, desc->rightreg, | ||
1555 | desc->volfunc(chip->right)); | ||
1556 | } | ||
1513 | } | 1557 | } |
1514 | if (desc->flags & CHIP_HAS_BASSTREBLE) { | 1558 | if (desc->flags & CHIP_HAS_BASSTREBLE) { |
1515 | chip->treble = desc->trebleinit ? desc->trebleinit : 32768; | 1559 | if (!desc->bassfunc || !desc->treblefunc) { |
1516 | chip->bass = desc->bassinit ? desc->bassinit : 32768; | 1560 | /* This shouldn't be happen. Warn user, but keep working |
1517 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | 1561 | without bass/treble controls |
1518 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | 1562 | */ |
1563 | v4l_info(chip->c, "bass/treble callbacks undefined!\n"); | ||
1564 | desc->flags &= ~CHIP_HAS_BASSTREBLE; | ||
1565 | } else { | ||
1566 | chip->treble = desc->trebleinit ? | ||
1567 | desc->trebleinit : 32768; | ||
1568 | chip->bass = desc->bassinit ? | ||
1569 | desc->bassinit : 32768; | ||
1570 | chip_write(chip, desc->bassreg, | ||
1571 | desc->bassfunc(chip->bass)); | ||
1572 | chip_write(chip, desc->treblereg, | ||
1573 | desc->treblefunc(chip->treble)); | ||
1574 | } | ||
1519 | } | 1575 | } |
1520 | 1576 | ||
1521 | chip->thread = NULL; | 1577 | chip->thread = NULL; |
1522 | if (desc->checkmode) { | 1578 | if (desc->flags & CHIP_NEED_CHECKMODE) { |
1579 | if (!desc->getmode || !desc->setmode) { | ||
1580 | /* This shouldn't be happen. Warn user, but keep working | ||
1581 | without kthread | ||
1582 | */ | ||
1583 | v4l_info(chip->c, "set/get mode callbacks undefined!\n"); | ||
1584 | return 0; | ||
1585 | } | ||
1523 | /* start async thread */ | 1586 | /* start async thread */ |
1524 | init_timer(&chip->wt); | 1587 | init_timer(&chip->wt); |
1525 | chip->wt.function = chip_thread_wake; | 1588 | chip->wt.function = chip_thread_wake; |
@@ -1552,7 +1615,7 @@ static int chip_remove(struct i2c_client *client) | |||
1552 | static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | 1615 | static int tvaudio_get_ctrl(struct CHIPSTATE *chip, |
1553 | struct v4l2_control *ctrl) | 1616 | struct v4l2_control *ctrl) |
1554 | { | 1617 | { |
1555 | struct CHIPDESC *desc = chiplist + chip->type; | 1618 | struct CHIPDESC *desc = chip->desc; |
1556 | 1619 | ||
1557 | switch (ctrl->id) { | 1620 | switch (ctrl->id) { |
1558 | case V4L2_CID_AUDIO_MUTE: | 1621 | case V4L2_CID_AUDIO_MUTE: |
@@ -1576,13 +1639,13 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | |||
1576 | return 0; | 1639 | return 0; |
1577 | } | 1640 | } |
1578 | case V4L2_CID_AUDIO_BASS: | 1641 | case V4L2_CID_AUDIO_BASS: |
1579 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1642 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1580 | break; | 1643 | break; |
1581 | ctrl->value = chip->bass; | 1644 | ctrl->value = chip->bass; |
1582 | return 0; | 1645 | return 0; |
1583 | case V4L2_CID_AUDIO_TREBLE: | 1646 | case V4L2_CID_AUDIO_TREBLE: |
1584 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1647 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1585 | return -EINVAL; | 1648 | break; |
1586 | ctrl->value = chip->treble; | 1649 | ctrl->value = chip->treble; |
1587 | return 0; | 1650 | return 0; |
1588 | } | 1651 | } |
@@ -1592,7 +1655,7 @@ static int tvaudio_get_ctrl(struct CHIPSTATE *chip, | |||
1592 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | 1655 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, |
1593 | struct v4l2_control *ctrl) | 1656 | struct v4l2_control *ctrl) |
1594 | { | 1657 | { |
1595 | struct CHIPDESC *desc = chiplist + chip->type; | 1658 | struct CHIPDESC *desc = chip->desc; |
1596 | 1659 | ||
1597 | switch (ctrl->id) { | 1660 | switch (ctrl->id) { |
1598 | case V4L2_CID_AUDIO_MUTE: | 1661 | case V4L2_CID_AUDIO_MUTE: |
@@ -1642,16 +1705,15 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | |||
1642 | return 0; | 1705 | return 0; |
1643 | } | 1706 | } |
1644 | case V4L2_CID_AUDIO_BASS: | 1707 | case V4L2_CID_AUDIO_BASS: |
1645 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1708 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1646 | break; | 1709 | break; |
1647 | chip->bass = ctrl->value; | 1710 | chip->bass = ctrl->value; |
1648 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | 1711 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); |
1649 | 1712 | ||
1650 | return 0; | 1713 | return 0; |
1651 | case V4L2_CID_AUDIO_TREBLE: | 1714 | case V4L2_CID_AUDIO_TREBLE: |
1652 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1715 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1653 | return -EINVAL; | 1716 | break; |
1654 | |||
1655 | chip->treble = ctrl->value; | 1717 | chip->treble = ctrl->value; |
1656 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | 1718 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); |
1657 | 1719 | ||
@@ -1668,9 +1730,12 @@ static int chip_command(struct i2c_client *client, | |||
1668 | unsigned int cmd, void *arg) | 1730 | unsigned int cmd, void *arg) |
1669 | { | 1731 | { |
1670 | struct CHIPSTATE *chip = i2c_get_clientdata(client); | 1732 | struct CHIPSTATE *chip = i2c_get_clientdata(client); |
1671 | struct CHIPDESC *desc = chiplist + chip->type; | 1733 | struct CHIPDESC *desc = chip->desc; |
1672 | 1734 | ||
1673 | v4l_dbg(1, debug, chip->c, "%s: chip_command 0x%x\n", chip->c->name, cmd); | 1735 | if (debug > 0) { |
1736 | v4l_i2c_print_ioctl(chip->c, cmd); | ||
1737 | printk("\n"); | ||
1738 | } | ||
1674 | 1739 | ||
1675 | switch (cmd) { | 1740 | switch (cmd) { |
1676 | case AUDC_SET_RADIO: | 1741 | case AUDC_SET_RADIO: |
@@ -1695,7 +1760,7 @@ static int chip_command(struct i2c_client *client, | |||
1695 | break; | 1760 | break; |
1696 | case V4L2_CID_AUDIO_BASS: | 1761 | case V4L2_CID_AUDIO_BASS: |
1697 | case V4L2_CID_AUDIO_TREBLE: | 1762 | case V4L2_CID_AUDIO_TREBLE: |
1698 | if (desc->flags & CHIP_HAS_BASSTREBLE) | 1763 | if (!(desc->flags & CHIP_HAS_BASSTREBLE)) |
1699 | return -EINVAL; | 1764 | return -EINVAL; |
1700 | break; | 1765 | break; |
1701 | default: | 1766 | default: |
@@ -1792,12 +1857,20 @@ static int chip_command(struct i2c_client *client, | |||
1792 | break; | 1857 | break; |
1793 | case VIDIOC_S_FREQUENCY: | 1858 | case VIDIOC_S_FREQUENCY: |
1794 | chip->mode = 0; /* automatic */ | 1859 | chip->mode = 0; /* automatic */ |
1795 | if (desc->checkmode && desc->setmode) { | 1860 | |
1861 | /* For chips that provide getmode and setmode, and doesn't | ||
1862 | automatically follows the stereo carrier, a kthread is | ||
1863 | created to set the audio standard. In this case, when then | ||
1864 | the video channel is changed, tvaudio starts on MONO mode. | ||
1865 | After waiting for 2 seconds, the kernel thread is called, | ||
1866 | to follow whatever audio standard is pointed by the | ||
1867 | audio carrier. | ||
1868 | */ | ||
1869 | if (chip->thread) { | ||
1796 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); | 1870 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); |
1797 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) | 1871 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) |
1798 | chip->prevmode = -1; /* reset previous mode */ | 1872 | chip->prevmode = -1; /* reset previous mode */ |
1799 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 1873 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
1800 | /* the thread will call checkmode() later */ | ||
1801 | } | 1874 | } |
1802 | break; | 1875 | break; |
1803 | 1876 | ||
@@ -1836,9 +1909,3 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = { | |||
1836 | .legacy_probe = chip_legacy_probe, | 1909 | .legacy_probe = chip_legacy_probe, |
1837 | .id_table = chip_id, | 1910 | .id_table = chip_id, |
1838 | }; | 1911 | }; |
1839 | |||
1840 | /* | ||
1841 | * Local variables: | ||
1842 | * c-basic-offset: 8 | ||
1843 | * End: | ||
1844 | */ | ||