aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/processor_core.c15
-rw-r--r--drivers/acpi/processor_idle.c29
-rw-r--r--drivers/acpi/processor_thermal.c38
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/thermal.c163
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c69
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c31
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c18
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c2
-rw-r--r--drivers/media/dvb/frontends/ves1820.c14
-rw-r--r--drivers/media/dvb/ttpci/Kconfig1
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c2
-rw-r--r--drivers/media/dvb/ttpci/budget.c2
-rw-r--r--drivers/media/dvb/ttpci/ttpci-eeprom.c1
-rw-r--r--drivers/media/video/Kconfig3
-rw-r--r--drivers/media/video/bttv-cards.c6
-rw-r--r--drivers/media/video/bttv-driver.c67
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c38
-rw-r--r--drivers/media/video/cx25840/cx25840.h9
-rw-r--r--drivers/media/video/cx88/cx88-cards.c43
-rw-r--r--drivers/media/video/cx88/cx88-core.c35
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c28
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c6
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/video/ir-kbd-i2c.c2
-rw-r--r--drivers/media/video/saa7115.c14
-rw-r--r--drivers/media/video/saa711x.c2
-rw-r--r--drivers/media/video/saa7127.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c36
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c25
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c81
-rw-r--r--drivers/media/video/saa7134/saa7134.h4
-rw-r--r--drivers/media/video/tveeprom.c64
-rw-r--r--drivers/media/video/video-buf.c9
-rw-r--r--drivers/media/video/videodev.c26
47 files changed, 569 insertions, 348 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fe1e8126fbae..fce21c257523 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -197,7 +197,6 @@ config ACPI_ASUS
197config ACPI_IBM 197config ACPI_IBM
198 tristate "IBM ThinkPad Laptop Extras" 198 tristate "IBM ThinkPad Laptop Extras"
199 depends on X86 199 depends on X86
200 default y
201 ---help--- 200 ---help---
202 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds 201 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
203 support for Fn-Fx key combinations, Bluetooth control, video 202 support for Fn-Fx key combinations, Bluetooth control, video
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index a18243488c66..5984b4f6715a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -16,7 +16,7 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
16# ACPI Boot-Time Table Parsing 16# ACPI Boot-Time Table Parsing
17# 17#
18obj-y += tables.o 18obj-y += tables.o
19obj-y += blacklist.o 19obj-$(CONFIG_X86) += blacklist.o
20 20
21# 21#
22# ACPI Core Subsystem (Interpreter) 22# ACPI Core Subsystem (Interpreter)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 421792562642..0c561c571f29 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -543,6 +543,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
543 return_VALUE(0); 543 return_VALUE(0);
544} 544}
545 545
546static void *processor_device_array[NR_CPUS];
547
546static int acpi_processor_start(struct acpi_device *device) 548static int acpi_processor_start(struct acpi_device *device)
547{ 549{
548 int result = 0; 550 int result = 0;
@@ -561,6 +563,19 @@ static int acpi_processor_start(struct acpi_device *device)
561 563
562 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 564 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
563 565
566 /*
567 * Buggy BIOS check
568 * ACPI id of processors can be reported wrongly by the BIOS.
569 * Don't trust it blindly
570 */
571 if (processor_device_array[pr->id] != NULL &&
572 processor_device_array[pr->id] != (void *)device) {
573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "BIOS reporting wrong ACPI id"
574 "for the processor\n"));
575 return_VALUE(-ENODEV);
576 }
577 processor_device_array[pr->id] = (void *)device;
578
564 processors[pr->id] = pr; 579 processors[pr->id] = pr;
565 580
566 result = acpi_processor_add_fs(device); 581 result = acpi_processor_add_fs(device);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 70d8a6ec0920..83fd1b6c10c4 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -280,6 +280,16 @@ static void acpi_processor_idle(void)
280 280
281 cx->usage++; 281 cx->usage++;
282 282
283#ifdef CONFIG_HOTPLUG_CPU
284 /*
285 * Check for P_LVL2_UP flag before entering C2 and above on
286 * an SMP system. We do it here instead of doing it at _CST/P_LVL
287 * detection phase, to work cleanly with logical CPU hotplug.
288 */
289 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
290 !pr->flags.has_cst && acpi_fadt.plvl2_up)
291 cx->type = ACPI_STATE_C1;
292#endif
283 /* 293 /*
284 * Sleep: 294 * Sleep:
285 * ------ 295 * ------
@@ -534,6 +544,15 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
534 pr->power.states[ACPI_STATE_C0].valid = 1; 544 pr->power.states[ACPI_STATE_C0].valid = 1;
535 pr->power.states[ACPI_STATE_C1].valid = 1; 545 pr->power.states[ACPI_STATE_C1].valid = 1;
536 546
547#ifndef CONFIG_HOTPLUG_CPU
548 /*
549 * Check for P_LVL2_UP flag before entering C2 and above on
550 * an SMP system.
551 */
552 if ((num_online_cpus() > 1) && acpi_fadt.plvl2_up)
553 return_VALUE(-ENODEV);
554#endif
555
537 /* determine C2 and C3 address from pblk */ 556 /* determine C2 and C3 address from pblk */
538 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4; 557 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4;
539 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5; 558 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5;
@@ -690,7 +709,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
690 709
691 /* Validate number of power states discovered */ 710 /* Validate number of power states discovered */
692 if (pr->power.count < 2) 711 if (pr->power.count < 2)
693 status = -ENODEV; 712 status = -EFAULT;
694 713
695 end: 714 end:
696 acpi_os_free(buffer.pointer); 715 acpi_os_free(buffer.pointer);
@@ -841,11 +860,11 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
841 * this function */ 860 * this function */
842 861
843 result = acpi_processor_get_power_info_cst(pr); 862 result = acpi_processor_get_power_info_cst(pr);
844 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 863 if (result == -ENODEV)
845 result = acpi_processor_get_power_info_fadt(pr); 864 result = acpi_processor_get_power_info_fadt(pr);
846 if ((result) || (acpi_processor_power_verify(pr) < 2)) 865
847 result = acpi_processor_get_power_info_default_c1(pr); 866 if ((result) || (acpi_processor_power_verify(pr) < 2))
848 } 867 result = acpi_processor_get_power_info_default_c1(pr);
849 868
850 /* 869 /*
851 * Set Default Policy 870 * Set Default Policy
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 37528c3b64b0..f37584015324 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -101,9 +101,7 @@ static unsigned int acpi_thermal_cpufreq_is_init = 0;
101static int cpu_has_cpufreq(unsigned int cpu) 101static int cpu_has_cpufreq(unsigned int cpu)
102{ 102{
103 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
104 if (!acpi_thermal_cpufreq_is_init) 104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105 return -ENODEV;
106 if (!cpufreq_get_policy(&policy, cpu))
107 return -ENODEV; 105 return -ENODEV;
108 return 0; 106 return 0;
109} 107}
@@ -127,13 +125,13 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
127 if (!cpu_has_cpufreq(cpu)) 125 if (!cpu_has_cpufreq(cpu))
128 return -ENODEV; 126 return -ENODEV;
129 127
130 if (cpufreq_thermal_reduction_pctg[cpu] >= 20) { 128 if (cpufreq_thermal_reduction_pctg[cpu] > 20)
131 cpufreq_thermal_reduction_pctg[cpu] -= 20; 129 cpufreq_thermal_reduction_pctg[cpu] -= 20;
132 cpufreq_update_policy(cpu); 130 else
133 return 0; 131 cpufreq_thermal_reduction_pctg[cpu] = 0;
134 } 132 cpufreq_update_policy(cpu);
135 133 /* We reached max freq again and can leave passive mode */
136 return -ERANGE; 134 return !cpufreq_thermal_reduction_pctg[cpu];
137} 135}
138 136
139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, 137static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
@@ -200,7 +198,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 int result = 0; 198 int result = 0;
201 struct acpi_processor *pr = NULL; 199 struct acpi_processor *pr = NULL;
202 struct acpi_device *device = NULL; 200 struct acpi_device *device = NULL;
203 int tx = 0; 201 int tx = 0, max_tx_px = 0;
204 202
205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
206 204
@@ -259,19 +257,27 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
259 /* if going down: T-states first, P-states later */ 257 /* if going down: T-states first, P-states later */
260 258
261 if (pr->flags.throttling) { 259 if (pr->flags.throttling) {
262 if (tx == 0) 260 if (tx == 0) {
261 max_tx_px = 1;
263 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
264 "At minimum throttling state\n")); 263 "At minimum throttling state\n"));
265 else { 264 } else {
266 tx--; 265 tx--;
267 goto end; 266 goto end;
268 } 267 }
269 } 268 }
270 269
271 result = acpi_thermal_cpufreq_decrease(pr->id); 270 result = acpi_thermal_cpufreq_decrease(pr->id);
272 if (result == -ERANGE) 271 if (result) {
272 /*
273 * We only could get -ERANGE, 1 or 0.
274 * In the first two cases we reached max freq again.
275 */
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 276 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "At minimum performance state\n")); 277 "At minimum performance state\n"));
278 max_tx_px = 1;
279 } else
280 max_tx_px = 0;
275 281
276 break; 282 break;
277 } 283 }
@@ -290,8 +296,10 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
290 pr->limit.thermal.px, pr->limit.thermal.tx)); 296 pr->limit.thermal.px, pr->limit.thermal.tx));
291 } else 297 } else
292 result = 0; 298 result = 0;
293 299 if (max_tx_px)
294 return_VALUE(result); 300 return_VALUE(1);
301 else
302 return_VALUE(result);
295} 303}
296 304
297int acpi_processor_get_limit_info(struct acpi_processor *pr) 305int acpi_processor_get_limit_info(struct acpi_processor *pr)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 23e2c6968a11..31218e1d2a18 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1110,7 +1110,7 @@ acpi_add_single_object(struct acpi_device **child,
1110 * 1110 *
1111 * TBD: Assumes LDM provides driver hot-plug capability. 1111 * TBD: Assumes LDM provides driver hot-plug capability.
1112 */ 1112 */
1113 result = acpi_bus_find_driver(device); 1113 acpi_bus_find_driver(device);
1114 1114
1115 end: 1115 end:
1116 if (!result) 1116 if (!result)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a24847c08f7f..19f3ea48475e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -72,7 +72,7 @@
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75 MODULE_AUTHOR("Paul Diefenbaugh"); 75MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -517,9 +517,9 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
517 return_VALUE(0); 517 return_VALUE(0);
518} 518}
519 519
520static int acpi_thermal_passive(struct acpi_thermal *tz) 520static void acpi_thermal_passive(struct acpi_thermal *tz)
521{ 521{
522 int result = 0; 522 int result = 1;
523 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
524 int trend = 0; 524 int trend = 0;
525 int i = 0; 525 int i = 0;
@@ -527,7 +527,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
527 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
528 528
529 if (!tz || !tz->trips.passive.flags.valid) 529 if (!tz || !tz->trips.passive.flags.valid)
530 return_VALUE(-EINVAL); 530 return;
531 531
532 passive = &(tz->trips.passive); 532 passive = &(tz->trips.passive);
533 533
@@ -547,7 +547,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
547 trend, passive->tc1, tz->temperature, 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2, 548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature)); 549 tz->temperature, passive->temperature));
550 tz->trips.passive.flags.enabled = 1; 550 passive->flags.enabled = 1;
551 /* Heating up? */ 551 /* Heating up? */
552 if (trend > 0) 552 if (trend > 0)
553 for (i = 0; i < passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
@@ -556,12 +556,32 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
556 handles[i], 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT); 557 ACPI_PROCESSOR_LIMIT_INCREMENT);
558 /* Cooling off? */ 558 /* Cooling off? */
559 else if (trend < 0) 559 else if (trend < 0) {
560 for (i = 0; i < passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
561 acpi_processor_set_thermal_limit(passive-> 561 /*
562 devices. 562 * assume that we are on highest
563 handles[i], 563 * freq/lowest thrott and can leave
564 ACPI_PROCESSOR_LIMIT_DECREMENT); 564 * passive mode, even in error case
565 */
566 if (!acpi_processor_set_thermal_limit
567 (passive->devices.handles[i],
568 ACPI_PROCESSOR_LIMIT_DECREMENT))
569 result = 0;
570 /*
571 * Leave cooling mode, even if the temp might
572 * higher than trip point This is because some
573 * machines might have long thermal polling
574 * frequencies (tsp) defined. We will fall back
575 * into passive mode in next cycle (probably quicker)
576 */
577 if (result) {
578 passive->flags.enabled = 0;
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
580 "Disabling passive cooling, still above threshold,"
581 " but we are cooling down\n"));
582 }
583 }
584 return;
565 } 585 }
566 586
567 /* 587 /*
@@ -571,23 +591,21 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
571 * and avoid thrashing around the passive trip point. Note that we 591 * and avoid thrashing around the passive trip point. Note that we
572 * assume symmetry. 592 * assume symmetry.
573 */ 593 */
574 else if (tz->trips.passive.flags.enabled) { 594 if (!passive->flags.enabled)
575 for (i = 0; i < passive->devices.count; i++) 595 return;
576 result = 596 for (i = 0; i < passive->devices.count; i++)
577 acpi_processor_set_thermal_limit(passive->devices. 597 if (!acpi_processor_set_thermal_limit
578 handles[i], 598 (passive->devices.handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT); 599 ACPI_PROCESSOR_LIMIT_DECREMENT))
580 if (result == 1) { 600 result = 0;
581 tz->trips.passive.flags.enabled = 0; 601 if (result) {
582 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 602 passive->flags.enabled = 0;
583 "Disabling passive cooling (zone is cool)\n")); 603 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
584 } 604 "Disabling passive cooling (zone is cool)\n"));
585 } 605 }
586
587 return_VALUE(0);
588} 606}
589 607
590static int acpi_thermal_active(struct acpi_thermal *tz) 608static void acpi_thermal_active(struct acpi_thermal *tz)
591{ 609{
592 int result = 0; 610 int result = 0;
593 struct acpi_thermal_active *active = NULL; 611 struct acpi_thermal_active *active = NULL;
@@ -598,74 +616,66 @@ static int acpi_thermal_active(struct acpi_thermal *tz)
598 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 616 ACPI_FUNCTION_TRACE("acpi_thermal_active");
599 617
600 if (!tz) 618 if (!tz)
601 return_VALUE(-EINVAL); 619 return;
602 620
603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 621 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
604
605 active = &(tz->trips.active[i]); 622 active = &(tz->trips.active[i]);
606 if (!active || !active->flags.valid) 623 if (!active || !active->flags.valid)
607 break; 624 break;
608
609 /*
610 * Above Threshold?
611 * ----------------
612 * If not already enabled, turn ON all cooling devices
613 * associated with this active threshold.
614 */
615 if (tz->temperature >= active->temperature) { 625 if (tz->temperature >= active->temperature) {
626 /*
627 * Above Threshold?
628 * ----------------
629 * If not already enabled, turn ON all cooling devices
630 * associated with this active threshold.
631 */
616 if (active->temperature > maxtemp) 632 if (active->temperature > maxtemp)
617 tz->state.active_index = i, maxtemp = 633 tz->state.active_index = i;
618 active->temperature; 634 maxtemp = active->temperature;
619 if (!active->flags.enabled) { 635 if (active->flags.enabled)
620 for (j = 0; j < active->devices.count; j++) { 636 continue;
621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
625 if (result) {
626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
631 continue;
632 }
633 active->flags.enabled = 1;
634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
638 }
639 }
640 }
641 /*
642 * Below Threshold?
643 * ----------------
644 * Turn OFF all cooling devices associated with this
645 * threshold.
646 */
647 else if (active->flags.enabled) {
648 for (j = 0; j < active->devices.count; j++) { 637 for (j = 0; j < active->devices.count; j++) {
649 result = 638 result =
650 acpi_bus_set_power(active->devices. 639 acpi_bus_set_power(active->devices.
651 handles[j], 640 handles[j],
652 ACPI_STATE_D3); 641 ACPI_STATE_D0);
653 if (result) { 642 if (result) {
654 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 643 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n", 644 "Unable to turn cooling device [%p] 'on'\n",
656 active->devices. 645 active->devices.
657 handles[j])); 646 handles[j]));
658 continue; 647 continue;
659 } 648 }
660 active->flags.enabled = 0; 649 active->flags.enabled = 1;
661 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n", 651 "Cooling device [%p] now 'on'\n",
663 active->devices.handles[j])); 652 active->devices.handles[j]));
664 } 653 }
654 continue;
655 }
656 if (!active->flags.enabled)
657 continue;
658 /*
659 * Below Threshold?
660 * ----------------
661 * Turn OFF all cooling devices associated with this
662 * threshold.
663 */
664 for (j = 0; j < active->devices.count; j++) {
665 result = acpi_bus_set_power(active->devices.handles[j],
666 ACPI_STATE_D3);
667 if (result) {
668 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
669 "Unable to turn cooling device [%p] 'off'\n",
670 active->devices.handles[j]));
671 continue;
672 }
673 active->flags.enabled = 0;
674 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
675 "Cooling device [%p] now 'off'\n",
676 active->devices.handles[j]));
665 } 677 }
666 } 678 }
667
668 return_VALUE(0);
669} 679}
670 680
671static void acpi_thermal_check(void *context); 681static void acpi_thermal_check(void *context);
@@ -744,15 +754,12 @@ static void acpi_thermal_check(void *data)
744 * Again, separated from the above two to allow independent policy 754 * Again, separated from the above two to allow independent policy
745 * decisions. 755 * decisions.
746 */ 756 */
747 if (tz->trips.critical.flags.enabled) 757 tz->state.critical = tz->trips.critical.flags.enabled;
748 tz->state.critical = 1; 758 tz->state.hot = tz->trips.hot.flags.enabled;
749 if (tz->trips.hot.flags.enabled) 759 tz->state.passive = tz->trips.passive.flags.enabled;
750 tz->state.hot = 1; 760 tz->state.active = 0;
751 if (tz->trips.passive.flags.enabled)
752 tz->state.passive = 1;
753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) 761 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
754 if (tz->trips.active[i].flags.enabled) 762 tz->state.active |= tz->trips.active[i].flags.enabled;
755 tz->state.active = 1;
756 763
757 /* 764 /*
758 * Calculate Sleep Time 765 * Calculate Sleep Time
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index f051b151580d..d10668f14699 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -812,7 +812,7 @@ acpi_video_device_write_brightness(struct file *file,
812 812
813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
814 814
815 if (!dev || count + 1 > sizeof str) 815 if (!dev || !dev->brightness || count + 1 > sizeof str)
816 return_VALUE(-EINVAL); 816 return_VALUE(-EINVAL);
817 817
818 if (copy_from_user(str, buffer, count)) 818 if (copy_from_user(str, buffer, count))
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 75cf237196eb..b386cc66c6b3 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -19,7 +19,7 @@ void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff); 19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff);
20} 20}
21 21
22void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff) 22static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
23{ 23{
24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff); 24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff);
25} 25}
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 2aa767f9bd7d..cb2e7d6ba283 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -35,7 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/rwsem.h> 38#include <linux/spinlock.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40 40
41#include "dvb_ca_en50221.h" 41#include "dvb_ca_en50221.h"
@@ -111,9 +111,6 @@ struct dvb_ca_slot {
111 /* size of the buffer to use when talking to the CAM */ 111 /* size of the buffer to use when talking to the CAM */
112 int link_buf_size; 112 int link_buf_size;
113 113
114 /* semaphore for syncing access to slot structure */
115 struct rw_semaphore sem;
116
117 /* buffer for incoming packets */ 114 /* buffer for incoming packets */
118 struct dvb_ringbuffer rx_buffer; 115 struct dvb_ringbuffer rx_buffer;
119 116
@@ -602,14 +599,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
602 if (ebuf == NULL) { 599 if (ebuf == NULL) {
603 int buf_free; 600 int buf_free;
604 601
605 down_read(&ca->slot_info[slot].sem);
606 if (ca->slot_info[slot].rx_buffer.data == NULL) { 602 if (ca->slot_info[slot].rx_buffer.data == NULL) {
607 up_read(&ca->slot_info[slot].sem);
608 status = -EIO; 603 status = -EIO;
609 goto exit; 604 goto exit;
610 } 605 }
611 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer); 606 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
612 up_read(&ca->slot_info[slot].sem);
613 607
614 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) { 608 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
615 status = -EAGAIN; 609 status = -EAGAIN;
@@ -680,14 +674,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
680 674
681 /* OK, add it to the receive buffer, or copy into external buffer if supplied */ 675 /* OK, add it to the receive buffer, or copy into external buffer if supplied */
682 if (ebuf == NULL) { 676 if (ebuf == NULL) {
683 down_read(&ca->slot_info[slot].sem);
684 if (ca->slot_info[slot].rx_buffer.data == NULL) { 677 if (ca->slot_info[slot].rx_buffer.data == NULL) {
685 up_read(&ca->slot_info[slot].sem);
686 status = -EIO; 678 status = -EIO;
687 goto exit; 679 goto exit;
688 } 680 }
689 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read); 681 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
690 up_read(&ca->slot_info[slot].sem);
691 } else { 682 } else {
692 memcpy(ebuf, buf, bytes_read); 683 memcpy(ebuf, buf, bytes_read);
693 } 684 }
@@ -802,12 +793,8 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
802{ 793{
803 dprintk("%s\n", __FUNCTION__); 794 dprintk("%s\n", __FUNCTION__);
804 795
805 down_write(&ca->slot_info[slot].sem);
806 ca->pub->slot_shutdown(ca->pub, slot); 796 ca->pub->slot_shutdown(ca->pub, slot);
807 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; 797 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
808 vfree(ca->slot_info[slot].rx_buffer.data);
809 ca->slot_info[slot].rx_buffer.data = NULL;
810 up_write(&ca->slot_info[slot].sem);
811 798
812 /* need to wake up all processes to check if they're now 799 /* need to wake up all processes to check if they're now
813 trying to write to a defunct CAM */ 800 trying to write to a defunct CAM */
@@ -893,7 +880,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
893 880
894 case DVB_CA_SLOTSTATE_RUNNING: 881 case DVB_CA_SLOTSTATE_RUNNING:
895 if (ca->open) 882 if (ca->open)
896 dvb_ca_en50221_read_data(ca, slot, NULL, 0); 883 dvb_ca_en50221_thread_wakeup(ca);
897 break; 884 break;
898 } 885 }
899} 886}
@@ -1127,16 +1114,16 @@ static int dvb_ca_en50221_thread(void *data)
1127 break; 1114 break;
1128 } 1115 }
1129 1116
1130 rxbuf = vmalloc(RX_BUFFER_SIZE); 1117 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1131 if (rxbuf == NULL) { 1118 rxbuf = vmalloc(RX_BUFFER_SIZE);
1132 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num); 1119 if (rxbuf == NULL) {
1133 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1120 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num);
1134 dvb_ca_en50221_thread_update_delay(ca); 1121 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1135 break; 1122 dvb_ca_en50221_thread_update_delay(ca);
1123 break;
1124 }
1125 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1136 } 1126 }
1137 down_write(&ca->slot_info[slot].sem);
1138 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1139 up_write(&ca->slot_info[slot].sem);
1140 1127
1141 ca->pub->slot_ts_enable(ca->pub, slot); 1128 ca->pub->slot_ts_enable(ca->pub, slot);
1142 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING; 1129 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
@@ -1148,11 +1135,7 @@ static int dvb_ca_en50221_thread(void *data)
1148 if (!ca->open) 1135 if (!ca->open)
1149 continue; 1136 continue;
1150 1137
1151 // no need to poll if the CAM supports IRQs 1138 // poll slots for data
1152 if (ca->slot_info[slot].da_irq_supported)
1153 break;
1154
1155 // poll mode
1156 pktcount = 0; 1139 pktcount = 0;
1157 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) { 1140 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
1158 if (!ca->open) 1141 if (!ca->open)
@@ -1367,12 +1350,13 @@ exit:
1367/** 1350/**
1368 * Condition for waking up in dvb_ca_en50221_io_read_condition 1351 * Condition for waking up in dvb_ca_en50221_io_read_condition
1369 */ 1352 */
1370static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *result, int *_slot) 1353static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
1354 int *result, int *_slot)
1371{ 1355{
1372 int slot; 1356 int slot;
1373 int slot_count = 0; 1357 int slot_count = 0;
1374 int idx; 1358 int idx;
1375 int fraglen; 1359 size_t fraglen;
1376 int connection_id = -1; 1360 int connection_id = -1;
1377 int found = 0; 1361 int found = 0;
1378 u8 hdr[2]; 1362 u8 hdr[2];
@@ -1382,10 +1366,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1382 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) 1366 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
1383 goto nextslot; 1367 goto nextslot;
1384 1368
1385 down_read(&ca->slot_info[slot].sem);
1386
1387 if (ca->slot_info[slot].rx_buffer.data == NULL) { 1369 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1388 up_read(&ca->slot_info[slot].sem);
1389 return 0; 1370 return 0;
1390 } 1371 }
1391 1372
@@ -1403,10 +1384,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1403 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen); 1384 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
1404 } 1385 }
1405 1386
1406 if (!found) 1387nextslot:
1407 up_read(&ca->slot_info[slot].sem);
1408
1409 nextslot:
1410 slot = (slot + 1) % ca->slot_count; 1388 slot = (slot + 1) % ca->slot_count;
1411 slot_count++; 1389 slot_count++;
1412 } 1390 }
@@ -1511,8 +1489,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1511 goto exit; 1489 goto exit;
1512 status = pktlen; 1490 status = pktlen;
1513 1491
1514 exit: 1492exit:
1515 up_read(&ca->slot_info[slot].sem);
1516 return status; 1493 return status;
1517} 1494}
1518 1495
@@ -1544,11 +1521,11 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1544 for (i = 0; i < ca->slot_count; i++) { 1521 for (i = 0; i < ca->slot_count; i++) {
1545 1522
1546 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) { 1523 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
1547 down_write(&ca->slot_info[i].sem);
1548 if (ca->slot_info[i].rx_buffer.data != NULL) { 1524 if (ca->slot_info[i].rx_buffer.data != NULL) {
1525 /* it is safe to call this here without locks because
1526 * ca->open == 0. Data is not read in this case */
1549 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer); 1527 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
1550 } 1528 }
1551 up_write(&ca->slot_info[i].sem);
1552 } 1529 }
1553 } 1530 }
1554 1531
@@ -1607,7 +1584,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1607 dprintk("%s\n", __FUNCTION__); 1584 dprintk("%s\n", __FUNCTION__);
1608 1585
1609 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1586 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1610 up_read(&ca->slot_info[slot].sem);
1611 mask |= POLLIN; 1587 mask |= POLLIN;
1612 } 1588 }
1613 1589
@@ -1619,7 +1595,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1619 poll_wait(file, &ca->wait_queue, wait); 1595 poll_wait(file, &ca->wait_queue, wait);
1620 1596
1621 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1597 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1622 up_read(&ca->slot_info[slot].sem);
1623 mask |= POLLIN; 1598 mask |= POLLIN;
1624 } 1599 }
1625 1600
@@ -1709,7 +1684,6 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1709 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; 1684 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
1710 atomic_set(&ca->slot_info[i].camchange_count, 0); 1685 atomic_set(&ca->slot_info[i].camchange_count, 0);
1711 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 1686 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
1712 init_rwsem(&ca->slot_info[i].sem);
1713 } 1687 }
1714 1688
1715 if (signal_pending(current)) { 1689 if (signal_pending(current)) {
@@ -1729,7 +1703,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1729 ca->thread_pid = ret; 1703 ca->thread_pid = ret;
1730 return 0; 1704 return 0;
1731 1705
1732 error: 1706error:
1733 if (ca != NULL) { 1707 if (ca != NULL) {
1734 if (ca->dvbdev != NULL) 1708 if (ca->dvbdev != NULL)
1735 dvb_unregister_device(ca->dvbdev); 1709 dvb_unregister_device(ca->dvbdev);
@@ -1771,6 +1745,9 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1771 1745
1772 for (i = 0; i < ca->slot_count; i++) { 1746 for (i = 0; i < ca->slot_count; i++) {
1773 dvb_ca_en50221_slot_shutdown(ca, i); 1747 dvb_ca_en50221_slot_shutdown(ca, i);
1748 if (ca->slot_info[i].rx_buffer.data != NULL) {
1749 vfree(ca->slot_info[i].rx_buffer.data);
1750 }
1774 } 1751 }
1775 kfree(ca->slot_info); 1752 kfree(ca->slot_info);
1776 dvb_unregister_device(ca->dvbdev); 1753 dvb_unregister_device(ca->dvbdev);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 87935490bfb2..df536bd2e103 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -151,6 +151,8 @@ struct dvb_net_priv {
151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */ 151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */ 152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
153 unsigned long ts_count; /* Current ts cell counter. */ 153 unsigned long ts_count; /* Current ts cell counter. */
154
155 struct semaphore mutex;
154}; 156};
155 157
156 158
@@ -881,12 +883,13 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
881 883
882static int dvb_net_feed_start(struct net_device *dev) 884static int dvb_net_feed_start(struct net_device *dev)
883{ 885{
884 int ret, i; 886 int ret = 0, i;
885 struct dvb_net_priv *priv = dev->priv; 887 struct dvb_net_priv *priv = dev->priv;
886 struct dmx_demux *demux = priv->demux; 888 struct dmx_demux *demux = priv->demux;
887 unsigned char *mac = (unsigned char *) dev->dev_addr; 889 unsigned char *mac = (unsigned char *) dev->dev_addr;
888 890
889 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); 891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
892 down(&priv->mutex);
890 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) 893 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
891 printk("%s: BUG %d\n", __FUNCTION__, __LINE__); 894 printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
892 895
@@ -900,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev)
900 dvb_net_sec_callback); 903 dvb_net_sec_callback);
901 if (ret<0) { 904 if (ret<0) {
902 printk("%s: could not allocate section feed\n", dev->name); 905 printk("%s: could not allocate section feed\n", dev->name);
903 return ret; 906 goto error;
904 } 907 }
905 908
906 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); 909 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1);
@@ -909,7 +912,7 @@ static int dvb_net_feed_start(struct net_device *dev)
909 printk("%s: could not set section feed\n", dev->name); 912 printk("%s: could not set section feed\n", dev->name);
910 priv->demux->release_section_feed(priv->demux, priv->secfeed); 913 priv->demux->release_section_feed(priv->demux, priv->secfeed);
911 priv->secfeed=NULL; 914 priv->secfeed=NULL;
912 return ret; 915 goto error;
913 } 916 }
914 917
915 if (priv->rx_mode != RX_MODE_PROMISC) { 918 if (priv->rx_mode != RX_MODE_PROMISC) {
@@ -948,7 +951,7 @@ static int dvb_net_feed_start(struct net_device *dev)
948 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); 951 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
949 if (ret < 0) { 952 if (ret < 0) {
950 printk("%s: could not allocate ts feed\n", dev->name); 953 printk("%s: could not allocate ts feed\n", dev->name);
951 return ret; 954 goto error;
952 } 955 }
953 956
954 /* Set netdevice pointer for ts decaps callback. */ 957 /* Set netdevice pointer for ts decaps callback. */
@@ -962,23 +965,26 @@ static int dvb_net_feed_start(struct net_device *dev)
962 printk("%s: could not set ts feed\n", dev->name); 965 printk("%s: could not set ts feed\n", dev->name);
963 priv->demux->release_ts_feed(priv->demux, priv->tsfeed); 966 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
964 priv->tsfeed = NULL; 967 priv->tsfeed = NULL;
965 return ret; 968 goto error;
966 } 969 }
967 970
968 dprintk("%s: start filtering\n", __FUNCTION__); 971 dprintk("%s: start filtering\n", __FUNCTION__);
969 priv->tsfeed->start_filtering(priv->tsfeed); 972 priv->tsfeed->start_filtering(priv->tsfeed);
970 } else 973 } else
971 return -EINVAL; 974 ret = -EINVAL;
972 975
973 return 0; 976error:
977 up(&priv->mutex);
978 return ret;
974} 979}
975 980
976static int dvb_net_feed_stop(struct net_device *dev) 981static int dvb_net_feed_stop(struct net_device *dev)
977{ 982{
978 struct dvb_net_priv *priv = dev->priv; 983 struct dvb_net_priv *priv = dev->priv;
979 int i; 984 int i, ret = 0;
980 985
981 dprintk("%s\n", __FUNCTION__); 986 dprintk("%s\n", __FUNCTION__);
987 down(&priv->mutex);
982 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { 988 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
983 if (priv->secfeed) { 989 if (priv->secfeed) {
984 if (priv->secfeed->is_filtering) { 990 if (priv->secfeed->is_filtering) {
@@ -1019,8 +1025,9 @@ static int dvb_net_feed_stop(struct net_device *dev)
1019 else 1025 else
1020 printk("%s: no ts feed to stop\n", dev->name); 1026 printk("%s: no ts feed to stop\n", dev->name);
1021 } else 1027 } else
1022 return -EINVAL; 1028 ret = -EINVAL;
1023 return 0; 1029 up(&priv->mutex);
1030 return ret;
1024} 1031}
1025 1032
1026 1033
@@ -1044,8 +1051,8 @@ static void wq_set_multicast_list (void *data)
1044 struct dvb_net_priv *priv = dev->priv; 1051 struct dvb_net_priv *priv = dev->priv;
1045 1052
1046 dvb_net_feed_stop(dev); 1053 dvb_net_feed_stop(dev);
1047
1048 priv->rx_mode = RX_MODE_UNI; 1054 priv->rx_mode = RX_MODE_UNI;
1055 spin_lock_bh(&dev->xmit_lock);
1049 1056
1050 if (dev->flags & IFF_PROMISC) { 1057 if (dev->flags & IFF_PROMISC) {
1051 dprintk("%s: promiscuous mode\n", dev->name); 1058 dprintk("%s: promiscuous mode\n", dev->name);
@@ -1070,6 +1077,7 @@ static void wq_set_multicast_list (void *data)
1070 } 1077 }
1071 } 1078 }
1072 1079
1080 spin_unlock_bh(&dev->xmit_lock);
1073 dvb_net_feed_start(dev); 1081 dvb_net_feed_start(dev);
1074} 1082}
1075 1083
@@ -1200,6 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1200 1208
1201 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1209 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
1202 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1210 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
1211 init_MUTEX(&priv->mutex);
1203 1212
1204 net->base_addr = pid; 1213 net->base_addr = pid;
1205 1214
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index 49f541d9a042..8c7beffb045f 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -65,7 +65,7 @@ static struct dvb_usb_rc_key a800_rc_keys[] = {
65 65
66}; 66};
67 67
68int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 68static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
69{ 69{
70 u8 key[5]; 70 u8 key[5];
71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0), 71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 00b946419b40..269d899da488 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -21,9 +21,9 @@ MODULE_LICENSE("GPL");
21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
22{ 22{
23 if (d->priv != NULL) { 23 if (d->priv != NULL) {
24 struct dib_fe_xfer_ops *ops = d->priv; 24 struct dibusb_state *st = d->priv;
25 if (ops->fifo_ctrl != NULL) 25 if (st->ops.fifo_ctrl != NULL)
26 if (ops->fifo_ctrl(d->fe,onoff)) { 26 if (st->ops.fifo_ctrl(d->fe,onoff)) {
27 err("error while controlling the fifo of the demod."); 27 err("error while controlling the fifo of the demod.");
28 return -ENODEV; 28 return -ENODEV;
29 } 29 }
@@ -35,9 +35,9 @@ EXPORT_SYMBOL(dibusb_streaming_ctrl);
35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
36{ 36{
37 if (d->priv != NULL) { 37 if (d->priv != NULL) {
38 struct dib_fe_xfer_ops *ops = d->priv; 38 struct dibusb_state *st = d->priv;
39 if (d->pid_filtering && ops->pid_ctrl != NULL) 39 if (st->ops.pid_ctrl != NULL)
40 ops->pid_ctrl(d->fe,index,pid,onoff); 40 st->ops.pid_ctrl(d->fe,index,pid,onoff);
41 } 41 }
42 return 0; 42 return 0;
43} 43}
@@ -46,9 +46,9 @@ EXPORT_SYMBOL(dibusb_pid_filter);
46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff) 46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff)
47{ 47{
48 if (d->priv != NULL) { 48 if (d->priv != NULL) {
49 struct dib_fe_xfer_ops *ops = d->priv; 49 struct dibusb_state *st = d->priv;
50 if (ops->pid_parse != NULL) 50 if (st->ops.pid_parse != NULL)
51 if (ops->pid_parse(d->fe,onoff) < 0) 51 if (st->ops.pid_parse(d->fe,onoff) < 0)
52 err("could not handle pid_parser"); 52 err("could not handle pid_parser");
53 } 53 }
54 return 0; 54 return 0;
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 74545f82eff1..f98e306a5759 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -148,7 +148,7 @@ static struct dvb_usb_rc_key digitv_rc_keys[] = {
148}; 148};
149 149
150/* TODO is it really the NEC protocol ? */ 150/* TODO is it really the NEC protocol ? */
151int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 151static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
152{ 152{
153 u8 key[5]; 153 u8 key[5];
154 154
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a902059812a2..dd8e0b94edba 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -23,7 +23,7 @@ module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); 23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24 24
25/* general initialization functions */ 25/* general initialization functions */
26int dvb_usb_exit(struct dvb_usb_device *d) 26static int dvb_usb_exit(struct dvb_usb_device *d)
27{ 27{
28 deb_info("state before exiting everything: %x\n",d->state); 28 deb_info("state before exiting everything: %x\n",d->state);
29 dvb_usb_remote_exit(d); 29 dvb_usb_remote_exit(d);
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 9f639297a9f2..d9a8ede14b45 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -7,7 +7,7 @@
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 11f86806756e..1f250885d2ce 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -7,7 +7,7 @@
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index bad0933eb714..84b62881cea7 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -44,6 +44,8 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/moduleparam.h> 46#include <linux/moduleparam.h>
47#include <linux/slab.h>
48#include <linux/string.h>
47 49
48#include "dvb_frontend.h" 50#include "dvb_frontend.h"
49#include "dvb-pll.h" 51#include "dvb-pll.h"
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index c6d276618e86..ad8647a3c85e 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -140,25 +140,25 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
140 /* yeuch! */ 140 /* yeuch! */
141 fpxin = state->config->xin * 10; 141 fpxin = state->config->xin * 10;
142 fptmp = fpxin; do_div(fptmp, 123); 142 fptmp = fpxin; do_div(fptmp, 123);
143 if (symbolrate < fptmp); 143 if (symbolrate < fptmp)
144 SFIL = 1; 144 SFIL = 1;
145 fptmp = fpxin; do_div(fptmp, 160); 145 fptmp = fpxin; do_div(fptmp, 160);
146 if (symbolrate < fptmp); 146 if (symbolrate < fptmp)
147 SFIL = 0; 147 SFIL = 0;
148 fptmp = fpxin; do_div(fptmp, 246); 148 fptmp = fpxin; do_div(fptmp, 246);
149 if (symbolrate < fptmp); 149 if (symbolrate < fptmp)
150 SFIL = 1; 150 SFIL = 1;
151 fptmp = fpxin; do_div(fptmp, 320); 151 fptmp = fpxin; do_div(fptmp, 320);
152 if (symbolrate < fptmp); 152 if (symbolrate < fptmp)
153 SFIL = 0; 153 SFIL = 0;
154 fptmp = fpxin; do_div(fptmp, 492); 154 fptmp = fpxin; do_div(fptmp, 492);
155 if (symbolrate < fptmp); 155 if (symbolrate < fptmp)
156 SFIL = 1; 156 SFIL = 1;
157 fptmp = fpxin; do_div(fptmp, 640); 157 fptmp = fpxin; do_div(fptmp, 640);
158 if (symbolrate < fptmp); 158 if (symbolrate < fptmp)
159 SFIL = 0; 159 SFIL = 0;
160 fptmp = fpxin; do_div(fptmp, 984); 160 fptmp = fpxin; do_div(fptmp, 984);
161 if (symbolrate < fptmp); 161 if (symbolrate < fptmp)
162 SFIL = 1; 162 SFIL = 1;
163 163
164 fin = state->config->xin >> 4; 164 fin = state->config->xin >> 4;
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index d8bf65877897..fa5034a9ecf5 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -81,6 +81,7 @@ config DVB_BUDGET_CI
81 tristate "Budget cards with onboard CI connector" 81 tristate "Budget cards with onboard CI connector"
82 depends on DVB_CORE && PCI 82 depends on DVB_CORE && PCI
83 select VIDEO_SAA7146 83 select VIDEO_SAA7146
84 select DVB_STV0297
84 select DVB_STV0299 85 select DVB_STV0299
85 select DVB_TDA1004X 86 select DVB_TDA1004X
86 help 87 help
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index c3801e328fe9..6079e8865d5b 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -40,6 +40,7 @@
40 40
41#include "av7110.h" 41#include "av7110.h"
42#include "av7110_hw.h" 42#include "av7110_hw.h"
43#include "av7110_ca.h"
43 44
44 45
45void CI_handle(struct av7110 *av7110, u8 *data, u16 len) 46void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index aa75dc03a0b3..9f51bae7194c 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1020,6 +1020,8 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1020 1020
1021static struct saa7146_extension budget_extension = { 1021static struct saa7146_extension budget_extension = {
1022 .name = "budget_av", 1022 .name = "budget_av",
1023 .flags = SAA7146_I2C_SHORT_DELAY,
1024
1023 .pci_tbl = pci_tbl, 1025 .pci_tbl = pci_tbl,
1024 1026
1025 .module = THIS_MODULE, 1027 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 75fb92d60998..b9b3cd9c0369 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -1166,7 +1166,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1166 1166
1167static struct saa7146_extension budget_extension = { 1167static struct saa7146_extension budget_extension = {
1168 .name = "budget_ci dvb\0", 1168 .name = "budget_ci dvb\0",
1169 .flags = 0, 1169 .flags = SAA7146_I2C_SHORT_DELAY,
1170 1170
1171 .module = THIS_MODULE, 1171 .module = THIS_MODULE,
1172 .pci_tbl = &pci_tbl[0], 1172 .pci_tbl = &pci_tbl[0],
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 4fd8bbc47037..bc4ce7559cbe 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -738,7 +738,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
738 738
739static struct saa7146_extension budget_extension = { 739static struct saa7146_extension budget_extension = {
740 .name = "budget dvb\0", 740 .name = "budget dvb\0",
741 .flags = 0, 741 .flags = SAA7146_I2C_SHORT_DELAY,
742 742
743 .module = THIS_MODULE, 743 .module = THIS_MODULE,
744 .pci_tbl = pci_tbl, 744 .pci_tbl = pci_tbl,
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c
index e9a8457b0727..ac79ef178c05 100644
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.c
+++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c
@@ -37,6 +37,7 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39 39
40#include "ttpci-eeprom.h"
40 41
41#if 1 42#if 1
42#define dprintk(x...) do { printk(x); } while (0) 43#define dprintk(x...) do { printk(x); } while (0)
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index ecb9a31dd003..cc4a723e24db 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -32,9 +32,6 @@ config VIDEO_BT848_DVB
32 ---help--- 32 ---help---
33 This adds support for DVB/ATSC cards based on the BT878 chip. 33 This adds support for DVB/ATSC cards based on the BT878 chip.
34 34
35 To compile this driver as a module, choose M here: the
36 module will be called dvb-bt8xx.
37
38config VIDEO_SAA6588 35config VIDEO_SAA6588
39 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" 36 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
40 depends on VIDEO_DEV && I2C && VIDEO_BT848 37 depends on VIDEO_DEV && I2C && VIDEO_BT848
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index e31ebb11c468..012be639aa18 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -2904,7 +2904,7 @@ void __devinit bttv_idcard(struct bttv *btv)
2904 */ 2904 */
2905 2905
2906/* Some Modular Technology cards have an eeprom, but no subsystem ID */ 2906/* Some Modular Technology cards have an eeprom, but no subsystem ID */
2907void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) 2907static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
2908{ 2908{
2909 int type = -1; 2909 int type = -1;
2910 2910
@@ -3879,7 +3879,7 @@ static void __devinit init_PXC200(struct bttv *btv)
3879 * error. ERROR_CPLD_Check_Failed. 3879 * error. ERROR_CPLD_Check_Failed.
3880 */ 3880 */
3881/* ----------------------------------------------------------------------- */ 3881/* ----------------------------------------------------------------------- */
3882void 3882static void
3883init_RTV24 (struct bttv *btv) 3883init_RTV24 (struct bttv *btv)
3884{ 3884{
3885 uint32_t dataRead = 0; 3885 uint32_t dataRead = 0;
@@ -4103,7 +4103,7 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq)
4103/* ----------------------------------------------------------------------- */ 4103/* ----------------------------------------------------------------------- */
4104/* winview */ 4104/* winview */
4105 4105
4106void winview_audio(struct bttv *btv, struct video_audio *v, int set) 4106static void winview_audio(struct bttv *btv, struct video_audio *v, int set)
4107{ 4107{
4108 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ 4108 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
4109 int bits_out, loops, vol, data; 4109 int bits_out, loops, vol, data;
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 709099f03bd2..3c58a2a68906 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1720,7 +1720,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1720 memset(i,0,sizeof(*i)); 1720 memset(i,0,sizeof(*i));
1721 i->index = n; 1721 i->index = n;
1722 i->type = V4L2_INPUT_TYPE_CAMERA; 1722 i->type = V4L2_INPUT_TYPE_CAMERA;
1723 i->audioset = 1; 1723 i->audioset = 0;
1724 if (i->index == bttv_tvcards[btv->c.type].tuner) { 1724 if (i->index == bttv_tvcards[btv->c.type].tuner) {
1725 sprintf(i->name, "Television"); 1725 sprintf(i->name, "Television");
1726 i->type = V4L2_INPUT_TYPE_TUNER; 1726 i->type = V4L2_INPUT_TYPE_TUNER;
@@ -1771,12 +1771,20 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1771 memset(t,0,sizeof(*t)); 1771 memset(t,0,sizeof(*t));
1772 strcpy(t->name, "Television"); 1772 strcpy(t->name, "Television");
1773 t->type = V4L2_TUNER_ANALOG_TV; 1773 t->type = V4L2_TUNER_ANALOG_TV;
1774 t->rangehigh = 0xffffffffUL;
1775 t->capability = V4L2_TUNER_CAP_NORM; 1774 t->capability = V4L2_TUNER_CAP_NORM;
1776 t->rxsubchans = V4L2_TUNER_SUB_MONO; 1775 t->rxsubchans = V4L2_TUNER_SUB_MONO;
1777 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) 1776 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
1778 t->signal = 0xffff; 1777 t->signal = 0xffff;
1779 { 1778 {
1779 struct video_tuner tuner;
1780
1781 memset(&tuner, 0, sizeof (tuner));
1782 tuner.rangehigh = 0xffffffffUL;
1783 bttv_call_i2c_clients(btv, VIDIOCGTUNER, &tuner);
1784 t->rangelow = tuner.rangelow;
1785 t->rangehigh = tuner.rangehigh;
1786 }
1787 {
1780 /* Hmmm ... */ 1788 /* Hmmm ... */
1781 struct video_audio va; 1789 struct video_audio va;
1782 memset(&va, 0, sizeof(struct video_audio)); 1790 memset(&va, 0, sizeof(struct video_audio));
@@ -1853,7 +1861,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1853 } 1861 }
1854 case VIDIOC_LOG_STATUS: 1862 case VIDIOC_LOG_STATUS:
1855 { 1863 {
1856 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, 0); 1864 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL);
1857 return 0; 1865 return 0;
1858 } 1866 }
1859 1867
@@ -2029,19 +2037,33 @@ static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type)
2029 return 0; 2037 return 0;
2030} 2038}
2031 2039
2040static void
2041pix_format_set_size (struct v4l2_pix_format * f,
2042 const struct bttv_format * fmt,
2043 unsigned int width,
2044 unsigned int height)
2045{
2046 f->width = width;
2047 f->height = height;
2048
2049 if (fmt->flags & FORMAT_FLAGS_PLANAR) {
2050 f->bytesperline = width; /* Y plane */
2051 f->sizeimage = (width * height * fmt->depth) >> 3;
2052 } else {
2053 f->bytesperline = (width * fmt->depth) >> 3;
2054 f->sizeimage = height * f->bytesperline;
2055 }
2056}
2057
2032static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f) 2058static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f)
2033{ 2059{
2034 switch (f->type) { 2060 switch (f->type) {
2035 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 2061 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2036 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format)); 2062 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format));
2037 f->fmt.pix.width = fh->width; 2063 pix_format_set_size (&f->fmt.pix, fh->fmt,
2038 f->fmt.pix.height = fh->height; 2064 fh->width, fh->height);
2039 f->fmt.pix.field = fh->cap.field; 2065 f->fmt.pix.field = fh->cap.field;
2040 f->fmt.pix.pixelformat = fh->fmt->fourcc; 2066 f->fmt.pix.pixelformat = fh->fmt->fourcc;
2041 f->fmt.pix.bytesperline =
2042 (f->fmt.pix.width * fh->fmt->depth) >> 3;
2043 f->fmt.pix.sizeimage =
2044 f->fmt.pix.height * f->fmt.pix.bytesperline;
2045 return 0; 2067 return 0;
2046 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 2068 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2047 memset(&f->fmt.win,0,sizeof(struct v4l2_window)); 2069 memset(&f->fmt.win,0,sizeof(struct v4l2_window));
@@ -2106,11 +2128,9 @@ static int bttv_try_fmt(struct bttv_fh *fh, struct bttv *btv,
2106 f->fmt.pix.width = maxw; 2128 f->fmt.pix.width = maxw;
2107 if (f->fmt.pix.height > maxh) 2129 if (f->fmt.pix.height > maxh)
2108 f->fmt.pix.height = maxh; 2130 f->fmt.pix.height = maxh;
2109 f->fmt.pix.width &= ~0x03; 2131 pix_format_set_size (&f->fmt.pix, fmt,
2110 f->fmt.pix.bytesperline = 2132 f->fmt.pix.width & ~3,
2111 (f->fmt.pix.width * fmt->depth) >> 3; 2133 f->fmt.pix.height);
2112 f->fmt.pix.sizeimage =
2113 f->fmt.pix.height * f->fmt.pix.bytesperline;
2114 2134
2115 return 0; 2135 return 0;
2116 } 2136 }
@@ -2278,6 +2298,15 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2278 retval = -EINVAL; 2298 retval = -EINVAL;
2279 goto fh_unlock_and_return; 2299 goto fh_unlock_and_return;
2280 } 2300 }
2301 if (fmt->flags & FORMAT_FLAGS_RAW) {
2302 /* VIDIOCMCAPTURE uses gbufsize, not RAW_BPL *
2303 RAW_LINES * 2. F1 is stored at offset 0, F2
2304 at buffer size / 2. */
2305 fh->width = RAW_BPL;
2306 fh->height = gbufsize / RAW_BPL;
2307 btv->init.width = RAW_BPL;
2308 btv->init.height = gbufsize / RAW_BPL;
2309 }
2281 fh->ovfmt = fmt; 2310 fh->ovfmt = fmt;
2282 fh->fmt = fmt; 2311 fh->fmt = fmt;
2283 btv->init.ovfmt = fmt; 2312 btv->init.ovfmt = fmt;
@@ -2589,9 +2618,11 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2589 2618
2590 if (0 == v4l2) 2619 if (0 == v4l2)
2591 return -EINVAL; 2620 return -EINVAL;
2592 strcpy(cap->driver,"bttv"); 2621 memset(cap, 0, sizeof (*cap));
2593 strlcpy(cap->card,btv->video_dev->name,sizeof(cap->card)); 2622 strlcpy(cap->driver, "bttv", sizeof (cap->driver));
2594 sprintf(cap->bus_info,"PCI:%s",pci_name(btv->c.pci)); 2623 strlcpy(cap->card, btv->video_dev->name, sizeof (cap->card));
2624 snprintf(cap->bus_info, sizeof (cap->bus_info),
2625 "PCI:%s", pci_name(btv->c.pci));
2595 cap->version = BTTV_VERSION_CODE; 2626 cap->version = BTTV_VERSION_CODE;
2596 cap->capabilities = 2627 cap->capabilities =
2597 V4L2_CAP_VIDEO_CAPTURE | 2628 V4L2_CAP_VIDEO_CAPTURE |
@@ -2952,6 +2983,8 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
2952 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 2983 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
2953 field = videobuf_next_field(&fh->cap); 2984 field = videobuf_next_field(&fh->cap);
2954 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 2985 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
2986 kfree (fh->cap.read_buf);
2987 fh->cap.read_buf = NULL;
2955 up(&fh->cap.lock); 2988 up(&fh->cap.lock);
2956 return POLLERR; 2989 return POLLERR;
2957 } 2990 }
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index f6afeec499c5..aea3f038cff6 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -208,8 +208,11 @@ static void cx25840_initialize(struct i2c_client *client, int loadfw)
208 208
209static void input_change(struct i2c_client *client) 209static void input_change(struct i2c_client *client)
210{ 210{
211 struct cx25840_state *state = i2c_get_clientdata(client);
211 v4l2_std_id std = cx25840_get_v4lstd(client); 212 v4l2_std_id std = cx25840_get_v4lstd(client);
212 213
214 /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
215 instead of V4L2_STD_PAL. Someone needs to test this. */
213 if (std & V4L2_STD_PAL) { 216 if (std & V4L2_STD_PAL) {
214 /* Follow tuner change procedure for PAL */ 217 /* Follow tuner change procedure for PAL */
215 cx25840_write(client, 0x808, 0xff); 218 cx25840_write(client, 0x808, 0xff);
@@ -220,7 +223,32 @@ static void input_change(struct i2c_client *client)
220 cx25840_write(client, 0x80b, 0x10); 223 cx25840_write(client, 0x80b, 0x10);
221 } else if (std & V4L2_STD_NTSC) { 224 } else if (std & V4L2_STD_NTSC) {
222 /* NTSC */ 225 /* NTSC */
223 cx25840_write(client, 0x808, 0xf6); 226 if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
227 /* Certain Hauppauge PVR150 models have a hardware bug
228 that causes audio to drop out. For these models the
229 audio standard must be set explicitly.
230 To be precise: it affects cards with tuner models
231 85, 99 and 112 (model numbers from tveeprom). */
232 if (std == V4L2_STD_NTSC_M_JP) {
233 /* Japan uses EIAJ audio standard */
234 cx25840_write(client, 0x808, 0x2f);
235 } else {
236 /* Others use the BTSC audio standard */
237 cx25840_write(client, 0x808, 0x1f);
238 }
239 /* South Korea uses the A2-M (aka Zweiton M) audio
240 standard, and should set 0x808 to 0x3f, but I don't
241 know how to detect this. */
242 } else if (std == V4L2_STD_NTSC_M_JP) {
243 /* Japan uses EIAJ audio standard */
244 cx25840_write(client, 0x808, 0xf7);
245 } else {
246 /* Others use the BTSC audio standard */
247 cx25840_write(client, 0x808, 0xf6);
248 }
249 /* South Korea uses the A2-M (aka Zweiton M) audio standard,
250 and should set 0x808 to 0xf8, but I don't know how to
251 detect this. */
224 cx25840_write(client, 0x80b, 0x00); 252 cx25840_write(client, 0x80b, 0x00);
225 } 253 }
226 254
@@ -241,7 +269,8 @@ static int set_input(struct i2c_client *client, enum cx25840_input input)
241 case CX25840_TUNER: 269 case CX25840_TUNER:
242 cx25840_dbg("now setting Tuner input\n"); 270 cx25840_dbg("now setting Tuner input\n");
243 271
244 if (state->cardtype == CARDTYPE_PVR150) { 272 if (state->cardtype == CARDTYPE_PVR150 ||
273 state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
245 /* CH_SEL_ADC2=1 */ 274 /* CH_SEL_ADC2=1 */
246 cx25840_and_or(client, 0x102, ~0x2, 0x02); 275 cx25840_and_or(client, 0x102, ~0x2, 0x02);
247 } 276 }
@@ -363,6 +392,7 @@ static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
363 case CX25840_CID_CARDTYPE: 392 case CX25840_CID_CARDTYPE:
364 switch (ctrl->value) { 393 switch (ctrl->value) {
365 case CARDTYPE_PVR150: 394 case CARDTYPE_PVR150:
395 case CARDTYPE_PVR150_WORKAROUND:
366 case CARDTYPE_PG600: 396 case CARDTYPE_PG600:
367 state->cardtype = ctrl->value; 397 state->cardtype = ctrl->value;
368 break; 398 break;
@@ -714,7 +744,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
714 744
715/* ----------------------------------------------------------------------- */ 745/* ----------------------------------------------------------------------- */
716 746
717struct i2c_driver i2c_driver_cx25840; 747static struct i2c_driver i2c_driver_cx25840;
718 748
719static int cx25840_detect_client(struct i2c_adapter *adapter, int address, 749static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
720 int kind) 750 int kind)
@@ -807,7 +837,7 @@ static int cx25840_detach_client(struct i2c_client *client)
807 837
808/* ----------------------------------------------------------------------- */ 838/* ----------------------------------------------------------------------- */
809 839
810struct i2c_driver i2c_driver_cx25840 = { 840static struct i2c_driver i2c_driver_cx25840 = {
811 .name = "cx25840", 841 .name = "cx25840",
812 842
813 .id = I2C_DRIVERID_CX25840, 843 .id = I2C_DRIVERID_CX25840,
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
index 5c3f0639fb77..4932ed1c9b19 100644
--- a/drivers/media/video/cx25840/cx25840.h
+++ b/drivers/media/video/cx25840/cx25840.h
@@ -40,9 +40,16 @@ extern int cx25840_debug;
40 40
41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)
42 42
43/* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a
44 hardware bug that is present in PVR150 (and possible PVR500) cards that
45 have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The
46 audio autodetect fails on some channels for these models and the workaround
47 is to select the audio standard explicitly. Many thanks to Hauppauge for
48 providing this information. */
43enum cx25840_cardtype { 49enum cx25840_cardtype {
44 CARDTYPE_PVR150, 50 CARDTYPE_PVR150,
45 CARDTYPE_PG600 51 CARDTYPE_PG600,
52 CARDTYPE_PVR150_WORKAROUND,
46}; 53};
47 54
48enum cx25840_input { 55enum cx25840_input {
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index f2268631b7c0..24651661630a 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1083,41 +1083,28 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1083 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); 1083 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
1084 core->tuner_type = tv.tuner_type; 1084 core->tuner_type = tv.tuner_type;
1085 core->has_radio = tv.has_radio; 1085 core->has_radio = tv.has_radio;
1086}
1087
1088static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
1089{
1090 int model;
1091 int tuner;
1092 1086
1093 /* Make sure we support the board model */ 1087 /* Make sure we support the board model */
1094 model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c]; 1088 switch (tv.model)
1095 switch(model) { 1089 {
1096 case 90002: 1090 case 90002: /* Nova-T-PCI (9002) */
1097 case 90500: 1091 case 92001: /* Nova-S-Plus (Video and IR) */
1098 case 90501: 1092 case 92002: /* Nova-S-Plus (Video and IR) */
1093 case 90003: /* Nova-T-PCI (9002 No RF out) */
1094 case 90500: /* Nova-T-PCI (oem) */
1095 case 90501: /* Nova-T-PCI (oem/IR) */
1096 case 92000: /* Nova-SE2 (OEM, No Video or IR) */
1097
1099 /* known */ 1098 /* known */
1100 break; 1099 break;
1101 default: 1100 default:
1102 printk("%s: warning: unknown hauppauge model #%d\n", 1101 printk("%s: warning: unknown hauppauge model #%d\n",
1103 core->name, model); 1102 core->name, tv.model);
1104 break; 1103 break;
1105 } 1104 }
1106 1105
1107 /* Make sure we support the tuner */ 1106 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
1108 tuner = ee[0x2d]; 1107 core->name, tv.model);
1109 switch(tuner) {
1110 case 0x4B: /* dtt 7595 */
1111 case 0x4C: /* dtt 7592 */
1112 break;
1113 default:
1114 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
1115 core->name, tuner);
1116 return -ENODEV;
1117 }
1118 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
1119 core->name, model, tuner);
1120 return 0;
1121} 1108}
1122 1109
1123/* ----------------------------------------------------------------------- */ 1110/* ----------------------------------------------------------------------- */
@@ -1201,7 +1188,7 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
1201 1188
1202void cx88_card_setup(struct cx88_core *core) 1189void cx88_card_setup(struct cx88_core *core)
1203{ 1190{
1204 static u8 eeprom[128]; 1191 static u8 eeprom[256];
1205 1192
1206 if (0 == core->i2c_rc) { 1193 if (0 == core->i2c_rc) {
1207 core->i2c_client.addr = 0xa0 >> 1; 1194 core->i2c_client.addr = 0xa0 >> 1;
@@ -1224,7 +1211,7 @@ void cx88_card_setup(struct cx88_core *core)
1224 break; 1211 break;
1225 case CX88_BOARD_HAUPPAUGE_DVB_T1: 1212 case CX88_BOARD_HAUPPAUGE_DVB_T1:
1226 if (0 == core->i2c_rc) 1213 if (0 == core->i2c_rc)
1227 hauppauge_eeprom_dvb(core,eeprom); 1214 hauppauge_eeprom(core,eeprom);
1228 break; 1215 break;
1229 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 1216 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
1230 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 1217 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index eb806af17182..bb6eb54e19ce 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -837,6 +837,29 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
837 return -1; 837 return -1;
838} 838}
839 839
840int cx88_start_audio_dma(struct cx88_core *core)
841{
842 /* setup fifo + format */
843 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
844 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
845
846 cx_write(MO_AUDD_LNGTH, 128); /* fifo bpl size */
847 cx_write(MO_AUDR_LNGTH, 128); /* fifo bpl size */
848
849 /* start dma */
850 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
851
852 return 0;
853}
854
855int cx88_stop_audio_dma(struct cx88_core *core)
856{
857 /* stop dma */
858 cx_write(MO_AUD_DMACNTRL, 0x0000);
859
860 return 0;
861}
862
840static int set_tvaudio(struct cx88_core *core) 863static int set_tvaudio(struct cx88_core *core)
841{ 864{
842 struct cx88_tvnorm *norm = core->tvnorm; 865 struct cx88_tvnorm *norm = core->tvnorm;
@@ -877,12 +900,16 @@ static int set_tvaudio(struct cx88_core *core)
877 cx88_set_tvaudio(core); 900 cx88_set_tvaudio(core);
878 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ 901 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
879 902
880 cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ 903/*
881 cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ 904 This should be needed only on cx88-alsa. It seems that some cx88 chips have
882 cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */ 905 bugs and does require DMA enabled for it to work.
906 */
907 cx88_start_audio_dma(core);
883 return 0; 908 return 0;
884} 909}
885 910
911
912
886int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) 913int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
887{ 914{
888 u32 fsc8; 915 u32 fsc8;
@@ -1204,6 +1231,8 @@ EXPORT_SYMBOL(cx88_set_scale);
1204EXPORT_SYMBOL(cx88_vdev_init); 1231EXPORT_SYMBOL(cx88_vdev_init);
1205EXPORT_SYMBOL(cx88_core_get); 1232EXPORT_SYMBOL(cx88_core_get);
1206EXPORT_SYMBOL(cx88_core_put); 1233EXPORT_SYMBOL(cx88_core_put);
1234EXPORT_SYMBOL(cx88_start_audio_dma);
1235EXPORT_SYMBOL(cx88_stop_audio_dma);
1207 1236
1208/* 1237/*
1209 * Local variables: 1238 * Local variables:
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 6d9bec1c583b..a1b120c8a9b5 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -119,13 +119,10 @@ static void set_audio_registers(struct cx88_core *core, const struct rlist *l)
119 119
120static void set_audio_start(struct cx88_core *core, u32 mode) 120static void set_audio_start(struct cx88_core *core, u32 mode)
121{ 121{
122 // mute 122 /* mute */
123 cx_write(AUD_VOL_CTL, (1 << 6)); 123 cx_write(AUD_VOL_CTL, (1 << 6));
124 124
125 // start programming 125 /* start programming */
126 cx_write(MO_AUD_DMACNTRL, 0x0000);
127 msleep(100);
128 //cx_write(AUD_CTL, 0x0000);
129 cx_write(AUD_INIT, mode); 126 cx_write(AUD_INIT, mode);
130 cx_write(AUD_INIT_LD, 0x0001); 127 cx_write(AUD_INIT_LD, 0x0001);
131 cx_write(AUD_SOFT_RESET, 0x0001); 128 cx_write(AUD_SOFT_RESET, 0x0001);
@@ -135,17 +132,21 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
135{ 132{
136 u32 volume; 133 u32 volume;
137 134
135 /* restart dma; This avoids buzz in NICAM and is good in others */
136 cx88_stop_audio_dma(core);
137 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
138 cx88_start_audio_dma(core);
139
138 if (cx88_boards[core->board].blackbird) { 140 if (cx88_boards[core->board].blackbird) {
139 // sets sound input from external adc 141 /* sets sound input from external adc */
140 cx_set(AUD_CTL, EN_I2SIN_ENABLE); 142 cx_set(AUD_CTL, EN_I2SIN_ENABLE);
141 //cx_write(AUD_I2SINPUTCNTL, 0);
142 cx_write(AUD_I2SINPUTCNTL, 4); 143 cx_write(AUD_I2SINPUTCNTL, 4);
143 cx_write(AUD_BAUDRATE, 1); 144 cx_write(AUD_BAUDRATE, 1);
144 // 'pass-thru mode': this enables the i2s output to the mpeg encoder 145 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
145 cx_set(AUD_CTL, EN_I2SOUT_ENABLE); 146 cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
146 cx_write(AUD_I2SOUTPUTCNTL, 1); 147 cx_write(AUD_I2SOUTPUTCNTL, 1);
147 cx_write(AUD_I2SCNTL, 0); 148 cx_write(AUD_I2SCNTL, 0);
148 //cx_write(AUD_APB_IN_RATE_ADJ, 0); 149 /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
149 } else { 150 } else {
150 ctl |= EN_DAC_ENABLE; 151 ctl |= EN_DAC_ENABLE;
151 cx_write(AUD_CTL, ctl); 152 cx_write(AUD_CTL, ctl);
@@ -153,7 +154,6 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
153 154
154 /* finish programming */ 155 /* finish programming */
155 cx_write(AUD_SOFT_RESET, 0x0000); 156 cx_write(AUD_SOFT_RESET, 0x0000);
156 cx_write(MO_AUD_DMACNTRL, 0x0003);
157 157
158 /* unmute */ 158 /* unmute */
159 volume = cx_sread(SHADOW_AUD_VOL_CTL); 159 volume = cx_sread(SHADOW_AUD_VOL_CTL);
@@ -313,7 +313,6 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
313 {AUD_RATE_ADJ3, 0x00000100}, 313 {AUD_RATE_ADJ3, 0x00000100},
314 {AUD_RATE_ADJ4, 0x00000400}, 314 {AUD_RATE_ADJ4, 0x00000400},
315 {AUD_RATE_ADJ5, 0x00001000}, 315 {AUD_RATE_ADJ5, 0x00001000},
316 //{ AUD_DMD_RA_DDS, 0x00c0d5ce },
317 {AUD_ERRLOGPERIOD_R, 0x00000fff}, 316 {AUD_ERRLOGPERIOD_R, 0x00000fff},
318 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff}, 317 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff},
319 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff}, 318 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff},
@@ -351,12 +350,12 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
351 set_audio_registers(core, nicam_l); 350 set_audio_registers(core, nicam_l);
352 break; 351 break;
353 case WW_I: 352 case WW_I:
354 dprintk("%s PAL-I NICAM (status: devel)\n", __FUNCTION__); 353 dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__);
355 set_audio_registers(core, nicam_bgdki_common); 354 set_audio_registers(core, nicam_bgdki_common);
356 set_audio_registers(core, nicam_i); 355 set_audio_registers(core, nicam_i);
357 break; 356 break;
358 default: 357 default:
359 dprintk("%s PAL-BGDK NICAM (status: unknown)\n", __FUNCTION__); 358 dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__);
360 set_audio_registers(core, nicam_bgdki_common); 359 set_audio_registers(core, nicam_bgdki_common);
361 set_audio_registers(core, nicam_default); 360 set_audio_registers(core, nicam_default);
362 break; 361 break;
@@ -715,8 +714,7 @@ int cx88_detect_nicam(struct cx88_core *core)
715 /* if bit1=1 then nicam is detected */ 714 /* if bit1=1 then nicam is detected */
716 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1); 715 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1);
717 716
718 /* 3x detected: absolutly sure now */ 717 if (j == 1) {
719 if (j == 3) {
720 dprintk("nicam is detected.\n"); 718 dprintk("nicam is detected.\n");
721 return 1; 719 return 1;
722 } 720 }
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b19d3a9e2298..27fb080fd7aa 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -491,6 +491,10 @@ extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
491extern void cx88_core_put(struct cx88_core *core, 491extern void cx88_core_put(struct cx88_core *core,
492 struct pci_dev *pci); 492 struct pci_dev *pci);
493 493
494extern int cx88_start_audio_dma(struct cx88_core *core);
495extern int cx88_stop_audio_dma(struct cx88_core *core);
496
497
494/* ----------------------------------------------------------- */ 498/* ----------------------------------------------------------- */
495/* cx88-vbi.c */ 499/* cx88-vbi.c */
496 500
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index d54bc0127484..9f6e5e5355a1 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -32,7 +32,7 @@
32 32
33/* #define ENABLE_DEBUG_ISOC_FRAMES */ 33/* #define ENABLE_DEBUG_ISOC_FRAMES */
34 34
35unsigned int core_debug; 35static unsigned int core_debug;
36module_param(core_debug,int,0644); 36module_param(core_debug,int,0644);
37MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); 37MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
38 38
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
41 printk(KERN_INFO "%s %s :"fmt, \ 41 printk(KERN_INFO "%s %s :"fmt, \
42 dev->name, __FUNCTION__ , ##arg); } while (0) 42 dev->name, __FUNCTION__ , ##arg); } while (0)
43 43
44unsigned int reg_debug; 44static unsigned int reg_debug;
45module_param(reg_debug,int,0644); 45module_param(reg_debug,int,0644);
46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); 46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
47 47
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
50 printk(KERN_INFO "%s %s :"fmt, \ 50 printk(KERN_INFO "%s %s :"fmt, \
51 dev->name, __FUNCTION__ , ##arg); } while (0) 51 dev->name, __FUNCTION__ , ##arg); } while (0)
52 52
53unsigned int isoc_debug; 53static unsigned int isoc_debug;
54module_param(isoc_debug,int,0644); 54module_param(isoc_debug,int,0644);
55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); 55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]");
56 56
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 57c1826b928e..abec32c175aa 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -226,7 +226,7 @@ static int em28xx_config(struct em28xx *dev)
226 * em28xx_config_i2c() 226 * em28xx_config_i2c()
227 * configure i2c attached devices 227 * configure i2c attached devices
228 */ 228 */
229void em28xx_config_i2c(struct em28xx *dev) 229static void em28xx_config_i2c(struct em28xx *dev)
230{ 230{
231 struct v4l2_frequency f; 231 struct v4l2_frequency f;
232 struct video_decoder_init em28xx_vdi = {.data = NULL }; 232 struct video_decoder_init em28xx_vdi = {.data = NULL };
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 801c736e9328..124c502ea1f3 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -278,7 +278,7 @@ static int ir_probe(struct i2c_adapter *adap);
278 278
279static struct i2c_driver driver = { 279static struct i2c_driver driver = {
280 .name = "ir remote kbd driver", 280 .name = "ir remote kbd driver",
281 .id = I2C_DRIVERID_EXP3, /* FIXME */ 281 .id = I2C_DRIVERID_I2C_IR,
282 .flags = I2C_DF_NOTIFY, 282 .flags = I2C_DF_NOTIFY,
283 .attach_adapter = ir_probe, 283 .attach_adapter = ir_probe,
284 .detach_client = ir_detach, 284 .detach_client = ir_detach,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 0235cef07b31..e717e30d8187 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -771,17 +771,19 @@ static v4l2_std_id saa7115_get_v4lstd(struct i2c_client *client)
771 771
772static void saa7115_log_status(struct i2c_client *client) 772static void saa7115_log_status(struct i2c_client *client)
773{ 773{
774 static const char * const audclk_freq_strs[] = {
775 "44.1 kHz",
776 "48 kHz",
777 "32 kHz"
778 };
779 struct saa7115_state *state = i2c_get_clientdata(client); 774 struct saa7115_state *state = i2c_get_clientdata(client);
775 char *audfreq = "undefined";
780 int reg1e, reg1f; 776 int reg1e, reg1f;
781 int signalOk; 777 int signalOk;
782 int vcr; 778 int vcr;
783 779
784 saa7115_info("Audio frequency: %s\n", audclk_freq_strs[state->audclk_freq]); 780 switch (state->audclk_freq) {
781 case V4L2_AUDCLK_32_KHZ: audfreq = "32 kHz"; break;
782 case V4L2_AUDCLK_441_KHZ: audfreq = "44.1 kHz"; break;
783 case V4L2_AUDCLK_48_KHZ: audfreq = "48 kHz"; break;
784 }
785
786 saa7115_info("Audio frequency: %s\n", audfreq);
785 if (client->name[6] == '4') { 787 if (client->name[6] == '4') {
786 /* status for the saa7114 */ 788 /* status for the saa7114 */
787 reg1f = saa7115_read(client, 0x1f); 789 reg1f = saa7115_read(client, 0x1f);
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 25b30f352d84..59e13fdea780 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -323,7 +323,7 @@ saa711x_command (struct i2c_client *client,
323 323
324 case VIDEO_MODE_SECAM: 324 case VIDEO_MODE_SECAM:
325 saa711x_write(client, 0x08, 325 saa711x_write(client, 0x08,
326 (decoder->reg[0x0e] & 0x3f) | 0x00); 326 (decoder->reg[0x08] & 0x3f) | 0x00);
327 saa711x_write(client, 0x0e, 327 saa711x_write(client, 0x0e,
328 (decoder->reg[0x0e] & 0x8f) | 0x50); 328 (decoder->reg[0x0e] & 0x8f) | 0x50);
329 break; 329 break;
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 843431f10e3b..3428e1ed0032 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -223,7 +223,7 @@ static const struct i2c_reg_value saa7127_init_config_60hz[] = {
223}; 223};
224 224
225#define SAA7127_50HZ_DAC_CONTROL 0x02 225#define SAA7127_50HZ_DAC_CONTROL 0x02
226struct i2c_reg_value saa7127_init_config_50hz[] = { 226static struct i2c_reg_value saa7127_init_config_50hz[] = {
227 { SAA7127_REG_BURST_START, 0x21 }, 227 { SAA7127_REG_BURST_START, 0x21 },
228 /* BURST_END is also used as a chip ID in saa7127_detect_client */ 228 /* BURST_END is also used as a chip ID in saa7127_detect_client */
229 { SAA7127_REG_BURST_END, 0x1d }, 229 { SAA7127_REG_BURST_END, 0x1d },
@@ -696,7 +696,7 @@ static int saa7127_command(struct i2c_client *client,
696 696
697/* ----------------------------------------------------------------------- */ 697/* ----------------------------------------------------------------------- */
698 698
699struct i2c_driver i2c_driver_saa7127; 699static struct i2c_driver i2c_driver_saa7127;
700 700
701/* ----------------------------------------------------------------------- */ 701/* ----------------------------------------------------------------------- */
702 702
@@ -818,7 +818,7 @@ static int saa7127_detach(struct i2c_client *client)
818 818
819/* ----------------------------------------------------------------------- */ 819/* ----------------------------------------------------------------------- */
820 820
821struct i2c_driver i2c_driver_saa7127 = { 821static struct i2c_driver i2c_driver_saa7127 = {
822 .name = "saa7127", 822 .name = "saa7127",
823 .id = I2C_DRIVERID_SAA7127, 823 .id = I2C_DRIVERID_SAA7127,
824 .flags = I2C_DF_NOTIFY, 824 .flags = I2C_DF_NOTIFY,
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 5707c666660b..263c6e2e3e8e 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -58,8 +58,6 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
58module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); 59MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
60 60
61int position;
62
63#define dprintk(fmt, arg...) if (debug) \ 61#define dprintk(fmt, arg...) if (debug) \
64 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) 62 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
65 63
@@ -140,7 +138,8 @@ static void saa7134_dma_start(struct saa7134_dev *dev)
140 * 138 *
141 */ 139 */
142 140
143void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) 141static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
142 unsigned long status)
144{ 143{
145 int next_blk, reg = 0; 144 int next_blk, reg = 0;
146 145
@@ -881,7 +880,7 @@ static void snd_saa7134_free(snd_card_t * card)
881 * 880 *
882 */ 881 */
883 882
884int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) 883static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
885{ 884{
886 885
887 snd_card_t *card; 886 snd_card_t *card;
@@ -945,6 +944,8 @@ int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
945 sprintf(card->longname, "%s at 0x%lx irq %d", 944 sprintf(card->longname, "%s at 0x%lx irq %d",
946 chip->dev->name, chip->iobase, chip->irq); 945 chip->dev->name, chip->iobase, chip->irq);
947 946
947 printk(KERN_INFO "%s/alsa: %s registered as card %d\n",dev->name,card->longname,index[devnum]);
948
948 if ((err = snd_card_register(card)) == 0) { 949 if ((err = snd_card_register(card)) == 0) {
949 snd_saa7134_cards[devnum] = card; 950 snd_saa7134_cards[devnum] = card;
950 return 0; 951 return 0;
@@ -955,6 +956,22 @@ __nodev:
955 return err; 956 return err;
956} 957}
957 958
959
960static int alsa_device_init(struct saa7134_dev *dev)
961{
962 dev->dmasound.priv_data = dev;
963 alsa_card_saa7134_create(dev,dev->nr);
964 return 1;
965}
966
967static int alsa_device_exit(struct saa7134_dev *dev)
968{
969
970 snd_card_free(snd_saa7134_cards[dev->nr]);
971 snd_saa7134_cards[dev->nr] = NULL;
972 return 1;
973}
974
958/* 975/*
959 * Module initializer 976 * Module initializer
960 * 977 *
@@ -968,22 +985,21 @@ static int saa7134_alsa_init(void)
968 struct saa7134_dev *dev = NULL; 985 struct saa7134_dev *dev = NULL;
969 struct list_head *list; 986 struct list_head *list;
970 987
971 position = 0;
972
973 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); 988 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
974 989
975 list_for_each(list,&saa7134_devlist) { 990 list_for_each(list,&saa7134_devlist) {
976 dev = list_entry(list, struct saa7134_dev, devlist); 991 dev = list_entry(list, struct saa7134_dev, devlist);
977 if (dev->dmasound.priv_data == NULL) { 992 if (dev->dmasound.priv_data == NULL) {
978 dev->dmasound.priv_data = dev; 993 alsa_device_init(dev);
979 alsa_card_saa7134_create(dev,position);
980 position++;
981 } else { 994 } else {
982 printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name); 995 printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
983 return -EBUSY; 996 return -EBUSY;
984 } 997 }
985 } 998 }
986 999
1000 dmasound_init = alsa_device_init;
1001 dmasound_exit = alsa_device_exit;
1002
987 if (dev == NULL) 1003 if (dev == NULL)
988 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); 1004 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
989 1005
@@ -994,7 +1010,7 @@ static int saa7134_alsa_init(void)
994 * Module destructor 1010 * Module destructor
995 */ 1011 */
996 1012
997void saa7134_alsa_exit(void) 1013static void saa7134_alsa_exit(void)
998{ 1014{
999 int idx; 1015 int idx;
1000 1016
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 4275d2ddb864..1a093bf176f3 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -88,6 +88,9 @@ LIST_HEAD(saa7134_devlist);
88static LIST_HEAD(mops_list); 88static LIST_HEAD(mops_list);
89static unsigned int saa7134_devcount; 89static unsigned int saa7134_devcount;
90 90
91int (*dmasound_init)(struct saa7134_dev *dev);
92int (*dmasound_exit)(struct saa7134_dev *dev);
93
91#define dprintk(fmt, arg...) if (core_debug) \ 94#define dprintk(fmt, arg...) if (core_debug) \
92 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg) 95 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
93 96
@@ -184,8 +187,7 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
184/* ----------------------------------------------------------- */ 187/* ----------------------------------------------------------- */
185/* delayed request_module */ 188/* delayed request_module */
186 189
187#ifdef CONFIG_MODULES 190#if defined(CONFIG_MODULES) && defined(MODULE)
188
189static int need_empress; 191static int need_empress;
190static int need_dvb; 192static int need_dvb;
191static int need_alsa; 193static int need_alsa;
@@ -234,9 +236,7 @@ static void request_module_depend(char *name, int *flag)
234} 236}
235 237
236#else 238#else
237
238#define request_module_depend(name,flag) 239#define request_module_depend(name,flag)
239
240#endif /* CONFIG_MODULES */ 240#endif /* CONFIG_MODULES */
241 241
242/* ------------------------------------------------------------------ */ 242/* ------------------------------------------------------------------ */
@@ -1017,6 +1017,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1017 /* check for signal */ 1017 /* check for signal */
1018 saa7134_irq_video_intl(dev); 1018 saa7134_irq_video_intl(dev);
1019 1019
1020 if (dmasound_init && !dev->dmasound.priv_data) {
1021 dmasound_init(dev);
1022 }
1023
1020 return 0; 1024 return 0;
1021 1025
1022 fail4: 1026 fail4:
@@ -1040,6 +1044,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1040 struct list_head *item; 1044 struct list_head *item;
1041 struct saa7134_mpeg_ops *mops; 1045 struct saa7134_mpeg_ops *mops;
1042 1046
1047 /* Release DMA sound modules if present */
1048 if (dmasound_exit && dev->dmasound.priv_data) {
1049 dmasound_exit(dev);
1050 }
1051
1043 /* debugging ... */ 1052 /* debugging ... */
1044 if (irq_debug) { 1053 if (irq_debug) {
1045 u32 report = saa_readl(SAA7134_IRQ_REPORT); 1054 u32 report = saa_readl(SAA7134_IRQ_REPORT);
@@ -1071,6 +1080,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1071 saa7134_i2c_unregister(dev); 1080 saa7134_i2c_unregister(dev);
1072 saa7134_unregister_video(dev); 1081 saa7134_unregister_video(dev);
1073 1082
1083
1074 /* the DMA sound modules should be unloaded before reaching 1084 /* the DMA sound modules should be unloaded before reaching
1075 this, but just in case they are still present... */ 1085 this, but just in case they are still present... */
1076 if (dev->dmasound.priv_data != NULL) { 1086 if (dev->dmasound.priv_data != NULL) {
@@ -1078,6 +1088,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1078 dev->dmasound.priv_data = NULL; 1088 dev->dmasound.priv_data = NULL;
1079 } 1089 }
1080 1090
1091
1081 /* release resources */ 1092 /* release resources */
1082 free_irq(pci_dev->irq, dev); 1093 free_irq(pci_dev->irq, dev);
1083 iounmap(dev->lmmio); 1094 iounmap(dev->lmmio);
@@ -1149,10 +1160,10 @@ static int saa7134_init(void)
1149 1160
1150static void saa7134_fini(void) 1161static void saa7134_fini(void)
1151{ 1162{
1152#ifdef CONFIG_MODULES 1163#if defined(CONFIG_MODULES) && defined(MODULE)
1153 if (pending_registered) 1164 if (pending_registered)
1154 unregister_module_notifier(&pending_notifier); 1165 unregister_module_notifier(&pending_notifier);
1155#endif 1166#endif /* CONFIG_MODULES */
1156 pci_unregister_driver(&saa7134_pci_driver); 1167 pci_unregister_driver(&saa7134_pci_driver);
1157} 1168}
1158 1169
@@ -1168,6 +1179,8 @@ EXPORT_SYMBOL(saa7134_boards);
1168 1179
1169/* ----------------- for the DMA sound modules --------------- */ 1180/* ----------------- for the DMA sound modules --------------- */
1170 1181
1182EXPORT_SYMBOL(dmasound_init);
1183EXPORT_SYMBOL(dmasound_exit);
1171EXPORT_SYMBOL(saa7134_pgtable_free); 1184EXPORT_SYMBOL(saa7134_pgtable_free);
1172EXPORT_SYMBOL(saa7134_pgtable_build); 1185EXPORT_SYMBOL(saa7134_pgtable_build);
1173EXPORT_SYMBOL(saa7134_pgtable_alloc); 1186EXPORT_SYMBOL(saa7134_pgtable_alloc);
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index fd9ed11ab1e2..5a579194e455 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -899,26 +899,26 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
899 spin_unlock(&dev->slock); 899 spin_unlock(&dev->slock);
900} 900}
901 901
902int saa7134_dsp_create(struct saa7134_dev *dev) 902static int saa7134_dsp_create(struct saa7134_dev *dev)
903{ 903{
904 int err; 904 int err;
905 905
906 err = dev->dmasound.minor_dsp = 906 err = dev->dmasound.minor_dsp =
907 register_sound_dsp(&saa7134_dsp_fops, 907 register_sound_dsp(&saa7134_dsp_fops,
908 dsp_nr[dev->nr]); 908 dsp_nr[dev->nr]);
909 if (err < 0) { 909 if (err < 0) {
910 goto fail; 910 goto fail;
911 } 911 }
912 printk(KERN_INFO "%s: registered device dsp%d\n", 912 printk(KERN_INFO "%s: registered device dsp%d\n",
913 dev->name,dev->dmasound.minor_dsp >> 4); 913 dev->name,dev->dmasound.minor_dsp >> 4);
914 914
915 err = dev->dmasound.minor_mixer = 915 err = dev->dmasound.minor_mixer =
916 register_sound_mixer(&saa7134_mixer_fops, 916 register_sound_mixer(&saa7134_mixer_fops,
917 mixer_nr[dev->nr]); 917 mixer_nr[dev->nr]);
918 if (err < 0) 918 if (err < 0)
919 goto fail; 919 goto fail;
920 printk(KERN_INFO "%s: registered device mixer%d\n", 920 printk(KERN_INFO "%s: registered device mixer%d\n",
921 dev->name,dev->dmasound.minor_mixer >> 4); 921 dev->name,dev->dmasound.minor_mixer >> 4);
922 922
923 return 0; 923 return 0;
924 924
@@ -929,6 +929,31 @@ fail:
929 929
930} 930}
931 931
932static int oss_device_init(struct saa7134_dev *dev)
933{
934 dev->dmasound.priv_data = dev;
935 saa7134_oss_init1(dev);
936 saa7134_dsp_create(dev);
937 return 1;
938}
939
940static int oss_device_exit(struct saa7134_dev *dev)
941{
942
943 unregister_sound_mixer(dev->dmasound.minor_mixer);
944 unregister_sound_dsp(dev->dmasound.minor_dsp);
945
946 saa7134_oss_fini(dev);
947
948 if (dev->pci->irq > 0) {
949 synchronize_irq(dev->pci->irq);
950 free_irq(dev->pci->irq,&dev->dmasound);
951 }
952
953 dev->dmasound.priv_data = NULL;
954 return 1;
955}
956
932static int saa7134_oss_init(void) 957static int saa7134_oss_init(void)
933{ 958{
934 struct saa7134_dev *dev = NULL; 959 struct saa7134_dev *dev = NULL;
@@ -939,9 +964,7 @@ static int saa7134_oss_init(void)
939 list_for_each(list,&saa7134_devlist) { 964 list_for_each(list,&saa7134_devlist) {
940 dev = list_entry(list, struct saa7134_dev, devlist); 965 dev = list_entry(list, struct saa7134_dev, devlist);
941 if (dev->dmasound.priv_data == NULL) { 966 if (dev->dmasound.priv_data == NULL) {
942 dev->dmasound.priv_data = dev; 967 oss_device_init(dev);
943 saa7134_oss_init1(dev);
944 saa7134_dsp_create(dev);
945 } else { 968 } else {
946 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name); 969 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
947 return -EBUSY; 970 return -EBUSY;
@@ -951,11 +974,14 @@ static int saa7134_oss_init(void)
951 if (dev == NULL) 974 if (dev == NULL)
952 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n"); 975 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
953 976
977 dmasound_init = oss_device_init;
978 dmasound_exit = oss_device_exit;
979
954 return 0; 980 return 0;
955 981
956} 982}
957 983
958void saa7134_oss_exit(void) 984static void saa7134_oss_exit(void)
959{ 985{
960 struct saa7134_dev *dev = NULL; 986 struct saa7134_dev *dev = NULL;
961 struct list_head *list; 987 struct list_head *list;
@@ -967,18 +993,7 @@ void saa7134_oss_exit(void)
967 if (!dev->dmasound.minor_dsp) 993 if (!dev->dmasound.minor_dsp)
968 continue; 994 continue;
969 995
970 unregister_sound_mixer(dev->dmasound.minor_mixer); 996 oss_device_exit(dev);
971 unregister_sound_dsp(dev->dmasound.minor_dsp);
972
973 saa7134_oss_fini(dev);
974
975 if (dev->pci->irq > 0) {
976 synchronize_irq(dev->pci->irq);
977 free_irq(dev->pci->irq,&dev->dmasound);
978 }
979
980 dev->dmasound.priv_data = NULL;
981
982 } 997 }
983 998
984 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n"); 999 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 244e1973081c..add49db1ad41 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -571,6 +571,10 @@ void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
571 571
572int saa7134_set_dmabits(struct saa7134_dev *dev); 572int saa7134_set_dmabits(struct saa7134_dev *dev);
573 573
574extern int (*dmasound_init)(struct saa7134_dev *dev);
575extern int (*dmasound_exit)(struct saa7134_dev *dev);
576
577
574/* ----------------------------------------------------------- */ 578/* ----------------------------------------------------------- */
575/* saa7134-cards.c */ 579/* saa7134-cards.c */
576 580
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 72e8741e8b59..d95aecebbda3 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -81,7 +81,7 @@ hauppauge_tuner_fmt[] =
81 { 0x00000010, " PAL(I)" }, 81 { 0x00000010, " PAL(I)" },
82 { 0x00400000, " SECAM(L/L')" }, 82 { 0x00400000, " SECAM(L/L')" },
83 { 0x00000e00, " PAL(D/K)" }, 83 { 0x00000e00, " PAL(D/K)" },
84 { 0x03000000, " ATSC Digital" }, 84 { 0x03000000, " ATSC/DVB Digital" },
85}; 85};
86 86
87/* This is the full list of possible tuners. Many thanks to Hauppauge for 87/* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -209,13 +209,27 @@ hauppauge_tuner[] =
209 { TUNER_ABSENT, "Philips FMD1216ME"}, 209 { TUNER_ABSENT, "Philips FMD1216ME"},
210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"}, 210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"},
211 { TUNER_ABSENT, "Panasonic ENV57H12D5"}, 211 { TUNER_ABSENT, "Panasonic ENV57H12D5"},
212 { TUNER_ABSENT, "TCL MFNM05-4"}, 212 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"},
213 { TUNER_ABSENT, "TCL MNM05-4"}, 213 { TUNER_ABSENT, "TCL MNM05-4"},
214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"}, 214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"},
215 { TUNER_ABSENT, "TCL MQNM05-4"}, 215 { TUNER_ABSENT, "TCL MQNM05-4"},
216 { TUNER_ABSENT, "LG TAPC-W701D"}, 216 { TUNER_ABSENT, "LG TAPC-W701D"},
217 { TUNER_ABSENT, "TCL 9886P-WM"}, 217 { TUNER_ABSENT, "TCL 9886P-WM"},
218 { TUNER_ABSENT, "TCL 1676NM-WM"}, 218 { TUNER_ABSENT, "TCL 1676NM-WM"},
219 /* 110-119 */
220 { TUNER_ABSENT, "Thompson DTT75105"},
221 { TUNER_ABSENT, "Conexant_CX24109"},
222 { TUNER_ABSENT, "TCL M2523_5N_E"},
223 { TUNER_ABSENT, "TCL M2523_3DB_E"},
224 { TUNER_ABSENT, "Philips 8275A"},
225 { TUNER_ABSENT, "Microtune MT2060"},
226 { TUNER_ABSENT, "Philips FM1236 MK5"},
227 { TUNER_ABSENT, "Philips FM1216ME MK5"},
228 { TUNER_ABSENT, "TCL M2523_3DI_E"},
229 { TUNER_ABSENT, "Samsung THPD5222FG30A"},
230 /* 120-129 */
231 { TUNER_ABSENT, "Xceive XC3028"},
232 { TUNER_ABSENT, "Philips FQ1216LME MK5"},
219}; 233};
220 234
221static struct HAUPPAUGE_AUDIOIC 235static struct HAUPPAUGE_AUDIOIC
@@ -325,6 +339,7 @@ static int hasRadioTuner(int tunerType)
325 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
326 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
327 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4:
342 case 105:
328 return 1; 343 return 1;
329 } 344 }
330 return 0; 345 return 0;
@@ -368,10 +383,15 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
368 memset(tvee, 0, sizeof(*tvee)); 383 memset(tvee, 0, sizeof(*tvee));
369 done = len = beenhere = 0; 384 done = len = beenhere = 0;
370 385
371 /* Hack for processing eeprom for em28xx */ 386 /* Hack for processing eeprom for em28xx and cx 2388x*/
372 if ((eeprom_data[0]==0x1a)&&(eeprom_data[1]==0xeb)&& 387 if ((eeprom_data[0] == 0x1a) && (eeprom_data[1] == 0xeb) &&
373 (eeprom_data[2]==0x67)&&(eeprom_data[3]==0x95)) 388 (eeprom_data[2] == 0x67) && (eeprom_data[3] == 0x95))
374 start=0xa0; 389 start=0xa0; /* Generic em28xx offset */
390 else if (((eeprom_data[0] & 0xf0) == 0x10) &&
391 (eeprom_data[1] == 0x00) &&
392 (eeprom_data[2] == 0x00) &&
393 (eeprom_data[8] == 0x84))
394 start=8; /* Generic cx2388x offset */
375 else 395 else
376 start=0; 396 start=0;
377 397
@@ -448,6 +468,17 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
448 eeprom_data[i+5] + 468 eeprom_data[i+5] +
449 (eeprom_data[i+6] << 8) + 469 (eeprom_data[i+6] << 8) +
450 (eeprom_data[i+7] << 16); 470 (eeprom_data[i+7] << 16);
471
472 if ( (eeprom_data[i + 8] && 0xf0) &&
473 (tvee->serial_number < 0xffffff) ) {
474 tvee->MAC_address[0] = 0x00;
475 tvee->MAC_address[1] = 0x0D;
476 tvee->MAC_address[2] = 0xFE;
477 tvee->MAC_address[3] = eeprom_data[i + 7];
478 tvee->MAC_address[4] = eeprom_data[i + 6];
479 tvee->MAC_address[5] = eeprom_data[i + 5];
480 tvee->has_MAC_address = 1;
481 }
451 break; 482 break;
452 483
453 case 0x05: 484 case 0x05:
@@ -466,11 +497,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
466 case 0x06: 497 case 0x06:
467 /* tag 'ModelRev' */ 498 /* tag 'ModelRev' */
468 tvee->model = 499 tvee->model =
469 eeprom_data[i+1] + 500 eeprom_data[i + 1] +
470 (eeprom_data[i+2] << 8); 501 (eeprom_data[i + 2] << 8) +
471 tvee->revision = eeprom_data[i+5] + 502 (eeprom_data[i + 3] << 16) +
472 (eeprom_data[i+6] << 8) + 503 (eeprom_data[i + 4] << 24);
473 (eeprom_data[i+7] << 16); 504 tvee->revision =
505 eeprom_data[i +5 ] +
506 (eeprom_data[i + 6] << 8) +
507 (eeprom_data[i + 7] << 16);
474 break; 508 break;
475 509
476 case 0x07: 510 case 0x07:
@@ -563,6 +597,8 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
563 t_name2 = "unknown"; 597 t_name2 = "unknown";
564 } 598 }
565 599
600 tvee->tuner_hauppauge_model = tuner1;
601 tvee->tuner2_hauppauge_model = tuner2;
566 tvee->tuner_formats = 0; 602 tvee->tuner_formats = 0;
567 tvee->tuner2_formats = 0; 603 tvee->tuner2_formats = 0;
568 for (i = j = 0; i < 8; i++) { 604 for (i = j = 0; i < 8; i++) {
@@ -578,6 +614,12 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
578 614
579 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", 615 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n",
580 tvee->model, tvee->rev_str, tvee->serial_number); 616 tvee->model, tvee->rev_str, tvee->serial_number);
617 if (tvee->has_MAC_address == 1) {
618 tveeprom_info("MAC address is %02X-%02X-%02X-%02X-%02X-%02X\n",
619 tvee->MAC_address[0], tvee->MAC_address[1],
620 tvee->MAC_address[2], tvee->MAC_address[3],
621 tvee->MAC_address[4], tvee->MAC_address[5]);
622 }
581 tveeprom_info("tuner model is %s (idx %d, type %d)\n", 623 tveeprom_info("tuner model is %s (idx %d, type %d)\n",
582 t_name1, tuner1, tvee->tuner_type); 624 t_name1, tuner1, tvee->tuner_type);
583 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 625 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index acfd3a103f35..9a6bf287e26a 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -753,10 +753,9 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
753 int retval; 753 int retval;
754 754
755 /* setup stuff */ 755 /* setup stuff */
756 retval = -ENOMEM;
757 q->read_buf = videobuf_alloc(q->msize); 756 q->read_buf = videobuf_alloc(q->msize);
758 if (NULL == q->read_buf) 757 if (NULL == q->read_buf)
759 goto done; 758 return -ENOMEM;
760 759
761 q->read_buf->memory = V4L2_MEMORY_USERPTR; 760 q->read_buf->memory = V4L2_MEMORY_USERPTR;
762 q->read_buf->baddr = (unsigned long)data; 761 q->read_buf->baddr = (unsigned long)data;
@@ -817,10 +816,14 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
817 if (NULL == q->read_buf) 816 if (NULL == q->read_buf)
818 goto done; 817 goto done;
819 q->read_buf->memory = V4L2_MEMORY_USERPTR; 818 q->read_buf->memory = V4L2_MEMORY_USERPTR;
819 q->read_buf->bsize = count; /* preferred size */
820 field = videobuf_next_field(q); 820 field = videobuf_next_field(q);
821 retval = q->ops->buf_prepare(q,q->read_buf,field); 821 retval = q->ops->buf_prepare(q,q->read_buf,field);
822 if (0 != retval) 822 if (0 != retval) {
823 kfree (q->read_buf);
824 q->read_buf = NULL;
823 goto done; 825 goto done;
826 }
824 spin_lock_irqsave(q->irqlock,flags); 827 spin_lock_irqsave(q->irqlock,flags);
825 q->ops->buf_queue(q,q->read_buf); 828 q->ops->buf_queue(q,q->read_buf);
826 spin_unlock_irqrestore(q->irqlock,flags); 829 spin_unlock_irqrestore(q->irqlock,flags);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 83c49f9610d0..6de5b0094b82 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -76,14 +76,14 @@ static void video_release(struct class_device *cd)
76} 76}
77 77
78static struct class video_class = { 78static struct class video_class = {
79 .name = VIDEO_NAME, 79 .name = VIDEO_NAME,
80 .release = video_release, 80 .release = video_release,
81}; 81};
82 82
83/* 83/*
84 * Active devices 84 * Active devices
85 */ 85 */
86 86
87static struct video_device *video_device[VIDEO_NUM_DEVICES]; 87static struct video_device *video_device[VIDEO_NUM_DEVICES];
88static DECLARE_MUTEX(videodev_lock); 88static DECLARE_MUTEX(videodev_lock);
89 89
@@ -101,7 +101,7 @@ static int video_open(struct inode *inode, struct file *file)
101 int err = 0; 101 int err = 0;
102 struct video_device *vfl; 102 struct video_device *vfl;
103 struct file_operations *old_fops; 103 struct file_operations *old_fops;
104 104
105 if(minor>=VIDEO_NUM_DEVICES) 105 if(minor>=VIDEO_NUM_DEVICES)
106 return -ENODEV; 106 return -ENODEV;
107 down(&videodev_lock); 107 down(&videodev_lock);
@@ -189,7 +189,7 @@ video_usercopy(struct inode *inode, struct file *file,
189 return -ENOMEM; 189 return -ENOMEM;
190 parg = mbuf; 190 parg = mbuf;
191 } 191 }
192 192
193 err = -EFAULT; 193 err = -EFAULT;
194 if (_IOC_DIR(cmd) & _IOC_WRITE) 194 if (_IOC_DIR(cmd) & _IOC_WRITE)
195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
@@ -240,7 +240,7 @@ int video_exclusive_open(struct inode *inode, struct file *file)
240int video_exclusive_release(struct inode *inode, struct file *file) 240int video_exclusive_release(struct inode *inode, struct file *file)
241{ 241{
242 struct video_device *vfl = video_devdata(file); 242 struct video_device *vfl = video_devdata(file);
243 243
244 vfl->users--; 244 vfl->users--;
245 return 0; 245 return 0;
246} 246}
@@ -253,7 +253,7 @@ static struct file_operations video_fops;
253 * @type: type of device to register 253 * @type: type of device to register
254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... 254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
255 * -1 == first free) 255 * -1 == first free)
256 * 256 *
257 * The registration code assigns minor numbers based on the type 257 * The registration code assigns minor numbers based on the type
258 * requested. -ENFILE is returned in all the device slots for this 258 * requested. -ENFILE is returned in all the device slots for this
259 * category are full. If not then the minor field is set and the 259 * category are full. If not then the minor field is set and the
@@ -269,7 +269,7 @@ static struct file_operations video_fops;
269 * 269 *
270 * %VFL_TYPE_VBI - Vertical blank data (undecoded) 270 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
271 * 271 *
272 * %VFL_TYPE_RADIO - A radio card 272 * %VFL_TYPE_RADIO - A radio card
273 */ 273 */
274 274
275int video_register_device(struct video_device *vfd, int type, int nr) 275int video_register_device(struct video_device *vfd, int type, int nr)
@@ -278,7 +278,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
278 int base; 278 int base;
279 int end; 279 int end;
280 char *name_base; 280 char *name_base;
281 281
282 switch(type) 282 switch(type)
283 { 283 {
284 case VFL_TYPE_GRABBER: 284 case VFL_TYPE_GRABBER:
@@ -293,7 +293,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
293 break; 293 break;
294 case VFL_TYPE_VBI: 294 case VFL_TYPE_VBI:
295 base=224; 295 base=224;
296 end=240; 296 end=256;
297 name_base = "vbi"; 297 name_base = "vbi";
298 break; 298 break;
299 case VFL_TYPE_RADIO: 299 case VFL_TYPE_RADIO:
@@ -334,7 +334,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
334 init_MUTEX(&vfd->lock); 334 init_MUTEX(&vfd->lock);
335 335
336 /* sysfs class */ 336 /* sysfs class */
337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); 337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
338 if (vfd->dev) 338 if (vfd->dev)
339 vfd->class_dev.dev = vfd->dev; 339 vfd->class_dev.dev = vfd->dev;
340 vfd->class_dev.class = &video_class; 340 vfd->class_dev.class = &video_class;
@@ -360,7 +360,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
360 * This unregisters the passed device and deassigns the minor 360 * This unregisters the passed device and deassigns the minor
361 * number. Future open calls will be met with errors. 361 * number. Future open calls will be met with errors.
362 */ 362 */
363 363
364void video_unregister_device(struct video_device *vfd) 364void video_unregister_device(struct video_device *vfd)
365{ 365{
366 down(&videodev_lock); 366 down(&videodev_lock);
@@ -384,7 +384,7 @@ static struct file_operations video_fops=
384/* 384/*
385 * Initialise video for linux 385 * Initialise video for linux
386 */ 386 */
387 387
388static int __init videodev_init(void) 388static int __init videodev_init(void)
389{ 389{
390 int ret; 390 int ret;