diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-11 04:46:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-11 04:46:50 -0400 |
commit | 0c81b2a1448bc6a2a9b2d6469fb0669fb4b25e5b (patch) | |
tree | 6f82579cae6d6e39fa9f837a3c349ded51e19d14 /drivers | |
parent | 0729fbf3bc70870370b4f43d652f05a468dc68b8 (diff) | |
parent | 70ff05554f91a1edda1f11684da1dbde09e2feea (diff) |
Merge branch 'linus' into core/rcu
Conflicts:
include/linux/rculist.h
kernel/rcupreempt.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers')
187 files changed, 8625 insertions, 937 deletions
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c index 26038c2a2a71..61b6c5beb2d3 100644 --- a/drivers/acpi/bay.c +++ b/drivers/acpi/bay.c | |||
@@ -377,6 +377,9 @@ static int __init bay_init(void) | |||
377 | 377 | ||
378 | INIT_LIST_HEAD(&drive_bays); | 378 | INIT_LIST_HEAD(&drive_bays); |
379 | 379 | ||
380 | if (acpi_disabled) | ||
381 | return -ENODEV; | ||
382 | |||
380 | /* look for dockable drive bays */ | 383 | /* look for dockable drive bays */ |
381 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 384 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
382 | ACPI_UINT32_MAX, find_bay, &bays, NULL); | 385 | ACPI_UINT32_MAX, find_bay, &bays, NULL); |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 96c542f7fded..bb7c51f712bd 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -917,6 +917,9 @@ static int __init dock_init(void) | |||
917 | 917 | ||
918 | dock_station = NULL; | 918 | dock_station = NULL; |
919 | 919 | ||
920 | if (acpi_disabled) | ||
921 | return 0; | ||
922 | |||
920 | /* look for a dock station */ | 923 | /* look for a dock station */ |
921 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 924 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
922 | ACPI_UINT32_MAX, find_dock, &num, NULL); | 925 | ACPI_UINT32_MAX, find_dock, &num, NULL); |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 2808dc60fd67..9b227d4dc9c9 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -333,6 +333,9 @@ static int __init acpi_rtc_init(void) | |||
333 | { | 333 | { |
334 | struct device *dev = get_rtc_dev(); | 334 | struct device *dev = get_rtc_dev(); |
335 | 335 | ||
336 | if (acpi_disabled) | ||
337 | return 0; | ||
338 | |||
336 | if (dev) { | 339 | if (dev) { |
337 | rtc_wake_setup(); | 340 | rtc_wake_setup(); |
338 | rtc_info.wake_on = rtc_wake_on; | 341 | rtc_info.wake_on = rtc_wake_on; |
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index c3b0cd88d09f..495c63a3e0af 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -36,9 +36,8 @@ static int acpi_sleep_prepare(u32 acpi_state) | |||
36 | if (!acpi_wakeup_address) { | 36 | if (!acpi_wakeup_address) { |
37 | return -EFAULT; | 37 | return -EFAULT; |
38 | } | 38 | } |
39 | acpi_set_firmware_waking_vector((acpi_physical_address) | 39 | acpi_set_firmware_waking_vector( |
40 | virt_to_phys((void *) | 40 | (acpi_physical_address)acpi_wakeup_address); |
41 | acpi_wakeup_address)); | ||
42 | 41 | ||
43 | } | 42 | } |
44 | ACPI_FLUSH_CPU_CACHE(); | 43 | ACPI_FLUSH_CPU_CACHE(); |
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index 224c57c03381..4ebbba2b6b19 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -315,8 +315,11 @@ acpi_system_write_alarm(struct file *file, | |||
315 | cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control); | 315 | cmos_bcd_write(day, acpi_gbl_FADT.day_alarm, rtc_control); |
316 | if (acpi_gbl_FADT.month_alarm) | 316 | if (acpi_gbl_FADT.month_alarm) |
317 | cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control); | 317 | cmos_bcd_write(mo, acpi_gbl_FADT.month_alarm, rtc_control); |
318 | if (acpi_gbl_FADT.century) | 318 | if (acpi_gbl_FADT.century) { |
319 | if (adjust) | ||
320 | yr += cmos_bcd_read(acpi_gbl_FADT.century, rtc_control) * 100; | ||
319 | cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control); | 321 | cmos_bcd_write(yr / 100, acpi_gbl_FADT.century, rtc_control); |
322 | } | ||
320 | /* enable the rtc alarm interrupt */ | 323 | /* enable the rtc alarm interrupt */ |
321 | rtc_control |= RTC_AIE; | 324 | rtc_control |= RTC_AIE; |
322 | CMOS_WRITE(rtc_control, RTC_CONTROL); | 325 | CMOS_WRITE(rtc_control, RTC_CONTROL); |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6a4a2a25d97a..5e6468a7ca4b 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -1777,7 +1777,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance) | |||
1777 | struct ahci_host_priv *hpriv; | 1777 | struct ahci_host_priv *hpriv; |
1778 | unsigned int i, handled = 0; | 1778 | unsigned int i, handled = 0; |
1779 | void __iomem *mmio; | 1779 | void __iomem *mmio; |
1780 | u32 irq_stat, irq_ack = 0; | 1780 | u32 irq_stat, irq_masked; |
1781 | 1781 | ||
1782 | VPRINTK("ENTER\n"); | 1782 | VPRINTK("ENTER\n"); |
1783 | 1783 | ||
@@ -1786,16 +1786,17 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance) | |||
1786 | 1786 | ||
1787 | /* sigh. 0xffffffff is a valid return from h/w */ | 1787 | /* sigh. 0xffffffff is a valid return from h/w */ |
1788 | irq_stat = readl(mmio + HOST_IRQ_STAT); | 1788 | irq_stat = readl(mmio + HOST_IRQ_STAT); |
1789 | irq_stat &= hpriv->port_map; | ||
1790 | if (!irq_stat) | 1789 | if (!irq_stat) |
1791 | return IRQ_NONE; | 1790 | return IRQ_NONE; |
1792 | 1791 | ||
1792 | irq_masked = irq_stat & hpriv->port_map; | ||
1793 | |||
1793 | spin_lock(&host->lock); | 1794 | spin_lock(&host->lock); |
1794 | 1795 | ||
1795 | for (i = 0; i < host->n_ports; i++) { | 1796 | for (i = 0; i < host->n_ports; i++) { |
1796 | struct ata_port *ap; | 1797 | struct ata_port *ap; |
1797 | 1798 | ||
1798 | if (!(irq_stat & (1 << i))) | 1799 | if (!(irq_masked & (1 << i))) |
1799 | continue; | 1800 | continue; |
1800 | 1801 | ||
1801 | ap = host->ports[i]; | 1802 | ap = host->ports[i]; |
@@ -1809,14 +1810,20 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance) | |||
1809 | "interrupt on disabled port %u\n", i); | 1810 | "interrupt on disabled port %u\n", i); |
1810 | } | 1811 | } |
1811 | 1812 | ||
1812 | irq_ack |= (1 << i); | ||
1813 | } | ||
1814 | |||
1815 | if (irq_ack) { | ||
1816 | writel(irq_ack, mmio + HOST_IRQ_STAT); | ||
1817 | handled = 1; | 1813 | handled = 1; |
1818 | } | 1814 | } |
1819 | 1815 | ||
1816 | /* HOST_IRQ_STAT behaves as level triggered latch meaning that | ||
1817 | * it should be cleared after all the port events are cleared; | ||
1818 | * otherwise, it will raise a spurious interrupt after each | ||
1819 | * valid one. Please read section 10.6.2 of ahci 1.1 for more | ||
1820 | * information. | ||
1821 | * | ||
1822 | * Also, use the unmasked value to clear interrupt as spurious | ||
1823 | * pending event on a dummy port might cause screaming IRQ. | ||
1824 | */ | ||
1825 | writel(irq_stat, mmio + HOST_IRQ_STAT); | ||
1826 | |||
1820 | spin_unlock(&host->lock); | 1827 | spin_unlock(&host->lock); |
1821 | 1828 | ||
1822 | VPRINTK("EXIT\n"); | 1829 | VPRINTK("EXIT\n"); |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 215d18672a5a..c0908c225483 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1094,6 +1094,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) | |||
1094 | int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | 1094 | int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, |
1095 | u8 status, int in_wq) | 1095 | u8 status, int in_wq) |
1096 | { | 1096 | { |
1097 | struct ata_eh_info *ehi = &ap->link.eh_info; | ||
1097 | unsigned long flags = 0; | 1098 | unsigned long flags = 0; |
1098 | int poll_next; | 1099 | int poll_next; |
1099 | 1100 | ||
@@ -1125,9 +1126,12 @@ fsm_start: | |||
1125 | if (likely(status & (ATA_ERR | ATA_DF))) | 1126 | if (likely(status & (ATA_ERR | ATA_DF))) |
1126 | /* device stops HSM for abort/error */ | 1127 | /* device stops HSM for abort/error */ |
1127 | qc->err_mask |= AC_ERR_DEV; | 1128 | qc->err_mask |= AC_ERR_DEV; |
1128 | else | 1129 | else { |
1129 | /* HSM violation. Let EH handle this */ | 1130 | /* HSM violation. Let EH handle this */ |
1131 | ata_ehi_push_desc(ehi, | ||
1132 | "ST_FIRST: !(DRQ|ERR|DF)"); | ||
1130 | qc->err_mask |= AC_ERR_HSM; | 1133 | qc->err_mask |= AC_ERR_HSM; |
1134 | } | ||
1131 | 1135 | ||
1132 | ap->hsm_task_state = HSM_ST_ERR; | 1136 | ap->hsm_task_state = HSM_ST_ERR; |
1133 | goto fsm_start; | 1137 | goto fsm_start; |
@@ -1146,9 +1150,9 @@ fsm_start: | |||
1146 | * the CDB. | 1150 | * the CDB. |
1147 | */ | 1151 | */ |
1148 | if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { | 1152 | if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { |
1149 | ata_port_printk(ap, KERN_WARNING, | 1153 | ata_ehi_push_desc(ehi, "ST_FIRST: " |
1150 | "DRQ=1 with device error, " | 1154 | "DRQ=1 with device error, " |
1151 | "dev_stat 0x%X\n", status); | 1155 | "dev_stat 0x%X", status); |
1152 | qc->err_mask |= AC_ERR_HSM; | 1156 | qc->err_mask |= AC_ERR_HSM; |
1153 | ap->hsm_task_state = HSM_ST_ERR; | 1157 | ap->hsm_task_state = HSM_ST_ERR; |
1154 | goto fsm_start; | 1158 | goto fsm_start; |
@@ -1205,9 +1209,9 @@ fsm_start: | |||
1205 | * let the EH abort the command or reset the device. | 1209 | * let the EH abort the command or reset the device. |
1206 | */ | 1210 | */ |
1207 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | 1211 | if (unlikely(status & (ATA_ERR | ATA_DF))) { |
1208 | ata_port_printk(ap, KERN_WARNING, "DRQ=1 with " | 1212 | ata_ehi_push_desc(ehi, "ST-ATAPI: " |
1209 | "device error, dev_stat 0x%X\n", | 1213 | "DRQ=1 with device error, " |
1210 | status); | 1214 | "dev_stat 0x%X", status); |
1211 | qc->err_mask |= AC_ERR_HSM; | 1215 | qc->err_mask |= AC_ERR_HSM; |
1212 | ap->hsm_task_state = HSM_ST_ERR; | 1216 | ap->hsm_task_state = HSM_ST_ERR; |
1213 | goto fsm_start; | 1217 | goto fsm_start; |
@@ -1226,13 +1230,17 @@ fsm_start: | |||
1226 | if (likely(status & (ATA_ERR | ATA_DF))) | 1230 | if (likely(status & (ATA_ERR | ATA_DF))) |
1227 | /* device stops HSM for abort/error */ | 1231 | /* device stops HSM for abort/error */ |
1228 | qc->err_mask |= AC_ERR_DEV; | 1232 | qc->err_mask |= AC_ERR_DEV; |
1229 | else | 1233 | else { |
1230 | /* HSM violation. Let EH handle this. | 1234 | /* HSM violation. Let EH handle this. |
1231 | * Phantom devices also trigger this | 1235 | * Phantom devices also trigger this |
1232 | * condition. Mark hint. | 1236 | * condition. Mark hint. |
1233 | */ | 1237 | */ |
1238 | ata_ehi_push_desc(ehi, "ST-ATA: " | ||
1239 | "DRQ=1 with device error, " | ||
1240 | "dev_stat 0x%X", status); | ||
1234 | qc->err_mask |= AC_ERR_HSM | | 1241 | qc->err_mask |= AC_ERR_HSM | |
1235 | AC_ERR_NODEV_HINT; | 1242 | AC_ERR_NODEV_HINT; |
1243 | } | ||
1236 | 1244 | ||
1237 | ap->hsm_task_state = HSM_ST_ERR; | 1245 | ap->hsm_task_state = HSM_ST_ERR; |
1238 | goto fsm_start; | 1246 | goto fsm_start; |
@@ -1257,8 +1265,12 @@ fsm_start: | |||
1257 | status = ata_wait_idle(ap); | 1265 | status = ata_wait_idle(ap); |
1258 | } | 1266 | } |
1259 | 1267 | ||
1260 | if (status & (ATA_BUSY | ATA_DRQ)) | 1268 | if (status & (ATA_BUSY | ATA_DRQ)) { |
1269 | ata_ehi_push_desc(ehi, "ST-ATA: " | ||
1270 | "BUSY|DRQ persists on ERR|DF, " | ||
1271 | "dev_stat 0x%X", status); | ||
1261 | qc->err_mask |= AC_ERR_HSM; | 1272 | qc->err_mask |= AC_ERR_HSM; |
1273 | } | ||
1262 | 1274 | ||
1263 | /* ata_pio_sectors() might change the | 1275 | /* ata_pio_sectors() might change the |
1264 | * state to HSM_ST_LAST. so, the state | 1276 | * state to HSM_ST_LAST. so, the state |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 28092bc50146..ad169ffbc4cb 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -1607,7 +1607,7 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1607 | * Much of the time, this could just work regardless. | 1607 | * Much of the time, this could just work regardless. |
1608 | * So for now, just log the incident, and allow the attempt. | 1608 | * So for now, just log the incident, and allow the attempt. |
1609 | */ | 1609 | */ |
1610 | if (limit_warnings && (qc->nbytes / qc->sect_size) > 1) { | 1610 | if (limit_warnings > 0 && (qc->nbytes / qc->sect_size) > 1) { |
1611 | --limit_warnings; | 1611 | --limit_warnings; |
1612 | ata_link_printk(qc->dev->link, KERN_WARNING, DRV_NAME | 1612 | ata_link_printk(qc->dev->link, KERN_WARNING, DRV_NAME |
1613 | ": attempting PIO w/multiple DRQ: " | 1613 | ": attempting PIO w/multiple DRQ: " |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index 8ee6b5b4ede7..84ffcc26a74b 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -370,6 +370,7 @@ static const struct pci_device_id sil24_pci_tbl[] = { | |||
370 | { PCI_VDEVICE(INTEL, 0x3124), BID_SIL3124 }, | 370 | { PCI_VDEVICE(INTEL, 0x3124), BID_SIL3124 }, |
371 | { PCI_VDEVICE(CMD, 0x3132), BID_SIL3132 }, | 371 | { PCI_VDEVICE(CMD, 0x3132), BID_SIL3132 }, |
372 | { PCI_VDEVICE(CMD, 0x0242), BID_SIL3132 }, | 372 | { PCI_VDEVICE(CMD, 0x0242), BID_SIL3132 }, |
373 | { PCI_VDEVICE(CMD, 0x0244), BID_SIL3132 }, | ||
373 | { PCI_VDEVICE(CMD, 0x3131), BID_SIL3131 }, | 374 | { PCI_VDEVICE(CMD, 0x3131), BID_SIL3131 }, |
374 | { PCI_VDEVICE(CMD, 0x3531), BID_SIL3131 }, | 375 | { PCI_VDEVICE(CMD, 0x3531), BID_SIL3131 }, |
375 | 376 | ||
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index f277cea904ce..db529b849948 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -83,6 +83,7 @@ static struct ata_port_operations uli_ops = { | |||
83 | .inherits = &ata_bmdma_port_ops, | 83 | .inherits = &ata_bmdma_port_ops, |
84 | .scr_read = uli_scr_read, | 84 | .scr_read = uli_scr_read, |
85 | .scr_write = uli_scr_write, | 85 | .scr_write = uli_scr_write, |
86 | .hardreset = ATA_OP_NULL, | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | static const struct ata_port_info uli_port_info = { | 89 | static const struct ata_port_info uli_port_info = { |
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig index 043353bd0600..14b9d5f4c203 100644 --- a/drivers/auxdisplay/Kconfig +++ b/drivers/auxdisplay/Kconfig | |||
@@ -64,7 +64,7 @@ config KS0108_DELAY | |||
64 | Amount of time the ks0108 should wait between each control write | 64 | Amount of time the ks0108 should wait between each control write |
65 | to the parallel port. | 65 | to the parallel port. |
66 | 66 | ||
67 | If your driver seems to miss random writings, increment this. | 67 | If your LCD seems to miss random writings, increment this. |
68 | 68 | ||
69 | If you don't know what I'm talking about, ignore it. | 69 | If you don't know what I'm talking about, ignore it. |
70 | 70 | ||
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c index 80bb06105387..683509f013ab 100644 --- a/drivers/auxdisplay/cfag12864b.c +++ b/drivers/auxdisplay/cfag12864b.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * License: GPLv2 | 5 | * License: GPLv2 |
6 | * Depends: ks0108 | 6 | * Depends: ks0108 |
7 | * | 7 | * |
8 | * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com> | 8 | * Author: Copyright (C) Miguel Ojeda Sandonis |
9 | * Date: 2006-10-31 | 9 | * Date: 2006-10-31 |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -398,5 +398,5 @@ module_init(cfag12864b_init); | |||
398 | module_exit(cfag12864b_exit); | 398 | module_exit(cfag12864b_exit); |
399 | 399 | ||
400 | MODULE_LICENSE("GPL v2"); | 400 | MODULE_LICENSE("GPL v2"); |
401 | MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>"); | 401 | MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>"); |
402 | MODULE_DESCRIPTION("cfag12864b LCD driver"); | 402 | MODULE_DESCRIPTION("cfag12864b LCD driver"); |
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c index 307c190699e0..fe3a865be4e5 100644 --- a/drivers/auxdisplay/cfag12864bfb.c +++ b/drivers/auxdisplay/cfag12864bfb.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * License: GPLv2 | 5 | * License: GPLv2 |
6 | * Depends: cfag12864b | 6 | * Depends: cfag12864b |
7 | * | 7 | * |
8 | * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com> | 8 | * Author: Copyright (C) Miguel Ojeda Sandonis |
9 | * Date: 2006-10-31 | 9 | * Date: 2006-10-31 |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -186,5 +186,5 @@ module_init(cfag12864bfb_init); | |||
186 | module_exit(cfag12864bfb_exit); | 186 | module_exit(cfag12864bfb_exit); |
187 | 187 | ||
188 | MODULE_LICENSE("GPL v2"); | 188 | MODULE_LICENSE("GPL v2"); |
189 | MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>"); | 189 | MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>"); |
190 | MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver"); | 190 | MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver"); |
diff --git a/drivers/auxdisplay/ks0108.c b/drivers/auxdisplay/ks0108.c index e6c3646ef18c..5b93852392b8 100644 --- a/drivers/auxdisplay/ks0108.c +++ b/drivers/auxdisplay/ks0108.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * License: GPLv2 | 5 | * License: GPLv2 |
6 | * Depends: parport | 6 | * Depends: parport |
7 | * | 7 | * |
8 | * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com> | 8 | * Author: Copyright (C) Miguel Ojeda Sandonis |
9 | * Date: 2006-10-31 | 9 | * Date: 2006-10-31 |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -173,6 +173,6 @@ module_init(ks0108_init); | |||
173 | module_exit(ks0108_exit); | 173 | module_exit(ks0108_exit); |
174 | 174 | ||
175 | MODULE_LICENSE("GPL v2"); | 175 | MODULE_LICENSE("GPL v2"); |
176 | MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>"); | 176 | MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>"); |
177 | MODULE_DESCRIPTION("ks0108 LCD Controller driver"); | 177 | MODULE_DESCRIPTION("ks0108 LCD Controller driver"); |
178 | 178 | ||
diff --git a/drivers/base/node.c b/drivers/base/node.c index 39f3d1b3a213..0f867a083338 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -84,8 +84,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) | |||
84 | nid, K(i.totalram), | 84 | nid, K(i.totalram), |
85 | nid, K(i.freeram), | 85 | nid, K(i.freeram), |
86 | nid, K(i.totalram - i.freeram), | 86 | nid, K(i.totalram - i.freeram), |
87 | nid, node_page_state(nid, NR_ACTIVE), | 87 | nid, K(node_page_state(nid, NR_ACTIVE)), |
88 | nid, node_page_state(nid, NR_INACTIVE), | 88 | nid, K(node_page_state(nid, NR_INACTIVE)), |
89 | #ifdef CONFIG_HIGHMEM | 89 | #ifdef CONFIG_HIGHMEM |
90 | nid, K(i.totalhigh), | 90 | nid, K(i.totalhigh), |
91 | nid, K(i.freehigh), | 91 | nid, K(i.freehigh), |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 5f1e1cc6165a..d81632cd7d06 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -106,35 +106,34 @@ MODULE_DEVICE_TABLE(pci, cciss_pci_device_id); | |||
106 | /* board_id = Subsystem Device ID & Vendor ID | 106 | /* board_id = Subsystem Device ID & Vendor ID |
107 | * product = Marketing Name for the board | 107 | * product = Marketing Name for the board |
108 | * access = Address of the struct of function pointers | 108 | * access = Address of the struct of function pointers |
109 | * nr_cmds = Number of commands supported by controller | ||
110 | */ | 109 | */ |
111 | static struct board_type products[] = { | 110 | static struct board_type products[] = { |
112 | {0x40700E11, "Smart Array 5300", &SA5_access, 512}, | 111 | {0x40700E11, "Smart Array 5300", &SA5_access}, |
113 | {0x40800E11, "Smart Array 5i", &SA5B_access, 512}, | 112 | {0x40800E11, "Smart Array 5i", &SA5B_access}, |
114 | {0x40820E11, "Smart Array 532", &SA5B_access, 512}, | 113 | {0x40820E11, "Smart Array 532", &SA5B_access}, |
115 | {0x40830E11, "Smart Array 5312", &SA5B_access, 512}, | 114 | {0x40830E11, "Smart Array 5312", &SA5B_access}, |
116 | {0x409A0E11, "Smart Array 641", &SA5_access, 512}, | 115 | {0x409A0E11, "Smart Array 641", &SA5_access}, |
117 | {0x409B0E11, "Smart Array 642", &SA5_access, 512}, | 116 | {0x409B0E11, "Smart Array 642", &SA5_access}, |
118 | {0x409C0E11, "Smart Array 6400", &SA5_access, 512}, | 117 | {0x409C0E11, "Smart Array 6400", &SA5_access}, |
119 | {0x409D0E11, "Smart Array 6400 EM", &SA5_access, 512}, | 118 | {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, |
120 | {0x40910E11, "Smart Array 6i", &SA5_access, 512}, | 119 | {0x40910E11, "Smart Array 6i", &SA5_access}, |
121 | {0x3225103C, "Smart Array P600", &SA5_access, 512}, | 120 | {0x3225103C, "Smart Array P600", &SA5_access}, |
122 | {0x3223103C, "Smart Array P800", &SA5_access, 512}, | 121 | {0x3223103C, "Smart Array P800", &SA5_access}, |
123 | {0x3234103C, "Smart Array P400", &SA5_access, 512}, | 122 | {0x3234103C, "Smart Array P400", &SA5_access}, |
124 | {0x3235103C, "Smart Array P400i", &SA5_access, 512}, | 123 | {0x3235103C, "Smart Array P400i", &SA5_access}, |
125 | {0x3211103C, "Smart Array E200i", &SA5_access, 120}, | 124 | {0x3211103C, "Smart Array E200i", &SA5_access}, |
126 | {0x3212103C, "Smart Array E200", &SA5_access, 120}, | 125 | {0x3212103C, "Smart Array E200", &SA5_access}, |
127 | {0x3213103C, "Smart Array E200i", &SA5_access, 120}, | 126 | {0x3213103C, "Smart Array E200i", &SA5_access}, |
128 | {0x3214103C, "Smart Array E200i", &SA5_access, 120}, | 127 | {0x3214103C, "Smart Array E200i", &SA5_access}, |
129 | {0x3215103C, "Smart Array E200i", &SA5_access, 120}, | 128 | {0x3215103C, "Smart Array E200i", &SA5_access}, |
130 | {0x3237103C, "Smart Array E500", &SA5_access, 512}, | 129 | {0x3237103C, "Smart Array E500", &SA5_access}, |
131 | {0x323D103C, "Smart Array P700m", &SA5_access, 512}, | 130 | {0x323D103C, "Smart Array P700m", &SA5_access}, |
132 | {0x3241103C, "Smart Array P212", &SA5_access, 384}, | 131 | {0x3241103C, "Smart Array P212", &SA5_access}, |
133 | {0x3243103C, "Smart Array P410", &SA5_access, 384}, | 132 | {0x3243103C, "Smart Array P410", &SA5_access}, |
134 | {0x3245103C, "Smart Array P410i", &SA5_access, 384}, | 133 | {0x3245103C, "Smart Array P410i", &SA5_access}, |
135 | {0x3247103C, "Smart Array P411", &SA5_access, 384}, | 134 | {0x3247103C, "Smart Array P411", &SA5_access}, |
136 | {0x3249103C, "Smart Array P812", &SA5_access, 384}, | 135 | {0x3249103C, "Smart Array P812", &SA5_access}, |
137 | {0xFFFF103C, "Unknown Smart Array", &SA5_access, 120}, | 136 | {0xFFFF103C, "Unknown Smart Array", &SA5_access}, |
138 | }; | 137 | }; |
139 | 138 | ||
140 | /* How long to wait (in milliseconds) for board to go into simple mode */ | 139 | /* How long to wait (in milliseconds) for board to go into simple mode */ |
@@ -3086,11 +3085,20 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
3086 | print_cfg_table(c->cfgtable); | 3085 | print_cfg_table(c->cfgtable); |
3087 | #endif /* CCISS_DEBUG */ | 3086 | #endif /* CCISS_DEBUG */ |
3088 | 3087 | ||
3088 | /* Some controllers support Zero Memory Raid (ZMR). | ||
3089 | * When configured in ZMR mode the number of supported | ||
3090 | * commands drops to 64. So instead of just setting an | ||
3091 | * arbitrary value we make the driver a little smarter. | ||
3092 | * We read the config table to tell us how many commands | ||
3093 | * are supported on the controller then subtract 4 to | ||
3094 | * leave a little room for ioctl calls. | ||
3095 | */ | ||
3096 | c->max_commands = readl(&(c->cfgtable->CmdsOutMax)); | ||
3089 | for (i = 0; i < ARRAY_SIZE(products); i++) { | 3097 | for (i = 0; i < ARRAY_SIZE(products); i++) { |
3090 | if (board_id == products[i].board_id) { | 3098 | if (board_id == products[i].board_id) { |
3091 | c->product_name = products[i].product_name; | 3099 | c->product_name = products[i].product_name; |
3092 | c->access = *(products[i].access); | 3100 | c->access = *(products[i].access); |
3093 | c->nr_cmds = products[i].nr_cmds; | 3101 | c->nr_cmds = c->max_commands - 4; |
3094 | break; | 3102 | break; |
3095 | } | 3103 | } |
3096 | } | 3104 | } |
@@ -3110,7 +3118,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) | |||
3110 | if (subsystem_vendor_id == PCI_VENDOR_ID_HP) { | 3118 | if (subsystem_vendor_id == PCI_VENDOR_ID_HP) { |
3111 | c->product_name = products[i-1].product_name; | 3119 | c->product_name = products[i-1].product_name; |
3112 | c->access = *(products[i-1].access); | 3120 | c->access = *(products[i-1].access); |
3113 | c->nr_cmds = products[i-1].nr_cmds; | 3121 | c->nr_cmds = c->max_commands - 4; |
3114 | printk(KERN_WARNING "cciss: This is an unknown " | 3122 | printk(KERN_WARNING "cciss: This is an unknown " |
3115 | "Smart Array controller.\n" | 3123 | "Smart Array controller.\n" |
3116 | "cciss: Please update to the latest driver " | 3124 | "cciss: Please update to the latest driver " |
@@ -3546,6 +3554,10 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
3546 | for (j = 0; j <= hba[i]->highest_lun; j++) | 3554 | for (j = 0; j <= hba[i]->highest_lun; j++) |
3547 | add_disk(hba[i]->gendisk[j]); | 3555 | add_disk(hba[i]->gendisk[j]); |
3548 | 3556 | ||
3557 | /* we must register the controller even if no disks exist */ | ||
3558 | if (hba[i]->highest_lun == -1) | ||
3559 | add_disk(hba[i]->gendisk[0]); | ||
3560 | |||
3549 | return 1; | 3561 | return 1; |
3550 | 3562 | ||
3551 | clean4: | 3563 | clean4: |
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c index f7f16e7a8bf3..df036118b8b1 100644 --- a/drivers/char/drm/i915_irq.c +++ b/drivers/char/drm/i915_irq.c | |||
@@ -62,11 +62,11 @@ static void i915_vblank_tasklet(struct drm_device *dev) | |||
62 | u32 ropcpp = (0xcc << 16) | ((cpp - 1) << 24); | 62 | u32 ropcpp = (0xcc << 16) | ((cpp - 1) << 24); |
63 | RING_LOCALS; | 63 | RING_LOCALS; |
64 | 64 | ||
65 | if (sarea_priv->front_tiled) { | 65 | if (IS_I965G(dev) && sarea_priv->front_tiled) { |
66 | cmd |= XY_SRC_COPY_BLT_DST_TILED; | 66 | cmd |= XY_SRC_COPY_BLT_DST_TILED; |
67 | dst_pitch >>= 2; | 67 | dst_pitch >>= 2; |
68 | } | 68 | } |
69 | if (sarea_priv->back_tiled) { | 69 | if (IS_I965G(dev) && sarea_priv->back_tiled) { |
70 | cmd |= XY_SRC_COPY_BLT_SRC_TILED; | 70 | cmd |= XY_SRC_COPY_BLT_SRC_TILED; |
71 | src_pitch >>= 2; | 71 | src_pitch >>= 2; |
72 | } | 72 | } |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e94bee032314..750131010af0 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -3322,7 +3322,7 @@ static int send_break(struct tty_struct *tty, unsigned int duration) | |||
3322 | msleep_interruptible(duration); | 3322 | msleep_interruptible(duration); |
3323 | tty->ops->break_ctl(tty, 0); | 3323 | tty->ops->break_ctl(tty, 0); |
3324 | tty_write_unlock(tty); | 3324 | tty_write_unlock(tty); |
3325 | if (!signal_pending(current)) | 3325 | if (signal_pending(current)) |
3326 | return -EINTR; | 3326 | return -EINTR; |
3327 | return 0; | 3327 | return 0; |
3328 | } | 3328 | } |
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index 85e2ba7fcfba..bf4830082a13 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
28 | #include <linux/connector.h> | 28 | #include <linux/connector.h> |
29 | #include <linux/mutex.h> | 29 | #include <linux/mutex.h> |
30 | #include <linux/proc_fs.h> | ||
31 | #include <linux/spinlock.h> | ||
30 | 32 | ||
31 | #include <net/sock.h> | 33 | #include <net/sock.h> |
32 | 34 | ||
@@ -403,6 +405,40 @@ static void cn_callback(void *data) | |||
403 | mutex_unlock(¬ify_lock); | 405 | mutex_unlock(¬ify_lock); |
404 | } | 406 | } |
405 | 407 | ||
408 | static int cn_proc_show(struct seq_file *m, void *v) | ||
409 | { | ||
410 | struct cn_queue_dev *dev = cdev.cbdev; | ||
411 | struct cn_callback_entry *cbq; | ||
412 | |||
413 | seq_printf(m, "Name ID\n"); | ||
414 | |||
415 | spin_lock_bh(&dev->queue_lock); | ||
416 | |||
417 | list_for_each_entry(cbq, &dev->queue_list, callback_entry) { | ||
418 | seq_printf(m, "%-15s %u:%u\n", | ||
419 | cbq->id.name, | ||
420 | cbq->id.id.idx, | ||
421 | cbq->id.id.val); | ||
422 | } | ||
423 | |||
424 | spin_unlock_bh(&dev->queue_lock); | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static int cn_proc_open(struct inode *inode, struct file *file) | ||
430 | { | ||
431 | return single_open(file, cn_proc_show, NULL); | ||
432 | } | ||
433 | |||
434 | static const struct file_operations cn_file_ops = { | ||
435 | .owner = THIS_MODULE, | ||
436 | .open = cn_proc_open, | ||
437 | .read = seq_read, | ||
438 | .llseek = seq_lseek, | ||
439 | .release = single_release | ||
440 | }; | ||
441 | |||
406 | static int __devinit cn_init(void) | 442 | static int __devinit cn_init(void) |
407 | { | 443 | { |
408 | struct cn_dev *dev = &cdev; | 444 | struct cn_dev *dev = &cdev; |
@@ -434,6 +470,8 @@ static int __devinit cn_init(void) | |||
434 | return -EINVAL; | 470 | return -EINVAL; |
435 | } | 471 | } |
436 | 472 | ||
473 | proc_net_fops_create(&init_net, "connector", S_IRUGO, &cn_file_ops); | ||
474 | |||
437 | return 0; | 475 | return 0; |
438 | } | 476 | } |
439 | 477 | ||
@@ -443,6 +481,8 @@ static void __devexit cn_fini(void) | |||
443 | 481 | ||
444 | cn_already_initialized = 0; | 482 | cn_already_initialized = 0; |
445 | 483 | ||
484 | proc_net_remove(&init_net, "connector"); | ||
485 | |||
446 | cn_del_callback(&dev->id); | 486 | cn_del_callback(&dev->id); |
447 | cn_queue_free_dev(dev->cbdev); | 487 | cn_queue_free_dev(dev->cbdev); |
448 | netlink_kernel_release(dev->nls); | 488 | netlink_kernel_release(dev->nls); |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index b2458bb8e9ca..227d2e036cd8 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -1051,7 +1051,8 @@ static int sbp2_scan_unit_dir(struct sbp2_target *tgt, u32 *directory, | |||
1051 | break; | 1051 | break; |
1052 | 1052 | ||
1053 | case SBP2_CSR_LOGICAL_UNIT_DIRECTORY: | 1053 | case SBP2_CSR_LOGICAL_UNIT_DIRECTORY: |
1054 | if (sbp2_scan_logical_unit_dir(tgt, ci.p + value) < 0) | 1054 | /* Adjust for the increment in the iterator */ |
1055 | if (sbp2_scan_logical_unit_dir(tgt, ci.p - 1 + value) < 0) | ||
1055 | return -ENOMEM; | 1056 | return -ENOMEM; |
1056 | break; | 1057 | break; |
1057 | } | 1058 | } |
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index bbd28342e771..008c38ba774f 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -28,12 +28,18 @@ config DEBUG_GPIO | |||
28 | comment "I2C GPIO expanders:" | 28 | comment "I2C GPIO expanders:" |
29 | 29 | ||
30 | config GPIO_PCA953X | 30 | config GPIO_PCA953X |
31 | tristate "PCA953x I/O ports" | 31 | tristate "PCA953x, PCA955x, and MAX7310 I/O ports" |
32 | depends on I2C | 32 | depends on I2C |
33 | help | 33 | help |
34 | Say yes here to support the PCA9534 (8-bit), PCA9535 (16-bit), | 34 | Say yes here to provide access to several register-oriented |
35 | PCA9536 (4-bit), PCA9537 (4-bit), PCA9538 (8-bit), and PCA9539 | 35 | SMBus I/O expanders, made mostly by NXP or TI. Compatible |
36 | (16-bit) I/O ports. These parts are made by NXP and TI. | 36 | models include: |
37 | |||
38 | 4 bits: pca9536, pca9537 | ||
39 | |||
40 | 8 bits: max7310, pca9534, pca9538, pca9554, pca9557 | ||
41 | |||
42 | 16 bits: pca9535, pca9539, pca9555 | ||
37 | 43 | ||
38 | This driver can also be built as a module. If so, the module | 44 | This driver can also be built as a module. If so, the module |
39 | will be called pca953x. | 45 | will be called pca953x. |
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 7e40e8a55edf..a380730b61ab 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c | |||
@@ -33,7 +33,7 @@ static const struct i2c_device_id pca953x_id[] = { | |||
33 | { "pca9554", 8, }, | 33 | { "pca9554", 8, }, |
34 | { "pca9555", 16, }, | 34 | { "pca9555", 16, }, |
35 | { "pca9557", 8, }, | 35 | { "pca9557", 8, }, |
36 | /* REVISIT several pca955x parts should work here too */ | 36 | { "max7310", 8, }, |
37 | { } | 37 | { } |
38 | }; | 38 | }; |
39 | MODULE_DEVICE_TABLE(i2c, pca953x_id); | 39 | MODULE_DEVICE_TABLE(i2c, pca953x_id); |
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c index 26df06f840eb..50f22690d611 100644 --- a/drivers/hwmon/hdaps.c +++ b/drivers/hwmon/hdaps.c | |||
@@ -516,17 +516,23 @@ static struct dmi_system_id __initdata hdaps_whitelist[] = { | |||
516 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"), | 516 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"), |
517 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"), | 517 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"), |
518 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61i"), | 518 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61i"), |
519 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61"), | ||
519 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"), | 520 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"), |
520 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"), | 521 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"), |
521 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"), | 522 | HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"), |
522 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"), | 523 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"), |
523 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"), | 524 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"), |
524 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"), | 525 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"), |
526 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61p"), | ||
525 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61"), | 527 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61"), |
526 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"), | 528 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"), |
527 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"), | 529 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"), |
528 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"), | 530 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"), |
531 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61s"), | ||
532 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61"), | ||
529 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"), | 533 | HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"), |
534 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61m"), | ||
535 | HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61p"), | ||
530 | { .ident = NULL } | 536 | { .ident = NULL } |
531 | }; | 537 | }; |
532 | 538 | ||
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 1305ef190fc1..9e8c875437be 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -290,12 +290,12 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
290 | * bus, or started a new i2c message | 290 | * bus, or started a new i2c message |
291 | */ | 291 | */ |
292 | 292 | ||
293 | if (iicstat & S3C2410_IICSTAT_LASTBIT && | 293 | if (iicstat & S3C2410_IICSTAT_LASTBIT && |
294 | !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { | 294 | !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { |
295 | /* ack was not received... */ | 295 | /* ack was not received... */ |
296 | 296 | ||
297 | dev_dbg(i2c->dev, "ack was not received\n"); | 297 | dev_dbg(i2c->dev, "ack was not received\n"); |
298 | s3c24xx_i2c_stop(i2c, -EREMOTEIO); | 298 | s3c24xx_i2c_stop(i2c, -ENXIO); |
299 | goto out_ack; | 299 | goto out_ack; |
300 | } | 300 | } |
301 | 301 | ||
@@ -305,7 +305,7 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
305 | i2c->state = STATE_WRITE; | 305 | i2c->state = STATE_WRITE; |
306 | 306 | ||
307 | /* terminate the transfer if there is nothing to do | 307 | /* terminate the transfer if there is nothing to do |
308 | * (used by the i2c probe to find devices */ | 308 | * as this is used by the i2c probe to find devices. */ |
309 | 309 | ||
310 | if (is_lastmsg(i2c) && i2c->msg->len == 0) { | 310 | if (is_lastmsg(i2c) && i2c->msg->len == 0) { |
311 | s3c24xx_i2c_stop(i2c, 0); | 311 | s3c24xx_i2c_stop(i2c, 0); |
@@ -323,7 +323,17 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
323 | * end of the message, and if so, work out what to do | 323 | * end of the message, and if so, work out what to do |
324 | */ | 324 | */ |
325 | 325 | ||
326 | if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) { | ||
327 | if (iicstat & S3C2410_IICSTAT_LASTBIT) { | ||
328 | dev_dbg(i2c->dev, "WRITE: No Ack\n"); | ||
329 | |||
330 | s3c24xx_i2c_stop(i2c, -ECONNREFUSED); | ||
331 | goto out_ack; | ||
332 | } | ||
333 | } | ||
334 | |||
326 | retry_write: | 335 | retry_write: |
336 | |||
327 | if (!is_msgend(i2c)) { | 337 | if (!is_msgend(i2c)) { |
328 | byte = i2c->msg->buf[i2c->msg_ptr++]; | 338 | byte = i2c->msg->buf[i2c->msg_ptr++]; |
329 | writeb(byte, i2c->regs + S3C2410_IICDS); | 339 | writeb(byte, i2c->regs + S3C2410_IICDS); |
@@ -377,17 +387,6 @@ static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) | |||
377 | * going to do any more read/write | 387 | * going to do any more read/write |
378 | */ | 388 | */ |
379 | 389 | ||
380 | if (!(i2c->msg->flags & I2C_M_IGNORE_NAK) && | ||
381 | !(is_msglast(i2c) && is_lastmsg(i2c))) { | ||
382 | |||
383 | if (iicstat & S3C2410_IICSTAT_LASTBIT) { | ||
384 | dev_dbg(i2c->dev, "READ: No Ack\n"); | ||
385 | |||
386 | s3c24xx_i2c_stop(i2c, -ECONNREFUSED); | ||
387 | goto out_ack; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | byte = readb(i2c->regs + S3C2410_IICDS); | 390 | byte = readb(i2c->regs + S3C2410_IICDS); |
392 | i2c->msg->buf[i2c->msg_ptr++] = byte; | 391 | i2c->msg->buf[i2c->msg_ptr++] = byte; |
393 | 392 | ||
@@ -949,3 +948,4 @@ MODULE_DESCRIPTION("S3C24XX I2C Bus driver"); | |||
949 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | 948 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); |
950 | MODULE_LICENSE("GPL"); | 949 | MODULE_LICENSE("GPL"); |
951 | MODULE_ALIAS("platform:s3c2410-i2c"); | 950 | MODULE_ALIAS("platform:s3c2410-i2c"); |
951 | MODULE_ALIAS("platform:s3c2440-i2c"); | ||
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 8e07de23d220..1607536ff5fb 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -823,6 +823,13 @@ config BLK_DEV_IDE_RAPIDE | |||
823 | Say Y here if you want to support the Yellowstone RapIDE controller | 823 | Say Y here if you want to support the Yellowstone RapIDE controller |
824 | manufactured for use with Acorn computers. | 824 | manufactured for use with Acorn computers. |
825 | 825 | ||
826 | config BLK_DEV_IDE_BAST | ||
827 | tristate "Simtec BAST / Thorcom VR1000 IDE support" | ||
828 | depends on ARM && (ARCH_BAST || MACH_VR1000) | ||
829 | help | ||
830 | Say Y here if you want to support the onboard IDE channels on the | ||
831 | Simtec BAST or the Thorcom VR1000 | ||
832 | |||
826 | config IDE_H8300 | 833 | config IDE_H8300 |
827 | tristate "H8300 IDE support" | 834 | tristate "H8300 IDE support" |
828 | depends on H8300 | 835 | depends on H8300 |
diff --git a/drivers/ide/arm/Makefile b/drivers/ide/arm/Makefile index 5bc26053afa6..936e7b0237f5 100644 --- a/drivers/ide/arm/Makefile +++ b/drivers/ide/arm/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o | 2 | obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o |
3 | obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o | 3 | obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o |
4 | obj-$(CONFIG_BLK_DEV_IDE_BAST) += bast-ide.o | ||
4 | obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o | 5 | obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o |
5 | 6 | ||
6 | ifeq ($(CONFIG_IDE_ARM), m) | 7 | ifeq ($(CONFIG_IDE_ARM), m) |
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c new file mode 100644 index 000000000000..8e8c28104b45 --- /dev/null +++ b/drivers/ide/arm/bast-ide.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2003-2004 Simtec Electronics | ||
3 | * Ben Dooks <ben@simtec.co.uk> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/errno.h> | ||
13 | #include <linux/ide.h> | ||
14 | #include <linux/init.h> | ||
15 | |||
16 | #include <asm/mach-types.h> | ||
17 | |||
18 | #include <asm/io.h> | ||
19 | #include <asm/irq.h> | ||
20 | #include <asm/arch/map.h> | ||
21 | #include <asm/arch/bast-map.h> | ||
22 | #include <asm/arch/bast-irq.h> | ||
23 | |||
24 | #define DRV_NAME "bast-ide" | ||
25 | |||
26 | static int __init bastide_register(unsigned int base, unsigned int aux, int irq) | ||
27 | { | ||
28 | ide_hwif_t *hwif; | ||
29 | hw_regs_t hw; | ||
30 | int i; | ||
31 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
32 | |||
33 | memset(&hw, 0, sizeof(hw)); | ||
34 | |||
35 | base += BAST_IDE_CS; | ||
36 | aux += BAST_IDE_CS; | ||
37 | |||
38 | for (i = 0; i <= 7; i++) { | ||
39 | hw.io_ports_array[i] = (unsigned long)base; | ||
40 | base += 0x20; | ||
41 | } | ||
42 | |||
43 | hw.io_ports.ctl_addr = aux + (6 * 0x20); | ||
44 | hw.irq = irq; | ||
45 | hw.chipset = ide_generic; | ||
46 | |||
47 | hwif = ide_find_port(); | ||
48 | if (hwif == NULL) | ||
49 | goto out; | ||
50 | |||
51 | i = hwif->index; | ||
52 | |||
53 | ide_init_port_data(hwif, i); | ||
54 | ide_init_port_hw(hwif, &hw); | ||
55 | hwif->port_ops = NULL; | ||
56 | |||
57 | idx[0] = i; | ||
58 | |||
59 | ide_device_add(idx, NULL); | ||
60 | out: | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int __init bastide_init(void) | ||
65 | { | ||
66 | unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS; | ||
67 | |||
68 | /* we can treat the VR1000 and the BAST the same */ | ||
69 | |||
70 | if (!(machine_is_bast() || machine_is_vr1000())) | ||
71 | return 0; | ||
72 | |||
73 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); | ||
74 | |||
75 | if (!request_mem_region(base, 0x400000, DRV_NAME)) { | ||
76 | printk(KERN_ERR "%s: resources busy\n", DRV_NAME); | ||
77 | return -EBUSY; | ||
78 | } | ||
79 | |||
80 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0); | ||
81 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | module_init(bastide_init); | ||
87 | |||
88 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | ||
89 | MODULE_LICENSE("GPL"); | ||
90 | MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver"); | ||
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index cc24803fadff..2f2b4f4cf229 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -76,7 +76,7 @@ struct palm_bk3710_udmatiming { | |||
76 | 76 | ||
77 | #include "../ide-timing.h" | 77 | #include "../ide-timing.h" |
78 | 78 | ||
79 | static long ide_palm_clk; | 79 | static unsigned ideclk_period; /* in nanoseconds */ |
80 | 80 | ||
81 | static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { | 81 | static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { |
82 | {160, 240}, /* UDMA Mode 0 */ | 82 | {160, 240}, /* UDMA Mode 0 */ |
@@ -86,8 +86,6 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { | |||
86 | {85, 60}, /* UDMA Mode 4 */ | 86 | {85, 60}, /* UDMA Mode 4 */ |
87 | }; | 87 | }; |
88 | 88 | ||
89 | static struct clk *ideclkp; | ||
90 | |||
91 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | 89 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, |
92 | unsigned int mode) | 90 | unsigned int mode) |
93 | { | 91 | { |
@@ -97,10 +95,10 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | |||
97 | 95 | ||
98 | /* DMA Data Setup */ | 96 | /* DMA Data Setup */ |
99 | t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, | 97 | t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, |
100 | ide_palm_clk) - 1; | 98 | ideclk_period) - 1; |
101 | tenv = DIV_ROUND_UP(20, ide_palm_clk) - 1; | 99 | tenv = DIV_ROUND_UP(20, ideclk_period) - 1; |
102 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, | 100 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, |
103 | ide_palm_clk) - 1; | 101 | ideclk_period) - 1; |
104 | 102 | ||
105 | /* udmatim Register */ | 103 | /* udmatim Register */ |
106 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); | 104 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); |
@@ -141,8 +139,8 @@ static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev, | |||
141 | cycletime = max_t(int, t->cycle, min_cycle); | 139 | cycletime = max_t(int, t->cycle, min_cycle); |
142 | 140 | ||
143 | /* DMA Data Setup */ | 141 | /* DMA Data Setup */ |
144 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); | 142 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); |
145 | td = DIV_ROUND_UP(t->active, ide_palm_clk); | 143 | td = DIV_ROUND_UP(t->active, ideclk_period); |
146 | tkw = t0 - td - 1; | 144 | tkw = t0 - td - 1; |
147 | td -= 1; | 145 | td -= 1; |
148 | 146 | ||
@@ -168,9 +166,9 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
168 | struct ide_timing *t; | 166 | struct ide_timing *t; |
169 | 167 | ||
170 | /* PIO Data Setup */ | 168 | /* PIO Data Setup */ |
171 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); | 169 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); |
172 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, | 170 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, |
173 | ide_palm_clk); | 171 | ideclk_period); |
174 | 172 | ||
175 | t2i = t0 - t2 - 1; | 173 | t2i = t0 - t2 - 1; |
176 | t2 -= 1; | 174 | t2 -= 1; |
@@ -192,8 +190,8 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
192 | 190 | ||
193 | /* TASKFILE Setup */ | 191 | /* TASKFILE Setup */ |
194 | t = ide_timing_find_mode(XFER_PIO_0 + mode); | 192 | t = ide_timing_find_mode(XFER_PIO_0 + mode); |
195 | t0 = DIV_ROUND_UP(t->cyc8b, ide_palm_clk); | 193 | t0 = DIV_ROUND_UP(t->cyc8b, ideclk_period); |
196 | t2 = DIV_ROUND_UP(t->act8b, ide_palm_clk); | 194 | t2 = DIV_ROUND_UP(t->act8b, ideclk_period); |
197 | 195 | ||
198 | t2i = t0 - t2 - 1; | 196 | t2i = t0 - t2 - 1; |
199 | t2 -= 1; | 197 | t2 -= 1; |
@@ -350,22 +348,22 @@ static const struct ide_port_info __devinitdata palm_bk3710_port_info = { | |||
350 | 348 | ||
351 | static int __devinit palm_bk3710_probe(struct platform_device *pdev) | 349 | static int __devinit palm_bk3710_probe(struct platform_device *pdev) |
352 | { | 350 | { |
353 | struct clk *clkp; | 351 | struct clk *clk; |
354 | struct resource *mem, *irq; | 352 | struct resource *mem, *irq; |
355 | ide_hwif_t *hwif; | 353 | ide_hwif_t *hwif; |
356 | unsigned long base; | 354 | unsigned long base, rate; |
357 | int i; | 355 | int i; |
358 | hw_regs_t hw; | 356 | hw_regs_t hw; |
359 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 357 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
360 | 358 | ||
361 | clkp = clk_get(NULL, "IDECLK"); | 359 | clk = clk_get(NULL, "IDECLK"); |
362 | if (IS_ERR(clkp)) | 360 | if (IS_ERR(clk)) |
363 | return -ENODEV; | 361 | return -ENODEV; |
364 | 362 | ||
365 | ideclkp = clkp; | 363 | clk_enable(clk); |
366 | clk_enable(ideclkp); | 364 | rate = clk_get_rate(clk); |
367 | ide_palm_clk = clk_get_rate(ideclkp)/100000; | 365 | ideclk_period = 1000000000UL / rate; |
368 | ide_palm_clk = (10000/ide_palm_clk) + 1; | 366 | |
369 | /* Register the IDE interface with Linux ATA Interface */ | 367 | /* Register the IDE interface with Linux ATA Interface */ |
370 | memset(&hw, 0, sizeof(hw)); | 368 | memset(&hw, 0, sizeof(hw)); |
371 | 369 | ||
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 380fa0c8cc84..26e68b65b7cf 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -646,8 +646,6 @@ static int ide_register_port(ide_hwif_t *hwif) | |||
646 | goto out; | 646 | goto out; |
647 | } | 647 | } |
648 | 648 | ||
649 | get_device(&hwif->gendev); | ||
650 | |||
651 | hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, | 649 | hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, |
652 | MKDEV(0, 0), hwif, hwif->name); | 650 | MKDEV(0, 0), hwif, hwif->name); |
653 | if (IS_ERR(hwif->portdev)) { | 651 | if (IS_ERR(hwif->portdev)) { |
@@ -1220,16 +1218,12 @@ static void drive_release_dev (struct device *dev) | |||
1220 | complete(&drive->gendev_rel_comp); | 1218 | complete(&drive->gendev_rel_comp); |
1221 | } | 1219 | } |
1222 | 1220 | ||
1223 | #ifndef ide_default_irq | ||
1224 | #define ide_default_irq(irq) 0 | ||
1225 | #endif | ||
1226 | |||
1227 | static int hwif_init(ide_hwif_t *hwif) | 1221 | static int hwif_init(ide_hwif_t *hwif) |
1228 | { | 1222 | { |
1229 | int old_irq; | 1223 | int old_irq; |
1230 | 1224 | ||
1231 | if (!hwif->irq) { | 1225 | if (!hwif->irq) { |
1232 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 1226 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1233 | if (!hwif->irq) { | 1227 | if (!hwif->irq) { |
1234 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1228 | printk("%s: DISABLED, NO IRQ\n", hwif->name); |
1235 | return 0; | 1229 | return 0; |
@@ -1259,7 +1253,7 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1259 | * It failed to initialise. Find the default IRQ for | 1253 | * It failed to initialise. Find the default IRQ for |
1260 | * this port and try that. | 1254 | * this port and try that. |
1261 | */ | 1255 | */ |
1262 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 1256 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1263 | if (!hwif->irq) { | 1257 | if (!hwif->irq) { |
1264 | printk("%s: Disabled unable to get IRQ %d.\n", | 1258 | printk("%s: Disabled unable to get IRQ %d.\n", |
1265 | hwif->name, old_irq); | 1259 | hwif->name, old_irq); |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index 55ec7f798772..8af88bf0969b 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
@@ -76,7 +76,7 @@ static int proc_ide_read_mate | |||
76 | ide_hwif_t *hwif = (ide_hwif_t *) data; | 76 | ide_hwif_t *hwif = (ide_hwif_t *) data; |
77 | int len; | 77 | int len; |
78 | 78 | ||
79 | if (hwif && hwif->mate && hwif->mate->present) | 79 | if (hwif && hwif->mate) |
80 | len = sprintf(page, "%s\n", hwif->mate->name); | 80 | len = sprintf(page, "%s\n", hwif->mate->name); |
81 | else | 81 | else |
82 | len = sprintf(page, "(none)\n"); | 82 | len = sprintf(page, "(none)\n"); |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index c758dcb13b14..300431d080a9 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -315,13 +315,14 @@ void ide_unregister(ide_hwif_t *hwif) | |||
315 | 315 | ||
316 | BUG_ON(in_interrupt()); | 316 | BUG_ON(in_interrupt()); |
317 | BUG_ON(irqs_disabled()); | 317 | BUG_ON(irqs_disabled()); |
318 | |||
318 | mutex_lock(&ide_cfg_mtx); | 319 | mutex_lock(&ide_cfg_mtx); |
319 | spin_lock_irq(&ide_lock); | ||
320 | if (!hwif->present) | ||
321 | goto abort; | ||
322 | __ide_port_unregister_devices(hwif); | ||
323 | hwif->present = 0; | ||
324 | 320 | ||
321 | spin_lock_irq(&ide_lock); | ||
322 | if (hwif->present) { | ||
323 | __ide_port_unregister_devices(hwif); | ||
324 | hwif->present = 0; | ||
325 | } | ||
325 | spin_unlock_irq(&ide_lock); | 326 | spin_unlock_irq(&ide_lock); |
326 | 327 | ||
327 | ide_proc_unregister_port(hwif); | 328 | ide_proc_unregister_port(hwif); |
@@ -351,16 +352,15 @@ void ide_unregister(ide_hwif_t *hwif) | |||
351 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); | 352 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); |
352 | kfree(hwif->sg_table); | 353 | kfree(hwif->sg_table); |
353 | unregister_blkdev(hwif->major, hwif->name); | 354 | unregister_blkdev(hwif->major, hwif->name); |
354 | spin_lock_irq(&ide_lock); | ||
355 | 355 | ||
356 | if (hwif->dma_base) | 356 | if (hwif->dma_base) |
357 | ide_release_dma_engine(hwif); | 357 | ide_release_dma_engine(hwif); |
358 | 358 | ||
359 | spin_lock_irq(&ide_lock); | ||
359 | /* restore hwif data to pristine status */ | 360 | /* restore hwif data to pristine status */ |
360 | ide_init_port_data(hwif, hwif->index); | 361 | ide_init_port_data(hwif, hwif->index); |
361 | |||
362 | abort: | ||
363 | spin_unlock_irq(&ide_lock); | 362 | spin_unlock_irq(&ide_lock); |
363 | |||
364 | mutex_unlock(&ide_cfg_mtx); | 364 | mutex_unlock(&ide_cfg_mtx); |
365 | } | 365 | } |
366 | 366 | ||
@@ -1094,13 +1094,6 @@ struct bus_type ide_bus_type = { | |||
1094 | 1094 | ||
1095 | EXPORT_SYMBOL_GPL(ide_bus_type); | 1095 | EXPORT_SYMBOL_GPL(ide_bus_type); |
1096 | 1096 | ||
1097 | static void ide_port_class_release(struct device *portdev) | ||
1098 | { | ||
1099 | ide_hwif_t *hwif = dev_get_drvdata(portdev); | ||
1100 | |||
1101 | put_device(&hwif->gendev); | ||
1102 | } | ||
1103 | |||
1104 | int ide_vlb_clk; | 1097 | int ide_vlb_clk; |
1105 | EXPORT_SYMBOL_GPL(ide_vlb_clk); | 1098 | EXPORT_SYMBOL_GPL(ide_vlb_clk); |
1106 | 1099 | ||
@@ -1305,7 +1298,6 @@ static int __init ide_init(void) | |||
1305 | ret = PTR_ERR(ide_port_class); | 1298 | ret = PTR_ERR(ide_port_class); |
1306 | goto out_port_class; | 1299 | goto out_port_class; |
1307 | } | 1300 | } |
1308 | ide_port_class->dev_release = ide_port_class_release; | ||
1309 | 1301 | ||
1310 | init_ide_data(); | 1302 | init_ide_data(); |
1311 | 1303 | ||
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 9053c8771e6e..2b71bdf74e73 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -184,8 +184,7 @@ static const struct ide_port_info it8213_chipsets[] __devinitdata = { | |||
184 | 184 | ||
185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
186 | { | 186 | { |
187 | ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); | 187 | return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); |
188 | return 0; | ||
189 | } | 188 | } |
190 | 189 | ||
191 | static const struct pci_device_id it8213_pci_tbl[] = { | 190 | static const struct pci_device_id it8213_pci_tbl[] = { |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index fec4955f449b..a7a41bb82778 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -225,10 +225,6 @@ static int ns87415_dma_setup(ide_drive_t *drive) | |||
225 | return 1; | 225 | return 1; |
226 | } | 226 | } |
227 | 227 | ||
228 | #ifndef ide_default_irq | ||
229 | #define ide_default_irq(irq) 0 | ||
230 | #endif | ||
231 | |||
232 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | 228 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) |
233 | { | 229 | { |
234 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 230 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -288,7 +284,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
288 | } | 284 | } |
289 | 285 | ||
290 | if (!using_inta) | 286 | if (!using_inta) |
291 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 287 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
292 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | 288 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) |
293 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ | 289 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ |
294 | 290 | ||
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 8934178a23ee..95f82cfb6c54 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c | |||
@@ -1096,7 +1096,9 @@ static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, ch | |||
1096 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | 1096 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1097 | 1097 | ||
1098 | PDBG("%s dev 0x%p\n", __func__, dev); | 1098 | PDBG("%s dev 0x%p\n", __func__, dev); |
1099 | rtnl_lock(); | ||
1099 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1100 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1101 | rtnl_unlock(); | ||
1100 | return sprintf(buf, "%s\n", info.fw_version); | 1102 | return sprintf(buf, "%s\n", info.fw_version); |
1101 | } | 1103 | } |
1102 | 1104 | ||
@@ -1109,7 +1111,9 @@ static ssize_t show_hca(struct device *dev, struct device_attribute *attr, | |||
1109 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; | 1111 | struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; |
1110 | 1112 | ||
1111 | PDBG("%s dev 0x%p\n", __func__, dev); | 1113 | PDBG("%s dev 0x%p\n", __func__, dev); |
1114 | rtnl_lock(); | ||
1112 | lldev->ethtool_ops->get_drvinfo(lldev, &info); | 1115 | lldev->ethtool_ops->get_drvinfo(lldev, &info); |
1116 | rtnl_unlock(); | ||
1113 | return sprintf(buf, "%s\n", info.driver); | 1117 | return sprintf(buf, "%s\n", info.driver); |
1114 | } | 1118 | } |
1115 | 1119 | ||
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c index eebc72465fc9..72c63e5dd630 100644 --- a/drivers/input/ff-core.c +++ b/drivers/input/ff-core.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/input.h> | 28 | #include <linux/input.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/sched.h> | ||
31 | 32 | ||
32 | /* | 33 | /* |
33 | * Check that the effect_id is a valid effect and whether the user | 34 | * Check that the effect_id is a valid effect and whether the user |
@@ -166,8 +167,10 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, | |||
166 | if (ret) | 167 | if (ret) |
167 | goto out; | 168 | goto out; |
168 | 169 | ||
170 | spin_lock_irq(&dev->event_lock); | ||
169 | ff->effects[id] = *effect; | 171 | ff->effects[id] = *effect; |
170 | ff->effect_owners[id] = file; | 172 | ff->effect_owners[id] = file; |
173 | spin_unlock_irq(&dev->event_lock); | ||
171 | 174 | ||
172 | out: | 175 | out: |
173 | mutex_unlock(&ff->mutex); | 176 | mutex_unlock(&ff->mutex); |
@@ -189,16 +192,22 @@ static int erase_effect(struct input_dev *dev, int effect_id, | |||
189 | if (error) | 192 | if (error) |
190 | return error; | 193 | return error; |
191 | 194 | ||
195 | spin_lock_irq(&dev->event_lock); | ||
192 | ff->playback(dev, effect_id, 0); | 196 | ff->playback(dev, effect_id, 0); |
197 | ff->effect_owners[effect_id] = NULL; | ||
198 | spin_unlock_irq(&dev->event_lock); | ||
193 | 199 | ||
194 | if (ff->erase) { | 200 | if (ff->erase) { |
195 | error = ff->erase(dev, effect_id); | 201 | error = ff->erase(dev, effect_id); |
196 | if (error) | 202 | if (error) { |
203 | spin_lock_irq(&dev->event_lock); | ||
204 | ff->effect_owners[effect_id] = file; | ||
205 | spin_unlock_irq(&dev->event_lock); | ||
206 | |||
197 | return error; | 207 | return error; |
208 | } | ||
198 | } | 209 | } |
199 | 210 | ||
200 | ff->effect_owners[effect_id] = NULL; | ||
201 | |||
202 | return 0; | 211 | return 0; |
203 | } | 212 | } |
204 | 213 | ||
@@ -263,8 +272,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type, | |||
263 | if (type != EV_FF) | 272 | if (type != EV_FF) |
264 | return 0; | 273 | return 0; |
265 | 274 | ||
266 | mutex_lock(&ff->mutex); | ||
267 | |||
268 | switch (code) { | 275 | switch (code) { |
269 | case FF_GAIN: | 276 | case FF_GAIN: |
270 | if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) | 277 | if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) |
@@ -286,7 +293,6 @@ int input_ff_event(struct input_dev *dev, unsigned int type, | |||
286 | break; | 293 | break; |
287 | } | 294 | } |
288 | 295 | ||
289 | mutex_unlock(&ff->mutex); | ||
290 | return 0; | 296 | return 0; |
291 | } | 297 | } |
292 | EXPORT_SYMBOL_GPL(input_ff_event); | 298 | EXPORT_SYMBOL_GPL(input_ff_event); |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 835def11419d..ab6a61db63ce 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -432,6 +432,7 @@ static int crypt_convert(struct crypt_config *cc, | |||
432 | case 0: | 432 | case 0: |
433 | atomic_dec(&ctx->pending); | 433 | atomic_dec(&ctx->pending); |
434 | ctx->sector++; | 434 | ctx->sector++; |
435 | cond_resched(); | ||
435 | continue; | 436 | continue; |
436 | 437 | ||
437 | /* error */ | 438 | /* error */ |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 7cf512a34ccf..2580ac1b9b0f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3897,8 +3897,10 @@ static void autorun_devices(int part) | |||
3897 | 3897 | ||
3898 | md_probe(dev, NULL, NULL); | 3898 | md_probe(dev, NULL, NULL); |
3899 | mddev = mddev_find(dev); | 3899 | mddev = mddev_find(dev); |
3900 | if (!mddev) { | 3900 | if (!mddev || !mddev->gendisk) { |
3901 | printk(KERN_ERR | 3901 | if (mddev) |
3902 | mddev_put(mddev); | ||
3903 | printk(KERN_ERR | ||
3902 | "md: cannot allocate memory for md drive.\n"); | 3904 | "md: cannot allocate memory for md drive.\n"); |
3903 | break; | 3905 | break; |
3904 | } | 3906 | } |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1de17da34a95..a71277b640ab 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -2137,6 +2137,8 @@ static int run(mddev_t *mddev) | |||
2137 | !test_bit(In_sync, &disk->rdev->flags)) { | 2137 | !test_bit(In_sync, &disk->rdev->flags)) { |
2138 | disk->head_position = 0; | 2138 | disk->head_position = 0; |
2139 | mddev->degraded++; | 2139 | mddev->degraded++; |
2140 | if (disk->rdev) | ||
2141 | conf->fullsync = 1; | ||
2140 | } | 2142 | } |
2141 | } | 2143 | } |
2142 | 2144 | ||
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c37e256b1176..3b27df52456b 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -2017,12 +2017,7 @@ static int __handle_issuing_new_read_requests5(struct stripe_head *sh, | |||
2017 | */ | 2017 | */ |
2018 | s->uptodate++; | 2018 | s->uptodate++; |
2019 | return 0; /* uptodate + compute == disks */ | 2019 | return 0; /* uptodate + compute == disks */ |
2020 | } else if ((s->uptodate < disks - 1) && | 2020 | } else if (test_bit(R5_Insync, &dev->flags)) { |
2021 | test_bit(R5_Insync, &dev->flags)) { | ||
2022 | /* Note: we hold off compute operations while checks are | ||
2023 | * in flight, but we still prefer 'compute' over 'read' | ||
2024 | * hence we only read if (uptodate < * disks-1) | ||
2025 | */ | ||
2026 | set_bit(R5_LOCKED, &dev->flags); | 2021 | set_bit(R5_LOCKED, &dev->flags); |
2027 | set_bit(R5_Wantread, &dev->flags); | 2022 | set_bit(R5_Wantread, &dev->flags); |
2028 | if (!test_and_set_bit(STRIPE_OP_IO, &sh->ops.pending)) | 2023 | if (!test_and_set_bit(STRIPE_OP_IO, &sh->ops.pending)) |
@@ -2898,6 +2893,8 @@ static void handle_stripe5(struct stripe_head *sh) | |||
2898 | 2893 | ||
2899 | for (i = conf->raid_disks; i--; ) { | 2894 | for (i = conf->raid_disks; i--; ) { |
2900 | set_bit(R5_Wantwrite, &sh->dev[i].flags); | 2895 | set_bit(R5_Wantwrite, &sh->dev[i].flags); |
2896 | set_bit(R5_LOCKED, &dev->flags); | ||
2897 | s.locked++; | ||
2901 | if (!test_and_set_bit(STRIPE_OP_IO, &sh->ops.pending)) | 2898 | if (!test_and_set_bit(STRIPE_OP_IO, &sh->ops.pending)) |
2902 | sh->ops.count++; | 2899 | sh->ops.count++; |
2903 | } | 2900 | } |
@@ -2911,6 +2908,7 @@ static void handle_stripe5(struct stripe_head *sh) | |||
2911 | conf->raid_disks); | 2908 | conf->raid_disks); |
2912 | s.locked += handle_write_operations5(sh, 1, 1); | 2909 | s.locked += handle_write_operations5(sh, 1, 1); |
2913 | } else if (s.expanded && | 2910 | } else if (s.expanded && |
2911 | s.locked == 0 && | ||
2914 | !test_bit(STRIPE_OP_POSTXOR, &sh->ops.pending)) { | 2912 | !test_bit(STRIPE_OP_POSTXOR, &sh->ops.pending)) { |
2915 | clear_bit(STRIPE_EXPAND_READY, &sh->state); | 2913 | clear_bit(STRIPE_EXPAND_READY, &sh->state); |
2916 | atomic_dec(&conf->reshape_stripes); | 2914 | atomic_dec(&conf->reshape_stripes); |
@@ -4305,7 +4303,9 @@ static int run(mddev_t *mddev) | |||
4305 | " disk %d\n", bdevname(rdev->bdev,b), | 4303 | " disk %d\n", bdevname(rdev->bdev,b), |
4306 | raid_disk); | 4304 | raid_disk); |
4307 | working_disks++; | 4305 | working_disks++; |
4308 | } | 4306 | } else |
4307 | /* Cannot rely on bitmap to complete recovery */ | ||
4308 | conf->fullsync = 1; | ||
4309 | } | 4309 | } |
4310 | 4310 | ||
4311 | /* | 4311 | /* |
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c index a3485817e46c..8fa91f846d59 100644 --- a/drivers/media/common/ir-keymaps.c +++ b/drivers/media/common/ir-keymaps.c | |||
@@ -2201,3 +2201,41 @@ IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE] = { | |||
2201 | [0x25] = KEY_POWER, /* power */ | 2201 | [0x25] = KEY_POWER, /* power */ |
2202 | }; | 2202 | }; |
2203 | EXPORT_SYMBOL_GPL(ir_codes_powercolor_real_angel); | 2203 | EXPORT_SYMBOL_GPL(ir_codes_powercolor_real_angel); |
2204 | |||
2205 | IR_KEYTAB_TYPE ir_codes_avermedia_a16d[IR_KEYTAB_SIZE] = { | ||
2206 | [0x20] = KEY_LIST, | ||
2207 | [0x00] = KEY_POWER, | ||
2208 | [0x28] = KEY_1, | ||
2209 | [0x18] = KEY_2, | ||
2210 | [0x38] = KEY_3, | ||
2211 | [0x24] = KEY_4, | ||
2212 | [0x14] = KEY_5, | ||
2213 | [0x34] = KEY_6, | ||
2214 | [0x2c] = KEY_7, | ||
2215 | [0x1c] = KEY_8, | ||
2216 | [0x3c] = KEY_9, | ||
2217 | [0x12] = KEY_SUBTITLE, | ||
2218 | [0x22] = KEY_0, | ||
2219 | [0x32] = KEY_REWIND, | ||
2220 | [0x3a] = KEY_SHUFFLE, | ||
2221 | [0x02] = KEY_PRINT, | ||
2222 | [0x11] = KEY_CHANNELDOWN, | ||
2223 | [0x31] = KEY_CHANNELUP, | ||
2224 | [0x0c] = KEY_ZOOM, | ||
2225 | [0x1e] = KEY_VOLUMEDOWN, | ||
2226 | [0x3e] = KEY_VOLUMEUP, | ||
2227 | [0x0a] = KEY_MUTE, | ||
2228 | [0x04] = KEY_AUDIO, | ||
2229 | [0x26] = KEY_RECORD, | ||
2230 | [0x06] = KEY_PLAY, | ||
2231 | [0x36] = KEY_STOP, | ||
2232 | [0x16] = KEY_PAUSE, | ||
2233 | [0x2e] = KEY_REWIND, | ||
2234 | [0x0e] = KEY_FASTFORWARD, | ||
2235 | [0x30] = KEY_TEXT, | ||
2236 | [0x21] = KEY_GREEN, | ||
2237 | [0x01] = KEY_BLUE, | ||
2238 | [0x08] = KEY_EPG, | ||
2239 | [0x2a] = KEY_MENU, | ||
2240 | }; | ||
2241 | EXPORT_SYMBOL_GPL(ir_codes_avermedia_a16d); | ||
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c index f1894fec32b9..6fb5b4586569 100644 --- a/drivers/media/common/tuners/tda18271-common.c +++ b/drivers/media/common/tuners/tda18271-common.c | |||
@@ -649,9 +649,17 @@ int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq) | |||
649 | u8 val; | 649 | u8 val; |
650 | 650 | ||
651 | int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val); | 651 | int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val); |
652 | /* The TDA18271HD/C1 rf_cal map lookup is expected to go out of range | ||
653 | * for frequencies above 61.1 MHz. In these cases, the internal RF | ||
654 | * tracking filters calibration mechanism is used. | ||
655 | * | ||
656 | * There is no need to warn the user about this. | ||
657 | */ | ||
658 | if (ret < 0) | ||
659 | goto fail; | ||
652 | 660 | ||
653 | regs[R_EB14] = val; | 661 | regs[R_EB14] = val; |
654 | 662 | fail: | |
655 | return ret; | 663 | return ret; |
656 | } | 664 | } |
657 | 665 | ||
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index 89c01fb1f859..93063c6fbbf6 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -45,6 +45,21 @@ static inline int charge_pump_source(struct dvb_frontend *fe, int force) | |||
45 | TDA18271_MAIN_PLL, force); | 45 | TDA18271_MAIN_PLL, force); |
46 | } | 46 | } |
47 | 47 | ||
48 | static inline void tda18271_set_if_notch(struct dvb_frontend *fe) | ||
49 | { | ||
50 | struct tda18271_priv *priv = fe->tuner_priv; | ||
51 | unsigned char *regs = priv->tda18271_regs; | ||
52 | |||
53 | switch (priv->mode) { | ||
54 | case TDA18271_ANALOG: | ||
55 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ | ||
56 | break; | ||
57 | case TDA18271_DIGITAL: | ||
58 | regs[R_MPD] |= 0x80; /* IF notch = 1 */ | ||
59 | break; | ||
60 | } | ||
61 | } | ||
62 | |||
48 | static int tda18271_channel_configuration(struct dvb_frontend *fe, | 63 | static int tda18271_channel_configuration(struct dvb_frontend *fe, |
49 | struct tda18271_std_map_item *map, | 64 | struct tda18271_std_map_item *map, |
50 | u32 freq, u32 bw) | 65 | u32 freq, u32 bw) |
@@ -60,25 +75,18 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
60 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | 75 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
61 | regs[R_EP3] |= (map->agc_mode << 3) | map->std; | 76 | regs[R_EP3] |= (map->agc_mode << 3) | map->std; |
62 | 77 | ||
63 | /* set rfagc to high speed mode */ | 78 | if (priv->id == TDA18271HDC2) { |
64 | regs[R_EP3] &= ~0x04; | 79 | /* set rfagc to high speed mode */ |
80 | regs[R_EP3] &= ~0x04; | ||
81 | } | ||
65 | 82 | ||
66 | /* set cal mode to normal */ | 83 | /* set cal mode to normal */ |
67 | regs[R_EP4] &= ~0x03; | 84 | regs[R_EP4] &= ~0x03; |
68 | 85 | ||
69 | /* update IF output level & IF notch frequency */ | 86 | /* update IF output level */ |
70 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 87 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
71 | regs[R_EP4] |= (map->if_lvl << 2); | 88 | regs[R_EP4] |= (map->if_lvl << 2); |
72 | 89 | ||
73 | switch (priv->mode) { | ||
74 | case TDA18271_ANALOG: | ||
75 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ | ||
76 | break; | ||
77 | case TDA18271_DIGITAL: | ||
78 | regs[R_MPD] |= 0x80; /* IF notch = 1 */ | ||
79 | break; | ||
80 | } | ||
81 | |||
82 | /* update FM_RFn */ | 90 | /* update FM_RFn */ |
83 | regs[R_EP4] &= ~0x80; | 91 | regs[R_EP4] &= ~0x80; |
84 | regs[R_EP4] |= map->fm_rfn << 7; | 92 | regs[R_EP4] |= map->fm_rfn << 7; |
@@ -95,6 +103,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
95 | /* disable Power Level Indicator */ | 103 | /* disable Power Level Indicator */ |
96 | regs[R_EP1] |= 0x40; | 104 | regs[R_EP1] |= 0x40; |
97 | 105 | ||
106 | /* make sure thermometer is off */ | ||
107 | regs[R_TM] &= ~0x10; | ||
108 | |||
98 | /* frequency dependent parameters */ | 109 | /* frequency dependent parameters */ |
99 | 110 | ||
100 | tda18271_calc_ir_measure(fe, &freq); | 111 | tda18271_calc_ir_measure(fe, &freq); |
@@ -135,6 +146,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
135 | switch (priv->role) { | 146 | switch (priv->role) { |
136 | case TDA18271_MASTER: | 147 | case TDA18271_MASTER: |
137 | tda18271_calc_main_pll(fe, N); | 148 | tda18271_calc_main_pll(fe, N); |
149 | tda18271_set_if_notch(fe); | ||
138 | tda18271_write_regs(fe, R_MPD, 4); | 150 | tda18271_write_regs(fe, R_MPD, 4); |
139 | break; | 151 | break; |
140 | case TDA18271_SLAVE: | 152 | case TDA18271_SLAVE: |
@@ -142,6 +154,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
142 | tda18271_write_regs(fe, R_CPD, 4); | 154 | tda18271_write_regs(fe, R_CPD, 4); |
143 | 155 | ||
144 | regs[R_MPD] = regs[R_CPD] & 0x7f; | 156 | regs[R_MPD] = regs[R_CPD] & 0x7f; |
157 | tda18271_set_if_notch(fe); | ||
145 | tda18271_write_regs(fe, R_MPD, 1); | 158 | tda18271_write_regs(fe, R_MPD, 1); |
146 | break; | 159 | break; |
147 | } | 160 | } |
@@ -160,12 +173,14 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
160 | 173 | ||
161 | msleep(20); | 174 | msleep(20); |
162 | 175 | ||
163 | /* set rfagc to normal speed mode */ | 176 | if (priv->id == TDA18271HDC2) { |
164 | if (map->fm_rfn) | 177 | /* set rfagc to normal speed mode */ |
165 | regs[R_EP3] &= ~0x04; | 178 | if (map->fm_rfn) |
166 | else | 179 | regs[R_EP3] &= ~0x04; |
167 | regs[R_EP3] |= 0x04; | 180 | else |
168 | ret = tda18271_write_regs(fe, R_EP3, 1); | 181 | regs[R_EP3] |= 0x04; |
182 | ret = tda18271_write_regs(fe, R_EP3, 1); | ||
183 | } | ||
169 | fail: | 184 | fail: |
170 | return ret; | 185 | return ret; |
171 | } | 186 | } |
@@ -507,7 +522,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
507 | /* set cal mode to normal */ | 522 | /* set cal mode to normal */ |
508 | regs[R_EP4] &= ~0x03; | 523 | regs[R_EP4] &= ~0x03; |
509 | 524 | ||
510 | /* update IF output level & IF notch frequency */ | 525 | /* update IF output level */ |
511 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 526 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
512 | 527 | ||
513 | ret = tda18271_write_regs(fe, R_EP3, 2); | 528 | ret = tda18271_write_regs(fe, R_EP3, 2); |
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index ceae6db901ec..7cf4f5bdb2ec 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -177,6 +177,7 @@ static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { | |||
177 | {"FM Radio-INPUT1", 0x0208, 0x9002} | 177 | {"FM Radio-INPUT1", 0x0208, 0x9002} |
178 | }; | 178 | }; |
179 | 179 | ||
180 | static int xc5000_is_firmware_loaded(struct dvb_frontend *fe); | ||
180 | static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len); | 181 | static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len); |
181 | static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); | 182 | static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); |
182 | static void xc5000_TunerReset(struct dvb_frontend *fe); | 183 | static void xc5000_TunerReset(struct dvb_frontend *fe); |
@@ -352,7 +353,7 @@ static int xc_SetTVStandard(struct xc5000_priv *priv, | |||
352 | 353 | ||
353 | static int xc_shutdown(struct xc5000_priv *priv) | 354 | static int xc_shutdown(struct xc5000_priv *priv) |
354 | { | 355 | { |
355 | return 0; | 356 | return XC_RESULT_SUCCESS; |
356 | /* Fixme: cannot bring tuner back alive once shutdown | 357 | /* Fixme: cannot bring tuner back alive once shutdown |
357 | * without reloading the driver modules. | 358 | * without reloading the driver modules. |
358 | * return xc_write_reg(priv, XREG_POWER_DOWN, 0); | 359 | * return xc_write_reg(priv, XREG_POWER_DOWN, 0); |
@@ -685,6 +686,25 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
685 | return 0; | 686 | return 0; |
686 | } | 687 | } |
687 | 688 | ||
689 | static int xc5000_is_firmware_loaded(struct dvb_frontend *fe) | ||
690 | { | ||
691 | struct xc5000_priv *priv = fe->tuner_priv; | ||
692 | int ret; | ||
693 | u16 id; | ||
694 | |||
695 | ret = xc5000_readreg(priv, XREG_PRODUCT_ID, &id); | ||
696 | if (ret == XC_RESULT_SUCCESS) { | ||
697 | if (id == XC_PRODUCT_ID_FW_NOT_LOADED) | ||
698 | ret = XC_RESULT_RESET_FAILURE; | ||
699 | else | ||
700 | ret = XC_RESULT_SUCCESS; | ||
701 | } | ||
702 | |||
703 | dprintk(1, "%s() returns %s id = 0x%x\n", __func__, | ||
704 | ret == XC_RESULT_SUCCESS ? "True" : "False", id); | ||
705 | return ret; | ||
706 | } | ||
707 | |||
688 | static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe); | 708 | static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe); |
689 | 709 | ||
690 | static int xc5000_set_analog_params(struct dvb_frontend *fe, | 710 | static int xc5000_set_analog_params(struct dvb_frontend *fe, |
@@ -693,7 +713,7 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe, | |||
693 | struct xc5000_priv *priv = fe->tuner_priv; | 713 | struct xc5000_priv *priv = fe->tuner_priv; |
694 | int ret; | 714 | int ret; |
695 | 715 | ||
696 | if(priv->fwloaded == 0) | 716 | if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) |
697 | xc_load_fw_and_init_tuner(fe); | 717 | xc_load_fw_and_init_tuner(fe); |
698 | 718 | ||
699 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", | 719 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", |
@@ -808,11 +828,10 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) | |||
808 | struct xc5000_priv *priv = fe->tuner_priv; | 828 | struct xc5000_priv *priv = fe->tuner_priv; |
809 | int ret = 0; | 829 | int ret = 0; |
810 | 830 | ||
811 | if (priv->fwloaded == 0) { | 831 | if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { |
812 | ret = xc5000_fwupload(fe); | 832 | ret = xc5000_fwupload(fe); |
813 | if (ret != XC_RESULT_SUCCESS) | 833 | if (ret != XC_RESULT_SUCCESS) |
814 | return ret; | 834 | return ret; |
815 | priv->fwloaded = 1; | ||
816 | } | 835 | } |
817 | 836 | ||
818 | /* Start the tuner self-calibration process */ | 837 | /* Start the tuner self-calibration process */ |
@@ -852,7 +871,6 @@ static int xc5000_sleep(struct dvb_frontend *fe) | |||
852 | return -EREMOTEIO; | 871 | return -EREMOTEIO; |
853 | } | 872 | } |
854 | else { | 873 | else { |
855 | /* priv->fwloaded = 0; */ | ||
856 | return XC_RESULT_SUCCESS; | 874 | return XC_RESULT_SUCCESS; |
857 | } | 875 | } |
858 | } | 876 | } |
@@ -933,7 +951,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
933 | cfg->i2c_address); | 951 | cfg->i2c_address); |
934 | printk(KERN_INFO | 952 | printk(KERN_INFO |
935 | "xc5000: Firmware has been loaded previously\n"); | 953 | "xc5000: Firmware has been loaded previously\n"); |
936 | priv->fwloaded = 1; | ||
937 | break; | 954 | break; |
938 | case XC_PRODUCT_ID_FW_NOT_LOADED: | 955 | case XC_PRODUCT_ID_FW_NOT_LOADED: |
939 | printk(KERN_INFO | 956 | printk(KERN_INFO |
@@ -941,7 +958,6 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
941 | cfg->i2c_address); | 958 | cfg->i2c_address); |
942 | printk(KERN_INFO | 959 | printk(KERN_INFO |
943 | "xc5000: Firmware has not been loaded previously\n"); | 960 | "xc5000: Firmware has not been loaded previously\n"); |
944 | priv->fwloaded = 0; | ||
945 | break; | 961 | break; |
946 | default: | 962 | default: |
947 | printk(KERN_ERR | 963 | printk(KERN_ERR |
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h index ecebfe4745ad..a72a9887fe7f 100644 --- a/drivers/media/common/tuners/xc5000_priv.h +++ b/drivers/media/common/tuners/xc5000_priv.h | |||
@@ -30,7 +30,6 @@ struct xc5000_priv { | |||
30 | u32 bandwidth; | 30 | u32 bandwidth; |
31 | u8 video_standard; | 31 | u8 video_standard; |
32 | u8 rf_mode; | 32 | u8 rf_mode; |
33 | u8 fwloaded; | ||
34 | 33 | ||
35 | void *devptr; | 34 | void *devptr; |
36 | }; | 35 | }; |
diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index 0a8ac64a4e33..037f7ffb47b2 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c | |||
@@ -47,6 +47,8 @@ static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, | |||
47 | return -EINVAL; | 47 | return -EINVAL; |
48 | } | 48 | } |
49 | 49 | ||
50 | msleep(1); /* avoid I2C errors */ | ||
51 | |||
50 | return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), req, type, | 52 | return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), req, type, |
51 | value, index, rbuf, rlen, 2000); | 53 | value, index, rbuf, rlen, 2000); |
52 | } | 54 | } |
@@ -92,16 +94,6 @@ static struct i2c_algorithm gl861_i2c_algo = { | |||
92 | }; | 94 | }; |
93 | 95 | ||
94 | /* Callbacks for DVB USB */ | 96 | /* Callbacks for DVB USB */ |
95 | static int gl861_identify_state(struct usb_device *udev, | ||
96 | struct dvb_usb_device_properties *props, | ||
97 | struct dvb_usb_device_description **desc, | ||
98 | int *cold) | ||
99 | { | ||
100 | *cold = 0; | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static struct zl10353_config gl861_zl10353_config = { | 97 | static struct zl10353_config gl861_zl10353_config = { |
106 | .demod_address = 0x0f, | 98 | .demod_address = 0x0f, |
107 | .no_tuner = 1, | 99 | .no_tuner = 1, |
@@ -172,7 +164,6 @@ static struct dvb_usb_device_properties gl861_properties = { | |||
172 | 164 | ||
173 | .size_of_priv = 0, | 165 | .size_of_priv = 0, |
174 | 166 | ||
175 | .identify_state = gl861_identify_state, | ||
176 | .num_adapters = 1, | 167 | .num_adapters = 1, |
177 | .adapter = {{ | 168 | .adapter = {{ |
178 | 169 | ||
@@ -194,13 +185,15 @@ static struct dvb_usb_device_properties gl861_properties = { | |||
194 | 185 | ||
195 | .num_device_descs = 2, | 186 | .num_device_descs = 2, |
196 | .devices = { | 187 | .devices = { |
197 | { "MSI Mega Sky 55801 DVB-T USB2.0", | 188 | { |
198 | { &gl861_table[0], NULL }, | 189 | .name = "MSI Mega Sky 55801 DVB-T USB2.0", |
199 | { NULL }, | 190 | .cold_ids = { NULL }, |
191 | .warm_ids = { &gl861_table[0], NULL }, | ||
200 | }, | 192 | }, |
201 | { "A-LINK DTU DVB-T USB2.0", | 193 | { |
202 | { &gl861_table[1], NULL }, | 194 | .name = "A-LINK DTU DVB-T USB2.0", |
203 | { NULL }, | 195 | .cold_ids = { NULL }, |
196 | .warm_ids = { &gl861_table[1], NULL }, | ||
204 | }, | 197 | }, |
205 | } | 198 | } |
206 | }; | 199 | }; |
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 9e7653bb3b66..118aab1a3e54 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c | |||
@@ -107,7 +107,7 @@ static struct dvb_usb_device_properties umt_properties = { | |||
107 | /* parameter for the MPEG2-data transfer */ | 107 | /* parameter for the MPEG2-data transfer */ |
108 | .stream = { | 108 | .stream = { |
109 | .type = USB_BULK, | 109 | .type = USB_BULK, |
110 | .count = 20, | 110 | .count = MAX_NO_URBS_FOR_DATA_STREAM, |
111 | .endpoint = 0x06, | 111 | .endpoint = 0x06, |
112 | .u = { | 112 | .u = { |
113 | .bulk = { | 113 | .bulk = { |
diff --git a/drivers/media/dvb/frontends/au8522.c b/drivers/media/dvb/frontends/au8522.c index 084a280c2d7f..03900d241a76 100644 --- a/drivers/media/dvb/frontends/au8522.c +++ b/drivers/media/dvb/frontends/au8522.c | |||
@@ -463,10 +463,13 @@ static int au8522_set_frontend(struct dvb_frontend *fe, | |||
463 | struct dvb_frontend_parameters *p) | 463 | struct dvb_frontend_parameters *p) |
464 | { | 464 | { |
465 | struct au8522_state *state = fe->demodulator_priv; | 465 | struct au8522_state *state = fe->demodulator_priv; |
466 | int ret = -EINVAL; | ||
466 | 467 | ||
467 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); | 468 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); |
468 | 469 | ||
469 | state->current_frequency = p->frequency; | 470 | if ((state->current_frequency == p->frequency) && |
471 | (state->current_modulation == p->u.vsb.modulation)) | ||
472 | return 0; | ||
470 | 473 | ||
471 | au8522_enable_modulation(fe, p->u.vsb.modulation); | 474 | au8522_enable_modulation(fe, p->u.vsb.modulation); |
472 | 475 | ||
@@ -476,11 +479,16 @@ static int au8522_set_frontend(struct dvb_frontend *fe, | |||
476 | if (fe->ops.tuner_ops.set_params) { | 479 | if (fe->ops.tuner_ops.set_params) { |
477 | if (fe->ops.i2c_gate_ctrl) | 480 | if (fe->ops.i2c_gate_ctrl) |
478 | fe->ops.i2c_gate_ctrl(fe, 1); | 481 | fe->ops.i2c_gate_ctrl(fe, 1); |
479 | fe->ops.tuner_ops.set_params(fe, p); | 482 | ret = fe->ops.tuner_ops.set_params(fe, p); |
480 | if (fe->ops.i2c_gate_ctrl) | 483 | if (fe->ops.i2c_gate_ctrl) |
481 | fe->ops.i2c_gate_ctrl(fe, 0); | 484 | fe->ops.i2c_gate_ctrl(fe, 0); |
482 | } | 485 | } |
483 | 486 | ||
487 | if (ret < 0) | ||
488 | return ret; | ||
489 | |||
490 | state->current_frequency = p->frequency; | ||
491 | |||
484 | return 0; | 492 | return 0; |
485 | } | 493 | } |
486 | 494 | ||
@@ -498,6 +506,16 @@ static int au8522_init(struct dvb_frontend *fe) | |||
498 | return 0; | 506 | return 0; |
499 | } | 507 | } |
500 | 508 | ||
509 | static int au8522_sleep(struct dvb_frontend *fe) | ||
510 | { | ||
511 | struct au8522_state *state = fe->demodulator_priv; | ||
512 | dprintk("%s()\n", __func__); | ||
513 | |||
514 | state->current_frequency = 0; | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
501 | static int au8522_read_status(struct dvb_frontend *fe, fe_status_t *status) | 519 | static int au8522_read_status(struct dvb_frontend *fe, fe_status_t *status) |
502 | { | 520 | { |
503 | struct au8522_state *state = fe->demodulator_priv; | 521 | struct au8522_state *state = fe->demodulator_priv; |
@@ -509,10 +527,8 @@ static int au8522_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
509 | if (state->current_modulation == VSB_8) { | 527 | if (state->current_modulation == VSB_8) { |
510 | dprintk("%s() Checking VSB_8\n", __func__); | 528 | dprintk("%s() Checking VSB_8\n", __func__); |
511 | reg = au8522_readreg(state, 0x4088); | 529 | reg = au8522_readreg(state, 0x4088); |
512 | if (reg & 0x01) | 530 | if ((reg & 0x03) == 0x03) |
513 | *status |= FE_HAS_VITERBI; | 531 | *status |= FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI; |
514 | if (reg & 0x02) | ||
515 | *status |= FE_HAS_LOCK | FE_HAS_SYNC; | ||
516 | } else { | 532 | } else { |
517 | dprintk("%s() Checking QAM\n", __func__); | 533 | dprintk("%s() Checking QAM\n", __func__); |
518 | reg = au8522_readreg(state, 0x4541); | 534 | reg = au8522_readreg(state, 0x4541); |
@@ -672,6 +688,7 @@ static struct dvb_frontend_ops au8522_ops = { | |||
672 | }, | 688 | }, |
673 | 689 | ||
674 | .init = au8522_init, | 690 | .init = au8522_init, |
691 | .sleep = au8522_sleep, | ||
675 | .i2c_gate_ctrl = au8522_i2c_gate_ctrl, | 692 | .i2c_gate_ctrl = au8522_i2c_gate_ctrl, |
676 | .set_frontend = au8522_set_frontend, | 693 | .set_frontend = au8522_set_frontend, |
677 | .get_frontend = au8522_get_frontend, | 694 | .get_frontend = au8522_get_frontend, |
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index 17556183e871..35435bef8e79 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c | |||
@@ -63,6 +63,7 @@ struct stv0299_state { | |||
63 | u32 symbol_rate; | 63 | u32 symbol_rate; |
64 | fe_code_rate_t fec_inner; | 64 | fe_code_rate_t fec_inner; |
65 | int errmode; | 65 | int errmode; |
66 | u32 ucblocks; | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | #define STATUS_BER 0 | 69 | #define STATUS_BER 0 |
@@ -501,8 +502,10 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) | |||
501 | { | 502 | { |
502 | struct stv0299_state* state = fe->demodulator_priv; | 503 | struct stv0299_state* state = fe->demodulator_priv; |
503 | 504 | ||
504 | if (state->errmode != STATUS_BER) return 0; | 505 | if (state->errmode != STATUS_BER) |
505 | *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); | 506 | return -ENOSYS; |
507 | |||
508 | *ber = stv0299_readreg(state, 0x1e) | (stv0299_readreg(state, 0x1d) << 8); | ||
506 | 509 | ||
507 | return 0; | 510 | return 0; |
508 | } | 511 | } |
@@ -540,8 +543,12 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
540 | { | 543 | { |
541 | struct stv0299_state* state = fe->demodulator_priv; | 544 | struct stv0299_state* state = fe->demodulator_priv; |
542 | 545 | ||
543 | if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; | 546 | if (state->errmode != STATUS_UCBLOCKS) |
544 | else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); | 547 | return -ENOSYS; |
548 | |||
549 | state->ucblocks += stv0299_readreg(state, 0x1e); | ||
550 | state->ucblocks += (stv0299_readreg(state, 0x1d) << 8); | ||
551 | *ucblocks = state->ucblocks; | ||
545 | 552 | ||
546 | return 0; | 553 | return 0; |
547 | } | 554 | } |
diff --git a/drivers/media/dvb/frontends/tda10023.c b/drivers/media/dvb/frontends/tda10023.c index 0727b80bc4d2..c6ff5b82ff80 100644 --- a/drivers/media/dvb/frontends/tda10023.c +++ b/drivers/media/dvb/frontends/tda10023.c | |||
@@ -116,9 +116,12 @@ static u8 tda10023_readreg (struct tda10023_state* state, u8 reg) | |||
116 | int ret; | 116 | int ret; |
117 | 117 | ||
118 | ret = i2c_transfer (state->i2c, msg, 2); | 118 | ret = i2c_transfer (state->i2c, msg, 2); |
119 | if (ret != 2) | 119 | if (ret != 2) { |
120 | printk("DVB: TDA10023: %s: readreg error (ret == %i)\n", | 120 | int num = state->frontend.dvb ? state->frontend.dvb->num : -1; |
121 | __func__, ret); | 121 | printk(KERN_ERR "DVB: TDA10023(%d): %s: readreg error " |
122 | "(reg == 0x%02x, ret == %i)\n", | ||
123 | num, __func__, reg, ret); | ||
124 | } | ||
122 | return b1[0]; | 125 | return b1[0]; |
123 | } | 126 | } |
124 | 127 | ||
@@ -129,11 +132,12 @@ static int tda10023_writereg (struct tda10023_state* state, u8 reg, u8 data) | |||
129 | int ret; | 132 | int ret; |
130 | 133 | ||
131 | ret = i2c_transfer (state->i2c, &msg, 1); | 134 | ret = i2c_transfer (state->i2c, &msg, 1); |
132 | if (ret != 1) | 135 | if (ret != 1) { |
133 | printk("DVB: TDA10023(%d): %s, writereg error " | 136 | int num = state->frontend.dvb ? state->frontend.dvb->num : -1; |
137 | printk(KERN_ERR "DVB: TDA10023(%d): %s, writereg error " | ||
134 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 138 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", |
135 | state->frontend.dvb->num, __func__, reg, data, ret); | 139 | num, __func__, reg, data, ret); |
136 | 140 | } | |
137 | return (ret != 1) ? -EREMOTEIO : 0; | 141 | return (ret != 1) ? -EREMOTEIO : 0; |
138 | } | 142 | } |
139 | 143 | ||
@@ -464,7 +468,7 @@ struct dvb_frontend* tda10023_attach(const struct tda1002x_config* config, | |||
464 | int i; | 468 | int i; |
465 | 469 | ||
466 | /* allocate memory for the internal state */ | 470 | /* allocate memory for the internal state */ |
467 | state = kmalloc(sizeof(struct tda10023_state), GFP_KERNEL); | 471 | state = kzalloc(sizeof(struct tda10023_state), GFP_KERNEL); |
468 | if (state == NULL) goto error; | 472 | if (state == NULL) goto error; |
469 | 473 | ||
470 | /* setup the state */ | 474 | /* setup the state */ |
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index 49973846373e..a0d638653567 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c | |||
@@ -1248,11 +1248,14 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, | |||
1248 | struct i2c_adapter* i2c) | 1248 | struct i2c_adapter* i2c) |
1249 | { | 1249 | { |
1250 | struct tda1004x_state *state; | 1250 | struct tda1004x_state *state; |
1251 | int id; | ||
1251 | 1252 | ||
1252 | /* allocate memory for the internal state */ | 1253 | /* allocate memory for the internal state */ |
1253 | state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); | 1254 | state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); |
1254 | if (!state) | 1255 | if (!state) { |
1256 | printk(KERN_ERR "Can't alocate memory for tda10045 state\n"); | ||
1255 | return NULL; | 1257 | return NULL; |
1258 | } | ||
1256 | 1259 | ||
1257 | /* setup the state */ | 1260 | /* setup the state */ |
1258 | state->config = config; | 1261 | state->config = config; |
@@ -1260,7 +1263,15 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, | |||
1260 | state->demod_type = TDA1004X_DEMOD_TDA10045; | 1263 | state->demod_type = TDA1004X_DEMOD_TDA10045; |
1261 | 1264 | ||
1262 | /* check if the demod is there */ | 1265 | /* check if the demod is there */ |
1263 | if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x25) { | 1266 | id = tda1004x_read_byte(state, TDA1004X_CHIPID); |
1267 | if (id < 0) { | ||
1268 | printk(KERN_ERR "tda10045: chip is not answering. Giving up.\n"); | ||
1269 | kfree(state); | ||
1270 | return NULL; | ||
1271 | } | ||
1272 | |||
1273 | if (id != 0x25) { | ||
1274 | printk(KERN_ERR "Invalid tda1004x ID = 0x%02x. Can't proceed\n", id); | ||
1264 | kfree(state); | 1275 | kfree(state); |
1265 | return NULL; | 1276 | return NULL; |
1266 | } | 1277 | } |
@@ -1307,11 +1318,14 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, | |||
1307 | struct i2c_adapter* i2c) | 1318 | struct i2c_adapter* i2c) |
1308 | { | 1319 | { |
1309 | struct tda1004x_state *state; | 1320 | struct tda1004x_state *state; |
1321 | int id; | ||
1310 | 1322 | ||
1311 | /* allocate memory for the internal state */ | 1323 | /* allocate memory for the internal state */ |
1312 | state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); | 1324 | state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); |
1313 | if (!state) | 1325 | if (!state) { |
1326 | printk(KERN_ERR "Can't alocate memory for tda10046 state\n"); | ||
1314 | return NULL; | 1327 | return NULL; |
1328 | } | ||
1315 | 1329 | ||
1316 | /* setup the state */ | 1330 | /* setup the state */ |
1317 | state->config = config; | 1331 | state->config = config; |
@@ -1319,7 +1333,14 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, | |||
1319 | state->demod_type = TDA1004X_DEMOD_TDA10046; | 1333 | state->demod_type = TDA1004X_DEMOD_TDA10046; |
1320 | 1334 | ||
1321 | /* check if the demod is there */ | 1335 | /* check if the demod is there */ |
1322 | if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) { | 1336 | id = tda1004x_read_byte(state, TDA1004X_CHIPID); |
1337 | if (id < 0) { | ||
1338 | printk(KERN_ERR "tda10046: chip is not answering. Giving up.\n"); | ||
1339 | kfree(state); | ||
1340 | return NULL; | ||
1341 | } | ||
1342 | if (id != 0x46) { | ||
1343 | printk(KERN_ERR "Invalid tda1004x ID = 0x%02x. Can't proceed\n", id); | ||
1323 | kfree(state); | 1344 | kfree(state); |
1324 | return NULL; | 1345 | return NULL; |
1325 | } | 1346 | } |
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig index d4339b1b3b68..07643e010093 100644 --- a/drivers/media/dvb/ttpci/Kconfig +++ b/drivers/media/dvb/ttpci/Kconfig | |||
@@ -101,6 +101,7 @@ config DVB_BUDGET | |||
101 | config DVB_BUDGET_CI | 101 | config DVB_BUDGET_CI |
102 | tristate "Budget cards with onboard CI connector" | 102 | tristate "Budget cards with onboard CI connector" |
103 | depends on DVB_BUDGET_CORE && I2C | 103 | depends on DVB_BUDGET_CORE && I2C |
104 | depends on INPUT # due to IR | ||
104 | select DVB_STV0297 if !DVB_FE_CUSTOMISE | 105 | select DVB_STV0297 if !DVB_FE_CUSTOMISE |
105 | select DVB_STV0299 if !DVB_FE_CUSTOMISE | 106 | select DVB_STV0299 if !DVB_FE_CUSTOMISE |
106 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE | 107 | select DVB_TDA1004X if !DVB_FE_CUSTOMISE |
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 9d81074b31df..3a3f5279e927 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c | |||
@@ -427,6 +427,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
427 | if (err) { | 427 | if (err) { |
428 | printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", | 428 | printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", |
429 | __func__, type); | 429 | __func__, type); |
430 | av7110->arm_errors++; | ||
430 | return -ETIMEDOUT; | 431 | return -ETIMEDOUT; |
431 | } | 432 | } |
432 | msleep(1); | 433 | msleep(1); |
@@ -853,10 +854,8 @@ static osd_raw_window_t bpp2bit[8] = { | |||
853 | 854 | ||
854 | static inline int WaitUntilBmpLoaded(struct av7110 *av7110) | 855 | static inline int WaitUntilBmpLoaded(struct av7110 *av7110) |
855 | { | 856 | { |
856 | int ret = wait_event_interruptible_timeout(av7110->bmpq, | 857 | int ret = wait_event_timeout(av7110->bmpq, |
857 | av7110->bmp_state != BMP_LOADING, 10*HZ); | 858 | av7110->bmp_state != BMP_LOADING, 10*HZ); |
858 | if (ret == -ERESTARTSYS) | ||
859 | return ret; | ||
860 | if (ret == 0) { | 859 | if (ret == 0) { |
861 | printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n", | 860 | printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n", |
862 | ret, av7110->bmp_state); | 861 | ret, av7110->bmp_state); |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 3b26fbd3e558..5ccb0aeca8cc 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -793,6 +793,14 @@ menuconfig V4L_USB_DRIVERS | |||
793 | 793 | ||
794 | if V4L_USB_DRIVERS && USB | 794 | if V4L_USB_DRIVERS && USB |
795 | 795 | ||
796 | config USB_VIDEO_CLASS | ||
797 | tristate "USB Video Class (UVC)" | ||
798 | ---help--- | ||
799 | Support for the USB Video Class (UVC). Currently only video | ||
800 | input devices, such as webcams, are supported. | ||
801 | |||
802 | For more information see: <http://linux-uvc.berlios.de/> | ||
803 | |||
796 | source "drivers/media/video/pvrusb2/Kconfig" | 804 | source "drivers/media/video/pvrusb2/Kconfig" |
797 | 805 | ||
798 | source "drivers/media/video/em28xx/Kconfig" | 806 | source "drivers/media/video/em28xx/Kconfig" |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index dff0d6abe917..ecbbfaab24d5 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -136,6 +136,8 @@ obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o | |||
136 | 136 | ||
137 | obj-$(CONFIG_VIDEO_AU0828) += au0828/ | 137 | obj-$(CONFIG_VIDEO_AU0828) += au0828/ |
138 | 138 | ||
139 | obj-$(CONFIG_USB_VIDEO_CLASS) += uvc/ | ||
140 | |||
139 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 141 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
140 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | 142 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends |
141 | EXTRA_CFLAGS += -Idrivers/media/common/tuners | 143 | EXTRA_CFLAGS += -Idrivers/media/common/tuners |
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index a2a6983444fa..898e12395e7c 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c | |||
@@ -77,8 +77,14 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) | |||
77 | 77 | ||
78 | /* Make sure we support the board model */ | 78 | /* Make sure we support the board model */ |
79 | switch (tv.model) { | 79 | switch (tv.model) { |
80 | case 72000: /* WinTV-HVR950q (Retail, IR, ATSC/QAM */ | ||
80 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ | 81 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ |
82 | case 72211: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | ||
83 | case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | ||
84 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | ||
85 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ | ||
81 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ | 86 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ |
87 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ | ||
82 | break; | 88 | break; |
83 | default: | 89 | default: |
84 | printk(KERN_WARNING "%s: warning: " | 90 | printk(KERN_WARNING "%s: warning: " |
@@ -175,6 +181,18 @@ struct usb_device_id au0828_usb_id_table [] = { | |||
175 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, | 181 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, |
176 | { USB_DEVICE(0x0fe9, 0xd620), | 182 | { USB_DEVICE(0x0fe9, 0xd620), |
177 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, | 183 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, |
184 | { USB_DEVICE(0x2040, 0x7210), | ||
185 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
186 | { USB_DEVICE(0x2040, 0x7217), | ||
187 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
188 | { USB_DEVICE(0x2040, 0x721b), | ||
189 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
190 | { USB_DEVICE(0x2040, 0x721f), | ||
191 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
192 | { USB_DEVICE(0x2040, 0x7280), | ||
193 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
194 | { USB_DEVICE(0x0fd9, 0x0008), | ||
195 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
178 | { }, | 196 | { }, |
179 | }; | 197 | }; |
180 | 198 | ||
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig index 5f942690570c..9aefdc5ea79a 100644 --- a/drivers/media/video/cx18/Kconfig +++ b/drivers/media/video/cx18/Kconfig | |||
@@ -10,8 +10,8 @@ config VIDEO_CX18 | |||
10 | select VIDEO_TVEEPROM | 10 | select VIDEO_TVEEPROM |
11 | select VIDEO_CX2341X | 11 | select VIDEO_CX2341X |
12 | select VIDEO_CS5345 | 12 | select VIDEO_CS5345 |
13 | select DVB_S5H1409 | 13 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE |
14 | select MEDIA_TUNER_MXL5005S | 14 | select MEDIA_TUNER_MXL5005S if !DVB_FE_CUSTOMISE |
15 | ---help--- | 15 | ---help--- |
16 | This is a video4linux driver for Conexant cx23418 based | 16 | This is a video4linux driver for Conexant cx23418 based |
17 | PCI combo video recorder devices. | 17 | PCI combo video recorder devices. |
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c index 9a26751615c6..faca43eb940f 100644 --- a/drivers/media/video/cx18/cx18-av-core.c +++ b/drivers/media/video/cx18/cx18-av-core.c | |||
@@ -69,6 +69,58 @@ int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 and_mask, | |||
69 | or_value); | 69 | or_value); |
70 | } | 70 | } |
71 | 71 | ||
72 | int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value, int no_acfg_mask) | ||
73 | { | ||
74 | int retval; | ||
75 | u32 saved_reg[8] = {0}; | ||
76 | |||
77 | if (no_acfg_mask & CXADEC_NO_ACFG_AFE) { | ||
78 | saved_reg[0] = cx18_av_read4(cx, CXADEC_CHIP_CTRL); | ||
79 | saved_reg[1] = cx18_av_read4(cx, CXADEC_AFE_CTRL); | ||
80 | } | ||
81 | |||
82 | if (no_acfg_mask & CXADEC_NO_ACFG_PLL) { | ||
83 | saved_reg[2] = cx18_av_read4(cx, CXADEC_PLL_CTRL1); | ||
84 | saved_reg[3] = cx18_av_read4(cx, CXADEC_VID_PLL_FRAC); | ||
85 | } | ||
86 | |||
87 | if (no_acfg_mask & CXADEC_NO_ACFG_VID) { | ||
88 | saved_reg[4] = cx18_av_read4(cx, CXADEC_HORIZ_TIM_CTRL); | ||
89 | saved_reg[5] = cx18_av_read4(cx, CXADEC_VERT_TIM_CTRL); | ||
90 | saved_reg[6] = cx18_av_read4(cx, CXADEC_SRC_COMB_CFG); | ||
91 | saved_reg[7] = cx18_av_read4(cx, CXADEC_CHROMA_VBIOFF_CFG); | ||
92 | } | ||
93 | |||
94 | retval = cx18_av_write(cx, addr, value); | ||
95 | |||
96 | if (no_acfg_mask & CXADEC_NO_ACFG_AFE) { | ||
97 | cx18_av_write4(cx, CXADEC_CHIP_CTRL, saved_reg[0]); | ||
98 | cx18_av_write4(cx, CXADEC_AFE_CTRL, saved_reg[1]); | ||
99 | } | ||
100 | |||
101 | if (no_acfg_mask & CXADEC_NO_ACFG_PLL) { | ||
102 | cx18_av_write4(cx, CXADEC_PLL_CTRL1, saved_reg[2]); | ||
103 | cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, saved_reg[3]); | ||
104 | } | ||
105 | |||
106 | if (no_acfg_mask & CXADEC_NO_ACFG_VID) { | ||
107 | cx18_av_write4(cx, CXADEC_HORIZ_TIM_CTRL, saved_reg[4]); | ||
108 | cx18_av_write4(cx, CXADEC_VERT_TIM_CTRL, saved_reg[5]); | ||
109 | cx18_av_write4(cx, CXADEC_SRC_COMB_CFG, saved_reg[6]); | ||
110 | cx18_av_write4(cx, CXADEC_CHROMA_VBIOFF_CFG, saved_reg[7]); | ||
111 | } | ||
112 | |||
113 | return retval; | ||
114 | } | ||
115 | |||
116 | int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned and_mask, | ||
117 | u8 or_value, int no_acfg_mask) | ||
118 | { | ||
119 | return cx18_av_write_no_acfg(cx, addr, | ||
120 | (cx18_av_read(cx, addr) & and_mask) | | ||
121 | or_value, no_acfg_mask); | ||
122 | } | ||
123 | |||
72 | /* ----------------------------------------------------------------------- */ | 124 | /* ----------------------------------------------------------------------- */ |
73 | 125 | ||
74 | static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | 126 | static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, |
@@ -170,13 +222,15 @@ static void input_change(struct cx18 *cx) | |||
170 | 222 | ||
171 | /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */ | 223 | /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */ |
172 | if (std & V4L2_STD_SECAM) | 224 | if (std & V4L2_STD_SECAM) |
173 | cx18_av_write(cx, 0x402, 0); | 225 | cx18_av_write_no_acfg(cx, 0x402, 0, CXADEC_NO_ACFG_ALL); |
174 | else { | 226 | else { |
175 | cx18_av_write(cx, 0x402, 0x04); | 227 | cx18_av_write_no_acfg(cx, 0x402, 0x04, CXADEC_NO_ACFG_ALL); |
176 | cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); | 228 | cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); |
177 | } | 229 | } |
178 | cx18_av_and_or(cx, 0x401, ~0x60, 0); | 230 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0, |
179 | cx18_av_and_or(cx, 0x401, ~0x60, 0x60); | 231 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); |
232 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0x60, | ||
233 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); | ||
180 | 234 | ||
181 | if (std & V4L2_STD_525_60) { | 235 | if (std & V4L2_STD_525_60) { |
182 | if (std == V4L2_STD_NTSC_M_JP) { | 236 | if (std == V4L2_STD_NTSC_M_JP) { |
@@ -228,7 +282,7 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | |||
228 | 282 | ||
229 | if ((vid_input & ~0xff0) || | 283 | if ((vid_input & ~0xff0) || |
230 | luma < CX18_AV_SVIDEO_LUMA1 || | 284 | luma < CX18_AV_SVIDEO_LUMA1 || |
231 | luma > CX18_AV_SVIDEO_LUMA4 || | 285 | luma > CX18_AV_SVIDEO_LUMA8 || |
232 | chroma < CX18_AV_SVIDEO_CHROMA4 || | 286 | chroma < CX18_AV_SVIDEO_CHROMA4 || |
233 | chroma > CX18_AV_SVIDEO_CHROMA8) { | 287 | chroma > CX18_AV_SVIDEO_CHROMA8) { |
234 | CX18_ERR("0x%04x is not a valid video input!\n", | 288 | CX18_ERR("0x%04x is not a valid video input!\n", |
@@ -262,7 +316,8 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, | |||
262 | 316 | ||
263 | cx18_av_write(cx, 0x103, reg); | 317 | cx18_av_write(cx, 0x103, reg); |
264 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ | 318 | /* Set INPUT_MODE to Composite (0) or S-Video (1) */ |
265 | cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02); | 319 | cx18_av_and_or_no_acfg(cx, 0x401, ~0x6, is_composite ? 0 : 0x02, |
320 | CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID); | ||
266 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ | 321 | /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ |
267 | cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); | 322 | cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); |
268 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ | 323 | /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ |
@@ -318,12 +373,12 @@ static int set_v4lstd(struct cx18 *cx) | |||
318 | This happens for example with the Yuan MPC622. */ | 373 | This happens for example with the Yuan MPC622. */ |
319 | if (fmt >= 4 && fmt < 8) { | 374 | if (fmt >= 4 && fmt < 8) { |
320 | /* Set format to NTSC-M */ | 375 | /* Set format to NTSC-M */ |
321 | cx18_av_and_or(cx, 0x400, ~0xf, 1); | 376 | cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, 1, CXADEC_NO_ACFG_AFE); |
322 | /* Turn off LCOMB */ | 377 | /* Turn off LCOMB */ |
323 | cx18_av_and_or(cx, 0x47b, ~6, 0); | 378 | cx18_av_and_or(cx, 0x47b, ~6, 0); |
324 | } | 379 | } |
325 | cx18_av_and_or(cx, 0x400, ~0xf, fmt); | 380 | cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, fmt, CXADEC_NO_ACFG_AFE); |
326 | cx18_av_and_or(cx, 0x403, ~0x3, pal_m); | 381 | cx18_av_and_or_no_acfg(cx, 0x403, ~0x3, pal_m, CXADEC_NO_ACFG_ALL); |
327 | cx18_av_vbi_setup(cx); | 382 | cx18_av_vbi_setup(cx); |
328 | input_change(cx); | 383 | input_change(cx); |
329 | return 0; | 384 | return 0; |
diff --git a/drivers/media/video/cx18/cx18-av-core.h b/drivers/media/video/cx18/cx18-av-core.h index 786901d72e9a..c172823ce1d8 100644 --- a/drivers/media/video/cx18/cx18-av-core.h +++ b/drivers/media/video/cx18/cx18-av-core.h | |||
@@ -37,12 +37,16 @@ enum cx18_av_video_input { | |||
37 | CX18_AV_COMPOSITE7, | 37 | CX18_AV_COMPOSITE7, |
38 | CX18_AV_COMPOSITE8, | 38 | CX18_AV_COMPOSITE8, |
39 | 39 | ||
40 | /* S-Video inputs consist of one luma input (In1-In4) ORed with one | 40 | /* S-Video inputs consist of one luma input (In1-In8) ORed with one |
41 | chroma input (In5-In8) */ | 41 | chroma input (In5-In8) */ |
42 | CX18_AV_SVIDEO_LUMA1 = 0x10, | 42 | CX18_AV_SVIDEO_LUMA1 = 0x10, |
43 | CX18_AV_SVIDEO_LUMA2 = 0x20, | 43 | CX18_AV_SVIDEO_LUMA2 = 0x20, |
44 | CX18_AV_SVIDEO_LUMA3 = 0x30, | 44 | CX18_AV_SVIDEO_LUMA3 = 0x30, |
45 | CX18_AV_SVIDEO_LUMA4 = 0x40, | 45 | CX18_AV_SVIDEO_LUMA4 = 0x40, |
46 | CX18_AV_SVIDEO_LUMA5 = 0x50, | ||
47 | CX18_AV_SVIDEO_LUMA6 = 0x60, | ||
48 | CX18_AV_SVIDEO_LUMA7 = 0x70, | ||
49 | CX18_AV_SVIDEO_LUMA8 = 0x80, | ||
46 | CX18_AV_SVIDEO_CHROMA4 = 0x400, | 50 | CX18_AV_SVIDEO_CHROMA4 = 0x400, |
47 | CX18_AV_SVIDEO_CHROMA5 = 0x500, | 51 | CX18_AV_SVIDEO_CHROMA5 = 0x500, |
48 | CX18_AV_SVIDEO_CHROMA6 = 0x600, | 52 | CX18_AV_SVIDEO_CHROMA6 = 0x600, |
@@ -291,14 +295,24 @@ struct cx18_av_state { | |||
291 | #define CXADEC_SELECT_AUDIO_STANDARD_FM 0xF9 /* FM radio */ | 295 | #define CXADEC_SELECT_AUDIO_STANDARD_FM 0xF9 /* FM radio */ |
292 | #define CXADEC_SELECT_AUDIO_STANDARD_AUTO 0xFF /* Auto detect */ | 296 | #define CXADEC_SELECT_AUDIO_STANDARD_AUTO 0xFF /* Auto detect */ |
293 | 297 | ||
298 | /* Flags on what to preserve on write to 0x400-0x403 with cx18_av_.*_no_acfg()*/ | ||
299 | #define CXADEC_NO_ACFG_AFE 0x01 /* Preserve 0x100-0x107 */ | ||
300 | #define CXADEC_NO_ACFG_PLL 0x02 /* Preserve 0x108-0x10f */ | ||
301 | #define CXADEC_NO_ACFG_VID 0x04 /* Preserve 0x470-0x47f */ | ||
302 | #define CXADEC_NO_ACFG_ALL 0x07 | ||
303 | |||
294 | /* ----------------------------------------------------------------------- */ | 304 | /* ----------------------------------------------------------------------- */ |
295 | /* cx18_av-core.c */ | 305 | /* cx18_av-core.c */ |
296 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); | 306 | int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); |
297 | int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value); | 307 | int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value); |
308 | int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value, | ||
309 | int no_acfg_mask); | ||
298 | u8 cx18_av_read(struct cx18 *cx, u16 addr); | 310 | u8 cx18_av_read(struct cx18 *cx, u16 addr); |
299 | u32 cx18_av_read4(struct cx18 *cx, u16 addr); | 311 | u32 cx18_av_read4(struct cx18 *cx, u16 addr); |
300 | int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); | 312 | int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); |
301 | int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); | 313 | int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); |
314 | int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned mask, u8 value, | ||
315 | int no_acfg_mask); | ||
302 | int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); | 316 | int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); |
303 | 317 | ||
304 | /* ----------------------------------------------------------------------- */ | 318 | /* ----------------------------------------------------------------------- */ |
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c index baccd079243d..c26e0ef5b075 100644 --- a/drivers/media/video/cx18/cx18-cards.c +++ b/drivers/media/video/cx18/cx18-cards.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include "cx18-driver.h" | 24 | #include "cx18-driver.h" |
25 | #include "cx18-cards.h" | 25 | #include "cx18-cards.h" |
26 | #include "cx18-av-core.h" | ||
26 | #include "cx18-i2c.h" | 27 | #include "cx18-i2c.h" |
27 | #include <media/cs5345.h> | 28 | #include <media/cs5345.h> |
28 | 29 | ||
@@ -54,22 +55,22 @@ static const struct cx18_card cx18_card_hvr1600_esmt = { | |||
54 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | | 55 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
55 | CX18_HW_CS5345 | CX18_HW_DVB, | 56 | CX18_HW_CS5345 | CX18_HW_DVB, |
56 | .video_inputs = { | 57 | .video_inputs = { |
57 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 58 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, |
58 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 59 | { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, |
59 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 60 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 }, |
60 | { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, | 61 | { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 }, |
61 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, | 62 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 }, |
62 | }, | 63 | }, |
63 | .audio_inputs = { | 64 | .audio_inputs = { |
64 | { CX18_CARD_INPUT_AUD_TUNER, | 65 | { CX18_CARD_INPUT_AUD_TUNER, |
65 | CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, | 66 | CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, |
66 | { CX18_CARD_INPUT_LINE_IN1, | 67 | { CX18_CARD_INPUT_LINE_IN1, |
67 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 68 | CX18_AV_AUDIO_SERIAL, CS5345_IN_2 }, |
68 | { CX18_CARD_INPUT_LINE_IN2, | 69 | { CX18_CARD_INPUT_LINE_IN2, |
69 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 70 | CX18_AV_AUDIO_SERIAL, CS5345_IN_3 }, |
70 | }, | 71 | }, |
71 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 72 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
72 | CX23418_AUDIO_SERIAL, 0 }, | 73 | CX18_AV_AUDIO_SERIAL, CS5345_IN_4 }, |
73 | .ddr = { | 74 | .ddr = { |
74 | /* ESMT M13S128324A-5B memory */ | 75 | /* ESMT M13S128324A-5B memory */ |
75 | .chip_config = 0x003, | 76 | .chip_config = 0x003, |
@@ -81,6 +82,11 @@ static const struct cx18_card cx18_card_hvr1600_esmt = { | |||
81 | }, | 82 | }, |
82 | .gpio_init.initial_value = 0x3001, | 83 | .gpio_init.initial_value = 0x3001, |
83 | .gpio_init.direction = 0x3001, | 84 | .gpio_init.direction = 0x3001, |
85 | .gpio_i2c_slave_reset = { | ||
86 | .active_lo_mask = 0x3001, | ||
87 | .msecs_asserted = 10, | ||
88 | .msecs_recovery = 40, | ||
89 | }, | ||
84 | .i2c = &cx18_i2c_std, | 90 | .i2c = &cx18_i2c_std, |
85 | }; | 91 | }; |
86 | 92 | ||
@@ -94,22 +100,22 @@ static const struct cx18_card cx18_card_hvr1600_samsung = { | |||
94 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | | 100 | .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | |
95 | CX18_HW_CS5345 | CX18_HW_DVB, | 101 | CX18_HW_CS5345 | CX18_HW_DVB, |
96 | .video_inputs = { | 102 | .video_inputs = { |
97 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 103 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, |
98 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 104 | { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, |
99 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 105 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 }, |
100 | { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, | 106 | { CX18_CARD_INPUT_SVIDEO2, 2, CX18_AV_SVIDEO2 }, |
101 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, | 107 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE4 }, |
102 | }, | 108 | }, |
103 | .audio_inputs = { | 109 | .audio_inputs = { |
104 | { CX18_CARD_INPUT_AUD_TUNER, | 110 | { CX18_CARD_INPUT_AUD_TUNER, |
105 | CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, | 111 | CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, |
106 | { CX18_CARD_INPUT_LINE_IN1, | 112 | { CX18_CARD_INPUT_LINE_IN1, |
107 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 113 | CX18_AV_AUDIO_SERIAL, CS5345_IN_2 }, |
108 | { CX18_CARD_INPUT_LINE_IN2, | 114 | { CX18_CARD_INPUT_LINE_IN2, |
109 | CX23418_AUDIO_SERIAL, CS5345_IN_2 }, | 115 | CX18_AV_AUDIO_SERIAL, CS5345_IN_3 }, |
110 | }, | 116 | }, |
111 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 117 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
112 | CX23418_AUDIO_SERIAL, 0 }, | 118 | CX18_AV_AUDIO_SERIAL, CS5345_IN_4 }, |
113 | .ddr = { | 119 | .ddr = { |
114 | /* Samsung K4D263238G-VC33 memory */ | 120 | /* Samsung K4D263238G-VC33 memory */ |
115 | .chip_config = 0x003, | 121 | .chip_config = 0x003, |
@@ -121,6 +127,11 @@ static const struct cx18_card cx18_card_hvr1600_samsung = { | |||
121 | }, | 127 | }, |
122 | .gpio_init.initial_value = 0x3001, | 128 | .gpio_init.initial_value = 0x3001, |
123 | .gpio_init.direction = 0x3001, | 129 | .gpio_init.direction = 0x3001, |
130 | .gpio_i2c_slave_reset = { | ||
131 | .active_lo_mask = 0x3001, | ||
132 | .msecs_asserted = 10, | ||
133 | .msecs_recovery = 40, | ||
134 | }, | ||
124 | .i2c = &cx18_i2c_std, | 135 | .i2c = &cx18_i2c_std, |
125 | }; | 136 | }; |
126 | 137 | ||
@@ -141,19 +152,19 @@ static const struct cx18_card cx18_card_h900 = { | |||
141 | .hw_audio_ctrl = CX18_HW_CX23418, | 152 | .hw_audio_ctrl = CX18_HW_CX23418, |
142 | .hw_all = CX18_HW_TUNER, | 153 | .hw_all = CX18_HW_TUNER, |
143 | .video_inputs = { | 154 | .video_inputs = { |
144 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 }, | 155 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, |
145 | { CX18_CARD_INPUT_SVIDEO1, 1, | 156 | { CX18_CARD_INPUT_SVIDEO1, 1, |
146 | CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 }, | 157 | CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 }, |
147 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 }, | 158 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 }, |
148 | }, | 159 | }, |
149 | .audio_inputs = { | 160 | .audio_inputs = { |
150 | { CX18_CARD_INPUT_AUD_TUNER, | 161 | { CX18_CARD_INPUT_AUD_TUNER, |
151 | CX23418_AUDIO8, 0 }, | 162 | CX18_AV_AUDIO8, 0 }, |
152 | { CX18_CARD_INPUT_LINE_IN1, | 163 | { CX18_CARD_INPUT_LINE_IN1, |
153 | CX23418_AUDIO_SERIAL, 0 }, | 164 | CX18_AV_AUDIO_SERIAL, 0 }, |
154 | }, | 165 | }, |
155 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 166 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, |
156 | CX23418_AUDIO_SERIAL, 0 }, | 167 | CX18_AV_AUDIO_SERIAL, 0 }, |
157 | .tuners = { | 168 | .tuners = { |
158 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, | 169 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, |
159 | }, | 170 | }, |
@@ -183,23 +194,26 @@ static const struct cx18_card_pci_info cx18_pci_mpc718[] = { | |||
183 | static const struct cx18_card cx18_card_mpc718 = { | 194 | static const struct cx18_card cx18_card_mpc718 = { |
184 | .type = CX18_CARD_YUAN_MPC718, | 195 | .type = CX18_CARD_YUAN_MPC718, |
185 | .name = "Yuan MPC718", | 196 | .name = "Yuan MPC718", |
186 | .comment = "Not yet supported!\n", | 197 | .comment = "Some Composite and S-Video inputs are currently working.\n", |
187 | .v4l2_capabilities = 0, | 198 | .v4l2_capabilities = CX18_CAP_ENCODER, |
188 | .hw_audio_ctrl = CX18_HW_CX23418, | 199 | .hw_audio_ctrl = CX18_HW_CX23418, |
189 | .hw_all = CX18_HW_TUNER, | 200 | .hw_all = CX18_HW_TUNER, |
190 | .video_inputs = { | 201 | .video_inputs = { |
191 | { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, | 202 | { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, |
192 | { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, | 203 | { CX18_CARD_INPUT_SVIDEO1, 1, |
193 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, | 204 | CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 }, |
205 | { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 }, | ||
206 | { CX18_CARD_INPUT_SVIDEO2, 2, | ||
207 | CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 }, | ||
208 | { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 }, | ||
209 | { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 }, | ||
194 | }, | 210 | }, |
195 | .audio_inputs = { | 211 | .audio_inputs = { |
196 | { CX18_CARD_INPUT_AUD_TUNER, | 212 | { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5, 0 }, |
197 | CX23418_AUDIO8, 0 }, | 213 | { CX18_CARD_INPUT_LINE_IN1, CX18_AV_AUDIO_SERIAL, 0 }, |
198 | { CX18_CARD_INPUT_LINE_IN1, | 214 | { CX18_CARD_INPUT_LINE_IN2, CX18_AV_AUDIO_SERIAL, 0 }, |
199 | CX23418_AUDIO_SERIAL, 0 }, | ||
200 | }, | 215 | }, |
201 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, | 216 | .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL, 0 }, |
202 | CX23418_AUDIO_SERIAL, 0 }, | ||
203 | .tuners = { | 217 | .tuners = { |
204 | /* XC3028 tuner */ | 218 | /* XC3028 tuner */ |
205 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, | 219 | { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, |
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h index bccb67f0db16..dc2dd945d4c3 100644 --- a/drivers/media/video/cx18/cx18-cards.h +++ b/drivers/media/video/cx18/cx18-cards.h | |||
@@ -36,36 +36,6 @@ | |||
36 | #define CX18_CARD_INPUT_COMPOSITE2 5 | 36 | #define CX18_CARD_INPUT_COMPOSITE2 5 |
37 | #define CX18_CARD_INPUT_COMPOSITE3 6 | 37 | #define CX18_CARD_INPUT_COMPOSITE3 6 |
38 | 38 | ||
39 | enum cx34180_video_input { | ||
40 | /* Composite video inputs In1-In8 */ | ||
41 | CX23418_COMPOSITE1 = 1, | ||
42 | CX23418_COMPOSITE2, | ||
43 | CX23418_COMPOSITE3, | ||
44 | CX23418_COMPOSITE4, | ||
45 | CX23418_COMPOSITE5, | ||
46 | CX23418_COMPOSITE6, | ||
47 | CX23418_COMPOSITE7, | ||
48 | CX23418_COMPOSITE8, | ||
49 | |||
50 | /* S-Video inputs consist of one luma input (In1-In4) ORed with one | ||
51 | chroma input (In5-In8) */ | ||
52 | CX23418_SVIDEO_LUMA1 = 0x10, | ||
53 | CX23418_SVIDEO_LUMA2 = 0x20, | ||
54 | CX23418_SVIDEO_LUMA3 = 0x30, | ||
55 | CX23418_SVIDEO_LUMA4 = 0x40, | ||
56 | CX23418_SVIDEO_CHROMA4 = 0x400, | ||
57 | CX23418_SVIDEO_CHROMA5 = 0x500, | ||
58 | CX23418_SVIDEO_CHROMA6 = 0x600, | ||
59 | CX23418_SVIDEO_CHROMA7 = 0x700, | ||
60 | CX23418_SVIDEO_CHROMA8 = 0x800, | ||
61 | |||
62 | /* S-Video aliases for common luma/chroma combinations */ | ||
63 | CX23418_SVIDEO1 = 0x510, | ||
64 | CX23418_SVIDEO2 = 0x620, | ||
65 | CX23418_SVIDEO3 = 0x730, | ||
66 | CX23418_SVIDEO4 = 0x840, | ||
67 | }; | ||
68 | |||
69 | /* audio inputs */ | 39 | /* audio inputs */ |
70 | #define CX18_CARD_INPUT_AUD_TUNER 1 | 40 | #define CX18_CARD_INPUT_AUD_TUNER 1 |
71 | #define CX18_CARD_INPUT_LINE_IN1 2 | 41 | #define CX18_CARD_INPUT_LINE_IN1 2 |
@@ -75,16 +45,6 @@ enum cx34180_video_input { | |||
75 | #define CX18_CARD_MAX_AUDIO_INPUTS 3 | 45 | #define CX18_CARD_MAX_AUDIO_INPUTS 3 |
76 | #define CX18_CARD_MAX_TUNERS 2 | 46 | #define CX18_CARD_MAX_TUNERS 2 |
77 | 47 | ||
78 | enum cx23418_audio_input { | ||
79 | /* Audio inputs: serial or In4-In8 */ | ||
80 | CX23418_AUDIO_SERIAL, | ||
81 | CX23418_AUDIO4 = 4, | ||
82 | CX23418_AUDIO5, | ||
83 | CX23418_AUDIO6, | ||
84 | CX23418_AUDIO7, | ||
85 | CX23418_AUDIO8, | ||
86 | }; | ||
87 | |||
88 | /* V4L2 capability aliases */ | 48 | /* V4L2 capability aliases */ |
89 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ | 49 | #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ |
90 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE) | 50 | V4L2_CAP_AUDIO | V4L2_CAP_READWRITE) |
@@ -118,6 +78,13 @@ struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ | |||
118 | u32 initial_value; | 78 | u32 initial_value; |
119 | }; | 79 | }; |
120 | 80 | ||
81 | struct cx18_gpio_i2c_slave_reset { | ||
82 | u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */ | ||
83 | u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */ | ||
84 | int msecs_asserted; /* time period reset must remain asserted */ | ||
85 | int msecs_recovery; /* time after deassert for chips to be ready */ | ||
86 | }; | ||
87 | |||
121 | struct cx18_card_tuner { | 88 | struct cx18_card_tuner { |
122 | v4l2_std_id std; /* standard for which the tuner is suitable */ | 89 | v4l2_std_id std; /* standard for which the tuner is suitable */ |
123 | int tuner; /* tuner ID (from tuner.h) */ | 90 | int tuner; /* tuner ID (from tuner.h) */ |
@@ -154,7 +121,8 @@ struct cx18_card { | |||
154 | 121 | ||
155 | /* GPIO card-specific settings */ | 122 | /* GPIO card-specific settings */ |
156 | u8 xceive_pin; /* XCeive tuner GPIO reset pin */ | 123 | u8 xceive_pin; /* XCeive tuner GPIO reset pin */ |
157 | struct cx18_gpio_init gpio_init; | 124 | struct cx18_gpio_init gpio_init; |
125 | struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset; | ||
158 | 126 | ||
159 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; | 127 | struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; |
160 | struct cx18_card_tuner_i2c *i2c; | 128 | struct cx18_card_tuner_i2c *i2c; |
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c index c9744173f969..cae38985b131 100644 --- a/drivers/media/video/cx18/cx18-dvb.c +++ b/drivers/media/video/cx18/cx18-dvb.c | |||
@@ -69,11 +69,21 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed) | |||
69 | struct dvb_demux *demux = feed->demux; | 69 | struct dvb_demux *demux = feed->demux; |
70 | struct cx18_stream *stream = (struct cx18_stream *) demux->priv; | 70 | struct cx18_stream *stream = (struct cx18_stream *) demux->priv; |
71 | struct cx18 *cx = stream->cx; | 71 | struct cx18 *cx = stream->cx; |
72 | int ret = -EINVAL; | 72 | int ret; |
73 | u32 v; | 73 | u32 v; |
74 | 74 | ||
75 | CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n", | 75 | CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n", |
76 | feed->pid, feed->index); | 76 | feed->pid, feed->index); |
77 | |||
78 | mutex_lock(&cx->serialize_lock); | ||
79 | ret = cx18_init_on_first_open(cx); | ||
80 | mutex_unlock(&cx->serialize_lock); | ||
81 | if (ret) { | ||
82 | CX18_ERR("Failed to initialize firmware starting DVB feed\n"); | ||
83 | return ret; | ||
84 | } | ||
85 | ret = -EINVAL; | ||
86 | |||
77 | switch (cx->card->type) { | 87 | switch (cx->card->type) { |
78 | case CX18_CARD_HVR_1600_ESMT: | 88 | case CX18_CARD_HVR_1600_ESMT: |
79 | case CX18_CARD_HVR_1600_SAMSUNG: | 89 | case CX18_CARD_HVR_1600_SAMSUNG: |
@@ -101,6 +111,11 @@ static int cx18_dvb_start_feed(struct dvb_demux_feed *feed) | |||
101 | if (stream->dvb.feeding++ == 0) { | 111 | if (stream->dvb.feeding++ == 0) { |
102 | CX18_DEBUG_INFO("Starting Transport DMA\n"); | 112 | CX18_DEBUG_INFO("Starting Transport DMA\n"); |
103 | ret = cx18_start_v4l2_encode_stream(stream); | 113 | ret = cx18_start_v4l2_encode_stream(stream); |
114 | if (ret < 0) { | ||
115 | CX18_DEBUG_INFO( | ||
116 | "Failed to start Transport DMA\n"); | ||
117 | stream->dvb.feeding--; | ||
118 | } | ||
104 | } else | 119 | } else |
105 | ret = 0; | 120 | ret = 0; |
106 | mutex_unlock(&stream->dvb.feedlock); | 121 | mutex_unlock(&stream->dvb.feedlock); |
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c index ceb63653c926..b302833f6f9d 100644 --- a/drivers/media/video/cx18/cx18-gpio.c +++ b/drivers/media/video/cx18/cx18-gpio.c | |||
@@ -53,10 +53,34 @@ static void gpio_write(struct cx18 *cx) | |||
53 | write_reg(((dir & 0xffff) << 16) | (val & 0xffff), | 53 | write_reg(((dir & 0xffff) << 16) | (val & 0xffff), |
54 | CX18_REG_GPIO_OUT1); | 54 | CX18_REG_GPIO_OUT1); |
55 | write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2); | 55 | write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2); |
56 | write_reg((dir & 0xffff0000) | ((val & 0xffff0000) >> 16), | 56 | write_reg_sync((dir & 0xffff0000) | ((val & 0xffff0000) >> 16), |
57 | CX18_REG_GPIO_OUT2); | 57 | CX18_REG_GPIO_OUT2); |
58 | } | 58 | } |
59 | 59 | ||
60 | void cx18_reset_i2c_slaves_gpio(struct cx18 *cx) | ||
61 | { | ||
62 | const struct cx18_gpio_i2c_slave_reset *p; | ||
63 | |||
64 | p = &cx->card->gpio_i2c_slave_reset; | ||
65 | |||
66 | if ((p->active_lo_mask | p->active_hi_mask) == 0) | ||
67 | return; | ||
68 | |||
69 | /* Assuming that the masks are a subset of the bits in gpio_dir */ | ||
70 | |||
71 | /* Assert */ | ||
72 | cx->gpio_val = | ||
73 | (cx->gpio_val | p->active_hi_mask) & ~(p->active_lo_mask); | ||
74 | gpio_write(cx); | ||
75 | schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_asserted)); | ||
76 | |||
77 | /* Deassert */ | ||
78 | cx->gpio_val = | ||
79 | (cx->gpio_val | p->active_lo_mask) & ~(p->active_hi_mask); | ||
80 | gpio_write(cx); | ||
81 | schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_recovery)); | ||
82 | } | ||
83 | |||
60 | void cx18_gpio_init(struct cx18 *cx) | 84 | void cx18_gpio_init(struct cx18 *cx) |
61 | { | 85 | { |
62 | cx->gpio_dir = cx->card->gpio_init.direction; | 86 | cx->gpio_dir = cx->card->gpio_init.direction; |
diff --git a/drivers/media/video/cx18/cx18-gpio.h b/drivers/media/video/cx18/cx18-gpio.h index 41bac8856b50..525c328f748a 100644 --- a/drivers/media/video/cx18/cx18-gpio.h +++ b/drivers/media/video/cx18/cx18-gpio.h | |||
@@ -21,4 +21,5 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | void cx18_gpio_init(struct cx18 *cx); | 23 | void cx18_gpio_init(struct cx18 *cx); |
24 | void cx18_reset_i2c_slaves_gpio(struct cx18 *cx); | ||
24 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value); | 25 | int cx18_reset_tuner_gpio(void *dev, int cmd, int value); |
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index 1d6c51a75313..680bc4e35b79 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -405,6 +405,8 @@ int init_cx18_i2c(struct cx18 *cx) | |||
405 | cx18_setscl(&cx->i2c_algo_cb_data[1], 1); | 405 | cx18_setscl(&cx->i2c_algo_cb_data[1], 1); |
406 | cx18_setsda(&cx->i2c_algo_cb_data[1], 1); | 406 | cx18_setsda(&cx->i2c_algo_cb_data[1], 1); |
407 | 407 | ||
408 | cx18_reset_i2c_slaves_gpio(cx); | ||
409 | |||
408 | return i2c_bit_add_bus(&cx->i2c_adap[0]) || | 410 | return i2c_bit_add_bus(&cx->i2c_adap[0]) || |
409 | i2c_bit_add_bus(&cx->i2c_adap[1]); | 411 | i2c_bit_add_bus(&cx->i2c_adap[1]); |
410 | } | 412 | } |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 607efdcd22f8..1da6f134888d 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -433,7 +433,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp | |||
433 | int chroma = vid_input & 0xf00; | 433 | int chroma = vid_input & 0xf00; |
434 | 434 | ||
435 | if ((vid_input & ~0xff0) || | 435 | if ((vid_input & ~0xff0) || |
436 | luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA4 || | 436 | luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA8 || |
437 | chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) { | 437 | chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) { |
438 | v4l_err(client, "0x%04x is not a valid video input!\n", | 438 | v4l_err(client, "0x%04x is not a valid video input!\n", |
439 | vid_input); | 439 | vid_input); |
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index e976fc6bef7c..80c8883e54b5 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
@@ -332,6 +332,12 @@ static int snd_cx88_pcm_open(struct snd_pcm_substream *substream) | |||
332 | struct snd_pcm_runtime *runtime = substream->runtime; | 332 | struct snd_pcm_runtime *runtime = substream->runtime; |
333 | int err; | 333 | int err; |
334 | 334 | ||
335 | if (!chip) { | ||
336 | printk(KERN_ERR "BUG: cx88 can't find device struct." | ||
337 | " Can't proceed with open\n"); | ||
338 | return -ENODEV; | ||
339 | } | ||
340 | |||
335 | err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS); | 341 | err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS); |
336 | if (err < 0) | 342 | if (err < 0) |
337 | goto _error; | 343 | goto _error; |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 92b2a6db4fdc..3c006103c1eb 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -268,6 +268,12 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) | |||
268 | 268 | ||
269 | dprintk("opening device and trying to acquire exclusive lock\n"); | 269 | dprintk("opening device and trying to acquire exclusive lock\n"); |
270 | 270 | ||
271 | if (!dev) { | ||
272 | printk(KERN_ERR "BUG: em28xx can't find device struct." | ||
273 | " Can't proceed with open\n"); | ||
274 | return -ENODEV; | ||
275 | } | ||
276 | |||
271 | /* Sets volume, mute, etc */ | 277 | /* Sets volume, mute, etc */ |
272 | 278 | ||
273 | dev->mute = 0; | 279 | dev->mute = 0; |
@@ -415,6 +421,12 @@ static int em28xx_audio_init(struct em28xx *dev) | |||
415 | static int devnr; | 421 | static int devnr; |
416 | int ret, err; | 422 | int ret, err; |
417 | 423 | ||
424 | if (dev->has_audio_class) { | ||
425 | /* This device does not support the extension (in this case | ||
426 | the device is expecting the snd-usb-audio module */ | ||
427 | return 0; | ||
428 | } | ||
429 | |||
418 | printk(KERN_INFO "em28xx-audio.c: probing for em28x1 " | 430 | printk(KERN_INFO "em28xx-audio.c: probing for em28x1 " |
419 | "non standard usbaudio\n"); | 431 | "non standard usbaudio\n"); |
420 | printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " | 432 | printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " |
@@ -458,6 +470,12 @@ static int em28xx_audio_fini(struct em28xx *dev) | |||
458 | if (dev == NULL) | 470 | if (dev == NULL) |
459 | return 0; | 471 | return 0; |
460 | 472 | ||
473 | if (dev->has_audio_class) { | ||
474 | /* This device does not support the extension (in this case | ||
475 | the device is expecting the snd-usb-audio module */ | ||
476 | return 0; | ||
477 | } | ||
478 | |||
461 | if (dev->adev) { | 479 | if (dev->adev) { |
462 | snd_card_free(dev->adev->sndcard); | 480 | snd_card_free(dev->adev->sndcard); |
463 | kfree(dev->adev); | 481 | kfree(dev->adev); |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 3e4f3c7e92e7..8cbda43727c3 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -157,6 +157,7 @@ struct em28xx_board em28xx_boards[] = { | |||
157 | .tda9887_conf = TDA9887_PRESENT, | 157 | .tda9887_conf = TDA9887_PRESENT, |
158 | .tuner_type = TUNER_XC2028, | 158 | .tuner_type = TUNER_XC2028, |
159 | .mts_firmware = 1, | 159 | .mts_firmware = 1, |
160 | .has_dvb = 1, | ||
160 | .decoder = EM28XX_TVP5150, | 161 | .decoder = EM28XX_TVP5150, |
161 | .input = { { | 162 | .input = { { |
162 | .type = EM28XX_VMUX_TELEVISION, | 163 | .type = EM28XX_VMUX_TELEVISION, |
@@ -524,6 +525,9 @@ void em28xx_pre_card_setup(struct em28xx *dev) | |||
524 | rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID); | 525 | rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID); |
525 | if (rc > 0) { | 526 | if (rc > 0) { |
526 | switch (rc) { | 527 | switch (rc) { |
528 | case CHIP_ID_EM2860: | ||
529 | em28xx_info("chip ID is em2860\n"); | ||
530 | break; | ||
527 | case CHIP_ID_EM2883: | 531 | case CHIP_ID_EM2883: |
528 | em28xx_info("chip ID is em2882/em2883\n"); | 532 | em28xx_info("chip ID is em2882/em2883\n"); |
529 | dev->wait_after_write = 0; | 533 | dev->wait_after_write = 0; |
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index 8cf4983f0039..0b2333ee07f8 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -382,6 +382,11 @@ static int dvb_init(struct em28xx *dev) | |||
382 | int result = 0; | 382 | int result = 0; |
383 | struct em28xx_dvb *dvb; | 383 | struct em28xx_dvb *dvb; |
384 | 384 | ||
385 | if (!dev->has_dvb) { | ||
386 | /* This device does not support the extension */ | ||
387 | return 0; | ||
388 | } | ||
389 | |||
385 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); | 390 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); |
386 | 391 | ||
387 | if (dvb == NULL) { | 392 | if (dvb == NULL) { |
@@ -444,6 +449,11 @@ out_free: | |||
444 | 449 | ||
445 | static int dvb_fini(struct em28xx *dev) | 450 | static int dvb_fini(struct em28xx *dev) |
446 | { | 451 | { |
452 | if (!dev->has_dvb) { | ||
453 | /* This device does not support the extension */ | ||
454 | return 0; | ||
455 | } | ||
456 | |||
447 | if (dev->dvb) { | 457 | if (dev->dvb) { |
448 | unregister_dvb(dev->dvb); | 458 | unregister_dvb(dev->dvb); |
449 | dev->dvb = NULL; | 459 | dev->dvb = NULL; |
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h index 9058bed07953..fac1ab23f621 100644 --- a/drivers/media/video/em28xx/em28xx-reg.h +++ b/drivers/media/video/em28xx/em28xx-reg.h | |||
@@ -84,5 +84,6 @@ | |||
84 | 84 | ||
85 | /* FIXME: Need to be populated with the other chip ID's */ | 85 | /* FIXME: Need to be populated with the other chip ID's */ |
86 | enum em28xx_chip_id { | 86 | enum em28xx_chip_id { |
87 | CHIP_ID_EM2860 = 34, | ||
87 | CHIP_ID_EM2883 = 36, | 88 | CHIP_ID_EM2883 = 36, |
88 | }; | 89 | }; |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index fb163ecd9216..285bc62bbe46 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1848,32 +1848,28 @@ static DEFINE_MUTEX(em28xx_extension_devlist_lock); | |||
1848 | 1848 | ||
1849 | int em28xx_register_extension(struct em28xx_ops *ops) | 1849 | int em28xx_register_extension(struct em28xx_ops *ops) |
1850 | { | 1850 | { |
1851 | struct em28xx *h, *dev = NULL; | 1851 | struct em28xx *dev = NULL; |
1852 | |||
1853 | list_for_each_entry(h, &em28xx_devlist, devlist) | ||
1854 | dev = h; | ||
1855 | 1852 | ||
1856 | mutex_lock(&em28xx_extension_devlist_lock); | 1853 | mutex_lock(&em28xx_extension_devlist_lock); |
1857 | list_add_tail(&ops->next, &em28xx_extension_devlist); | 1854 | list_add_tail(&ops->next, &em28xx_extension_devlist); |
1858 | if (dev) | 1855 | list_for_each_entry(dev, &em28xx_devlist, devlist) { |
1859 | ops->init(dev); | 1856 | if (dev) |
1860 | 1857 | ops->init(dev); | |
1858 | } | ||
1861 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); | 1859 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); |
1862 | mutex_unlock(&em28xx_extension_devlist_lock); | 1860 | mutex_unlock(&em28xx_extension_devlist_lock); |
1863 | |||
1864 | return 0; | 1861 | return 0; |
1865 | } | 1862 | } |
1866 | EXPORT_SYMBOL(em28xx_register_extension); | 1863 | EXPORT_SYMBOL(em28xx_register_extension); |
1867 | 1864 | ||
1868 | void em28xx_unregister_extension(struct em28xx_ops *ops) | 1865 | void em28xx_unregister_extension(struct em28xx_ops *ops) |
1869 | { | 1866 | { |
1870 | struct em28xx *h, *dev = NULL; | 1867 | struct em28xx *dev = NULL; |
1871 | |||
1872 | list_for_each_entry(h, &em28xx_devlist, devlist) | ||
1873 | dev = h; | ||
1874 | 1868 | ||
1875 | if (dev) | 1869 | list_for_each_entry(dev, &em28xx_devlist, devlist) { |
1876 | ops->fini(dev); | 1870 | if (dev) |
1871 | ops->fini(dev); | ||
1872 | } | ||
1877 | 1873 | ||
1878 | mutex_lock(&em28xx_extension_devlist_lock); | 1874 | mutex_lock(&em28xx_extension_devlist_lock); |
1879 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); | 1875 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); |
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index 7cc8e9b19fb7..5ec5bb9a94d2 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -1019,12 +1019,12 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1019 | struct pxa_camera_dev *pcdev; | 1019 | struct pxa_camera_dev *pcdev; |
1020 | struct resource *res; | 1020 | struct resource *res; |
1021 | void __iomem *base; | 1021 | void __iomem *base; |
1022 | unsigned int irq; | 1022 | int irq; |
1023 | int err = 0; | 1023 | int err = 0; |
1024 | 1024 | ||
1025 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1025 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1026 | irq = platform_get_irq(pdev, 0); | 1026 | irq = platform_get_irq(pdev, 0); |
1027 | if (!res || !irq) { | 1027 | if (!res || irq < 0) { |
1028 | err = -ENODEV; | 1028 | err = -ENODEV; |
1029 | goto exit; | 1029 | goto exit; |
1030 | } | 1030 | } |
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index ba3082422a01..f118de6e3672 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -613,9 +613,15 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream) | |||
613 | struct snd_pcm_runtime *runtime = substream->runtime; | 613 | struct snd_pcm_runtime *runtime = substream->runtime; |
614 | snd_card_saa7134_pcm_t *pcm; | 614 | snd_card_saa7134_pcm_t *pcm; |
615 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); | 615 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); |
616 | struct saa7134_dev *dev = saa7134->dev; | 616 | struct saa7134_dev *dev; |
617 | int amux, err; | 617 | int amux, err; |
618 | 618 | ||
619 | if (!saa7134) { | ||
620 | printk(KERN_ERR "BUG: saa7134 can't find device struct." | ||
621 | " Can't proceed with open\n"); | ||
622 | return -ENODEV; | ||
623 | } | ||
624 | dev = saa7134->dev; | ||
619 | mutex_lock(&dev->dmasound.lock); | 625 | mutex_lock(&dev->dmasound.lock); |
620 | 626 | ||
621 | dev->dmasound.read_count = 0; | 627 | dev->dmasound.read_count = 0; |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index b111903aa322..2618cfa592e7 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4114,11 +4114,7 @@ struct saa7134_board saa7134_boards[] = { | |||
4114 | .radio_type = UNSET, | 4114 | .radio_type = UNSET, |
4115 | .tuner_addr = ADDR_UNSET, | 4115 | .tuner_addr = ADDR_UNSET, |
4116 | .radio_addr = ADDR_UNSET, | 4116 | .radio_addr = ADDR_UNSET, |
4117 | /* | ||
4118 | TODO: | ||
4119 | .mpeg = SAA7134_MPEG_DVB, | 4117 | .mpeg = SAA7134_MPEG_DVB, |
4120 | */ | ||
4121 | |||
4122 | .inputs = {{ | 4118 | .inputs = {{ |
4123 | .name = name_tv, | 4119 | .name = name_tv, |
4124 | .vmux = 1, | 4120 | .vmux = 1, |
@@ -4157,7 +4153,7 @@ struct saa7134_board saa7134_boards[] = { | |||
4157 | } }, | 4153 | } }, |
4158 | .radio = { | 4154 | .radio = { |
4159 | .name = name_radio, | 4155 | .name = name_radio, |
4160 | .amux = LINE1, | 4156 | .amux = TV, |
4161 | }, | 4157 | }, |
4162 | }, | 4158 | }, |
4163 | [SAA7134_BOARD_AVERMEDIA_M115] = { | 4159 | [SAA7134_BOARD_AVERMEDIA_M115] = { |
@@ -4167,6 +4163,7 @@ struct saa7134_board saa7134_boards[] = { | |||
4167 | .radio_type = UNSET, | 4163 | .radio_type = UNSET, |
4168 | .tuner_addr = ADDR_UNSET, | 4164 | .tuner_addr = ADDR_UNSET, |
4169 | .radio_addr = ADDR_UNSET, | 4165 | .radio_addr = ADDR_UNSET, |
4166 | .mpeg = SAA7134_MPEG_DVB, | ||
4170 | .inputs = {{ | 4167 | .inputs = {{ |
4171 | .name = name_tv, | 4168 | .name = name_tv, |
4172 | .vmux = 1, | 4169 | .vmux = 1, |
@@ -5351,22 +5348,21 @@ static int saa7134_xc2028_callback(struct saa7134_dev *dev, | |||
5351 | { | 5348 | { |
5352 | switch (command) { | 5349 | switch (command) { |
5353 | case XC2028_TUNER_RESET: | 5350 | case XC2028_TUNER_RESET: |
5354 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000); | 5351 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00008000, 0x00000000); |
5355 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000); | 5352 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00008000, 0x00008000); |
5356 | mdelay(250); | 5353 | switch (dev->board) { |
5357 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0); | 5354 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
5358 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0); | 5355 | saa7134_set_gpio(dev, 23, 0); |
5359 | mdelay(250); | 5356 | msleep(10); |
5360 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000); | 5357 | saa7134_set_gpio(dev, 23, 1); |
5361 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000); | 5358 | break; |
5362 | mdelay(250); | 5359 | case SAA7134_BOARD_AVERMEDIA_A16D: |
5363 | saa_andorl(SAA7133_ANALOG_IO_SELECT >> 2, 0x02, 0x02); | 5360 | saa7134_set_gpio(dev, 21, 0); |
5364 | saa_andorl(SAA7134_ANALOG_IN_CTRL1 >> 2, 0x81, 0x81); | 5361 | msleep(10); |
5365 | saa_andorl(SAA7134_AUDIO_CLOCK0 >> 2, 0x03187de7, 0x03187de7); | 5362 | saa7134_set_gpio(dev, 21, 1); |
5366 | saa_andorl(SAA7134_AUDIO_PLL_CTRL >> 2, 0x03, 0x03); | 5363 | break; |
5367 | saa_andorl(SAA7134_AUDIO_CLOCKS_PER_FIELD0 >> 2, | 5364 | } |
5368 | 0x0001e000, 0x0001e000); | 5365 | return 0; |
5369 | return 0; | ||
5370 | } | 5366 | } |
5371 | return -EINVAL; | 5367 | return -EINVAL; |
5372 | } | 5368 | } |
@@ -5553,9 +5549,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
5553 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000); | 5549 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000); |
5554 | break; | 5550 | break; |
5555 | case SAA7134_BOARD_AVERMEDIA_CARDBUS: | 5551 | case SAA7134_BOARD_AVERMEDIA_CARDBUS: |
5556 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | ||
5557 | case SAA7134_BOARD_AVERMEDIA_M115: | 5552 | case SAA7134_BOARD_AVERMEDIA_M115: |
5558 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
5559 | /* power-down tuner chip */ | 5553 | /* power-down tuner chip */ |
5560 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0); | 5554 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0); |
5561 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0); | 5555 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0); |
@@ -5565,6 +5559,18 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
5565 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff); | 5559 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff); |
5566 | msleep(10); | 5560 | msleep(10); |
5567 | break; | 5561 | break; |
5562 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | ||
5563 | saa7134_set_gpio(dev, 23, 0); | ||
5564 | msleep(10); | ||
5565 | saa7134_set_gpio(dev, 23, 1); | ||
5566 | break; | ||
5567 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
5568 | saa7134_set_gpio(dev, 21, 0); | ||
5569 | msleep(10); | ||
5570 | saa7134_set_gpio(dev, 21, 1); | ||
5571 | msleep(1); | ||
5572 | dev->has_remote = SAA7134_REMOTE_GPIO; | ||
5573 | break; | ||
5568 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | 5574 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: |
5569 | /* power-down tuner chip */ | 5575 | /* power-down tuner chip */ |
5570 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x000A8004, 0x000A8004); | 5576 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x000A8004, 0x000A8004); |
@@ -5615,7 +5621,8 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
5615 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); | 5621 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); |
5616 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x80040100, 0x00040100); | 5622 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x80040100, 0x00040100); |
5617 | printk("%s: %s: hybrid analog/dvb card\n" | 5623 | printk("%s: %s: hybrid analog/dvb card\n" |
5618 | "%s: Sorry, only the analog inputs are supported for now.\n", | 5624 | "%s: Sorry, only analog s-video and composite input " |
5625 | "are supported for now.\n", | ||
5619 | dev->name, card(dev).name, dev->name); | 5626 | dev->name, card(dev).name, dev->name); |
5620 | break; | 5627 | break; |
5621 | } | 5628 | } |
@@ -5675,6 +5682,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) | |||
5675 | 5682 | ||
5676 | switch (dev->board) { | 5683 | switch (dev->board) { |
5677 | case SAA7134_BOARD_AVERMEDIA_A16D: | 5684 | case SAA7134_BOARD_AVERMEDIA_A16D: |
5685 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | ||
5678 | ctl.demod = XC3028_FE_ZARLINK456; | 5686 | ctl.demod = XC3028_FE_ZARLINK456; |
5679 | break; | 5687 | break; |
5680 | default: | 5688 | default: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 469f93aac008..341b101b0357 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -153,12 +153,12 @@ static int mt352_aver777_init(struct dvb_frontend* fe) | |||
153 | return 0; | 153 | return 0; |
154 | } | 154 | } |
155 | 155 | ||
156 | static int mt352_aver_a16d_init(struct dvb_frontend *fe) | 156 | static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe) |
157 | { | 157 | { |
158 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d }; | 158 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d }; |
159 | static u8 reset [] = { RESET, 0x80 }; | 159 | static u8 reset [] = { RESET, 0x80 }; |
160 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; | 160 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; |
161 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; | 161 | static u8 agc_cfg [] = { AGC_TARGET, 0xe }; |
162 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 }; | 162 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 }; |
163 | 163 | ||
164 | mt352_write(fe, clock_config, sizeof(clock_config)); | 164 | mt352_write(fe, clock_config, sizeof(clock_config)); |
@@ -167,12 +167,9 @@ static int mt352_aver_a16d_init(struct dvb_frontend *fe) | |||
167 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); | 167 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
168 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); | 168 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
169 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); | 169 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
170 | |||
171 | return 0; | 170 | return 0; |
172 | } | 171 | } |
173 | 172 | ||
174 | |||
175 | |||
176 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, | 173 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, |
177 | struct dvb_frontend_parameters* params) | 174 | struct dvb_frontend_parameters* params) |
178 | { | 175 | { |
@@ -215,14 +212,10 @@ static struct mt352_config avermedia_777 = { | |||
215 | .demod_init = mt352_aver777_init, | 212 | .demod_init = mt352_aver777_init, |
216 | }; | 213 | }; |
217 | 214 | ||
218 | static struct mt352_config avermedia_16d = { | 215 | static struct mt352_config avermedia_xc3028_mt352_dev = { |
219 | .demod_address = 0xf, | ||
220 | .demod_init = mt352_aver_a16d_init, | ||
221 | }; | ||
222 | |||
223 | static struct mt352_config avermedia_e506r_mt352_dev = { | ||
224 | .demod_address = (0x1e >> 1), | 216 | .demod_address = (0x1e >> 1), |
225 | .no_tuner = 1, | 217 | .no_tuner = 1, |
218 | .demod_init = mt352_avermedia_xc3028_init, | ||
226 | }; | 219 | }; |
227 | 220 | ||
228 | /* ================================================================== | 221 | /* ================================================================== |
@@ -975,9 +968,10 @@ static int dvb_init(struct saa7134_dev *dev) | |||
975 | } | 968 | } |
976 | break; | 969 | break; |
977 | case SAA7134_BOARD_AVERMEDIA_A16D: | 970 | case SAA7134_BOARD_AVERMEDIA_A16D: |
978 | dprintk("avertv A16D dvb setup\n"); | 971 | dprintk("AverMedia A16D dvb setup\n"); |
979 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_16d, | 972 | dev->dvb.frontend = dvb_attach(mt352_attach, |
980 | &dev->i2c_adap); | 973 | &avermedia_xc3028_mt352_dev, |
974 | &dev->i2c_adap); | ||
981 | attach_xc3028 = 1; | 975 | attach_xc3028 = 1; |
982 | break; | 976 | break; |
983 | case SAA7134_BOARD_MD7134: | 977 | case SAA7134_BOARD_MD7134: |
@@ -1091,7 +1085,8 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1091 | ads_tech_duo_config.tuner_address); | 1085 | ads_tech_duo_config.tuner_address); |
1092 | goto dettach_frontend; | 1086 | goto dettach_frontend; |
1093 | } | 1087 | } |
1094 | } | 1088 | } else |
1089 | wprintk("failed to attach tda10046\n"); | ||
1095 | break; | 1090 | break; |
1096 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 1091 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
1097 | if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config, | 1092 | if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config, |
@@ -1260,11 +1255,14 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1260 | goto dettach_frontend; | 1255 | goto dettach_frontend; |
1261 | break; | 1256 | break; |
1262 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | 1257 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
1258 | dprintk("AverMedia E506R dvb setup\n"); | ||
1259 | saa7134_set_gpio(dev, 25, 0); | ||
1260 | msleep(10); | ||
1261 | saa7134_set_gpio(dev, 25, 1); | ||
1263 | dev->dvb.frontend = dvb_attach(mt352_attach, | 1262 | dev->dvb.frontend = dvb_attach(mt352_attach, |
1264 | &avermedia_e506r_mt352_dev, | 1263 | &avermedia_xc3028_mt352_dev, |
1265 | &dev->i2c_adap); | 1264 | &dev->i2c_adap); |
1266 | attach_xc3028 = 1; | 1265 | attach_xc3028 = 1; |
1267 | break; | ||
1268 | case SAA7134_BOARD_MD7134_BRIDGE_2: | 1266 | case SAA7134_BOARD_MD7134_BRIDGE_2: |
1269 | dev->dvb.frontend = dvb_attach(tda10086_attach, | 1267 | dev->dvb.frontend = dvb_attach(tda10086_attach, |
1270 | &sd1878_4m, &dev->i2c_adap); | 1268 | &sd1878_4m, &dev->i2c_adap); |
@@ -1338,7 +1336,8 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1338 | return ret; | 1336 | return ret; |
1339 | 1337 | ||
1340 | dettach_frontend: | 1338 | dettach_frontend: |
1341 | dvb_frontend_detach(dev->dvb.frontend); | 1339 | if (dev->dvb.frontend) |
1340 | dvb_frontend_detach(dev->dvb.frontend); | ||
1342 | dev->dvb.frontend = NULL; | 1341 | dev->dvb.frontend = NULL; |
1343 | 1342 | ||
1344 | return -1; | 1343 | return -1; |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 81431ee41842..3ae71a340822 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
@@ -110,9 +110,10 @@ static int ts_release(struct inode *inode, struct file *file) | |||
110 | { | 110 | { |
111 | struct saa7134_dev *dev = file->private_data; | 111 | struct saa7134_dev *dev = file->private_data; |
112 | 112 | ||
113 | mutex_lock(&dev->empress_tsq.vb_lock); | ||
114 | |||
113 | videobuf_stop(&dev->empress_tsq); | 115 | videobuf_stop(&dev->empress_tsq); |
114 | videobuf_mmap_free(&dev->empress_tsq); | 116 | videobuf_mmap_free(&dev->empress_tsq); |
115 | dev->empress_users--; | ||
116 | 117 | ||
117 | /* stop the encoder */ | 118 | /* stop the encoder */ |
118 | ts_reset_encoder(dev); | 119 | ts_reset_encoder(dev); |
@@ -121,6 +122,10 @@ static int ts_release(struct inode *inode, struct file *file) | |||
121 | saa_writeb(SAA7134_AUDIO_MUTE_CTRL, | 122 | saa_writeb(SAA7134_AUDIO_MUTE_CTRL, |
122 | saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); | 123 | saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6)); |
123 | 124 | ||
125 | dev->empress_users--; | ||
126 | |||
127 | mutex_unlock(&dev->empress_tsq.vb_lock); | ||
128 | |||
124 | return 0; | 129 | return 0; |
125 | } | 130 | } |
126 | 131 | ||
@@ -218,8 +223,7 @@ static int empress_enum_fmt_cap(struct file *file, void *priv, | |||
218 | static int empress_g_fmt_cap(struct file *file, void *priv, | 223 | static int empress_g_fmt_cap(struct file *file, void *priv, |
219 | struct v4l2_format *f) | 224 | struct v4l2_format *f) |
220 | { | 225 | { |
221 | struct saa7134_fh *fh = priv; | 226 | struct saa7134_dev *dev = file->private_data; |
222 | struct saa7134_dev *dev = fh->dev; | ||
223 | 227 | ||
224 | saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f); | 228 | saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f); |
225 | 229 | ||
@@ -232,8 +236,7 @@ static int empress_g_fmt_cap(struct file *file, void *priv, | |||
232 | static int empress_s_fmt_cap(struct file *file, void *priv, | 236 | static int empress_s_fmt_cap(struct file *file, void *priv, |
233 | struct v4l2_format *f) | 237 | struct v4l2_format *f) |
234 | { | 238 | { |
235 | struct saa7134_fh *fh = priv; | 239 | struct saa7134_dev *dev = file->private_data; |
236 | struct saa7134_dev *dev = fh->dev; | ||
237 | 240 | ||
238 | saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f); | 241 | saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f); |
239 | 242 | ||
@@ -247,8 +250,7 @@ static int empress_s_fmt_cap(struct file *file, void *priv, | |||
247 | static int empress_reqbufs(struct file *file, void *priv, | 250 | static int empress_reqbufs(struct file *file, void *priv, |
248 | struct v4l2_requestbuffers *p) | 251 | struct v4l2_requestbuffers *p) |
249 | { | 252 | { |
250 | struct saa7134_fh *fh = priv; | 253 | struct saa7134_dev *dev = file->private_data; |
251 | struct saa7134_dev *dev = fh->dev; | ||
252 | 254 | ||
253 | return videobuf_reqbufs(&dev->empress_tsq, p); | 255 | return videobuf_reqbufs(&dev->empress_tsq, p); |
254 | } | 256 | } |
@@ -256,24 +258,21 @@ static int empress_reqbufs(struct file *file, void *priv, | |||
256 | static int empress_querybuf(struct file *file, void *priv, | 258 | static int empress_querybuf(struct file *file, void *priv, |
257 | struct v4l2_buffer *b) | 259 | struct v4l2_buffer *b) |
258 | { | 260 | { |
259 | struct saa7134_fh *fh = priv; | 261 | struct saa7134_dev *dev = file->private_data; |
260 | struct saa7134_dev *dev = fh->dev; | ||
261 | 262 | ||
262 | return videobuf_querybuf(&dev->empress_tsq, b); | 263 | return videobuf_querybuf(&dev->empress_tsq, b); |
263 | } | 264 | } |
264 | 265 | ||
265 | static int empress_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | 266 | static int empress_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) |
266 | { | 267 | { |
267 | struct saa7134_fh *fh = priv; | 268 | struct saa7134_dev *dev = file->private_data; |
268 | struct saa7134_dev *dev = fh->dev; | ||
269 | 269 | ||
270 | return videobuf_qbuf(&dev->empress_tsq, b); | 270 | return videobuf_qbuf(&dev->empress_tsq, b); |
271 | } | 271 | } |
272 | 272 | ||
273 | static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | 273 | static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) |
274 | { | 274 | { |
275 | struct saa7134_fh *fh = priv; | 275 | struct saa7134_dev *dev = file->private_data; |
276 | struct saa7134_dev *dev = fh->dev; | ||
277 | 276 | ||
278 | return videobuf_dqbuf(&dev->empress_tsq, b, | 277 | return videobuf_dqbuf(&dev->empress_tsq, b, |
279 | file->f_flags & O_NONBLOCK); | 278 | file->f_flags & O_NONBLOCK); |
@@ -282,8 +281,7 @@ static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | |||
282 | static int empress_streamon(struct file *file, void *priv, | 281 | static int empress_streamon(struct file *file, void *priv, |
283 | enum v4l2_buf_type type) | 282 | enum v4l2_buf_type type) |
284 | { | 283 | { |
285 | struct saa7134_fh *fh = priv; | 284 | struct saa7134_dev *dev = file->private_data; |
286 | struct saa7134_dev *dev = fh->dev; | ||
287 | 285 | ||
288 | return videobuf_streamon(&dev->empress_tsq); | 286 | return videobuf_streamon(&dev->empress_tsq); |
289 | } | 287 | } |
@@ -291,8 +289,7 @@ static int empress_streamon(struct file *file, void *priv, | |||
291 | static int empress_streamoff(struct file *file, void *priv, | 289 | static int empress_streamoff(struct file *file, void *priv, |
292 | enum v4l2_buf_type type) | 290 | enum v4l2_buf_type type) |
293 | { | 291 | { |
294 | struct saa7134_fh *fh = priv; | 292 | struct saa7134_dev *dev = file->private_data; |
295 | struct saa7134_dev *dev = fh->dev; | ||
296 | 293 | ||
297 | return videobuf_streamoff(&dev->empress_tsq); | 294 | return videobuf_streamoff(&dev->empress_tsq); |
298 | } | 295 | } |
@@ -300,8 +297,7 @@ static int empress_streamoff(struct file *file, void *priv, | |||
300 | static int empress_s_ext_ctrls(struct file *file, void *priv, | 297 | static int empress_s_ext_ctrls(struct file *file, void *priv, |
301 | struct v4l2_ext_controls *ctrls) | 298 | struct v4l2_ext_controls *ctrls) |
302 | { | 299 | { |
303 | struct saa7134_fh *fh = priv; | 300 | struct saa7134_dev *dev = file->private_data; |
304 | struct saa7134_dev *dev = fh->dev; | ||
305 | 301 | ||
306 | /* count == 0 is abused in saa6752hs.c, so that special | 302 | /* count == 0 is abused in saa6752hs.c, so that special |
307 | case is handled here explicitly. */ | 303 | case is handled here explicitly. */ |
@@ -320,8 +316,7 @@ static int empress_s_ext_ctrls(struct file *file, void *priv, | |||
320 | static int empress_g_ext_ctrls(struct file *file, void *priv, | 316 | static int empress_g_ext_ctrls(struct file *file, void *priv, |
321 | struct v4l2_ext_controls *ctrls) | 317 | struct v4l2_ext_controls *ctrls) |
322 | { | 318 | { |
323 | struct saa7134_fh *fh = priv; | 319 | struct saa7134_dev *dev = file->private_data; |
324 | struct saa7134_dev *dev = fh->dev; | ||
325 | 320 | ||
326 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 321 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
327 | return -EINVAL; | 322 | return -EINVAL; |
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 919632b10aae..76e6501d238d 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
@@ -323,6 +323,15 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
323 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); | 323 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); |
324 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | 324 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); |
325 | break; | 325 | break; |
326 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
327 | ir_codes = ir_codes_avermedia_a16d; | ||
328 | mask_keycode = 0x02F200; | ||
329 | mask_keydown = 0x000400; | ||
330 | polling = 50; /* ms */ | ||
331 | /* Without this we won't receive key up events */ | ||
332 | saa_setb(SAA7134_GPIO_GPMODE1, 0x1); | ||
333 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); | ||
334 | break; | ||
326 | case SAA7134_BOARD_KWORLD_TERMINATOR: | 335 | case SAA7134_BOARD_KWORLD_TERMINATOR: |
327 | ir_codes = ir_codes_pixelview; | 336 | ir_codes = ir_codes_pixelview; |
328 | mask_keycode = 0x00001f; | 337 | mask_keycode = 0x00001f; |
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index a1b92446c8b4..d015bfe00950 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -763,15 +763,6 @@ static struct device_driver ic_drv = { | |||
763 | .owner = THIS_MODULE, | 763 | .owner = THIS_MODULE, |
764 | }; | 764 | }; |
765 | 765 | ||
766 | /* | ||
767 | * Image capture host - this is a host device, not a bus device, so, | ||
768 | * no bus reference, no probing. | ||
769 | */ | ||
770 | static struct class soc_camera_host_class = { | ||
771 | .owner = THIS_MODULE, | ||
772 | .name = "camera_host", | ||
773 | }; | ||
774 | |||
775 | static void dummy_release(struct device *dev) | 766 | static void dummy_release(struct device *dev) |
776 | { | 767 | { |
777 | } | 768 | } |
@@ -801,7 +792,6 @@ int soc_camera_host_register(struct soc_camera_host *ici) | |||
801 | 792 | ||
802 | /* Number might be equal to the platform device ID */ | 793 | /* Number might be equal to the platform device ID */ |
803 | sprintf(ici->dev.bus_id, "camera_host%d", ici->nr); | 794 | sprintf(ici->dev.bus_id, "camera_host%d", ici->nr); |
804 | ici->dev.class = &soc_camera_host_class; | ||
805 | 795 | ||
806 | mutex_lock(&list_lock); | 796 | mutex_lock(&list_lock); |
807 | list_for_each_entry(ix, &hosts, list) { | 797 | list_for_each_entry(ix, &hosts, list) { |
@@ -1003,14 +993,9 @@ static int __init soc_camera_init(void) | |||
1003 | ret = driver_register(&ic_drv); | 993 | ret = driver_register(&ic_drv); |
1004 | if (ret) | 994 | if (ret) |
1005 | goto edrvr; | 995 | goto edrvr; |
1006 | ret = class_register(&soc_camera_host_class); | ||
1007 | if (ret) | ||
1008 | goto eclr; | ||
1009 | 996 | ||
1010 | return 0; | 997 | return 0; |
1011 | 998 | ||
1012 | eclr: | ||
1013 | driver_unregister(&ic_drv); | ||
1014 | edrvr: | 999 | edrvr: |
1015 | bus_unregister(&soc_camera_bus_type); | 1000 | bus_unregister(&soc_camera_bus_type); |
1016 | return ret; | 1001 | return ret; |
@@ -1018,7 +1003,6 @@ edrvr: | |||
1018 | 1003 | ||
1019 | static void __exit soc_camera_exit(void) | 1004 | static void __exit soc_camera_exit(void) |
1020 | { | 1005 | { |
1021 | class_unregister(&soc_camera_host_class); | ||
1022 | driver_unregister(&ic_drv); | 1006 | driver_unregister(&ic_drv); |
1023 | bus_unregister(&soc_camera_bus_type); | 1007 | bus_unregister(&soc_camera_bus_type); |
1024 | } | 1008 | } |
diff --git a/drivers/media/video/uvc/Makefile b/drivers/media/video/uvc/Makefile new file mode 100644 index 000000000000..968c1994eda0 --- /dev/null +++ b/drivers/media/video/uvc/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ | ||
2 | uvc_status.o uvc_isight.o | ||
3 | obj-$(CONFIG_USB_VIDEO_CLASS) += uvcvideo.o | ||
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c new file mode 100644 index 000000000000..f0ee46d15540 --- /dev/null +++ b/drivers/media/video/uvc/uvc_ctrl.c | |||
@@ -0,0 +1,1256 @@ | |||
1 | /* | ||
2 | * uvc_ctrl.c -- USB Video Class driver - Controls | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/uaccess.h> | ||
19 | #include <linux/usb.h> | ||
20 | #include <linux/videodev2.h> | ||
21 | #include <linux/vmalloc.h> | ||
22 | #include <linux/wait.h> | ||
23 | #include <asm/atomic.h> | ||
24 | |||
25 | #include "uvcvideo.h" | ||
26 | |||
27 | #define UVC_CTRL_NDATA 2 | ||
28 | #define UVC_CTRL_DATA_CURRENT 0 | ||
29 | #define UVC_CTRL_DATA_BACKUP 1 | ||
30 | |||
31 | /* ------------------------------------------------------------------------ | ||
32 | * Control, formats, ... | ||
33 | */ | ||
34 | |||
35 | static struct uvc_control_info uvc_ctrls[] = { | ||
36 | { | ||
37 | .entity = UVC_GUID_UVC_PROCESSING, | ||
38 | .selector = PU_BRIGHTNESS_CONTROL, | ||
39 | .index = 0, | ||
40 | .size = 2, | ||
41 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
42 | | UVC_CONTROL_RESTORE, | ||
43 | }, | ||
44 | { | ||
45 | .entity = UVC_GUID_UVC_PROCESSING, | ||
46 | .selector = PU_CONTRAST_CONTROL, | ||
47 | .index = 1, | ||
48 | .size = 2, | ||
49 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
50 | | UVC_CONTROL_RESTORE, | ||
51 | }, | ||
52 | { | ||
53 | .entity = UVC_GUID_UVC_PROCESSING, | ||
54 | .selector = PU_HUE_CONTROL, | ||
55 | .index = 2, | ||
56 | .size = 2, | ||
57 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
58 | | UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE, | ||
59 | }, | ||
60 | { | ||
61 | .entity = UVC_GUID_UVC_PROCESSING, | ||
62 | .selector = PU_SATURATION_CONTROL, | ||
63 | .index = 3, | ||
64 | .size = 2, | ||
65 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
66 | | UVC_CONTROL_RESTORE, | ||
67 | }, | ||
68 | { | ||
69 | .entity = UVC_GUID_UVC_PROCESSING, | ||
70 | .selector = PU_SHARPNESS_CONTROL, | ||
71 | .index = 4, | ||
72 | .size = 2, | ||
73 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
74 | | UVC_CONTROL_RESTORE, | ||
75 | }, | ||
76 | { | ||
77 | .entity = UVC_GUID_UVC_PROCESSING, | ||
78 | .selector = PU_GAMMA_CONTROL, | ||
79 | .index = 5, | ||
80 | .size = 2, | ||
81 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
82 | | UVC_CONTROL_RESTORE, | ||
83 | }, | ||
84 | { | ||
85 | .entity = UVC_GUID_UVC_PROCESSING, | ||
86 | .selector = PU_BACKLIGHT_COMPENSATION_CONTROL, | ||
87 | .index = 8, | ||
88 | .size = 2, | ||
89 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
90 | | UVC_CONTROL_RESTORE, | ||
91 | }, | ||
92 | { | ||
93 | .entity = UVC_GUID_UVC_PROCESSING, | ||
94 | .selector = PU_GAIN_CONTROL, | ||
95 | .index = 9, | ||
96 | .size = 2, | ||
97 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
98 | | UVC_CONTROL_RESTORE, | ||
99 | }, | ||
100 | { | ||
101 | .entity = UVC_GUID_UVC_PROCESSING, | ||
102 | .selector = PU_POWER_LINE_FREQUENCY_CONTROL, | ||
103 | .index = 10, | ||
104 | .size = 1, | ||
105 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
106 | | UVC_CONTROL_RESTORE, | ||
107 | }, | ||
108 | { | ||
109 | .entity = UVC_GUID_UVC_PROCESSING, | ||
110 | .selector = PU_HUE_AUTO_CONTROL, | ||
111 | .index = 11, | ||
112 | .size = 1, | ||
113 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
114 | | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE, | ||
115 | }, | ||
116 | { | ||
117 | .entity = UVC_GUID_UVC_CAMERA, | ||
118 | .selector = CT_AE_MODE_CONTROL, | ||
119 | .index = 1, | ||
120 | .size = 1, | ||
121 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
122 | | UVC_CONTROL_GET_DEF | UVC_CONTROL_GET_RES | ||
123 | | UVC_CONTROL_RESTORE, | ||
124 | }, | ||
125 | { | ||
126 | .entity = UVC_GUID_UVC_CAMERA, | ||
127 | .selector = CT_AE_PRIORITY_CONTROL, | ||
128 | .index = 2, | ||
129 | .size = 1, | ||
130 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
131 | | UVC_CONTROL_RESTORE, | ||
132 | }, | ||
133 | { | ||
134 | .entity = UVC_GUID_UVC_CAMERA, | ||
135 | .selector = CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, | ||
136 | .index = 3, | ||
137 | .size = 4, | ||
138 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
139 | | UVC_CONTROL_RESTORE, | ||
140 | }, | ||
141 | { | ||
142 | .entity = UVC_GUID_UVC_CAMERA, | ||
143 | .selector = CT_FOCUS_ABSOLUTE_CONTROL, | ||
144 | .index = 5, | ||
145 | .size = 2, | ||
146 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
147 | | UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE, | ||
148 | }, | ||
149 | { | ||
150 | .entity = UVC_GUID_UVC_CAMERA, | ||
151 | .selector = CT_FOCUS_AUTO_CONTROL, | ||
152 | .index = 17, | ||
153 | .size = 1, | ||
154 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
155 | | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE, | ||
156 | }, | ||
157 | { | ||
158 | .entity = UVC_GUID_UVC_PROCESSING, | ||
159 | .selector = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, | ||
160 | .index = 12, | ||
161 | .size = 1, | ||
162 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
163 | | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE, | ||
164 | }, | ||
165 | { | ||
166 | .entity = UVC_GUID_UVC_PROCESSING, | ||
167 | .selector = PU_WHITE_BALANCE_TEMPERATURE_CONTROL, | ||
168 | .index = 6, | ||
169 | .size = 2, | ||
170 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
171 | | UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE, | ||
172 | }, | ||
173 | { | ||
174 | .entity = UVC_GUID_UVC_PROCESSING, | ||
175 | .selector = PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, | ||
176 | .index = 13, | ||
177 | .size = 1, | ||
178 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR | ||
179 | | UVC_CONTROL_GET_DEF | UVC_CONTROL_RESTORE, | ||
180 | }, | ||
181 | { | ||
182 | .entity = UVC_GUID_UVC_PROCESSING, | ||
183 | .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, | ||
184 | .index = 7, | ||
185 | .size = 4, | ||
186 | .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE | ||
187 | | UVC_CONTROL_RESTORE | UVC_CONTROL_AUTO_UPDATE, | ||
188 | }, | ||
189 | }; | ||
190 | |||
191 | static struct uvc_menu_info power_line_frequency_controls[] = { | ||
192 | { 0, "Disabled" }, | ||
193 | { 1, "50 Hz" }, | ||
194 | { 2, "60 Hz" }, | ||
195 | }; | ||
196 | |||
197 | static struct uvc_menu_info exposure_auto_controls[] = { | ||
198 | { 1, "Manual Mode" }, | ||
199 | { 2, "Auto Mode" }, | ||
200 | { 4, "Shutter Priority Mode" }, | ||
201 | { 8, "Aperture Priority Mode" }, | ||
202 | }; | ||
203 | |||
204 | static struct uvc_control_mapping uvc_ctrl_mappings[] = { | ||
205 | { | ||
206 | .id = V4L2_CID_BRIGHTNESS, | ||
207 | .name = "Brightness", | ||
208 | .entity = UVC_GUID_UVC_PROCESSING, | ||
209 | .selector = PU_BRIGHTNESS_CONTROL, | ||
210 | .size = 16, | ||
211 | .offset = 0, | ||
212 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
213 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
214 | }, | ||
215 | { | ||
216 | .id = V4L2_CID_CONTRAST, | ||
217 | .name = "Contrast", | ||
218 | .entity = UVC_GUID_UVC_PROCESSING, | ||
219 | .selector = PU_CONTRAST_CONTROL, | ||
220 | .size = 16, | ||
221 | .offset = 0, | ||
222 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
223 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
224 | }, | ||
225 | { | ||
226 | .id = V4L2_CID_HUE, | ||
227 | .name = "Hue", | ||
228 | .entity = UVC_GUID_UVC_PROCESSING, | ||
229 | .selector = PU_HUE_CONTROL, | ||
230 | .size = 16, | ||
231 | .offset = 0, | ||
232 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
233 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
234 | }, | ||
235 | { | ||
236 | .id = V4L2_CID_SATURATION, | ||
237 | .name = "Saturation", | ||
238 | .entity = UVC_GUID_UVC_PROCESSING, | ||
239 | .selector = PU_SATURATION_CONTROL, | ||
240 | .size = 16, | ||
241 | .offset = 0, | ||
242 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
243 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
244 | }, | ||
245 | { | ||
246 | .id = V4L2_CID_SHARPNESS, | ||
247 | .name = "Sharpness", | ||
248 | .entity = UVC_GUID_UVC_PROCESSING, | ||
249 | .selector = PU_SHARPNESS_CONTROL, | ||
250 | .size = 16, | ||
251 | .offset = 0, | ||
252 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
253 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
254 | }, | ||
255 | { | ||
256 | .id = V4L2_CID_GAMMA, | ||
257 | .name = "Gamma", | ||
258 | .entity = UVC_GUID_UVC_PROCESSING, | ||
259 | .selector = PU_GAMMA_CONTROL, | ||
260 | .size = 16, | ||
261 | .offset = 0, | ||
262 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
263 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
264 | }, | ||
265 | { | ||
266 | .id = V4L2_CID_BACKLIGHT_COMPENSATION, | ||
267 | .name = "Backlight Compensation", | ||
268 | .entity = UVC_GUID_UVC_PROCESSING, | ||
269 | .selector = PU_BACKLIGHT_COMPENSATION_CONTROL, | ||
270 | .size = 16, | ||
271 | .offset = 0, | ||
272 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
273 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
274 | }, | ||
275 | { | ||
276 | .id = V4L2_CID_GAIN, | ||
277 | .name = "Gain", | ||
278 | .entity = UVC_GUID_UVC_PROCESSING, | ||
279 | .selector = PU_GAIN_CONTROL, | ||
280 | .size = 16, | ||
281 | .offset = 0, | ||
282 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
283 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
284 | }, | ||
285 | { | ||
286 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
287 | .name = "Power Line Frequency", | ||
288 | .entity = UVC_GUID_UVC_PROCESSING, | ||
289 | .selector = PU_POWER_LINE_FREQUENCY_CONTROL, | ||
290 | .size = 2, | ||
291 | .offset = 0, | ||
292 | .v4l2_type = V4L2_CTRL_TYPE_MENU, | ||
293 | .data_type = UVC_CTRL_DATA_TYPE_ENUM, | ||
294 | .menu_info = power_line_frequency_controls, | ||
295 | .menu_count = ARRAY_SIZE(power_line_frequency_controls), | ||
296 | }, | ||
297 | { | ||
298 | .id = V4L2_CID_HUE_AUTO, | ||
299 | .name = "Hue, Auto", | ||
300 | .entity = UVC_GUID_UVC_PROCESSING, | ||
301 | .selector = PU_HUE_AUTO_CONTROL, | ||
302 | .size = 1, | ||
303 | .offset = 0, | ||
304 | .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, | ||
305 | .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, | ||
306 | }, | ||
307 | { | ||
308 | .id = V4L2_CID_EXPOSURE_AUTO, | ||
309 | .name = "Exposure, Auto", | ||
310 | .entity = UVC_GUID_UVC_CAMERA, | ||
311 | .selector = CT_AE_MODE_CONTROL, | ||
312 | .size = 4, | ||
313 | .offset = 0, | ||
314 | .v4l2_type = V4L2_CTRL_TYPE_MENU, | ||
315 | .data_type = UVC_CTRL_DATA_TYPE_BITMASK, | ||
316 | .menu_info = exposure_auto_controls, | ||
317 | .menu_count = ARRAY_SIZE(exposure_auto_controls), | ||
318 | }, | ||
319 | { | ||
320 | .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY, | ||
321 | .name = "Exposure, Auto Priority", | ||
322 | .entity = UVC_GUID_UVC_CAMERA, | ||
323 | .selector = CT_AE_PRIORITY_CONTROL, | ||
324 | .size = 1, | ||
325 | .offset = 0, | ||
326 | .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, | ||
327 | .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, | ||
328 | }, | ||
329 | { | ||
330 | .id = V4L2_CID_EXPOSURE_ABSOLUTE, | ||
331 | .name = "Exposure (Absolute)", | ||
332 | .entity = UVC_GUID_UVC_CAMERA, | ||
333 | .selector = CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, | ||
334 | .size = 32, | ||
335 | .offset = 0, | ||
336 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
337 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
338 | }, | ||
339 | { | ||
340 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | ||
341 | .name = "White Balance Temperature, Auto", | ||
342 | .entity = UVC_GUID_UVC_PROCESSING, | ||
343 | .selector = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, | ||
344 | .size = 1, | ||
345 | .offset = 0, | ||
346 | .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, | ||
347 | .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, | ||
348 | }, | ||
349 | { | ||
350 | .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, | ||
351 | .name = "White Balance Temperature", | ||
352 | .entity = UVC_GUID_UVC_PROCESSING, | ||
353 | .selector = PU_WHITE_BALANCE_TEMPERATURE_CONTROL, | ||
354 | .size = 16, | ||
355 | .offset = 0, | ||
356 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
357 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
358 | }, | ||
359 | { | ||
360 | .id = V4L2_CID_AUTO_WHITE_BALANCE, | ||
361 | .name = "White Balance Component, Auto", | ||
362 | .entity = UVC_GUID_UVC_PROCESSING, | ||
363 | .selector = PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, | ||
364 | .size = 1, | ||
365 | .offset = 0, | ||
366 | .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, | ||
367 | .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, | ||
368 | }, | ||
369 | { | ||
370 | .id = V4L2_CID_BLUE_BALANCE, | ||
371 | .name = "White Balance Blue Component", | ||
372 | .entity = UVC_GUID_UVC_PROCESSING, | ||
373 | .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, | ||
374 | .size = 16, | ||
375 | .offset = 0, | ||
376 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
377 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
378 | }, | ||
379 | { | ||
380 | .id = V4L2_CID_RED_BALANCE, | ||
381 | .name = "White Balance Red Component", | ||
382 | .entity = UVC_GUID_UVC_PROCESSING, | ||
383 | .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, | ||
384 | .size = 16, | ||
385 | .offset = 16, | ||
386 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
387 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
388 | }, | ||
389 | { | ||
390 | .id = V4L2_CID_FOCUS_ABSOLUTE, | ||
391 | .name = "Focus (absolute)", | ||
392 | .entity = UVC_GUID_UVC_CAMERA, | ||
393 | .selector = CT_FOCUS_ABSOLUTE_CONTROL, | ||
394 | .size = 16, | ||
395 | .offset = 0, | ||
396 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
397 | .data_type = UVC_CTRL_DATA_TYPE_UNSIGNED, | ||
398 | }, | ||
399 | { | ||
400 | .id = V4L2_CID_FOCUS_AUTO, | ||
401 | .name = "Focus, Auto", | ||
402 | .entity = UVC_GUID_UVC_CAMERA, | ||
403 | .selector = CT_FOCUS_AUTO_CONTROL, | ||
404 | .size = 1, | ||
405 | .offset = 0, | ||
406 | .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, | ||
407 | .data_type = UVC_CTRL_DATA_TYPE_BOOLEAN, | ||
408 | }, | ||
409 | }; | ||
410 | |||
411 | /* ------------------------------------------------------------------------ | ||
412 | * Utility functions | ||
413 | */ | ||
414 | |||
415 | static inline __u8 *uvc_ctrl_data(struct uvc_control *ctrl, int id) | ||
416 | { | ||
417 | return ctrl->data + id * ctrl->info->size; | ||
418 | } | ||
419 | |||
420 | static inline int uvc_get_bit(const __u8 *data, int bit) | ||
421 | { | ||
422 | return (data[bit >> 3] >> (bit & 7)) & 1; | ||
423 | } | ||
424 | |||
425 | /* Extract the bit string specified by mapping->offset and mapping->size | ||
426 | * from the little-endian data stored at 'data' and return the result as | ||
427 | * a signed 32bit integer. Sign extension will be performed if the mapping | ||
428 | * references a signed data type. | ||
429 | */ | ||
430 | static __s32 uvc_get_le_value(const __u8 *data, | ||
431 | struct uvc_control_mapping *mapping) | ||
432 | { | ||
433 | int bits = mapping->size; | ||
434 | int offset = mapping->offset; | ||
435 | __s32 value = 0; | ||
436 | __u8 mask; | ||
437 | |||
438 | data += offset / 8; | ||
439 | offset &= 7; | ||
440 | mask = ((1LL << bits) - 1) << offset; | ||
441 | |||
442 | for (; bits > 0; data++) { | ||
443 | __u8 byte = *data & mask; | ||
444 | value |= offset > 0 ? (byte >> offset) : (byte << (-offset)); | ||
445 | bits -= 8 - (offset > 0 ? offset : 0); | ||
446 | offset -= 8; | ||
447 | mask = (1 << bits) - 1; | ||
448 | } | ||
449 | |||
450 | /* Sign-extend the value if needed */ | ||
451 | if (mapping->data_type == UVC_CTRL_DATA_TYPE_SIGNED) | ||
452 | value |= -(value & (1 << (mapping->size - 1))); | ||
453 | |||
454 | return value; | ||
455 | } | ||
456 | |||
457 | /* Set the bit string specified by mapping->offset and mapping->size | ||
458 | * in the little-endian data stored at 'data' to the value 'value'. | ||
459 | */ | ||
460 | static void uvc_set_le_value(__s32 value, __u8 *data, | ||
461 | struct uvc_control_mapping *mapping) | ||
462 | { | ||
463 | int bits = mapping->size; | ||
464 | int offset = mapping->offset; | ||
465 | __u8 mask; | ||
466 | |||
467 | data += offset / 8; | ||
468 | offset &= 7; | ||
469 | |||
470 | for (; bits > 0; data++) { | ||
471 | mask = ((1LL << bits) - 1) << offset; | ||
472 | *data = (*data & ~mask) | ((value << offset) & mask); | ||
473 | value >>= offset ? offset : 8; | ||
474 | bits -= 8 - offset; | ||
475 | offset = 0; | ||
476 | } | ||
477 | } | ||
478 | |||
479 | /* ------------------------------------------------------------------------ | ||
480 | * Terminal and unit management | ||
481 | */ | ||
482 | |||
483 | static const __u8 uvc_processing_guid[16] = UVC_GUID_UVC_PROCESSING; | ||
484 | static const __u8 uvc_camera_guid[16] = UVC_GUID_UVC_CAMERA; | ||
485 | static const __u8 uvc_media_transport_input_guid[16] = | ||
486 | UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT; | ||
487 | |||
488 | static int uvc_entity_match_guid(struct uvc_entity *entity, __u8 guid[16]) | ||
489 | { | ||
490 | switch (UVC_ENTITY_TYPE(entity)) { | ||
491 | case ITT_CAMERA: | ||
492 | return memcmp(uvc_camera_guid, guid, 16) == 0; | ||
493 | |||
494 | case ITT_MEDIA_TRANSPORT_INPUT: | ||
495 | return memcmp(uvc_media_transport_input_guid, guid, 16) == 0; | ||
496 | |||
497 | case VC_PROCESSING_UNIT: | ||
498 | return memcmp(uvc_processing_guid, guid, 16) == 0; | ||
499 | |||
500 | case VC_EXTENSION_UNIT: | ||
501 | return memcmp(entity->extension.guidExtensionCode, | ||
502 | guid, 16) == 0; | ||
503 | |||
504 | default: | ||
505 | return 0; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | /* ------------------------------------------------------------------------ | ||
510 | * UVC Controls | ||
511 | */ | ||
512 | |||
513 | static void __uvc_find_control(struct uvc_entity *entity, __u32 v4l2_id, | ||
514 | struct uvc_control_mapping **mapping, struct uvc_control **control, | ||
515 | int next) | ||
516 | { | ||
517 | struct uvc_control *ctrl; | ||
518 | struct uvc_control_mapping *map; | ||
519 | unsigned int i; | ||
520 | |||
521 | if (entity == NULL) | ||
522 | return; | ||
523 | |||
524 | for (i = 0; i < entity->ncontrols; ++i) { | ||
525 | ctrl = &entity->controls[i]; | ||
526 | if (ctrl->info == NULL) | ||
527 | continue; | ||
528 | |||
529 | list_for_each_entry(map, &ctrl->info->mappings, list) { | ||
530 | if ((map->id == v4l2_id) && !next) { | ||
531 | *control = ctrl; | ||
532 | *mapping = map; | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | if ((*mapping == NULL || (*mapping)->id > map->id) && | ||
537 | (map->id > v4l2_id) && next) { | ||
538 | *control = ctrl; | ||
539 | *mapping = map; | ||
540 | } | ||
541 | } | ||
542 | } | ||
543 | } | ||
544 | |||
545 | struct uvc_control *uvc_find_control(struct uvc_video_device *video, | ||
546 | __u32 v4l2_id, struct uvc_control_mapping **mapping) | ||
547 | { | ||
548 | struct uvc_control *ctrl = NULL; | ||
549 | struct uvc_entity *entity; | ||
550 | int next = v4l2_id & V4L2_CTRL_FLAG_NEXT_CTRL; | ||
551 | |||
552 | *mapping = NULL; | ||
553 | |||
554 | /* Mask the query flags. */ | ||
555 | v4l2_id &= V4L2_CTRL_ID_MASK; | ||
556 | |||
557 | /* Find the control. */ | ||
558 | __uvc_find_control(video->processing, v4l2_id, mapping, &ctrl, next); | ||
559 | if (ctrl && !next) | ||
560 | return ctrl; | ||
561 | |||
562 | list_for_each_entry(entity, &video->iterms, chain) { | ||
563 | __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next); | ||
564 | if (ctrl && !next) | ||
565 | return ctrl; | ||
566 | } | ||
567 | |||
568 | list_for_each_entry(entity, &video->extensions, chain) { | ||
569 | __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next); | ||
570 | if (ctrl && !next) | ||
571 | return ctrl; | ||
572 | } | ||
573 | |||
574 | if (ctrl == NULL && !next) | ||
575 | uvc_trace(UVC_TRACE_CONTROL, "Control 0x%08x not found.\n", | ||
576 | v4l2_id); | ||
577 | |||
578 | return ctrl; | ||
579 | } | ||
580 | |||
581 | int uvc_query_v4l2_ctrl(struct uvc_video_device *video, | ||
582 | struct v4l2_queryctrl *v4l2_ctrl) | ||
583 | { | ||
584 | struct uvc_control *ctrl; | ||
585 | struct uvc_control_mapping *mapping; | ||
586 | struct uvc_menu_info *menu; | ||
587 | unsigned int i; | ||
588 | __u8 data[8]; | ||
589 | int ret; | ||
590 | |||
591 | ctrl = uvc_find_control(video, v4l2_ctrl->id, &mapping); | ||
592 | if (ctrl == NULL) | ||
593 | return -EINVAL; | ||
594 | |||
595 | v4l2_ctrl->id = mapping->id; | ||
596 | v4l2_ctrl->type = mapping->v4l2_type; | ||
597 | strncpy(v4l2_ctrl->name, mapping->name, sizeof v4l2_ctrl->name); | ||
598 | v4l2_ctrl->flags = 0; | ||
599 | |||
600 | if (!(ctrl->info->flags & UVC_CONTROL_SET_CUR)) | ||
601 | v4l2_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; | ||
602 | |||
603 | if (ctrl->info->flags & UVC_CONTROL_GET_DEF) { | ||
604 | if ((ret = uvc_query_ctrl(video->dev, GET_DEF, ctrl->entity->id, | ||
605 | video->dev->intfnum, ctrl->info->selector, | ||
606 | &data, ctrl->info->size)) < 0) | ||
607 | return ret; | ||
608 | v4l2_ctrl->default_value = uvc_get_le_value(data, mapping); | ||
609 | } | ||
610 | |||
611 | if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { | ||
612 | v4l2_ctrl->minimum = 0; | ||
613 | v4l2_ctrl->maximum = mapping->menu_count - 1; | ||
614 | v4l2_ctrl->step = 1; | ||
615 | |||
616 | menu = mapping->menu_info; | ||
617 | for (i = 0; i < mapping->menu_count; ++i, ++menu) { | ||
618 | if (menu->value == v4l2_ctrl->default_value) { | ||
619 | v4l2_ctrl->default_value = i; | ||
620 | break; | ||
621 | } | ||
622 | } | ||
623 | |||
624 | return 0; | ||
625 | } | ||
626 | |||
627 | if (ctrl->info->flags & UVC_CONTROL_GET_MIN) { | ||
628 | if ((ret = uvc_query_ctrl(video->dev, GET_MIN, ctrl->entity->id, | ||
629 | video->dev->intfnum, ctrl->info->selector, | ||
630 | &data, ctrl->info->size)) < 0) | ||
631 | return ret; | ||
632 | v4l2_ctrl->minimum = uvc_get_le_value(data, mapping); | ||
633 | } | ||
634 | if (ctrl->info->flags & UVC_CONTROL_GET_MAX) { | ||
635 | if ((ret = uvc_query_ctrl(video->dev, GET_MAX, ctrl->entity->id, | ||
636 | video->dev->intfnum, ctrl->info->selector, | ||
637 | &data, ctrl->info->size)) < 0) | ||
638 | return ret; | ||
639 | v4l2_ctrl->maximum = uvc_get_le_value(data, mapping); | ||
640 | } | ||
641 | if (ctrl->info->flags & UVC_CONTROL_GET_RES) { | ||
642 | if ((ret = uvc_query_ctrl(video->dev, GET_RES, ctrl->entity->id, | ||
643 | video->dev->intfnum, ctrl->info->selector, | ||
644 | &data, ctrl->info->size)) < 0) | ||
645 | return ret; | ||
646 | v4l2_ctrl->step = uvc_get_le_value(data, mapping); | ||
647 | } | ||
648 | |||
649 | return 0; | ||
650 | } | ||
651 | |||
652 | |||
653 | /* -------------------------------------------------------------------------- | ||
654 | * Control transactions | ||
655 | * | ||
656 | * To make extended set operations as atomic as the hardware allows, controls | ||
657 | * are handled using begin/commit/rollback operations. | ||
658 | * | ||
659 | * At the beginning of a set request, uvc_ctrl_begin should be called to | ||
660 | * initialize the request. This function acquires the control lock. | ||
661 | * | ||
662 | * When setting a control, the new value is stored in the control data field | ||
663 | * at position UVC_CTRL_DATA_CURRENT. The control is then marked as dirty for | ||
664 | * later processing. If the UVC and V4L2 control sizes differ, the current | ||
665 | * value is loaded from the hardware before storing the new value in the data | ||
666 | * field. | ||
667 | * | ||
668 | * After processing all controls in the transaction, uvc_ctrl_commit or | ||
669 | * uvc_ctrl_rollback must be called to apply the pending changes to the | ||
670 | * hardware or revert them. When applying changes, all controls marked as | ||
671 | * dirty will be modified in the UVC device, and the dirty flag will be | ||
672 | * cleared. When reverting controls, the control data field | ||
673 | * UVC_CTRL_DATA_CURRENT is reverted to its previous value | ||
674 | * (UVC_CTRL_DATA_BACKUP) for all dirty controls. Both functions release the | ||
675 | * control lock. | ||
676 | */ | ||
677 | int uvc_ctrl_begin(struct uvc_video_device *video) | ||
678 | { | ||
679 | return mutex_lock_interruptible(&video->ctrl_mutex) ? -ERESTARTSYS : 0; | ||
680 | } | ||
681 | |||
682 | static int uvc_ctrl_commit_entity(struct uvc_device *dev, | ||
683 | struct uvc_entity *entity, int rollback) | ||
684 | { | ||
685 | struct uvc_control *ctrl; | ||
686 | unsigned int i; | ||
687 | int ret; | ||
688 | |||
689 | if (entity == NULL) | ||
690 | return 0; | ||
691 | |||
692 | for (i = 0; i < entity->ncontrols; ++i) { | ||
693 | ctrl = &entity->controls[i]; | ||
694 | if (ctrl->info == NULL || !ctrl->dirty) | ||
695 | continue; | ||
696 | |||
697 | if (!rollback) | ||
698 | ret = uvc_query_ctrl(dev, SET_CUR, ctrl->entity->id, | ||
699 | dev->intfnum, ctrl->info->selector, | ||
700 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
701 | ctrl->info->size); | ||
702 | else | ||
703 | ret = 0; | ||
704 | |||
705 | if (rollback || ret < 0) | ||
706 | memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
707 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), | ||
708 | ctrl->info->size); | ||
709 | |||
710 | if ((ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0) | ||
711 | ctrl->loaded = 0; | ||
712 | |||
713 | ctrl->dirty = 0; | ||
714 | |||
715 | if (ret < 0) | ||
716 | return ret; | ||
717 | } | ||
718 | |||
719 | return 0; | ||
720 | } | ||
721 | |||
722 | int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback) | ||
723 | { | ||
724 | struct uvc_entity *entity; | ||
725 | int ret = 0; | ||
726 | |||
727 | /* Find the control. */ | ||
728 | ret = uvc_ctrl_commit_entity(video->dev, video->processing, rollback); | ||
729 | if (ret < 0) | ||
730 | goto done; | ||
731 | |||
732 | list_for_each_entry(entity, &video->iterms, chain) { | ||
733 | ret = uvc_ctrl_commit_entity(video->dev, entity, rollback); | ||
734 | if (ret < 0) | ||
735 | goto done; | ||
736 | } | ||
737 | |||
738 | list_for_each_entry(entity, &video->extensions, chain) { | ||
739 | ret = uvc_ctrl_commit_entity(video->dev, entity, rollback); | ||
740 | if (ret < 0) | ||
741 | goto done; | ||
742 | } | ||
743 | |||
744 | done: | ||
745 | mutex_unlock(&video->ctrl_mutex); | ||
746 | return ret; | ||
747 | } | ||
748 | |||
749 | int uvc_ctrl_get(struct uvc_video_device *video, | ||
750 | struct v4l2_ext_control *xctrl) | ||
751 | { | ||
752 | struct uvc_control *ctrl; | ||
753 | struct uvc_control_mapping *mapping; | ||
754 | struct uvc_menu_info *menu; | ||
755 | unsigned int i; | ||
756 | int ret; | ||
757 | |||
758 | ctrl = uvc_find_control(video, xctrl->id, &mapping); | ||
759 | if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0) | ||
760 | return -EINVAL; | ||
761 | |||
762 | if (!ctrl->loaded) { | ||
763 | ret = uvc_query_ctrl(video->dev, GET_CUR, ctrl->entity->id, | ||
764 | video->dev->intfnum, ctrl->info->selector, | ||
765 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
766 | ctrl->info->size); | ||
767 | if (ret < 0) | ||
768 | return ret; | ||
769 | |||
770 | if ((ctrl->info->flags & UVC_CONTROL_AUTO_UPDATE) == 0) | ||
771 | ctrl->loaded = 1; | ||
772 | } | ||
773 | |||
774 | xctrl->value = uvc_get_le_value( | ||
775 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), mapping); | ||
776 | |||
777 | if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { | ||
778 | menu = mapping->menu_info; | ||
779 | for (i = 0; i < mapping->menu_count; ++i, ++menu) { | ||
780 | if (menu->value == xctrl->value) { | ||
781 | xctrl->value = i; | ||
782 | break; | ||
783 | } | ||
784 | } | ||
785 | } | ||
786 | |||
787 | return 0; | ||
788 | } | ||
789 | |||
790 | int uvc_ctrl_set(struct uvc_video_device *video, | ||
791 | struct v4l2_ext_control *xctrl) | ||
792 | { | ||
793 | struct uvc_control *ctrl; | ||
794 | struct uvc_control_mapping *mapping; | ||
795 | s32 value = xctrl->value; | ||
796 | int ret; | ||
797 | |||
798 | ctrl = uvc_find_control(video, xctrl->id, &mapping); | ||
799 | if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_SET_CUR) == 0) | ||
800 | return -EINVAL; | ||
801 | |||
802 | if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { | ||
803 | if (value < 0 || value >= mapping->menu_count) | ||
804 | return -EINVAL; | ||
805 | value = mapping->menu_info[value].value; | ||
806 | } | ||
807 | |||
808 | if (!ctrl->loaded && (ctrl->info->size * 8) != mapping->size) { | ||
809 | if ((ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0) { | ||
810 | memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
811 | 0, ctrl->info->size); | ||
812 | } else { | ||
813 | ret = uvc_query_ctrl(video->dev, GET_CUR, | ||
814 | ctrl->entity->id, video->dev->intfnum, | ||
815 | ctrl->info->selector, | ||
816 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
817 | ctrl->info->size); | ||
818 | if (ret < 0) | ||
819 | return ret; | ||
820 | } | ||
821 | |||
822 | if ((ctrl->info->flags & UVC_CONTROL_AUTO_UPDATE) == 0) | ||
823 | ctrl->loaded = 1; | ||
824 | } | ||
825 | |||
826 | if (!ctrl->dirty) { | ||
827 | memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), | ||
828 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
829 | ctrl->info->size); | ||
830 | } | ||
831 | |||
832 | uvc_set_le_value(value, | ||
833 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), mapping); | ||
834 | |||
835 | ctrl->dirty = 1; | ||
836 | ctrl->modified = 1; | ||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | /* -------------------------------------------------------------------------- | ||
841 | * Dynamic controls | ||
842 | */ | ||
843 | |||
844 | int uvc_xu_ctrl_query(struct uvc_video_device *video, | ||
845 | struct uvc_xu_control *xctrl, int set) | ||
846 | { | ||
847 | struct uvc_entity *entity; | ||
848 | struct uvc_control *ctrl = NULL; | ||
849 | unsigned int i, found = 0; | ||
850 | __u8 *data; | ||
851 | int ret; | ||
852 | |||
853 | /* Find the extension unit. */ | ||
854 | list_for_each_entry(entity, &video->extensions, chain) { | ||
855 | if (entity->id == xctrl->unit) | ||
856 | break; | ||
857 | } | ||
858 | |||
859 | if (entity->id != xctrl->unit) { | ||
860 | uvc_trace(UVC_TRACE_CONTROL, "Extension unit %u not found.\n", | ||
861 | xctrl->unit); | ||
862 | return -EINVAL; | ||
863 | } | ||
864 | |||
865 | /* Find the control. */ | ||
866 | for (i = 0; i < entity->ncontrols; ++i) { | ||
867 | ctrl = &entity->controls[i]; | ||
868 | if (ctrl->info == NULL) | ||
869 | continue; | ||
870 | |||
871 | if (ctrl->info->selector == xctrl->selector) { | ||
872 | found = 1; | ||
873 | break; | ||
874 | } | ||
875 | } | ||
876 | |||
877 | if (!found) { | ||
878 | uvc_trace(UVC_TRACE_CONTROL, | ||
879 | "Control " UVC_GUID_FORMAT "/%u not found.\n", | ||
880 | UVC_GUID_ARGS(entity->extension.guidExtensionCode), | ||
881 | xctrl->selector); | ||
882 | return -EINVAL; | ||
883 | } | ||
884 | |||
885 | /* Validate control data size. */ | ||
886 | if (ctrl->info->size != xctrl->size) | ||
887 | return -EINVAL; | ||
888 | |||
889 | if ((set && !(ctrl->info->flags & UVC_CONTROL_SET_CUR)) || | ||
890 | (!set && !(ctrl->info->flags & UVC_CONTROL_GET_CUR))) | ||
891 | return -EINVAL; | ||
892 | |||
893 | if (mutex_lock_interruptible(&video->ctrl_mutex)) | ||
894 | return -ERESTARTSYS; | ||
895 | |||
896 | memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), | ||
897 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
898 | xctrl->size); | ||
899 | data = uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT); | ||
900 | |||
901 | if (set && copy_from_user(data, xctrl->data, xctrl->size)) { | ||
902 | ret = -EFAULT; | ||
903 | goto out; | ||
904 | } | ||
905 | |||
906 | ret = uvc_query_ctrl(video->dev, set ? SET_CUR : GET_CUR, xctrl->unit, | ||
907 | video->dev->intfnum, xctrl->selector, data, | ||
908 | xctrl->size); | ||
909 | if (ret < 0) | ||
910 | goto out; | ||
911 | |||
912 | if (!set && copy_to_user(xctrl->data, data, xctrl->size)) { | ||
913 | ret = -EFAULT; | ||
914 | goto out; | ||
915 | } | ||
916 | |||
917 | out: | ||
918 | if (ret) | ||
919 | memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), | ||
920 | uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), | ||
921 | xctrl->size); | ||
922 | |||
923 | mutex_unlock(&video->ctrl_mutex); | ||
924 | return ret; | ||
925 | } | ||
926 | |||
927 | /* -------------------------------------------------------------------------- | ||
928 | * Suspend/resume | ||
929 | */ | ||
930 | |||
931 | /* | ||
932 | * Restore control values after resume, skipping controls that haven't been | ||
933 | * changed. | ||
934 | * | ||
935 | * TODO | ||
936 | * - Don't restore modified controls that are back to their default value. | ||
937 | * - Handle restore order (Auto-Exposure Mode should be restored before | ||
938 | * Exposure Time). | ||
939 | */ | ||
940 | int uvc_ctrl_resume_device(struct uvc_device *dev) | ||
941 | { | ||
942 | struct uvc_control *ctrl; | ||
943 | struct uvc_entity *entity; | ||
944 | unsigned int i; | ||
945 | int ret; | ||
946 | |||
947 | /* Walk the entities list and restore controls when possible. */ | ||
948 | list_for_each_entry(entity, &dev->entities, list) { | ||
949 | |||
950 | for (i = 0; i < entity->ncontrols; ++i) { | ||
951 | ctrl = &entity->controls[i]; | ||
952 | |||
953 | if (ctrl->info == NULL || !ctrl->modified || | ||
954 | (ctrl->info->flags & UVC_CONTROL_RESTORE) == 0) | ||
955 | continue; | ||
956 | |||
957 | printk(KERN_INFO "restoring control " UVC_GUID_FORMAT | ||
958 | "/%u/%u\n", UVC_GUID_ARGS(ctrl->info->entity), | ||
959 | ctrl->info->index, ctrl->info->selector); | ||
960 | ctrl->dirty = 1; | ||
961 | } | ||
962 | |||
963 | ret = uvc_ctrl_commit_entity(dev, entity, 0); | ||
964 | if (ret < 0) | ||
965 | return ret; | ||
966 | } | ||
967 | |||
968 | return 0; | ||
969 | } | ||
970 | |||
971 | /* -------------------------------------------------------------------------- | ||
972 | * Control and mapping handling | ||
973 | */ | ||
974 | |||
975 | static void uvc_ctrl_add_ctrl(struct uvc_device *dev, | ||
976 | struct uvc_control_info *info) | ||
977 | { | ||
978 | struct uvc_entity *entity; | ||
979 | struct uvc_control *ctrl = NULL; | ||
980 | int ret, found = 0; | ||
981 | unsigned int i; | ||
982 | |||
983 | list_for_each_entry(entity, &dev->entities, list) { | ||
984 | if (!uvc_entity_match_guid(entity, info->entity)) | ||
985 | continue; | ||
986 | |||
987 | for (i = 0; i < entity->ncontrols; ++i) { | ||
988 | ctrl = &entity->controls[i]; | ||
989 | if (ctrl->index == info->index) { | ||
990 | found = 1; | ||
991 | break; | ||
992 | } | ||
993 | } | ||
994 | |||
995 | if (found) | ||
996 | break; | ||
997 | } | ||
998 | |||
999 | if (!found) | ||
1000 | return; | ||
1001 | |||
1002 | if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) { | ||
1003 | /* Check if the device control information and length match | ||
1004 | * the user supplied information. | ||
1005 | */ | ||
1006 | __u32 flags; | ||
1007 | __le16 size; | ||
1008 | __u8 inf; | ||
1009 | |||
1010 | if ((ret = uvc_query_ctrl(dev, GET_LEN, ctrl->entity->id, | ||
1011 | dev->intfnum, info->selector, (__u8 *)&size, 2)) < 0) { | ||
1012 | uvc_trace(UVC_TRACE_CONTROL, "GET_LEN failed on " | ||
1013 | "control " UVC_GUID_FORMAT "/%u (%d).\n", | ||
1014 | UVC_GUID_ARGS(info->entity), info->selector, | ||
1015 | ret); | ||
1016 | return; | ||
1017 | } | ||
1018 | |||
1019 | if (info->size != le16_to_cpu(size)) { | ||
1020 | uvc_trace(UVC_TRACE_CONTROL, "Control " UVC_GUID_FORMAT | ||
1021 | "/%u size doesn't match user supplied " | ||
1022 | "value.\n", UVC_GUID_ARGS(info->entity), | ||
1023 | info->selector); | ||
1024 | return; | ||
1025 | } | ||
1026 | |||
1027 | if ((ret = uvc_query_ctrl(dev, GET_INFO, ctrl->entity->id, | ||
1028 | dev->intfnum, info->selector, &inf, 1)) < 0) { | ||
1029 | uvc_trace(UVC_TRACE_CONTROL, "GET_INFO failed on " | ||
1030 | "control " UVC_GUID_FORMAT "/%u (%d).\n", | ||
1031 | UVC_GUID_ARGS(info->entity), info->selector, | ||
1032 | ret); | ||
1033 | return; | ||
1034 | } | ||
1035 | |||
1036 | flags = info->flags; | ||
1037 | if (((flags & UVC_CONTROL_GET_CUR) && !(inf & (1 << 0))) || | ||
1038 | ((flags & UVC_CONTROL_SET_CUR) && !(inf & (1 << 1)))) { | ||
1039 | uvc_trace(UVC_TRACE_CONTROL, "Control " | ||
1040 | UVC_GUID_FORMAT "/%u flags don't match " | ||
1041 | "supported operations.\n", | ||
1042 | UVC_GUID_ARGS(info->entity), info->selector); | ||
1043 | return; | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | ctrl->info = info; | ||
1048 | ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA, GFP_KERNEL); | ||
1049 | uvc_trace(UVC_TRACE_CONTROL, "Added control " UVC_GUID_FORMAT "/%u " | ||
1050 | "to device %s entity %u\n", UVC_GUID_ARGS(ctrl->info->entity), | ||
1051 | ctrl->info->selector, dev->udev->devpath, entity->id); | ||
1052 | } | ||
1053 | |||
1054 | /* | ||
1055 | * Add an item to the UVC control information list, and instantiate a control | ||
1056 | * structure for each device that supports the control. | ||
1057 | */ | ||
1058 | int uvc_ctrl_add_info(struct uvc_control_info *info) | ||
1059 | { | ||
1060 | struct uvc_control_info *ctrl; | ||
1061 | struct uvc_device *dev; | ||
1062 | int ret = 0; | ||
1063 | |||
1064 | /* Find matching controls by walking the devices, entities and | ||
1065 | * controls list. | ||
1066 | */ | ||
1067 | mutex_lock(&uvc_driver.ctrl_mutex); | ||
1068 | |||
1069 | /* First check if the list contains a control matching the new one. | ||
1070 | * Bail out if it does. | ||
1071 | */ | ||
1072 | list_for_each_entry(ctrl, &uvc_driver.controls, list) { | ||
1073 | if (memcmp(ctrl->entity, info->entity, 16)) | ||
1074 | continue; | ||
1075 | |||
1076 | if (ctrl->selector == info->selector) { | ||
1077 | uvc_trace(UVC_TRACE_CONTROL, "Control " | ||
1078 | UVC_GUID_FORMAT "/%u is already defined.\n", | ||
1079 | UVC_GUID_ARGS(info->entity), info->selector); | ||
1080 | ret = -EEXIST; | ||
1081 | goto end; | ||
1082 | } | ||
1083 | if (ctrl->index == info->index) { | ||
1084 | uvc_trace(UVC_TRACE_CONTROL, "Control " | ||
1085 | UVC_GUID_FORMAT "/%u would overwrite index " | ||
1086 | "%d.\n", UVC_GUID_ARGS(info->entity), | ||
1087 | info->selector, info->index); | ||
1088 | ret = -EEXIST; | ||
1089 | goto end; | ||
1090 | } | ||
1091 | } | ||
1092 | |||
1093 | list_for_each_entry(dev, &uvc_driver.devices, list) | ||
1094 | uvc_ctrl_add_ctrl(dev, info); | ||
1095 | |||
1096 | INIT_LIST_HEAD(&info->mappings); | ||
1097 | list_add_tail(&info->list, &uvc_driver.controls); | ||
1098 | end: | ||
1099 | mutex_unlock(&uvc_driver.ctrl_mutex); | ||
1100 | return ret; | ||
1101 | } | ||
1102 | |||
1103 | int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping) | ||
1104 | { | ||
1105 | struct uvc_control_info *info; | ||
1106 | struct uvc_control_mapping *map; | ||
1107 | int ret = -EINVAL; | ||
1108 | |||
1109 | if (mapping->id & ~V4L2_CTRL_ID_MASK) { | ||
1110 | uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s' with " | ||
1111 | "invalid control id 0x%08x\n", mapping->name, | ||
1112 | mapping->id); | ||
1113 | return -EINVAL; | ||
1114 | } | ||
1115 | |||
1116 | mutex_lock(&uvc_driver.ctrl_mutex); | ||
1117 | list_for_each_entry(info, &uvc_driver.controls, list) { | ||
1118 | if (memcmp(info->entity, mapping->entity, 16) || | ||
1119 | info->selector != mapping->selector) | ||
1120 | continue; | ||
1121 | |||
1122 | if (info->size * 8 < mapping->size + mapping->offset) { | ||
1123 | uvc_trace(UVC_TRACE_CONTROL, "Mapping '%s' would " | ||
1124 | "overflow control " UVC_GUID_FORMAT "/%u\n", | ||
1125 | mapping->name, UVC_GUID_ARGS(info->entity), | ||
1126 | info->selector); | ||
1127 | ret = -EOVERFLOW; | ||
1128 | goto end; | ||
1129 | } | ||
1130 | |||
1131 | /* Check if the list contains a mapping matching the new one. | ||
1132 | * Bail out if it does. | ||
1133 | */ | ||
1134 | list_for_each_entry(map, &info->mappings, list) { | ||
1135 | if (map->id == mapping->id) { | ||
1136 | uvc_trace(UVC_TRACE_CONTROL, "Mapping '%s' is " | ||
1137 | "already defined.\n", mapping->name); | ||
1138 | ret = -EEXIST; | ||
1139 | goto end; | ||
1140 | } | ||
1141 | } | ||
1142 | |||
1143 | mapping->ctrl = info; | ||
1144 | list_add_tail(&mapping->list, &info->mappings); | ||
1145 | uvc_trace(UVC_TRACE_CONTROL, "Adding mapping %s to control " | ||
1146 | UVC_GUID_FORMAT "/%u.\n", mapping->name, | ||
1147 | UVC_GUID_ARGS(info->entity), info->selector); | ||
1148 | |||
1149 | ret = 0; | ||
1150 | break; | ||
1151 | } | ||
1152 | end: | ||
1153 | mutex_unlock(&uvc_driver.ctrl_mutex); | ||
1154 | return ret; | ||
1155 | } | ||
1156 | |||
1157 | /* | ||
1158 | * Initialize device controls. | ||
1159 | */ | ||
1160 | int uvc_ctrl_init_device(struct uvc_device *dev) | ||
1161 | { | ||
1162 | struct uvc_control_info *info; | ||
1163 | struct uvc_control *ctrl; | ||
1164 | struct uvc_entity *entity; | ||
1165 | unsigned int i; | ||
1166 | |||
1167 | /* Walk the entities list and instantiate controls */ | ||
1168 | list_for_each_entry(entity, &dev->entities, list) { | ||
1169 | unsigned int bControlSize = 0, ncontrols = 0; | ||
1170 | __u8 *bmControls = NULL; | ||
1171 | |||
1172 | if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) { | ||
1173 | bmControls = entity->extension.bmControls; | ||
1174 | bControlSize = entity->extension.bControlSize; | ||
1175 | } else if (UVC_ENTITY_TYPE(entity) == VC_PROCESSING_UNIT) { | ||
1176 | bmControls = entity->processing.bmControls; | ||
1177 | bControlSize = entity->processing.bControlSize; | ||
1178 | } else if (UVC_ENTITY_TYPE(entity) == ITT_CAMERA) { | ||
1179 | bmControls = entity->camera.bmControls; | ||
1180 | bControlSize = entity->camera.bControlSize; | ||
1181 | } | ||
1182 | |||
1183 | for (i = 0; i < bControlSize; ++i) | ||
1184 | ncontrols += hweight8(bmControls[i]); | ||
1185 | |||
1186 | if (ncontrols == 0) | ||
1187 | continue; | ||
1188 | |||
1189 | entity->controls = kzalloc(ncontrols*sizeof *ctrl, GFP_KERNEL); | ||
1190 | if (entity->controls == NULL) | ||
1191 | return -ENOMEM; | ||
1192 | |||
1193 | entity->ncontrols = ncontrols; | ||
1194 | |||
1195 | ctrl = entity->controls; | ||
1196 | for (i = 0; i < bControlSize * 8; ++i) { | ||
1197 | if (uvc_get_bit(bmControls, i) == 0) | ||
1198 | continue; | ||
1199 | |||
1200 | ctrl->entity = entity; | ||
1201 | ctrl->index = i; | ||
1202 | ctrl++; | ||
1203 | } | ||
1204 | } | ||
1205 | |||
1206 | /* Walk the controls info list and associate them with the device | ||
1207 | * controls, then add the device to the global device list. This has | ||
1208 | * to be done while holding the controls lock, to make sure | ||
1209 | * uvc_ctrl_add_info() will not get called in-between. | ||
1210 | */ | ||
1211 | mutex_lock(&uvc_driver.ctrl_mutex); | ||
1212 | list_for_each_entry(info, &uvc_driver.controls, list) | ||
1213 | uvc_ctrl_add_ctrl(dev, info); | ||
1214 | |||
1215 | list_add_tail(&dev->list, &uvc_driver.devices); | ||
1216 | mutex_unlock(&uvc_driver.ctrl_mutex); | ||
1217 | |||
1218 | return 0; | ||
1219 | } | ||
1220 | |||
1221 | /* | ||
1222 | * Cleanup device controls. | ||
1223 | */ | ||
1224 | void uvc_ctrl_cleanup_device(struct uvc_device *dev) | ||
1225 | { | ||
1226 | struct uvc_entity *entity; | ||
1227 | unsigned int i; | ||
1228 | |||
1229 | /* Remove the device from the global devices list */ | ||
1230 | mutex_lock(&uvc_driver.ctrl_mutex); | ||
1231 | if (dev->list.next != NULL) | ||
1232 | list_del(&dev->list); | ||
1233 | mutex_unlock(&uvc_driver.ctrl_mutex); | ||
1234 | |||
1235 | list_for_each_entry(entity, &dev->entities, list) { | ||
1236 | for (i = 0; i < entity->ncontrols; ++i) | ||
1237 | kfree(entity->controls[i].data); | ||
1238 | |||
1239 | kfree(entity->controls); | ||
1240 | } | ||
1241 | } | ||
1242 | |||
1243 | void uvc_ctrl_init(void) | ||
1244 | { | ||
1245 | struct uvc_control_info *ctrl = uvc_ctrls; | ||
1246 | struct uvc_control_info *cend = ctrl + ARRAY_SIZE(uvc_ctrls); | ||
1247 | struct uvc_control_mapping *mapping = uvc_ctrl_mappings; | ||
1248 | struct uvc_control_mapping *mend = | ||
1249 | mapping + ARRAY_SIZE(uvc_ctrl_mappings); | ||
1250 | |||
1251 | for (; ctrl < cend; ++ctrl) | ||
1252 | uvc_ctrl_add_info(ctrl); | ||
1253 | |||
1254 | for (; mapping < mend; ++mapping) | ||
1255 | uvc_ctrl_add_mapping(mapping); | ||
1256 | } | ||
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c new file mode 100644 index 000000000000..60ced589f898 --- /dev/null +++ b/drivers/media/video/uvc/uvc_driver.c | |||
@@ -0,0 +1,1955 @@ | |||
1 | /* | ||
2 | * uvc_driver.c -- USB Video Class driver | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | /* | ||
15 | * This driver aims to support video input devices compliant with the 'USB | ||
16 | * Video Class' specification. | ||
17 | * | ||
18 | * The driver doesn't support the deprecated v4l1 interface. It implements the | ||
19 | * mmap capture method only, and doesn't do any image format conversion in | ||
20 | * software. If your user-space application doesn't support YUYV or MJPEG, fix | ||
21 | * it :-). Please note that the MJPEG data have been stripped from their | ||
22 | * Huffman tables (DHT marker), you will need to add it back if your JPEG | ||
23 | * codec can't handle MJPEG data. | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/version.h> | ||
28 | #include <linux/list.h> | ||
29 | #include <linux/module.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/videodev2.h> | ||
32 | #include <linux/vmalloc.h> | ||
33 | #include <linux/wait.h> | ||
34 | #include <asm/atomic.h> | ||
35 | |||
36 | #include <media/v4l2-common.h> | ||
37 | |||
38 | #include "uvcvideo.h" | ||
39 | |||
40 | #define DRIVER_AUTHOR "Laurent Pinchart <laurent.pinchart@skynet.be>" | ||
41 | #define DRIVER_DESC "USB Video Class driver" | ||
42 | #ifndef DRIVER_VERSION | ||
43 | #define DRIVER_VERSION "v0.1.0" | ||
44 | #endif | ||
45 | |||
46 | static unsigned int uvc_quirks_param; | ||
47 | unsigned int uvc_trace_param; | ||
48 | |||
49 | /* ------------------------------------------------------------------------ | ||
50 | * Control, formats, ... | ||
51 | */ | ||
52 | |||
53 | static struct uvc_format_desc uvc_fmts[] = { | ||
54 | { | ||
55 | .name = "YUV 4:2:2 (YUYV)", | ||
56 | .guid = UVC_GUID_FORMAT_YUY2, | ||
57 | .fcc = V4L2_PIX_FMT_YUYV, | ||
58 | }, | ||
59 | { | ||
60 | .name = "YUV 4:2:0 (NV12)", | ||
61 | .guid = UVC_GUID_FORMAT_NV12, | ||
62 | .fcc = V4L2_PIX_FMT_NV12, | ||
63 | }, | ||
64 | { | ||
65 | .name = "MJPEG", | ||
66 | .guid = UVC_GUID_FORMAT_MJPEG, | ||
67 | .fcc = V4L2_PIX_FMT_MJPEG, | ||
68 | }, | ||
69 | { | ||
70 | .name = "YVU 4:2:0 (YV12)", | ||
71 | .guid = UVC_GUID_FORMAT_YV12, | ||
72 | .fcc = V4L2_PIX_FMT_YVU420, | ||
73 | }, | ||
74 | { | ||
75 | .name = "YUV 4:2:0 (I420)", | ||
76 | .guid = UVC_GUID_FORMAT_I420, | ||
77 | .fcc = V4L2_PIX_FMT_YUV420, | ||
78 | }, | ||
79 | { | ||
80 | .name = "YUV 4:2:2 (UYVY)", | ||
81 | .guid = UVC_GUID_FORMAT_UYVY, | ||
82 | .fcc = V4L2_PIX_FMT_UYVY, | ||
83 | }, | ||
84 | { | ||
85 | .name = "Greyscale", | ||
86 | .guid = UVC_GUID_FORMAT_Y800, | ||
87 | .fcc = V4L2_PIX_FMT_GREY, | ||
88 | }, | ||
89 | { | ||
90 | .name = "RGB Bayer", | ||
91 | .guid = UVC_GUID_FORMAT_BY8, | ||
92 | .fcc = V4L2_PIX_FMT_SBGGR8, | ||
93 | }, | ||
94 | }; | ||
95 | |||
96 | /* ------------------------------------------------------------------------ | ||
97 | * Utility functions | ||
98 | */ | ||
99 | |||
100 | struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts, | ||
101 | __u8 epaddr) | ||
102 | { | ||
103 | struct usb_host_endpoint *ep; | ||
104 | unsigned int i; | ||
105 | |||
106 | for (i = 0; i < alts->desc.bNumEndpoints; ++i) { | ||
107 | ep = &alts->endpoint[i]; | ||
108 | if (ep->desc.bEndpointAddress == epaddr) | ||
109 | return ep; | ||
110 | } | ||
111 | |||
112 | return NULL; | ||
113 | } | ||
114 | |||
115 | static struct uvc_format_desc *uvc_format_by_guid(const __u8 guid[16]) | ||
116 | { | ||
117 | unsigned int len = ARRAY_SIZE(uvc_fmts); | ||
118 | unsigned int i; | ||
119 | |||
120 | for (i = 0; i < len; ++i) { | ||
121 | if (memcmp(guid, uvc_fmts[i].guid, 16) == 0) | ||
122 | return &uvc_fmts[i]; | ||
123 | } | ||
124 | |||
125 | return NULL; | ||
126 | } | ||
127 | |||
128 | static __u32 uvc_colorspace(const __u8 primaries) | ||
129 | { | ||
130 | static const __u8 colorprimaries[] = { | ||
131 | 0, | ||
132 | V4L2_COLORSPACE_SRGB, | ||
133 | V4L2_COLORSPACE_470_SYSTEM_M, | ||
134 | V4L2_COLORSPACE_470_SYSTEM_BG, | ||
135 | V4L2_COLORSPACE_SMPTE170M, | ||
136 | V4L2_COLORSPACE_SMPTE240M, | ||
137 | }; | ||
138 | |||
139 | if (primaries < ARRAY_SIZE(colorprimaries)) | ||
140 | return colorprimaries[primaries]; | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | /* Simplify a fraction using a simple continued fraction decomposition. The | ||
146 | * idea here is to convert fractions such as 333333/10000000 to 1/30 using | ||
147 | * 32 bit arithmetic only. The algorithm is not perfect and relies upon two | ||
148 | * arbitrary parameters to remove non-significative terms from the simple | ||
149 | * continued fraction decomposition. Using 8 and 333 for n_terms and threshold | ||
150 | * respectively seems to give nice results. | ||
151 | */ | ||
152 | void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator, | ||
153 | unsigned int n_terms, unsigned int threshold) | ||
154 | { | ||
155 | uint32_t *an; | ||
156 | uint32_t x, y, r; | ||
157 | unsigned int i, n; | ||
158 | |||
159 | an = kmalloc(n_terms * sizeof *an, GFP_KERNEL); | ||
160 | if (an == NULL) | ||
161 | return; | ||
162 | |||
163 | /* Convert the fraction to a simple continued fraction. See | ||
164 | * http://mathforum.org/dr.math/faq/faq.fractions.html | ||
165 | * Stop if the current term is bigger than or equal to the given | ||
166 | * threshold. | ||
167 | */ | ||
168 | x = *numerator; | ||
169 | y = *denominator; | ||
170 | |||
171 | for (n = 0; n < n_terms && y != 0; ++n) { | ||
172 | an[n] = x / y; | ||
173 | if (an[n] >= threshold) { | ||
174 | if (n < 2) | ||
175 | n++; | ||
176 | break; | ||
177 | } | ||
178 | |||
179 | r = x - an[n] * y; | ||
180 | x = y; | ||
181 | y = r; | ||
182 | } | ||
183 | |||
184 | /* Expand the simple continued fraction back to an integer fraction. */ | ||
185 | x = 0; | ||
186 | y = 1; | ||
187 | |||
188 | for (i = n; i > 0; --i) { | ||
189 | r = y; | ||
190 | y = an[i-1] * y + x; | ||
191 | x = r; | ||
192 | } | ||
193 | |||
194 | *numerator = y; | ||
195 | *denominator = x; | ||
196 | kfree(an); | ||
197 | } | ||
198 | |||
199 | /* Convert a fraction to a frame interval in 100ns multiples. The idea here is | ||
200 | * to compute numerator / denominator * 10000000 using 32 bit fixed point | ||
201 | * arithmetic only. | ||
202 | */ | ||
203 | uint32_t uvc_fraction_to_interval(uint32_t numerator, uint32_t denominator) | ||
204 | { | ||
205 | uint32_t multiplier; | ||
206 | |||
207 | /* Saturate the result if the operation would overflow. */ | ||
208 | if (denominator == 0 || | ||
209 | numerator/denominator >= ((uint32_t)-1)/10000000) | ||
210 | return (uint32_t)-1; | ||
211 | |||
212 | /* Divide both the denominator and the multiplier by two until | ||
213 | * numerator * multiplier doesn't overflow. If anyone knows a better | ||
214 | * algorithm please let me know. | ||
215 | */ | ||
216 | multiplier = 10000000; | ||
217 | while (numerator > ((uint32_t)-1)/multiplier) { | ||
218 | multiplier /= 2; | ||
219 | denominator /= 2; | ||
220 | } | ||
221 | |||
222 | return denominator ? numerator * multiplier / denominator : 0; | ||
223 | } | ||
224 | |||
225 | /* ------------------------------------------------------------------------ | ||
226 | * Terminal and unit management | ||
227 | */ | ||
228 | |||
229 | static struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id) | ||
230 | { | ||
231 | struct uvc_entity *entity; | ||
232 | |||
233 | list_for_each_entry(entity, &dev->entities, list) { | ||
234 | if (entity->id == id) | ||
235 | return entity; | ||
236 | } | ||
237 | |||
238 | return NULL; | ||
239 | } | ||
240 | |||
241 | static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev, | ||
242 | int id, struct uvc_entity *entity) | ||
243 | { | ||
244 | unsigned int i; | ||
245 | |||
246 | if (entity == NULL) | ||
247 | entity = list_entry(&dev->entities, struct uvc_entity, list); | ||
248 | |||
249 | list_for_each_entry_continue(entity, &dev->entities, list) { | ||
250 | switch (UVC_ENTITY_TYPE(entity)) { | ||
251 | case TT_STREAMING: | ||
252 | if (entity->output.bSourceID == id) | ||
253 | return entity; | ||
254 | break; | ||
255 | |||
256 | case VC_PROCESSING_UNIT: | ||
257 | if (entity->processing.bSourceID == id) | ||
258 | return entity; | ||
259 | break; | ||
260 | |||
261 | case VC_SELECTOR_UNIT: | ||
262 | for (i = 0; i < entity->selector.bNrInPins; ++i) | ||
263 | if (entity->selector.baSourceID[i] == id) | ||
264 | return entity; | ||
265 | break; | ||
266 | |||
267 | case VC_EXTENSION_UNIT: | ||
268 | for (i = 0; i < entity->extension.bNrInPins; ++i) | ||
269 | if (entity->extension.baSourceID[i] == id) | ||
270 | return entity; | ||
271 | break; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | return NULL; | ||
276 | } | ||
277 | |||
278 | /* ------------------------------------------------------------------------ | ||
279 | * Descriptors handling | ||
280 | */ | ||
281 | |||
282 | static int uvc_parse_format(struct uvc_device *dev, | ||
283 | struct uvc_streaming *streaming, struct uvc_format *format, | ||
284 | __u32 **intervals, unsigned char *buffer, int buflen) | ||
285 | { | ||
286 | struct usb_interface *intf = streaming->intf; | ||
287 | struct usb_host_interface *alts = intf->cur_altsetting; | ||
288 | struct uvc_format_desc *fmtdesc; | ||
289 | struct uvc_frame *frame; | ||
290 | const unsigned char *start = buffer; | ||
291 | unsigned int interval; | ||
292 | unsigned int i, n; | ||
293 | __u8 ftype; | ||
294 | |||
295 | format->type = buffer[2]; | ||
296 | format->index = buffer[3]; | ||
297 | |||
298 | switch (buffer[2]) { | ||
299 | case VS_FORMAT_UNCOMPRESSED: | ||
300 | case VS_FORMAT_FRAME_BASED: | ||
301 | if (buflen < 27) { | ||
302 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
303 | "interface %d FORMAT error\n", | ||
304 | dev->udev->devnum, | ||
305 | alts->desc.bInterfaceNumber); | ||
306 | return -EINVAL; | ||
307 | } | ||
308 | |||
309 | /* Find the format descriptor from its GUID. */ | ||
310 | fmtdesc = uvc_format_by_guid(&buffer[5]); | ||
311 | |||
312 | if (fmtdesc != NULL) { | ||
313 | strncpy(format->name, fmtdesc->name, | ||
314 | sizeof format->name); | ||
315 | format->fcc = fmtdesc->fcc; | ||
316 | } else { | ||
317 | uvc_printk(KERN_INFO, "Unknown video format " | ||
318 | UVC_GUID_FORMAT "\n", | ||
319 | UVC_GUID_ARGS(&buffer[5])); | ||
320 | snprintf(format->name, sizeof format->name, | ||
321 | UVC_GUID_FORMAT, UVC_GUID_ARGS(&buffer[5])); | ||
322 | format->fcc = 0; | ||
323 | } | ||
324 | |||
325 | format->bpp = buffer[21]; | ||
326 | if (buffer[2] == VS_FORMAT_UNCOMPRESSED) { | ||
327 | ftype = VS_FRAME_UNCOMPRESSED; | ||
328 | } else { | ||
329 | ftype = VS_FRAME_FRAME_BASED; | ||
330 | if (buffer[27]) | ||
331 | format->flags = UVC_FMT_FLAG_COMPRESSED; | ||
332 | } | ||
333 | break; | ||
334 | |||
335 | case VS_FORMAT_MJPEG: | ||
336 | if (buflen < 11) { | ||
337 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
338 | "interface %d FORMAT error\n", | ||
339 | dev->udev->devnum, | ||
340 | alts->desc.bInterfaceNumber); | ||
341 | return -EINVAL; | ||
342 | } | ||
343 | |||
344 | strncpy(format->name, "MJPEG", sizeof format->name); | ||
345 | format->fcc = V4L2_PIX_FMT_MJPEG; | ||
346 | format->flags = UVC_FMT_FLAG_COMPRESSED; | ||
347 | format->bpp = 0; | ||
348 | ftype = VS_FRAME_MJPEG; | ||
349 | break; | ||
350 | |||
351 | case VS_FORMAT_DV: | ||
352 | if (buflen < 9) { | ||
353 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
354 | "interface %d FORMAT error\n", | ||
355 | dev->udev->devnum, | ||
356 | alts->desc.bInterfaceNumber); | ||
357 | return -EINVAL; | ||
358 | } | ||
359 | |||
360 | switch (buffer[8] & 0x7f) { | ||
361 | case 0: | ||
362 | strncpy(format->name, "SD-DV", sizeof format->name); | ||
363 | break; | ||
364 | case 1: | ||
365 | strncpy(format->name, "SDL-DV", sizeof format->name); | ||
366 | break; | ||
367 | case 2: | ||
368 | strncpy(format->name, "HD-DV", sizeof format->name); | ||
369 | break; | ||
370 | default: | ||
371 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
372 | "interface %d: unknown DV format %u\n", | ||
373 | dev->udev->devnum, | ||
374 | alts->desc.bInterfaceNumber, buffer[8]); | ||
375 | return -EINVAL; | ||
376 | } | ||
377 | |||
378 | strncat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz", | ||
379 | sizeof format->name); | ||
380 | |||
381 | format->fcc = V4L2_PIX_FMT_DV; | ||
382 | format->flags = UVC_FMT_FLAG_COMPRESSED | UVC_FMT_FLAG_STREAM; | ||
383 | format->bpp = 0; | ||
384 | ftype = 0; | ||
385 | |||
386 | /* Create a dummy frame descriptor. */ | ||
387 | frame = &format->frame[0]; | ||
388 | memset(&format->frame[0], 0, sizeof format->frame[0]); | ||
389 | frame->bFrameIntervalType = 1; | ||
390 | frame->dwDefaultFrameInterval = 1; | ||
391 | frame->dwFrameInterval = *intervals; | ||
392 | *(*intervals)++ = 1; | ||
393 | format->nframes = 1; | ||
394 | break; | ||
395 | |||
396 | case VS_FORMAT_MPEG2TS: | ||
397 | case VS_FORMAT_STREAM_BASED: | ||
398 | /* Not supported yet. */ | ||
399 | default: | ||
400 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
401 | "interface %d unsupported format %u\n", | ||
402 | dev->udev->devnum, alts->desc.bInterfaceNumber, | ||
403 | buffer[2]); | ||
404 | return -EINVAL; | ||
405 | } | ||
406 | |||
407 | uvc_trace(UVC_TRACE_DESCR, "Found format %s.\n", format->name); | ||
408 | |||
409 | buflen -= buffer[0]; | ||
410 | buffer += buffer[0]; | ||
411 | |||
412 | /* Parse the frame descriptors. Only uncompressed, MJPEG and frame | ||
413 | * based formats have frame descriptors. | ||
414 | */ | ||
415 | while (buflen > 2 && buffer[2] == ftype) { | ||
416 | frame = &format->frame[format->nframes]; | ||
417 | |||
418 | if (ftype != VS_FRAME_FRAME_BASED) | ||
419 | n = buflen > 25 ? buffer[25] : 0; | ||
420 | else | ||
421 | n = buflen > 21 ? buffer[21] : 0; | ||
422 | |||
423 | n = n ? n : 3; | ||
424 | |||
425 | if (buflen < 26 + 4*n) { | ||
426 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
427 | "interface %d FRAME error\n", dev->udev->devnum, | ||
428 | alts->desc.bInterfaceNumber); | ||
429 | return -EINVAL; | ||
430 | } | ||
431 | |||
432 | frame->bFrameIndex = buffer[3]; | ||
433 | frame->bmCapabilities = buffer[4]; | ||
434 | frame->wWidth = le16_to_cpup((__le16 *)&buffer[5]); | ||
435 | frame->wHeight = le16_to_cpup((__le16 *)&buffer[7]); | ||
436 | frame->dwMinBitRate = le32_to_cpup((__le32 *)&buffer[9]); | ||
437 | frame->dwMaxBitRate = le32_to_cpup((__le32 *)&buffer[13]); | ||
438 | if (ftype != VS_FRAME_FRAME_BASED) { | ||
439 | frame->dwMaxVideoFrameBufferSize = | ||
440 | le32_to_cpup((__le32 *)&buffer[17]); | ||
441 | frame->dwDefaultFrameInterval = | ||
442 | le32_to_cpup((__le32 *)&buffer[21]); | ||
443 | frame->bFrameIntervalType = buffer[25]; | ||
444 | } else { | ||
445 | frame->dwMaxVideoFrameBufferSize = 0; | ||
446 | frame->dwDefaultFrameInterval = | ||
447 | le32_to_cpup((__le32 *)&buffer[17]); | ||
448 | frame->bFrameIntervalType = buffer[21]; | ||
449 | } | ||
450 | frame->dwFrameInterval = *intervals; | ||
451 | |||
452 | /* Several UVC chipsets screw up dwMaxVideoFrameBufferSize | ||
453 | * completely. Observed behaviours range from setting the | ||
454 | * value to 1.1x the actual frame size of hardwiring the | ||
455 | * 16 low bits to 0. This results in a higher than necessary | ||
456 | * memory usage as well as a wrong image size information. For | ||
457 | * uncompressed formats this can be fixed by computing the | ||
458 | * value from the frame size. | ||
459 | */ | ||
460 | if (!(format->flags & UVC_FMT_FLAG_COMPRESSED)) | ||
461 | frame->dwMaxVideoFrameBufferSize = format->bpp | ||
462 | * frame->wWidth * frame->wHeight / 8; | ||
463 | |||
464 | /* Some bogus devices report dwMinFrameInterval equal to | ||
465 | * dwMaxFrameInterval and have dwFrameIntervalStep set to | ||
466 | * zero. Setting all null intervals to 1 fixes the problem and | ||
467 | * some other divisions by zero which could happen. | ||
468 | */ | ||
469 | for (i = 0; i < n; ++i) { | ||
470 | interval = le32_to_cpup((__le32 *)&buffer[26+4*i]); | ||
471 | *(*intervals)++ = interval ? interval : 1; | ||
472 | } | ||
473 | |||
474 | /* Make sure that the default frame interval stays between | ||
475 | * the boundaries. | ||
476 | */ | ||
477 | n -= frame->bFrameIntervalType ? 1 : 2; | ||
478 | frame->dwDefaultFrameInterval = | ||
479 | min(frame->dwFrameInterval[n], | ||
480 | max(frame->dwFrameInterval[0], | ||
481 | frame->dwDefaultFrameInterval)); | ||
482 | |||
483 | uvc_trace(UVC_TRACE_DESCR, "- %ux%u (%u.%u fps)\n", | ||
484 | frame->wWidth, frame->wHeight, | ||
485 | 10000000/frame->dwDefaultFrameInterval, | ||
486 | (100000000/frame->dwDefaultFrameInterval)%10); | ||
487 | |||
488 | format->nframes++; | ||
489 | buflen -= buffer[0]; | ||
490 | buffer += buffer[0]; | ||
491 | } | ||
492 | |||
493 | if (buflen > 2 && buffer[2] == VS_STILL_IMAGE_FRAME) { | ||
494 | buflen -= buffer[0]; | ||
495 | buffer += buffer[0]; | ||
496 | } | ||
497 | |||
498 | if (buflen > 2 && buffer[2] == VS_COLORFORMAT) { | ||
499 | if (buflen < 6) { | ||
500 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming" | ||
501 | "interface %d COLORFORMAT error\n", | ||
502 | dev->udev->devnum, | ||
503 | alts->desc.bInterfaceNumber); | ||
504 | return -EINVAL; | ||
505 | } | ||
506 | |||
507 | format->colorspace = uvc_colorspace(buffer[3]); | ||
508 | |||
509 | buflen -= buffer[0]; | ||
510 | buffer += buffer[0]; | ||
511 | } | ||
512 | |||
513 | return buffer - start; | ||
514 | } | ||
515 | |||
516 | static int uvc_parse_streaming(struct uvc_device *dev, | ||
517 | struct usb_interface *intf) | ||
518 | { | ||
519 | struct uvc_streaming *streaming = NULL; | ||
520 | struct uvc_format *format; | ||
521 | struct uvc_frame *frame; | ||
522 | struct usb_host_interface *alts = &intf->altsetting[0]; | ||
523 | unsigned char *_buffer, *buffer = alts->extra; | ||
524 | int _buflen, buflen = alts->extralen; | ||
525 | unsigned int nformats = 0, nframes = 0, nintervals = 0; | ||
526 | unsigned int size, i, n, p; | ||
527 | __u32 *interval; | ||
528 | __u16 psize; | ||
529 | int ret = -EINVAL; | ||
530 | |||
531 | if (intf->cur_altsetting->desc.bInterfaceSubClass | ||
532 | != SC_VIDEOSTREAMING) { | ||
533 | uvc_trace(UVC_TRACE_DESCR, "device %d interface %d isn't a " | ||
534 | "video streaming interface\n", dev->udev->devnum, | ||
535 | intf->altsetting[0].desc.bInterfaceNumber); | ||
536 | return -EINVAL; | ||
537 | } | ||
538 | |||
539 | if (usb_driver_claim_interface(&uvc_driver.driver, intf, dev)) { | ||
540 | uvc_trace(UVC_TRACE_DESCR, "device %d interface %d is already " | ||
541 | "claimed\n", dev->udev->devnum, | ||
542 | intf->altsetting[0].desc.bInterfaceNumber); | ||
543 | return -EINVAL; | ||
544 | } | ||
545 | |||
546 | streaming = kzalloc(sizeof *streaming, GFP_KERNEL); | ||
547 | if (streaming == NULL) { | ||
548 | usb_driver_release_interface(&uvc_driver.driver, intf); | ||
549 | return -EINVAL; | ||
550 | } | ||
551 | |||
552 | mutex_init(&streaming->mutex); | ||
553 | streaming->intf = usb_get_intf(intf); | ||
554 | streaming->intfnum = intf->cur_altsetting->desc.bInterfaceNumber; | ||
555 | |||
556 | /* The Pico iMage webcam has its class-specific interface descriptors | ||
557 | * after the endpoint descriptors. | ||
558 | */ | ||
559 | if (buflen == 0) { | ||
560 | for (i = 0; i < alts->desc.bNumEndpoints; ++i) { | ||
561 | struct usb_host_endpoint *ep = &alts->endpoint[i]; | ||
562 | |||
563 | if (ep->extralen == 0) | ||
564 | continue; | ||
565 | |||
566 | if (ep->extralen > 2 && | ||
567 | ep->extra[1] == USB_DT_CS_INTERFACE) { | ||
568 | uvc_trace(UVC_TRACE_DESCR, "trying extra data " | ||
569 | "from endpoint %u.\n", i); | ||
570 | buffer = alts->endpoint[i].extra; | ||
571 | buflen = alts->endpoint[i].extralen; | ||
572 | break; | ||
573 | } | ||
574 | } | ||
575 | } | ||
576 | |||
577 | /* Skip the standard interface descriptors. */ | ||
578 | while (buflen > 2 && buffer[1] != USB_DT_CS_INTERFACE) { | ||
579 | buflen -= buffer[0]; | ||
580 | buffer += buffer[0]; | ||
581 | } | ||
582 | |||
583 | if (buflen <= 2) { | ||
584 | uvc_trace(UVC_TRACE_DESCR, "no class-specific streaming " | ||
585 | "interface descriptors found.\n"); | ||
586 | goto error; | ||
587 | } | ||
588 | |||
589 | /* Parse the header descriptor. */ | ||
590 | if (buffer[2] == VS_OUTPUT_HEADER) { | ||
591 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface " | ||
592 | "%d OUTPUT HEADER descriptor is not supported.\n", | ||
593 | dev->udev->devnum, alts->desc.bInterfaceNumber); | ||
594 | goto error; | ||
595 | } else if (buffer[2] == VS_INPUT_HEADER) { | ||
596 | p = buflen >= 5 ? buffer[3] : 0; | ||
597 | n = buflen >= 12 ? buffer[12] : 0; | ||
598 | |||
599 | if (buflen < 13 + p*n || buffer[2] != VS_INPUT_HEADER) { | ||
600 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " | ||
601 | "interface %d INPUT HEADER descriptor is " | ||
602 | "invalid.\n", dev->udev->devnum, | ||
603 | alts->desc.bInterfaceNumber); | ||
604 | goto error; | ||
605 | } | ||
606 | |||
607 | streaming->header.bNumFormats = p; | ||
608 | streaming->header.bEndpointAddress = buffer[6]; | ||
609 | streaming->header.bmInfo = buffer[7]; | ||
610 | streaming->header.bTerminalLink = buffer[8]; | ||
611 | streaming->header.bStillCaptureMethod = buffer[9]; | ||
612 | streaming->header.bTriggerSupport = buffer[10]; | ||
613 | streaming->header.bTriggerUsage = buffer[11]; | ||
614 | streaming->header.bControlSize = n; | ||
615 | |||
616 | streaming->header.bmaControls = kmalloc(p*n, GFP_KERNEL); | ||
617 | if (streaming->header.bmaControls == NULL) { | ||
618 | ret = -ENOMEM; | ||
619 | goto error; | ||
620 | } | ||
621 | |||
622 | memcpy(streaming->header.bmaControls, &buffer[13], p*n); | ||
623 | } else { | ||
624 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface " | ||
625 | "%d HEADER descriptor not found.\n", dev->udev->devnum, | ||
626 | alts->desc.bInterfaceNumber); | ||
627 | goto error; | ||
628 | } | ||
629 | |||
630 | buflen -= buffer[0]; | ||
631 | buffer += buffer[0]; | ||
632 | |||
633 | _buffer = buffer; | ||
634 | _buflen = buflen; | ||
635 | |||
636 | /* Count the format and frame descriptors. */ | ||
637 | while (_buflen > 2) { | ||
638 | switch (_buffer[2]) { | ||
639 | case VS_FORMAT_UNCOMPRESSED: | ||
640 | case VS_FORMAT_MJPEG: | ||
641 | case VS_FORMAT_FRAME_BASED: | ||
642 | nformats++; | ||
643 | break; | ||
644 | |||
645 | case VS_FORMAT_DV: | ||
646 | /* DV format has no frame descriptor. We will create a | ||
647 | * dummy frame descriptor with a dummy frame interval. | ||
648 | */ | ||
649 | nformats++; | ||
650 | nframes++; | ||
651 | nintervals++; | ||
652 | break; | ||
653 | |||
654 | case VS_FORMAT_MPEG2TS: | ||
655 | case VS_FORMAT_STREAM_BASED: | ||
656 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " | ||
657 | "interface %d FORMAT %u is not supported.\n", | ||
658 | dev->udev->devnum, | ||
659 | alts->desc.bInterfaceNumber, _buffer[2]); | ||
660 | break; | ||
661 | |||
662 | case VS_FRAME_UNCOMPRESSED: | ||
663 | case VS_FRAME_MJPEG: | ||
664 | nframes++; | ||
665 | if (_buflen > 25) | ||
666 | nintervals += _buffer[25] ? _buffer[25] : 3; | ||
667 | break; | ||
668 | |||
669 | case VS_FRAME_FRAME_BASED: | ||
670 | nframes++; | ||
671 | if (_buflen > 21) | ||
672 | nintervals += _buffer[21] ? _buffer[21] : 3; | ||
673 | break; | ||
674 | } | ||
675 | |||
676 | _buflen -= _buffer[0]; | ||
677 | _buffer += _buffer[0]; | ||
678 | } | ||
679 | |||
680 | if (nformats == 0) { | ||
681 | uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface " | ||
682 | "%d has no supported formats defined.\n", | ||
683 | dev->udev->devnum, alts->desc.bInterfaceNumber); | ||
684 | goto error; | ||
685 | } | ||
686 | |||
687 | size = nformats * sizeof *format + nframes * sizeof *frame | ||
688 | + nintervals * sizeof *interval; | ||
689 | format = kzalloc(size, GFP_KERNEL); | ||
690 | if (format == NULL) { | ||
691 | ret = -ENOMEM; | ||
692 | goto error; | ||
693 | } | ||
694 | |||
695 | frame = (struct uvc_frame *)&format[nformats]; | ||
696 | interval = (__u32 *)&frame[nframes]; | ||
697 | |||
698 | streaming->format = format; | ||
699 | streaming->nformats = nformats; | ||
700 | |||
701 | /* Parse the format descriptors. */ | ||
702 | while (buflen > 2) { | ||
703 | switch (buffer[2]) { | ||
704 | case VS_FORMAT_UNCOMPRESSED: | ||
705 | case VS_FORMAT_MJPEG: | ||
706 | case VS_FORMAT_DV: | ||
707 | case VS_FORMAT_FRAME_BASED: | ||
708 | format->frame = frame; | ||
709 | ret = uvc_parse_format(dev, streaming, format, | ||
710 | &interval, buffer, buflen); | ||
711 | if (ret < 0) | ||
712 | goto error; | ||
713 | |||
714 | frame += format->nframes; | ||
715 | format++; | ||
716 | |||
717 | buflen -= ret; | ||
718 | buffer += ret; | ||
719 | continue; | ||
720 | |||
721 | default: | ||
722 | break; | ||
723 | } | ||
724 | |||
725 | buflen -= buffer[0]; | ||
726 | buffer += buffer[0]; | ||
727 | } | ||
728 | |||
729 | /* Parse the alternate settings to find the maximum bandwidth. */ | ||
730 | for (i = 0; i < intf->num_altsetting; ++i) { | ||
731 | struct usb_host_endpoint *ep; | ||
732 | alts = &intf->altsetting[i]; | ||
733 | ep = uvc_find_endpoint(alts, | ||
734 | streaming->header.bEndpointAddress); | ||
735 | if (ep == NULL) | ||
736 | continue; | ||
737 | |||
738 | psize = le16_to_cpu(ep->desc.wMaxPacketSize); | ||
739 | psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); | ||
740 | if (psize > streaming->maxpsize) | ||
741 | streaming->maxpsize = psize; | ||
742 | } | ||
743 | |||
744 | list_add_tail(&streaming->list, &dev->streaming); | ||
745 | return 0; | ||
746 | |||
747 | error: | ||
748 | usb_driver_release_interface(&uvc_driver.driver, intf); | ||
749 | usb_put_intf(intf); | ||
750 | kfree(streaming->format); | ||
751 | kfree(streaming->header.bmaControls); | ||
752 | kfree(streaming); | ||
753 | return ret; | ||
754 | } | ||
755 | |||
756 | /* Parse vendor-specific extensions. */ | ||
757 | static int uvc_parse_vendor_control(struct uvc_device *dev, | ||
758 | const unsigned char *buffer, int buflen) | ||
759 | { | ||
760 | struct usb_device *udev = dev->udev; | ||
761 | struct usb_host_interface *alts = dev->intf->cur_altsetting; | ||
762 | struct uvc_entity *unit; | ||
763 | unsigned int n, p; | ||
764 | int handled = 0; | ||
765 | |||
766 | switch (le16_to_cpu(dev->udev->descriptor.idVendor)) { | ||
767 | case 0x046d: /* Logitech */ | ||
768 | if (buffer[1] != 0x41 || buffer[2] != 0x01) | ||
769 | break; | ||
770 | |||
771 | /* Logitech implements several vendor specific functions | ||
772 | * through vendor specific extension units (LXU). | ||
773 | * | ||
774 | * The LXU descriptors are similar to XU descriptors | ||
775 | * (see "USB Device Video Class for Video Devices", section | ||
776 | * 3.7.2.6 "Extension Unit Descriptor") with the following | ||
777 | * differences: | ||
778 | * | ||
779 | * ---------------------------------------------------------- | ||
780 | * 0 bLength 1 Number | ||
781 | * Size of this descriptor, in bytes: 24+p+n*2 | ||
782 | * ---------------------------------------------------------- | ||
783 | * 23+p+n bmControlsType N Bitmap | ||
784 | * Individual bits in the set are defined: | ||
785 | * 0: Absolute | ||
786 | * 1: Relative | ||
787 | * | ||
788 | * This bitset is mapped exactly the same as bmControls. | ||
789 | * ---------------------------------------------------------- | ||
790 | * 23+p+n*2 bReserved 1 Boolean | ||
791 | * ---------------------------------------------------------- | ||
792 | * 24+p+n*2 iExtension 1 Index | ||
793 | * Index of a string descriptor that describes this | ||
794 | * extension unit. | ||
795 | * ---------------------------------------------------------- | ||
796 | */ | ||
797 | p = buflen >= 22 ? buffer[21] : 0; | ||
798 | n = buflen >= 25 + p ? buffer[22+p] : 0; | ||
799 | |||
800 | if (buflen < 25 + p + 2*n) { | ||
801 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
802 | "interface %d EXTENSION_UNIT error\n", | ||
803 | udev->devnum, alts->desc.bInterfaceNumber); | ||
804 | break; | ||
805 | } | ||
806 | |||
807 | unit = kzalloc(sizeof *unit + p + 2*n, GFP_KERNEL); | ||
808 | if (unit == NULL) | ||
809 | return -ENOMEM; | ||
810 | |||
811 | unit->id = buffer[3]; | ||
812 | unit->type = VC_EXTENSION_UNIT; | ||
813 | memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); | ||
814 | unit->extension.bNumControls = buffer[20]; | ||
815 | unit->extension.bNrInPins = | ||
816 | le16_to_cpup((__le16 *)&buffer[21]); | ||
817 | unit->extension.baSourceID = (__u8 *)unit + sizeof *unit; | ||
818 | memcpy(unit->extension.baSourceID, &buffer[22], p); | ||
819 | unit->extension.bControlSize = buffer[22+p]; | ||
820 | unit->extension.bmControls = (__u8 *)unit + sizeof *unit + p; | ||
821 | unit->extension.bmControlsType = (__u8 *)unit + sizeof *unit | ||
822 | + p + n; | ||
823 | memcpy(unit->extension.bmControls, &buffer[23+p], 2*n); | ||
824 | |||
825 | if (buffer[24+p+2*n] != 0) | ||
826 | usb_string(udev, buffer[24+p+2*n], unit->name, | ||
827 | sizeof unit->name); | ||
828 | else | ||
829 | sprintf(unit->name, "Extension %u", buffer[3]); | ||
830 | |||
831 | list_add_tail(&unit->list, &dev->entities); | ||
832 | handled = 1; | ||
833 | break; | ||
834 | } | ||
835 | |||
836 | return handled; | ||
837 | } | ||
838 | |||
839 | static int uvc_parse_standard_control(struct uvc_device *dev, | ||
840 | const unsigned char *buffer, int buflen) | ||
841 | { | ||
842 | struct usb_device *udev = dev->udev; | ||
843 | struct uvc_entity *unit, *term; | ||
844 | struct usb_interface *intf; | ||
845 | struct usb_host_interface *alts = dev->intf->cur_altsetting; | ||
846 | unsigned int i, n, p, len; | ||
847 | __u16 type; | ||
848 | |||
849 | switch (buffer[2]) { | ||
850 | case VC_HEADER: | ||
851 | n = buflen >= 12 ? buffer[11] : 0; | ||
852 | |||
853 | if (buflen < 12 || buflen < 12 + n) { | ||
854 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
855 | "interface %d HEADER error\n", udev->devnum, | ||
856 | alts->desc.bInterfaceNumber); | ||
857 | return -EINVAL; | ||
858 | } | ||
859 | |||
860 | dev->uvc_version = le16_to_cpup((__le16 *)&buffer[3]); | ||
861 | dev->clock_frequency = le32_to_cpup((__le32 *)&buffer[7]); | ||
862 | |||
863 | /* Parse all USB Video Streaming interfaces. */ | ||
864 | for (i = 0; i < n; ++i) { | ||
865 | intf = usb_ifnum_to_if(udev, buffer[12+i]); | ||
866 | if (intf == NULL) { | ||
867 | uvc_trace(UVC_TRACE_DESCR, "device %d " | ||
868 | "interface %d doesn't exists\n", | ||
869 | udev->devnum, i); | ||
870 | continue; | ||
871 | } | ||
872 | |||
873 | uvc_parse_streaming(dev, intf); | ||
874 | } | ||
875 | break; | ||
876 | |||
877 | case VC_INPUT_TERMINAL: | ||
878 | if (buflen < 8) { | ||
879 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
880 | "interface %d INPUT_TERMINAL error\n", | ||
881 | udev->devnum, alts->desc.bInterfaceNumber); | ||
882 | return -EINVAL; | ||
883 | } | ||
884 | |||
885 | /* Make sure the terminal type MSB is not null, otherwise it | ||
886 | * could be confused with a unit. | ||
887 | */ | ||
888 | type = le16_to_cpup((__le16 *)&buffer[4]); | ||
889 | if ((type & 0xff00) == 0) { | ||
890 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
891 | "interface %d INPUT_TERMINAL %d has invalid " | ||
892 | "type 0x%04x, skipping\n", udev->devnum, | ||
893 | alts->desc.bInterfaceNumber, | ||
894 | buffer[3], type); | ||
895 | return 0; | ||
896 | } | ||
897 | |||
898 | n = 0; | ||
899 | p = 0; | ||
900 | len = 8; | ||
901 | |||
902 | if (type == ITT_CAMERA) { | ||
903 | n = buflen >= 15 ? buffer[14] : 0; | ||
904 | len = 15; | ||
905 | |||
906 | } else if (type == ITT_MEDIA_TRANSPORT_INPUT) { | ||
907 | n = buflen >= 9 ? buffer[8] : 0; | ||
908 | p = buflen >= 10 + n ? buffer[9+n] : 0; | ||
909 | len = 10; | ||
910 | } | ||
911 | |||
912 | if (buflen < len + n + p) { | ||
913 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
914 | "interface %d INPUT_TERMINAL error\n", | ||
915 | udev->devnum, alts->desc.bInterfaceNumber); | ||
916 | return -EINVAL; | ||
917 | } | ||
918 | |||
919 | term = kzalloc(sizeof *term + n + p, GFP_KERNEL); | ||
920 | if (term == NULL) | ||
921 | return -ENOMEM; | ||
922 | |||
923 | term->id = buffer[3]; | ||
924 | term->type = type | UVC_TERM_INPUT; | ||
925 | |||
926 | if (UVC_ENTITY_TYPE(term) == ITT_CAMERA) { | ||
927 | term->camera.bControlSize = n; | ||
928 | term->camera.bmControls = (__u8 *)term + sizeof *term; | ||
929 | term->camera.wObjectiveFocalLengthMin = | ||
930 | le16_to_cpup((__le16 *)&buffer[8]); | ||
931 | term->camera.wObjectiveFocalLengthMax = | ||
932 | le16_to_cpup((__le16 *)&buffer[10]); | ||
933 | term->camera.wOcularFocalLength = | ||
934 | le16_to_cpup((__le16 *)&buffer[12]); | ||
935 | memcpy(term->camera.bmControls, &buffer[15], n); | ||
936 | } else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT) { | ||
937 | term->media.bControlSize = n; | ||
938 | term->media.bmControls = (__u8 *)term + sizeof *term; | ||
939 | term->media.bTransportModeSize = p; | ||
940 | term->media.bmTransportModes = (__u8 *)term | ||
941 | + sizeof *term + n; | ||
942 | memcpy(term->media.bmControls, &buffer[9], n); | ||
943 | memcpy(term->media.bmTransportModes, &buffer[10+n], p); | ||
944 | } | ||
945 | |||
946 | if (buffer[7] != 0) | ||
947 | usb_string(udev, buffer[7], term->name, | ||
948 | sizeof term->name); | ||
949 | else if (UVC_ENTITY_TYPE(term) == ITT_CAMERA) | ||
950 | sprintf(term->name, "Camera %u", buffer[3]); | ||
951 | else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT) | ||
952 | sprintf(term->name, "Media %u", buffer[3]); | ||
953 | else | ||
954 | sprintf(term->name, "Input %u", buffer[3]); | ||
955 | |||
956 | list_add_tail(&term->list, &dev->entities); | ||
957 | break; | ||
958 | |||
959 | case VC_OUTPUT_TERMINAL: | ||
960 | if (buflen < 9) { | ||
961 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
962 | "interface %d OUTPUT_TERMINAL error\n", | ||
963 | udev->devnum, alts->desc.bInterfaceNumber); | ||
964 | return -EINVAL; | ||
965 | } | ||
966 | |||
967 | /* Make sure the terminal type MSB is not null, otherwise it | ||
968 | * could be confused with a unit. | ||
969 | */ | ||
970 | type = le16_to_cpup((__le16 *)&buffer[4]); | ||
971 | if ((type & 0xff00) == 0) { | ||
972 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
973 | "interface %d OUTPUT_TERMINAL %d has invalid " | ||
974 | "type 0x%04x, skipping\n", udev->devnum, | ||
975 | alts->desc.bInterfaceNumber, buffer[3], type); | ||
976 | return 0; | ||
977 | } | ||
978 | |||
979 | term = kzalloc(sizeof *term, GFP_KERNEL); | ||
980 | if (term == NULL) | ||
981 | return -ENOMEM; | ||
982 | |||
983 | term->id = buffer[3]; | ||
984 | term->type = type | UVC_TERM_OUTPUT; | ||
985 | term->output.bSourceID = buffer[7]; | ||
986 | |||
987 | if (buffer[8] != 0) | ||
988 | usb_string(udev, buffer[8], term->name, | ||
989 | sizeof term->name); | ||
990 | else | ||
991 | sprintf(term->name, "Output %u", buffer[3]); | ||
992 | |||
993 | list_add_tail(&term->list, &dev->entities); | ||
994 | break; | ||
995 | |||
996 | case VC_SELECTOR_UNIT: | ||
997 | p = buflen >= 5 ? buffer[4] : 0; | ||
998 | |||
999 | if (buflen < 5 || buflen < 6 + p) { | ||
1000 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
1001 | "interface %d SELECTOR_UNIT error\n", | ||
1002 | udev->devnum, alts->desc.bInterfaceNumber); | ||
1003 | return -EINVAL; | ||
1004 | } | ||
1005 | |||
1006 | unit = kzalloc(sizeof *unit + p, GFP_KERNEL); | ||
1007 | if (unit == NULL) | ||
1008 | return -ENOMEM; | ||
1009 | |||
1010 | unit->id = buffer[3]; | ||
1011 | unit->type = buffer[2]; | ||
1012 | unit->selector.bNrInPins = buffer[4]; | ||
1013 | unit->selector.baSourceID = (__u8 *)unit + sizeof *unit; | ||
1014 | memcpy(unit->selector.baSourceID, &buffer[5], p); | ||
1015 | |||
1016 | if (buffer[5+p] != 0) | ||
1017 | usb_string(udev, buffer[5+p], unit->name, | ||
1018 | sizeof unit->name); | ||
1019 | else | ||
1020 | sprintf(unit->name, "Selector %u", buffer[3]); | ||
1021 | |||
1022 | list_add_tail(&unit->list, &dev->entities); | ||
1023 | break; | ||
1024 | |||
1025 | case VC_PROCESSING_UNIT: | ||
1026 | n = buflen >= 8 ? buffer[7] : 0; | ||
1027 | p = dev->uvc_version >= 0x0110 ? 10 : 9; | ||
1028 | |||
1029 | if (buflen < p + n) { | ||
1030 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
1031 | "interface %d PROCESSING_UNIT error\n", | ||
1032 | udev->devnum, alts->desc.bInterfaceNumber); | ||
1033 | return -EINVAL; | ||
1034 | } | ||
1035 | |||
1036 | unit = kzalloc(sizeof *unit + n, GFP_KERNEL); | ||
1037 | if (unit == NULL) | ||
1038 | return -ENOMEM; | ||
1039 | |||
1040 | unit->id = buffer[3]; | ||
1041 | unit->type = buffer[2]; | ||
1042 | unit->processing.bSourceID = buffer[4]; | ||
1043 | unit->processing.wMaxMultiplier = | ||
1044 | le16_to_cpup((__le16 *)&buffer[5]); | ||
1045 | unit->processing.bControlSize = buffer[7]; | ||
1046 | unit->processing.bmControls = (__u8 *)unit + sizeof *unit; | ||
1047 | memcpy(unit->processing.bmControls, &buffer[8], n); | ||
1048 | if (dev->uvc_version >= 0x0110) | ||
1049 | unit->processing.bmVideoStandards = buffer[9+n]; | ||
1050 | |||
1051 | if (buffer[8+n] != 0) | ||
1052 | usb_string(udev, buffer[8+n], unit->name, | ||
1053 | sizeof unit->name); | ||
1054 | else | ||
1055 | sprintf(unit->name, "Processing %u", buffer[3]); | ||
1056 | |||
1057 | list_add_tail(&unit->list, &dev->entities); | ||
1058 | break; | ||
1059 | |||
1060 | case VC_EXTENSION_UNIT: | ||
1061 | p = buflen >= 22 ? buffer[21] : 0; | ||
1062 | n = buflen >= 24 + p ? buffer[22+p] : 0; | ||
1063 | |||
1064 | if (buflen < 24 + p + n) { | ||
1065 | uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " | ||
1066 | "interface %d EXTENSION_UNIT error\n", | ||
1067 | udev->devnum, alts->desc.bInterfaceNumber); | ||
1068 | return -EINVAL; | ||
1069 | } | ||
1070 | |||
1071 | unit = kzalloc(sizeof *unit + p + n, GFP_KERNEL); | ||
1072 | if (unit == NULL) | ||
1073 | return -ENOMEM; | ||
1074 | |||
1075 | unit->id = buffer[3]; | ||
1076 | unit->type = buffer[2]; | ||
1077 | memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); | ||
1078 | unit->extension.bNumControls = buffer[20]; | ||
1079 | unit->extension.bNrInPins = | ||
1080 | le16_to_cpup((__le16 *)&buffer[21]); | ||
1081 | unit->extension.baSourceID = (__u8 *)unit + sizeof *unit; | ||
1082 | memcpy(unit->extension.baSourceID, &buffer[22], p); | ||
1083 | unit->extension.bControlSize = buffer[22+p]; | ||
1084 | unit->extension.bmControls = (__u8 *)unit + sizeof *unit + p; | ||
1085 | memcpy(unit->extension.bmControls, &buffer[23+p], n); | ||
1086 | |||
1087 | if (buffer[23+p+n] != 0) | ||
1088 | usb_string(udev, buffer[23+p+n], unit->name, | ||
1089 | sizeof unit->name); | ||
1090 | else | ||
1091 | sprintf(unit->name, "Extension %u", buffer[3]); | ||
1092 | |||
1093 | list_add_tail(&unit->list, &dev->entities); | ||
1094 | break; | ||
1095 | |||
1096 | default: | ||
1097 | uvc_trace(UVC_TRACE_DESCR, "Found an unknown CS_INTERFACE " | ||
1098 | "descriptor (%u)\n", buffer[2]); | ||
1099 | break; | ||
1100 | } | ||
1101 | |||
1102 | return 0; | ||
1103 | } | ||
1104 | |||
1105 | static int uvc_parse_control(struct uvc_device *dev) | ||
1106 | { | ||
1107 | struct usb_host_interface *alts = dev->intf->cur_altsetting; | ||
1108 | unsigned char *buffer = alts->extra; | ||
1109 | int buflen = alts->extralen; | ||
1110 | int ret; | ||
1111 | |||
1112 | /* Parse the default alternate setting only, as the UVC specification | ||
1113 | * defines a single alternate setting, the default alternate setting | ||
1114 | * zero. | ||
1115 | */ | ||
1116 | |||
1117 | while (buflen > 2) { | ||
1118 | if (uvc_parse_vendor_control(dev, buffer, buflen) || | ||
1119 | buffer[1] != USB_DT_CS_INTERFACE) | ||
1120 | goto next_descriptor; | ||
1121 | |||
1122 | if ((ret = uvc_parse_standard_control(dev, buffer, buflen)) < 0) | ||
1123 | return ret; | ||
1124 | |||
1125 | next_descriptor: | ||
1126 | buflen -= buffer[0]; | ||
1127 | buffer += buffer[0]; | ||
1128 | } | ||
1129 | |||
1130 | /* Check if the optional status endpoint is present. */ | ||
1131 | if (alts->desc.bNumEndpoints == 1) { | ||
1132 | struct usb_host_endpoint *ep = &alts->endpoint[0]; | ||
1133 | struct usb_endpoint_descriptor *desc = &ep->desc; | ||
1134 | |||
1135 | if (usb_endpoint_is_int_in(desc) && | ||
1136 | le16_to_cpu(desc->wMaxPacketSize) >= 8 && | ||
1137 | desc->bInterval != 0) { | ||
1138 | uvc_trace(UVC_TRACE_DESCR, "Found a Status endpoint " | ||
1139 | "(addr %02x).\n", desc->bEndpointAddress); | ||
1140 | dev->int_ep = ep; | ||
1141 | } | ||
1142 | } | ||
1143 | |||
1144 | return 0; | ||
1145 | } | ||
1146 | |||
1147 | /* ------------------------------------------------------------------------ | ||
1148 | * USB probe and disconnect | ||
1149 | */ | ||
1150 | |||
1151 | /* | ||
1152 | * Unregister the video devices. | ||
1153 | */ | ||
1154 | static void uvc_unregister_video(struct uvc_device *dev) | ||
1155 | { | ||
1156 | if (dev->video.vdev) { | ||
1157 | if (dev->video.vdev->minor == -1) | ||
1158 | video_device_release(dev->video.vdev); | ||
1159 | else | ||
1160 | video_unregister_device(dev->video.vdev); | ||
1161 | dev->video.vdev = NULL; | ||
1162 | } | ||
1163 | } | ||
1164 | |||
1165 | /* | ||
1166 | * Scan the UVC descriptors to locate a chain starting at an Output Terminal | ||
1167 | * and containing the following units: | ||
1168 | * | ||
1169 | * - a USB Streaming Output Terminal | ||
1170 | * - zero or one Processing Unit | ||
1171 | * - zero, one or mode single-input Selector Units | ||
1172 | * - zero or one multiple-input Selector Units, provided all inputs are | ||
1173 | * connected to input terminals | ||
1174 | * - zero, one or mode single-input Extension Units | ||
1175 | * - one Camera Input Terminal, or one or more External terminals. | ||
1176 | * | ||
1177 | * A side forward scan is made on each detected entity to check for additional | ||
1178 | * extension units. | ||
1179 | */ | ||
1180 | static int uvc_scan_chain_entity(struct uvc_video_device *video, | ||
1181 | struct uvc_entity *entity) | ||
1182 | { | ||
1183 | switch (UVC_ENTITY_TYPE(entity)) { | ||
1184 | case VC_EXTENSION_UNIT: | ||
1185 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1186 | printk(" <- XU %d", entity->id); | ||
1187 | |||
1188 | if (entity->extension.bNrInPins != 1) { | ||
1189 | uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more " | ||
1190 | "than 1 input pin.\n", entity->id); | ||
1191 | return -1; | ||
1192 | } | ||
1193 | |||
1194 | list_add_tail(&entity->chain, &video->extensions); | ||
1195 | break; | ||
1196 | |||
1197 | case VC_PROCESSING_UNIT: | ||
1198 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1199 | printk(" <- PU %d", entity->id); | ||
1200 | |||
1201 | if (video->processing != NULL) { | ||
1202 | uvc_trace(UVC_TRACE_DESCR, "Found multiple " | ||
1203 | "Processing Units in chain.\n"); | ||
1204 | return -1; | ||
1205 | } | ||
1206 | |||
1207 | video->processing = entity; | ||
1208 | break; | ||
1209 | |||
1210 | case VC_SELECTOR_UNIT: | ||
1211 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1212 | printk(" <- SU %d", entity->id); | ||
1213 | |||
1214 | /* Single-input selector units are ignored. */ | ||
1215 | if (entity->selector.bNrInPins == 1) | ||
1216 | break; | ||
1217 | |||
1218 | if (video->selector != NULL) { | ||
1219 | uvc_trace(UVC_TRACE_DESCR, "Found multiple Selector " | ||
1220 | "Units in chain.\n"); | ||
1221 | return -1; | ||
1222 | } | ||
1223 | |||
1224 | video->selector = entity; | ||
1225 | break; | ||
1226 | |||
1227 | case ITT_VENDOR_SPECIFIC: | ||
1228 | case ITT_CAMERA: | ||
1229 | case ITT_MEDIA_TRANSPORT_INPUT: | ||
1230 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1231 | printk(" <- IT %d\n", entity->id); | ||
1232 | |||
1233 | list_add_tail(&entity->chain, &video->iterms); | ||
1234 | break; | ||
1235 | |||
1236 | default: | ||
1237 | uvc_trace(UVC_TRACE_DESCR, "Unsupported entity type " | ||
1238 | "0x%04x found in chain.\n", UVC_ENTITY_TYPE(entity)); | ||
1239 | return -1; | ||
1240 | } | ||
1241 | |||
1242 | return 0; | ||
1243 | } | ||
1244 | |||
1245 | static int uvc_scan_chain_forward(struct uvc_video_device *video, | ||
1246 | struct uvc_entity *entity, struct uvc_entity *prev) | ||
1247 | { | ||
1248 | struct uvc_entity *forward; | ||
1249 | int found; | ||
1250 | |||
1251 | /* Forward scan */ | ||
1252 | forward = NULL; | ||
1253 | found = 0; | ||
1254 | |||
1255 | while (1) { | ||
1256 | forward = uvc_entity_by_reference(video->dev, entity->id, | ||
1257 | forward); | ||
1258 | if (forward == NULL) | ||
1259 | break; | ||
1260 | |||
1261 | if (UVC_ENTITY_TYPE(forward) != VC_EXTENSION_UNIT || | ||
1262 | forward == prev) | ||
1263 | continue; | ||
1264 | |||
1265 | if (forward->extension.bNrInPins != 1) { | ||
1266 | uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has" | ||
1267 | "more than 1 input pin.\n", entity->id); | ||
1268 | return -1; | ||
1269 | } | ||
1270 | |||
1271 | list_add_tail(&forward->chain, &video->extensions); | ||
1272 | if (uvc_trace_param & UVC_TRACE_PROBE) { | ||
1273 | if (!found) | ||
1274 | printk(" (-> XU"); | ||
1275 | |||
1276 | printk(" %d", forward->id); | ||
1277 | found = 1; | ||
1278 | } | ||
1279 | } | ||
1280 | if (found) | ||
1281 | printk(")"); | ||
1282 | |||
1283 | return 0; | ||
1284 | } | ||
1285 | |||
1286 | static int uvc_scan_chain_backward(struct uvc_video_device *video, | ||
1287 | struct uvc_entity *entity) | ||
1288 | { | ||
1289 | struct uvc_entity *term; | ||
1290 | int id = -1, i; | ||
1291 | |||
1292 | switch (UVC_ENTITY_TYPE(entity)) { | ||
1293 | case VC_EXTENSION_UNIT: | ||
1294 | id = entity->extension.baSourceID[0]; | ||
1295 | break; | ||
1296 | |||
1297 | case VC_PROCESSING_UNIT: | ||
1298 | id = entity->processing.bSourceID; | ||
1299 | break; | ||
1300 | |||
1301 | case VC_SELECTOR_UNIT: | ||
1302 | /* Single-input selector units are ignored. */ | ||
1303 | if (entity->selector.bNrInPins == 1) { | ||
1304 | id = entity->selector.baSourceID[0]; | ||
1305 | break; | ||
1306 | } | ||
1307 | |||
1308 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1309 | printk(" <- IT"); | ||
1310 | |||
1311 | video->selector = entity; | ||
1312 | for (i = 0; i < entity->selector.bNrInPins; ++i) { | ||
1313 | id = entity->selector.baSourceID[i]; | ||
1314 | term = uvc_entity_by_id(video->dev, id); | ||
1315 | if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) { | ||
1316 | uvc_trace(UVC_TRACE_DESCR, "Selector unit %d " | ||
1317 | "input %d isn't connected to an " | ||
1318 | "input terminal\n", entity->id, i); | ||
1319 | return -1; | ||
1320 | } | ||
1321 | |||
1322 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1323 | printk(" %d", term->id); | ||
1324 | |||
1325 | list_add_tail(&term->chain, &video->iterms); | ||
1326 | uvc_scan_chain_forward(video, term, entity); | ||
1327 | } | ||
1328 | |||
1329 | if (uvc_trace_param & UVC_TRACE_PROBE) | ||
1330 | printk("\n"); | ||
1331 | |||
1332 | id = 0; | ||
1333 | break; | ||
1334 | } | ||
1335 | |||
1336 | return id; | ||
1337 | } | ||
1338 | |||
1339 | static int uvc_scan_chain(struct uvc_video_device *video) | ||
1340 | { | ||
1341 | struct uvc_entity *entity, *prev; | ||
1342 | int id; | ||
1343 | |||
1344 | entity = video->oterm; | ||
1345 | uvc_trace(UVC_TRACE_PROBE, "Scanning UVC chain: OT %d", entity->id); | ||
1346 | id = entity->output.bSourceID; | ||
1347 | while (id != 0) { | ||
1348 | prev = entity; | ||
1349 | entity = uvc_entity_by_id(video->dev, id); | ||
1350 | if (entity == NULL) { | ||
1351 | uvc_trace(UVC_TRACE_DESCR, "Found reference to " | ||
1352 | "unknown entity %d.\n", id); | ||
1353 | return -1; | ||
1354 | } | ||
1355 | |||
1356 | /* Process entity */ | ||
1357 | if (uvc_scan_chain_entity(video, entity) < 0) | ||
1358 | return -1; | ||
1359 | |||
1360 | /* Forward scan */ | ||
1361 | if (uvc_scan_chain_forward(video, entity, prev) < 0) | ||
1362 | return -1; | ||
1363 | |||
1364 | /* Stop when a terminal is found. */ | ||
1365 | if (!UVC_ENTITY_IS_UNIT(entity)) | ||
1366 | break; | ||
1367 | |||
1368 | /* Backward scan */ | ||
1369 | id = uvc_scan_chain_backward(video, entity); | ||
1370 | if (id < 0) | ||
1371 | return id; | ||
1372 | } | ||
1373 | |||
1374 | /* Initialize the video buffers queue. */ | ||
1375 | uvc_queue_init(&video->queue); | ||
1376 | |||
1377 | return 0; | ||
1378 | } | ||
1379 | |||
1380 | /* | ||
1381 | * Register the video devices. | ||
1382 | * | ||
1383 | * The driver currently supports a single video device per control interface | ||
1384 | * only. The terminal and units must match the following structure: | ||
1385 | * | ||
1386 | * ITT_CAMERA -> VC_PROCESSING_UNIT -> VC_EXTENSION_UNIT{0,n} -> TT_STREAMING | ||
1387 | * | ||
1388 | * The Extension Units, if present, must have a single input pin. The | ||
1389 | * Processing Unit and Extension Units can be in any order. Additional | ||
1390 | * Extension Units connected to the main chain as single-unit branches are | ||
1391 | * also supported. | ||
1392 | */ | ||
1393 | static int uvc_register_video(struct uvc_device *dev) | ||
1394 | { | ||
1395 | struct video_device *vdev; | ||
1396 | struct uvc_entity *term; | ||
1397 | int found = 0, ret; | ||
1398 | |||
1399 | /* Check if the control interface matches the structure we expect. */ | ||
1400 | list_for_each_entry(term, &dev->entities, list) { | ||
1401 | struct uvc_streaming *streaming; | ||
1402 | |||
1403 | if (UVC_ENTITY_TYPE(term) != TT_STREAMING) | ||
1404 | continue; | ||
1405 | |||
1406 | memset(&dev->video, 0, sizeof dev->video); | ||
1407 | mutex_init(&dev->video.ctrl_mutex); | ||
1408 | INIT_LIST_HEAD(&dev->video.iterms); | ||
1409 | INIT_LIST_HEAD(&dev->video.extensions); | ||
1410 | dev->video.oterm = term; | ||
1411 | dev->video.dev = dev; | ||
1412 | if (uvc_scan_chain(&dev->video) < 0) | ||
1413 | continue; | ||
1414 | |||
1415 | list_for_each_entry(streaming, &dev->streaming, list) { | ||
1416 | if (streaming->header.bTerminalLink == term->id) { | ||
1417 | dev->video.streaming = streaming; | ||
1418 | found = 1; | ||
1419 | break; | ||
1420 | } | ||
1421 | } | ||
1422 | |||
1423 | if (found) | ||
1424 | break; | ||
1425 | } | ||
1426 | |||
1427 | if (!found) { | ||
1428 | uvc_printk(KERN_INFO, "No valid video chain found.\n"); | ||
1429 | return -1; | ||
1430 | } | ||
1431 | |||
1432 | if (uvc_trace_param & UVC_TRACE_PROBE) { | ||
1433 | uvc_printk(KERN_INFO, "Found a valid video chain ("); | ||
1434 | list_for_each_entry(term, &dev->video.iterms, chain) { | ||
1435 | printk("%d", term->id); | ||
1436 | if (term->chain.next != &dev->video.iterms) | ||
1437 | printk(","); | ||
1438 | } | ||
1439 | printk(" -> %d).\n", dev->video.oterm->id); | ||
1440 | } | ||
1441 | |||
1442 | /* Initialize the streaming interface with default streaming | ||
1443 | * parameters. | ||
1444 | */ | ||
1445 | if ((ret = uvc_video_init(&dev->video)) < 0) { | ||
1446 | uvc_printk(KERN_ERR, "Failed to initialize the device " | ||
1447 | "(%d).\n", ret); | ||
1448 | return ret; | ||
1449 | } | ||
1450 | |||
1451 | /* Register the device with V4L. */ | ||
1452 | vdev = video_device_alloc(); | ||
1453 | if (vdev == NULL) | ||
1454 | return -1; | ||
1455 | |||
1456 | /* We already hold a reference to dev->udev. The video device will be | ||
1457 | * unregistered before the reference is released, so we don't need to | ||
1458 | * get another one. | ||
1459 | */ | ||
1460 | vdev->dev = &dev->intf->dev; | ||
1461 | vdev->type = 0; | ||
1462 | vdev->type2 = 0; | ||
1463 | vdev->minor = -1; | ||
1464 | vdev->fops = &uvc_fops; | ||
1465 | vdev->release = video_device_release; | ||
1466 | strncpy(vdev->name, dev->name, sizeof vdev->name); | ||
1467 | |||
1468 | /* Set the driver data before calling video_register_device, otherwise | ||
1469 | * uvc_v4l2_open might race us. | ||
1470 | * | ||
1471 | * FIXME: usb_set_intfdata hasn't been called so far. Is that a | ||
1472 | * problem ? Does any function which could be called here get | ||
1473 | * a pointer to the usb_interface ? | ||
1474 | */ | ||
1475 | dev->video.vdev = vdev; | ||
1476 | video_set_drvdata(vdev, &dev->video); | ||
1477 | |||
1478 | if (video_register_device(vdev, VFL_TYPE_GRABBER, -1) < 0) { | ||
1479 | dev->video.vdev = NULL; | ||
1480 | video_device_release(vdev); | ||
1481 | return -1; | ||
1482 | } | ||
1483 | |||
1484 | return 0; | ||
1485 | } | ||
1486 | |||
1487 | /* | ||
1488 | * Delete the UVC device. | ||
1489 | * | ||
1490 | * Called by the kernel when the last reference to the uvc_device structure | ||
1491 | * is released. | ||
1492 | * | ||
1493 | * Unregistering the video devices is done here because every opened instance | ||
1494 | * must be closed before the device can be unregistered. An alternative would | ||
1495 | * have been to use another reference count for uvc_v4l2_open/uvc_release, and | ||
1496 | * unregister the video devices on disconnect when that reference count drops | ||
1497 | * to zero. | ||
1498 | * | ||
1499 | * As this function is called after or during disconnect(), all URBs have | ||
1500 | * already been canceled by the USB core. There is no need to kill the | ||
1501 | * interrupt URB manually. | ||
1502 | */ | ||
1503 | void uvc_delete(struct kref *kref) | ||
1504 | { | ||
1505 | struct uvc_device *dev = container_of(kref, struct uvc_device, kref); | ||
1506 | struct list_head *p, *n; | ||
1507 | |||
1508 | /* Unregister the video device */ | ||
1509 | uvc_unregister_video(dev); | ||
1510 | usb_put_intf(dev->intf); | ||
1511 | usb_put_dev(dev->udev); | ||
1512 | |||
1513 | uvc_status_cleanup(dev); | ||
1514 | uvc_ctrl_cleanup_device(dev); | ||
1515 | |||
1516 | list_for_each_safe(p, n, &dev->entities) { | ||
1517 | struct uvc_entity *entity; | ||
1518 | entity = list_entry(p, struct uvc_entity, list); | ||
1519 | kfree(entity); | ||
1520 | } | ||
1521 | |||
1522 | list_for_each_safe(p, n, &dev->streaming) { | ||
1523 | struct uvc_streaming *streaming; | ||
1524 | streaming = list_entry(p, struct uvc_streaming, list); | ||
1525 | usb_driver_release_interface(&uvc_driver.driver, | ||
1526 | streaming->intf); | ||
1527 | usb_put_intf(streaming->intf); | ||
1528 | kfree(streaming->format); | ||
1529 | kfree(streaming->header.bmaControls); | ||
1530 | kfree(streaming); | ||
1531 | } | ||
1532 | |||
1533 | kfree(dev); | ||
1534 | } | ||
1535 | |||
1536 | static int uvc_probe(struct usb_interface *intf, | ||
1537 | const struct usb_device_id *id) | ||
1538 | { | ||
1539 | struct usb_device *udev = interface_to_usbdev(intf); | ||
1540 | struct uvc_device *dev; | ||
1541 | int ret; | ||
1542 | |||
1543 | if (id->idVendor && id->idProduct) | ||
1544 | uvc_trace(UVC_TRACE_PROBE, "Probing known UVC device %s " | ||
1545 | "(%04x:%04x)\n", udev->devpath, id->idVendor, | ||
1546 | id->idProduct); | ||
1547 | else | ||
1548 | uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n", | ||
1549 | udev->devpath); | ||
1550 | |||
1551 | /* Allocate memory for the device and initialize it */ | ||
1552 | if ((dev = kzalloc(sizeof *dev, GFP_KERNEL)) == NULL) | ||
1553 | return -ENOMEM; | ||
1554 | |||
1555 | INIT_LIST_HEAD(&dev->entities); | ||
1556 | INIT_LIST_HEAD(&dev->streaming); | ||
1557 | kref_init(&dev->kref); | ||
1558 | |||
1559 | dev->udev = usb_get_dev(udev); | ||
1560 | dev->intf = usb_get_intf(intf); | ||
1561 | dev->intfnum = intf->cur_altsetting->desc.bInterfaceNumber; | ||
1562 | dev->quirks = id->driver_info | uvc_quirks_param; | ||
1563 | |||
1564 | if (udev->product != NULL) | ||
1565 | strncpy(dev->name, udev->product, sizeof dev->name); | ||
1566 | else | ||
1567 | snprintf(dev->name, sizeof dev->name, | ||
1568 | "UVC Camera (%04x:%04x)", | ||
1569 | le16_to_cpu(udev->descriptor.idVendor), | ||
1570 | le16_to_cpu(udev->descriptor.idProduct)); | ||
1571 | |||
1572 | /* Parse the Video Class control descriptor */ | ||
1573 | if (uvc_parse_control(dev) < 0) { | ||
1574 | uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC " | ||
1575 | "descriptors.\n"); | ||
1576 | goto error; | ||
1577 | } | ||
1578 | |||
1579 | uvc_printk(KERN_INFO, "Found UVC %u.%02u device %s (%04x:%04x)\n", | ||
1580 | dev->uvc_version >> 8, dev->uvc_version & 0xff, | ||
1581 | udev->product ? udev->product : "<unnamed>", | ||
1582 | le16_to_cpu(udev->descriptor.idVendor), | ||
1583 | le16_to_cpu(udev->descriptor.idProduct)); | ||
1584 | |||
1585 | if (uvc_quirks_param != 0) { | ||
1586 | uvc_printk(KERN_INFO, "Forcing device quirks 0x%x by module " | ||
1587 | "parameter for testing purpose.\n", uvc_quirks_param); | ||
1588 | uvc_printk(KERN_INFO, "Please report required quirks to the " | ||
1589 | "linux-uvc-devel mailing list.\n"); | ||
1590 | } | ||
1591 | |||
1592 | /* Initialize controls */ | ||
1593 | if (uvc_ctrl_init_device(dev) < 0) | ||
1594 | goto error; | ||
1595 | |||
1596 | /* Register the video devices */ | ||
1597 | if (uvc_register_video(dev) < 0) | ||
1598 | goto error; | ||
1599 | |||
1600 | /* Save our data pointer in the interface data */ | ||
1601 | usb_set_intfdata(intf, dev); | ||
1602 | |||
1603 | /* Initialize the interrupt URB */ | ||
1604 | if ((ret = uvc_status_init(dev)) < 0) { | ||
1605 | uvc_printk(KERN_INFO, "Unable to initialize the status " | ||
1606 | "endpoint (%d), status interrupt will not be " | ||
1607 | "supported.\n", ret); | ||
1608 | } | ||
1609 | |||
1610 | uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n"); | ||
1611 | return 0; | ||
1612 | |||
1613 | error: | ||
1614 | kref_put(&dev->kref, uvc_delete); | ||
1615 | return -ENODEV; | ||
1616 | } | ||
1617 | |||
1618 | static void uvc_disconnect(struct usb_interface *intf) | ||
1619 | { | ||
1620 | struct uvc_device *dev = usb_get_intfdata(intf); | ||
1621 | |||
1622 | /* Set the USB interface data to NULL. This can be done outside the | ||
1623 | * lock, as there's no other reader. | ||
1624 | */ | ||
1625 | usb_set_intfdata(intf, NULL); | ||
1626 | |||
1627 | if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOSTREAMING) | ||
1628 | return; | ||
1629 | |||
1630 | /* uvc_v4l2_open() might race uvc_disconnect(). A static driver-wide | ||
1631 | * lock is needed to prevent uvc_disconnect from releasing its | ||
1632 | * reference to the uvc_device instance after uvc_v4l2_open() received | ||
1633 | * the pointer to the device (video_devdata) but before it got the | ||
1634 | * chance to increase the reference count (kref_get). | ||
1635 | */ | ||
1636 | mutex_lock(&uvc_driver.open_mutex); | ||
1637 | |||
1638 | dev->state |= UVC_DEV_DISCONNECTED; | ||
1639 | kref_put(&dev->kref, uvc_delete); | ||
1640 | |||
1641 | mutex_unlock(&uvc_driver.open_mutex); | ||
1642 | } | ||
1643 | |||
1644 | static int uvc_suspend(struct usb_interface *intf, pm_message_t message) | ||
1645 | { | ||
1646 | struct uvc_device *dev = usb_get_intfdata(intf); | ||
1647 | |||
1648 | uvc_trace(UVC_TRACE_SUSPEND, "Suspending interface %u\n", | ||
1649 | intf->cur_altsetting->desc.bInterfaceNumber); | ||
1650 | |||
1651 | /* Controls are cached on the fly so they don't need to be saved. */ | ||
1652 | if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) | ||
1653 | return uvc_status_suspend(dev); | ||
1654 | |||
1655 | if (dev->video.streaming->intf != intf) { | ||
1656 | uvc_trace(UVC_TRACE_SUSPEND, "Suspend: video streaming USB " | ||
1657 | "interface mismatch.\n"); | ||
1658 | return -EINVAL; | ||
1659 | } | ||
1660 | |||
1661 | return uvc_video_suspend(&dev->video); | ||
1662 | } | ||
1663 | |||
1664 | static int uvc_resume(struct usb_interface *intf) | ||
1665 | { | ||
1666 | struct uvc_device *dev = usb_get_intfdata(intf); | ||
1667 | int ret; | ||
1668 | |||
1669 | uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", | ||
1670 | intf->cur_altsetting->desc.bInterfaceNumber); | ||
1671 | |||
1672 | if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) { | ||
1673 | if ((ret = uvc_ctrl_resume_device(dev)) < 0) | ||
1674 | return ret; | ||
1675 | |||
1676 | return uvc_status_resume(dev); | ||
1677 | } | ||
1678 | |||
1679 | if (dev->video.streaming->intf != intf) { | ||
1680 | uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB " | ||
1681 | "interface mismatch.\n"); | ||
1682 | return -EINVAL; | ||
1683 | } | ||
1684 | |||
1685 | return uvc_video_resume(&dev->video); | ||
1686 | } | ||
1687 | |||
1688 | /* ------------------------------------------------------------------------ | ||
1689 | * Driver initialization and cleanup | ||
1690 | */ | ||
1691 | |||
1692 | /* | ||
1693 | * The Logitech cameras listed below have their interface class set to | ||
1694 | * VENDOR_SPEC because they don't announce themselves as UVC devices, even | ||
1695 | * though they are compliant. | ||
1696 | */ | ||
1697 | static struct usb_device_id uvc_ids[] = { | ||
1698 | /* ALi M5606 (Clevo M540SR) */ | ||
1699 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1700 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1701 | .idVendor = 0x0402, | ||
1702 | .idProduct = 0x5606, | ||
1703 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1704 | .bInterfaceSubClass = 1, | ||
1705 | .bInterfaceProtocol = 0, | ||
1706 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1707 | /* Creative Live! Optia */ | ||
1708 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1709 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1710 | .idVendor = 0x041e, | ||
1711 | .idProduct = 0x4057, | ||
1712 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1713 | .bInterfaceSubClass = 1, | ||
1714 | .bInterfaceProtocol = 0, | ||
1715 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1716 | /* Microsoft Lifecam NX-6000 */ | ||
1717 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1718 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1719 | .idVendor = 0x045e, | ||
1720 | .idProduct = 0x00f8, | ||
1721 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1722 | .bInterfaceSubClass = 1, | ||
1723 | .bInterfaceProtocol = 0, | ||
1724 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1725 | /* Microsoft Lifecam VX-7000 */ | ||
1726 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1727 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1728 | .idVendor = 0x045e, | ||
1729 | .idProduct = 0x0723, | ||
1730 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1731 | .bInterfaceSubClass = 1, | ||
1732 | .bInterfaceProtocol = 0, | ||
1733 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1734 | /* Logitech Quickcam Fusion */ | ||
1735 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1736 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1737 | .idVendor = 0x046d, | ||
1738 | .idProduct = 0x08c1, | ||
1739 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1740 | .bInterfaceSubClass = 1, | ||
1741 | .bInterfaceProtocol = 0 }, | ||
1742 | /* Logitech Quickcam Orbit MP */ | ||
1743 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1744 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1745 | .idVendor = 0x046d, | ||
1746 | .idProduct = 0x08c2, | ||
1747 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1748 | .bInterfaceSubClass = 1, | ||
1749 | .bInterfaceProtocol = 0 }, | ||
1750 | /* Logitech Quickcam Pro for Notebook */ | ||
1751 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1752 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1753 | .idVendor = 0x046d, | ||
1754 | .idProduct = 0x08c3, | ||
1755 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1756 | .bInterfaceSubClass = 1, | ||
1757 | .bInterfaceProtocol = 0 }, | ||
1758 | /* Logitech Quickcam Pro 5000 */ | ||
1759 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1760 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1761 | .idVendor = 0x046d, | ||
1762 | .idProduct = 0x08c5, | ||
1763 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1764 | .bInterfaceSubClass = 1, | ||
1765 | .bInterfaceProtocol = 0 }, | ||
1766 | /* Logitech Quickcam OEM Dell Notebook */ | ||
1767 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1768 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1769 | .idVendor = 0x046d, | ||
1770 | .idProduct = 0x08c6, | ||
1771 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1772 | .bInterfaceSubClass = 1, | ||
1773 | .bInterfaceProtocol = 0 }, | ||
1774 | /* Logitech Quickcam OEM Cisco VT Camera II */ | ||
1775 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1776 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1777 | .idVendor = 0x046d, | ||
1778 | .idProduct = 0x08c7, | ||
1779 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
1780 | .bInterfaceSubClass = 1, | ||
1781 | .bInterfaceProtocol = 0 }, | ||
1782 | /* Apple Built-In iSight */ | ||
1783 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1784 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1785 | .idVendor = 0x05ac, | ||
1786 | .idProduct = 0x8501, | ||
1787 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1788 | .bInterfaceSubClass = 1, | ||
1789 | .bInterfaceProtocol = 0, | ||
1790 | .driver_info = UVC_QUIRK_PROBE_MINMAX | ||
1791 | | UVC_QUIRK_BUILTIN_ISIGHT }, | ||
1792 | /* Genesys Logic USB 2.0 PC Camera */ | ||
1793 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1794 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1795 | .idVendor = 0x05e3, | ||
1796 | .idProduct = 0x0505, | ||
1797 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1798 | .bInterfaceSubClass = 1, | ||
1799 | .bInterfaceProtocol = 0, | ||
1800 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, | ||
1801 | /* Silicon Motion SM371 */ | ||
1802 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1803 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1804 | .idVendor = 0x090c, | ||
1805 | .idProduct = 0xb371, | ||
1806 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1807 | .bInterfaceSubClass = 1, | ||
1808 | .bInterfaceProtocol = 0, | ||
1809 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1810 | /* MT6227 */ | ||
1811 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1812 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1813 | .idVendor = 0x0e8d, | ||
1814 | .idProduct = 0x0004, | ||
1815 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1816 | .bInterfaceSubClass = 1, | ||
1817 | .bInterfaceProtocol = 0, | ||
1818 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1819 | /* Syntek (HP Spartan) */ | ||
1820 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1821 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1822 | .idVendor = 0x174f, | ||
1823 | .idProduct = 0x5212, | ||
1824 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1825 | .bInterfaceSubClass = 1, | ||
1826 | .bInterfaceProtocol = 0, | ||
1827 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, | ||
1828 | /* Syntek (Asus U3S) */ | ||
1829 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1830 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1831 | .idVendor = 0x174f, | ||
1832 | .idProduct = 0x8a33, | ||
1833 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1834 | .bInterfaceSubClass = 1, | ||
1835 | .bInterfaceProtocol = 0, | ||
1836 | .driver_info = UVC_QUIRK_STREAM_NO_FID }, | ||
1837 | /* Ecamm Pico iMage */ | ||
1838 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1839 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1840 | .idVendor = 0x18cd, | ||
1841 | .idProduct = 0xcafe, | ||
1842 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1843 | .bInterfaceSubClass = 1, | ||
1844 | .bInterfaceProtocol = 0, | ||
1845 | .driver_info = UVC_QUIRK_PROBE_EXTRAFIELDS }, | ||
1846 | /* Bodelin ProScopeHR */ | ||
1847 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1848 | | USB_DEVICE_ID_MATCH_DEV_HI | ||
1849 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1850 | .idVendor = 0x19ab, | ||
1851 | .idProduct = 0x1000, | ||
1852 | .bcdDevice_hi = 0x0126, | ||
1853 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1854 | .bInterfaceSubClass = 1, | ||
1855 | .bInterfaceProtocol = 0, | ||
1856 | .driver_info = UVC_QUIRK_STATUS_INTERVAL }, | ||
1857 | /* SiGma Micro USB Web Camera */ | ||
1858 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1859 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1860 | .idVendor = 0x1c4f, | ||
1861 | .idProduct = 0x3000, | ||
1862 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1863 | .bInterfaceSubClass = 1, | ||
1864 | .bInterfaceProtocol = 0, | ||
1865 | .driver_info = UVC_QUIRK_PROBE_MINMAX | ||
1866 | | UVC_QUIRK_IGNORE_SELECTOR_UNIT}, | ||
1867 | /* Acer OEM Webcam - Unknown vendor */ | ||
1868 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1869 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1870 | .idVendor = 0x5986, | ||
1871 | .idProduct = 0x0100, | ||
1872 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1873 | .bInterfaceSubClass = 1, | ||
1874 | .bInterfaceProtocol = 0, | ||
1875 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1876 | /* Packard Bell OEM Webcam */ | ||
1877 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1878 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1879 | .idVendor = 0x5986, | ||
1880 | .idProduct = 0x0101, | ||
1881 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1882 | .bInterfaceSubClass = 1, | ||
1883 | .bInterfaceProtocol = 0, | ||
1884 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1885 | /* Acer Crystal Eye webcam */ | ||
1886 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1887 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1888 | .idVendor = 0x5986, | ||
1889 | .idProduct = 0x0102, | ||
1890 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1891 | .bInterfaceSubClass = 1, | ||
1892 | .bInterfaceProtocol = 0, | ||
1893 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1894 | /* Acer OrbiCam - Unknown vendor */ | ||
1895 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ||
1896 | | USB_DEVICE_ID_MATCH_INT_INFO, | ||
1897 | .idVendor = 0x5986, | ||
1898 | .idProduct = 0x0200, | ||
1899 | .bInterfaceClass = USB_CLASS_VIDEO, | ||
1900 | .bInterfaceSubClass = 1, | ||
1901 | .bInterfaceProtocol = 0, | ||
1902 | .driver_info = UVC_QUIRK_PROBE_MINMAX }, | ||
1903 | /* Generic USB Video Class */ | ||
1904 | { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, | ||
1905 | {} | ||
1906 | }; | ||
1907 | |||
1908 | MODULE_DEVICE_TABLE(usb, uvc_ids); | ||
1909 | |||
1910 | struct uvc_driver uvc_driver = { | ||
1911 | .driver = { | ||
1912 | .name = "uvcvideo", | ||
1913 | .probe = uvc_probe, | ||
1914 | .disconnect = uvc_disconnect, | ||
1915 | .suspend = uvc_suspend, | ||
1916 | .resume = uvc_resume, | ||
1917 | .id_table = uvc_ids, | ||
1918 | .supports_autosuspend = 1, | ||
1919 | }, | ||
1920 | }; | ||
1921 | |||
1922 | static int __init uvc_init(void) | ||
1923 | { | ||
1924 | int result; | ||
1925 | |||
1926 | INIT_LIST_HEAD(&uvc_driver.devices); | ||
1927 | INIT_LIST_HEAD(&uvc_driver.controls); | ||
1928 | mutex_init(&uvc_driver.open_mutex); | ||
1929 | mutex_init(&uvc_driver.ctrl_mutex); | ||
1930 | |||
1931 | uvc_ctrl_init(); | ||
1932 | |||
1933 | result = usb_register(&uvc_driver.driver); | ||
1934 | if (result == 0) | ||
1935 | printk(KERN_INFO DRIVER_DESC " (" DRIVER_VERSION ")\n"); | ||
1936 | return result; | ||
1937 | } | ||
1938 | |||
1939 | static void __exit uvc_cleanup(void) | ||
1940 | { | ||
1941 | usb_deregister(&uvc_driver.driver); | ||
1942 | } | ||
1943 | |||
1944 | module_init(uvc_init); | ||
1945 | module_exit(uvc_cleanup); | ||
1946 | |||
1947 | module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR); | ||
1948 | MODULE_PARM_DESC(quirks, "Forced device quirks"); | ||
1949 | module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR); | ||
1950 | MODULE_PARM_DESC(trace, "Trace level bitmask"); | ||
1951 | |||
1952 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
1953 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
1954 | MODULE_LICENSE("GPL"); | ||
1955 | MODULE_VERSION(DRIVER_VERSION); | ||
diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c new file mode 100644 index 000000000000..37bdefdbead5 --- /dev/null +++ b/drivers/media/video/uvc/uvc_isight.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * uvc_isight.c -- USB Video Class driver - iSight support | ||
3 | * | ||
4 | * Copyright (C) 2006-2007 | ||
5 | * Ivan N. Zlatev <contact@i-nz.net> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/usb.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/mm.h> | ||
17 | |||
18 | #include "uvcvideo.h" | ||
19 | |||
20 | /* Built-in iSight webcams implements most of UVC 1.0 except a | ||
21 | * different packet format. Instead of sending a header at the | ||
22 | * beginning of each isochronous transfer payload, the webcam sends a | ||
23 | * single header per image (on its own in a packet), followed by | ||
24 | * packets containing data only. | ||
25 | * | ||
26 | * Offset Size (bytes) Description | ||
27 | * ------------------------------------------------------------------ | ||
28 | * 0x00 1 Header length | ||
29 | * 0x01 1 Flags (UVC-compliant) | ||
30 | * 0x02 4 Always equal to '11223344' | ||
31 | * 0x06 8 Always equal to 'deadbeefdeadface' | ||
32 | * 0x0e 16 Unknown | ||
33 | * | ||
34 | * The header can be prefixed by an optional, unknown-purpose byte. | ||
35 | */ | ||
36 | |||
37 | static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf, | ||
38 | const __u8 *data, unsigned int len) | ||
39 | { | ||
40 | static const __u8 hdr[] = { | ||
41 | 0x11, 0x22, 0x33, 0x44, | ||
42 | 0xde, 0xad, 0xbe, 0xef, | ||
43 | 0xde, 0xad, 0xfa, 0xce | ||
44 | }; | ||
45 | |||
46 | unsigned int maxlen, nbytes; | ||
47 | __u8 *mem; | ||
48 | int is_header = 0; | ||
49 | |||
50 | if (buf == NULL) | ||
51 | return 0; | ||
52 | |||
53 | if ((len >= 14 && memcmp(&data[2], hdr, 12) == 0) || | ||
54 | (len >= 15 && memcmp(&data[3], hdr, 12) == 0)) { | ||
55 | uvc_trace(UVC_TRACE_FRAME, "iSight header found\n"); | ||
56 | is_header = 1; | ||
57 | } | ||
58 | |||
59 | /* Synchronize to the input stream by waiting for a header packet. */ | ||
60 | if (buf->state != UVC_BUF_STATE_ACTIVE) { | ||
61 | if (!is_header) { | ||
62 | uvc_trace(UVC_TRACE_FRAME, "Dropping packet (out of " | ||
63 | "sync).\n"); | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | buf->state = UVC_BUF_STATE_ACTIVE; | ||
68 | } | ||
69 | |||
70 | /* Mark the buffer as done if we're at the beginning of a new frame. | ||
71 | * | ||
72 | * Empty buffers (bytesused == 0) don't trigger end of frame detection | ||
73 | * as it doesn't make sense to return an empty buffer. | ||
74 | */ | ||
75 | if (is_header && buf->buf.bytesused != 0) { | ||
76 | buf->state = UVC_BUF_STATE_DONE; | ||
77 | return -EAGAIN; | ||
78 | } | ||
79 | |||
80 | /* Copy the video data to the buffer. Skip header packets, as they | ||
81 | * contain no data. | ||
82 | */ | ||
83 | if (!is_header) { | ||
84 | maxlen = buf->buf.length - buf->buf.bytesused; | ||
85 | mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused; | ||
86 | nbytes = min(len, maxlen); | ||
87 | memcpy(mem, data, nbytes); | ||
88 | buf->buf.bytesused += nbytes; | ||
89 | |||
90 | if (len > maxlen || buf->buf.bytesused == buf->buf.length) { | ||
91 | uvc_trace(UVC_TRACE_FRAME, "Frame complete " | ||
92 | "(overflow).\n"); | ||
93 | buf->state = UVC_BUF_STATE_DONE; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video, | ||
101 | struct uvc_buffer *buf) | ||
102 | { | ||
103 | int ret, i; | ||
104 | |||
105 | for (i = 0; i < urb->number_of_packets; ++i) { | ||
106 | if (urb->iso_frame_desc[i].status < 0) { | ||
107 | uvc_trace(UVC_TRACE_FRAME, "USB isochronous frame " | ||
108 | "lost (%d).\n", | ||
109 | urb->iso_frame_desc[i].status); | ||
110 | } | ||
111 | |||
112 | /* Decode the payload packet. | ||
113 | * uvc_video_decode is entered twice when a frame transition | ||
114 | * has been detected because the end of frame can only be | ||
115 | * reliably detected when the first packet of the new frame | ||
116 | * is processed. The first pass detects the transition and | ||
117 | * closes the previous frame's buffer, the second pass | ||
118 | * processes the data of the first payload of the new frame. | ||
119 | */ | ||
120 | do { | ||
121 | ret = isight_decode(&video->queue, buf, | ||
122 | urb->transfer_buffer + | ||
123 | urb->iso_frame_desc[i].offset, | ||
124 | urb->iso_frame_desc[i].actual_length); | ||
125 | |||
126 | if (buf == NULL) | ||
127 | break; | ||
128 | |||
129 | if (buf->state == UVC_BUF_STATE_DONE || | ||
130 | buf->state == UVC_BUF_STATE_ERROR) | ||
131 | buf = uvc_queue_next_buffer(&video->queue, buf); | ||
132 | } while (ret == -EAGAIN); | ||
133 | } | ||
134 | } | ||
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c new file mode 100644 index 000000000000..0923f0e3b3d4 --- /dev/null +++ b/drivers/media/video/uvc/uvc_queue.c | |||
@@ -0,0 +1,477 @@ | |||
1 | /* | ||
2 | * uvc_queue.c -- USB Video Class driver - Buffers management | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/usb.h> | ||
19 | #include <linux/videodev2.h> | ||
20 | #include <linux/vmalloc.h> | ||
21 | #include <linux/wait.h> | ||
22 | #include <asm/atomic.h> | ||
23 | |||
24 | #include "uvcvideo.h" | ||
25 | |||
26 | /* ------------------------------------------------------------------------ | ||
27 | * Video buffers queue management. | ||
28 | * | ||
29 | * Video queues is initialized by uvc_queue_init(). The function performs | ||
30 | * basic initialization of the uvc_video_queue struct and never fails. | ||
31 | * | ||
32 | * Video buffer allocation and freeing are performed by uvc_alloc_buffers and | ||
33 | * uvc_free_buffers respectively. The former acquires the video queue lock, | ||
34 | * while the later must be called with the lock held (so that allocation can | ||
35 | * free previously allocated buffers). Trying to free buffers that are mapped | ||
36 | * to user space will return -EBUSY. | ||
37 | * | ||
38 | * Video buffers are managed using two queues. However, unlike most USB video | ||
39 | * drivers which use an in queue and an out queue, we use a main queue which | ||
40 | * holds all queued buffers (both 'empty' and 'done' buffers), and an irq | ||
41 | * queue which holds empty buffers. This design (copied from video-buf) | ||
42 | * minimizes locking in interrupt, as only one queue is shared between | ||
43 | * interrupt and user contexts. | ||
44 | * | ||
45 | * Use cases | ||
46 | * --------- | ||
47 | * | ||
48 | * Unless stated otherwise, all operations which modify the irq buffers queue | ||
49 | * are protected by the irq spinlock. | ||
50 | * | ||
51 | * 1. The user queues the buffers, starts streaming and dequeues a buffer. | ||
52 | * | ||
53 | * The buffers are added to the main and irq queues. Both operations are | ||
54 | * protected by the queue lock, and the latert is protected by the irq | ||
55 | * spinlock as well. | ||
56 | * | ||
57 | * The completion handler fetches a buffer from the irq queue and fills it | ||
58 | * with video data. If no buffer is available (irq queue empty), the handler | ||
59 | * returns immediately. | ||
60 | * | ||
61 | * When the buffer is full, the completion handler removes it from the irq | ||
62 | * queue, marks it as ready (UVC_BUF_STATE_DONE) and wake its wait queue. | ||
63 | * At that point, any process waiting on the buffer will be woken up. If a | ||
64 | * process tries to dequeue a buffer after it has been marked ready, the | ||
65 | * dequeing will succeed immediately. | ||
66 | * | ||
67 | * 2. Buffers are queued, user is waiting on a buffer and the device gets | ||
68 | * disconnected. | ||
69 | * | ||
70 | * When the device is disconnected, the kernel calls the completion handler | ||
71 | * with an appropriate status code. The handler marks all buffers in the | ||
72 | * irq queue as being erroneous (UVC_BUF_STATE_ERROR) and wakes them up so | ||
73 | * that any process waiting on a buffer gets woken up. | ||
74 | * | ||
75 | * Waking up up the first buffer on the irq list is not enough, as the | ||
76 | * process waiting on the buffer might restart the dequeue operation | ||
77 | * immediately. | ||
78 | * | ||
79 | */ | ||
80 | |||
81 | void uvc_queue_init(struct uvc_video_queue *queue) | ||
82 | { | ||
83 | mutex_init(&queue->mutex); | ||
84 | spin_lock_init(&queue->irqlock); | ||
85 | INIT_LIST_HEAD(&queue->mainqueue); | ||
86 | INIT_LIST_HEAD(&queue->irqqueue); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Allocate the video buffers. | ||
91 | * | ||
92 | * Pages are reserved to make sure they will not be swaped, as they will be | ||
93 | * filled in URB completion handler. | ||
94 | * | ||
95 | * Buffers will be individually mapped, so they must all be page aligned. | ||
96 | */ | ||
97 | int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers, | ||
98 | unsigned int buflength) | ||
99 | { | ||
100 | unsigned int bufsize = PAGE_ALIGN(buflength); | ||
101 | unsigned int i; | ||
102 | void *mem = NULL; | ||
103 | int ret; | ||
104 | |||
105 | if (nbuffers > UVC_MAX_VIDEO_BUFFERS) | ||
106 | nbuffers = UVC_MAX_VIDEO_BUFFERS; | ||
107 | |||
108 | mutex_lock(&queue->mutex); | ||
109 | |||
110 | if ((ret = uvc_free_buffers(queue)) < 0) | ||
111 | goto done; | ||
112 | |||
113 | /* Bail out if no buffers should be allocated. */ | ||
114 | if (nbuffers == 0) | ||
115 | goto done; | ||
116 | |||
117 | /* Decrement the number of buffers until allocation succeeds. */ | ||
118 | for (; nbuffers > 0; --nbuffers) { | ||
119 | mem = vmalloc_32(nbuffers * bufsize); | ||
120 | if (mem != NULL) | ||
121 | break; | ||
122 | } | ||
123 | |||
124 | if (mem == NULL) { | ||
125 | ret = -ENOMEM; | ||
126 | goto done; | ||
127 | } | ||
128 | |||
129 | for (i = 0; i < nbuffers; ++i) { | ||
130 | memset(&queue->buffer[i], 0, sizeof queue->buffer[i]); | ||
131 | queue->buffer[i].buf.index = i; | ||
132 | queue->buffer[i].buf.m.offset = i * bufsize; | ||
133 | queue->buffer[i].buf.length = buflength; | ||
134 | queue->buffer[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
135 | queue->buffer[i].buf.sequence = 0; | ||
136 | queue->buffer[i].buf.field = V4L2_FIELD_NONE; | ||
137 | queue->buffer[i].buf.memory = V4L2_MEMORY_MMAP; | ||
138 | queue->buffer[i].buf.flags = 0; | ||
139 | init_waitqueue_head(&queue->buffer[i].wait); | ||
140 | } | ||
141 | |||
142 | queue->mem = mem; | ||
143 | queue->count = nbuffers; | ||
144 | queue->buf_size = bufsize; | ||
145 | ret = nbuffers; | ||
146 | |||
147 | done: | ||
148 | mutex_unlock(&queue->mutex); | ||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | /* | ||
153 | * Free the video buffers. | ||
154 | * | ||
155 | * This function must be called with the queue lock held. | ||
156 | */ | ||
157 | int uvc_free_buffers(struct uvc_video_queue *queue) | ||
158 | { | ||
159 | unsigned int i; | ||
160 | |||
161 | for (i = 0; i < queue->count; ++i) { | ||
162 | if (queue->buffer[i].vma_use_count != 0) | ||
163 | return -EBUSY; | ||
164 | } | ||
165 | |||
166 | if (queue->count) { | ||
167 | vfree(queue->mem); | ||
168 | queue->count = 0; | ||
169 | } | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static void __uvc_query_buffer(struct uvc_buffer *buf, | ||
175 | struct v4l2_buffer *v4l2_buf) | ||
176 | { | ||
177 | memcpy(v4l2_buf, &buf->buf, sizeof *v4l2_buf); | ||
178 | |||
179 | if (buf->vma_use_count) | ||
180 | v4l2_buf->flags |= V4L2_BUF_FLAG_MAPPED; | ||
181 | |||
182 | switch (buf->state) { | ||
183 | case UVC_BUF_STATE_ERROR: | ||
184 | case UVC_BUF_STATE_DONE: | ||
185 | v4l2_buf->flags |= V4L2_BUF_FLAG_DONE; | ||
186 | break; | ||
187 | case UVC_BUF_STATE_QUEUED: | ||
188 | case UVC_BUF_STATE_ACTIVE: | ||
189 | v4l2_buf->flags |= V4L2_BUF_FLAG_QUEUED; | ||
190 | break; | ||
191 | case UVC_BUF_STATE_IDLE: | ||
192 | default: | ||
193 | break; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | int uvc_query_buffer(struct uvc_video_queue *queue, | ||
198 | struct v4l2_buffer *v4l2_buf) | ||
199 | { | ||
200 | int ret = 0; | ||
201 | |||
202 | mutex_lock(&queue->mutex); | ||
203 | if (v4l2_buf->index >= queue->count) { | ||
204 | ret = -EINVAL; | ||
205 | goto done; | ||
206 | } | ||
207 | |||
208 | __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); | ||
209 | |||
210 | done: | ||
211 | mutex_unlock(&queue->mutex); | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | /* | ||
216 | * Queue a video buffer. Attempting to queue a buffer that has already been | ||
217 | * queued will return -EINVAL. | ||
218 | */ | ||
219 | int uvc_queue_buffer(struct uvc_video_queue *queue, | ||
220 | struct v4l2_buffer *v4l2_buf) | ||
221 | { | ||
222 | struct uvc_buffer *buf; | ||
223 | unsigned long flags; | ||
224 | int ret = 0; | ||
225 | |||
226 | uvc_trace(UVC_TRACE_CAPTURE, "Queuing buffer %u.\n", v4l2_buf->index); | ||
227 | |||
228 | if (v4l2_buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
229 | v4l2_buf->memory != V4L2_MEMORY_MMAP) { | ||
230 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer type (%u) " | ||
231 | "and/or memory (%u).\n", v4l2_buf->type, | ||
232 | v4l2_buf->memory); | ||
233 | return -EINVAL; | ||
234 | } | ||
235 | |||
236 | mutex_lock(&queue->mutex); | ||
237 | if (v4l2_buf->index >= queue->count) { | ||
238 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); | ||
239 | ret = -EINVAL; | ||
240 | goto done; | ||
241 | } | ||
242 | |||
243 | buf = &queue->buffer[v4l2_buf->index]; | ||
244 | if (buf->state != UVC_BUF_STATE_IDLE) { | ||
245 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer state " | ||
246 | "(%u).\n", buf->state); | ||
247 | ret = -EINVAL; | ||
248 | goto done; | ||
249 | } | ||
250 | |||
251 | spin_lock_irqsave(&queue->irqlock, flags); | ||
252 | if (queue->flags & UVC_QUEUE_DISCONNECTED) { | ||
253 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
254 | ret = -ENODEV; | ||
255 | goto done; | ||
256 | } | ||
257 | buf->state = UVC_BUF_STATE_QUEUED; | ||
258 | buf->buf.bytesused = 0; | ||
259 | list_add_tail(&buf->stream, &queue->mainqueue); | ||
260 | list_add_tail(&buf->queue, &queue->irqqueue); | ||
261 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
262 | |||
263 | done: | ||
264 | mutex_unlock(&queue->mutex); | ||
265 | return ret; | ||
266 | } | ||
267 | |||
268 | static int uvc_queue_waiton(struct uvc_buffer *buf, int nonblocking) | ||
269 | { | ||
270 | if (nonblocking) { | ||
271 | return (buf->state != UVC_BUF_STATE_QUEUED && | ||
272 | buf->state != UVC_BUF_STATE_ACTIVE) | ||
273 | ? 0 : -EAGAIN; | ||
274 | } | ||
275 | |||
276 | return wait_event_interruptible(buf->wait, | ||
277 | buf->state != UVC_BUF_STATE_QUEUED && | ||
278 | buf->state != UVC_BUF_STATE_ACTIVE); | ||
279 | } | ||
280 | |||
281 | /* | ||
282 | * Dequeue a video buffer. If nonblocking is false, block until a buffer is | ||
283 | * available. | ||
284 | */ | ||
285 | int uvc_dequeue_buffer(struct uvc_video_queue *queue, | ||
286 | struct v4l2_buffer *v4l2_buf, int nonblocking) | ||
287 | { | ||
288 | struct uvc_buffer *buf; | ||
289 | int ret = 0; | ||
290 | |||
291 | if (v4l2_buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
292 | v4l2_buf->memory != V4L2_MEMORY_MMAP) { | ||
293 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer type (%u) " | ||
294 | "and/or memory (%u).\n", v4l2_buf->type, | ||
295 | v4l2_buf->memory); | ||
296 | return -EINVAL; | ||
297 | } | ||
298 | |||
299 | mutex_lock(&queue->mutex); | ||
300 | if (list_empty(&queue->mainqueue)) { | ||
301 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Empty buffer queue.\n"); | ||
302 | ret = -EINVAL; | ||
303 | goto done; | ||
304 | } | ||
305 | |||
306 | buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream); | ||
307 | if ((ret = uvc_queue_waiton(buf, nonblocking)) < 0) | ||
308 | goto done; | ||
309 | |||
310 | uvc_trace(UVC_TRACE_CAPTURE, "Dequeuing buffer %u (%u, %u bytes).\n", | ||
311 | buf->buf.index, buf->state, buf->buf.bytesused); | ||
312 | |||
313 | switch (buf->state) { | ||
314 | case UVC_BUF_STATE_ERROR: | ||
315 | uvc_trace(UVC_TRACE_CAPTURE, "[W] Corrupted data " | ||
316 | "(transmission error).\n"); | ||
317 | ret = -EIO; | ||
318 | case UVC_BUF_STATE_DONE: | ||
319 | buf->state = UVC_BUF_STATE_IDLE; | ||
320 | break; | ||
321 | |||
322 | case UVC_BUF_STATE_IDLE: | ||
323 | case UVC_BUF_STATE_QUEUED: | ||
324 | case UVC_BUF_STATE_ACTIVE: | ||
325 | default: | ||
326 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Invalid buffer state %u " | ||
327 | "(driver bug?).\n", buf->state); | ||
328 | ret = -EINVAL; | ||
329 | goto done; | ||
330 | } | ||
331 | |||
332 | list_del(&buf->stream); | ||
333 | __uvc_query_buffer(buf, v4l2_buf); | ||
334 | |||
335 | done: | ||
336 | mutex_unlock(&queue->mutex); | ||
337 | return ret; | ||
338 | } | ||
339 | |||
340 | /* | ||
341 | * Poll the video queue. | ||
342 | * | ||
343 | * This function implements video queue polling and is intended to be used by | ||
344 | * the device poll handler. | ||
345 | */ | ||
346 | unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, | ||
347 | poll_table *wait) | ||
348 | { | ||
349 | struct uvc_buffer *buf; | ||
350 | unsigned int mask = 0; | ||
351 | |||
352 | mutex_lock(&queue->mutex); | ||
353 | if (list_empty(&queue->mainqueue)) { | ||
354 | mask |= POLLERR; | ||
355 | goto done; | ||
356 | } | ||
357 | buf = list_first_entry(&queue->mainqueue, struct uvc_buffer, stream); | ||
358 | |||
359 | poll_wait(file, &buf->wait, wait); | ||
360 | if (buf->state == UVC_BUF_STATE_DONE || | ||
361 | buf->state == UVC_BUF_STATE_ERROR) | ||
362 | mask |= POLLIN | POLLRDNORM; | ||
363 | |||
364 | done: | ||
365 | mutex_unlock(&queue->mutex); | ||
366 | return mask; | ||
367 | } | ||
368 | |||
369 | /* | ||
370 | * Enable or disable the video buffers queue. | ||
371 | * | ||
372 | * The queue must be enabled before starting video acquisition and must be | ||
373 | * disabled after stopping it. This ensures that the video buffers queue | ||
374 | * state can be properly initialized before buffers are accessed from the | ||
375 | * interrupt handler. | ||
376 | * | ||
377 | * Enabling the video queue initializes parameters (such as sequence number, | ||
378 | * sync pattern, ...). If the queue is already enabled, return -EBUSY. | ||
379 | * | ||
380 | * Disabling the video queue cancels the queue and removes all buffers from | ||
381 | * the main queue. | ||
382 | * | ||
383 | * This function can't be called from interrupt context. Use | ||
384 | * uvc_queue_cancel() instead. | ||
385 | */ | ||
386 | int uvc_queue_enable(struct uvc_video_queue *queue, int enable) | ||
387 | { | ||
388 | unsigned int i; | ||
389 | int ret = 0; | ||
390 | |||
391 | mutex_lock(&queue->mutex); | ||
392 | if (enable) { | ||
393 | if (uvc_queue_streaming(queue)) { | ||
394 | ret = -EBUSY; | ||
395 | goto done; | ||
396 | } | ||
397 | queue->sequence = 0; | ||
398 | queue->flags |= UVC_QUEUE_STREAMING; | ||
399 | } else { | ||
400 | uvc_queue_cancel(queue, 0); | ||
401 | INIT_LIST_HEAD(&queue->mainqueue); | ||
402 | |||
403 | for (i = 0; i < queue->count; ++i) | ||
404 | queue->buffer[i].state = UVC_BUF_STATE_IDLE; | ||
405 | |||
406 | queue->flags &= ~UVC_QUEUE_STREAMING; | ||
407 | } | ||
408 | |||
409 | done: | ||
410 | mutex_unlock(&queue->mutex); | ||
411 | return ret; | ||
412 | } | ||
413 | |||
414 | /* | ||
415 | * Cancel the video buffers queue. | ||
416 | * | ||
417 | * Cancelling the queue marks all buffers on the irq queue as erroneous, | ||
418 | * wakes them up and remove them from the queue. | ||
419 | * | ||
420 | * If the disconnect parameter is set, further calls to uvc_queue_buffer will | ||
421 | * fail with -ENODEV. | ||
422 | * | ||
423 | * This function acquires the irq spinlock and can be called from interrupt | ||
424 | * context. | ||
425 | */ | ||
426 | void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect) | ||
427 | { | ||
428 | struct uvc_buffer *buf; | ||
429 | unsigned long flags; | ||
430 | |||
431 | spin_lock_irqsave(&queue->irqlock, flags); | ||
432 | while (!list_empty(&queue->irqqueue)) { | ||
433 | buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, | ||
434 | queue); | ||
435 | list_del(&buf->queue); | ||
436 | buf->state = UVC_BUF_STATE_ERROR; | ||
437 | wake_up(&buf->wait); | ||
438 | } | ||
439 | /* This must be protected by the irqlock spinlock to avoid race | ||
440 | * conditions between uvc_queue_buffer and the disconnection event that | ||
441 | * could result in an interruptible wait in uvc_dequeue_buffer. Do not | ||
442 | * blindly replace this logic by checking for the UVC_DEV_DISCONNECTED | ||
443 | * state outside the queue code. | ||
444 | */ | ||
445 | if (disconnect) | ||
446 | queue->flags |= UVC_QUEUE_DISCONNECTED; | ||
447 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
448 | } | ||
449 | |||
450 | struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | ||
451 | struct uvc_buffer *buf) | ||
452 | { | ||
453 | struct uvc_buffer *nextbuf; | ||
454 | unsigned long flags; | ||
455 | |||
456 | if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && | ||
457 | buf->buf.length != buf->buf.bytesused) { | ||
458 | buf->state = UVC_BUF_STATE_QUEUED; | ||
459 | buf->buf.bytesused = 0; | ||
460 | return buf; | ||
461 | } | ||
462 | |||
463 | spin_lock_irqsave(&queue->irqlock, flags); | ||
464 | list_del(&buf->queue); | ||
465 | if (!list_empty(&queue->irqqueue)) | ||
466 | nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer, | ||
467 | queue); | ||
468 | else | ||
469 | nextbuf = NULL; | ||
470 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
471 | |||
472 | buf->buf.sequence = queue->sequence++; | ||
473 | do_gettimeofday(&buf->buf.timestamp); | ||
474 | |||
475 | wake_up(&buf->wait); | ||
476 | return nextbuf; | ||
477 | } | ||
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c new file mode 100644 index 000000000000..be9084e5eace --- /dev/null +++ b/drivers/media/video/uvc/uvc_status.c | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | * uvc_status.c -- USB Video Class driver - Status endpoint | ||
3 | * | ||
4 | * Copyright (C) 2007-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/version.h> | ||
16 | #include <linux/input.h> | ||
17 | #include <linux/usb.h> | ||
18 | #include <linux/usb/input.h> | ||
19 | |||
20 | #include "uvcvideo.h" | ||
21 | |||
22 | /* -------------------------------------------------------------------------- | ||
23 | * Input device | ||
24 | */ | ||
25 | static int uvc_input_init(struct uvc_device *dev) | ||
26 | { | ||
27 | struct usb_device *udev = dev->udev; | ||
28 | struct input_dev *input; | ||
29 | char *phys = NULL; | ||
30 | int ret; | ||
31 | |||
32 | input = input_allocate_device(); | ||
33 | if (input == NULL) | ||
34 | return -ENOMEM; | ||
35 | |||
36 | phys = kmalloc(6 + strlen(udev->bus->bus_name) + strlen(udev->devpath), | ||
37 | GFP_KERNEL); | ||
38 | if (phys == NULL) { | ||
39 | ret = -ENOMEM; | ||
40 | goto error; | ||
41 | } | ||
42 | sprintf(phys, "usb-%s-%s", udev->bus->bus_name, udev->devpath); | ||
43 | |||
44 | input->name = dev->name; | ||
45 | input->phys = phys; | ||
46 | usb_to_input_id(udev, &input->id); | ||
47 | input->dev.parent = &dev->intf->dev; | ||
48 | |||
49 | set_bit(EV_KEY, input->evbit); | ||
50 | set_bit(BTN_0, input->keybit); | ||
51 | |||
52 | if ((ret = input_register_device(input)) < 0) | ||
53 | goto error; | ||
54 | |||
55 | dev->input = input; | ||
56 | return 0; | ||
57 | |||
58 | error: | ||
59 | input_free_device(input); | ||
60 | kfree(phys); | ||
61 | return ret; | ||
62 | } | ||
63 | |||
64 | static void uvc_input_cleanup(struct uvc_device *dev) | ||
65 | { | ||
66 | if (dev->input) | ||
67 | input_unregister_device(dev->input); | ||
68 | } | ||
69 | |||
70 | /* -------------------------------------------------------------------------- | ||
71 | * Status interrupt endpoint | ||
72 | */ | ||
73 | static void uvc_event_streaming(struct uvc_device *dev, __u8 *data, int len) | ||
74 | { | ||
75 | if (len < 3) { | ||
76 | uvc_trace(UVC_TRACE_STATUS, "Invalid streaming status event " | ||
77 | "received.\n"); | ||
78 | return; | ||
79 | } | ||
80 | |||
81 | if (data[2] == 0) { | ||
82 | if (len < 4) | ||
83 | return; | ||
84 | uvc_trace(UVC_TRACE_STATUS, "Button (intf %u) %s len %d\n", | ||
85 | data[1], data[3] ? "pressed" : "released", len); | ||
86 | if (dev->input) | ||
87 | input_report_key(dev->input, BTN_0, data[3]); | ||
88 | } else { | ||
89 | uvc_trace(UVC_TRACE_STATUS, "Stream %u error event %02x %02x " | ||
90 | "len %d.\n", data[1], data[2], data[3], len); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static void uvc_event_control(struct uvc_device *dev, __u8 *data, int len) | ||
95 | { | ||
96 | char *attrs[3] = { "value", "info", "failure" }; | ||
97 | |||
98 | if (len < 6 || data[2] != 0 || data[4] > 2) { | ||
99 | uvc_trace(UVC_TRACE_STATUS, "Invalid control status event " | ||
100 | "received.\n"); | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | uvc_trace(UVC_TRACE_STATUS, "Control %u/%u %s change len %d.\n", | ||
105 | data[1], data[3], attrs[data[4]], len); | ||
106 | } | ||
107 | |||
108 | static void uvc_status_complete(struct urb *urb) | ||
109 | { | ||
110 | struct uvc_device *dev = urb->context; | ||
111 | int len, ret; | ||
112 | |||
113 | switch (urb->status) { | ||
114 | case 0: | ||
115 | break; | ||
116 | |||
117 | case -ENOENT: /* usb_kill_urb() called. */ | ||
118 | case -ECONNRESET: /* usb_unlink_urb() called. */ | ||
119 | case -ESHUTDOWN: /* The endpoint is being disabled. */ | ||
120 | case -EPROTO: /* Device is disconnected (reported by some | ||
121 | * host controller). */ | ||
122 | return; | ||
123 | |||
124 | default: | ||
125 | uvc_printk(KERN_WARNING, "Non-zero status (%d) in status " | ||
126 | "completion handler.\n", urb->status); | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | len = urb->actual_length; | ||
131 | if (len > 0) { | ||
132 | switch (dev->status[0] & 0x0f) { | ||
133 | case UVC_STATUS_TYPE_CONTROL: | ||
134 | uvc_event_control(dev, dev->status, len); | ||
135 | break; | ||
136 | |||
137 | case UVC_STATUS_TYPE_STREAMING: | ||
138 | uvc_event_streaming(dev, dev->status, len); | ||
139 | break; | ||
140 | |||
141 | default: | ||
142 | uvc_printk(KERN_INFO, "unknown event type %u.\n", | ||
143 | dev->status[0]); | ||
144 | break; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | /* Resubmit the URB. */ | ||
149 | urb->interval = dev->int_ep->desc.bInterval; | ||
150 | if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { | ||
151 | uvc_printk(KERN_ERR, "Failed to resubmit status URB (%d).\n", | ||
152 | ret); | ||
153 | } | ||
154 | } | ||
155 | |||
156 | int uvc_status_init(struct uvc_device *dev) | ||
157 | { | ||
158 | struct usb_host_endpoint *ep = dev->int_ep; | ||
159 | unsigned int pipe; | ||
160 | int interval; | ||
161 | |||
162 | if (ep == NULL) | ||
163 | return 0; | ||
164 | |||
165 | uvc_input_init(dev); | ||
166 | |||
167 | dev->int_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
168 | if (dev->int_urb == NULL) | ||
169 | return -ENOMEM; | ||
170 | |||
171 | pipe = usb_rcvintpipe(dev->udev, ep->desc.bEndpointAddress); | ||
172 | |||
173 | /* For high-speed interrupt endpoints, the bInterval value is used as | ||
174 | * an exponent of two. Some developers forgot about it. | ||
175 | */ | ||
176 | interval = ep->desc.bInterval; | ||
177 | if (interval > 16 && dev->udev->speed == USB_SPEED_HIGH && | ||
178 | (dev->quirks & UVC_QUIRK_STATUS_INTERVAL)) | ||
179 | interval = fls(interval) - 1; | ||
180 | |||
181 | usb_fill_int_urb(dev->int_urb, dev->udev, pipe, | ||
182 | dev->status, sizeof dev->status, uvc_status_complete, | ||
183 | dev, interval); | ||
184 | |||
185 | return usb_submit_urb(dev->int_urb, GFP_KERNEL); | ||
186 | } | ||
187 | |||
188 | void uvc_status_cleanup(struct uvc_device *dev) | ||
189 | { | ||
190 | usb_kill_urb(dev->int_urb); | ||
191 | usb_free_urb(dev->int_urb); | ||
192 | uvc_input_cleanup(dev); | ||
193 | } | ||
194 | |||
195 | int uvc_status_suspend(struct uvc_device *dev) | ||
196 | { | ||
197 | usb_kill_urb(dev->int_urb); | ||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | int uvc_status_resume(struct uvc_device *dev) | ||
202 | { | ||
203 | if (dev->int_urb == NULL) | ||
204 | return 0; | ||
205 | |||
206 | return usb_submit_urb(dev->int_urb, GFP_KERNEL); | ||
207 | } | ||
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c new file mode 100644 index 000000000000..2e0a66575bb4 --- /dev/null +++ b/drivers/media/video/uvc/uvc_v4l2.c | |||
@@ -0,0 +1,1105 @@ | |||
1 | /* | ||
2 | * uvc_v4l2.c -- USB Video Class driver - V4L2 API | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/usb.h> | ||
19 | #include <linux/videodev2.h> | ||
20 | #include <linux/vmalloc.h> | ||
21 | #include <linux/mm.h> | ||
22 | #include <linux/wait.h> | ||
23 | #include <asm/atomic.h> | ||
24 | |||
25 | #include <media/v4l2-common.h> | ||
26 | |||
27 | #include "uvcvideo.h" | ||
28 | |||
29 | /* ------------------------------------------------------------------------ | ||
30 | * V4L2 interface | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * Mapping V4L2 controls to UVC controls can be straighforward if done well. | ||
35 | * Most of the UVC controls exist in V4L2, and can be mapped directly. Some | ||
36 | * must be grouped (for instance the Red Balance, Blue Balance and Do White | ||
37 | * Balance V4L2 controls use the White Balance Component UVC control) or | ||
38 | * otherwise translated. The approach we take here is to use a translation | ||
39 | * table for the controls which can be mapped directly, and handle the others | ||
40 | * manually. | ||
41 | */ | ||
42 | static int uvc_v4l2_query_menu(struct uvc_video_device *video, | ||
43 | struct v4l2_querymenu *query_menu) | ||
44 | { | ||
45 | struct uvc_menu_info *menu_info; | ||
46 | struct uvc_control_mapping *mapping; | ||
47 | struct uvc_control *ctrl; | ||
48 | |||
49 | ctrl = uvc_find_control(video, query_menu->id, &mapping); | ||
50 | if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) | ||
51 | return -EINVAL; | ||
52 | |||
53 | if (query_menu->index >= mapping->menu_count) | ||
54 | return -EINVAL; | ||
55 | |||
56 | menu_info = &mapping->menu_info[query_menu->index]; | ||
57 | strncpy(query_menu->name, menu_info->name, 32); | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * Find the frame interval closest to the requested frame interval for the | ||
63 | * given frame format and size. This should be done by the device as part of | ||
64 | * the Video Probe and Commit negotiation, but some hardware don't implement | ||
65 | * that feature. | ||
66 | */ | ||
67 | static __u32 uvc_try_frame_interval(struct uvc_frame *frame, __u32 interval) | ||
68 | { | ||
69 | unsigned int i; | ||
70 | |||
71 | if (frame->bFrameIntervalType) { | ||
72 | __u32 best = -1, dist; | ||
73 | |||
74 | for (i = 0; i < frame->bFrameIntervalType; ++i) { | ||
75 | dist = interval > frame->dwFrameInterval[i] | ||
76 | ? interval - frame->dwFrameInterval[i] | ||
77 | : frame->dwFrameInterval[i] - interval; | ||
78 | |||
79 | if (dist > best) | ||
80 | break; | ||
81 | |||
82 | best = dist; | ||
83 | } | ||
84 | |||
85 | interval = frame->dwFrameInterval[i-1]; | ||
86 | } else { | ||
87 | const __u32 min = frame->dwFrameInterval[0]; | ||
88 | const __u32 max = frame->dwFrameInterval[1]; | ||
89 | const __u32 step = frame->dwFrameInterval[2]; | ||
90 | |||
91 | interval = min + (interval - min + step/2) / step * step; | ||
92 | if (interval > max) | ||
93 | interval = max; | ||
94 | } | ||
95 | |||
96 | return interval; | ||
97 | } | ||
98 | |||
99 | static int uvc_v4l2_try_format(struct uvc_video_device *video, | ||
100 | struct v4l2_format *fmt, struct uvc_streaming_control *probe, | ||
101 | struct uvc_format **uvc_format, struct uvc_frame **uvc_frame) | ||
102 | { | ||
103 | struct uvc_format *format = NULL; | ||
104 | struct uvc_frame *frame = NULL; | ||
105 | __u16 rw, rh; | ||
106 | unsigned int d, maxd; | ||
107 | unsigned int i; | ||
108 | __u32 interval; | ||
109 | int ret = 0; | ||
110 | __u8 *fcc; | ||
111 | |||
112 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
113 | return -EINVAL; | ||
114 | |||
115 | fcc = (__u8 *)&fmt->fmt.pix.pixelformat; | ||
116 | uvc_trace(UVC_TRACE_FORMAT, "Trying format 0x%08x (%c%c%c%c): %ux%u.\n", | ||
117 | fmt->fmt.pix.pixelformat, | ||
118 | fcc[0], fcc[1], fcc[2], fcc[3], | ||
119 | fmt->fmt.pix.width, fmt->fmt.pix.height); | ||
120 | |||
121 | /* Check if the hardware supports the requested format. */ | ||
122 | for (i = 0; i < video->streaming->nformats; ++i) { | ||
123 | format = &video->streaming->format[i]; | ||
124 | if (format->fcc == fmt->fmt.pix.pixelformat) | ||
125 | break; | ||
126 | } | ||
127 | |||
128 | if (format == NULL || format->fcc != fmt->fmt.pix.pixelformat) { | ||
129 | uvc_trace(UVC_TRACE_FORMAT, "Unsupported format 0x%08x.\n", | ||
130 | fmt->fmt.pix.pixelformat); | ||
131 | return -EINVAL; | ||
132 | } | ||
133 | |||
134 | /* Find the closest image size. The distance between image sizes is | ||
135 | * the size in pixels of the non-overlapping regions between the | ||
136 | * requested size and the frame-specified size. | ||
137 | */ | ||
138 | rw = fmt->fmt.pix.width; | ||
139 | rh = fmt->fmt.pix.height; | ||
140 | maxd = (unsigned int)-1; | ||
141 | |||
142 | for (i = 0; i < format->nframes; ++i) { | ||
143 | __u16 w = format->frame[i].wWidth; | ||
144 | __u16 h = format->frame[i].wHeight; | ||
145 | |||
146 | d = min(w, rw) * min(h, rh); | ||
147 | d = w*h + rw*rh - 2*d; | ||
148 | if (d < maxd) { | ||
149 | maxd = d; | ||
150 | frame = &format->frame[i]; | ||
151 | } | ||
152 | |||
153 | if (maxd == 0) | ||
154 | break; | ||
155 | } | ||
156 | |||
157 | if (frame == NULL) { | ||
158 | uvc_trace(UVC_TRACE_FORMAT, "Unsupported size %ux%u.\n", | ||
159 | fmt->fmt.pix.width, fmt->fmt.pix.height); | ||
160 | return -EINVAL; | ||
161 | } | ||
162 | |||
163 | /* Use the default frame interval. */ | ||
164 | interval = frame->dwDefaultFrameInterval; | ||
165 | uvc_trace(UVC_TRACE_FORMAT, "Using default frame interval %u.%u us " | ||
166 | "(%u.%u fps).\n", interval/10, interval%10, 10000000/interval, | ||
167 | (100000000/interval)%10); | ||
168 | |||
169 | /* Set the format index, frame index and frame interval. */ | ||
170 | memset(probe, 0, sizeof *probe); | ||
171 | probe->bmHint = 1; /* dwFrameInterval */ | ||
172 | probe->bFormatIndex = format->index; | ||
173 | probe->bFrameIndex = frame->bFrameIndex; | ||
174 | probe->dwFrameInterval = uvc_try_frame_interval(frame, interval); | ||
175 | /* Some webcams stall the probe control set request when the | ||
176 | * dwMaxVideoFrameSize field is set to zero. The UVC specification | ||
177 | * clearly states that the field is read-only from the host, so this | ||
178 | * is a webcam bug. Set dwMaxVideoFrameSize to the value reported by | ||
179 | * the webcam to work around the problem. | ||
180 | * | ||
181 | * The workaround could probably be enabled for all webcams, so the | ||
182 | * quirk can be removed if needed. It's currently useful to detect | ||
183 | * webcam bugs and fix them before they hit the market (providing | ||
184 | * developers test their webcams with the Linux driver as well as with | ||
185 | * the Windows driver). | ||
186 | */ | ||
187 | if (video->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS) | ||
188 | probe->dwMaxVideoFrameSize = | ||
189 | video->streaming->ctrl.dwMaxVideoFrameSize; | ||
190 | |||
191 | /* Probe the device */ | ||
192 | if ((ret = uvc_probe_video(video, probe)) < 0) | ||
193 | goto done; | ||
194 | |||
195 | fmt->fmt.pix.width = frame->wWidth; | ||
196 | fmt->fmt.pix.height = frame->wHeight; | ||
197 | fmt->fmt.pix.field = V4L2_FIELD_NONE; | ||
198 | fmt->fmt.pix.bytesperline = format->bpp * frame->wWidth / 8; | ||
199 | fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize; | ||
200 | fmt->fmt.pix.colorspace = format->colorspace; | ||
201 | fmt->fmt.pix.priv = 0; | ||
202 | |||
203 | if (uvc_format != NULL) | ||
204 | *uvc_format = format; | ||
205 | if (uvc_frame != NULL) | ||
206 | *uvc_frame = frame; | ||
207 | |||
208 | done: | ||
209 | return ret; | ||
210 | } | ||
211 | |||
212 | static int uvc_v4l2_get_format(struct uvc_video_device *video, | ||
213 | struct v4l2_format *fmt) | ||
214 | { | ||
215 | struct uvc_format *format = video->streaming->cur_format; | ||
216 | struct uvc_frame *frame = video->streaming->cur_frame; | ||
217 | |||
218 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
219 | return -EINVAL; | ||
220 | |||
221 | if (format == NULL || frame == NULL) | ||
222 | return -EINVAL; | ||
223 | |||
224 | fmt->fmt.pix.pixelformat = format->fcc; | ||
225 | fmt->fmt.pix.width = frame->wWidth; | ||
226 | fmt->fmt.pix.height = frame->wHeight; | ||
227 | fmt->fmt.pix.field = V4L2_FIELD_NONE; | ||
228 | fmt->fmt.pix.bytesperline = format->bpp * frame->wWidth / 8; | ||
229 | fmt->fmt.pix.sizeimage = video->streaming->ctrl.dwMaxVideoFrameSize; | ||
230 | fmt->fmt.pix.colorspace = format->colorspace; | ||
231 | fmt->fmt.pix.priv = 0; | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int uvc_v4l2_set_format(struct uvc_video_device *video, | ||
237 | struct v4l2_format *fmt) | ||
238 | { | ||
239 | struct uvc_streaming_control probe; | ||
240 | struct uvc_format *format; | ||
241 | struct uvc_frame *frame; | ||
242 | int ret; | ||
243 | |||
244 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
245 | return -EINVAL; | ||
246 | |||
247 | if (uvc_queue_streaming(&video->queue)) | ||
248 | return -EBUSY; | ||
249 | |||
250 | ret = uvc_v4l2_try_format(video, fmt, &probe, &format, &frame); | ||
251 | if (ret < 0) | ||
252 | return ret; | ||
253 | |||
254 | if ((ret = uvc_set_video_ctrl(video, &probe, 0)) < 0) | ||
255 | return ret; | ||
256 | |||
257 | memcpy(&video->streaming->ctrl, &probe, sizeof probe); | ||
258 | video->streaming->cur_format = format; | ||
259 | video->streaming->cur_frame = frame; | ||
260 | |||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | static int uvc_v4l2_get_streamparm(struct uvc_video_device *video, | ||
265 | struct v4l2_streamparm *parm) | ||
266 | { | ||
267 | uint32_t numerator, denominator; | ||
268 | |||
269 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
270 | return -EINVAL; | ||
271 | |||
272 | numerator = video->streaming->ctrl.dwFrameInterval; | ||
273 | denominator = 10000000; | ||
274 | uvc_simplify_fraction(&numerator, &denominator, 8, 333); | ||
275 | |||
276 | memset(parm, 0, sizeof *parm); | ||
277 | parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
278 | parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; | ||
279 | parm->parm.capture.capturemode = 0; | ||
280 | parm->parm.capture.timeperframe.numerator = numerator; | ||
281 | parm->parm.capture.timeperframe.denominator = denominator; | ||
282 | parm->parm.capture.extendedmode = 0; | ||
283 | parm->parm.capture.readbuffers = 0; | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static int uvc_v4l2_set_streamparm(struct uvc_video_device *video, | ||
289 | struct v4l2_streamparm *parm) | ||
290 | { | ||
291 | struct uvc_frame *frame = video->streaming->cur_frame; | ||
292 | struct uvc_streaming_control probe; | ||
293 | uint32_t interval; | ||
294 | int ret; | ||
295 | |||
296 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
297 | return -EINVAL; | ||
298 | |||
299 | if (uvc_queue_streaming(&video->queue)) | ||
300 | return -EBUSY; | ||
301 | |||
302 | memcpy(&probe, &video->streaming->ctrl, sizeof probe); | ||
303 | interval = uvc_fraction_to_interval( | ||
304 | parm->parm.capture.timeperframe.numerator, | ||
305 | parm->parm.capture.timeperframe.denominator); | ||
306 | |||
307 | uvc_trace(UVC_TRACE_FORMAT, "Setting frame interval to %u/%u (%u).\n", | ||
308 | parm->parm.capture.timeperframe.numerator, | ||
309 | parm->parm.capture.timeperframe.denominator, | ||
310 | interval); | ||
311 | probe.dwFrameInterval = uvc_try_frame_interval(frame, interval); | ||
312 | |||
313 | /* Probe the device with the new settings. */ | ||
314 | if ((ret = uvc_probe_video(video, &probe)) < 0) | ||
315 | return ret; | ||
316 | |||
317 | /* Commit the new settings. */ | ||
318 | if ((ret = uvc_set_video_ctrl(video, &probe, 0)) < 0) | ||
319 | return ret; | ||
320 | |||
321 | memcpy(&video->streaming->ctrl, &probe, sizeof probe); | ||
322 | |||
323 | /* Return the actual frame period. */ | ||
324 | parm->parm.capture.timeperframe.numerator = probe.dwFrameInterval; | ||
325 | parm->parm.capture.timeperframe.denominator = 10000000; | ||
326 | uvc_simplify_fraction(&parm->parm.capture.timeperframe.numerator, | ||
327 | &parm->parm.capture.timeperframe.denominator, | ||
328 | 8, 333); | ||
329 | |||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | /* ------------------------------------------------------------------------ | ||
334 | * Privilege management | ||
335 | */ | ||
336 | |||
337 | /* | ||
338 | * Privilege management is the multiple-open implementation basis. The current | ||
339 | * implementation is completely transparent for the end-user and doesn't | ||
340 | * require explicit use of the VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY ioctls. | ||
341 | * Those ioctls enable finer control on the device (by making possible for a | ||
342 | * user to request exclusive access to a device), but are not mature yet. | ||
343 | * Switching to the V4L2 priority mechanism might be considered in the future | ||
344 | * if this situation changes. | ||
345 | * | ||
346 | * Each open instance of a UVC device can either be in a privileged or | ||
347 | * unprivileged state. Only a single instance can be in a privileged state at | ||
348 | * a given time. Trying to perform an operation which requires privileges will | ||
349 | * automatically acquire the required privileges if possible, or return -EBUSY | ||
350 | * otherwise. Privileges are dismissed when closing the instance. | ||
351 | * | ||
352 | * Operations which require privileges are: | ||
353 | * | ||
354 | * - VIDIOC_S_INPUT | ||
355 | * - VIDIOC_S_PARM | ||
356 | * - VIDIOC_S_FMT | ||
357 | * - VIDIOC_TRY_FMT | ||
358 | * - VIDIOC_REQBUFS | ||
359 | */ | ||
360 | static int uvc_acquire_privileges(struct uvc_fh *handle) | ||
361 | { | ||
362 | int ret = 0; | ||
363 | |||
364 | /* Always succeed if the handle is already privileged. */ | ||
365 | if (handle->state == UVC_HANDLE_ACTIVE) | ||
366 | return 0; | ||
367 | |||
368 | /* Check if the device already has a privileged handle. */ | ||
369 | mutex_lock(&uvc_driver.open_mutex); | ||
370 | if (atomic_inc_return(&handle->device->active) != 1) { | ||
371 | atomic_dec(&handle->device->active); | ||
372 | ret = -EBUSY; | ||
373 | goto done; | ||
374 | } | ||
375 | |||
376 | handle->state = UVC_HANDLE_ACTIVE; | ||
377 | |||
378 | done: | ||
379 | mutex_unlock(&uvc_driver.open_mutex); | ||
380 | return ret; | ||
381 | } | ||
382 | |||
383 | static void uvc_dismiss_privileges(struct uvc_fh *handle) | ||
384 | { | ||
385 | if (handle->state == UVC_HANDLE_ACTIVE) | ||
386 | atomic_dec(&handle->device->active); | ||
387 | |||
388 | handle->state = UVC_HANDLE_PASSIVE; | ||
389 | } | ||
390 | |||
391 | static int uvc_has_privileges(struct uvc_fh *handle) | ||
392 | { | ||
393 | return handle->state == UVC_HANDLE_ACTIVE; | ||
394 | } | ||
395 | |||
396 | /* ------------------------------------------------------------------------ | ||
397 | * V4L2 file operations | ||
398 | */ | ||
399 | |||
400 | static int uvc_v4l2_open(struct inode *inode, struct file *file) | ||
401 | { | ||
402 | struct video_device *vdev; | ||
403 | struct uvc_video_device *video; | ||
404 | struct uvc_fh *handle; | ||
405 | int ret = 0; | ||
406 | |||
407 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n"); | ||
408 | mutex_lock(&uvc_driver.open_mutex); | ||
409 | vdev = video_devdata(file); | ||
410 | video = video_get_drvdata(vdev); | ||
411 | |||
412 | if (video->dev->state & UVC_DEV_DISCONNECTED) { | ||
413 | ret = -ENODEV; | ||
414 | goto done; | ||
415 | } | ||
416 | |||
417 | ret = usb_autopm_get_interface(video->dev->intf); | ||
418 | if (ret < 0) | ||
419 | goto done; | ||
420 | |||
421 | /* Create the device handle. */ | ||
422 | handle = kzalloc(sizeof *handle, GFP_KERNEL); | ||
423 | if (handle == NULL) { | ||
424 | usb_autopm_put_interface(video->dev->intf); | ||
425 | ret = -ENOMEM; | ||
426 | goto done; | ||
427 | } | ||
428 | |||
429 | handle->device = video; | ||
430 | handle->state = UVC_HANDLE_PASSIVE; | ||
431 | file->private_data = handle; | ||
432 | |||
433 | kref_get(&video->dev->kref); | ||
434 | |||
435 | done: | ||
436 | mutex_unlock(&uvc_driver.open_mutex); | ||
437 | return ret; | ||
438 | } | ||
439 | |||
440 | static int uvc_v4l2_release(struct inode *inode, struct file *file) | ||
441 | { | ||
442 | struct video_device *vdev = video_devdata(file); | ||
443 | struct uvc_video_device *video = video_get_drvdata(vdev); | ||
444 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; | ||
445 | |||
446 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n"); | ||
447 | |||
448 | /* Only free resources if this is a privileged handle. */ | ||
449 | if (uvc_has_privileges(handle)) { | ||
450 | uvc_video_enable(video, 0); | ||
451 | |||
452 | mutex_lock(&video->queue.mutex); | ||
453 | if (uvc_free_buffers(&video->queue) < 0) | ||
454 | uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to " | ||
455 | "free buffers.\n"); | ||
456 | mutex_unlock(&video->queue.mutex); | ||
457 | } | ||
458 | |||
459 | /* Release the file handle. */ | ||
460 | uvc_dismiss_privileges(handle); | ||
461 | kfree(handle); | ||
462 | file->private_data = NULL; | ||
463 | |||
464 | usb_autopm_put_interface(video->dev->intf); | ||
465 | kref_put(&video->dev->kref, uvc_delete); | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static int uvc_v4l2_do_ioctl(struct inode *inode, struct file *file, | ||
470 | unsigned int cmd, void *arg) | ||
471 | { | ||
472 | struct video_device *vdev = video_devdata(file); | ||
473 | struct uvc_video_device *video = video_get_drvdata(vdev); | ||
474 | struct uvc_fh *handle = (struct uvc_fh *)file->private_data; | ||
475 | int ret = 0; | ||
476 | |||
477 | if (uvc_trace_param & UVC_TRACE_IOCTL) | ||
478 | v4l_printk_ioctl(cmd); | ||
479 | |||
480 | switch (cmd) { | ||
481 | /* Query capabilities */ | ||
482 | case VIDIOC_QUERYCAP: | ||
483 | { | ||
484 | struct v4l2_capability *cap = arg; | ||
485 | |||
486 | memset(cap, 0, sizeof *cap); | ||
487 | strncpy(cap->driver, "uvcvideo", sizeof cap->driver); | ||
488 | strncpy(cap->card, vdev->name, 32); | ||
489 | strncpy(cap->bus_info, video->dev->udev->bus->bus_name, | ||
490 | sizeof cap->bus_info); | ||
491 | cap->version = DRIVER_VERSION_NUMBER; | ||
492 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | ||
493 | | V4L2_CAP_STREAMING; | ||
494 | break; | ||
495 | } | ||
496 | |||
497 | /* Get, Set & Query control */ | ||
498 | case VIDIOC_QUERYCTRL: | ||
499 | return uvc_query_v4l2_ctrl(video, arg); | ||
500 | |||
501 | case VIDIOC_G_CTRL: | ||
502 | { | ||
503 | struct v4l2_control *ctrl = arg; | ||
504 | struct v4l2_ext_control xctrl; | ||
505 | |||
506 | memset(&xctrl, 0, sizeof xctrl); | ||
507 | xctrl.id = ctrl->id; | ||
508 | |||
509 | uvc_ctrl_begin(video); | ||
510 | ret = uvc_ctrl_get(video, &xctrl); | ||
511 | uvc_ctrl_rollback(video); | ||
512 | if (ret >= 0) | ||
513 | ctrl->value = xctrl.value; | ||
514 | break; | ||
515 | } | ||
516 | |||
517 | case VIDIOC_S_CTRL: | ||
518 | { | ||
519 | struct v4l2_control *ctrl = arg; | ||
520 | struct v4l2_ext_control xctrl; | ||
521 | |||
522 | memset(&xctrl, 0, sizeof xctrl); | ||
523 | xctrl.id = ctrl->id; | ||
524 | xctrl.value = ctrl->value; | ||
525 | |||
526 | uvc_ctrl_begin(video); | ||
527 | ret = uvc_ctrl_set(video, &xctrl); | ||
528 | if (ret < 0) { | ||
529 | uvc_ctrl_rollback(video); | ||
530 | return ret; | ||
531 | } | ||
532 | ret = uvc_ctrl_commit(video); | ||
533 | break; | ||
534 | } | ||
535 | |||
536 | case VIDIOC_QUERYMENU: | ||
537 | return uvc_v4l2_query_menu(video, arg); | ||
538 | |||
539 | case VIDIOC_G_EXT_CTRLS: | ||
540 | { | ||
541 | struct v4l2_ext_controls *ctrls = arg; | ||
542 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
543 | unsigned int i; | ||
544 | |||
545 | uvc_ctrl_begin(video); | ||
546 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { | ||
547 | ret = uvc_ctrl_get(video, ctrl); | ||
548 | if (ret < 0) { | ||
549 | uvc_ctrl_rollback(video); | ||
550 | ctrls->error_idx = i; | ||
551 | return ret; | ||
552 | } | ||
553 | } | ||
554 | ctrls->error_idx = 0; | ||
555 | ret = uvc_ctrl_rollback(video); | ||
556 | break; | ||
557 | } | ||
558 | |||
559 | case VIDIOC_S_EXT_CTRLS: | ||
560 | case VIDIOC_TRY_EXT_CTRLS: | ||
561 | { | ||
562 | struct v4l2_ext_controls *ctrls = arg; | ||
563 | struct v4l2_ext_control *ctrl = ctrls->controls; | ||
564 | unsigned int i; | ||
565 | |||
566 | ret = uvc_ctrl_begin(video); | ||
567 | if (ret < 0) | ||
568 | return ret; | ||
569 | |||
570 | for (i = 0; i < ctrls->count; ++ctrl, ++i) { | ||
571 | ret = uvc_ctrl_set(video, ctrl); | ||
572 | if (ret < 0) { | ||
573 | uvc_ctrl_rollback(video); | ||
574 | ctrls->error_idx = i; | ||
575 | return ret; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | ctrls->error_idx = 0; | ||
580 | |||
581 | if (cmd == VIDIOC_S_EXT_CTRLS) | ||
582 | ret = uvc_ctrl_commit(video); | ||
583 | else | ||
584 | ret = uvc_ctrl_rollback(video); | ||
585 | break; | ||
586 | } | ||
587 | |||
588 | /* Get, Set & Enum input */ | ||
589 | case VIDIOC_ENUMINPUT: | ||
590 | { | ||
591 | const struct uvc_entity *selector = video->selector; | ||
592 | struct v4l2_input *input = arg; | ||
593 | struct uvc_entity *iterm = NULL; | ||
594 | u32 index = input->index; | ||
595 | int pin = 0; | ||
596 | |||
597 | if (selector == NULL || | ||
598 | (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | ||
599 | if (index != 0) | ||
600 | return -EINVAL; | ||
601 | iterm = list_first_entry(&video->iterms, | ||
602 | struct uvc_entity, chain); | ||
603 | pin = iterm->id; | ||
604 | } else if (pin < selector->selector.bNrInPins) { | ||
605 | pin = selector->selector.baSourceID[index]; | ||
606 | list_for_each_entry(iterm, video->iterms.next, chain) { | ||
607 | if (iterm->id == pin) | ||
608 | break; | ||
609 | } | ||
610 | } | ||
611 | |||
612 | if (iterm == NULL || iterm->id != pin) | ||
613 | return -EINVAL; | ||
614 | |||
615 | memset(input, 0, sizeof *input); | ||
616 | input->index = index; | ||
617 | strncpy(input->name, iterm->name, sizeof input->name); | ||
618 | if (UVC_ENTITY_TYPE(iterm) == ITT_CAMERA) | ||
619 | input->type = V4L2_INPUT_TYPE_CAMERA; | ||
620 | break; | ||
621 | } | ||
622 | |||
623 | case VIDIOC_G_INPUT: | ||
624 | { | ||
625 | u8 input; | ||
626 | |||
627 | if (video->selector == NULL || | ||
628 | (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | ||
629 | *(int *)arg = 0; | ||
630 | break; | ||
631 | } | ||
632 | |||
633 | ret = uvc_query_ctrl(video->dev, GET_CUR, video->selector->id, | ||
634 | video->dev->intfnum, SU_INPUT_SELECT_CONTROL, | ||
635 | &input, 1); | ||
636 | if (ret < 0) | ||
637 | return ret; | ||
638 | |||
639 | *(int *)arg = input - 1; | ||
640 | break; | ||
641 | } | ||
642 | |||
643 | case VIDIOC_S_INPUT: | ||
644 | { | ||
645 | u8 input = *(u32 *)arg + 1; | ||
646 | |||
647 | if ((ret = uvc_acquire_privileges(handle)) < 0) | ||
648 | return ret; | ||
649 | |||
650 | if (video->selector == NULL || | ||
651 | (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { | ||
652 | if (input != 1) | ||
653 | return -EINVAL; | ||
654 | break; | ||
655 | } | ||
656 | |||
657 | if (input > video->selector->selector.bNrInPins) | ||
658 | return -EINVAL; | ||
659 | |||
660 | return uvc_query_ctrl(video->dev, SET_CUR, video->selector->id, | ||
661 | video->dev->intfnum, SU_INPUT_SELECT_CONTROL, | ||
662 | &input, 1); | ||
663 | } | ||
664 | |||
665 | /* Try, Get, Set & Enum format */ | ||
666 | case VIDIOC_ENUM_FMT: | ||
667 | { | ||
668 | struct v4l2_fmtdesc *fmt = arg; | ||
669 | struct uvc_format *format; | ||
670 | |||
671 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
672 | fmt->index >= video->streaming->nformats) | ||
673 | return -EINVAL; | ||
674 | |||
675 | format = &video->streaming->format[fmt->index]; | ||
676 | fmt->flags = 0; | ||
677 | if (format->flags & UVC_FMT_FLAG_COMPRESSED) | ||
678 | fmt->flags |= V4L2_FMT_FLAG_COMPRESSED; | ||
679 | strncpy(fmt->description, format->name, | ||
680 | sizeof fmt->description); | ||
681 | fmt->description[sizeof fmt->description - 1] = 0; | ||
682 | fmt->pixelformat = format->fcc; | ||
683 | break; | ||
684 | } | ||
685 | |||
686 | case VIDIOC_TRY_FMT: | ||
687 | { | ||
688 | struct uvc_streaming_control probe; | ||
689 | |||
690 | if ((ret = uvc_acquire_privileges(handle)) < 0) | ||
691 | return ret; | ||
692 | |||
693 | return uvc_v4l2_try_format(video, arg, &probe, NULL, NULL); | ||
694 | } | ||
695 | |||
696 | case VIDIOC_S_FMT: | ||
697 | if ((ret = uvc_acquire_privileges(handle)) < 0) | ||
698 | return ret; | ||
699 | |||
700 | return uvc_v4l2_set_format(video, arg); | ||
701 | |||
702 | case VIDIOC_G_FMT: | ||
703 | return uvc_v4l2_get_format(video, arg); | ||
704 | |||
705 | /* Frame size enumeration */ | ||
706 | case VIDIOC_ENUM_FRAMESIZES: | ||
707 | { | ||
708 | struct v4l2_frmsizeenum *fsize = arg; | ||
709 | struct uvc_format *format = NULL; | ||
710 | struct uvc_frame *frame; | ||
711 | int i; | ||
712 | |||
713 | /* Look for the given pixel format */ | ||
714 | for (i = 0; i < video->streaming->nformats; i++) { | ||
715 | if (video->streaming->format[i].fcc == | ||
716 | fsize->pixel_format) { | ||
717 | format = &video->streaming->format[i]; | ||
718 | break; | ||
719 | } | ||
720 | } | ||
721 | if (format == NULL) | ||
722 | return -EINVAL; | ||
723 | |||
724 | if (fsize->index >= format->nframes) | ||
725 | return -EINVAL; | ||
726 | |||
727 | frame = &format->frame[fsize->index]; | ||
728 | fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; | ||
729 | fsize->discrete.width = frame->wWidth; | ||
730 | fsize->discrete.height = frame->wHeight; | ||
731 | break; | ||
732 | } | ||
733 | |||
734 | /* Frame interval enumeration */ | ||
735 | case VIDIOC_ENUM_FRAMEINTERVALS: | ||
736 | { | ||
737 | struct v4l2_frmivalenum *fival = arg; | ||
738 | struct uvc_format *format = NULL; | ||
739 | struct uvc_frame *frame = NULL; | ||
740 | int i; | ||
741 | |||
742 | /* Look for the given pixel format and frame size */ | ||
743 | for (i = 0; i < video->streaming->nformats; i++) { | ||
744 | if (video->streaming->format[i].fcc == | ||
745 | fival->pixel_format) { | ||
746 | format = &video->streaming->format[i]; | ||
747 | break; | ||
748 | } | ||
749 | } | ||
750 | if (format == NULL) | ||
751 | return -EINVAL; | ||
752 | |||
753 | for (i = 0; i < format->nframes; i++) { | ||
754 | if (format->frame[i].wWidth == fival->width && | ||
755 | format->frame[i].wHeight == fival->height) { | ||
756 | frame = &format->frame[i]; | ||
757 | break; | ||
758 | } | ||
759 | } | ||
760 | if (frame == NULL) | ||
761 | return -EINVAL; | ||
762 | |||
763 | if (frame->bFrameIntervalType) { | ||
764 | if (fival->index >= frame->bFrameIntervalType) | ||
765 | return -EINVAL; | ||
766 | |||
767 | fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; | ||
768 | fival->discrete.numerator = | ||
769 | frame->dwFrameInterval[fival->index]; | ||
770 | fival->discrete.denominator = 10000000; | ||
771 | uvc_simplify_fraction(&fival->discrete.numerator, | ||
772 | &fival->discrete.denominator, 8, 333); | ||
773 | } else { | ||
774 | fival->type = V4L2_FRMIVAL_TYPE_STEPWISE; | ||
775 | fival->stepwise.min.numerator = | ||
776 | frame->dwFrameInterval[0]; | ||
777 | fival->stepwise.min.denominator = 10000000; | ||
778 | fival->stepwise.max.numerator = | ||
779 | frame->dwFrameInterval[1]; | ||
780 | fival->stepwise.max.denominator = 10000000; | ||
781 | fival->stepwise.step.numerator = | ||
782 | frame->dwFrameInterval[2]; | ||
783 | fival->stepwise.step.denominator = 10000000; | ||
784 | uvc_simplify_fraction(&fival->stepwise.min.numerator, | ||
785 | &fival->stepwise.min.denominator, 8, 333); | ||
786 | uvc_simplify_fraction(&fival->stepwise.max.numerator, | ||
787 | &fival->stepwise.max.denominator, 8, 333); | ||
788 | uvc_simplify_fraction(&fival->stepwise.step.numerator, | ||
789 | &fival->stepwise.step.denominator, 8, 333); | ||
790 | } | ||
791 | break; | ||
792 | } | ||
793 | |||
794 | /* Get & Set streaming parameters */ | ||
795 | case VIDIOC_G_PARM: | ||
796 | return uvc_v4l2_get_streamparm(video, arg); | ||
797 | |||
798 | case VIDIOC_S_PARM: | ||
799 | if ((ret = uvc_acquire_privileges(handle)) < 0) | ||
800 | return ret; | ||
801 | |||
802 | return uvc_v4l2_set_streamparm(video, arg); | ||
803 | |||
804 | /* Cropping and scaling */ | ||
805 | case VIDIOC_CROPCAP: | ||
806 | { | ||
807 | struct v4l2_cropcap *ccap = arg; | ||
808 | struct uvc_frame *frame = video->streaming->cur_frame; | ||
809 | |||
810 | if (ccap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
811 | return -EINVAL; | ||
812 | |||
813 | ccap->bounds.left = 0; | ||
814 | ccap->bounds.top = 0; | ||
815 | ccap->bounds.width = frame->wWidth; | ||
816 | ccap->bounds.height = frame->wHeight; | ||
817 | |||
818 | ccap->defrect = ccap->bounds; | ||
819 | |||
820 | ccap->pixelaspect.numerator = 1; | ||
821 | ccap->pixelaspect.denominator = 1; | ||
822 | break; | ||
823 | } | ||
824 | |||
825 | case VIDIOC_G_CROP: | ||
826 | case VIDIOC_S_CROP: | ||
827 | return -EINVAL; | ||
828 | |||
829 | /* Buffers & streaming */ | ||
830 | case VIDIOC_REQBUFS: | ||
831 | { | ||
832 | struct v4l2_requestbuffers *rb = arg; | ||
833 | unsigned int bufsize = | ||
834 | video->streaming->ctrl.dwMaxVideoFrameSize; | ||
835 | |||
836 | if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
837 | rb->memory != V4L2_MEMORY_MMAP) | ||
838 | return -EINVAL; | ||
839 | |||
840 | if ((ret = uvc_acquire_privileges(handle)) < 0) | ||
841 | return ret; | ||
842 | |||
843 | ret = uvc_alloc_buffers(&video->queue, rb->count, bufsize); | ||
844 | if (ret < 0) | ||
845 | return ret; | ||
846 | |||
847 | if (!(video->streaming->cur_format->flags & | ||
848 | UVC_FMT_FLAG_COMPRESSED)) | ||
849 | video->queue.flags |= UVC_QUEUE_DROP_INCOMPLETE; | ||
850 | |||
851 | rb->count = ret; | ||
852 | ret = 0; | ||
853 | break; | ||
854 | } | ||
855 | |||
856 | case VIDIOC_QUERYBUF: | ||
857 | { | ||
858 | struct v4l2_buffer *buf = arg; | ||
859 | |||
860 | if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
861 | return -EINVAL; | ||
862 | |||
863 | if (!uvc_has_privileges(handle)) | ||
864 | return -EBUSY; | ||
865 | |||
866 | return uvc_query_buffer(&video->queue, buf); | ||
867 | } | ||
868 | |||
869 | case VIDIOC_QBUF: | ||
870 | if (!uvc_has_privileges(handle)) | ||
871 | return -EBUSY; | ||
872 | |||
873 | return uvc_queue_buffer(&video->queue, arg); | ||
874 | |||
875 | case VIDIOC_DQBUF: | ||
876 | if (!uvc_has_privileges(handle)) | ||
877 | return -EBUSY; | ||
878 | |||
879 | return uvc_dequeue_buffer(&video->queue, arg, | ||
880 | file->f_flags & O_NONBLOCK); | ||
881 | |||
882 | case VIDIOC_STREAMON: | ||
883 | { | ||
884 | int *type = arg; | ||
885 | |||
886 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
887 | return -EINVAL; | ||
888 | |||
889 | if (!uvc_has_privileges(handle)) | ||
890 | return -EBUSY; | ||
891 | |||
892 | if ((ret = uvc_video_enable(video, 1)) < 0) | ||
893 | return ret; | ||
894 | break; | ||
895 | } | ||
896 | |||
897 | case VIDIOC_STREAMOFF: | ||
898 | { | ||
899 | int *type = arg; | ||
900 | |||
901 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
902 | return -EINVAL; | ||
903 | |||
904 | if (!uvc_has_privileges(handle)) | ||
905 | return -EBUSY; | ||
906 | |||
907 | return uvc_video_enable(video, 0); | ||
908 | } | ||
909 | |||
910 | /* Analog video standards make no sense for digital cameras. */ | ||
911 | case VIDIOC_ENUMSTD: | ||
912 | case VIDIOC_QUERYSTD: | ||
913 | case VIDIOC_G_STD: | ||
914 | case VIDIOC_S_STD: | ||
915 | |||
916 | case VIDIOC_OVERLAY: | ||
917 | |||
918 | case VIDIOC_ENUMAUDIO: | ||
919 | case VIDIOC_ENUMAUDOUT: | ||
920 | |||
921 | case VIDIOC_ENUMOUTPUT: | ||
922 | uvc_trace(UVC_TRACE_IOCTL, "Unsupported ioctl 0x%08x\n", cmd); | ||
923 | return -EINVAL; | ||
924 | |||
925 | /* Dynamic controls. */ | ||
926 | case UVCIOC_CTRL_ADD: | ||
927 | { | ||
928 | struct uvc_xu_control_info *xinfo = arg; | ||
929 | struct uvc_control_info *info; | ||
930 | |||
931 | if (!capable(CAP_SYS_ADMIN)) | ||
932 | return -EPERM; | ||
933 | |||
934 | info = kmalloc(sizeof *info, GFP_KERNEL); | ||
935 | if (info == NULL) | ||
936 | return -ENOMEM; | ||
937 | |||
938 | memcpy(info->entity, xinfo->entity, sizeof info->entity); | ||
939 | info->index = xinfo->index; | ||
940 | info->selector = xinfo->selector; | ||
941 | info->size = xinfo->size; | ||
942 | info->flags = xinfo->flags; | ||
943 | |||
944 | info->flags |= UVC_CONTROL_GET_MIN | UVC_CONTROL_GET_MAX | | ||
945 | UVC_CONTROL_GET_RES | UVC_CONTROL_GET_DEF; | ||
946 | |||
947 | ret = uvc_ctrl_add_info(info); | ||
948 | if (ret < 0) | ||
949 | kfree(info); | ||
950 | break; | ||
951 | } | ||
952 | |||
953 | case UVCIOC_CTRL_MAP: | ||
954 | { | ||
955 | struct uvc_xu_control_mapping *xmap = arg; | ||
956 | struct uvc_control_mapping *map; | ||
957 | |||
958 | if (!capable(CAP_SYS_ADMIN)) | ||
959 | return -EPERM; | ||
960 | |||
961 | map = kmalloc(sizeof *map, GFP_KERNEL); | ||
962 | if (map == NULL) | ||
963 | return -ENOMEM; | ||
964 | |||
965 | map->id = xmap->id; | ||
966 | memcpy(map->name, xmap->name, sizeof map->name); | ||
967 | memcpy(map->entity, xmap->entity, sizeof map->entity); | ||
968 | map->selector = xmap->selector; | ||
969 | map->size = xmap->size; | ||
970 | map->offset = xmap->offset; | ||
971 | map->v4l2_type = xmap->v4l2_type; | ||
972 | map->data_type = xmap->data_type; | ||
973 | |||
974 | ret = uvc_ctrl_add_mapping(map); | ||
975 | if (ret < 0) | ||
976 | kfree(map); | ||
977 | break; | ||
978 | } | ||
979 | |||
980 | case UVCIOC_CTRL_GET: | ||
981 | return uvc_xu_ctrl_query(video, arg, 0); | ||
982 | |||
983 | case UVCIOC_CTRL_SET: | ||
984 | return uvc_xu_ctrl_query(video, arg, 1); | ||
985 | |||
986 | default: | ||
987 | if ((ret = v4l_compat_translate_ioctl(inode, file, cmd, arg, | ||
988 | uvc_v4l2_do_ioctl)) == -ENOIOCTLCMD) | ||
989 | uvc_trace(UVC_TRACE_IOCTL, "Unknown ioctl 0x%08x\n", | ||
990 | cmd); | ||
991 | return ret; | ||
992 | } | ||
993 | |||
994 | return ret; | ||
995 | } | ||
996 | |||
997 | static int uvc_v4l2_ioctl(struct inode *inode, struct file *file, | ||
998 | unsigned int cmd, unsigned long arg) | ||
999 | { | ||
1000 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_ioctl\n"); | ||
1001 | return video_usercopy(inode, file, cmd, arg, uvc_v4l2_do_ioctl); | ||
1002 | } | ||
1003 | |||
1004 | static ssize_t uvc_v4l2_read(struct file *file, char __user *data, | ||
1005 | size_t count, loff_t *ppos) | ||
1006 | { | ||
1007 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_read: not implemented.\n"); | ||
1008 | return -ENODEV; | ||
1009 | } | ||
1010 | |||
1011 | /* | ||
1012 | * VMA operations. | ||
1013 | */ | ||
1014 | static void uvc_vm_open(struct vm_area_struct *vma) | ||
1015 | { | ||
1016 | struct uvc_buffer *buffer = vma->vm_private_data; | ||
1017 | buffer->vma_use_count++; | ||
1018 | } | ||
1019 | |||
1020 | static void uvc_vm_close(struct vm_area_struct *vma) | ||
1021 | { | ||
1022 | struct uvc_buffer *buffer = vma->vm_private_data; | ||
1023 | buffer->vma_use_count--; | ||
1024 | } | ||
1025 | |||
1026 | static struct vm_operations_struct uvc_vm_ops = { | ||
1027 | .open = uvc_vm_open, | ||
1028 | .close = uvc_vm_close, | ||
1029 | }; | ||
1030 | |||
1031 | static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | ||
1032 | { | ||
1033 | struct video_device *vdev = video_devdata(file); | ||
1034 | struct uvc_video_device *video = video_get_drvdata(vdev); | ||
1035 | struct uvc_buffer *buffer; | ||
1036 | struct page *page; | ||
1037 | unsigned long addr, start, size; | ||
1038 | unsigned int i; | ||
1039 | int ret = 0; | ||
1040 | |||
1041 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_mmap\n"); | ||
1042 | |||
1043 | start = vma->vm_start; | ||
1044 | size = vma->vm_end - vma->vm_start; | ||
1045 | |||
1046 | mutex_lock(&video->queue.mutex); | ||
1047 | |||
1048 | for (i = 0; i < video->queue.count; ++i) { | ||
1049 | buffer = &video->queue.buffer[i]; | ||
1050 | if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff) | ||
1051 | break; | ||
1052 | } | ||
1053 | |||
1054 | if (i == video->queue.count || size != video->queue.buf_size) { | ||
1055 | ret = -EINVAL; | ||
1056 | goto done; | ||
1057 | } | ||
1058 | |||
1059 | /* | ||
1060 | * VM_IO marks the area as being an mmaped region for I/O to a | ||
1061 | * device. It also prevents the region from being core dumped. | ||
1062 | */ | ||
1063 | vma->vm_flags |= VM_IO; | ||
1064 | |||
1065 | addr = (unsigned long)video->queue.mem + buffer->buf.m.offset; | ||
1066 | while (size > 0) { | ||
1067 | page = vmalloc_to_page((void *)addr); | ||
1068 | if ((ret = vm_insert_page(vma, start, page)) < 0) | ||
1069 | goto done; | ||
1070 | |||
1071 | start += PAGE_SIZE; | ||
1072 | addr += PAGE_SIZE; | ||
1073 | size -= PAGE_SIZE; | ||
1074 | } | ||
1075 | |||
1076 | vma->vm_ops = &uvc_vm_ops; | ||
1077 | vma->vm_private_data = buffer; | ||
1078 | uvc_vm_open(vma); | ||
1079 | |||
1080 | done: | ||
1081 | mutex_unlock(&video->queue.mutex); | ||
1082 | return ret; | ||
1083 | } | ||
1084 | |||
1085 | static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait) | ||
1086 | { | ||
1087 | struct video_device *vdev = video_devdata(file); | ||
1088 | struct uvc_video_device *video = video_get_drvdata(vdev); | ||
1089 | |||
1090 | uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n"); | ||
1091 | |||
1092 | return uvc_queue_poll(&video->queue, file, wait); | ||
1093 | } | ||
1094 | |||
1095 | struct file_operations uvc_fops = { | ||
1096 | .owner = THIS_MODULE, | ||
1097 | .open = uvc_v4l2_open, | ||
1098 | .release = uvc_v4l2_release, | ||
1099 | .ioctl = uvc_v4l2_ioctl, | ||
1100 | .compat_ioctl = v4l_compat_ioctl32, | ||
1101 | .llseek = no_llseek, | ||
1102 | .read = uvc_v4l2_read, | ||
1103 | .mmap = uvc_v4l2_mmap, | ||
1104 | .poll = uvc_v4l2_poll, | ||
1105 | }; | ||
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c new file mode 100644 index 000000000000..6faf1fb21614 --- /dev/null +++ b/drivers/media/video/uvc/uvc_video.c | |||
@@ -0,0 +1,934 @@ | |||
1 | /* | ||
2 | * uvc_video.c -- USB Video Class driver - Video handling | ||
3 | * | ||
4 | * Copyright (C) 2005-2008 | ||
5 | * Laurent Pinchart (laurent.pinchart@skynet.be) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/version.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/usb.h> | ||
19 | #include <linux/videodev2.h> | ||
20 | #include <linux/vmalloc.h> | ||
21 | #include <linux/wait.h> | ||
22 | #include <asm/atomic.h> | ||
23 | #include <asm/unaligned.h> | ||
24 | |||
25 | #include <media/v4l2-common.h> | ||
26 | |||
27 | #include "uvcvideo.h" | ||
28 | |||
29 | /* ------------------------------------------------------------------------ | ||
30 | * UVC Controls | ||
31 | */ | ||
32 | |||
33 | static int __uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, | ||
34 | __u8 intfnum, __u8 cs, void *data, __u16 size, | ||
35 | int timeout) | ||
36 | { | ||
37 | __u8 type = USB_TYPE_CLASS | USB_RECIP_INTERFACE; | ||
38 | unsigned int pipe; | ||
39 | int ret; | ||
40 | |||
41 | pipe = (query & 0x80) ? usb_rcvctrlpipe(dev->udev, 0) | ||
42 | : usb_sndctrlpipe(dev->udev, 0); | ||
43 | type |= (query & 0x80) ? USB_DIR_IN : USB_DIR_OUT; | ||
44 | |||
45 | ret = usb_control_msg(dev->udev, pipe, query, type, cs << 8, | ||
46 | unit << 8 | intfnum, data, size, timeout); | ||
47 | |||
48 | if (ret != size) { | ||
49 | uvc_printk(KERN_ERR, "Failed to query (%u) UVC control %u " | ||
50 | "(unit %u) : %d (exp. %u).\n", query, cs, unit, ret, | ||
51 | size); | ||
52 | return -EIO; | ||
53 | } | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, | ||
59 | __u8 intfnum, __u8 cs, void *data, __u16 size) | ||
60 | { | ||
61 | return __uvc_query_ctrl(dev, query, unit, intfnum, cs, data, size, | ||
62 | UVC_CTRL_CONTROL_TIMEOUT); | ||
63 | } | ||
64 | |||
65 | static void uvc_fixup_buffer_size(struct uvc_video_device *video, | ||
66 | struct uvc_streaming_control *ctrl) | ||
67 | { | ||
68 | struct uvc_format *format; | ||
69 | struct uvc_frame *frame; | ||
70 | |||
71 | if (ctrl->bFormatIndex <= 0 || | ||
72 | ctrl->bFormatIndex > video->streaming->nformats) | ||
73 | return; | ||
74 | |||
75 | format = &video->streaming->format[ctrl->bFormatIndex - 1]; | ||
76 | |||
77 | if (ctrl->bFrameIndex <= 0 || | ||
78 | ctrl->bFrameIndex > format->nframes) | ||
79 | return; | ||
80 | |||
81 | frame = &format->frame[ctrl->bFrameIndex - 1]; | ||
82 | |||
83 | if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) || | ||
84 | (ctrl->dwMaxVideoFrameSize == 0 && | ||
85 | video->dev->uvc_version < 0x0110)) | ||
86 | ctrl->dwMaxVideoFrameSize = | ||
87 | frame->dwMaxVideoFrameBufferSize; | ||
88 | } | ||
89 | |||
90 | static int uvc_get_video_ctrl(struct uvc_video_device *video, | ||
91 | struct uvc_streaming_control *ctrl, int probe, __u8 query) | ||
92 | { | ||
93 | __u8 data[34]; | ||
94 | __u8 size; | ||
95 | int ret; | ||
96 | |||
97 | size = video->dev->uvc_version >= 0x0110 ? 34 : 26; | ||
98 | ret = __uvc_query_ctrl(video->dev, query, 0, video->streaming->intfnum, | ||
99 | probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, &data, size, | ||
100 | UVC_CTRL_STREAMING_TIMEOUT); | ||
101 | |||
102 | if (ret < 0) | ||
103 | return ret; | ||
104 | |||
105 | ctrl->bmHint = le16_to_cpup((__le16 *)&data[0]); | ||
106 | ctrl->bFormatIndex = data[2]; | ||
107 | ctrl->bFrameIndex = data[3]; | ||
108 | ctrl->dwFrameInterval = le32_to_cpup((__le32 *)&data[4]); | ||
109 | ctrl->wKeyFrameRate = le16_to_cpup((__le16 *)&data[8]); | ||
110 | ctrl->wPFrameRate = le16_to_cpup((__le16 *)&data[10]); | ||
111 | ctrl->wCompQuality = le16_to_cpup((__le16 *)&data[12]); | ||
112 | ctrl->wCompWindowSize = le16_to_cpup((__le16 *)&data[14]); | ||
113 | ctrl->wDelay = le16_to_cpup((__le16 *)&data[16]); | ||
114 | ctrl->dwMaxVideoFrameSize = | ||
115 | le32_to_cpu(get_unaligned((__le32 *)&data[18])); | ||
116 | ctrl->dwMaxPayloadTransferSize = | ||
117 | le32_to_cpu(get_unaligned((__le32 *)&data[22])); | ||
118 | |||
119 | if (size == 34) { | ||
120 | ctrl->dwClockFrequency = | ||
121 | le32_to_cpu(get_unaligned((__le32 *)&data[26])); | ||
122 | ctrl->bmFramingInfo = data[30]; | ||
123 | ctrl->bPreferedVersion = data[31]; | ||
124 | ctrl->bMinVersion = data[32]; | ||
125 | ctrl->bMaxVersion = data[33]; | ||
126 | } else { | ||
127 | ctrl->dwClockFrequency = video->dev->clock_frequency; | ||
128 | ctrl->bmFramingInfo = 0; | ||
129 | ctrl->bPreferedVersion = 0; | ||
130 | ctrl->bMinVersion = 0; | ||
131 | ctrl->bMaxVersion = 0; | ||
132 | } | ||
133 | |||
134 | /* Some broken devices return a null or wrong dwMaxVideoFrameSize. | ||
135 | * Try to get the value from the format and frame descriptor. | ||
136 | */ | ||
137 | uvc_fixup_buffer_size(video, ctrl); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | int uvc_set_video_ctrl(struct uvc_video_device *video, | ||
143 | struct uvc_streaming_control *ctrl, int probe) | ||
144 | { | ||
145 | __u8 data[34]; | ||
146 | __u8 size; | ||
147 | |||
148 | size = video->dev->uvc_version >= 0x0110 ? 34 : 26; | ||
149 | memset(data, 0, sizeof data); | ||
150 | |||
151 | *(__le16 *)&data[0] = cpu_to_le16(ctrl->bmHint); | ||
152 | data[2] = ctrl->bFormatIndex; | ||
153 | data[3] = ctrl->bFrameIndex; | ||
154 | *(__le32 *)&data[4] = cpu_to_le32(ctrl->dwFrameInterval); | ||
155 | *(__le16 *)&data[8] = cpu_to_le16(ctrl->wKeyFrameRate); | ||
156 | *(__le16 *)&data[10] = cpu_to_le16(ctrl->wPFrameRate); | ||
157 | *(__le16 *)&data[12] = cpu_to_le16(ctrl->wCompQuality); | ||
158 | *(__le16 *)&data[14] = cpu_to_le16(ctrl->wCompWindowSize); | ||
159 | *(__le16 *)&data[16] = cpu_to_le16(ctrl->wDelay); | ||
160 | /* Note: Some of the fields below are not required for IN devices (see | ||
161 | * UVC spec, 4.3.1.1), but we still copy them in case support for OUT | ||
162 | * devices is added in the future. */ | ||
163 | put_unaligned(cpu_to_le32(ctrl->dwMaxVideoFrameSize), | ||
164 | (__le32 *)&data[18]); | ||
165 | put_unaligned(cpu_to_le32(ctrl->dwMaxPayloadTransferSize), | ||
166 | (__le32 *)&data[22]); | ||
167 | |||
168 | if (size == 34) { | ||
169 | put_unaligned(cpu_to_le32(ctrl->dwClockFrequency), | ||
170 | (__le32 *)&data[26]); | ||
171 | data[30] = ctrl->bmFramingInfo; | ||
172 | data[31] = ctrl->bPreferedVersion; | ||
173 | data[32] = ctrl->bMinVersion; | ||
174 | data[33] = ctrl->bMaxVersion; | ||
175 | } | ||
176 | |||
177 | return __uvc_query_ctrl(video->dev, SET_CUR, 0, | ||
178 | video->streaming->intfnum, | ||
179 | probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, &data, size, | ||
180 | UVC_CTRL_STREAMING_TIMEOUT); | ||
181 | } | ||
182 | |||
183 | int uvc_probe_video(struct uvc_video_device *video, | ||
184 | struct uvc_streaming_control *probe) | ||
185 | { | ||
186 | struct uvc_streaming_control probe_min, probe_max; | ||
187 | __u16 bandwidth; | ||
188 | unsigned int i; | ||
189 | int ret; | ||
190 | |||
191 | mutex_lock(&video->streaming->mutex); | ||
192 | |||
193 | /* Perform probing. The device should adjust the requested values | ||
194 | * according to its capabilities. However, some devices, namely the | ||
195 | * first generation UVC Logitech webcams, don't implement the Video | ||
196 | * Probe control properly, and just return the needed bandwidth. For | ||
197 | * that reason, if the needed bandwidth exceeds the maximum available | ||
198 | * bandwidth, try to lower the quality. | ||
199 | */ | ||
200 | if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0) | ||
201 | goto done; | ||
202 | |||
203 | /* Get the minimum and maximum values for compression settings. */ | ||
204 | if (!(video->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) { | ||
205 | ret = uvc_get_video_ctrl(video, &probe_min, 1, GET_MIN); | ||
206 | if (ret < 0) | ||
207 | goto done; | ||
208 | ret = uvc_get_video_ctrl(video, &probe_max, 1, GET_MAX); | ||
209 | if (ret < 0) | ||
210 | goto done; | ||
211 | |||
212 | probe->wCompQuality = probe_max.wCompQuality; | ||
213 | } | ||
214 | |||
215 | for (i = 0; i < 2; ++i) { | ||
216 | if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0 || | ||
217 | (ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) | ||
218 | goto done; | ||
219 | |||
220 | if (video->streaming->intf->num_altsetting == 1) | ||
221 | break; | ||
222 | |||
223 | bandwidth = probe->dwMaxPayloadTransferSize; | ||
224 | if (bandwidth <= video->streaming->maxpsize) | ||
225 | break; | ||
226 | |||
227 | if (video->dev->quirks & UVC_QUIRK_PROBE_MINMAX) { | ||
228 | ret = -ENOSPC; | ||
229 | goto done; | ||
230 | } | ||
231 | |||
232 | /* TODO: negotiate compression parameters */ | ||
233 | probe->wKeyFrameRate = probe_min.wKeyFrameRate; | ||
234 | probe->wPFrameRate = probe_min.wPFrameRate; | ||
235 | probe->wCompQuality = probe_max.wCompQuality; | ||
236 | probe->wCompWindowSize = probe_min.wCompWindowSize; | ||
237 | } | ||
238 | |||
239 | done: | ||
240 | mutex_unlock(&video->streaming->mutex); | ||
241 | return ret; | ||
242 | } | ||
243 | |||
244 | /* ------------------------------------------------------------------------ | ||
245 | * Video codecs | ||
246 | */ | ||
247 | |||
248 | /* Values for bmHeaderInfo (Video and Still Image Payload Headers, 2.4.3.3) */ | ||
249 | #define UVC_STREAM_EOH (1 << 7) | ||
250 | #define UVC_STREAM_ERR (1 << 6) | ||
251 | #define UVC_STREAM_STI (1 << 5) | ||
252 | #define UVC_STREAM_RES (1 << 4) | ||
253 | #define UVC_STREAM_SCR (1 << 3) | ||
254 | #define UVC_STREAM_PTS (1 << 2) | ||
255 | #define UVC_STREAM_EOF (1 << 1) | ||
256 | #define UVC_STREAM_FID (1 << 0) | ||
257 | |||
258 | /* Video payload decoding is handled by uvc_video_decode_start(), | ||
259 | * uvc_video_decode_data() and uvc_video_decode_end(). | ||
260 | * | ||
261 | * uvc_video_decode_start is called with URB data at the start of a bulk or | ||
262 | * isochronous payload. It processes header data and returns the header size | ||
263 | * in bytes if successful. If an error occurs, it returns a negative error | ||
264 | * code. The following error codes have special meanings. | ||
265 | * | ||
266 | * - EAGAIN informs the caller that the current video buffer should be marked | ||
267 | * as done, and that the function should be called again with the same data | ||
268 | * and a new video buffer. This is used when end of frame conditions can be | ||
269 | * reliably detected at the beginning of the next frame only. | ||
270 | * | ||
271 | * If an error other than -EAGAIN is returned, the caller will drop the current | ||
272 | * payload. No call to uvc_video_decode_data and uvc_video_decode_end will be | ||
273 | * made until the next payload. -ENODATA can be used to drop the current | ||
274 | * payload if no other error code is appropriate. | ||
275 | * | ||
276 | * uvc_video_decode_data is called for every URB with URB data. It copies the | ||
277 | * data to the video buffer. | ||
278 | * | ||
279 | * uvc_video_decode_end is called with header data at the end of a bulk or | ||
280 | * isochronous payload. It performs any additional header data processing and | ||
281 | * returns 0 or a negative error code if an error occured. As header data have | ||
282 | * already been processed by uvc_video_decode_start, this functions isn't | ||
283 | * required to perform sanity checks a second time. | ||
284 | * | ||
285 | * For isochronous transfers where a payload is always transfered in a single | ||
286 | * URB, the three functions will be called in a row. | ||
287 | * | ||
288 | * To let the decoder process header data and update its internal state even | ||
289 | * when no video buffer is available, uvc_video_decode_start must be prepared | ||
290 | * to be called with a NULL buf parameter. uvc_video_decode_data and | ||
291 | * uvc_video_decode_end will never be called with a NULL buffer. | ||
292 | */ | ||
293 | static int uvc_video_decode_start(struct uvc_video_device *video, | ||
294 | struct uvc_buffer *buf, const __u8 *data, int len) | ||
295 | { | ||
296 | __u8 fid; | ||
297 | |||
298 | /* Sanity checks: | ||
299 | * - packet must be at least 2 bytes long | ||
300 | * - bHeaderLength value must be at least 2 bytes (see above) | ||
301 | * - bHeaderLength value can't be larger than the packet size. | ||
302 | */ | ||
303 | if (len < 2 || data[0] < 2 || data[0] > len) | ||
304 | return -EINVAL; | ||
305 | |||
306 | /* Skip payloads marked with the error bit ("error frames"). */ | ||
307 | if (data[1] & UVC_STREAM_ERR) { | ||
308 | uvc_trace(UVC_TRACE_FRAME, "Dropping payload (error bit " | ||
309 | "set).\n"); | ||
310 | return -ENODATA; | ||
311 | } | ||
312 | |||
313 | fid = data[1] & UVC_STREAM_FID; | ||
314 | |||
315 | /* Store the payload FID bit and return immediately when the buffer is | ||
316 | * NULL. | ||
317 | */ | ||
318 | if (buf == NULL) { | ||
319 | video->last_fid = fid; | ||
320 | return -ENODATA; | ||
321 | } | ||
322 | |||
323 | /* Synchronize to the input stream by waiting for the FID bit to be | ||
324 | * toggled when the the buffer state is not UVC_BUF_STATE_ACTIVE. | ||
325 | * queue->last_fid is initialized to -1, so the first isochronous | ||
326 | * frame will always be in sync. | ||
327 | * | ||
328 | * If the device doesn't toggle the FID bit, invert video->last_fid | ||
329 | * when the EOF bit is set to force synchronisation on the next packet. | ||
330 | */ | ||
331 | if (buf->state != UVC_BUF_STATE_ACTIVE) { | ||
332 | if (fid == video->last_fid) { | ||
333 | uvc_trace(UVC_TRACE_FRAME, "Dropping payload (out of " | ||
334 | "sync).\n"); | ||
335 | if ((video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) && | ||
336 | (data[1] & UVC_STREAM_EOF)) | ||
337 | video->last_fid ^= UVC_STREAM_FID; | ||
338 | return -ENODATA; | ||
339 | } | ||
340 | |||
341 | /* TODO: Handle PTS and SCR. */ | ||
342 | buf->state = UVC_BUF_STATE_ACTIVE; | ||
343 | } | ||
344 | |||
345 | /* Mark the buffer as done if we're at the beginning of a new frame. | ||
346 | * End of frame detection is better implemented by checking the EOF | ||
347 | * bit (FID bit toggling is delayed by one frame compared to the EOF | ||
348 | * bit), but some devices don't set the bit at end of frame (and the | ||
349 | * last payload can be lost anyway). We thus must check if the FID has | ||
350 | * been toggled. | ||
351 | * | ||
352 | * queue->last_fid is initialized to -1, so the first isochronous | ||
353 | * frame will never trigger an end of frame detection. | ||
354 | * | ||
355 | * Empty buffers (bytesused == 0) don't trigger end of frame detection | ||
356 | * as it doesn't make sense to return an empty buffer. This also | ||
357 | * avoids detecting and of frame conditions at FID toggling if the | ||
358 | * previous payload had the EOF bit set. | ||
359 | */ | ||
360 | if (fid != video->last_fid && buf->buf.bytesused != 0) { | ||
361 | uvc_trace(UVC_TRACE_FRAME, "Frame complete (FID bit " | ||
362 | "toggled).\n"); | ||
363 | buf->state = UVC_BUF_STATE_DONE; | ||
364 | return -EAGAIN; | ||
365 | } | ||
366 | |||
367 | video->last_fid = fid; | ||
368 | |||
369 | return data[0]; | ||
370 | } | ||
371 | |||
372 | static void uvc_video_decode_data(struct uvc_video_device *video, | ||
373 | struct uvc_buffer *buf, const __u8 *data, int len) | ||
374 | { | ||
375 | struct uvc_video_queue *queue = &video->queue; | ||
376 | unsigned int maxlen, nbytes; | ||
377 | void *mem; | ||
378 | |||
379 | if (len <= 0) | ||
380 | return; | ||
381 | |||
382 | /* Copy the video data to the buffer. */ | ||
383 | maxlen = buf->buf.length - buf->buf.bytesused; | ||
384 | mem = queue->mem + buf->buf.m.offset + buf->buf.bytesused; | ||
385 | nbytes = min((unsigned int)len, maxlen); | ||
386 | memcpy(mem, data, nbytes); | ||
387 | buf->buf.bytesused += nbytes; | ||
388 | |||
389 | /* Complete the current frame if the buffer size was exceeded. */ | ||
390 | if (len > maxlen) { | ||
391 | uvc_trace(UVC_TRACE_FRAME, "Frame complete (overflow).\n"); | ||
392 | buf->state = UVC_BUF_STATE_DONE; | ||
393 | } | ||
394 | } | ||
395 | |||
396 | static void uvc_video_decode_end(struct uvc_video_device *video, | ||
397 | struct uvc_buffer *buf, const __u8 *data, int len) | ||
398 | { | ||
399 | /* Mark the buffer as done if the EOF marker is set. */ | ||
400 | if (data[1] & UVC_STREAM_EOF && buf->buf.bytesused != 0) { | ||
401 | uvc_trace(UVC_TRACE_FRAME, "Frame complete (EOF found).\n"); | ||
402 | if (data[0] == len) | ||
403 | uvc_trace(UVC_TRACE_FRAME, "EOF in empty payload.\n"); | ||
404 | buf->state = UVC_BUF_STATE_DONE; | ||
405 | if (video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) | ||
406 | video->last_fid ^= UVC_STREAM_FID; | ||
407 | } | ||
408 | } | ||
409 | |||
410 | /* ------------------------------------------------------------------------ | ||
411 | * URB handling | ||
412 | */ | ||
413 | |||
414 | /* | ||
415 | * Completion handler for video URBs. | ||
416 | */ | ||
417 | static void uvc_video_decode_isoc(struct urb *urb, | ||
418 | struct uvc_video_device *video, struct uvc_buffer *buf) | ||
419 | { | ||
420 | u8 *mem; | ||
421 | int ret, i; | ||
422 | |||
423 | for (i = 0; i < urb->number_of_packets; ++i) { | ||
424 | if (urb->iso_frame_desc[i].status < 0) { | ||
425 | uvc_trace(UVC_TRACE_FRAME, "USB isochronous frame " | ||
426 | "lost (%d).\n", urb->iso_frame_desc[i].status); | ||
427 | continue; | ||
428 | } | ||
429 | |||
430 | /* Decode the payload header. */ | ||
431 | mem = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | ||
432 | do { | ||
433 | ret = uvc_video_decode_start(video, buf, mem, | ||
434 | urb->iso_frame_desc[i].actual_length); | ||
435 | if (ret == -EAGAIN) | ||
436 | buf = uvc_queue_next_buffer(&video->queue, buf); | ||
437 | } while (ret == -EAGAIN); | ||
438 | |||
439 | if (ret < 0) | ||
440 | continue; | ||
441 | |||
442 | /* Decode the payload data. */ | ||
443 | uvc_video_decode_data(video, buf, mem + ret, | ||
444 | urb->iso_frame_desc[i].actual_length - ret); | ||
445 | |||
446 | /* Process the header again. */ | ||
447 | uvc_video_decode_end(video, buf, mem, ret); | ||
448 | |||
449 | if (buf->state == UVC_BUF_STATE_DONE || | ||
450 | buf->state == UVC_BUF_STATE_ERROR) | ||
451 | buf = uvc_queue_next_buffer(&video->queue, buf); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | static void uvc_video_decode_bulk(struct urb *urb, | ||
456 | struct uvc_video_device *video, struct uvc_buffer *buf) | ||
457 | { | ||
458 | u8 *mem; | ||
459 | int len, ret; | ||
460 | |||
461 | mem = urb->transfer_buffer; | ||
462 | len = urb->actual_length; | ||
463 | video->bulk.payload_size += len; | ||
464 | |||
465 | /* If the URB is the first of its payload, decode and save the | ||
466 | * header. | ||
467 | */ | ||
468 | if (video->bulk.header_size == 0) { | ||
469 | do { | ||
470 | ret = uvc_video_decode_start(video, buf, mem, len); | ||
471 | if (ret == -EAGAIN) | ||
472 | buf = uvc_queue_next_buffer(&video->queue, buf); | ||
473 | } while (ret == -EAGAIN); | ||
474 | |||
475 | /* If an error occured skip the rest of the payload. */ | ||
476 | if (ret < 0 || buf == NULL) { | ||
477 | video->bulk.skip_payload = 1; | ||
478 | return; | ||
479 | } | ||
480 | |||
481 | video->bulk.header_size = ret; | ||
482 | memcpy(video->bulk.header, mem, video->bulk.header_size); | ||
483 | |||
484 | mem += ret; | ||
485 | len -= ret; | ||
486 | } | ||
487 | |||
488 | /* The buffer queue might have been cancelled while a bulk transfer | ||
489 | * was in progress, so we can reach here with buf equal to NULL. Make | ||
490 | * sure buf is never dereferenced if NULL. | ||
491 | */ | ||
492 | |||
493 | /* Process video data. */ | ||
494 | if (!video->bulk.skip_payload && buf != NULL) | ||
495 | uvc_video_decode_data(video, buf, mem, len); | ||
496 | |||
497 | /* Detect the payload end by a URB smaller than the maximum size (or | ||
498 | * a payload size equal to the maximum) and process the header again. | ||
499 | */ | ||
500 | if (urb->actual_length < urb->transfer_buffer_length || | ||
501 | video->bulk.payload_size >= video->bulk.max_payload_size) { | ||
502 | if (!video->bulk.skip_payload && buf != NULL) { | ||
503 | uvc_video_decode_end(video, buf, video->bulk.header, | ||
504 | video->bulk.header_size); | ||
505 | if (buf->state == UVC_BUF_STATE_DONE || | ||
506 | buf->state == UVC_BUF_STATE_ERROR) | ||
507 | buf = uvc_queue_next_buffer(&video->queue, buf); | ||
508 | } | ||
509 | |||
510 | video->bulk.header_size = 0; | ||
511 | video->bulk.skip_payload = 0; | ||
512 | video->bulk.payload_size = 0; | ||
513 | } | ||
514 | } | ||
515 | |||
516 | static void uvc_video_complete(struct urb *urb) | ||
517 | { | ||
518 | struct uvc_video_device *video = urb->context; | ||
519 | struct uvc_video_queue *queue = &video->queue; | ||
520 | struct uvc_buffer *buf = NULL; | ||
521 | unsigned long flags; | ||
522 | int ret; | ||
523 | |||
524 | switch (urb->status) { | ||
525 | case 0: | ||
526 | break; | ||
527 | |||
528 | default: | ||
529 | uvc_printk(KERN_WARNING, "Non-zero status (%d) in video " | ||
530 | "completion handler.\n", urb->status); | ||
531 | |||
532 | case -ENOENT: /* usb_kill_urb() called. */ | ||
533 | if (video->frozen) | ||
534 | return; | ||
535 | |||
536 | case -ECONNRESET: /* usb_unlink_urb() called. */ | ||
537 | case -ESHUTDOWN: /* The endpoint is being disabled. */ | ||
538 | uvc_queue_cancel(queue, urb->status == -ESHUTDOWN); | ||
539 | return; | ||
540 | } | ||
541 | |||
542 | spin_lock_irqsave(&queue->irqlock, flags); | ||
543 | if (!list_empty(&queue->irqqueue)) | ||
544 | buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, | ||
545 | queue); | ||
546 | spin_unlock_irqrestore(&queue->irqlock, flags); | ||
547 | |||
548 | video->decode(urb, video, buf); | ||
549 | |||
550 | if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { | ||
551 | uvc_printk(KERN_ERR, "Failed to resubmit video URB (%d).\n", | ||
552 | ret); | ||
553 | } | ||
554 | } | ||
555 | |||
556 | /* | ||
557 | * Uninitialize isochronous/bulk URBs and free transfer buffers. | ||
558 | */ | ||
559 | static void uvc_uninit_video(struct uvc_video_device *video) | ||
560 | { | ||
561 | struct urb *urb; | ||
562 | unsigned int i; | ||
563 | |||
564 | for (i = 0; i < UVC_URBS; ++i) { | ||
565 | if ((urb = video->urb[i]) == NULL) | ||
566 | continue; | ||
567 | |||
568 | usb_kill_urb(urb); | ||
569 | /* urb->transfer_buffer_length is not touched by USB core, so | ||
570 | * we can use it here as the buffer length. | ||
571 | */ | ||
572 | if (video->urb_buffer[i]) { | ||
573 | usb_buffer_free(video->dev->udev, | ||
574 | urb->transfer_buffer_length, | ||
575 | video->urb_buffer[i], urb->transfer_dma); | ||
576 | video->urb_buffer[i] = NULL; | ||
577 | } | ||
578 | |||
579 | usb_free_urb(urb); | ||
580 | video->urb[i] = NULL; | ||
581 | } | ||
582 | } | ||
583 | |||
584 | /* | ||
585 | * Initialize isochronous URBs and allocate transfer buffers. The packet size | ||
586 | * is given by the endpoint. | ||
587 | */ | ||
588 | static int uvc_init_video_isoc(struct uvc_video_device *video, | ||
589 | struct usb_host_endpoint *ep) | ||
590 | { | ||
591 | struct urb *urb; | ||
592 | unsigned int npackets, i, j; | ||
593 | __u16 psize; | ||
594 | __u32 size; | ||
595 | |||
596 | /* Compute the number of isochronous packets to allocate by dividing | ||
597 | * the maximum video frame size by the packet size. Limit the result | ||
598 | * to UVC_MAX_ISO_PACKETS. | ||
599 | */ | ||
600 | psize = le16_to_cpu(ep->desc.wMaxPacketSize); | ||
601 | psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); | ||
602 | |||
603 | size = video->streaming->ctrl.dwMaxVideoFrameSize; | ||
604 | if (size > UVC_MAX_FRAME_SIZE) | ||
605 | return -EINVAL; | ||
606 | |||
607 | npackets = (size + psize - 1) / psize; | ||
608 | if (npackets > UVC_MAX_ISO_PACKETS) | ||
609 | npackets = UVC_MAX_ISO_PACKETS; | ||
610 | |||
611 | size = npackets * psize; | ||
612 | |||
613 | for (i = 0; i < UVC_URBS; ++i) { | ||
614 | urb = usb_alloc_urb(npackets, GFP_KERNEL); | ||
615 | if (urb == NULL) { | ||
616 | uvc_uninit_video(video); | ||
617 | return -ENOMEM; | ||
618 | } | ||
619 | |||
620 | video->urb_buffer[i] = usb_buffer_alloc(video->dev->udev, | ||
621 | size, GFP_KERNEL, &urb->transfer_dma); | ||
622 | if (video->urb_buffer[i] == NULL) { | ||
623 | usb_free_urb(urb); | ||
624 | uvc_uninit_video(video); | ||
625 | return -ENOMEM; | ||
626 | } | ||
627 | |||
628 | urb->dev = video->dev->udev; | ||
629 | urb->context = video; | ||
630 | urb->pipe = usb_rcvisocpipe(video->dev->udev, | ||
631 | ep->desc.bEndpointAddress); | ||
632 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | ||
633 | urb->interval = ep->desc.bInterval; | ||
634 | urb->transfer_buffer = video->urb_buffer[i]; | ||
635 | urb->complete = uvc_video_complete; | ||
636 | urb->number_of_packets = npackets; | ||
637 | urb->transfer_buffer_length = size; | ||
638 | |||
639 | for (j = 0; j < npackets; ++j) { | ||
640 | urb->iso_frame_desc[j].offset = j * psize; | ||
641 | urb->iso_frame_desc[j].length = psize; | ||
642 | } | ||
643 | |||
644 | video->urb[i] = urb; | ||
645 | } | ||
646 | |||
647 | return 0; | ||
648 | } | ||
649 | |||
650 | /* | ||
651 | * Initialize bulk URBs and allocate transfer buffers. The packet size is | ||
652 | * given by the endpoint. | ||
653 | */ | ||
654 | static int uvc_init_video_bulk(struct uvc_video_device *video, | ||
655 | struct usb_host_endpoint *ep) | ||
656 | { | ||
657 | struct urb *urb; | ||
658 | unsigned int pipe, i; | ||
659 | __u16 psize; | ||
660 | __u32 size; | ||
661 | |||
662 | /* Compute the bulk URB size. Some devices set the maximum payload | ||
663 | * size to a value too high for memory-constrained devices. We must | ||
664 | * then transfer the payload accross multiple URBs. To be consistant | ||
665 | * with isochronous mode, allocate maximum UVC_MAX_ISO_PACKETS per bulk | ||
666 | * URB. | ||
667 | */ | ||
668 | psize = le16_to_cpu(ep->desc.wMaxPacketSize) & 0x07ff; | ||
669 | size = video->streaming->ctrl.dwMaxPayloadTransferSize; | ||
670 | video->bulk.max_payload_size = size; | ||
671 | if (size > psize * UVC_MAX_ISO_PACKETS) | ||
672 | size = psize * UVC_MAX_ISO_PACKETS; | ||
673 | |||
674 | pipe = usb_rcvbulkpipe(video->dev->udev, ep->desc.bEndpointAddress); | ||
675 | |||
676 | for (i = 0; i < UVC_URBS; ++i) { | ||
677 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
678 | if (urb == NULL) { | ||
679 | uvc_uninit_video(video); | ||
680 | return -ENOMEM; | ||
681 | } | ||
682 | |||
683 | video->urb_buffer[i] = usb_buffer_alloc(video->dev->udev, | ||
684 | size, GFP_KERNEL, &urb->transfer_dma); | ||
685 | if (video->urb_buffer[i] == NULL) { | ||
686 | usb_free_urb(urb); | ||
687 | uvc_uninit_video(video); | ||
688 | return -ENOMEM; | ||
689 | } | ||
690 | |||
691 | usb_fill_bulk_urb(urb, video->dev->udev, pipe, | ||
692 | video->urb_buffer[i], size, uvc_video_complete, | ||
693 | video); | ||
694 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
695 | |||
696 | video->urb[i] = urb; | ||
697 | } | ||
698 | |||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | /* | ||
703 | * Initialize isochronous/bulk URBs and allocate transfer buffers. | ||
704 | */ | ||
705 | static int uvc_init_video(struct uvc_video_device *video) | ||
706 | { | ||
707 | struct usb_interface *intf = video->streaming->intf; | ||
708 | struct usb_host_interface *alts; | ||
709 | struct usb_host_endpoint *ep = NULL; | ||
710 | int intfnum = video->streaming->intfnum; | ||
711 | unsigned int bandwidth, psize, i; | ||
712 | int ret; | ||
713 | |||
714 | video->last_fid = -1; | ||
715 | video->bulk.header_size = 0; | ||
716 | video->bulk.skip_payload = 0; | ||
717 | video->bulk.payload_size = 0; | ||
718 | |||
719 | if (intf->num_altsetting > 1) { | ||
720 | /* Isochronous endpoint, select the alternate setting. */ | ||
721 | bandwidth = video->streaming->ctrl.dwMaxPayloadTransferSize; | ||
722 | |||
723 | if (bandwidth == 0) { | ||
724 | uvc_printk(KERN_WARNING, "device %s requested null " | ||
725 | "bandwidth, defaulting to lowest.\n", | ||
726 | video->vdev->name); | ||
727 | bandwidth = 1; | ||
728 | } | ||
729 | |||
730 | for (i = 0; i < intf->num_altsetting; ++i) { | ||
731 | alts = &intf->altsetting[i]; | ||
732 | ep = uvc_find_endpoint(alts, | ||
733 | video->streaming->header.bEndpointAddress); | ||
734 | if (ep == NULL) | ||
735 | continue; | ||
736 | |||
737 | /* Check if the bandwidth is high enough. */ | ||
738 | psize = le16_to_cpu(ep->desc.wMaxPacketSize); | ||
739 | psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); | ||
740 | if (psize >= bandwidth) | ||
741 | break; | ||
742 | } | ||
743 | |||
744 | if (i >= intf->num_altsetting) | ||
745 | return -EIO; | ||
746 | |||
747 | if ((ret = usb_set_interface(video->dev->udev, intfnum, i)) < 0) | ||
748 | return ret; | ||
749 | |||
750 | ret = uvc_init_video_isoc(video, ep); | ||
751 | } else { | ||
752 | /* Bulk endpoint, proceed to URB initialization. */ | ||
753 | ep = uvc_find_endpoint(&intf->altsetting[0], | ||
754 | video->streaming->header.bEndpointAddress); | ||
755 | if (ep == NULL) | ||
756 | return -EIO; | ||
757 | |||
758 | ret = uvc_init_video_bulk(video, ep); | ||
759 | } | ||
760 | |||
761 | if (ret < 0) | ||
762 | return ret; | ||
763 | |||
764 | /* Submit the URBs. */ | ||
765 | for (i = 0; i < UVC_URBS; ++i) { | ||
766 | if ((ret = usb_submit_urb(video->urb[i], GFP_KERNEL)) < 0) { | ||
767 | uvc_printk(KERN_ERR, "Failed to submit URB %u " | ||
768 | "(%d).\n", i, ret); | ||
769 | uvc_uninit_video(video); | ||
770 | return ret; | ||
771 | } | ||
772 | } | ||
773 | |||
774 | return 0; | ||
775 | } | ||
776 | |||
777 | /* -------------------------------------------------------------------------- | ||
778 | * Suspend/resume | ||
779 | */ | ||
780 | |||
781 | /* | ||
782 | * Stop streaming without disabling the video queue. | ||
783 | * | ||
784 | * To let userspace applications resume without trouble, we must not touch the | ||
785 | * video buffers in any way. We mark the device as frozen to make sure the URB | ||
786 | * completion handler won't try to cancel the queue when we kill the URBs. | ||
787 | */ | ||
788 | int uvc_video_suspend(struct uvc_video_device *video) | ||
789 | { | ||
790 | if (!uvc_queue_streaming(&video->queue)) | ||
791 | return 0; | ||
792 | |||
793 | video->frozen = 1; | ||
794 | uvc_uninit_video(video); | ||
795 | usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); | ||
796 | return 0; | ||
797 | } | ||
798 | |||
799 | /* | ||
800 | * Reconfigure the video interface and restart streaming if it was enable | ||
801 | * before suspend. | ||
802 | * | ||
803 | * If an error occurs, disable the video queue. This will wake all pending | ||
804 | * buffers, making sure userspace applications are notified of the problem | ||
805 | * instead of waiting forever. | ||
806 | */ | ||
807 | int uvc_video_resume(struct uvc_video_device *video) | ||
808 | { | ||
809 | int ret; | ||
810 | |||
811 | video->frozen = 0; | ||
812 | |||
813 | if ((ret = uvc_set_video_ctrl(video, &video->streaming->ctrl, 0)) < 0) { | ||
814 | uvc_queue_enable(&video->queue, 0); | ||
815 | return ret; | ||
816 | } | ||
817 | |||
818 | if (!uvc_queue_streaming(&video->queue)) | ||
819 | return 0; | ||
820 | |||
821 | if ((ret = uvc_init_video(video)) < 0) | ||
822 | uvc_queue_enable(&video->queue, 0); | ||
823 | |||
824 | return ret; | ||
825 | } | ||
826 | |||
827 | /* ------------------------------------------------------------------------ | ||
828 | * Video device | ||
829 | */ | ||
830 | |||
831 | /* | ||
832 | * Initialize the UVC video device by retrieving the default format and | ||
833 | * committing it. | ||
834 | * | ||
835 | * Some cameras (namely the Fuji Finepix) set the format and frame | ||
836 | * indexes to zero. The UVC standard doesn't clearly make this a spec | ||
837 | * violation, so try to silently fix the values if possible. | ||
838 | * | ||
839 | * This function is called before registering the device with V4L. | ||
840 | */ | ||
841 | int uvc_video_init(struct uvc_video_device *video) | ||
842 | { | ||
843 | struct uvc_streaming_control *probe = &video->streaming->ctrl; | ||
844 | struct uvc_format *format = NULL; | ||
845 | struct uvc_frame *frame = NULL; | ||
846 | unsigned int i; | ||
847 | int ret; | ||
848 | |||
849 | if (video->streaming->nformats == 0) { | ||
850 | uvc_printk(KERN_INFO, "No supported video formats found.\n"); | ||
851 | return -EINVAL; | ||
852 | } | ||
853 | |||
854 | /* Alternate setting 0 should be the default, yet the XBox Live Vision | ||
855 | * Cam (and possibly other devices) crash or otherwise misbehave if | ||
856 | * they don't receive a SET_INTERFACE request before any other video | ||
857 | * control request. | ||
858 | */ | ||
859 | usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); | ||
860 | |||
861 | /* Some webcams don't suport GET_DEF request on the probe control. We | ||
862 | * fall back to GET_CUR if GET_DEF fails. | ||
863 | */ | ||
864 | if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && | ||
865 | (ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) | ||
866 | return ret; | ||
867 | |||
868 | /* Check if the default format descriptor exists. Use the first | ||
869 | * available format otherwise. | ||
870 | */ | ||
871 | for (i = video->streaming->nformats; i > 0; --i) { | ||
872 | format = &video->streaming->format[i-1]; | ||
873 | if (format->index == probe->bFormatIndex) | ||
874 | break; | ||
875 | } | ||
876 | |||
877 | if (format->nframes == 0) { | ||
878 | uvc_printk(KERN_INFO, "No frame descriptor found for the " | ||
879 | "default format.\n"); | ||
880 | return -EINVAL; | ||
881 | } | ||
882 | |||
883 | /* Zero bFrameIndex might be correct. Stream-based formats (including | ||
884 | * MPEG-2 TS and DV) do not support frames but have a dummy frame | ||
885 | * descriptor with bFrameIndex set to zero. If the default frame | ||
886 | * descriptor is not found, use the first avalable frame. | ||
887 | */ | ||
888 | for (i = format->nframes; i > 0; --i) { | ||
889 | frame = &format->frame[i-1]; | ||
890 | if (frame->bFrameIndex == probe->bFrameIndex) | ||
891 | break; | ||
892 | } | ||
893 | |||
894 | /* Commit the default settings. */ | ||
895 | probe->bFormatIndex = format->index; | ||
896 | probe->bFrameIndex = frame->bFrameIndex; | ||
897 | if ((ret = uvc_set_video_ctrl(video, probe, 0)) < 0) | ||
898 | return ret; | ||
899 | |||
900 | video->streaming->cur_format = format; | ||
901 | video->streaming->cur_frame = frame; | ||
902 | atomic_set(&video->active, 0); | ||
903 | |||
904 | /* Select the video decoding function */ | ||
905 | if (video->dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT) | ||
906 | video->decode = uvc_video_decode_isight; | ||
907 | else if (video->streaming->intf->num_altsetting > 1) | ||
908 | video->decode = uvc_video_decode_isoc; | ||
909 | else | ||
910 | video->decode = uvc_video_decode_bulk; | ||
911 | |||
912 | return 0; | ||
913 | } | ||
914 | |||
915 | /* | ||
916 | * Enable or disable the video stream. | ||
917 | */ | ||
918 | int uvc_video_enable(struct uvc_video_device *video, int enable) | ||
919 | { | ||
920 | int ret; | ||
921 | |||
922 | if (!enable) { | ||
923 | uvc_uninit_video(video); | ||
924 | usb_set_interface(video->dev->udev, | ||
925 | video->streaming->intfnum, 0); | ||
926 | uvc_queue_enable(&video->queue, 0); | ||
927 | return 0; | ||
928 | } | ||
929 | |||
930 | if ((ret = uvc_queue_enable(&video->queue, 1)) < 0) | ||
931 | return ret; | ||
932 | |||
933 | return uvc_init_video(video); | ||
934 | } | ||
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h new file mode 100644 index 000000000000..a995a780db1c --- /dev/null +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -0,0 +1,796 @@ | |||
1 | #ifndef _USB_VIDEO_H_ | ||
2 | #define _USB_VIDEO_H_ | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/videodev2.h> | ||
6 | |||
7 | |||
8 | /* | ||
9 | * Dynamic controls | ||
10 | */ | ||
11 | |||
12 | /* Data types for UVC control data */ | ||
13 | #define UVC_CTRL_DATA_TYPE_RAW 0 | ||
14 | #define UVC_CTRL_DATA_TYPE_SIGNED 1 | ||
15 | #define UVC_CTRL_DATA_TYPE_UNSIGNED 2 | ||
16 | #define UVC_CTRL_DATA_TYPE_BOOLEAN 3 | ||
17 | #define UVC_CTRL_DATA_TYPE_ENUM 4 | ||
18 | #define UVC_CTRL_DATA_TYPE_BITMASK 5 | ||
19 | |||
20 | /* Control flags */ | ||
21 | #define UVC_CONTROL_SET_CUR (1 << 0) | ||
22 | #define UVC_CONTROL_GET_CUR (1 << 1) | ||
23 | #define UVC_CONTROL_GET_MIN (1 << 2) | ||
24 | #define UVC_CONTROL_GET_MAX (1 << 3) | ||
25 | #define UVC_CONTROL_GET_RES (1 << 4) | ||
26 | #define UVC_CONTROL_GET_DEF (1 << 5) | ||
27 | /* Control should be saved at suspend and restored at resume. */ | ||
28 | #define UVC_CONTROL_RESTORE (1 << 6) | ||
29 | /* Control can be updated by the camera. */ | ||
30 | #define UVC_CONTROL_AUTO_UPDATE (1 << 7) | ||
31 | |||
32 | #define UVC_CONTROL_GET_RANGE (UVC_CONTROL_GET_CUR | UVC_CONTROL_GET_MIN | \ | ||
33 | UVC_CONTROL_GET_MAX | UVC_CONTROL_GET_RES | \ | ||
34 | UVC_CONTROL_GET_DEF) | ||
35 | |||
36 | struct uvc_xu_control_info { | ||
37 | __u8 entity[16]; | ||
38 | __u8 index; | ||
39 | __u8 selector; | ||
40 | __u16 size; | ||
41 | __u32 flags; | ||
42 | }; | ||
43 | |||
44 | struct uvc_xu_control_mapping { | ||
45 | __u32 id; | ||
46 | __u8 name[32]; | ||
47 | __u8 entity[16]; | ||
48 | __u8 selector; | ||
49 | |||
50 | __u8 size; | ||
51 | __u8 offset; | ||
52 | enum v4l2_ctrl_type v4l2_type; | ||
53 | __u32 data_type; | ||
54 | }; | ||
55 | |||
56 | struct uvc_xu_control { | ||
57 | __u8 unit; | ||
58 | __u8 selector; | ||
59 | __u16 size; | ||
60 | __u8 __user *data; | ||
61 | }; | ||
62 | |||
63 | #define UVCIOC_CTRL_ADD _IOW('U', 1, struct uvc_xu_control_info) | ||
64 | #define UVCIOC_CTRL_MAP _IOWR('U', 2, struct uvc_xu_control_mapping) | ||
65 | #define UVCIOC_CTRL_GET _IOWR('U', 3, struct uvc_xu_control) | ||
66 | #define UVCIOC_CTRL_SET _IOW('U', 4, struct uvc_xu_control) | ||
67 | |||
68 | #ifdef __KERNEL__ | ||
69 | |||
70 | #include <linux/poll.h> | ||
71 | |||
72 | /* -------------------------------------------------------------------------- | ||
73 | * UVC constants | ||
74 | */ | ||
75 | |||
76 | #define SC_UNDEFINED 0x00 | ||
77 | #define SC_VIDEOCONTROL 0x01 | ||
78 | #define SC_VIDEOSTREAMING 0x02 | ||
79 | #define SC_VIDEO_INTERFACE_COLLECTION 0x03 | ||
80 | |||
81 | #define PC_PROTOCOL_UNDEFINED 0x00 | ||
82 | |||
83 | #define CS_UNDEFINED 0x20 | ||
84 | #define CS_DEVICE 0x21 | ||
85 | #define CS_CONFIGURATION 0x22 | ||
86 | #define CS_STRING 0x23 | ||
87 | #define CS_INTERFACE 0x24 | ||
88 | #define CS_ENDPOINT 0x25 | ||
89 | |||
90 | /* VideoControl class specific interface descriptor */ | ||
91 | #define VC_DESCRIPTOR_UNDEFINED 0x00 | ||
92 | #define VC_HEADER 0x01 | ||
93 | #define VC_INPUT_TERMINAL 0x02 | ||
94 | #define VC_OUTPUT_TERMINAL 0x03 | ||
95 | #define VC_SELECTOR_UNIT 0x04 | ||
96 | #define VC_PROCESSING_UNIT 0x05 | ||
97 | #define VC_EXTENSION_UNIT 0x06 | ||
98 | |||
99 | /* VideoStreaming class specific interface descriptor */ | ||
100 | #define VS_UNDEFINED 0x00 | ||
101 | #define VS_INPUT_HEADER 0x01 | ||
102 | #define VS_OUTPUT_HEADER 0x02 | ||
103 | #define VS_STILL_IMAGE_FRAME 0x03 | ||
104 | #define VS_FORMAT_UNCOMPRESSED 0x04 | ||
105 | #define VS_FRAME_UNCOMPRESSED 0x05 | ||
106 | #define VS_FORMAT_MJPEG 0x06 | ||
107 | #define VS_FRAME_MJPEG 0x07 | ||
108 | #define VS_FORMAT_MPEG2TS 0x0a | ||
109 | #define VS_FORMAT_DV 0x0c | ||
110 | #define VS_COLORFORMAT 0x0d | ||
111 | #define VS_FORMAT_FRAME_BASED 0x10 | ||
112 | #define VS_FRAME_FRAME_BASED 0x11 | ||
113 | #define VS_FORMAT_STREAM_BASED 0x12 | ||
114 | |||
115 | /* Endpoint type */ | ||
116 | #define EP_UNDEFINED 0x00 | ||
117 | #define EP_GENERAL 0x01 | ||
118 | #define EP_ENDPOINT 0x02 | ||
119 | #define EP_INTERRUPT 0x03 | ||
120 | |||
121 | /* Request codes */ | ||
122 | #define RC_UNDEFINED 0x00 | ||
123 | #define SET_CUR 0x01 | ||
124 | #define GET_CUR 0x81 | ||
125 | #define GET_MIN 0x82 | ||
126 | #define GET_MAX 0x83 | ||
127 | #define GET_RES 0x84 | ||
128 | #define GET_LEN 0x85 | ||
129 | #define GET_INFO 0x86 | ||
130 | #define GET_DEF 0x87 | ||
131 | |||
132 | /* VideoControl interface controls */ | ||
133 | #define VC_CONTROL_UNDEFINED 0x00 | ||
134 | #define VC_VIDEO_POWER_MODE_CONTROL 0x01 | ||
135 | #define VC_REQUEST_ERROR_CODE_CONTROL 0x02 | ||
136 | |||
137 | /* Terminal controls */ | ||
138 | #define TE_CONTROL_UNDEFINED 0x00 | ||
139 | |||
140 | /* Selector Unit controls */ | ||
141 | #define SU_CONTROL_UNDEFINED 0x00 | ||
142 | #define SU_INPUT_SELECT_CONTROL 0x01 | ||
143 | |||
144 | /* Camera Terminal controls */ | ||
145 | #define CT_CONTROL_UNDEFINED 0x00 | ||
146 | #define CT_SCANNING_MODE_CONTROL 0x01 | ||
147 | #define CT_AE_MODE_CONTROL 0x02 | ||
148 | #define CT_AE_PRIORITY_CONTROL 0x03 | ||
149 | #define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 | ||
150 | #define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 | ||
151 | #define CT_FOCUS_ABSOLUTE_CONTROL 0x06 | ||
152 | #define CT_FOCUS_RELATIVE_CONTROL 0x07 | ||
153 | #define CT_FOCUS_AUTO_CONTROL 0x08 | ||
154 | #define CT_IRIS_ABSOLUTE_CONTROL 0x09 | ||
155 | #define CT_IRIS_RELATIVE_CONTROL 0x0a | ||
156 | #define CT_ZOOM_ABSOLUTE_CONTROL 0x0b | ||
157 | #define CT_ZOOM_RELATIVE_CONTROL 0x0c | ||
158 | #define CT_PANTILT_ABSOLUTE_CONTROL 0x0d | ||
159 | #define CT_PANTILT_RELATIVE_CONTROL 0x0e | ||
160 | #define CT_ROLL_ABSOLUTE_CONTROL 0x0f | ||
161 | #define CT_ROLL_RELATIVE_CONTROL 0x10 | ||
162 | #define CT_PRIVACY_CONTROL 0x11 | ||
163 | |||
164 | /* Processing Unit controls */ | ||
165 | #define PU_CONTROL_UNDEFINED 0x00 | ||
166 | #define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 | ||
167 | #define PU_BRIGHTNESS_CONTROL 0x02 | ||
168 | #define PU_CONTRAST_CONTROL 0x03 | ||
169 | #define PU_GAIN_CONTROL 0x04 | ||
170 | #define PU_POWER_LINE_FREQUENCY_CONTROL 0x05 | ||
171 | #define PU_HUE_CONTROL 0x06 | ||
172 | #define PU_SATURATION_CONTROL 0x07 | ||
173 | #define PU_SHARPNESS_CONTROL 0x08 | ||
174 | #define PU_GAMMA_CONTROL 0x09 | ||
175 | #define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a | ||
176 | #define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b | ||
177 | #define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c | ||
178 | #define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d | ||
179 | #define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e | ||
180 | #define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f | ||
181 | #define PU_HUE_AUTO_CONTROL 0x10 | ||
182 | #define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 | ||
183 | #define PU_ANALOG_LOCK_STATUS_CONTROL 0x12 | ||
184 | |||
185 | #define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01 | ||
186 | #define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02 | ||
187 | #define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03 | ||
188 | |||
189 | /* VideoStreaming interface controls */ | ||
190 | #define VS_CONTROL_UNDEFINED 0x00 | ||
191 | #define VS_PROBE_CONTROL 0x01 | ||
192 | #define VS_COMMIT_CONTROL 0x02 | ||
193 | #define VS_STILL_PROBE_CONTROL 0x03 | ||
194 | #define VS_STILL_COMMIT_CONTROL 0x04 | ||
195 | #define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 | ||
196 | #define VS_STREAM_ERROR_CODE_CONTROL 0x06 | ||
197 | #define VS_GENERATE_KEY_FRAME_CONTROL 0x07 | ||
198 | #define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 | ||
199 | #define VS_SYNC_DELAY_CONTROL 0x09 | ||
200 | |||
201 | #define TT_VENDOR_SPECIFIC 0x0100 | ||
202 | #define TT_STREAMING 0x0101 | ||
203 | |||
204 | /* Input Terminal types */ | ||
205 | #define ITT_VENDOR_SPECIFIC 0x0200 | ||
206 | #define ITT_CAMERA 0x0201 | ||
207 | #define ITT_MEDIA_TRANSPORT_INPUT 0x0202 | ||
208 | |||
209 | /* Output Terminal types */ | ||
210 | #define OTT_VENDOR_SPECIFIC 0x0300 | ||
211 | #define OTT_DISPLAY 0x0301 | ||
212 | #define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 | ||
213 | |||
214 | /* External Terminal types */ | ||
215 | #define EXTERNAL_VENDOR_SPECIFIC 0x0400 | ||
216 | #define COMPOSITE_CONNECTOR 0x0401 | ||
217 | #define SVIDEO_CONNECTOR 0x0402 | ||
218 | #define COMPONENT_CONNECTOR 0x0403 | ||
219 | |||
220 | #define UVC_TERM_INPUT 0x0000 | ||
221 | #define UVC_TERM_OUTPUT 0x8000 | ||
222 | |||
223 | #define UVC_ENTITY_TYPE(entity) ((entity)->type & 0x7fff) | ||
224 | #define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0) | ||
225 | #define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0) | ||
226 | #define UVC_ENTITY_IS_ITERM(entity) \ | ||
227 | (((entity)->type & 0x8000) == UVC_TERM_INPUT) | ||
228 | #define UVC_ENTITY_IS_OTERM(entity) \ | ||
229 | (((entity)->type & 0x8000) == UVC_TERM_OUTPUT) | ||
230 | |||
231 | #define UVC_STATUS_TYPE_CONTROL 1 | ||
232 | #define UVC_STATUS_TYPE_STREAMING 2 | ||
233 | |||
234 | /* ------------------------------------------------------------------------ | ||
235 | * GUIDs | ||
236 | */ | ||
237 | #define UVC_GUID_UVC_CAMERA \ | ||
238 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | ||
239 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} | ||
240 | #define UVC_GUID_UVC_OUTPUT \ | ||
241 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | ||
242 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02} | ||
243 | #define UVC_GUID_UVC_MEDIA_TRANSPORT_INPUT \ | ||
244 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | ||
245 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03} | ||
246 | #define UVC_GUID_UVC_PROCESSING \ | ||
247 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | ||
248 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01} | ||
249 | #define UVC_GUID_UVC_SELECTOR \ | ||
250 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ | ||
251 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02} | ||
252 | |||
253 | #define UVC_GUID_LOGITECH_DEV_INFO \ | ||
254 | {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \ | ||
255 | 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1e} | ||
256 | #define UVC_GUID_LOGITECH_USER_HW \ | ||
257 | {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \ | ||
258 | 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f} | ||
259 | #define UVC_GUID_LOGITECH_VIDEO \ | ||
260 | {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \ | ||
261 | 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x50} | ||
262 | #define UVC_GUID_LOGITECH_MOTOR \ | ||
263 | {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \ | ||
264 | 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x56} | ||
265 | |||
266 | #define UVC_GUID_FORMAT_MJPEG \ | ||
267 | { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ | ||
268 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
269 | #define UVC_GUID_FORMAT_YUY2 \ | ||
270 | { 'Y', 'U', 'Y', '2', 0x00, 0x00, 0x10, 0x00, \ | ||
271 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
272 | #define UVC_GUID_FORMAT_NV12 \ | ||
273 | { 'N', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ | ||
274 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
275 | #define UVC_GUID_FORMAT_YV12 \ | ||
276 | { 'Y', 'V', '1', '2', 0x00, 0x00, 0x10, 0x00, \ | ||
277 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
278 | #define UVC_GUID_FORMAT_I420 \ | ||
279 | { 'I', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ | ||
280 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
281 | #define UVC_GUID_FORMAT_UYVY \ | ||
282 | { 'U', 'Y', 'V', 'Y', 0x00, 0x00, 0x10, 0x00, \ | ||
283 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
284 | #define UVC_GUID_FORMAT_Y800 \ | ||
285 | { 'Y', '8', '0', '0', 0x00, 0x00, 0x10, 0x00, \ | ||
286 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
287 | #define UVC_GUID_FORMAT_BY8 \ | ||
288 | { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ | ||
289 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} | ||
290 | |||
291 | |||
292 | /* ------------------------------------------------------------------------ | ||
293 | * Driver specific constants. | ||
294 | */ | ||
295 | |||
296 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0) | ||
297 | |||
298 | /* Number of isochronous URBs. */ | ||
299 | #define UVC_URBS 5 | ||
300 | /* Maximum number of packets per isochronous URB. */ | ||
301 | #define UVC_MAX_ISO_PACKETS 40 | ||
302 | /* Maximum frame size in bytes, for sanity checking. */ | ||
303 | #define UVC_MAX_FRAME_SIZE (16*1024*1024) | ||
304 | /* Maximum number of video buffers. */ | ||
305 | #define UVC_MAX_VIDEO_BUFFERS 32 | ||
306 | |||
307 | #define UVC_CTRL_CONTROL_TIMEOUT 300 | ||
308 | #define UVC_CTRL_STREAMING_TIMEOUT 1000 | ||
309 | |||
310 | /* Devices quirks */ | ||
311 | #define UVC_QUIRK_STATUS_INTERVAL 0x00000001 | ||
312 | #define UVC_QUIRK_PROBE_MINMAX 0x00000002 | ||
313 | #define UVC_QUIRK_PROBE_EXTRAFIELDS 0x00000004 | ||
314 | #define UVC_QUIRK_BUILTIN_ISIGHT 0x00000008 | ||
315 | #define UVC_QUIRK_STREAM_NO_FID 0x00000010 | ||
316 | #define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 | ||
317 | |||
318 | /* Format flags */ | ||
319 | #define UVC_FMT_FLAG_COMPRESSED 0x00000001 | ||
320 | #define UVC_FMT_FLAG_STREAM 0x00000002 | ||
321 | |||
322 | /* ------------------------------------------------------------------------ | ||
323 | * Structures. | ||
324 | */ | ||
325 | |||
326 | struct uvc_device; | ||
327 | |||
328 | /* TODO: Put the most frequently accessed fields at the beginning of | ||
329 | * structures to maximize cache efficiency. | ||
330 | */ | ||
331 | struct uvc_streaming_control { | ||
332 | __u16 bmHint; | ||
333 | __u8 bFormatIndex; | ||
334 | __u8 bFrameIndex; | ||
335 | __u32 dwFrameInterval; | ||
336 | __u16 wKeyFrameRate; | ||
337 | __u16 wPFrameRate; | ||
338 | __u16 wCompQuality; | ||
339 | __u16 wCompWindowSize; | ||
340 | __u16 wDelay; | ||
341 | __u32 dwMaxVideoFrameSize; | ||
342 | __u32 dwMaxPayloadTransferSize; | ||
343 | __u32 dwClockFrequency; | ||
344 | __u8 bmFramingInfo; | ||
345 | __u8 bPreferedVersion; | ||
346 | __u8 bMinVersion; | ||
347 | __u8 bMaxVersion; | ||
348 | }; | ||
349 | |||
350 | struct uvc_menu_info { | ||
351 | __u32 value; | ||
352 | __u8 name[32]; | ||
353 | }; | ||
354 | |||
355 | struct uvc_control_info { | ||
356 | struct list_head list; | ||
357 | struct list_head mappings; | ||
358 | |||
359 | __u8 entity[16]; | ||
360 | __u8 index; | ||
361 | __u8 selector; | ||
362 | |||
363 | __u16 size; | ||
364 | __u32 flags; | ||
365 | }; | ||
366 | |||
367 | struct uvc_control_mapping { | ||
368 | struct list_head list; | ||
369 | |||
370 | struct uvc_control_info *ctrl; | ||
371 | |||
372 | __u32 id; | ||
373 | __u8 name[32]; | ||
374 | __u8 entity[16]; | ||
375 | __u8 selector; | ||
376 | |||
377 | __u8 size; | ||
378 | __u8 offset; | ||
379 | enum v4l2_ctrl_type v4l2_type; | ||
380 | __u32 data_type; | ||
381 | |||
382 | struct uvc_menu_info *menu_info; | ||
383 | __u32 menu_count; | ||
384 | }; | ||
385 | |||
386 | struct uvc_control { | ||
387 | struct uvc_entity *entity; | ||
388 | struct uvc_control_info *info; | ||
389 | |||
390 | __u8 index; /* Used to match the uvc_control entry with a | ||
391 | uvc_control_info. */ | ||
392 | __u8 dirty : 1, | ||
393 | loaded : 1, | ||
394 | modified : 1; | ||
395 | |||
396 | __u8 *data; | ||
397 | }; | ||
398 | |||
399 | struct uvc_format_desc { | ||
400 | char *name; | ||
401 | __u8 guid[16]; | ||
402 | __u32 fcc; | ||
403 | }; | ||
404 | |||
405 | /* The term 'entity' refers to both UVC units and UVC terminals. | ||
406 | * | ||
407 | * The type field is either the terminal type (wTerminalType in the terminal | ||
408 | * descriptor), or the unit type (bDescriptorSubtype in the unit descriptor). | ||
409 | * As the bDescriptorSubtype field is one byte long, the type value will | ||
410 | * always have a null MSB for units. All terminal types defined by the UVC | ||
411 | * specification have a non-null MSB, so it is safe to use the MSB to | ||
412 | * differentiate between units and terminals as long as the descriptor parsing | ||
413 | * code makes sure terminal types have a non-null MSB. | ||
414 | * | ||
415 | * For terminals, the type's most significant bit stores the terminal | ||
416 | * direction (either UVC_TERM_INPUT or UVC_TERM_OUTPUT). The type field should | ||
417 | * always be accessed with the UVC_ENTITY_* macros and never directly. | ||
418 | */ | ||
419 | |||
420 | struct uvc_entity { | ||
421 | struct list_head list; /* Entity as part of a UVC device. */ | ||
422 | struct list_head chain; /* Entity as part of a video device | ||
423 | * chain. */ | ||
424 | __u8 id; | ||
425 | __u16 type; | ||
426 | char name[64]; | ||
427 | |||
428 | union { | ||
429 | struct { | ||
430 | __u16 wObjectiveFocalLengthMin; | ||
431 | __u16 wObjectiveFocalLengthMax; | ||
432 | __u16 wOcularFocalLength; | ||
433 | __u8 bControlSize; | ||
434 | __u8 *bmControls; | ||
435 | } camera; | ||
436 | |||
437 | struct { | ||
438 | __u8 bControlSize; | ||
439 | __u8 *bmControls; | ||
440 | __u8 bTransportModeSize; | ||
441 | __u8 *bmTransportModes; | ||
442 | } media; | ||
443 | |||
444 | struct { | ||
445 | __u8 bSourceID; | ||
446 | } output; | ||
447 | |||
448 | struct { | ||
449 | __u8 bSourceID; | ||
450 | __u16 wMaxMultiplier; | ||
451 | __u8 bControlSize; | ||
452 | __u8 *bmControls; | ||
453 | __u8 bmVideoStandards; | ||
454 | } processing; | ||
455 | |||
456 | struct { | ||
457 | __u8 bNrInPins; | ||
458 | __u8 *baSourceID; | ||
459 | } selector; | ||
460 | |||
461 | struct { | ||
462 | __u8 guidExtensionCode[16]; | ||
463 | __u8 bNumControls; | ||
464 | __u8 bNrInPins; | ||
465 | __u8 *baSourceID; | ||
466 | __u8 bControlSize; | ||
467 | __u8 *bmControls; | ||
468 | __u8 *bmControlsType; | ||
469 | } extension; | ||
470 | }; | ||
471 | |||
472 | unsigned int ncontrols; | ||
473 | struct uvc_control *controls; | ||
474 | }; | ||
475 | |||
476 | struct uvc_frame { | ||
477 | __u8 bFrameIndex; | ||
478 | __u8 bmCapabilities; | ||
479 | __u16 wWidth; | ||
480 | __u16 wHeight; | ||
481 | __u32 dwMinBitRate; | ||
482 | __u32 dwMaxBitRate; | ||
483 | __u32 dwMaxVideoFrameBufferSize; | ||
484 | __u8 bFrameIntervalType; | ||
485 | __u32 dwDefaultFrameInterval; | ||
486 | __u32 *dwFrameInterval; | ||
487 | }; | ||
488 | |||
489 | struct uvc_format { | ||
490 | __u8 type; | ||
491 | __u8 index; | ||
492 | __u8 bpp; | ||
493 | __u8 colorspace; | ||
494 | __u32 fcc; | ||
495 | __u32 flags; | ||
496 | |||
497 | char name[32]; | ||
498 | |||
499 | unsigned int nframes; | ||
500 | struct uvc_frame *frame; | ||
501 | }; | ||
502 | |||
503 | struct uvc_streaming_header { | ||
504 | __u8 bNumFormats; | ||
505 | __u8 bEndpointAddress; | ||
506 | __u8 bTerminalLink; | ||
507 | __u8 bControlSize; | ||
508 | __u8 *bmaControls; | ||
509 | /* The following fields are used by input headers only. */ | ||
510 | __u8 bmInfo; | ||
511 | __u8 bStillCaptureMethod; | ||
512 | __u8 bTriggerSupport; | ||
513 | __u8 bTriggerUsage; | ||
514 | }; | ||
515 | |||
516 | struct uvc_streaming { | ||
517 | struct list_head list; | ||
518 | |||
519 | struct usb_interface *intf; | ||
520 | int intfnum; | ||
521 | __u16 maxpsize; | ||
522 | |||
523 | struct uvc_streaming_header header; | ||
524 | |||
525 | unsigned int nformats; | ||
526 | struct uvc_format *format; | ||
527 | |||
528 | struct uvc_streaming_control ctrl; | ||
529 | struct uvc_format *cur_format; | ||
530 | struct uvc_frame *cur_frame; | ||
531 | |||
532 | struct mutex mutex; | ||
533 | }; | ||
534 | |||
535 | enum uvc_buffer_state { | ||
536 | UVC_BUF_STATE_IDLE = 0, | ||
537 | UVC_BUF_STATE_QUEUED = 1, | ||
538 | UVC_BUF_STATE_ACTIVE = 2, | ||
539 | UVC_BUF_STATE_DONE = 3, | ||
540 | UVC_BUF_STATE_ERROR = 4, | ||
541 | }; | ||
542 | |||
543 | struct uvc_buffer { | ||
544 | unsigned long vma_use_count; | ||
545 | struct list_head stream; | ||
546 | |||
547 | /* Touched by interrupt handler. */ | ||
548 | struct v4l2_buffer buf; | ||
549 | struct list_head queue; | ||
550 | wait_queue_head_t wait; | ||
551 | enum uvc_buffer_state state; | ||
552 | }; | ||
553 | |||
554 | #define UVC_QUEUE_STREAMING (1 << 0) | ||
555 | #define UVC_QUEUE_DISCONNECTED (1 << 1) | ||
556 | #define UVC_QUEUE_DROP_INCOMPLETE (1 << 2) | ||
557 | |||
558 | struct uvc_video_queue { | ||
559 | void *mem; | ||
560 | unsigned int flags; | ||
561 | __u32 sequence; | ||
562 | |||
563 | unsigned int count; | ||
564 | unsigned int buf_size; | ||
565 | struct uvc_buffer buffer[UVC_MAX_VIDEO_BUFFERS]; | ||
566 | struct mutex mutex; /* protects buffers and mainqueue */ | ||
567 | spinlock_t irqlock; /* protects irqqueue */ | ||
568 | |||
569 | struct list_head mainqueue; | ||
570 | struct list_head irqqueue; | ||
571 | }; | ||
572 | |||
573 | struct uvc_video_device { | ||
574 | struct uvc_device *dev; | ||
575 | struct video_device *vdev; | ||
576 | atomic_t active; | ||
577 | unsigned int frozen : 1; | ||
578 | |||
579 | struct list_head iterms; | ||
580 | struct uvc_entity *oterm; | ||
581 | struct uvc_entity *processing; | ||
582 | struct uvc_entity *selector; | ||
583 | struct list_head extensions; | ||
584 | struct mutex ctrl_mutex; | ||
585 | |||
586 | struct uvc_video_queue queue; | ||
587 | |||
588 | /* Video streaming object, must always be non-NULL. */ | ||
589 | struct uvc_streaming *streaming; | ||
590 | |||
591 | void (*decode) (struct urb *urb, struct uvc_video_device *video, | ||
592 | struct uvc_buffer *buf); | ||
593 | |||
594 | /* Context data used by the bulk completion handler. */ | ||
595 | struct { | ||
596 | __u8 header[256]; | ||
597 | unsigned int header_size; | ||
598 | int skip_payload; | ||
599 | __u32 payload_size; | ||
600 | __u32 max_payload_size; | ||
601 | } bulk; | ||
602 | |||
603 | struct urb *urb[UVC_URBS]; | ||
604 | char *urb_buffer[UVC_URBS]; | ||
605 | |||
606 | __u8 last_fid; | ||
607 | }; | ||
608 | |||
609 | enum uvc_device_state { | ||
610 | UVC_DEV_DISCONNECTED = 1, | ||
611 | }; | ||
612 | |||
613 | struct uvc_device { | ||
614 | struct usb_device *udev; | ||
615 | struct usb_interface *intf; | ||
616 | __u32 quirks; | ||
617 | int intfnum; | ||
618 | char name[32]; | ||
619 | |||
620 | enum uvc_device_state state; | ||
621 | struct kref kref; | ||
622 | struct list_head list; | ||
623 | |||
624 | /* Video control interface */ | ||
625 | __u16 uvc_version; | ||
626 | __u32 clock_frequency; | ||
627 | |||
628 | struct list_head entities; | ||
629 | |||
630 | struct uvc_video_device video; | ||
631 | |||
632 | /* Status Interrupt Endpoint */ | ||
633 | struct usb_host_endpoint *int_ep; | ||
634 | struct urb *int_urb; | ||
635 | __u8 status[16]; | ||
636 | struct input_dev *input; | ||
637 | |||
638 | /* Video Streaming interfaces */ | ||
639 | struct list_head streaming; | ||
640 | }; | ||
641 | |||
642 | enum uvc_handle_state { | ||
643 | UVC_HANDLE_PASSIVE = 0, | ||
644 | UVC_HANDLE_ACTIVE = 1, | ||
645 | }; | ||
646 | |||
647 | struct uvc_fh { | ||
648 | struct uvc_video_device *device; | ||
649 | enum uvc_handle_state state; | ||
650 | }; | ||
651 | |||
652 | struct uvc_driver { | ||
653 | struct usb_driver driver; | ||
654 | |||
655 | struct mutex open_mutex; /* protects from open/disconnect race */ | ||
656 | |||
657 | struct list_head devices; /* struct uvc_device list */ | ||
658 | struct list_head controls; /* struct uvc_control_info list */ | ||
659 | struct mutex ctrl_mutex; /* protects controls and devices | ||
660 | lists */ | ||
661 | }; | ||
662 | |||
663 | /* ------------------------------------------------------------------------ | ||
664 | * Debugging, printing and logging | ||
665 | */ | ||
666 | |||
667 | #define UVC_TRACE_PROBE (1 << 0) | ||
668 | #define UVC_TRACE_DESCR (1 << 1) | ||
669 | #define UVC_TRACE_CONTROL (1 << 2) | ||
670 | #define UVC_TRACE_FORMAT (1 << 3) | ||
671 | #define UVC_TRACE_CAPTURE (1 << 4) | ||
672 | #define UVC_TRACE_CALLS (1 << 5) | ||
673 | #define UVC_TRACE_IOCTL (1 << 6) | ||
674 | #define UVC_TRACE_FRAME (1 << 7) | ||
675 | #define UVC_TRACE_SUSPEND (1 << 8) | ||
676 | #define UVC_TRACE_STATUS (1 << 9) | ||
677 | |||
678 | extern unsigned int uvc_trace_param; | ||
679 | |||
680 | #define uvc_trace(flag, msg...) \ | ||
681 | do { \ | ||
682 | if (uvc_trace_param & flag) \ | ||
683 | printk(KERN_DEBUG "uvcvideo: " msg); \ | ||
684 | } while (0) | ||
685 | |||
686 | #define uvc_printk(level, msg...) \ | ||
687 | printk(level "uvcvideo: " msg) | ||
688 | |||
689 | #define UVC_GUID_FORMAT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-" \ | ||
690 | "%02x%02x%02x%02x%02x%02x" | ||
691 | #define UVC_GUID_ARGS(guid) \ | ||
692 | (guid)[3], (guid)[2], (guid)[1], (guid)[0], \ | ||
693 | (guid)[5], (guid)[4], \ | ||
694 | (guid)[7], (guid)[6], \ | ||
695 | (guid)[8], (guid)[9], \ | ||
696 | (guid)[10], (guid)[11], (guid)[12], \ | ||
697 | (guid)[13], (guid)[14], (guid)[15] | ||
698 | |||
699 | /* -------------------------------------------------------------------------- | ||
700 | * Internal functions. | ||
701 | */ | ||
702 | |||
703 | /* Core driver */ | ||
704 | extern struct uvc_driver uvc_driver; | ||
705 | extern void uvc_delete(struct kref *kref); | ||
706 | |||
707 | /* Video buffers queue management. */ | ||
708 | extern void uvc_queue_init(struct uvc_video_queue *queue); | ||
709 | extern int uvc_alloc_buffers(struct uvc_video_queue *queue, | ||
710 | unsigned int nbuffers, unsigned int buflength); | ||
711 | extern int uvc_free_buffers(struct uvc_video_queue *queue); | ||
712 | extern int uvc_query_buffer(struct uvc_video_queue *queue, | ||
713 | struct v4l2_buffer *v4l2_buf); | ||
714 | extern int uvc_queue_buffer(struct uvc_video_queue *queue, | ||
715 | struct v4l2_buffer *v4l2_buf); | ||
716 | extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, | ||
717 | struct v4l2_buffer *v4l2_buf, int nonblocking); | ||
718 | extern int uvc_queue_enable(struct uvc_video_queue *queue, int enable); | ||
719 | extern void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect); | ||
720 | extern struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | ||
721 | struct uvc_buffer *buf); | ||
722 | extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue, | ||
723 | struct file *file, poll_table *wait); | ||
724 | static inline int uvc_queue_streaming(struct uvc_video_queue *queue) | ||
725 | { | ||
726 | return queue->flags & UVC_QUEUE_STREAMING; | ||
727 | } | ||
728 | |||
729 | /* V4L2 interface */ | ||
730 | extern struct file_operations uvc_fops; | ||
731 | |||
732 | /* Video */ | ||
733 | extern int uvc_video_init(struct uvc_video_device *video); | ||
734 | extern int uvc_video_suspend(struct uvc_video_device *video); | ||
735 | extern int uvc_video_resume(struct uvc_video_device *video); | ||
736 | extern int uvc_video_enable(struct uvc_video_device *video, int enable); | ||
737 | extern int uvc_probe_video(struct uvc_video_device *video, | ||
738 | struct uvc_streaming_control *probe); | ||
739 | extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, | ||
740 | __u8 intfnum, __u8 cs, void *data, __u16 size); | ||
741 | extern int uvc_set_video_ctrl(struct uvc_video_device *video, | ||
742 | struct uvc_streaming_control *ctrl, int probe); | ||
743 | |||
744 | /* Status */ | ||
745 | extern int uvc_status_init(struct uvc_device *dev); | ||
746 | extern void uvc_status_cleanup(struct uvc_device *dev); | ||
747 | extern int uvc_status_suspend(struct uvc_device *dev); | ||
748 | extern int uvc_status_resume(struct uvc_device *dev); | ||
749 | |||
750 | /* Controls */ | ||
751 | extern struct uvc_control *uvc_find_control(struct uvc_video_device *video, | ||
752 | __u32 v4l2_id, struct uvc_control_mapping **mapping); | ||
753 | extern int uvc_query_v4l2_ctrl(struct uvc_video_device *video, | ||
754 | struct v4l2_queryctrl *v4l2_ctrl); | ||
755 | |||
756 | extern int uvc_ctrl_add_info(struct uvc_control_info *info); | ||
757 | extern int uvc_ctrl_add_mapping(struct uvc_control_mapping *mapping); | ||
758 | extern int uvc_ctrl_init_device(struct uvc_device *dev); | ||
759 | extern void uvc_ctrl_cleanup_device(struct uvc_device *dev); | ||
760 | extern int uvc_ctrl_resume_device(struct uvc_device *dev); | ||
761 | extern void uvc_ctrl_init(void); | ||
762 | |||
763 | extern int uvc_ctrl_begin(struct uvc_video_device *video); | ||
764 | extern int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback); | ||
765 | static inline int uvc_ctrl_commit(struct uvc_video_device *video) | ||
766 | { | ||
767 | return __uvc_ctrl_commit(video, 0); | ||
768 | } | ||
769 | static inline int uvc_ctrl_rollback(struct uvc_video_device *video) | ||
770 | { | ||
771 | return __uvc_ctrl_commit(video, 1); | ||
772 | } | ||
773 | |||
774 | extern int uvc_ctrl_get(struct uvc_video_device *video, | ||
775 | struct v4l2_ext_control *xctrl); | ||
776 | extern int uvc_ctrl_set(struct uvc_video_device *video, | ||
777 | struct v4l2_ext_control *xctrl); | ||
778 | |||
779 | extern int uvc_xu_ctrl_query(struct uvc_video_device *video, | ||
780 | struct uvc_xu_control *ctrl, int set); | ||
781 | |||
782 | /* Utility functions */ | ||
783 | extern void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator, | ||
784 | unsigned int n_terms, unsigned int threshold); | ||
785 | extern uint32_t uvc_fraction_to_interval(uint32_t numerator, | ||
786 | uint32_t denominator); | ||
787 | extern struct usb_host_endpoint *uvc_find_endpoint( | ||
788 | struct usb_host_interface *alts, __u8 epaddr); | ||
789 | |||
790 | /* Quirks support */ | ||
791 | void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video, | ||
792 | struct uvc_buffer *buf); | ||
793 | |||
794 | #endif /* __KERNEL__ */ | ||
795 | |||
796 | #endif | ||
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 31e8af0ba278..67a661cf5219 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -51,12 +51,51 @@ | |||
51 | #define VIDEO_NUM_DEVICES 256 | 51 | #define VIDEO_NUM_DEVICES 256 |
52 | #define VIDEO_NAME "video4linux" | 52 | #define VIDEO_NAME "video4linux" |
53 | 53 | ||
54 | struct std_descr { | ||
55 | v4l2_std_id std; | ||
56 | const char *descr; | ||
57 | }; | ||
58 | |||
59 | static const struct std_descr standards[] = { | ||
60 | { V4L2_STD_NTSC, "NTSC" }, | ||
61 | { V4L2_STD_NTSC_M, "NTSC-M" }, | ||
62 | { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" }, | ||
63 | { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" }, | ||
64 | { V4L2_STD_NTSC_443, "NTSC-443" }, | ||
65 | { V4L2_STD_PAL, "PAL" }, | ||
66 | { V4L2_STD_PAL_BG, "PAL-BG" }, | ||
67 | { V4L2_STD_PAL_B, "PAL-B" }, | ||
68 | { V4L2_STD_PAL_B1, "PAL-B1" }, | ||
69 | { V4L2_STD_PAL_G, "PAL-G" }, | ||
70 | { V4L2_STD_PAL_H, "PAL-H" }, | ||
71 | { V4L2_STD_PAL_I, "PAL-I" }, | ||
72 | { V4L2_STD_PAL_DK, "PAL-DK" }, | ||
73 | { V4L2_STD_PAL_D, "PAL-D" }, | ||
74 | { V4L2_STD_PAL_D1, "PAL-D1" }, | ||
75 | { V4L2_STD_PAL_K, "PAL-K" }, | ||
76 | { V4L2_STD_PAL_M, "PAL-M" }, | ||
77 | { V4L2_STD_PAL_N, "PAL-N" }, | ||
78 | { V4L2_STD_PAL_Nc, "PAL-Nc" }, | ||
79 | { V4L2_STD_PAL_60, "PAL-60" }, | ||
80 | { V4L2_STD_SECAM, "SECAM" }, | ||
81 | { V4L2_STD_SECAM_B, "SECAM-B" }, | ||
82 | { V4L2_STD_SECAM_G, "SECAM-G" }, | ||
83 | { V4L2_STD_SECAM_H, "SECAM-H" }, | ||
84 | { V4L2_STD_SECAM_DK, "SECAM-DK" }, | ||
85 | { V4L2_STD_SECAM_D, "SECAM-D" }, | ||
86 | { V4L2_STD_SECAM_K, "SECAM-K" }, | ||
87 | { V4L2_STD_SECAM_K1, "SECAM-K1" }, | ||
88 | { V4L2_STD_SECAM_L, "SECAM-L" }, | ||
89 | { V4L2_STD_SECAM_LC, "SECAM-Lc" }, | ||
90 | { 0, "Unknown" } | ||
91 | }; | ||
92 | |||
54 | /* video4linux standard ID conversion to standard name | 93 | /* video4linux standard ID conversion to standard name |
55 | */ | 94 | */ |
56 | char *v4l2_norm_to_name(v4l2_std_id id) | 95 | const char *v4l2_norm_to_name(v4l2_std_id id) |
57 | { | 96 | { |
58 | char *name; | ||
59 | u32 myid = id; | 97 | u32 myid = id; |
98 | int i; | ||
60 | 99 | ||
61 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle | 100 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle |
62 | 64 bit comparations. So, on that architecture, with some gcc | 101 | 64 bit comparations. So, on that architecture, with some gcc |
@@ -64,110 +103,17 @@ char *v4l2_norm_to_name(v4l2_std_id id) | |||
64 | */ | 103 | */ |
65 | BUG_ON(myid != id); | 104 | BUG_ON(myid != id); |
66 | 105 | ||
67 | switch (myid) { | 106 | for (i = 0; standards[i].std; i++) |
68 | case V4L2_STD_PAL: | 107 | if (myid == standards[i].std) |
69 | name = "PAL"; | 108 | break; |
70 | break; | 109 | return standards[i].descr; |
71 | case V4L2_STD_PAL_BG: | ||
72 | name = "PAL-BG"; | ||
73 | break; | ||
74 | case V4L2_STD_PAL_DK: | ||
75 | name = "PAL-DK"; | ||
76 | break; | ||
77 | case V4L2_STD_PAL_B: | ||
78 | name = "PAL-B"; | ||
79 | break; | ||
80 | case V4L2_STD_PAL_B1: | ||
81 | name = "PAL-B1"; | ||
82 | break; | ||
83 | case V4L2_STD_PAL_G: | ||
84 | name = "PAL-G"; | ||
85 | break; | ||
86 | case V4L2_STD_PAL_H: | ||
87 | name = "PAL-H"; | ||
88 | break; | ||
89 | case V4L2_STD_PAL_I: | ||
90 | name = "PAL-I"; | ||
91 | break; | ||
92 | case V4L2_STD_PAL_D: | ||
93 | name = "PAL-D"; | ||
94 | break; | ||
95 | case V4L2_STD_PAL_D1: | ||
96 | name = "PAL-D1"; | ||
97 | break; | ||
98 | case V4L2_STD_PAL_K: | ||
99 | name = "PAL-K"; | ||
100 | break; | ||
101 | case V4L2_STD_PAL_M: | ||
102 | name = "PAL-M"; | ||
103 | break; | ||
104 | case V4L2_STD_PAL_N: | ||
105 | name = "PAL-N"; | ||
106 | break; | ||
107 | case V4L2_STD_PAL_Nc: | ||
108 | name = "PAL-Nc"; | ||
109 | break; | ||
110 | case V4L2_STD_PAL_60: | ||
111 | name = "PAL-60"; | ||
112 | break; | ||
113 | case V4L2_STD_NTSC: | ||
114 | name = "NTSC"; | ||
115 | break; | ||
116 | case V4L2_STD_NTSC_M: | ||
117 | name = "NTSC-M"; | ||
118 | break; | ||
119 | case V4L2_STD_NTSC_M_JP: | ||
120 | name = "NTSC-M-JP"; | ||
121 | break; | ||
122 | case V4L2_STD_NTSC_443: | ||
123 | name = "NTSC-443"; | ||
124 | break; | ||
125 | case V4L2_STD_NTSC_M_KR: | ||
126 | name = "NTSC-M-KR"; | ||
127 | break; | ||
128 | case V4L2_STD_SECAM: | ||
129 | name = "SECAM"; | ||
130 | break; | ||
131 | case V4L2_STD_SECAM_DK: | ||
132 | name = "SECAM-DK"; | ||
133 | break; | ||
134 | case V4L2_STD_SECAM_B: | ||
135 | name = "SECAM-B"; | ||
136 | break; | ||
137 | case V4L2_STD_SECAM_D: | ||
138 | name = "SECAM-D"; | ||
139 | break; | ||
140 | case V4L2_STD_SECAM_G: | ||
141 | name = "SECAM-G"; | ||
142 | break; | ||
143 | case V4L2_STD_SECAM_H: | ||
144 | name = "SECAM-H"; | ||
145 | break; | ||
146 | case V4L2_STD_SECAM_K: | ||
147 | name = "SECAM-K"; | ||
148 | break; | ||
149 | case V4L2_STD_SECAM_K1: | ||
150 | name = "SECAM-K1"; | ||
151 | break; | ||
152 | case V4L2_STD_SECAM_L: | ||
153 | name = "SECAM-L"; | ||
154 | break; | ||
155 | case V4L2_STD_SECAM_LC: | ||
156 | name = "SECAM-LC"; | ||
157 | break; | ||
158 | default: | ||
159 | name = "Unknown"; | ||
160 | break; | ||
161 | } | ||
162 | |||
163 | return name; | ||
164 | } | 110 | } |
165 | EXPORT_SYMBOL(v4l2_norm_to_name); | 111 | EXPORT_SYMBOL(v4l2_norm_to_name); |
166 | 112 | ||
167 | /* Fill in the fields of a v4l2_standard structure according to the | 113 | /* Fill in the fields of a v4l2_standard structure according to the |
168 | 'id' and 'transmission' parameters. Returns negative on error. */ | 114 | 'id' and 'transmission' parameters. Returns negative on error. */ |
169 | int v4l2_video_std_construct(struct v4l2_standard *vs, | 115 | int v4l2_video_std_construct(struct v4l2_standard *vs, |
170 | int id, char *name) | 116 | int id, const char *name) |
171 | { | 117 | { |
172 | u32 index = vs->index; | 118 | u32 index = vs->index; |
173 | 119 | ||
@@ -1218,95 +1164,40 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1218 | case VIDIOC_ENUMSTD: | 1164 | case VIDIOC_ENUMSTD: |
1219 | { | 1165 | { |
1220 | struct v4l2_standard *p = arg; | 1166 | struct v4l2_standard *p = arg; |
1221 | v4l2_std_id id = vfd->tvnorms,curr_id=0; | 1167 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; |
1222 | unsigned int index = p->index,i; | 1168 | unsigned int index = p->index, i, j = 0; |
1223 | 1169 | const char *descr = ""; | |
1224 | if (index<0) { | 1170 | |
1225 | ret=-EINVAL; | 1171 | /* Return norm array in a canonical way */ |
1226 | break; | 1172 | for (i = 0; i <= index && id; i++) { |
1227 | } | 1173 | /* last std value in the standards array is 0, so this |
1228 | 1174 | while always ends there since (id & 0) == 0. */ | |
1229 | /* Return norm array on a canonical way */ | 1175 | while ((id & standards[j].std) != standards[j].std) |
1230 | for (i=0;i<= index && id; i++) { | 1176 | j++; |
1231 | if ( (id & V4L2_STD_PAL) == V4L2_STD_PAL) { | 1177 | curr_id = standards[j].std; |
1232 | curr_id = V4L2_STD_PAL; | 1178 | descr = standards[j].descr; |
1233 | } else if ( (id & V4L2_STD_PAL_BG) == V4L2_STD_PAL_BG) { | 1179 | j++; |
1234 | curr_id = V4L2_STD_PAL_BG; | 1180 | if (curr_id == 0) |
1235 | } else if ( (id & V4L2_STD_PAL_DK) == V4L2_STD_PAL_DK) { | ||
1236 | curr_id = V4L2_STD_PAL_DK; | ||
1237 | } else if ( (id & V4L2_STD_PAL_B) == V4L2_STD_PAL_B) { | ||
1238 | curr_id = V4L2_STD_PAL_B; | ||
1239 | } else if ( (id & V4L2_STD_PAL_B1) == V4L2_STD_PAL_B1) { | ||
1240 | curr_id = V4L2_STD_PAL_B1; | ||
1241 | } else if ( (id & V4L2_STD_PAL_G) == V4L2_STD_PAL_G) { | ||
1242 | curr_id = V4L2_STD_PAL_G; | ||
1243 | } else if ( (id & V4L2_STD_PAL_H) == V4L2_STD_PAL_H) { | ||
1244 | curr_id = V4L2_STD_PAL_H; | ||
1245 | } else if ( (id & V4L2_STD_PAL_I) == V4L2_STD_PAL_I) { | ||
1246 | curr_id = V4L2_STD_PAL_I; | ||
1247 | } else if ( (id & V4L2_STD_PAL_D) == V4L2_STD_PAL_D) { | ||
1248 | curr_id = V4L2_STD_PAL_D; | ||
1249 | } else if ( (id & V4L2_STD_PAL_D1) == V4L2_STD_PAL_D1) { | ||
1250 | curr_id = V4L2_STD_PAL_D1; | ||
1251 | } else if ( (id & V4L2_STD_PAL_K) == V4L2_STD_PAL_K) { | ||
1252 | curr_id = V4L2_STD_PAL_K; | ||
1253 | } else if ( (id & V4L2_STD_PAL_M) == V4L2_STD_PAL_M) { | ||
1254 | curr_id = V4L2_STD_PAL_M; | ||
1255 | } else if ( (id & V4L2_STD_PAL_N) == V4L2_STD_PAL_N) { | ||
1256 | curr_id = V4L2_STD_PAL_N; | ||
1257 | } else if ( (id & V4L2_STD_PAL_Nc) == V4L2_STD_PAL_Nc) { | ||
1258 | curr_id = V4L2_STD_PAL_Nc; | ||
1259 | } else if ( (id & V4L2_STD_PAL_60) == V4L2_STD_PAL_60) { | ||
1260 | curr_id = V4L2_STD_PAL_60; | ||
1261 | } else if ( (id & V4L2_STD_NTSC) == V4L2_STD_NTSC) { | ||
1262 | curr_id = V4L2_STD_NTSC; | ||
1263 | } else if ( (id & V4L2_STD_NTSC_M) == V4L2_STD_NTSC_M) { | ||
1264 | curr_id = V4L2_STD_NTSC_M; | ||
1265 | } else if ( (id & V4L2_STD_NTSC_M_JP) == V4L2_STD_NTSC_M_JP) { | ||
1266 | curr_id = V4L2_STD_NTSC_M_JP; | ||
1267 | } else if ( (id & V4L2_STD_NTSC_443) == V4L2_STD_NTSC_443) { | ||
1268 | curr_id = V4L2_STD_NTSC_443; | ||
1269 | } else if ( (id & V4L2_STD_NTSC_M_KR) == V4L2_STD_NTSC_M_KR) { | ||
1270 | curr_id = V4L2_STD_NTSC_M_KR; | ||
1271 | } else if ( (id & V4L2_STD_SECAM) == V4L2_STD_SECAM) { | ||
1272 | curr_id = V4L2_STD_SECAM; | ||
1273 | } else if ( (id & V4L2_STD_SECAM_DK) == V4L2_STD_SECAM_DK) { | ||
1274 | curr_id = V4L2_STD_SECAM_DK; | ||
1275 | } else if ( (id & V4L2_STD_SECAM_B) == V4L2_STD_SECAM_B) { | ||
1276 | curr_id = V4L2_STD_SECAM_B; | ||
1277 | } else if ( (id & V4L2_STD_SECAM_D) == V4L2_STD_SECAM_D) { | ||
1278 | curr_id = V4L2_STD_SECAM_D; | ||
1279 | } else if ( (id & V4L2_STD_SECAM_G) == V4L2_STD_SECAM_G) { | ||
1280 | curr_id = V4L2_STD_SECAM_G; | ||
1281 | } else if ( (id & V4L2_STD_SECAM_H) == V4L2_STD_SECAM_H) { | ||
1282 | curr_id = V4L2_STD_SECAM_H; | ||
1283 | } else if ( (id & V4L2_STD_SECAM_K) == V4L2_STD_SECAM_K) { | ||
1284 | curr_id = V4L2_STD_SECAM_K; | ||
1285 | } else if ( (id & V4L2_STD_SECAM_K1) == V4L2_STD_SECAM_K1) { | ||
1286 | curr_id = V4L2_STD_SECAM_K1; | ||
1287 | } else if ( (id & V4L2_STD_SECAM_L) == V4L2_STD_SECAM_L) { | ||
1288 | curr_id = V4L2_STD_SECAM_L; | ||
1289 | } else if ( (id & V4L2_STD_SECAM_LC) == V4L2_STD_SECAM_LC) { | ||
1290 | curr_id = V4L2_STD_SECAM_LC; | ||
1291 | } else { | ||
1292 | break; | 1181 | break; |
1293 | } | 1182 | if (curr_id != V4L2_STD_PAL && |
1294 | id &= ~curr_id; | 1183 | curr_id != V4L2_STD_SECAM && |
1184 | curr_id != V4L2_STD_NTSC) | ||
1185 | id &= ~curr_id; | ||
1295 | } | 1186 | } |
1296 | if (i<=index) | 1187 | if (i <= index) |
1297 | return -EINVAL; | 1188 | return -EINVAL; |
1298 | 1189 | ||
1299 | v4l2_video_std_construct(p, curr_id,v4l2_norm_to_name(curr_id)); | 1190 | v4l2_video_std_construct(p, curr_id, descr); |
1300 | p->index = index; | 1191 | p->index = index; |
1301 | 1192 | ||
1302 | dbgarg (cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, " | 1193 | dbgarg(cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, " |
1303 | "framelines=%d\n", p->index, | 1194 | "framelines=%d\n", p->index, |
1304 | (unsigned long long)p->id, p->name, | 1195 | (unsigned long long)p->id, p->name, |
1305 | p->frameperiod.numerator, | 1196 | p->frameperiod.numerator, |
1306 | p->frameperiod.denominator, | 1197 | p->frameperiod.denominator, |
1307 | p->framelines); | 1198 | p->framelines); |
1308 | 1199 | ||
1309 | ret=0; | 1200 | ret = 0; |
1310 | break; | 1201 | break; |
1311 | } | 1202 | } |
1312 | case VIDIOC_G_STD: | 1203 | case VIDIOC_G_STD: |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 845be1864f68..5ff9a58b6135 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -327,13 +327,14 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
327 | int hmax = buf->vb.height; | 327 | int hmax = buf->vb.height; |
328 | int wmax = buf->vb.width; | 328 | int wmax = buf->vb.width; |
329 | struct timeval ts; | 329 | struct timeval ts; |
330 | char *tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC); | 330 | char *tmpbuf; |
331 | void *vbuf = videobuf_to_vmalloc(&buf->vb); | 331 | void *vbuf = videobuf_to_vmalloc(&buf->vb); |
332 | 332 | ||
333 | if (!tmpbuf) | 333 | if (!vbuf) |
334 | return; | 334 | return; |
335 | 335 | ||
336 | if (!vbuf) | 336 | tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC); |
337 | if (!tmpbuf) | ||
337 | return; | 338 | return; |
338 | 339 | ||
339 | for (h = 0; h < hmax; h++) { | 340 | for (h = 0; h < hmax; h++) { |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 65210fca37ed..d89475d36988 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -114,6 +114,7 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
114 | unsigned int nob = data->blocks; | 114 | unsigned int nob = data->blocks; |
115 | unsigned long long clks; | 115 | unsigned long long clks; |
116 | unsigned int timeout; | 116 | unsigned int timeout; |
117 | bool dalgn = 0; | ||
117 | u32 dcmd; | 118 | u32 dcmd; |
118 | int i; | 119 | int i; |
119 | 120 | ||
@@ -152,6 +153,9 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
152 | host->sg_cpu[i].dcmd = dcmd | length; | 153 | host->sg_cpu[i].dcmd = dcmd | length; |
153 | if (length & 31 && !(data->flags & MMC_DATA_READ)) | 154 | if (length & 31 && !(data->flags & MMC_DATA_READ)) |
154 | host->sg_cpu[i].dcmd |= DCMD_ENDIRQEN; | 155 | host->sg_cpu[i].dcmd |= DCMD_ENDIRQEN; |
156 | /* Not aligned to 8-byte boundary? */ | ||
157 | if (sg_dma_address(&data->sg[i]) & 0x7) | ||
158 | dalgn = 1; | ||
155 | if (data->flags & MMC_DATA_READ) { | 159 | if (data->flags & MMC_DATA_READ) { |
156 | host->sg_cpu[i].dsadr = host->res->start + MMC_RXFIFO; | 160 | host->sg_cpu[i].dsadr = host->res->start + MMC_RXFIFO; |
157 | host->sg_cpu[i].dtadr = sg_dma_address(&data->sg[i]); | 161 | host->sg_cpu[i].dtadr = sg_dma_address(&data->sg[i]); |
@@ -165,6 +169,15 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
165 | host->sg_cpu[host->dma_len - 1].ddadr = DDADR_STOP; | 169 | host->sg_cpu[host->dma_len - 1].ddadr = DDADR_STOP; |
166 | wmb(); | 170 | wmb(); |
167 | 171 | ||
172 | /* | ||
173 | * The PXA27x DMA controller encounters overhead when working with | ||
174 | * unaligned (to 8-byte boundaries) data, so switch on byte alignment | ||
175 | * mode only if we have unaligned data. | ||
176 | */ | ||
177 | if (dalgn) | ||
178 | DALGN |= (1 << host->dma); | ||
179 | else | ||
180 | DALGN &= (1 << host->dma); | ||
168 | DDADR(host->dma) = host->sg_dma; | 181 | DDADR(host->dma) = host->sg_dma; |
169 | DCSR(host->dma) = DCSR_RUN; | 182 | DCSR(host->dma) = DCSR_RUN; |
170 | } | 183 | } |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 07c2048b230b..b413aa6c246b 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -55,6 +55,10 @@ static unsigned int debug_quirks = 0; | |||
55 | #define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<7) | 55 | #define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<7) |
56 | /* Controller needs to be reset after each request to stay stable */ | 56 | /* Controller needs to be reset after each request to stay stable */ |
57 | #define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<8) | 57 | #define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<8) |
58 | /* Controller needs voltage and power writes to happen separately */ | ||
59 | #define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1<<9) | ||
60 | /* Controller has an off-by-one issue with timeout value */ | ||
61 | #define SDHCI_QUIRK_INCR_TIMEOUT_CONTROL (1<<10) | ||
58 | 62 | ||
59 | static const struct pci_device_id pci_ids[] __devinitdata = { | 63 | static const struct pci_device_id pci_ids[] __devinitdata = { |
60 | { | 64 | { |
@@ -115,7 +119,8 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
115 | .subvendor = PCI_ANY_ID, | 119 | .subvendor = PCI_ANY_ID, |
116 | .subdevice = PCI_ANY_ID, | 120 | .subdevice = PCI_ANY_ID, |
117 | .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | | 121 | .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | |
118 | SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS, | 122 | SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS | |
123 | SDHCI_QUIRK_BROKEN_DMA, | ||
119 | }, | 124 | }, |
120 | 125 | ||
121 | { | 126 | { |
@@ -124,7 +129,17 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
124 | .subvendor = PCI_ANY_ID, | 129 | .subvendor = PCI_ANY_ID, |
125 | .subdevice = PCI_ANY_ID, | 130 | .subdevice = PCI_ANY_ID, |
126 | .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | | 131 | .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE | |
127 | SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS, | 132 | SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS | |
133 | SDHCI_QUIRK_BROKEN_DMA, | ||
134 | }, | ||
135 | |||
136 | { | ||
137 | .vendor = PCI_VENDOR_ID_MARVELL, | ||
138 | .device = PCI_DEVICE_ID_MARVELL_CAFE_SD, | ||
139 | .subvendor = PCI_ANY_ID, | ||
140 | .subdevice = PCI_ANY_ID, | ||
141 | .driver_data = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER | | ||
142 | SDHCI_QUIRK_INCR_TIMEOUT_CONTROL, | ||
128 | }, | 143 | }, |
129 | 144 | ||
130 | { | 145 | { |
@@ -469,6 +484,13 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) | |||
469 | break; | 484 | break; |
470 | } | 485 | } |
471 | 486 | ||
487 | /* | ||
488 | * Compensate for an off-by-one error in the CaFe hardware; otherwise, | ||
489 | * a too-small count gives us interrupt timeouts. | ||
490 | */ | ||
491 | if ((host->chip->quirks & SDHCI_QUIRK_INCR_TIMEOUT_CONTROL)) | ||
492 | count++; | ||
493 | |||
472 | if (count >= 0xF) { | 494 | if (count >= 0xF) { |
473 | printk(KERN_WARNING "%s: Too large timeout requested!\n", | 495 | printk(KERN_WARNING "%s: Too large timeout requested!\n", |
474 | mmc_hostname(host->mmc)); | 496 | mmc_hostname(host->mmc)); |
@@ -774,6 +796,14 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power) | |||
774 | BUG(); | 796 | BUG(); |
775 | } | 797 | } |
776 | 798 | ||
799 | /* | ||
800 | * At least the CaFe chip gets confused if we set the voltage | ||
801 | * and set turn on power at the same time, so set the voltage first. | ||
802 | */ | ||
803 | if ((host->chip->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER)) | ||
804 | writeb(pwr & ~SDHCI_POWER_ON, | ||
805 | host->ioaddr + SDHCI_POWER_CONTROL); | ||
806 | |||
777 | writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL); | 807 | writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL); |
778 | 808 | ||
779 | out: | 809 | out: |
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 2edda8cc7f99..aabad8ce7458 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c | |||
@@ -1768,9 +1768,10 @@ vortex_timer(unsigned long data) | |||
1768 | case XCVR_MII: case XCVR_NWAY: | 1768 | case XCVR_MII: case XCVR_NWAY: |
1769 | { | 1769 | { |
1770 | ok = 1; | 1770 | ok = 1; |
1771 | spin_lock_bh(&vp->lock); | 1771 | /* Interrupts are already disabled */ |
1772 | spin_lock(&vp->lock); | ||
1772 | vortex_check_media(dev, 0); | 1773 | vortex_check_media(dev, 0); |
1773 | spin_unlock_bh(&vp->lock); | 1774 | spin_unlock(&vp->lock); |
1774 | } | 1775 | } |
1775 | break; | 1776 | break; |
1776 | default: /* Other media types handled by Tx timeouts. */ | 1777 | default: /* Other media types handled by Tx timeouts. */ |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index f3cba5e24ec5..1037b1332312 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1803,6 +1803,8 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) | |||
1803 | if (rx->prev->skb) { | 1803 | if (rx->prev->skb) { |
1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; | 1804 | struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; |
1805 | put_unaligned_le32(rx->dma_addr, &prev_rfd->link); | 1805 | put_unaligned_le32(rx->dma_addr, &prev_rfd->link); |
1806 | pci_dma_sync_single_for_device(nic->pdev, rx->prev->dma_addr, | ||
1807 | sizeof(struct rfd), PCI_DMA_TODEVICE); | ||
1806 | } | 1808 | } |
1807 | 1809 | ||
1808 | return 0; | 1810 | return 0; |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 701531e72e7b..a3f6a9c72ec8 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -347,7 +347,7 @@ e1000_set_tso(struct net_device *netdev, u32 data) | |||
347 | else | 347 | else |
348 | netdev->features &= ~NETIF_F_TSO; | 348 | netdev->features &= ~NETIF_F_TSO; |
349 | 349 | ||
350 | if (data) | 350 | if (data && (adapter->hw.mac_type > e1000_82547_rev_2)) |
351 | netdev->features |= NETIF_F_TSO6; | 351 | netdev->features |= NETIF_F_TSO6; |
352 | else | 352 | else |
353 | netdev->features &= ~NETIF_F_TSO6; | 353 | netdev->features &= ~NETIF_F_TSO6; |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index cab1835173cd..648a87bbf467 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -2535,7 +2535,8 @@ void e1000e_down(struct e1000_adapter *adapter) | |||
2535 | adapter->link_speed = 0; | 2535 | adapter->link_speed = 0; |
2536 | adapter->link_duplex = 0; | 2536 | adapter->link_duplex = 0; |
2537 | 2537 | ||
2538 | e1000e_reset(adapter); | 2538 | if (!pci_channel_offline(adapter->pdev)) |
2539 | e1000e_reset(adapter); | ||
2539 | e1000_clean_tx_ring(adapter); | 2540 | e1000_clean_tx_ring(adapter); |
2540 | e1000_clean_rx_ring(adapter); | 2541 | e1000_clean_rx_ring(adapter); |
2541 | 2542 | ||
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index fe872fbd671e..e01926b7b5b7 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | 41 | ||
42 | #define DRV_NAME "ehea" | 42 | #define DRV_NAME "ehea" |
43 | #define DRV_VERSION "EHEA_0091" | 43 | #define DRV_VERSION "EHEA_0092" |
44 | 44 | ||
45 | /* eHEA capability flags */ | 45 | /* eHEA capability flags */ |
46 | #define DLPAR_PORT_ADD_REM 1 | 46 | #define DLPAR_PORT_ADD_REM 1 |
@@ -452,7 +452,7 @@ struct ehea_bcmc_reg_entry { | |||
452 | struct ehea_bcmc_reg_array { | 452 | struct ehea_bcmc_reg_array { |
453 | struct ehea_bcmc_reg_entry *arr; | 453 | struct ehea_bcmc_reg_entry *arr; |
454 | int num_entries; | 454 | int num_entries; |
455 | struct mutex lock; | 455 | spinlock_t lock; |
456 | }; | 456 | }; |
457 | 457 | ||
458 | #define EHEA_PORT_UP 1 | 458 | #define EHEA_PORT_UP 1 |
@@ -478,6 +478,7 @@ struct ehea_port { | |||
478 | int num_add_tx_qps; | 478 | int num_add_tx_qps; |
479 | int num_mcs; | 479 | int num_mcs; |
480 | int resets; | 480 | int resets; |
481 | u64 flags; | ||
481 | u64 mac_addr; | 482 | u64 mac_addr; |
482 | u32 logical_port_id; | 483 | u32 logical_port_id; |
483 | u32 port_speed; | 484 | u32 port_speed; |
@@ -501,7 +502,8 @@ struct port_res_cfg { | |||
501 | }; | 502 | }; |
502 | 503 | ||
503 | enum ehea_flag_bits { | 504 | enum ehea_flag_bits { |
504 | __EHEA_STOP_XFER | 505 | __EHEA_STOP_XFER, |
506 | __EHEA_DISABLE_PORT_RESET | ||
505 | }; | 507 | }; |
506 | 508 | ||
507 | void ehea_set_ethtool_ops(struct net_device *netdev); | 509 | void ehea_set_ethtool_ops(struct net_device *netdev); |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 075fd547421e..0920b796bd78 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -118,6 +118,7 @@ static struct of_device_id ehea_device_table[] = { | |||
118 | }, | 118 | }, |
119 | {}, | 119 | {}, |
120 | }; | 120 | }; |
121 | MODULE_DEVICE_TABLE(of, ehea_device_table); | ||
121 | 122 | ||
122 | static struct of_platform_driver ehea_driver = { | 123 | static struct of_platform_driver ehea_driver = { |
123 | .name = "ehea", | 124 | .name = "ehea", |
@@ -137,6 +138,12 @@ void ehea_dump(void *adr, int len, char *msg) | |||
137 | } | 138 | } |
138 | } | 139 | } |
139 | 140 | ||
141 | void ehea_schedule_port_reset(struct ehea_port *port) | ||
142 | { | ||
143 | if (!test_bit(__EHEA_DISABLE_PORT_RESET, &port->flags)) | ||
144 | schedule_work(&port->reset_task); | ||
145 | } | ||
146 | |||
140 | static void ehea_update_firmware_handles(void) | 147 | static void ehea_update_firmware_handles(void) |
141 | { | 148 | { |
142 | struct ehea_fw_handle_entry *arr = NULL; | 149 | struct ehea_fw_handle_entry *arr = NULL; |
@@ -241,7 +248,7 @@ static void ehea_update_bcmc_registrations(void) | |||
241 | } | 248 | } |
242 | 249 | ||
243 | if (num_registrations) { | 250 | if (num_registrations) { |
244 | arr = kzalloc(num_registrations * sizeof(*arr), GFP_KERNEL); | 251 | arr = kzalloc(num_registrations * sizeof(*arr), GFP_ATOMIC); |
245 | if (!arr) | 252 | if (!arr) |
246 | return; /* Keep the existing array */ | 253 | return; /* Keep the existing array */ |
247 | } else | 254 | } else |
@@ -301,7 +308,7 @@ static struct net_device_stats *ehea_get_stats(struct net_device *dev) | |||
301 | 308 | ||
302 | memset(stats, 0, sizeof(*stats)); | 309 | memset(stats, 0, sizeof(*stats)); |
303 | 310 | ||
304 | cb2 = kzalloc(PAGE_SIZE, GFP_KERNEL); | 311 | cb2 = kzalloc(PAGE_SIZE, GFP_ATOMIC); |
305 | if (!cb2) { | 312 | if (!cb2) { |
306 | ehea_error("no mem for cb2"); | 313 | ehea_error("no mem for cb2"); |
307 | goto out; | 314 | goto out; |
@@ -587,7 +594,7 @@ static int ehea_treat_poll_error(struct ehea_port_res *pr, int rq, | |||
587 | "Resetting port.", pr->qp->init_attr.qp_nr); | 594 | "Resetting port.", pr->qp->init_attr.qp_nr); |
588 | ehea_dump(cqe, sizeof(*cqe), "CQE"); | 595 | ehea_dump(cqe, sizeof(*cqe), "CQE"); |
589 | } | 596 | } |
590 | schedule_work(&pr->port->reset_task); | 597 | ehea_schedule_port_reset(pr->port); |
591 | return 1; | 598 | return 1; |
592 | } | 599 | } |
593 | 600 | ||
@@ -616,7 +623,7 @@ static int get_skb_hdr(struct sk_buff *skb, void **iphdr, | |||
616 | *tcph = tcp_hdr(skb); | 623 | *tcph = tcp_hdr(skb); |
617 | 624 | ||
618 | /* check if ip header and tcp header are complete */ | 625 | /* check if ip header and tcp header are complete */ |
619 | if (iph->tot_len < ip_len + tcp_hdrlen(skb)) | 626 | if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb)) |
620 | return -1; | 627 | return -1; |
621 | 628 | ||
622 | *hdr_flags = LRO_IPV4 | LRO_TCP; | 629 | *hdr_flags = LRO_IPV4 | LRO_TCP; |
@@ -765,7 +772,7 @@ static struct ehea_cqe *ehea_proc_cqes(struct ehea_port_res *pr, int my_quota) | |||
765 | ehea_error("Send Completion Error: Resetting port"); | 772 | ehea_error("Send Completion Error: Resetting port"); |
766 | if (netif_msg_tx_err(pr->port)) | 773 | if (netif_msg_tx_err(pr->port)) |
767 | ehea_dump(cqe, sizeof(*cqe), "Send CQE"); | 774 | ehea_dump(cqe, sizeof(*cqe), "Send CQE"); |
768 | schedule_work(&pr->port->reset_task); | 775 | ehea_schedule_port_reset(pr->port); |
769 | break; | 776 | break; |
770 | } | 777 | } |
771 | 778 | ||
@@ -885,7 +892,7 @@ static irqreturn_t ehea_qp_aff_irq_handler(int irq, void *param) | |||
885 | eqe = ehea_poll_eq(port->qp_eq); | 892 | eqe = ehea_poll_eq(port->qp_eq); |
886 | } | 893 | } |
887 | 894 | ||
888 | schedule_work(&port->reset_task); | 895 | ehea_schedule_port_reset(port); |
889 | 896 | ||
890 | return IRQ_HANDLED; | 897 | return IRQ_HANDLED; |
891 | } | 898 | } |
@@ -1763,7 +1770,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa) | |||
1763 | 1770 | ||
1764 | memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); | 1771 | memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); |
1765 | 1772 | ||
1766 | mutex_lock(&ehea_bcmc_regs.lock); | 1773 | spin_lock(&ehea_bcmc_regs.lock); |
1767 | 1774 | ||
1768 | /* Deregister old MAC in pHYP */ | 1775 | /* Deregister old MAC in pHYP */ |
1769 | if (port->state == EHEA_PORT_UP) { | 1776 | if (port->state == EHEA_PORT_UP) { |
@@ -1785,7 +1792,7 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa) | |||
1785 | 1792 | ||
1786 | out_upregs: | 1793 | out_upregs: |
1787 | ehea_update_bcmc_registrations(); | 1794 | ehea_update_bcmc_registrations(); |
1788 | mutex_unlock(&ehea_bcmc_regs.lock); | 1795 | spin_unlock(&ehea_bcmc_regs.lock); |
1789 | out_free: | 1796 | out_free: |
1790 | kfree(cb0); | 1797 | kfree(cb0); |
1791 | out: | 1798 | out: |
@@ -1947,7 +1954,7 @@ static void ehea_set_multicast_list(struct net_device *dev) | |||
1947 | } | 1954 | } |
1948 | ehea_promiscuous(dev, 0); | 1955 | ehea_promiscuous(dev, 0); |
1949 | 1956 | ||
1950 | mutex_lock(&ehea_bcmc_regs.lock); | 1957 | spin_lock(&ehea_bcmc_regs.lock); |
1951 | 1958 | ||
1952 | if (dev->flags & IFF_ALLMULTI) { | 1959 | if (dev->flags & IFF_ALLMULTI) { |
1953 | ehea_allmulti(dev, 1); | 1960 | ehea_allmulti(dev, 1); |
@@ -1978,7 +1985,7 @@ static void ehea_set_multicast_list(struct net_device *dev) | |||
1978 | } | 1985 | } |
1979 | out: | 1986 | out: |
1980 | ehea_update_bcmc_registrations(); | 1987 | ehea_update_bcmc_registrations(); |
1981 | mutex_unlock(&ehea_bcmc_regs.lock); | 1988 | spin_unlock(&ehea_bcmc_regs.lock); |
1982 | return; | 1989 | return; |
1983 | } | 1990 | } |
1984 | 1991 | ||
@@ -2497,7 +2504,7 @@ static int ehea_up(struct net_device *dev) | |||
2497 | } | 2504 | } |
2498 | } | 2505 | } |
2499 | 2506 | ||
2500 | mutex_lock(&ehea_bcmc_regs.lock); | 2507 | spin_lock(&ehea_bcmc_regs.lock); |
2501 | 2508 | ||
2502 | ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); | 2509 | ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); |
2503 | if (ret) { | 2510 | if (ret) { |
@@ -2520,7 +2527,7 @@ out: | |||
2520 | ehea_info("Failed starting %s. ret=%i", dev->name, ret); | 2527 | ehea_info("Failed starting %s. ret=%i", dev->name, ret); |
2521 | 2528 | ||
2522 | ehea_update_bcmc_registrations(); | 2529 | ehea_update_bcmc_registrations(); |
2523 | mutex_unlock(&ehea_bcmc_regs.lock); | 2530 | spin_unlock(&ehea_bcmc_regs.lock); |
2524 | 2531 | ||
2525 | ehea_update_firmware_handles(); | 2532 | ehea_update_firmware_handles(); |
2526 | mutex_unlock(&ehea_fw_handles.lock); | 2533 | mutex_unlock(&ehea_fw_handles.lock); |
@@ -2575,7 +2582,7 @@ static int ehea_down(struct net_device *dev) | |||
2575 | 2582 | ||
2576 | mutex_lock(&ehea_fw_handles.lock); | 2583 | mutex_lock(&ehea_fw_handles.lock); |
2577 | 2584 | ||
2578 | mutex_lock(&ehea_bcmc_regs.lock); | 2585 | spin_lock(&ehea_bcmc_regs.lock); |
2579 | ehea_drop_multicast_list(dev); | 2586 | ehea_drop_multicast_list(dev); |
2580 | ehea_broadcast_reg_helper(port, H_DEREG_BCMC); | 2587 | ehea_broadcast_reg_helper(port, H_DEREG_BCMC); |
2581 | 2588 | ||
@@ -2584,7 +2591,7 @@ static int ehea_down(struct net_device *dev) | |||
2584 | port->state = EHEA_PORT_DOWN; | 2591 | port->state = EHEA_PORT_DOWN; |
2585 | 2592 | ||
2586 | ehea_update_bcmc_registrations(); | 2593 | ehea_update_bcmc_registrations(); |
2587 | mutex_unlock(&ehea_bcmc_regs.lock); | 2594 | spin_unlock(&ehea_bcmc_regs.lock); |
2588 | 2595 | ||
2589 | ret = ehea_clean_all_portres(port); | 2596 | ret = ehea_clean_all_portres(port); |
2590 | if (ret) | 2597 | if (ret) |
@@ -2605,13 +2612,14 @@ static int ehea_stop(struct net_device *dev) | |||
2605 | if (netif_msg_ifdown(port)) | 2612 | if (netif_msg_ifdown(port)) |
2606 | ehea_info("disabling port %s", dev->name); | 2613 | ehea_info("disabling port %s", dev->name); |
2607 | 2614 | ||
2615 | set_bit(__EHEA_DISABLE_PORT_RESET, &port->flags); | ||
2608 | cancel_work_sync(&port->reset_task); | 2616 | cancel_work_sync(&port->reset_task); |
2609 | |||
2610 | mutex_lock(&port->port_lock); | 2617 | mutex_lock(&port->port_lock); |
2611 | netif_stop_queue(dev); | 2618 | netif_stop_queue(dev); |
2612 | port_napi_disable(port); | 2619 | port_napi_disable(port); |
2613 | ret = ehea_down(dev); | 2620 | ret = ehea_down(dev); |
2614 | mutex_unlock(&port->port_lock); | 2621 | mutex_unlock(&port->port_lock); |
2622 | clear_bit(__EHEA_DISABLE_PORT_RESET, &port->flags); | ||
2615 | return ret; | 2623 | return ret; |
2616 | } | 2624 | } |
2617 | 2625 | ||
@@ -2941,7 +2949,7 @@ static void ehea_tx_watchdog(struct net_device *dev) | |||
2941 | 2949 | ||
2942 | if (netif_carrier_ok(dev) && | 2950 | if (netif_carrier_ok(dev) && |
2943 | !test_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) | 2951 | !test_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) |
2944 | schedule_work(&port->reset_task); | 2952 | ehea_schedule_port_reset(port); |
2945 | } | 2953 | } |
2946 | 2954 | ||
2947 | int ehea_sense_adapter_attr(struct ehea_adapter *adapter) | 2955 | int ehea_sense_adapter_attr(struct ehea_adapter *adapter) |
@@ -3590,7 +3598,7 @@ int __init ehea_module_init(void) | |||
3590 | memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs)); | 3598 | memset(&ehea_bcmc_regs, 0, sizeof(ehea_bcmc_regs)); |
3591 | 3599 | ||
3592 | mutex_init(&ehea_fw_handles.lock); | 3600 | mutex_init(&ehea_fw_handles.lock); |
3593 | mutex_init(&ehea_bcmc_regs.lock); | 3601 | spin_lock_init(&ehea_bcmc_regs.lock); |
3594 | 3602 | ||
3595 | ret = check_module_parm(); | 3603 | ret = check_module_parm(); |
3596 | if (ret) | 3604 | if (ret) |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 2cb244763292..20d4fe96a81c 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -4194,12 +4194,23 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
4194 | 4194 | ||
4195 | netif_carrier_off(dev); | 4195 | netif_carrier_off(dev); |
4196 | if (netif_running(dev)) { | 4196 | if (netif_running(dev)) { |
4197 | unsigned long flags; | ||
4198 | |||
4197 | nv_disable_irq(dev); | 4199 | nv_disable_irq(dev); |
4198 | netif_tx_lock_bh(dev); | 4200 | netif_tx_lock_bh(dev); |
4199 | spin_lock(&np->lock); | 4201 | /* with plain spinlock lockdep complains */ |
4202 | spin_lock_irqsave(&np->lock, flags); | ||
4200 | /* stop engines */ | 4203 | /* stop engines */ |
4204 | /* FIXME: | ||
4205 | * this can take some time, and interrupts are disabled | ||
4206 | * due to spin_lock_irqsave, but let's hope no daemon | ||
4207 | * is going to change the settings very often... | ||
4208 | * Worst case: | ||
4209 | * NV_RXSTOP_DELAY1MAX + NV_TXSTOP_DELAY1MAX | ||
4210 | * + some minor delays, which is up to a second approximately | ||
4211 | */ | ||
4201 | nv_stop_rxtx(dev); | 4212 | nv_stop_rxtx(dev); |
4202 | spin_unlock(&np->lock); | 4213 | spin_unlock_irqrestore(&np->lock, flags); |
4203 | netif_tx_unlock_bh(dev); | 4214 | netif_tx_unlock_bh(dev); |
4204 | } | 4215 | } |
4205 | 4216 | ||
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c index e36321152d50..8268b3535b30 100644 --- a/drivers/net/fs_enet/mac-fcc.c +++ b/drivers/net/fs_enet/mac-fcc.c | |||
@@ -463,6 +463,9 @@ static void restart(struct net_device *dev) | |||
463 | else | 463 | else |
464 | C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB); | 464 | C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB); |
465 | 465 | ||
466 | /* Restore multicast and promiscuous settings */ | ||
467 | set_multicast_list(dev); | ||
468 | |||
466 | S32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT); | 469 | S32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT); |
467 | } | 470 | } |
468 | 471 | ||
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index 0b94833e23f7..e8cfadefa4b6 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c | |||
@@ -1077,8 +1077,6 @@ static inline void rx_off(struct scc_priv *priv) | |||
1077 | 1077 | ||
1078 | static void start_timer(struct scc_priv *priv, int t, int r15) | 1078 | static void start_timer(struct scc_priv *priv, int t, int r15) |
1079 | { | 1079 | { |
1080 | unsigned long flags; | ||
1081 | |||
1082 | outb(priv->tmr_mode, priv->tmr_ctrl); | 1080 | outb(priv->tmr_mode, priv->tmr_ctrl); |
1083 | if (t == 0) { | 1081 | if (t == 0) { |
1084 | tm_isr(priv); | 1082 | tm_isr(priv); |
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 5d2108c5ac7c..babc79ad490b 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -1636,6 +1636,12 @@ static int emac_poll_rx(void *param, int budget) | |||
1636 | goto next; | 1636 | goto next; |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | if (len < ETH_HLEN) { | ||
1640 | ++dev->estats.rx_dropped_stack; | ||
1641 | emac_recycle_rx_skb(dev, slot, len); | ||
1642 | goto next; | ||
1643 | } | ||
1644 | |||
1639 | if (len && len < EMAC_RX_COPY_THRESH) { | 1645 | if (len && len < EMAC_RX_COPY_THRESH) { |
1640 | struct sk_buff *copy_skb = | 1646 | struct sk_buff *copy_skb = |
1641 | alloc_skb(len + EMAC_RX_SKB_HEADROOM + 2, GFP_ATOMIC); | 1647 | alloc_skb(len + EMAC_RX_SKB_HEADROOM + 2, GFP_ATOMIC); |
@@ -2719,6 +2725,8 @@ static int __devinit emac_probe(struct of_device *ofdev, | |||
2719 | /* Clean rings */ | 2725 | /* Clean rings */ |
2720 | memset(dev->tx_desc, 0, NUM_TX_BUFF * sizeof(struct mal_descriptor)); | 2726 | memset(dev->tx_desc, 0, NUM_TX_BUFF * sizeof(struct mal_descriptor)); |
2721 | memset(dev->rx_desc, 0, NUM_RX_BUFF * sizeof(struct mal_descriptor)); | 2727 | memset(dev->rx_desc, 0, NUM_RX_BUFF * sizeof(struct mal_descriptor)); |
2728 | memset(dev->tx_skb, 0, NUM_TX_BUFF * sizeof(struct sk_buff *)); | ||
2729 | memset(dev->rx_skb, 0, NUM_RX_BUFF * sizeof(struct sk_buff *)); | ||
2722 | 2730 | ||
2723 | /* Attach to ZMII, if needed */ | 2731 | /* Attach to ZMII, if needed */ |
2724 | if (emac_has_feature(dev, EMAC_FTR_HAS_ZMII) && | 2732 | if (emac_has_feature(dev, EMAC_FTR_HAS_ZMII) && |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index ae398f04c7b4..e79a26a886c8 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -718,7 +718,8 @@ void igb_down(struct igb_adapter *adapter) | |||
718 | adapter->link_speed = 0; | 718 | adapter->link_speed = 0; |
719 | adapter->link_duplex = 0; | 719 | adapter->link_duplex = 0; |
720 | 720 | ||
721 | igb_reset(adapter); | 721 | if (!pci_channel_offline(adapter->pdev)) |
722 | igb_reset(adapter); | ||
722 | igb_clean_all_tx_rings(adapter); | 723 | igb_clean_all_tx_rings(adapter); |
723 | igb_clean_all_rx_rings(adapter); | 724 | igb_clean_all_rx_rings(adapter); |
724 | } | 725 | } |
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index 679a0826780e..2c03f4e2ccc4 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c | |||
@@ -1271,7 +1271,7 @@ static void ipg_nic_rx_with_end(struct net_device *dev, | |||
1271 | 1271 | ||
1272 | framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; | 1272 | framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; |
1273 | 1273 | ||
1274 | endframeLen = framelen - jumbo->current_size; | 1274 | endframelen = framelen - jumbo->current_size; |
1275 | /* | 1275 | /* |
1276 | if (framelen > IPG_RXFRAG_SIZE) | 1276 | if (framelen > IPG_RXFRAG_SIZE) |
1277 | framelen=IPG_RXFRAG_SIZE; | 1277 | framelen=IPG_RXFRAG_SIZE; |
@@ -1279,8 +1279,8 @@ static void ipg_nic_rx_with_end(struct net_device *dev, | |||
1279 | if (framelen > IPG_RXSUPPORT_SIZE) | 1279 | if (framelen > IPG_RXSUPPORT_SIZE) |
1280 | dev_kfree_skb_irq(jumbo->skb); | 1280 | dev_kfree_skb_irq(jumbo->skb); |
1281 | else { | 1281 | else { |
1282 | memcpy(skb_put(jumbo->skb, endframeLen), | 1282 | memcpy(skb_put(jumbo->skb, endframelen), |
1283 | skb->data, endframeLen); | 1283 | skb->data, endframelen); |
1284 | 1284 | ||
1285 | jumbo->skb->protocol = | 1285 | jumbo->skb->protocol = |
1286 | eth_type_trans(jumbo->skb, dev); | 1286 | eth_type_trans(jumbo->skb, dev); |
@@ -1352,16 +1352,16 @@ static int ipg_nic_rx(struct net_device *dev) | |||
1352 | 1352 | ||
1353 | switch (ipg_nic_rx_check_frame_type(dev)) { | 1353 | switch (ipg_nic_rx_check_frame_type(dev)) { |
1354 | case FRAME_WITH_START_WITH_END: | 1354 | case FRAME_WITH_START_WITH_END: |
1355 | ipg_nic_rx_with_start_and_end(dev, tp, rxfd, entry); | 1355 | ipg_nic_rx_with_start_and_end(dev, sp, rxfd, entry); |
1356 | break; | 1356 | break; |
1357 | case FRAME_WITH_START: | 1357 | case FRAME_WITH_START: |
1358 | ipg_nic_rx_with_start(dev, tp, rxfd, entry); | 1358 | ipg_nic_rx_with_start(dev, sp, rxfd, entry); |
1359 | break; | 1359 | break; |
1360 | case FRAME_WITH_END: | 1360 | case FRAME_WITH_END: |
1361 | ipg_nic_rx_with_end(dev, tp, rxfd, entry); | 1361 | ipg_nic_rx_with_end(dev, sp, rxfd, entry); |
1362 | break; | 1362 | break; |
1363 | case FRAME_NO_START_NO_END: | 1363 | case FRAME_NO_START_NO_END: |
1364 | ipg_nic_rx_no_start_no_end(dev, tp, rxfd, entry); | 1364 | ipg_nic_rx_no_start_no_end(dev, sp, rxfd, entry); |
1365 | break; | 1365 | break; |
1366 | } | 1366 | } |
1367 | } | 1367 | } |
@@ -1808,7 +1808,7 @@ static int ipg_nic_open(struct net_device *dev) | |||
1808 | /* initialize JUMBO Frame control variable */ | 1808 | /* initialize JUMBO Frame control variable */ |
1809 | sp->jumbo.found_start = 0; | 1809 | sp->jumbo.found_start = 0; |
1810 | sp->jumbo.current_size = 0; | 1810 | sp->jumbo.current_size = 0; |
1811 | sp->jumbo.skb = 0; | 1811 | sp->jumbo.skb = NULL; |
1812 | dev->mtu = IPG_TXFRAG_SIZE; | 1812 | dev->mtu = IPG_TXFRAG_SIZE; |
1813 | #endif | 1813 | #endif |
1814 | 1814 | ||
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 7b859220c255..8f0460901153 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -1969,7 +1969,8 @@ void ixgbe_down(struct ixgbe_adapter *adapter) | |||
1969 | netif_carrier_off(netdev); | 1969 | netif_carrier_off(netdev); |
1970 | netif_stop_queue(netdev); | 1970 | netif_stop_queue(netdev); |
1971 | 1971 | ||
1972 | ixgbe_reset(adapter); | 1972 | if (!pci_channel_offline(adapter->pdev)) |
1973 | ixgbe_reset(adapter); | ||
1973 | ixgbe_clean_all_tx_rings(adapter); | 1974 | ixgbe_clean_all_tx_rings(adapter); |
1974 | ixgbe_clean_all_rx_rings(adapter); | 1975 | ixgbe_clean_all_rx_rings(adapter); |
1975 | 1976 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 6797ed069f1f..63cd67b931e7 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -71,14 +71,18 @@ static irqreturn_t netxen_intr(int irq, void *data); | |||
71 | static irqreturn_t netxen_msi_intr(int irq, void *data); | 71 | static irqreturn_t netxen_msi_intr(int irq, void *data); |
72 | 72 | ||
73 | /* PCI Device ID Table */ | 73 | /* PCI Device ID Table */ |
74 | #define ENTRY(device) \ | ||
75 | {PCI_DEVICE(0x4040, (device)), \ | ||
76 | .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0} | ||
77 | |||
74 | static struct pci_device_id netxen_pci_tbl[] __devinitdata = { | 78 | static struct pci_device_id netxen_pci_tbl[] __devinitdata = { |
75 | {PCI_DEVICE(0x4040, 0x0001), PCI_DEVICE_CLASS(0x020000, ~0)}, | 79 | ENTRY(0x0001), |
76 | {PCI_DEVICE(0x4040, 0x0002), PCI_DEVICE_CLASS(0x020000, ~0)}, | 80 | ENTRY(0x0002), |
77 | {PCI_DEVICE(0x4040, 0x0003), PCI_DEVICE_CLASS(0x020000, ~0)}, | 81 | ENTRY(0x0003), |
78 | {PCI_DEVICE(0x4040, 0x0004), PCI_DEVICE_CLASS(0x020000, ~0)}, | 82 | ENTRY(0x0004), |
79 | {PCI_DEVICE(0x4040, 0x0005), PCI_DEVICE_CLASS(0x020000, ~0)}, | 83 | ENTRY(0x0005), |
80 | {PCI_DEVICE(0x4040, 0x0024), PCI_DEVICE_CLASS(0x020000, ~0)}, | 84 | ENTRY(0x0024), |
81 | {PCI_DEVICE(0x4040, 0x0025), PCI_DEVICE_CLASS(0x020000, ~0)}, | 85 | ENTRY(0x0025), |
82 | {0,} | 86 | {0,} |
83 | }; | 87 | }; |
84 | 88 | ||
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index 3b2a6c598088..993d87c9296f 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c | |||
@@ -277,7 +277,7 @@ static int get_skb_hdr(struct sk_buff *skb, void **iphdr, | |||
277 | *tcph = tcp_hdr(skb); | 277 | *tcph = tcp_hdr(skb); |
278 | 278 | ||
279 | /* check if ip header and tcp header are complete */ | 279 | /* check if ip header and tcp header are complete */ |
280 | if (iph->tot_len < ip_len + tcp_hdrlen(skb)) | 280 | if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb)) |
281 | return -1; | 281 | return -1; |
282 | 282 | ||
283 | *hdr_flags = LRO_IPV4 | LRO_TCP; | 283 | *hdr_flags = LRO_IPV4 | LRO_TCP; |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index ce95c5d168fe..70d012e90dcf 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -525,12 +525,14 @@ static int axnet_open(struct net_device *dev) | |||
525 | int ret; | 525 | int ret; |
526 | axnet_dev_t *info = PRIV(dev); | 526 | axnet_dev_t *info = PRIV(dev); |
527 | struct pcmcia_device *link = info->p_dev; | 527 | struct pcmcia_device *link = info->p_dev; |
528 | unsigned int nic_base = dev->base_addr; | ||
528 | 529 | ||
529 | DEBUG(2, "axnet_open('%s')\n", dev->name); | 530 | DEBUG(2, "axnet_open('%s')\n", dev->name); |
530 | 531 | ||
531 | if (!pcmcia_dev_present(link)) | 532 | if (!pcmcia_dev_present(link)) |
532 | return -ENODEV; | 533 | return -ENODEV; |
533 | 534 | ||
535 | outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */ | ||
534 | ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev); | 536 | ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev); |
535 | if (ret) | 537 | if (ret) |
536 | return ret; | 538 | return ret; |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index fd8158a86f64..2d4c4ad89b8d 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -969,6 +969,7 @@ static int pcnet_open(struct net_device *dev) | |||
969 | int ret; | 969 | int ret; |
970 | pcnet_dev_t *info = PRIV(dev); | 970 | pcnet_dev_t *info = PRIV(dev); |
971 | struct pcmcia_device *link = info->p_dev; | 971 | struct pcmcia_device *link = info->p_dev; |
972 | unsigned int nic_base = dev->base_addr; | ||
972 | 973 | ||
973 | DEBUG(2, "pcnet_open('%s')\n", dev->name); | 974 | DEBUG(2, "pcnet_open('%s')\n", dev->name); |
974 | 975 | ||
@@ -976,6 +977,8 @@ static int pcnet_open(struct net_device *dev) | |||
976 | return -ENODEV; | 977 | return -ENODEV; |
977 | 978 | ||
978 | set_misc_reg(dev); | 979 | set_misc_reg(dev); |
980 | |||
981 | outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */ | ||
979 | ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev); | 982 | ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev); |
980 | if (ret) | 983 | if (ret) |
981 | return ret; | 984 | return ret; |
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c index b7f7b2227d56..bccee68bd48a 100644 --- a/drivers/net/qla3xxx.c +++ b/drivers/net/qla3xxx.c | |||
@@ -3701,7 +3701,9 @@ static int ql_cycle_adapter(struct ql3_adapter *qdev, int reset) | |||
3701 | printk(KERN_ERR PFX | 3701 | printk(KERN_ERR PFX |
3702 | "%s: Driver up/down cycle failed, " | 3702 | "%s: Driver up/down cycle failed, " |
3703 | "closing device\n",qdev->ndev->name); | 3703 | "closing device\n",qdev->ndev->name); |
3704 | rtnl_lock(); | ||
3704 | dev_close(qdev->ndev); | 3705 | dev_close(qdev->ndev); |
3706 | rtnl_unlock(); | ||
3705 | return -1; | 3707 | return -1; |
3706 | } | 3708 | } |
3707 | return 0; | 3709 | return 0; |
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c index 858b191517b3..504a48ff73c8 100644 --- a/drivers/net/r6040.c +++ b/drivers/net/r6040.c | |||
@@ -273,7 +273,7 @@ static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring, | |||
273 | dma_addr_t mapping = desc_dma; | 273 | dma_addr_t mapping = desc_dma; |
274 | 274 | ||
275 | while (size-- > 0) { | 275 | while (size-- > 0) { |
276 | mapping += sizeof(sizeof(*desc)); | 276 | mapping += sizeof(*desc); |
277 | desc->ndesc = cpu_to_le32(mapping); | 277 | desc->ndesc = cpu_to_le32(mapping); |
278 | desc->vndescp = desc + 1; | 278 | desc->vndescp = desc + 1; |
279 | desc++; | 279 | desc++; |
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index b5c1e663417d..ae7b697456b4 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -2625,9 +2625,7 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2625 | rxdp1->Buffer0_ptr = pci_map_single | 2625 | rxdp1->Buffer0_ptr = pci_map_single |
2626 | (ring->pdev, skb->data, size - NET_IP_ALIGN, | 2626 | (ring->pdev, skb->data, size - NET_IP_ALIGN, |
2627 | PCI_DMA_FROMDEVICE); | 2627 | PCI_DMA_FROMDEVICE); |
2628 | if( (rxdp1->Buffer0_ptr == 0) || | 2628 | if(pci_dma_mapping_error(rxdp1->Buffer0_ptr)) |
2629 | (rxdp1->Buffer0_ptr == | ||
2630 | DMA_ERROR_CODE)) | ||
2631 | goto pci_map_failed; | 2629 | goto pci_map_failed; |
2632 | 2630 | ||
2633 | rxdp->Control_2 = | 2631 | rxdp->Control_2 = |
@@ -2657,6 +2655,7 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2657 | skb->data = (void *) (unsigned long)tmp; | 2655 | skb->data = (void *) (unsigned long)tmp; |
2658 | skb_reset_tail_pointer(skb); | 2656 | skb_reset_tail_pointer(skb); |
2659 | 2657 | ||
2658 | /* AK: check is wrong. 0 can be valid dma address */ | ||
2660 | if (!(rxdp3->Buffer0_ptr)) | 2659 | if (!(rxdp3->Buffer0_ptr)) |
2661 | rxdp3->Buffer0_ptr = | 2660 | rxdp3->Buffer0_ptr = |
2662 | pci_map_single(ring->pdev, ba->ba_0, | 2661 | pci_map_single(ring->pdev, ba->ba_0, |
@@ -2665,8 +2664,7 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2665 | pci_dma_sync_single_for_device(ring->pdev, | 2664 | pci_dma_sync_single_for_device(ring->pdev, |
2666 | (dma_addr_t) rxdp3->Buffer0_ptr, | 2665 | (dma_addr_t) rxdp3->Buffer0_ptr, |
2667 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 2666 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
2668 | if( (rxdp3->Buffer0_ptr == 0) || | 2667 | if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) |
2669 | (rxdp3->Buffer0_ptr == DMA_ERROR_CODE)) | ||
2670 | goto pci_map_failed; | 2668 | goto pci_map_failed; |
2671 | 2669 | ||
2672 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); | 2670 | rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); |
@@ -2681,18 +2679,17 @@ static int fill_rx_buffers(struct ring_info *ring) | |||
2681 | (ring->pdev, skb->data, ring->mtu + 4, | 2679 | (ring->pdev, skb->data, ring->mtu + 4, |
2682 | PCI_DMA_FROMDEVICE); | 2680 | PCI_DMA_FROMDEVICE); |
2683 | 2681 | ||
2684 | if( (rxdp3->Buffer2_ptr == 0) || | 2682 | if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) |
2685 | (rxdp3->Buffer2_ptr == DMA_ERROR_CODE)) | ||
2686 | goto pci_map_failed; | 2683 | goto pci_map_failed; |
2687 | 2684 | ||
2685 | /* AK: check is wrong */ | ||
2688 | if (!rxdp3->Buffer1_ptr) | 2686 | if (!rxdp3->Buffer1_ptr) |
2689 | rxdp3->Buffer1_ptr = | 2687 | rxdp3->Buffer1_ptr = |
2690 | pci_map_single(ring->pdev, | 2688 | pci_map_single(ring->pdev, |
2691 | ba->ba_1, BUF1_LEN, | 2689 | ba->ba_1, BUF1_LEN, |
2692 | PCI_DMA_FROMDEVICE); | 2690 | PCI_DMA_FROMDEVICE); |
2693 | 2691 | ||
2694 | if( (rxdp3->Buffer1_ptr == 0) || | 2692 | if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) { |
2695 | (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) { | ||
2696 | pci_unmap_single | 2693 | pci_unmap_single |
2697 | (ring->pdev, | 2694 | (ring->pdev, |
2698 | (dma_addr_t)(unsigned long) | 2695 | (dma_addr_t)(unsigned long) |
@@ -4264,16 +4261,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4264 | txdp->Buffer_Pointer = pci_map_single(sp->pdev, | 4261 | txdp->Buffer_Pointer = pci_map_single(sp->pdev, |
4265 | fifo->ufo_in_band_v, | 4262 | fifo->ufo_in_band_v, |
4266 | sizeof(u64), PCI_DMA_TODEVICE); | 4263 | sizeof(u64), PCI_DMA_TODEVICE); |
4267 | if((txdp->Buffer_Pointer == 0) || | 4264 | if (pci_dma_mapping_error(txdp->Buffer_Pointer)) |
4268 | (txdp->Buffer_Pointer == DMA_ERROR_CODE)) | ||
4269 | goto pci_map_failed; | 4265 | goto pci_map_failed; |
4270 | txdp++; | 4266 | txdp++; |
4271 | } | 4267 | } |
4272 | 4268 | ||
4273 | txdp->Buffer_Pointer = pci_map_single | 4269 | txdp->Buffer_Pointer = pci_map_single |
4274 | (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); | 4270 | (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); |
4275 | if((txdp->Buffer_Pointer == 0) || | 4271 | if (pci_dma_mapping_error(txdp->Buffer_Pointer)) |
4276 | (txdp->Buffer_Pointer == DMA_ERROR_CODE)) | ||
4277 | goto pci_map_failed; | 4272 | goto pci_map_failed; |
4278 | 4273 | ||
4279 | txdp->Host_Control = (unsigned long) skb; | 4274 | txdp->Host_Control = (unsigned long) skb; |
@@ -6884,10 +6879,8 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6884 | pci_map_single( sp->pdev, (*skb)->data, | 6879 | pci_map_single( sp->pdev, (*skb)->data, |
6885 | size - NET_IP_ALIGN, | 6880 | size - NET_IP_ALIGN, |
6886 | PCI_DMA_FROMDEVICE); | 6881 | PCI_DMA_FROMDEVICE); |
6887 | if( (rxdp1->Buffer0_ptr == 0) || | 6882 | if (pci_dma_mapping_error(rxdp1->Buffer0_ptr)) |
6888 | (rxdp1->Buffer0_ptr == DMA_ERROR_CODE)) { | ||
6889 | goto memalloc_failed; | 6883 | goto memalloc_failed; |
6890 | } | ||
6891 | rxdp->Host_Control = (unsigned long) (*skb); | 6884 | rxdp->Host_Control = (unsigned long) (*skb); |
6892 | } | 6885 | } |
6893 | } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) { | 6886 | } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) { |
@@ -6913,15 +6906,12 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6913 | pci_map_single(sp->pdev, (*skb)->data, | 6906 | pci_map_single(sp->pdev, (*skb)->data, |
6914 | dev->mtu + 4, | 6907 | dev->mtu + 4, |
6915 | PCI_DMA_FROMDEVICE); | 6908 | PCI_DMA_FROMDEVICE); |
6916 | if( (rxdp3->Buffer2_ptr == 0) || | 6909 | if (pci_dma_mapping_error(rxdp3->Buffer2_ptr)) |
6917 | (rxdp3->Buffer2_ptr == DMA_ERROR_CODE)) { | ||
6918 | goto memalloc_failed; | 6910 | goto memalloc_failed; |
6919 | } | ||
6920 | rxdp3->Buffer0_ptr = *temp0 = | 6911 | rxdp3->Buffer0_ptr = *temp0 = |
6921 | pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN, | 6912 | pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN, |
6922 | PCI_DMA_FROMDEVICE); | 6913 | PCI_DMA_FROMDEVICE); |
6923 | if( (rxdp3->Buffer0_ptr == 0) || | 6914 | if (pci_dma_mapping_error(rxdp3->Buffer0_ptr)) { |
6924 | (rxdp3->Buffer0_ptr == DMA_ERROR_CODE)) { | ||
6925 | pci_unmap_single (sp->pdev, | 6915 | pci_unmap_single (sp->pdev, |
6926 | (dma_addr_t)rxdp3->Buffer2_ptr, | 6916 | (dma_addr_t)rxdp3->Buffer2_ptr, |
6927 | dev->mtu + 4, PCI_DMA_FROMDEVICE); | 6917 | dev->mtu + 4, PCI_DMA_FROMDEVICE); |
@@ -6933,8 +6923,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp, | |||
6933 | rxdp3->Buffer1_ptr = *temp1 = | 6923 | rxdp3->Buffer1_ptr = *temp1 = |
6934 | pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, | 6924 | pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, |
6935 | PCI_DMA_FROMDEVICE); | 6925 | PCI_DMA_FROMDEVICE); |
6936 | if( (rxdp3->Buffer1_ptr == 0) || | 6926 | if (pci_dma_mapping_error(rxdp3->Buffer1_ptr)) { |
6937 | (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) { | ||
6938 | pci_unmap_single (sp->pdev, | 6927 | pci_unmap_single (sp->pdev, |
6939 | (dma_addr_t)rxdp3->Buffer0_ptr, | 6928 | (dma_addr_t)rxdp3->Buffer0_ptr, |
6940 | BUF0_LEN, PCI_DMA_FROMDEVICE); | 6929 | BUF0_LEN, PCI_DMA_FROMDEVICE); |
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index 4706f7f9acb6..1827b6686c98 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h | |||
@@ -75,10 +75,6 @@ static int debug_level = ERR_DBG; | |||
75 | /* DEBUG message print. */ | 75 | /* DEBUG message print. */ |
76 | #define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) | 76 | #define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) |
77 | 77 | ||
78 | #ifndef DMA_ERROR_CODE | ||
79 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) | ||
80 | #endif | ||
81 | |||
82 | /* Protocol assist features of the NIC */ | 78 | /* Protocol assist features of the NIC */ |
83 | #define L3_CKSUM_OK 0xFFFF | 79 | #define L3_CKSUM_OK 0xFFFF |
84 | #define L4_CKSUM_OK 0xFFFF | 80 | #define L4_CKSUM_OK 0xFFFF |
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c index 10e4e85da3fc..b07b8cbadeaf 100644 --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c | |||
@@ -1394,6 +1394,7 @@ tc35815_open(struct net_device *dev) | |||
1394 | tc35815_chip_init(dev); | 1394 | tc35815_chip_init(dev); |
1395 | spin_unlock_irq(&lp->lock); | 1395 | spin_unlock_irq(&lp->lock); |
1396 | 1396 | ||
1397 | netif_carrier_off(dev); | ||
1397 | /* schedule a link state check */ | 1398 | /* schedule a link state check */ |
1398 | phy_start(lp->phy_dev); | 1399 | phy_start(lp->phy_dev); |
1399 | 1400 | ||
@@ -1735,7 +1736,6 @@ tc35815_rx(struct net_device *dev) | |||
1735 | skb = lp->rx_skbs[cur_bd].skb; | 1736 | skb = lp->rx_skbs[cur_bd].skb; |
1736 | prefetch(skb->data); | 1737 | prefetch(skb->data); |
1737 | lp->rx_skbs[cur_bd].skb = NULL; | 1738 | lp->rx_skbs[cur_bd].skb = NULL; |
1738 | lp->fbl_count--; | ||
1739 | pci_unmap_single(lp->pci_dev, | 1739 | pci_unmap_single(lp->pci_dev, |
1740 | lp->rx_skbs[cur_bd].skb_dma, | 1740 | lp->rx_skbs[cur_bd].skb_dma, |
1741 | RX_BUF_SIZE, PCI_DMA_FROMDEVICE); | 1741 | RX_BUF_SIZE, PCI_DMA_FROMDEVICE); |
@@ -1791,6 +1791,7 @@ tc35815_rx(struct net_device *dev) | |||
1791 | #ifdef TC35815_USE_PACKEDBUFFER | 1791 | #ifdef TC35815_USE_PACKEDBUFFER |
1792 | while (lp->fbl_curid != id) | 1792 | while (lp->fbl_curid != id) |
1793 | #else | 1793 | #else |
1794 | lp->fbl_count--; | ||
1794 | while (lp->fbl_count < RX_BUF_NUM) | 1795 | while (lp->fbl_count < RX_BUF_NUM) |
1795 | #endif | 1796 | #endif |
1796 | { | 1797 | { |
@@ -2453,6 +2454,7 @@ static int tc35815_resume(struct pci_dev *pdev) | |||
2453 | return 0; | 2454 | return 0; |
2454 | pci_set_power_state(pdev, PCI_D0); | 2455 | pci_set_power_state(pdev, PCI_D0); |
2455 | tc35815_restart(dev); | 2456 | tc35815_restart(dev); |
2457 | netif_carrier_off(dev); | ||
2456 | if (lp->phy_dev) | 2458 | if (lp->phy_dev) |
2457 | phy_start(lp->phy_dev); | 2459 | phy_start(lp->phy_dev); |
2458 | netif_device_attach(dev); | 2460 | netif_device_attach(dev); |
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index 520bb0b1a9a2..6d35155c7145 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c | |||
@@ -1008,6 +1008,7 @@ static int fr_rx(struct sk_buff *skb) | |||
1008 | stats->rx_bytes += skb->len; | 1008 | stats->rx_bytes += skb->len; |
1009 | if (pvc->state.becn) | 1009 | if (pvc->state.becn) |
1010 | stats->rx_compressed++; | 1010 | stats->rx_compressed++; |
1011 | skb->dev = dev; | ||
1011 | netif_rx(skb); | 1012 | netif_rx(skb); |
1012 | return NET_RX_SUCCESS; | 1013 | return NET_RX_SUCCESS; |
1013 | } else { | 1014 | } else { |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 249e18053d5f..069f8bb0a99f 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/x25.h> | 32 | #include <linux/x25.h> |
33 | #include <linux/lapb.h> | 33 | #include <linux/lapb.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/rtnetlink.h> | ||
35 | #include "x25_asy.h" | 36 | #include "x25_asy.h" |
36 | 37 | ||
37 | #include <net/x25device.h> | 38 | #include <net/x25device.h> |
@@ -601,8 +602,10 @@ static void x25_asy_close_tty(struct tty_struct *tty) | |||
601 | if (!sl || sl->magic != X25_ASY_MAGIC) | 602 | if (!sl || sl->magic != X25_ASY_MAGIC) |
602 | return; | 603 | return; |
603 | 604 | ||
605 | rtnl_lock(); | ||
604 | if (sl->dev->flags & IFF_UP) | 606 | if (sl->dev->flags & IFF_UP) |
605 | dev_close(sl->dev); | 607 | dev_close(sl->dev); |
608 | rtnl_unlock(); | ||
606 | 609 | ||
607 | tty->disc_data = NULL; | 610 | tty->disc_data = NULL; |
608 | sl->tty = NULL; | 611 | sl->tty = NULL; |
diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index 36a9c42df835..76f4c7bad8b8 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c | |||
@@ -72,6 +72,9 @@ static void b43_led_brightness_set(struct led_classdev *led_dev, | |||
72 | struct b43_wldev *dev = led->dev; | 72 | struct b43_wldev *dev = led->dev; |
73 | bool radio_enabled; | 73 | bool radio_enabled; |
74 | 74 | ||
75 | if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) | ||
76 | return; | ||
77 | |||
75 | /* Checking the radio-enabled status here is slightly racy, | 78 | /* Checking the radio-enabled status here is slightly racy, |
76 | * but we want to avoid the locking overhead and we don't care | 79 | * but we want to avoid the locking overhead and we don't care |
77 | * whether the LED has the wrong state for a second. */ | 80 | * whether the LED has the wrong state for a second. */ |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index fa4b0d8b74a2..a70827793086 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -2883,12 +2883,11 @@ static int b43_op_tx(struct ieee80211_hw *hw, | |||
2883 | 2883 | ||
2884 | if (unlikely(skb->len < 2 + 2 + 6)) { | 2884 | if (unlikely(skb->len < 2 + 2 + 6)) { |
2885 | /* Too short, this can't be a valid frame. */ | 2885 | /* Too short, this can't be a valid frame. */ |
2886 | dev_kfree_skb_any(skb); | 2886 | goto drop_packet; |
2887 | return NETDEV_TX_OK; | ||
2888 | } | 2887 | } |
2889 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); | 2888 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); |
2890 | if (unlikely(!dev)) | 2889 | if (unlikely(!dev)) |
2891 | return NETDEV_TX_BUSY; | 2890 | goto drop_packet; |
2892 | 2891 | ||
2893 | /* Transmissions on seperate queues can run concurrently. */ | 2892 | /* Transmissions on seperate queues can run concurrently. */ |
2894 | read_lock_irqsave(&wl->tx_lock, flags); | 2893 | read_lock_irqsave(&wl->tx_lock, flags); |
@@ -2904,7 +2903,12 @@ static int b43_op_tx(struct ieee80211_hw *hw, | |||
2904 | read_unlock_irqrestore(&wl->tx_lock, flags); | 2903 | read_unlock_irqrestore(&wl->tx_lock, flags); |
2905 | 2904 | ||
2906 | if (unlikely(err)) | 2905 | if (unlikely(err)) |
2907 | return NETDEV_TX_BUSY; | 2906 | goto drop_packet; |
2907 | return NETDEV_TX_OK; | ||
2908 | |||
2909 | drop_packet: | ||
2910 | /* We can not transmit this packet. Drop it. */ | ||
2911 | dev_kfree_skb_any(skb); | ||
2908 | return NETDEV_TX_OK; | 2912 | return NETDEV_TX_OK; |
2909 | } | 2913 | } |
2910 | 2914 | ||
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c index c990f87b107a..93ddc1cbcc8b 100644 --- a/drivers/net/wireless/b43legacy/dma.c +++ b/drivers/net/wireless/b43legacy/dma.c | |||
@@ -876,6 +876,7 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev, | |||
876 | if (!ring) | 876 | if (!ring) |
877 | goto out; | 877 | goto out; |
878 | ring->type = type; | 878 | ring->type = type; |
879 | ring->dev = dev; | ||
879 | 880 | ||
880 | nr_slots = B43legacy_RXRING_SLOTS; | 881 | nr_slots = B43legacy_RXRING_SLOTS; |
881 | if (for_tx) | 882 | if (for_tx) |
@@ -922,7 +923,6 @@ struct b43legacy_dmaring *b43legacy_setup_dmaring(struct b43legacy_wldev *dev, | |||
922 | DMA_TO_DEVICE); | 923 | DMA_TO_DEVICE); |
923 | } | 924 | } |
924 | 925 | ||
925 | ring->dev = dev; | ||
926 | ring->nr_slots = nr_slots; | 926 | ring->nr_slots = nr_slots; |
927 | ring->mmio_base = b43legacy_dmacontroller_base(type, controller_index); | 927 | ring->mmio_base = b43legacy_dmacontroller_base(type, controller_index); |
928 | ring->index = controller_index; | 928 | ring->index = controller_index; |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 204077c13870..3e612d0a13e8 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -2378,8 +2378,10 @@ static int b43legacy_op_tx(struct ieee80211_hw *hw, | |||
2378 | } else | 2378 | } else |
2379 | err = b43legacy_dma_tx(dev, skb, ctl); | 2379 | err = b43legacy_dma_tx(dev, skb, ctl); |
2380 | out: | 2380 | out: |
2381 | if (unlikely(err)) | 2381 | if (unlikely(err)) { |
2382 | return NETDEV_TX_BUSY; | 2382 | /* Drop the packet. */ |
2383 | dev_kfree_skb_any(skb); | ||
2384 | } | ||
2383 | return NETDEV_TX_OK; | 2385 | return NETDEV_TX_OK; |
2384 | } | 2386 | } |
2385 | 2387 | ||
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c index 4fd73809602e..020f450e9dba 100644 --- a/drivers/net/wireless/hostap/hostap_80211_rx.c +++ b/drivers/net/wireless/hostap/hostap_80211_rx.c | |||
@@ -64,7 +64,7 @@ int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb, | |||
64 | int hdrlen, phdrlen, head_need, tail_need; | 64 | int hdrlen, phdrlen, head_need, tail_need; |
65 | u16 fc; | 65 | u16 fc; |
66 | int prism_header, ret; | 66 | int prism_header, ret; |
67 | struct ieee80211_hdr_4addr *hdr; | 67 | struct ieee80211_hdr_4addr *fhdr; |
68 | 68 | ||
69 | iface = netdev_priv(dev); | 69 | iface = netdev_priv(dev); |
70 | local = iface->local; | 70 | local = iface->local; |
@@ -83,8 +83,8 @@ int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb, | |||
83 | phdrlen = 0; | 83 | phdrlen = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | hdr = (struct ieee80211_hdr_4addr *) skb->data; | 86 | fhdr = (struct ieee80211_hdr_4addr *) skb->data; |
87 | fc = le16_to_cpu(hdr->frame_ctl); | 87 | fc = le16_to_cpu(fhdr->frame_ctl); |
88 | 88 | ||
89 | if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) { | 89 | if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) { |
90 | printk(KERN_DEBUG "%s: dropped management frame with header " | 90 | printk(KERN_DEBUG "%s: dropped management frame with header " |
@@ -551,7 +551,7 @@ hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr, | |||
551 | hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff || | 551 | hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff || |
552 | hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) { | 552 | hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) { |
553 | /* RA (or BSSID) is not ours - drop */ | 553 | /* RA (or BSSID) is not ours - drop */ |
554 | PDEBUG(DEBUG_EXTRA, "%s: received WDS frame with " | 554 | PDEBUG(DEBUG_EXTRA2, "%s: received WDS frame with " |
555 | "not own or broadcast %s=%s\n", | 555 | "not own or broadcast %s=%s\n", |
556 | local->dev->name, | 556 | local->dev->name, |
557 | fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID", | 557 | fc & IEEE80211_FCTL_FROMDS ? "RA" : "BSSID", |
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index 0acd9589c48c..ab981afd481d 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c | |||
@@ -1930,7 +1930,7 @@ static void handle_pspoll(local_info_t *local, | |||
1930 | PDEBUG(DEBUG_PS, " PSPOLL and AID[15:14] not set\n"); | 1930 | PDEBUG(DEBUG_PS, " PSPOLL and AID[15:14] not set\n"); |
1931 | return; | 1931 | return; |
1932 | } | 1932 | } |
1933 | aid &= ~BIT(15) & ~BIT(14); | 1933 | aid &= ~(BIT(15) | BIT(14)); |
1934 | if (aid == 0 || aid > MAX_AID_TABLE_SIZE) { | 1934 | if (aid == 0 || aid > MAX_AID_TABLE_SIZE) { |
1935 | PDEBUG(DEBUG_PS, " invalid aid=%d\n", aid); | 1935 | PDEBUG(DEBUG_PS, " invalid aid=%d\n", aid); |
1936 | return; | 1936 | return; |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index ed4317a17cbb..80039a0ae027 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -533,10 +533,10 @@ static void prism2_detach(struct pcmcia_device *link) | |||
533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
534 | 534 | ||
535 | #define CFG_CHECK2(fn, retf) \ | 535 | #define CFG_CHECK2(fn, retf) \ |
536 | do { int ret = (retf); \ | 536 | do { int _ret = (retf); \ |
537 | if (ret != 0) { \ | 537 | if (_ret != 0) { \ |
538 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \ | 538 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", _ret); \ |
539 | cs_error(link, fn, ret); \ | 539 | cs_error(link, fn, _ret); \ |
540 | goto next_entry; \ | 540 | goto next_entry; \ |
541 | } \ | 541 | } \ |
542 | } while (0) | 542 | } while (0) |
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index cdf90c40f11b..936f52e3d95c 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c | |||
@@ -2835,7 +2835,7 @@ static void hostap_passive_scan(unsigned long data) | |||
2835 | { | 2835 | { |
2836 | local_info_t *local = (local_info_t *) data; | 2836 | local_info_t *local = (local_info_t *) data; |
2837 | struct net_device *dev = local->dev; | 2837 | struct net_device *dev = local->dev; |
2838 | u16 channel; | 2838 | u16 chan; |
2839 | 2839 | ||
2840 | if (local->passive_scan_interval <= 0) | 2840 | if (local->passive_scan_interval <= 0) |
2841 | return; | 2841 | return; |
@@ -2872,11 +2872,11 @@ static void hostap_passive_scan(unsigned long data) | |||
2872 | 2872 | ||
2873 | printk(KERN_DEBUG "%s: passive scan channel %d\n", | 2873 | printk(KERN_DEBUG "%s: passive scan channel %d\n", |
2874 | dev->name, local->passive_scan_channel); | 2874 | dev->name, local->passive_scan_channel); |
2875 | channel = local->passive_scan_channel; | 2875 | chan = local->passive_scan_channel; |
2876 | local->passive_scan_state = PASSIVE_SCAN_WAIT; | 2876 | local->passive_scan_state = PASSIVE_SCAN_WAIT; |
2877 | local->passive_scan_timer.expires = jiffies + HZ / 10; | 2877 | local->passive_scan_timer.expires = jiffies + HZ / 10; |
2878 | } else { | 2878 | } else { |
2879 | channel = local->channel; | 2879 | chan = local->channel; |
2880 | local->passive_scan_state = PASSIVE_SCAN_LISTEN; | 2880 | local->passive_scan_state = PASSIVE_SCAN_LISTEN; |
2881 | local->passive_scan_timer.expires = jiffies + | 2881 | local->passive_scan_timer.expires = jiffies + |
2882 | local->passive_scan_interval * HZ; | 2882 | local->passive_scan_interval * HZ; |
@@ -2884,9 +2884,9 @@ static void hostap_passive_scan(unsigned long data) | |||
2884 | 2884 | ||
2885 | if (hfa384x_cmd_callback(dev, HFA384X_CMDCODE_TEST | | 2885 | if (hfa384x_cmd_callback(dev, HFA384X_CMDCODE_TEST | |
2886 | (HFA384X_TEST_CHANGE_CHANNEL << 8), | 2886 | (HFA384X_TEST_CHANGE_CHANNEL << 8), |
2887 | channel, NULL, 0)) | 2887 | chan, NULL, 0)) |
2888 | printk(KERN_ERR "%s: passive scan channel set %d " | 2888 | printk(KERN_ERR "%s: passive scan channel set %d " |
2889 | "failed\n", dev->name, channel); | 2889 | "failed\n", dev->name, chan); |
2890 | 2890 | ||
2891 | add_timer(&local->passive_scan_timer); | 2891 | add_timer(&local->passive_scan_timer); |
2892 | } | 2892 | } |
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c index f7aec9309d04..a38e85f334df 100644 --- a/drivers/net/wireless/hostap/hostap_main.c +++ b/drivers/net/wireless/hostap/hostap_main.c | |||
@@ -594,7 +594,8 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx) | |||
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | int hostap_80211_header_parse(const struct sk_buff *skb, unsigned char *haddr) | 597 | static int hostap_80211_header_parse(const struct sk_buff *skb, |
598 | unsigned char *haddr) | ||
598 | { | 599 | { |
599 | struct hostap_interface *iface = netdev_priv(skb->dev); | 600 | struct hostap_interface *iface = netdev_priv(skb->dev); |
600 | local_info_t *local = iface->local; | 601 | local_info_t *local = iface->local; |
@@ -857,7 +858,6 @@ const struct header_ops hostap_80211_ops = { | |||
857 | .rebuild = eth_rebuild_header, | 858 | .rebuild = eth_rebuild_header, |
858 | .cache = eth_header_cache, | 859 | .cache = eth_header_cache, |
859 | .cache_update = eth_header_cache_update, | 860 | .cache_update = eth_header_cache_update, |
860 | |||
861 | .parse = hostap_80211_header_parse, | 861 | .parse = hostap_80211_header_parse, |
862 | }; | 862 | }; |
863 | EXPORT_SYMBOL(hostap_80211_ops); | 863 | EXPORT_SYMBOL(hostap_80211_ops); |
@@ -1150,7 +1150,6 @@ EXPORT_SYMBOL(hostap_set_roaming); | |||
1150 | EXPORT_SYMBOL(hostap_set_auth_algs); | 1150 | EXPORT_SYMBOL(hostap_set_auth_algs); |
1151 | EXPORT_SYMBOL(hostap_dump_rx_header); | 1151 | EXPORT_SYMBOL(hostap_dump_rx_header); |
1152 | EXPORT_SYMBOL(hostap_dump_tx_header); | 1152 | EXPORT_SYMBOL(hostap_dump_tx_header); |
1153 | EXPORT_SYMBOL(hostap_80211_header_parse); | ||
1154 | EXPORT_SYMBOL(hostap_80211_get_hdrlen); | 1153 | EXPORT_SYMBOL(hostap_80211_get_hdrlen); |
1155 | EXPORT_SYMBOL(hostap_get_stats); | 1154 | EXPORT_SYMBOL(hostap_get_stats); |
1156 | EXPORT_SYMBOL(hostap_setup_dev); | 1155 | EXPORT_SYMBOL(hostap_setup_dev); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index 62a3d8f8563e..f5387a7a76c0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -588,8 +588,12 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv, | |||
588 | 588 | ||
589 | if (rate == -1) | 589 | if (rate == -1) |
590 | iwl3945_rt->rt_rate = 0; | 590 | iwl3945_rt->rt_rate = 0; |
591 | else | 591 | else { |
592 | if (stats->band == IEEE80211_BAND_5GHZ) | ||
593 | rate += IWL_FIRST_OFDM_RATE; | ||
594 | |||
592 | iwl3945_rt->rt_rate = iwl3945_rates[rate].ieee; | 595 | iwl3945_rt->rt_rate = iwl3945_rates[rate].ieee; |
596 | } | ||
593 | 597 | ||
594 | /* antenna number */ | 598 | /* antenna number */ |
595 | antenna = phy_flags_hw & RX_RES_PHY_FLAGS_ANTENNA_MSK; | 599 | antenna = phy_flags_hw & RX_RES_PHY_FLAGS_ANTENNA_MSK; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index bf19eb8aafd0..de330ae0ca95 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -3528,8 +3528,12 @@ static void iwl4965_add_radiotap(struct iwl_priv *priv, | |||
3528 | 3528 | ||
3529 | if (rate == -1) | 3529 | if (rate == -1) |
3530 | iwl4965_rt->rt_rate = 0; | 3530 | iwl4965_rt->rt_rate = 0; |
3531 | else | 3531 | else { |
3532 | if (stats->band == IEEE80211_BAND_5GHZ) | ||
3533 | rate += IWL_FIRST_OFDM_RATE; | ||
3534 | |||
3532 | iwl4965_rt->rt_rate = iwl4965_rates[rate].ieee; | 3535 | iwl4965_rt->rt_rate = iwl4965_rates[rate].ieee; |
3536 | } | ||
3533 | 3537 | ||
3534 | /* | 3538 | /* |
3535 | * "antenna number" | 3539 | * "antenna number" |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 13925b627e3b..6027e1119c3f 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -2227,7 +2227,10 @@ static int iwl3945_scan_initiate(struct iwl3945_priv *priv) | |||
2227 | } | 2227 | } |
2228 | 2228 | ||
2229 | IWL_DEBUG_INFO("Starting scan...\n"); | 2229 | IWL_DEBUG_INFO("Starting scan...\n"); |
2230 | priv->scan_bands = 2; | 2230 | if (priv->cfg->sku & IWL_SKU_G) |
2231 | priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); | ||
2232 | if (priv->cfg->sku & IWL_SKU_A) | ||
2233 | priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ); | ||
2231 | set_bit(STATUS_SCANNING, &priv->status); | 2234 | set_bit(STATUS_SCANNING, &priv->status); |
2232 | priv->scan_start = jiffies; | 2235 | priv->scan_start = jiffies; |
2233 | priv->scan_pass_start = priv->scan_start; | 2236 | priv->scan_pass_start = priv->scan_start; |
@@ -3352,13 +3355,18 @@ static void iwl3945_rx_scan_complete_notif(struct iwl3945_priv *priv, | |||
3352 | cancel_delayed_work(&priv->scan_check); | 3355 | cancel_delayed_work(&priv->scan_check); |
3353 | 3356 | ||
3354 | IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", | 3357 | IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", |
3355 | (priv->scan_bands == 2) ? "2.4" : "5.2", | 3358 | (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? |
3359 | "2.4" : "5.2", | ||
3356 | jiffies_to_msecs(elapsed_jiffies | 3360 | jiffies_to_msecs(elapsed_jiffies |
3357 | (priv->scan_pass_start, jiffies))); | 3361 | (priv->scan_pass_start, jiffies))); |
3358 | 3362 | ||
3359 | /* Remove this scanned band from the list | 3363 | /* Remove this scanned band from the list of pending |
3360 | * of pending bands to scan */ | 3364 | * bands to scan, band G precedes A in order of scanning |
3361 | priv->scan_bands--; | 3365 | * as seen in iwl3945_bg_request_scan */ |
3366 | if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) | ||
3367 | priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ); | ||
3368 | else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) | ||
3369 | priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ); | ||
3362 | 3370 | ||
3363 | /* If a request to abort was given, or the scan did not succeed | 3371 | /* If a request to abort was given, or the scan did not succeed |
3364 | * then we reset the scan state machine and terminate, | 3372 | * then we reset the scan state machine and terminate, |
@@ -4972,7 +4980,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv, | |||
4972 | 4980 | ||
4973 | ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); | 4981 | ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); |
4974 | if (!is_channel_valid(ch_info)) { | 4982 | if (!is_channel_valid(ch_info)) { |
4975 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", | 4983 | IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", |
4976 | scan_ch->channel); | 4984 | scan_ch->channel); |
4977 | continue; | 4985 | continue; |
4978 | } | 4986 | } |
@@ -6315,21 +6323,16 @@ static void iwl3945_bg_request_scan(struct work_struct *data) | |||
6315 | 6323 | ||
6316 | /* flags + rate selection */ | 6324 | /* flags + rate selection */ |
6317 | 6325 | ||
6318 | switch (priv->scan_bands) { | 6326 | if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) { |
6319 | case 2: | ||
6320 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; | 6327 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; |
6321 | scan->tx_cmd.rate = IWL_RATE_1M_PLCP; | 6328 | scan->tx_cmd.rate = IWL_RATE_1M_PLCP; |
6322 | scan->good_CRC_th = 0; | 6329 | scan->good_CRC_th = 0; |
6323 | band = IEEE80211_BAND_2GHZ; | 6330 | band = IEEE80211_BAND_2GHZ; |
6324 | break; | 6331 | } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { |
6325 | |||
6326 | case 1: | ||
6327 | scan->tx_cmd.rate = IWL_RATE_6M_PLCP; | 6332 | scan->tx_cmd.rate = IWL_RATE_6M_PLCP; |
6328 | scan->good_CRC_th = IWL_GOOD_CRC_TH; | 6333 | scan->good_CRC_th = IWL_GOOD_CRC_TH; |
6329 | band = IEEE80211_BAND_5GHZ; | 6334 | band = IEEE80211_BAND_5GHZ; |
6330 | break; | 6335 | } else { |
6331 | |||
6332 | default: | ||
6333 | IWL_WARNING("Invalid scan band count\n"); | 6336 | IWL_WARNING("Invalid scan band count\n"); |
6334 | goto done; | 6337 | goto done; |
6335 | } | 6338 | } |
@@ -6684,7 +6687,8 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
6684 | 6687 | ||
6685 | if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { | 6688 | if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { |
6686 | IWL_DEBUG_MAC80211("leave - monitor\n"); | 6689 | IWL_DEBUG_MAC80211("leave - monitor\n"); |
6687 | return -1; | 6690 | dev_kfree_skb_any(skb); |
6691 | return 0; | ||
6688 | } | 6692 | } |
6689 | 6693 | ||
6690 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 6694 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
@@ -6770,7 +6774,7 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *co | |||
6770 | ch_info = iwl3945_get_channel_info(priv, conf->channel->band, | 6774 | ch_info = iwl3945_get_channel_info(priv, conf->channel->band, |
6771 | conf->channel->hw_value); | 6775 | conf->channel->hw_value); |
6772 | if (!is_channel_valid(ch_info)) { | 6776 | if (!is_channel_valid(ch_info)) { |
6773 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this SKU.\n", | 6777 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this band.\n", |
6774 | conf->channel->hw_value, conf->channel->band); | 6778 | conf->channel->hw_value, conf->channel->band); |
6775 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); | 6779 | IWL_DEBUG_MAC80211("leave - invalid channel\n"); |
6776 | spin_unlock_irqrestore(&priv->lock, flags); | 6780 | spin_unlock_irqrestore(&priv->lock, flags); |
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 883b42f7e998..0bd55bb19739 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -1774,7 +1774,10 @@ static int iwl4965_scan_initiate(struct iwl_priv *priv) | |||
1774 | } | 1774 | } |
1775 | 1775 | ||
1776 | IWL_DEBUG_INFO("Starting scan...\n"); | 1776 | IWL_DEBUG_INFO("Starting scan...\n"); |
1777 | priv->scan_bands = 2; | 1777 | if (priv->cfg->sku & IWL_SKU_G) |
1778 | priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); | ||
1779 | if (priv->cfg->sku & IWL_SKU_A) | ||
1780 | priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ); | ||
1778 | set_bit(STATUS_SCANNING, &priv->status); | 1781 | set_bit(STATUS_SCANNING, &priv->status); |
1779 | priv->scan_start = jiffies; | 1782 | priv->scan_start = jiffies; |
1780 | priv->scan_pass_start = priv->scan_start; | 1783 | priv->scan_pass_start = priv->scan_start; |
@@ -3023,8 +3026,9 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, | |||
3023 | 3026 | ||
3024 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); | 3027 | IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); |
3025 | if (index != -1) { | 3028 | if (index != -1) { |
3026 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
3027 | #ifdef CONFIG_IWL4965_HT | 3029 | #ifdef CONFIG_IWL4965_HT |
3030 | int freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); | ||
3031 | |||
3028 | if (tid != MAX_TID_COUNT) | 3032 | if (tid != MAX_TID_COUNT) |
3029 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; | 3033 | priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; |
3030 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && | 3034 | if (iwl4965_queue_space(&txq->q) > txq->q.low_mark && |
@@ -3276,13 +3280,18 @@ static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, | |||
3276 | cancel_delayed_work(&priv->scan_check); | 3280 | cancel_delayed_work(&priv->scan_check); |
3277 | 3281 | ||
3278 | IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", | 3282 | IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", |
3279 | (priv->scan_bands == 2) ? "2.4" : "5.2", | 3283 | (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? |
3284 | "2.4" : "5.2", | ||
3280 | jiffies_to_msecs(elapsed_jiffies | 3285 | jiffies_to_msecs(elapsed_jiffies |
3281 | (priv->scan_pass_start, jiffies))); | 3286 | (priv->scan_pass_start, jiffies))); |
3282 | 3287 | ||
3283 | /* Remove this scanned band from the list | 3288 | /* Remove this scanned band from the list of pending |
3284 | * of pending bands to scan */ | 3289 | * bands to scan, band G precedes A in order of scanning |
3285 | priv->scan_bands--; | 3290 | * as seen in iwl_bg_request_scan */ |
3291 | if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) | ||
3292 | priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ); | ||
3293 | else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) | ||
3294 | priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ); | ||
3286 | 3295 | ||
3287 | /* If a request to abort was given, or the scan did not succeed | 3296 | /* If a request to abort was given, or the scan did not succeed |
3288 | * then we reset the scan state machine and terminate, | 3297 | * then we reset the scan state machine and terminate, |
@@ -3292,7 +3301,7 @@ static void iwl4965_rx_scan_complete_notif(struct iwl_priv *priv, | |||
3292 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); | 3301 | clear_bit(STATUS_SCAN_ABORTING, &priv->status); |
3293 | } else { | 3302 | } else { |
3294 | /* If there are more bands on this scan pass reschedule */ | 3303 | /* If there are more bands on this scan pass reschedule */ |
3295 | if (priv->scan_bands > 0) | 3304 | if (priv->scan_bands) |
3296 | goto reschedule; | 3305 | goto reschedule; |
3297 | } | 3306 | } |
3298 | 3307 | ||
@@ -4635,10 +4644,9 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, | |||
4635 | 4644 | ||
4636 | scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); | 4645 | scan_ch->channel = ieee80211_frequency_to_channel(channels[i].center_freq); |
4637 | 4646 | ||
4638 | ch_info = iwl_get_channel_info(priv, band, | 4647 | ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); |
4639 | scan_ch->channel); | ||
4640 | if (!is_channel_valid(ch_info)) { | 4648 | if (!is_channel_valid(ch_info)) { |
4641 | IWL_DEBUG_SCAN("Channel %d is INVALID for this SKU.\n", | 4649 | IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", |
4642 | scan_ch->channel); | 4650 | scan_ch->channel); |
4643 | continue; | 4651 | continue; |
4644 | } | 4652 | } |
@@ -5830,8 +5838,7 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
5830 | scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; | 5838 | scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
5831 | 5839 | ||
5832 | 5840 | ||
5833 | switch (priv->scan_bands) { | 5841 | if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) { |
5834 | case 2: | ||
5835 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; | 5842 | scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; |
5836 | scan->tx_cmd.rate_n_flags = | 5843 | scan->tx_cmd.rate_n_flags = |
5837 | iwl4965_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, | 5844 | iwl4965_hw_set_rate_n_flags(IWL_RATE_1M_PLCP, |
@@ -5839,17 +5846,13 @@ static void iwl4965_bg_request_scan(struct work_struct *data) | |||
5839 | 5846 | ||
5840 | scan->good_CRC_th = 0; | 5847 | scan->good_CRC_th = 0; |
5841 | band = IEEE80211_BAND_2GHZ; | 5848 | band = IEEE80211_BAND_2GHZ; |
5842 | break; | 5849 | } else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) { |
5843 | |||
5844 | case 1: | ||
5845 | scan->tx_cmd.rate_n_flags = | 5850 | scan->tx_cmd.rate_n_flags = |
5846 | iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, | 5851 | iwl4965_hw_set_rate_n_flags(IWL_RATE_6M_PLCP, |
5847 | RATE_MCS_ANT_B_MSK); | 5852 | RATE_MCS_ANT_B_MSK); |
5848 | scan->good_CRC_th = IWL_GOOD_CRC_TH; | 5853 | scan->good_CRC_th = IWL_GOOD_CRC_TH; |
5849 | band = IEEE80211_BAND_5GHZ; | 5854 | band = IEEE80211_BAND_5GHZ; |
5850 | break; | 5855 | } else { |
5851 | |||
5852 | default: | ||
5853 | IWL_WARNING("Invalid scan band count\n"); | 5856 | IWL_WARNING("Invalid scan band count\n"); |
5854 | goto done; | 5857 | goto done; |
5855 | } | 5858 | } |
@@ -6234,7 +6237,8 @@ static int iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
6234 | 6237 | ||
6235 | if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { | 6238 | if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { |
6236 | IWL_DEBUG_MAC80211("leave - monitor\n"); | 6239 | IWL_DEBUG_MAC80211("leave - monitor\n"); |
6237 | return -1; | 6240 | dev_kfree_skb_any(skb); |
6241 | return 0; | ||
6238 | } | 6242 | } |
6239 | 6243 | ||
6240 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, | 6244 | IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 8032df72aaab..36288b29abf7 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -925,6 +925,7 @@ static struct usb_driver if_usb_driver = { | |||
925 | .id_table = if_usb_table, | 925 | .id_table = if_usb_table, |
926 | .suspend = if_usb_suspend, | 926 | .suspend = if_usb_suspend, |
927 | .resume = if_usb_resume, | 927 | .resume = if_usb_resume, |
928 | .reset_resume = if_usb_resume, | ||
928 | }; | 929 | }; |
929 | 930 | ||
930 | static int __init if_usb_init_module(void) | 931 | static int __init if_usb_init_module(void) |
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c index 762e85bef55d..e43bae97ed8f 100644 --- a/drivers/net/wireless/prism54/islpci_eth.c +++ b/drivers/net/wireless/prism54/islpci_eth.c | |||
@@ -290,7 +290,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb) | |||
290 | 290 | ||
291 | avs->version = cpu_to_be32(P80211CAPTURE_VERSION); | 291 | avs->version = cpu_to_be32(P80211CAPTURE_VERSION); |
292 | avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header)); | 292 | avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header)); |
293 | avs->mactime = cpu_to_be64(le64_to_cpu(clock)); | 293 | avs->mactime = cpu_to_be64(clock); |
294 | avs->hosttime = cpu_to_be64(jiffies); | 294 | avs->hosttime = cpu_to_be64(jiffies); |
295 | avs->phytype = cpu_to_be32(6); /*OFDM: 6 for (g), 8 for (a) */ | 295 | avs->phytype = cpu_to_be32(6); /*OFDM: 6 for (g), 8 for (a) */ |
296 | avs->channel = cpu_to_be32(channel_of_freq(freq)); | 296 | avs->channel = cpu_to_be32(channel_of_freq(freq)); |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index fdbd0ef2be4b..61e59c17a60a 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -138,11 +138,8 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
138 | * Wait until the BBP becomes ready. | 138 | * Wait until the BBP becomes ready. |
139 | */ | 139 | */ |
140 | reg = rt2500usb_bbp_check(rt2x00dev); | 140 | reg = rt2500usb_bbp_check(rt2x00dev); |
141 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { | 141 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) |
142 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n"); | 142 | goto exit_fail; |
143 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
144 | return; | ||
145 | } | ||
146 | 143 | ||
147 | /* | 144 | /* |
148 | * Write the data into the BBP. | 145 | * Write the data into the BBP. |
@@ -155,6 +152,13 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
155 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg); | 152 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg); |
156 | 153 | ||
157 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 154 | mutex_unlock(&rt2x00dev->usb_cache_mutex); |
155 | |||
156 | return; | ||
157 | |||
158 | exit_fail: | ||
159 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
160 | |||
161 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n"); | ||
158 | } | 162 | } |
159 | 163 | ||
160 | static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, | 164 | static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, |
@@ -168,10 +172,8 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
168 | * Wait until the BBP becomes ready. | 172 | * Wait until the BBP becomes ready. |
169 | */ | 173 | */ |
170 | reg = rt2500usb_bbp_check(rt2x00dev); | 174 | reg = rt2500usb_bbp_check(rt2x00dev); |
171 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { | 175 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) |
172 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); | 176 | goto exit_fail; |
173 | return; | ||
174 | } | ||
175 | 177 | ||
176 | /* | 178 | /* |
177 | * Write the request into the BBP. | 179 | * Write the request into the BBP. |
@@ -186,17 +188,21 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
186 | * Wait until the BBP becomes ready. | 188 | * Wait until the BBP becomes ready. |
187 | */ | 189 | */ |
188 | reg = rt2500usb_bbp_check(rt2x00dev); | 190 | reg = rt2500usb_bbp_check(rt2x00dev); |
189 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) { | 191 | if (rt2x00_get_field16(reg, PHY_CSR8_BUSY)) |
190 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); | 192 | goto exit_fail; |
191 | *value = 0xff; | ||
192 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
193 | return; | ||
194 | } | ||
195 | 193 | ||
196 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, ®); | 194 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, ®); |
197 | *value = rt2x00_get_field16(reg, PHY_CSR7_DATA); | 195 | *value = rt2x00_get_field16(reg, PHY_CSR7_DATA); |
198 | 196 | ||
199 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 197 | mutex_unlock(&rt2x00dev->usb_cache_mutex); |
198 | |||
199 | return; | ||
200 | |||
201 | exit_fail: | ||
202 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
203 | |||
204 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); | ||
205 | *value = 0xff; | ||
200 | } | 206 | } |
201 | 207 | ||
202 | static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev, | 208 | static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev, |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 611d98320593..b4bf1e09cf9a 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -821,6 +821,7 @@ struct rt2x00_dev { | |||
821 | /* | 821 | /* |
822 | * Scheduled work. | 822 | * Scheduled work. |
823 | */ | 823 | */ |
824 | struct workqueue_struct *workqueue; | ||
824 | struct work_struct intf_work; | 825 | struct work_struct intf_work; |
825 | struct work_struct filter_work; | 826 | struct work_struct filter_work; |
826 | 827 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 2673d568bcac..c997d4f28ab3 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -75,7 +75,7 @@ static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
75 | 75 | ||
76 | rt2x00lib_reset_link_tuner(rt2x00dev); | 76 | rt2x00lib_reset_link_tuner(rt2x00dev); |
77 | 77 | ||
78 | queue_delayed_work(rt2x00dev->hw->workqueue, | 78 | queue_delayed_work(rt2x00dev->workqueue, |
79 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); | 79 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); |
80 | } | 80 | } |
81 | 81 | ||
@@ -137,14 +137,6 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
137 | return; | 137 | return; |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * Stop all scheduled work. | ||
141 | */ | ||
142 | if (work_pending(&rt2x00dev->intf_work)) | ||
143 | cancel_work_sync(&rt2x00dev->intf_work); | ||
144 | if (work_pending(&rt2x00dev->filter_work)) | ||
145 | cancel_work_sync(&rt2x00dev->filter_work); | ||
146 | |||
147 | /* | ||
148 | * Stop the TX queues. | 140 | * Stop the TX queues. |
149 | */ | 141 | */ |
150 | ieee80211_stop_queues(rt2x00dev->hw); | 142 | ieee80211_stop_queues(rt2x00dev->hw); |
@@ -398,8 +390,8 @@ static void rt2x00lib_link_tuner(struct work_struct *work) | |||
398 | * Increase tuner counter, and reschedule the next link tuner run. | 390 | * Increase tuner counter, and reschedule the next link tuner run. |
399 | */ | 391 | */ |
400 | rt2x00dev->link.count++; | 392 | rt2x00dev->link.count++; |
401 | queue_delayed_work(rt2x00dev->hw->workqueue, &rt2x00dev->link.work, | 393 | queue_delayed_work(rt2x00dev->workqueue, |
402 | LINK_TUNE_INTERVAL); | 394 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); |
403 | } | 395 | } |
404 | 396 | ||
405 | static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) | 397 | static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) |
@@ -433,6 +425,15 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, | |||
433 | 425 | ||
434 | spin_unlock(&intf->lock); | 426 | spin_unlock(&intf->lock); |
435 | 427 | ||
428 | /* | ||
429 | * It is possible the radio was disabled while the work had been | ||
430 | * scheduled. If that happens we should return here immediately, | ||
431 | * note that in the spinlock protected area above the delayed_flags | ||
432 | * have been cleared correctly. | ||
433 | */ | ||
434 | if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) | ||
435 | return; | ||
436 | |||
436 | if (delayed_flags & DELAYED_UPDATE_BEACON) { | 437 | if (delayed_flags & DELAYED_UPDATE_BEACON) { |
437 | skb = ieee80211_beacon_get(rt2x00dev->hw, vif, &control); | 438 | skb = ieee80211_beacon_get(rt2x00dev->hw, vif, &control); |
438 | if (skb && rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, | 439 | if (skb && rt2x00dev->ops->hw->beacon_update(rt2x00dev->hw, |
@@ -441,7 +442,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac, | |||
441 | } | 442 | } |
442 | 443 | ||
443 | if (delayed_flags & DELAYED_CONFIG_ERP) | 444 | if (delayed_flags & DELAYED_CONFIG_ERP) |
444 | rt2x00lib_config_erp(rt2x00dev, intf, &intf->conf); | 445 | rt2x00lib_config_erp(rt2x00dev, intf, &conf); |
445 | 446 | ||
446 | if (delayed_flags & DELAYED_LED_ASSOC) | 447 | if (delayed_flags & DELAYED_LED_ASSOC) |
447 | rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); | 448 | rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); |
@@ -487,7 +488,7 @@ void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev) | |||
487 | rt2x00lib_beacondone_iter, | 488 | rt2x00lib_beacondone_iter, |
488 | rt2x00dev); | 489 | rt2x00dev); |
489 | 490 | ||
490 | queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); | 491 | queue_work(rt2x00dev->workqueue, &rt2x00dev->intf_work); |
491 | } | 492 | } |
492 | EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); | 493 | EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); |
493 | 494 | ||
@@ -1130,6 +1131,10 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
1130 | /* | 1131 | /* |
1131 | * Initialize configuration work. | 1132 | * Initialize configuration work. |
1132 | */ | 1133 | */ |
1134 | rt2x00dev->workqueue = create_singlethread_workqueue("rt2x00lib"); | ||
1135 | if (!rt2x00dev->workqueue) | ||
1136 | goto exit; | ||
1137 | |||
1133 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); | 1138 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); |
1134 | INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); | 1139 | INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); |
1135 | INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); | 1140 | INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); |
@@ -1190,6 +1195,13 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) | |||
1190 | rt2x00leds_unregister(rt2x00dev); | 1195 | rt2x00leds_unregister(rt2x00dev); |
1191 | 1196 | ||
1192 | /* | 1197 | /* |
1198 | * Stop all queued work. Note that most tasks will already be halted | ||
1199 | * during rt2x00lib_disable_radio() and rt2x00lib_uninitialize(). | ||
1200 | */ | ||
1201 | flush_workqueue(rt2x00dev->workqueue); | ||
1202 | destroy_workqueue(rt2x00dev->workqueue); | ||
1203 | |||
1204 | /* | ||
1193 | * Free ieee80211_hw memory. | 1205 | * Free ieee80211_hw memory. |
1194 | */ | 1206 | */ |
1195 | rt2x00lib_remove_hw(rt2x00dev); | 1207 | rt2x00lib_remove_hw(rt2x00dev); |
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index 87e280a21971..9cb023edd2e9 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c | |||
@@ -428,7 +428,7 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw, | |||
428 | if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags)) | 428 | if (!test_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags)) |
429 | rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags); | 429 | rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags); |
430 | else | 430 | else |
431 | queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->filter_work); | 431 | queue_work(rt2x00dev->workqueue, &rt2x00dev->filter_work); |
432 | } | 432 | } |
433 | EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter); | 433 | EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter); |
434 | 434 | ||
@@ -509,7 +509,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, | |||
509 | memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); | 509 | memcpy(&intf->conf, bss_conf, sizeof(*bss_conf)); |
510 | if (delayed) { | 510 | if (delayed) { |
511 | intf->delayed_flags |= delayed; | 511 | intf->delayed_flags |= delayed; |
512 | queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work); | 512 | queue_work(rt2x00dev->workqueue, &rt2x00dev->intf_work); |
513 | } | 513 | } |
514 | spin_unlock(&intf->lock); | 514 | spin_unlock(&intf->lock); |
515 | } | 515 | } |
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index fff8386e816b..83cc0147f698 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -134,11 +134,8 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
134 | * Wait until the BBP becomes ready. | 134 | * Wait until the BBP becomes ready. |
135 | */ | 135 | */ |
136 | reg = rt73usb_bbp_check(rt2x00dev); | 136 | reg = rt73usb_bbp_check(rt2x00dev); |
137 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 137 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
138 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); | 138 | goto exit_fail; |
139 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
140 | return; | ||
141 | } | ||
142 | 139 | ||
143 | /* | 140 | /* |
144 | * Write the data into the BBP. | 141 | * Write the data into the BBP. |
@@ -151,6 +148,13 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
151 | 148 | ||
152 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg); | 149 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg); |
153 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 150 | mutex_unlock(&rt2x00dev->usb_cache_mutex); |
151 | |||
152 | return; | ||
153 | |||
154 | exit_fail: | ||
155 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
156 | |||
157 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); | ||
154 | } | 158 | } |
155 | 159 | ||
156 | static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, | 160 | static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, |
@@ -164,11 +168,8 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
164 | * Wait until the BBP becomes ready. | 168 | * Wait until the BBP becomes ready. |
165 | */ | 169 | */ |
166 | reg = rt73usb_bbp_check(rt2x00dev); | 170 | reg = rt73usb_bbp_check(rt2x00dev); |
167 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 171 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
168 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | 172 | goto exit_fail; |
169 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
170 | return; | ||
171 | } | ||
172 | 173 | ||
173 | /* | 174 | /* |
174 | * Write the request into the BBP. | 175 | * Write the request into the BBP. |
@@ -184,14 +185,19 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
184 | * Wait until the BBP becomes ready. | 185 | * Wait until the BBP becomes ready. |
185 | */ | 186 | */ |
186 | reg = rt73usb_bbp_check(rt2x00dev); | 187 | reg = rt73usb_bbp_check(rt2x00dev); |
187 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 188 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
188 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | 189 | goto exit_fail; |
189 | *value = 0xff; | ||
190 | return; | ||
191 | } | ||
192 | 190 | ||
193 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); | 191 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); |
194 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 192 | mutex_unlock(&rt2x00dev->usb_cache_mutex); |
193 | |||
194 | return; | ||
195 | |||
196 | exit_fail: | ||
197 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | ||
198 | |||
199 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | ||
200 | *value = 0xff; | ||
195 | } | 201 | } |
196 | 202 | ||
197 | static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev, | 203 | static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev, |
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index ec8f7002b09d..39bb96b413ef 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -178,8 +178,7 @@ static int pci_vpd_pci22_read(struct pci_dev *dev, int pos, int size, | |||
178 | int ret; | 178 | int ret; |
179 | int begin, end, i; | 179 | int begin, end, i; |
180 | 180 | ||
181 | if (pos < 0 || pos > PCI_VPD_PCI22_SIZE || | 181 | if (pos < 0 || pos > vpd->base.len || size > vpd->base.len - pos) |
182 | size > PCI_VPD_PCI22_SIZE - pos) | ||
183 | return -EINVAL; | 182 | return -EINVAL; |
184 | if (size == 0) | 183 | if (size == 0) |
185 | return 0; | 184 | return 0; |
@@ -223,8 +222,8 @@ static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size, | |||
223 | u32 val; | 222 | u32 val; |
224 | int ret; | 223 | int ret; |
225 | 224 | ||
226 | if (pos < 0 || pos > PCI_VPD_PCI22_SIZE || pos & 3 || | 225 | if (pos < 0 || pos > vpd->base.len || pos & 3 || |
227 | size > PCI_VPD_PCI22_SIZE - pos || size < 4) | 226 | size > vpd->base.len - pos || size < 4) |
228 | return -EINVAL; | 227 | return -EINVAL; |
229 | 228 | ||
230 | val = (u8) *buf++; | 229 | val = (u8) *buf++; |
@@ -255,11 +254,6 @@ out: | |||
255 | return 4; | 254 | return 4; |
256 | } | 255 | } |
257 | 256 | ||
258 | static int pci_vpd_pci22_get_size(struct pci_dev *dev) | ||
259 | { | ||
260 | return PCI_VPD_PCI22_SIZE; | ||
261 | } | ||
262 | |||
263 | static void pci_vpd_pci22_release(struct pci_dev *dev) | 257 | static void pci_vpd_pci22_release(struct pci_dev *dev) |
264 | { | 258 | { |
265 | kfree(container_of(dev->vpd, struct pci_vpd_pci22, base)); | 259 | kfree(container_of(dev->vpd, struct pci_vpd_pci22, base)); |
@@ -268,7 +262,6 @@ static void pci_vpd_pci22_release(struct pci_dev *dev) | |||
268 | static struct pci_vpd_ops pci_vpd_pci22_ops = { | 262 | static struct pci_vpd_ops pci_vpd_pci22_ops = { |
269 | .read = pci_vpd_pci22_read, | 263 | .read = pci_vpd_pci22_read, |
270 | .write = pci_vpd_pci22_write, | 264 | .write = pci_vpd_pci22_write, |
271 | .get_size = pci_vpd_pci22_get_size, | ||
272 | .release = pci_vpd_pci22_release, | 265 | .release = pci_vpd_pci22_release, |
273 | }; | 266 | }; |
274 | 267 | ||
@@ -284,6 +277,7 @@ int pci_vpd_pci22_init(struct pci_dev *dev) | |||
284 | if (!vpd) | 277 | if (!vpd) |
285 | return -ENOMEM; | 278 | return -ENOMEM; |
286 | 279 | ||
280 | vpd->base.len = PCI_VPD_PCI22_SIZE; | ||
287 | vpd->base.ops = &pci_vpd_pci22_ops; | 281 | vpd->base.ops = &pci_vpd_pci22_ops; |
288 | spin_lock_init(&vpd->lock); | 282 | spin_lock_init(&vpd->lock); |
289 | vpd->cap = cap; | 283 | vpd->cap = cap; |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 648596d469f6..91156f85a926 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -700,9 +700,10 @@ cleanup_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
700 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | 700 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, |
701 | cleanup_p2p_bridge, NULL, NULL); | 701 | cleanup_p2p_bridge, NULL, NULL); |
702 | 702 | ||
703 | if (!(bridge = acpiphp_handle_to_bridge(handle))) | 703 | bridge = acpiphp_handle_to_bridge(handle); |
704 | return AE_OK; | 704 | if (bridge) |
705 | cleanup_bridge(bridge); | 705 | cleanup_bridge(bridge); |
706 | |||
706 | return AE_OK; | 707 | return AE_OK; |
707 | } | 708 | } |
708 | 709 | ||
@@ -715,9 +716,19 @@ static void remove_bridge(acpi_handle handle) | |||
715 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, | 716 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
716 | (u32)1, cleanup_p2p_bridge, NULL, NULL); | 717 | (u32)1, cleanup_p2p_bridge, NULL, NULL); |
717 | 718 | ||
719 | /* | ||
720 | * On root bridges with hotplug slots directly underneath (ie, | ||
721 | * no p2p bridge inbetween), we call cleanup_bridge(). | ||
722 | * | ||
723 | * The else clause cleans up root bridges that either had no | ||
724 | * hotplug slots at all, or had a p2p bridge underneath. | ||
725 | */ | ||
718 | bridge = acpiphp_handle_to_bridge(handle); | 726 | bridge = acpiphp_handle_to_bridge(handle); |
719 | if (bridge) | 727 | if (bridge) |
720 | cleanup_bridge(bridge); | 728 | cleanup_bridge(bridge); |
729 | else | ||
730 | acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
731 | handle_hotplug_event_bridge); | ||
721 | } | 732 | } |
722 | 733 | ||
723 | static struct pci_dev * get_apic_pci_info(acpi_handle handle) | 734 | static struct pci_dev * get_apic_pci_info(acpi_handle handle) |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 6f3c7446c329..9c718583a237 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -736,9 +736,9 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
736 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); | 736 | attr = kzalloc(sizeof(*attr), GFP_ATOMIC); |
737 | if (attr) { | 737 | if (attr) { |
738 | pdev->vpd->attr = attr; | 738 | pdev->vpd->attr = attr; |
739 | attr->size = pdev->vpd->ops->get_size(pdev); | 739 | attr->size = pdev->vpd->len; |
740 | attr->attr.name = "vpd"; | 740 | attr->attr.name = "vpd"; |
741 | attr->attr.mode = S_IRUGO | S_IWUSR; | 741 | attr->attr.mode = S_IRUSR | S_IWUSR; |
742 | attr->read = pci_read_vpd; | 742 | attr->read = pci_read_vpd; |
743 | attr->write = pci_write_vpd; | 743 | attr->write = pci_write_vpd; |
744 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); | 744 | retval = sysfs_create_bin_file(&pdev->dev.kobj, attr); |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 0a497c1b4227..00408c97e5fc 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -21,11 +21,11 @@ extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val); | |||
21 | struct pci_vpd_ops { | 21 | struct pci_vpd_ops { |
22 | int (*read)(struct pci_dev *dev, int pos, int size, char *buf); | 22 | int (*read)(struct pci_dev *dev, int pos, int size, char *buf); |
23 | int (*write)(struct pci_dev *dev, int pos, int size, const char *buf); | 23 | int (*write)(struct pci_dev *dev, int pos, int size, const char *buf); |
24 | int (*get_size)(struct pci_dev *dev); | ||
25 | void (*release)(struct pci_dev *dev); | 24 | void (*release)(struct pci_dev *dev); |
26 | }; | 25 | }; |
27 | 26 | ||
28 | struct pci_vpd { | 27 | struct pci_vpd { |
28 | unsigned int len; | ||
29 | struct pci_vpd_ops *ops; | 29 | struct pci_vpd_ops *ops; |
30 | struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ | 30 | struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ |
31 | }; | 31 | }; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dabb563f51d9..338a3f94b4d4 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -1670,6 +1670,48 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
1670 | } | 1670 | } |
1671 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); | 1671 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); |
1672 | 1672 | ||
1673 | /* | ||
1674 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the | ||
1675 | * VPD end tag will hang the device. This problem was initially | ||
1676 | * observed when a vpd entry was created in sysfs | ||
1677 | * ('/sys/bus/pci/devices/<id>/vpd'). A read to this sysfs entry | ||
1678 | * will dump 32k of data. Reading a full 32k will cause an access | ||
1679 | * beyond the VPD end tag causing the device to hang. Once the device | ||
1680 | * is hung, the bnx2 driver will not be able to reset the device. | ||
1681 | * We believe that it is legal to read beyond the end tag and | ||
1682 | * therefore the solution is to limit the read/write length. | ||
1683 | */ | ||
1684 | static void __devinit quirk_brcm_570x_limit_vpd(struct pci_dev *dev) | ||
1685 | { | ||
1686 | /* Only disable the VPD capability for 5706, 5708, and 5709 rev. A */ | ||
1687 | if ((dev->device == PCI_DEVICE_ID_NX2_5706) || | ||
1688 | (dev->device == PCI_DEVICE_ID_NX2_5708) || | ||
1689 | ((dev->device == PCI_DEVICE_ID_NX2_5709) && | ||
1690 | (dev->revision & 0xf0) == 0x0)) { | ||
1691 | if (dev->vpd) | ||
1692 | dev->vpd->len = 0x80; | ||
1693 | } | ||
1694 | } | ||
1695 | |||
1696 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1697 | PCI_DEVICE_ID_NX2_5706, | ||
1698 | quirk_brcm_570x_limit_vpd); | ||
1699 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1700 | PCI_DEVICE_ID_NX2_5706S, | ||
1701 | quirk_brcm_570x_limit_vpd); | ||
1702 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1703 | PCI_DEVICE_ID_NX2_5708, | ||
1704 | quirk_brcm_570x_limit_vpd); | ||
1705 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1706 | PCI_DEVICE_ID_NX2_5708S, | ||
1707 | quirk_brcm_570x_limit_vpd); | ||
1708 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1709 | PCI_DEVICE_ID_NX2_5709, | ||
1710 | quirk_brcm_570x_limit_vpd); | ||
1711 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, | ||
1712 | PCI_DEVICE_ID_NX2_5709S, | ||
1713 | quirk_brcm_570x_limit_vpd); | ||
1714 | |||
1673 | #ifdef CONFIG_PCI_MSI | 1715 | #ifdef CONFIG_PCI_MSI |
1674 | /* Some chipsets do not support MSI. We cannot easily rely on setting | 1716 | /* Some chipsets do not support MSI. We cannot easily rely on setting |
1675 | * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually | 1717 | * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually |
@@ -1685,6 +1727,7 @@ static void __init quirk_disable_all_msi(struct pci_dev *dev) | |||
1685 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); | 1727 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); |
1686 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); | 1728 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); |
1687 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_all_msi); | 1729 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_all_msi); |
1730 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3336, quirk_disable_all_msi); | ||
1688 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3351, quirk_disable_all_msi); | 1731 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3351, quirk_disable_all_msi); |
1689 | 1732 | ||
1690 | /* Disable MSI on chipsets that are known to not support it */ | 1733 | /* Disable MSI on chipsets that are known to not support it */ |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 7e3ad4f3b343..58b7336640ff 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -126,12 +126,25 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
126 | int err; | 126 | int err; |
127 | struct rtc_time before, now; | 127 | struct rtc_time before, now; |
128 | int first_time = 1; | 128 | int first_time = 1; |
129 | unsigned long t_now, t_alm; | ||
130 | enum { none, day, month, year } missing = none; | ||
131 | unsigned days; | ||
129 | 132 | ||
130 | /* The lower level RTC driver may not be capable of filling | 133 | /* The lower level RTC driver may return -1 in some fields, |
131 | * in all fields of the rtc_time struct (eg. rtc-cmos), | 134 | * creating invalid alarm->time values, for reasons like: |
132 | * and so might instead return -1 in some fields. | 135 | * |
133 | * We deal with that here by grabbing a current RTC timestamp | 136 | * - The hardware may not be capable of filling them in; |
134 | * and using values from that for any missing (-1) values. | 137 | * many alarms match only on time-of-day fields, not |
138 | * day/month/year calendar data. | ||
139 | * | ||
140 | * - Some hardware uses illegal values as "wildcard" match | ||
141 | * values, which non-Linux firmware (like a BIOS) may try | ||
142 | * to set up as e.g. "alarm 15 minutes after each hour". | ||
143 | * Linux uses only oneshot alarms. | ||
144 | * | ||
145 | * When we see that here, we deal with it by using values from | ||
146 | * a current RTC timestamp for any missing (-1) values. The | ||
147 | * RTC driver prevents "periodic alarm" modes. | ||
135 | * | 148 | * |
136 | * But this can be racey, because some fields of the RTC timestamp | 149 | * But this can be racey, because some fields of the RTC timestamp |
137 | * may have wrapped in the interval since we read the RTC alarm, | 150 | * may have wrapped in the interval since we read the RTC alarm, |
@@ -174,6 +187,10 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
174 | if (!alarm->enabled) | 187 | if (!alarm->enabled) |
175 | return 0; | 188 | return 0; |
176 | 189 | ||
190 | /* full-function RTCs won't have such missing fields */ | ||
191 | if (rtc_valid_tm(&alarm->time) == 0) | ||
192 | return 0; | ||
193 | |||
177 | /* get the "after" timestamp, to detect wrapped fields */ | 194 | /* get the "after" timestamp, to detect wrapped fields */ |
178 | err = rtc_read_time(rtc, &now); | 195 | err = rtc_read_time(rtc, &now); |
179 | if (err < 0) | 196 | if (err < 0) |
@@ -183,22 +200,85 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
183 | } while ( before.tm_min != now.tm_min | 200 | } while ( before.tm_min != now.tm_min |
184 | || before.tm_hour != now.tm_hour | 201 | || before.tm_hour != now.tm_hour |
185 | || before.tm_mon != now.tm_mon | 202 | || before.tm_mon != now.tm_mon |
186 | || before.tm_year != now.tm_year | 203 | || before.tm_year != now.tm_year); |
187 | || before.tm_isdst != now.tm_isdst); | ||
188 | 204 | ||
189 | /* Fill in any missing alarm fields using the timestamp */ | 205 | /* Fill in the missing alarm fields using the timestamp; we |
206 | * know there's at least one since alarm->time is invalid. | ||
207 | */ | ||
190 | if (alarm->time.tm_sec == -1) | 208 | if (alarm->time.tm_sec == -1) |
191 | alarm->time.tm_sec = now.tm_sec; | 209 | alarm->time.tm_sec = now.tm_sec; |
192 | if (alarm->time.tm_min == -1) | 210 | if (alarm->time.tm_min == -1) |
193 | alarm->time.tm_min = now.tm_min; | 211 | alarm->time.tm_min = now.tm_min; |
194 | if (alarm->time.tm_hour == -1) | 212 | if (alarm->time.tm_hour == -1) |
195 | alarm->time.tm_hour = now.tm_hour; | 213 | alarm->time.tm_hour = now.tm_hour; |
196 | if (alarm->time.tm_mday == -1) | 214 | |
215 | /* For simplicity, only support date rollover for now */ | ||
216 | if (alarm->time.tm_mday == -1) { | ||
197 | alarm->time.tm_mday = now.tm_mday; | 217 | alarm->time.tm_mday = now.tm_mday; |
198 | if (alarm->time.tm_mon == -1) | 218 | missing = day; |
219 | } | ||
220 | if (alarm->time.tm_mon == -1) { | ||
199 | alarm->time.tm_mon = now.tm_mon; | 221 | alarm->time.tm_mon = now.tm_mon; |
200 | if (alarm->time.tm_year == -1) | 222 | if (missing == none) |
223 | missing = month; | ||
224 | } | ||
225 | if (alarm->time.tm_year == -1) { | ||
201 | alarm->time.tm_year = now.tm_year; | 226 | alarm->time.tm_year = now.tm_year; |
227 | if (missing == none) | ||
228 | missing = year; | ||
229 | } | ||
230 | |||
231 | /* with luck, no rollover is needed */ | ||
232 | rtc_tm_to_time(&now, &t_now); | ||
233 | rtc_tm_to_time(&alarm->time, &t_alm); | ||
234 | if (t_now < t_alm) | ||
235 | goto done; | ||
236 | |||
237 | switch (missing) { | ||
238 | |||
239 | /* 24 hour rollover ... if it's now 10am Monday, an alarm that | ||
240 | * that will trigger at 5am will do so at 5am Tuesday, which | ||
241 | * could also be in the next month or year. This is a common | ||
242 | * case, especially for PCs. | ||
243 | */ | ||
244 | case day: | ||
245 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); | ||
246 | t_alm += 24 * 60 * 60; | ||
247 | rtc_time_to_tm(t_alm, &alarm->time); | ||
248 | break; | ||
249 | |||
250 | /* Month rollover ... if it's the 31th, an alarm on the 3rd will | ||
251 | * be next month. An alarm matching on the 30th, 29th, or 28th | ||
252 | * may end up in the month after that! Many newer PCs support | ||
253 | * this type of alarm. | ||
254 | */ | ||
255 | case month: | ||
256 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month"); | ||
257 | do { | ||
258 | if (alarm->time.tm_mon < 11) | ||
259 | alarm->time.tm_mon++; | ||
260 | else { | ||
261 | alarm->time.tm_mon = 0; | ||
262 | alarm->time.tm_year++; | ||
263 | } | ||
264 | days = rtc_month_days(alarm->time.tm_mon, | ||
265 | alarm->time.tm_year); | ||
266 | } while (days < alarm->time.tm_mday); | ||
267 | break; | ||
268 | |||
269 | /* Year rollover ... easy except for leap years! */ | ||
270 | case year: | ||
271 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); | ||
272 | do { | ||
273 | alarm->time.tm_year++; | ||
274 | } while (!rtc_valid_tm(&alarm->time)); | ||
275 | break; | ||
276 | |||
277 | default: | ||
278 | dev_warn(&rtc->dev, "alarm rollover not handled\n"); | ||
279 | } | ||
280 | |||
281 | done: | ||
202 | return 0; | 282 | return 0; |
203 | } | 283 | } |
204 | EXPORT_SYMBOL_GPL(rtc_read_alarm); | 284 | EXPORT_SYMBOL_GPL(rtc_read_alarm); |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 82f62d25f921..67421b0d3a7b 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -331,14 +331,14 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
331 | RCNR = 0; | 331 | RCNR = 0; |
332 | } | 332 | } |
333 | 333 | ||
334 | device_init_wakeup(&pdev->dev, 1); | ||
335 | |||
334 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, | 336 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
335 | THIS_MODULE); | 337 | THIS_MODULE); |
336 | 338 | ||
337 | if (IS_ERR(rtc)) | 339 | if (IS_ERR(rtc)) |
338 | return PTR_ERR(rtc); | 340 | return PTR_ERR(rtc); |
339 | 341 | ||
340 | device_init_wakeup(&pdev->dev, 1); | ||
341 | |||
342 | platform_set_drvdata(pdev, rtc); | 342 | platform_set_drvdata(pdev, rtc); |
343 | 343 | ||
344 | return 0; | 344 | return 0; |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index eaf55945f21b..7dcfba1bbfe1 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #define X1205_SR_RTCF 0x01 /* Clock failure */ | 71 | #define X1205_SR_RTCF 0x01 /* Clock failure */ |
72 | #define X1205_SR_WEL 0x02 /* Write Enable Latch */ | 72 | #define X1205_SR_WEL 0x02 /* Write Enable Latch */ |
73 | #define X1205_SR_RWEL 0x04 /* Register Write Enable */ | 73 | #define X1205_SR_RWEL 0x04 /* Register Write Enable */ |
74 | #define X1205_SR_AL0 0x20 /* Alarm 0 match */ | ||
74 | 75 | ||
75 | #define X1205_DTR_DTR0 0x01 | 76 | #define X1205_DTR_DTR0 0x01 |
76 | #define X1205_DTR_DTR1 0x02 | 77 | #define X1205_DTR_DTR1 0x02 |
@@ -78,6 +79,8 @@ | |||
78 | 79 | ||
79 | #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ | 80 | #define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */ |
80 | 81 | ||
82 | #define X1205_INT_AL0E 0x20 /* Alarm 0 enable */ | ||
83 | |||
81 | static struct i2c_driver x1205_driver; | 84 | static struct i2c_driver x1205_driver; |
82 | 85 | ||
83 | /* | 86 | /* |
@@ -89,8 +92,8 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
89 | unsigned char reg_base) | 92 | unsigned char reg_base) |
90 | { | 93 | { |
91 | unsigned char dt_addr[2] = { 0, reg_base }; | 94 | unsigned char dt_addr[2] = { 0, reg_base }; |
92 | |||
93 | unsigned char buf[8]; | 95 | unsigned char buf[8]; |
96 | int i; | ||
94 | 97 | ||
95 | struct i2c_msg msgs[] = { | 98 | struct i2c_msg msgs[] = { |
96 | { client->addr, 0, 2, dt_addr }, /* setup read ptr */ | 99 | { client->addr, 0, 2, dt_addr }, /* setup read ptr */ |
@@ -98,7 +101,7 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
98 | }; | 101 | }; |
99 | 102 | ||
100 | /* read date registers */ | 103 | /* read date registers */ |
101 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 104 | if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { |
102 | dev_err(&client->dev, "%s: read error\n", __func__); | 105 | dev_err(&client->dev, "%s: read error\n", __func__); |
103 | return -EIO; | 106 | return -EIO; |
104 | } | 107 | } |
@@ -110,6 +113,11 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
110 | buf[0], buf[1], buf[2], buf[3], | 113 | buf[0], buf[1], buf[2], buf[3], |
111 | buf[4], buf[5], buf[6], buf[7]); | 114 | buf[4], buf[5], buf[6], buf[7]); |
112 | 115 | ||
116 | /* Mask out the enable bits if these are alarm registers */ | ||
117 | if (reg_base < X1205_CCR_BASE) | ||
118 | for (i = 0; i <= 4; i++) | ||
119 | buf[i] &= 0x7F; | ||
120 | |||
113 | tm->tm_sec = BCD2BIN(buf[CCR_SEC]); | 121 | tm->tm_sec = BCD2BIN(buf[CCR_SEC]); |
114 | tm->tm_min = BCD2BIN(buf[CCR_MIN]); | 122 | tm->tm_min = BCD2BIN(buf[CCR_MIN]); |
115 | tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ | 123 | tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */ |
@@ -138,7 +146,7 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr) | |||
138 | }; | 146 | }; |
139 | 147 | ||
140 | /* read status register */ | 148 | /* read status register */ |
141 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 149 | if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { |
142 | dev_err(&client->dev, "%s: read error\n", __func__); | 150 | dev_err(&client->dev, "%s: read error\n", __func__); |
143 | return -EIO; | 151 | return -EIO; |
144 | } | 152 | } |
@@ -147,10 +155,11 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr) | |||
147 | } | 155 | } |
148 | 156 | ||
149 | static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | 157 | static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, |
150 | int datetoo, u8 reg_base) | 158 | int datetoo, u8 reg_base, unsigned char alm_enable) |
151 | { | 159 | { |
152 | int i, xfer; | 160 | int i, xfer, nbytes; |
153 | unsigned char buf[8]; | 161 | unsigned char buf[8]; |
162 | unsigned char rdata[10] = { 0, reg_base }; | ||
154 | 163 | ||
155 | static const unsigned char wel[3] = { 0, X1205_REG_SR, | 164 | static const unsigned char wel[3] = { 0, X1205_REG_SR, |
156 | X1205_SR_WEL }; | 165 | X1205_SR_WEL }; |
@@ -189,6 +198,11 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
189 | buf[CCR_Y2K] = BIN2BCD(tm->tm_year / 100); | 198 | buf[CCR_Y2K] = BIN2BCD(tm->tm_year / 100); |
190 | } | 199 | } |
191 | 200 | ||
201 | /* If writing alarm registers, set compare bits on registers 0-4 */ | ||
202 | if (reg_base < X1205_CCR_BASE) | ||
203 | for (i = 0; i <= 4; i++) | ||
204 | buf[i] |= 0x80; | ||
205 | |||
192 | /* this sequence is required to unlock the chip */ | 206 | /* this sequence is required to unlock the chip */ |
193 | if ((xfer = i2c_master_send(client, wel, 3)) != 3) { | 207 | if ((xfer = i2c_master_send(client, wel, 3)) != 3) { |
194 | dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); | 208 | dev_err(&client->dev, "%s: wel - %d\n", __func__, xfer); |
@@ -200,19 +214,57 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm, | |||
200 | return -EIO; | 214 | return -EIO; |
201 | } | 215 | } |
202 | 216 | ||
217 | |||
203 | /* write register's data */ | 218 | /* write register's data */ |
204 | for (i = 0; i < (datetoo ? 8 : 3); i++) { | 219 | if (datetoo) |
205 | unsigned char rdata[3] = { 0, reg_base + i, buf[i] }; | 220 | nbytes = 8; |
221 | else | ||
222 | nbytes = 3; | ||
223 | for (i = 0; i < nbytes; i++) | ||
224 | rdata[2+i] = buf[i]; | ||
225 | |||
226 | xfer = i2c_master_send(client, rdata, nbytes+2); | ||
227 | if (xfer != nbytes+2) { | ||
228 | dev_err(&client->dev, | ||
229 | "%s: result=%d addr=%02x, data=%02x\n", | ||
230 | __func__, | ||
231 | xfer, rdata[1], rdata[2]); | ||
232 | return -EIO; | ||
233 | } | ||
234 | |||
235 | /* If we wrote to the nonvolatile region, wait 10msec for write cycle*/ | ||
236 | if (reg_base < X1205_CCR_BASE) { | ||
237 | unsigned char al0e[3] = { 0, X1205_REG_INT, 0 }; | ||
238 | |||
239 | msleep(10); | ||
206 | 240 | ||
207 | xfer = i2c_master_send(client, rdata, 3); | 241 | /* ...and set or clear the AL0E bit in the INT register */ |
242 | |||
243 | /* Need to set RWEL again as the write has cleared it */ | ||
244 | xfer = i2c_master_send(client, rwel, 3); | ||
208 | if (xfer != 3) { | 245 | if (xfer != 3) { |
209 | dev_err(&client->dev, | 246 | dev_err(&client->dev, |
210 | "%s: xfer=%d addr=%02x, data=%02x\n", | 247 | "%s: aloe rwel - %d\n", |
211 | __func__, | 248 | __func__, |
212 | xfer, rdata[1], rdata[2]); | 249 | xfer); |
250 | return -EIO; | ||
251 | } | ||
252 | |||
253 | if (alm_enable) | ||
254 | al0e[2] = X1205_INT_AL0E; | ||
255 | |||
256 | xfer = i2c_master_send(client, al0e, 3); | ||
257 | if (xfer != 3) { | ||
258 | dev_err(&client->dev, | ||
259 | "%s: al0e - %d\n", | ||
260 | __func__, | ||
261 | xfer); | ||
213 | return -EIO; | 262 | return -EIO; |
214 | } | 263 | } |
215 | }; | 264 | |
265 | /* and wait 10msec again for this write to complete */ | ||
266 | msleep(10); | ||
267 | } | ||
216 | 268 | ||
217 | /* disable further writes */ | 269 | /* disable further writes */ |
218 | if ((xfer = i2c_master_send(client, diswe, 3)) != 3) { | 270 | if ((xfer = i2c_master_send(client, diswe, 3)) != 3) { |
@@ -230,9 +282,9 @@ static int x1205_fix_osc(struct i2c_client *client) | |||
230 | 282 | ||
231 | tm.tm_hour = tm.tm_min = tm.tm_sec = 0; | 283 | tm.tm_hour = tm.tm_min = tm.tm_sec = 0; |
232 | 284 | ||
233 | if ((err = x1205_set_datetime(client, &tm, 0, X1205_CCR_BASE)) < 0) | 285 | err = x1205_set_datetime(client, &tm, 0, X1205_CCR_BASE, 0); |
234 | dev_err(&client->dev, | 286 | if (err < 0) |
235 | "unable to restart the oscillator\n"); | 287 | dev_err(&client->dev, "unable to restart the oscillator\n"); |
236 | 288 | ||
237 | return err; | 289 | return err; |
238 | } | 290 | } |
@@ -248,7 +300,7 @@ static int x1205_get_dtrim(struct i2c_client *client, int *trim) | |||
248 | }; | 300 | }; |
249 | 301 | ||
250 | /* read dtr register */ | 302 | /* read dtr register */ |
251 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 303 | if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { |
252 | dev_err(&client->dev, "%s: read error\n", __func__); | 304 | dev_err(&client->dev, "%s: read error\n", __func__); |
253 | return -EIO; | 305 | return -EIO; |
254 | } | 306 | } |
@@ -280,7 +332,7 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) | |||
280 | }; | 332 | }; |
281 | 333 | ||
282 | /* read atr register */ | 334 | /* read atr register */ |
283 | if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) { | 335 | if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { |
284 | dev_err(&client->dev, "%s: read error\n", __func__); | 336 | dev_err(&client->dev, "%s: read error\n", __func__); |
285 | return -EIO; | 337 | return -EIO; |
286 | } | 338 | } |
@@ -403,14 +455,33 @@ static int x1205_validate_client(struct i2c_client *client) | |||
403 | 455 | ||
404 | static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 456 | static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
405 | { | 457 | { |
406 | return x1205_get_datetime(to_i2c_client(dev), | 458 | int err; |
407 | &alrm->time, X1205_ALM0_BASE); | 459 | unsigned char intreg, status; |
460 | static unsigned char int_addr[2] = { 0, X1205_REG_INT }; | ||
461 | struct i2c_client *client = to_i2c_client(dev); | ||
462 | struct i2c_msg msgs[] = { | ||
463 | { client->addr, 0, 2, int_addr }, /* setup read ptr */ | ||
464 | { client->addr, I2C_M_RD, 1, &intreg }, /* read INT register */ | ||
465 | }; | ||
466 | |||
467 | /* read interrupt register and status register */ | ||
468 | if (i2c_transfer(client->adapter, &msgs[0], 2) != 2) { | ||
469 | dev_err(&client->dev, "%s: read error\n", __func__); | ||
470 | return -EIO; | ||
471 | } | ||
472 | err = x1205_get_status(client, &status); | ||
473 | if (err == 0) { | ||
474 | alrm->pending = (status & X1205_SR_AL0) ? 1 : 0; | ||
475 | alrm->enabled = (intreg & X1205_INT_AL0E) ? 1 : 0; | ||
476 | err = x1205_get_datetime(client, &alrm->time, X1205_ALM0_BASE); | ||
477 | } | ||
478 | return err; | ||
408 | } | 479 | } |
409 | 480 | ||
410 | static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 481 | static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
411 | { | 482 | { |
412 | return x1205_set_datetime(to_i2c_client(dev), | 483 | return x1205_set_datetime(to_i2c_client(dev), |
413 | &alrm->time, 1, X1205_ALM0_BASE); | 484 | &alrm->time, 1, X1205_ALM0_BASE, alrm->enabled); |
414 | } | 485 | } |
415 | 486 | ||
416 | static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm) | 487 | static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -422,7 +493,7 @@ static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
422 | static int x1205_rtc_set_time(struct device *dev, struct rtc_time *tm) | 493 | static int x1205_rtc_set_time(struct device *dev, struct rtc_time *tm) |
423 | { | 494 | { |
424 | return x1205_set_datetime(to_i2c_client(dev), | 495 | return x1205_set_datetime(to_i2c_client(dev), |
425 | tm, 1, X1205_CCR_BASE); | 496 | tm, 1, X1205_CCR_BASE, 0); |
426 | } | 497 | } |
427 | 498 | ||
428 | static int x1205_rtc_proc(struct device *dev, struct seq_file *seq) | 499 | static int x1205_rtc_proc(struct device *dev, struct seq_file *seq) |
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c index a0b6d414953d..59fbef08d690 100644 --- a/drivers/scsi/esp_scsi.c +++ b/drivers/scsi/esp_scsi.c | |||
@@ -2359,6 +2359,24 @@ void scsi_esp_unregister(struct esp *esp) | |||
2359 | } | 2359 | } |
2360 | EXPORT_SYMBOL(scsi_esp_unregister); | 2360 | EXPORT_SYMBOL(scsi_esp_unregister); |
2361 | 2361 | ||
2362 | static int esp_target_alloc(struct scsi_target *starget) | ||
2363 | { | ||
2364 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
2365 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
2366 | |||
2367 | tp->starget = starget; | ||
2368 | |||
2369 | return 0; | ||
2370 | } | ||
2371 | |||
2372 | static void esp_target_destroy(struct scsi_target *starget) | ||
2373 | { | ||
2374 | struct esp *esp = shost_priv(dev_to_shost(&starget->dev)); | ||
2375 | struct esp_target_data *tp = &esp->target[starget->id]; | ||
2376 | |||
2377 | tp->starget = NULL; | ||
2378 | } | ||
2379 | |||
2362 | static int esp_slave_alloc(struct scsi_device *dev) | 2380 | static int esp_slave_alloc(struct scsi_device *dev) |
2363 | { | 2381 | { |
2364 | struct esp *esp = shost_priv(dev->host); | 2382 | struct esp *esp = shost_priv(dev->host); |
@@ -2370,8 +2388,6 @@ static int esp_slave_alloc(struct scsi_device *dev) | |||
2370 | return -ENOMEM; | 2388 | return -ENOMEM; |
2371 | dev->hostdata = lp; | 2389 | dev->hostdata = lp; |
2372 | 2390 | ||
2373 | tp->starget = dev->sdev_target; | ||
2374 | |||
2375 | spi_min_period(tp->starget) = esp->min_period; | 2391 | spi_min_period(tp->starget) = esp->min_period; |
2376 | spi_max_offset(tp->starget) = 15; | 2392 | spi_max_offset(tp->starget) = 15; |
2377 | 2393 | ||
@@ -2608,6 +2624,8 @@ struct scsi_host_template scsi_esp_template = { | |||
2608 | .name = "esp", | 2624 | .name = "esp", |
2609 | .info = esp_info, | 2625 | .info = esp_info, |
2610 | .queuecommand = esp_queuecommand, | 2626 | .queuecommand = esp_queuecommand, |
2627 | .target_alloc = esp_target_alloc, | ||
2628 | .target_destroy = esp_target_destroy, | ||
2611 | .slave_alloc = esp_slave_alloc, | 2629 | .slave_alloc = esp_slave_alloc, |
2612 | .slave_configure = esp_slave_configure, | 2630 | .slave_configure = esp_slave_configure, |
2613 | .slave_destroy = esp_slave_destroy, | 2631 | .slave_destroy = esp_slave_destroy, |
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 45df83b9d847..0fe031f003e7 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -61,7 +61,7 @@ static int ses_probe(struct device *dev) | |||
61 | return err; | 61 | return err; |
62 | } | 62 | } |
63 | 63 | ||
64 | #define SES_TIMEOUT 30 | 64 | #define SES_TIMEOUT (30 * HZ) |
65 | #define SES_RETRIES 3 | 65 | #define SES_RETRIES 3 |
66 | 66 | ||
67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, | 67 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index c9b64e73c987..42d2e108b679 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1991,7 +1991,9 @@ struct uart_match { | |||
1991 | static int serial_match_port(struct device *dev, void *data) | 1991 | static int serial_match_port(struct device *dev, void *data) |
1992 | { | 1992 | { |
1993 | struct uart_match *match = data; | 1993 | struct uart_match *match = data; |
1994 | dev_t devt = MKDEV(match->driver->major, match->driver->minor) + match->port->line; | 1994 | struct tty_driver *tty_drv = match->driver->tty_driver; |
1995 | dev_t devt = MKDEV(tty_drv->major, tty_drv->minor_start) + | ||
1996 | match->port->line; | ||
1995 | 1997 | ||
1996 | return dev->devt == devt; /* Actually, only one tty per port */ | 1998 | return dev->devt == devt; /* Actually, only one tty per port */ |
1997 | } | 1999 | } |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 799337f7fde1..f5b60c70389b 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -167,14 +167,14 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) | |||
167 | 167 | ||
168 | mutex_lock(&spidev->buf_lock); | 168 | mutex_lock(&spidev->buf_lock); |
169 | status = spidev_sync_read(spidev, count); | 169 | status = spidev_sync_read(spidev, count); |
170 | if (status == 0) { | 170 | if (status > 0) { |
171 | unsigned long missing; | 171 | unsigned long missing; |
172 | 172 | ||
173 | missing = copy_to_user(buf, spidev->buffer, count); | 173 | missing = copy_to_user(buf, spidev->buffer, status); |
174 | if (count && missing == count) | 174 | if (missing == status) |
175 | status = -EFAULT; | 175 | status = -EFAULT; |
176 | else | 176 | else |
177 | status = count - missing; | 177 | status = status - missing; |
178 | } | 178 | } |
179 | mutex_unlock(&spidev->buf_lock); | 179 | mutex_unlock(&spidev->buf_lock); |
180 | 180 | ||
@@ -200,8 +200,6 @@ spidev_write(struct file *filp, const char __user *buf, | |||
200 | missing = copy_from_user(spidev->buffer, buf, count); | 200 | missing = copy_from_user(spidev->buffer, buf, count); |
201 | if (missing == 0) { | 201 | if (missing == 0) { |
202 | status = spidev_sync_write(spidev, count); | 202 | status = spidev_sync_write(spidev, count); |
203 | if (status == 0) | ||
204 | status = count; | ||
205 | } else | 203 | } else |
206 | status = -EFAULT; | 204 | status = -EFAULT; |
207 | mutex_unlock(&spidev->buf_lock); | 205 | mutex_unlock(&spidev->buf_lock); |
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 4b628526df09..a86e952ed4ca 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig | |||
@@ -12,3 +12,12 @@ menuconfig THERMAL | |||
12 | cooling devices. | 12 | cooling devices. |
13 | All platforms with ACPI thermal support can use this driver. | 13 | All platforms with ACPI thermal support can use this driver. |
14 | If you want this support, you should say Y or M here. | 14 | If you want this support, you should say Y or M here. |
15 | |||
16 | config THERMAL_HWMON | ||
17 | bool "Hardware monitoring support" | ||
18 | depends on HWMON=y || HWMON=THERMAL | ||
19 | help | ||
20 | The generic thermal sysfs driver's hardware monitoring support | ||
21 | requires a 2.10.7/3.0.2 or later lm-sensors userspace. | ||
22 | |||
23 | Say Y if your user-space is new enough. | ||
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 6098787341f3..fe07462d5947 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
@@ -295,8 +295,8 @@ thermal_cooling_device_trip_point_show(struct device *dev, | |||
295 | 295 | ||
296 | /* Device management */ | 296 | /* Device management */ |
297 | 297 | ||
298 | #if defined(CONFIG_HWMON) || \ | 298 | #if defined(CONFIG_THERMAL_HWMON) |
299 | (defined(CONFIG_HWMON_MODULE) && defined(CONFIG_THERMAL_MODULE)) | 299 | |
300 | /* hwmon sys I/F */ | 300 | /* hwmon sys I/F */ |
301 | #include <linux/hwmon.h> | 301 | #include <linux/hwmon.h> |
302 | static LIST_HEAD(thermal_hwmon_list); | 302 | static LIST_HEAD(thermal_hwmon_list); |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 63c34043b4d9..c3201affa0b6 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -1125,9 +1125,6 @@ static void stop_data_traffic(struct acm *acm) | |||
1125 | for (i = 0; i < acm->rx_buflimit; i++) | 1125 | for (i = 0; i < acm->rx_buflimit; i++) |
1126 | usb_kill_urb(acm->ru[i].urb); | 1126 | usb_kill_urb(acm->ru[i].urb); |
1127 | 1127 | ||
1128 | INIT_LIST_HEAD(&acm->filled_read_bufs); | ||
1129 | INIT_LIST_HEAD(&acm->spare_read_bufs); | ||
1130 | |||
1131 | tasklet_enable(&acm->urb_task); | 1128 | tasklet_enable(&acm->urb_task); |
1132 | 1129 | ||
1133 | cancel_work_sync(&acm->work); | 1130 | cancel_work_sync(&acm->work); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 09a53e7f3327..42a436478b78 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -924,6 +924,15 @@ static int register_root_hub(struct usb_hcd *hcd) | |||
924 | return retval; | 924 | return retval; |
925 | } | 925 | } |
926 | 926 | ||
927 | void usb_enable_root_hub_irq (struct usb_bus *bus) | ||
928 | { | ||
929 | struct usb_hcd *hcd; | ||
930 | |||
931 | hcd = container_of (bus, struct usb_hcd, self); | ||
932 | if (hcd->driver->hub_irq_enable && hcd->state != HC_STATE_HALT) | ||
933 | hcd->driver->hub_irq_enable (hcd); | ||
934 | } | ||
935 | |||
927 | 936 | ||
928 | /*-------------------------------------------------------------------------*/ | 937 | /*-------------------------------------------------------------------------*/ |
929 | 938 | ||
@@ -1684,19 +1693,30 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum); | |||
1684 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) | 1693 | irqreturn_t usb_hcd_irq (int irq, void *__hcd) |
1685 | { | 1694 | { |
1686 | struct usb_hcd *hcd = __hcd; | 1695 | struct usb_hcd *hcd = __hcd; |
1687 | int start = hcd->state; | 1696 | unsigned long flags; |
1697 | irqreturn_t rc; | ||
1688 | 1698 | ||
1689 | if (unlikely(start == HC_STATE_HALT || | 1699 | /* IRQF_DISABLED doesn't work correctly with shared IRQs |
1690 | !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) | 1700 | * when the first handler doesn't use it. So let's just |
1691 | return IRQ_NONE; | 1701 | * assume it's never used. |
1692 | if (hcd->driver->irq (hcd) == IRQ_NONE) | 1702 | */ |
1693 | return IRQ_NONE; | 1703 | local_irq_save(flags); |
1694 | 1704 | ||
1695 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | 1705 | if (unlikely(hcd->state == HC_STATE_HALT || |
1706 | !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) { | ||
1707 | rc = IRQ_NONE; | ||
1708 | } else if (hcd->driver->irq(hcd) == IRQ_NONE) { | ||
1709 | rc = IRQ_NONE; | ||
1710 | } else { | ||
1711 | set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); | ||
1712 | |||
1713 | if (unlikely(hcd->state == HC_STATE_HALT)) | ||
1714 | usb_hc_died(hcd); | ||
1715 | rc = IRQ_HANDLED; | ||
1716 | } | ||
1696 | 1717 | ||
1697 | if (unlikely(hcd->state == HC_STATE_HALT)) | 1718 | local_irq_restore(flags); |
1698 | usb_hc_died (hcd); | 1719 | return rc; |
1699 | return IRQ_HANDLED; | ||
1700 | } | 1720 | } |
1701 | 1721 | ||
1702 | /*-------------------------------------------------------------------------*/ | 1722 | /*-------------------------------------------------------------------------*/ |
@@ -1860,6 +1880,13 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1860 | 1880 | ||
1861 | /* enable irqs just before we start the controller */ | 1881 | /* enable irqs just before we start the controller */ |
1862 | if (hcd->driver->irq) { | 1882 | if (hcd->driver->irq) { |
1883 | |||
1884 | /* IRQF_DISABLED doesn't work as advertised when used together | ||
1885 | * with IRQF_SHARED. As usb_hcd_irq() will always disable | ||
1886 | * interrupts we can remove it here. | ||
1887 | */ | ||
1888 | irqflags &= ~IRQF_DISABLED; | ||
1889 | |||
1863 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | 1890 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", |
1864 | hcd->driver->description, hcd->self.busnum); | 1891 | hcd->driver->description, hcd->self.busnum); |
1865 | if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags, | 1892 | if ((retval = request_irq(irqnum, &usb_hcd_irq, irqflags, |
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index a0bf5df6cb6f..b9de1569b39e 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h | |||
@@ -210,6 +210,8 @@ struct hc_driver { | |||
210 | int (*bus_suspend)(struct usb_hcd *); | 210 | int (*bus_suspend)(struct usb_hcd *); |
211 | int (*bus_resume)(struct usb_hcd *); | 211 | int (*bus_resume)(struct usb_hcd *); |
212 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 212 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
213 | void (*hub_irq_enable)(struct usb_hcd *); | ||
214 | /* Needed only if port-change IRQs are level-triggered */ | ||
213 | 215 | ||
214 | /* force handover of high-speed port to full-speed companion */ | 216 | /* force handover of high-speed port to full-speed companion */ |
215 | void (*relinquish_port)(struct usb_hcd *, int); | 217 | void (*relinquish_port)(struct usb_hcd *, int); |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 94789be54ca3..4cfe32a16c37 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -713,18 +713,11 @@ static void hub_restart(struct usb_hub *hub, int type) | |||
713 | } | 713 | } |
714 | 714 | ||
715 | /* Was the power session lost while we were suspended? */ | 715 | /* Was the power session lost while we were suspended? */ |
716 | switch (type) { | 716 | status = hub_port_status(hub, port1, &portstatus, &portchange); |
717 | case HUB_RESET_RESUME: | ||
718 | portstatus = 0; | ||
719 | portchange = USB_PORT_STAT_C_CONNECTION; | ||
720 | break; | ||
721 | 717 | ||
722 | case HUB_RESET: | 718 | /* If the device is gone, khubd will handle it later */ |
723 | case HUB_RESUME: | 719 | if (status == 0 && !(portstatus & USB_PORT_STAT_CONNECTION)) |
724 | status = hub_port_status(hub, port1, | 720 | continue; |
725 | &portstatus, &portchange); | ||
726 | break; | ||
727 | } | ||
728 | 721 | ||
729 | /* For "USB_PERSIST"-enabled children we must | 722 | /* For "USB_PERSIST"-enabled children we must |
730 | * mark the child device for reset-resume and | 723 | * mark the child device for reset-resume and |
@@ -2080,6 +2073,8 @@ int usb_port_resume(struct usb_device *udev) | |||
2080 | } | 2073 | } |
2081 | 2074 | ||
2082 | clear_bit(port1, hub->busy_bits); | 2075 | clear_bit(port1, hub->busy_bits); |
2076 | if (!hub->hdev->parent && !hub->busy_bits[0]) | ||
2077 | usb_enable_root_hub_irq(hub->hdev->bus); | ||
2083 | 2078 | ||
2084 | if (status == 0) | 2079 | if (status == 0) |
2085 | status = finish_port_resume(udev); | 2080 | status = finish_port_resume(udev); |
@@ -3009,6 +3004,11 @@ static void hub_events(void) | |||
3009 | 3004 | ||
3010 | hub->activating = 0; | 3005 | hub->activating = 0; |
3011 | 3006 | ||
3007 | /* If this is a root hub, tell the HCD it's okay to | ||
3008 | * re-enable port-change interrupts now. */ | ||
3009 | if (!hdev->parent && !hub->busy_bits[0]) | ||
3010 | usb_enable_root_hub_irq(hdev->bus); | ||
3011 | |||
3012 | loop_autopm: | 3012 | loop_autopm: |
3013 | /* Allow autosuspend if we're not going to run again */ | 3013 | /* Allow autosuspend if we're not going to run again */ |
3014 | if (list_empty(&hub->event_list)) | 3014 | if (list_empty(&hub->event_list)) |
@@ -3234,6 +3234,8 @@ int usb_reset_device(struct usb_device *udev) | |||
3234 | break; | 3234 | break; |
3235 | } | 3235 | } |
3236 | clear_bit(port1, parent_hub->busy_bits); | 3236 | clear_bit(port1, parent_hub->busy_bits); |
3237 | if (!parent_hdev->parent && !parent_hub->busy_bits[0]) | ||
3238 | usb_enable_root_hub_irq(parent_hdev->bus); | ||
3237 | 3239 | ||
3238 | if (ret < 0) | 3240 | if (ret < 0) |
3239 | goto re_enumerate; | 3241 | goto re_enumerate; |
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 35a03095757e..90245fd8bac4 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -177,6 +177,15 @@ timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
177 | static inline void | 177 | static inline void |
178 | timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | 178 | timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) |
179 | { | 179 | { |
180 | /* Don't override timeouts which shrink or (later) disable | ||
181 | * the async ring; just the I/O watchdog. Note that if a | ||
182 | * SHRINK were pending, OFF would never be requested. | ||
183 | */ | ||
184 | if (timer_pending(&ehci->watchdog) | ||
185 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
186 | & ehci->actions)) | ||
187 | return; | ||
188 | |||
180 | if (!test_and_set_bit (action, &ehci->actions)) { | 189 | if (!test_and_set_bit (action, &ehci->actions)) { |
181 | unsigned long t; | 190 | unsigned long t; |
182 | 191 | ||
@@ -192,15 +201,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
192 | t = EHCI_SHRINK_JIFFIES; | 201 | t = EHCI_SHRINK_JIFFIES; |
193 | break; | 202 | break; |
194 | } | 203 | } |
195 | t += jiffies; | 204 | mod_timer(&ehci->watchdog, t + jiffies); |
196 | // all timings except IAA watchdog can be overridden. | ||
197 | // async queue SHRINK often precedes IAA. while it's ready | ||
198 | // to go OFF neither can matter, and afterwards the IO | ||
199 | // watchdog stops unless there's still periodic traffic. | ||
200 | if (time_before_eq(t, ehci->watchdog.expires) | ||
201 | && timer_pending (&ehci->watchdog)) | ||
202 | return; | ||
203 | mod_timer (&ehci->watchdog, t); | ||
204 | } | 205 | } |
205 | } | 206 | } |
206 | 207 | ||
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index c96db1153dcf..e534f9de0f05 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -261,6 +261,7 @@ static const struct hc_driver ohci_at91_hc_driver = { | |||
261 | */ | 261 | */ |
262 | .hub_status_data = ohci_hub_status_data, | 262 | .hub_status_data = ohci_hub_status_data, |
263 | .hub_control = ohci_hub_control, | 263 | .hub_control = ohci_hub_control, |
264 | .hub_irq_enable = ohci_rhsc_enable, | ||
264 | #ifdef CONFIG_PM | 265 | #ifdef CONFIG_PM |
265 | .bus_suspend = ohci_bus_suspend, | 266 | .bus_suspend = ohci_bus_suspend, |
266 | .bus_resume = ohci_bus_resume, | 267 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c index 1b9abdba920b..f90fe0c7373f 100644 --- a/drivers/usb/host/ohci-au1xxx.c +++ b/drivers/usb/host/ohci-au1xxx.c | |||
@@ -288,6 +288,7 @@ static const struct hc_driver ohci_au1xxx_hc_driver = { | |||
288 | */ | 288 | */ |
289 | .hub_status_data = ohci_hub_status_data, | 289 | .hub_status_data = ohci_hub_status_data, |
290 | .hub_control = ohci_hub_control, | 290 | .hub_control = ohci_hub_control, |
291 | .hub_irq_enable = ohci_rhsc_enable, | ||
291 | #ifdef CONFIG_PM | 292 | #ifdef CONFIG_PM |
292 | .bus_suspend = ohci_bus_suspend, | 293 | .bus_suspend = ohci_bus_suspend, |
293 | .bus_resume = ohci_bus_resume, | 294 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 06aadfb0ec29..5adaf36e47d0 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -135,6 +135,7 @@ static struct hc_driver ohci_ep93xx_hc_driver = { | |||
135 | .get_frame_number = ohci_get_frame, | 135 | .get_frame_number = ohci_get_frame, |
136 | .hub_status_data = ohci_hub_status_data, | 136 | .hub_status_data = ohci_hub_status_data, |
137 | .hub_control = ohci_hub_control, | 137 | .hub_control = ohci_hub_control, |
138 | .hub_irq_enable = ohci_rhsc_enable, | ||
138 | #ifdef CONFIG_PM | 139 | #ifdef CONFIG_PM |
139 | .bus_suspend = ohci_bus_suspend, | 140 | .bus_suspend = ohci_bus_suspend, |
140 | .bus_resume = ohci_bus_resume, | 141 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 33f1c1c32edf..a8160d65f32b 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -1054,7 +1054,7 @@ MODULE_LICENSE ("GPL"); | |||
1054 | 1054 | ||
1055 | #ifdef CONFIG_MFD_SM501 | 1055 | #ifdef CONFIG_MFD_SM501 |
1056 | #include "ohci-sm501.c" | 1056 | #include "ohci-sm501.c" |
1057 | #define PLATFORM_DRIVER ohci_hcd_sm501_driver | 1057 | #define SM501_OHCI_DRIVER ohci_hcd_sm501_driver |
1058 | #endif | 1058 | #endif |
1059 | 1059 | ||
1060 | #if !defined(PCI_DRIVER) && \ | 1060 | #if !defined(PCI_DRIVER) && \ |
@@ -1062,6 +1062,7 @@ MODULE_LICENSE ("GPL"); | |||
1062 | !defined(OF_PLATFORM_DRIVER) && \ | 1062 | !defined(OF_PLATFORM_DRIVER) && \ |
1063 | !defined(SA1111_DRIVER) && \ | 1063 | !defined(SA1111_DRIVER) && \ |
1064 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ | 1064 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ |
1065 | !defined(SM501_OHCI_DRIVER) && \ | ||
1065 | !defined(SSB_OHCI_DRIVER) | 1066 | !defined(SSB_OHCI_DRIVER) |
1066 | #error "missing bus glue for ohci-hcd" | 1067 | #error "missing bus glue for ohci-hcd" |
1067 | #endif | 1068 | #endif |
@@ -1121,9 +1122,18 @@ static int __init ohci_hcd_mod_init(void) | |||
1121 | goto error_ssb; | 1122 | goto error_ssb; |
1122 | #endif | 1123 | #endif |
1123 | 1124 | ||
1125 | #ifdef SM501_OHCI_DRIVER | ||
1126 | retval = platform_driver_register(&SM501_OHCI_DRIVER); | ||
1127 | if (retval < 0) | ||
1128 | goto error_sm501; | ||
1129 | #endif | ||
1130 | |||
1124 | return retval; | 1131 | return retval; |
1125 | 1132 | ||
1126 | /* Error path */ | 1133 | /* Error path */ |
1134 | #ifdef SM501_OHCI_DRIVER | ||
1135 | error_sm501: | ||
1136 | #endif | ||
1127 | #ifdef SSB_OHCI_DRIVER | 1137 | #ifdef SSB_OHCI_DRIVER |
1128 | error_ssb: | 1138 | error_ssb: |
1129 | #endif | 1139 | #endif |
@@ -1159,6 +1169,9 @@ module_init(ohci_hcd_mod_init); | |||
1159 | 1169 | ||
1160 | static void __exit ohci_hcd_mod_exit(void) | 1170 | static void __exit ohci_hcd_mod_exit(void) |
1161 | { | 1171 | { |
1172 | #ifdef SM501_OHCI_DRIVER | ||
1173 | platform_driver_unregister(&SM501_OHCI_DRIVER); | ||
1174 | #endif | ||
1162 | #ifdef SSB_OHCI_DRIVER | 1175 | #ifdef SSB_OHCI_DRIVER |
1163 | ssb_driver_unregister(&SSB_OHCI_DRIVER); | 1176 | ssb_driver_unregister(&SSB_OHCI_DRIVER); |
1164 | #endif | 1177 | #endif |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 79a78029f896..b56739221d11 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -36,6 +36,18 @@ | |||
36 | 36 | ||
37 | /*-------------------------------------------------------------------------*/ | 37 | /*-------------------------------------------------------------------------*/ |
38 | 38 | ||
39 | /* hcd->hub_irq_enable() */ | ||
40 | static void ohci_rhsc_enable (struct usb_hcd *hcd) | ||
41 | { | ||
42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
43 | |||
44 | spin_lock_irq(&ohci->lock); | ||
45 | if (!ohci->autostop) | ||
46 | del_timer(&hcd->rh_timer); /* Prevent next poll */ | ||
47 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
48 | spin_unlock_irq(&ohci->lock); | ||
49 | } | ||
50 | |||
39 | #define OHCI_SCHED_ENABLES \ | 51 | #define OHCI_SCHED_ENABLES \ |
40 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) | 52 | (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) |
41 | 53 | ||
@@ -362,28 +374,18 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
362 | int any_connected) | 374 | int any_connected) |
363 | { | 375 | { |
364 | int poll_rh = 1; | 376 | int poll_rh = 1; |
365 | int rhsc; | ||
366 | 377 | ||
367 | rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC; | ||
368 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | 378 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { |
369 | 379 | ||
370 | case OHCI_USB_OPER: | 380 | case OHCI_USB_OPER: |
371 | /* If no status changes are pending, enable status-change | 381 | /* keep on polling until we know a device is connected |
372 | * interrupts. | 382 | * and RHSC is enabled */ |
373 | */ | ||
374 | if (!rhsc && !changed) { | ||
375 | rhsc = OHCI_INTR_RHSC; | ||
376 | ohci_writel(ohci, rhsc, &ohci->regs->intrenable); | ||
377 | } | ||
378 | |||
379 | /* Keep on polling until we know a device is connected | ||
380 | * and RHSC is enabled, or until we autostop. | ||
381 | */ | ||
382 | if (!ohci->autostop) { | 383 | if (!ohci->autostop) { |
383 | if (any_connected || | 384 | if (any_connected || |
384 | !device_may_wakeup(&ohci_to_hcd(ohci) | 385 | !device_may_wakeup(&ohci_to_hcd(ohci) |
385 | ->self.root_hub->dev)) { | 386 | ->self.root_hub->dev)) { |
386 | if (rhsc) | 387 | if (ohci_readl(ohci, &ohci->regs->intrenable) & |
388 | OHCI_INTR_RHSC) | ||
387 | poll_rh = 0; | 389 | poll_rh = 0; |
388 | } else { | 390 | } else { |
389 | ohci->autostop = 1; | 391 | ohci->autostop = 1; |
@@ -396,13 +398,12 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
396 | ohci->autostop = 0; | 398 | ohci->autostop = 0; |
397 | ohci->next_statechange = jiffies + | 399 | ohci->next_statechange = jiffies + |
398 | STATECHANGE_DELAY; | 400 | STATECHANGE_DELAY; |
399 | } else if (rhsc && time_after_eq(jiffies, | 401 | } else if (time_after_eq(jiffies, |
400 | ohci->next_statechange) | 402 | ohci->next_statechange) |
401 | && !ohci->ed_rm_list | 403 | && !ohci->ed_rm_list |
402 | && !(ohci->hc_control & | 404 | && !(ohci->hc_control & |
403 | OHCI_SCHED_ENABLES)) { | 405 | OHCI_SCHED_ENABLES)) { |
404 | ohci_rh_suspend(ohci, 1); | 406 | ohci_rh_suspend(ohci, 1); |
405 | poll_rh = 0; | ||
406 | } | 407 | } |
407 | } | 408 | } |
408 | break; | 409 | break; |
@@ -416,12 +417,6 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | |||
416 | else | 417 | else |
417 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); | 418 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); |
418 | } else { | 419 | } else { |
419 | if (!rhsc && (ohci->autostop || | ||
420 | ohci_to_hcd(ohci)->self.root_hub-> | ||
421 | do_remote_wakeup)) | ||
422 | ohci_writel(ohci, OHCI_INTR_RHSC, | ||
423 | &ohci->regs->intrenable); | ||
424 | |||
425 | /* everything is idle, no need for polling */ | 420 | /* everything is idle, no need for polling */ |
426 | poll_rh = 0; | 421 | poll_rh = 0; |
427 | } | 422 | } |
@@ -443,16 +438,12 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci) | |||
443 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 438 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
444 | int any_connected) | 439 | int any_connected) |
445 | { | 440 | { |
446 | /* If RHSC is enabled, don't poll */ | 441 | int poll_rh = 1; |
447 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) | ||
448 | return 0; | ||
449 | 442 | ||
450 | /* If no status changes are pending, enable status-change interrupts */ | 443 | /* keep on polling until RHSC is enabled */ |
451 | if (!changed) { | 444 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) |
452 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | 445 | poll_rh = 0; |
453 | return 0; | 446 | return poll_rh; |
454 | } | ||
455 | return 1; | ||
456 | } | 447 | } |
457 | 448 | ||
458 | #endif /* CONFIG_PM */ | 449 | #endif /* CONFIG_PM */ |
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c index 96d14fa1d833..13c12ed22252 100644 --- a/drivers/usb/host/ohci-lh7a404.c +++ b/drivers/usb/host/ohci-lh7a404.c | |||
@@ -193,6 +193,7 @@ static const struct hc_driver ohci_lh7a404_hc_driver = { | |||
193 | */ | 193 | */ |
194 | .hub_status_data = ohci_hub_status_data, | 194 | .hub_status_data = ohci_hub_status_data, |
195 | .hub_control = ohci_hub_control, | 195 | .hub_control = ohci_hub_control, |
196 | .hub_irq_enable = ohci_rhsc_enable, | ||
196 | #ifdef CONFIG_PM | 197 | #ifdef CONFIG_PM |
197 | .bus_suspend = ohci_bus_suspend, | 198 | .bus_suspend = ohci_bus_suspend, |
198 | .bus_resume = ohci_bus_resume, | 199 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 6859fb5f1d6f..3a7c24c03671 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -466,6 +466,7 @@ static const struct hc_driver ohci_omap_hc_driver = { | |||
466 | */ | 466 | */ |
467 | .hub_status_data = ohci_hub_status_data, | 467 | .hub_status_data = ohci_hub_status_data, |
468 | .hub_control = ohci_hub_control, | 468 | .hub_control = ohci_hub_control, |
469 | .hub_irq_enable = ohci_rhsc_enable, | ||
469 | #ifdef CONFIG_PM | 470 | #ifdef CONFIG_PM |
470 | .bus_suspend = ohci_bus_suspend, | 471 | .bus_suspend = ohci_bus_suspend, |
471 | .bus_resume = ohci_bus_resume, | 472 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 3bf175d95a23..4696cc912e16 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -327,6 +327,7 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
327 | */ | 327 | */ |
328 | .hub_status_data = ohci_hub_status_data, | 328 | .hub_status_data = ohci_hub_status_data, |
329 | .hub_control = ohci_hub_control, | 329 | .hub_control = ohci_hub_control, |
330 | .hub_irq_enable = ohci_rhsc_enable, | ||
330 | #ifdef CONFIG_PM | 331 | #ifdef CONFIG_PM |
331 | .bus_suspend = ohci_bus_suspend, | 332 | .bus_suspend = ohci_bus_suspend, |
332 | .bus_resume = ohci_bus_resume, | 333 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c index 664f07ee8732..28b458f20cc3 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-pnx4008.c | |||
@@ -280,6 +280,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
280 | */ | 280 | */ |
281 | .hub_status_data = ohci_hub_status_data, | 281 | .hub_status_data = ohci_hub_status_data, |
282 | .hub_control = ohci_hub_control, | 282 | .hub_control = ohci_hub_control, |
283 | .hub_irq_enable = ohci_rhsc_enable, | ||
283 | #ifdef CONFIG_PM | 284 | #ifdef CONFIG_PM |
284 | .bus_suspend = ohci_bus_suspend, | 285 | .bus_suspend = ohci_bus_suspend, |
285 | .bus_resume = ohci_bus_resume, | 286 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c index 28467e288a93..605d59cba28e 100644 --- a/drivers/usb/host/ohci-pnx8550.c +++ b/drivers/usb/host/ohci-pnx8550.c | |||
@@ -201,6 +201,7 @@ static const struct hc_driver ohci_pnx8550_hc_driver = { | |||
201 | */ | 201 | */ |
202 | .hub_status_data = ohci_hub_status_data, | 202 | .hub_status_data = ohci_hub_status_data, |
203 | .hub_control = ohci_hub_control, | 203 | .hub_control = ohci_hub_control, |
204 | .hub_irq_enable = ohci_rhsc_enable, | ||
204 | #ifdef CONFIG_PM | 205 | #ifdef CONFIG_PM |
205 | .bus_suspend = ohci_bus_suspend, | 206 | .bus_suspend = ohci_bus_suspend, |
206 | .bus_resume = ohci_bus_resume, | 207 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c index 50e55db13636..a67252791223 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
@@ -72,6 +72,7 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { | |||
72 | */ | 72 | */ |
73 | .hub_status_data = ohci_hub_status_data, | 73 | .hub_status_data = ohci_hub_status_data, |
74 | .hub_control = ohci_hub_control, | 74 | .hub_control = ohci_hub_control, |
75 | .hub_irq_enable = ohci_rhsc_enable, | ||
75 | #ifdef CONFIG_PM | 76 | #ifdef CONFIG_PM |
76 | .bus_suspend = ohci_bus_suspend, | 77 | .bus_suspend = ohci_bus_suspend, |
77 | .bus_resume = ohci_bus_resume, | 78 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c index cd3398b675b2..523c30125577 100644 --- a/drivers/usb/host/ohci-ppc-soc.c +++ b/drivers/usb/host/ohci-ppc-soc.c | |||
@@ -172,6 +172,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = { | |||
172 | */ | 172 | */ |
173 | .hub_status_data = ohci_hub_status_data, | 173 | .hub_status_data = ohci_hub_status_data, |
174 | .hub_control = ohci_hub_control, | 174 | .hub_control = ohci_hub_control, |
175 | .hub_irq_enable = ohci_rhsc_enable, | ||
175 | #ifdef CONFIG_PM | 176 | #ifdef CONFIG_PM |
176 | .bus_suspend = ohci_bus_suspend, | 177 | .bus_suspend = ohci_bus_suspend, |
177 | .bus_resume = ohci_bus_resume, | 178 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c index bfdeb0d22d05..c1935ae537f8 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
@@ -68,6 +68,7 @@ static const struct hc_driver ps3_ohci_hc_driver = { | |||
68 | .get_frame_number = ohci_get_frame, | 68 | .get_frame_number = ohci_get_frame, |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
71 | .start_port_reset = ohci_start_port_reset, | 72 | .start_port_reset = ohci_start_port_reset, |
72 | #if defined(CONFIG_PM) | 73 | #if defined(CONFIG_PM) |
73 | .bus_suspend = ohci_bus_suspend, | 74 | .bus_suspend = ohci_bus_suspend, |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 70b0d4b459e7..d4ee27d92be8 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -298,6 +298,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { | |||
298 | */ | 298 | */ |
299 | .hub_status_data = ohci_hub_status_data, | 299 | .hub_status_data = ohci_hub_status_data, |
300 | .hub_control = ohci_hub_control, | 300 | .hub_control = ohci_hub_control, |
301 | .hub_irq_enable = ohci_rhsc_enable, | ||
301 | #ifdef CONFIG_PM | 302 | #ifdef CONFIG_PM |
302 | .bus_suspend = ohci_bus_suspend, | 303 | .bus_suspend = ohci_bus_suspend, |
303 | .bus_resume = ohci_bus_resume, | 304 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index 9c9f3b59186f..9b547407c934 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -952,6 +952,7 @@ rescan_this: | |||
952 | struct urb *urb; | 952 | struct urb *urb; |
953 | urb_priv_t *urb_priv; | 953 | urb_priv_t *urb_priv; |
954 | __hc32 savebits; | 954 | __hc32 savebits; |
955 | u32 tdINFO; | ||
955 | 956 | ||
956 | td = list_entry (entry, struct td, td_list); | 957 | td = list_entry (entry, struct td, td_list); |
957 | urb = td->urb; | 958 | urb = td->urb; |
@@ -966,6 +967,17 @@ rescan_this: | |||
966 | savebits = *prev & ~cpu_to_hc32 (ohci, TD_MASK); | 967 | savebits = *prev & ~cpu_to_hc32 (ohci, TD_MASK); |
967 | *prev = td->hwNextTD | savebits; | 968 | *prev = td->hwNextTD | savebits; |
968 | 969 | ||
970 | /* If this was unlinked, the TD may not have been | ||
971 | * retired ... so manually save the data toggle. | ||
972 | * The controller ignores the value we save for | ||
973 | * control and ISO endpoints. | ||
974 | */ | ||
975 | tdINFO = hc32_to_cpup(ohci, &td->hwINFO); | ||
976 | if ((tdINFO & TD_T) == TD_T_DATA0) | ||
977 | ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_C); | ||
978 | else if ((tdINFO & TD_T) == TD_T_DATA1) | ||
979 | ed->hwHeadP |= cpu_to_hc32(ohci, ED_C); | ||
980 | |||
969 | /* HC may have partly processed this TD */ | 981 | /* HC may have partly processed this TD */ |
970 | td_done (ohci, urb, td); | 982 | td_done (ohci, urb, td); |
971 | urb_priv->td_cnt++; | 983 | urb_priv->td_cnt++; |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index a73d2ff322e2..ead4772f0f27 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -466,6 +466,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
466 | */ | 466 | */ |
467 | .hub_status_data = ohci_s3c2410_hub_status_data, | 467 | .hub_status_data = ohci_s3c2410_hub_status_data, |
468 | .hub_control = ohci_s3c2410_hub_control, | 468 | .hub_control = ohci_s3c2410_hub_control, |
469 | .hub_irq_enable = ohci_rhsc_enable, | ||
469 | #ifdef CONFIG_PM | 470 | #ifdef CONFIG_PM |
470 | .bus_suspend = ohci_bus_suspend, | 471 | .bus_suspend = ohci_bus_suspend, |
471 | .bus_resume = ohci_bus_resume, | 472 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 99438c65981b..0f48f2d99226 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
@@ -231,6 +231,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = { | |||
231 | */ | 231 | */ |
232 | .hub_status_data = ohci_hub_status_data, | 232 | .hub_status_data = ohci_hub_status_data, |
233 | .hub_control = ohci_hub_control, | 233 | .hub_control = ohci_hub_control, |
234 | .hub_irq_enable = ohci_rhsc_enable, | ||
234 | #ifdef CONFIG_PM | 235 | #ifdef CONFIG_PM |
235 | .bus_suspend = ohci_bus_suspend, | 236 | .bus_suspend = ohci_bus_suspend, |
236 | .bus_resume = ohci_bus_resume, | 237 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index 60f03cc7ec4f..e7ee607278fe 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -68,6 +68,7 @@ static const struct hc_driver ohci_sh_hc_driver = { | |||
68 | */ | 68 | */ |
69 | .hub_status_data = ohci_hub_status_data, | 69 | .hub_status_data = ohci_hub_status_data, |
70 | .hub_control = ohci_hub_control, | 70 | .hub_control = ohci_hub_control, |
71 | .hub_irq_enable = ohci_rhsc_enable, | ||
71 | #ifdef CONFIG_PM | 72 | #ifdef CONFIG_PM |
72 | .bus_suspend = ohci_bus_suspend, | 73 | .bus_suspend = ohci_bus_suspend, |
73 | .bus_resume = ohci_bus_resume, | 74 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index e899a77dfb83..e610698c6b60 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -75,6 +75,7 @@ static const struct hc_driver ohci_sm501_hc_driver = { | |||
75 | */ | 75 | */ |
76 | .hub_status_data = ohci_hub_status_data, | 76 | .hub_status_data = ohci_hub_status_data, |
77 | .hub_control = ohci_hub_control, | 77 | .hub_control = ohci_hub_control, |
78 | .hub_irq_enable = ohci_rhsc_enable, | ||
78 | #ifdef CONFIG_PM | 79 | #ifdef CONFIG_PM |
79 | .bus_suspend = ohci_bus_suspend, | 80 | .bus_suspend = ohci_bus_suspend, |
80 | .bus_resume = ohci_bus_resume, | 81 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c index c4265caec780..7275186db315 100644 --- a/drivers/usb/host/ohci-ssb.c +++ b/drivers/usb/host/ohci-ssb.c | |||
@@ -81,6 +81,7 @@ static const struct hc_driver ssb_ohci_hc_driver = { | |||
81 | 81 | ||
82 | .hub_status_data = ohci_hub_status_data, | 82 | .hub_status_data = ohci_hub_status_data, |
83 | .hub_control = ohci_hub_control, | 83 | .hub_control = ohci_hub_control, |
84 | .hub_irq_enable = ohci_rhsc_enable, | ||
84 | #ifdef CONFIG_PM | 85 | #ifdef CONFIG_PM |
85 | .bus_suspend = ohci_bus_suspend, | 86 | .bus_suspend = ohci_bus_suspend, |
86 | .bus_resume = ohci_bus_resume, | 87 | .bus_resume = ohci_bus_resume, |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index f29307405bb3..9b6323f768b2 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -2934,6 +2934,16 @@ static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num) | |||
2934 | return 0; | 2934 | return 0; |
2935 | } | 2935 | } |
2936 | 2936 | ||
2937 | static void u132_hub_irq_enable(struct usb_hcd *hcd) | ||
2938 | { | ||
2939 | struct u132 *u132 = hcd_to_u132(hcd); | ||
2940 | if (u132->going > 1) { | ||
2941 | dev_err(&u132->platform_dev->dev, "device has been removed %d\n" | ||
2942 | , u132->going); | ||
2943 | } else if (u132->going > 0) | ||
2944 | dev_err(&u132->platform_dev->dev, "device is being removed\n"); | ||
2945 | } | ||
2946 | |||
2937 | 2947 | ||
2938 | #ifdef CONFIG_PM | 2948 | #ifdef CONFIG_PM |
2939 | static int u132_bus_suspend(struct usb_hcd *hcd) | 2949 | static int u132_bus_suspend(struct usb_hcd *hcd) |
@@ -2985,6 +2995,7 @@ static struct hc_driver u132_hc_driver = { | |||
2985 | .bus_suspend = u132_bus_suspend, | 2995 | .bus_suspend = u132_bus_suspend, |
2986 | .bus_resume = u132_bus_resume, | 2996 | .bus_resume = u132_bus_resume, |
2987 | .start_port_reset = u132_start_port_reset, | 2997 | .start_port_reset = u132_start_port_reset, |
2998 | .hub_irq_enable = u132_hub_irq_enable, | ||
2988 | }; | 2999 | }; |
2989 | 3000 | ||
2990 | /* | 3001 | /* |
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index cb7fa0eaf3ae..33182f4c2267 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c | |||
@@ -3264,8 +3264,6 @@ static void sisusb_disconnect(struct usb_interface *intf) | |||
3264 | 3264 | ||
3265 | /* decrement our usage count */ | 3265 | /* decrement our usage count */ |
3266 | kref_put(&sisusb->kref, sisusb_delete); | 3266 | kref_put(&sisusb->kref, sisusb_delete); |
3267 | |||
3268 | dev_info(&sisusb->sisusb_dev->dev, "Disconnected\n"); | ||
3269 | } | 3267 | } |
3270 | 3268 | ||
3271 | static struct usb_device_id sisusb_table [] = { | 3269 | static struct usb_device_id sisusb_table [] = { |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 5234e7a3bd2c..0ff4a3971e45 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -637,6 +637,7 @@ static struct usb_device_id id_table_combined [] = { | |||
637 | { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), | 637 | { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), |
638 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 638 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
639 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, | 639 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, |
640 | { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, | ||
640 | { }, /* Optional parameter entry */ | 641 | { }, /* Optional parameter entry */ |
641 | { } /* Terminating entry */ | 642 | { } /* Terminating entry */ |
642 | }; | 643 | }; |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 06e0ecabb3eb..8302eca893ea 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -828,6 +828,9 @@ | |||
828 | /* Propox devices */ | 828 | /* Propox devices */ |
829 | #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 | 829 | #define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 |
830 | 830 | ||
831 | /* Rig Expert Ukraine devices */ | ||
832 | #define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ | ||
833 | |||
831 | /* Commands */ | 834 | /* Commands */ |
832 | #define FTDI_SIO_RESET 0 /* Reset the port */ | 835 | #define FTDI_SIO_RESET 0 /* Reset the port */ |
833 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ | 836 | #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index ea924dc48496..d9fb3768a2d7 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -570,7 +570,12 @@ static struct usb_serial_driver ipaq_device = { | |||
570 | .description = "PocketPC PDA", | 570 | .description = "PocketPC PDA", |
571 | .usb_driver = &ipaq_driver, | 571 | .usb_driver = &ipaq_driver, |
572 | .id_table = ipaq_id_table, | 572 | .id_table = ipaq_id_table, |
573 | .num_ports = 2, | 573 | /* |
574 | * some devices have an extra endpoint, which | ||
575 | * must be ignored as it would make the core | ||
576 | * create a second port which oopses when used | ||
577 | */ | ||
578 | .num_ports = 1, | ||
574 | .open = ipaq_open, | 579 | .open = ipaq_open, |
575 | .close = ipaq_close, | 580 | .close = ipaq_close, |
576 | .attach = ipaq_startup, | 581 | .attach = ipaq_startup, |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 43cfde83a93b..a73420dd052a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -306,6 +306,7 @@ static struct usb_device_id option_ids[] = { | |||
306 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 306 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, |
307 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 307 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, |
308 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 308 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
309 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ | ||
309 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ | 310 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ |
310 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ | 311 | { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ |
311 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, | 312 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 103195abd417..2a0dd1b50dc4 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -57,6 +57,7 @@ static struct usb_device_id id_table [] = { | |||
57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, | 57 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, |
58 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, | 58 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, |
59 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, | 59 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, |
60 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, | ||
60 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, | 61 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, |
61 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, | 62 | { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, |
62 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, | 63 | { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index cff160abb130..6ac3bbcf7a22 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 | 15 | #define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 |
16 | #define PL2303_PRODUCT_ID_ALDIGA 0x0611 | 16 | #define PL2303_PRODUCT_ID_ALDIGA 0x0611 |
17 | #define PL2303_PRODUCT_ID_MMX 0x0612 | 17 | #define PL2303_PRODUCT_ID_MMX 0x0612 |
18 | #define PL2303_PRODUCT_ID_GPRS 0x0609 | ||
18 | 19 | ||
19 | #define ATEN_VENDOR_ID 0x0557 | 20 | #define ATEN_VENDOR_ID 0x0557 |
20 | #define ATEN_VENDOR_ID2 0x0547 | 21 | #define ATEN_VENDOR_ID2 0x0547 |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 45fe3663fa7f..39a7c11795c4 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -402,11 +402,19 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100, | |||
402 | US_FL_IGNORE_RESIDUE ), | 402 | US_FL_IGNORE_RESIDUE ), |
403 | 403 | ||
404 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB | 404 | #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB |
405 | /* CY7C68300 : support atacb */ | ||
405 | UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, | 406 | UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, |
406 | "Cypress", | 407 | "Cypress", |
407 | "Cypress AT2LP", | 408 | "Cypress AT2LP", |
408 | US_SC_CYP_ATACB, US_PR_DEVICE, NULL, | 409 | US_SC_CYP_ATACB, US_PR_DEVICE, NULL, |
409 | 0), | 410 | 0), |
411 | |||
412 | /* CY7C68310 : support atacb and atacb2 */ | ||
413 | UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999, | ||
414 | "Cypress", | ||
415 | "Cypress ISD-300LP", | ||
416 | US_SC_CYP_ATACB, US_PR_DEVICE, NULL, | ||
417 | 0), | ||
410 | #endif | 418 | #endif |
411 | 419 | ||
412 | /* Reported by Simon Levitt <simon@whattf.com> | 420 | /* Reported by Simon Levitt <simon@whattf.com> |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 002b61b4f0f6..e0c5f96b273d 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1825,12 +1825,13 @@ config FB_FSL_DIU | |||
1825 | 1825 | ||
1826 | config FB_W100 | 1826 | config FB_W100 |
1827 | tristate "W100 frame buffer support" | 1827 | tristate "W100 frame buffer support" |
1828 | depends on FB && PXA_SHARPSL | 1828 | depends on FB && ARCH_PXA |
1829 | select FB_CFB_FILLRECT | 1829 | select FB_CFB_FILLRECT |
1830 | select FB_CFB_COPYAREA | 1830 | select FB_CFB_COPYAREA |
1831 | select FB_CFB_IMAGEBLIT | 1831 | select FB_CFB_IMAGEBLIT |
1832 | ---help--- | 1832 | ---help--- |
1833 | Frame buffer driver for the w100 as found on the Sharp SL-Cxx series. | 1833 | Frame buffer driver for the w100 as found on the Sharp SL-Cxx series. |
1834 | It can also drive the w3220 chip found on iPAQ hx4700. | ||
1834 | 1835 | ||
1835 | This driver is also available as a module ( = code which can be | 1836 | This driver is also available as a module ( = code which can be |
1836 | inserted and removed from the running kernel whenever you want). The | 1837 | inserted and removed from the running kernel whenever you want). The |
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c index 0a2785361ca3..09d7e22c6fef 100644 --- a/drivers/video/fsl-diu-fb.c +++ b/drivers/video/fsl-diu-fb.c | |||
@@ -286,7 +286,7 @@ static struct diu_pool pool; | |||
286 | * rheap and make the furture large allocation fail. | 286 | * rheap and make the furture large allocation fail. |
287 | */ | 287 | */ |
288 | 288 | ||
289 | void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys) | 289 | static void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys) |
290 | { | 290 | { |
291 | void *virt; | 291 | void *virt; |
292 | 292 | ||
@@ -311,12 +311,12 @@ void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys) | |||
311 | memset(virt, 0, size); | 311 | memset(virt, 0, size); |
312 | } | 312 | } |
313 | 313 | ||
314 | pr_debug("rh virt=%p phys=%lx\n", virt, *phys); | 314 | pr_debug("rh virt=%p phys=%llx\n", virt, (unsigned long long)*phys); |
315 | 315 | ||
316 | return virt; | 316 | return virt; |
317 | } | 317 | } |
318 | 318 | ||
319 | void fsl_diu_free(void *p, unsigned long size) | 319 | static void fsl_diu_free(void *p, unsigned long size) |
320 | { | 320 | { |
321 | pr_debug("p=%p size=%lu\n", p, size); | 321 | pr_debug("p=%p size=%lu\n", p, size); |
322 | 322 | ||
@@ -770,7 +770,7 @@ static int map_video_memory(struct fb_info *info) | |||
770 | info->fix.smem_len = info->fix.line_length * info->var.yres_virtual; | 770 | info->fix.smem_len = info->fix.line_length * info->var.yres_virtual; |
771 | pr_debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->fix.smem_len); | 771 | pr_debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->fix.smem_len); |
772 | info->screen_base = fsl_diu_alloc(info->fix.smem_len, &phys); | 772 | info->screen_base = fsl_diu_alloc(info->fix.smem_len, &phys); |
773 | if (info->screen_base == 0) { | 773 | if (info->screen_base == NULL) { |
774 | printk(KERN_ERR "Unable to allocate fb memory\n"); | 774 | printk(KERN_ERR "Unable to allocate fb memory\n"); |
775 | return -ENOMEM; | 775 | return -ENOMEM; |
776 | } | 776 | } |
@@ -788,7 +788,7 @@ static int map_video_memory(struct fb_info *info) | |||
788 | static void unmap_video_memory(struct fb_info *info) | 788 | static void unmap_video_memory(struct fb_info *info) |
789 | { | 789 | { |
790 | fsl_diu_free(info->screen_base, info->fix.smem_len); | 790 | fsl_diu_free(info->screen_base, info->fix.smem_len); |
791 | info->screen_base = 0; | 791 | info->screen_base = NULL; |
792 | info->fix.smem_start = 0; | 792 | info->fix.smem_start = 0; |
793 | info->fix.smem_len = 0; | 793 | info->fix.smem_len = 0; |
794 | } | 794 | } |
@@ -1158,7 +1158,7 @@ static int init_fbinfo(struct fb_info *info) | |||
1158 | return 0; | 1158 | return 0; |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | static int install_fb(struct fb_info *info) | 1161 | static int __devinit install_fb(struct fb_info *info) |
1162 | { | 1162 | { |
1163 | int rc; | 1163 | int rc; |
1164 | struct mfb_info *mfbi = info->par; | 1164 | struct mfb_info *mfbi = info->par; |
@@ -1233,7 +1233,7 @@ static int install_fb(struct fb_info *info) | |||
1233 | return 0; | 1233 | return 0; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | static void __exit uninstall_fb(struct fb_info *info) | 1236 | static void uninstall_fb(struct fb_info *info) |
1237 | { | 1237 | { |
1238 | struct mfb_info *mfbi = info->par; | 1238 | struct mfb_info *mfbi = info->par; |
1239 | 1239 | ||
@@ -1287,7 +1287,7 @@ static int request_irq_local(int irq) | |||
1287 | /* Read to clear the status */ | 1287 | /* Read to clear the status */ |
1288 | status = in_be32(&hw->int_status); | 1288 | status = in_be32(&hw->int_status); |
1289 | 1289 | ||
1290 | ret = request_irq(irq, fsl_diu_isr, 0, "diu", 0); | 1290 | ret = request_irq(irq, fsl_diu_isr, 0, "diu", NULL); |
1291 | if (ret) | 1291 | if (ret) |
1292 | pr_info("Request diu IRQ failed.\n"); | 1292 | pr_info("Request diu IRQ failed.\n"); |
1293 | else { | 1293 | else { |
@@ -1312,7 +1312,7 @@ static void free_irq_local(int irq) | |||
1312 | /* Disable all LCDC interrupt */ | 1312 | /* Disable all LCDC interrupt */ |
1313 | out_be32(&hw->int_mask, 0x1f); | 1313 | out_be32(&hw->int_mask, 0x1f); |
1314 | 1314 | ||
1315 | free_irq(irq, 0); | 1315 | free_irq(irq, NULL); |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | #ifdef CONFIG_PM | 1318 | #ifdef CONFIG_PM |
@@ -1353,7 +1353,8 @@ static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align) | |||
1353 | dma_addr_t paddr = 0; | 1353 | dma_addr_t paddr = 0; |
1354 | 1354 | ||
1355 | ssize = size + bytes_align; | 1355 | ssize = size + bytes_align; |
1356 | buf->vaddr = dma_alloc_coherent(0, ssize, &paddr, GFP_DMA | __GFP_ZERO); | 1356 | buf->vaddr = dma_alloc_coherent(NULL, ssize, &paddr, GFP_DMA | |
1357 | __GFP_ZERO); | ||
1357 | if (!buf->vaddr) | 1358 | if (!buf->vaddr) |
1358 | return -ENOMEM; | 1359 | return -ENOMEM; |
1359 | 1360 | ||
@@ -1371,7 +1372,7 @@ static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align) | |||
1371 | 1372 | ||
1372 | static void free_buf(struct diu_addr *buf, u32 size, u32 bytes_align) | 1373 | static void free_buf(struct diu_addr *buf, u32 size, u32 bytes_align) |
1373 | { | 1374 | { |
1374 | dma_free_coherent(0, size + bytes_align, | 1375 | dma_free_coherent(NULL, size + bytes_align, |
1375 | buf->vaddr, (buf->paddr - buf->offset)); | 1376 | buf->vaddr, (buf->paddr - buf->offset)); |
1376 | return; | 1377 | return; |
1377 | } | 1378 | } |
@@ -1411,7 +1412,7 @@ static ssize_t show_monitor(struct device *device, | |||
1411 | return diu_ops.show_monitor_port(machine_data->monitor_port, buf); | 1412 | return diu_ops.show_monitor_port(machine_data->monitor_port, buf); |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | static int fsl_diu_probe(struct of_device *ofdev, | 1415 | static int __devinit fsl_diu_probe(struct of_device *ofdev, |
1415 | const struct of_device_id *match) | 1416 | const struct of_device_id *match) |
1416 | { | 1417 | { |
1417 | struct device_node *np = ofdev->node; | 1418 | struct device_node *np = ofdev->node; |
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 7dcda187d9ba..fafe7db20d6d 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -1246,7 +1246,7 @@ static int pxafb_resume(struct platform_device *dev) | |||
1246 | * cache. Once this area is remapped, all virtual memory | 1246 | * cache. Once this area is remapped, all virtual memory |
1247 | * access to the video memory should occur at the new region. | 1247 | * access to the video memory should occur at the new region. |
1248 | */ | 1248 | */ |
1249 | static int __init pxafb_map_video_memory(struct pxafb_info *fbi) | 1249 | static int __devinit pxafb_map_video_memory(struct pxafb_info *fbi) |
1250 | { | 1250 | { |
1251 | /* | 1251 | /* |
1252 | * We reserve one page for the palette, plus the size | 1252 | * We reserve one page for the palette, plus the size |
@@ -1348,7 +1348,7 @@ decode_mode: | |||
1348 | pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes); | 1348 | pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes); |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev) | 1351 | static struct pxafb_info * __devinit pxafb_init_fbinfo(struct device *dev) |
1352 | { | 1352 | { |
1353 | struct pxafb_info *fbi; | 1353 | struct pxafb_info *fbi; |
1354 | void *addr; | 1354 | void *addr; |
@@ -1410,7 +1410,7 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev) | |||
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | #ifdef CONFIG_FB_PXA_PARAMETERS | 1412 | #ifdef CONFIG_FB_PXA_PARAMETERS |
1413 | static int __init parse_opt_mode(struct device *dev, const char *this_opt) | 1413 | static int __devinit parse_opt_mode(struct device *dev, const char *this_opt) |
1414 | { | 1414 | { |
1415 | struct pxafb_mach_info *inf = dev->platform_data; | 1415 | struct pxafb_mach_info *inf = dev->platform_data; |
1416 | 1416 | ||
@@ -1469,7 +1469,7 @@ done: | |||
1469 | return 0; | 1469 | return 0; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | static int __init parse_opt(struct device *dev, char *this_opt) | 1472 | static int __devinit parse_opt(struct device *dev, char *this_opt) |
1473 | { | 1473 | { |
1474 | struct pxafb_mach_info *inf = dev->platform_data; | 1474 | struct pxafb_mach_info *inf = dev->platform_data; |
1475 | struct pxafb_mode_info *mode = &inf->modes[0]; | 1475 | struct pxafb_mode_info *mode = &inf->modes[0]; |
@@ -1567,7 +1567,7 @@ static int __init parse_opt(struct device *dev, char *this_opt) | |||
1567 | return 0; | 1567 | return 0; |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | static int __init pxafb_parse_options(struct device *dev, char *options) | 1570 | static int __devinit pxafb_parse_options(struct device *dev, char *options) |
1571 | { | 1571 | { |
1572 | char *this_opt; | 1572 | char *this_opt; |
1573 | int ret; | 1573 | int ret; |
@@ -1588,8 +1588,8 @@ static int __init pxafb_parse_options(struct device *dev, char *options) | |||
1588 | 1588 | ||
1589 | static char g_options[256] __devinitdata = ""; | 1589 | static char g_options[256] __devinitdata = ""; |
1590 | 1590 | ||
1591 | #ifndef CONFIG_MODULES | 1591 | #ifndef MODULE |
1592 | static int __devinit pxafb_setup_options(void) | 1592 | static int __init pxafb_setup_options(void) |
1593 | { | 1593 | { |
1594 | char *options = NULL; | 1594 | char *options = NULL; |
1595 | 1595 | ||
@@ -1613,7 +1613,7 @@ MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)"); | |||
1613 | #define pxafb_setup_options() (0) | 1613 | #define pxafb_setup_options() (0) |
1614 | #endif | 1614 | #endif |
1615 | 1615 | ||
1616 | static int __init pxafb_probe(struct platform_device *dev) | 1616 | static int __devinit pxafb_probe(struct platform_device *dev) |
1617 | { | 1617 | { |
1618 | struct pxafb_info *fbi; | 1618 | struct pxafb_info *fbi; |
1619 | struct pxafb_mach_info *inf; | 1619 | struct pxafb_mach_info *inf; |
@@ -1685,14 +1685,14 @@ static int __init pxafb_probe(struct platform_device *dev) | |||
1685 | if (r == NULL) { | 1685 | if (r == NULL) { |
1686 | dev_err(&dev->dev, "no I/O memory resource defined\n"); | 1686 | dev_err(&dev->dev, "no I/O memory resource defined\n"); |
1687 | ret = -ENODEV; | 1687 | ret = -ENODEV; |
1688 | goto failed; | 1688 | goto failed_fbi; |
1689 | } | 1689 | } |
1690 | 1690 | ||
1691 | r = request_mem_region(r->start, r->end - r->start + 1, dev->name); | 1691 | r = request_mem_region(r->start, r->end - r->start + 1, dev->name); |
1692 | if (r == NULL) { | 1692 | if (r == NULL) { |
1693 | dev_err(&dev->dev, "failed to request I/O memory\n"); | 1693 | dev_err(&dev->dev, "failed to request I/O memory\n"); |
1694 | ret = -EBUSY; | 1694 | ret = -EBUSY; |
1695 | goto failed; | 1695 | goto failed_fbi; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | fbi->mmio_base = ioremap(r->start, r->end - r->start + 1); | 1698 | fbi->mmio_base = ioremap(r->start, r->end - r->start + 1); |
@@ -1735,8 +1735,17 @@ static int __init pxafb_probe(struct platform_device *dev) | |||
1735 | * This makes sure that our colour bitfield | 1735 | * This makes sure that our colour bitfield |
1736 | * descriptors are correctly initialised. | 1736 | * descriptors are correctly initialised. |
1737 | */ | 1737 | */ |
1738 | pxafb_check_var(&fbi->fb.var, &fbi->fb); | 1738 | ret = pxafb_check_var(&fbi->fb.var, &fbi->fb); |
1739 | pxafb_set_par(&fbi->fb); | 1739 | if (ret) { |
1740 | dev_err(&dev->dev, "failed to get suitable mode\n"); | ||
1741 | goto failed_free_irq; | ||
1742 | } | ||
1743 | |||
1744 | ret = pxafb_set_par(&fbi->fb); | ||
1745 | if (ret) { | ||
1746 | dev_err(&dev->dev, "Failed to set parameters\n"); | ||
1747 | goto failed_free_irq; | ||
1748 | } | ||
1740 | 1749 | ||
1741 | platform_set_drvdata(dev, fbi); | 1750 | platform_set_drvdata(dev, fbi); |
1742 | 1751 | ||
@@ -1744,7 +1753,7 @@ static int __init pxafb_probe(struct platform_device *dev) | |||
1744 | if (ret < 0) { | 1753 | if (ret < 0) { |
1745 | dev_err(&dev->dev, | 1754 | dev_err(&dev->dev, |
1746 | "Failed to register framebuffer device: %d\n", ret); | 1755 | "Failed to register framebuffer device: %d\n", ret); |
1747 | goto failed_free_irq; | 1756 | goto failed_free_cmap; |
1748 | } | 1757 | } |
1749 | 1758 | ||
1750 | #ifdef CONFIG_CPU_FREQ | 1759 | #ifdef CONFIG_CPU_FREQ |
@@ -1763,18 +1772,23 @@ static int __init pxafb_probe(struct platform_device *dev) | |||
1763 | 1772 | ||
1764 | return 0; | 1773 | return 0; |
1765 | 1774 | ||
1775 | failed_free_cmap: | ||
1776 | if (fbi->fb.cmap.len) | ||
1777 | fb_dealloc_cmap(&fbi->fb.cmap); | ||
1766 | failed_free_irq: | 1778 | failed_free_irq: |
1767 | free_irq(irq, fbi); | 1779 | free_irq(irq, fbi); |
1768 | failed_free_res: | ||
1769 | release_mem_region(r->start, r->end - r->start + 1); | ||
1770 | failed_free_io: | ||
1771 | iounmap(fbi->mmio_base); | ||
1772 | failed_free_mem: | 1780 | failed_free_mem: |
1773 | dma_free_writecombine(&dev->dev, fbi->map_size, | 1781 | dma_free_writecombine(&dev->dev, fbi->map_size, |
1774 | fbi->map_cpu, fbi->map_dma); | 1782 | fbi->map_cpu, fbi->map_dma); |
1775 | failed: | 1783 | failed_free_io: |
1784 | iounmap(fbi->mmio_base); | ||
1785 | failed_free_res: | ||
1786 | release_mem_region(r->start, r->end - r->start + 1); | ||
1787 | failed_fbi: | ||
1788 | clk_put(fbi->clk); | ||
1776 | platform_set_drvdata(dev, NULL); | 1789 | platform_set_drvdata(dev, NULL); |
1777 | kfree(fbi); | 1790 | kfree(fbi); |
1791 | failed: | ||
1778 | return ret; | 1792 | return ret; |
1779 | } | 1793 | } |
1780 | 1794 | ||
@@ -1787,7 +1801,7 @@ static struct platform_driver pxafb_driver = { | |||
1787 | }, | 1801 | }, |
1788 | }; | 1802 | }; |
1789 | 1803 | ||
1790 | static int __devinit pxafb_init(void) | 1804 | static int __init pxafb_init(void) |
1791 | { | 1805 | { |
1792 | if (pxafb_setup_options()) | 1806 | if (pxafb_setup_options()) |
1793 | return -EINVAL; | 1807 | return -EINVAL; |
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c index 30469bf906e5..d0674f1e3f10 100644 --- a/drivers/video/w100fb.c +++ b/drivers/video/w100fb.c | |||
@@ -1003,6 +1003,7 @@ static struct w100_pll_info xtal_14318000[] = { | |||
1003 | static struct w100_pll_info xtal_16000000[] = { | 1003 | static struct w100_pll_info xtal_16000000[] = { |
1004 | /*freq M N_int N_fac tfgoal lock_time */ | 1004 | /*freq M N_int N_fac tfgoal lock_time */ |
1005 | { 72, 1, 8, 0, 0xe0, 48}, /* tfgoal guessed */ | 1005 | { 72, 1, 8, 0, 0xe0, 48}, /* tfgoal guessed */ |
1006 | { 80, 1, 9, 0, 0xe0, 13}, /* tfgoal guessed */ | ||
1006 | { 95, 1, 10, 7, 0xe0, 38}, /* tfgoal guessed */ | 1007 | { 95, 1, 10, 7, 0xe0, 38}, /* tfgoal guessed */ |
1007 | { 96, 1, 11, 0, 0xe0, 36}, /* tfgoal guessed */ | 1008 | { 96, 1, 11, 0, 0xe0, 36}, /* tfgoal guessed */ |
1008 | { 0, 0, 0, 0, 0, 0}, | 1009 | { 0, 0, 0, 0, 0, 0}, |