diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-10-07 14:08:56 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-10-07 14:08:56 -0400 |
commit | 5a89770daad83df74d77a8d34a1ffaedae565ce9 (patch) | |
tree | 0d8ef70293a6ef969ba8b7718e59608337643d40 /drivers | |
parent | c46c948260f41af18b277c1eb1895d788d3605dc (diff) | |
parent | af7c951d76708c61b862463d579d76be757130bf (diff) |
Merge branches 'pxa-core' and 'pxa-machines' into pxa-all
Conflicts:
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/pxa25x.c
arch/arm/mach-pxa/pxa27x.c
Diffstat (limited to 'drivers')
324 files changed, 8441 insertions, 5471 deletions
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c index 1022e38994c2..0f2805899210 100644 --- a/drivers/acpi/dispatcher/dsobject.c +++ b/drivers/acpi/dispatcher/dsobject.c | |||
@@ -496,7 +496,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state, | |||
496 | arg = arg->common.next; | 496 | arg = arg->common.next; |
497 | } | 497 | } |
498 | 498 | ||
499 | ACPI_ERROR((AE_INFO, | 499 | ACPI_WARNING((AE_INFO, |
500 | "Package List length (%X) larger than NumElements count (%X), truncated\n", | 500 | "Package List length (%X) larger than NumElements count (%X), truncated\n", |
501 | i, element_count)); | 501 | i, element_count)); |
502 | } else if (i < element_count) { | 502 | } else if (i < element_count) { |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index d3f0a62efcc1..ee68ac54c0d4 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -138,7 +138,7 @@ static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = { | |||
138 | { | 138 | { |
139 | set_no_mwait, "Extensa 5220", { | 139 | set_no_mwait, "Extensa 5220", { |
140 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), | 140 | DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), |
141 | DMI_MATCH(DMI_SYS_VENDOR, "ACER"), | 141 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
142 | DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), | 142 | DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), |
143 | DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, | 143 | DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL}, |
144 | {}, | 144 | {}, |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 80e32093e977..80c251ec6d2a 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -71,7 +71,7 @@ static DEFINE_MUTEX(performance_mutex); | |||
71 | * 1 -> ignore _PPC totally -> forced by user through boot param | 71 | * 1 -> ignore _PPC totally -> forced by user through boot param |
72 | */ | 72 | */ |
73 | static int ignore_ppc = -1; | 73 | static int ignore_ppc = -1; |
74 | module_param(ignore_ppc, uint, 0644); | 74 | module_param(ignore_ppc, int, 0644); |
75 | MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \ | 75 | MODULE_PARM_DESC(ignore_ppc, "If the frequency of your machine gets wrongly" \ |
76 | "limited by BIOS, this should help"); | 76 | "limited by BIOS, this should help"); |
77 | 77 | ||
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index bcf2c70fca87..a4e3767b8c64 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -107,6 +107,13 @@ static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout) | |||
107 | if (wait_event_timeout(hc->wait, smb_check_done(hc), | 107 | if (wait_event_timeout(hc->wait, smb_check_done(hc), |
108 | msecs_to_jiffies(timeout))) | 108 | msecs_to_jiffies(timeout))) |
109 | return 0; | 109 | return 0; |
110 | /* | ||
111 | * After the timeout happens, OS will try to check the status of SMbus. | ||
112 | * If the status is what OS expected, it will be regarded as the bogus | ||
113 | * timeout. | ||
114 | */ | ||
115 | if (smb_check_done(hc)) | ||
116 | return 0; | ||
110 | else | 117 | else |
111 | return -ETIME; | 118 | return -ETIME; |
112 | } | 119 | } |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index c3419182c9a7..775c97a282bd 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -300,6 +300,8 @@ int __init acpi_table_init(void) | |||
300 | 300 | ||
301 | static int __init acpi_parse_apic_instance(char *str) | 301 | static int __init acpi_parse_apic_instance(char *str) |
302 | { | 302 | { |
303 | if (!str) | ||
304 | return -EINVAL; | ||
303 | 305 | ||
304 | acpi_apic_instance = simple_strtoul(str, NULL, 0); | 306 | acpi_apic_instance = simple_strtoul(str, NULL, 0); |
305 | 307 | ||
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index ae8494944c45..11c8c19f0fb7 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -448,8 +448,10 @@ config PATA_MARVELL | |||
448 | tristate "Marvell PATA support via legacy mode" | 448 | tristate "Marvell PATA support via legacy mode" |
449 | depends on PCI | 449 | depends on PCI |
450 | help | 450 | help |
451 | This option enables limited support for the Marvell 88SE6145 ATA | 451 | This option enables limited support for the Marvell 88SE61xx ATA |
452 | controller. | 452 | controllers. If you wish to use only the SATA ports then select |
453 | the AHCI driver alone. If you wish to the use the PATA port or | ||
454 | both SATA and PATA include this driver. | ||
453 | 455 | ||
454 | If unsure, say N. | 456 | If unsure, say N. |
455 | 457 | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index c729e6988bbb..2e1a7cb2ed5f 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -420,7 +420,7 @@ static const struct ata_port_info ahci_port_info[] = { | |||
420 | /* board_ahci_mv */ | 420 | /* board_ahci_mv */ |
421 | { | 421 | { |
422 | AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI | | 422 | AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI | |
423 | AHCI_HFLAG_MV_PATA), | 423 | AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP), |
424 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 424 | .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
425 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, | 425 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, |
426 | .pio_mask = 0x1f, /* pio0-4 */ | 426 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -487,7 +487,9 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
487 | { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */ | 487 | { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */ |
488 | { PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */ | 488 | { PCI_VDEVICE(INTEL, 0x3a25), board_ahci }, /* ICH10 */ |
489 | { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */ | 489 | { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */ |
490 | { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */ | ||
490 | { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ | 491 | { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ |
492 | { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ | ||
491 | 493 | ||
492 | /* JMicron 360/1/3/5/6, match class to avoid IDE function */ | 494 | /* JMicron 360/1/3/5/6, match class to avoid IDE function */ |
493 | { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 495 | { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
@@ -610,6 +612,15 @@ module_param(ahci_em_messages, int, 0444); | |||
610 | MODULE_PARM_DESC(ahci_em_messages, | 612 | MODULE_PARM_DESC(ahci_em_messages, |
611 | "Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED"); | 613 | "Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED"); |
612 | 614 | ||
615 | #if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE) | ||
616 | static int marvell_enable; | ||
617 | #else | ||
618 | static int marvell_enable = 1; | ||
619 | #endif | ||
620 | module_param(marvell_enable, int, 0644); | ||
621 | MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); | ||
622 | |||
623 | |||
613 | static inline int ahci_nr_ports(u32 cap) | 624 | static inline int ahci_nr_ports(u32 cap) |
614 | { | 625 | { |
615 | return (cap & 0x1f) + 1; | 626 | return (cap & 0x1f) + 1; |
@@ -732,6 +743,8 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
732 | "MV_AHCI HACK: port_map %x -> %x\n", | 743 | "MV_AHCI HACK: port_map %x -> %x\n", |
733 | port_map, | 744 | port_map, |
734 | port_map & mv); | 745 | port_map & mv); |
746 | dev_printk(KERN_ERR, &pdev->dev, | ||
747 | "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n"); | ||
735 | 748 | ||
736 | port_map &= mv; | 749 | port_map &= mv; |
737 | } | 750 | } |
@@ -2533,6 +2546,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2533 | if (!printed_version++) | 2546 | if (!printed_version++) |
2534 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 2547 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
2535 | 2548 | ||
2549 | /* The AHCI driver can only drive the SATA ports, the PATA driver | ||
2550 | can drive them all so if both drivers are selected make sure | ||
2551 | AHCI stays out of the way */ | ||
2552 | if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable) | ||
2553 | return -ENODEV; | ||
2554 | |||
2536 | /* acquire resources */ | 2555 | /* acquire resources */ |
2537 | rc = pcim_enable_device(pdev); | 2556 | rc = pcim_enable_device(pdev); |
2538 | if (rc) | 2557 | if (rc) |
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 304fdc6f1dc2..2a4c516894f0 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1315,11 +1315,6 @@ fsm_start: | |||
1315 | break; | 1315 | break; |
1316 | 1316 | ||
1317 | case HSM_ST_ERR: | 1317 | case HSM_ST_ERR: |
1318 | /* make sure qc->err_mask is available to | ||
1319 | * know what's wrong and recover | ||
1320 | */ | ||
1321 | WARN_ON(!(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM))); | ||
1322 | |||
1323 | ap->hsm_task_state = HSM_ST_IDLE; | 1318 | ap->hsm_task_state = HSM_ST_IDLE; |
1324 | 1319 | ||
1325 | /* complete taskfile transaction */ | 1320 | /* complete taskfile transaction */ |
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 24a011b25024..0d87eec84966 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c | |||
@@ -20,29 +20,30 @@ | |||
20 | #include <linux/ata.h> | 20 | #include <linux/ata.h> |
21 | 21 | ||
22 | #define DRV_NAME "pata_marvell" | 22 | #define DRV_NAME "pata_marvell" |
23 | #define DRV_VERSION "0.1.4" | 23 | #define DRV_VERSION "0.1.6" |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * marvell_pre_reset - check for 40/80 pin | 26 | * marvell_pata_active - check if PATA is active |
27 | * @link: link | 27 | * @pdev: PCI device |
28 | * @deadline: deadline jiffies for the operation | ||
29 | * | 28 | * |
30 | * Perform the PATA port setup we need. | 29 | * Returns 1 if the PATA port may be active. We know how to check this |
30 | * for the 6145 but not the other devices | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) | 33 | static int marvell_pata_active(struct pci_dev *pdev) |
34 | { | 34 | { |
35 | struct ata_port *ap = link->ap; | 35 | int i; |
36 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | ||
37 | u32 devices; | 36 | u32 devices; |
38 | void __iomem *barp; | 37 | void __iomem *barp; |
39 | int i; | ||
40 | 38 | ||
41 | /* Check if our port is enabled */ | 39 | /* We don't yet know how to do this for other devices */ |
40 | if (pdev->device != 0x6145) | ||
41 | return 1; | ||
42 | 42 | ||
43 | barp = pci_iomap(pdev, 5, 0x10); | 43 | barp = pci_iomap(pdev, 5, 0x10); |
44 | if (barp == NULL) | 44 | if (barp == NULL) |
45 | return -ENOMEM; | 45 | return -ENOMEM; |
46 | |||
46 | printk("BAR5:"); | 47 | printk("BAR5:"); |
47 | for(i = 0; i <= 0x0F; i++) | 48 | for(i = 0; i <= 0x0F; i++) |
48 | printk("%02X:%02X ", i, ioread8(barp + i)); | 49 | printk("%02X:%02X ", i, ioread8(barp + i)); |
@@ -51,9 +52,27 @@ static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) | |||
51 | devices = ioread32(barp + 0x0C); | 52 | devices = ioread32(barp + 0x0C); |
52 | pci_iounmap(pdev, barp); | 53 | pci_iounmap(pdev, barp); |
53 | 54 | ||
54 | if ((pdev->device == 0x6145) && (ap->port_no == 0) && | 55 | if (devices & 0x10) |
55 | (!(devices & 0x10))) /* PATA enable ? */ | 56 | return 1; |
56 | return -ENOENT; | 57 | return 0; |
58 | } | ||
59 | |||
60 | /** | ||
61 | * marvell_pre_reset - check for 40/80 pin | ||
62 | * @link: link | ||
63 | * @deadline: deadline jiffies for the operation | ||
64 | * | ||
65 | * Perform the PATA port setup we need. | ||
66 | */ | ||
67 | |||
68 | static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) | ||
69 | { | ||
70 | struct ata_port *ap = link->ap; | ||
71 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | ||
72 | |||
73 | if (pdev->device == 0x6145 && ap->port_no == 0 && | ||
74 | !marvell_pata_active(pdev)) /* PATA enable ? */ | ||
75 | return -ENOENT; | ||
57 | 76 | ||
58 | return ata_sff_prereset(link, deadline); | 77 | return ata_sff_prereset(link, deadline); |
59 | } | 78 | } |
@@ -128,6 +147,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i | |||
128 | if (pdev->device == 0x6101) | 147 | if (pdev->device == 0x6101) |
129 | ppi[1] = &ata_dummy_port_info; | 148 | ppi[1] = &ata_dummy_port_info; |
130 | 149 | ||
150 | #if defined(CONFIG_AHCI) || defined(CONFIG_AHCI_MODULE) | ||
151 | if (!marvell_pata_active(pdev)) { | ||
152 | printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n"); | ||
153 | return -ENODEV; | ||
154 | } | ||
155 | #endif | ||
131 | return ata_pci_sff_init_one(pdev, ppi, &marvell_sht, NULL); | 156 | return ata_pci_sff_init_one(pdev, ppi, &marvell_sht, NULL); |
132 | } | 157 | } |
133 | 158 | ||
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index 720b8645f58a..e970b227fbce 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -322,9 +322,6 @@ static int __devinit sil680_init_one(struct pci_dev *pdev, | |||
322 | /* Try to acquire MMIO resources and fallback to PIO if | 322 | /* Try to acquire MMIO resources and fallback to PIO if |
323 | * that fails | 323 | * that fails |
324 | */ | 324 | */ |
325 | rc = pcim_enable_device(pdev); | ||
326 | if (rc) | ||
327 | return rc; | ||
328 | rc = pcim_iomap_regions(pdev, 1 << SIL680_MMIO_BAR, DRV_NAME); | 325 | rc = pcim_iomap_regions(pdev, 1 << SIL680_MMIO_BAR, DRV_NAME); |
329 | if (rc) | 326 | if (rc) |
330 | goto use_ioports; | 327 | goto use_ioports; |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 13c1d2af18ac..c815f8ecf6e6 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -667,7 +667,8 @@ static const struct pci_device_id mv_pci_tbl[] = { | |||
667 | { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, | 667 | { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, |
668 | { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, | 668 | { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, |
669 | { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, | 669 | { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, |
670 | /* RocketRAID 1740/174x have different identifiers */ | 670 | /* RocketRAID 1720/174x have different identifiers */ |
671 | { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, | ||
671 | { PCI_VDEVICE(TTI, 0x1740), chip_508x }, | 672 | { PCI_VDEVICE(TTI, 0x1740), chip_508x }, |
672 | { PCI_VDEVICE(TTI, 0x1742), chip_508x }, | 673 | { PCI_VDEVICE(TTI, 0x1742), chip_508x }, |
673 | 674 | ||
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 858f70610eda..1e1f3f3757ae 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -309,8 +309,6 @@ static void nv_nf2_freeze(struct ata_port *ap); | |||
309 | static void nv_nf2_thaw(struct ata_port *ap); | 309 | static void nv_nf2_thaw(struct ata_port *ap); |
310 | static void nv_ck804_freeze(struct ata_port *ap); | 310 | static void nv_ck804_freeze(struct ata_port *ap); |
311 | static void nv_ck804_thaw(struct ata_port *ap); | 311 | static void nv_ck804_thaw(struct ata_port *ap); |
312 | static int nv_hardreset(struct ata_link *link, unsigned int *class, | ||
313 | unsigned long deadline); | ||
314 | static int nv_adma_slave_config(struct scsi_device *sdev); | 312 | static int nv_adma_slave_config(struct scsi_device *sdev); |
315 | static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); | 313 | static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); |
316 | static void nv_adma_qc_prep(struct ata_queued_cmd *qc); | 314 | static void nv_adma_qc_prep(struct ata_queued_cmd *qc); |
@@ -407,7 +405,7 @@ static struct scsi_host_template nv_swncq_sht = { | |||
407 | 405 | ||
408 | static struct ata_port_operations nv_generic_ops = { | 406 | static struct ata_port_operations nv_generic_ops = { |
409 | .inherits = &ata_bmdma_port_ops, | 407 | .inherits = &ata_bmdma_port_ops, |
410 | .hardreset = nv_hardreset, | 408 | .hardreset = ATA_OP_NULL, |
411 | .scr_read = nv_scr_read, | 409 | .scr_read = nv_scr_read, |
412 | .scr_write = nv_scr_write, | 410 | .scr_write = nv_scr_write, |
413 | }; | 411 | }; |
@@ -1588,21 +1586,6 @@ static void nv_mcp55_thaw(struct ata_port *ap) | |||
1588 | ata_sff_thaw(ap); | 1586 | ata_sff_thaw(ap); |
1589 | } | 1587 | } |
1590 | 1588 | ||
1591 | static int nv_hardreset(struct ata_link *link, unsigned int *class, | ||
1592 | unsigned long deadline) | ||
1593 | { | ||
1594 | int rc; | ||
1595 | |||
1596 | /* SATA hardreset fails to retrieve proper device signature on | ||
1597 | * some controllers. Request follow up SRST. For more info, | ||
1598 | * see http://bugzilla.kernel.org/show_bug.cgi?id=3352 | ||
1599 | */ | ||
1600 | rc = sata_sff_hardreset(link, class, deadline); | ||
1601 | if (rc) | ||
1602 | return rc; | ||
1603 | return -EAGAIN; | ||
1604 | } | ||
1605 | |||
1606 | static void nv_adma_error_handler(struct ata_port *ap) | 1589 | static void nv_adma_error_handler(struct ata_port *ap) |
1607 | { | 1590 | { |
1608 | struct nv_adma_port_priv *pp = ap->private_data; | 1591 | struct nv_adma_port_priv *pp = ap->private_data; |
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 158eed4d5161..29b7a648cc6e 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/types.h> | 49 | #include <linux/types.h> |
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
51 | #include <linux/kthread.h> | 51 | #include <linux/kthread.h> |
52 | #include <linux/smp_lock.h> | ||
53 | #include <linux/errno.h> | 52 | #include <linux/errno.h> |
54 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
55 | #include <linux/file.h> | 54 | #include <linux/file.h> |
@@ -2798,14 +2797,9 @@ out_mem: | |||
2798 | return ret; | 2797 | return ret; |
2799 | } | 2798 | } |
2800 | 2799 | ||
2801 | static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 2800 | static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
2802 | { | 2801 | { |
2803 | struct inode *inode = file->f_path.dentry->d_inode; | 2802 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; |
2804 | struct pktcdvd_device *pd; | ||
2805 | long ret; | ||
2806 | |||
2807 | lock_kernel(); | ||
2808 | pd = inode->i_bdev->bd_disk->private_data; | ||
2809 | 2803 | ||
2810 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); | 2804 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); |
2811 | 2805 | ||
@@ -2818,8 +2812,7 @@ static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2818 | case CDROM_LAST_WRITTEN: | 2812 | case CDROM_LAST_WRITTEN: |
2819 | case CDROM_SEND_PACKET: | 2813 | case CDROM_SEND_PACKET: |
2820 | case SCSI_IOCTL_SEND_COMMAND: | 2814 | case SCSI_IOCTL_SEND_COMMAND: |
2821 | ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | 2815 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); |
2822 | break; | ||
2823 | 2816 | ||
2824 | case CDROMEJECT: | 2817 | case CDROMEJECT: |
2825 | /* | 2818 | /* |
@@ -2828,15 +2821,14 @@ static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2828 | */ | 2821 | */ |
2829 | if (pd->refcnt == 1) | 2822 | if (pd->refcnt == 1) |
2830 | pkt_lock_door(pd, 0); | 2823 | pkt_lock_door(pd, 0); |
2831 | ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | 2824 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); |
2832 | break; | ||
2833 | 2825 | ||
2834 | default: | 2826 | default: |
2835 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); | 2827 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); |
2836 | ret = -ENOTTY; | 2828 | return -ENOTTY; |
2837 | } | 2829 | } |
2838 | unlock_kernel(); | 2830 | |
2839 | return ret; | 2831 | return 0; |
2840 | } | 2832 | } |
2841 | 2833 | ||
2842 | static int pkt_media_changed(struct gendisk *disk) | 2834 | static int pkt_media_changed(struct gendisk *disk) |
@@ -2858,7 +2850,7 @@ static struct block_device_operations pktcdvd_ops = { | |||
2858 | .owner = THIS_MODULE, | 2850 | .owner = THIS_MODULE, |
2859 | .open = pkt_open, | 2851 | .open = pkt_open, |
2860 | .release = pkt_close, | 2852 | .release = pkt_close, |
2861 | .unlocked_ioctl = pkt_ioctl, | 2853 | .ioctl = pkt_ioctl, |
2862 | .media_changed = pkt_media_changed, | 2854 | .media_changed = pkt_media_changed, |
2863 | }; | 2855 | }; |
2864 | 2856 | ||
@@ -3023,8 +3015,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd) | |||
3023 | mutex_unlock(&ctl_mutex); | 3015 | mutex_unlock(&ctl_mutex); |
3024 | } | 3016 | } |
3025 | 3017 | ||
3026 | static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | 3018 | static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
3027 | unsigned long arg) | ||
3028 | { | 3019 | { |
3029 | void __user *argp = (void __user *)arg; | 3020 | void __user *argp = (void __user *)arg; |
3030 | struct pkt_ctrl_command ctrl_cmd; | 3021 | struct pkt_ctrl_command ctrl_cmd; |
@@ -3041,22 +3032,16 @@ static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | |||
3041 | case PKT_CTRL_CMD_SETUP: | 3032 | case PKT_CTRL_CMD_SETUP: |
3042 | if (!capable(CAP_SYS_ADMIN)) | 3033 | if (!capable(CAP_SYS_ADMIN)) |
3043 | return -EPERM; | 3034 | return -EPERM; |
3044 | lock_kernel(); | ||
3045 | ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); | 3035 | ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); |
3046 | ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); | 3036 | ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); |
3047 | unlock_kernel(); | ||
3048 | break; | 3037 | break; |
3049 | case PKT_CTRL_CMD_TEARDOWN: | 3038 | case PKT_CTRL_CMD_TEARDOWN: |
3050 | if (!capable(CAP_SYS_ADMIN)) | 3039 | if (!capable(CAP_SYS_ADMIN)) |
3051 | return -EPERM; | 3040 | return -EPERM; |
3052 | lock_kernel(); | ||
3053 | ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); | 3041 | ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); |
3054 | unlock_kernel(); | ||
3055 | break; | 3042 | break; |
3056 | case PKT_CTRL_CMD_STATUS: | 3043 | case PKT_CTRL_CMD_STATUS: |
3057 | lock_kernel(); | ||
3058 | pkt_get_status(&ctrl_cmd); | 3044 | pkt_get_status(&ctrl_cmd); |
3059 | unlock_kernel(); | ||
3060 | break; | 3045 | break; |
3061 | default: | 3046 | default: |
3062 | return -ENOTTY; | 3047 | return -ENOTTY; |
@@ -3069,7 +3054,7 @@ static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | |||
3069 | 3054 | ||
3070 | 3055 | ||
3071 | static const struct file_operations pkt_ctl_fops = { | 3056 | static const struct file_operations pkt_ctl_fops = { |
3072 | .unlocked_ioctl = pkt_ctl_ioctl, | 3057 | .ioctl = pkt_ctl_ioctl, |
3073 | .owner = THIS_MODULE, | 3058 | .owner = THIS_MODULE, |
3074 | }; | 3059 | }; |
3075 | 3060 | ||
diff --git a/drivers/char/random.c b/drivers/char/random.c index 1838aa3d24fe..7ce1ac4baa6d 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -407,7 +407,7 @@ struct entropy_store { | |||
407 | /* read-write data: */ | 407 | /* read-write data: */ |
408 | spinlock_t lock; | 408 | spinlock_t lock; |
409 | unsigned add_ptr; | 409 | unsigned add_ptr; |
410 | int entropy_count; | 410 | int entropy_count; /* Must at no time exceed ->POOLBITS! */ |
411 | int input_rotate; | 411 | int input_rotate; |
412 | }; | 412 | }; |
413 | 413 | ||
@@ -520,6 +520,7 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes) | |||
520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) | 520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) |
521 | { | 521 | { |
522 | unsigned long flags; | 522 | unsigned long flags; |
523 | int entropy_count; | ||
523 | 524 | ||
524 | if (!nbits) | 525 | if (!nbits) |
525 | return; | 526 | return; |
@@ -527,20 +528,20 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) | |||
527 | spin_lock_irqsave(&r->lock, flags); | 528 | spin_lock_irqsave(&r->lock, flags); |
528 | 529 | ||
529 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); | 530 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); |
530 | r->entropy_count += nbits; | 531 | entropy_count = r->entropy_count; |
531 | if (r->entropy_count < 0) { | 532 | entropy_count += nbits; |
533 | if (entropy_count < 0) { | ||
532 | DEBUG_ENT("negative entropy/overflow\n"); | 534 | DEBUG_ENT("negative entropy/overflow\n"); |
533 | r->entropy_count = 0; | 535 | entropy_count = 0; |
534 | } else if (r->entropy_count > r->poolinfo->POOLBITS) | 536 | } else if (entropy_count > r->poolinfo->POOLBITS) |
535 | r->entropy_count = r->poolinfo->POOLBITS; | 537 | entropy_count = r->poolinfo->POOLBITS; |
538 | r->entropy_count = entropy_count; | ||
536 | 539 | ||
537 | /* should we wake readers? */ | 540 | /* should we wake readers? */ |
538 | if (r == &input_pool && | 541 | if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) { |
539 | r->entropy_count >= random_read_wakeup_thresh) { | ||
540 | wake_up_interruptible(&random_read_wait); | 542 | wake_up_interruptible(&random_read_wait); |
541 | kill_fasync(&fasync, SIGIO, POLL_IN); | 543 | kill_fasync(&fasync, SIGIO, POLL_IN); |
542 | } | 544 | } |
543 | |||
544 | spin_unlock_irqrestore(&r->lock, flags); | 545 | spin_unlock_irqrestore(&r->lock, flags); |
545 | } | 546 | } |
546 | 547 | ||
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index a27160ba21d7..daeb8f766971 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2498,7 +2498,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2498 | /** | 2498 | /** |
2499 | * tty_do_resize - resize event | 2499 | * tty_do_resize - resize event |
2500 | * @tty: tty being resized | 2500 | * @tty: tty being resized |
2501 | * @real_tty: real tty (if using a pty/tty pair) | 2501 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) |
2502 | * @rows: rows (character) | 2502 | * @rows: rows (character) |
2503 | * @cols: cols (character) | 2503 | * @cols: cols (character) |
2504 | * | 2504 | * |
@@ -2512,7 +2512,8 @@ int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2512 | struct pid *pgrp, *rpgrp; | 2512 | struct pid *pgrp, *rpgrp; |
2513 | unsigned long flags; | 2513 | unsigned long flags; |
2514 | 2514 | ||
2515 | mutex_lock(&tty->termios_mutex); | 2515 | /* For a PTY we need to lock the tty side */ |
2516 | mutex_lock(&real_tty->termios_mutex); | ||
2516 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) | 2517 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) |
2517 | goto done; | 2518 | goto done; |
2518 | /* Get the PID values and reference them so we can | 2519 | /* Get the PID values and reference them so we can |
@@ -2533,7 +2534,7 @@ int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2533 | tty->winsize = *ws; | 2534 | tty->winsize = *ws; |
2534 | real_tty->winsize = *ws; | 2535 | real_tty->winsize = *ws; |
2535 | done: | 2536 | done: |
2536 | mutex_unlock(&tty->termios_mutex); | 2537 | mutex_unlock(&real_tty->termios_mutex); |
2537 | return 0; | 2538 | return 0; |
2538 | } | 2539 | } |
2539 | 2540 | ||
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index ea9fc5d03b99..bf34e4597421 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c | |||
@@ -937,12 +937,14 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file, | |||
937 | return 0; | 937 | return 0; |
938 | #endif | 938 | #endif |
939 | case TIOCGSOFTCAR: | 939 | case TIOCGSOFTCAR: |
940 | return put_user(C_CLOCAL(tty) ? 1 : 0, | 940 | /* FIXME: for correctness we may need to take the termios |
941 | lock here - review */ | ||
942 | return put_user(C_CLOCAL(real_tty) ? 1 : 0, | ||
941 | (int __user *)arg); | 943 | (int __user *)arg); |
942 | case TIOCSSOFTCAR: | 944 | case TIOCSSOFTCAR: |
943 | if (get_user(arg, (unsigned int __user *) arg)) | 945 | if (get_user(arg, (unsigned int __user *) arg)) |
944 | return -EFAULT; | 946 | return -EFAULT; |
945 | return tty_change_softcar(tty, arg); | 947 | return tty_change_softcar(real_tty, arg); |
946 | default: | 948 | default: |
947 | return -ENOIOCTLCMD; | 949 | return -ENOIOCTLCMD; |
948 | } | 950 | } |
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c index 5ca1d80de182..4eee533f3f4a 100644 --- a/drivers/clocksource/acpi_pm.c +++ b/drivers/clocksource/acpi_pm.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
24 | #include <linux/delay.h> | ||
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
25 | 26 | ||
26 | /* | 27 | /* |
@@ -151,13 +152,13 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE, | |||
151 | */ | 152 | */ |
152 | static int verify_pmtmr_rate(void) | 153 | static int verify_pmtmr_rate(void) |
153 | { | 154 | { |
154 | u32 value1, value2; | 155 | cycle_t value1, value2; |
155 | unsigned long count, delta; | 156 | unsigned long count, delta; |
156 | 157 | ||
157 | mach_prepare_counter(); | 158 | mach_prepare_counter(); |
158 | value1 = read_pmtmr(); | 159 | value1 = clocksource_acpi_pm.read(); |
159 | mach_countup(&count); | 160 | mach_countup(&count); |
160 | value2 = read_pmtmr(); | 161 | value2 = clocksource_acpi_pm.read(); |
161 | delta = (value2 - value1) & ACPI_PM_MASK; | 162 | delta = (value2 - value1) & ACPI_PM_MASK; |
162 | 163 | ||
163 | /* Check that the PMTMR delta is within 5% of what we expect */ | 164 | /* Check that the PMTMR delta is within 5% of what we expect */ |
@@ -175,10 +176,13 @@ static int verify_pmtmr_rate(void) | |||
175 | #define verify_pmtmr_rate() (0) | 176 | #define verify_pmtmr_rate() (0) |
176 | #endif | 177 | #endif |
177 | 178 | ||
179 | /* Number of monotonicity checks to perform during initialization */ | ||
180 | #define ACPI_PM_MONOTONICITY_CHECKS 10 | ||
181 | |||
178 | static int __init init_acpi_pm_clocksource(void) | 182 | static int __init init_acpi_pm_clocksource(void) |
179 | { | 183 | { |
180 | u32 value1, value2; | 184 | cycle_t value1, value2; |
181 | unsigned int i; | 185 | unsigned int i, j, good = 0; |
182 | 186 | ||
183 | if (!pmtmr_ioport) | 187 | if (!pmtmr_ioport) |
184 | return -ENODEV; | 188 | return -ENODEV; |
@@ -187,24 +191,32 @@ static int __init init_acpi_pm_clocksource(void) | |||
187 | clocksource_acpi_pm.shift); | 191 | clocksource_acpi_pm.shift); |
188 | 192 | ||
189 | /* "verify" this timing source: */ | 193 | /* "verify" this timing source: */ |
190 | value1 = read_pmtmr(); | 194 | for (j = 0; j < ACPI_PM_MONOTONICITY_CHECKS; j++) { |
191 | for (i = 0; i < 10000; i++) { | 195 | value1 = clocksource_acpi_pm.read(); |
192 | value2 = read_pmtmr(); | 196 | for (i = 0; i < 10000; i++) { |
193 | if (value2 == value1) | 197 | value2 = clocksource_acpi_pm.read(); |
194 | continue; | 198 | if (value2 == value1) |
195 | if (value2 > value1) | 199 | continue; |
196 | goto pm_good; | 200 | if (value2 > value1) |
197 | if ((value2 < value1) && ((value2) < 0xFFF)) | 201 | good++; |
198 | goto pm_good; | 202 | break; |
199 | printk(KERN_INFO "PM-Timer had inconsistent results:" | 203 | if ((value2 < value1) && ((value2) < 0xFFF)) |
200 | " 0x%#x, 0x%#x - aborting.\n", value1, value2); | 204 | good++; |
201 | return -EINVAL; | 205 | break; |
206 | printk(KERN_INFO "PM-Timer had inconsistent results:" | ||
207 | " 0x%#llx, 0x%#llx - aborting.\n", | ||
208 | value1, value2); | ||
209 | return -EINVAL; | ||
210 | } | ||
211 | udelay(300 * i); | ||
212 | } | ||
213 | |||
214 | if (good != ACPI_PM_MONOTONICITY_CHECKS) { | ||
215 | printk(KERN_INFO "PM-Timer failed consistency check " | ||
216 | " (0x%#llx) - aborting.\n", value1); | ||
217 | return -ENODEV; | ||
202 | } | 218 | } |
203 | printk(KERN_INFO "PM-Timer had no reasonable result:" | ||
204 | " 0x%#x - aborting.\n", value1); | ||
205 | return -ENODEV; | ||
206 | 219 | ||
207 | pm_good: | ||
208 | if (verify_pmtmr_rate() != 0) | 220 | if (verify_pmtmr_rate() != 0) |
209 | return -ENODEV; | 221 | return -ENODEV; |
210 | 222 | ||
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index 8024e3bfd877..b91ef63126ed 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c | |||
@@ -669,8 +669,7 @@ static int __init ibft_register_kobjects(struct ibft_table_header *header, | |||
669 | 669 | ||
670 | control = (void *)header + sizeof(*header); | 670 | control = (void *)header + sizeof(*header); |
671 | end = (void *)control + control->hdr.length; | 671 | end = (void *)control + control->hdr.length; |
672 | eot_offset = (void *)header + header->length - | 672 | eot_offset = (void *)header + header->length - (void *)control; |
673 | (void *)control - sizeof(*header); | ||
674 | rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, | 673 | rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, |
675 | sizeof(*control)); | 674 | sizeof(*control)); |
676 | 675 | ||
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 089c015c01d1..53f0e5af1cc8 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -400,27 +400,31 @@ static void drm_locked_tasklet_func(unsigned long data) | |||
400 | { | 400 | { |
401 | struct drm_device *dev = (struct drm_device *)data; | 401 | struct drm_device *dev = (struct drm_device *)data; |
402 | unsigned long irqflags; | 402 | unsigned long irqflags; |
403 | 403 | void (*tasklet_func)(struct drm_device *); | |
404 | |||
404 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); | 405 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); |
406 | tasklet_func = dev->locked_tasklet_func; | ||
407 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); | ||
405 | 408 | ||
406 | if (!dev->locked_tasklet_func || | 409 | if (!tasklet_func || |
407 | !drm_lock_take(&dev->lock, | 410 | !drm_lock_take(&dev->lock, |
408 | DRM_KERNEL_CONTEXT)) { | 411 | DRM_KERNEL_CONTEXT)) { |
409 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); | ||
410 | return; | 412 | return; |
411 | } | 413 | } |
412 | 414 | ||
413 | dev->lock.lock_time = jiffies; | 415 | dev->lock.lock_time = jiffies; |
414 | atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); | 416 | atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); |
415 | 417 | ||
416 | dev->locked_tasklet_func(dev); | 418 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); |
419 | tasklet_func = dev->locked_tasklet_func; | ||
420 | dev->locked_tasklet_func = NULL; | ||
421 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); | ||
422 | |||
423 | if (tasklet_func != NULL) | ||
424 | tasklet_func(dev); | ||
417 | 425 | ||
418 | drm_lock_free(&dev->lock, | 426 | drm_lock_free(&dev->lock, |
419 | DRM_KERNEL_CONTEXT); | 427 | DRM_KERNEL_CONTEXT); |
420 | |||
421 | dev->locked_tasklet_func = NULL; | ||
422 | |||
423 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); | ||
424 | } | 428 | } |
425 | 429 | ||
426 | /** | 430 | /** |
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c index 0998723cde79..a4caf95485d7 100644 --- a/drivers/gpu/drm/drm_lock.c +++ b/drivers/gpu/drm/drm_lock.c | |||
@@ -105,14 +105,19 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
105 | ret ? "interrupted" : "has lock"); | 105 | ret ? "interrupted" : "has lock"); |
106 | if (ret) return ret; | 106 | if (ret) return ret; |
107 | 107 | ||
108 | sigemptyset(&dev->sigmask); | 108 | /* don't set the block all signals on the master process for now |
109 | sigaddset(&dev->sigmask, SIGSTOP); | 109 | * really probably not the correct answer but lets us debug xkb |
110 | sigaddset(&dev->sigmask, SIGTSTP); | 110 | * xserver for now */ |
111 | sigaddset(&dev->sigmask, SIGTTIN); | 111 | if (!file_priv->master) { |
112 | sigaddset(&dev->sigmask, SIGTTOU); | 112 | sigemptyset(&dev->sigmask); |
113 | dev->sigdata.context = lock->context; | 113 | sigaddset(&dev->sigmask, SIGSTOP); |
114 | dev->sigdata.lock = dev->lock.hw_lock; | 114 | sigaddset(&dev->sigmask, SIGTSTP); |
115 | block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); | 115 | sigaddset(&dev->sigmask, SIGTTIN); |
116 | sigaddset(&dev->sigmask, SIGTTOU); | ||
117 | dev->sigdata.context = lock->context; | ||
118 | dev->sigdata.lock = dev->lock.hw_lock; | ||
119 | block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); | ||
120 | } | ||
116 | 121 | ||
117 | if (dev->driver->dma_ready && (lock->flags & _DRM_LOCK_READY)) | 122 | if (dev->driver->dma_ready && (lock->flags & _DRM_LOCK_READY)) |
118 | dev->driver->dma_ready(dev); | 123 | dev->driver->dma_ready(dev); |
@@ -150,6 +155,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
150 | { | 155 | { |
151 | struct drm_lock *lock = data; | 156 | struct drm_lock *lock = data; |
152 | unsigned long irqflags; | 157 | unsigned long irqflags; |
158 | void (*tasklet_func)(struct drm_device *); | ||
153 | 159 | ||
154 | if (lock->context == DRM_KERNEL_CONTEXT) { | 160 | if (lock->context == DRM_KERNEL_CONTEXT) { |
155 | DRM_ERROR("Process %d using kernel context %d\n", | 161 | DRM_ERROR("Process %d using kernel context %d\n", |
@@ -158,14 +164,11 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
158 | } | 164 | } |
159 | 165 | ||
160 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); | 166 | spin_lock_irqsave(&dev->tasklet_lock, irqflags); |
161 | 167 | tasklet_func = dev->locked_tasklet_func; | |
162 | if (dev->locked_tasklet_func) { | 168 | dev->locked_tasklet_func = NULL; |
163 | dev->locked_tasklet_func(dev); | ||
164 | |||
165 | dev->locked_tasklet_func = NULL; | ||
166 | } | ||
167 | |||
168 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); | 169 | spin_unlock_irqrestore(&dev->tasklet_lock, irqflags); |
170 | if (tasklet_func != NULL) | ||
171 | tasklet_func(dev); | ||
169 | 172 | ||
170 | atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); | 173 | atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); |
171 | 174 | ||
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c index 702df45320f7..4b27d9abb7bc 100644 --- a/drivers/gpu/drm/radeon/r300_cmdbuf.c +++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c | |||
@@ -77,6 +77,9 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv, | |||
77 | return -EFAULT; | 77 | return -EFAULT; |
78 | } | 78 | } |
79 | 79 | ||
80 | box.x2--; /* Hardware expects inclusive bottom-right corner */ | ||
81 | box.y2--; | ||
82 | |||
80 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) { | 83 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV515) { |
81 | box.x1 = (box.x1) & | 84 | box.x1 = (box.x1) & |
82 | R300_CLIPRECT_MASK; | 85 | R300_CLIPRECT_MASK; |
@@ -95,8 +98,8 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv, | |||
95 | R300_CLIPRECT_MASK; | 98 | R300_CLIPRECT_MASK; |
96 | box.y2 = (box.y2 + R300_CLIPRECT_OFFSET) & | 99 | box.y2 = (box.y2 + R300_CLIPRECT_OFFSET) & |
97 | R300_CLIPRECT_MASK; | 100 | R300_CLIPRECT_MASK; |
98 | |||
99 | } | 101 | } |
102 | |||
100 | OUT_RING((box.x1 << R300_CLIPRECT_X_SHIFT) | | 103 | OUT_RING((box.x1 << R300_CLIPRECT_X_SHIFT) | |
101 | (box.y1 << R300_CLIPRECT_Y_SHIFT)); | 104 | (box.y1 << R300_CLIPRECT_Y_SHIFT)); |
102 | OUT_RING((box.x2 << R300_CLIPRECT_X_SHIFT) | | 105 | OUT_RING((box.x2 << R300_CLIPRECT_X_SHIFT) | |
@@ -136,6 +139,18 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv, | |||
136 | ADVANCE_RING(); | 139 | ADVANCE_RING(); |
137 | } | 140 | } |
138 | 141 | ||
142 | /* flus cache and wait idle clean after cliprect change */ | ||
143 | BEGIN_RING(2); | ||
144 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); | ||
145 | OUT_RING(R300_RB3D_DC_FLUSH); | ||
146 | ADVANCE_RING(); | ||
147 | BEGIN_RING(2); | ||
148 | OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); | ||
149 | OUT_RING(RADEON_WAIT_3D_IDLECLEAN); | ||
150 | ADVANCE_RING(); | ||
151 | /* set flush flag */ | ||
152 | dev_priv->track_flush |= RADEON_FLUSH_EMITED; | ||
153 | |||
139 | return 0; | 154 | return 0; |
140 | } | 155 | } |
141 | 156 | ||
@@ -166,13 +181,13 @@ void r300_init_reg_flags(struct drm_device *dev) | |||
166 | ADD_RANGE(0x21DC, 1); | 181 | ADD_RANGE(0x21DC, 1); |
167 | ADD_RANGE(R300_VAP_UNKNOWN_221C, 1); | 182 | ADD_RANGE(R300_VAP_UNKNOWN_221C, 1); |
168 | ADD_RANGE(R300_VAP_CLIP_X_0, 4); | 183 | ADD_RANGE(R300_VAP_CLIP_X_0, 4); |
169 | ADD_RANGE(R300_VAP_PVS_WAITIDLE, 1); | 184 | ADD_RANGE(R300_VAP_PVS_STATE_FLUSH_REG, 1); |
170 | ADD_RANGE(R300_VAP_UNKNOWN_2288, 1); | 185 | ADD_RANGE(R300_VAP_UNKNOWN_2288, 1); |
171 | ADD_RANGE(R300_VAP_OUTPUT_VTX_FMT_0, 2); | 186 | ADD_RANGE(R300_VAP_OUTPUT_VTX_FMT_0, 2); |
172 | ADD_RANGE(R300_VAP_PVS_CNTL_1, 3); | 187 | ADD_RANGE(R300_VAP_PVS_CNTL_1, 3); |
173 | ADD_RANGE(R300_GB_ENABLE, 1); | 188 | ADD_RANGE(R300_GB_ENABLE, 1); |
174 | ADD_RANGE(R300_GB_MSPOS0, 5); | 189 | ADD_RANGE(R300_GB_MSPOS0, 5); |
175 | ADD_RANGE(R300_TX_CNTL, 1); | 190 | ADD_RANGE(R300_TX_INVALTAGS, 1); |
176 | ADD_RANGE(R300_TX_ENABLE, 1); | 191 | ADD_RANGE(R300_TX_ENABLE, 1); |
177 | ADD_RANGE(0x4200, 4); | 192 | ADD_RANGE(0x4200, 4); |
178 | ADD_RANGE(0x4214, 1); | 193 | ADD_RANGE(0x4214, 1); |
@@ -388,15 +403,28 @@ static __inline__ int r300_emit_vpu(drm_radeon_private_t *dev_priv, | |||
388 | if (sz * 16 > cmdbuf->bufsz) | 403 | if (sz * 16 > cmdbuf->bufsz) |
389 | return -EINVAL; | 404 | return -EINVAL; |
390 | 405 | ||
391 | BEGIN_RING(5 + sz * 4); | 406 | /* VAP is very sensitive so we purge cache before we program it |
392 | /* Wait for VAP to come to senses.. */ | 407 | * and we also flush its state before & after */ |
393 | /* there is no need to emit it multiple times, (only once before VAP is programmed, | 408 | BEGIN_RING(6); |
394 | but this optimization is for later */ | 409 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); |
395 | OUT_RING_REG(R300_VAP_PVS_WAITIDLE, 0); | 410 | OUT_RING(R300_RB3D_DC_FLUSH); |
411 | OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); | ||
412 | OUT_RING(RADEON_WAIT_3D_IDLECLEAN); | ||
413 | OUT_RING(CP_PACKET0(R300_VAP_PVS_STATE_FLUSH_REG, 0)); | ||
414 | OUT_RING(0); | ||
415 | ADVANCE_RING(); | ||
416 | /* set flush flag */ | ||
417 | dev_priv->track_flush |= RADEON_FLUSH_EMITED; | ||
418 | |||
419 | BEGIN_RING(3 + sz * 4); | ||
396 | OUT_RING_REG(R300_VAP_PVS_UPLOAD_ADDRESS, addr); | 420 | OUT_RING_REG(R300_VAP_PVS_UPLOAD_ADDRESS, addr); |
397 | OUT_RING(CP_PACKET0_TABLE(R300_VAP_PVS_UPLOAD_DATA, sz * 4 - 1)); | 421 | OUT_RING(CP_PACKET0_TABLE(R300_VAP_PVS_UPLOAD_DATA, sz * 4 - 1)); |
398 | OUT_RING_TABLE((int *)cmdbuf->buf, sz * 4); | 422 | OUT_RING_TABLE((int *)cmdbuf->buf, sz * 4); |
423 | ADVANCE_RING(); | ||
399 | 424 | ||
425 | BEGIN_RING(2); | ||
426 | OUT_RING(CP_PACKET0(R300_VAP_PVS_STATE_FLUSH_REG, 0)); | ||
427 | OUT_RING(0); | ||
400 | ADVANCE_RING(); | 428 | ADVANCE_RING(); |
401 | 429 | ||
402 | cmdbuf->buf += sz * 16; | 430 | cmdbuf->buf += sz * 16; |
@@ -424,6 +452,15 @@ static __inline__ int r300_emit_clear(drm_radeon_private_t *dev_priv, | |||
424 | OUT_RING_TABLE((int *)cmdbuf->buf, 8); | 452 | OUT_RING_TABLE((int *)cmdbuf->buf, 8); |
425 | ADVANCE_RING(); | 453 | ADVANCE_RING(); |
426 | 454 | ||
455 | BEGIN_RING(4); | ||
456 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); | ||
457 | OUT_RING(R300_RB3D_DC_FLUSH); | ||
458 | OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); | ||
459 | OUT_RING(RADEON_WAIT_3D_IDLECLEAN); | ||
460 | ADVANCE_RING(); | ||
461 | /* set flush flag */ | ||
462 | dev_priv->track_flush |= RADEON_FLUSH_EMITED; | ||
463 | |||
427 | cmdbuf->buf += 8 * 4; | 464 | cmdbuf->buf += 8 * 4; |
428 | cmdbuf->bufsz -= 8 * 4; | 465 | cmdbuf->bufsz -= 8 * 4; |
429 | 466 | ||
@@ -543,22 +580,23 @@ static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv, | |||
543 | return 0; | 580 | return 0; |
544 | } | 581 | } |
545 | 582 | ||
546 | static __inline__ int r300_emit_indx_buffer(drm_radeon_private_t *dev_priv, | 583 | static __inline__ int r300_emit_draw_indx_2(drm_radeon_private_t *dev_priv, |
547 | drm_radeon_kcmd_buffer_t *cmdbuf) | 584 | drm_radeon_kcmd_buffer_t *cmdbuf) |
548 | { | 585 | { |
549 | u32 *cmd = (u32 *) cmdbuf->buf; | 586 | u32 *cmd; |
550 | int count, ret; | 587 | int count; |
588 | int expected_count; | ||
551 | RING_LOCALS; | 589 | RING_LOCALS; |
552 | 590 | ||
553 | count=(cmd[0]>>16) & 0x3fff; | 591 | cmd = (u32 *) cmdbuf->buf; |
592 | count = (cmd[0]>>16) & 0x3fff; | ||
593 | expected_count = cmd[1] >> 16; | ||
594 | if (!(cmd[1] & R300_VAP_VF_CNTL__INDEX_SIZE_32bit)) | ||
595 | expected_count = (expected_count+1)/2; | ||
554 | 596 | ||
555 | if ((cmd[1] & 0x8000ffff) != 0x80000810) { | 597 | if (count && count != expected_count) { |
556 | DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]); | 598 | DRM_ERROR("3D_DRAW_INDX_2: packet size %i, expected %i\n", |
557 | return -EINVAL; | 599 | count, expected_count); |
558 | } | ||
559 | ret = !radeon_check_offset(dev_priv, cmd[2]); | ||
560 | if (ret) { | ||
561 | DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]); | ||
562 | return -EINVAL; | 600 | return -EINVAL; |
563 | } | 601 | } |
564 | 602 | ||
@@ -570,6 +608,50 @@ static __inline__ int r300_emit_indx_buffer(drm_radeon_private_t *dev_priv, | |||
570 | cmdbuf->buf += (count+2)*4; | 608 | cmdbuf->buf += (count+2)*4; |
571 | cmdbuf->bufsz -= (count+2)*4; | 609 | cmdbuf->bufsz -= (count+2)*4; |
572 | 610 | ||
611 | if (!count) { | ||
612 | drm_r300_cmd_header_t header; | ||
613 | |||
614 | if (cmdbuf->bufsz < 4*4 + sizeof(header)) { | ||
615 | DRM_ERROR("3D_DRAW_INDX_2: expect subsequent INDX_BUFFER, but stream is too short.\n"); | ||
616 | return -EINVAL; | ||
617 | } | ||
618 | |||
619 | header.u = *(unsigned int *)cmdbuf->buf; | ||
620 | |||
621 | cmdbuf->buf += sizeof(header); | ||
622 | cmdbuf->bufsz -= sizeof(header); | ||
623 | cmd = (u32 *) cmdbuf->buf; | ||
624 | |||
625 | if (header.header.cmd_type != R300_CMD_PACKET3 || | ||
626 | header.packet3.packet != R300_CMD_PACKET3_RAW || | ||
627 | cmd[0] != CP_PACKET3(RADEON_CP_INDX_BUFFER, 2)) { | ||
628 | DRM_ERROR("3D_DRAW_INDX_2: expect subsequent INDX_BUFFER.\n"); | ||
629 | return -EINVAL; | ||
630 | } | ||
631 | |||
632 | if ((cmd[1] & 0x8000ffff) != 0x80000810) { | ||
633 | DRM_ERROR("Invalid indx_buffer reg address %08X\n", cmd[1]); | ||
634 | return -EINVAL; | ||
635 | } | ||
636 | if (!radeon_check_offset(dev_priv, cmd[2])) { | ||
637 | DRM_ERROR("Invalid indx_buffer offset is %08X\n", cmd[2]); | ||
638 | return -EINVAL; | ||
639 | } | ||
640 | if (cmd[3] != expected_count) { | ||
641 | DRM_ERROR("INDX_BUFFER: buffer size %i, expected %i\n", | ||
642 | cmd[3], expected_count); | ||
643 | return -EINVAL; | ||
644 | } | ||
645 | |||
646 | BEGIN_RING(4); | ||
647 | OUT_RING(cmd[0]); | ||
648 | OUT_RING_TABLE((int *)(cmdbuf->buf + 4), 3); | ||
649 | ADVANCE_RING(); | ||
650 | |||
651 | cmdbuf->buf += 4*4; | ||
652 | cmdbuf->bufsz -= 4*4; | ||
653 | } | ||
654 | |||
573 | return 0; | 655 | return 0; |
574 | } | 656 | } |
575 | 657 | ||
@@ -613,11 +695,22 @@ static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv, | |||
613 | case RADEON_CNTL_BITBLT_MULTI: | 695 | case RADEON_CNTL_BITBLT_MULTI: |
614 | return r300_emit_bitblt_multi(dev_priv, cmdbuf); | 696 | return r300_emit_bitblt_multi(dev_priv, cmdbuf); |
615 | 697 | ||
616 | case RADEON_CP_INDX_BUFFER: /* DRAW_INDX_2 without INDX_BUFFER seems to lock up the gpu */ | 698 | case RADEON_CP_INDX_BUFFER: |
617 | return r300_emit_indx_buffer(dev_priv, cmdbuf); | 699 | DRM_ERROR("packet3 INDX_BUFFER without preceding 3D_DRAW_INDX_2 is illegal.\n"); |
618 | case RADEON_CP_3D_DRAW_IMMD_2: /* triggers drawing using in-packet vertex data */ | 700 | return -EINVAL; |
619 | case RADEON_CP_3D_DRAW_VBUF_2: /* triggers drawing of vertex buffers setup elsewhere */ | 701 | case RADEON_CP_3D_DRAW_IMMD_2: |
620 | case RADEON_CP_3D_DRAW_INDX_2: /* triggers drawing using indices to vertex buffer */ | 702 | /* triggers drawing using in-packet vertex data */ |
703 | case RADEON_CP_3D_DRAW_VBUF_2: | ||
704 | /* triggers drawing of vertex buffers setup elsewhere */ | ||
705 | dev_priv->track_flush &= ~(RADEON_FLUSH_EMITED | | ||
706 | RADEON_PURGE_EMITED); | ||
707 | break; | ||
708 | case RADEON_CP_3D_DRAW_INDX_2: | ||
709 | /* triggers drawing using indices to vertex buffer */ | ||
710 | /* whenever we send vertex we clear flush & purge */ | ||
711 | dev_priv->track_flush &= ~(RADEON_FLUSH_EMITED | | ||
712 | RADEON_PURGE_EMITED); | ||
713 | return r300_emit_draw_indx_2(dev_priv, cmdbuf); | ||
621 | case RADEON_WAIT_FOR_IDLE: | 714 | case RADEON_WAIT_FOR_IDLE: |
622 | case RADEON_CP_NOP: | 715 | case RADEON_CP_NOP: |
623 | /* these packets are safe */ | 716 | /* these packets are safe */ |
@@ -713,17 +806,53 @@ static __inline__ int r300_emit_packet3(drm_radeon_private_t *dev_priv, | |||
713 | */ | 806 | */ |
714 | static __inline__ void r300_pacify(drm_radeon_private_t *dev_priv) | 807 | static __inline__ void r300_pacify(drm_radeon_private_t *dev_priv) |
715 | { | 808 | { |
809 | uint32_t cache_z, cache_3d, cache_2d; | ||
716 | RING_LOCALS; | 810 | RING_LOCALS; |
717 | 811 | ||
718 | BEGIN_RING(6); | 812 | cache_z = R300_ZC_FLUSH; |
719 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); | 813 | cache_2d = R300_RB2D_DC_FLUSH; |
720 | OUT_RING(R300_RB3D_DSTCACHE_UNKNOWN_0A); | 814 | cache_3d = R300_RB3D_DC_FLUSH; |
815 | if (!(dev_priv->track_flush & RADEON_PURGE_EMITED)) { | ||
816 | /* we can purge, primitive where draw since last purge */ | ||
817 | cache_z |= R300_ZC_FREE; | ||
818 | cache_2d |= R300_RB2D_DC_FREE; | ||
819 | cache_3d |= R300_RB3D_DC_FREE; | ||
820 | } | ||
821 | |||
822 | /* flush & purge zbuffer */ | ||
823 | BEGIN_RING(2); | ||
721 | OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); | 824 | OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); |
722 | OUT_RING(R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE| | 825 | OUT_RING(cache_z); |
723 | R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); | 826 | ADVANCE_RING(); |
724 | OUT_RING(CP_PACKET3(RADEON_CP_NOP, 0)); | 827 | /* flush & purge 3d */ |
725 | OUT_RING(0x0); | 828 | BEGIN_RING(2); |
829 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); | ||
830 | OUT_RING(cache_3d); | ||
831 | ADVANCE_RING(); | ||
832 | /* flush & purge texture */ | ||
833 | BEGIN_RING(2); | ||
834 | OUT_RING(CP_PACKET0(R300_TX_INVALTAGS, 0)); | ||
835 | OUT_RING(0); | ||
836 | ADVANCE_RING(); | ||
837 | /* FIXME: is this one really needed ? */ | ||
838 | BEGIN_RING(2); | ||
839 | OUT_RING(CP_PACKET0(R300_RB3D_AARESOLVE_CTL, 0)); | ||
840 | OUT_RING(0); | ||
841 | ADVANCE_RING(); | ||
842 | BEGIN_RING(2); | ||
843 | OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); | ||
844 | OUT_RING(RADEON_WAIT_3D_IDLECLEAN); | ||
845 | ADVANCE_RING(); | ||
846 | /* flush & purge 2d through E2 as RB2D will trigger lockup */ | ||
847 | BEGIN_RING(4); | ||
848 | OUT_RING(CP_PACKET0(R300_DSTCACHE_CTLSTAT, 0)); | ||
849 | OUT_RING(cache_2d); | ||
850 | OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0)); | ||
851 | OUT_RING(RADEON_WAIT_2D_IDLECLEAN | | ||
852 | RADEON_WAIT_HOST_IDLECLEAN); | ||
726 | ADVANCE_RING(); | 853 | ADVANCE_RING(); |
854 | /* set flush & purge flags */ | ||
855 | dev_priv->track_flush |= RADEON_FLUSH_EMITED | RADEON_PURGE_EMITED; | ||
727 | } | 856 | } |
728 | 857 | ||
729 | /** | 858 | /** |
@@ -905,8 +1034,7 @@ int r300_do_cp_cmdbuf(struct drm_device *dev, | |||
905 | 1034 | ||
906 | DRM_DEBUG("\n"); | 1035 | DRM_DEBUG("\n"); |
907 | 1036 | ||
908 | /* See the comment above r300_emit_begin3d for why this call must be here, | 1037 | /* pacify */ |
909 | * and what the cleanup gotos are for. */ | ||
910 | r300_pacify(dev_priv); | 1038 | r300_pacify(dev_priv); |
911 | 1039 | ||
912 | if (cmdbuf->nbox <= R300_SIMULTANEOUS_CLIPRECTS) { | 1040 | if (cmdbuf->nbox <= R300_SIMULTANEOUS_CLIPRECTS) { |
diff --git a/drivers/gpu/drm/radeon/r300_reg.h b/drivers/gpu/drm/radeon/r300_reg.h index a6802f26afc4..ee6f811599a3 100644 --- a/drivers/gpu/drm/radeon/r300_reg.h +++ b/drivers/gpu/drm/radeon/r300_reg.h | |||
@@ -317,7 +317,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
317 | * Therefore, I suspect writing zero to 0x2284 synchronizes the engine and | 317 | * Therefore, I suspect writing zero to 0x2284 synchronizes the engine and |
318 | * avoids bugs caused by still running shaders reading bad data from memory. | 318 | * avoids bugs caused by still running shaders reading bad data from memory. |
319 | */ | 319 | */ |
320 | #define R300_VAP_PVS_WAITIDLE 0x2284 /* GUESS */ | 320 | #define R300_VAP_PVS_STATE_FLUSH_REG 0x2284 |
321 | 321 | ||
322 | /* Absolutely no clue what this register is about. */ | 322 | /* Absolutely no clue what this register is about. */ |
323 | #define R300_VAP_UNKNOWN_2288 0x2288 | 323 | #define R300_VAP_UNKNOWN_2288 0x2288 |
@@ -513,7 +513,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
513 | /* gap */ | 513 | /* gap */ |
514 | 514 | ||
515 | /* Zero to flush caches. */ | 515 | /* Zero to flush caches. */ |
516 | #define R300_TX_CNTL 0x4100 | 516 | #define R300_TX_INVALTAGS 0x4100 |
517 | #define R300_TX_FLUSH 0x0 | 517 | #define R300_TX_FLUSH 0x0 |
518 | 518 | ||
519 | /* The upper enable bits are guessed, based on fglrx reported limits. */ | 519 | /* The upper enable bits are guessed, based on fglrx reported limits. */ |
@@ -1362,6 +1362,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
1362 | #define R300_RB3D_COLORPITCH2 0x4E40 /* GUESS */ | 1362 | #define R300_RB3D_COLORPITCH2 0x4E40 /* GUESS */ |
1363 | #define R300_RB3D_COLORPITCH3 0x4E44 /* GUESS */ | 1363 | #define R300_RB3D_COLORPITCH3 0x4E44 /* GUESS */ |
1364 | 1364 | ||
1365 | #define R300_RB3D_AARESOLVE_CTL 0x4E88 | ||
1365 | /* gap */ | 1366 | /* gap */ |
1366 | 1367 | ||
1367 | /* Guess by Vladimir. | 1368 | /* Guess by Vladimir. |
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c index f0de81a5689d..248ab4a7d39f 100644 --- a/drivers/gpu/drm/radeon/radeon_cp.c +++ b/drivers/gpu/drm/radeon/radeon_cp.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #define RADEON_FIFO_DEBUG 0 | 40 | #define RADEON_FIFO_DEBUG 0 |
41 | 41 | ||
42 | static int radeon_do_cleanup_cp(struct drm_device * dev); | 42 | static int radeon_do_cleanup_cp(struct drm_device * dev); |
43 | static void radeon_do_cp_start(drm_radeon_private_t * dev_priv); | ||
43 | 44 | ||
44 | static u32 R500_READ_MCIND(drm_radeon_private_t *dev_priv, int addr) | 45 | static u32 R500_READ_MCIND(drm_radeon_private_t *dev_priv, int addr) |
45 | { | 46 | { |
@@ -198,23 +199,8 @@ static int radeon_do_pixcache_flush(drm_radeon_private_t * dev_priv) | |||
198 | DRM_UDELAY(1); | 199 | DRM_UDELAY(1); |
199 | } | 200 | } |
200 | } else { | 201 | } else { |
201 | /* 3D */ | 202 | /* don't flush or purge cache here or lockup */ |
202 | tmp = RADEON_READ(R300_RB3D_DSTCACHE_CTLSTAT); | 203 | return 0; |
203 | tmp |= RADEON_RB3D_DC_FLUSH_ALL; | ||
204 | RADEON_WRITE(R300_RB3D_DSTCACHE_CTLSTAT, tmp); | ||
205 | |||
206 | /* 2D */ | ||
207 | tmp = RADEON_READ(R300_DSTCACHE_CTLSTAT); | ||
208 | tmp |= RADEON_RB3D_DC_FLUSH_ALL; | ||
209 | RADEON_WRITE(R300_DSTCACHE_CTLSTAT, tmp); | ||
210 | |||
211 | for (i = 0; i < dev_priv->usec_timeout; i++) { | ||
212 | if (!(RADEON_READ(R300_DSTCACHE_CTLSTAT) | ||
213 | & RADEON_RB3D_DC_BUSY)) { | ||
214 | return 0; | ||
215 | } | ||
216 | DRM_UDELAY(1); | ||
217 | } | ||
218 | } | 204 | } |
219 | 205 | ||
220 | #if RADEON_FIFO_DEBUG | 206 | #if RADEON_FIFO_DEBUG |
@@ -237,6 +223,9 @@ static int radeon_do_wait_for_fifo(drm_radeon_private_t * dev_priv, int entries) | |||
237 | return 0; | 223 | return 0; |
238 | DRM_UDELAY(1); | 224 | DRM_UDELAY(1); |
239 | } | 225 | } |
226 | DRM_DEBUG("wait for fifo failed status : 0x%08X 0x%08X\n", | ||
227 | RADEON_READ(RADEON_RBBM_STATUS), | ||
228 | RADEON_READ(R300_VAP_CNTL_STATUS)); | ||
240 | 229 | ||
241 | #if RADEON_FIFO_DEBUG | 230 | #if RADEON_FIFO_DEBUG |
242 | DRM_ERROR("failed!\n"); | 231 | DRM_ERROR("failed!\n"); |
@@ -263,6 +252,9 @@ static int radeon_do_wait_for_idle(drm_radeon_private_t * dev_priv) | |||
263 | } | 252 | } |
264 | DRM_UDELAY(1); | 253 | DRM_UDELAY(1); |
265 | } | 254 | } |
255 | DRM_DEBUG("wait idle failed status : 0x%08X 0x%08X\n", | ||
256 | RADEON_READ(RADEON_RBBM_STATUS), | ||
257 | RADEON_READ(R300_VAP_CNTL_STATUS)); | ||
266 | 258 | ||
267 | #if RADEON_FIFO_DEBUG | 259 | #if RADEON_FIFO_DEBUG |
268 | DRM_ERROR("failed!\n"); | 260 | DRM_ERROR("failed!\n"); |
@@ -443,14 +435,20 @@ static void radeon_do_cp_start(drm_radeon_private_t * dev_priv) | |||
443 | 435 | ||
444 | dev_priv->cp_running = 1; | 436 | dev_priv->cp_running = 1; |
445 | 437 | ||
446 | BEGIN_RING(6); | 438 | BEGIN_RING(8); |
447 | 439 | /* isync can only be written through cp on r5xx write it here */ | |
440 | OUT_RING(CP_PACKET0(RADEON_ISYNC_CNTL, 0)); | ||
441 | OUT_RING(RADEON_ISYNC_ANY2D_IDLE3D | | ||
442 | RADEON_ISYNC_ANY3D_IDLE2D | | ||
443 | RADEON_ISYNC_WAIT_IDLEGUI | | ||
444 | RADEON_ISYNC_CPSCRATCH_IDLEGUI); | ||
448 | RADEON_PURGE_CACHE(); | 445 | RADEON_PURGE_CACHE(); |
449 | RADEON_PURGE_ZCACHE(); | 446 | RADEON_PURGE_ZCACHE(); |
450 | RADEON_WAIT_UNTIL_IDLE(); | 447 | RADEON_WAIT_UNTIL_IDLE(); |
451 | |||
452 | ADVANCE_RING(); | 448 | ADVANCE_RING(); |
453 | COMMIT_RING(); | 449 | COMMIT_RING(); |
450 | |||
451 | dev_priv->track_flush |= RADEON_FLUSH_EMITED | RADEON_PURGE_EMITED; | ||
454 | } | 452 | } |
455 | 453 | ||
456 | /* Reset the Command Processor. This will not flush any pending | 454 | /* Reset the Command Processor. This will not flush any pending |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h index 3f0eca957aa7..099381693175 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.h +++ b/drivers/gpu/drm/radeon/radeon_drv.h | |||
@@ -220,6 +220,9 @@ struct radeon_virt_surface { | |||
220 | struct drm_file *file_priv; | 220 | struct drm_file *file_priv; |
221 | }; | 221 | }; |
222 | 222 | ||
223 | #define RADEON_FLUSH_EMITED (1 < 0) | ||
224 | #define RADEON_PURGE_EMITED (1 < 1) | ||
225 | |||
223 | typedef struct drm_radeon_private { | 226 | typedef struct drm_radeon_private { |
224 | drm_radeon_ring_buffer_t ring; | 227 | drm_radeon_ring_buffer_t ring; |
225 | drm_radeon_sarea_t *sarea_priv; | 228 | drm_radeon_sarea_t *sarea_priv; |
@@ -311,6 +314,7 @@ typedef struct drm_radeon_private { | |||
311 | unsigned long fb_aper_offset; | 314 | unsigned long fb_aper_offset; |
312 | 315 | ||
313 | int num_gb_pipes; | 316 | int num_gb_pipes; |
317 | int track_flush; | ||
314 | } drm_radeon_private_t; | 318 | } drm_radeon_private_t; |
315 | 319 | ||
316 | typedef struct drm_radeon_buf_priv { | 320 | typedef struct drm_radeon_buf_priv { |
@@ -693,7 +697,6 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev, | |||
693 | #define R300_ZB_ZCACHE_CTLSTAT 0x4f18 | 697 | #define R300_ZB_ZCACHE_CTLSTAT 0x4f18 |
694 | # define R300_ZC_FLUSH (1 << 0) | 698 | # define R300_ZC_FLUSH (1 << 0) |
695 | # define R300_ZC_FREE (1 << 1) | 699 | # define R300_ZC_FREE (1 << 1) |
696 | # define R300_ZC_FLUSH_ALL 0x3 | ||
697 | # define R300_ZC_BUSY (1 << 31) | 700 | # define R300_ZC_BUSY (1 << 31) |
698 | #define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c | 701 | #define RADEON_RB3D_DSTCACHE_CTLSTAT 0x325c |
699 | # define RADEON_RB3D_DC_FLUSH (3 << 0) | 702 | # define RADEON_RB3D_DC_FLUSH (3 << 0) |
@@ -701,6 +704,8 @@ extern int r300_do_cp_cmdbuf(struct drm_device * dev, | |||
701 | # define RADEON_RB3D_DC_FLUSH_ALL 0xf | 704 | # define RADEON_RB3D_DC_FLUSH_ALL 0xf |
702 | # define RADEON_RB3D_DC_BUSY (1 << 31) | 705 | # define RADEON_RB3D_DC_BUSY (1 << 31) |
703 | #define R300_RB3D_DSTCACHE_CTLSTAT 0x4e4c | 706 | #define R300_RB3D_DSTCACHE_CTLSTAT 0x4e4c |
707 | # define R300_RB3D_DC_FLUSH (2 << 0) | ||
708 | # define R300_RB3D_DC_FREE (2 << 2) | ||
704 | # define R300_RB3D_DC_FINISH (1 << 4) | 709 | # define R300_RB3D_DC_FINISH (1 << 4) |
705 | #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c | 710 | #define RADEON_RB3D_ZSTENCILCNTL 0x1c2c |
706 | # define RADEON_Z_TEST_MASK (7 << 4) | 711 | # define RADEON_Z_TEST_MASK (7 << 4) |
@@ -1246,17 +1251,17 @@ do { \ | |||
1246 | OUT_RING(RADEON_RB3D_DC_FLUSH); \ | 1251 | OUT_RING(RADEON_RB3D_DC_FLUSH); \ |
1247 | } else { \ | 1252 | } else { \ |
1248 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ | 1253 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ |
1249 | OUT_RING(RADEON_RB3D_DC_FLUSH); \ | 1254 | OUT_RING(R300_RB3D_DC_FLUSH); \ |
1250 | } \ | 1255 | } \ |
1251 | } while (0) | 1256 | } while (0) |
1252 | 1257 | ||
1253 | #define RADEON_PURGE_CACHE() do { \ | 1258 | #define RADEON_PURGE_CACHE() do { \ |
1254 | if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \ | 1259 | if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \ |
1255 | OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \ | 1260 | OUT_RING(CP_PACKET0(RADEON_RB3D_DSTCACHE_CTLSTAT, 0)); \ |
1256 | OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \ | 1261 | OUT_RING(RADEON_RB3D_DC_FLUSH | RADEON_RB3D_DC_FREE); \ |
1257 | } else { \ | 1262 | } else { \ |
1258 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ | 1263 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ |
1259 | OUT_RING(RADEON_RB3D_DC_FLUSH_ALL); \ | 1264 | OUT_RING(R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE); \ |
1260 | } \ | 1265 | } \ |
1261 | } while (0) | 1266 | } while (0) |
1262 | 1267 | ||
@@ -1273,10 +1278,10 @@ do { \ | |||
1273 | #define RADEON_PURGE_ZCACHE() do { \ | 1278 | #define RADEON_PURGE_ZCACHE() do { \ |
1274 | if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \ | 1279 | if ((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV280) { \ |
1275 | OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \ | 1280 | OUT_RING(CP_PACKET0(RADEON_RB3D_ZCACHE_CTLSTAT, 0)); \ |
1276 | OUT_RING(RADEON_RB3D_ZC_FLUSH_ALL); \ | 1281 | OUT_RING(RADEON_RB3D_ZC_FLUSH | RADEON_RB3D_ZC_FREE); \ |
1277 | } else { \ | 1282 | } else { \ |
1278 | OUT_RING(CP_PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0)); \ | 1283 | OUT_RING(CP_PACKET0(R300_ZB_ZCACHE_CTLSTAT, 0)); \ |
1279 | OUT_RING(R300_ZC_FLUSH_ALL); \ | 1284 | OUT_RING(R300_ZC_FLUSH | R300_ZC_FREE); \ |
1280 | } \ | 1285 | } \ |
1281 | } while (0) | 1286 | } while (0) |
1282 | 1287 | ||
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index d402e8d813ce..3309e862f317 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -540,6 +540,15 @@ config SENSORS_LM93 | |||
540 | This driver can also be built as a module. If so, the module | 540 | This driver can also be built as a module. If so, the module |
541 | will be called lm93. | 541 | will be called lm93. |
542 | 542 | ||
543 | config SENSORS_MAX1111 | ||
544 | tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip" | ||
545 | depends on SPI_MASTER | ||
546 | help | ||
547 | Say y here to support Maxim's MAX1111 ADC chips. | ||
548 | |||
549 | This driver can also be built as a module. If so, the module | ||
550 | will be called max1111. | ||
551 | |||
543 | config SENSORS_MAX1619 | 552 | config SENSORS_MAX1619 |
544 | tristate "Maxim MAX1619 sensor chip" | 553 | tristate "Maxim MAX1619 sensor chip" |
545 | depends on I2C | 554 | depends on I2C |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 950134ab8426..6babc801b348 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -59,6 +59,7 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o | |||
59 | obj-$(CONFIG_SENSORS_LM90) += lm90.o | 59 | obj-$(CONFIG_SENSORS_LM90) += lm90.o |
60 | obj-$(CONFIG_SENSORS_LM92) += lm92.o | 60 | obj-$(CONFIG_SENSORS_LM92) += lm92.o |
61 | obj-$(CONFIG_SENSORS_LM93) += lm93.o | 61 | obj-$(CONFIG_SENSORS_LM93) += lm93.o |
62 | obj-$(CONFIG_SENSORS_MAX1111) += max1111.o | ||
62 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o | 63 | obj-$(CONFIG_SENSORS_MAX1619) += max1619.o |
63 | obj-$(CONFIG_SENSORS_MAX6650) += max6650.o | 64 | obj-$(CONFIG_SENSORS_MAX6650) += max6650.o |
64 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o | 65 | obj-$(CONFIG_SENSORS_PC87360) += pc87360.o |
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c new file mode 100644 index 000000000000..bfaa665ccf32 --- /dev/null +++ b/drivers/hwmon/max1111.c | |||
@@ -0,0 +1,244 @@ | |||
1 | /* | ||
2 | * max1111.c - +2.7V, Low-Power, Multichannel, Serial 8-bit ADCs | ||
3 | * | ||
4 | * Based on arch/arm/mach-pxa/corgi_ssp.c | ||
5 | * | ||
6 | * Copyright (C) 2004-2005 Richard Purdie | ||
7 | * | ||
8 | * Copyright (C) 2008 Marvell International Ltd. | ||
9 | * Eric Miao <eric.miao@marvell.com> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * publishhed by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/hwmon.h> | ||
21 | #include <linux/hwmon-sysfs.h> | ||
22 | #include <linux/spi/spi.h> | ||
23 | |||
24 | #define MAX1111_TX_BUF_SIZE 1 | ||
25 | #define MAX1111_RX_BUF_SIZE 2 | ||
26 | |||
27 | /* MAX1111 Commands */ | ||
28 | #define MAX1111_CTRL_PD0 (1u << 0) | ||
29 | #define MAX1111_CTRL_PD1 (1u << 1) | ||
30 | #define MAX1111_CTRL_SGL (1u << 2) | ||
31 | #define MAX1111_CTRL_UNI (1u << 3) | ||
32 | #define MAX1111_CTRL_SEL_SH (5) /* NOTE: bit 4 is ignored */ | ||
33 | #define MAX1111_CTRL_STR (1u << 7) | ||
34 | |||
35 | struct max1111_data { | ||
36 | struct spi_device *spi; | ||
37 | struct device *hwmon_dev; | ||
38 | struct spi_message msg; | ||
39 | struct spi_transfer xfer[2]; | ||
40 | uint8_t *tx_buf; | ||
41 | uint8_t *rx_buf; | ||
42 | }; | ||
43 | |||
44 | static int max1111_read(struct device *dev, int channel) | ||
45 | { | ||
46 | struct max1111_data *data = dev_get_drvdata(dev); | ||
47 | uint8_t v1, v2; | ||
48 | int err; | ||
49 | |||
50 | data->tx_buf[0] = (channel << MAX1111_CTRL_SEL_SH) | | ||
51 | MAX1111_CTRL_PD0 | MAX1111_CTRL_PD1 | | ||
52 | MAX1111_CTRL_SGL | MAX1111_CTRL_UNI | MAX1111_CTRL_STR; | ||
53 | |||
54 | err = spi_sync(data->spi, &data->msg); | ||
55 | if (err < 0) { | ||
56 | dev_err(dev, "spi_sync failed with %d\n", err); | ||
57 | return err; | ||
58 | } | ||
59 | |||
60 | v1 = data->rx_buf[0]; | ||
61 | v2 = data->rx_buf[1]; | ||
62 | |||
63 | if ((v1 & 0xc0) || (v2 & 0x3f)) | ||
64 | return -EINVAL; | ||
65 | |||
66 | return (v1 << 2) | (v2 >> 6); | ||
67 | } | ||
68 | |||
69 | #ifdef CONFIG_SHARPSL_PM | ||
70 | static struct max1111_data *the_max1111; | ||
71 | |||
72 | int max1111_read_channel(int channel) | ||
73 | { | ||
74 | return max1111_read(&the_max1111->spi->dev, channel); | ||
75 | } | ||
76 | EXPORT_SYMBOL(max1111_read_channel); | ||
77 | #endif | ||
78 | |||
79 | /* | ||
80 | * NOTE: SPI devices do not have a default 'name' attribute, which is | ||
81 | * likely to be used by hwmon applications to distinguish between | ||
82 | * different devices, explicitly add a name attribute here. | ||
83 | */ | ||
84 | static ssize_t show_name(struct device *dev, | ||
85 | struct device_attribute *attr, char *buf) | ||
86 | { | ||
87 | return sprintf(buf, "max1111\n"); | ||
88 | } | ||
89 | |||
90 | static ssize_t show_adc(struct device *dev, | ||
91 | struct device_attribute *attr, char *buf) | ||
92 | { | ||
93 | int channel = to_sensor_dev_attr(attr)->index; | ||
94 | int ret; | ||
95 | |||
96 | ret = max1111_read(dev, channel); | ||
97 | if (ret < 0) | ||
98 | return ret; | ||
99 | |||
100 | return sprintf(buf, "%d\n", ret); | ||
101 | } | ||
102 | |||
103 | #define MAX1111_ADC_ATTR(_id) \ | ||
104 | SENSOR_DEVICE_ATTR(adc##_id##_in, S_IRUGO, show_adc, NULL, _id) | ||
105 | |||
106 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | ||
107 | static MAX1111_ADC_ATTR(0); | ||
108 | static MAX1111_ADC_ATTR(1); | ||
109 | static MAX1111_ADC_ATTR(2); | ||
110 | static MAX1111_ADC_ATTR(3); | ||
111 | |||
112 | static struct attribute *max1111_attributes[] = { | ||
113 | &dev_attr_name.attr, | ||
114 | &sensor_dev_attr_adc0_in.dev_attr.attr, | ||
115 | &sensor_dev_attr_adc1_in.dev_attr.attr, | ||
116 | &sensor_dev_attr_adc2_in.dev_attr.attr, | ||
117 | &sensor_dev_attr_adc3_in.dev_attr.attr, | ||
118 | NULL, | ||
119 | }; | ||
120 | |||
121 | static const struct attribute_group max1111_attr_group = { | ||
122 | .attrs = max1111_attributes, | ||
123 | }; | ||
124 | |||
125 | static int setup_transfer(struct max1111_data *data) | ||
126 | { | ||
127 | struct spi_message *m; | ||
128 | struct spi_transfer *x; | ||
129 | |||
130 | data->tx_buf = kmalloc(MAX1111_TX_BUF_SIZE, GFP_KERNEL); | ||
131 | if (!data->tx_buf) | ||
132 | return -ENOMEM; | ||
133 | |||
134 | data->rx_buf = kmalloc(MAX1111_RX_BUF_SIZE, GFP_KERNEL); | ||
135 | if (!data->rx_buf) { | ||
136 | kfree(data->tx_buf); | ||
137 | return -ENOMEM; | ||
138 | } | ||
139 | |||
140 | m = &data->msg; | ||
141 | x = &data->xfer[0]; | ||
142 | |||
143 | spi_message_init(m); | ||
144 | |||
145 | x->tx_buf = &data->tx_buf[0]; | ||
146 | x->len = 1; | ||
147 | spi_message_add_tail(x, m); | ||
148 | |||
149 | x++; | ||
150 | x->rx_buf = &data->rx_buf[0]; | ||
151 | x->len = 2; | ||
152 | spi_message_add_tail(x, m); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static int __devinit max1111_probe(struct spi_device *spi) | ||
158 | { | ||
159 | struct max1111_data *data; | ||
160 | int err; | ||
161 | |||
162 | spi->bits_per_word = 8; | ||
163 | spi->mode = SPI_MODE_0; | ||
164 | err = spi_setup(spi); | ||
165 | if (err < 0) | ||
166 | return err; | ||
167 | |||
168 | data = kzalloc(sizeof(struct max1111_data), GFP_KERNEL); | ||
169 | if (data == NULL) { | ||
170 | dev_err(&spi->dev, "failed to allocate memory\n"); | ||
171 | return -ENOMEM; | ||
172 | } | ||
173 | |||
174 | err = setup_transfer(data); | ||
175 | if (err) | ||
176 | goto err_free_data; | ||
177 | |||
178 | data->spi = spi; | ||
179 | spi_set_drvdata(spi, data); | ||
180 | |||
181 | err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group); | ||
182 | if (err) { | ||
183 | dev_err(&spi->dev, "failed to create attribute group\n"); | ||
184 | goto err_free_all; | ||
185 | } | ||
186 | |||
187 | data->hwmon_dev = hwmon_device_register(&spi->dev); | ||
188 | if (IS_ERR(data->hwmon_dev)) { | ||
189 | dev_err(&spi->dev, "failed to create hwmon device\n"); | ||
190 | err = PTR_ERR(data->hwmon_dev); | ||
191 | goto err_remove; | ||
192 | } | ||
193 | |||
194 | #ifdef CONFIG_SHARPSL_PM | ||
195 | the_max1111 = data; | ||
196 | #endif | ||
197 | return 0; | ||
198 | |||
199 | err_remove: | ||
200 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | ||
201 | err_free_all: | ||
202 | kfree(data->rx_buf); | ||
203 | kfree(data->tx_buf); | ||
204 | err_free_data: | ||
205 | kfree(data); | ||
206 | return err; | ||
207 | } | ||
208 | |||
209 | static int __devexit max1111_remove(struct spi_device *spi) | ||
210 | { | ||
211 | struct max1111_data *data = spi_get_drvdata(spi); | ||
212 | |||
213 | hwmon_device_unregister(data->hwmon_dev); | ||
214 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | ||
215 | kfree(data->rx_buf); | ||
216 | kfree(data->tx_buf); | ||
217 | kfree(data); | ||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static struct spi_driver max1111_driver = { | ||
222 | .driver = { | ||
223 | .name = "max1111", | ||
224 | .owner = THIS_MODULE, | ||
225 | }, | ||
226 | .probe = max1111_probe, | ||
227 | .remove = __devexit_p(max1111_remove), | ||
228 | }; | ||
229 | |||
230 | static int __init max1111_init(void) | ||
231 | { | ||
232 | return spi_register_driver(&max1111_driver); | ||
233 | } | ||
234 | module_init(max1111_init); | ||
235 | |||
236 | static void __exit max1111_exit(void) | ||
237 | { | ||
238 | spi_unregister_driver(&max1111_driver); | ||
239 | } | ||
240 | module_exit(max1111_exit); | ||
241 | |||
242 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
243 | MODULE_DESCRIPTION("MAX1111 ADC Driver"); | ||
244 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 840e634fa31f..640cbb237328 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -31,13 +31,84 @@ | |||
31 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
32 | #include <linux/io.h> | 32 | #include <linux/io.h> |
33 | 33 | ||
34 | /* Transmit operation: */ | ||
35 | /* */ | ||
36 | /* 0 byte transmit */ | ||
37 | /* BUS: S A8 ACK P */ | ||
38 | /* IRQ: DTE WAIT */ | ||
39 | /* ICIC: */ | ||
40 | /* ICCR: 0x94 0x90 */ | ||
41 | /* ICDR: A8 */ | ||
42 | /* */ | ||
43 | /* 1 byte transmit */ | ||
44 | /* BUS: S A8 ACK D8(1) ACK P */ | ||
45 | /* IRQ: DTE WAIT WAIT */ | ||
46 | /* ICIC: -DTE */ | ||
47 | /* ICCR: 0x94 0x90 */ | ||
48 | /* ICDR: A8 D8(1) */ | ||
49 | /* */ | ||
50 | /* 2 byte transmit */ | ||
51 | /* BUS: S A8 ACK D8(1) ACK D8(2) ACK P */ | ||
52 | /* IRQ: DTE WAIT WAIT WAIT */ | ||
53 | /* ICIC: -DTE */ | ||
54 | /* ICCR: 0x94 0x90 */ | ||
55 | /* ICDR: A8 D8(1) D8(2) */ | ||
56 | /* */ | ||
57 | /* 3 bytes or more, +---------+ gets repeated */ | ||
58 | /* */ | ||
59 | /* */ | ||
60 | /* Receive operation: */ | ||
61 | /* */ | ||
62 | /* 0 byte receive - not supported since slave may hold SDA low */ | ||
63 | /* */ | ||
64 | /* 1 byte receive [TX] | [RX] */ | ||
65 | /* BUS: S A8 ACK | D8(1) ACK P */ | ||
66 | /* IRQ: DTE WAIT | WAIT DTE */ | ||
67 | /* ICIC: -DTE | +DTE */ | ||
68 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
69 | /* ICDR: A8 | D8(1) */ | ||
70 | /* */ | ||
71 | /* 2 byte receive [TX]| [RX] */ | ||
72 | /* BUS: S A8 ACK | D8(1) ACK D8(2) ACK P */ | ||
73 | /* IRQ: DTE WAIT | WAIT WAIT DTE */ | ||
74 | /* ICIC: -DTE | +DTE */ | ||
75 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
76 | /* ICDR: A8 | D8(1) D8(2) */ | ||
77 | /* */ | ||
78 | /* 3 byte receive [TX] | [RX] */ | ||
79 | /* BUS: S A8 ACK | D8(1) ACK D8(2) ACK D8(3) ACK P */ | ||
80 | /* IRQ: DTE WAIT | WAIT WAIT WAIT DTE */ | ||
81 | /* ICIC: -DTE | +DTE */ | ||
82 | /* ICCR: 0x94 0x81 | 0xc0 */ | ||
83 | /* ICDR: A8 | D8(1) D8(2) D8(3) */ | ||
84 | /* */ | ||
85 | /* 4 bytes or more, this part is repeated +---------+ */ | ||
86 | /* */ | ||
87 | /* */ | ||
88 | /* Interrupt order and BUSY flag */ | ||
89 | /* ___ _ */ | ||
90 | /* SDA ___\___XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAAAAAAAAA___/ */ | ||
91 | /* SCL \_/1\_/2\_/3\_/4\_/5\_/6\_/7\_/8\___/9\_____/ */ | ||
92 | /* */ | ||
93 | /* S D7 D6 D5 D4 D3 D2 D1 D0 P */ | ||
94 | /* ___ */ | ||
95 | /* WAIT IRQ ________________________________/ \___________ */ | ||
96 | /* TACK IRQ ____________________________________/ \_______ */ | ||
97 | /* DTE IRQ __________________________________________/ \_ */ | ||
98 | /* AL IRQ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ | ||
99 | /* _______________________________________________ */ | ||
100 | /* BUSY __/ \_ */ | ||
101 | /* */ | ||
102 | |||
34 | enum sh_mobile_i2c_op { | 103 | enum sh_mobile_i2c_op { |
35 | OP_START = 0, | 104 | OP_START = 0, |
36 | OP_TX_ONLY, | 105 | OP_TX_FIRST, |
106 | OP_TX, | ||
37 | OP_TX_STOP, | 107 | OP_TX_STOP, |
38 | OP_TX_TO_RX, | 108 | OP_TX_TO_RX, |
39 | OP_RX_ONLY, | 109 | OP_RX, |
40 | OP_RX_STOP, | 110 | OP_RX_STOP, |
111 | OP_RX_STOP_DATA, | ||
41 | }; | 112 | }; |
42 | 113 | ||
43 | struct sh_mobile_i2c_data { | 114 | struct sh_mobile_i2c_data { |
@@ -127,25 +198,34 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, | |||
127 | spin_lock_irqsave(&pd->lock, flags); | 198 | spin_lock_irqsave(&pd->lock, flags); |
128 | 199 | ||
129 | switch (op) { | 200 | switch (op) { |
130 | case OP_START: | 201 | case OP_START: /* issue start and trigger DTE interrupt */ |
131 | iowrite8(0x94, ICCR(pd)); | 202 | iowrite8(0x94, ICCR(pd)); |
132 | break; | 203 | break; |
133 | case OP_TX_ONLY: | 204 | case OP_TX_FIRST: /* disable DTE interrupt and write data */ |
205 | iowrite8(ICIC_WAITE | ICIC_ALE | ICIC_TACKE, ICIC(pd)); | ||
134 | iowrite8(data, ICDR(pd)); | 206 | iowrite8(data, ICDR(pd)); |
135 | break; | 207 | break; |
136 | case OP_TX_STOP: | 208 | case OP_TX: /* write data */ |
137 | iowrite8(data, ICDR(pd)); | 209 | iowrite8(data, ICDR(pd)); |
138 | iowrite8(0x90, ICCR(pd)); | ||
139 | iowrite8(ICIC_ALE | ICIC_TACKE, ICIC(pd)); | ||
140 | break; | 210 | break; |
141 | case OP_TX_TO_RX: | 211 | case OP_TX_STOP: /* write data and issue a stop afterwards */ |
142 | iowrite8(data, ICDR(pd)); | 212 | iowrite8(data, ICDR(pd)); |
213 | iowrite8(0x90, ICCR(pd)); | ||
214 | break; | ||
215 | case OP_TX_TO_RX: /* select read mode */ | ||
143 | iowrite8(0x81, ICCR(pd)); | 216 | iowrite8(0x81, ICCR(pd)); |
144 | break; | 217 | break; |
145 | case OP_RX_ONLY: | 218 | case OP_RX: /* just read data */ |
146 | ret = ioread8(ICDR(pd)); | 219 | ret = ioread8(ICDR(pd)); |
147 | break; | 220 | break; |
148 | case OP_RX_STOP: | 221 | case OP_RX_STOP: /* enable DTE interrupt, issue stop */ |
222 | iowrite8(ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE, | ||
223 | ICIC(pd)); | ||
224 | iowrite8(0xc0, ICCR(pd)); | ||
225 | break; | ||
226 | case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */ | ||
227 | iowrite8(ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE, | ||
228 | ICIC(pd)); | ||
149 | ret = ioread8(ICDR(pd)); | 229 | ret = ioread8(ICDR(pd)); |
150 | iowrite8(0xc0, ICCR(pd)); | 230 | iowrite8(0xc0, ICCR(pd)); |
151 | break; | 231 | break; |
@@ -157,58 +237,120 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, | |||
157 | return ret; | 237 | return ret; |
158 | } | 238 | } |
159 | 239 | ||
240 | static int sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd) | ||
241 | { | ||
242 | if (pd->pos == -1) | ||
243 | return 1; | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int sh_mobile_i2c_is_last_byte(struct sh_mobile_i2c_data *pd) | ||
249 | { | ||
250 | if (pd->pos == (pd->msg->len - 1)) | ||
251 | return 1; | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static void sh_mobile_i2c_get_data(struct sh_mobile_i2c_data *pd, | ||
257 | unsigned char *buf) | ||
258 | { | ||
259 | switch (pd->pos) { | ||
260 | case -1: | ||
261 | *buf = (pd->msg->addr & 0x7f) << 1; | ||
262 | *buf |= (pd->msg->flags & I2C_M_RD) ? 1 : 0; | ||
263 | break; | ||
264 | default: | ||
265 | *buf = pd->msg->buf[pd->pos]; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) | ||
270 | { | ||
271 | unsigned char data; | ||
272 | |||
273 | if (pd->pos == pd->msg->len) | ||
274 | return 1; | ||
275 | |||
276 | sh_mobile_i2c_get_data(pd, &data); | ||
277 | |||
278 | if (sh_mobile_i2c_is_last_byte(pd)) | ||
279 | i2c_op(pd, OP_TX_STOP, data); | ||
280 | else if (sh_mobile_i2c_is_first_byte(pd)) | ||
281 | i2c_op(pd, OP_TX_FIRST, data); | ||
282 | else | ||
283 | i2c_op(pd, OP_TX, data); | ||
284 | |||
285 | pd->pos++; | ||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) | ||
290 | { | ||
291 | unsigned char data; | ||
292 | int real_pos; | ||
293 | |||
294 | do { | ||
295 | if (pd->pos <= -1) { | ||
296 | sh_mobile_i2c_get_data(pd, &data); | ||
297 | |||
298 | if (sh_mobile_i2c_is_first_byte(pd)) | ||
299 | i2c_op(pd, OP_TX_FIRST, data); | ||
300 | else | ||
301 | i2c_op(pd, OP_TX, data); | ||
302 | break; | ||
303 | } | ||
304 | |||
305 | if (pd->pos == 0) { | ||
306 | i2c_op(pd, OP_TX_TO_RX, 0); | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | real_pos = pd->pos - 2; | ||
311 | |||
312 | if (pd->pos == pd->msg->len) { | ||
313 | if (real_pos < 0) { | ||
314 | i2c_op(pd, OP_RX_STOP, 0); | ||
315 | break; | ||
316 | } | ||
317 | data = i2c_op(pd, OP_RX_STOP_DATA, 0); | ||
318 | } else | ||
319 | data = i2c_op(pd, OP_RX, 0); | ||
320 | |||
321 | pd->msg->buf[real_pos] = data; | ||
322 | } while (0); | ||
323 | |||
324 | pd->pos++; | ||
325 | return pd->pos == (pd->msg->len + 2); | ||
326 | } | ||
327 | |||
160 | static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) | 328 | static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) |
161 | { | 329 | { |
162 | struct platform_device *dev = dev_id; | 330 | struct platform_device *dev = dev_id; |
163 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); | 331 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); |
164 | struct i2c_msg *msg = pd->msg; | 332 | unsigned char sr; |
165 | unsigned char data, sr; | 333 | int wakeup; |
166 | int wakeup = 0; | ||
167 | 334 | ||
168 | sr = ioread8(ICSR(pd)); | 335 | sr = ioread8(ICSR(pd)); |
169 | pd->sr |= sr; | 336 | pd->sr |= sr; /* remember state */ |
170 | 337 | ||
171 | dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr, | 338 | dev_dbg(pd->dev, "i2c_isr 0x%02x 0x%02x %s %d %d!\n", sr, pd->sr, |
172 | (msg->flags & I2C_M_RD) ? "read" : "write", | 339 | (pd->msg->flags & I2C_M_RD) ? "read" : "write", |
173 | pd->pos, msg->len); | 340 | pd->pos, pd->msg->len); |
174 | 341 | ||
175 | if (sr & (ICSR_AL | ICSR_TACK)) { | 342 | if (sr & (ICSR_AL | ICSR_TACK)) { |
176 | iowrite8(0, ICIC(pd)); /* disable interrupts */ | 343 | /* don't interrupt transaction - continue to issue stop */ |
177 | wakeup = 1; | 344 | iowrite8(sr & ~(ICSR_AL | ICSR_TACK), ICSR(pd)); |
178 | goto do_wakeup; | 345 | wakeup = 0; |
179 | } | 346 | } else if (pd->msg->flags & I2C_M_RD) |
347 | wakeup = sh_mobile_i2c_isr_rx(pd); | ||
348 | else | ||
349 | wakeup = sh_mobile_i2c_isr_tx(pd); | ||
180 | 350 | ||
181 | if (pd->pos == msg->len) { | 351 | if (sr & ICSR_WAIT) /* TODO: add delay here to support slow acks */ |
182 | i2c_op(pd, OP_RX_ONLY, 0); | 352 | iowrite8(sr & ~ICSR_WAIT, ICSR(pd)); |
183 | wakeup = 1; | ||
184 | goto do_wakeup; | ||
185 | } | ||
186 | 353 | ||
187 | if (pd->pos == -1) { | ||
188 | data = (msg->addr & 0x7f) << 1; | ||
189 | data |= (msg->flags & I2C_M_RD) ? 1 : 0; | ||
190 | } else | ||
191 | data = msg->buf[pd->pos]; | ||
192 | |||
193 | if ((pd->pos == -1) || !(msg->flags & I2C_M_RD)) { | ||
194 | if (msg->flags & I2C_M_RD) | ||
195 | i2c_op(pd, OP_TX_TO_RX, data); | ||
196 | else if (pd->pos == (msg->len - 1)) { | ||
197 | i2c_op(pd, OP_TX_STOP, data); | ||
198 | wakeup = 1; | ||
199 | } else | ||
200 | i2c_op(pd, OP_TX_ONLY, data); | ||
201 | } else { | ||
202 | if (pd->pos == (msg->len - 1)) | ||
203 | data = i2c_op(pd, OP_RX_STOP, 0); | ||
204 | else | ||
205 | data = i2c_op(pd, OP_RX_ONLY, 0); | ||
206 | |||
207 | msg->buf[pd->pos] = data; | ||
208 | } | ||
209 | pd->pos++; | ||
210 | |||
211 | do_wakeup: | ||
212 | if (wakeup) { | 354 | if (wakeup) { |
213 | pd->sr |= SW_DONE; | 355 | pd->sr |= SW_DONE; |
214 | wake_up(&pd->wait); | 356 | wake_up(&pd->wait); |
@@ -219,6 +361,11 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id) | |||
219 | 361 | ||
220 | static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) | 362 | static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) |
221 | { | 363 | { |
364 | if (usr_msg->len == 0 && (usr_msg->flags & I2C_M_RD)) { | ||
365 | dev_err(pd->dev, "Unsupported zero length i2c read\n"); | ||
366 | return -EIO; | ||
367 | } | ||
368 | |||
222 | /* Initialize channel registers */ | 369 | /* Initialize channel registers */ |
223 | iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); | 370 | iowrite8(ioread8(ICCR(pd)) & ~ICCR_ICE, ICCR(pd)); |
224 | 371 | ||
@@ -233,9 +380,8 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg) | |||
233 | pd->pos = -1; | 380 | pd->pos = -1; |
234 | pd->sr = 0; | 381 | pd->sr = 0; |
235 | 382 | ||
236 | /* Enable all interrupts except wait */ | 383 | /* Enable all interrupts to begin with */ |
237 | iowrite8(ioread8(ICIC(pd)) | ICIC_ALE | ICIC_TACKE | ICIC_DTEE, | 384 | iowrite8(ICIC_WAITE | ICIC_ALE | ICIC_TACKE | ICIC_DTEE, ICIC(pd)); |
238 | ICIC(pd)); | ||
239 | return 0; | 385 | return 0; |
240 | } | 386 | } |
241 | 387 | ||
@@ -268,25 +414,18 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, | |||
268 | if (!k) | 414 | if (!k) |
269 | dev_err(pd->dev, "Transfer request timed out\n"); | 415 | dev_err(pd->dev, "Transfer request timed out\n"); |
270 | 416 | ||
271 | retry_count = 10; | 417 | retry_count = 1000; |
272 | again: | 418 | again: |
273 | val = ioread8(ICSR(pd)); | 419 | val = ioread8(ICSR(pd)); |
274 | 420 | ||
275 | dev_dbg(pd->dev, "val 0x%02x pd->sr 0x%02x\n", val, pd->sr); | 421 | dev_dbg(pd->dev, "val 0x%02x pd->sr 0x%02x\n", val, pd->sr); |
276 | 422 | ||
277 | if ((val | pd->sr) & (ICSR_TACK | ICSR_AL)) { | ||
278 | err = -EIO; | ||
279 | break; | ||
280 | } | ||
281 | |||
282 | /* the interrupt handler may wake us up before the | 423 | /* the interrupt handler may wake us up before the |
283 | * transfer is finished, so poll the hardware | 424 | * transfer is finished, so poll the hardware |
284 | * until we're done. | 425 | * until we're done. |
285 | */ | 426 | */ |
286 | 427 | if (val & ICSR_BUSY) { | |
287 | if (!(!(val & ICSR_BUSY) && (val & ICSR_SCLM) && | 428 | udelay(10); |
288 | (val & ICSR_SDAM))) { | ||
289 | msleep(1); | ||
290 | if (retry_count--) | 429 | if (retry_count--) |
291 | goto again; | 430 | goto again; |
292 | 431 | ||
@@ -294,6 +433,12 @@ again: | |||
294 | dev_err(pd->dev, "Polling timed out\n"); | 433 | dev_err(pd->dev, "Polling timed out\n"); |
295 | break; | 434 | break; |
296 | } | 435 | } |
436 | |||
437 | /* handle missing acknowledge and arbitration lost */ | ||
438 | if ((val | pd->sr) & (ICSR_TACK | ICSR_AL)) { | ||
439 | err = -EIO; | ||
440 | break; | ||
441 | } | ||
297 | } | 442 | } |
298 | 443 | ||
299 | deactivate_ch(pd); | 444 | deactivate_ch(pd); |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 550853f79ae8..b346a687ab59 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -108,6 +108,9 @@ static int i2c_device_probe(struct device *dev) | |||
108 | if (!driver->probe || !driver->id_table) | 108 | if (!driver->probe || !driver->id_table) |
109 | return -ENODEV; | 109 | return -ENODEV; |
110 | client->driver = driver; | 110 | client->driver = driver; |
111 | if (!device_can_wakeup(&client->dev)) | ||
112 | device_init_wakeup(&client->dev, | ||
113 | client->flags & I2C_CLIENT_WAKE); | ||
111 | dev_dbg(dev, "probe\n"); | 114 | dev_dbg(dev, "probe\n"); |
112 | 115 | ||
113 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); | 116 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); |
@@ -262,9 +265,8 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) | |||
262 | client->adapter = adap; | 265 | client->adapter = adap; |
263 | 266 | ||
264 | client->dev.platform_data = info->platform_data; | 267 | client->dev.platform_data = info->platform_data; |
265 | device_init_wakeup(&client->dev, info->flags & I2C_CLIENT_WAKE); | ||
266 | 268 | ||
267 | client->flags = info->flags & ~I2C_CLIENT_WAKE; | 269 | client->flags = info->flags; |
268 | client->addr = info->addr; | 270 | client->addr = info->addr; |
269 | client->irq = info->irq; | 271 | client->irq = info->irq; |
270 | 272 | ||
@@ -1188,8 +1190,8 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
1188 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | 1190 | && address_data->normal_i2c[0] == I2C_CLIENT_END) |
1189 | return 0; | 1191 | return 0; |
1190 | 1192 | ||
1191 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | 1193 | dev_dbg(&adapter->dev, "SMBus Quick command not supported, " |
1192 | "can't probe for chips\n"); | 1194 | "can't probe for chips\n"); |
1193 | return -EOPNOTSUPP; | 1195 | return -EOPNOTSUPP; |
1194 | } | 1196 | } |
1195 | 1197 | ||
@@ -1350,6 +1352,10 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) | |||
1350 | } | 1352 | } |
1351 | } | 1353 | } |
1352 | 1354 | ||
1355 | /* Stop here if the classes do not match */ | ||
1356 | if (!(adapter->class & driver->class)) | ||
1357 | goto exit_free; | ||
1358 | |||
1353 | /* Stop here if we can't use SMBUS_QUICK */ | 1359 | /* Stop here if we can't use SMBUS_QUICK */ |
1354 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | 1360 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { |
1355 | if (address_data->probe[0] == I2C_CLIENT_END | 1361 | if (address_data->probe[0] == I2C_CLIENT_END |
@@ -1362,10 +1368,6 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) | |||
1362 | goto exit_free; | 1368 | goto exit_free; |
1363 | } | 1369 | } |
1364 | 1370 | ||
1365 | /* Stop here if the classes do not match */ | ||
1366 | if (!(adapter->class & driver->class)) | ||
1367 | goto exit_free; | ||
1368 | |||
1369 | /* Probe entries are done second, and are not affected by ignore | 1371 | /* Probe entries are done second, and are not affected by ignore |
1370 | entries either */ | 1372 | entries either */ |
1371 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { | 1373 | for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index a34758d29516..fc735ab08ff4 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -242,7 +242,7 @@ config BLK_DEV_IDEFLOPPY | |||
242 | module will be called ide-floppy. | 242 | module will be called ide-floppy. |
243 | 243 | ||
244 | config BLK_DEV_IDESCSI | 244 | config BLK_DEV_IDESCSI |
245 | tristate "SCSI emulation support" | 245 | tristate "SCSI emulation support (DEPRECATED)" |
246 | depends on SCSI | 246 | depends on SCSI |
247 | select IDE_ATAPI | 247 | select IDE_ATAPI |
248 | ---help--- | 248 | ---help--- |
@@ -255,20 +255,6 @@ config BLK_DEV_IDESCSI | |||
255 | and will allow you to use a SCSI device driver instead of a native | 255 | and will allow you to use a SCSI device driver instead of a native |
256 | ATAPI driver. | 256 | ATAPI driver. |
257 | 257 | ||
258 | This is useful if you have an ATAPI device for which no native | ||
259 | driver has been written (for example, an ATAPI PD-CD drive); | ||
260 | you can then use this emulation together with an appropriate SCSI | ||
261 | device driver. In order to do this, say Y here and to "SCSI support" | ||
262 | and "SCSI generic support", below. You must then provide the kernel | ||
263 | command line "hdx=ide-scsi" (try "man bootparam" or see the | ||
264 | documentation of your boot loader (lilo or loadlin) about how to | ||
265 | pass options to the kernel at boot time) for devices if you want the | ||
266 | native EIDE sub-drivers to skip over the native support, so that | ||
267 | this SCSI emulation can be used instead. | ||
268 | |||
269 | Note that this option does NOT allow you to attach SCSI devices to a | ||
270 | box that doesn't have a SCSI host adapter installed. | ||
271 | |||
272 | If both this SCSI emulation and native ATAPI support are compiled | 258 | If both this SCSI emulation and native ATAPI support are compiled |
273 | into the kernel, the native support will be used. | 259 | into the kernel, the native support will be used. |
274 | 260 | ||
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index f788fa5a977b..4fd91dcf1dc2 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -343,11 +343,10 @@ static struct ide_port_info __devinitdata palm_bk3710_port_info = { | |||
343 | .mwdma_mask = ATA_MWDMA2, | 343 | .mwdma_mask = ATA_MWDMA2, |
344 | }; | 344 | }; |
345 | 345 | ||
346 | static int __devinit palm_bk3710_probe(struct platform_device *pdev) | 346 | static int __init palm_bk3710_probe(struct platform_device *pdev) |
347 | { | 347 | { |
348 | struct clk *clk; | 348 | struct clk *clk; |
349 | struct resource *mem, *irq; | 349 | struct resource *mem, *irq; |
350 | struct ide_host *host; | ||
351 | unsigned long base, rate; | 350 | unsigned long base, rate; |
352 | int i, rc; | 351 | int i, rc; |
353 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; | 352 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
@@ -390,6 +389,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
390 | hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i; | 389 | hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i; |
391 | hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET; | 390 | hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET; |
392 | hw.irq = irq->start; | 391 | hw.irq = irq->start; |
392 | hw.dev = &pdev->dev; | ||
393 | hw.chipset = ide_palm3710; | 393 | hw.chipset = ide_palm3710; |
394 | 394 | ||
395 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : | 395 | palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 : |
@@ -413,13 +413,11 @@ static struct platform_driver platform_bk_driver = { | |||
413 | .name = "palm_bk3710", | 413 | .name = "palm_bk3710", |
414 | .owner = THIS_MODULE, | 414 | .owner = THIS_MODULE, |
415 | }, | 415 | }, |
416 | .probe = palm_bk3710_probe, | ||
417 | .remove = NULL, | ||
418 | }; | 416 | }; |
419 | 417 | ||
420 | static int __init palm_bk3710_init(void) | 418 | static int __init palm_bk3710_init(void) |
421 | { | 419 | { |
422 | return platform_driver_register(&platform_bk_driver); | 420 | return platform_driver_probe(&platform_bk_driver, palm_bk3710_probe); |
423 | } | 421 | } |
424 | 422 | ||
425 | module_init(palm_bk3710_init); | 423 | module_init(palm_bk3710_init); |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 49a8c589e346..f1489999cf91 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1933,6 +1933,7 @@ static void ide_cd_remove(ide_drive_t *drive) | |||
1933 | 1933 | ||
1934 | ide_proc_unregister_driver(drive, info->driver); | 1934 | ide_proc_unregister_driver(drive, info->driver); |
1935 | 1935 | ||
1936 | blk_unregister_filter(info->disk); | ||
1936 | del_gendisk(info->disk); | 1937 | del_gendisk(info->disk); |
1937 | 1938 | ||
1938 | ide_cd_put(info); | 1939 | ide_cd_put(info); |
@@ -2158,6 +2159,7 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2158 | g->fops = &idecd_ops; | 2159 | g->fops = &idecd_ops; |
2159 | g->flags |= GENHD_FL_REMOVABLE; | 2160 | g->flags |= GENHD_FL_REMOVABLE; |
2160 | add_disk(g); | 2161 | add_disk(g); |
2162 | blk_register_filter(g); | ||
2161 | return 0; | 2163 | return 0; |
2162 | 2164 | ||
2163 | out_free_cd: | 2165 | out_free_cd: |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 68b9cf0138b0..07ef88bd109b 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -445,20 +445,6 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | /* | ||
449 | * Compute drive->capacity, the full capacity of the drive | ||
450 | * Called with drive->id != NULL. | ||
451 | * | ||
452 | * To compute capacity, this uses either of | ||
453 | * | ||
454 | * 1. CHS value set by user (whatever user sets will be trusted) | ||
455 | * 2. LBA value from target drive (require new ATA feature) | ||
456 | * 3. LBA value from system BIOS (new one is OK, old one may break) | ||
457 | * 4. CHS value from system BIOS (traditional style) | ||
458 | * | ||
459 | * in above order (i.e., if value of higher priority is available, | ||
460 | * reset will be ignored). | ||
461 | */ | ||
462 | static void init_idedisk_capacity(ide_drive_t *drive) | 448 | static void init_idedisk_capacity(ide_drive_t *drive) |
463 | { | 449 | { |
464 | struct hd_driveid *id = drive->id; | 450 | struct hd_driveid *id = drive->id; |
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c index a4cdb465cd1d..87f5c5a87b98 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c | |||
@@ -204,6 +204,8 @@ struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd, | |||
204 | if (err) | 204 | if (err) |
205 | goto err_mr; | 205 | goto err_mr; |
206 | 206 | ||
207 | mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; | ||
208 | |||
207 | return &mr->ibmr; | 209 | return &mr->ibmr; |
208 | 210 | ||
209 | err_mr: | 211 | err_mr: |
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index 6f227d3dbda1..e348cfccc17a 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/input.h> | 43 | #include <linux/input.h> |
44 | 44 | ||
45 | #include <asm/portmux.h> | 45 | #include <asm/portmux.h> |
46 | #include <asm/mach/bf54x_keys.h> | 46 | #include <mach/bf54x_keys.h> |
47 | 47 | ||
48 | #define DRV_NAME "bf54x-keys" | 48 | #define DRV_NAME "bf54x-keys" |
49 | #define TIME_SCALE 100 /* 100 ns */ | 49 | #define TIME_SCALE 100 /* 100 ns */ |
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index 2ec921bf3c60..18f4d7f6ce6d 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c | |||
@@ -63,7 +63,7 @@ | |||
63 | } | 63 | } |
64 | 64 | ||
65 | /* table of devices that work with this driver */ | 65 | /* table of devices that work with this driver */ |
66 | static const struct usb_device_id bcm5974_table [] = { | 66 | static const struct usb_device_id bcm5974_table[] = { |
67 | /* MacbookAir1.1 */ | 67 | /* MacbookAir1.1 */ |
68 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), | 68 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
69 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), | 69 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
@@ -105,7 +105,7 @@ struct tp_header { | |||
105 | 105 | ||
106 | /* trackpad finger structure */ | 106 | /* trackpad finger structure */ |
107 | struct tp_finger { | 107 | struct tp_finger { |
108 | __le16 origin; /* left/right origin? */ | 108 | __le16 origin; /* zero when switching track finger */ |
109 | __le16 abs_x; /* absolute x coodinate */ | 109 | __le16 abs_x; /* absolute x coodinate */ |
110 | __le16 abs_y; /* absolute y coodinate */ | 110 | __le16 abs_y; /* absolute y coodinate */ |
111 | __le16 rel_x; /* relative x coodinate */ | 111 | __le16 rel_x; /* relative x coodinate */ |
@@ -159,6 +159,7 @@ struct bcm5974 { | |||
159 | struct bt_data *bt_data; /* button transferred data */ | 159 | struct bt_data *bt_data; /* button transferred data */ |
160 | struct urb *tp_urb; /* trackpad usb request block */ | 160 | struct urb *tp_urb; /* trackpad usb request block */ |
161 | struct tp_data *tp_data; /* trackpad transferred data */ | 161 | struct tp_data *tp_data; /* trackpad transferred data */ |
162 | int fingers; /* number of fingers on trackpad */ | ||
162 | }; | 163 | }; |
163 | 164 | ||
164 | /* logical dimensions */ | 165 | /* logical dimensions */ |
@@ -172,6 +173,10 @@ struct bcm5974 { | |||
172 | #define SN_WIDTH 100 /* width signal-to-noise ratio */ | 173 | #define SN_WIDTH 100 /* width signal-to-noise ratio */ |
173 | #define SN_COORD 250 /* coordinate signal-to-noise ratio */ | 174 | #define SN_COORD 250 /* coordinate signal-to-noise ratio */ |
174 | 175 | ||
176 | /* pressure thresholds */ | ||
177 | #define PRESSURE_LOW (2 * DIM_PRESSURE / SN_PRESSURE) | ||
178 | #define PRESSURE_HIGH (3 * PRESSURE_LOW) | ||
179 | |||
175 | /* device constants */ | 180 | /* device constants */ |
176 | static const struct bcm5974_config bcm5974_config_table[] = { | 181 | static const struct bcm5974_config bcm5974_config_table[] = { |
177 | { | 182 | { |
@@ -248,6 +253,7 @@ static void setup_events_to_report(struct input_dev *input_dev, | |||
248 | 0, cfg->y.dim, cfg->y.fuzz, 0); | 253 | 0, cfg->y.dim, cfg->y.fuzz, 0); |
249 | 254 | ||
250 | __set_bit(EV_KEY, input_dev->evbit); | 255 | __set_bit(EV_KEY, input_dev->evbit); |
256 | __set_bit(BTN_TOUCH, input_dev->keybit); | ||
251 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | 257 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); |
252 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | 258 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); |
253 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); | 259 | __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); |
@@ -273,32 +279,66 @@ static int report_tp_state(struct bcm5974 *dev, int size) | |||
273 | const struct tp_finger *f = dev->tp_data->finger; | 279 | const struct tp_finger *f = dev->tp_data->finger; |
274 | struct input_dev *input = dev->input; | 280 | struct input_dev *input = dev->input; |
275 | const int fingers = (size - 26) / 28; | 281 | const int fingers = (size - 26) / 28; |
276 | int p = 0, w, x, y, n = 0; | 282 | int raw_p, raw_w, raw_x, raw_y; |
283 | int ptest = 0, origin = 0, nmin = 0, nmax = 0; | ||
284 | int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; | ||
277 | 285 | ||
278 | if (size < 26 || (size - 26) % 28 != 0) | 286 | if (size < 26 || (size - 26) % 28 != 0) |
279 | return -EIO; | 287 | return -EIO; |
280 | 288 | ||
289 | /* always track the first finger; when detached, start over */ | ||
281 | if (fingers) { | 290 | if (fingers) { |
282 | p = raw2int(f->force_major); | 291 | raw_p = raw2int(f->force_major); |
283 | w = raw2int(f->size_major); | 292 | raw_w = raw2int(f->size_major); |
284 | x = raw2int(f->abs_x); | 293 | raw_x = raw2int(f->abs_x); |
285 | y = raw2int(f->abs_y); | 294 | raw_y = raw2int(f->abs_y); |
286 | n = p > 0 ? fingers : 0; | ||
287 | 295 | ||
288 | dprintk(9, | 296 | dprintk(9, |
289 | "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", | 297 | "bcm5974: raw: p: %+05d w: %+05d x: %+05d y: %+05d\n", |
290 | p, w, x, y, n); | 298 | raw_p, raw_w, raw_x, raw_y); |
299 | |||
300 | ptest = int2bound(&c->p, raw_p); | ||
301 | origin = raw2int(f->origin); | ||
302 | } | ||
291 | 303 | ||
292 | input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); | 304 | /* while tracking finger still valid, count all fingers */ |
293 | input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); | 305 | if (ptest > PRESSURE_LOW && origin) { |
294 | input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); | 306 | abs_p = ptest; |
307 | abs_w = int2bound(&c->w, raw_w); | ||
308 | abs_x = int2bound(&c->x, raw_x - c->x.devmin); | ||
309 | abs_y = int2bound(&c->y, c->y.devmax - raw_y); | ||
310 | for (; f != dev->tp_data->finger + fingers; f++) { | ||
311 | ptest = int2bound(&c->p, raw2int(f->force_major)); | ||
312 | if (ptest > PRESSURE_LOW) | ||
313 | nmax++; | ||
314 | if (ptest > PRESSURE_HIGH) | ||
315 | nmin++; | ||
316 | } | ||
295 | } | 317 | } |
296 | 318 | ||
297 | input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); | 319 | if (dev->fingers < nmin) |
320 | dev->fingers = nmin; | ||
321 | if (dev->fingers > nmax) | ||
322 | dev->fingers = nmax; | ||
323 | |||
324 | input_report_key(input, BTN_TOUCH, dev->fingers > 0); | ||
325 | input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1); | ||
326 | input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2); | ||
327 | input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers > 2); | ||
298 | 328 | ||
299 | input_report_key(input, BTN_TOOL_FINGER, n == 1); | 329 | input_report_abs(input, ABS_PRESSURE, abs_p); |
300 | input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); | 330 | input_report_abs(input, ABS_TOOL_WIDTH, abs_w); |
301 | input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); | 331 | |
332 | if (abs_p) { | ||
333 | input_report_abs(input, ABS_X, abs_x); | ||
334 | input_report_abs(input, ABS_Y, abs_y); | ||
335 | |||
336 | dprintk(8, | ||
337 | "bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d " | ||
338 | "nmin: %d nmax: %d n: %d\n", | ||
339 | abs_p, abs_w, abs_x, abs_y, nmin, nmax, dev->fingers); | ||
340 | |||
341 | } | ||
302 | 342 | ||
303 | input_sync(input); | 343 | input_sync(input); |
304 | 344 | ||
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 3282b741e246..5aafe24984c5 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
@@ -305,7 +305,7 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = { | |||
305 | .ident = "Lenovo 3000 n100", | 305 | .ident = "Lenovo 3000 n100", |
306 | .matches = { | 306 | .matches = { |
307 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | 307 | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
308 | DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), | 308 | DMI_MATCH(DMI_PRODUCT_NAME, "076804U"), |
309 | }, | 309 | }, |
310 | }, | 310 | }, |
311 | { | 311 | { |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 25287e80e236..6e1e8c624f9e 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -220,6 +220,7 @@ config TOUCHSCREEN_ATMEL_TSADCC | |||
220 | config TOUCHSCREEN_UCB1400 | 220 | config TOUCHSCREEN_UCB1400 |
221 | tristate "Philips UCB1400 touchscreen" | 221 | tristate "Philips UCB1400 touchscreen" |
222 | select AC97_BUS | 222 | select AC97_BUS |
223 | depends on UCB1400_CORE | ||
223 | help | 224 | help |
224 | This enables support for the Philips UCB1400 touchscreen interface. | 225 | This enables support for the Philips UCB1400 touchscreen interface. |
225 | The UCB1400 is an AC97 audio codec. The touchscreen interface | 226 | The UCB1400 is an AC97 audio codec. The touchscreen interface |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index ce6f48c695f5..8583c766d565 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/input.h> | 24 | #include <linux/input.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/gpio.h> | ||
27 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
28 | #include <linux/spi/ads7846.h> | 29 | #include <linux/spi/ads7846.h> |
29 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
@@ -116,6 +117,7 @@ struct ads7846 { | |||
116 | void *filter_data; | 117 | void *filter_data; |
117 | void (*filter_cleanup)(void *data); | 118 | void (*filter_cleanup)(void *data); |
118 | int (*get_pendown_state)(void); | 119 | int (*get_pendown_state)(void); |
120 | int gpio_pendown; | ||
119 | }; | 121 | }; |
120 | 122 | ||
121 | /* leave chip selected when we're done, for quicker re-select? */ | 123 | /* leave chip selected when we're done, for quicker re-select? */ |
@@ -491,6 +493,14 @@ static struct attribute_group ads784x_attr_group = { | |||
491 | 493 | ||
492 | /*--------------------------------------------------------------------------*/ | 494 | /*--------------------------------------------------------------------------*/ |
493 | 495 | ||
496 | static int get_pendown_state(struct ads7846 *ts) | ||
497 | { | ||
498 | if (ts->get_pendown_state) | ||
499 | return ts->get_pendown_state(); | ||
500 | |||
501 | return !gpio_get_value(ts->gpio_pendown); | ||
502 | } | ||
503 | |||
494 | /* | 504 | /* |
495 | * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, | 505 | * PENIRQ only kicks the timer. The timer only reissues the SPI transfer, |
496 | * to retrieve touchscreen status. | 506 | * to retrieve touchscreen status. |
@@ -550,7 +560,7 @@ static void ads7846_rx(void *ads) | |||
550 | */ | 560 | */ |
551 | if (ts->penirq_recheck_delay_usecs) { | 561 | if (ts->penirq_recheck_delay_usecs) { |
552 | udelay(ts->penirq_recheck_delay_usecs); | 562 | udelay(ts->penirq_recheck_delay_usecs); |
553 | if (!ts->get_pendown_state()) | 563 | if (!get_pendown_state(ts)) |
554 | Rt = 0; | 564 | Rt = 0; |
555 | } | 565 | } |
556 | 566 | ||
@@ -677,7 +687,7 @@ static enum hrtimer_restart ads7846_timer(struct hrtimer *handle) | |||
677 | 687 | ||
678 | spin_lock_irq(&ts->lock); | 688 | spin_lock_irq(&ts->lock); |
679 | 689 | ||
680 | if (unlikely(!ts->get_pendown_state() || | 690 | if (unlikely(!get_pendown_state(ts) || |
681 | device_suspended(&ts->spi->dev))) { | 691 | device_suspended(&ts->spi->dev))) { |
682 | if (ts->pendown) { | 692 | if (ts->pendown) { |
683 | struct input_dev *input = ts->input; | 693 | struct input_dev *input = ts->input; |
@@ -716,7 +726,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle) | |||
716 | unsigned long flags; | 726 | unsigned long flags; |
717 | 727 | ||
718 | spin_lock_irqsave(&ts->lock, flags); | 728 | spin_lock_irqsave(&ts->lock, flags); |
719 | if (likely(ts->get_pendown_state())) { | 729 | if (likely(get_pendown_state(ts))) { |
720 | if (!ts->irq_disabled) { | 730 | if (!ts->irq_disabled) { |
721 | /* The ARM do_simple_IRQ() dispatcher doesn't act | 731 | /* The ARM do_simple_IRQ() dispatcher doesn't act |
722 | * like the other dispatchers: it will report IRQs | 732 | * like the other dispatchers: it will report IRQs |
@@ -806,6 +816,36 @@ static int ads7846_resume(struct spi_device *spi) | |||
806 | return 0; | 816 | return 0; |
807 | } | 817 | } |
808 | 818 | ||
819 | static int __devinit setup_pendown(struct spi_device *spi, struct ads7846 *ts) | ||
820 | { | ||
821 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | ||
822 | int err; | ||
823 | |||
824 | /* REVISIT when the irq can be triggered active-low, or if for some | ||
825 | * reason the touchscreen isn't hooked up, we don't need to access | ||
826 | * the pendown state. | ||
827 | */ | ||
828 | if (!pdata->get_pendown_state && !gpio_is_valid(pdata->gpio_pendown)) { | ||
829 | dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); | ||
830 | return -EINVAL; | ||
831 | } | ||
832 | |||
833 | if (pdata->get_pendown_state) { | ||
834 | ts->get_pendown_state = pdata->get_pendown_state; | ||
835 | return 0; | ||
836 | } | ||
837 | |||
838 | err = gpio_request(pdata->gpio_pendown, "ads7846_pendown"); | ||
839 | if (err) { | ||
840 | dev_err(&spi->dev, "failed to request pendown GPIO%d\n", | ||
841 | pdata->gpio_pendown); | ||
842 | return err; | ||
843 | } | ||
844 | |||
845 | ts->gpio_pendown = pdata->gpio_pendown; | ||
846 | return 0; | ||
847 | } | ||
848 | |||
809 | static int __devinit ads7846_probe(struct spi_device *spi) | 849 | static int __devinit ads7846_probe(struct spi_device *spi) |
810 | { | 850 | { |
811 | struct ads7846 *ts; | 851 | struct ads7846 *ts; |
@@ -833,15 +873,6 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
833 | return -EINVAL; | 873 | return -EINVAL; |
834 | } | 874 | } |
835 | 875 | ||
836 | /* REVISIT when the irq can be triggered active-low, or if for some | ||
837 | * reason the touchscreen isn't hooked up, we don't need to access | ||
838 | * the pendown state. | ||
839 | */ | ||
840 | if (pdata->get_pendown_state == NULL) { | ||
841 | dev_dbg(&spi->dev, "no get_pendown_state function?\n"); | ||
842 | return -EINVAL; | ||
843 | } | ||
844 | |||
845 | /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except | 876 | /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except |
846 | * that even if the hardware can do that, the SPI controller driver | 877 | * that even if the hardware can do that, the SPI controller driver |
847 | * may not. So we stick to very-portable 8 bit words, both RX and TX. | 878 | * may not. So we stick to very-portable 8 bit words, both RX and TX. |
@@ -893,7 +924,10 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
893 | ts->filter_data = ts; | 924 | ts->filter_data = ts; |
894 | } else | 925 | } else |
895 | ts->filter = ads7846_no_filter; | 926 | ts->filter = ads7846_no_filter; |
896 | ts->get_pendown_state = pdata->get_pendown_state; | 927 | |
928 | err = setup_pendown(spi, ts); | ||
929 | if (err) | ||
930 | goto err_cleanup_filter; | ||
897 | 931 | ||
898 | if (pdata->penirq_recheck_delay_usecs) | 932 | if (pdata->penirq_recheck_delay_usecs) |
899 | ts->penirq_recheck_delay_usecs = | 933 | ts->penirq_recheck_delay_usecs = |
@@ -1085,7 +1119,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1085 | spi->dev.driver->name, ts)) { | 1119 | spi->dev.driver->name, ts)) { |
1086 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); | 1120 | dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); |
1087 | err = -EBUSY; | 1121 | err = -EBUSY; |
1088 | goto err_cleanup_filter; | 1122 | goto err_free_gpio; |
1089 | } | 1123 | } |
1090 | 1124 | ||
1091 | err = ads784x_hwmon_register(spi, ts); | 1125 | err = ads784x_hwmon_register(spi, ts); |
@@ -1116,6 +1150,9 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
1116 | ads784x_hwmon_unregister(spi, ts); | 1150 | ads784x_hwmon_unregister(spi, ts); |
1117 | err_free_irq: | 1151 | err_free_irq: |
1118 | free_irq(spi->irq, ts); | 1152 | free_irq(spi->irq, ts); |
1153 | err_free_gpio: | ||
1154 | if (ts->gpio_pendown != -1) | ||
1155 | gpio_free(ts->gpio_pendown); | ||
1119 | err_cleanup_filter: | 1156 | err_cleanup_filter: |
1120 | if (ts->filter_cleanup) | 1157 | if (ts->filter_cleanup) |
1121 | ts->filter_cleanup(ts->filter_data); | 1158 | ts->filter_cleanup(ts->filter_data); |
@@ -1140,6 +1177,9 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
1140 | /* suspend left the IRQ disabled */ | 1177 | /* suspend left the IRQ disabled */ |
1141 | enable_irq(ts->spi->irq); | 1178 | enable_irq(ts->spi->irq); |
1142 | 1179 | ||
1180 | if (ts->gpio_pendown != -1) | ||
1181 | gpio_free(ts->gpio_pendown); | ||
1182 | |||
1143 | if (ts->filter_cleanup) | 1183 | if (ts->filter_cleanup) |
1144 | ts->filter_cleanup(ts->filter_data); | 1184 | ts->filter_cleanup(ts->filter_data); |
1145 | 1185 | ||
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c index bce018e45bce..54986627def0 100644 --- a/drivers/input/touchscreen/ucb1400_ts.c +++ b/drivers/input/touchscreen/ucb1400_ts.c | |||
@@ -5,6 +5,10 @@ | |||
5 | * Created: September 25, 2006 | 5 | * Created: September 25, 2006 |
6 | * Copyright: MontaVista Software, Inc. | 6 | * Copyright: MontaVista Software, Inc. |
7 | * | 7 | * |
8 | * Spliting done by: Marek Vasut <marek.vasut@gmail.com> | ||
9 | * If something doesnt work and it worked before spliting, e-mail me, | ||
10 | * dont bother Nicolas please ;-) | ||
11 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as | 13 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation. | 14 | * published by the Free Software Foundation. |
@@ -25,124 +29,16 @@ | |||
25 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
26 | #include <linux/kthread.h> | 30 | #include <linux/kthread.h> |
27 | #include <linux/freezer.h> | 31 | #include <linux/freezer.h> |
28 | 32 | #include <linux/ucb1400.h> | |
29 | #include <sound/core.h> | ||
30 | #include <sound/ac97_codec.h> | ||
31 | |||
32 | |||
33 | /* | ||
34 | * Interesting UCB1400 AC-link registers | ||
35 | */ | ||
36 | |||
37 | #define UCB_IE_RIS 0x5e | ||
38 | #define UCB_IE_FAL 0x60 | ||
39 | #define UCB_IE_STATUS 0x62 | ||
40 | #define UCB_IE_CLEAR 0x62 | ||
41 | #define UCB_IE_ADC (1 << 11) | ||
42 | #define UCB_IE_TSPX (1 << 12) | ||
43 | |||
44 | #define UCB_TS_CR 0x64 | ||
45 | #define UCB_TS_CR_TSMX_POW (1 << 0) | ||
46 | #define UCB_TS_CR_TSPX_POW (1 << 1) | ||
47 | #define UCB_TS_CR_TSMY_POW (1 << 2) | ||
48 | #define UCB_TS_CR_TSPY_POW (1 << 3) | ||
49 | #define UCB_TS_CR_TSMX_GND (1 << 4) | ||
50 | #define UCB_TS_CR_TSPX_GND (1 << 5) | ||
51 | #define UCB_TS_CR_TSMY_GND (1 << 6) | ||
52 | #define UCB_TS_CR_TSPY_GND (1 << 7) | ||
53 | #define UCB_TS_CR_MODE_INT (0 << 8) | ||
54 | #define UCB_TS_CR_MODE_PRES (1 << 8) | ||
55 | #define UCB_TS_CR_MODE_POS (2 << 8) | ||
56 | #define UCB_TS_CR_BIAS_ENA (1 << 11) | ||
57 | #define UCB_TS_CR_TSPX_LOW (1 << 12) | ||
58 | #define UCB_TS_CR_TSMX_LOW (1 << 13) | ||
59 | |||
60 | #define UCB_ADC_CR 0x66 | ||
61 | #define UCB_ADC_SYNC_ENA (1 << 0) | ||
62 | #define UCB_ADC_VREFBYP_CON (1 << 1) | ||
63 | #define UCB_ADC_INP_TSPX (0 << 2) | ||
64 | #define UCB_ADC_INP_TSMX (1 << 2) | ||
65 | #define UCB_ADC_INP_TSPY (2 << 2) | ||
66 | #define UCB_ADC_INP_TSMY (3 << 2) | ||
67 | #define UCB_ADC_INP_AD0 (4 << 2) | ||
68 | #define UCB_ADC_INP_AD1 (5 << 2) | ||
69 | #define UCB_ADC_INP_AD2 (6 << 2) | ||
70 | #define UCB_ADC_INP_AD3 (7 << 2) | ||
71 | #define UCB_ADC_EXT_REF (1 << 5) | ||
72 | #define UCB_ADC_START (1 << 7) | ||
73 | #define UCB_ADC_ENA (1 << 15) | ||
74 | |||
75 | #define UCB_ADC_DATA 0x68 | ||
76 | #define UCB_ADC_DAT_VALID (1 << 15) | ||
77 | #define UCB_ADC_DAT_VALUE(x) ((x) & 0x3ff) | ||
78 | |||
79 | #define UCB_ID 0x7e | ||
80 | #define UCB_ID_1400 0x4304 | ||
81 | |||
82 | |||
83 | struct ucb1400 { | ||
84 | struct snd_ac97 *ac97; | ||
85 | struct input_dev *ts_idev; | ||
86 | |||
87 | int irq; | ||
88 | |||
89 | wait_queue_head_t ts_wait; | ||
90 | struct task_struct *ts_task; | ||
91 | |||
92 | unsigned int irq_pending; /* not bit field shared */ | ||
93 | unsigned int ts_restart:1; | ||
94 | unsigned int adcsync:1; | ||
95 | }; | ||
96 | 33 | ||
97 | static int adcsync; | 34 | static int adcsync; |
98 | static int ts_delay = 55; /* us */ | 35 | static int ts_delay = 55; /* us */ |
99 | static int ts_delay_pressure; /* us */ | 36 | static int ts_delay_pressure; /* us */ |
100 | 37 | ||
101 | static inline u16 ucb1400_reg_read(struct ucb1400 *ucb, u16 reg) | ||
102 | { | ||
103 | return ucb->ac97->bus->ops->read(ucb->ac97, reg); | ||
104 | } | ||
105 | |||
106 | static inline void ucb1400_reg_write(struct ucb1400 *ucb, u16 reg, u16 val) | ||
107 | { | ||
108 | ucb->ac97->bus->ops->write(ucb->ac97, reg, val); | ||
109 | } | ||
110 | |||
111 | static inline void ucb1400_adc_enable(struct ucb1400 *ucb) | ||
112 | { | ||
113 | ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA); | ||
114 | } | ||
115 | |||
116 | static unsigned int ucb1400_adc_read(struct ucb1400 *ucb, u16 adc_channel) | ||
117 | { | ||
118 | unsigned int val; | ||
119 | |||
120 | if (ucb->adcsync) | ||
121 | adc_channel |= UCB_ADC_SYNC_ENA; | ||
122 | |||
123 | ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | adc_channel); | ||
124 | ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | adc_channel | UCB_ADC_START); | ||
125 | |||
126 | for (;;) { | ||
127 | val = ucb1400_reg_read(ucb, UCB_ADC_DATA); | ||
128 | if (val & UCB_ADC_DAT_VALID) | ||
129 | break; | ||
130 | /* yield to other processes */ | ||
131 | schedule_timeout_uninterruptible(1); | ||
132 | } | ||
133 | |||
134 | return UCB_ADC_DAT_VALUE(val); | ||
135 | } | ||
136 | |||
137 | static inline void ucb1400_adc_disable(struct ucb1400 *ucb) | ||
138 | { | ||
139 | ucb1400_reg_write(ucb, UCB_ADC_CR, 0); | ||
140 | } | ||
141 | |||
142 | /* Switch to interrupt mode. */ | 38 | /* Switch to interrupt mode. */ |
143 | static inline void ucb1400_ts_mode_int(struct ucb1400 *ucb) | 39 | static inline void ucb1400_ts_mode_int(struct snd_ac97 *ac97) |
144 | { | 40 | { |
145 | ucb1400_reg_write(ucb, UCB_TS_CR, | 41 | ucb1400_reg_write(ac97, UCB_TS_CR, |
146 | UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | | 42 | UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | |
147 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | | 43 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | |
148 | UCB_TS_CR_MODE_INT); | 44 | UCB_TS_CR_MODE_INT); |
@@ -152,14 +48,14 @@ static inline void ucb1400_ts_mode_int(struct ucb1400 *ucb) | |||
152 | * Switch to pressure mode, and read pressure. We don't need to wait | 48 | * Switch to pressure mode, and read pressure. We don't need to wait |
153 | * here, since both plates are being driven. | 49 | * here, since both plates are being driven. |
154 | */ | 50 | */ |
155 | static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400 *ucb) | 51 | static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400_ts *ucb) |
156 | { | 52 | { |
157 | ucb1400_reg_write(ucb, UCB_TS_CR, | 53 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
158 | UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | | 54 | UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | |
159 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | | 55 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | |
160 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 56 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
161 | udelay(ts_delay_pressure); | 57 | udelay(ts_delay_pressure); |
162 | return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY); | 58 | return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPY, adcsync); |
163 | } | 59 | } |
164 | 60 | ||
165 | /* | 61 | /* |
@@ -168,21 +64,21 @@ static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400 *ucb) | |||
168 | * gives a faster response time. Even so, we need to wait about 55us | 64 | * gives a faster response time. Even so, we need to wait about 55us |
169 | * for things to stabilise. | 65 | * for things to stabilise. |
170 | */ | 66 | */ |
171 | static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400 *ucb) | 67 | static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400_ts *ucb) |
172 | { | 68 | { |
173 | ucb1400_reg_write(ucb, UCB_TS_CR, | 69 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
174 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | | 70 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | |
175 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 71 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
176 | ucb1400_reg_write(ucb, UCB_TS_CR, | 72 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
177 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | | 73 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | |
178 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 74 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
179 | ucb1400_reg_write(ucb, UCB_TS_CR, | 75 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
180 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | | 76 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | |
181 | UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); | 77 | UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); |
182 | 78 | ||
183 | udelay(ts_delay); | 79 | udelay(ts_delay); |
184 | 80 | ||
185 | return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPY); | 81 | return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPY, adcsync); |
186 | } | 82 | } |
187 | 83 | ||
188 | /* | 84 | /* |
@@ -191,63 +87,63 @@ static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400 *ucb) | |||
191 | * gives a faster response time. Even so, we need to wait about 55us | 87 | * gives a faster response time. Even so, we need to wait about 55us |
192 | * for things to stabilise. | 88 | * for things to stabilise. |
193 | */ | 89 | */ |
194 | static inline unsigned int ucb1400_ts_read_ypos(struct ucb1400 *ucb) | 90 | static inline unsigned int ucb1400_ts_read_ypos(struct ucb1400_ts *ucb) |
195 | { | 91 | { |
196 | ucb1400_reg_write(ucb, UCB_TS_CR, | 92 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
197 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | | 93 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | |
198 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 94 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
199 | ucb1400_reg_write(ucb, UCB_TS_CR, | 95 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
200 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | | 96 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | |
201 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 97 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
202 | ucb1400_reg_write(ucb, UCB_TS_CR, | 98 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
203 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | | 99 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | |
204 | UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); | 100 | UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); |
205 | 101 | ||
206 | udelay(ts_delay); | 102 | udelay(ts_delay); |
207 | 103 | ||
208 | return ucb1400_adc_read(ucb, UCB_ADC_INP_TSPX); | 104 | return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPX, adcsync); |
209 | } | 105 | } |
210 | 106 | ||
211 | /* | 107 | /* |
212 | * Switch to X plate resistance mode. Set MX to ground, PX to | 108 | * Switch to X plate resistance mode. Set MX to ground, PX to |
213 | * supply. Measure current. | 109 | * supply. Measure current. |
214 | */ | 110 | */ |
215 | static inline unsigned int ucb1400_ts_read_xres(struct ucb1400 *ucb) | 111 | static inline unsigned int ucb1400_ts_read_xres(struct ucb1400_ts *ucb) |
216 | { | 112 | { |
217 | ucb1400_reg_write(ucb, UCB_TS_CR, | 113 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
218 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | | 114 | UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | |
219 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 115 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
220 | return ucb1400_adc_read(ucb, 0); | 116 | return ucb1400_adc_read(ucb->ac97, 0, adcsync); |
221 | } | 117 | } |
222 | 118 | ||
223 | /* | 119 | /* |
224 | * Switch to Y plate resistance mode. Set MY to ground, PY to | 120 | * Switch to Y plate resistance mode. Set MY to ground, PY to |
225 | * supply. Measure current. | 121 | * supply. Measure current. |
226 | */ | 122 | */ |
227 | static inline unsigned int ucb1400_ts_read_yres(struct ucb1400 *ucb) | 123 | static inline unsigned int ucb1400_ts_read_yres(struct ucb1400_ts *ucb) |
228 | { | 124 | { |
229 | ucb1400_reg_write(ucb, UCB_TS_CR, | 125 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, |
230 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | | 126 | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | |
231 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); | 127 | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); |
232 | return ucb1400_adc_read(ucb, 0); | 128 | return ucb1400_adc_read(ucb->ac97, 0, adcsync); |
233 | } | 129 | } |
234 | 130 | ||
235 | static inline int ucb1400_ts_pen_down(struct ucb1400 *ucb) | 131 | static inline int ucb1400_ts_pen_down(struct snd_ac97 *ac97) |
236 | { | 132 | { |
237 | unsigned short val = ucb1400_reg_read(ucb, UCB_TS_CR); | 133 | unsigned short val = ucb1400_reg_read(ac97, UCB_TS_CR); |
238 | return (val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW)); | 134 | return val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW); |
239 | } | 135 | } |
240 | 136 | ||
241 | static inline void ucb1400_ts_irq_enable(struct ucb1400 *ucb) | 137 | static inline void ucb1400_ts_irq_enable(struct snd_ac97 *ac97) |
242 | { | 138 | { |
243 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, UCB_IE_TSPX); | 139 | ucb1400_reg_write(ac97, UCB_IE_CLEAR, UCB_IE_TSPX); |
244 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); | 140 | ucb1400_reg_write(ac97, UCB_IE_CLEAR, 0); |
245 | ucb1400_reg_write(ucb, UCB_IE_FAL, UCB_IE_TSPX); | 141 | ucb1400_reg_write(ac97, UCB_IE_FAL, UCB_IE_TSPX); |
246 | } | 142 | } |
247 | 143 | ||
248 | static inline void ucb1400_ts_irq_disable(struct ucb1400 *ucb) | 144 | static inline void ucb1400_ts_irq_disable(struct snd_ac97 *ac97) |
249 | { | 145 | { |
250 | ucb1400_reg_write(ucb, UCB_IE_FAL, 0); | 146 | ucb1400_reg_write(ac97, UCB_IE_FAL, 0); |
251 | } | 147 | } |
252 | 148 | ||
253 | static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16 y) | 149 | static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16 y) |
@@ -264,25 +160,24 @@ static void ucb1400_ts_event_release(struct input_dev *idev) | |||
264 | input_sync(idev); | 160 | input_sync(idev); |
265 | } | 161 | } |
266 | 162 | ||
267 | static void ucb1400_handle_pending_irq(struct ucb1400 *ucb) | 163 | static void ucb1400_handle_pending_irq(struct ucb1400_ts *ucb) |
268 | { | 164 | { |
269 | unsigned int isr; | 165 | unsigned int isr; |
270 | 166 | ||
271 | isr = ucb1400_reg_read(ucb, UCB_IE_STATUS); | 167 | isr = ucb1400_reg_read(ucb->ac97, UCB_IE_STATUS); |
272 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, isr); | 168 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, isr); |
273 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); | 169 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); |
274 | 170 | ||
275 | if (isr & UCB_IE_TSPX) | 171 | if (isr & UCB_IE_TSPX) { |
276 | ucb1400_ts_irq_disable(ucb); | 172 | ucb1400_ts_irq_disable(ucb->ac97); |
277 | else | 173 | enable_irq(ucb->irq); |
174 | } else | ||
278 | printk(KERN_ERR "ucb1400: unexpected IE_STATUS = %#x\n", isr); | 175 | printk(KERN_ERR "ucb1400: unexpected IE_STATUS = %#x\n", isr); |
279 | |||
280 | enable_irq(ucb->irq); | ||
281 | } | 176 | } |
282 | 177 | ||
283 | static int ucb1400_ts_thread(void *_ucb) | 178 | static int ucb1400_ts_thread(void *_ucb) |
284 | { | 179 | { |
285 | struct ucb1400 *ucb = _ucb; | 180 | struct ucb1400_ts *ucb = _ucb; |
286 | struct task_struct *tsk = current; | 181 | struct task_struct *tsk = current; |
287 | int valid = 0; | 182 | int valid = 0; |
288 | struct sched_param param = { .sched_priority = 1 }; | 183 | struct sched_param param = { .sched_priority = 1 }; |
@@ -301,19 +196,19 @@ static int ucb1400_ts_thread(void *_ucb) | |||
301 | ucb1400_handle_pending_irq(ucb); | 196 | ucb1400_handle_pending_irq(ucb); |
302 | } | 197 | } |
303 | 198 | ||
304 | ucb1400_adc_enable(ucb); | 199 | ucb1400_adc_enable(ucb->ac97); |
305 | x = ucb1400_ts_read_xpos(ucb); | 200 | x = ucb1400_ts_read_xpos(ucb); |
306 | y = ucb1400_ts_read_ypos(ucb); | 201 | y = ucb1400_ts_read_ypos(ucb); |
307 | p = ucb1400_ts_read_pressure(ucb); | 202 | p = ucb1400_ts_read_pressure(ucb); |
308 | ucb1400_adc_disable(ucb); | 203 | ucb1400_adc_disable(ucb->ac97); |
309 | 204 | ||
310 | /* Switch back to interrupt mode. */ | 205 | /* Switch back to interrupt mode. */ |
311 | ucb1400_ts_mode_int(ucb); | 206 | ucb1400_ts_mode_int(ucb->ac97); |
312 | 207 | ||
313 | msleep(10); | 208 | msleep(10); |
314 | 209 | ||
315 | if (ucb1400_ts_pen_down(ucb)) { | 210 | if (ucb1400_ts_pen_down(ucb->ac97)) { |
316 | ucb1400_ts_irq_enable(ucb); | 211 | ucb1400_ts_irq_enable(ucb->ac97); |
317 | 212 | ||
318 | /* | 213 | /* |
319 | * If we spat out a valid sample set last time, | 214 | * If we spat out a valid sample set last time, |
@@ -332,8 +227,8 @@ static int ucb1400_ts_thread(void *_ucb) | |||
332 | } | 227 | } |
333 | 228 | ||
334 | wait_event_freezable_timeout(ucb->ts_wait, | 229 | wait_event_freezable_timeout(ucb->ts_wait, |
335 | ucb->irq_pending || ucb->ts_restart || kthread_should_stop(), | 230 | ucb->irq_pending || ucb->ts_restart || |
336 | timeout); | 231 | kthread_should_stop(), timeout); |
337 | } | 232 | } |
338 | 233 | ||
339 | /* Send the "pen off" if we are stopping with the pen still active */ | 234 | /* Send the "pen off" if we are stopping with the pen still active */ |
@@ -356,7 +251,7 @@ static int ucb1400_ts_thread(void *_ucb) | |||
356 | */ | 251 | */ |
357 | static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) | 252 | static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) |
358 | { | 253 | { |
359 | struct ucb1400 *ucb = devid; | 254 | struct ucb1400_ts *ucb = devid; |
360 | 255 | ||
361 | if (irqnr == ucb->irq) { | 256 | if (irqnr == ucb->irq) { |
362 | disable_irq(ucb->irq); | 257 | disable_irq(ucb->irq); |
@@ -369,7 +264,7 @@ static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) | |||
369 | 264 | ||
370 | static int ucb1400_ts_open(struct input_dev *idev) | 265 | static int ucb1400_ts_open(struct input_dev *idev) |
371 | { | 266 | { |
372 | struct ucb1400 *ucb = input_get_drvdata(idev); | 267 | struct ucb1400_ts *ucb = input_get_drvdata(idev); |
373 | int ret = 0; | 268 | int ret = 0; |
374 | 269 | ||
375 | BUG_ON(ucb->ts_task); | 270 | BUG_ON(ucb->ts_task); |
@@ -385,34 +280,14 @@ static int ucb1400_ts_open(struct input_dev *idev) | |||
385 | 280 | ||
386 | static void ucb1400_ts_close(struct input_dev *idev) | 281 | static void ucb1400_ts_close(struct input_dev *idev) |
387 | { | 282 | { |
388 | struct ucb1400 *ucb = input_get_drvdata(idev); | 283 | struct ucb1400_ts *ucb = input_get_drvdata(idev); |
389 | 284 | ||
390 | if (ucb->ts_task) | 285 | if (ucb->ts_task) |
391 | kthread_stop(ucb->ts_task); | 286 | kthread_stop(ucb->ts_task); |
392 | 287 | ||
393 | ucb1400_ts_irq_disable(ucb); | 288 | ucb1400_ts_irq_disable(ucb->ac97); |
394 | ucb1400_reg_write(ucb, UCB_TS_CR, 0); | 289 | ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); |
395 | } | ||
396 | |||
397 | #ifdef CONFIG_PM | ||
398 | static int ucb1400_ts_resume(struct device *dev) | ||
399 | { | ||
400 | struct ucb1400 *ucb = dev_get_drvdata(dev); | ||
401 | |||
402 | if (ucb->ts_task) { | ||
403 | /* | ||
404 | * Restart the TS thread to ensure the | ||
405 | * TS interrupt mode is set up again | ||
406 | * after sleep. | ||
407 | */ | ||
408 | ucb->ts_restart = 1; | ||
409 | wake_up(&ucb->ts_wait); | ||
410 | } | ||
411 | return 0; | ||
412 | } | 290 | } |
413 | #else | ||
414 | #define ucb1400_ts_resume NULL | ||
415 | #endif | ||
416 | 291 | ||
417 | #ifndef NO_IRQ | 292 | #ifndef NO_IRQ |
418 | #define NO_IRQ 0 | 293 | #define NO_IRQ 0 |
@@ -422,25 +297,26 @@ static int ucb1400_ts_resume(struct device *dev) | |||
422 | * Try to probe our interrupt, rather than relying on lots of | 297 | * Try to probe our interrupt, rather than relying on lots of |
423 | * hard-coded machine dependencies. | 298 | * hard-coded machine dependencies. |
424 | */ | 299 | */ |
425 | static int ucb1400_detect_irq(struct ucb1400 *ucb) | 300 | static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb) |
426 | { | 301 | { |
427 | unsigned long mask, timeout; | 302 | unsigned long mask, timeout; |
428 | 303 | ||
429 | mask = probe_irq_on(); | 304 | mask = probe_irq_on(); |
430 | 305 | ||
431 | /* Enable the ADC interrupt. */ | 306 | /* Enable the ADC interrupt. */ |
432 | ucb1400_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC); | 307 | ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, UCB_IE_ADC); |
433 | ucb1400_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC); | 308 | ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_ADC); |
434 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff); | 309 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); |
435 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); | 310 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); |
436 | 311 | ||
437 | /* Cause an ADC interrupt. */ | 312 | /* Cause an ADC interrupt. */ |
438 | ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA); | 313 | ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA); |
439 | ucb1400_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); | 314 | ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START); |
440 | 315 | ||
441 | /* Wait for the conversion to complete. */ | 316 | /* Wait for the conversion to complete. */ |
442 | timeout = jiffies + HZ/2; | 317 | timeout = jiffies + HZ/2; |
443 | while (!(ucb1400_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VALID)) { | 318 | while (!(ucb1400_reg_read(ucb->ac97, UCB_ADC_DATA) & |
319 | UCB_ADC_DAT_VALID)) { | ||
444 | cpu_relax(); | 320 | cpu_relax(); |
445 | if (time_after(jiffies, timeout)) { | 321 | if (time_after(jiffies, timeout)) { |
446 | printk(KERN_ERR "ucb1400: timed out in IRQ probe\n"); | 322 | printk(KERN_ERR "ucb1400: timed out in IRQ probe\n"); |
@@ -448,13 +324,13 @@ static int ucb1400_detect_irq(struct ucb1400 *ucb) | |||
448 | return -ENODEV; | 324 | return -ENODEV; |
449 | } | 325 | } |
450 | } | 326 | } |
451 | ucb1400_reg_write(ucb, UCB_ADC_CR, 0); | 327 | ucb1400_reg_write(ucb->ac97, UCB_ADC_CR, 0); |
452 | 328 | ||
453 | /* Disable and clear interrupt. */ | 329 | /* Disable and clear interrupt. */ |
454 | ucb1400_reg_write(ucb, UCB_IE_RIS, 0); | 330 | ucb1400_reg_write(ucb->ac97, UCB_IE_RIS, 0); |
455 | ucb1400_reg_write(ucb, UCB_IE_FAL, 0); | 331 | ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); |
456 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0xffff); | 332 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0xffff); |
457 | ucb1400_reg_write(ucb, UCB_IE_CLEAR, 0); | 333 | ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); |
458 | 334 | ||
459 | /* Read triggered interrupt. */ | 335 | /* Read triggered interrupt. */ |
460 | ucb->irq = probe_irq_off(mask); | 336 | ucb->irq = probe_irq_off(mask); |
@@ -464,36 +340,25 @@ static int ucb1400_detect_irq(struct ucb1400 *ucb) | |||
464 | return 0; | 340 | return 0; |
465 | } | 341 | } |
466 | 342 | ||
467 | static int ucb1400_ts_probe(struct device *dev) | 343 | static int ucb1400_ts_probe(struct platform_device *dev) |
468 | { | 344 | { |
469 | struct ucb1400 *ucb; | 345 | int error, x_res, y_res; |
470 | struct input_dev *idev; | 346 | struct ucb1400_ts *ucb = dev->dev.platform_data; |
471 | int error, id, x_res, y_res; | ||
472 | 347 | ||
473 | ucb = kzalloc(sizeof(struct ucb1400), GFP_KERNEL); | 348 | ucb->ts_idev = input_allocate_device(); |
474 | idev = input_allocate_device(); | 349 | if (!ucb->ts_idev) { |
475 | if (!ucb || !idev) { | ||
476 | error = -ENOMEM; | 350 | error = -ENOMEM; |
477 | goto err_free_devs; | 351 | goto err; |
478 | } | 352 | } |
479 | 353 | ||
480 | ucb->ts_idev = idev; | 354 | error = ucb1400_ts_detect_irq(ucb); |
481 | ucb->adcsync = adcsync; | ||
482 | ucb->ac97 = to_ac97_t(dev); | ||
483 | init_waitqueue_head(&ucb->ts_wait); | ||
484 | |||
485 | id = ucb1400_reg_read(ucb, UCB_ID); | ||
486 | if (id != UCB_ID_1400) { | ||
487 | error = -ENODEV; | ||
488 | goto err_free_devs; | ||
489 | } | ||
490 | |||
491 | error = ucb1400_detect_irq(ucb); | ||
492 | if (error) { | 355 | if (error) { |
493 | printk(KERN_ERR "UCB1400: IRQ probe failed\n"); | 356 | printk(KERN_ERR "UCB1400: IRQ probe failed\n"); |
494 | goto err_free_devs; | 357 | goto err_free_devs; |
495 | } | 358 | } |
496 | 359 | ||
360 | init_waitqueue_head(&ucb->ts_wait); | ||
361 | |||
497 | error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING, | 362 | error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING, |
498 | "UCB1400", ucb); | 363 | "UCB1400", ucb); |
499 | if (error) { | 364 | if (error) { |
@@ -503,80 +368,101 @@ static int ucb1400_ts_probe(struct device *dev) | |||
503 | } | 368 | } |
504 | printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq); | 369 | printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq); |
505 | 370 | ||
506 | input_set_drvdata(idev, ucb); | 371 | input_set_drvdata(ucb->ts_idev, ucb); |
507 | 372 | ||
508 | idev->dev.parent = dev; | 373 | ucb->ts_idev->dev.parent = &dev->dev; |
509 | idev->name = "UCB1400 touchscreen interface"; | 374 | ucb->ts_idev->name = "UCB1400 touchscreen interface"; |
510 | idev->id.vendor = ucb1400_reg_read(ucb, AC97_VENDOR_ID1); | 375 | ucb->ts_idev->id.vendor = ucb1400_reg_read(ucb->ac97, |
511 | idev->id.product = id; | 376 | AC97_VENDOR_ID1); |
512 | idev->open = ucb1400_ts_open; | 377 | ucb->ts_idev->id.product = ucb->id; |
513 | idev->close = ucb1400_ts_close; | 378 | ucb->ts_idev->open = ucb1400_ts_open; |
514 | idev->evbit[0] = BIT_MASK(EV_ABS); | 379 | ucb->ts_idev->close = ucb1400_ts_close; |
380 | ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS); | ||
515 | 381 | ||
516 | ucb1400_adc_enable(ucb); | 382 | ucb1400_adc_enable(ucb->ac97); |
517 | x_res = ucb1400_ts_read_xres(ucb); | 383 | x_res = ucb1400_ts_read_xres(ucb); |
518 | y_res = ucb1400_ts_read_yres(ucb); | 384 | y_res = ucb1400_ts_read_yres(ucb); |
519 | ucb1400_adc_disable(ucb); | 385 | ucb1400_adc_disable(ucb->ac97); |
520 | printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res); | 386 | printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res); |
521 | 387 | ||
522 | input_set_abs_params(idev, ABS_X, 0, x_res, 0, 0); | 388 | input_set_abs_params(ucb->ts_idev, ABS_X, 0, x_res, 0, 0); |
523 | input_set_abs_params(idev, ABS_Y, 0, y_res, 0, 0); | 389 | input_set_abs_params(ucb->ts_idev, ABS_Y, 0, y_res, 0, 0); |
524 | input_set_abs_params(idev, ABS_PRESSURE, 0, 0, 0, 0); | 390 | input_set_abs_params(ucb->ts_idev, ABS_PRESSURE, 0, 0, 0, 0); |
525 | 391 | ||
526 | error = input_register_device(idev); | 392 | error = input_register_device(ucb->ts_idev); |
527 | if (error) | 393 | if (error) |
528 | goto err_free_irq; | 394 | goto err_free_irq; |
529 | 395 | ||
530 | dev_set_drvdata(dev, ucb); | ||
531 | return 0; | 396 | return 0; |
532 | 397 | ||
533 | err_free_irq: | 398 | err_free_irq: |
534 | free_irq(ucb->irq, ucb); | 399 | free_irq(ucb->irq, ucb); |
535 | err_free_devs: | 400 | err_free_devs: |
536 | input_free_device(idev); | 401 | input_free_device(ucb->ts_idev); |
537 | kfree(ucb); | 402 | err: |
538 | return error; | 403 | return error; |
404 | |||
539 | } | 405 | } |
540 | 406 | ||
541 | static int ucb1400_ts_remove(struct device *dev) | 407 | static int ucb1400_ts_remove(struct platform_device *dev) |
542 | { | 408 | { |
543 | struct ucb1400 *ucb = dev_get_drvdata(dev); | 409 | struct ucb1400_ts *ucb = dev->dev.platform_data; |
544 | 410 | ||
545 | free_irq(ucb->irq, ucb); | 411 | free_irq(ucb->irq, ucb); |
546 | input_unregister_device(ucb->ts_idev); | 412 | input_unregister_device(ucb->ts_idev); |
547 | dev_set_drvdata(dev, NULL); | ||
548 | kfree(ucb); | ||
549 | return 0; | 413 | return 0; |
550 | } | 414 | } |
551 | 415 | ||
552 | static struct device_driver ucb1400_ts_driver = { | 416 | #ifdef CONFIG_PM |
553 | .name = "ucb1400_ts", | 417 | static int ucb1400_ts_resume(struct platform_device *dev) |
554 | .owner = THIS_MODULE, | 418 | { |
555 | .bus = &ac97_bus_type, | 419 | struct ucb1400_ts *ucb = platform_get_drvdata(dev); |
556 | .probe = ucb1400_ts_probe, | 420 | |
557 | .remove = ucb1400_ts_remove, | 421 | if (ucb->ts_task) { |
558 | .resume = ucb1400_ts_resume, | 422 | /* |
423 | * Restart the TS thread to ensure the | ||
424 | * TS interrupt mode is set up again | ||
425 | * after sleep. | ||
426 | */ | ||
427 | ucb->ts_restart = 1; | ||
428 | wake_up(&ucb->ts_wait); | ||
429 | } | ||
430 | return 0; | ||
431 | } | ||
432 | #else | ||
433 | #define ucb1400_ts_resume NULL | ||
434 | #endif | ||
435 | |||
436 | static struct platform_driver ucb1400_ts_driver = { | ||
437 | .probe = ucb1400_ts_probe, | ||
438 | .remove = ucb1400_ts_remove, | ||
439 | .resume = ucb1400_ts_resume, | ||
440 | .driver = { | ||
441 | .name = "ucb1400_ts", | ||
442 | }, | ||
559 | }; | 443 | }; |
560 | 444 | ||
561 | static int __init ucb1400_ts_init(void) | 445 | static int __init ucb1400_ts_init(void) |
562 | { | 446 | { |
563 | return driver_register(&ucb1400_ts_driver); | 447 | return platform_driver_register(&ucb1400_ts_driver); |
564 | } | 448 | } |
565 | 449 | ||
566 | static void __exit ucb1400_ts_exit(void) | 450 | static void __exit ucb1400_ts_exit(void) |
567 | { | 451 | { |
568 | driver_unregister(&ucb1400_ts_driver); | 452 | platform_driver_unregister(&ucb1400_ts_driver); |
569 | } | 453 | } |
570 | 454 | ||
571 | module_param(adcsync, bool, 0444); | 455 | module_param(adcsync, bool, 0444); |
572 | MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin."); | 456 | MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin."); |
573 | 457 | ||
574 | module_param(ts_delay, int, 0444); | 458 | module_param(ts_delay, int, 0444); |
575 | MODULE_PARM_DESC(ts_delay, "Delay between panel setup and position read. Default = 55us."); | 459 | MODULE_PARM_DESC(ts_delay, "Delay between panel setup and" |
460 | " position read. Default = 55us."); | ||
576 | 461 | ||
577 | module_param(ts_delay_pressure, int, 0444); | 462 | module_param(ts_delay_pressure, int, 0444); |
578 | MODULE_PARM_DESC(ts_delay_pressure, | 463 | MODULE_PARM_DESC(ts_delay_pressure, |
579 | "delay between panel setup and pressure read. Default = 0us."); | 464 | "delay between panel setup and pressure read." |
465 | " Default = 0us."); | ||
580 | 466 | ||
581 | module_init(ucb1400_ts_init); | 467 | module_init(ucb1400_ts_init); |
582 | module_exit(ucb1400_ts_exit); | 468 | module_exit(ucb1400_ts_exit); |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 9556262dda5a..5b14262af017 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -24,13 +24,6 @@ config LEDS_ATMEL_PWM | |||
24 | This option enables support for LEDs driven using outputs | 24 | This option enables support for LEDs driven using outputs |
25 | of the dedicated PWM controller found on newer Atmel SOCs. | 25 | of the dedicated PWM controller found on newer Atmel SOCs. |
26 | 26 | ||
27 | config LEDS_CORGI | ||
28 | tristate "LED Support for the Sharp SL-C7x0 series" | ||
29 | depends on LEDS_CLASS && PXA_SHARP_C7xx | ||
30 | help | ||
31 | This option enables support for the LEDs on Sharp Zaurus | ||
32 | SL-C7x0 series (C700, C750, C760, C860). | ||
33 | |||
34 | config LEDS_LOCOMO | 27 | config LEDS_LOCOMO |
35 | tristate "LED Support for Locomo device" | 28 | tristate "LED Support for Locomo device" |
36 | depends on LEDS_CLASS && SHARP_LOCOMO | 29 | depends on LEDS_CLASS && SHARP_LOCOMO |
@@ -38,13 +31,6 @@ config LEDS_LOCOMO | |||
38 | This option enables support for the LEDs on Sharp Locomo. | 31 | This option enables support for the LEDs on Sharp Locomo. |
39 | Zaurus models SL-5500 and SL-5600. | 32 | Zaurus models SL-5500 and SL-5600. |
40 | 33 | ||
41 | config LEDS_SPITZ | ||
42 | tristate "LED Support for the Sharp SL-Cxx00 series" | ||
43 | depends on LEDS_CLASS && PXA_SHARP_Cxx00 | ||
44 | help | ||
45 | This option enables support for the LEDs on Sharp Zaurus | ||
46 | SL-Cxx00 series (C1000, C3000, C3100). | ||
47 | |||
48 | config LEDS_S3C24XX | 34 | config LEDS_S3C24XX |
49 | tristate "LED Support for Samsung S3C24XX GPIO LEDs" | 35 | tristate "LED Support for Samsung S3C24XX GPIO LEDs" |
50 | depends on LEDS_CLASS && ARCH_S3C2410 | 36 | depends on LEDS_CLASS && ARCH_S3C2410 |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index ff7982b44565..3a8e6a04363c 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -6,9 +6,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o | |||
6 | 6 | ||
7 | # LED Platform Drivers | 7 | # LED Platform Drivers |
8 | obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o | 8 | obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o |
9 | obj-$(CONFIG_LEDS_CORGI) += leds-corgi.o | ||
10 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o | 9 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o |
11 | obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o | ||
12 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o | 10 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o |
13 | obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o | 11 | obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o |
14 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o | 12 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o |
diff --git a/drivers/leds/leds-corgi.c b/drivers/leds/leds-corgi.c deleted file mode 100644 index bc2dcd89f635..000000000000 --- a/drivers/leds/leds-corgi.c +++ /dev/null | |||
@@ -1,124 +0,0 @@ | |||
1 | /* | ||
2 | * LED Triggers Core | ||
3 | * | ||
4 | * Copyright 2005-2006 Openedhand Ltd. | ||
5 | * | ||
6 | * Author: Richard Purdie <rpurdie@openedhand.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/leds.h> | ||
18 | #include <mach/corgi.h> | ||
19 | #include <mach/hardware.h> | ||
20 | #include <mach/pxa-regs.h> | ||
21 | #include <asm/hardware/scoop.h> | ||
22 | |||
23 | static void corgiled_amber_set(struct led_classdev *led_cdev, | ||
24 | enum led_brightness value) | ||
25 | { | ||
26 | if (value) | ||
27 | GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
28 | else | ||
29 | GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
30 | } | ||
31 | |||
32 | static void corgiled_green_set(struct led_classdev *led_cdev, | ||
33 | enum led_brightness value) | ||
34 | { | ||
35 | if (value) | ||
36 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); | ||
37 | else | ||
38 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); | ||
39 | } | ||
40 | |||
41 | static struct led_classdev corgi_amber_led = { | ||
42 | .name = "corgi:amber:charge", | ||
43 | .default_trigger = "sharpsl-charge", | ||
44 | .brightness_set = corgiled_amber_set, | ||
45 | }; | ||
46 | |||
47 | static struct led_classdev corgi_green_led = { | ||
48 | .name = "corgi:green:mail", | ||
49 | .default_trigger = "nand-disk", | ||
50 | .brightness_set = corgiled_green_set, | ||
51 | }; | ||
52 | |||
53 | #ifdef CONFIG_PM | ||
54 | static int corgiled_suspend(struct platform_device *dev, pm_message_t state) | ||
55 | { | ||
56 | #ifdef CONFIG_LEDS_TRIGGERS | ||
57 | if (corgi_amber_led.trigger && | ||
58 | strcmp(corgi_amber_led.trigger->name, "sharpsl-charge")) | ||
59 | #endif | ||
60 | led_classdev_suspend(&corgi_amber_led); | ||
61 | led_classdev_suspend(&corgi_green_led); | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int corgiled_resume(struct platform_device *dev) | ||
66 | { | ||
67 | led_classdev_resume(&corgi_amber_led); | ||
68 | led_classdev_resume(&corgi_green_led); | ||
69 | return 0; | ||
70 | } | ||
71 | #endif | ||
72 | |||
73 | static int corgiled_probe(struct platform_device *pdev) | ||
74 | { | ||
75 | int ret; | ||
76 | |||
77 | ret = led_classdev_register(&pdev->dev, &corgi_amber_led); | ||
78 | if (ret < 0) | ||
79 | return ret; | ||
80 | |||
81 | ret = led_classdev_register(&pdev->dev, &corgi_green_led); | ||
82 | if (ret < 0) | ||
83 | led_classdev_unregister(&corgi_amber_led); | ||
84 | |||
85 | return ret; | ||
86 | } | ||
87 | |||
88 | static int corgiled_remove(struct platform_device *pdev) | ||
89 | { | ||
90 | led_classdev_unregister(&corgi_amber_led); | ||
91 | led_classdev_unregister(&corgi_green_led); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | static struct platform_driver corgiled_driver = { | ||
96 | .probe = corgiled_probe, | ||
97 | .remove = corgiled_remove, | ||
98 | #ifdef CONFIG_PM | ||
99 | .suspend = corgiled_suspend, | ||
100 | .resume = corgiled_resume, | ||
101 | #endif | ||
102 | .driver = { | ||
103 | .name = "corgi-led", | ||
104 | .owner = THIS_MODULE, | ||
105 | }, | ||
106 | }; | ||
107 | |||
108 | static int __init corgiled_init(void) | ||
109 | { | ||
110 | return platform_driver_register(&corgiled_driver); | ||
111 | } | ||
112 | |||
113 | static void __exit corgiled_exit(void) | ||
114 | { | ||
115 | platform_driver_unregister(&corgiled_driver); | ||
116 | } | ||
117 | |||
118 | module_init(corgiled_init); | ||
119 | module_exit(corgiled_exit); | ||
120 | |||
121 | MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); | ||
122 | MODULE_DESCRIPTION("Corgi LED driver"); | ||
123 | MODULE_LICENSE("GPL"); | ||
124 | MODULE_ALIAS("platform:corgi-led"); | ||
diff --git a/drivers/leds/leds-spitz.c b/drivers/leds/leds-spitz.c deleted file mode 100644 index 178831c64bfb..000000000000 --- a/drivers/leds/leds-spitz.c +++ /dev/null | |||
@@ -1,131 +0,0 @@ | |||
1 | /* | ||
2 | * LED Triggers Core | ||
3 | * | ||
4 | * Copyright 2005-2006 Openedhand Ltd. | ||
5 | * | ||
6 | * Author: Richard Purdie <rpurdie@openedhand.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/leds.h> | ||
18 | #include <asm/hardware/scoop.h> | ||
19 | #include <asm/mach-types.h> | ||
20 | #include <mach/hardware.h> | ||
21 | #include <mach/pxa-regs.h> | ||
22 | #include <mach/spitz.h> | ||
23 | |||
24 | static void spitzled_amber_set(struct led_classdev *led_cdev, | ||
25 | enum led_brightness value) | ||
26 | { | ||
27 | if (value) | ||
28 | set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE); | ||
29 | else | ||
30 | reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE); | ||
31 | } | ||
32 | |||
33 | static void spitzled_green_set(struct led_classdev *led_cdev, | ||
34 | enum led_brightness value) | ||
35 | { | ||
36 | if (value) | ||
37 | set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN); | ||
38 | else | ||
39 | reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN); | ||
40 | } | ||
41 | |||
42 | static struct led_classdev spitz_amber_led = { | ||
43 | .name = "spitz:amber:charge", | ||
44 | .default_trigger = "sharpsl-charge", | ||
45 | .brightness_set = spitzled_amber_set, | ||
46 | }; | ||
47 | |||
48 | static struct led_classdev spitz_green_led = { | ||
49 | .name = "spitz:green:hddactivity", | ||
50 | .default_trigger = "ide-disk", | ||
51 | .brightness_set = spitzled_green_set, | ||
52 | }; | ||
53 | |||
54 | #ifdef CONFIG_PM | ||
55 | static int spitzled_suspend(struct platform_device *dev, pm_message_t state) | ||
56 | { | ||
57 | #ifdef CONFIG_LEDS_TRIGGERS | ||
58 | if (spitz_amber_led.trigger && | ||
59 | strcmp(spitz_amber_led.trigger->name, "sharpsl-charge")) | ||
60 | #endif | ||
61 | led_classdev_suspend(&spitz_amber_led); | ||
62 | led_classdev_suspend(&spitz_green_led); | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | static int spitzled_resume(struct platform_device *dev) | ||
67 | { | ||
68 | led_classdev_resume(&spitz_amber_led); | ||
69 | led_classdev_resume(&spitz_green_led); | ||
70 | return 0; | ||
71 | } | ||
72 | #endif | ||
73 | |||
74 | static int spitzled_probe(struct platform_device *pdev) | ||
75 | { | ||
76 | int ret; | ||
77 | |||
78 | if (machine_is_akita()) { | ||
79 | spitz_green_led.name = "spitz:green:mail"; | ||
80 | spitz_green_led.default_trigger = "nand-disk"; | ||
81 | } | ||
82 | |||
83 | ret = led_classdev_register(&pdev->dev, &spitz_amber_led); | ||
84 | if (ret < 0) | ||
85 | return ret; | ||
86 | |||
87 | ret = led_classdev_register(&pdev->dev, &spitz_green_led); | ||
88 | if (ret < 0) | ||
89 | led_classdev_unregister(&spitz_amber_led); | ||
90 | |||
91 | return ret; | ||
92 | } | ||
93 | |||
94 | static int spitzled_remove(struct platform_device *pdev) | ||
95 | { | ||
96 | led_classdev_unregister(&spitz_amber_led); | ||
97 | led_classdev_unregister(&spitz_green_led); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static struct platform_driver spitzled_driver = { | ||
103 | .probe = spitzled_probe, | ||
104 | .remove = spitzled_remove, | ||
105 | #ifdef CONFIG_PM | ||
106 | .suspend = spitzled_suspend, | ||
107 | .resume = spitzled_resume, | ||
108 | #endif | ||
109 | .driver = { | ||
110 | .name = "spitz-led", | ||
111 | .owner = THIS_MODULE, | ||
112 | }, | ||
113 | }; | ||
114 | |||
115 | static int __init spitzled_init(void) | ||
116 | { | ||
117 | return platform_driver_register(&spitzled_driver); | ||
118 | } | ||
119 | |||
120 | static void __exit spitzled_exit(void) | ||
121 | { | ||
122 | platform_driver_unregister(&spitzled_driver); | ||
123 | } | ||
124 | |||
125 | module_init(spitzled_init); | ||
126 | module_exit(spitzled_exit); | ||
127 | |||
128 | MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>"); | ||
129 | MODULE_DESCRIPTION("Spitz LED driver"); | ||
130 | MODULE_LICENSE("GPL"); | ||
131 | MODULE_ALIAS("platform:spitz-led"); | ||
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 7e65bad522cb..ac89a5deaca2 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -238,15 +238,47 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde | |||
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | static mdk_rdev_t *next_active_rdev(mdk_rdev_t *rdev, mddev_t *mddev) | ||
242 | { | ||
243 | /* Iterate the disks of an mddev, using rcu to protect access to the | ||
244 | * linked list, and raising the refcount of devices we return to ensure | ||
245 | * they don't disappear while in use. | ||
246 | * As devices are only added or removed when raid_disk is < 0 and | ||
247 | * nr_pending is 0 and In_sync is clear, the entries we return will | ||
248 | * still be in the same position on the list when we re-enter | ||
249 | * list_for_each_continue_rcu. | ||
250 | */ | ||
251 | struct list_head *pos; | ||
252 | rcu_read_lock(); | ||
253 | if (rdev == NULL) | ||
254 | /* start at the beginning */ | ||
255 | pos = &mddev->disks; | ||
256 | else { | ||
257 | /* release the previous rdev and start from there. */ | ||
258 | rdev_dec_pending(rdev, mddev); | ||
259 | pos = &rdev->same_set; | ||
260 | } | ||
261 | list_for_each_continue_rcu(pos, &mddev->disks) { | ||
262 | rdev = list_entry(pos, mdk_rdev_t, same_set); | ||
263 | if (rdev->raid_disk >= 0 && | ||
264 | test_bit(In_sync, &rdev->flags) && | ||
265 | !test_bit(Faulty, &rdev->flags)) { | ||
266 | /* this is a usable devices */ | ||
267 | atomic_inc(&rdev->nr_pending); | ||
268 | rcu_read_unlock(); | ||
269 | return rdev; | ||
270 | } | ||
271 | } | ||
272 | rcu_read_unlock(); | ||
273 | return NULL; | ||
274 | } | ||
275 | |||
241 | static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | 276 | static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) |
242 | { | 277 | { |
243 | mdk_rdev_t *rdev; | 278 | mdk_rdev_t *rdev = NULL; |
244 | mddev_t *mddev = bitmap->mddev; | 279 | mddev_t *mddev = bitmap->mddev; |
245 | 280 | ||
246 | rcu_read_lock(); | 281 | while ((rdev = next_active_rdev(rdev, mddev)) != NULL) { |
247 | rdev_for_each_rcu(rdev, mddev) | ||
248 | if (test_bit(In_sync, &rdev->flags) | ||
249 | && !test_bit(Faulty, &rdev->flags)) { | ||
250 | int size = PAGE_SIZE; | 282 | int size = PAGE_SIZE; |
251 | if (page->index == bitmap->file_pages-1) | 283 | if (page->index == bitmap->file_pages-1) |
252 | size = roundup(bitmap->last_page_size, | 284 | size = roundup(bitmap->last_page_size, |
@@ -281,8 +313,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) | |||
281 | + page->index * (PAGE_SIZE/512), | 313 | + page->index * (PAGE_SIZE/512), |
282 | size, | 314 | size, |
283 | page); | 315 | page); |
284 | } | 316 | } |
285 | rcu_read_unlock(); | ||
286 | 317 | ||
287 | if (wait) | 318 | if (wait) |
288 | md_super_wait(mddev); | 319 | md_super_wait(mddev); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 8cfadc5bd2ba..4790c83d78d0 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3841,8 +3841,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
3841 | 3841 | ||
3842 | del_timer_sync(&mddev->safemode_timer); | 3842 | del_timer_sync(&mddev->safemode_timer); |
3843 | 3843 | ||
3844 | invalidate_partition(disk, 0); | ||
3845 | |||
3846 | switch(mode) { | 3844 | switch(mode) { |
3847 | case 1: /* readonly */ | 3845 | case 1: /* readonly */ |
3848 | err = -ENXIO; | 3846 | err = -ENXIO; |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index e8bc7abf2409..99be9e5c85f7 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
@@ -1068,7 +1068,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int | |||
1068 | { | 1068 | { |
1069 | v4l2_std_id *id = arg; | 1069 | v4l2_std_id *id = arg; |
1070 | int found = 0; | 1070 | int found = 0; |
1071 | int i, err; | 1071 | int i; |
1072 | 1072 | ||
1073 | DEB_EE(("VIDIOC_S_STD\n")); | 1073 | DEB_EE(("VIDIOC_S_STD\n")); |
1074 | 1074 | ||
@@ -1116,7 +1116,6 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int | |||
1116 | case VIDIOC_OVERLAY: | 1116 | case VIDIOC_OVERLAY: |
1117 | { | 1117 | { |
1118 | int on = *(int *)arg; | 1118 | int on = *(int *)arg; |
1119 | int err = 0; | ||
1120 | 1119 | ||
1121 | DEB_D(("VIDIOC_OVERLAY on:%d\n",on)); | 1120 | DEB_D(("VIDIOC_OVERLAY on:%d\n",on)); |
1122 | if (on != 0) { | 1121 | if (on != 0) { |
@@ -1192,7 +1191,6 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int | |||
1192 | case VIDIOCGMBUF: | 1191 | case VIDIOCGMBUF: |
1193 | { | 1192 | { |
1194 | struct video_mbuf *mbuf = arg; | 1193 | struct video_mbuf *mbuf = arg; |
1195 | struct videobuf_queue *q; | ||
1196 | int i; | 1194 | int i; |
1197 | 1195 | ||
1198 | /* fixme: number of capture buffers and sizes for v4l apps */ | 1196 | /* fixme: number of capture buffers and sizes for v4l apps */ |
diff --git a/drivers/media/common/tuners/mt2131.c b/drivers/media/common/tuners/mt2131.c index e254bcfc2efb..e8d3c48f8605 100644 --- a/drivers/media/common/tuners/mt2131.c +++ b/drivers/media/common/tuners/mt2131.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" | 2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/mt2131.h b/drivers/media/common/tuners/mt2131.h index cd8376f6f7b4..6632de640df0 100644 --- a/drivers/media/common/tuners/mt2131.h +++ b/drivers/media/common/tuners/mt2131.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" | 2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/mt2131_priv.h b/drivers/media/common/tuners/mt2131_priv.h index e930759c2c00..4e05a67e88c1 100644 --- a/drivers/media/common/tuners/mt2131_priv.h +++ b/drivers/media/common/tuners/mt2131_priv.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" | 2 | * Driver for Microtune MT2131 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c index 0dc2bef9f6a3..227642b044ae 100644 --- a/drivers/media/common/tuners/mxl5005s.c +++ b/drivers/media/common/tuners/mxl5005s.c | |||
@@ -2,7 +2,7 @@ | |||
2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver | 2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver |
3 | 3 | ||
4 | Copyright (C) 2008 MaxLinear | 4 | Copyright (C) 2008 MaxLinear |
5 | Copyright (C) 2006 Steven Toth <stoth@hauppauge.com> | 5 | Copyright (C) 2006 Steven Toth <stoth@linuxtv.org> |
6 | Functions: | 6 | Functions: |
7 | mxl5005s_reset() | 7 | mxl5005s_reset() |
8 | mxl5005s_writereg() | 8 | mxl5005s_writereg() |
@@ -3837,7 +3837,7 @@ static u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis) | |||
3837 | /* ---------------------------------------------------------------- | 3837 | /* ---------------------------------------------------------------- |
3838 | * Begin: Everything after here is new code to adapt the | 3838 | * Begin: Everything after here is new code to adapt the |
3839 | * proprietary Realtek driver into a Linux API tuner. | 3839 | * proprietary Realtek driver into a Linux API tuner. |
3840 | * Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 3840 | * Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
3841 | */ | 3841 | */ |
3842 | static int mxl5005s_reset(struct dvb_frontend *fe) | 3842 | static int mxl5005s_reset(struct dvb_frontend *fe) |
3843 | { | 3843 | { |
diff --git a/drivers/media/common/tuners/mxl5005s.h b/drivers/media/common/tuners/mxl5005s.h index 396db150bf0c..7ac6815b30aa 100644 --- a/drivers/media/common/tuners/mxl5005s.h +++ b/drivers/media/common/tuners/mxl5005s.h | |||
@@ -2,7 +2,7 @@ | |||
2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver | 2 | MaxLinear MXL5005S VSB/QAM/DVBT tuner driver |
3 | 3 | ||
4 | Copyright (C) 2008 MaxLinear | 4 | Copyright (C) 2008 MaxLinear |
5 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 5 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 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 | 8 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index 597e47f5d69c..aa773a658a2a 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -253,7 +253,7 @@ static struct tuner_params *simple_tuner_params(struct dvb_frontend *fe, | |||
253 | 253 | ||
254 | static int simple_config_lookup(struct dvb_frontend *fe, | 254 | static int simple_config_lookup(struct dvb_frontend *fe, |
255 | struct tuner_params *t_params, | 255 | struct tuner_params *t_params, |
256 | int *frequency, u8 *config, u8 *cb) | 256 | unsigned *frequency, u8 *config, u8 *cb) |
257 | { | 257 | { |
258 | struct tuner_simple_priv *priv = fe->tuner_priv; | 258 | struct tuner_simple_priv *priv = fe->tuner_priv; |
259 | int i; | 259 | int i; |
@@ -587,45 +587,45 @@ static int simple_set_tv_freq(struct dvb_frontend *fe, | |||
587 | priv->last_div = div; | 587 | priv->last_div = div; |
588 | if (t_params->has_tda9887) { | 588 | if (t_params->has_tda9887) { |
589 | struct v4l2_priv_tun_config tda9887_cfg; | 589 | struct v4l2_priv_tun_config tda9887_cfg; |
590 | int config = 0; | 590 | int tda_config = 0; |
591 | int is_secam_l = (params->std & (V4L2_STD_SECAM_L | | 591 | int is_secam_l = (params->std & (V4L2_STD_SECAM_L | |
592 | V4L2_STD_SECAM_LC)) && | 592 | V4L2_STD_SECAM_LC)) && |
593 | !(params->std & ~(V4L2_STD_SECAM_L | | 593 | !(params->std & ~(V4L2_STD_SECAM_L | |
594 | V4L2_STD_SECAM_LC)); | 594 | V4L2_STD_SECAM_LC)); |
595 | 595 | ||
596 | tda9887_cfg.tuner = TUNER_TDA9887; | 596 | tda9887_cfg.tuner = TUNER_TDA9887; |
597 | tda9887_cfg.priv = &config; | 597 | tda9887_cfg.priv = &tda_config; |
598 | 598 | ||
599 | if (params->std == V4L2_STD_SECAM_LC) { | 599 | if (params->std == V4L2_STD_SECAM_LC) { |
600 | if (t_params->port1_active ^ t_params->port1_invert_for_secam_lc) | 600 | if (t_params->port1_active ^ t_params->port1_invert_for_secam_lc) |
601 | config |= TDA9887_PORT1_ACTIVE; | 601 | tda_config |= TDA9887_PORT1_ACTIVE; |
602 | if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc) | 602 | if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc) |
603 | config |= TDA9887_PORT2_ACTIVE; | 603 | tda_config |= TDA9887_PORT2_ACTIVE; |
604 | } else { | 604 | } else { |
605 | if (t_params->port1_active) | 605 | if (t_params->port1_active) |
606 | config |= TDA9887_PORT1_ACTIVE; | 606 | tda_config |= TDA9887_PORT1_ACTIVE; |
607 | if (t_params->port2_active) | 607 | if (t_params->port2_active) |
608 | config |= TDA9887_PORT2_ACTIVE; | 608 | tda_config |= TDA9887_PORT2_ACTIVE; |
609 | } | 609 | } |
610 | if (t_params->intercarrier_mode) | 610 | if (t_params->intercarrier_mode) |
611 | config |= TDA9887_INTERCARRIER; | 611 | tda_config |= TDA9887_INTERCARRIER; |
612 | if (is_secam_l) { | 612 | if (is_secam_l) { |
613 | if (i == 0 && t_params->default_top_secam_low) | 613 | if (i == 0 && t_params->default_top_secam_low) |
614 | config |= TDA9887_TOP(t_params->default_top_secam_low); | 614 | tda_config |= TDA9887_TOP(t_params->default_top_secam_low); |
615 | else if (i == 1 && t_params->default_top_secam_mid) | 615 | else if (i == 1 && t_params->default_top_secam_mid) |
616 | config |= TDA9887_TOP(t_params->default_top_secam_mid); | 616 | tda_config |= TDA9887_TOP(t_params->default_top_secam_mid); |
617 | else if (t_params->default_top_secam_high) | 617 | else if (t_params->default_top_secam_high) |
618 | config |= TDA9887_TOP(t_params->default_top_secam_high); | 618 | tda_config |= TDA9887_TOP(t_params->default_top_secam_high); |
619 | } else { | 619 | } else { |
620 | if (i == 0 && t_params->default_top_low) | 620 | if (i == 0 && t_params->default_top_low) |
621 | config |= TDA9887_TOP(t_params->default_top_low); | 621 | tda_config |= TDA9887_TOP(t_params->default_top_low); |
622 | else if (i == 1 && t_params->default_top_mid) | 622 | else if (i == 1 && t_params->default_top_mid) |
623 | config |= TDA9887_TOP(t_params->default_top_mid); | 623 | tda_config |= TDA9887_TOP(t_params->default_top_mid); |
624 | else if (t_params->default_top_high) | 624 | else if (t_params->default_top_high) |
625 | config |= TDA9887_TOP(t_params->default_top_high); | 625 | tda_config |= TDA9887_TOP(t_params->default_top_high); |
626 | } | 626 | } |
627 | if (t_params->default_pll_gating_18) | 627 | if (t_params->default_pll_gating_18) |
628 | config |= TDA9887_GATING_18; | 628 | tda_config |= TDA9887_GATING_18; |
629 | i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG, | 629 | i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG, |
630 | &tda9887_cfg); | 630 | &tda9887_cfg); |
631 | } | 631 | } |
@@ -813,7 +813,8 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
813 | static struct tuner_params *t_params; | 813 | static struct tuner_params *t_params; |
814 | u8 config, cb; | 814 | u8 config, cb; |
815 | u32 div; | 815 | u32 div; |
816 | int ret, frequency = params->frequency / 62500; | 816 | int ret; |
817 | unsigned frequency = params->frequency / 62500; | ||
817 | 818 | ||
818 | t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); | 819 | t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); |
819 | ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); | 820 | ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); |
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index 5f99de0ad612..dcddfa803a75 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" | 2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Xceive Corporation | 4 | * Copyright (c) 2007 Xceive Corporation |
5 | * Copyright (c) 2007 Steven Toth <stoth@hauppauge.com> | 5 | * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 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 | 8 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h index c910715addc9..5389f740945a 100644 --- a/drivers/media/common/tuners/xc5000.h +++ b/drivers/media/common/tuners/xc5000.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" | 2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h index a72a9887fe7f..b2a0074c99c9 100644 --- a/drivers/media/common/tuners/xc5000_priv.h +++ b/drivers/media/common/tuners/xc5000_priv.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" | 2 | * Driver for Xceive XC5000 "QAM/8VSB single chip tuner" |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index f9d087669d5d..4eed783f4bce 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
@@ -137,7 +137,8 @@ static int flexcop_send_diseqc_msg(struct dvb_frontend* fe, int len, u8 *msg, un | |||
137 | flexcop_diseqc_send_byte(fe, 0xff); | 137 | flexcop_diseqc_send_byte(fe, 0xff); |
138 | else { | 138 | else { |
139 | flexcop_set_tone(fe, SEC_TONE_ON); | 139 | flexcop_set_tone(fe, SEC_TONE_ON); |
140 | udelay(12500); | 140 | mdelay(12); |
141 | udelay(500); | ||
141 | flexcop_set_tone(fe, SEC_TONE_OFF); | 142 | flexcop_set_tone(fe, SEC_TONE_OFF); |
142 | } | 143 | } |
143 | msleep(20); | 144 | msleep(20); |
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index 55973eaf3711..43a112ec6d44 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c | |||
@@ -221,12 +221,12 @@ int flexcop_i2c_init(struct flexcop_device *fc) | |||
221 | fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM; | 221 | fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM; |
222 | fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER; | 222 | fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER; |
223 | 223 | ||
224 | strncpy(fc->fc_i2c_adap[0].i2c_adap.name, | 224 | strlcpy(fc->fc_i2c_adap[0].i2c_adap.name, "B2C2 FlexCop I2C to demod", |
225 | "B2C2 FlexCop I2C to demod", I2C_NAME_SIZE); | 225 | sizeof(fc->fc_i2c_adap[0].i2c_adap.name)); |
226 | strncpy(fc->fc_i2c_adap[1].i2c_adap.name, | 226 | strlcpy(fc->fc_i2c_adap[1].i2c_adap.name, "B2C2 FlexCop I2C to eeprom", |
227 | "B2C2 FlexCop I2C to eeprom", I2C_NAME_SIZE); | 227 | sizeof(fc->fc_i2c_adap[1].i2c_adap.name)); |
228 | strncpy(fc->fc_i2c_adap[2].i2c_adap.name, | 228 | strlcpy(fc->fc_i2c_adap[2].i2c_adap.name, "B2C2 FlexCop I2C to tuner", |
229 | "B2C2 FlexCop I2C to tuner", I2C_NAME_SIZE); | 229 | sizeof(fc->fc_i2c_adap[2].i2c_adap.name)); |
230 | 230 | ||
231 | i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]); | 231 | i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]); |
232 | i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]); | 232 | i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]); |
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index a7637562e742..aa3db57d32d9 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c | |||
@@ -1244,7 +1244,7 @@ static int dst_command(struct dst_state *state, u8 *data, u8 len) | |||
1244 | goto error; | 1244 | goto error; |
1245 | } | 1245 | } |
1246 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 1246 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
1247 | udelay(3000); | 1247 | mdelay(3); |
1248 | if (read_dst(state, &reply, GET_ACK)) { | 1248 | if (read_dst(state, &reply, GET_ACK)) { |
1249 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); | 1249 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); |
1250 | if ((dst_error_recovery(state)) < 0) { | 1250 | if ((dst_error_recovery(state)) < 0) { |
@@ -1260,7 +1260,7 @@ static int dst_command(struct dst_state *state, u8 *data, u8 len) | |||
1260 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) | 1260 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) |
1261 | goto error; | 1261 | goto error; |
1262 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 1262 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
1263 | udelay(3000); | 1263 | mdelay(3); |
1264 | else | 1264 | else |
1265 | udelay(2000); | 1265 | udelay(2000); |
1266 | if (!dst_wait_dst_ready(state, NO_DELAY)) | 1266 | if (!dst_wait_dst_ready(state, NO_DELAY)) |
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 1cf9fcb6f514..069d847ba887 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c | |||
@@ -641,7 +641,6 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
641 | struct timespec timeout = { 0 }; | 641 | struct timespec timeout = { 0 }; |
642 | struct dmx_pes_filter_params *para = &filter->params.pes; | 642 | struct dmx_pes_filter_params *para = &filter->params.pes; |
643 | dmx_output_t otype; | 643 | dmx_output_t otype; |
644 | int ret; | ||
645 | int ts_type; | 644 | int ts_type; |
646 | enum dmx_ts_pes ts_pes; | 645 | enum dmx_ts_pes ts_pes; |
647 | struct dmx_ts_feed **tsfeed = &filter->feed.ts; | 646 | struct dmx_ts_feed **tsfeed = &filter->feed.ts; |
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 8e5dd7b1f034..98ee16773ff2 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
@@ -1032,7 +1032,7 @@ static int dvb_ca_en50221_thread(void *data) | |||
1032 | /* we need this extra check for annoying interfaces like the budget-av */ | 1032 | /* we need this extra check for annoying interfaces like the budget-av */ |
1033 | if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && | 1033 | if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && |
1034 | (ca->pub->poll_slot_status)) { | 1034 | (ca->pub->poll_slot_status)) { |
1035 | int status = ca->pub->poll_slot_status(ca->pub, slot, 0); | 1035 | status = ca->pub->poll_slot_status(ca->pub, slot, 0); |
1036 | if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { | 1036 | if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { |
1037 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; | 1037 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; |
1038 | dvb_ca_en50221_thread_update_delay(ca); | 1038 | dvb_ca_en50221_thread_update_delay(ca); |
@@ -1089,7 +1089,7 @@ static int dvb_ca_en50221_thread(void *data) | |||
1089 | /* we need this extra check for annoying interfaces like the budget-av */ | 1089 | /* we need this extra check for annoying interfaces like the budget-av */ |
1090 | if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && | 1090 | if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && |
1091 | (ca->pub->poll_slot_status)) { | 1091 | (ca->pub->poll_slot_status)) { |
1092 | int status = ca->pub->poll_slot_status(ca->pub, slot, 0); | 1092 | status = ca->pub->poll_slot_status(ca->pub, slot, 0); |
1093 | if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { | 1093 | if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { |
1094 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; | 1094 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; |
1095 | dvb_ca_en50221_thread_update_delay(ca); | 1095 | dvb_ca_en50221_thread_update_delay(ca); |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 8cbdb218952f..3526e3ee9487 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -889,13 +889,13 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
889 | * initialization, so parg is 8 bits and does not | 889 | * initialization, so parg is 8 bits and does not |
890 | * include the initialization or start bit | 890 | * include the initialization or start bit |
891 | */ | 891 | */ |
892 | unsigned long cmd = ((unsigned long) parg) << 1; | 892 | unsigned long swcmd = ((unsigned long) parg) << 1; |
893 | struct timeval nexttime; | 893 | struct timeval nexttime; |
894 | struct timeval tv[10]; | 894 | struct timeval tv[10]; |
895 | int i; | 895 | int i; |
896 | u8 last = 1; | 896 | u8 last = 1; |
897 | if (dvb_frontend_debug) | 897 | if (dvb_frontend_debug) |
898 | printk("%s switch command: 0x%04lx\n", __func__, cmd); | 898 | printk("%s switch command: 0x%04lx\n", __func__, swcmd); |
899 | do_gettimeofday(&nexttime); | 899 | do_gettimeofday(&nexttime); |
900 | if (dvb_frontend_debug) | 900 | if (dvb_frontend_debug) |
901 | memcpy(&tv[0], &nexttime, sizeof(struct timeval)); | 901 | memcpy(&tv[0], &nexttime, sizeof(struct timeval)); |
@@ -908,12 +908,12 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
908 | for (i = 0; i < 9; i++) { | 908 | for (i = 0; i < 9; i++) { |
909 | if (dvb_frontend_debug) | 909 | if (dvb_frontend_debug) |
910 | do_gettimeofday(&tv[i + 1]); | 910 | do_gettimeofday(&tv[i + 1]); |
911 | if ((cmd & 0x01) != last) { | 911 | if ((swcmd & 0x01) != last) { |
912 | /* set voltage to (last ? 13V : 18V) */ | 912 | /* set voltage to (last ? 13V : 18V) */ |
913 | fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); | 913 | fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); |
914 | last = (last) ? 0 : 1; | 914 | last = (last) ? 0 : 1; |
915 | } | 915 | } |
916 | cmd = cmd >> 1; | 916 | swcmd = swcmd >> 1; |
917 | if (i != 8) | 917 | if (i != 8) |
918 | dvb_frontend_sleep_until(&nexttime, 8000); | 918 | dvb_frontend_sleep_until(&nexttime, 8000); |
919 | } | 919 | } |
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index aaa0b6f0b521..563400277a42 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
@@ -210,7 +210,7 @@ static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
210 | if (d->state == DVB_USB_STATE_INIT && | 210 | if (d->state == DVB_USB_STATE_INIT && |
211 | usb_set_interface(d->udev, 0, 0) < 0) | 211 | usb_set_interface(d->udev, 0, 0) < 0) |
212 | err("set interface failed"); | 212 | err("set interface failed"); |
213 | do; while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) && | 213 | do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) && |
214 | !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) && | 214 | !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) && |
215 | !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0); | 215 | !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0); |
216 | if (!ret) { | 216 | if (!ret) { |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index 3dd20bfbed32..6c0e5c5f4362 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
@@ -1117,7 +1117,8 @@ struct usb_device_id dib0700_usb_id_table[] = { | |||
1117 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) }, | 1117 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) }, |
1118 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) }, | 1118 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) }, |
1119 | { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) }, | 1119 | { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) }, |
1120 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) }, | 1120 | /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) }, |
1121 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) }, | ||
1121 | { 0 } /* Terminating entry */ | 1122 | { 0 } /* Terminating entry */ |
1122 | }; | 1123 | }; |
1123 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | 1124 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); |
@@ -1373,7 +1374,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1373 | } | 1374 | } |
1374 | }, | 1375 | }, |
1375 | 1376 | ||
1376 | .num_device_descs = 3, | 1377 | .num_device_descs = 4, |
1377 | .devices = { | 1378 | .devices = { |
1378 | { "DiBcom STK7070PD reference design", | 1379 | { "DiBcom STK7070PD reference design", |
1379 | { &dib0700_usb_id_table[17], NULL }, | 1380 | { &dib0700_usb_id_table[17], NULL }, |
@@ -1386,6 +1387,10 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
1386 | { "Hauppauge Nova-TD Stick (52009)", | 1387 | { "Hauppauge Nova-TD Stick (52009)", |
1387 | { &dib0700_usb_id_table[35], NULL }, | 1388 | { &dib0700_usb_id_table[35], NULL }, |
1388 | { NULL }, | 1389 | { NULL }, |
1390 | }, | ||
1391 | { "Hauppauge Nova-TD-500 (84xxx)", | ||
1392 | { &dib0700_usb_id_table[36], NULL }, | ||
1393 | { NULL }, | ||
1389 | } | 1394 | } |
1390 | } | 1395 | } |
1391 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | 1396 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 029b437caf9a..03dfb9f2fe30 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -129,6 +129,7 @@ | |||
129 | #define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 | 129 | #define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 |
130 | #define USB_PID_HAUPPAUGE_NOVA_T_500 0x9941 | 130 | #define USB_PID_HAUPPAUGE_NOVA_T_500 0x9941 |
131 | #define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950 | 131 | #define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950 |
132 | #define USB_PID_HAUPPAUGE_NOVA_T_500_3 0x8400 | ||
132 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050 | 133 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050 |
133 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060 | 134 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060 |
134 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK_3 0x7070 | 135 | #define USB_PID_HAUPPAUGE_NOVA_T_STICK_3 0x7070 |
diff --git a/drivers/media/dvb/frontends/au8522.c b/drivers/media/dvb/frontends/au8522.c index f7b71657f0f6..0b82cc2a1e16 100644 --- a/drivers/media/dvb/frontends/au8522.c +++ b/drivers/media/dvb/frontends/au8522.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Auvitek AU8522 QAM/8VSB demodulator driver | 2 | Auvitek AU8522 QAM/8VSB demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
@@ -304,6 +304,43 @@ static int au8522_mse2snr_lookup(struct mse2snr_tab *tab, int sz, int mse, | |||
304 | return ret; | 304 | return ret; |
305 | } | 305 | } |
306 | 306 | ||
307 | static int au8522_set_if(struct dvb_frontend *fe, enum au8522_if_freq if_freq) | ||
308 | { | ||
309 | struct au8522_state *state = fe->demodulator_priv; | ||
310 | u8 r0b5, r0b6, r0b7; | ||
311 | char *ifmhz; | ||
312 | |||
313 | switch (if_freq) { | ||
314 | case AU8522_IF_3_25MHZ: | ||
315 | ifmhz = "3.25"; | ||
316 | r0b5 = 0x00; | ||
317 | r0b6 = 0x3d; | ||
318 | r0b7 = 0xa0; | ||
319 | break; | ||
320 | case AU8522_IF_4MHZ: | ||
321 | ifmhz = "4.00"; | ||
322 | r0b5 = 0x00; | ||
323 | r0b6 = 0x4b; | ||
324 | r0b7 = 0xd9; | ||
325 | break; | ||
326 | case AU8522_IF_6MHZ: | ||
327 | ifmhz = "6.00"; | ||
328 | r0b5 = 0xfb; | ||
329 | r0b6 = 0x8e; | ||
330 | r0b7 = 0x39; | ||
331 | break; | ||
332 | default: | ||
333 | dprintk("%s() IF Frequency not supported\n", __func__); | ||
334 | return -EINVAL; | ||
335 | } | ||
336 | dprintk("%s() %s MHz\n", __func__, ifmhz); | ||
337 | au8522_writereg(state, 0x80b5, r0b5); | ||
338 | au8522_writereg(state, 0x80b6, r0b6); | ||
339 | au8522_writereg(state, 0x80b7, r0b7); | ||
340 | |||
341 | return 0; | ||
342 | } | ||
343 | |||
307 | /* VSB Modulation table */ | 344 | /* VSB Modulation table */ |
308 | static struct { | 345 | static struct { |
309 | u16 reg; | 346 | u16 reg; |
@@ -334,9 +371,6 @@ static struct { | |||
334 | { 0x80af, 0x66 }, | 371 | { 0x80af, 0x66 }, |
335 | { 0x821b, 0xcc }, | 372 | { 0x821b, 0xcc }, |
336 | { 0x821d, 0x80 }, | 373 | { 0x821d, 0x80 }, |
337 | { 0x80b5, 0xfb }, | ||
338 | { 0x80b6, 0x8e }, | ||
339 | { 0x80b7, 0x39 }, | ||
340 | { 0x80a4, 0xe8 }, | 374 | { 0x80a4, 0xe8 }, |
341 | { 0x8231, 0x13 }, | 375 | { 0x8231, 0x13 }, |
342 | }; | 376 | }; |
@@ -350,9 +384,6 @@ static struct { | |||
350 | { 0x80a4, 0x00 }, | 384 | { 0x80a4, 0x00 }, |
351 | { 0x8081, 0xc4 }, | 385 | { 0x8081, 0xc4 }, |
352 | { 0x80a5, 0x40 }, | 386 | { 0x80a5, 0x40 }, |
353 | { 0x80b5, 0xfb }, | ||
354 | { 0x80b6, 0x8e }, | ||
355 | { 0x80b7, 0x39 }, | ||
356 | { 0x80aa, 0x77 }, | 387 | { 0x80aa, 0x77 }, |
357 | { 0x80ad, 0x77 }, | 388 | { 0x80ad, 0x77 }, |
358 | { 0x80a6, 0x67 }, | 389 | { 0x80a6, 0x67 }, |
@@ -438,6 +469,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe, | |||
438 | au8522_writereg(state, | 469 | au8522_writereg(state, |
439 | VSB_mod_tab[i].reg, | 470 | VSB_mod_tab[i].reg, |
440 | VSB_mod_tab[i].data); | 471 | VSB_mod_tab[i].data); |
472 | au8522_set_if(fe, state->config->vsb_if); | ||
441 | break; | 473 | break; |
442 | case QAM_64: | 474 | case QAM_64: |
443 | case QAM_256: | 475 | case QAM_256: |
@@ -446,6 +478,7 @@ static int au8522_enable_modulation(struct dvb_frontend *fe, | |||
446 | au8522_writereg(state, | 478 | au8522_writereg(state, |
447 | QAM_mod_tab[i].reg, | 479 | QAM_mod_tab[i].reg, |
448 | QAM_mod_tab[i].data); | 480 | QAM_mod_tab[i].data); |
481 | au8522_set_if(fe, state->config->qam_if); | ||
449 | break; | 482 | break; |
450 | default: | 483 | default: |
451 | dprintk("%s() Invalid modulation\n", __func__); | 484 | dprintk("%s() Invalid modulation\n", __func__); |
diff --git a/drivers/media/dvb/frontends/au8522.h b/drivers/media/dvb/frontends/au8522.h index d7affa3cdb27..595915ade8c3 100644 --- a/drivers/media/dvb/frontends/au8522.h +++ b/drivers/media/dvb/frontends/au8522.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Auvitek AU8522 QAM/8VSB demodulator driver | 2 | Auvitek AU8522 QAM/8VSB demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
@@ -24,6 +24,12 @@ | |||
24 | 24 | ||
25 | #include <linux/dvb/frontend.h> | 25 | #include <linux/dvb/frontend.h> |
26 | 26 | ||
27 | enum au8522_if_freq { | ||
28 | AU8522_IF_6MHZ = 0, | ||
29 | AU8522_IF_4MHZ, | ||
30 | AU8522_IF_3_25MHZ, | ||
31 | }; | ||
32 | |||
27 | struct au8522_config { | 33 | struct au8522_config { |
28 | /* the demodulator's i2c address */ | 34 | /* the demodulator's i2c address */ |
29 | u8 demod_address; | 35 | u8 demod_address; |
@@ -32,6 +38,9 @@ struct au8522_config { | |||
32 | #define AU8522_TUNERLOCKING 0 | 38 | #define AU8522_TUNERLOCKING 0 |
33 | #define AU8522_DEMODLOCKING 1 | 39 | #define AU8522_DEMODLOCKING 1 |
34 | u8 status_mode; | 40 | u8 status_mode; |
41 | |||
42 | enum au8522_if_freq vsb_if; | ||
43 | enum au8522_if_freq qam_if; | ||
35 | }; | 44 | }; |
36 | 45 | ||
37 | #if defined(CONFIG_DVB_AU8522) || \ | 46 | #if defined(CONFIG_DVB_AU8522) || \ |
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c index cc1db4e371c3..9430e03dba6c 100644 --- a/drivers/media/dvb/frontends/cx22702.c +++ b/drivers/media/dvb/frontends/cx22702.c | |||
@@ -7,7 +7,7 @@ | |||
7 | Copyright (C) 2001-2002 Convergence Integrated Media GmbH | 7 | Copyright (C) 2001-2002 Convergence Integrated Media GmbH |
8 | Holger Waechtler <holger@convergence.de> | 8 | Holger Waechtler <holger@convergence.de> |
9 | 9 | ||
10 | Copyright (C) 2004 Steven Toth <stoth@hauppauge.com> | 10 | Copyright (C) 2004 Steven Toth <stoth@linuxtv.org> |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h index 8af766a31552..b1e465c6c2ce 100644 --- a/drivers/media/dvb/frontends/cx22702.h +++ b/drivers/media/dvb/frontends/cx22702.h | |||
@@ -7,7 +7,7 @@ | |||
7 | Copyright (C) 2001-2002 Convergence Integrated Media GmbH | 7 | Copyright (C) 2001-2002 Convergence Integrated Media GmbH |
8 | Holger Waechtler <holger@convergence.de> | 8 | Holger Waechtler <holger@convergence.de> |
9 | 9 | ||
10 | Copyright (C) 2004 Steven Toth <stoth@hauppauge.com> | 10 | Copyright (C) 2004 Steven Toth <stoth@linuxtv.org> |
11 | 11 | ||
12 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
13 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c index 7f68d78c6558..7156157cb34b 100644 --- a/drivers/media/dvb/frontends/cx24123.c +++ b/drivers/media/dvb/frontends/cx24123.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver | 2 | * Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver |
3 | * | 3 | * |
4 | * Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (C) 2005 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc> | 6 | * Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc> |
7 | * | 7 | * |
@@ -1072,8 +1072,8 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | |||
1072 | if (config->dont_use_pll) | 1072 | if (config->dont_use_pll) |
1073 | cx24123_repeater_mode(state, 1, 0); | 1073 | cx24123_repeater_mode(state, 1, 0); |
1074 | 1074 | ||
1075 | strncpy(state->tuner_i2c_adapter.name, | 1075 | strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", |
1076 | "CX24123 tuner I2C bus", I2C_NAME_SIZE); | 1076 | sizeof(state->tuner_i2c_adapter.name)); |
1077 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, | 1077 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, |
1078 | state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo; | 1078 | state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo; |
1079 | state->tuner_i2c_adapter.algo_data = NULL; | 1079 | state->tuner_i2c_adapter.algo_data = NULL; |
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h index 81ebc3d2f19f..cc6b411d6d20 100644 --- a/drivers/media/dvb/frontends/cx24123.h +++ b/drivers/media/dvb/frontends/cx24123.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver | 2 | Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver |
3 | 3 | ||
4 | Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2005 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c index 5ddb2dca305c..7500a1c53e68 100644 --- a/drivers/media/dvb/frontends/s5h1409.c +++ b/drivers/media/dvb/frontends/s5h1409.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Samsung S5H1409 VSB/QAM demodulator driver | 2 | Samsung S5H1409 VSB/QAM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2006 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2006 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
@@ -404,6 +404,7 @@ static int s5h1409_enable_modulation(struct dvb_frontend* fe, | |||
404 | break; | 404 | break; |
405 | case QAM_64: | 405 | case QAM_64: |
406 | case QAM_256: | 406 | case QAM_256: |
407 | case QAM_AUTO: | ||
407 | dprintk("%s() QAM_AUTO (64/256)\n", __func__); | 408 | dprintk("%s() QAM_AUTO (64/256)\n", __func__); |
408 | if (state->if_freq != S5H1409_QAM_IF_FREQ) | 409 | if (state->if_freq != S5H1409_QAM_IF_FREQ) |
409 | s5h1409_set_if_freq(fe, S5H1409_QAM_IF_FREQ); | 410 | s5h1409_set_if_freq(fe, S5H1409_QAM_IF_FREQ); |
diff --git a/drivers/media/dvb/frontends/s5h1409.h b/drivers/media/dvb/frontends/s5h1409.h index 59f4335964c6..d1a1d2eb8e11 100644 --- a/drivers/media/dvb/frontends/s5h1409.h +++ b/drivers/media/dvb/frontends/s5h1409.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Samsung S5H1409 VSB/QAM demodulator driver | 2 | Samsung S5H1409 VSB/QAM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2006 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2006 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/frontends/s5h1411.c b/drivers/media/dvb/frontends/s5h1411.c index cff360ce1ba3..2da1a3763de9 100644 --- a/drivers/media/dvb/frontends/s5h1411.c +++ b/drivers/media/dvb/frontends/s5h1411.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Samsung S5H1411 VSB/QAM demodulator driver | 2 | Samsung S5H1411 VSB/QAM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
@@ -488,6 +488,7 @@ static int s5h1411_enable_modulation(struct dvb_frontend *fe, | |||
488 | break; | 488 | break; |
489 | case QAM_64: | 489 | case QAM_64: |
490 | case QAM_256: | 490 | case QAM_256: |
491 | case QAM_AUTO: | ||
491 | dprintk("%s() QAM_AUTO (64/256)\n", __func__); | 492 | dprintk("%s() QAM_AUTO (64/256)\n", __func__); |
492 | s5h1411_set_if_freq(fe, state->config->qam_if); | 493 | s5h1411_set_if_freq(fe, state->config->qam_if); |
493 | s5h1411_writereg(state, S5H1411_I2C_TOP_ADDR, 0x00, 0x0171); | 494 | s5h1411_writereg(state, S5H1411_I2C_TOP_ADDR, 0x00, 0x0171); |
diff --git a/drivers/media/dvb/frontends/s5h1411.h b/drivers/media/dvb/frontends/s5h1411.h index 1855f64ed4d8..7d542bc00c48 100644 --- a/drivers/media/dvb/frontends/s5h1411.h +++ b/drivers/media/dvb/frontends/s5h1411.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Samsung S5H1411 VSB/QAM demodulator driver | 2 | Samsung S5H1411 VSB/QAM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 720ed9ff7c5f..747d3fa2e5e5 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
@@ -915,7 +915,8 @@ struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config, | |||
915 | state->frontend.demodulator_priv = state; | 915 | state->frontend.demodulator_priv = state; |
916 | 916 | ||
917 | /* create tuner i2c adapter */ | 917 | /* create tuner i2c adapter */ |
918 | strncpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus", I2C_NAME_SIZE); | 918 | strlcpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus", |
919 | sizeof(state->tuner_i2c_adapter.name)); | ||
919 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, | 920 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, |
920 | state->tuner_i2c_adapter.algo = &s5h1420_tuner_i2c_algo; | 921 | state->tuner_i2c_adapter.algo = &s5h1420_tuner_i2c_algo; |
921 | state->tuner_i2c_adapter.algo_data = NULL; | 922 | state->tuner_i2c_adapter.algo_data = NULL; |
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c index 0ab8d86b3ae3..04e7f1cc1403 100644 --- a/drivers/media/dvb/frontends/tda10048.c +++ b/drivers/media/dvb/frontends/tda10048.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | NXP TDA10048HN DVB OFDM demodulator driver | 2 | NXP TDA10048HN DVB OFDM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
@@ -303,7 +303,7 @@ static int tda10048_firmware_upload(struct dvb_frontend *fe) | |||
303 | 303 | ||
304 | if (fw->size != TDA10048_DEFAULT_FIRMWARE_SIZE) { | 304 | if (fw->size != TDA10048_DEFAULT_FIRMWARE_SIZE) { |
305 | printk(KERN_ERR "%s: firmware incorrect size\n", __func__); | 305 | printk(KERN_ERR "%s: firmware incorrect size\n", __func__); |
306 | return -EIO; | 306 | ret = -EIO; |
307 | } else { | 307 | } else { |
308 | printk(KERN_INFO "%s: firmware uploading\n", __func__); | 308 | printk(KERN_INFO "%s: firmware uploading\n", __func__); |
309 | 309 | ||
diff --git a/drivers/media/dvb/frontends/tda10048.h b/drivers/media/dvb/frontends/tda10048.h index 2b5c78e62c86..0457b24601fa 100644 --- a/drivers/media/dvb/frontends/tda10048.h +++ b/drivers/media/dvb/frontends/tda10048.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | NXP TDA10048HN DVB OFDM demodulator driver | 2 | NXP TDA10048HN DVB OFDM demodulator driver |
3 | 3 | ||
4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | 4 | Copyright (C) 2008 Steven Toth <stoth@linuxtv.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c index e7a8ac0c4049..cc5efb643f33 100644 --- a/drivers/media/dvb/siano/sms-cards.c +++ b/drivers/media/dvb/siano/sms-cards.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> | 4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 3 as | 7 | * it under the terms of the GNU General Public License version 2 as |
8 | * published by the Free Software Foundation; | 8 | * published by the Free Software Foundation; |
9 | * | 9 | * |
10 | * Software distributed under the License is distributed on an "AS IS" | 10 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/siano/sms-cards.h b/drivers/media/dvb/siano/sms-cards.h index 83b39bc203fe..c8f3da6f9bc1 100644 --- a/drivers/media/dvb/siano/sms-cards.h +++ b/drivers/media/dvb/siano/sms-cards.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> | 4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 3 as | 7 | * it under the terms of the GNU General Public License version 2 as |
8 | * published by the Free Software Foundation; | 8 | * published by the Free Software Foundation; |
9 | * | 9 | * |
10 | * Software distributed under the License is distributed on an "AS IS" | 10 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c index c5f45fed69dc..6576fbb40fc6 100644 --- a/drivers/media/dvb/siano/smscoreapi.c +++ b/drivers/media/dvb/siano/smscoreapi.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | 8 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 3 as | 11 | * it under the terms of the GNU General Public License version 2 as |
12 | * published by the Free Software Foundation; | 12 | * published by the Free Software Foundation; |
13 | * | 13 | * |
14 | * Software distributed under the License is distributed on an "AS IS" | 14 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/siano/smscoreapi.h b/drivers/media/dvb/siano/smscoreapi.h index c1f8f1dccb11..8d973f726fb8 100644 --- a/drivers/media/dvb/siano/smscoreapi.h +++ b/drivers/media/dvb/siano/smscoreapi.h | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | 6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 3 as | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation; | 10 | * published by the Free Software Foundation; |
11 | * | 11 | * |
12 | * Software distributed under the License is distributed on an "AS IS" | 12 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index 229274a14110..8d490e133f35 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | 6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 3 as | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation; | 10 | * published by the Free Software Foundation; |
11 | * | 11 | * |
12 | * Software distributed under the License is distributed on an "AS IS" | 12 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c index c10b1849c6a3..87a3c24454b9 100644 --- a/drivers/media/dvb/siano/smsusb.c +++ b/drivers/media/dvb/siano/smsusb.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. | 6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 3 as | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation; | 10 | * published by the Free Software Foundation; |
11 | * | 11 | * |
12 | * Software distributed under the License is distributed on an "AS IS" | 12 | * Software distributed under the License is distributed on an "AS IS" |
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index 39bd0a20f53a..aa5ed4ef19f2 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c | |||
@@ -116,7 +116,8 @@ static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long | |||
116 | DiseqcSendByte(budget, 0xff); | 116 | DiseqcSendByte(budget, 0xff); |
117 | else { | 117 | else { |
118 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); | 118 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); |
119 | udelay(12500); | 119 | mdelay(12); |
120 | udelay(500); | ||
120 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); | 121 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); |
121 | } | 122 | } |
122 | msleep(20); | 123 | msleep(20); |
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 2293d80c6e51..f0068996ac07 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
@@ -108,7 +108,8 @@ static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long | |||
108 | DiseqcSendByte(budget, 0xff); | 108 | DiseqcSendByte(budget, 0xff); |
109 | else { | 109 | else { |
110 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); | 110 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); |
111 | udelay(12500); | 111 | mdelay(12); |
112 | udelay(500); | ||
112 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); | 113 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); |
113 | } | 114 | } |
114 | msleep(20); | 115 | msleep(20); |
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index a30159f6fa42..7ca71ab96b43 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile | |||
@@ -2,8 +2,6 @@ | |||
2 | # Makefile for the kernel character device drivers. | 2 | # Makefile for the kernel character device drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | miropcm20-objs := miropcm20-rds-core.o miropcm20-radio.o | ||
6 | |||
7 | obj-$(CONFIG_RADIO_AZTECH) += radio-aztech.o | 5 | obj-$(CONFIG_RADIO_AZTECH) += radio-aztech.o |
8 | obj-$(CONFIG_RADIO_RTRACK2) += radio-rtrack2.o | 6 | obj-$(CONFIG_RADIO_RTRACK2) += radio-rtrack2.o |
9 | obj-$(CONFIG_RADIO_SF16FMI) += radio-sf16fmi.o | 7 | obj-$(CONFIG_RADIO_SF16FMI) += radio-sf16fmi.o |
@@ -14,8 +12,6 @@ obj-$(CONFIG_RADIO_TERRATEC) += radio-terratec.o | |||
14 | obj-$(CONFIG_RADIO_MAXIRADIO) += radio-maxiradio.o | 12 | obj-$(CONFIG_RADIO_MAXIRADIO) += radio-maxiradio.o |
15 | obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o | 13 | obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o |
16 | obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o | 14 | obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o |
17 | obj-$(CONFIG_RADIO_MIROPCM20) += miropcm20.o | ||
18 | obj-$(CONFIG_RADIO_MIROPCM20_RDS) += miropcm20-rds.o | ||
19 | obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o | 15 | obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o |
20 | obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o | 16 | obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o |
21 | obj-$(CONFIG_RADIO_TRUST) += radio-trust.o | 17 | obj-$(CONFIG_RADIO_TRUST) += radio-trust.o |
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 1ed88f3abe61..70c65a745923 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -493,7 +493,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
493 | radio->usbdev = interface_to_usbdev(intf); | 493 | radio->usbdev = interface_to_usbdev(intf); |
494 | radio->curfreq = FREQ_MIN*FREQ_MUL; | 494 | radio->curfreq = FREQ_MIN*FREQ_MUL; |
495 | video_set_drvdata(radio->videodev, radio); | 495 | video_set_drvdata(radio->videodev, radio); |
496 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO,radio_nr)) { | 496 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr) < 0) { |
497 | warn("Could not register video device"); | 497 | warn("Could not register video device"); |
498 | video_device_release(radio->videodev); | 498 | video_device_release(radio->videodev); |
499 | kfree(radio->transfer_buffer); | 499 | kfree(radio->transfer_buffer); |
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c deleted file mode 100644 index 7fd7ee2d32c1..000000000000 --- a/drivers/media/radio/miropcm20-radio.c +++ /dev/null | |||
@@ -1,266 +0,0 @@ | |||
1 | /* Miro PCM20 radio driver for Linux radio support | ||
2 | * (c) 1998 Ruurd Reitsma <R.A.Reitsma@wbmt.tudelft.nl> | ||
3 | * Thanks to Norberto Pellici for the ACI device interface specification | ||
4 | * The API part is based on the radiotrack driver by M. Kirkwood | ||
5 | * This driver relies on the aci mixer (drivers/sound/aci.c) | ||
6 | * Look there for further info... | ||
7 | */ | ||
8 | |||
9 | /* Revision history: | ||
10 | * | ||
11 | * 1998 Ruurd Reitsma <R.A.Reitsma@wbmt.tudelft.nl> | ||
12 | * 2000-09-05 Robert Siemer <Robert.Siemer@gmx.de> | ||
13 | * removed unfinished volume control (maybe adding it later again) | ||
14 | * use OSS-mixer; added stereo control | ||
15 | */ | ||
16 | |||
17 | /* What ever you think about the ACI, version 0x07 is not very well! | ||
18 | * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono | ||
19 | * conditions... Robert | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/videodev.h> | ||
25 | #include <media/v4l2-common.h> | ||
26 | #include <media/v4l2-ioctl.h> | ||
27 | #include "oss/aci.h" | ||
28 | #include "miropcm20-rds-core.h" | ||
29 | |||
30 | static int radio_nr = -1; | ||
31 | module_param(radio_nr, int, 0); | ||
32 | |||
33 | struct pcm20_device { | ||
34 | unsigned long freq; | ||
35 | int muted; | ||
36 | int stereo; | ||
37 | }; | ||
38 | |||
39 | |||
40 | static int pcm20_mute(struct pcm20_device *dev, unsigned char mute) | ||
41 | { | ||
42 | dev->muted = mute; | ||
43 | return aci_write_cmd(ACI_SET_TUNERMUTE, mute); | ||
44 | } | ||
45 | |||
46 | static int pcm20_stereo(struct pcm20_device *dev, unsigned char stereo) | ||
47 | { | ||
48 | dev->stereo = stereo; | ||
49 | return aci_write_cmd(ACI_SET_TUNERMONO, !stereo); | ||
50 | } | ||
51 | |||
52 | static int pcm20_setfreq(struct pcm20_device *dev, unsigned long freq) | ||
53 | { | ||
54 | unsigned char freql; | ||
55 | unsigned char freqh; | ||
56 | |||
57 | dev->freq=freq; | ||
58 | |||
59 | freq /= 160; | ||
60 | if (!(aci_version==0x07 || aci_version>=0xb0)) | ||
61 | freq /= 10; /* I don't know exactly which version | ||
62 | * needs this hack */ | ||
63 | freql = freq & 0xff; | ||
64 | freqh = freq >> 8; | ||
65 | |||
66 | aci_rds_cmd(RDS_RESET, NULL, 0); | ||
67 | pcm20_stereo(dev, 1); | ||
68 | |||
69 | return aci_rw_cmd(ACI_WRITE_TUNE, freql, freqh); | ||
70 | } | ||
71 | |||
72 | static int pcm20_getflags(struct pcm20_device *dev, __u32 *flags, __u16 *signal) | ||
73 | { | ||
74 | /* okay, check for signal, stereo and rds here... */ | ||
75 | int i; | ||
76 | unsigned char buf; | ||
77 | |||
78 | if ((i=aci_rw_cmd(ACI_READ_TUNERSTATION, -1, -1))<0) | ||
79 | return i; | ||
80 | pr_debug("check_sig: 0x%x\n", i); | ||
81 | if (i & 0x80) { | ||
82 | /* no signal from tuner */ | ||
83 | *flags=0; | ||
84 | *signal=0; | ||
85 | return 0; | ||
86 | } else | ||
87 | *signal=0xffff; | ||
88 | |||
89 | if ((i=aci_rw_cmd(ACI_READ_TUNERSTEREO, -1, -1))<0) | ||
90 | return i; | ||
91 | if (i & 0x40) { | ||
92 | *flags=0; | ||
93 | } else { | ||
94 | /* stereo */ | ||
95 | *flags=VIDEO_TUNER_STEREO_ON; | ||
96 | /* I can't see stereo, when forced to mono */ | ||
97 | dev->stereo=1; | ||
98 | } | ||
99 | |||
100 | if ((i=aci_rds_cmd(RDS_STATUS, &buf, 1))<0) | ||
101 | return i; | ||
102 | if (buf & 1) | ||
103 | /* RDS available */ | ||
104 | *flags|=VIDEO_TUNER_RDS_ON; | ||
105 | else | ||
106 | return 0; | ||
107 | |||
108 | if ((i=aci_rds_cmd(RDS_RXVALUE, &buf, 1))<0) | ||
109 | return i; | ||
110 | pr_debug("rds-signal: %d\n", buf); | ||
111 | if (buf > 15) { | ||
112 | printk("miropcm20-radio: RX strengths unexpected high...\n"); | ||
113 | buf=15; | ||
114 | } | ||
115 | /* refine signal */ | ||
116 | if ((*signal=SCALE(15, 0xffff, buf))==0) | ||
117 | *signal = 1; | ||
118 | |||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static int pcm20_do_ioctl(struct inode *inode, struct file *file, | ||
123 | unsigned int cmd, void *arg) | ||
124 | { | ||
125 | struct video_device *dev = video_devdata(file); | ||
126 | struct pcm20_device *pcm20 = dev->priv; | ||
127 | int i; | ||
128 | |||
129 | switch(cmd) | ||
130 | { | ||
131 | case VIDIOCGCAP: | ||
132 | { | ||
133 | struct video_capability *v = arg; | ||
134 | memset(v,0,sizeof(*v)); | ||
135 | v->type=VID_TYPE_TUNER; | ||
136 | strcpy(v->name, "Miro PCM20"); | ||
137 | v->channels=1; | ||
138 | v->audios=1; | ||
139 | return 0; | ||
140 | } | ||
141 | case VIDIOCGTUNER: | ||
142 | { | ||
143 | struct video_tuner *v = arg; | ||
144 | if(v->tuner) /* Only 1 tuner */ | ||
145 | return -EINVAL; | ||
146 | v->rangelow=87*16000; | ||
147 | v->rangehigh=108*16000; | ||
148 | pcm20_getflags(pcm20, &v->flags, &v->signal); | ||
149 | v->flags|=VIDEO_TUNER_LOW; | ||
150 | v->mode=VIDEO_MODE_AUTO; | ||
151 | strcpy(v->name, "FM"); | ||
152 | return 0; | ||
153 | } | ||
154 | case VIDIOCSTUNER: | ||
155 | { | ||
156 | struct video_tuner *v = arg; | ||
157 | if(v->tuner!=0) | ||
158 | return -EINVAL; | ||
159 | /* Only 1 tuner so no setting needed ! */ | ||
160 | return 0; | ||
161 | } | ||
162 | case VIDIOCGFREQ: | ||
163 | { | ||
164 | unsigned long *freq = arg; | ||
165 | *freq = pcm20->freq; | ||
166 | return 0; | ||
167 | } | ||
168 | case VIDIOCSFREQ: | ||
169 | { | ||
170 | unsigned long *freq = arg; | ||
171 | pcm20->freq = *freq; | ||
172 | i=pcm20_setfreq(pcm20, pcm20->freq); | ||
173 | pr_debug("First view (setfreq): 0x%x\n", i); | ||
174 | return i; | ||
175 | } | ||
176 | case VIDIOCGAUDIO: | ||
177 | { | ||
178 | struct video_audio *v = arg; | ||
179 | memset(v,0, sizeof(*v)); | ||
180 | v->flags=VIDEO_AUDIO_MUTABLE; | ||
181 | if (pcm20->muted) | ||
182 | v->flags|=VIDEO_AUDIO_MUTE; | ||
183 | v->mode=VIDEO_SOUND_STEREO; | ||
184 | if (pcm20->stereo) | ||
185 | v->mode|=VIDEO_SOUND_MONO; | ||
186 | /* v->step=2048; */ | ||
187 | strcpy(v->name, "Radio"); | ||
188 | return 0; | ||
189 | } | ||
190 | case VIDIOCSAUDIO: | ||
191 | { | ||
192 | struct video_audio *v = arg; | ||
193 | if(v->audio) | ||
194 | return -EINVAL; | ||
195 | |||
196 | pcm20_mute(pcm20, !!(v->flags&VIDEO_AUDIO_MUTE)); | ||
197 | if(v->flags&VIDEO_SOUND_MONO) | ||
198 | pcm20_stereo(pcm20, 0); | ||
199 | if(v->flags&VIDEO_SOUND_STEREO) | ||
200 | pcm20_stereo(pcm20, 1); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | default: | ||
205 | return -ENOIOCTLCMD; | ||
206 | } | ||
207 | } | ||
208 | |||
209 | static int pcm20_ioctl(struct inode *inode, struct file *file, | ||
210 | unsigned int cmd, unsigned long arg) | ||
211 | { | ||
212 | return video_usercopy(inode, file, cmd, arg, pcm20_do_ioctl); | ||
213 | } | ||
214 | |||
215 | static struct pcm20_device pcm20_unit = { | ||
216 | .freq = 87*16000, | ||
217 | .muted = 1, | ||
218 | }; | ||
219 | |||
220 | static const struct file_operations pcm20_fops = { | ||
221 | .owner = THIS_MODULE, | ||
222 | .open = video_exclusive_open, | ||
223 | .release = video_exclusive_release, | ||
224 | .ioctl = pcm20_ioctl, | ||
225 | #ifdef CONFIG_COMPAT | ||
226 | .compat_ioctl = v4l_compat_ioctl32, | ||
227 | #endif | ||
228 | .llseek = no_llseek, | ||
229 | }; | ||
230 | |||
231 | static struct video_device pcm20_radio = { | ||
232 | .name = "Miro PCM 20 radio", | ||
233 | .fops = &pcm20_fops, | ||
234 | .priv = &pcm20_unit | ||
235 | }; | ||
236 | |||
237 | static int __init pcm20_init(void) | ||
238 | { | ||
239 | if(video_register_device(&pcm20_radio, VFL_TYPE_RADIO, radio_nr)==-1) | ||
240 | goto video_register_device; | ||
241 | |||
242 | if(attach_aci_rds()<0) | ||
243 | goto attach_aci_rds; | ||
244 | |||
245 | printk(KERN_INFO "Miro PCM20 radio card driver.\n"); | ||
246 | |||
247 | return 0; | ||
248 | |||
249 | attach_aci_rds: | ||
250 | video_unregister_device(&pcm20_radio); | ||
251 | video_register_device: | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | MODULE_AUTHOR("Ruurd Reitsma"); | ||
256 | MODULE_DESCRIPTION("A driver for the Miro PCM20 radio card."); | ||
257 | MODULE_LICENSE("GPL"); | ||
258 | |||
259 | static void __exit pcm20_cleanup(void) | ||
260 | { | ||
261 | unload_aci_rds(); | ||
262 | video_unregister_device(&pcm20_radio); | ||
263 | } | ||
264 | |||
265 | module_init(pcm20_init); | ||
266 | module_exit(pcm20_cleanup); | ||
diff --git a/drivers/media/radio/miropcm20-rds-core.c b/drivers/media/radio/miropcm20-rds-core.c deleted file mode 100644 index 9428d8b2642c..000000000000 --- a/drivers/media/radio/miropcm20-rds-core.c +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | /* | ||
2 | * Many thanks to Fred Seidel <seidel@metabox.de>, the | ||
3 | * designer of the RDS decoder hardware. With his help | ||
4 | * I was able to code this driver. | ||
5 | * Thanks also to Norberto Pellicci, Dominic Mounteney | ||
6 | * <DMounteney@pinnaclesys.com> and www.teleauskunft.de | ||
7 | * for good hints on finding Fred. It was somewhat hard | ||
8 | * to locate him here in Germany... [: | ||
9 | * | ||
10 | * Revision history: | ||
11 | * | ||
12 | * 2000-08-09 Robert Siemer <Robert.Siemer@gmx.de> | ||
13 | * RDS support for MiroSound PCM20 radio | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/errno.h> | ||
18 | #include <linux/string.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/mutex.h> | ||
22 | |||
23 | #include <asm/io.h> | ||
24 | #include "oss/aci.h" | ||
25 | #include "miropcm20-rds-core.h" | ||
26 | |||
27 | #define DEBUG 0 | ||
28 | |||
29 | static struct mutex aci_rds_mutex; | ||
30 | |||
31 | #define RDS_DATASHIFT 2 /* Bit 2 */ | ||
32 | #define RDS_DATAMASK (1 << RDS_DATASHIFT) | ||
33 | #define RDS_BUSYMASK 0x10 /* Bit 4 */ | ||
34 | #define RDS_CLOCKMASK 0x08 /* Bit 3 */ | ||
35 | |||
36 | #define RDS_DATA(x) (((x) >> RDS_DATASHIFT) & 1) | ||
37 | |||
38 | |||
39 | #if DEBUG | ||
40 | static void print_matrix(char array[], unsigned int length) | ||
41 | { | ||
42 | int i, j; | ||
43 | |||
44 | for (i=0; i<length; i++) { | ||
45 | printk(KERN_DEBUG "aci-rds: "); | ||
46 | for (j=7; j>=0; j--) { | ||
47 | printk("%d", (array[i] >> j) & 0x1); | ||
48 | } | ||
49 | if (i%8 == 0) | ||
50 | printk(" byte-border\n"); | ||
51 | else | ||
52 | printk("\n"); | ||
53 | } | ||
54 | } | ||
55 | #endif /* DEBUG */ | ||
56 | |||
57 | static int byte2trans(unsigned char byte, unsigned char sendbuffer[], int size) | ||
58 | { | ||
59 | int i; | ||
60 | |||
61 | if (size != 8) | ||
62 | return -1; | ||
63 | for (i = 7; i >= 0; i--) | ||
64 | sendbuffer[7-i] = (byte & (1 << i)) ? RDS_DATAMASK : 0; | ||
65 | sendbuffer[0] |= RDS_CLOCKMASK; | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int rds_waitread(void) | ||
71 | { | ||
72 | unsigned char byte; | ||
73 | int i=2000; | ||
74 | |||
75 | do { | ||
76 | byte=inb(RDS_REGISTER); | ||
77 | i--; | ||
78 | } | ||
79 | while ((byte & RDS_BUSYMASK) && i); | ||
80 | |||
81 | if (i) { | ||
82 | #if DEBUG | ||
83 | printk(KERN_DEBUG "rds_waitread()"); | ||
84 | print_matrix(&byte, 1); | ||
85 | #endif | ||
86 | return (byte); | ||
87 | } else { | ||
88 | printk(KERN_WARNING "aci-rds: rds_waitread() timeout...\n"); | ||
89 | return -1; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | /* don't use any ..._nowait() function if you are not sure what you do... */ | ||
94 | |||
95 | static inline void rds_rawwrite_nowait(unsigned char byte) | ||
96 | { | ||
97 | #if DEBUG | ||
98 | printk(KERN_DEBUG "rds_rawwrite()"); | ||
99 | print_matrix(&byte, 1); | ||
100 | #endif | ||
101 | outb(byte, RDS_REGISTER); | ||
102 | } | ||
103 | |||
104 | static int rds_rawwrite(unsigned char byte) | ||
105 | { | ||
106 | if (rds_waitread() >= 0) { | ||
107 | rds_rawwrite_nowait(byte); | ||
108 | return 0; | ||
109 | } else | ||
110 | return -1; | ||
111 | } | ||
112 | |||
113 | static int rds_write(unsigned char cmd) | ||
114 | { | ||
115 | unsigned char sendbuffer[8]; | ||
116 | int i; | ||
117 | |||
118 | if (byte2trans(cmd, sendbuffer, 8) != 0){ | ||
119 | return -1; | ||
120 | } else { | ||
121 | for (i=0; i<8; i++) { | ||
122 | rds_rawwrite(sendbuffer[i]); | ||
123 | } | ||
124 | } | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int rds_readcycle_nowait(void) | ||
129 | { | ||
130 | rds_rawwrite_nowait(0); | ||
131 | return rds_waitread(); | ||
132 | } | ||
133 | |||
134 | static int rds_readcycle(void) | ||
135 | { | ||
136 | if (rds_rawwrite(0) < 0) | ||
137 | return -1; | ||
138 | return rds_waitread(); | ||
139 | } | ||
140 | |||
141 | static int rds_read(unsigned char databuffer[], int datasize) | ||
142 | { | ||
143 | #define READSIZE (8*datasize) | ||
144 | |||
145 | int i,j; | ||
146 | |||
147 | if (datasize < 1) /* nothing to read */ | ||
148 | return 0; | ||
149 | |||
150 | /* to be able to use rds_readcycle_nowait() | ||
151 | I have to waitread() here */ | ||
152 | if (rds_waitread() < 0) | ||
153 | return -1; | ||
154 | |||
155 | memset(databuffer, 0, datasize); | ||
156 | |||
157 | for (i=0; i< READSIZE; i++) | ||
158 | if((j=rds_readcycle_nowait()) < 0) { | ||
159 | return -1; | ||
160 | } else { | ||
161 | databuffer[i/8]|=(RDS_DATA(j) << (7-(i%8))); | ||
162 | } | ||
163 | |||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static int rds_ack(void) | ||
168 | { | ||
169 | int i=rds_readcycle(); | ||
170 | |||
171 | if (i < 0) | ||
172 | return -1; | ||
173 | if (i & RDS_DATAMASK) { | ||
174 | return 0; /* ACK */ | ||
175 | } else { | ||
176 | printk(KERN_DEBUG "aci-rds: NACK\n"); | ||
177 | return 1; /* NACK */ | ||
178 | } | ||
179 | } | ||
180 | |||
181 | int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize) | ||
182 | { | ||
183 | int ret; | ||
184 | |||
185 | if (mutex_lock_interruptible(&aci_rds_mutex)) | ||
186 | return -EINTR; | ||
187 | |||
188 | rds_write(cmd); | ||
189 | |||
190 | /* RDS_RESET doesn't need further processing */ | ||
191 | if (cmd!=RDS_RESET && (rds_ack() || rds_read(databuffer, datasize))) | ||
192 | ret = -1; | ||
193 | else | ||
194 | ret = 0; | ||
195 | |||
196 | mutex_unlock(&aci_rds_mutex); | ||
197 | |||
198 | return ret; | ||
199 | } | ||
200 | EXPORT_SYMBOL(aci_rds_cmd); | ||
201 | |||
202 | int __init attach_aci_rds(void) | ||
203 | { | ||
204 | mutex_init(&aci_rds_mutex); | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | void __exit unload_aci_rds(void) | ||
209 | { | ||
210 | } | ||
211 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/radio/miropcm20-rds-core.h b/drivers/media/radio/miropcm20-rds-core.h deleted file mode 100644 index aeb5761f0469..000000000000 --- a/drivers/media/radio/miropcm20-rds-core.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | #ifndef _MIROPCM20_RDS_CORE_H_ | ||
2 | #define _MIROPCM20_RDS_CORE_H_ | ||
3 | |||
4 | extern int aci_rds_cmd(unsigned char cmd, unsigned char databuffer[], int datasize); | ||
5 | |||
6 | #define RDS_STATUS 0x01 | ||
7 | #define RDS_STATIONNAME 0x02 | ||
8 | #define RDS_TEXT 0x03 | ||
9 | #define RDS_ALTFREQ 0x04 | ||
10 | #define RDS_TIMEDATE 0x05 | ||
11 | #define RDS_PI_CODE 0x06 | ||
12 | #define RDS_PTYTATP 0x07 | ||
13 | #define RDS_RESET 0x08 | ||
14 | #define RDS_RXVALUE 0x09 | ||
15 | |||
16 | extern void __exit unload_aci_rds(void); | ||
17 | extern int __init attach_aci_rds(void); | ||
18 | |||
19 | #endif /* _MIROPCM20_RDS_CORE_H_ */ | ||
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c deleted file mode 100644 index 3e840f74d45c..000000000000 --- a/drivers/media/radio/miropcm20-rds.c +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* MiroSOUND PCM20 radio rds interface driver | ||
2 | * (c) 2001 Robert Siemer <Robert.Siemer@gmx.de> | ||
3 | * Thanks to Fred Seidel. See miropcm20-rds-core.c for further information. | ||
4 | */ | ||
5 | |||
6 | /* Revision history: | ||
7 | * | ||
8 | * 2001-04-18 Robert Siemer <Robert.Siemer@gmx.de> | ||
9 | * separate file for user interface driver | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/fs.h> | ||
17 | #include <linux/miscdevice.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <asm/uaccess.h> | ||
20 | #include "miropcm20-rds-core.h" | ||
21 | |||
22 | static char * text_buffer; | ||
23 | static int rds_users; | ||
24 | |||
25 | |||
26 | static int rds_f_open(struct inode *in, struct file *fi) | ||
27 | { | ||
28 | if (rds_users) | ||
29 | return -EBUSY; | ||
30 | |||
31 | lock_kernel(); | ||
32 | rds_users++; | ||
33 | if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) { | ||
34 | rds_users--; | ||
35 | printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n"); | ||
36 | unlock_kernel(); | ||
37 | return -ENOMEM; | ||
38 | } | ||
39 | |||
40 | unlock_kernel(); | ||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | static int rds_f_release(struct inode *in, struct file *fi) | ||
45 | { | ||
46 | kfree(text_buffer); | ||
47 | |||
48 | rds_users--; | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static void print_matrix(char *ch, char out[]) | ||
53 | { | ||
54 | int j; | ||
55 | |||
56 | for (j=7; j>=0; j--) { | ||
57 | out[7-j] = ((*ch >> j) & 0x1) + '0'; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | static ssize_t rds_f_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) | ||
62 | { | ||
63 | // i = sprintf(text_buffer, "length: %d, offset: %d\n", length, *offset); | ||
64 | |||
65 | char c; | ||
66 | char bits[8]; | ||
67 | |||
68 | msleep(2000); | ||
69 | aci_rds_cmd(RDS_STATUS, &c, 1); | ||
70 | print_matrix(&c, bits); | ||
71 | if (copy_to_user(buffer, bits, 8)) | ||
72 | return -EFAULT; | ||
73 | |||
74 | /* if ((c >> 3) & 1) { | ||
75 | aci_rds_cmd(RDS_STATIONNAME, text_buffer+1, 8); | ||
76 | text_buffer[0] = ' ' ; | ||
77 | text_buffer[9] = '\n'; | ||
78 | return copy_to_user(buffer+8, text_buffer, 10) ? -EFAULT: 18; | ||
79 | } | ||
80 | */ | ||
81 | /* if ((c >> 6) & 1) { | ||
82 | aci_rds_cmd(RDS_PTYTATP, &c, 1); | ||
83 | if ( c & 1) | ||
84 | sprintf(text_buffer, " M"); | ||
85 | else | ||
86 | sprintf(text_buffer, " S"); | ||
87 | if ((c >> 1) & 1) | ||
88 | sprintf(text_buffer+2, " TA"); | ||
89 | else | ||
90 | sprintf(text_buffer+2, " --"); | ||
91 | if ((c >> 7) & 1) | ||
92 | sprintf(text_buffer+5, " TP"); | ||
93 | else | ||
94 | sprintf(text_buffer+5, " --"); | ||
95 | sprintf(text_buffer+8, " %2d\n", (c >> 2) & 0x1f); | ||
96 | return copy_to_user(buffer+8, text_buffer, 12) ? -EFAULT: 20; | ||
97 | } | ||
98 | */ | ||
99 | |||
100 | if ((c >> 4) & 1) { | ||
101 | aci_rds_cmd(RDS_TEXT, text_buffer, 65); | ||
102 | text_buffer[0] = ' ' ; | ||
103 | text_buffer[65] = '\n'; | ||
104 | return copy_to_user(buffer+8, text_buffer,66) ? -EFAULT : 66+8; | ||
105 | } else { | ||
106 | put_user('\n', buffer+8); | ||
107 | return 9; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | static const struct file_operations rds_fops = { | ||
112 | .owner = THIS_MODULE, | ||
113 | .read = rds_f_read, | ||
114 | .open = rds_f_open, | ||
115 | .release = rds_f_release | ||
116 | }; | ||
117 | |||
118 | static struct miscdevice rds_miscdev = { | ||
119 | .minor = MISC_DYNAMIC_MINOR, | ||
120 | .name = "radiotext", | ||
121 | .fops = &rds_fops, | ||
122 | }; | ||
123 | |||
124 | static int __init miropcm20_rds_init(void) | ||
125 | { | ||
126 | return misc_register(&rds_miscdev); | ||
127 | } | ||
128 | |||
129 | static void __exit miropcm20_rds_cleanup(void) | ||
130 | { | ||
131 | misc_deregister(&rds_miscdev); | ||
132 | } | ||
133 | |||
134 | module_init(miropcm20_rds_init); | ||
135 | module_exit(miropcm20_rds_cleanup); | ||
136 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index eba9209b3024..1f064f4b32df 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
@@ -426,8 +426,7 @@ static int __init rtrack_init(void) | |||
426 | 426 | ||
427 | rtrack_radio.priv=&rtrack_unit; | 427 | rtrack_radio.priv=&rtrack_unit; |
428 | 428 | ||
429 | if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr)==-1) | 429 | if (video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
430 | { | ||
431 | release_region(io, 2); | 430 | release_region(io, 2); |
432 | return -EINVAL; | 431 | return -EINVAL; |
433 | } | 432 | } |
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 3fe5504428c5..628c689e3ffe 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c | |||
@@ -394,8 +394,7 @@ static int __init aztech_init(void) | |||
394 | mutex_init(&lock); | 394 | mutex_init(&lock); |
395 | aztech_radio.priv=&aztech_unit; | 395 | aztech_radio.priv=&aztech_unit; |
396 | 396 | ||
397 | if(video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr)==-1) | 397 | if (video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
398 | { | ||
399 | release_region(io,2); | 398 | release_region(io,2); |
400 | return -EINVAL; | 399 | return -EINVAL; |
401 | } | 400 | } |
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 6166e726ed72..04c3698d32e4 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c | |||
@@ -682,7 +682,7 @@ static int __init cadet_init(void) | |||
682 | } | 682 | } |
683 | if (!request_region(io,2,"cadet")) | 683 | if (!request_region(io,2,"cadet")) |
684 | goto fail; | 684 | goto fail; |
685 | if(video_register_device(&cadet_radio,VFL_TYPE_RADIO,radio_nr)==-1) { | 685 | if (video_register_device(&cadet_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
686 | release_region(io,2); | 686 | release_region(io,2); |
687 | goto fail; | 687 | goto fail; |
688 | } | 688 | } |
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index 36e754e3ffb2..5cd7f032298d 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c | |||
@@ -425,7 +425,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci | |||
425 | } | 425 | } |
426 | *devradio = vdev_template; | 426 | *devradio = vdev_template; |
427 | 427 | ||
428 | if ( video_register_device( devradio, VFL_TYPE_RADIO , nr_radio) == -1 ) { | 428 | if (video_register_device(devradio, VFL_TYPE_RADIO, nr_radio) < 0) { |
429 | kfree( devradio ); | 429 | kfree( devradio ); |
430 | goto err_video; | 430 | goto err_video; |
431 | } | 431 | } |
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index 2b1a6221de6d..0a0f956bb308 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c | |||
@@ -612,8 +612,7 @@ static int __init gemtek_init(void) | |||
612 | 612 | ||
613 | gemtek_radio.priv = &gemtek_unit; | 613 | gemtek_radio.priv = &gemtek_unit; |
614 | 614 | ||
615 | if (video_register_device(&gemtek_radio, VFL_TYPE_RADIO, | 615 | if (video_register_device(&gemtek_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
616 | radio_nr) == -1) { | ||
617 | release_region(io, 1); | 616 | release_region(io, 1); |
618 | return -EBUSY; | 617 | return -EBUSY; |
619 | } | 618 | } |
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index 0ada1c697e8a..9ef0a763eeb7 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
@@ -409,8 +409,7 @@ static int __devinit maestro_probe(struct pci_dev *pdev, | |||
409 | video_set_drvdata(maestro_radio_inst, radio_unit); | 409 | video_set_drvdata(maestro_radio_inst, radio_unit); |
410 | pci_set_drvdata(pdev, maestro_radio_inst); | 410 | pci_set_drvdata(pdev, maestro_radio_inst); |
411 | 411 | ||
412 | retval = video_register_device(maestro_radio_inst, VFL_TYPE_RADIO, | 412 | retval = video_register_device(maestro_radio_inst, VFL_TYPE_RADIO, radio_nr); |
413 | radio_nr); | ||
414 | if (retval) { | 413 | if (retval) { |
415 | printk(KERN_ERR "can't register video device!\n"); | 414 | printk(KERN_ERR "can't register video device!\n"); |
416 | goto errfr1; | 415 | goto errfr1; |
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 43c75497dc49..0cc6fcb041fd 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -156,28 +156,28 @@ static void set_freq(__u16 io, __u32 freq) | |||
156 | { | 156 | { |
157 | unsigned long int si; | 157 | unsigned long int si; |
158 | int bl; | 158 | int bl; |
159 | int data = FREQ2BITS(freq); | 159 | int val = FREQ2BITS(freq); |
160 | 160 | ||
161 | /* TEA5757 shift register bits (see pdf) */ | 161 | /* TEA5757 shift register bits (see pdf) */ |
162 | 162 | ||
163 | outbit(0,io); // 24 search | 163 | outbit(0, io); /* 24 search */ |
164 | outbit(1,io); // 23 search up/down | 164 | outbit(1, io); /* 23 search up/down */ |
165 | 165 | ||
166 | outbit(0,io); // 22 stereo/mono | 166 | outbit(0, io); /* 22 stereo/mono */ |
167 | 167 | ||
168 | outbit(0,io); // 21 band | 168 | outbit(0, io); /* 21 band */ |
169 | outbit(0,io); // 20 band (only 00=FM works I think) | 169 | outbit(0, io); /* 20 band (only 00=FM works I think) */ |
170 | 170 | ||
171 | outbit(0,io); // 19 port ? | 171 | outbit(0, io); /* 19 port ? */ |
172 | outbit(0,io); // 18 port ? | 172 | outbit(0, io); /* 18 port ? */ |
173 | 173 | ||
174 | outbit(0,io); // 17 search level | 174 | outbit(0, io); /* 17 search level */ |
175 | outbit(0,io); // 16 search level | 175 | outbit(0, io); /* 16 search level */ |
176 | 176 | ||
177 | si = 0x8000; | 177 | si = 0x8000; |
178 | for (bl = 1; bl <= 16 ; bl++) { | 178 | for (bl = 1; bl <= 16; bl++) { |
179 | outbit(data & si,io); | 179 | outbit(val & si, io); |
180 | si >>=1; | 180 | si >>= 1; |
181 | } | 181 | } |
182 | 182 | ||
183 | dprintk(1, "Radio freq set to %d.%02d MHz\n", | 183 | dprintk(1, "Radio freq set to %d.%02d MHz\n", |
@@ -410,7 +410,7 @@ static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d | |||
410 | mutex_init(&radio_unit.lock); | 410 | mutex_init(&radio_unit.lock); |
411 | maxiradio_radio.priv = &radio_unit; | 411 | maxiradio_radio.priv = &radio_unit; |
412 | 412 | ||
413 | if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr)==-1) { | 413 | if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
414 | printk("radio-maxiradio: can't register device!"); | 414 | printk("radio-maxiradio: can't register device!"); |
415 | goto err_out_free_region; | 415 | goto err_out_free_region; |
416 | } | 416 | } |
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index e2dde0807268..6d820e2481e7 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c | |||
@@ -332,8 +332,7 @@ static int __init rtrack2_init(void) | |||
332 | rtrack2_radio.priv=&rtrack2_unit; | 332 | rtrack2_radio.priv=&rtrack2_unit; |
333 | 333 | ||
334 | spin_lock_init(&lock); | 334 | spin_lock_init(&lock); |
335 | if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr)==-1) | 335 | if (video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
336 | { | ||
337 | release_region(io, 4); | 336 | release_region(io, 4); |
338 | return -EINVAL; | 337 | return -EINVAL; |
339 | } | 338 | } |
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index bb5d92f104af..0d478f54a907 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -377,7 +377,7 @@ static int __init fmi_init(void) | |||
377 | 377 | ||
378 | mutex_init(&lock); | 378 | mutex_init(&lock); |
379 | 379 | ||
380 | if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) == -1) { | 380 | if (video_register_device(&fmi_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
381 | release_region(io, 2); | 381 | release_region(io, 2); |
382 | return -EINVAL; | 382 | return -EINVAL; |
383 | } | 383 | } |
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index a4984ff87c9c..16c7ef20265c 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -1694,8 +1694,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1694 | INIT_DELAYED_WORK(&radio->work, si470x_work); | 1694 | INIT_DELAYED_WORK(&radio->work, si470x_work); |
1695 | 1695 | ||
1696 | /* register video device */ | 1696 | /* register video device */ |
1697 | if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) { | 1697 | retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); |
1698 | retval = -EIO; | 1698 | if (retval) { |
1699 | printk(KERN_WARNING DRIVER_NAME | 1699 | printk(KERN_WARNING DRIVER_NAME |
1700 | ": Could not register video device\n"); | 1700 | ": Could not register video device\n"); |
1701 | goto err_all; | 1701 | goto err_all; |
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index cefa44fc5aed..0876fecc5f27 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c | |||
@@ -405,8 +405,7 @@ static int __init terratec_init(void) | |||
405 | 405 | ||
406 | spin_lock_init(&lock); | 406 | spin_lock_init(&lock); |
407 | 407 | ||
408 | if(video_register_device(&terratec_radio, VFL_TYPE_RADIO, radio_nr)==-1) | 408 | if (video_register_device(&terratec_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
409 | { | ||
410 | release_region(io,2); | 409 | release_region(io,2); |
411 | return -EINVAL; | 410 | return -EINVAL; |
412 | } | 411 | } |
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c index d70172d23edb..193161956253 100644 --- a/drivers/media/radio/radio-trust.c +++ b/drivers/media/radio/radio-trust.c | |||
@@ -378,8 +378,7 @@ static int __init trust_init(void) | |||
378 | printk(KERN_ERR "trust: port 0x%x already in use\n", io); | 378 | printk(KERN_ERR "trust: port 0x%x already in use\n", io); |
379 | return -EBUSY; | 379 | return -EBUSY; |
380 | } | 380 | } |
381 | if(video_register_device(&trust_radio, VFL_TYPE_RADIO, radio_nr)==-1) | 381 | if (video_register_device(&trust_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
382 | { | ||
383 | release_region(io, 2); | 382 | release_region(io, 2); |
384 | return -EINVAL; | 383 | return -EINVAL; |
385 | } | 384 | } |
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 9f17a332fa11..51d57ed3b3e1 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -446,8 +446,7 @@ static int __init zoltrix_init(void) | |||
446 | return -EBUSY; | 446 | return -EBUSY; |
447 | } | 447 | } |
448 | 448 | ||
449 | if (video_register_device(&zoltrix_radio, VFL_TYPE_RADIO, radio_nr) == -1) | 449 | if (video_register_device(&zoltrix_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
450 | { | ||
451 | release_region(io, 2); | 450 | release_region(io, 2); |
452 | return -EINVAL; | 451 | return -EINVAL; |
453 | } | 452 | } |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index bbc6f8b82297..ef7c8d3ffb18 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -20,6 +20,8 @@ ifeq ($(CONFIG_VIDEO_V4L1_COMPAT),y) | |||
20 | obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o | 20 | obj-$(CONFIG_VIDEO_DEV) += v4l1-compat.o |
21 | endif | 21 | endif |
22 | 22 | ||
23 | obj-$(CONFIG_VIDEO_TUNER) += tuner.o | ||
24 | |||
23 | obj-$(CONFIG_VIDEO_BT848) += bt8xx/ | 25 | obj-$(CONFIG_VIDEO_BT848) += bt8xx/ |
24 | obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o | 26 | obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o |
25 | obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o | 27 | obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o |
@@ -85,8 +87,6 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o | |||
85 | obj-$(CONFIG_VIDEO_DPC) += dpc7146.o | 87 | obj-$(CONFIG_VIDEO_DPC) += dpc7146.o |
86 | obj-$(CONFIG_TUNER_3036) += tuner-3036.o | 88 | obj-$(CONFIG_TUNER_3036) += tuner-3036.o |
87 | 89 | ||
88 | obj-$(CONFIG_VIDEO_TUNER) += tuner.o | ||
89 | |||
90 | obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o | 90 | obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o |
91 | obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o | 91 | obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o |
92 | obj-$(CONFIG_VIDEOBUF_DMA_CONTIG) += videobuf-dma-contig.o | 92 | obj-$(CONFIG_VIDEOBUF_DMA_CONTIG) += videobuf-dma-contig.o |
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig index ed9a50f189fc..018f72b8e3e2 100644 --- a/drivers/media/video/au0828/Kconfig +++ b/drivers/media/video/au0828/Kconfig | |||
@@ -7,6 +7,7 @@ config VIDEO_AU0828 | |||
7 | select DVB_AU8522 if !DVB_FE_CUSTOMIZE | 7 | select DVB_AU8522 if !DVB_FE_CUSTOMIZE |
8 | select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE | 8 | select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE |
9 | select MEDIA_TUNER_MXL5007T if !DVB_FE_CUSTOMIZE | 9 | select MEDIA_TUNER_MXL5007T if !DVB_FE_CUSTOMIZE |
10 | select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE | ||
10 | ---help--- | 11 | ---help--- |
11 | This is a video4linux driver for Auvitek's USB device. | 12 | This is a video4linux driver for Auvitek's USB device. |
12 | 13 | ||
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index 443e59009762..ed48908a9034 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek USB bridge | 2 | * Driver for the Auvitek USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -38,6 +38,9 @@ struct au0828_board au0828_boards[] = { | |||
38 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { | 38 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { |
39 | .name = "DViCO FusionHDTV USB", | 39 | .name = "DViCO FusionHDTV USB", |
40 | }, | 40 | }, |
41 | [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { | ||
42 | .name = "Hauppauge Woodbury", | ||
43 | }, | ||
41 | }; | 44 | }; |
42 | 45 | ||
43 | /* Tuner callback function for au0828 boards. Currently only needed | 46 | /* Tuner callback function for au0828 boards. Currently only needed |
@@ -115,6 +118,7 @@ void au0828_card_setup(struct au0828_dev *dev) | |||
115 | case AU0828_BOARD_HAUPPAUGE_HVR850: | 118 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
116 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | 119 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
117 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: | 120 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
121 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: | ||
118 | if (dev->i2c_rc == 0) | 122 | if (dev->i2c_rc == 0) |
119 | hauppauge_eeprom(dev, eeprom+0xa0); | 123 | hauppauge_eeprom(dev, eeprom+0xa0); |
120 | break; | 124 | break; |
@@ -134,6 +138,7 @@ void au0828_gpio_setup(struct au0828_dev *dev) | |||
134 | case AU0828_BOARD_HAUPPAUGE_HVR850: | 138 | case AU0828_BOARD_HAUPPAUGE_HVR850: |
135 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | 139 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: |
136 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: | 140 | case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL: |
141 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: | ||
137 | /* GPIO's | 142 | /* GPIO's |
138 | * 4 - CS5340 | 143 | * 4 - CS5340 |
139 | * 5 - AU8522 Demodulator | 144 | * 5 - AU8522 Demodulator |
@@ -205,6 +210,8 @@ struct usb_device_id au0828_usb_id_table [] = { | |||
205 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, | 210 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, |
206 | { USB_DEVICE(0x2040, 0x7281), | 211 | { USB_DEVICE(0x2040, 0x7281), |
207 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, | 212 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL }, |
213 | { USB_DEVICE(0x2040, 0x8200), | ||
214 | .driver_info = AU0828_BOARD_HAUPPAUGE_WOODBURY }, | ||
208 | { }, | 215 | { }, |
209 | }; | 216 | }; |
210 | 217 | ||
diff --git a/drivers/media/video/au0828/au0828-cards.h b/drivers/media/video/au0828/au0828-cards.h index c37f5fd0fa80..48a1882c2b6b 100644 --- a/drivers/media/video/au0828/au0828-cards.h +++ b/drivers/media/video/au0828/au0828-cards.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek USB bridge | 2 | * Driver for the Auvitek USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -24,3 +24,4 @@ | |||
24 | #define AU0828_BOARD_HAUPPAUGE_HVR850 2 | 24 | #define AU0828_BOARD_HAUPPAUGE_HVR850 2 |
25 | #define AU0828_BOARD_DVICO_FUSIONHDTV7 3 | 25 | #define AU0828_BOARD_DVICO_FUSIONHDTV7 3 |
26 | #define AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL 4 | 26 | #define AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL 4 |
27 | #define AU0828_BOARD_HAUPPAUGE_WOODBURY 5 | ||
diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c index 54bfc0f05295..d856de9f742f 100644 --- a/drivers/media/video/au0828/au0828-core.c +++ b/drivers/media/video/au0828/au0828-core.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek USB bridge | 2 | * Driver for the Auvitek USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -252,5 +252,5 @@ module_init(au0828_init); | |||
252 | module_exit(au0828_exit); | 252 | module_exit(au0828_exit); |
253 | 253 | ||
254 | MODULE_DESCRIPTION("Driver for Auvitek AU0828 based products"); | 254 | MODULE_DESCRIPTION("Driver for Auvitek AU0828 based products"); |
255 | MODULE_AUTHOR("Steven Toth <stoth@hauppauge.com>"); | 255 | MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); |
256 | MODULE_LICENSE("GPL"); | 256 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c index 584a83a94a2a..ba94be7e0ac1 100644 --- a/drivers/media/video/au0828/au0828-dvb.c +++ b/drivers/media/video/au0828/au0828-dvb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek USB bridge | 2 | * Driver for the Auvitek USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -29,6 +29,7 @@ | |||
29 | #include "au8522.h" | 29 | #include "au8522.h" |
30 | #include "xc5000.h" | 30 | #include "xc5000.h" |
31 | #include "mxl5007t.h" | 31 | #include "mxl5007t.h" |
32 | #include "tda18271.h" | ||
32 | 33 | ||
33 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 34 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
34 | 35 | ||
@@ -38,6 +39,15 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
38 | static struct au8522_config hauppauge_hvr950q_config = { | 39 | static struct au8522_config hauppauge_hvr950q_config = { |
39 | .demod_address = 0x8e >> 1, | 40 | .demod_address = 0x8e >> 1, |
40 | .status_mode = AU8522_DEMODLOCKING, | 41 | .status_mode = AU8522_DEMODLOCKING, |
42 | .qam_if = AU8522_IF_6MHZ, | ||
43 | .vsb_if = AU8522_IF_6MHZ, | ||
44 | }; | ||
45 | |||
46 | static struct au8522_config hauppauge_woodbury_config = { | ||
47 | .demod_address = 0x8e >> 1, | ||
48 | .status_mode = AU8522_DEMODLOCKING, | ||
49 | .qam_if = AU8522_IF_4MHZ, | ||
50 | .vsb_if = AU8522_IF_3_25MHZ, | ||
41 | }; | 51 | }; |
42 | 52 | ||
43 | static struct xc5000_config hauppauge_hvr950q_tunerconfig = { | 53 | static struct xc5000_config hauppauge_hvr950q_tunerconfig = { |
@@ -51,6 +61,10 @@ static struct mxl5007t_config mxl5007t_hvr950q_config = { | |||
51 | .if_freq_hz = MxL_IF_6_MHZ, | 61 | .if_freq_hz = MxL_IF_6_MHZ, |
52 | }; | 62 | }; |
53 | 63 | ||
64 | static struct tda18271_config hauppauge_woodbury_tunerconfig = { | ||
65 | .gate = TDA18271_GATE_DIGITAL, | ||
66 | }; | ||
67 | |||
54 | /*-------------------------------------------------------------------*/ | 68 | /*-------------------------------------------------------------------*/ |
55 | static void urb_completion(struct urb *purb) | 69 | static void urb_completion(struct urb *purb) |
56 | { | 70 | { |
@@ -357,6 +371,15 @@ int au0828_dvb_register(struct au0828_dev *dev) | |||
357 | &dev->i2c_adap, 0x60, | 371 | &dev->i2c_adap, 0x60, |
358 | &mxl5007t_hvr950q_config); | 372 | &mxl5007t_hvr950q_config); |
359 | break; | 373 | break; |
374 | case AU0828_BOARD_HAUPPAUGE_WOODBURY: | ||
375 | dvb->frontend = dvb_attach(au8522_attach, | ||
376 | &hauppauge_woodbury_config, | ||
377 | &dev->i2c_adap); | ||
378 | if (dvb->frontend != NULL) | ||
379 | dvb_attach(tda18271_attach, dvb->frontend, | ||
380 | 0x60, &dev->i2c_adap, | ||
381 | &hauppauge_woodbury_tunerconfig); | ||
382 | break; | ||
360 | default: | 383 | default: |
361 | printk(KERN_WARNING "The frontend of your DVB/ATSC card " | 384 | printk(KERN_WARNING "The frontend of your DVB/ATSC card " |
362 | "isn't supported yet\n"); | 385 | "isn't supported yet\n"); |
diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c index 741a4937b050..d618fbaade1b 100644 --- a/drivers/media/video/au0828/au0828-i2c.c +++ b/drivers/media/video/au0828/au0828-i2c.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek AU0828 USB bridge | 2 | * Driver for the Auvitek AU0828 USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/au0828/au0828-reg.h b/drivers/media/video/au0828/au0828-reg.h index 39827550891c..1e87fa0c6842 100644 --- a/drivers/media/video/au0828/au0828-reg.h +++ b/drivers/media/video/au0828/au0828-reg.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek USB bridge | 2 | * Driver for the Auvitek USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h index 7beb571798e5..4f10ff300135 100644 --- a/drivers/media/video/au0828/au0828.h +++ b/drivers/media/video/au0828/au0828.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Auvitek AU0828 USB bridge | 2 | * Driver for the Auvitek AU0828 USB bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 1c56ae92ce74..6081edc362df 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c | |||
@@ -3144,8 +3144,9 @@ static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) | |||
3144 | 3144 | ||
3145 | static void flyvideo_gpio(struct bttv *btv) | 3145 | static void flyvideo_gpio(struct bttv *btv) |
3146 | { | 3146 | { |
3147 | int gpio,has_remote,has_radio,is_capture_only,is_lr90,has_tda9820_tda9821; | 3147 | int gpio, has_remote, has_radio, is_capture_only; |
3148 | int tuner=UNSET,ttype; | 3148 | int is_lr90, has_tda9820_tda9821; |
3149 | int tuner_type = UNSET, ttype; | ||
3149 | 3150 | ||
3150 | gpio_inout(0xffffff, 0); | 3151 | gpio_inout(0xffffff, 0); |
3151 | udelay(8); /* without this we would see the 0x1800 mask */ | 3152 | udelay(8); /* without this we would see the 0x1800 mask */ |
@@ -3163,20 +3164,26 @@ static void flyvideo_gpio(struct bttv *btv) | |||
3163 | * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered | 3164 | * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered |
3164 | * Note: Some bits are Audio_Mask ! | 3165 | * Note: Some bits are Audio_Mask ! |
3165 | */ | 3166 | */ |
3166 | ttype=(gpio&0x0f0000)>>16; | 3167 | ttype = (gpio & 0x0f0000) >> 16; |
3167 | switch(ttype) { | 3168 | switch (ttype) { |
3168 | case 0x0: tuner=2; /* NTSC, e.g. TPI8NSR11P */ | 3169 | case 0x0: |
3170 | tuner_type = 2; /* NTSC, e.g. TPI8NSR11P */ | ||
3169 | break; | 3171 | break; |
3170 | case 0x2: tuner=39;/* LG NTSC (newer TAPC series) TAPC-H701P */ | 3172 | case 0x2: |
3173 | tuner_type = 39; /* LG NTSC (newer TAPC series) TAPC-H701P */ | ||
3171 | break; | 3174 | break; |
3172 | case 0x4: tuner=5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ | 3175 | case 0x4: |
3176 | tuner_type = 5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ | ||
3173 | break; | 3177 | break; |
3174 | case 0x6: tuner=37;/* LG PAL (newer TAPC series) TAPC-G702P */ | 3178 | case 0x6: |
3179 | tuner_type = 37; /* LG PAL (newer TAPC series) TAPC-G702P */ | ||
3175 | break; | 3180 | break; |
3176 | case 0xC: tuner=3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ | 3181 | case 0xC: |
3182 | tuner_type = 3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ | ||
3177 | break; | 3183 | break; |
3178 | default: | 3184 | default: |
3179 | printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr); | 3185 | printk(KERN_INFO "bttv%d: FlyVideo_gpio: unknown tuner type.\n", btv->c.nr); |
3186 | break; | ||
3180 | } | 3187 | } |
3181 | 3188 | ||
3182 | has_remote = gpio & 0x800000; | 3189 | has_remote = gpio & 0x800000; |
@@ -3189,23 +3196,26 @@ static void flyvideo_gpio(struct bttv *btv) | |||
3189 | /* | 3196 | /* |
3190 | * gpio & 0x001000 output bit for audio routing */ | 3197 | * gpio & 0x001000 output bit for audio routing */ |
3191 | 3198 | ||
3192 | if(is_capture_only) | 3199 | if (is_capture_only) |
3193 | tuner = TUNER_ABSENT; /* No tuner present */ | 3200 | tuner_type = TUNER_ABSENT; /* No tuner present */ |
3194 | 3201 | ||
3195 | printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", | 3202 | printk(KERN_INFO "bttv%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", |
3196 | btv->c.nr, has_radio? "yes":"no ", has_remote? "yes":"no ", tuner, gpio); | 3203 | btv->c.nr, has_radio ? "yes" : "no ", |
3204 | has_remote ? "yes" : "no ", tuner_type, gpio); | ||
3197 | printk(KERN_INFO "bttv%d: FlyVideo LR90=%s tda9821/tda9820=%s capture_only=%s\n", | 3205 | printk(KERN_INFO "bttv%d: FlyVideo LR90=%s tda9821/tda9820=%s capture_only=%s\n", |
3198 | btv->c.nr, is_lr90?"yes":"no ", has_tda9820_tda9821?"yes":"no ", | 3206 | btv->c.nr, is_lr90 ? "yes" : "no ", |
3199 | is_capture_only?"yes":"no "); | 3207 | has_tda9820_tda9821 ? "yes" : "no ", |
3208 | is_capture_only ? "yes" : "no "); | ||
3200 | 3209 | ||
3201 | if (tuner != UNSET) /* only set if known tuner autodetected, else let insmod option through */ | 3210 | if (tuner_type != UNSET) /* only set if known tuner autodetected, else let insmod option through */ |
3202 | btv->tuner_type = tuner; | 3211 | btv->tuner_type = tuner_type; |
3203 | btv->has_radio = has_radio; | 3212 | btv->has_radio = has_radio; |
3204 | 3213 | ||
3205 | /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 | 3214 | /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 |
3206 | * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 | 3215 | * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 |
3207 | * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ | 3216 | * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ |
3208 | if(has_tda9820_tda9821) btv->audio_mode_gpio = lt9415_audio; | 3217 | if (has_tda9820_tda9821) |
3218 | btv->audio_mode_gpio = lt9415_audio; | ||
3209 | /* todo: if(has_tda9874) btv->audio_mode_gpio = fv2000s_audio; */ | 3219 | /* todo: if(has_tda9874) btv->audio_mode_gpio = fv2000s_audio; */ |
3210 | } | 3220 | } |
3211 | 3221 | ||
@@ -3962,7 +3972,7 @@ static int tuner_1_table[] = { | |||
3962 | 3972 | ||
3963 | static void __devinit avermedia_eeprom(struct bttv *btv) | 3973 | static void __devinit avermedia_eeprom(struct bttv *btv) |
3964 | { | 3974 | { |
3965 | int tuner_make,tuner_tv_fm,tuner_format,tuner=0; | 3975 | int tuner_make, tuner_tv_fm, tuner_format, tuner_type = 0; |
3966 | 3976 | ||
3967 | tuner_make = (eeprom_data[0x41] & 0x7); | 3977 | tuner_make = (eeprom_data[0x41] & 0x7); |
3968 | tuner_tv_fm = (eeprom_data[0x41] & 0x18) >> 3; | 3978 | tuner_tv_fm = (eeprom_data[0x41] & 0x18) >> 3; |
@@ -3970,24 +3980,24 @@ static void __devinit avermedia_eeprom(struct bttv *btv) | |||
3970 | btv->has_remote = (eeprom_data[0x42] & 0x01); | 3980 | btv->has_remote = (eeprom_data[0x42] & 0x01); |
3971 | 3981 | ||
3972 | if (tuner_make == 0 || tuner_make == 2) | 3982 | if (tuner_make == 0 || tuner_make == 2) |
3973 | if(tuner_format <=0x0a) | 3983 | if (tuner_format <= 0x0a) |
3974 | tuner = tuner_0_table[tuner_format]; | 3984 | tuner_type = tuner_0_table[tuner_format]; |
3975 | if (tuner_make == 1) | 3985 | if (tuner_make == 1) |
3976 | if(tuner_format <=9) | 3986 | if (tuner_format <= 9) |
3977 | tuner = tuner_1_table[tuner_format]; | 3987 | tuner_type = tuner_1_table[tuner_format]; |
3978 | 3988 | ||
3979 | if (tuner_make == 4) | 3989 | if (tuner_make == 4) |
3980 | if(tuner_format == 0x09) | 3990 | if (tuner_format == 0x09) |
3981 | tuner = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ | 3991 | tuner_type = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ |
3982 | 3992 | ||
3983 | printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=", | 3993 | printk(KERN_INFO "bttv%d: Avermedia eeprom[0x%02x%02x]: tuner=", |
3984 | btv->c.nr,eeprom_data[0x41],eeprom_data[0x42]); | 3994 | btv->c.nr, eeprom_data[0x41], eeprom_data[0x42]); |
3985 | if(tuner) { | 3995 | if (tuner_type) { |
3986 | btv->tuner_type=tuner; | 3996 | btv->tuner_type = tuner_type; |
3987 | printk("%d",tuner); | 3997 | printk(KERN_CONT "%d", tuner_type); |
3988 | } else | 3998 | } else |
3989 | printk("Unknown type"); | 3999 | printk(KERN_CONT "Unknown type"); |
3990 | printk(" radio:%s remote control:%s\n", | 4000 | printk(KERN_CONT " radio:%s remote control:%s\n", |
3991 | tuner_tv_fm ? "yes" : "no", | 4001 | tuner_tv_fm ? "yes" : "no", |
3992 | btv->has_remote ? "yes" : "no"); | 4002 | btv->has_remote ? "yes" : "no"); |
3993 | } | 4003 | } |
@@ -4029,7 +4039,8 @@ static void __devinit boot_msp34xx(struct bttv *btv, int pin) | |||
4029 | 4039 | ||
4030 | gpio_inout(mask,mask); | 4040 | gpio_inout(mask,mask); |
4031 | gpio_bits(mask,0); | 4041 | gpio_bits(mask,0); |
4032 | udelay(2500); | 4042 | mdelay(2); |
4043 | udelay(500); | ||
4033 | gpio_bits(mask,mask); | 4044 | gpio_bits(mask,mask); |
4034 | 4045 | ||
4035 | if (bttv_gpio) | 4046 | if (bttv_gpio) |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 85bf31ab8789..6ae4cc860efe 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -96,7 +96,6 @@ static unsigned int irq_iswitch; | |||
96 | static unsigned int uv_ratio = 50; | 96 | static unsigned int uv_ratio = 50; |
97 | static unsigned int full_luma_range; | 97 | static unsigned int full_luma_range; |
98 | static unsigned int coring; | 98 | static unsigned int coring; |
99 | extern int no_overlay; | ||
100 | 99 | ||
101 | /* API features (turn on/off stuff for testing) */ | 100 | /* API features (turn on/off stuff for testing) */ |
102 | static unsigned int v4l2 = 1; | 101 | static unsigned int v4l2 = 1; |
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c index 649682aac1ac..5b1b8e4c78ba 100644 --- a/drivers/media/video/bt8xx/bttv-risc.c +++ b/drivers/media/video/bt8xx/bttv-risc.c | |||
@@ -244,7 +244,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | |||
244 | const struct bttv_format *fmt, struct bttv_overlay *ov, | 244 | const struct bttv_format *fmt, struct bttv_overlay *ov, |
245 | int skip_even, int skip_odd) | 245 | int skip_even, int skip_odd) |
246 | { | 246 | { |
247 | int dwords,rc,line,maxy,start,end,skip,nskips; | 247 | int dwords, rc, line, maxy, start, end; |
248 | unsigned skip, nskips; | ||
248 | struct btcx_skiplist *skips; | 249 | struct btcx_skiplist *skips; |
249 | __le32 *rp; | 250 | __le32 *rp; |
250 | u32 ri,ra; | 251 | u32 ri,ra; |
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h index 08ef54a22c9e..b4d940b2e447 100644 --- a/drivers/media/video/bt8xx/bttvp.h +++ b/drivers/media/video/bt8xx/bttvp.h | |||
@@ -267,6 +267,11 @@ int bttv_sub_add_device(struct bttv_core *core, char *name); | |||
267 | int bttv_sub_del_devices(struct bttv_core *core); | 267 | int bttv_sub_del_devices(struct bttv_core *core); |
268 | 268 | ||
269 | /* ---------------------------------------------------------- */ | 269 | /* ---------------------------------------------------------- */ |
270 | /* bttv-cards.c */ | ||
271 | |||
272 | extern int no_overlay; | ||
273 | |||
274 | /* ---------------------------------------------------------- */ | ||
270 | /* bttv-driver.c */ | 275 | /* bttv-driver.c */ |
271 | 276 | ||
272 | /* insmod options */ | 277 | /* insmod options */ |
diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c index f42701f82e7f..3324ab38f58c 100644 --- a/drivers/media/video/btcx-risc.c +++ b/drivers/media/video/btcx-risc.c | |||
@@ -184,12 +184,12 @@ btcx_sort_clips(struct v4l2_clip *clips, unsigned int nclips) | |||
184 | } | 184 | } |
185 | 185 | ||
186 | void | 186 | void |
187 | btcx_calc_skips(int line, int width, unsigned int *maxy, | 187 | btcx_calc_skips(int line, int width, int *maxy, |
188 | struct btcx_skiplist *skips, unsigned int *nskips, | 188 | struct btcx_skiplist *skips, unsigned int *nskips, |
189 | const struct v4l2_clip *clips, unsigned int nclips) | 189 | const struct v4l2_clip *clips, unsigned int nclips) |
190 | { | 190 | { |
191 | unsigned int clip,skip; | 191 | unsigned int clip,skip; |
192 | int end,maxline; | 192 | int end, maxline; |
193 | 193 | ||
194 | skip=0; | 194 | skip=0; |
195 | maxline = 9999; | 195 | maxline = 9999; |
diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h index 861bc8112824..f8bc6e8e7b51 100644 --- a/drivers/media/video/btcx-risc.h +++ b/drivers/media/video/btcx-risc.h | |||
@@ -23,7 +23,7 @@ int btcx_screen_clips(int swidth, int sheight, struct v4l2_rect *win, | |||
23 | int btcx_align(struct v4l2_rect *win, struct v4l2_clip *clips, | 23 | int btcx_align(struct v4l2_rect *win, struct v4l2_clip *clips, |
24 | unsigned int n, int mask); | 24 | unsigned int n, int mask); |
25 | void btcx_sort_clips(struct v4l2_clip *clips, unsigned int nclips); | 25 | void btcx_sort_clips(struct v4l2_clip *clips, unsigned int nclips); |
26 | void btcx_calc_skips(int line, int width, unsigned int *maxy, | 26 | void btcx_calc_skips(int line, int width, int *maxy, |
27 | struct btcx_skiplist *skips, unsigned int *nskips, | 27 | struct btcx_skiplist *skips, unsigned int *nskips, |
28 | const struct v4l2_clip *clips, unsigned int nclips); | 28 | const struct v4l2_clip *clips, unsigned int nclips); |
29 | 29 | ||
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index d3b3268bace8..6e39e253ce53 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
@@ -946,8 +946,7 @@ static int init_bwqcam(struct parport *port) | |||
946 | 946 | ||
947 | printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name); | 947 | printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name); |
948 | 948 | ||
949 | if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) | 949 | if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
950 | { | ||
951 | parport_unregister_device(qcam->pdev); | 950 | parport_unregister_device(qcam->pdev); |
952 | kfree(qcam); | 951 | kfree(qcam); |
953 | return -ENODEV; | 952 | return -ENODEV; |
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c index fe9379b282d3..7f6c6b4bec10 100644 --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c | |||
@@ -787,8 +787,7 @@ static int init_cqcam(struct parport *port) | |||
787 | 787 | ||
788 | parport_release(qcam->pdev); | 788 | parport_release(qcam->pdev); |
789 | 789 | ||
790 | if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1) | 790 | if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
791 | { | ||
792 | printk(KERN_ERR "Unable to register Colour QuickCam on %s\n", | 791 | printk(KERN_ERR "Unable to register Colour QuickCam on %s\n", |
793 | qcam->pport->name); | 792 | qcam->pport->name); |
794 | parport_unregister_device(qcam->pdev); | 793 | parport_unregister_device(qcam->pdev); |
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index dc8cc6115e2f..a661800b0e69 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -3955,7 +3955,7 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve | |||
3955 | camera->lowlevel_data = lowlevel; | 3955 | camera->lowlevel_data = lowlevel; |
3956 | 3956 | ||
3957 | /* register v4l device */ | 3957 | /* register v4l device */ |
3958 | if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { | 3958 | if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
3959 | kfree(camera); | 3959 | kfree(camera); |
3960 | printk(KERN_DEBUG "video_register_device failed\n"); | 3960 | printk(KERN_DEBUG "video_register_device failed\n"); |
3961 | return NULL; | 3961 | return NULL; |
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 515c8b57a60d..eb9f15cd4c45 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
@@ -1024,7 +1024,6 @@ static int ioctl_queryctrl(void *arg,struct camera_data *cam) | |||
1024 | if(cam->params.pnp_id.device_type == DEVICE_STV_672 && | 1024 | if(cam->params.pnp_id.device_type == DEVICE_STV_672 && |
1025 | cam->params.version.sensor_flags==CPIA2_VP_SENSOR_FLAGS_500){ | 1025 | cam->params.version.sensor_flags==CPIA2_VP_SENSOR_FLAGS_500){ |
1026 | // Maximum 15fps | 1026 | // Maximum 15fps |
1027 | int i; | ||
1028 | for(i=0; i<c->maximum; ++i) { | 1027 | for(i=0; i<c->maximum; ++i) { |
1029 | if(framerate_controls[i].value == | 1028 | if(framerate_controls[i].value == |
1030 | CPIA2_VP_FRAMERATE_15) { | 1029 | CPIA2_VP_FRAMERATE_15) { |
@@ -1959,8 +1958,7 @@ int cpia2_register_camera(struct camera_data *cam) | |||
1959 | reset_camera_struct_v4l(cam); | 1958 | reset_camera_struct_v4l(cam); |
1960 | 1959 | ||
1961 | /* register v4l device */ | 1960 | /* register v4l device */ |
1962 | if (video_register_device | 1961 | if (video_register_device(cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
1963 | (cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { | ||
1964 | ERR("video_register_device failed\n"); | 1962 | ERR("video_register_device failed\n"); |
1965 | video_device_release(cam->vdev); | 1963 | video_device_release(cam->vdev); |
1966 | return -ENODEV; | 1964 | return -ENODEV; |
diff --git a/drivers/media/video/cx18/cx18-av-firmware.c b/drivers/media/video/cx18/cx18-av-firmware.c index 834b9248242e..e996a4e3123a 100644 --- a/drivers/media/video/cx18/cx18-av-firmware.c +++ b/drivers/media/video/cx18/cx18-av-firmware.c | |||
@@ -32,7 +32,7 @@ int cx18_av_loadfw(struct cx18 *cx) | |||
32 | u32 v; | 32 | u32 v; |
33 | const u8 *ptr; | 33 | const u8 *ptr; |
34 | int i; | 34 | int i; |
35 | int retries = 0; | 35 | int retries1 = 0; |
36 | 36 | ||
37 | if (request_firmware(&fw, FWFILE, &cx->dev->dev) != 0) { | 37 | if (request_firmware(&fw, FWFILE, &cx->dev->dev) != 0) { |
38 | CX18_ERR("unable to open firmware %s\n", FWFILE); | 38 | CX18_ERR("unable to open firmware %s\n", FWFILE); |
@@ -41,7 +41,7 @@ int cx18_av_loadfw(struct cx18 *cx) | |||
41 | 41 | ||
42 | /* The firmware load often has byte errors, so allow for several | 42 | /* The firmware load often has byte errors, so allow for several |
43 | retries, both at byte level and at the firmware load level. */ | 43 | retries, both at byte level and at the firmware load level. */ |
44 | while (retries < 5) { | 44 | while (retries1 < 5) { |
45 | cx18_av_write4(cx, CXADEC_CHIP_CTRL, 0x00010000); | 45 | cx18_av_write4(cx, CXADEC_CHIP_CTRL, 0x00010000); |
46 | cx18_av_write(cx, CXADEC_STD_DET_CTL, 0xf6); | 46 | cx18_av_write(cx, CXADEC_STD_DET_CTL, 0xf6); |
47 | 47 | ||
@@ -57,9 +57,9 @@ int cx18_av_loadfw(struct cx18 *cx) | |||
57 | for (i = 0; i < size; i++) { | 57 | for (i = 0; i < size; i++) { |
58 | u32 dl_control = 0x0F000000 | i | ((u32)ptr[i] << 16); | 58 | u32 dl_control = 0x0F000000 | i | ((u32)ptr[i] << 16); |
59 | u32 value = 0; | 59 | u32 value = 0; |
60 | int retries; | 60 | int retries2; |
61 | 61 | ||
62 | for (retries = 0; retries < 5; retries++) { | 62 | for (retries2 = 0; retries2 < 5; retries2++) { |
63 | cx18_av_write4(cx, CXADEC_DL_CTL, dl_control); | 63 | cx18_av_write4(cx, CXADEC_DL_CTL, dl_control); |
64 | udelay(10); | 64 | udelay(10); |
65 | value = cx18_av_read4(cx, CXADEC_DL_CTL); | 65 | value = cx18_av_read4(cx, CXADEC_DL_CTL); |
@@ -69,18 +69,18 @@ int cx18_av_loadfw(struct cx18 *cx) | |||
69 | the address. We can only write the lower | 69 | the address. We can only write the lower |
70 | address byte of the address. */ | 70 | address byte of the address. */ |
71 | if ((value & 0x3F00) != (dl_control & 0x3F00)) { | 71 | if ((value & 0x3F00) != (dl_control & 0x3F00)) { |
72 | retries = 5; | 72 | retries2 = 5; |
73 | break; | 73 | break; |
74 | } | 74 | } |
75 | } | 75 | } |
76 | if (retries >= 5) | 76 | if (retries2 >= 5) |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | if (i == size) | 79 | if (i == size) |
80 | break; | 80 | break; |
81 | retries++; | 81 | retries1++; |
82 | } | 82 | } |
83 | if (retries >= 5) { | 83 | if (retries1 >= 5) { |
84 | CX18_ERR("unable to load firmware %s\n", FWFILE); | 84 | CX18_ERR("unable to load firmware %s\n", FWFILE); |
85 | release_firmware(fw); | 85 | release_firmware(fw); |
86 | return -EIO; | 86 | return -EIO; |
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 22434aadde31..bd18afebbf86 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -74,9 +74,9 @@ static int radio[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, | |||
74 | -1, -1, -1, -1, -1, -1, -1, -1, | 74 | -1, -1, -1, -1, -1, -1, -1, -1, |
75 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 75 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
76 | 76 | ||
77 | static int cardtype_c = 1; | 77 | static unsigned cardtype_c = 1; |
78 | static int tuner_c = 1; | 78 | static unsigned tuner_c = 1; |
79 | static int radio_c = 1; | 79 | static unsigned radio_c = 1; |
80 | static char pal[] = "--"; | 80 | static char pal[] = "--"; |
81 | static char secam[] = "--"; | 81 | static char secam[] = "--"; |
82 | static char ntsc[] = "-"; | 82 | static char ntsc[] = "-"; |
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c index cae38985b131..1e420a804fc9 100644 --- a/drivers/media/video/cx18/cx18-dvb.c +++ b/drivers/media/video/cx18/cx18-dvb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * cx18 functions for DVB support | 2 | * cx18 functions for DVB support |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx18/cx18-dvb.h b/drivers/media/video/cx18/cx18-dvb.h index d6a6ccda79a9..bf8d8f6f5455 100644 --- a/drivers/media/video/cx18/cx18-dvb.h +++ b/drivers/media/video/cx18/cx18-dvb.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * cx18 functions for DVB support | 2 | * cx18 functions for DVB support |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2008 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx18/cx18-irq.c b/drivers/media/video/cx18/cx18-irq.c index 25114a5cbd57..ab218315c84b 100644 --- a/drivers/media/video/cx18/cx18-irq.c +++ b/drivers/media/video/cx18/cx18-irq.c | |||
@@ -61,7 +61,7 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb) | |||
61 | CX18_WARN("Ack struct = %d for %s\n", | 61 | CX18_WARN("Ack struct = %d for %s\n", |
62 | mb->args[2], s->name); | 62 | mb->args[2], s->name); |
63 | id = read_enc(off); | 63 | id = read_enc(off); |
64 | buf = cx18_queue_find_buf(s, id, read_enc(off + 4)); | 64 | buf = cx18_queue_get_buf_irq(s, id, read_enc(off + 4)); |
65 | CX18_DEBUG_HI_DMA("DMA DONE for %s (buffer %d)\n", s->name, id); | 65 | CX18_DEBUG_HI_DMA("DMA DONE for %s (buffer %d)\n", s->name, id); |
66 | if (buf) { | 66 | if (buf) { |
67 | cx18_buf_sync_for_cpu(s, buf); | 67 | cx18_buf_sync_for_cpu(s, buf); |
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c index 6990b77c6200..dbe792ac3001 100644 --- a/drivers/media/video/cx18/cx18-queue.c +++ b/drivers/media/video/cx18/cx18-queue.c | |||
@@ -78,12 +78,13 @@ struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q) | |||
78 | return buf; | 78 | return buf; |
79 | } | 79 | } |
80 | 80 | ||
81 | struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, | 81 | struct cx18_buffer *cx18_queue_get_buf_irq(struct cx18_stream *s, u32 id, |
82 | u32 bytesused) | 82 | u32 bytesused) |
83 | { | 83 | { |
84 | struct cx18 *cx = s->cx; | 84 | struct cx18 *cx = s->cx; |
85 | struct list_head *p; | 85 | struct list_head *p; |
86 | 86 | ||
87 | spin_lock(&s->qlock); | ||
87 | list_for_each(p, &s->q_free.list) { | 88 | list_for_each(p, &s->q_free.list) { |
88 | struct cx18_buffer *buf = | 89 | struct cx18_buffer *buf = |
89 | list_entry(p, struct cx18_buffer, list); | 90 | list_entry(p, struct cx18_buffer, list); |
@@ -92,114 +93,48 @@ struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, | |||
92 | continue; | 93 | continue; |
93 | buf->bytesused = bytesused; | 94 | buf->bytesused = bytesused; |
94 | /* the transport buffers are handled differently, | 95 | /* the transport buffers are handled differently, |
95 | so there is no need to move them to the full queue */ | 96 | they are not moved to the full queue */ |
96 | if (s->type == CX18_ENC_STREAM_TYPE_TS) | 97 | if (s->type != CX18_ENC_STREAM_TYPE_TS) { |
97 | return buf; | 98 | s->q_free.buffers--; |
98 | s->q_free.buffers--; | 99 | s->q_free.length -= s->buf_size; |
99 | s->q_free.length -= s->buf_size; | 100 | s->q_full.buffers++; |
100 | s->q_full.buffers++; | 101 | s->q_full.length += s->buf_size; |
101 | s->q_full.length += s->buf_size; | 102 | s->q_full.bytesused += buf->bytesused; |
102 | s->q_full.bytesused += buf->bytesused; | 103 | list_move_tail(&buf->list, &s->q_full.list); |
103 | list_move_tail(&buf->list, &s->q_full.list); | 104 | } |
105 | spin_unlock(&s->qlock); | ||
104 | return buf; | 106 | return buf; |
105 | } | 107 | } |
108 | spin_unlock(&s->qlock); | ||
106 | CX18_ERR("Cannot find buffer %d for stream %s\n", id, s->name); | 109 | CX18_ERR("Cannot find buffer %d for stream %s\n", id, s->name); |
107 | return NULL; | 110 | return NULL; |
108 | } | 111 | } |
109 | 112 | ||
110 | static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from, | 113 | /* Move all buffers of a queue to q_free, while flushing the buffers */ |
111 | struct cx18_queue *to, int clear, int full) | 114 | static void cx18_queue_flush(struct cx18_stream *s, struct cx18_queue *q) |
112 | { | ||
113 | struct cx18_buffer *buf = | ||
114 | list_entry(from->list.next, struct cx18_buffer, list); | ||
115 | |||
116 | list_move_tail(from->list.next, &to->list); | ||
117 | from->buffers--; | ||
118 | from->length -= s->buf_size; | ||
119 | from->bytesused -= buf->bytesused - buf->readpos; | ||
120 | /* special handling for q_free */ | ||
121 | if (clear) | ||
122 | buf->bytesused = buf->readpos = buf->b_flags = 0; | ||
123 | else if (full) { | ||
124 | /* special handling for stolen buffers, assume | ||
125 | all bytes are used. */ | ||
126 | buf->bytesused = s->buf_size; | ||
127 | buf->readpos = buf->b_flags = 0; | ||
128 | } | ||
129 | to->buffers++; | ||
130 | to->length += s->buf_size; | ||
131 | to->bytesused += buf->bytesused - buf->readpos; | ||
132 | } | ||
133 | |||
134 | /* Move 'needed_bytes' worth of buffers from queue 'from' into queue 'to'. | ||
135 | If 'needed_bytes' == 0, then move all buffers from 'from' into 'to'. | ||
136 | If 'steal' != NULL, then buffers may also taken from that queue if | ||
137 | needed. | ||
138 | |||
139 | The buffer is automatically cleared if it goes to the free queue. It is | ||
140 | also cleared if buffers need to be taken from the 'steal' queue and | ||
141 | the 'from' queue is the free queue. | ||
142 | |||
143 | When 'from' is q_free, then needed_bytes is compared to the total | ||
144 | available buffer length, otherwise needed_bytes is compared to the | ||
145 | bytesused value. For the 'steal' queue the total available buffer | ||
146 | length is always used. | ||
147 | |||
148 | -ENOMEM is returned if the buffers could not be obtained, 0 if all | ||
149 | buffers where obtained from the 'from' list and if non-zero then | ||
150 | the number of stolen buffers is returned. */ | ||
151 | static int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, | ||
152 | struct cx18_queue *steal, struct cx18_queue *to, | ||
153 | int needed_bytes) | ||
154 | { | 115 | { |
155 | unsigned long flags; | 116 | unsigned long flags; |
156 | int rc = 0; | 117 | struct cx18_buffer *buf; |
157 | int from_free = from == &s->q_free; | ||
158 | int to_free = to == &s->q_free; | ||
159 | int bytes_available; | ||
160 | |||
161 | spin_lock_irqsave(&s->qlock, flags); | ||
162 | if (needed_bytes == 0) { | ||
163 | from_free = 1; | ||
164 | needed_bytes = from->length; | ||
165 | } | ||
166 | |||
167 | bytes_available = from_free ? from->length : from->bytesused; | ||
168 | bytes_available += steal ? steal->length : 0; | ||
169 | 118 | ||
170 | if (bytes_available < needed_bytes) { | 119 | if (q == &s->q_free) |
171 | spin_unlock_irqrestore(&s->qlock, flags); | 120 | return; |
172 | return -ENOMEM; | ||
173 | } | ||
174 | if (from_free) { | ||
175 | u32 old_length = to->length; | ||
176 | 121 | ||
177 | while (to->length - old_length < needed_bytes) { | 122 | spin_lock_irqsave(&s->qlock, flags); |
178 | if (list_empty(&from->list)) | 123 | while (!list_empty(&q->list)) { |
179 | from = steal; | 124 | buf = list_entry(q->list.next, struct cx18_buffer, list); |
180 | if (from == steal) | 125 | list_move_tail(q->list.next, &s->q_free.list); |
181 | rc++; /* keep track of 'stolen' buffers */ | 126 | buf->bytesused = buf->readpos = buf->b_flags = 0; |
182 | cx18_queue_move_buf(s, from, to, 1, 0); | 127 | s->q_free.buffers++; |
183 | } | 128 | s->q_free.length += s->buf_size; |
184 | } else { | ||
185 | u32 old_bytesused = to->bytesused; | ||
186 | |||
187 | while (to->bytesused - old_bytesused < needed_bytes) { | ||
188 | if (list_empty(&from->list)) | ||
189 | from = steal; | ||
190 | if (from == steal) | ||
191 | rc++; /* keep track of 'stolen' buffers */ | ||
192 | cx18_queue_move_buf(s, from, to, to_free, rc); | ||
193 | } | ||
194 | } | 129 | } |
130 | cx18_queue_init(q); | ||
195 | spin_unlock_irqrestore(&s->qlock, flags); | 131 | spin_unlock_irqrestore(&s->qlock, flags); |
196 | return rc; | ||
197 | } | 132 | } |
198 | 133 | ||
199 | void cx18_flush_queues(struct cx18_stream *s) | 134 | void cx18_flush_queues(struct cx18_stream *s) |
200 | { | 135 | { |
201 | cx18_queue_move(s, &s->q_io, NULL, &s->q_free, 0); | 136 | cx18_queue_flush(s, &s->q_io); |
202 | cx18_queue_move(s, &s->q_full, NULL, &s->q_free, 0); | 137 | cx18_queue_flush(s, &s->q_full); |
203 | } | 138 | } |
204 | 139 | ||
205 | int cx18_stream_alloc(struct cx18_stream *s) | 140 | int cx18_stream_alloc(struct cx18_stream *s) |
@@ -214,10 +149,10 @@ int cx18_stream_alloc(struct cx18_stream *s) | |||
214 | s->name, s->buffers, s->buf_size, | 149 | s->name, s->buffers, s->buf_size, |
215 | s->buffers * s->buf_size / 1024); | 150 | s->buffers * s->buf_size / 1024); |
216 | 151 | ||
217 | if (((char *)&cx->scb->cpu_mdl[cx->mdl_offset + s->buffers] - | 152 | if (((char __iomem *)&cx->scb->cpu_mdl[cx->mdl_offset + s->buffers] - |
218 | (char *)cx->scb) > SCB_RESERVED_SIZE) { | 153 | (char __iomem *)cx->scb) > SCB_RESERVED_SIZE) { |
219 | unsigned bufsz = (((char *)cx->scb) + SCB_RESERVED_SIZE - | 154 | unsigned bufsz = (((char __iomem *)cx->scb) + SCB_RESERVED_SIZE - |
220 | ((char *)cx->scb->cpu_mdl)); | 155 | ((char __iomem *)cx->scb->cpu_mdl)); |
221 | 156 | ||
222 | CX18_ERR("Too many buffers, cannot fit in SCB area\n"); | 157 | CX18_ERR("Too many buffers, cannot fit in SCB area\n"); |
223 | CX18_ERR("Max buffers = %zd\n", | 158 | CX18_ERR("Max buffers = %zd\n", |
diff --git a/drivers/media/video/cx18/cx18-queue.h b/drivers/media/video/cx18/cx18-queue.h index 91423b9863a4..7f93bb13c09f 100644 --- a/drivers/media/video/cx18/cx18-queue.h +++ b/drivers/media/video/cx18/cx18-queue.h | |||
@@ -46,7 +46,7 @@ void cx18_queue_init(struct cx18_queue *q); | |||
46 | void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, | 46 | void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, |
47 | struct cx18_queue *q); | 47 | struct cx18_queue *q); |
48 | struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); | 48 | struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); |
49 | struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, | 49 | struct cx18_buffer *cx18_queue_get_buf_irq(struct cx18_stream *s, u32 id, |
50 | u32 bytesused); | 50 | u32 bytesused); |
51 | void cx18_flush_queues(struct cx18_stream *s); | 51 | void cx18_flush_queues(struct cx18_stream *s); |
52 | 52 | ||
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c index 8118091568fc..7b0e8c01692e 100644 --- a/drivers/media/video/cx23885/cx23885-417.c +++ b/drivers/media/video/cx23885/cx23885-417.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * (c) 2004 Jelle Foks <jelle@foks.8m.com> | 5 | * (c) 2004 Jelle Foks <jelle@foks.8m.com> |
6 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> | 6 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> |
7 | * (c) 2008 Steven Toth <stoth@hauppauge.com> | 7 | * (c) 2008 Steven Toth <stoth@linuxtv.org> |
8 | * - CX23885/7/8 support | 8 | * - CX23885/7/8 support |
9 | * | 9 | * |
10 | * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/), | 10 | * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/), |
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c index a19de850955d..c36d3f632104 100644 --- a/drivers/media/video/cx23885/cx23885-cards.c +++ b/drivers/media/video/cx23885/cx23885-cards.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index 6286a9cf957e..25fb09938744 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -33,7 +33,7 @@ | |||
33 | #include "cx23885.h" | 33 | #include "cx23885.h" |
34 | 34 | ||
35 | MODULE_DESCRIPTION("Driver for cx23885 based TV cards"); | 35 | MODULE_DESCRIPTION("Driver for cx23885 based TV cards"); |
36 | MODULE_AUTHOR("Steven Toth <stoth@hauppauge.com>"); | 36 | MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); |
37 | MODULE_LICENSE("GPL"); | 37 | MODULE_LICENSE("GPL"); |
38 | 38 | ||
39 | static unsigned int debug; | 39 | static unsigned int debug; |
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index 0a2e6558cd66..291b9d008da8 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index c6bb0a05bc1c..f98e476e9617 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx23885/cx23885-reg.h b/drivers/media/video/cx23885/cx23885-reg.h index bdd11bc513ad..20b68a236260 100644 --- a/drivers/media/video/cx23885/cx23885-reg.h +++ b/drivers/media/video/cx23885/cx23885-reg.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx23885/cx23885-vbi.c b/drivers/media/video/cx23885/cx23885-vbi.c index e36e3fcae2fb..35e61cd112fc 100644 --- a/drivers/media/video/cx23885/cx23885-vbi.c +++ b/drivers/media/video/cx23885/cx23885-vbi.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index ad2235dab5b1..6047c78d84bf 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2007 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
@@ -41,7 +41,7 @@ | |||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | MODULE_DESCRIPTION("v4l2 driver module for cx23885 based TV cards"); | 43 | MODULE_DESCRIPTION("v4l2 driver module for cx23885 based TV cards"); |
44 | MODULE_AUTHOR("Steven Toth <stoth@hauppauge.com>"); | 44 | MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); |
45 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
46 | 46 | ||
47 | /* ------------------------------------------------------------------ */ | 47 | /* ------------------------------------------------------------------ */ |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index 00dfdc89d641..e23d97c071e0 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Conexant CX23885 PCIe bridge | 2 | * Driver for the Conexant CX23885 PCIe bridge |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 209d3bcb5dbb..4da8cd74f00e 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
@@ -13,7 +13,7 @@ | |||
13 | * NTSC sliced VBI support by Christopher Neufeld <television@cneufeld.ca> | 13 | * NTSC sliced VBI support by Christopher Neufeld <television@cneufeld.ca> |
14 | * with additional fixes by Hans Verkuil <hverkuil@xs4all.nl>. | 14 | * with additional fixes by Hans Verkuil <hverkuil@xs4all.nl>. |
15 | * | 15 | * |
16 | * CX23885 support by Steven Toth <stoth@hauppauge.com>. | 16 | * CX23885 support by Steven Toth <stoth@linuxtv.org>. |
17 | * | 17 | * |
18 | * This program is free software; you can redistribute it and/or | 18 | * This program is free software; you can redistribute it and/or |
19 | * modify it under the terms of the GNU General Public License | 19 | * modify it under the terms of the GNU General Public License |
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index 48f4b92a8f8b..79faedf58521 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c | |||
@@ -403,6 +403,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) | |||
403 | ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev); | 403 | ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev); |
404 | if (ret) { | 404 | if (ret) { |
405 | err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret); | 405 | err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret); |
406 | kfree(b); | ||
406 | return ret; | 407 | return ret; |
407 | } | 408 | } |
408 | 409 | ||
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index 2d170d101c21..8db2a05bf9c5 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c | |||
@@ -2588,6 +2588,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2588 | cam->v4ldev->fops = &et61x251_fops; | 2588 | cam->v4ldev->fops = &et61x251_fops; |
2589 | cam->v4ldev->minor = video_nr[dev_nr]; | 2589 | cam->v4ldev->minor = video_nr[dev_nr]; |
2590 | cam->v4ldev->release = video_device_release; | 2590 | cam->v4ldev->release = video_device_release; |
2591 | cam->v4ldev->parent = &udev->dev; | ||
2591 | video_set_drvdata(cam->v4ldev, cam); | 2592 | video_set_drvdata(cam->v4ldev, cam); |
2592 | 2593 | ||
2593 | init_completion(&cam->probe); | 2594 | init_completion(&cam->probe); |
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index cd3a3f5829b2..4d9f4cc255a9 100644 --- a/drivers/media/video/gspca/conex.c +++ b/drivers/media/video/gspca/conex.c | |||
@@ -124,7 +124,7 @@ static void reg_r(struct gspca_dev *gspca_dev, | |||
124 | struct usb_device *dev = gspca_dev->dev; | 124 | struct usb_device *dev = gspca_dev->dev; |
125 | 125 | ||
126 | #ifdef GSPCA_DEBUG | 126 | #ifdef GSPCA_DEBUG |
127 | if (len > sizeof gspca_dev->usb_buf) { | 127 | if (len > USB_BUF_SZ) { |
128 | err("reg_r: buffer overflow"); | 128 | err("reg_r: buffer overflow"); |
129 | return; | 129 | return; |
130 | } | 130 | } |
@@ -164,7 +164,7 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
164 | struct usb_device *dev = gspca_dev->dev; | 164 | struct usb_device *dev = gspca_dev->dev; |
165 | 165 | ||
166 | #ifdef GSPCA_DEBUG | 166 | #ifdef GSPCA_DEBUG |
167 | if (len > sizeof gspca_dev->usb_buf) { | 167 | if (len > USB_BUF_SZ) { |
168 | err("reg_w: buffer overflow"); | 168 | err("reg_w: buffer overflow"); |
169 | return; | 169 | return; |
170 | } | 170 | } |
@@ -731,13 +731,13 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) | |||
731 | reg_w_val(gspca_dev, 0x0000, 0x00); | 731 | reg_w_val(gspca_dev, 0x0000, 0x00); |
732 | /* wait for completion */ | 732 | /* wait for completion */ |
733 | retry = 50; | 733 | retry = 50; |
734 | while (retry--) { | 734 | do { |
735 | reg_r(gspca_dev, 0x0002, 1); | 735 | reg_r(gspca_dev, 0x0002, 1); |
736 | /* 0x07 until 0x00 */ | 736 | /* 0x07 until 0x00 */ |
737 | if (gspca_dev->usb_buf[0] == 0x00) | 737 | if (gspca_dev->usb_buf[0] == 0x00) |
738 | break; | 738 | break; |
739 | reg_w_val(gspca_dev, 0x0053, 0x00); | 739 | reg_w_val(gspca_dev, 0x0053, 0x00); |
740 | } | 740 | } while (--retry); |
741 | if (retry == 0) | 741 | if (retry == 0) |
742 | PDEBUG(D_ERR, "Damned Errors sending jpeg Table"); | 742 | PDEBUG(D_ERR, "Damned Errors sending jpeg Table"); |
743 | /* send the qtable now */ | 743 | /* send the qtable now */ |
@@ -826,8 +826,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
826 | return 0; | 826 | return 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | /* this function is called at open time */ | 829 | /* this function is called at probe and resume time */ |
830 | static int sd_open(struct gspca_dev *gspca_dev) | 830 | static int sd_init(struct gspca_dev *gspca_dev) |
831 | { | 831 | { |
832 | cx11646_init1(gspca_dev); | 832 | cx11646_init1(gspca_dev); |
833 | cx11646_initsize(gspca_dev); | 833 | cx11646_initsize(gspca_dev); |
@@ -845,10 +845,6 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
845 | cx11646_jpeg(gspca_dev); | 845 | cx11646_jpeg(gspca_dev); |
846 | } | 846 | } |
847 | 847 | ||
848 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
849 | { | ||
850 | } | ||
851 | |||
852 | static void sd_stop0(struct gspca_dev *gspca_dev) | 848 | static void sd_stop0(struct gspca_dev *gspca_dev) |
853 | { | 849 | { |
854 | int retry = 50; | 850 | int retry = 50; |
@@ -871,10 +867,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
871 | reg_w_val(gspca_dev, 0x00fc, 0xe0); | 867 | reg_w_val(gspca_dev, 0x00fc, 0xe0); |
872 | } | 868 | } |
873 | 869 | ||
874 | static void sd_close(struct gspca_dev *gspca_dev) | ||
875 | { | ||
876 | } | ||
877 | |||
878 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 870 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
879 | struct gspca_frame *frame, /* target */ | 871 | struct gspca_frame *frame, /* target */ |
880 | __u8 *data, /* isoc packet */ | 872 | __u8 *data, /* isoc packet */ |
@@ -998,11 +990,9 @@ static struct sd_desc sd_desc = { | |||
998 | .ctrls = sd_ctrls, | 990 | .ctrls = sd_ctrls, |
999 | .nctrls = ARRAY_SIZE(sd_ctrls), | 991 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1000 | .config = sd_config, | 992 | .config = sd_config, |
1001 | .open = sd_open, | 993 | .init = sd_init, |
1002 | .start = sd_start, | 994 | .start = sd_start, |
1003 | .stopN = sd_stopN, | ||
1004 | .stop0 = sd_stop0, | 995 | .stop0 = sd_stop0, |
1005 | .close = sd_close, | ||
1006 | .pkt_scan = sd_pkt_scan, | 996 | .pkt_scan = sd_pkt_scan, |
1007 | }; | 997 | }; |
1008 | 998 | ||
@@ -1026,6 +1016,10 @@ static struct usb_driver sd_driver = { | |||
1026 | .id_table = device_table, | 1016 | .id_table = device_table, |
1027 | .probe = sd_probe, | 1017 | .probe = sd_probe, |
1028 | .disconnect = gspca_disconnect, | 1018 | .disconnect = gspca_disconnect, |
1019 | #ifdef CONFIG_PM | ||
1020 | .suspend = gspca_suspend, | ||
1021 | .resume = gspca_resume, | ||
1022 | #endif | ||
1029 | }; | 1023 | }; |
1030 | 1024 | ||
1031 | /* -- module insert / remove -- */ | 1025 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c index 1dbe92d01e6a..4ff0e386914b 100644 --- a/drivers/media/video/gspca/etoms.c +++ b/drivers/media/video/gspca/etoms.c | |||
@@ -81,6 +81,7 @@ static struct ctrl sd_ctrls[] = { | |||
81 | .set = sd_setcontrast, | 81 | .set = sd_setcontrast, |
82 | .get = sd_getcontrast, | 82 | .get = sd_getcontrast, |
83 | }, | 83 | }, |
84 | #define COLOR_IDX 2 | ||
84 | { | 85 | { |
85 | { | 86 | { |
86 | .id = V4L2_CID_SATURATION, | 87 | .id = V4L2_CID_SATURATION, |
@@ -234,7 +235,7 @@ static void reg_r(struct gspca_dev *gspca_dev, | |||
234 | struct usb_device *dev = gspca_dev->dev; | 235 | struct usb_device *dev = gspca_dev->dev; |
235 | 236 | ||
236 | #ifdef GSPCA_DEBUG | 237 | #ifdef GSPCA_DEBUG |
237 | if (len > sizeof gspca_dev->usb_buf) { | 238 | if (len > USB_BUF_SZ) { |
238 | err("reg_r: buffer overflow"); | 239 | err("reg_r: buffer overflow"); |
239 | return; | 240 | return; |
240 | } | 241 | } |
@@ -272,7 +273,7 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
272 | struct usb_device *dev = gspca_dev->dev; | 273 | struct usb_device *dev = gspca_dev->dev; |
273 | 274 | ||
274 | #ifdef GSPCA_DEBUG | 275 | #ifdef GSPCA_DEBUG |
275 | if (len > sizeof gspca_dev->usb_buf) { | 276 | if (len > USB_BUF_SZ) { |
276 | err("reg_w: buffer overflow"); | 277 | err("reg_w: buffer overflow"); |
277 | return; | 278 | return; |
278 | } | 279 | } |
@@ -665,6 +666,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
665 | } else { | 666 | } else { |
666 | cam->cam_mode = vga_mode; | 667 | cam->cam_mode = vga_mode; |
667 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; | 668 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; |
669 | gspca_dev->ctrl_dis = (1 << COLOR_IDX); | ||
668 | } | 670 | } |
669 | sd->brightness = BRIGHTNESS_DEF; | 671 | sd->brightness = BRIGHTNESS_DEF; |
670 | sd->contrast = CONTRAST_DEF; | 672 | sd->contrast = CONTRAST_DEF; |
@@ -674,8 +676,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
674 | return 0; | 676 | return 0; |
675 | } | 677 | } |
676 | 678 | ||
677 | /* this function is called at open time */ | 679 | /* this function is called at probe and resume time */ |
678 | static int sd_open(struct gspca_dev *gspca_dev) | 680 | static int sd_init(struct gspca_dev *gspca_dev) |
679 | { | 681 | { |
680 | struct sd *sd = (struct sd *) gspca_dev; | 682 | struct sd *sd = (struct sd *) gspca_dev; |
681 | 683 | ||
@@ -709,14 +711,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
709 | et_video(gspca_dev, 0); /* video off */ | 711 | et_video(gspca_dev, 0); /* video off */ |
710 | } | 712 | } |
711 | 713 | ||
712 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
713 | { | ||
714 | } | ||
715 | |||
716 | static void sd_close(struct gspca_dev *gspca_dev) | ||
717 | { | ||
718 | } | ||
719 | |||
720 | static __u8 Et_getgainG(struct gspca_dev *gspca_dev) | 714 | static __u8 Et_getgainG(struct gspca_dev *gspca_dev) |
721 | { | 715 | { |
722 | struct sd *sd = (struct sd *) gspca_dev; | 716 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -893,21 +887,19 @@ static struct sd_desc sd_desc = { | |||
893 | .ctrls = sd_ctrls, | 887 | .ctrls = sd_ctrls, |
894 | .nctrls = ARRAY_SIZE(sd_ctrls), | 888 | .nctrls = ARRAY_SIZE(sd_ctrls), |
895 | .config = sd_config, | 889 | .config = sd_config, |
896 | .open = sd_open, | 890 | .init = sd_init, |
897 | .start = sd_start, | 891 | .start = sd_start, |
898 | .stopN = sd_stopN, | 892 | .stopN = sd_stopN, |
899 | .stop0 = sd_stop0, | ||
900 | .close = sd_close, | ||
901 | .pkt_scan = sd_pkt_scan, | 893 | .pkt_scan = sd_pkt_scan, |
902 | .dq_callback = do_autogain, | 894 | .dq_callback = do_autogain, |
903 | }; | 895 | }; |
904 | 896 | ||
905 | /* -- module initialisation -- */ | 897 | /* -- module initialisation -- */ |
906 | static __devinitdata struct usb_device_id device_table[] = { | 898 | static __devinitdata struct usb_device_id device_table[] = { |
907 | #ifndef CONFIG_USB_ET61X251 | ||
908 | {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, | 899 | {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, |
909 | #endif | 900 | #if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE |
910 | {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, | 901 | {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, |
902 | #endif | ||
911 | {} | 903 | {} |
912 | }; | 904 | }; |
913 | 905 | ||
@@ -926,6 +918,10 @@ static struct usb_driver sd_driver = { | |||
926 | .id_table = device_table, | 918 | .id_table = device_table, |
927 | .probe = sd_probe, | 919 | .probe = sd_probe, |
928 | .disconnect = gspca_disconnect, | 920 | .disconnect = gspca_disconnect, |
921 | #ifdef CONFIG_PM | ||
922 | .suspend = gspca_suspend, | ||
923 | .resume = gspca_resume, | ||
924 | #endif | ||
929 | }; | 925 | }; |
930 | 926 | ||
931 | /* -- module insert / remove -- */ | 927 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 15d302b28b79..7be69284da03 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -114,7 +114,10 @@ static void fill_frame(struct gspca_dev *gspca_dev, | |||
114 | cam_pkt_op pkt_scan; | 114 | cam_pkt_op pkt_scan; |
115 | 115 | ||
116 | if (urb->status != 0) { | 116 | if (urb->status != 0) { |
117 | PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status); | 117 | #ifdef CONFIG_PM |
118 | if (!gspca_dev->frozen) | ||
119 | #endif | ||
120 | PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status); | ||
118 | return; /* disconnection ? */ | 121 | return; /* disconnection ? */ |
119 | } | 122 | } |
120 | pkt_scan = gspca_dev->sd_desc->pkt_scan; | 123 | pkt_scan = gspca_dev->sd_desc->pkt_scan; |
@@ -555,10 +558,12 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev) | |||
555 | gspca_dev->streaming = 0; | 558 | gspca_dev->streaming = 0; |
556 | atomic_set(&gspca_dev->nevent, 0); | 559 | atomic_set(&gspca_dev->nevent, 0); |
557 | if (gspca_dev->present) { | 560 | if (gspca_dev->present) { |
558 | gspca_dev->sd_desc->stopN(gspca_dev); | 561 | if (gspca_dev->sd_desc->stopN) |
562 | gspca_dev->sd_desc->stopN(gspca_dev); | ||
559 | destroy_urbs(gspca_dev); | 563 | destroy_urbs(gspca_dev); |
560 | gspca_set_alt0(gspca_dev); | 564 | gspca_set_alt0(gspca_dev); |
561 | gspca_dev->sd_desc->stop0(gspca_dev); | 565 | if (gspca_dev->sd_desc->stop0) |
566 | gspca_dev->sd_desc->stop0(gspca_dev); | ||
562 | PDEBUG(D_STREAM, "stream off OK"); | 567 | PDEBUG(D_STREAM, "stream off OK"); |
563 | } | 568 | } |
564 | } | 569 | } |
@@ -767,19 +772,7 @@ static int dev_open(struct inode *inode, struct file *file) | |||
767 | goto out; | 772 | goto out; |
768 | } | 773 | } |
769 | 774 | ||
770 | /* if not done yet, initialize the sensor */ | 775 | if (gspca_dev->users > 4) { /* (arbitrary value) */ |
771 | if (gspca_dev->users == 0) { | ||
772 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) { | ||
773 | ret = -ERESTARTSYS; | ||
774 | goto out; | ||
775 | } | ||
776 | ret = gspca_dev->sd_desc->open(gspca_dev); | ||
777 | mutex_unlock(&gspca_dev->usb_lock); | ||
778 | if (ret != 0) { | ||
779 | PDEBUG(D_ERR|D_CONF, "init device failed %d", ret); | ||
780 | goto out; | ||
781 | } | ||
782 | } else if (gspca_dev->users > 4) { /* (arbitrary value) */ | ||
783 | ret = -EBUSY; | 776 | ret = -EBUSY; |
784 | goto out; | 777 | goto out; |
785 | } | 778 | } |
@@ -792,6 +785,7 @@ static int dev_open(struct inode *inode, struct file *file) | |||
792 | else | 785 | else |
793 | gspca_dev->vdev.debug &= ~3; | 786 | gspca_dev->vdev.debug &= ~3; |
794 | #endif | 787 | #endif |
788 | ret = 0; | ||
795 | out: | 789 | out: |
796 | mutex_unlock(&gspca_dev->queue_lock); | 790 | mutex_unlock(&gspca_dev->queue_lock); |
797 | if (ret != 0) | 791 | if (ret != 0) |
@@ -812,11 +806,11 @@ static int dev_close(struct inode *inode, struct file *file) | |||
812 | 806 | ||
813 | /* if the file did the capture, free the streaming resources */ | 807 | /* if the file did the capture, free the streaming resources */ |
814 | if (gspca_dev->capt_file == file) { | 808 | if (gspca_dev->capt_file == file) { |
815 | mutex_lock(&gspca_dev->usb_lock); | 809 | if (gspca_dev->streaming) { |
816 | if (gspca_dev->streaming) | 810 | mutex_lock(&gspca_dev->usb_lock); |
817 | gspca_stream_off(gspca_dev); | 811 | gspca_stream_off(gspca_dev); |
818 | gspca_dev->sd_desc->close(gspca_dev); | 812 | mutex_unlock(&gspca_dev->usb_lock); |
819 | mutex_unlock(&gspca_dev->usb_lock); | 813 | } |
820 | frame_free(gspca_dev); | 814 | frame_free(gspca_dev); |
821 | gspca_dev->capt_file = NULL; | 815 | gspca_dev->capt_file = NULL; |
822 | gspca_dev->memory = GSPCA_MEMORY_NO; | 816 | gspca_dev->memory = GSPCA_MEMORY_NO; |
@@ -853,42 +847,44 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
853 | return 0; | 847 | return 0; |
854 | } | 848 | } |
855 | 849 | ||
856 | /* the use of V4L2_CTRL_FLAG_NEXT_CTRL asks for the controls to be sorted */ | ||
857 | static int vidioc_queryctrl(struct file *file, void *priv, | 850 | static int vidioc_queryctrl(struct file *file, void *priv, |
858 | struct v4l2_queryctrl *q_ctrl) | 851 | struct v4l2_queryctrl *q_ctrl) |
859 | { | 852 | { |
860 | struct gspca_dev *gspca_dev = priv; | 853 | struct gspca_dev *gspca_dev = priv; |
861 | int i; | 854 | int i, ix; |
862 | u32 id; | 855 | u32 id; |
863 | 856 | ||
857 | ix = -1; | ||
864 | id = q_ctrl->id; | 858 | id = q_ctrl->id; |
865 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 859 | if (id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
866 | id &= V4L2_CTRL_ID_MASK; | 860 | id &= V4L2_CTRL_ID_MASK; |
867 | id++; | 861 | id++; |
868 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 862 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
869 | if (id >= gspca_dev->sd_desc->ctrls[i].qctrl.id) { | 863 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) |
870 | memcpy(q_ctrl, | 864 | continue; |
871 | &gspca_dev->sd_desc->ctrls[i].qctrl, | 865 | if (ix < 0) { |
872 | sizeof *q_ctrl); | 866 | ix = i; |
873 | return 0; | 867 | continue; |
874 | } | 868 | } |
869 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id | ||
870 | > gspca_dev->sd_desc->ctrls[ix].qctrl.id) | ||
871 | continue; | ||
872 | ix = i; | ||
875 | } | 873 | } |
876 | return -EINVAL; | ||
877 | } | 874 | } |
878 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 875 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
879 | if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) { | 876 | if (id == gspca_dev->sd_desc->ctrls[i].qctrl.id) { |
880 | memcpy(q_ctrl, | 877 | ix = i; |
881 | &gspca_dev->sd_desc->ctrls[i].qctrl, | 878 | break; |
882 | sizeof *q_ctrl); | ||
883 | return 0; | ||
884 | } | 879 | } |
885 | } | 880 | } |
886 | if (id >= V4L2_CID_BASE | 881 | if (ix < 0) |
887 | && id <= V4L2_CID_LASTP1) { | 882 | return -EINVAL; |
883 | memcpy(q_ctrl, &gspca_dev->sd_desc->ctrls[ix].qctrl, | ||
884 | sizeof *q_ctrl); | ||
885 | if (gspca_dev->ctrl_dis & (1 << ix)) | ||
888 | q_ctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | 886 | q_ctrl->flags |= V4L2_CTRL_FLAG_DISABLED; |
889 | return 0; | 887 | return 0; |
890 | } | ||
891 | return -EINVAL; | ||
892 | } | 888 | } |
893 | 889 | ||
894 | static int vidioc_s_ctrl(struct file *file, void *priv, | 890 | static int vidioc_s_ctrl(struct file *file, void *priv, |
@@ -903,6 +899,8 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
903 | i++, ctrls++) { | 899 | i++, ctrls++) { |
904 | if (ctrl->id != ctrls->qctrl.id) | 900 | if (ctrl->id != ctrls->qctrl.id) |
905 | continue; | 901 | continue; |
902 | if (gspca_dev->ctrl_dis & (1 << i)) | ||
903 | return -EINVAL; | ||
906 | if (ctrl->value < ctrls->qctrl.minimum | 904 | if (ctrl->value < ctrls->qctrl.minimum |
907 | || ctrl->value > ctrls->qctrl.maximum) | 905 | || ctrl->value > ctrls->qctrl.maximum) |
908 | return -ERANGE; | 906 | return -ERANGE; |
@@ -929,6 +927,8 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
929 | i++, ctrls++) { | 927 | i++, ctrls++) { |
930 | if (ctrl->id != ctrls->qctrl.id) | 928 | if (ctrl->id != ctrls->qctrl.id) |
931 | continue; | 929 | continue; |
930 | if (gspca_dev->ctrl_dis & (1 << i)) | ||
931 | return -EINVAL; | ||
932 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) | 932 | if (mutex_lock_interruptible(&gspca_dev->usb_lock)) |
933 | return -ERESTARTSYS; | 933 | return -ERESTARTSYS; |
934 | ret = ctrls->get(gspca_dev, &ctrl->value); | 934 | ret = ctrls->get(gspca_dev, &ctrl->value); |
@@ -1403,7 +1403,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, | |||
1403 | i = ret; /* frame index */ | 1403 | i = ret; /* frame index */ |
1404 | frame = &gspca_dev->frame[i]; | 1404 | frame = &gspca_dev->frame[i]; |
1405 | if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { | 1405 | if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { |
1406 | if (copy_to_user((__u8 *) frame->v4l2_buf.m.userptr, | 1406 | if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, |
1407 | frame->data, | 1407 | frame->data, |
1408 | frame->v4l2_buf.bytesused)) { | 1408 | frame->v4l2_buf.bytesused)) { |
1409 | PDEBUG(D_ERR|D_STREAM, | 1409 | PDEBUG(D_ERR|D_STREAM, |
@@ -1731,6 +1731,12 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
1731 | err("couldn't kzalloc gspca struct"); | 1731 | err("couldn't kzalloc gspca struct"); |
1732 | return -EIO; | 1732 | return -EIO; |
1733 | } | 1733 | } |
1734 | gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL); | ||
1735 | if (!gspca_dev->usb_buf) { | ||
1736 | err("out of memory"); | ||
1737 | ret = -EIO; | ||
1738 | goto out; | ||
1739 | } | ||
1734 | gspca_dev->dev = dev; | 1740 | gspca_dev->dev = dev; |
1735 | gspca_dev->iface = interface->bInterfaceNumber; | 1741 | gspca_dev->iface = interface->bInterfaceNumber; |
1736 | gspca_dev->nbalt = intf->num_altsetting; | 1742 | gspca_dev->nbalt = intf->num_altsetting; |
@@ -1738,10 +1744,13 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
1738 | /* gspca_dev->users = 0; (done by kzalloc) */ | 1744 | /* gspca_dev->users = 0; (done by kzalloc) */ |
1739 | gspca_dev->nbufread = 2; | 1745 | gspca_dev->nbufread = 2; |
1740 | 1746 | ||
1741 | /* configure the subdriver */ | 1747 | /* configure the subdriver and initialize the USB device */ |
1742 | ret = gspca_dev->sd_desc->config(gspca_dev, id); | 1748 | ret = gspca_dev->sd_desc->config(gspca_dev, id); |
1743 | if (ret < 0) | 1749 | if (ret < 0) |
1744 | goto out; | 1750 | goto out; |
1751 | ret = gspca_dev->sd_desc->init(gspca_dev); | ||
1752 | if (ret < 0) | ||
1753 | goto out; | ||
1745 | ret = gspca_set_alt0(gspca_dev); | 1754 | ret = gspca_set_alt0(gspca_dev); |
1746 | if (ret < 0) | 1755 | if (ret < 0) |
1747 | goto out; | 1756 | goto out; |
@@ -1771,6 +1780,7 @@ int gspca_dev_probe(struct usb_interface *intf, | |||
1771 | PDEBUG(D_PROBE, "probe ok"); | 1780 | PDEBUG(D_PROBE, "probe ok"); |
1772 | return 0; | 1781 | return 0; |
1773 | out: | 1782 | out: |
1783 | kfree(gspca_dev->usb_buf); | ||
1774 | kfree(gspca_dev); | 1784 | kfree(gspca_dev); |
1775 | return ret; | 1785 | return ret; |
1776 | } | 1786 | } |
@@ -1803,11 +1813,42 @@ void gspca_disconnect(struct usb_interface *intf) | |||
1803 | /* We don't want people trying to open up the device */ | 1813 | /* We don't want people trying to open up the device */ |
1804 | video_unregister_device(&gspca_dev->vdev); | 1814 | video_unregister_device(&gspca_dev->vdev); |
1805 | /* Free the memory */ | 1815 | /* Free the memory */ |
1816 | kfree(gspca_dev->usb_buf); | ||
1806 | kfree(gspca_dev); | 1817 | kfree(gspca_dev); |
1807 | PDEBUG(D_PROBE, "disconnect complete"); | 1818 | PDEBUG(D_PROBE, "disconnect complete"); |
1808 | } | 1819 | } |
1809 | EXPORT_SYMBOL(gspca_disconnect); | 1820 | EXPORT_SYMBOL(gspca_disconnect); |
1810 | 1821 | ||
1822 | #ifdef CONFIG_PM | ||
1823 | int gspca_suspend(struct usb_interface *intf, pm_message_t message) | ||
1824 | { | ||
1825 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); | ||
1826 | |||
1827 | if (!gspca_dev->streaming) | ||
1828 | return 0; | ||
1829 | gspca_dev->frozen = 1; /* avoid urb error messages */ | ||
1830 | if (gspca_dev->sd_desc->stopN) | ||
1831 | gspca_dev->sd_desc->stopN(gspca_dev); | ||
1832 | destroy_urbs(gspca_dev); | ||
1833 | gspca_set_alt0(gspca_dev); | ||
1834 | if (gspca_dev->sd_desc->stop0) | ||
1835 | gspca_dev->sd_desc->stop0(gspca_dev); | ||
1836 | return 0; | ||
1837 | } | ||
1838 | EXPORT_SYMBOL(gspca_suspend); | ||
1839 | |||
1840 | int gspca_resume(struct usb_interface *intf) | ||
1841 | { | ||
1842 | struct gspca_dev *gspca_dev = usb_get_intfdata(intf); | ||
1843 | |||
1844 | gspca_dev->frozen = 0; | ||
1845 | gspca_dev->sd_desc->init(gspca_dev); | ||
1846 | if (gspca_dev->streaming) | ||
1847 | return gspca_init_transfer(gspca_dev); | ||
1848 | return 0; | ||
1849 | } | ||
1850 | EXPORT_SYMBOL(gspca_resume); | ||
1851 | #endif | ||
1811 | /* -- cam driver utility functions -- */ | 1852 | /* -- cam driver utility functions -- */ |
1812 | 1853 | ||
1813 | /* auto gain and exposure algorithm based on the knee algorithm described here: | 1854 | /* auto gain and exposure algorithm based on the knee algorithm described here: |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index 67e448940eaa..c17625cff9ba 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -56,7 +56,6 @@ extern int gspca_debug; | |||
56 | 56 | ||
57 | /* device information - set at probe time */ | 57 | /* device information - set at probe time */ |
58 | struct cam { | 58 | struct cam { |
59 | char *dev_name; | ||
60 | struct v4l2_pix_format *cam_mode; /* size nmodes */ | 59 | struct v4l2_pix_format *cam_mode; /* size nmodes */ |
61 | char nmodes; | 60 | char nmodes; |
62 | __u8 epaddr; | 61 | __u8 epaddr; |
@@ -91,15 +90,14 @@ struct sd_desc { | |||
91 | /* controls */ | 90 | /* controls */ |
92 | const struct ctrl *ctrls; | 91 | const struct ctrl *ctrls; |
93 | int nctrls; | 92 | int nctrls; |
94 | /* operations */ | 93 | /* mandatory operations */ |
95 | cam_cf_op config; /* called on probe */ | 94 | cam_cf_op config; /* called on probe */ |
96 | cam_op open; /* called on open */ | 95 | cam_op init; /* called on probe and resume */ |
97 | cam_v_op start; /* called on stream on */ | 96 | cam_v_op start; /* called on stream on */ |
98 | cam_v_op stopN; /* called on stream off - main alt */ | ||
99 | cam_v_op stop0; /* called on stream off - alt 0 */ | ||
100 | cam_v_op close; /* called on close */ | ||
101 | cam_pkt_op pkt_scan; | 97 | cam_pkt_op pkt_scan; |
102 | /* optional operations */ | 98 | /* optional operations */ |
99 | cam_v_op stopN; /* called on stream off - main alt */ | ||
100 | cam_v_op stop0; /* called on stream off - alt 0 */ | ||
103 | cam_v_op dq_callback; /* called when a frame has been dequeued */ | 101 | cam_v_op dq_callback; /* called when a frame has been dequeued */ |
104 | cam_jpg_op get_jcomp; | 102 | cam_jpg_op get_jcomp; |
105 | cam_jpg_op set_jcomp; | 103 | cam_jpg_op set_jcomp; |
@@ -127,8 +125,10 @@ struct gspca_dev { | |||
127 | 125 | ||
128 | struct cam cam; /* device information */ | 126 | struct cam cam; /* device information */ |
129 | const struct sd_desc *sd_desc; /* subdriver description */ | 127 | const struct sd_desc *sd_desc; /* subdriver description */ |
128 | unsigned ctrl_dis; /* disabled controls (bit map) */ | ||
130 | 129 | ||
131 | __u8 usb_buf[8]; /* buffer for USB exchanges */ | 130 | #define USB_BUF_SZ 64 |
131 | __u8 *usb_buf; /* buffer for USB exchanges */ | ||
132 | struct urb *urb[MAX_NURBS]; | 132 | struct urb *urb[MAX_NURBS]; |
133 | 133 | ||
134 | __u8 *frbuf; /* buffer for nframes */ | 134 | __u8 *frbuf; /* buffer for nframes */ |
@@ -155,6 +155,9 @@ struct gspca_dev { | |||
155 | struct mutex queue_lock; /* ISOC queue protection */ | 155 | struct mutex queue_lock; /* ISOC queue protection */ |
156 | __u32 sequence; /* frame sequence number */ | 156 | __u32 sequence; /* frame sequence number */ |
157 | char streaming; | 157 | char streaming; |
158 | #ifdef CONFIG_PM | ||
159 | char frozen; /* suspend - resume */ | ||
160 | #endif | ||
158 | char users; /* number of opens */ | 161 | char users; /* number of opens */ |
159 | char present; /* device connected */ | 162 | char present; /* device connected */ |
160 | char nbufread; /* number of buffers for read() */ | 163 | char nbufread; /* number of buffers for read() */ |
@@ -174,6 +177,10 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, | |||
174 | struct gspca_frame *frame, | 177 | struct gspca_frame *frame, |
175 | const __u8 *data, | 178 | const __u8 *data, |
176 | int len); | 179 | int len); |
180 | #ifdef CONFIG_PM | ||
181 | int gspca_suspend(struct usb_interface *intf, pm_message_t message); | ||
182 | int gspca_resume(struct usb_interface *intf); | ||
183 | #endif | ||
177 | int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum, | 184 | int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum, |
178 | int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee); | 185 | int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee); |
179 | #endif /* GSPCAV2_H */ | 186 | #endif /* GSPCAV2_H */ |
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c index 21c4ee56a10a..4d5db47ba8cb 100644 --- a/drivers/media/video/gspca/mars.c +++ b/drivers/media/video/gspca/mars.c | |||
@@ -100,22 +100,6 @@ static int reg_w(struct gspca_dev *gspca_dev, | |||
100 | return rc; | 100 | return rc; |
101 | } | 101 | } |
102 | 102 | ||
103 | static int reg_w_buf(struct gspca_dev *gspca_dev, | ||
104 | __u16 index, __u8 *buf, int len) | ||
105 | { | ||
106 | int rc; | ||
107 | |||
108 | rc = usb_control_msg(gspca_dev->dev, | ||
109 | usb_sndbulkpipe(gspca_dev->dev, 4), | ||
110 | 0x12, | ||
111 | 0xc8, /* ?? */ | ||
112 | 0, /* value */ | ||
113 | index, buf, len, 500); | ||
114 | if (rc < 0) | ||
115 | PDEBUG(D_ERR, "reg write [%02x] error %d", index, rc); | ||
116 | return rc; | ||
117 | } | ||
118 | |||
119 | static void bulk_w(struct gspca_dev *gspca_dev, | 103 | static void bulk_w(struct gspca_dev *gspca_dev, |
120 | __u16 *pch, | 104 | __u16 *pch, |
121 | __u16 Address) | 105 | __u16 Address) |
@@ -144,8 +128,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
144 | return 0; | 128 | return 0; |
145 | } | 129 | } |
146 | 130 | ||
147 | /* this function is called at open time */ | 131 | /* this function is called at probe and resume time */ |
148 | static int sd_open(struct gspca_dev *gspca_dev) | 132 | static int sd_init(struct gspca_dev *gspca_dev) |
149 | { | 133 | { |
150 | return 0; | 134 | return 0; |
151 | } | 135 | } |
@@ -175,7 +159,6 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
175 | /* | 159 | /* |
176 | Initialize the MR97113 chip register | 160 | Initialize the MR97113 chip register |
177 | */ | 161 | */ |
178 | data = kmalloc(16, GFP_KERNEL); | ||
179 | data[0] = 0x00; /* address */ | 162 | data[0] = 0x00; /* address */ |
180 | data[1] = 0x0c | 0x01; /* reg 0 */ | 163 | data[1] = 0x0c | 0x01; /* reg 0 */ |
181 | data[2] = 0x01; /* reg 1 */ | 164 | data[2] = 0x01; /* reg 1 */ |
@@ -195,12 +178,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
195 | data[10] = 0x5d; /* reg 9, I2C device address | 178 | data[10] = 0x5d; /* reg 9, I2C device address |
196 | * [for PAS5101 (0x40)] [for MI (0x5d)] */ | 179 | * [for PAS5101 (0x40)] [for MI (0x5d)] */ |
197 | 180 | ||
198 | err_code = reg_w_buf(gspca_dev, data[0], data, 11); | 181 | err_code = reg_w(gspca_dev, data[0], 11); |
199 | kfree(data); | ||
200 | if (err_code < 0) | 182 | if (err_code < 0) |
201 | return; | 183 | return; |
202 | 184 | ||
203 | data = gspca_dev->usb_buf; | ||
204 | data[0] = 0x23; /* address */ | 185 | data[0] = 0x23; /* address */ |
205 | data[1] = 0x09; /* reg 35, append frame header */ | 186 | data[1] = 0x09; /* reg 35, append frame header */ |
206 | 187 | ||
@@ -358,14 +339,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
358 | PDEBUG(D_ERR, "Camera Stop failed"); | 339 | PDEBUG(D_ERR, "Camera Stop failed"); |
359 | } | 340 | } |
360 | 341 | ||
361 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
362 | { | ||
363 | } | ||
364 | |||
365 | static void sd_close(struct gspca_dev *gspca_dev) | ||
366 | { | ||
367 | } | ||
368 | |||
369 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 342 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
370 | struct gspca_frame *frame, /* target */ | 343 | struct gspca_frame *frame, /* target */ |
371 | __u8 *data, /* isoc packet */ | 344 | __u8 *data, /* isoc packet */ |
@@ -411,11 +384,9 @@ static const struct sd_desc sd_desc = { | |||
411 | .ctrls = sd_ctrls, | 384 | .ctrls = sd_ctrls, |
412 | .nctrls = ARRAY_SIZE(sd_ctrls), | 385 | .nctrls = ARRAY_SIZE(sd_ctrls), |
413 | .config = sd_config, | 386 | .config = sd_config, |
414 | .open = sd_open, | 387 | .init = sd_init, |
415 | .start = sd_start, | 388 | .start = sd_start, |
416 | .stopN = sd_stopN, | 389 | .stopN = sd_stopN, |
417 | .stop0 = sd_stop0, | ||
418 | .close = sd_close, | ||
419 | .pkt_scan = sd_pkt_scan, | 390 | .pkt_scan = sd_pkt_scan, |
420 | }; | 391 | }; |
421 | 392 | ||
@@ -439,6 +410,10 @@ static struct usb_driver sd_driver = { | |||
439 | .id_table = device_table, | 410 | .id_table = device_table, |
440 | .probe = sd_probe, | 411 | .probe = sd_probe, |
441 | .disconnect = gspca_disconnect, | 412 | .disconnect = gspca_disconnect, |
413 | #ifdef CONFIG_PM | ||
414 | .suspend = gspca_suspend, | ||
415 | .resume = gspca_resume, | ||
416 | #endif | ||
442 | }; | 417 | }; |
443 | 418 | ||
444 | /* -- module insert / remove -- */ | 419 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index b4f00ec0885c..4df4eec9f7e7 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -63,11 +63,10 @@ struct sd { | |||
63 | #define SEN_OV6630 2 | 63 | #define SEN_OV6630 2 |
64 | #define SEN_OV7610 3 | 64 | #define SEN_OV7610 3 |
65 | #define SEN_OV7620 4 | 65 | #define SEN_OV7620 4 |
66 | #define SEN_OV7630 5 | 66 | #define SEN_OV7640 5 |
67 | #define SEN_OV7640 6 | 67 | #define SEN_OV7670 6 |
68 | #define SEN_OV7670 7 | 68 | #define SEN_OV76BE 7 |
69 | #define SEN_OV76BE 8 | 69 | #define SEN_OV8610 8 |
70 | #define SEN_OV8610 9 | ||
71 | 70 | ||
72 | }; | 71 | }; |
73 | 72 | ||
@@ -127,6 +126,7 @@ static struct ctrl sd_ctrls[] = { | |||
127 | .get = sd_getcolors, | 126 | .get = sd_getcolors, |
128 | }, | 127 | }, |
129 | /* next controls work with ov7670 only */ | 128 | /* next controls work with ov7670 only */ |
129 | #define HFLIP_IDX 3 | ||
130 | { | 130 | { |
131 | { | 131 | { |
132 | .id = V4L2_CID_HFLIP, | 132 | .id = V4L2_CID_HFLIP, |
@@ -141,6 +141,7 @@ static struct ctrl sd_ctrls[] = { | |||
141 | .set = sd_sethflip, | 141 | .set = sd_sethflip, |
142 | .get = sd_gethflip, | 142 | .get = sd_gethflip, |
143 | }, | 143 | }, |
144 | #define VFLIP_IDX 4 | ||
144 | { | 145 | { |
145 | { | 146 | { |
146 | .id = V4L2_CID_VFLIP, | 147 | .id = V4L2_CID_VFLIP, |
@@ -293,6 +294,541 @@ static struct v4l2_pix_format sif_mode[] = { | |||
293 | #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */ | 294 | #define OV7670_REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */ |
294 | #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */ | 295 | #define OV7670_REG_BD60MAX 0xab /* 60hz banding step limit */ |
295 | 296 | ||
297 | struct ov_regvals { | ||
298 | __u8 reg; | ||
299 | __u8 val; | ||
300 | }; | ||
301 | struct ov_i2c_regvals { | ||
302 | __u8 reg; | ||
303 | __u8 val; | ||
304 | }; | ||
305 | |||
306 | static const struct ov_i2c_regvals norm_6x20[] = { | ||
307 | { 0x12, 0x80 }, /* reset */ | ||
308 | { 0x11, 0x01 }, | ||
309 | { 0x03, 0x60 }, | ||
310 | { 0x05, 0x7f }, /* For when autoadjust is off */ | ||
311 | { 0x07, 0xa8 }, | ||
312 | /* The ratio of 0x0c and 0x0d controls the white point */ | ||
313 | { 0x0c, 0x24 }, | ||
314 | { 0x0d, 0x24 }, | ||
315 | { 0x0f, 0x15 }, /* COMS */ | ||
316 | { 0x10, 0x75 }, /* AEC Exposure time */ | ||
317 | { 0x12, 0x24 }, /* Enable AGC */ | ||
318 | { 0x14, 0x04 }, | ||
319 | /* 0x16: 0x06 helps frame stability with moving objects */ | ||
320 | { 0x16, 0x06 }, | ||
321 | /* { 0x20, 0x30 }, * Aperture correction enable */ | ||
322 | { 0x26, 0xb2 }, /* BLC enable */ | ||
323 | /* 0x28: 0x05 Selects RGB format if RGB on */ | ||
324 | { 0x28, 0x05 }, | ||
325 | { 0x2a, 0x04 }, /* Disable framerate adjust */ | ||
326 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ | ||
327 | { 0x2d, 0x99 }, | ||
328 | { 0x33, 0xa0 }, /* Color Processing Parameter */ | ||
329 | { 0x34, 0xd2 }, /* Max A/D range */ | ||
330 | { 0x38, 0x8b }, | ||
331 | { 0x39, 0x40 }, | ||
332 | |||
333 | { 0x3c, 0x39 }, /* Enable AEC mode changing */ | ||
334 | { 0x3c, 0x3c }, /* Change AEC mode */ | ||
335 | { 0x3c, 0x24 }, /* Disable AEC mode changing */ | ||
336 | |||
337 | { 0x3d, 0x80 }, | ||
338 | /* These next two registers (0x4a, 0x4b) are undocumented. | ||
339 | * They control the color balance */ | ||
340 | { 0x4a, 0x80 }, | ||
341 | { 0x4b, 0x80 }, | ||
342 | { 0x4d, 0xd2 }, /* This reduces noise a bit */ | ||
343 | { 0x4e, 0xc1 }, | ||
344 | { 0x4f, 0x04 }, | ||
345 | /* Do 50-53 have any effect? */ | ||
346 | /* Toggle 0x12[2] off and on here? */ | ||
347 | }; | ||
348 | |||
349 | static const struct ov_i2c_regvals norm_6x30[] = { | ||
350 | { 0x12, 0x80 }, /* Reset */ | ||
351 | { 0x00, 0x1f }, /* Gain */ | ||
352 | { 0x01, 0x99 }, /* Blue gain */ | ||
353 | { 0x02, 0x7c }, /* Red gain */ | ||
354 | { 0x03, 0xc0 }, /* Saturation */ | ||
355 | { 0x05, 0x0a }, /* Contrast */ | ||
356 | { 0x06, 0x95 }, /* Brightness */ | ||
357 | { 0x07, 0x2d }, /* Sharpness */ | ||
358 | { 0x0c, 0x20 }, | ||
359 | { 0x0d, 0x20 }, | ||
360 | { 0x0e, 0x20 }, | ||
361 | { 0x0f, 0x05 }, | ||
362 | { 0x10, 0x9a }, | ||
363 | { 0x11, 0x00 }, /* Pixel clock = fastest */ | ||
364 | { 0x12, 0x24 }, /* Enable AGC and AWB */ | ||
365 | { 0x13, 0x21 }, | ||
366 | { 0x14, 0x80 }, | ||
367 | { 0x15, 0x01 }, | ||
368 | { 0x16, 0x03 }, | ||
369 | { 0x17, 0x38 }, | ||
370 | { 0x18, 0xea }, | ||
371 | { 0x19, 0x04 }, | ||
372 | { 0x1a, 0x93 }, | ||
373 | { 0x1b, 0x00 }, | ||
374 | { 0x1e, 0xc4 }, | ||
375 | { 0x1f, 0x04 }, | ||
376 | { 0x20, 0x20 }, | ||
377 | { 0x21, 0x10 }, | ||
378 | { 0x22, 0x88 }, | ||
379 | { 0x23, 0xc0 }, /* Crystal circuit power level */ | ||
380 | { 0x25, 0x9a }, /* Increase AEC black ratio */ | ||
381 | { 0x26, 0xb2 }, /* BLC enable */ | ||
382 | { 0x27, 0xa2 }, | ||
383 | { 0x28, 0x00 }, | ||
384 | { 0x29, 0x00 }, | ||
385 | { 0x2a, 0x84 }, /* 60 Hz power */ | ||
386 | { 0x2b, 0xa8 }, /* 60 Hz power */ | ||
387 | { 0x2c, 0xa0 }, | ||
388 | { 0x2d, 0x95 }, /* Enable auto-brightness */ | ||
389 | { 0x2e, 0x88 }, | ||
390 | { 0x33, 0x26 }, | ||
391 | { 0x34, 0x03 }, | ||
392 | { 0x36, 0x8f }, | ||
393 | { 0x37, 0x80 }, | ||
394 | { 0x38, 0x83 }, | ||
395 | { 0x39, 0x80 }, | ||
396 | { 0x3a, 0x0f }, | ||
397 | { 0x3b, 0x3c }, | ||
398 | { 0x3c, 0x1a }, | ||
399 | { 0x3d, 0x80 }, | ||
400 | { 0x3e, 0x80 }, | ||
401 | { 0x3f, 0x0e }, | ||
402 | { 0x40, 0x00 }, /* White bal */ | ||
403 | { 0x41, 0x00 }, /* White bal */ | ||
404 | { 0x42, 0x80 }, | ||
405 | { 0x43, 0x3f }, /* White bal */ | ||
406 | { 0x44, 0x80 }, | ||
407 | { 0x45, 0x20 }, | ||
408 | { 0x46, 0x20 }, | ||
409 | { 0x47, 0x80 }, | ||
410 | { 0x48, 0x7f }, | ||
411 | { 0x49, 0x00 }, | ||
412 | { 0x4a, 0x00 }, | ||
413 | { 0x4b, 0x80 }, | ||
414 | { 0x4c, 0xd0 }, | ||
415 | { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */ | ||
416 | { 0x4e, 0x40 }, | ||
417 | { 0x4f, 0x07 }, /* UV avg., col. killer: max */ | ||
418 | { 0x50, 0xff }, | ||
419 | { 0x54, 0x23 }, /* Max AGC gain: 18dB */ | ||
420 | { 0x55, 0xff }, | ||
421 | { 0x56, 0x12 }, | ||
422 | { 0x57, 0x81 }, | ||
423 | { 0x58, 0x75 }, | ||
424 | { 0x59, 0x01 }, /* AGC dark current comp.: +1 */ | ||
425 | { 0x5a, 0x2c }, | ||
426 | { 0x5b, 0x0f }, /* AWB chrominance levels */ | ||
427 | { 0x5c, 0x10 }, | ||
428 | { 0x3d, 0x80 }, | ||
429 | { 0x27, 0xa6 }, | ||
430 | { 0x12, 0x20 }, /* Toggle AWB */ | ||
431 | { 0x12, 0x24 }, | ||
432 | }; | ||
433 | |||
434 | /* Lawrence Glaister <lg@jfm.bc.ca> reports: | ||
435 | * | ||
436 | * Register 0x0f in the 7610 has the following effects: | ||
437 | * | ||
438 | * 0x85 (AEC method 1): Best overall, good contrast range | ||
439 | * 0x45 (AEC method 2): Very overexposed | ||
440 | * 0xa5 (spec sheet default): Ok, but the black level is | ||
441 | * shifted resulting in loss of contrast | ||
442 | * 0x05 (old driver setting): very overexposed, too much | ||
443 | * contrast | ||
444 | */ | ||
445 | static const struct ov_i2c_regvals norm_7610[] = { | ||
446 | { 0x10, 0xff }, | ||
447 | { 0x16, 0x06 }, | ||
448 | { 0x28, 0x24 }, | ||
449 | { 0x2b, 0xac }, | ||
450 | { 0x12, 0x00 }, | ||
451 | { 0x38, 0x81 }, | ||
452 | { 0x28, 0x24 }, /* 0c */ | ||
453 | { 0x0f, 0x85 }, /* lg's setting */ | ||
454 | { 0x15, 0x01 }, | ||
455 | { 0x20, 0x1c }, | ||
456 | { 0x23, 0x2a }, | ||
457 | { 0x24, 0x10 }, | ||
458 | { 0x25, 0x8a }, | ||
459 | { 0x26, 0xa2 }, | ||
460 | { 0x27, 0xc2 }, | ||
461 | { 0x2a, 0x04 }, | ||
462 | { 0x2c, 0xfe }, | ||
463 | { 0x2d, 0x93 }, | ||
464 | { 0x30, 0x71 }, | ||
465 | { 0x31, 0x60 }, | ||
466 | { 0x32, 0x26 }, | ||
467 | { 0x33, 0x20 }, | ||
468 | { 0x34, 0x48 }, | ||
469 | { 0x12, 0x24 }, | ||
470 | { 0x11, 0x01 }, | ||
471 | { 0x0c, 0x24 }, | ||
472 | { 0x0d, 0x24 }, | ||
473 | }; | ||
474 | |||
475 | static const struct ov_i2c_regvals norm_7620[] = { | ||
476 | { 0x00, 0x00 }, /* gain */ | ||
477 | { 0x01, 0x80 }, /* blue gain */ | ||
478 | { 0x02, 0x80 }, /* red gain */ | ||
479 | { 0x03, 0xc0 }, /* OV7670_REG_VREF */ | ||
480 | { 0x06, 0x60 }, | ||
481 | { 0x07, 0x00 }, | ||
482 | { 0x0c, 0x24 }, | ||
483 | { 0x0c, 0x24 }, | ||
484 | { 0x0d, 0x24 }, | ||
485 | { 0x11, 0x01 }, | ||
486 | { 0x12, 0x24 }, | ||
487 | { 0x13, 0x01 }, | ||
488 | { 0x14, 0x84 }, | ||
489 | { 0x15, 0x01 }, | ||
490 | { 0x16, 0x03 }, | ||
491 | { 0x17, 0x2f }, | ||
492 | { 0x18, 0xcf }, | ||
493 | { 0x19, 0x06 }, | ||
494 | { 0x1a, 0xf5 }, | ||
495 | { 0x1b, 0x00 }, | ||
496 | { 0x20, 0x18 }, | ||
497 | { 0x21, 0x80 }, | ||
498 | { 0x22, 0x80 }, | ||
499 | { 0x23, 0x00 }, | ||
500 | { 0x26, 0xa2 }, | ||
501 | { 0x27, 0xea }, | ||
502 | { 0x28, 0x20 }, | ||
503 | { 0x29, 0x00 }, | ||
504 | { 0x2a, 0x10 }, | ||
505 | { 0x2b, 0x00 }, | ||
506 | { 0x2c, 0x88 }, | ||
507 | { 0x2d, 0x91 }, | ||
508 | { 0x2e, 0x80 }, | ||
509 | { 0x2f, 0x44 }, | ||
510 | { 0x60, 0x27 }, | ||
511 | { 0x61, 0x02 }, | ||
512 | { 0x62, 0x5f }, | ||
513 | { 0x63, 0xd5 }, | ||
514 | { 0x64, 0x57 }, | ||
515 | { 0x65, 0x83 }, | ||
516 | { 0x66, 0x55 }, | ||
517 | { 0x67, 0x92 }, | ||
518 | { 0x68, 0xcf }, | ||
519 | { 0x69, 0x76 }, | ||
520 | { 0x6a, 0x22 }, | ||
521 | { 0x6b, 0x00 }, | ||
522 | { 0x6c, 0x02 }, | ||
523 | { 0x6d, 0x44 }, | ||
524 | { 0x6e, 0x80 }, | ||
525 | { 0x6f, 0x1d }, | ||
526 | { 0x70, 0x8b }, | ||
527 | { 0x71, 0x00 }, | ||
528 | { 0x72, 0x14 }, | ||
529 | { 0x73, 0x54 }, | ||
530 | { 0x74, 0x00 }, | ||
531 | { 0x75, 0x8e }, | ||
532 | { 0x76, 0x00 }, | ||
533 | { 0x77, 0xff }, | ||
534 | { 0x78, 0x80 }, | ||
535 | { 0x79, 0x80 }, | ||
536 | { 0x7a, 0x80 }, | ||
537 | { 0x7b, 0xe2 }, | ||
538 | { 0x7c, 0x00 }, | ||
539 | }; | ||
540 | |||
541 | /* 7640 and 7648. The defaults should be OK for most registers. */ | ||
542 | static const struct ov_i2c_regvals norm_7640[] = { | ||
543 | { 0x12, 0x80 }, | ||
544 | { 0x12, 0x14 }, | ||
545 | }; | ||
546 | |||
547 | /* 7670. Defaults taken from OmniVision provided data, | ||
548 | * as provided by Jonathan Corbet of OLPC */ | ||
549 | static const struct ov_i2c_regvals norm_7670[] = { | ||
550 | { OV7670_REG_COM7, OV7670_COM7_RESET }, | ||
551 | { OV7670_REG_TSLB, 0x04 }, /* OV */ | ||
552 | { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ | ||
553 | { OV7670_REG_CLKRC, 0x01 }, | ||
554 | /* | ||
555 | * Set the hardware window. These values from OV don't entirely | ||
556 | * make sense - hstop is less than hstart. But they work... | ||
557 | */ | ||
558 | { OV7670_REG_HSTART, 0x13 }, | ||
559 | { OV7670_REG_HSTOP, 0x01 }, | ||
560 | { OV7670_REG_HREF, 0xb6 }, | ||
561 | { OV7670_REG_VSTART, 0x02 }, | ||
562 | { OV7670_REG_VSTOP, 0x7a }, | ||
563 | { OV7670_REG_VREF, 0x0a }, | ||
564 | |||
565 | { OV7670_REG_COM3, 0 }, | ||
566 | { OV7670_REG_COM14, 0 }, | ||
567 | /* Mystery scaling numbers */ | ||
568 | { 0x70, 0x3a }, | ||
569 | { 0x71, 0x35 }, | ||
570 | { 0x72, 0x11 }, | ||
571 | { 0x73, 0xf0 }, | ||
572 | { 0xa2, 0x02 }, | ||
573 | /* { OV7670_REG_COM10, 0x0 }, */ | ||
574 | |||
575 | /* Gamma curve values */ | ||
576 | { 0x7a, 0x20 }, | ||
577 | { 0x7b, 0x10 }, | ||
578 | { 0x7c, 0x1e }, | ||
579 | { 0x7d, 0x35 }, | ||
580 | { 0x7e, 0x5a }, | ||
581 | { 0x7f, 0x69 }, | ||
582 | { 0x80, 0x76 }, | ||
583 | { 0x81, 0x80 }, | ||
584 | { 0x82, 0x88 }, | ||
585 | { 0x83, 0x8f }, | ||
586 | { 0x84, 0x96 }, | ||
587 | { 0x85, 0xa3 }, | ||
588 | { 0x86, 0xaf }, | ||
589 | { 0x87, 0xc4 }, | ||
590 | { 0x88, 0xd7 }, | ||
591 | { 0x89, 0xe8 }, | ||
592 | |||
593 | /* AGC and AEC parameters. Note we start by disabling those features, | ||
594 | then turn them only after tweaking the values. */ | ||
595 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
596 | | OV7670_COM8_AECSTEP | ||
597 | | OV7670_COM8_BFILT }, | ||
598 | { OV7670_REG_GAIN, 0 }, | ||
599 | { OV7670_REG_AECH, 0 }, | ||
600 | { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */ | ||
601 | { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ | ||
602 | { OV7670_REG_BD50MAX, 0x05 }, | ||
603 | { OV7670_REG_BD60MAX, 0x07 }, | ||
604 | { OV7670_REG_AEW, 0x95 }, | ||
605 | { OV7670_REG_AEB, 0x33 }, | ||
606 | { OV7670_REG_VPT, 0xe3 }, | ||
607 | { OV7670_REG_HAECC1, 0x78 }, | ||
608 | { OV7670_REG_HAECC2, 0x68 }, | ||
609 | { 0xa1, 0x03 }, /* magic */ | ||
610 | { OV7670_REG_HAECC3, 0xd8 }, | ||
611 | { OV7670_REG_HAECC4, 0xd8 }, | ||
612 | { OV7670_REG_HAECC5, 0xf0 }, | ||
613 | { OV7670_REG_HAECC6, 0x90 }, | ||
614 | { OV7670_REG_HAECC7, 0x94 }, | ||
615 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
616 | | OV7670_COM8_AECSTEP | ||
617 | | OV7670_COM8_BFILT | ||
618 | | OV7670_COM8_AGC | ||
619 | | OV7670_COM8_AEC }, | ||
620 | |||
621 | /* Almost all of these are magic "reserved" values. */ | ||
622 | { OV7670_REG_COM5, 0x61 }, | ||
623 | { OV7670_REG_COM6, 0x4b }, | ||
624 | { 0x16, 0x02 }, | ||
625 | { OV7670_REG_MVFP, 0x07 }, | ||
626 | { 0x21, 0x02 }, | ||
627 | { 0x22, 0x91 }, | ||
628 | { 0x29, 0x07 }, | ||
629 | { 0x33, 0x0b }, | ||
630 | { 0x35, 0x0b }, | ||
631 | { 0x37, 0x1d }, | ||
632 | { 0x38, 0x71 }, | ||
633 | { 0x39, 0x2a }, | ||
634 | { OV7670_REG_COM12, 0x78 }, | ||
635 | { 0x4d, 0x40 }, | ||
636 | { 0x4e, 0x20 }, | ||
637 | { OV7670_REG_GFIX, 0 }, | ||
638 | { 0x6b, 0x4a }, | ||
639 | { 0x74, 0x10 }, | ||
640 | { 0x8d, 0x4f }, | ||
641 | { 0x8e, 0 }, | ||
642 | { 0x8f, 0 }, | ||
643 | { 0x90, 0 }, | ||
644 | { 0x91, 0 }, | ||
645 | { 0x96, 0 }, | ||
646 | { 0x9a, 0 }, | ||
647 | { 0xb0, 0x84 }, | ||
648 | { 0xb1, 0x0c }, | ||
649 | { 0xb2, 0x0e }, | ||
650 | { 0xb3, 0x82 }, | ||
651 | { 0xb8, 0x0a }, | ||
652 | |||
653 | /* More reserved magic, some of which tweaks white balance */ | ||
654 | { 0x43, 0x0a }, | ||
655 | { 0x44, 0xf0 }, | ||
656 | { 0x45, 0x34 }, | ||
657 | { 0x46, 0x58 }, | ||
658 | { 0x47, 0x28 }, | ||
659 | { 0x48, 0x3a }, | ||
660 | { 0x59, 0x88 }, | ||
661 | { 0x5a, 0x88 }, | ||
662 | { 0x5b, 0x44 }, | ||
663 | { 0x5c, 0x67 }, | ||
664 | { 0x5d, 0x49 }, | ||
665 | { 0x5e, 0x0e }, | ||
666 | { 0x6c, 0x0a }, | ||
667 | { 0x6d, 0x55 }, | ||
668 | { 0x6e, 0x11 }, | ||
669 | { 0x6f, 0x9f }, | ||
670 | /* "9e for advance AWB" */ | ||
671 | { 0x6a, 0x40 }, | ||
672 | { OV7670_REG_BLUE, 0x40 }, | ||
673 | { OV7670_REG_RED, 0x60 }, | ||
674 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
675 | | OV7670_COM8_AECSTEP | ||
676 | | OV7670_COM8_BFILT | ||
677 | | OV7670_COM8_AGC | ||
678 | | OV7670_COM8_AEC | ||
679 | | OV7670_COM8_AWB }, | ||
680 | |||
681 | /* Matrix coefficients */ | ||
682 | { 0x4f, 0x80 }, | ||
683 | { 0x50, 0x80 }, | ||
684 | { 0x51, 0 }, | ||
685 | { 0x52, 0x22 }, | ||
686 | { 0x53, 0x5e }, | ||
687 | { 0x54, 0x80 }, | ||
688 | { 0x58, 0x9e }, | ||
689 | |||
690 | { OV7670_REG_COM16, OV7670_COM16_AWBGAIN }, | ||
691 | { OV7670_REG_EDGE, 0 }, | ||
692 | { 0x75, 0x05 }, | ||
693 | { 0x76, 0xe1 }, | ||
694 | { 0x4c, 0 }, | ||
695 | { 0x77, 0x01 }, | ||
696 | { OV7670_REG_COM13, OV7670_COM13_GAMMA | ||
697 | | OV7670_COM13_UVSAT | ||
698 | | 2}, /* was 3 */ | ||
699 | { 0x4b, 0x09 }, | ||
700 | { 0xc9, 0x60 }, | ||
701 | { OV7670_REG_COM16, 0x38 }, | ||
702 | { 0x56, 0x40 }, | ||
703 | |||
704 | { 0x34, 0x11 }, | ||
705 | { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, | ||
706 | { 0xa4, 0x88 }, | ||
707 | { 0x96, 0 }, | ||
708 | { 0x97, 0x30 }, | ||
709 | { 0x98, 0x20 }, | ||
710 | { 0x99, 0x30 }, | ||
711 | { 0x9a, 0x84 }, | ||
712 | { 0x9b, 0x29 }, | ||
713 | { 0x9c, 0x03 }, | ||
714 | { 0x9d, 0x4c }, | ||
715 | { 0x9e, 0x3f }, | ||
716 | { 0x78, 0x04 }, | ||
717 | |||
718 | /* Extra-weird stuff. Some sort of multiplexor register */ | ||
719 | { 0x79, 0x01 }, | ||
720 | { 0xc8, 0xf0 }, | ||
721 | { 0x79, 0x0f }, | ||
722 | { 0xc8, 0x00 }, | ||
723 | { 0x79, 0x10 }, | ||
724 | { 0xc8, 0x7e }, | ||
725 | { 0x79, 0x0a }, | ||
726 | { 0xc8, 0x80 }, | ||
727 | { 0x79, 0x0b }, | ||
728 | { 0xc8, 0x01 }, | ||
729 | { 0x79, 0x0c }, | ||
730 | { 0xc8, 0x0f }, | ||
731 | { 0x79, 0x0d }, | ||
732 | { 0xc8, 0x20 }, | ||
733 | { 0x79, 0x09 }, | ||
734 | { 0xc8, 0x80 }, | ||
735 | { 0x79, 0x02 }, | ||
736 | { 0xc8, 0xc0 }, | ||
737 | { 0x79, 0x03 }, | ||
738 | { 0xc8, 0x40 }, | ||
739 | { 0x79, 0x05 }, | ||
740 | { 0xc8, 0x30 }, | ||
741 | { 0x79, 0x26 }, | ||
742 | }; | ||
743 | |||
744 | static const struct ov_i2c_regvals norm_8610[] = { | ||
745 | { 0x12, 0x80 }, | ||
746 | { 0x00, 0x00 }, | ||
747 | { 0x01, 0x80 }, | ||
748 | { 0x02, 0x80 }, | ||
749 | { 0x03, 0xc0 }, | ||
750 | { 0x04, 0x30 }, | ||
751 | { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
752 | { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */ | ||
753 | { 0x0a, 0x86 }, | ||
754 | { 0x0b, 0xb0 }, | ||
755 | { 0x0c, 0x20 }, | ||
756 | { 0x0d, 0x20 }, | ||
757 | { 0x11, 0x01 }, | ||
758 | { 0x12, 0x25 }, | ||
759 | { 0x13, 0x01 }, | ||
760 | { 0x14, 0x04 }, | ||
761 | { 0x15, 0x01 }, /* Lin and Win think different about UV order */ | ||
762 | { 0x16, 0x03 }, | ||
763 | { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */ | ||
764 | { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */ | ||
765 | { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */ | ||
766 | { 0x1a, 0xf5 }, | ||
767 | { 0x1b, 0x00 }, | ||
768 | { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */ | ||
769 | { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */ | ||
770 | { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */ | ||
771 | { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */ | ||
772 | { 0x26, 0xa2 }, | ||
773 | { 0x27, 0xea }, | ||
774 | { 0x28, 0x00 }, | ||
775 | { 0x29, 0x00 }, | ||
776 | { 0x2a, 0x80 }, | ||
777 | { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */ | ||
778 | { 0x2c, 0xac }, | ||
779 | { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */ | ||
780 | { 0x2e, 0x80 }, | ||
781 | { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */ | ||
782 | { 0x4c, 0x00 }, | ||
783 | { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
784 | { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */ | ||
785 | { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */ | ||
786 | { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */ | ||
787 | { 0x63, 0xff }, | ||
788 | { 0x64, 0x53 }, /* new windrv 090403 says 0x57, | ||
789 | * maybe thats wrong */ | ||
790 | { 0x65, 0x00 }, | ||
791 | { 0x66, 0x55 }, | ||
792 | { 0x67, 0xb0 }, | ||
793 | { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */ | ||
794 | { 0x69, 0x02 }, | ||
795 | { 0x6a, 0x22 }, | ||
796 | { 0x6b, 0x00 }, | ||
797 | { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but | ||
798 | * deleting bit7 colors the first images red */ | ||
799 | { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
800 | { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
801 | { 0x6f, 0x01 }, | ||
802 | { 0x70, 0x8b }, | ||
803 | { 0x71, 0x00 }, | ||
804 | { 0x72, 0x14 }, | ||
805 | { 0x73, 0x54 }, | ||
806 | { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */ | ||
807 | { 0x75, 0x0e }, | ||
808 | { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */ | ||
809 | { 0x77, 0xff }, | ||
810 | { 0x78, 0x80 }, | ||
811 | { 0x79, 0x80 }, | ||
812 | { 0x7a, 0x80 }, | ||
813 | { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */ | ||
814 | { 0x7c, 0x00 }, | ||
815 | { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */ | ||
816 | { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */ | ||
817 | { 0x7f, 0xfb }, | ||
818 | { 0x80, 0x28 }, | ||
819 | { 0x81, 0x00 }, | ||
820 | { 0x82, 0x23 }, | ||
821 | { 0x83, 0x0b }, | ||
822 | { 0x84, 0x00 }, | ||
823 | { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */ | ||
824 | { 0x86, 0xc9 }, | ||
825 | { 0x87, 0x00 }, | ||
826 | { 0x88, 0x00 }, | ||
827 | { 0x89, 0x01 }, | ||
828 | { 0x12, 0x20 }, | ||
829 | { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */ | ||
830 | }; | ||
831 | |||
296 | static unsigned char ov7670_abs_to_sm(unsigned char v) | 832 | static unsigned char ov7670_abs_to_sm(unsigned char v) |
297 | { | 833 | { |
298 | if (v > 127) | 834 | if (v > 127) |
@@ -537,18 +1073,10 @@ static int ov51x_set_slave_ids(struct sd *sd, | |||
537 | rc = reg_w(sd, R51x_I2C_W_SID, slave); | 1073 | rc = reg_w(sd, R51x_I2C_W_SID, slave); |
538 | if (rc < 0) | 1074 | if (rc < 0) |
539 | return rc; | 1075 | return rc; |
1076 | sd->primary_i2c_slave = slave; | ||
540 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); | 1077 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); |
541 | } | 1078 | } |
542 | 1079 | ||
543 | struct ov_regvals { | ||
544 | __u8 reg; | ||
545 | __u8 val; | ||
546 | }; | ||
547 | struct ov_i2c_regvals { | ||
548 | __u8 reg; | ||
549 | __u8 val; | ||
550 | }; | ||
551 | |||
552 | static int write_regvals(struct sd *sd, | 1080 | static int write_regvals(struct sd *sd, |
553 | const struct ov_regvals *regvals, | 1081 | const struct ov_regvals *regvals, |
554 | int n) | 1082 | int n) |
@@ -591,101 +1119,9 @@ static int write_i2c_regvals(struct sd *sd, | |||
591 | static int ov8xx0_configure(struct sd *sd) | 1119 | static int ov8xx0_configure(struct sd *sd) |
592 | { | 1120 | { |
593 | int rc; | 1121 | int rc; |
594 | static const struct ov_i2c_regvals norm_8610[] = { | ||
595 | { 0x12, 0x80 }, | ||
596 | { 0x00, 0x00 }, | ||
597 | { 0x01, 0x80 }, | ||
598 | { 0x02, 0x80 }, | ||
599 | { 0x03, 0xc0 }, | ||
600 | { 0x04, 0x30 }, | ||
601 | { 0x05, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
602 | { 0x06, 0x70 }, /* was 0x80, new from windrv 090403 */ | ||
603 | { 0x0a, 0x86 }, | ||
604 | { 0x0b, 0xb0 }, | ||
605 | { 0x0c, 0x20 }, | ||
606 | { 0x0d, 0x20 }, | ||
607 | { 0x11, 0x01 }, | ||
608 | { 0x12, 0x25 }, | ||
609 | { 0x13, 0x01 }, | ||
610 | { 0x14, 0x04 }, | ||
611 | { 0x15, 0x01 }, /* Lin and Win think different about UV order */ | ||
612 | { 0x16, 0x03 }, | ||
613 | { 0x17, 0x38 }, /* was 0x2f, new from windrv 090403 */ | ||
614 | { 0x18, 0xea }, /* was 0xcf, new from windrv 090403 */ | ||
615 | { 0x19, 0x02 }, /* was 0x06, new from windrv 090403 */ | ||
616 | { 0x1a, 0xf5 }, | ||
617 | { 0x1b, 0x00 }, | ||
618 | { 0x20, 0xd0 }, /* was 0x90, new from windrv 090403 */ | ||
619 | { 0x23, 0xc0 }, /* was 0x00, new from windrv 090403 */ | ||
620 | { 0x24, 0x30 }, /* was 0x1d, new from windrv 090403 */ | ||
621 | { 0x25, 0x50 }, /* was 0x57, new from windrv 090403 */ | ||
622 | { 0x26, 0xa2 }, | ||
623 | { 0x27, 0xea }, | ||
624 | { 0x28, 0x00 }, | ||
625 | { 0x29, 0x00 }, | ||
626 | { 0x2a, 0x80 }, | ||
627 | { 0x2b, 0xc8 }, /* was 0xcc, new from windrv 090403 */ | ||
628 | { 0x2c, 0xac }, | ||
629 | { 0x2d, 0x45 }, /* was 0xd5, new from windrv 090403 */ | ||
630 | { 0x2e, 0x80 }, | ||
631 | { 0x2f, 0x14 }, /* was 0x01, new from windrv 090403 */ | ||
632 | { 0x4c, 0x00 }, | ||
633 | { 0x4d, 0x30 }, /* was 0x10, new from windrv 090403 */ | ||
634 | { 0x60, 0x02 }, /* was 0x01, new from windrv 090403 */ | ||
635 | { 0x61, 0x00 }, /* was 0x09, new from windrv 090403 */ | ||
636 | { 0x62, 0x5f }, /* was 0xd7, new from windrv 090403 */ | ||
637 | { 0x63, 0xff }, | ||
638 | { 0x64, 0x53 }, /* new windrv 090403 says 0x57, | ||
639 | * maybe thats wrong */ | ||
640 | { 0x65, 0x00 }, | ||
641 | { 0x66, 0x55 }, | ||
642 | { 0x67, 0xb0 }, | ||
643 | { 0x68, 0xc0 }, /* was 0xaf, new from windrv 090403 */ | ||
644 | { 0x69, 0x02 }, | ||
645 | { 0x6a, 0x22 }, | ||
646 | { 0x6b, 0x00 }, | ||
647 | { 0x6c, 0x99 }, /* was 0x80, old windrv says 0x00, but | ||
648 | deleting bit7 colors the first images red */ | ||
649 | { 0x6d, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
650 | { 0x6e, 0x11 }, /* was 0x00, new from windrv 090403 */ | ||
651 | { 0x6f, 0x01 }, | ||
652 | { 0x70, 0x8b }, | ||
653 | { 0x71, 0x00 }, | ||
654 | { 0x72, 0x14 }, | ||
655 | { 0x73, 0x54 }, | ||
656 | { 0x74, 0x00 },/* 0x60? - was 0x00, new from windrv 090403 */ | ||
657 | { 0x75, 0x0e }, | ||
658 | { 0x76, 0x02 }, /* was 0x02, new from windrv 090403 */ | ||
659 | { 0x77, 0xff }, | ||
660 | { 0x78, 0x80 }, | ||
661 | { 0x79, 0x80 }, | ||
662 | { 0x7a, 0x80 }, | ||
663 | { 0x7b, 0x10 }, /* was 0x13, new from windrv 090403 */ | ||
664 | { 0x7c, 0x00 }, | ||
665 | { 0x7d, 0x08 }, /* was 0x09, new from windrv 090403 */ | ||
666 | { 0x7e, 0x08 }, /* was 0xc0, new from windrv 090403 */ | ||
667 | { 0x7f, 0xfb }, | ||
668 | { 0x80, 0x28 }, | ||
669 | { 0x81, 0x00 }, | ||
670 | { 0x82, 0x23 }, | ||
671 | { 0x83, 0x0b }, | ||
672 | { 0x84, 0x00 }, | ||
673 | { 0x85, 0x62 }, /* was 0x61, new from windrv 090403 */ | ||
674 | { 0x86, 0xc9 }, | ||
675 | { 0x87, 0x00 }, | ||
676 | { 0x88, 0x00 }, | ||
677 | { 0x89, 0x01 }, | ||
678 | { 0x12, 0x20 }, | ||
679 | { 0x12, 0x25 }, /* was 0x24, new from windrv 090403 */ | ||
680 | }; | ||
681 | 1122 | ||
682 | PDEBUG(D_PROBE, "starting ov8xx0 configuration"); | 1123 | PDEBUG(D_PROBE, "starting ov8xx0 configuration"); |
683 | 1124 | ||
684 | if (init_ov_sensor(sd) < 0) | ||
685 | PDEBUG(D_ERR|D_PROBE, "Failed to read sensor ID"); | ||
686 | else | ||
687 | PDEBUG(D_PROBE, "OV86x0 initialized"); | ||
688 | |||
689 | /* Detect sensor (sub)type */ | 1125 | /* Detect sensor (sub)type */ |
690 | rc = i2c_r(sd, OV7610_REG_COM_I); | 1126 | rc = i2c_r(sd, OV7610_REG_COM_I); |
691 | if (rc < 0) { | 1127 | if (rc < 0) { |
@@ -698,9 +1134,6 @@ static int ov8xx0_configure(struct sd *sd) | |||
698 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); | 1134 | PDEBUG(D_ERR, "Unknown image sensor version: %d", rc & 3); |
699 | return -1; | 1135 | return -1; |
700 | } | 1136 | } |
701 | PDEBUG(D_PROBE, "Writing 8610 registers"); | ||
702 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | ||
703 | return -1; | ||
704 | 1137 | ||
705 | /* Set sensor-specific vars */ | 1138 | /* Set sensor-specific vars */ |
706 | /* sd->sif = 0; already done */ | 1139 | /* sd->sif = 0; already done */ |
@@ -714,252 +1147,6 @@ static int ov7xx0_configure(struct sd *sd) | |||
714 | { | 1147 | { |
715 | int rc, high, low; | 1148 | int rc, high, low; |
716 | 1149 | ||
717 | /* Lawrence Glaister <lg@jfm.bc.ca> reports: | ||
718 | * | ||
719 | * Register 0x0f in the 7610 has the following effects: | ||
720 | * | ||
721 | * 0x85 (AEC method 1): Best overall, good contrast range | ||
722 | * 0x45 (AEC method 2): Very overexposed | ||
723 | * 0xa5 (spec sheet default): Ok, but the black level is | ||
724 | * shifted resulting in loss of contrast | ||
725 | * 0x05 (old driver setting): very overexposed, too much | ||
726 | * contrast | ||
727 | */ | ||
728 | static const struct ov_i2c_regvals norm_7610[] = { | ||
729 | { 0x10, 0xff }, | ||
730 | { 0x16, 0x06 }, | ||
731 | { 0x28, 0x24 }, | ||
732 | { 0x2b, 0xac }, | ||
733 | { 0x12, 0x00 }, | ||
734 | { 0x38, 0x81 }, | ||
735 | { 0x28, 0x24 }, /* 0c */ | ||
736 | { 0x0f, 0x85 }, /* lg's setting */ | ||
737 | { 0x15, 0x01 }, | ||
738 | { 0x20, 0x1c }, | ||
739 | { 0x23, 0x2a }, | ||
740 | { 0x24, 0x10 }, | ||
741 | { 0x25, 0x8a }, | ||
742 | { 0x26, 0xa2 }, | ||
743 | { 0x27, 0xc2 }, | ||
744 | { 0x2a, 0x04 }, | ||
745 | { 0x2c, 0xfe }, | ||
746 | { 0x2d, 0x93 }, | ||
747 | { 0x30, 0x71 }, | ||
748 | { 0x31, 0x60 }, | ||
749 | { 0x32, 0x26 }, | ||
750 | { 0x33, 0x20 }, | ||
751 | { 0x34, 0x48 }, | ||
752 | { 0x12, 0x24 }, | ||
753 | { 0x11, 0x01 }, | ||
754 | { 0x0c, 0x24 }, | ||
755 | { 0x0d, 0x24 }, | ||
756 | }; | ||
757 | |||
758 | static const struct ov_i2c_regvals norm_7620[] = { | ||
759 | { 0x00, 0x00 }, /* gain */ | ||
760 | { 0x01, 0x80 }, /* blue gain */ | ||
761 | { 0x02, 0x80 }, /* red gain */ | ||
762 | { 0x03, 0xc0 }, /* OV7670_REG_VREF */ | ||
763 | { 0x06, 0x60 }, | ||
764 | { 0x07, 0x00 }, | ||
765 | { 0x0c, 0x24 }, | ||
766 | { 0x0c, 0x24 }, | ||
767 | { 0x0d, 0x24 }, | ||
768 | { 0x11, 0x01 }, | ||
769 | { 0x12, 0x24 }, | ||
770 | { 0x13, 0x01 }, | ||
771 | { 0x14, 0x84 }, | ||
772 | { 0x15, 0x01 }, | ||
773 | { 0x16, 0x03 }, | ||
774 | { 0x17, 0x2f }, | ||
775 | { 0x18, 0xcf }, | ||
776 | { 0x19, 0x06 }, | ||
777 | { 0x1a, 0xf5 }, | ||
778 | { 0x1b, 0x00 }, | ||
779 | { 0x20, 0x18 }, | ||
780 | { 0x21, 0x80 }, | ||
781 | { 0x22, 0x80 }, | ||
782 | { 0x23, 0x00 }, | ||
783 | { 0x26, 0xa2 }, | ||
784 | { 0x27, 0xea }, | ||
785 | { 0x28, 0x20 }, | ||
786 | { 0x29, 0x00 }, | ||
787 | { 0x2a, 0x10 }, | ||
788 | { 0x2b, 0x00 }, | ||
789 | { 0x2c, 0x88 }, | ||
790 | { 0x2d, 0x91 }, | ||
791 | { 0x2e, 0x80 }, | ||
792 | { 0x2f, 0x44 }, | ||
793 | { 0x60, 0x27 }, | ||
794 | { 0x61, 0x02 }, | ||
795 | { 0x62, 0x5f }, | ||
796 | { 0x63, 0xd5 }, | ||
797 | { 0x64, 0x57 }, | ||
798 | { 0x65, 0x83 }, | ||
799 | { 0x66, 0x55 }, | ||
800 | { 0x67, 0x92 }, | ||
801 | { 0x68, 0xcf }, | ||
802 | { 0x69, 0x76 }, | ||
803 | { 0x6a, 0x22 }, | ||
804 | { 0x6b, 0x00 }, | ||
805 | { 0x6c, 0x02 }, | ||
806 | { 0x6d, 0x44 }, | ||
807 | { 0x6e, 0x80 }, | ||
808 | { 0x6f, 0x1d }, | ||
809 | { 0x70, 0x8b }, | ||
810 | { 0x71, 0x00 }, | ||
811 | { 0x72, 0x14 }, | ||
812 | { 0x73, 0x54 }, | ||
813 | { 0x74, 0x00 }, | ||
814 | { 0x75, 0x8e }, | ||
815 | { 0x76, 0x00 }, | ||
816 | { 0x77, 0xff }, | ||
817 | { 0x78, 0x80 }, | ||
818 | { 0x79, 0x80 }, | ||
819 | { 0x7a, 0x80 }, | ||
820 | { 0x7b, 0xe2 }, | ||
821 | { 0x7c, 0x00 }, | ||
822 | }; | ||
823 | |||
824 | /* 7640 and 7648. The defaults should be OK for most registers. */ | ||
825 | static const struct ov_i2c_regvals norm_7640[] = { | ||
826 | { 0x12, 0x80 }, | ||
827 | { 0x12, 0x14 }, | ||
828 | }; | ||
829 | |||
830 | /* 7670. Defaults taken from OmniVision provided data, | ||
831 | * as provided by Jonathan Corbet of OLPC */ | ||
832 | static const struct ov_i2c_regvals norm_7670[] = { | ||
833 | { OV7670_REG_COM7, OV7670_COM7_RESET }, | ||
834 | { OV7670_REG_TSLB, 0x04 }, /* OV */ | ||
835 | { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ | ||
836 | { OV7670_REG_CLKRC, 0x01 }, | ||
837 | /* | ||
838 | * Set the hardware window. These values from OV don't entirely | ||
839 | * make sense - hstop is less than hstart. But they work... | ||
840 | */ | ||
841 | { OV7670_REG_HSTART, 0x13 }, { OV7670_REG_HSTOP, 0x01 }, | ||
842 | { OV7670_REG_HREF, 0xb6 }, { OV7670_REG_VSTART, 0x02 }, | ||
843 | { OV7670_REG_VSTOP, 0x7a }, { OV7670_REG_VREF, 0x0a }, | ||
844 | |||
845 | { OV7670_REG_COM3, 0 }, { OV7670_REG_COM14, 0 }, | ||
846 | /* Mystery scaling numbers */ | ||
847 | { 0x70, 0x3a }, { 0x71, 0x35 }, | ||
848 | { 0x72, 0x11 }, { 0x73, 0xf0 }, | ||
849 | { 0xa2, 0x02 }, | ||
850 | /* { OV7670_REG_COM10, 0x0 }, */ | ||
851 | |||
852 | /* Gamma curve values */ | ||
853 | { 0x7a, 0x20 }, | ||
854 | { 0x7b, 0x10 }, | ||
855 | { 0x7c, 0x1e }, | ||
856 | { 0x7d, 0x35 }, | ||
857 | { 0x7e, 0x5a }, { 0x7f, 0x69 }, | ||
858 | { 0x80, 0x76 }, { 0x81, 0x80 }, | ||
859 | { 0x82, 0x88 }, { 0x83, 0x8f }, | ||
860 | { 0x84, 0x96 }, { 0x85, 0xa3 }, | ||
861 | { 0x86, 0xaf }, { 0x87, 0xc4 }, | ||
862 | { 0x88, 0xd7 }, { 0x89, 0xe8 }, | ||
863 | |||
864 | /* AGC and AEC parameters. Note we start by disabling those features, | ||
865 | then turn them only after tweaking the values. */ | ||
866 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
867 | | OV7670_COM8_AECSTEP | ||
868 | | OV7670_COM8_BFILT }, | ||
869 | { OV7670_REG_GAIN, 0 }, { OV7670_REG_AECH, 0 }, | ||
870 | { OV7670_REG_COM4, 0x40 }, /* magic reserved bit */ | ||
871 | { OV7670_REG_COM9, 0x18 }, /* 4x gain + magic rsvd bit */ | ||
872 | { OV7670_REG_BD50MAX, 0x05 }, { OV7670_REG_BD60MAX, 0x07 }, | ||
873 | { OV7670_REG_AEW, 0x95 }, { OV7670_REG_AEB, 0x33 }, | ||
874 | { OV7670_REG_VPT, 0xe3 }, { OV7670_REG_HAECC1, 0x78 }, | ||
875 | { OV7670_REG_HAECC2, 0x68 }, | ||
876 | { 0xa1, 0x03 }, /* magic */ | ||
877 | { OV7670_REG_HAECC3, 0xd8 }, { OV7670_REG_HAECC4, 0xd8 }, | ||
878 | { OV7670_REG_HAECC5, 0xf0 }, { OV7670_REG_HAECC6, 0x90 }, | ||
879 | { OV7670_REG_HAECC7, 0x94 }, | ||
880 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
881 | | OV7670_COM8_AECSTEP | ||
882 | | OV7670_COM8_BFILT | ||
883 | | OV7670_COM8_AGC | ||
884 | | OV7670_COM8_AEC }, | ||
885 | |||
886 | /* Almost all of these are magic "reserved" values. */ | ||
887 | { OV7670_REG_COM5, 0x61 }, { OV7670_REG_COM6, 0x4b }, | ||
888 | { 0x16, 0x02 }, | ||
889 | { OV7670_REG_MVFP, 0x07 }, | ||
890 | { 0x21, 0x02 }, { 0x22, 0x91 }, | ||
891 | { 0x29, 0x07 }, { 0x33, 0x0b }, | ||
892 | { 0x35, 0x0b }, { 0x37, 0x1d }, | ||
893 | { 0x38, 0x71 }, { 0x39, 0x2a }, | ||
894 | { OV7670_REG_COM12, 0x78 }, { 0x4d, 0x40 }, | ||
895 | { 0x4e, 0x20 }, { OV7670_REG_GFIX, 0 }, | ||
896 | { 0x6b, 0x4a }, { 0x74, 0x10 }, | ||
897 | { 0x8d, 0x4f }, { 0x8e, 0 }, | ||
898 | { 0x8f, 0 }, { 0x90, 0 }, | ||
899 | { 0x91, 0 }, { 0x96, 0 }, | ||
900 | { 0x9a, 0 }, { 0xb0, 0x84 }, | ||
901 | { 0xb1, 0x0c }, { 0xb2, 0x0e }, | ||
902 | { 0xb3, 0x82 }, { 0xb8, 0x0a }, | ||
903 | |||
904 | /* More reserved magic, some of which tweaks white balance */ | ||
905 | { 0x43, 0x0a }, { 0x44, 0xf0 }, | ||
906 | { 0x45, 0x34 }, { 0x46, 0x58 }, | ||
907 | { 0x47, 0x28 }, { 0x48, 0x3a }, | ||
908 | { 0x59, 0x88 }, { 0x5a, 0x88 }, | ||
909 | { 0x5b, 0x44 }, { 0x5c, 0x67 }, | ||
910 | { 0x5d, 0x49 }, { 0x5e, 0x0e }, | ||
911 | { 0x6c, 0x0a }, { 0x6d, 0x55 }, | ||
912 | { 0x6e, 0x11 }, { 0x6f, 0x9f }, | ||
913 | /* "9e for advance AWB" */ | ||
914 | { 0x6a, 0x40 }, { OV7670_REG_BLUE, 0x40 }, | ||
915 | { OV7670_REG_RED, 0x60 }, | ||
916 | { OV7670_REG_COM8, OV7670_COM8_FASTAEC | ||
917 | | OV7670_COM8_AECSTEP | ||
918 | | OV7670_COM8_BFILT | ||
919 | | OV7670_COM8_AGC | ||
920 | | OV7670_COM8_AEC | ||
921 | | OV7670_COM8_AWB }, | ||
922 | |||
923 | /* Matrix coefficients */ | ||
924 | { 0x4f, 0x80 }, { 0x50, 0x80 }, | ||
925 | { 0x51, 0 }, { 0x52, 0x22 }, | ||
926 | { 0x53, 0x5e }, { 0x54, 0x80 }, | ||
927 | { 0x58, 0x9e }, | ||
928 | |||
929 | { OV7670_REG_COM16, OV7670_COM16_AWBGAIN }, | ||
930 | { OV7670_REG_EDGE, 0 }, | ||
931 | { 0x75, 0x05 }, { 0x76, 0xe1 }, | ||
932 | { 0x4c, 0 }, { 0x77, 0x01 }, | ||
933 | { OV7670_REG_COM13, OV7670_COM13_GAMMA | ||
934 | | OV7670_COM13_UVSAT | ||
935 | | 2}, /* was 3 */ | ||
936 | { 0x4b, 0x09 }, | ||
937 | { 0xc9, 0x60 }, { OV7670_REG_COM16, 0x38 }, | ||
938 | { 0x56, 0x40 }, | ||
939 | |||
940 | { 0x34, 0x11 }, | ||
941 | { OV7670_REG_COM11, OV7670_COM11_EXP|OV7670_COM11_HZAUTO }, | ||
942 | { 0xa4, 0x88 }, { 0x96, 0 }, | ||
943 | { 0x97, 0x30 }, { 0x98, 0x20 }, | ||
944 | { 0x99, 0x30 }, { 0x9a, 0x84 }, | ||
945 | { 0x9b, 0x29 }, { 0x9c, 0x03 }, | ||
946 | { 0x9d, 0x4c }, { 0x9e, 0x3f }, | ||
947 | { 0x78, 0x04 }, | ||
948 | |||
949 | /* Extra-weird stuff. Some sort of multiplexor register */ | ||
950 | { 0x79, 0x01 }, { 0xc8, 0xf0 }, | ||
951 | { 0x79, 0x0f }, { 0xc8, 0x00 }, | ||
952 | { 0x79, 0x10 }, { 0xc8, 0x7e }, | ||
953 | { 0x79, 0x0a }, { 0xc8, 0x80 }, | ||
954 | { 0x79, 0x0b }, { 0xc8, 0x01 }, | ||
955 | { 0x79, 0x0c }, { 0xc8, 0x0f }, | ||
956 | { 0x79, 0x0d }, { 0xc8, 0x20 }, | ||
957 | { 0x79, 0x09 }, { 0xc8, 0x80 }, | ||
958 | { 0x79, 0x02 }, { 0xc8, 0xc0 }, | ||
959 | { 0x79, 0x03 }, { 0xc8, 0x40 }, | ||
960 | { 0x79, 0x05 }, { 0xc8, 0x30 }, | ||
961 | { 0x79, 0x26 }, | ||
962 | }; | ||
963 | 1150 | ||
964 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); | 1151 | PDEBUG(D_PROBE, "starting OV7xx0 configuration"); |
965 | 1152 | ||
@@ -1011,8 +1198,9 @@ static int ov7xx0_configure(struct sd *sd) | |||
1011 | switch (low) { | 1198 | switch (low) { |
1012 | case 0x30: | 1199 | case 0x30: |
1013 | PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); | 1200 | PDEBUG(D_PROBE, "Sensor is an OV7630/OV7635"); |
1014 | sd->sensor = SEN_OV7630; | 1201 | PDEBUG(D_ERR, |
1015 | break; | 1202 | "7630 is not supported by this driver"); |
1203 | return -1; | ||
1016 | case 0x40: | 1204 | case 0x40: |
1017 | PDEBUG(D_PROBE, "Sensor is an OV7645"); | 1205 | PDEBUG(D_PROBE, "Sensor is an OV7645"); |
1018 | sd->sensor = SEN_OV7640; /* FIXME */ | 1206 | sd->sensor = SEN_OV7640; /* FIXME */ |
@@ -1038,32 +1226,6 @@ static int ov7xx0_configure(struct sd *sd) | |||
1038 | return -1; | 1226 | return -1; |
1039 | } | 1227 | } |
1040 | 1228 | ||
1041 | switch (sd->sensor) { | ||
1042 | case SEN_OV7620: | ||
1043 | PDEBUG(D_PROBE, "Writing 7620 registers"); | ||
1044 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | ||
1045 | return -1; | ||
1046 | break; | ||
1047 | case SEN_OV7630: | ||
1048 | PDEBUG(D_ERR, "7630 is not supported by this driver version"); | ||
1049 | return -1; | ||
1050 | case SEN_OV7640: | ||
1051 | PDEBUG(D_PROBE, "Writing 7640 registers"); | ||
1052 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | ||
1053 | return -1; | ||
1054 | break; | ||
1055 | case SEN_OV7670: | ||
1056 | PDEBUG(D_PROBE, "Writing 7670 registers"); | ||
1057 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | ||
1058 | return -1; | ||
1059 | break; | ||
1060 | default: | ||
1061 | PDEBUG(D_PROBE, "Writing 7610 registers"); | ||
1062 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | ||
1063 | return -1; | ||
1064 | break; | ||
1065 | } | ||
1066 | |||
1067 | /* Set sensor-specific vars */ | 1229 | /* Set sensor-specific vars */ |
1068 | /* sd->sif = 0; already done */ | 1230 | /* sd->sif = 0; already done */ |
1069 | return 0; | 1231 | return 0; |
@@ -1073,141 +1235,7 @@ static int ov7xx0_configure(struct sd *sd) | |||
1073 | static int ov6xx0_configure(struct sd *sd) | 1235 | static int ov6xx0_configure(struct sd *sd) |
1074 | { | 1236 | { |
1075 | int rc; | 1237 | int rc; |
1076 | static const struct ov_i2c_regvals norm_6x20[] = { | 1238 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); |
1077 | { 0x12, 0x80 }, /* reset */ | ||
1078 | { 0x11, 0x01 }, | ||
1079 | { 0x03, 0x60 }, | ||
1080 | { 0x05, 0x7f }, /* For when autoadjust is off */ | ||
1081 | { 0x07, 0xa8 }, | ||
1082 | /* The ratio of 0x0c and 0x0d controls the white point */ | ||
1083 | { 0x0c, 0x24 }, | ||
1084 | { 0x0d, 0x24 }, | ||
1085 | { 0x0f, 0x15 }, /* COMS */ | ||
1086 | { 0x10, 0x75 }, /* AEC Exposure time */ | ||
1087 | { 0x12, 0x24 }, /* Enable AGC */ | ||
1088 | { 0x14, 0x04 }, | ||
1089 | /* 0x16: 0x06 helps frame stability with moving objects */ | ||
1090 | { 0x16, 0x06 }, | ||
1091 | /* { 0x20, 0x30 }, * Aperture correction enable */ | ||
1092 | { 0x26, 0xb2 }, /* BLC enable */ | ||
1093 | /* 0x28: 0x05 Selects RGB format if RGB on */ | ||
1094 | { 0x28, 0x05 }, | ||
1095 | { 0x2a, 0x04 }, /* Disable framerate adjust */ | ||
1096 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ | ||
1097 | { 0x2d, 0x99 }, | ||
1098 | { 0x33, 0xa0 }, /* Color Processing Parameter */ | ||
1099 | { 0x34, 0xd2 }, /* Max A/D range */ | ||
1100 | { 0x38, 0x8b }, | ||
1101 | { 0x39, 0x40 }, | ||
1102 | |||
1103 | { 0x3c, 0x39 }, /* Enable AEC mode changing */ | ||
1104 | { 0x3c, 0x3c }, /* Change AEC mode */ | ||
1105 | { 0x3c, 0x24 }, /* Disable AEC mode changing */ | ||
1106 | |||
1107 | { 0x3d, 0x80 }, | ||
1108 | /* These next two registers (0x4a, 0x4b) are undocumented. | ||
1109 | * They control the color balance */ | ||
1110 | { 0x4a, 0x80 }, | ||
1111 | { 0x4b, 0x80 }, | ||
1112 | { 0x4d, 0xd2 }, /* This reduces noise a bit */ | ||
1113 | { 0x4e, 0xc1 }, | ||
1114 | { 0x4f, 0x04 }, | ||
1115 | /* Do 50-53 have any effect? */ | ||
1116 | /* Toggle 0x12[2] off and on here? */ | ||
1117 | }; | ||
1118 | |||
1119 | static const struct ov_i2c_regvals norm_6x30[] = { | ||
1120 | { 0x12, 0x80 }, /* Reset */ | ||
1121 | { 0x00, 0x1f }, /* Gain */ | ||
1122 | { 0x01, 0x99 }, /* Blue gain */ | ||
1123 | { 0x02, 0x7c }, /* Red gain */ | ||
1124 | { 0x03, 0xc0 }, /* Saturation */ | ||
1125 | { 0x05, 0x0a }, /* Contrast */ | ||
1126 | { 0x06, 0x95 }, /* Brightness */ | ||
1127 | { 0x07, 0x2d }, /* Sharpness */ | ||
1128 | { 0x0c, 0x20 }, | ||
1129 | { 0x0d, 0x20 }, | ||
1130 | { 0x0e, 0x20 }, | ||
1131 | { 0x0f, 0x05 }, | ||
1132 | { 0x10, 0x9a }, | ||
1133 | { 0x11, 0x00 }, /* Pixel clock = fastest */ | ||
1134 | { 0x12, 0x24 }, /* Enable AGC and AWB */ | ||
1135 | { 0x13, 0x21 }, | ||
1136 | { 0x14, 0x80 }, | ||
1137 | { 0x15, 0x01 }, | ||
1138 | { 0x16, 0x03 }, | ||
1139 | { 0x17, 0x38 }, | ||
1140 | { 0x18, 0xea }, | ||
1141 | { 0x19, 0x04 }, | ||
1142 | { 0x1a, 0x93 }, | ||
1143 | { 0x1b, 0x00 }, | ||
1144 | { 0x1e, 0xc4 }, | ||
1145 | { 0x1f, 0x04 }, | ||
1146 | { 0x20, 0x20 }, | ||
1147 | { 0x21, 0x10 }, | ||
1148 | { 0x22, 0x88 }, | ||
1149 | { 0x23, 0xc0 }, /* Crystal circuit power level */ | ||
1150 | { 0x25, 0x9a }, /* Increase AEC black ratio */ | ||
1151 | { 0x26, 0xb2 }, /* BLC enable */ | ||
1152 | { 0x27, 0xa2 }, | ||
1153 | { 0x28, 0x00 }, | ||
1154 | { 0x29, 0x00 }, | ||
1155 | { 0x2a, 0x84 }, /* 60 Hz power */ | ||
1156 | { 0x2b, 0xa8 }, /* 60 Hz power */ | ||
1157 | { 0x2c, 0xa0 }, | ||
1158 | { 0x2d, 0x95 }, /* Enable auto-brightness */ | ||
1159 | { 0x2e, 0x88 }, | ||
1160 | { 0x33, 0x26 }, | ||
1161 | { 0x34, 0x03 }, | ||
1162 | { 0x36, 0x8f }, | ||
1163 | { 0x37, 0x80 }, | ||
1164 | { 0x38, 0x83 }, | ||
1165 | { 0x39, 0x80 }, | ||
1166 | { 0x3a, 0x0f }, | ||
1167 | { 0x3b, 0x3c }, | ||
1168 | { 0x3c, 0x1a }, | ||
1169 | { 0x3d, 0x80 }, | ||
1170 | { 0x3e, 0x80 }, | ||
1171 | { 0x3f, 0x0e }, | ||
1172 | { 0x40, 0x00 }, /* White bal */ | ||
1173 | { 0x41, 0x00 }, /* White bal */ | ||
1174 | { 0x42, 0x80 }, | ||
1175 | { 0x43, 0x3f }, /* White bal */ | ||
1176 | { 0x44, 0x80 }, | ||
1177 | { 0x45, 0x20 }, | ||
1178 | { 0x46, 0x20 }, | ||
1179 | { 0x47, 0x80 }, | ||
1180 | { 0x48, 0x7f }, | ||
1181 | { 0x49, 0x00 }, | ||
1182 | { 0x4a, 0x00 }, | ||
1183 | { 0x4b, 0x80 }, | ||
1184 | { 0x4c, 0xd0 }, | ||
1185 | { 0x4d, 0x10 }, /* U = 0.563u, V = 0.714v */ | ||
1186 | { 0x4e, 0x40 }, | ||
1187 | { 0x4f, 0x07 }, /* UV avg., col. killer: max */ | ||
1188 | { 0x50, 0xff }, | ||
1189 | { 0x54, 0x23 }, /* Max AGC gain: 18dB */ | ||
1190 | { 0x55, 0xff }, | ||
1191 | { 0x56, 0x12 }, | ||
1192 | { 0x57, 0x81 }, | ||
1193 | { 0x58, 0x75 }, | ||
1194 | { 0x59, 0x01 }, /* AGC dark current comp.: +1 */ | ||
1195 | { 0x5a, 0x2c }, | ||
1196 | { 0x5b, 0x0f }, /* AWB chrominance levels */ | ||
1197 | { 0x5c, 0x10 }, | ||
1198 | { 0x3d, 0x80 }, | ||
1199 | { 0x27, 0xa6 }, | ||
1200 | { 0x12, 0x20 }, /* Toggle AWB */ | ||
1201 | { 0x12, 0x24 }, | ||
1202 | }; | ||
1203 | |||
1204 | PDEBUG(D_PROBE, "starting sensor configuration"); | ||
1205 | |||
1206 | if (init_ov_sensor(sd) < 0) { | ||
1207 | PDEBUG(D_ERR, "Failed to read sensor ID."); | ||
1208 | return -1; | ||
1209 | } | ||
1210 | PDEBUG(D_PROBE, "OV6xx0 sensor detected"); | ||
1211 | 1239 | ||
1212 | /* Detect sensor (sub)type */ | 1240 | /* Detect sensor (sub)type */ |
1213 | rc = i2c_r(sd, OV7610_REG_COM_I); | 1241 | rc = i2c_r(sd, OV7610_REG_COM_I); |
@@ -1251,15 +1279,6 @@ static int ov6xx0_configure(struct sd *sd) | |||
1251 | /* Set sensor-specific vars */ | 1279 | /* Set sensor-specific vars */ |
1252 | sd->sif = 1; | 1280 | sd->sif = 1; |
1253 | 1281 | ||
1254 | if (sd->sensor == SEN_OV6620) { | ||
1255 | PDEBUG(D_PROBE, "Writing 6x20 registers"); | ||
1256 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | ||
1257 | return -1; | ||
1258 | } else { | ||
1259 | PDEBUG(D_PROBE, "Writing 6x30 registers"); | ||
1260 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | ||
1261 | return -1; | ||
1262 | } | ||
1263 | return 0; | 1282 | return 0; |
1264 | } | 1283 | } |
1265 | 1284 | ||
@@ -1298,22 +1317,31 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1298 | ov51x_led_control(sd, 0); /* turn LED off */ | 1317 | ov51x_led_control(sd, 0); /* turn LED off */ |
1299 | 1318 | ||
1300 | /* Test for 76xx */ | 1319 | /* Test for 76xx */ |
1301 | sd->primary_i2c_slave = OV7xx0_SID; | ||
1302 | if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0) | 1320 | if (ov51x_set_slave_ids(sd, OV7xx0_SID) < 0) |
1303 | goto error; | 1321 | goto error; |
1304 | 1322 | ||
1305 | /* The OV519 must be more aggressive about sensor detection since | 1323 | /* The OV519 must be more aggressive about sensor detection since |
1306 | * I2C write will never fail if the sensor is not present. We have | 1324 | * I2C write will never fail if the sensor is not present. We have |
1307 | * to try to initialize the sensor to detect its presence */ | 1325 | * to try to initialize the sensor to detect its presence */ |
1308 | if (init_ov_sensor(sd) < 0) { | 1326 | if (init_ov_sensor(sd) >= 0) { |
1327 | if (ov7xx0_configure(sd) < 0) { | ||
1328 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | ||
1329 | goto error; | ||
1330 | } | ||
1331 | } else { | ||
1332 | |||
1309 | /* Test for 6xx0 */ | 1333 | /* Test for 6xx0 */ |
1310 | sd->primary_i2c_slave = OV6xx0_SID; | ||
1311 | if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0) | 1334 | if (ov51x_set_slave_ids(sd, OV6xx0_SID) < 0) |
1312 | goto error; | 1335 | goto error; |
1313 | 1336 | ||
1314 | if (init_ov_sensor(sd) < 0) { | 1337 | if (init_ov_sensor(sd) >= 0) { |
1338 | if (ov6xx0_configure(sd) < 0) { | ||
1339 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | ||
1340 | goto error; | ||
1341 | } | ||
1342 | } else { | ||
1343 | |||
1315 | /* Test for 8xx0 */ | 1344 | /* Test for 8xx0 */ |
1316 | sd->primary_i2c_slave = OV8xx0_SID; | ||
1317 | if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0) | 1345 | if (ov51x_set_slave_ids(sd, OV8xx0_SID) < 0) |
1318 | goto error; | 1346 | goto error; |
1319 | 1347 | ||
@@ -1321,24 +1349,13 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1321 | PDEBUG(D_ERR, | 1349 | PDEBUG(D_ERR, |
1322 | "Can't determine sensor slave IDs"); | 1350 | "Can't determine sensor slave IDs"); |
1323 | goto error; | 1351 | goto error; |
1324 | } else { | ||
1325 | if (ov8xx0_configure(sd) < 0) { | ||
1326 | PDEBUG(D_ERR, | ||
1327 | "Failed to configure OV8xx0 sensor"); | ||
1328 | goto error; | ||
1329 | } | ||
1330 | } | 1352 | } |
1331 | } else { | 1353 | if (ov8xx0_configure(sd) < 0) { |
1332 | if (ov6xx0_configure(sd) < 0) { | 1354 | PDEBUG(D_ERR, |
1333 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | 1355 | "Failed to configure OV8xx0 sensor"); |
1334 | goto error; | 1356 | goto error; |
1335 | } | 1357 | } |
1336 | } | 1358 | } |
1337 | } else { | ||
1338 | if (ov7xx0_configure(sd) < 0) { | ||
1339 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | ||
1340 | goto error; | ||
1341 | } | ||
1342 | } | 1359 | } |
1343 | 1360 | ||
1344 | cam = &gspca_dev->cam; | 1361 | cam = &gspca_dev->cam; |
@@ -1355,15 +1372,53 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1355 | sd->colors = COLOR_DEF; | 1372 | sd->colors = COLOR_DEF; |
1356 | sd->hflip = HFLIP_DEF; | 1373 | sd->hflip = HFLIP_DEF; |
1357 | sd->vflip = VFLIP_DEF; | 1374 | sd->vflip = VFLIP_DEF; |
1375 | if (sd->sensor != SEN_OV7670) | ||
1376 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | ||
1377 | | (1 << VFLIP_IDX); | ||
1358 | return 0; | 1378 | return 0; |
1359 | error: | 1379 | error: |
1360 | PDEBUG(D_ERR, "OV519 Config failed"); | 1380 | PDEBUG(D_ERR, "OV519 Config failed"); |
1361 | return -EBUSY; | 1381 | return -EBUSY; |
1362 | } | 1382 | } |
1363 | 1383 | ||
1364 | /* this function is called at open time */ | 1384 | /* this function is called at probe and resume time */ |
1365 | static int sd_open(struct gspca_dev *gspca_dev) | 1385 | static int sd_init(struct gspca_dev *gspca_dev) |
1366 | { | 1386 | { |
1387 | struct sd *sd = (struct sd *) gspca_dev; | ||
1388 | |||
1389 | /* initialize the sensor */ | ||
1390 | switch (sd->sensor) { | ||
1391 | case SEN_OV6620: | ||
1392 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | ||
1393 | return -EIO; | ||
1394 | break; | ||
1395 | case SEN_OV6630: | ||
1396 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | ||
1397 | return -EIO; | ||
1398 | break; | ||
1399 | default: | ||
1400 | /* case SEN_OV7610: */ | ||
1401 | /* case SEN_OV76BE: */ | ||
1402 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | ||
1403 | return -EIO; | ||
1404 | break; | ||
1405 | case SEN_OV7620: | ||
1406 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | ||
1407 | return -EIO; | ||
1408 | break; | ||
1409 | case SEN_OV7640: | ||
1410 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | ||
1411 | return -EIO; | ||
1412 | break; | ||
1413 | case SEN_OV7670: | ||
1414 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | ||
1415 | return -EIO; | ||
1416 | break; | ||
1417 | case SEN_OV8610: | ||
1418 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | ||
1419 | return -EIO; | ||
1420 | break; | ||
1421 | } | ||
1367 | return 0; | 1422 | return 0; |
1368 | } | 1423 | } |
1369 | 1424 | ||
@@ -1827,14 +1882,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1827 | ov51x_led_control((struct sd *) gspca_dev, 0); | 1882 | ov51x_led_control((struct sd *) gspca_dev, 0); |
1828 | } | 1883 | } |
1829 | 1884 | ||
1830 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1831 | { | ||
1832 | } | ||
1833 | |||
1834 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1835 | { | ||
1836 | } | ||
1837 | |||
1838 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1885 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1839 | struct gspca_frame *frame, /* target */ | 1886 | struct gspca_frame *frame, /* target */ |
1840 | __u8 *data, /* isoc packet */ | 1887 | __u8 *data, /* isoc packet */ |
@@ -2091,11 +2138,9 @@ static const struct sd_desc sd_desc = { | |||
2091 | .ctrls = sd_ctrls, | 2138 | .ctrls = sd_ctrls, |
2092 | .nctrls = ARRAY_SIZE(sd_ctrls), | 2139 | .nctrls = ARRAY_SIZE(sd_ctrls), |
2093 | .config = sd_config, | 2140 | .config = sd_config, |
2094 | .open = sd_open, | 2141 | .init = sd_init, |
2095 | .start = sd_start, | 2142 | .start = sd_start, |
2096 | .stopN = sd_stopN, | 2143 | .stopN = sd_stopN, |
2097 | .stop0 = sd_stop0, | ||
2098 | .close = sd_close, | ||
2099 | .pkt_scan = sd_pkt_scan, | 2144 | .pkt_scan = sd_pkt_scan, |
2100 | }; | 2145 | }; |
2101 | 2146 | ||
@@ -2132,6 +2177,10 @@ static struct usb_driver sd_driver = { | |||
2132 | .id_table = device_table, | 2177 | .id_table = device_table, |
2133 | .probe = sd_probe, | 2178 | .probe = sd_probe, |
2134 | .disconnect = gspca_disconnect, | 2179 | .disconnect = gspca_disconnect, |
2180 | #ifdef CONFIG_PM | ||
2181 | .suspend = gspca_suspend, | ||
2182 | .resume = gspca_resume, | ||
2183 | #endif | ||
2135 | }; | 2184 | }; |
2136 | 2185 | ||
2137 | /* -- module insert / remove -- */ | 2186 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c index 7ef18d578811..83b5f740c947 100644 --- a/drivers/media/video/gspca/pac207.c +++ b/drivers/media/video/gspca/pac207.c | |||
@@ -56,12 +56,6 @@ MODULE_LICENSE("GPL"); | |||
56 | #define PAC207_GAIN_KNEE 20 | 56 | #define PAC207_GAIN_KNEE 20 |
57 | 57 | ||
58 | #define PAC207_AUTOGAIN_DEADZONE 30 | 58 | #define PAC207_AUTOGAIN_DEADZONE 30 |
59 | /* We calculating the autogain at the end of the transfer of a frame, at this | ||
60 | moment a frame with the old settings is being transmitted, and a frame is | ||
61 | being captured with the old settings. So if we adjust the autogain we must | ||
62 | ignore atleast the 2 next frames for the new settings to come into effect | ||
63 | before doing any other adjustments */ | ||
64 | #define PAC207_AUTOGAIN_IGNORE_FRAMES 3 | ||
65 | 59 | ||
66 | /* specific webcam descriptor */ | 60 | /* specific webcam descriptor */ |
67 | struct sd { | 61 | struct sd { |
@@ -131,7 +125,8 @@ static struct ctrl sd_ctrls[] = { | |||
131 | .minimum = 0, | 125 | .minimum = 0, |
132 | .maximum = 1, | 126 | .maximum = 1, |
133 | .step = 1, | 127 | .step = 1, |
134 | .default_value = 1, | 128 | #define AUTOGAIN_DEF 1 |
129 | .default_value = AUTOGAIN_DEF, | ||
135 | .flags = 0, | 130 | .flags = 0, |
136 | }, | 131 | }, |
137 | .set = sd_setautogain, | 132 | .set = sd_setautogain, |
@@ -181,9 +176,6 @@ static const __u8 pac207_sensor_init[][8] = { | |||
181 | /* 48 reg_72 Rate Control end BalSize_4a =0x36 */ | 176 | /* 48 reg_72 Rate Control end BalSize_4a =0x36 */ |
182 | static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 }; | 177 | static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 }; |
183 | 178 | ||
184 | static const unsigned char pac207_sof_marker[5] = | ||
185 | { 0xff, 0xff, 0x00, 0xff, 0x96 }; | ||
186 | |||
187 | static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, | 179 | static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, |
188 | const u8 *buffer, u16 length) | 180 | const u8 *buffer, u16 length) |
189 | { | 181 | { |
@@ -259,35 +251,32 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
259 | return -ENODEV; | 251 | return -ENODEV; |
260 | } | 252 | } |
261 | 253 | ||
262 | pac207_write_reg(gspca_dev, 0x41, 0x00); | ||
263 | /* Bit_0=Image Format, | ||
264 | * Bit_1=LED, | ||
265 | * Bit_2=Compression test mode enable */ | ||
266 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | ||
267 | pac207_write_reg(gspca_dev, 0x11, 0x30); /* Analog Bias */ | ||
268 | |||
269 | PDEBUG(D_PROBE, | 254 | PDEBUG(D_PROBE, |
270 | "Pixart PAC207BCA Image Processor and Control Chip detected" | 255 | "Pixart PAC207BCA Image Processor and Control Chip detected" |
271 | " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); | 256 | " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct); |
272 | 257 | ||
273 | cam = &gspca_dev->cam; | 258 | cam = &gspca_dev->cam; |
274 | cam->dev_name = (char *) id->driver_info; | ||
275 | cam->epaddr = 0x05; | 259 | cam->epaddr = 0x05; |
276 | cam->cam_mode = sif_mode; | 260 | cam->cam_mode = sif_mode; |
277 | cam->nmodes = ARRAY_SIZE(sif_mode); | 261 | cam->nmodes = ARRAY_SIZE(sif_mode); |
278 | sd->brightness = PAC207_BRIGHTNESS_DEFAULT; | 262 | sd->brightness = PAC207_BRIGHTNESS_DEFAULT; |
279 | sd->exposure = PAC207_EXPOSURE_DEFAULT; | 263 | sd->exposure = PAC207_EXPOSURE_DEFAULT; |
280 | sd->gain = PAC207_GAIN_DEFAULT; | 264 | sd->gain = PAC207_GAIN_DEFAULT; |
265 | sd->autogain = AUTOGAIN_DEF; | ||
281 | 266 | ||
282 | return 0; | 267 | return 0; |
283 | } | 268 | } |
284 | 269 | ||
285 | /* this function is called at open time */ | 270 | /* this function is called at probe and resume time */ |
286 | static int sd_open(struct gspca_dev *gspca_dev) | 271 | static int sd_init(struct gspca_dev *gspca_dev) |
287 | { | 272 | { |
288 | struct sd *sd = (struct sd *) gspca_dev; | 273 | pac207_write_reg(gspca_dev, 0x41, 0x00); |
274 | /* Bit_0=Image Format, | ||
275 | * Bit_1=LED, | ||
276 | * Bit_2=Compression test mode enable */ | ||
277 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | ||
278 | pac207_write_reg(gspca_dev, 0x11, 0x30); /* Analog Bias */ | ||
289 | 279 | ||
290 | sd->autogain = 1; | ||
291 | return 0; | 280 | return 0; |
292 | } | 281 | } |
293 | 282 | ||
@@ -343,14 +332,8 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
343 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ | 332 | pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ |
344 | } | 333 | } |
345 | 334 | ||
346 | static void sd_stop0(struct gspca_dev *gspca_dev) | 335 | /* Include pac common sof detection functions */ |
347 | { | 336 | #include "pac_common.h" |
348 | } | ||
349 | |||
350 | /* this function is called at close time */ | ||
351 | static void sd_close(struct gspca_dev *gspca_dev) | ||
352 | { | ||
353 | } | ||
354 | 337 | ||
355 | static void pac207_do_auto_gain(struct gspca_dev *gspca_dev) | 338 | static void pac207_do_auto_gain(struct gspca_dev *gspca_dev) |
356 | { | 339 | { |
@@ -365,33 +348,7 @@ static void pac207_do_auto_gain(struct gspca_dev *gspca_dev) | |||
365 | else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, | 348 | else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, |
366 | 100 + sd->brightness / 2, PAC207_AUTOGAIN_DEADZONE, | 349 | 100 + sd->brightness / 2, PAC207_AUTOGAIN_DEADZONE, |
367 | PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE)) | 350 | PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE)) |
368 | sd->autogain_ignore_frames = PAC207_AUTOGAIN_IGNORE_FRAMES; | 351 | sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; |
369 | } | ||
370 | |||
371 | static unsigned char *pac207_find_sof(struct gspca_dev *gspca_dev, | ||
372 | unsigned char *m, int len) | ||
373 | { | ||
374 | struct sd *sd = (struct sd *) gspca_dev; | ||
375 | int i; | ||
376 | |||
377 | /* Search for the SOF marker (fixed part) in the header */ | ||
378 | for (i = 0; i < len; i++) { | ||
379 | if (m[i] == pac207_sof_marker[sd->sof_read]) { | ||
380 | sd->sof_read++; | ||
381 | if (sd->sof_read == sizeof(pac207_sof_marker)) { | ||
382 | PDEBUG(D_STREAM, | ||
383 | "SOF found, bytes to analyze: %u." | ||
384 | " Frame starts at byte #%u", | ||
385 | len, i + 1); | ||
386 | sd->sof_read = 0; | ||
387 | return m + i + 1; | ||
388 | } | ||
389 | } else { | ||
390 | sd->sof_read = 0; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | return NULL; | ||
395 | } | 352 | } |
396 | 353 | ||
397 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 354 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
@@ -402,14 +359,14 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
402 | struct sd *sd = (struct sd *) gspca_dev; | 359 | struct sd *sd = (struct sd *) gspca_dev; |
403 | unsigned char *sof; | 360 | unsigned char *sof; |
404 | 361 | ||
405 | sof = pac207_find_sof(gspca_dev, data, len); | 362 | sof = pac_find_sof(gspca_dev, data, len); |
406 | if (sof) { | 363 | if (sof) { |
407 | int n; | 364 | int n; |
408 | 365 | ||
409 | /* finish decoding current frame */ | 366 | /* finish decoding current frame */ |
410 | n = sof - data; | 367 | n = sof - data; |
411 | if (n > sizeof pac207_sof_marker) | 368 | if (n > sizeof pac_sof_marker) |
412 | n -= sizeof pac207_sof_marker; | 369 | n -= sizeof pac_sof_marker; |
413 | else | 370 | else |
414 | n = 0; | 371 | n = 0; |
415 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, | 372 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
@@ -537,7 +494,7 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | |||
537 | sd->gain = PAC207_GAIN_DEFAULT; | 494 | sd->gain = PAC207_GAIN_DEFAULT; |
538 | if (gspca_dev->streaming) { | 495 | if (gspca_dev->streaming) { |
539 | sd->autogain_ignore_frames = | 496 | sd->autogain_ignore_frames = |
540 | PAC207_AUTOGAIN_IGNORE_FRAMES; | 497 | PAC_AUTOGAIN_IGNORE_FRAMES; |
541 | setexposure(gspca_dev); | 498 | setexposure(gspca_dev); |
542 | setgain(gspca_dev); | 499 | setgain(gspca_dev); |
543 | } | 500 | } |
@@ -560,11 +517,9 @@ static const struct sd_desc sd_desc = { | |||
560 | .ctrls = sd_ctrls, | 517 | .ctrls = sd_ctrls, |
561 | .nctrls = ARRAY_SIZE(sd_ctrls), | 518 | .nctrls = ARRAY_SIZE(sd_ctrls), |
562 | .config = sd_config, | 519 | .config = sd_config, |
563 | .open = sd_open, | 520 | .init = sd_init, |
564 | .start = sd_start, | 521 | .start = sd_start, |
565 | .stopN = sd_stopN, | 522 | .stopN = sd_stopN, |
566 | .stop0 = sd_stop0, | ||
567 | .close = sd_close, | ||
568 | .dq_callback = pac207_do_auto_gain, | 523 | .dq_callback = pac207_do_auto_gain, |
569 | .pkt_scan = sd_pkt_scan, | 524 | .pkt_scan = sd_pkt_scan, |
570 | }; | 525 | }; |
@@ -597,6 +552,10 @@ static struct usb_driver sd_driver = { | |||
597 | .id_table = device_table, | 552 | .id_table = device_table, |
598 | .probe = sd_probe, | 553 | .probe = sd_probe, |
599 | .disconnect = gspca_disconnect, | 554 | .disconnect = gspca_disconnect, |
555 | #ifdef CONFIG_PM | ||
556 | .suspend = gspca_suspend, | ||
557 | .resume = gspca_resume, | ||
558 | #endif | ||
600 | }; | 559 | }; |
601 | 560 | ||
602 | /* -- module insert / remove -- */ | 561 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 815bea6edc44..d4be51843286 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -19,6 +19,36 @@ | |||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* Some documentation about various registers as determined by trial and error. | ||
23 | When the register addresses differ between the 7202 and the 7311 the 2 | ||
24 | different addresses are written as 7302addr/7311addr, when one of the 2 | ||
25 | addresses is a - sign that register description is not valid for the | ||
26 | matching IC. | ||
27 | |||
28 | Register page 1: | ||
29 | |||
30 | Address Description | ||
31 | -/0x08 Unknown compressor related, must always be 8 except when not | ||
32 | in 640x480 resolution and page 4 reg 2 <= 3 then set it to 9 ! | ||
33 | -/0x1b Auto white balance related, bit 0 is AWB enable (inverted) | ||
34 | bits 345 seem to toggle per color gains on/off (inverted) | ||
35 | 0x78 Global control, bit 6 controls the LED (inverted) | ||
36 | -/0x80 JPEG compression ratio ? Best not touched | ||
37 | |||
38 | Register page 3/4: | ||
39 | |||
40 | Address Description | ||
41 | 0x02 Clock divider 2-63, fps =~ 60 / val. Must be a multiple of 3 on | ||
42 | the 7302, so one of 3, 6, 9, ..., except when between 6 and 12? | ||
43 | -/0x0f Master gain 1-245, low value = high gain | ||
44 | 0x10/- Master gain 0-31 | ||
45 | -/0x10 Another gain 0-15, limited influence (1-2x gain I guess) | ||
46 | 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused | ||
47 | -/0x27 Seems to toggle various gains on / off, Setting bit 7 seems to | ||
48 | completely disable the analog amplification block. Set to 0x68 | ||
49 | for max gain, 0x14 for minimal gain. | ||
50 | */ | ||
51 | |||
22 | #define MODULE_NAME "pac7311" | 52 | #define MODULE_NAME "pac7311" |
23 | 53 | ||
24 | #include "gspca.h" | 54 | #include "gspca.h" |
@@ -31,18 +61,23 @@ MODULE_LICENSE("GPL"); | |||
31 | struct sd { | 61 | struct sd { |
32 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 62 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
33 | 63 | ||
34 | int lum_sum; | ||
35 | atomic_t avg_lum; | ||
36 | atomic_t do_gain; | ||
37 | |||
38 | unsigned char brightness; | 64 | unsigned char brightness; |
39 | unsigned char contrast; | 65 | unsigned char contrast; |
40 | unsigned char colors; | 66 | unsigned char colors; |
67 | unsigned char gain; | ||
68 | unsigned char exposure; | ||
41 | unsigned char autogain; | 69 | unsigned char autogain; |
70 | __u8 hflip; | ||
71 | __u8 vflip; | ||
72 | |||
73 | __u8 sensor; | ||
74 | #define SENSOR_PAC7302 0 | ||
75 | #define SENSOR_PAC7311 1 | ||
42 | 76 | ||
43 | char ffseq; | 77 | u8 sof_read; |
44 | signed char ag_cnt; | 78 | u8 autogain_ignore_frames; |
45 | #define AG_CNT_START 13 | 79 | |
80 | atomic_t avg_lum; | ||
46 | }; | 81 | }; |
47 | 82 | ||
48 | /* V4L2 controls supported by the driver */ | 83 | /* V4L2 controls supported by the driver */ |
@@ -54,8 +89,18 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | |||
54 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 89 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
55 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 90 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
56 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 91 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); |
92 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | ||
93 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
94 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | ||
95 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
96 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val); | ||
97 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); | ||
98 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); | ||
99 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); | ||
57 | 100 | ||
58 | static struct ctrl sd_ctrls[] = { | 101 | static struct ctrl sd_ctrls[] = { |
102 | /* This control is pac7302 only */ | ||
103 | #define BRIGHTNESS_IDX 0 | ||
59 | { | 104 | { |
60 | { | 105 | { |
61 | .id = V4L2_CID_BRIGHTNESS, | 106 | .id = V4L2_CID_BRIGHTNESS, |
@@ -71,13 +116,15 @@ static struct ctrl sd_ctrls[] = { | |||
71 | .set = sd_setbrightness, | 116 | .set = sd_setbrightness, |
72 | .get = sd_getbrightness, | 117 | .get = sd_getbrightness, |
73 | }, | 118 | }, |
119 | /* This control is for both the 7302 and the 7311 */ | ||
74 | { | 120 | { |
75 | { | 121 | { |
76 | .id = V4L2_CID_CONTRAST, | 122 | .id = V4L2_CID_CONTRAST, |
77 | .type = V4L2_CTRL_TYPE_INTEGER, | 123 | .type = V4L2_CTRL_TYPE_INTEGER, |
78 | .name = "Contrast", | 124 | .name = "Contrast", |
79 | .minimum = 0, | 125 | .minimum = 0, |
80 | .maximum = 255, | 126 | #define CONTRAST_MAX 255 |
127 | .maximum = CONTRAST_MAX, | ||
81 | .step = 1, | 128 | .step = 1, |
82 | #define CONTRAST_DEF 127 | 129 | #define CONTRAST_DEF 127 |
83 | .default_value = CONTRAST_DEF, | 130 | .default_value = CONTRAST_DEF, |
@@ -85,13 +132,16 @@ static struct ctrl sd_ctrls[] = { | |||
85 | .set = sd_setcontrast, | 132 | .set = sd_setcontrast, |
86 | .get = sd_getcontrast, | 133 | .get = sd_getcontrast, |
87 | }, | 134 | }, |
135 | /* This control is pac7302 only */ | ||
136 | #define SATURATION_IDX 2 | ||
88 | { | 137 | { |
89 | { | 138 | { |
90 | .id = V4L2_CID_SATURATION, | 139 | .id = V4L2_CID_SATURATION, |
91 | .type = V4L2_CTRL_TYPE_INTEGER, | 140 | .type = V4L2_CTRL_TYPE_INTEGER, |
92 | .name = "Color", | 141 | .name = "Saturation", |
93 | .minimum = 0, | 142 | .minimum = 0, |
94 | .maximum = 255, | 143 | #define COLOR_MAX 255 |
144 | .maximum = COLOR_MAX, | ||
95 | .step = 1, | 145 | .step = 1, |
96 | #define COLOR_DEF 127 | 146 | #define COLOR_DEF 127 |
97 | .default_value = COLOR_DEF, | 147 | .default_value = COLOR_DEF, |
@@ -99,6 +149,39 @@ static struct ctrl sd_ctrls[] = { | |||
99 | .set = sd_setcolors, | 149 | .set = sd_setcolors, |
100 | .get = sd_getcolors, | 150 | .get = sd_getcolors, |
101 | }, | 151 | }, |
152 | /* All controls below are for both the 7302 and the 7311 */ | ||
153 | { | ||
154 | { | ||
155 | .id = V4L2_CID_GAIN, | ||
156 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
157 | .name = "Gain", | ||
158 | .minimum = 0, | ||
159 | #define GAIN_MAX 255 | ||
160 | .maximum = GAIN_MAX, | ||
161 | .step = 1, | ||
162 | #define GAIN_DEF 127 | ||
163 | #define GAIN_KNEE 255 /* Gain seems to cause little noise on the pac73xx */ | ||
164 | .default_value = GAIN_DEF, | ||
165 | }, | ||
166 | .set = sd_setgain, | ||
167 | .get = sd_getgain, | ||
168 | }, | ||
169 | { | ||
170 | { | ||
171 | .id = V4L2_CID_EXPOSURE, | ||
172 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
173 | .name = "Exposure", | ||
174 | .minimum = 0, | ||
175 | #define EXPOSURE_MAX 255 | ||
176 | .maximum = EXPOSURE_MAX, | ||
177 | .step = 1, | ||
178 | #define EXPOSURE_DEF 16 /* 32 ms / 30 fps */ | ||
179 | #define EXPOSURE_KNEE 50 /* 100 ms / 10 fps */ | ||
180 | .default_value = EXPOSURE_DEF, | ||
181 | }, | ||
182 | .set = sd_setexposure, | ||
183 | .get = sd_getexposure, | ||
184 | }, | ||
102 | { | 185 | { |
103 | { | 186 | { |
104 | .id = V4L2_CID_AUTOGAIN, | 187 | .id = V4L2_CID_AUTOGAIN, |
@@ -113,101 +196,207 @@ static struct ctrl sd_ctrls[] = { | |||
113 | .set = sd_setautogain, | 196 | .set = sd_setautogain, |
114 | .get = sd_getautogain, | 197 | .get = sd_getautogain, |
115 | }, | 198 | }, |
199 | { | ||
200 | { | ||
201 | .id = V4L2_CID_HFLIP, | ||
202 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
203 | .name = "Mirror", | ||
204 | .minimum = 0, | ||
205 | .maximum = 1, | ||
206 | .step = 1, | ||
207 | #define HFLIP_DEF 0 | ||
208 | .default_value = HFLIP_DEF, | ||
209 | }, | ||
210 | .set = sd_sethflip, | ||
211 | .get = sd_gethflip, | ||
212 | }, | ||
213 | { | ||
214 | { | ||
215 | .id = V4L2_CID_VFLIP, | ||
216 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
217 | .name = "Vflip", | ||
218 | .minimum = 0, | ||
219 | .maximum = 1, | ||
220 | .step = 1, | ||
221 | #define VFLIP_DEF 0 | ||
222 | .default_value = VFLIP_DEF, | ||
223 | }, | ||
224 | .set = sd_setvflip, | ||
225 | .get = sd_getvflip, | ||
226 | }, | ||
116 | }; | 227 | }; |
117 | 228 | ||
118 | static struct v4l2_pix_format vga_mode[] = { | 229 | static struct v4l2_pix_format vga_mode[] = { |
119 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 230 | {160, 120, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE, |
120 | .bytesperline = 160, | 231 | .bytesperline = 160, |
121 | .sizeimage = 160 * 120 * 3 / 8 + 590, | 232 | .sizeimage = 160 * 120 * 3 / 8 + 590, |
122 | .colorspace = V4L2_COLORSPACE_JPEG, | 233 | .colorspace = V4L2_COLORSPACE_JPEG, |
123 | .priv = 2}, | 234 | .priv = 2}, |
124 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 235 | {320, 240, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE, |
125 | .bytesperline = 320, | 236 | .bytesperline = 320, |
126 | .sizeimage = 320 * 240 * 3 / 8 + 590, | 237 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
127 | .colorspace = V4L2_COLORSPACE_JPEG, | 238 | .colorspace = V4L2_COLORSPACE_JPEG, |
128 | .priv = 1}, | 239 | .priv = 1}, |
129 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 240 | {640, 480, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE, |
130 | .bytesperline = 640, | 241 | .bytesperline = 640, |
131 | .sizeimage = 640 * 480 * 3 / 8 + 590, | 242 | .sizeimage = 640 * 480 * 3 / 8 + 590, |
132 | .colorspace = V4L2_COLORSPACE_JPEG, | 243 | .colorspace = V4L2_COLORSPACE_JPEG, |
133 | .priv = 0}, | 244 | .priv = 0}, |
134 | }; | 245 | }; |
135 | 246 | ||
136 | #define PAC7311_JPEG_HEADER_SIZE (sizeof pac7311_jpeg_header) /* (594) */ | 247 | /* pac 7302 */ |
137 | 248 | static const __u8 init_7302[] = { | |
138 | static const __u8 pac7311_jpeg_header[] = { | 249 | /* index,value */ |
139 | 0xff, 0xd8, | 250 | 0xff, 0x01, /* page 1 */ |
140 | 0xff, 0xe0, 0x00, 0x03, 0x20, | 251 | 0x78, 0x00, /* deactivate */ |
141 | 0xff, 0xc0, 0x00, 0x11, 0x08, | 252 | 0xff, 0x01, |
142 | 0x01, 0xe0, /* 12: height */ | 253 | 0x78, 0x40, /* led off */ |
143 | 0x02, 0x80, /* 14: width */ | 254 | }; |
144 | 0x03, /* 16 */ | 255 | static const __u8 start_7302[] = { |
145 | 0x01, 0x21, 0x00, | 256 | /* index, len, [value]* */ |
146 | 0x02, 0x11, 0x01, | 257 | 0xff, 1, 0x00, /* page 0 */ |
147 | 0x03, 0x11, 0x01, | 258 | 0x00, 12, 0x01, 0x40, 0x40, 0x40, 0x01, 0xe0, 0x02, 0x80, |
148 | 0xff, 0xdb, 0x00, 0x84, | 259 | 0x00, 0x00, 0x00, 0x00, |
149 | 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, | 260 | 0x0d, 24, 0x03, 0x01, 0x00, 0xb5, 0x07, 0xcb, 0x00, 0x00, |
150 | 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, | 261 | 0x07, 0xc8, 0x00, 0xea, 0x07, 0xcf, 0x07, 0xf7, |
151 | 0x16, 0x18, 0x31, 0x23, 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, | 262 | 0x07, 0x7e, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x11, |
152 | 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40, 0x48, 0x5c, 0x4e, 0x40, | 263 | 0x26, 2, 0xaa, 0xaa, |
153 | 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51, 0x57, 0x5f, | 264 | 0x2e, 1, 0x31, |
154 | 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64, | 265 | 0x38, 1, 0x01, |
155 | 0x78, 0x5c, 0x65, 0x67, 0x63, 0x01, 0x11, 0x12, 0x12, 0x18, | 266 | 0x3a, 3, 0x14, 0xff, 0x5a, |
156 | 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, | 267 | 0x43, 11, 0x00, 0x0a, 0x18, 0x11, 0x01, 0x2c, 0x88, 0x11, |
157 | 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, | 268 | 0x00, 0x54, 0x11, |
158 | 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, | 269 | 0x55, 1, 0x00, |
159 | 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, | 270 | 0x62, 4, 0x10, 0x1e, 0x1e, 0x18, |
160 | 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, | 271 | 0x6b, 1, 0x00, |
161 | 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, | 272 | 0x6e, 3, 0x08, 0x06, 0x00, |
162 | 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, | 273 | 0x72, 3, 0x00, 0xff, 0x00, |
163 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 274 | 0x7d, 23, 0x01, 0x01, 0x58, 0x46, 0x50, 0x3c, 0x50, 0x3c, |
164 | 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, | 275 | 0x54, 0x46, 0x54, 0x56, 0x52, 0x50, 0x52, 0x50, |
165 | 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, | 276 | 0x56, 0x64, 0xa4, 0x00, 0xda, 0x00, 0x00, |
166 | 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, | 277 | 0xa2, 10, 0x22, 0x2c, 0x3c, 0x54, 0x69, 0x7c, 0x9c, 0xb9, |
167 | 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, | 278 | 0xd2, 0xeb, |
168 | 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, | 279 | 0xaf, 1, 0x02, |
169 | 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, | 280 | 0xb5, 2, 0x08, 0x08, |
170 | 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, | 281 | 0xb8, 2, 0x08, 0x88, |
171 | 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, | 282 | 0xc4, 4, 0xae, 0x01, 0x04, 0x01, |
172 | 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, | 283 | 0xcc, 1, 0x00, |
173 | 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, | 284 | 0xd1, 11, 0x01, 0x30, 0x49, 0x5e, 0x6f, 0x7f, 0x8e, 0xa9, |
174 | 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, | 285 | 0xc1, 0xd7, 0xec, |
175 | 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, | 286 | 0xdc, 1, 0x01, |
176 | 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, | 287 | 0xff, 1, 0x01, /* page 1 */ |
177 | 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, | 288 | 0x12, 3, 0x02, 0x00, 0x01, |
178 | 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, | 289 | 0x3e, 2, 0x00, 0x00, |
179 | 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, | 290 | 0x76, 5, 0x01, 0x20, 0x40, 0x00, 0xf2, |
180 | 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, | 291 | 0x7c, 1, 0x00, |
181 | 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, | 292 | 0x7f, 10, 0x4b, 0x0f, 0x01, 0x2c, 0x02, 0x58, 0x03, 0x20, |
182 | 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, | 293 | 0x02, 0x00, |
183 | 0xf9, 0xfa, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, | 294 | 0x96, 5, 0x01, 0x10, 0x04, 0x01, 0x04, |
184 | 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 295 | 0xc8, 14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, |
185 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, | 296 | 0x07, 0x00, 0x01, 0x07, 0x04, 0x01, |
186 | 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, | 297 | 0xd8, 1, 0x01, |
187 | 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, | 298 | 0xdb, 2, 0x00, 0x01, |
188 | 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, | 299 | 0xde, 7, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x00, |
189 | 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, | 300 | 0xe6, 4, 0x00, 0x00, 0x00, 0x01, |
190 | 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, | 301 | 0xeb, 1, 0x00, |
191 | 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, | 302 | 0xff, 1, 0x02, /* page 2 */ |
192 | 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, | 303 | 0x22, 1, 0x00, |
193 | 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, | 304 | 0xff, 1, 0x03, /* page 3 */ |
194 | 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, | 305 | 0x00, 255, /* load the page 3 */ |
195 | 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, | 306 | 0x11, 1, 0x01, |
196 | 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, | 307 | 0xff, 1, 0x02, /* page 2 */ |
197 | 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, | 308 | 0x13, 1, 0x00, |
198 | 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, | 309 | 0x22, 4, 0x1f, 0xa4, 0xf0, 0x96, |
199 | 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, | 310 | 0x27, 2, 0x14, 0x0c, |
200 | 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, | 311 | 0x2a, 5, 0xc8, 0x00, 0x18, 0x12, 0x22, |
201 | 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, | 312 | 0x64, 8, 0x00, 0x00, 0xf0, 0x01, 0x14, 0x44, 0x44, 0x44, |
202 | 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, | 313 | 0x6e, 1, 0x08, |
203 | 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, | 314 | 0xff, 1, 0x01, /* page 1 */ |
204 | 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, | 315 | 0x78, 1, 0x00, |
205 | 0x11, 0x00, 0x3f, 0x00 | 316 | 0, 0 /* end of sequence */ |
317 | }; | ||
318 | |||
319 | /* page 3 - the value 0xaa says skip the index - see reg_w_page() */ | ||
320 | static const __u8 page3_7302[] = { | ||
321 | 0x90, 0x40, 0x03, 0x50, 0xc2, 0x01, 0x14, 0x16, | ||
322 | 0x14, 0x12, 0x00, 0x00, 0x00, 0x02, 0x33, 0x00, | ||
323 | 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
324 | 0x00, 0x00, 0x00, 0x47, 0x01, 0xb3, 0x01, 0x00, | ||
325 | 0x00, 0x08, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x21, | ||
326 | 0x00, 0x00, 0x00, 0x54, 0xf4, 0x02, 0x52, 0x54, | ||
327 | 0xa4, 0xb8, 0xe0, 0x2a, 0xf6, 0x00, 0x00, 0x00, | ||
328 | 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
329 | 0x00, 0xfc, 0x00, 0xf2, 0x1f, 0x04, 0x00, 0x00, | ||
330 | 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x10, 0x00, 0x00, | ||
331 | 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
332 | 0x00, 0x40, 0xff, 0x03, 0x19, 0x00, 0x00, 0x00, | ||
333 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
334 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xc8, | ||
335 | 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, | ||
336 | 0x08, 0x10, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, | ||
337 | 0x01, 0x00, 0x02, 0x47, 0x00, 0x00, 0x00, 0x00, | ||
338 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
339 | 0x00, 0x02, 0xfa, 0x00, 0x64, 0x5a, 0x28, 0x00, | ||
340 | 0x00 | ||
341 | }; | ||
342 | |||
343 | /* pac 7311 */ | ||
344 | static const __u8 init_7311[] = { | ||
345 | 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */ | ||
346 | 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */ | ||
347 | 0x78, 0x44, /* Bit_0=start stream, Bit_6=LED */ | ||
348 | 0xff, 0x04, | ||
349 | 0x27, 0x80, | ||
350 | 0x28, 0xca, | ||
351 | 0x29, 0x53, | ||
352 | 0x2a, 0x0e, | ||
353 | 0xff, 0x01, | ||
354 | 0x3e, 0x20, | ||
355 | }; | ||
356 | |||
357 | static const __u8 start_7311[] = { | ||
358 | /* index, len, [value]* */ | ||
359 | 0xff, 1, 0x01, /* page 1 */ | ||
360 | 0x02, 43, 0x48, 0x0a, 0x40, 0x08, 0x00, 0x00, 0x08, 0x00, | ||
361 | 0x06, 0xff, 0x11, 0xff, 0x5a, 0x30, 0x90, 0x4c, | ||
362 | 0x00, 0x07, 0x00, 0x0a, 0x10, 0x00, 0xa0, 0x10, | ||
363 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00, | ||
364 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
365 | 0x00, 0x00, 0x00, | ||
366 | 0x3e, 42, 0x00, 0x00, 0x78, 0x52, 0x4a, 0x52, 0x78, 0x6e, | ||
367 | 0x48, 0x46, 0x48, 0x6e, 0x5f, 0x49, 0x42, 0x49, | ||
368 | 0x5f, 0x5f, 0x49, 0x42, 0x49, 0x5f, 0x6e, 0x48, | ||
369 | 0x46, 0x48, 0x6e, 0x78, 0x52, 0x4a, 0x52, 0x78, | ||
370 | 0x00, 0x00, 0x09, 0x1b, 0x34, 0x49, 0x5c, 0x9b, | ||
371 | 0xd0, 0xff, | ||
372 | 0x78, 6, 0x44, 0x00, 0xf2, 0x01, 0x01, 0x80, | ||
373 | 0x7f, 18, 0x2a, 0x1c, 0x00, 0xc8, 0x02, 0x58, 0x03, 0x84, | ||
374 | 0x12, 0x00, 0x1a, 0x04, 0x08, 0x0c, 0x10, 0x14, | ||
375 | 0x18, 0x20, | ||
376 | 0x96, 3, 0x01, 0x08, 0x04, | ||
377 | 0xa0, 4, 0x44, 0x44, 0x44, 0x04, | ||
378 | 0xf0, 13, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x00, | ||
379 | 0x3f, 0x00, 0x0a, 0x01, 0x00, | ||
380 | 0xff, 1, 0x04, /* page 4 */ | ||
381 | 0x00, 254, /* load the page 4 */ | ||
382 | 0x11, 1, 0x01, | ||
383 | 0, 0 /* end of sequence */ | ||
384 | }; | ||
385 | |||
386 | /* page 4 - the value 0xaa says skip the index - see reg_w_page() */ | ||
387 | static const __u8 page4_7311[] = { | ||
388 | 0xaa, 0xaa, 0x04, 0x54, 0x07, 0x2b, 0x09, 0x0f, | ||
389 | 0x09, 0x00, 0xaa, 0xaa, 0x07, 0x00, 0x00, 0x62, | ||
390 | 0x08, 0xaa, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
391 | 0x00, 0x00, 0x00, 0x03, 0xa0, 0x01, 0xf4, 0xaa, | ||
392 | 0xaa, 0x00, 0x08, 0xaa, 0x03, 0xaa, 0x00, 0x68, | ||
393 | 0xca, 0x10, 0x06, 0x78, 0x00, 0x00, 0x00, 0x00, | ||
394 | 0x23, 0x28, 0x04, 0x11, 0x00, 0x00 | ||
206 | }; | 395 | }; |
207 | 396 | ||
208 | static void reg_w_buf(struct gspca_dev *gspca_dev, | 397 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
209 | __u16 index, | 398 | __u8 index, |
210 | const char *buffer, __u16 len) | 399 | const char *buffer, int len) |
211 | { | 400 | { |
212 | memcpy(gspca_dev->usb_buf, buffer, len); | 401 | memcpy(gspca_dev->usb_buf, buffer, len); |
213 | usb_control_msg(gspca_dev->dev, | 402 | usb_control_msg(gspca_dev->dev, |
@@ -219,21 +408,9 @@ static void reg_w_buf(struct gspca_dev *gspca_dev, | |||
219 | 500); | 408 | 500); |
220 | } | 409 | } |
221 | 410 | ||
222 | static __u8 reg_r(struct gspca_dev *gspca_dev, | ||
223 | __u16 index) | ||
224 | { | ||
225 | usb_control_msg(gspca_dev->dev, | ||
226 | usb_rcvctrlpipe(gspca_dev->dev, 0), | ||
227 | 0, /* request */ | ||
228 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
229 | 0, /* value */ | ||
230 | index, gspca_dev->usb_buf, 1, | ||
231 | 500); | ||
232 | return gspca_dev->usb_buf[0]; | ||
233 | } | ||
234 | 411 | ||
235 | static void reg_w(struct gspca_dev *gspca_dev, | 412 | static void reg_w(struct gspca_dev *gspca_dev, |
236 | __u16 index, | 413 | __u8 index, |
237 | __u8 value) | 414 | __u8 value) |
238 | { | 415 | { |
239 | gspca_dev->usb_buf[0] = value; | 416 | gspca_dev->usb_buf[0] = value; |
@@ -241,10 +418,78 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
241 | usb_sndctrlpipe(gspca_dev->dev, 0), | 418 | usb_sndctrlpipe(gspca_dev->dev, 0), |
242 | 0, /* request */ | 419 | 0, /* request */ |
243 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 420 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
244 | value, index, gspca_dev->usb_buf, 1, | 421 | 0, index, gspca_dev->usb_buf, 1, |
245 | 500); | 422 | 500); |
246 | } | 423 | } |
247 | 424 | ||
425 | static void reg_w_seq(struct gspca_dev *gspca_dev, | ||
426 | const __u8 *seq, int len) | ||
427 | { | ||
428 | while (--len >= 0) { | ||
429 | reg_w(gspca_dev, seq[0], seq[1]); | ||
430 | seq += 2; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | /* load the beginning of a page */ | ||
435 | static void reg_w_page(struct gspca_dev *gspca_dev, | ||
436 | const __u8 *page, int len) | ||
437 | { | ||
438 | int index; | ||
439 | |||
440 | for (index = 0; index < len; index++) { | ||
441 | if (page[index] == 0xaa) /* skip this index */ | ||
442 | continue; | ||
443 | gspca_dev->usb_buf[0] = page[index]; | ||
444 | usb_control_msg(gspca_dev->dev, | ||
445 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
446 | 0, /* request */ | ||
447 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
448 | 0, index, gspca_dev->usb_buf, 1, | ||
449 | 500); | ||
450 | } | ||
451 | } | ||
452 | |||
453 | /* output a variable sequence */ | ||
454 | static void reg_w_var(struct gspca_dev *gspca_dev, | ||
455 | const __u8 *seq) | ||
456 | { | ||
457 | int index, len; | ||
458 | |||
459 | for (;;) { | ||
460 | index = *seq++; | ||
461 | len = *seq++; | ||
462 | switch (len) { | ||
463 | case 0: | ||
464 | return; | ||
465 | case 254: | ||
466 | reg_w_page(gspca_dev, page4_7311, sizeof page4_7311); | ||
467 | break; | ||
468 | case 255: | ||
469 | reg_w_page(gspca_dev, page3_7302, sizeof page3_7302); | ||
470 | break; | ||
471 | default: | ||
472 | if (len > 64) { | ||
473 | PDEBUG(D_ERR|D_STREAM, | ||
474 | "Incorrect variable sequence"); | ||
475 | return; | ||
476 | } | ||
477 | while (len > 0) { | ||
478 | if (len < 8) { | ||
479 | reg_w_buf(gspca_dev, index, seq, len); | ||
480 | seq += len; | ||
481 | break; | ||
482 | } | ||
483 | reg_w_buf(gspca_dev, index, seq, 8); | ||
484 | seq += 8; | ||
485 | index += 8; | ||
486 | len -= 8; | ||
487 | } | ||
488 | } | ||
489 | } | ||
490 | /* not reached */ | ||
491 | } | ||
492 | |||
248 | /* this function is called at probe time */ | 493 | /* this function is called at probe time */ |
249 | static int sd_config(struct gspca_dev *gspca_dev, | 494 | static int sd_config(struct gspca_dev *gspca_dev, |
250 | const struct usb_device_id *id) | 495 | const struct usb_device_id *id) |
@@ -252,203 +497,245 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
252 | struct sd *sd = (struct sd *) gspca_dev; | 497 | struct sd *sd = (struct sd *) gspca_dev; |
253 | struct cam *cam; | 498 | struct cam *cam; |
254 | 499 | ||
255 | PDEBUG(D_CONF, "Find Sensor PAC7311"); | ||
256 | reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ | ||
257 | reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ | ||
258 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
259 | reg_w(gspca_dev, 0xff, 0x04); | ||
260 | reg_w(gspca_dev, 0x27, 0x80); | ||
261 | reg_w(gspca_dev, 0x28, 0xca); | ||
262 | reg_w(gspca_dev, 0x29, 0x53); | ||
263 | reg_w(gspca_dev, 0x2a, 0x0e); | ||
264 | reg_w(gspca_dev, 0xff, 0x01); | ||
265 | reg_w(gspca_dev, 0x3e, 0x20); | ||
266 | |||
267 | cam = &gspca_dev->cam; | 500 | cam = &gspca_dev->cam; |
268 | cam->epaddr = 0x05; | 501 | cam->epaddr = 0x05; |
269 | cam->cam_mode = vga_mode; | 502 | |
270 | cam->nmodes = ARRAY_SIZE(vga_mode); | 503 | sd->sensor = id->driver_info; |
504 | if (sd->sensor == SENSOR_PAC7302) { | ||
505 | PDEBUG(D_CONF, "Find Sensor PAC7302"); | ||
506 | cam->cam_mode = &vga_mode[2]; /* only 640x480 */ | ||
507 | cam->nmodes = 1; | ||
508 | } else { | ||
509 | PDEBUG(D_CONF, "Find Sensor PAC7311"); | ||
510 | cam->cam_mode = vga_mode; | ||
511 | cam->nmodes = ARRAY_SIZE(vga_mode); | ||
512 | gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX) | ||
513 | | (1 << SATURATION_IDX); | ||
514 | } | ||
271 | 515 | ||
272 | sd->brightness = BRIGHTNESS_DEF; | 516 | sd->brightness = BRIGHTNESS_DEF; |
273 | sd->contrast = CONTRAST_DEF; | 517 | sd->contrast = CONTRAST_DEF; |
274 | sd->colors = COLOR_DEF; | 518 | sd->colors = COLOR_DEF; |
519 | sd->gain = GAIN_DEF; | ||
520 | sd->exposure = EXPOSURE_DEF; | ||
275 | sd->autogain = AUTOGAIN_DEF; | 521 | sd->autogain = AUTOGAIN_DEF; |
276 | sd->ag_cnt = -1; | 522 | sd->hflip = HFLIP_DEF; |
523 | sd->vflip = VFLIP_DEF; | ||
277 | return 0; | 524 | return 0; |
278 | } | 525 | } |
279 | 526 | ||
280 | static void setbrightness(struct gspca_dev *gspca_dev) | 527 | /* This function is used by pac7302 only */ |
528 | static void setbrightcont(struct gspca_dev *gspca_dev) | ||
529 | { | ||
530 | struct sd *sd = (struct sd *) gspca_dev; | ||
531 | int i, v; | ||
532 | static const __u8 max[10] = | ||
533 | {0x29, 0x33, 0x42, 0x5a, 0x6e, 0x80, 0x9f, 0xbb, | ||
534 | 0xd4, 0xec}; | ||
535 | static const __u8 delta[10] = | ||
536 | {0x35, 0x33, 0x33, 0x2f, 0x2a, 0x25, 0x1e, 0x17, | ||
537 | 0x11, 0x0b}; | ||
538 | |||
539 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
540 | for (i = 0; i < 10; i++) { | ||
541 | v = max[i]; | ||
542 | v += (sd->brightness - BRIGHTNESS_MAX) | ||
543 | * 150 / BRIGHTNESS_MAX; /* 200 ? */ | ||
544 | v -= delta[i] * sd->contrast / CONTRAST_MAX; | ||
545 | if (v < 0) | ||
546 | v = 0; | ||
547 | else if (v > 0xff) | ||
548 | v = 0xff; | ||
549 | reg_w(gspca_dev, 0xa2 + i, v); | ||
550 | } | ||
551 | reg_w(gspca_dev, 0xdc, 0x01); | ||
552 | } | ||
553 | |||
554 | /* This function is used by pac7311 only */ | ||
555 | static void setcontrast(struct gspca_dev *gspca_dev) | ||
281 | { | 556 | { |
282 | struct sd *sd = (struct sd *) gspca_dev; | 557 | struct sd *sd = (struct sd *) gspca_dev; |
283 | int brightness; | ||
284 | 558 | ||
285 | /*jfm: inverted?*/ | ||
286 | brightness = BRIGHTNESS_MAX - sd->brightness; | ||
287 | reg_w(gspca_dev, 0xff, 0x04); | 559 | reg_w(gspca_dev, 0xff, 0x04); |
288 | /* reg_w(gspca_dev, 0x0e, 0x00); */ | 560 | reg_w(gspca_dev, 0x10, sd->contrast >> 4); |
289 | reg_w(gspca_dev, 0x0f, brightness); | ||
290 | /* load registers to sensor (Bit 0, auto clear) */ | 561 | /* load registers to sensor (Bit 0, auto clear) */ |
291 | reg_w(gspca_dev, 0x11, 0x01); | 562 | reg_w(gspca_dev, 0x11, 0x01); |
292 | PDEBUG(D_CONF|D_STREAM, "brightness: %i", brightness); | ||
293 | } | 563 | } |
294 | 564 | ||
295 | static void setcontrast(struct gspca_dev *gspca_dev) | 565 | /* This function is used by pac7302 only */ |
566 | static void setcolors(struct gspca_dev *gspca_dev) | ||
296 | { | 567 | { |
297 | struct sd *sd = (struct sd *) gspca_dev; | 568 | struct sd *sd = (struct sd *) gspca_dev; |
569 | int i, v; | ||
570 | static const int a[9] = | ||
571 | {217, -212, 0, -101, 170, -67, -38, -315, 355}; | ||
572 | static const int b[9] = | ||
573 | {19, 106, 0, 19, 106, 1, 19, 106, 1}; | ||
298 | 574 | ||
299 | reg_w(gspca_dev, 0xff, 0x01); | 575 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
300 | reg_w(gspca_dev, 0x80, sd->contrast); | ||
301 | /* load registers to sensor (Bit 0, auto clear) */ | ||
302 | reg_w(gspca_dev, 0x11, 0x01); | 576 | reg_w(gspca_dev, 0x11, 0x01); |
303 | PDEBUG(D_CONF|D_STREAM, "contrast: %i", sd->contrast); | 577 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
578 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
579 | for (i = 0; i < 9; i++) { | ||
580 | v = a[i] * sd->colors / COLOR_MAX + b[i]; | ||
581 | reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07); | ||
582 | reg_w(gspca_dev, 0x0f + 2 * i + 1, v); | ||
583 | } | ||
584 | reg_w(gspca_dev, 0xdc, 0x01); | ||
585 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); | ||
304 | } | 586 | } |
305 | 587 | ||
306 | static void setcolors(struct gspca_dev *gspca_dev) | 588 | static void setgain(struct gspca_dev *gspca_dev) |
307 | { | 589 | { |
308 | struct sd *sd = (struct sd *) gspca_dev; | 590 | struct sd *sd = (struct sd *) gspca_dev; |
309 | 591 | ||
310 | reg_w(gspca_dev, 0xff, 0x01); | 592 | if (sd->sensor == SENSOR_PAC7302) { |
311 | reg_w(gspca_dev, 0x10, sd->colors); | 593 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
594 | reg_w(gspca_dev, 0x10, sd->gain >> 3); | ||
595 | } else { | ||
596 | int gain = GAIN_MAX - sd->gain; | ||
597 | if (gain < 1) | ||
598 | gain = 1; | ||
599 | else if (gain > 245) | ||
600 | gain = 245; | ||
601 | reg_w(gspca_dev, 0xff, 0x04); /* page 4 */ | ||
602 | reg_w(gspca_dev, 0x0e, 0x00); | ||
603 | reg_w(gspca_dev, 0x0f, gain); | ||
604 | } | ||
312 | /* load registers to sensor (Bit 0, auto clear) */ | 605 | /* load registers to sensor (Bit 0, auto clear) */ |
313 | reg_w(gspca_dev, 0x11, 0x01); | 606 | reg_w(gspca_dev, 0x11, 0x01); |
314 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); | ||
315 | } | 607 | } |
316 | 608 | ||
317 | static void setautogain(struct gspca_dev *gspca_dev) | 609 | static void setexposure(struct gspca_dev *gspca_dev) |
318 | { | 610 | { |
319 | struct sd *sd = (struct sd *) gspca_dev; | 611 | struct sd *sd = (struct sd *) gspca_dev; |
612 | __u8 reg; | ||
613 | |||
614 | /* register 2 of frame 3/4 contains the clock divider configuring the | ||
615 | no fps according to the formula: 60 / reg. sd->exposure is the | ||
616 | desired exposure time in ms. */ | ||
617 | reg = 120 * sd->exposure / 1000; | ||
618 | if (reg < 2) | ||
619 | reg = 2; | ||
620 | else if (reg > 63) | ||
621 | reg = 63; | ||
622 | |||
623 | if (sd->sensor == SENSOR_PAC7302) { | ||
624 | /* On the pac7302 reg2 MUST be a multiple of 3, so round it to | ||
625 | the nearest multiple of 3, except when between 6 and 12? */ | ||
626 | if (reg < 6 || reg > 12) | ||
627 | reg = ((reg + 1) / 3) * 3; | ||
628 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | ||
629 | reg_w(gspca_dev, 0x02, reg); | ||
630 | } else { | ||
631 | reg_w(gspca_dev, 0xff, 0x04); /* page 4 */ | ||
632 | reg_w(gspca_dev, 0x02, reg); | ||
633 | /* Page 1 register 8 must always be 0x08 except when not in | ||
634 | 640x480 mode and Page3/4 reg 2 <= 3 then it must be 9 */ | ||
635 | reg_w(gspca_dev, 0xff, 0x01); | ||
636 | if (gspca_dev->cam.cam_mode[(int)gspca_dev->curr_mode].priv && | ||
637 | reg <= 3) | ||
638 | reg_w(gspca_dev, 0x08, 0x09); | ||
639 | else | ||
640 | reg_w(gspca_dev, 0x08, 0x08); | ||
641 | } | ||
642 | /* load registers to sensor (Bit 0, auto clear) */ | ||
643 | reg_w(gspca_dev, 0x11, 0x01); | ||
644 | } | ||
320 | 645 | ||
321 | if (sd->autogain) { | 646 | static void sethvflip(struct gspca_dev *gspca_dev) |
322 | sd->lum_sum = 0; | 647 | { |
323 | sd->ag_cnt = AG_CNT_START; | 648 | struct sd *sd = (struct sd *) gspca_dev; |
649 | __u8 data; | ||
650 | |||
651 | if (sd->sensor == SENSOR_PAC7302) { | ||
652 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | ||
653 | data = (sd->hflip ? 0x08 : 0x00) | ||
654 | | (sd->vflip ? 0x04 : 0x00); | ||
324 | } else { | 655 | } else { |
325 | sd->ag_cnt = -1; | 656 | reg_w(gspca_dev, 0xff, 0x04); /* page 4 */ |
657 | data = (sd->hflip ? 0x04 : 0x00) | ||
658 | | (sd->vflip ? 0x08 : 0x00); | ||
326 | } | 659 | } |
660 | reg_w(gspca_dev, 0x21, data); | ||
661 | /* load registers to sensor (Bit 0, auto clear) */ | ||
662 | reg_w(gspca_dev, 0x11, 0x01); | ||
327 | } | 663 | } |
328 | 664 | ||
329 | /* this function is called at open time */ | 665 | /* this function is called at probe and resume time */ |
330 | static int sd_open(struct gspca_dev *gspca_dev) | 666 | static int sd_init(struct gspca_dev *gspca_dev) |
331 | { | 667 | { |
332 | reg_w(gspca_dev, 0x78, 0x00); /* Turn on LED */ | 668 | struct sd *sd = (struct sd *) gspca_dev; |
669 | |||
670 | if (sd->sensor == SENSOR_PAC7302) | ||
671 | reg_w_seq(gspca_dev, init_7302, sizeof init_7302); | ||
672 | else | ||
673 | reg_w_seq(gspca_dev, init_7311, sizeof init_7311); | ||
674 | |||
333 | return 0; | 675 | return 0; |
334 | } | 676 | } |
335 | 677 | ||
336 | static void sd_start(struct gspca_dev *gspca_dev) | 678 | static void sd_start(struct gspca_dev *gspca_dev) |
337 | { | 679 | { |
338 | reg_w(gspca_dev, 0xff, 0x01); | 680 | struct sd *sd = (struct sd *) gspca_dev; |
339 | reg_w_buf(gspca_dev, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8); | ||
340 | reg_w_buf(gspca_dev, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8); | ||
341 | reg_w_buf(gspca_dev, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8); | ||
342 | reg_w_buf(gspca_dev, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8); | ||
343 | reg_w_buf(gspca_dev, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8); | ||
344 | reg_w_buf(gspca_dev, 0x002a, "\x00\x00\x00", 3); | ||
345 | reg_w_buf(gspca_dev, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8); | ||
346 | reg_w_buf(gspca_dev, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8); | ||
347 | reg_w_buf(gspca_dev, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8); | ||
348 | reg_w_buf(gspca_dev, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8); | ||
349 | reg_w_buf(gspca_dev, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8); | ||
350 | reg_w_buf(gspca_dev, 0x0066, "\xd0\xff", 2); | ||
351 | reg_w_buf(gspca_dev, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6); | ||
352 | reg_w_buf(gspca_dev, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8); | ||
353 | reg_w_buf(gspca_dev, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8); | ||
354 | reg_w_buf(gspca_dev, 0x008f, "\x18\x20", 2); | ||
355 | reg_w_buf(gspca_dev, 0x0096, "\x01\x08\x04", 3); | ||
356 | reg_w_buf(gspca_dev, 0x00a0, "\x44\x44\x44\x04", 4); | ||
357 | reg_w_buf(gspca_dev, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8); | ||
358 | reg_w_buf(gspca_dev, 0x00f8, "\x3f\x00\x0a\x01\x00", 5); | ||
359 | 681 | ||
360 | reg_w(gspca_dev, 0xff, 0x04); | 682 | sd->sof_read = 0; |
361 | reg_w(gspca_dev, 0x02, 0x04); | 683 | |
362 | reg_w(gspca_dev, 0x03, 0x54); | 684 | if (sd->sensor == SENSOR_PAC7302) { |
363 | reg_w(gspca_dev, 0x04, 0x07); | 685 | reg_w_var(gspca_dev, start_7302); |
364 | reg_w(gspca_dev, 0x05, 0x2b); | 686 | setbrightcont(gspca_dev); |
365 | reg_w(gspca_dev, 0x06, 0x09); | 687 | setcolors(gspca_dev); |
366 | reg_w(gspca_dev, 0x07, 0x0f); | 688 | } else { |
367 | reg_w(gspca_dev, 0x08, 0x09); | 689 | reg_w_var(gspca_dev, start_7311); |
368 | reg_w(gspca_dev, 0x09, 0x00); | 690 | setcontrast(gspca_dev); |
369 | reg_w(gspca_dev, 0x0c, 0x07); | 691 | } |
370 | reg_w(gspca_dev, 0x0d, 0x00); | 692 | setgain(gspca_dev); |
371 | reg_w(gspca_dev, 0x0e, 0x00); | 693 | setexposure(gspca_dev); |
372 | reg_w(gspca_dev, 0x0f, 0x62); | 694 | sethvflip(gspca_dev); |
373 | reg_w(gspca_dev, 0x10, 0x08); | ||
374 | reg_w(gspca_dev, 0x12, 0x07); | ||
375 | reg_w(gspca_dev, 0x13, 0x00); | ||
376 | reg_w(gspca_dev, 0x14, 0x00); | ||
377 | reg_w(gspca_dev, 0x15, 0x00); | ||
378 | reg_w(gspca_dev, 0x16, 0x00); | ||
379 | reg_w(gspca_dev, 0x17, 0x00); | ||
380 | reg_w(gspca_dev, 0x18, 0x00); | ||
381 | reg_w(gspca_dev, 0x19, 0x00); | ||
382 | reg_w(gspca_dev, 0x1a, 0x00); | ||
383 | reg_w(gspca_dev, 0x1b, 0x03); | ||
384 | reg_w(gspca_dev, 0x1c, 0xa0); | ||
385 | reg_w(gspca_dev, 0x1d, 0x01); | ||
386 | reg_w(gspca_dev, 0x1e, 0xf4); | ||
387 | reg_w(gspca_dev, 0x21, 0x00); | ||
388 | reg_w(gspca_dev, 0x22, 0x08); | ||
389 | reg_w(gspca_dev, 0x24, 0x03); | ||
390 | reg_w(gspca_dev, 0x26, 0x00); | ||
391 | reg_w(gspca_dev, 0x27, 0x01); | ||
392 | reg_w(gspca_dev, 0x28, 0xca); | ||
393 | reg_w(gspca_dev, 0x29, 0x10); | ||
394 | reg_w(gspca_dev, 0x2a, 0x06); | ||
395 | reg_w(gspca_dev, 0x2b, 0x78); | ||
396 | reg_w(gspca_dev, 0x2c, 0x00); | ||
397 | reg_w(gspca_dev, 0x2d, 0x00); | ||
398 | reg_w(gspca_dev, 0x2e, 0x00); | ||
399 | reg_w(gspca_dev, 0x2f, 0x00); | ||
400 | reg_w(gspca_dev, 0x30, 0x23); | ||
401 | reg_w(gspca_dev, 0x31, 0x28); | ||
402 | reg_w(gspca_dev, 0x32, 0x04); | ||
403 | reg_w(gspca_dev, 0x33, 0x11); | ||
404 | reg_w(gspca_dev, 0x34, 0x00); | ||
405 | reg_w(gspca_dev, 0x35, 0x00); | ||
406 | reg_w(gspca_dev, 0x11, 0x01); | ||
407 | setcontrast(gspca_dev); | ||
408 | setbrightness(gspca_dev); | ||
409 | setcolors(gspca_dev); | ||
410 | setautogain(gspca_dev); | ||
411 | 695 | ||
412 | /* set correct resolution */ | 696 | /* set correct resolution */ |
413 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { | 697 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
414 | case 2: /* 160x120 */ | 698 | case 2: /* 160x120 pac7311 */ |
415 | reg_w(gspca_dev, 0xff, 0x04); | ||
416 | reg_w(gspca_dev, 0x02, 0x03); | ||
417 | reg_w(gspca_dev, 0xff, 0x01); | 699 | reg_w(gspca_dev, 0xff, 0x01); |
418 | reg_w(gspca_dev, 0x08, 0x09); | ||
419 | reg_w(gspca_dev, 0x17, 0x20); | 700 | reg_w(gspca_dev, 0x17, 0x20); |
420 | reg_w(gspca_dev, 0x1b, 0x00); | ||
421 | /* reg_w(gspca_dev, 0x80, 0x69); */ | ||
422 | reg_w(gspca_dev, 0x87, 0x10); | 701 | reg_w(gspca_dev, 0x87, 0x10); |
423 | break; | 702 | break; |
424 | case 1: /* 320x240 */ | 703 | case 1: /* 320x240 pac7311 */ |
425 | reg_w(gspca_dev, 0xff, 0x04); | ||
426 | reg_w(gspca_dev, 0x02, 0x03); | ||
427 | reg_w(gspca_dev, 0xff, 0x01); | 704 | reg_w(gspca_dev, 0xff, 0x01); |
428 | reg_w(gspca_dev, 0x08, 0x09); | ||
429 | reg_w(gspca_dev, 0x17, 0x30); | 705 | reg_w(gspca_dev, 0x17, 0x30); |
430 | /* reg_w(gspca_dev, 0x80, 0x3f); */ | ||
431 | reg_w(gspca_dev, 0x87, 0x11); | 706 | reg_w(gspca_dev, 0x87, 0x11); |
432 | break; | 707 | break; |
433 | case 0: /* 640x480 */ | 708 | case 0: /* 640x480 */ |
434 | reg_w(gspca_dev, 0xff, 0x04); | 709 | if (sd->sensor == SENSOR_PAC7302) |
435 | reg_w(gspca_dev, 0x02, 0x03); | 710 | break; |
436 | reg_w(gspca_dev, 0xff, 0x01); | 711 | reg_w(gspca_dev, 0xff, 0x01); |
437 | reg_w(gspca_dev, 0x08, 0x08); | ||
438 | reg_w(gspca_dev, 0x17, 0x00); | 712 | reg_w(gspca_dev, 0x17, 0x00); |
439 | /* reg_w(gspca_dev, 0x80, 0x1c); */ | ||
440 | reg_w(gspca_dev, 0x87, 0x12); | 713 | reg_w(gspca_dev, 0x87, 0x12); |
441 | break; | 714 | break; |
442 | } | 715 | } |
443 | 716 | ||
717 | sd->sof_read = 0; | ||
718 | sd->autogain_ignore_frames = 0; | ||
719 | atomic_set(&sd->avg_lum, -1); | ||
720 | |||
444 | /* start stream */ | 721 | /* start stream */ |
445 | reg_w(gspca_dev, 0xff, 0x01); | 722 | reg_w(gspca_dev, 0xff, 0x01); |
446 | reg_w(gspca_dev, 0x78, 0x04); | 723 | if (sd->sensor == SENSOR_PAC7302) |
447 | reg_w(gspca_dev, 0x78, 0x05); | 724 | reg_w(gspca_dev, 0x78, 0x01); |
725 | else | ||
726 | reg_w(gspca_dev, 0x78, 0x05); | ||
448 | } | 727 | } |
449 | 728 | ||
450 | static void sd_stopN(struct gspca_dev *gspca_dev) | 729 | static void sd_stopN(struct gspca_dev *gspca_dev) |
451 | { | 730 | { |
731 | struct sd *sd = (struct sd *) gspca_dev; | ||
732 | |||
733 | if (sd->sensor == SENSOR_PAC7302) { | ||
734 | reg_w(gspca_dev, 0xff, 0x01); | ||
735 | reg_w(gspca_dev, 0x78, 0x00); | ||
736 | reg_w(gspca_dev, 0x78, 0x00); | ||
737 | return; | ||
738 | } | ||
452 | reg_w(gspca_dev, 0xff, 0x04); | 739 | reg_w(gspca_dev, 0xff, 0x04); |
453 | reg_w(gspca_dev, 0x27, 0x80); | 740 | reg_w(gspca_dev, 0x27, 0x80); |
454 | reg_w(gspca_dev, 0x28, 0xca); | 741 | reg_w(gspca_dev, 0x28, 0xca); |
@@ -456,187 +743,147 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
456 | reg_w(gspca_dev, 0x2a, 0x0e); | 743 | reg_w(gspca_dev, 0x2a, 0x0e); |
457 | reg_w(gspca_dev, 0xff, 0x01); | 744 | reg_w(gspca_dev, 0xff, 0x01); |
458 | reg_w(gspca_dev, 0x3e, 0x20); | 745 | reg_w(gspca_dev, 0x3e, 0x20); |
459 | reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ | 746 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ |
460 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | 747 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ |
461 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | 748 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ |
462 | } | 749 | } |
463 | 750 | ||
464 | static void sd_stop0(struct gspca_dev *gspca_dev) | 751 | static void sd_stop0(struct gspca_dev *gspca_dev) |
465 | { | 752 | { |
466 | } | 753 | struct sd *sd = (struct sd *) gspca_dev; |
467 | 754 | ||
468 | /* this function is called at close time */ | 755 | if (sd->sensor == SENSOR_PAC7302) { |
469 | static void sd_close(struct gspca_dev *gspca_dev) | 756 | reg_w(gspca_dev, 0xff, 0x01); |
470 | { | 757 | reg_w(gspca_dev, 0x78, 0x40); |
471 | reg_w(gspca_dev, 0xff, 0x04); | 758 | } |
472 | reg_w(gspca_dev, 0x27, 0x80); | ||
473 | reg_w(gspca_dev, 0x28, 0xca); | ||
474 | reg_w(gspca_dev, 0x29, 0x53); | ||
475 | reg_w(gspca_dev, 0x2a, 0x0e); | ||
476 | reg_w(gspca_dev, 0xff, 0x01); | ||
477 | reg_w(gspca_dev, 0x3e, 0x20); | ||
478 | reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ | ||
479 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
480 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
481 | } | 759 | } |
482 | 760 | ||
761 | /* Include pac common sof detection functions */ | ||
762 | #include "pac_common.h" | ||
763 | |||
483 | static void do_autogain(struct gspca_dev *gspca_dev) | 764 | static void do_autogain(struct gspca_dev *gspca_dev) |
484 | { | 765 | { |
485 | struct sd *sd = (struct sd *) gspca_dev; | 766 | struct sd *sd = (struct sd *) gspca_dev; |
486 | int luma; | 767 | int avg_lum = atomic_read(&sd->avg_lum); |
487 | int luma_mean = 128; | 768 | int desired_lum, deadzone; |
488 | int luma_delta = 20; | ||
489 | __u8 spring = 5; | ||
490 | int Gbright; | ||
491 | 769 | ||
492 | if (!atomic_read(&sd->do_gain)) | 770 | if (avg_lum == -1) |
493 | return; | 771 | return; |
494 | atomic_set(&sd->do_gain, 0); | 772 | |
495 | 773 | if (sd->sensor == SENSOR_PAC7302) { | |
496 | luma = atomic_read(&sd->avg_lum); | 774 | desired_lum = 270 + sd->brightness * 4; |
497 | Gbright = reg_r(gspca_dev, 0x02); | 775 | /* Hack hack, with the 7202 the first exposure step is |
498 | PDEBUG(D_FRAM, "luma mean %d", luma); | 776 | pretty large, so if we're about to make the first |
499 | if (luma < luma_mean - luma_delta || | 777 | exposure increase make the deadzone large to avoid |
500 | luma > luma_mean + luma_delta) { | 778 | oscilating */ |
501 | Gbright += (luma_mean - luma) >> spring; | 779 | if (desired_lum > avg_lum && sd->gain == GAIN_DEF && |
502 | if (Gbright > 0x1a) | 780 | sd->exposure > EXPOSURE_DEF && |
503 | Gbright = 0x1a; | 781 | sd->exposure < 42) |
504 | else if (Gbright < 4) | 782 | deadzone = 90; |
505 | Gbright = 4; | 783 | else |
506 | PDEBUG(D_FRAM, "gbright %d", Gbright); | 784 | deadzone = 30; |
507 | reg_w(gspca_dev, 0xff, 0x04); | 785 | } else { |
508 | reg_w(gspca_dev, 0x0f, Gbright); | 786 | desired_lum = 200; |
509 | /* load registers to sensor (Bit 0, auto clear) */ | 787 | deadzone = 20; |
510 | reg_w(gspca_dev, 0x11, 0x01); | ||
511 | } | 788 | } |
789 | |||
790 | if (sd->autogain_ignore_frames > 0) | ||
791 | sd->autogain_ignore_frames--; | ||
792 | else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum, | ||
793 | deadzone, GAIN_KNEE, EXPOSURE_KNEE)) | ||
794 | sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; | ||
512 | } | 795 | } |
513 | 796 | ||
797 | static const unsigned char pac7311_jpeg_header1[] = { | ||
798 | 0xff, 0xd8, 0xff, 0xc0, 0x00, 0x11, 0x08 | ||
799 | }; | ||
800 | |||
801 | static const unsigned char pac7311_jpeg_header2[] = { | ||
802 | 0x03, 0x01, 0x21, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xda, | ||
803 | 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00 | ||
804 | }; | ||
805 | |||
806 | /* this function is run at interrupt level */ | ||
514 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 807 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
515 | struct gspca_frame *frame, /* target */ | 808 | struct gspca_frame *frame, /* target */ |
516 | __u8 *data, /* isoc packet */ | 809 | __u8 *data, /* isoc packet */ |
517 | int len) /* iso packet length */ | 810 | int len) /* iso packet length */ |
518 | { | 811 | { |
519 | struct sd *sd = (struct sd *) gspca_dev; | 812 | struct sd *sd = (struct sd *) gspca_dev; |
520 | unsigned char tmpbuf[4]; | 813 | unsigned char *sof; |
521 | int i, p, ffseq; | 814 | |
522 | 815 | sof = pac_find_sof(gspca_dev, data, len); | |
523 | /* if (len < 5) { */ | 816 | if (sof) { |
524 | if (len < 6) { | 817 | unsigned char tmpbuf[4]; |
525 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ | 818 | int n, lum_offset, footer_length; |
526 | return; | 819 | |
527 | } | 820 | if (sd->sensor == SENSOR_PAC7302) { |
528 | 821 | /* 6 bytes after the FF D9 EOF marker a number of lumination | |
529 | ffseq = sd->ffseq; | 822 | bytes are send corresponding to different parts of the |
530 | 823 | image, the 14th and 15th byte after the EOF seem to | |
531 | for (p = 0; p < len - 6; p++) { | 824 | correspond to the center of the image */ |
532 | if ((data[0 + p] == 0xff) | 825 | lum_offset = 61 + sizeof pac_sof_marker; |
533 | && (data[1 + p] == 0xff) | 826 | footer_length = 74; |
534 | && (data[2 + p] == 0x00) | 827 | } else { |
535 | && (data[3 + p] == 0xff) | 828 | lum_offset = 24 + sizeof pac_sof_marker; |
536 | && (data[4 + p] == 0x96)) { | 829 | footer_length = 26; |
537 | 830 | } | |
538 | /* start of frame */ | ||
539 | if (sd->ag_cnt >= 0 && p > 28) { | ||
540 | sd->lum_sum += data[p - 23]; | ||
541 | if (--sd->ag_cnt < 0) { | ||
542 | sd->ag_cnt = AG_CNT_START; | ||
543 | atomic_set(&sd->avg_lum, | ||
544 | sd->lum_sum / AG_CNT_START); | ||
545 | sd->lum_sum = 0; | ||
546 | atomic_set(&sd->do_gain, 1); | ||
547 | } | ||
548 | } | ||
549 | 831 | ||
550 | /* copy the end of data to the current frame */ | 832 | /* Finish decoding current frame */ |
833 | n = (sof - data) - (footer_length + sizeof pac_sof_marker); | ||
834 | if (n < 0) { | ||
835 | frame->data_end += n; | ||
836 | n = 0; | ||
837 | } | ||
838 | frame = gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
839 | data, n); | ||
840 | if (gspca_dev->last_packet_type != DISCARD_PACKET && | ||
841 | frame->data_end[-2] == 0xff && | ||
842 | frame->data_end[-1] == 0xd9) | ||
551 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, | 843 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
552 | data, p); | 844 | NULL, 0); |
553 | 845 | ||
554 | /* put the JPEG header in the new frame */ | 846 | n = sof - data; |
555 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, | 847 | len -= n; |
556 | (unsigned char *) pac7311_jpeg_header, | 848 | data = sof; |
557 | 12); | 849 | |
850 | /* Get average lumination */ | ||
851 | if (gspca_dev->last_packet_type == LAST_PACKET && | ||
852 | n >= lum_offset) | ||
853 | atomic_set(&sd->avg_lum, data[-lum_offset] + | ||
854 | data[-lum_offset + 1]); | ||
855 | else | ||
856 | atomic_set(&sd->avg_lum, -1); | ||
857 | |||
858 | /* Start the new frame with the jpeg header */ | ||
859 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, | ||
860 | pac7311_jpeg_header1, sizeof(pac7311_jpeg_header1)); | ||
861 | if (sd->sensor == SENSOR_PAC7302) { | ||
862 | /* The PAC7302 has the image rotated 90 degrees */ | ||
863 | tmpbuf[0] = gspca_dev->width >> 8; | ||
864 | tmpbuf[1] = gspca_dev->width & 0xff; | ||
865 | tmpbuf[2] = gspca_dev->height >> 8; | ||
866 | tmpbuf[3] = gspca_dev->height & 0xff; | ||
867 | } else { | ||
558 | tmpbuf[0] = gspca_dev->height >> 8; | 868 | tmpbuf[0] = gspca_dev->height >> 8; |
559 | tmpbuf[1] = gspca_dev->height & 0xff; | 869 | tmpbuf[1] = gspca_dev->height & 0xff; |
560 | tmpbuf[2] = gspca_dev->width >> 8; | 870 | tmpbuf[2] = gspca_dev->width >> 8; |
561 | tmpbuf[3] = gspca_dev->width & 0xff; | 871 | tmpbuf[3] = gspca_dev->width & 0xff; |
562 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
563 | tmpbuf, 4); | ||
564 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
565 | (unsigned char *) &pac7311_jpeg_header[16], | ||
566 | PAC7311_JPEG_HEADER_SIZE - 16); | ||
567 | |||
568 | data += p + 7; | ||
569 | len -= p + 7; | ||
570 | ffseq = 0; | ||
571 | break; | ||
572 | } | 872 | } |
873 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, tmpbuf, 4); | ||
874 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
875 | pac7311_jpeg_header2, sizeof(pac7311_jpeg_header2)); | ||
573 | } | 876 | } |
574 | |||
575 | /* remove the 'ff ff ff xx' sequences */ | ||
576 | switch (ffseq) { | ||
577 | case 3: | ||
578 | data += 1; | ||
579 | len -= 1; | ||
580 | break; | ||
581 | case 2: | ||
582 | if (data[0] == 0xff) { | ||
583 | data += 2; | ||
584 | len -= 2; | ||
585 | frame->data_end -= 2; | ||
586 | } | ||
587 | break; | ||
588 | case 1: | ||
589 | if (data[0] == 0xff | ||
590 | && data[1] == 0xff) { | ||
591 | data += 3; | ||
592 | len -= 3; | ||
593 | frame->data_end -= 1; | ||
594 | } | ||
595 | break; | ||
596 | } | ||
597 | for (i = 0; i < len - 4; i++) { | ||
598 | if (data[i] == 0xff | ||
599 | && data[i + 1] == 0xff | ||
600 | && data[i + 2] == 0xff) { | ||
601 | memmove(&data[i], &data[i + 4], len - i - 4); | ||
602 | len -= 4; | ||
603 | } | ||
604 | } | ||
605 | ffseq = 0; | ||
606 | if (data[len - 4] == 0xff) { | ||
607 | if (data[len - 3] == 0xff | ||
608 | && data[len - 2] == 0xff) { | ||
609 | len -= 4; | ||
610 | } | ||
611 | } else if (data[len - 3] == 0xff) { | ||
612 | if (data[len - 2] == 0xff | ||
613 | && data[len - 1] == 0xff) | ||
614 | ffseq = 3; | ||
615 | } else if (data[len - 2] == 0xff) { | ||
616 | if (data[len - 1] == 0xff) | ||
617 | ffseq = 2; | ||
618 | } else if (data[len - 1] == 0xff) | ||
619 | ffseq = 1; | ||
620 | sd->ffseq = ffseq; | ||
621 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 877 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
622 | } | 878 | } |
623 | 879 | ||
624 | static void getbrightness(struct gspca_dev *gspca_dev) | ||
625 | { | ||
626 | /* sd->brightness = reg_r(gspca_dev, 0x08); | ||
627 | return sd->brightness; */ | ||
628 | /* PDEBUG(D_CONF, "Called pac7311_getbrightness: Not implemented yet"); */ | ||
629 | } | ||
630 | |||
631 | |||
632 | |||
633 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 880 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
634 | { | 881 | { |
635 | struct sd *sd = (struct sd *) gspca_dev; | 882 | struct sd *sd = (struct sd *) gspca_dev; |
636 | 883 | ||
637 | sd->brightness = val; | 884 | sd->brightness = val; |
638 | if (gspca_dev->streaming) | 885 | if (gspca_dev->streaming) |
639 | setbrightness(gspca_dev); | 886 | setbrightcont(gspca_dev); |
640 | return 0; | 887 | return 0; |
641 | } | 888 | } |
642 | 889 | ||
@@ -644,7 +891,6 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
644 | { | 891 | { |
645 | struct sd *sd = (struct sd *) gspca_dev; | 892 | struct sd *sd = (struct sd *) gspca_dev; |
646 | 893 | ||
647 | getbrightness(gspca_dev); | ||
648 | *val = sd->brightness; | 894 | *val = sd->brightness; |
649 | return 0; | 895 | return 0; |
650 | } | 896 | } |
@@ -654,8 +900,12 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | |||
654 | struct sd *sd = (struct sd *) gspca_dev; | 900 | struct sd *sd = (struct sd *) gspca_dev; |
655 | 901 | ||
656 | sd->contrast = val; | 902 | sd->contrast = val; |
657 | if (gspca_dev->streaming) | 903 | if (gspca_dev->streaming) { |
658 | setcontrast(gspca_dev); | 904 | if (sd->sensor == SENSOR_PAC7302) |
905 | setbrightcont(gspca_dev); | ||
906 | else | ||
907 | setcontrast(gspca_dev); | ||
908 | } | ||
659 | return 0; | 909 | return 0; |
660 | } | 910 | } |
661 | 911 | ||
@@ -663,7 +913,6 @@ static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | |||
663 | { | 913 | { |
664 | struct sd *sd = (struct sd *) gspca_dev; | 914 | struct sd *sd = (struct sd *) gspca_dev; |
665 | 915 | ||
666 | /* getcontrast(gspca_dev); */ | ||
667 | *val = sd->contrast; | 916 | *val = sd->contrast; |
668 | return 0; | 917 | return 0; |
669 | } | 918 | } |
@@ -682,18 +931,66 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |||
682 | { | 931 | { |
683 | struct sd *sd = (struct sd *) gspca_dev; | 932 | struct sd *sd = (struct sd *) gspca_dev; |
684 | 933 | ||
685 | /* getcolors(gspca_dev); */ | ||
686 | *val = sd->colors; | 934 | *val = sd->colors; |
687 | return 0; | 935 | return 0; |
688 | } | 936 | } |
689 | 937 | ||
938 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | ||
939 | { | ||
940 | struct sd *sd = (struct sd *) gspca_dev; | ||
941 | |||
942 | sd->gain = val; | ||
943 | if (gspca_dev->streaming) | ||
944 | setgain(gspca_dev); | ||
945 | return 0; | ||
946 | } | ||
947 | |||
948 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | ||
949 | { | ||
950 | struct sd *sd = (struct sd *) gspca_dev; | ||
951 | |||
952 | *val = sd->gain; | ||
953 | return 0; | ||
954 | } | ||
955 | |||
956 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val) | ||
957 | { | ||
958 | struct sd *sd = (struct sd *) gspca_dev; | ||
959 | |||
960 | sd->exposure = val; | ||
961 | if (gspca_dev->streaming) | ||
962 | setexposure(gspca_dev); | ||
963 | return 0; | ||
964 | } | ||
965 | |||
966 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) | ||
967 | { | ||
968 | struct sd *sd = (struct sd *) gspca_dev; | ||
969 | |||
970 | *val = sd->exposure; | ||
971 | return 0; | ||
972 | } | ||
973 | |||
690 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | 974 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
691 | { | 975 | { |
692 | struct sd *sd = (struct sd *) gspca_dev; | 976 | struct sd *sd = (struct sd *) gspca_dev; |
693 | 977 | ||
694 | sd->autogain = val; | 978 | sd->autogain = val; |
695 | if (gspca_dev->streaming) | 979 | /* when switching to autogain set defaults to make sure |
696 | setautogain(gspca_dev); | 980 | we are on a valid point of the autogain gain / |
981 | exposure knee graph, and give this change time to | ||
982 | take effect before doing autogain. */ | ||
983 | if (sd->autogain) { | ||
984 | sd->exposure = EXPOSURE_DEF; | ||
985 | sd->gain = GAIN_DEF; | ||
986 | if (gspca_dev->streaming) { | ||
987 | sd->autogain_ignore_frames = | ||
988 | PAC_AUTOGAIN_IGNORE_FRAMES; | ||
989 | setexposure(gspca_dev); | ||
990 | setgain(gspca_dev); | ||
991 | } | ||
992 | } | ||
993 | |||
697 | return 0; | 994 | return 0; |
698 | } | 995 | } |
699 | 996 | ||
@@ -705,30 +1002,67 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | |||
705 | return 0; | 1002 | return 0; |
706 | } | 1003 | } |
707 | 1004 | ||
1005 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) | ||
1006 | { | ||
1007 | struct sd *sd = (struct sd *) gspca_dev; | ||
1008 | |||
1009 | sd->hflip = val; | ||
1010 | if (gspca_dev->streaming) | ||
1011 | sethvflip(gspca_dev); | ||
1012 | return 0; | ||
1013 | } | ||
1014 | |||
1015 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
1016 | { | ||
1017 | struct sd *sd = (struct sd *) gspca_dev; | ||
1018 | |||
1019 | *val = sd->hflip; | ||
1020 | return 0; | ||
1021 | } | ||
1022 | |||
1023 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) | ||
1024 | { | ||
1025 | struct sd *sd = (struct sd *) gspca_dev; | ||
1026 | |||
1027 | sd->vflip = val; | ||
1028 | if (gspca_dev->streaming) | ||
1029 | sethvflip(gspca_dev); | ||
1030 | return 0; | ||
1031 | } | ||
1032 | |||
1033 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
1034 | { | ||
1035 | struct sd *sd = (struct sd *) gspca_dev; | ||
1036 | |||
1037 | *val = sd->vflip; | ||
1038 | return 0; | ||
1039 | } | ||
1040 | |||
708 | /* sub-driver description */ | 1041 | /* sub-driver description */ |
709 | static struct sd_desc sd_desc = { | 1042 | static struct sd_desc sd_desc = { |
710 | .name = MODULE_NAME, | 1043 | .name = MODULE_NAME, |
711 | .ctrls = sd_ctrls, | 1044 | .ctrls = sd_ctrls, |
712 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1045 | .nctrls = ARRAY_SIZE(sd_ctrls), |
713 | .config = sd_config, | 1046 | .config = sd_config, |
714 | .open = sd_open, | 1047 | .init = sd_init, |
715 | .start = sd_start, | 1048 | .start = sd_start, |
716 | .stopN = sd_stopN, | 1049 | .stopN = sd_stopN, |
717 | .stop0 = sd_stop0, | 1050 | .stop0 = sd_stop0, |
718 | .close = sd_close, | ||
719 | .pkt_scan = sd_pkt_scan, | 1051 | .pkt_scan = sd_pkt_scan, |
720 | .dq_callback = do_autogain, | 1052 | .dq_callback = do_autogain, |
721 | }; | 1053 | }; |
722 | 1054 | ||
723 | /* -- module initialisation -- */ | 1055 | /* -- module initialisation -- */ |
724 | static __devinitdata struct usb_device_id device_table[] = { | 1056 | static __devinitdata struct usb_device_id device_table[] = { |
725 | {USB_DEVICE(0x093a, 0x2600)}, | 1057 | {USB_DEVICE(0x093a, 0x2600), .driver_info = SENSOR_PAC7311}, |
726 | {USB_DEVICE(0x093a, 0x2601)}, | 1058 | {USB_DEVICE(0x093a, 0x2601), .driver_info = SENSOR_PAC7311}, |
727 | {USB_DEVICE(0x093a, 0x2603)}, | 1059 | {USB_DEVICE(0x093a, 0x2603), .driver_info = SENSOR_PAC7311}, |
728 | {USB_DEVICE(0x093a, 0x2608)}, | 1060 | {USB_DEVICE(0x093a, 0x2608), .driver_info = SENSOR_PAC7311}, |
729 | {USB_DEVICE(0x093a, 0x260e)}, | 1061 | {USB_DEVICE(0x093a, 0x260e), .driver_info = SENSOR_PAC7311}, |
730 | {USB_DEVICE(0x093a, 0x260f)}, | 1062 | {USB_DEVICE(0x093a, 0x260f), .driver_info = SENSOR_PAC7311}, |
731 | {USB_DEVICE(0x093a, 0x2621)}, | 1063 | {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302}, |
1064 | {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302}, | ||
1065 | {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302}, | ||
732 | {} | 1066 | {} |
733 | }; | 1067 | }; |
734 | MODULE_DEVICE_TABLE(usb, device_table); | 1068 | MODULE_DEVICE_TABLE(usb, device_table); |
@@ -746,6 +1080,10 @@ static struct usb_driver sd_driver = { | |||
746 | .id_table = device_table, | 1080 | .id_table = device_table, |
747 | .probe = sd_probe, | 1081 | .probe = sd_probe, |
748 | .disconnect = gspca_disconnect, | 1082 | .disconnect = gspca_disconnect, |
1083 | #ifdef CONFIG_PM | ||
1084 | .suspend = gspca_suspend, | ||
1085 | .resume = gspca_resume, | ||
1086 | #endif | ||
749 | }; | 1087 | }; |
750 | 1088 | ||
751 | /* -- module insert / remove -- */ | 1089 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/pac_common.h b/drivers/media/video/gspca/pac_common.h new file mode 100644 index 000000000000..34d4b1494cd5 --- /dev/null +++ b/drivers/media/video/gspca/pac_common.h | |||
@@ -0,0 +1,60 @@ | |||
1 | /* | ||
2 | * Pixart PAC207BCA / PAC73xx common functions | ||
3 | * | ||
4 | * Copyright (C) 2008 Hans de Goede <j.w.r.degoede@hhs.nl> | ||
5 | * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li | ||
6 | * Copyleft (C) 2005 Michel Xhaard mxhaard@magic.fr | ||
7 | * | ||
8 | * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | /* We calculate the autogain at the end of the transfer of a frame, at this | ||
27 | moment a frame with the old settings is being transmitted, and a frame is | ||
28 | being captured with the old settings. So if we adjust the autogain we must | ||
29 | ignore atleast the 2 next frames for the new settings to come into effect | ||
30 | before doing any other adjustments */ | ||
31 | #define PAC_AUTOGAIN_IGNORE_FRAMES 3 | ||
32 | |||
33 | static const unsigned char pac_sof_marker[5] = | ||
34 | { 0xff, 0xff, 0x00, 0xff, 0x96 }; | ||
35 | |||
36 | static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, | ||
37 | unsigned char *m, int len) | ||
38 | { | ||
39 | struct sd *sd = (struct sd *) gspca_dev; | ||
40 | int i; | ||
41 | |||
42 | /* Search for the SOF marker (fixed part) in the header */ | ||
43 | for (i = 0; i < len; i++) { | ||
44 | if (m[i] == pac_sof_marker[sd->sof_read]) { | ||
45 | sd->sof_read++; | ||
46 | if (sd->sof_read == sizeof(pac_sof_marker)) { | ||
47 | PDEBUG(D_FRAM, | ||
48 | "SOF found, bytes to analyze: %u." | ||
49 | " Frame starts at byte #%u", | ||
50 | len, i + 1); | ||
51 | sd->sof_read = 0; | ||
52 | return m + i + 1; | ||
53 | } | ||
54 | } else { | ||
55 | sd->sof_read = 0; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | return NULL; | ||
60 | } | ||
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c index 11210c71f66c..5dd78c6766ea 100644 --- a/drivers/media/video/gspca/sonixb.c +++ b/drivers/media/video/gspca/sonixb.c | |||
@@ -20,6 +20,26 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /* Some documentation on known sonixb registers: | ||
24 | |||
25 | Reg Use | ||
26 | 0x10 high nibble red gain low nibble blue gain | ||
27 | 0x11 low nibble green gain | ||
28 | 0x12 hstart | ||
29 | 0x13 vstart | ||
30 | 0x15 hsize (hsize = register-value * 16) | ||
31 | 0x16 vsize (vsize = register-value * 16) | ||
32 | 0x17 bit 0 toggle compression quality (according to sn9c102 driver) | ||
33 | 0x18 bit 7 enables compression, bit 4-5 set image down scaling: | ||
34 | 00 scale 1, 01 scale 1/2, 10, scale 1/4 | ||
35 | 0x19 high-nibble is sensor clock divider, changes exposure on sensors which | ||
36 | use a clock generated by the bridge. Some sensors have their own clock. | ||
37 | 0x1c auto_exposure area (for avg_lum) startx (startx = register-value * 32) | ||
38 | 0x1d auto_exposure area (for avg_lum) starty (starty = register-value * 32) | ||
39 | 0x1e auto_exposure area (for avg_lum) stopx (hsize = (0x1e - 0x1c) * 32) | ||
40 | 0x1f auto_exposure area (for avg_lum) stopy (vsize = (0x1f - 0x1d) * 32) | ||
41 | */ | ||
42 | |||
23 | #define MODULE_NAME "sonixb" | 43 | #define MODULE_NAME "sonixb" |
24 | 44 | ||
25 | #include "gspca.h" | 45 | #include "gspca.h" |
@@ -31,10 +51,8 @@ MODULE_LICENSE("GPL"); | |||
31 | /* specific webcam descriptor */ | 51 | /* specific webcam descriptor */ |
32 | struct sd { | 52 | struct sd { |
33 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 53 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
34 | |||
35 | struct sd_desc sd_desc; /* our nctrls differ dependend upon the | ||
36 | sensor, so we use a per cam copy */ | ||
37 | atomic_t avg_lum; | 54 | atomic_t avg_lum; |
55 | int prev_avg_lum; | ||
38 | 56 | ||
39 | unsigned char gain; | 57 | unsigned char gain; |
40 | unsigned char exposure; | 58 | unsigned char exposure; |
@@ -44,8 +62,12 @@ struct sd { | |||
44 | unsigned char frames_to_drop; | 62 | unsigned char frames_to_drop; |
45 | unsigned char freq; /* light freq filter setting */ | 63 | unsigned char freq; /* light freq filter setting */ |
46 | 64 | ||
47 | unsigned char fr_h_sz; /* size of frame header */ | 65 | __u8 bridge; /* Type of bridge */ |
48 | char sensor; /* Type of image sensor chip */ | 66 | #define BRIDGE_101 0 |
67 | #define BRIDGE_102 0 /* We make no difference between 101 and 102 */ | ||
68 | #define BRIDGE_103 1 | ||
69 | |||
70 | __u8 sensor; /* Type of image sensor chip */ | ||
49 | #define SENSOR_HV7131R 0 | 71 | #define SENSOR_HV7131R 0 |
50 | #define SENSOR_OV6650 1 | 72 | #define SENSOR_OV6650 1 |
51 | #define SENSOR_OV7630 2 | 73 | #define SENSOR_OV7630 2 |
@@ -53,16 +75,35 @@ struct sd { | |||
53 | #define SENSOR_PAS202 4 | 75 | #define SENSOR_PAS202 4 |
54 | #define SENSOR_TAS5110 5 | 76 | #define SENSOR_TAS5110 5 |
55 | #define SENSOR_TAS5130CXX 6 | 77 | #define SENSOR_TAS5130CXX 6 |
56 | char sensor_has_gain; | ||
57 | __u8 sensor_addr; | ||
58 | __u8 reg11; | 78 | __u8 reg11; |
59 | }; | 79 | }; |
60 | 80 | ||
61 | /* flags used in the device id table */ | 81 | typedef const __u8 sensor_init_t[8]; |
82 | |||
83 | struct sensor_data { | ||
84 | const __u8 *bridge_init[2]; | ||
85 | int bridge_init_size[2]; | ||
86 | sensor_init_t *sensor_init; | ||
87 | int sensor_init_size; | ||
88 | sensor_init_t *sensor_bridge_init[2]; | ||
89 | int sensor_bridge_init_size[2]; | ||
90 | int flags; | ||
91 | unsigned ctrl_dis; | ||
92 | __u8 sensor_addr; | ||
93 | }; | ||
94 | |||
95 | /* sensor_data flags */ | ||
62 | #define F_GAIN 0x01 /* has gain */ | 96 | #define F_GAIN 0x01 /* has gain */ |
63 | #define F_AUTO 0x02 /* has autogain */ | 97 | #define F_SIF 0x02 /* sif or vga */ |
64 | #define F_SIF 0x04 /* sif or vga */ | 98 | |
65 | #define F_H18 0x08 /* long (18 b) or short (12 b) frame header */ | 99 | /* priv field of struct v4l2_pix_format flags (do not use low nibble!) */ |
100 | #define MODE_RAW 0x10 /* raw bayer mode */ | ||
101 | #define MODE_REDUCED_SIF 0x20 /* vga mode (320x240 / 160x120) on sif cam */ | ||
102 | |||
103 | /* ctrl_dis helper macros */ | ||
104 | #define NO_EXPO ((1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX)) | ||
105 | #define NO_FREQ (1 << FREQ_IDX) | ||
106 | #define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX) | ||
66 | 107 | ||
67 | #define COMP2 0x8f | 108 | #define COMP2 0x8f |
68 | #define COMP 0xc7 /* 0x87 //0x07 */ | 109 | #define COMP 0xc7 /* 0x87 //0x07 */ |
@@ -73,6 +114,18 @@ struct sd { | |||
73 | 114 | ||
74 | #define SYS_CLK 0x04 | 115 | #define SYS_CLK 0x04 |
75 | 116 | ||
117 | #define SENS(bridge_1, bridge_3, sensor, sensor_1, \ | ||
118 | sensor_3, _flags, _ctrl_dis, _sensor_addr) \ | ||
119 | { \ | ||
120 | .bridge_init = { bridge_1, bridge_3 }, \ | ||
121 | .bridge_init_size = { sizeof(bridge_1), sizeof(bridge_3) }, \ | ||
122 | .sensor_init = sensor, \ | ||
123 | .sensor_init_size = sizeof(sensor), \ | ||
124 | .sensor_bridge_init = { sensor_1, sensor_3,}, \ | ||
125 | .sensor_bridge_init_size = { sizeof(sensor_1), sizeof(sensor_3)}, \ | ||
126 | .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \ | ||
127 | } | ||
128 | |||
76 | /* We calculate the autogain at the end of the transfer of a frame, at this | 129 | /* We calculate the autogain at the end of the transfer of a frame, at this |
77 | moment a frame with the old settings is being transmitted, and a frame is | 130 | moment a frame with the old settings is being transmitted, and a frame is |
78 | being captured with the old settings. So if we adjust the autogain we must | 131 | being captured with the old settings. So if we adjust the autogain we must |
@@ -95,6 +148,7 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | |||
95 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | 148 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); |
96 | 149 | ||
97 | static struct ctrl sd_ctrls[] = { | 150 | static struct ctrl sd_ctrls[] = { |
151 | #define BRIGHTNESS_IDX 0 | ||
98 | { | 152 | { |
99 | { | 153 | { |
100 | .id = V4L2_CID_BRIGHTNESS, | 154 | .id = V4L2_CID_BRIGHTNESS, |
@@ -109,6 +163,7 @@ static struct ctrl sd_ctrls[] = { | |||
109 | .set = sd_setbrightness, | 163 | .set = sd_setbrightness, |
110 | .get = sd_getbrightness, | 164 | .get = sd_getbrightness, |
111 | }, | 165 | }, |
166 | #define GAIN_IDX 1 | ||
112 | { | 167 | { |
113 | { | 168 | { |
114 | .id = V4L2_CID_GAIN, | 169 | .id = V4L2_CID_GAIN, |
@@ -124,6 +179,7 @@ static struct ctrl sd_ctrls[] = { | |||
124 | .set = sd_setgain, | 179 | .set = sd_setgain, |
125 | .get = sd_getgain, | 180 | .get = sd_getgain, |
126 | }, | 181 | }, |
182 | #define EXPOSURE_IDX 2 | ||
127 | { | 183 | { |
128 | { | 184 | { |
129 | .id = V4L2_CID_EXPOSURE, | 185 | .id = V4L2_CID_EXPOSURE, |
@@ -140,6 +196,7 @@ static struct ctrl sd_ctrls[] = { | |||
140 | .set = sd_setexposure, | 196 | .set = sd_setexposure, |
141 | .get = sd_getexposure, | 197 | .get = sd_getexposure, |
142 | }, | 198 | }, |
199 | #define AUTOGAIN_IDX 3 | ||
143 | { | 200 | { |
144 | { | 201 | { |
145 | .id = V4L2_CID_AUTOGAIN, | 202 | .id = V4L2_CID_AUTOGAIN, |
@@ -155,6 +212,7 @@ static struct ctrl sd_ctrls[] = { | |||
155 | .set = sd_setautogain, | 212 | .set = sd_setautogain, |
156 | .get = sd_getautogain, | 213 | .get = sd_getautogain, |
157 | }, | 214 | }, |
215 | #define FREQ_IDX 4 | ||
158 | { | 216 | { |
159 | { | 217 | { |
160 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 218 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
@@ -172,31 +230,56 @@ static struct ctrl sd_ctrls[] = { | |||
172 | }; | 230 | }; |
173 | 231 | ||
174 | static struct v4l2_pix_format vga_mode[] = { | 232 | static struct v4l2_pix_format vga_mode[] = { |
233 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | ||
234 | .bytesperline = 160, | ||
235 | .sizeimage = 160 * 120 * 5 / 4, | ||
236 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
237 | .priv = 2 | MODE_RAW}, | ||
175 | {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | 238 | {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, |
176 | .bytesperline = 160, | 239 | .bytesperline = 160, |
177 | .sizeimage = 160 * 120, | 240 | .sizeimage = 160 * 120 * 5 / 4, |
178 | .colorspace = V4L2_COLORSPACE_SRGB, | 241 | .colorspace = V4L2_COLORSPACE_SRGB, |
179 | .priv = 2}, | 242 | .priv = 2}, |
180 | {320, 240, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | 243 | {320, 240, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, |
181 | .bytesperline = 320, | 244 | .bytesperline = 320, |
182 | .sizeimage = 320 * 240, | 245 | .sizeimage = 320 * 240 * 5 / 4, |
183 | .colorspace = V4L2_COLORSPACE_SRGB, | 246 | .colorspace = V4L2_COLORSPACE_SRGB, |
184 | .priv = 1}, | 247 | .priv = 1}, |
185 | {640, 480, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | 248 | {640, 480, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, |
186 | .bytesperline = 640, | 249 | .bytesperline = 640, |
187 | .sizeimage = 640 * 480, | 250 | .sizeimage = 640 * 480 * 5 / 4, |
188 | .colorspace = V4L2_COLORSPACE_SRGB, | 251 | .colorspace = V4L2_COLORSPACE_SRGB, |
189 | .priv = 0}, | 252 | .priv = 0}, |
190 | }; | 253 | }; |
191 | static struct v4l2_pix_format sif_mode[] = { | 254 | static struct v4l2_pix_format sif_mode[] = { |
255 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | ||
256 | .bytesperline = 160, | ||
257 | .sizeimage = 160 * 120, | ||
258 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
259 | .priv = 1 | MODE_RAW | MODE_REDUCED_SIF}, | ||
260 | {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | ||
261 | .bytesperline = 160, | ||
262 | .sizeimage = 160 * 120 * 5 / 4, | ||
263 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
264 | .priv = 1 | MODE_REDUCED_SIF}, | ||
265 | {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | ||
266 | .bytesperline = 176, | ||
267 | .sizeimage = 176 * 144 * 5 / 4, | ||
268 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
269 | .priv = 1 | MODE_RAW}, | ||
192 | {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | 270 | {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, |
193 | .bytesperline = 176, | 271 | .bytesperline = 176, |
194 | .sizeimage = 176 * 144, | 272 | .sizeimage = 176 * 144 * 5 / 4, |
195 | .colorspace = V4L2_COLORSPACE_SRGB, | 273 | .colorspace = V4L2_COLORSPACE_SRGB, |
196 | .priv = 1}, | 274 | .priv = 1}, |
275 | {320, 240, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | ||
276 | .bytesperline = 320, | ||
277 | .sizeimage = 320 * 240 * 5 / 4, | ||
278 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
279 | .priv = 0 | MODE_REDUCED_SIF}, | ||
197 | {352, 288, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, | 280 | {352, 288, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, |
198 | .bytesperline = 352, | 281 | .bytesperline = 352, |
199 | .sizeimage = 352 * 288, | 282 | .sizeimage = 352 * 288 * 5 / 4, |
200 | .colorspace = V4L2_COLORSPACE_SRGB, | 283 | .colorspace = V4L2_COLORSPACE_SRGB, |
201 | .priv = 0}, | 284 | .priv = 0}, |
202 | }; | 285 | }; |
@@ -204,7 +287,7 @@ static struct v4l2_pix_format sif_mode[] = { | |||
204 | static const __u8 initHv7131[] = { | 287 | static const __u8 initHv7131[] = { |
205 | 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, | 288 | 0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, |
206 | 0x00, 0x00, | 289 | 0x00, 0x00, |
207 | 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, /* shift from 0x02 0x01 0x00 */ | 290 | 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, |
208 | 0x28, 0x1e, 0x60, 0x8a, 0x20, | 291 | 0x28, 0x1e, 0x60, 0x8a, 0x20, |
209 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c | 292 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c |
210 | }; | 293 | }; |
@@ -218,8 +301,8 @@ static const __u8 hv7131_sensor_init[][8] = { | |||
218 | static const __u8 initOv6650[] = { | 301 | static const __u8 initOv6650[] = { |
219 | 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | 302 | 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, |
220 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 303 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
221 | 0x00, 0x02, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x0b, | 304 | 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, |
222 | 0x10, 0x1d, 0x10, 0x00, 0x06, 0x1f, 0x00 | 305 | 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07 |
223 | }; | 306 | }; |
224 | static const __u8 ov6650_sensor_init[][8] = | 307 | static const __u8 ov6650_sensor_init[][8] = |
225 | { | 308 | { |
@@ -257,15 +340,15 @@ static const __u8 ov6650_sensor_init[][8] = | |||
257 | static const __u8 initOv7630[] = { | 340 | static const __u8 initOv7630[] = { |
258 | 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* r01 .. r08 */ | 341 | 0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* r01 .. r08 */ |
259 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ | 342 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ |
260 | 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */ | 343 | 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ |
261 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ | 344 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ |
262 | 0x68, COMP1, MCK_INIT1, /* r17 .. r19 */ | 345 | 0x68, COMP2, MCK_INIT1, /* r17 .. r19 */ |
263 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */ | 346 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */ |
264 | }; | 347 | }; |
265 | static const __u8 initOv7630_3[] = { | 348 | static const __u8 initOv7630_3[] = { |
266 | 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */ | 349 | 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */ |
267 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, /* r09 .. r10 */ | 350 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, /* r09 .. r10 */ |
268 | 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ | 351 | 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */ |
269 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ | 352 | 0x28, 0x1e, /* H & V sizes r15 .. r16 */ |
270 | 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ | 353 | 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ |
271 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */ | 354 | 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */ |
@@ -294,47 +377,65 @@ static const __u8 ov7630_sensor_init[][8] = { | |||
294 | {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, | 377 | {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, |
295 | }; | 378 | }; |
296 | 379 | ||
380 | static const __u8 ov7630_sensor_init_3[][8] = { | ||
381 | {0xa0, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
382 | }; | ||
383 | |||
297 | static const __u8 initPas106[] = { | 384 | static const __u8 initPas106[] = { |
298 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, | 385 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, |
299 | 0x00, 0x00, | 386 | 0x00, 0x00, |
300 | 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, | 387 | 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, |
301 | 0x16, 0x12, 0x28, COMP1, MCK_INIT1, | 388 | 0x16, 0x12, 0x24, COMP1, MCK_INIT1, |
302 | 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c | 389 | 0x18, 0x10, 0x02, 0x02, 0x09, 0x07 |
303 | }; | 390 | }; |
304 | /* compression 0x86 mckinit1 0x2b */ | 391 | /* compression 0x86 mckinit1 0x2b */ |
305 | static const __u8 pas106_data[][2] = { | 392 | static const __u8 pas106_sensor_init[][8] = { |
306 | {0x02, 0x04}, /* Pixel Clock Divider 6 */ | 393 | /* Pixel Clock Divider 6 */ |
307 | {0x03, 0x13}, /* Frame Time MSB */ | 394 | { 0xa1, 0x40, 0x02, 0x04, 0x00, 0x00, 0x00, 0x14 }, |
308 | /* {0x03, 0x12}, * Frame Time MSB */ | 395 | /* Frame Time MSB (also seen as 0x12) */ |
309 | {0x04, 0x06}, /* Frame Time LSB */ | 396 | { 0xa1, 0x40, 0x03, 0x13, 0x00, 0x00, 0x00, 0x14 }, |
310 | /* {0x04, 0x05}, * Frame Time LSB */ | 397 | /* Frame Time LSB (also seen as 0x05) */ |
311 | {0x05, 0x65}, /* Shutter Time Line Offset */ | 398 | { 0xa1, 0x40, 0x04, 0x06, 0x00, 0x00, 0x00, 0x14 }, |
312 | /* {0x05, 0x6d}, * Shutter Time Line Offset */ | 399 | /* Shutter Time Line Offset (also seen as 0x6d) */ |
313 | /* {0x06, 0xb1}, * Shutter Time Pixel Offset */ | 400 | { 0xa1, 0x40, 0x05, 0x65, 0x00, 0x00, 0x00, 0x14 }, |
314 | {0x06, 0xcd}, /* Shutter Time Pixel Offset */ | 401 | /* Shutter Time Pixel Offset (also seen as 0xb1) */ |
315 | {0x07, 0xc1}, /* Black Level Subtract Sign */ | 402 | { 0xa1, 0x40, 0x06, 0xcd, 0x00, 0x00, 0x00, 0x14 }, |
316 | /* {0x07, 0x00}, * Black Level Subtract Sign */ | 403 | /* Black Level Subtract Sign (also seen 0x00) */ |
317 | {0x08, 0x06}, /* Black Level Subtract Level */ | 404 | { 0xa1, 0x40, 0x07, 0xc1, 0x00, 0x00, 0x00, 0x14 }, |
318 | {0x08, 0x06}, /* Black Level Subtract Level */ | 405 | /* Black Level Subtract Level (also seen 0x01) */ |
319 | /* {0x08, 0x01}, * Black Level Subtract Level */ | 406 | { 0xa1, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0x14 }, |
320 | {0x09, 0x05}, /* Color Gain B Pixel 5 a */ | 407 | { 0xa1, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0x14 }, |
321 | {0x0a, 0x04}, /* Color Gain G1 Pixel 1 5 */ | 408 | /* Color Gain B Pixel 5 a */ |
322 | {0x0b, 0x04}, /* Color Gain G2 Pixel 1 0 5 */ | 409 | { 0xa1, 0x40, 0x09, 0x05, 0x00, 0x00, 0x00, 0x14 }, |
323 | {0x0c, 0x05}, /* Color Gain R Pixel 3 1 */ | 410 | /* Color Gain G1 Pixel 1 5 */ |
324 | {0x0d, 0x00}, /* Color GainH Pixel */ | 411 | { 0xa1, 0x40, 0x0a, 0x04, 0x00, 0x00, 0x00, 0x14 }, |
325 | {0x0e, 0x0e}, /* Global Gain */ | 412 | /* Color Gain G2 Pixel 1 0 5 */ |
326 | {0x0f, 0x00}, /* Contrast */ | 413 | { 0xa1, 0x40, 0x0b, 0x04, 0x00, 0x00, 0x00, 0x14 }, |
327 | {0x10, 0x06}, /* H&V synchro polarity */ | 414 | /* Color Gain R Pixel 3 1 */ |
328 | {0x11, 0x06}, /* ?default */ | 415 | { 0xa1, 0x40, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x14 }, |
329 | {0x12, 0x06}, /* DAC scale */ | 416 | /* Color GainH Pixel */ |
330 | {0x14, 0x02}, /* ?default */ | 417 | { 0xa1, 0x40, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x14 }, |
331 | {0x13, 0x01}, /* Validate Settings */ | 418 | /* Global Gain */ |
419 | { 0xa1, 0x40, 0x0e, 0x0e, 0x00, 0x00, 0x00, 0x14 }, | ||
420 | /* Contrast */ | ||
421 | { 0xa1, 0x40, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x14 }, | ||
422 | /* H&V synchro polarity */ | ||
423 | { 0xa1, 0x40, 0x10, 0x06, 0x00, 0x00, 0x00, 0x14 }, | ||
424 | /* ?default */ | ||
425 | { 0xa1, 0x40, 0x11, 0x06, 0x00, 0x00, 0x00, 0x14 }, | ||
426 | /* DAC scale */ | ||
427 | { 0xa1, 0x40, 0x12, 0x06, 0x00, 0x00, 0x00, 0x14 }, | ||
428 | /* ?default */ | ||
429 | { 0xa1, 0x40, 0x14, 0x02, 0x00, 0x00, 0x00, 0x14 }, | ||
430 | /* Validate Settings */ | ||
431 | { 0xa1, 0x40, 0x13, 0x01, 0x00, 0x00, 0x00, 0x14 }, | ||
332 | }; | 432 | }; |
433 | |||
333 | static const __u8 initPas202[] = { | 434 | static const __u8 initPas202[] = { |
334 | 0x44, 0x44, 0x21, 0x30, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, | 435 | 0x44, 0x44, 0x21, 0x30, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, |
335 | 0x00, 0x00, | 436 | 0x00, 0x00, |
336 | 0x00, 0x00, 0x00, 0x07, 0x03, 0x0a, /* 6 */ | 437 | 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a, |
337 | 0x28, 0x1e, 0x28, 0x89, 0x30, | 438 | 0x28, 0x1e, 0x28, 0x89, 0x20, |
338 | 0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c | 439 | 0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c |
339 | }; | 440 | }; |
340 | static const __u8 pas202_sensor_init[][8] = { | 441 | static const __u8 pas202_sensor_init[][8] = { |
@@ -364,7 +465,7 @@ static const __u8 pas202_sensor_init[][8] = { | |||
364 | static const __u8 initTas5110[] = { | 465 | static const __u8 initTas5110[] = { |
365 | 0x44, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00, | 466 | 0x44, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00, |
366 | 0x00, 0x00, | 467 | 0x00, 0x00, |
367 | 0x00, 0x01, 0x00, 0x46, 0x09, 0x0a, /* shift from 0x45 0x09 0x0a */ | 468 | 0x00, 0x01, 0x00, 0x45, 0x09, 0x0a, |
368 | 0x16, 0x12, 0x60, 0x86, 0x2b, | 469 | 0x16, 0x12, 0x60, 0x86, 0x2b, |
369 | 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 | 470 | 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07 |
370 | }; | 471 | }; |
@@ -377,7 +478,7 @@ static const __u8 tas5110_sensor_init[][8] = { | |||
377 | static const __u8 initTas5130[] = { | 478 | static const __u8 initTas5130[] = { |
378 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00, | 479 | 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00, |
379 | 0x00, 0x00, | 480 | 0x00, 0x00, |
380 | 0x00, 0x01, 0x00, 0x69, 0x0c, 0x0a, | 481 | 0x00, 0x01, 0x00, 0x68, 0x0c, 0x0a, |
381 | 0x28, 0x1e, 0x60, COMP, MCK_INIT, | 482 | 0x28, 0x1e, 0x60, COMP, MCK_INIT, |
382 | 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c | 483 | 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c |
383 | }; | 484 | }; |
@@ -389,6 +490,21 @@ static const __u8 tas5130_sensor_init[][8] = { | |||
389 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}, | 490 | {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}, |
390 | }; | 491 | }; |
391 | 492 | ||
493 | struct sensor_data sensor_data[] = { | ||
494 | SENS(initHv7131, NULL, hv7131_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, 0), | ||
495 | SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF, 0, 0x60), | ||
496 | SENS(initOv7630, initOv7630_3, ov7630_sensor_init, NULL, ov7630_sensor_init_3, | ||
497 | F_GAIN, 0, 0x21), | ||
498 | SENS(initPas106, NULL, pas106_sensor_init, NULL, NULL, F_SIF, NO_EXPO|NO_FREQ, | ||
499 | 0), | ||
500 | SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, 0, | ||
501 | NO_EXPO|NO_FREQ, 0), | ||
502 | SENS(initTas5110, NULL, tas5110_sensor_init, NULL, NULL, F_GAIN|F_SIF, | ||
503 | NO_BRIGHTNESS|NO_FREQ, 0), | ||
504 | SENS(initTas5130, NULL, tas5130_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, | ||
505 | 0), | ||
506 | }; | ||
507 | |||
392 | /* get one byte in gspca_dev->usb_buf */ | 508 | /* get one byte in gspca_dev->usb_buf */ |
393 | static void reg_r(struct gspca_dev *gspca_dev, | 509 | static void reg_r(struct gspca_dev *gspca_dev, |
394 | __u16 value) | 510 | __u16 value) |
@@ -409,7 +525,7 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
409 | int len) | 525 | int len) |
410 | { | 526 | { |
411 | #ifdef GSPCA_DEBUG | 527 | #ifdef GSPCA_DEBUG |
412 | if (len > sizeof gspca_dev->usb_buf) { | 528 | if (len > USB_BUF_SZ) { |
413 | PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow"); | 529 | PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow"); |
414 | return; | 530 | return; |
415 | } | 531 | } |
@@ -425,26 +541,6 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
425 | 500); | 541 | 500); |
426 | } | 542 | } |
427 | 543 | ||
428 | static void reg_w_big(struct gspca_dev *gspca_dev, | ||
429 | __u16 value, | ||
430 | const __u8 *buffer, | ||
431 | int len) | ||
432 | { | ||
433 | __u8 *tmpbuf; | ||
434 | |||
435 | tmpbuf = kmalloc(len, GFP_KERNEL); | ||
436 | memcpy(tmpbuf, buffer, len); | ||
437 | usb_control_msg(gspca_dev->dev, | ||
438 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
439 | 0x08, /* request */ | ||
440 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
441 | value, | ||
442 | 0, /* index */ | ||
443 | tmpbuf, len, | ||
444 | 500); | ||
445 | kfree(tmpbuf); | ||
446 | } | ||
447 | |||
448 | static int i2c_w(struct gspca_dev *gspca_dev, const __u8 *buffer) | 544 | static int i2c_w(struct gspca_dev *gspca_dev, const __u8 *buffer) |
449 | { | 545 | { |
450 | int retry = 60; | 546 | int retry = 60; |
@@ -487,7 +583,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
487 | {0xa0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}; | 583 | {0xa0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}; |
488 | 584 | ||
489 | /* change reg 0x06 */ | 585 | /* change reg 0x06 */ |
490 | i2cOV[1] = sd->sensor_addr; | 586 | i2cOV[1] = sensor_data[sd->sensor].sensor_addr; |
491 | i2cOV[3] = sd->brightness; | 587 | i2cOV[3] = sd->brightness; |
492 | if (i2c_w(gspca_dev, i2cOV) < 0) | 588 | if (i2c_w(gspca_dev, i2cOV) < 0) |
493 | goto err; | 589 | goto err; |
@@ -545,9 +641,6 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
545 | goto err; | 641 | goto err; |
546 | break; | 642 | break; |
547 | } | 643 | } |
548 | case SENSOR_TAS5110: | ||
549 | /* FIXME figure out howto control brightness on TAS5110 */ | ||
550 | break; | ||
551 | } | 644 | } |
552 | return; | 645 | return; |
553 | err: | 646 | err: |
@@ -577,7 +670,7 @@ static void setsensorgain(struct gspca_dev *gspca_dev) | |||
577 | case SENSOR_OV7630: { | 670 | case SENSOR_OV7630: { |
578 | __u8 i2c[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; | 671 | __u8 i2c[] = {0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; |
579 | 672 | ||
580 | i2c[1] = sd->sensor_addr; | 673 | i2c[1] = sensor_data[sd->sensor].sensor_addr; |
581 | i2c[3] = gain >> 2; | 674 | i2c[3] = gain >> 2; |
582 | if (i2c_w(gspca_dev, i2c) < 0) | 675 | if (i2c_w(gspca_dev, i2c) < 0) |
583 | goto err; | 676 | goto err; |
@@ -604,7 +697,7 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
604 | rgb_value = gain; | 697 | rgb_value = gain; |
605 | reg_w(gspca_dev, 0x11, &rgb_value, 1); | 698 | reg_w(gspca_dev, 0x11, &rgb_value, 1); |
606 | 699 | ||
607 | if (sd->sensor_has_gain) | 700 | if (sensor_data[sd->sensor].flags & F_GAIN) |
608 | setsensorgain(gspca_dev); | 701 | setsensorgain(gspca_dev); |
609 | } | 702 | } |
610 | 703 | ||
@@ -665,6 +758,11 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
665 | else if (reg11 > 16) | 758 | else if (reg11 > 16) |
666 | reg11 = 16; | 759 | reg11 = 16; |
667 | 760 | ||
761 | /* In 640x480, if the reg11 has less than 3, the image is | ||
762 | unstable (not enough bandwidth). */ | ||
763 | if (gspca_dev->width == 640 && reg11 < 3) | ||
764 | reg11 = 3; | ||
765 | |||
668 | /* frame exposure time in ms = 1000 * reg11 / 30 -> | 766 | /* frame exposure time in ms = 1000 * reg11 / 30 -> |
669 | reg10 = sd->exposure * 2 * reg10_max / (1000 * reg11 / 30) */ | 767 | reg10 = sd->exposure * 2 * reg10_max / (1000 * reg11 / 30) */ |
670 | reg10 = (sd->exposure * 60 * reg10_max) / (1000 * reg11); | 768 | reg10 = (sd->exposure * 60 * reg10_max) / (1000 * reg11); |
@@ -678,13 +776,8 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
678 | else if (reg10 > reg10_max) | 776 | else if (reg10 > reg10_max) |
679 | reg10 = reg10_max; | 777 | reg10 = reg10_max; |
680 | 778 | ||
681 | /* In 640x480, if the reg11 has less than 3, the image is | ||
682 | unstable (not enough bandwidth). */ | ||
683 | if (gspca_dev->width == 640 && reg11 < 3) | ||
684 | reg11 = 3; | ||
685 | |||
686 | /* Write reg 10 and reg11 low nibble */ | 779 | /* Write reg 10 and reg11 low nibble */ |
687 | i2c[1] = sd->sensor_addr; | 780 | i2c[1] = sensor_data[sd->sensor].sensor_addr; |
688 | i2c[3] = reg10; | 781 | i2c[3] = reg10; |
689 | i2c[4] |= reg11 - 1; | 782 | i2c[4] |= reg11 - 1; |
690 | 783 | ||
@@ -724,7 +817,7 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
724 | ? 0x4f : 0x8a; | 817 | ? 0x4f : 0x8a; |
725 | break; | 818 | break; |
726 | } | 819 | } |
727 | i2c[1] = sd->sensor_addr; | 820 | i2c[1] = sensor_data[sd->sensor].sensor_addr; |
728 | if (i2c_w(gspca_dev, i2c) < 0) | 821 | if (i2c_w(gspca_dev, i2c) < 0) |
729 | PDEBUG(D_ERR, "i2c error setfreq"); | 822 | PDEBUG(D_ERR, "i2c error setfreq"); |
730 | break; | 823 | break; |
@@ -757,30 +850,19 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
757 | { | 850 | { |
758 | struct sd *sd = (struct sd *) gspca_dev; | 851 | struct sd *sd = (struct sd *) gspca_dev; |
759 | struct cam *cam; | 852 | struct cam *cam; |
760 | int sif = 0; | ||
761 | 853 | ||
762 | /* nctrls depends upon the sensor, so we use a per cam copy */ | 854 | reg_r(gspca_dev, 0x00); |
763 | memcpy(&sd->sd_desc, gspca_dev->sd_desc, sizeof(struct sd_desc)); | 855 | if (gspca_dev->usb_buf[0] != 0x10) |
764 | gspca_dev->sd_desc = &sd->sd_desc; | 856 | return -ENODEV; |
765 | 857 | ||
766 | /* copy the webcam info from the device id */ | 858 | /* copy the webcam info from the device id */ |
767 | sd->sensor = (id->driver_info >> 24) & 0xff; | 859 | sd->sensor = id->driver_info >> 8; |
768 | if (id->driver_info & (F_GAIN << 16)) | 860 | sd->bridge = id->driver_info & 0xff; |
769 | sd->sensor_has_gain = 1; | 861 | gspca_dev->ctrl_dis = sensor_data[sd->sensor].ctrl_dis; |
770 | if (id->driver_info & (F_AUTO << 16)) | ||
771 | sd->sd_desc.dq_callback = do_autogain; | ||
772 | if (id->driver_info & (F_SIF << 16)) | ||
773 | sif = 1; | ||
774 | if (id->driver_info & (F_H18 << 16)) | ||
775 | sd->fr_h_sz = 18; /* size of frame header */ | ||
776 | else | ||
777 | sd->fr_h_sz = 12; | ||
778 | sd->sd_desc.nctrls = (id->driver_info >> 8) & 0xff; | ||
779 | sd->sensor_addr = id->driver_info & 0xff; | ||
780 | 862 | ||
781 | cam = &gspca_dev->cam; | 863 | cam = &gspca_dev->cam; |
782 | cam->epaddr = 0x01; | 864 | cam->epaddr = 0x01; |
783 | if (!sif) { | 865 | if (!(sensor_data[sd->sensor].flags & F_SIF)) { |
784 | cam->cam_mode = vga_mode; | 866 | cam->cam_mode = vga_mode; |
785 | cam->nmodes = ARRAY_SIZE(vga_mode); | 867 | cam->nmodes = ARRAY_SIZE(vga_mode); |
786 | } else { | 868 | } else { |
@@ -790,157 +872,98 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
790 | sd->brightness = BRIGHTNESS_DEF; | 872 | sd->brightness = BRIGHTNESS_DEF; |
791 | sd->gain = GAIN_DEF; | 873 | sd->gain = GAIN_DEF; |
792 | sd->exposure = EXPOSURE_DEF; | 874 | sd->exposure = EXPOSURE_DEF; |
793 | sd->autogain = AUTOGAIN_DEF; | 875 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
876 | sd->autogain = 0; /* Disable do_autogain callback */ | ||
877 | else | ||
878 | sd->autogain = AUTOGAIN_DEF; | ||
794 | sd->freq = FREQ_DEF; | 879 | sd->freq = FREQ_DEF; |
795 | 880 | ||
796 | return 0; | 881 | return 0; |
797 | } | 882 | } |
798 | 883 | ||
799 | /* this function is called at open time */ | 884 | /* this function is called at probe and resume time */ |
800 | static int sd_open(struct gspca_dev *gspca_dev) | 885 | static int sd_init(struct gspca_dev *gspca_dev) |
801 | { | 886 | { |
802 | reg_r(gspca_dev, 0x00); | 887 | const __u8 stop = 0x09; /* Disable stream turn of LED */ |
803 | if (gspca_dev->usb_buf[0] != 0x10) | ||
804 | return -ENODEV; | ||
805 | return 0; | ||
806 | } | ||
807 | 888 | ||
808 | static void pas106_i2cinit(struct gspca_dev *gspca_dev) | 889 | reg_w(gspca_dev, 0x01, &stop, 1); |
809 | { | 890 | |
810 | int i; | 891 | return 0; |
811 | const __u8 *data; | ||
812 | __u8 i2c1[] = { 0xa1, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14 }; | ||
813 | |||
814 | i = ARRAY_SIZE(pas106_data); | ||
815 | data = pas106_data[0]; | ||
816 | while (--i >= 0) { | ||
817 | memcpy(&i2c1[2], data, 2); | ||
818 | /* copy 2 bytes from the template */ | ||
819 | if (i2c_w(gspca_dev, i2c1) < 0) | ||
820 | PDEBUG(D_ERR, "i2c error pas106"); | ||
821 | data += 2; | ||
822 | } | ||
823 | } | 892 | } |
824 | 893 | ||
825 | /* -- start the camera -- */ | 894 | /* -- start the camera -- */ |
826 | static void sd_start(struct gspca_dev *gspca_dev) | 895 | static void sd_start(struct gspca_dev *gspca_dev) |
827 | { | 896 | { |
828 | struct sd *sd = (struct sd *) gspca_dev; | 897 | struct sd *sd = (struct sd *) gspca_dev; |
829 | int mode, l = 0x1f; | 898 | struct cam *cam = &gspca_dev->cam; |
899 | int mode, l; | ||
830 | const __u8 *sn9c10x; | 900 | const __u8 *sn9c10x; |
831 | __u8 reg17_19[3]; | 901 | __u8 reg12_19[8]; |
832 | 902 | ||
833 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 903 | mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; |
904 | sn9c10x = sensor_data[sd->sensor].bridge_init[sd->bridge]; | ||
905 | l = sensor_data[sd->sensor].bridge_init_size[sd->bridge]; | ||
906 | memcpy(reg12_19, &sn9c10x[0x12 - 1], 8); | ||
907 | reg12_19[6] = sn9c10x[0x18 - 1] | (mode << 4); | ||
908 | /* Special cases where reg 17 and or 19 value depends on mode */ | ||
834 | switch (sd->sensor) { | 909 | switch (sd->sensor) { |
835 | case SENSOR_HV7131R: | ||
836 | sn9c10x = initHv7131; | ||
837 | reg17_19[0] = 0x60; | ||
838 | reg17_19[1] = (mode << 4) | 0x8a; | ||
839 | reg17_19[2] = 0x20; | ||
840 | break; | ||
841 | case SENSOR_OV6650: | ||
842 | sn9c10x = initOv6650; | ||
843 | reg17_19[0] = 0x68; | ||
844 | reg17_19[1] = (mode << 4) | 0x8b; | ||
845 | reg17_19[2] = 0x20; | ||
846 | break; | ||
847 | case SENSOR_OV7630: | ||
848 | if (sd->fr_h_sz == 18) { /* SN9C103 */ | ||
849 | sn9c10x = initOv7630_3; | ||
850 | l = sizeof initOv7630_3; | ||
851 | } else | ||
852 | sn9c10x = initOv7630; | ||
853 | reg17_19[0] = 0x68; | ||
854 | reg17_19[1] = (mode << 4) | COMP2; | ||
855 | reg17_19[2] = MCK_INIT1; | ||
856 | break; | ||
857 | case SENSOR_PAS106: | ||
858 | sn9c10x = initPas106; | ||
859 | reg17_19[0] = 0x24; /* 0x28 */ | ||
860 | reg17_19[1] = (mode << 4) | COMP1; | ||
861 | reg17_19[2] = MCK_INIT1; | ||
862 | break; | ||
863 | case SENSOR_PAS202: | 910 | case SENSOR_PAS202: |
864 | sn9c10x = initPas202; | 911 | reg12_19[5] = mode ? 0x24 : 0x20; |
865 | reg17_19[0] = mode ? 0x24 : 0x20; | ||
866 | reg17_19[1] = (mode << 4) | 0x89; | ||
867 | reg17_19[2] = 0x20; | ||
868 | break; | 912 | break; |
869 | case SENSOR_TAS5110: | 913 | case SENSOR_TAS5130CXX: |
870 | sn9c10x = initTas5110; | 914 | /* probably not mode specific at all most likely the upper |
871 | reg17_19[0] = 0x60; | 915 | nibble of 0x19 is exposure (clock divider) just as with |
872 | reg17_19[1] = (mode << 4) | 0x86; | 916 | the tas5110, we need someone to test this. */ |
873 | reg17_19[2] = 0x2b; /* 0xf3; */ | 917 | reg12_19[7] = mode ? 0x23 : 0x43; |
874 | break; | ||
875 | default: | ||
876 | /* case SENSOR_TAS5130CXX: */ | ||
877 | sn9c10x = initTas5130; | ||
878 | reg17_19[0] = 0x60; | ||
879 | reg17_19[1] = (mode << 4) | COMP; | ||
880 | reg17_19[2] = mode ? 0x23 : 0x43; | ||
881 | break; | 918 | break; |
882 | } | 919 | } |
920 | /* Disable compression when the raw bayer format has been selected */ | ||
921 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) | ||
922 | reg12_19[6] &= ~0x80; | ||
923 | |||
924 | /* Vga mode emulation on SIF sensor? */ | ||
925 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { | ||
926 | reg12_19[0] += 16; /* 0x12: hstart adjust */ | ||
927 | reg12_19[1] += 24; /* 0x13: vstart adjust */ | ||
928 | reg12_19[3] = 320 / 16; /* 0x15: hsize */ | ||
929 | reg12_19[4] = 240 / 16; /* 0x16: vsize */ | ||
930 | } | ||
883 | 931 | ||
884 | /* reg 0x01 bit 2 video transfert on */ | 932 | /* reg 0x01 bit 2 video transfert on */ |
885 | reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1); | 933 | reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1); |
886 | /* reg 0x17 SensorClk enable inv Clk 0x60 */ | 934 | /* reg 0x17 SensorClk enable inv Clk 0x60 */ |
887 | reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); | 935 | reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); |
888 | /* Set the registers from the template */ | 936 | /* Set the registers from the template */ |
889 | reg_w_big(gspca_dev, 0x01, sn9c10x, l); | 937 | reg_w(gspca_dev, 0x01, sn9c10x, l); |
890 | switch (sd->sensor) { | 938 | |
891 | case SENSOR_HV7131R: | 939 | /* Init the sensor */ |
892 | i2c_w_vector(gspca_dev, hv7131_sensor_init, | 940 | i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, |
893 | sizeof hv7131_sensor_init); | 941 | sensor_data[sd->sensor].sensor_init_size); |
894 | break; | 942 | if (sensor_data[sd->sensor].sensor_bridge_init[sd->bridge]) |
895 | case SENSOR_OV6650: | 943 | i2c_w_vector(gspca_dev, |
896 | i2c_w_vector(gspca_dev, ov6650_sensor_init, | 944 | sensor_data[sd->sensor].sensor_bridge_init[sd->bridge], |
897 | sizeof ov6650_sensor_init); | 945 | sensor_data[sd->sensor].sensor_bridge_init_size[ |
898 | break; | 946 | sd->bridge]); |
899 | case SENSOR_OV7630: | 947 | |
900 | i2c_w_vector(gspca_dev, ov7630_sensor_init, | ||
901 | sizeof ov7630_sensor_init); | ||
902 | if (sd->fr_h_sz == 18) { /* SN9C103 */ | ||
903 | const __u8 i2c[] = { 0xa0, 0x21, 0x13, 0x80, 0x00, | ||
904 | 0x00, 0x00, 0x10 }; | ||
905 | i2c_w(gspca_dev, i2c); | ||
906 | } | ||
907 | break; | ||
908 | case SENSOR_PAS106: | ||
909 | pas106_i2cinit(gspca_dev); | ||
910 | break; | ||
911 | case SENSOR_PAS202: | ||
912 | i2c_w_vector(gspca_dev, pas202_sensor_init, | ||
913 | sizeof pas202_sensor_init); | ||
914 | break; | ||
915 | case SENSOR_TAS5110: | ||
916 | i2c_w_vector(gspca_dev, tas5110_sensor_init, | ||
917 | sizeof tas5110_sensor_init); | ||
918 | break; | ||
919 | default: | ||
920 | /* case SENSOR_TAS5130CXX: */ | ||
921 | i2c_w_vector(gspca_dev, tas5130_sensor_init, | ||
922 | sizeof tas5130_sensor_init); | ||
923 | break; | ||
924 | } | ||
925 | /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ | 948 | /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ |
926 | reg_w(gspca_dev, 0x15, &sn9c10x[0x15 - 1], 2); | 949 | reg_w(gspca_dev, 0x15, ®12_19[3], 2); |
927 | /* compression register */ | 950 | /* compression register */ |
928 | reg_w(gspca_dev, 0x18, ®17_19[1], 1); | 951 | reg_w(gspca_dev, 0x18, ®12_19[6], 1); |
929 | /* H_start */ | 952 | /* H_start */ |
930 | reg_w(gspca_dev, 0x12, &sn9c10x[0x12 - 1], 1); | 953 | reg_w(gspca_dev, 0x12, ®12_19[0], 1); |
931 | /* V_START */ | 954 | /* V_START */ |
932 | reg_w(gspca_dev, 0x13, &sn9c10x[0x13 - 1], 1); | 955 | reg_w(gspca_dev, 0x13, ®12_19[1], 1); |
933 | /* reset 0x17 SensorClk enable inv Clk 0x60 */ | 956 | /* reset 0x17 SensorClk enable inv Clk 0x60 */ |
934 | /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ | 957 | /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ |
935 | reg_w(gspca_dev, 0x17, ®17_19[0], 1); | 958 | reg_w(gspca_dev, 0x17, ®12_19[5], 1); |
936 | /*MCKSIZE ->3 */ /*fixme: not ov7630*/ | 959 | /*MCKSIZE ->3 */ /*fixme: not ov7630*/ |
937 | reg_w(gspca_dev, 0x19, ®17_19[2], 1); | 960 | reg_w(gspca_dev, 0x19, ®12_19[7], 1); |
938 | /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ | 961 | /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ |
939 | reg_w(gspca_dev, 0x1c, &sn9c10x[0x1c - 1], 4); | 962 | reg_w(gspca_dev, 0x1c, &sn9c10x[0x1c - 1], 4); |
940 | /* Enable video transfert */ | 963 | /* Enable video transfert */ |
941 | reg_w(gspca_dev, 0x01, &sn9c10x[0], 1); | 964 | reg_w(gspca_dev, 0x01, &sn9c10x[0], 1); |
942 | /* Compression */ | 965 | /* Compression */ |
943 | reg_w(gspca_dev, 0x18, ®17_19[1], 2); | 966 | reg_w(gspca_dev, 0x18, ®12_19[6], 2); |
944 | msleep(20); | 967 | msleep(20); |
945 | 968 | ||
946 | sd->reg11 = -1; | 969 | sd->reg11 = -1; |
@@ -957,18 +980,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
957 | 980 | ||
958 | static void sd_stopN(struct gspca_dev *gspca_dev) | 981 | static void sd_stopN(struct gspca_dev *gspca_dev) |
959 | { | 982 | { |
960 | __u8 ByteSend; | 983 | sd_init(gspca_dev); |
961 | |||
962 | ByteSend = 0x09; /* 0X00 */ | ||
963 | reg_w(gspca_dev, 0x01, &ByteSend, 1); | ||
964 | } | ||
965 | |||
966 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
967 | { | ||
968 | } | ||
969 | |||
970 | static void sd_close(struct gspca_dev *gspca_dev) | ||
971 | { | ||
972 | } | 984 | } |
973 | 985 | ||
974 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 986 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
@@ -978,6 +990,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
978 | { | 990 | { |
979 | int i; | 991 | int i; |
980 | struct sd *sd = (struct sd *) gspca_dev; | 992 | struct sd *sd = (struct sd *) gspca_dev; |
993 | struct cam *cam = &gspca_dev->cam; | ||
981 | 994 | ||
982 | /* frames start with: | 995 | /* frames start with: |
983 | * ff ff 00 c4 c4 96 synchro | 996 | * ff ff 00 c4 c4 96 synchro |
@@ -998,20 +1011,31 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
998 | && data[5 + i] == 0x96) { /* start of frame */ | 1011 | && data[5 + i] == 0x96) { /* start of frame */ |
999 | int lum = -1; | 1012 | int lum = -1; |
1000 | int pkt_type = LAST_PACKET; | 1013 | int pkt_type = LAST_PACKET; |
1014 | int fr_h_sz = (sd->bridge == BRIDGE_103) ? | ||
1015 | 18 : 12; | ||
1001 | 1016 | ||
1002 | if (len - i < sd->fr_h_sz) { | 1017 | if (len - i < fr_h_sz) { |
1003 | PDEBUG(D_STREAM, "packet too short to" | 1018 | PDEBUG(D_STREAM, "packet too short to" |
1004 | " get avg brightness"); | 1019 | " get avg brightness"); |
1005 | } else if (sd->fr_h_sz == 12) { | 1020 | } else if (sd->bridge == BRIDGE_103) { |
1006 | lum = data[i + 8] + (data[i + 9] << 8); | ||
1007 | } else { | ||
1008 | lum = data[i + 9] + | 1021 | lum = data[i + 9] + |
1009 | (data[i + 10] << 8); | 1022 | (data[i + 10] << 8); |
1023 | } else { | ||
1024 | lum = data[i + 8] + (data[i + 9] << 8); | ||
1010 | } | 1025 | } |
1011 | if (lum == 0) { | 1026 | /* When exposure changes midway a frame we |
1027 | get a lum of 0 in this case drop 2 frames | ||
1028 | as the frames directly after an exposure | ||
1029 | change have an unstable image. Sometimes lum | ||
1030 | *really* is 0 (cam used in low light with | ||
1031 | low exposure setting), so do not drop frames | ||
1032 | if the previous lum was 0 too. */ | ||
1033 | if (lum == 0 && sd->prev_avg_lum != 0) { | ||
1012 | lum = -1; | 1034 | lum = -1; |
1013 | sd->frames_to_drop = 2; | 1035 | sd->frames_to_drop = 2; |
1014 | } | 1036 | sd->prev_avg_lum = 0; |
1037 | } else | ||
1038 | sd->prev_avg_lum = lum; | ||
1015 | atomic_set(&sd->avg_lum, lum); | 1039 | atomic_set(&sd->avg_lum, lum); |
1016 | 1040 | ||
1017 | if (sd->frames_to_drop) { | 1041 | if (sd->frames_to_drop) { |
@@ -1021,14 +1045,25 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1021 | 1045 | ||
1022 | frame = gspca_frame_add(gspca_dev, pkt_type, | 1046 | frame = gspca_frame_add(gspca_dev, pkt_type, |
1023 | frame, data, 0); | 1047 | frame, data, 0); |
1024 | data += i + sd->fr_h_sz; | 1048 | data += i + fr_h_sz; |
1025 | len -= i + sd->fr_h_sz; | 1049 | len -= i + fr_h_sz; |
1026 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 1050 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
1027 | frame, data, len); | 1051 | frame, data, len); |
1028 | return; | 1052 | return; |
1029 | } | 1053 | } |
1030 | } | 1054 | } |
1031 | } | 1055 | } |
1056 | |||
1057 | if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) { | ||
1058 | /* In raw mode we sometimes get some garbage after the frame | ||
1059 | ignore this */ | ||
1060 | int used = frame->data_end - frame->data; | ||
1061 | int size = cam->cam_mode[gspca_dev->curr_mode].sizeimage; | ||
1062 | |||
1063 | if (used + len > size) | ||
1064 | len = size - used; | ||
1065 | } | ||
1066 | |||
1032 | gspca_frame_add(gspca_dev, INTER_PACKET, | 1067 | gspca_frame_add(gspca_dev, INTER_PACKET, |
1033 | frame, data, len); | 1068 | frame, data, len); |
1034 | } | 1069 | } |
@@ -1162,58 +1197,45 @@ static const struct sd_desc sd_desc = { | |||
1162 | .ctrls = sd_ctrls, | 1197 | .ctrls = sd_ctrls, |
1163 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1198 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1164 | .config = sd_config, | 1199 | .config = sd_config, |
1165 | .open = sd_open, | 1200 | .init = sd_init, |
1166 | .start = sd_start, | 1201 | .start = sd_start, |
1167 | .stopN = sd_stopN, | 1202 | .stopN = sd_stopN, |
1168 | .stop0 = sd_stop0, | ||
1169 | .close = sd_close, | ||
1170 | .pkt_scan = sd_pkt_scan, | 1203 | .pkt_scan = sd_pkt_scan, |
1171 | .querymenu = sd_querymenu, | 1204 | .querymenu = sd_querymenu, |
1205 | .dq_callback = do_autogain, | ||
1172 | }; | 1206 | }; |
1173 | 1207 | ||
1174 | /* -- module initialisation -- */ | 1208 | /* -- module initialisation -- */ |
1175 | #define SFCI(sensor, flags, nctrls, i2c_addr) \ | 1209 | #define SB(sensor, bridge) \ |
1176 | .driver_info = (SENSOR_ ## sensor << 24) \ | 1210 | .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge |
1177 | | ((flags) << 16) \ | 1211 | |
1178 | | ((nctrls) << 8) \ | 1212 | |
1179 | | (i2c_addr) | ||
1180 | static __devinitdata struct usb_device_id device_table[] = { | 1213 | static __devinitdata struct usb_device_id device_table[] = { |
1181 | #ifndef CONFIG_USB_SN9C102 | 1214 | {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110, 102)}, /* TAS5110C1B */ |
1182 | {USB_DEVICE(0x0c45, 0x6001), /* SN9C102 */ | 1215 | {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110, 101)}, /* TAS5110C1B */ |
1183 | SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, | 1216 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1184 | {USB_DEVICE(0x0c45, 0x6005), /* SN9C101 */ | 1217 | {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110, 101)}, /* TAS5110D */ |
1185 | SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, | 1218 | {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)}, |
1186 | {USB_DEVICE(0x0c45, 0x6007), /* SN9C101 */ | 1219 | {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, |
1187 | SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, | ||
1188 | {USB_DEVICE(0x0c45, 0x6009), /* SN9C101 */ | ||
1189 | SFCI(PAS106, F_SIF, 2, 0)}, | ||
1190 | {USB_DEVICE(0x0c45, 0x600d), /* SN9C101 */ | ||
1191 | SFCI(PAS106, F_SIF, 2, 0)}, | ||
1192 | #endif | 1220 | #endif |
1193 | {USB_DEVICE(0x0c45, 0x6011), /* SN9C101 - SN9C101G */ | 1221 | {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, |
1194 | SFCI(OV6650, F_GAIN|F_AUTO|F_SIF, 5, 0x60)}, | 1222 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1195 | #ifndef CONFIG_USB_SN9C102 | 1223 | {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, |
1196 | {USB_DEVICE(0x0c45, 0x6019), /* SN9C101 */ | 1224 | {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, |
1197 | SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, | 1225 | {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, |
1198 | {USB_DEVICE(0x0c45, 0x6024), /* SN9C102 */ | 1226 | {USB_DEVICE(0x0c45, 0x6028), SB(PAS202, 102)}, |
1199 | SFCI(TAS5130CXX, 0, 2, 0)}, | 1227 | {USB_DEVICE(0x0c45, 0x6029), SB(PAS106, 102)}, |
1200 | {USB_DEVICE(0x0c45, 0x6025), /* SN9C102 */ | 1228 | {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)}, |
1201 | SFCI(TAS5130CXX, 0, 2, 0)}, | ||
1202 | {USB_DEVICE(0x0c45, 0x6028), /* SN9C102 */ | ||
1203 | SFCI(PAS202, 0, 2, 0)}, | ||
1204 | {USB_DEVICE(0x0c45, 0x6029), /* SN9C101 */ | ||
1205 | SFCI(PAS106, F_SIF, 2, 0)}, | ||
1206 | {USB_DEVICE(0x0c45, 0x602c), /* SN9C102 */ | ||
1207 | SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, | ||
1208 | {USB_DEVICE(0x0c45, 0x602d), /* SN9C102 */ | ||
1209 | SFCI(HV7131R, 0, 2, 0)}, | ||
1210 | {USB_DEVICE(0x0c45, 0x602e), /* SN9C102 */ | ||
1211 | SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, | ||
1212 | {USB_DEVICE(0x0c45, 0x60af), /* SN9C103 */ | ||
1213 | SFCI(PAS202, F_H18, 2, 0)}, | ||
1214 | {USB_DEVICE(0x0c45, 0x60b0), /* SN9C103 */ | ||
1215 | SFCI(OV7630, F_GAIN|F_AUTO|F_H18, 5, 0x21)}, | ||
1216 | #endif | 1229 | #endif |
1230 | {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)}, | ||
1231 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1232 | {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)}, | ||
1233 | #endif | ||
1234 | {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)}, | ||
1235 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1236 | {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)}, | ||
1237 | #endif | ||
1238 | {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)}, | ||
1217 | {} | 1239 | {} |
1218 | }; | 1240 | }; |
1219 | MODULE_DEVICE_TABLE(usb, device_table); | 1241 | MODULE_DEVICE_TABLE(usb, device_table); |
@@ -1231,6 +1253,10 @@ static struct usb_driver sd_driver = { | |||
1231 | .id_table = device_table, | 1253 | .id_table = device_table, |
1232 | .probe = sd_probe, | 1254 | .probe = sd_probe, |
1233 | .disconnect = gspca_disconnect, | 1255 | .disconnect = gspca_disconnect, |
1256 | #ifdef CONFIG_PM | ||
1257 | .suspend = gspca_suspend, | ||
1258 | .resume = gspca_resume, | ||
1259 | #endif | ||
1234 | }; | 1260 | }; |
1235 | 1261 | ||
1236 | /* -- module insert / remove -- */ | 1262 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 245a30ec5fb1..d75b1d20b318 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -54,8 +54,10 @@ struct sd { | |||
54 | #define SENSOR_HV7131R 0 | 54 | #define SENSOR_HV7131R 0 |
55 | #define SENSOR_MI0360 1 | 55 | #define SENSOR_MI0360 1 |
56 | #define SENSOR_MO4000 2 | 56 | #define SENSOR_MO4000 2 |
57 | #define SENSOR_OV7648 3 | 57 | #define SENSOR_OM6802 3 |
58 | #define SENSOR_OV7660 4 | 58 | #define SENSOR_OV7630 4 |
59 | #define SENSOR_OV7648 5 | ||
60 | #define SENSOR_OV7660 6 | ||
59 | unsigned char i2c_base; | 61 | unsigned char i2c_base; |
60 | }; | 62 | }; |
61 | 63 | ||
@@ -76,7 +78,8 @@ static struct ctrl sd_ctrls[] = { | |||
76 | .type = V4L2_CTRL_TYPE_INTEGER, | 78 | .type = V4L2_CTRL_TYPE_INTEGER, |
77 | .name = "Brightness", | 79 | .name = "Brightness", |
78 | .minimum = 0, | 80 | .minimum = 0, |
79 | .maximum = 0xffff, | 81 | #define BRIGHTNESS_MAX 0xffff |
82 | .maximum = BRIGHTNESS_MAX, | ||
80 | .step = 1, | 83 | .step = 1, |
81 | #define BRIGHTNESS_DEF 0x7fff | 84 | #define BRIGHTNESS_DEF 0x7fff |
82 | .default_value = BRIGHTNESS_DEF, | 85 | .default_value = BRIGHTNESS_DEF, |
@@ -90,7 +93,8 @@ static struct ctrl sd_ctrls[] = { | |||
90 | .type = V4L2_CTRL_TYPE_INTEGER, | 93 | .type = V4L2_CTRL_TYPE_INTEGER, |
91 | .name = "Contrast", | 94 | .name = "Contrast", |
92 | .minimum = 0, | 95 | .minimum = 0, |
93 | .maximum = 127, | 96 | #define CONTRAST_MAX 127 |
97 | .maximum = CONTRAST_MAX, | ||
94 | .step = 1, | 98 | .step = 1, |
95 | #define CONTRAST_DEF 63 | 99 | #define CONTRAST_DEF 63 |
96 | .default_value = CONTRAST_DEF, | 100 | .default_value = CONTRAST_DEF, |
@@ -104,14 +108,15 @@ static struct ctrl sd_ctrls[] = { | |||
104 | .type = V4L2_CTRL_TYPE_INTEGER, | 108 | .type = V4L2_CTRL_TYPE_INTEGER, |
105 | .name = "Color", | 109 | .name = "Color", |
106 | .minimum = 0, | 110 | .minimum = 0, |
107 | .maximum = 255, | 111 | .maximum = 64, |
108 | .step = 1, | 112 | .step = 1, |
109 | #define COLOR_DEF 127 | 113 | #define COLOR_DEF 32 |
110 | .default_value = COLOR_DEF, | 114 | .default_value = COLOR_DEF, |
111 | }, | 115 | }, |
112 | .set = sd_setcolors, | 116 | .set = sd_setcolors, |
113 | .get = sd_getcolors, | 117 | .get = sd_getcolors, |
114 | }, | 118 | }, |
119 | #define AUTOGAIN_IDX 3 | ||
115 | { | 120 | { |
116 | { | 121 | { |
117 | .id = V4L2_CID_AUTOGAIN, | 122 | .id = V4L2_CID_AUTOGAIN, |
@@ -131,7 +136,7 @@ static struct ctrl sd_ctrls[] = { | |||
131 | static struct v4l2_pix_format vga_mode[] = { | 136 | static struct v4l2_pix_format vga_mode[] = { |
132 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 137 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
133 | .bytesperline = 160, | 138 | .bytesperline = 160, |
134 | .sizeimage = 160 * 120 * 3 / 8 + 590, | 139 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
135 | .colorspace = V4L2_COLORSPACE_JPEG, | 140 | .colorspace = V4L2_COLORSPACE_JPEG, |
136 | .priv = 2}, | 141 | .priv = 2}, |
137 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 142 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
@@ -180,6 +185,31 @@ static const __u8 sn_mo4000[] = { | |||
180 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 185 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
181 | }; | 186 | }; |
182 | 187 | ||
188 | static const __u8 sn_om6802[] = { | ||
189 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
190 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20, | ||
191 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
192 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
193 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
194 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, | ||
195 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | ||
196 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
197 | 0x08, 0x22, 0x44, 0x63, 0x7d, 0x92, 0xa3, 0xaf, | ||
198 | 0xbc, 0xc4, 0xcd, 0xd5, 0xdc, 0xe1, 0xe8, 0xef, | ||
199 | 0xf7 | ||
200 | }; | ||
201 | |||
202 | static const __u8 sn_ov7630[] = { | ||
203 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
204 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20, | ||
205 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
206 | 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10, | ||
207 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
208 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, | ||
209 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | ||
210 | 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
211 | }; | ||
212 | |||
183 | static const __u8 sn_ov7648[] = { | 213 | static const __u8 sn_ov7648[] = { |
184 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 214 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
185 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, | 215 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, |
@@ -207,31 +237,22 @@ static const __u8 *sn_tb[] = { | |||
207 | sn_hv7131, | 237 | sn_hv7131, |
208 | sn_mi0360, | 238 | sn_mi0360, |
209 | sn_mo4000, | 239 | sn_mo4000, |
240 | sn_om6802, | ||
241 | sn_ov7630, | ||
210 | sn_ov7648, | 242 | sn_ov7648, |
211 | sn_ov7660 | 243 | sn_ov7660 |
212 | }; | 244 | }; |
213 | 245 | ||
214 | static const __u8 regsn20[] = { | 246 | static const __u8 gamma_def[] = { |
215 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, | 247 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
216 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff | 248 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
217 | }; | 249 | }; |
218 | static const __u8 regsn20_sn9c325[] = { | ||
219 | 0x0a, 0x3a, 0x56, 0x6c, 0x7e, 0x8d, 0x9a, 0xa4, | ||
220 | 0xaf, 0xbb, 0xc5, 0xcd, 0xd5, 0xde, 0xe8, 0xed, 0xf5 | ||
221 | }; | ||
222 | 250 | ||
223 | static const __u8 reg84[] = { | 251 | static const __u8 reg84[] = { |
224 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, | 252 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, |
225 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, | 253 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, |
226 | /* 0x00, 0x00, 0x00, 0x00, 0x00 */ | 254 | 0xf7, 0x0f, 0x00, 0x00, 0x00 |
227 | 0xf7, 0x0f, 0x0a, 0x00, 0x00 | ||
228 | }; | ||
229 | static const __u8 reg84_sn9c325[] = { | ||
230 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe4, 0x0f, | ||
231 | 0xd3, 0x0f, 0x4b, 0x00, 0x48, 0x00, 0xc0, 0x0f, | ||
232 | 0xf8, 0x0f, 0x00, 0x00, 0x00 | ||
233 | }; | 255 | }; |
234 | |||
235 | static const __u8 hv7131r_sensor_init[][8] = { | 256 | static const __u8 hv7131r_sensor_init[][8] = { |
236 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, | 257 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
237 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, | 258 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, |
@@ -340,6 +361,92 @@ static const __u8 mo4000_sensor_init[][8] = { | |||
340 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | 361 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
341 | {} | 362 | {} |
342 | }; | 363 | }; |
364 | static __u8 om6802_sensor_init[][8] = { | ||
365 | {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10}, | ||
366 | {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10}, | ||
367 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, | ||
368 | {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10}, | ||
369 | /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */ | ||
370 | {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
371 | /* white balance & auto-exposure */ | ||
372 | /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10}, | ||
373 | * set color mode */ | ||
374 | /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10}, | ||
375 | * max AGC value in AE */ | ||
376 | /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
377 | * preset AGC */ | ||
378 | /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
379 | * preset brightness */ | ||
380 | /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
381 | * preset contrast */ | ||
382 | /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10}, | ||
383 | * preset gamma */ | ||
384 | {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10}, | ||
385 | /* luminance mode (0x4f = AE) */ | ||
386 | {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10}, | ||
387 | /* preset shutter */ | ||
388 | /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
389 | * auto frame rate */ | ||
390 | /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */ | ||
391 | |||
392 | /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */ | ||
393 | /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */ | ||
394 | /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */ | ||
395 | /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */ | ||
396 | {} | ||
397 | }; | ||
398 | static const __u8 ov7630_sensor_init[][8] = { | ||
399 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, | ||
400 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | ||
401 | /* win: delay 20ms */ | ||
402 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
403 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | ||
404 | /* win: delay 20ms */ | ||
405 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
406 | /* win: i2c_r from 00 to 80 */ | ||
407 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, | ||
408 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, | ||
409 | {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10}, | ||
410 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, | ||
411 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | ||
412 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
413 | {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10}, | ||
414 | {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10}, | ||
415 | {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10}, | ||
416 | {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10}, | ||
417 | {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10}, | ||
418 | {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10}, | ||
419 | {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
420 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
421 | {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10}, | ||
422 | {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
423 | {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10}, | ||
424 | {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10}, | ||
425 | {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10}, | ||
426 | {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10}, | ||
427 | {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10}, | ||
428 | {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10}, | ||
429 | {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10}, | ||
430 | {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10}, | ||
431 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | ||
432 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
433 | /* */ | ||
434 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
435 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
436 | /*fixme: + 0x12, 0x04*/ | ||
437 | {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, | ||
438 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, | ||
439 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
440 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, | ||
441 | /* */ | ||
442 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
443 | {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, | ||
444 | {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, | ||
445 | /* */ | ||
446 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, | ||
447 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ | ||
448 | {} | ||
449 | }; | ||
343 | static const __u8 ov7660_sensor_init[][8] = { | 450 | static const __u8 ov7660_sensor_init[][8] = { |
344 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ | 451 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
345 | /* (delay 20ms) */ | 452 | /* (delay 20ms) */ |
@@ -506,10 +613,16 @@ static const __u8 qtable4[] = { | |||
506 | 0x29, 0x29, 0x29, 0x29 | 613 | 0x29, 0x29, 0x29, 0x29 |
507 | }; | 614 | }; |
508 | 615 | ||
509 | /* read <len> bytes (len < sizeof gspca_dev->usb_buf) to gspca_dev->usb_buf */ | 616 | /* read <len> bytes to gspca_dev->usb_buf */ |
510 | static void reg_r(struct gspca_dev *gspca_dev, | 617 | static void reg_r(struct gspca_dev *gspca_dev, |
511 | __u16 value, int len) | 618 | __u16 value, int len) |
512 | { | 619 | { |
620 | #ifdef GSPCA_DEBUG | ||
621 | if (len > USB_BUF_SZ) { | ||
622 | err("reg_r: buffer overflow"); | ||
623 | return; | ||
624 | } | ||
625 | #endif | ||
513 | usb_control_msg(gspca_dev->dev, | 626 | usb_control_msg(gspca_dev->dev, |
514 | usb_rcvctrlpipe(gspca_dev->dev, 0), | 627 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
515 | 0, | 628 | 0, |
@@ -542,29 +655,20 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
542 | { | 655 | { |
543 | PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", | 656 | PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", |
544 | value, buffer[0], buffer[1]); | 657 | value, buffer[0], buffer[1]); |
545 | if (len <= sizeof gspca_dev->usb_buf) { | 658 | #ifdef GSPCA_DEBUG |
546 | memcpy(gspca_dev->usb_buf, buffer, len); | 659 | if (len > USB_BUF_SZ) { |
547 | usb_control_msg(gspca_dev->dev, | 660 | err("reg_w: buffer overflow"); |
548 | usb_sndctrlpipe(gspca_dev->dev, 0), | 661 | return; |
549 | 0x08, | ||
550 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
551 | value, 0, | ||
552 | gspca_dev->usb_buf, len, | ||
553 | 500); | ||
554 | } else { | ||
555 | __u8 *tmpbuf; | ||
556 | |||
557 | tmpbuf = kmalloc(len, GFP_KERNEL); | ||
558 | memcpy(tmpbuf, buffer, len); | ||
559 | usb_control_msg(gspca_dev->dev, | ||
560 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
561 | 0x08, | ||
562 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
563 | value, 0, | ||
564 | tmpbuf, len, | ||
565 | 500); | ||
566 | kfree(tmpbuf); | ||
567 | } | 662 | } |
663 | #endif | ||
664 | memcpy(gspca_dev->usb_buf, buffer, len); | ||
665 | usb_control_msg(gspca_dev->dev, | ||
666 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
667 | 0x08, | ||
668 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
669 | value, 0, | ||
670 | gspca_dev->usb_buf, len, | ||
671 | 500); | ||
568 | } | 672 | } |
569 | 673 | ||
570 | /* I2C write 1 byte */ | 674 | /* I2C write 1 byte */ |
@@ -665,7 +769,7 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
665 | static const __u8 regd4[] = {0x60, 0x00, 0x00}; | 769 | static const __u8 regd4[] = {0x60, 0x00, 0x00}; |
666 | 770 | ||
667 | reg_w1(gspca_dev, 0xf1, 0x00); | 771 | reg_w1(gspca_dev, 0xf1, 0x00); |
668 | reg_w1(gspca_dev, 0x01, 0x00); /*jfm was sn9c1xx[1] in v1*/ | 772 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
669 | 773 | ||
670 | /* configure gpio */ | 774 | /* configure gpio */ |
671 | reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); | 775 | reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); |
@@ -685,21 +789,41 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
685 | 789 | ||
686 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | 790 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
687 | 791 | ||
688 | switch (sd->bridge) { | 792 | switch (sd->sensor) { |
689 | case BRIDGE_SN9C325: | 793 | case SENSOR_OM6802: |
794 | reg_w1(gspca_dev, 0x02, 0x71); | ||
795 | reg_w1(gspca_dev, 0x01, 0x42); | ||
796 | reg_w1(gspca_dev, 0x17, 0x64); | ||
797 | reg_w1(gspca_dev, 0x01, 0x42); | ||
798 | break; | ||
799 | /*jfm: from win trace */ | ||
800 | case SENSOR_OV7630: | ||
801 | reg_w1(gspca_dev, 0x01, 0x61); | ||
802 | reg_w1(gspca_dev, 0x17, 0xe2); | ||
803 | reg_w1(gspca_dev, 0x01, 0x60); | ||
804 | reg_w1(gspca_dev, 0x01, 0x40); | ||
805 | break; | ||
806 | case SENSOR_OV7648: | ||
690 | reg_w1(gspca_dev, 0x01, 0x43); | 807 | reg_w1(gspca_dev, 0x01, 0x43); |
691 | reg_w1(gspca_dev, 0x17, 0xae); | 808 | reg_w1(gspca_dev, 0x17, 0xae); |
692 | reg_w1(gspca_dev, 0x01, 0x42); | 809 | reg_w1(gspca_dev, 0x01, 0x42); |
693 | break; | 810 | break; |
811 | /*jfm: from win trace */ | ||
812 | case SENSOR_OV7660: | ||
813 | reg_w1(gspca_dev, 0x01, 0x61); | ||
814 | reg_w1(gspca_dev, 0x17, 0x20); | ||
815 | reg_w1(gspca_dev, 0x01, 0x60); | ||
816 | reg_w1(gspca_dev, 0x01, 0x40); | ||
817 | break; | ||
694 | default: | 818 | default: |
695 | reg_w1(gspca_dev, 0x01, 0x43); | 819 | reg_w1(gspca_dev, 0x01, 0x43); |
696 | reg_w1(gspca_dev, 0x17, 0x61); | 820 | reg_w1(gspca_dev, 0x17, 0x61); |
697 | reg_w1(gspca_dev, 0x01, 0x42); | 821 | reg_w1(gspca_dev, 0x01, 0x42); |
698 | } | 822 | if (sd->sensor == SENSOR_HV7131R) { |
699 | 823 | if (probesensor(gspca_dev) < 0) | |
700 | if (sd->sensor == SENSOR_HV7131R) { | 824 | return -ENODEV; |
701 | if (probesensor(gspca_dev) < 0) | 825 | } |
702 | return -ENODEV; | 826 | break; |
703 | } | 827 | } |
704 | return 0; | 828 | return 0; |
705 | } | 829 | } |
@@ -737,6 +861,40 @@ static void mo4000_InitSensor(struct gspca_dev *gspca_dev) | |||
737 | } | 861 | } |
738 | } | 862 | } |
739 | 863 | ||
864 | static void om6802_InitSensor(struct gspca_dev *gspca_dev) | ||
865 | { | ||
866 | int i = 0; | ||
867 | |||
868 | while (om6802_sensor_init[i][0]) { | ||
869 | i2c_w8(gspca_dev, om6802_sensor_init[i]); | ||
870 | i++; | ||
871 | } | ||
872 | } | ||
873 | |||
874 | static void ov7630_InitSensor(struct gspca_dev *gspca_dev) | ||
875 | { | ||
876 | int i = 0; | ||
877 | |||
878 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */ | ||
879 | i++; | ||
880 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */ | ||
881 | i++; | ||
882 | msleep(20); | ||
883 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */ | ||
884 | i++; | ||
885 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */ | ||
886 | i++; | ||
887 | msleep(20); | ||
888 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */ | ||
889 | i++; | ||
890 | /*jfm:win i2c_r from 00 to 80*/ | ||
891 | |||
892 | while (ov7630_sensor_init[i][0]) { | ||
893 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); | ||
894 | i++; | ||
895 | } | ||
896 | } | ||
897 | |||
740 | static void ov7648_InitSensor(struct gspca_dev *gspca_dev) | 898 | static void ov7648_InitSensor(struct gspca_dev *gspca_dev) |
741 | { | 899 | { |
742 | int i = 0; | 900 | int i = 0; |
@@ -783,11 +941,19 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
783 | sd->autogain = AUTOGAIN_DEF; | 941 | sd->autogain = AUTOGAIN_DEF; |
784 | sd->ag_cnt = -1; | 942 | sd->ag_cnt = -1; |
785 | 943 | ||
944 | switch (sd->sensor) { | ||
945 | case SENSOR_OV7630: | ||
946 | case SENSOR_OV7648: | ||
947 | case SENSOR_OV7660: | ||
948 | gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX); | ||
949 | break; | ||
950 | } | ||
951 | |||
786 | return 0; | 952 | return 0; |
787 | } | 953 | } |
788 | 954 | ||
789 | /* this function is called at open time */ | 955 | /* this function is called at probe and resume time */ |
790 | static int sd_open(struct gspca_dev *gspca_dev) | 956 | static int sd_init(struct gspca_dev *gspca_dev) |
791 | { | 957 | { |
792 | struct sd *sd = (struct sd *) gspca_dev; | 958 | struct sd *sd = (struct sd *) gspca_dev; |
793 | /* const __u8 *sn9c1xx; */ | 959 | /* const __u8 *sn9c1xx; */ |
@@ -891,16 +1057,53 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
891 | | ((expoMo10[3] & 0x30) >> 4)); | 1057 | | ((expoMo10[3] & 0x30) >> 4)); |
892 | break; | 1058 | break; |
893 | } | 1059 | } |
1060 | case SENSOR_OM6802: { | ||
1061 | __u8 gainOm[] = | ||
1062 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; | ||
1063 | |||
1064 | if (expo > 0x03ff) | ||
1065 | expo = 0x03ff; | ||
1066 | if (expo < 0x0001) | ||
1067 | expo = 0x0001; | ||
1068 | gainOm[3] = expo >> 2; | ||
1069 | i2c_w8(gspca_dev, gainOm); | ||
1070 | reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f); | ||
1071 | PDEBUG(D_CONF, "set exposure %d", gainOm[3]); | ||
1072 | break; | ||
1073 | } | ||
894 | } | 1074 | } |
895 | return expo; | 1075 | return expo; |
896 | } | 1076 | } |
897 | 1077 | ||
1078 | /* this function is used for sensors o76xx only */ | ||
1079 | static void setbrightcont(struct gspca_dev *gspca_dev) | ||
1080 | { | ||
1081 | struct sd *sd = (struct sd *) gspca_dev; | ||
1082 | unsigned val; | ||
1083 | __u8 reg84_full[0x15]; | ||
1084 | |||
1085 | memset(reg84_full, 0, sizeof reg84_full); | ||
1086 | val = sd->contrast * 0x20 / CONTRAST_MAX + 0x10; /* 10..30 */ | ||
1087 | reg84_full[2] = val; | ||
1088 | reg84_full[0] = (val + 1) / 2; | ||
1089 | reg84_full[4] = (val + 1) / 5; | ||
1090 | if (val > BRIGHTNESS_DEF) | ||
1091 | val = (sd->brightness - BRIGHTNESS_DEF) * 0x20 | ||
1092 | / BRIGHTNESS_MAX; | ||
1093 | else | ||
1094 | val = 0; | ||
1095 | reg84_full[0x12] = val; /* 00..1f */ | ||
1096 | reg_w(gspca_dev, 0x84, reg84_full, sizeof reg84_full); | ||
1097 | } | ||
1098 | |||
1099 | /* sensor != ov76xx */ | ||
898 | static void setbrightness(struct gspca_dev *gspca_dev) | 1100 | static void setbrightness(struct gspca_dev *gspca_dev) |
899 | { | 1101 | { |
900 | struct sd *sd = (struct sd *) gspca_dev; | 1102 | struct sd *sd = (struct sd *) gspca_dev; |
901 | unsigned int expo; | 1103 | unsigned int expo; |
902 | __u8 k2; | 1104 | __u8 k2; |
903 | 1105 | ||
1106 | k2 = sd->brightness >> 10; | ||
904 | switch (sd->sensor) { | 1107 | switch (sd->sensor) { |
905 | case SENSOR_HV7131R: | 1108 | case SENSOR_HV7131R: |
906 | expo = sd->brightness << 4; | 1109 | expo = sd->brightness << 4; |
@@ -915,12 +1118,17 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
915 | expo = sd->brightness >> 4; | 1118 | expo = sd->brightness >> 4; |
916 | sd->exposure = setexposure(gspca_dev, expo); | 1119 | sd->exposure = setexposure(gspca_dev, expo); |
917 | break; | 1120 | break; |
1121 | case SENSOR_OM6802: | ||
1122 | expo = sd->brightness >> 6; | ||
1123 | sd->exposure = setexposure(gspca_dev, expo); | ||
1124 | k2 = sd->brightness >> 11; | ||
1125 | break; | ||
918 | } | 1126 | } |
919 | 1127 | ||
920 | k2 = sd->brightness >> 10; | ||
921 | reg_w1(gspca_dev, 0x96, k2); | 1128 | reg_w1(gspca_dev, 0x96, k2); |
922 | } | 1129 | } |
923 | 1130 | ||
1131 | /* sensor != ov76xx */ | ||
924 | static void setcontrast(struct gspca_dev *gspca_dev) | 1132 | static void setcontrast(struct gspca_dev *gspca_dev) |
925 | { | 1133 | { |
926 | struct sd *sd = (struct sd *) gspca_dev; | 1134 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -937,31 +1145,30 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
937 | static void setcolors(struct gspca_dev *gspca_dev) | 1145 | static void setcolors(struct gspca_dev *gspca_dev) |
938 | { | 1146 | { |
939 | struct sd *sd = (struct sd *) gspca_dev; | 1147 | struct sd *sd = (struct sd *) gspca_dev; |
940 | __u8 data; | 1148 | __u8 blue, red; |
941 | int colour; | ||
942 | 1149 | ||
943 | colour = sd->colors - 128; | 1150 | if (sd->colors >= 32) { |
944 | if (colour > 0) | 1151 | red = 32 + (sd->colors - 32) / 2; |
945 | data = (colour + 32) & 0x7f; /* blue */ | 1152 | blue = 64 - sd->colors; |
946 | else | 1153 | } else { |
947 | data = (-colour + 32) & 0x7f; /* red */ | 1154 | red = sd->colors; |
948 | reg_w1(gspca_dev, 0x05, data); | 1155 | blue = 32 + (32 - sd->colors) / 2; |
1156 | } | ||
1157 | reg_w1(gspca_dev, 0x05, red); | ||
1158 | /* reg_w1(gspca_dev, 0x07, 32); */ | ||
1159 | reg_w1(gspca_dev, 0x06, blue); | ||
949 | } | 1160 | } |
950 | 1161 | ||
951 | static void setautogain(struct gspca_dev *gspca_dev) | 1162 | static void setautogain(struct gspca_dev *gspca_dev) |
952 | { | 1163 | { |
953 | struct sd *sd = (struct sd *) gspca_dev; | 1164 | struct sd *sd = (struct sd *) gspca_dev; |
954 | 1165 | ||
955 | switch (sd->sensor) { | 1166 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
956 | case SENSOR_HV7131R: | 1167 | return; |
957 | case SENSOR_MO4000: | 1168 | if (sd->autogain) |
958 | case SENSOR_MI0360: | 1169 | sd->ag_cnt = AG_CNT_START; |
959 | if (sd->autogain) | 1170 | else |
960 | sd->ag_cnt = AG_CNT_START; | 1171 | sd->ag_cnt = -1; |
961 | else | ||
962 | sd->ag_cnt = -1; | ||
963 | break; | ||
964 | } | ||
965 | } | 1172 | } |
966 | 1173 | ||
967 | /* -- start the camera -- */ | 1174 | /* -- start the camera -- */ |
@@ -975,13 +1182,12 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
975 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 1182 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
976 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 1183 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
977 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ | 1184 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
978 | static const __u8 CE_sn9c325[] = | 1185 | static const __u8 CE_ov76xx[] = |
979 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7648 - SN9C325 */ | 1186 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7630/48 */ |
980 | 1187 | ||
981 | sn9c1xx = sn_tb[(int) sd->sensor]; | 1188 | sn9c1xx = sn_tb[(int) sd->sensor]; |
982 | configure_gpio(gspca_dev, sn9c1xx); | 1189 | configure_gpio(gspca_dev, sn9c1xx); |
983 | 1190 | ||
984 | /* reg_w1(gspca_dev, 0x01, 0x44); jfm from win trace*/ | ||
985 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); | 1191 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); |
986 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); | 1192 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); |
987 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); | 1193 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); |
@@ -994,10 +1200,17 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
994 | reg_w1(gspca_dev, 0xc8, 0x50); | 1200 | reg_w1(gspca_dev, 0xc8, 0x50); |
995 | reg_w1(gspca_dev, 0xc9, 0x3c); | 1201 | reg_w1(gspca_dev, 0xc9, 0x3c); |
996 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | 1202 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
997 | switch (sd->bridge) { | 1203 | switch (sd->sensor) { |
998 | case BRIDGE_SN9C325: | 1204 | case SENSOR_OV7630: |
1205 | reg17 = 0xe2; | ||
1206 | break; | ||
1207 | case SENSOR_OV7648: | ||
999 | reg17 = 0xae; | 1208 | reg17 = 0xae; |
1000 | break; | 1209 | break; |
1210 | /*jfm: from win trace */ | ||
1211 | case SENSOR_OV7660: | ||
1212 | reg17 = 0xa0; | ||
1213 | break; | ||
1001 | default: | 1214 | default: |
1002 | reg17 = 0x60; | 1215 | reg17 = 0x60; |
1003 | break; | 1216 | break; |
@@ -1007,24 +1220,11 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1007 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); | 1220 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); |
1008 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); | 1221 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); |
1009 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); | 1222 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
1010 | switch (sd->bridge) { | 1223 | reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); |
1011 | case BRIDGE_SN9C325: | 1224 | for (i = 0; i < 8; i++) |
1012 | reg_w(gspca_dev, 0x20, regsn20_sn9c325, | 1225 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
1013 | sizeof regsn20_sn9c325); | ||
1014 | for (i = 0; i < 8; i++) | ||
1015 | reg_w(gspca_dev, 0x84, reg84_sn9c325, | ||
1016 | sizeof reg84_sn9c325); | ||
1017 | reg_w1(gspca_dev, 0x9a, 0x0a); | ||
1018 | reg_w1(gspca_dev, 0x99, 0x60); | ||
1019 | break; | ||
1020 | default: | ||
1021 | reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20); | ||
1022 | for (i = 0; i < 8; i++) | ||
1023 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); | ||
1024 | reg_w1(gspca_dev, 0x9a, 0x08); | 1226 | reg_w1(gspca_dev, 0x9a, 0x08); |
1025 | reg_w1(gspca_dev, 0x99, 0x59); | 1227 | reg_w1(gspca_dev, 0x99, 0x59); |
1026 | break; | ||
1027 | } | ||
1028 | 1228 | ||
1029 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 1229 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; |
1030 | if (mode) | 1230 | if (mode) |
@@ -1049,6 +1249,15 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1049 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | 1249 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
1050 | } | 1250 | } |
1051 | break; | 1251 | break; |
1252 | case SENSOR_OM6802: | ||
1253 | om6802_InitSensor(gspca_dev); | ||
1254 | reg17 = 0x64; /* 640 MCKSIZE */ | ||
1255 | break; | ||
1256 | case SENSOR_OV7630: | ||
1257 | ov7630_InitSensor(gspca_dev); | ||
1258 | reg17 = 0xe2; | ||
1259 | reg1 = 0x44; | ||
1260 | break; | ||
1052 | case SENSOR_OV7648: | 1261 | case SENSOR_OV7648: |
1053 | ov7648_InitSensor(gspca_dev); | 1262 | ov7648_InitSensor(gspca_dev); |
1054 | reg17 = 0xa2; | 1263 | reg17 = 0xa2; |
@@ -1073,9 +1282,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1073 | } | 1282 | } |
1074 | reg_w(gspca_dev, 0xc0, C0, 6); | 1283 | reg_w(gspca_dev, 0xc0, C0, 6); |
1075 | reg_w(gspca_dev, 0xca, CA, 4); | 1284 | reg_w(gspca_dev, 0xca, CA, 4); |
1076 | switch (sd->bridge) { | 1285 | switch (sd->sensor) { |
1077 | case BRIDGE_SN9C325: | 1286 | case SENSOR_OV7630: |
1078 | reg_w(gspca_dev, 0xce, CE_sn9c325, 4); | 1287 | case SENSOR_OV7648: |
1288 | reg_w(gspca_dev, 0xce, CE_ov76xx, 4); | ||
1079 | break; | 1289 | break; |
1080 | default: | 1290 | default: |
1081 | reg_w(gspca_dev, 0xce, CE, 4); | 1291 | reg_w(gspca_dev, 0xce, CE, 4); |
@@ -1093,10 +1303,20 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1093 | reg_w1(gspca_dev, 0x18, reg18); | 1303 | reg_w1(gspca_dev, 0x18, reg18); |
1094 | 1304 | ||
1095 | reg_w1(gspca_dev, 0x17, reg17); | 1305 | reg_w1(gspca_dev, 0x17, reg17); |
1096 | reg_w1(gspca_dev, 0x01, reg1); | 1306 | switch (sd->sensor) { |
1097 | setbrightness(gspca_dev); | 1307 | case SENSOR_HV7131R: |
1098 | setcontrast(gspca_dev); | 1308 | case SENSOR_MI0360: |
1309 | case SENSOR_MO4000: | ||
1310 | case SENSOR_OM6802: | ||
1311 | setbrightness(gspca_dev); | ||
1312 | setcontrast(gspca_dev); | ||
1313 | break; | ||
1314 | default: /* OV76xx */ | ||
1315 | setbrightcont(gspca_dev); | ||
1316 | break; | ||
1317 | } | ||
1099 | setautogain(gspca_dev); | 1318 | setautogain(gspca_dev); |
1319 | reg_w1(gspca_dev, 0x01, reg1); | ||
1100 | } | 1320 | } |
1101 | 1321 | ||
1102 | static void sd_stopN(struct gspca_dev *gspca_dev) | 1322 | static void sd_stopN(struct gspca_dev *gspca_dev) |
@@ -1119,6 +1339,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1119 | i2c_w8(gspca_dev, stopmi0360); | 1339 | i2c_w8(gspca_dev, stopmi0360); |
1120 | data = 0x29; | 1340 | data = 0x29; |
1121 | break; | 1341 | break; |
1342 | case SENSOR_OV7630: | ||
1122 | case SENSOR_OV7648: | 1343 | case SENSOR_OV7648: |
1123 | data = 0x29; | 1344 | data = 0x29; |
1124 | break; | 1345 | break; |
@@ -1132,15 +1353,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1132 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); | 1353 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); |
1133 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 1354 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
1134 | reg_w1(gspca_dev, 0x01, data); | 1355 | reg_w1(gspca_dev, 0x01, data); |
1135 | reg_w1(gspca_dev, 0xf1, 0x01); | 1356 | reg_w1(gspca_dev, 0xf1, 0x00); |
1136 | } | ||
1137 | |||
1138 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1139 | { | ||
1140 | } | ||
1141 | |||
1142 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1143 | { | ||
1144 | } | 1357 | } |
1145 | 1358 | ||
1146 | static void do_autogain(struct gspca_dev *gspca_dev) | 1359 | static void do_autogain(struct gspca_dev *gspca_dev) |
@@ -1174,6 +1387,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
1174 | default: | 1387 | default: |
1175 | /* case SENSOR_MO4000: */ | 1388 | /* case SENSOR_MO4000: */ |
1176 | /* case SENSOR_MI0360: */ | 1389 | /* case SENSOR_MI0360: */ |
1390 | /* case SENSOR_OM6802: */ | ||
1177 | expotimes = sd->exposure; | 1391 | expotimes = sd->exposure; |
1178 | expotimes += (luma_mean - delta) >> 6; | 1392 | expotimes += (luma_mean - delta) >> 6; |
1179 | if (expotimes < 0) | 1393 | if (expotimes < 0) |
@@ -1229,69 +1443,24 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1229 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 1443 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
1230 | } | 1444 | } |
1231 | 1445 | ||
1232 | static unsigned int getexposure(struct gspca_dev *gspca_dev) | ||
1233 | { | ||
1234 | struct sd *sd = (struct sd *) gspca_dev; | ||
1235 | __u8 hexpo, mexpo, lexpo; | ||
1236 | |||
1237 | switch (sd->sensor) { | ||
1238 | case SENSOR_HV7131R: | ||
1239 | /* read sensor exposure */ | ||
1240 | i2c_r5(gspca_dev, 0x25); | ||
1241 | return (gspca_dev->usb_buf[0] << 16) | ||
1242 | | (gspca_dev->usb_buf[1] << 8) | ||
1243 | | gspca_dev->usb_buf[2]; | ||
1244 | case SENSOR_MI0360: | ||
1245 | /* read sensor exposure */ | ||
1246 | i2c_r5(gspca_dev, 0x09); | ||
1247 | return (gspca_dev->usb_buf[0] << 8) | ||
1248 | | gspca_dev->usb_buf[1]; | ||
1249 | case SENSOR_MO4000: | ||
1250 | i2c_r5(gspca_dev, 0x0e); | ||
1251 | hexpo = 0; /* gspca_dev->usb_buf[1] & 0x07; */ | ||
1252 | mexpo = 0x40; /* gspca_dev->usb_buf[2] & 0xff; */ | ||
1253 | lexpo = (gspca_dev->usb_buf[1] & 0x30) >> 4; | ||
1254 | PDEBUG(D_CONF, "exposure %d", | ||
1255 | (hexpo << 10) | (mexpo << 2) | lexpo); | ||
1256 | return (hexpo << 10) | (mexpo << 2) | lexpo; | ||
1257 | default: | ||
1258 | /* case SENSOR_OV7648: * jfm: is it ok for 7648? */ | ||
1259 | /* case SENSOR_OV7660: */ | ||
1260 | /* read sensor exposure */ | ||
1261 | i2c_r5(gspca_dev, 0x04); | ||
1262 | hexpo = gspca_dev->usb_buf[3] & 0x2f; | ||
1263 | lexpo = gspca_dev->usb_buf[0] & 0x02; | ||
1264 | i2c_r5(gspca_dev, 0x08); | ||
1265 | mexpo = gspca_dev->usb_buf[2]; | ||
1266 | return (hexpo << 10) | (mexpo << 2) | lexpo; | ||
1267 | } | ||
1268 | } | ||
1269 | |||
1270 | static void getbrightness(struct gspca_dev *gspca_dev) | ||
1271 | { | ||
1272 | struct sd *sd = (struct sd *) gspca_dev; | ||
1273 | |||
1274 | /* hardcoded registers seem not readable */ | ||
1275 | switch (sd->sensor) { | ||
1276 | case SENSOR_HV7131R: | ||
1277 | sd->brightness = getexposure(gspca_dev) >> 4; | ||
1278 | break; | ||
1279 | case SENSOR_MI0360: | ||
1280 | sd->brightness = getexposure(gspca_dev) << 4; | ||
1281 | break; | ||
1282 | case SENSOR_MO4000: | ||
1283 | sd->brightness = getexposure(gspca_dev) << 4; | ||
1284 | break; | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 1446 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
1289 | { | 1447 | { |
1290 | struct sd *sd = (struct sd *) gspca_dev; | 1448 | struct sd *sd = (struct sd *) gspca_dev; |
1291 | 1449 | ||
1292 | sd->brightness = val; | 1450 | sd->brightness = val; |
1293 | if (gspca_dev->streaming) | 1451 | if (gspca_dev->streaming) { |
1294 | setbrightness(gspca_dev); | 1452 | switch (sd->sensor) { |
1453 | case SENSOR_HV7131R: | ||
1454 | case SENSOR_MI0360: | ||
1455 | case SENSOR_MO4000: | ||
1456 | case SENSOR_OM6802: | ||
1457 | setbrightness(gspca_dev); | ||
1458 | break; | ||
1459 | default: /* OV76xx */ | ||
1460 | setbrightcont(gspca_dev); | ||
1461 | break; | ||
1462 | } | ||
1463 | } | ||
1295 | return 0; | 1464 | return 0; |
1296 | } | 1465 | } |
1297 | 1466 | ||
@@ -1299,7 +1468,6 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
1299 | { | 1468 | { |
1300 | struct sd *sd = (struct sd *) gspca_dev; | 1469 | struct sd *sd = (struct sd *) gspca_dev; |
1301 | 1470 | ||
1302 | getbrightness(gspca_dev); | ||
1303 | *val = sd->brightness; | 1471 | *val = sd->brightness; |
1304 | return 0; | 1472 | return 0; |
1305 | } | 1473 | } |
@@ -1309,8 +1477,19 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | |||
1309 | struct sd *sd = (struct sd *) gspca_dev; | 1477 | struct sd *sd = (struct sd *) gspca_dev; |
1310 | 1478 | ||
1311 | sd->contrast = val; | 1479 | sd->contrast = val; |
1312 | if (gspca_dev->streaming) | 1480 | if (gspca_dev->streaming) { |
1313 | setcontrast(gspca_dev); | 1481 | switch (sd->sensor) { |
1482 | case SENSOR_HV7131R: | ||
1483 | case SENSOR_MI0360: | ||
1484 | case SENSOR_MO4000: | ||
1485 | case SENSOR_OM6802: | ||
1486 | setcontrast(gspca_dev); | ||
1487 | break; | ||
1488 | default: /* OV76xx */ | ||
1489 | setbrightcont(gspca_dev); | ||
1490 | break; | ||
1491 | } | ||
1492 | } | ||
1314 | return 0; | 1493 | return 0; |
1315 | } | 1494 | } |
1316 | 1495 | ||
@@ -1364,11 +1543,9 @@ static const struct sd_desc sd_desc = { | |||
1364 | .ctrls = sd_ctrls, | 1543 | .ctrls = sd_ctrls, |
1365 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1544 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1366 | .config = sd_config, | 1545 | .config = sd_config, |
1367 | .open = sd_open, | 1546 | .init = sd_init, |
1368 | .start = sd_start, | 1547 | .start = sd_start, |
1369 | .stopN = sd_stopN, | 1548 | .stopN = sd_stopN, |
1370 | .stop0 = sd_stop0, | ||
1371 | .close = sd_close, | ||
1372 | .pkt_scan = sd_pkt_scan, | 1549 | .pkt_scan = sd_pkt_scan, |
1373 | .dq_callback = do_autogain, | 1550 | .dq_callback = do_autogain, |
1374 | }; | 1551 | }; |
@@ -1379,7 +1556,7 @@ static const struct sd_desc sd_desc = { | |||
1379 | | (SENSOR_ ## sensor << 8) \ | 1556 | | (SENSOR_ ## sensor << 8) \ |
1380 | | (i2c_addr) | 1557 | | (i2c_addr) |
1381 | static const __devinitdata struct usb_device_id device_table[] = { | 1558 | static const __devinitdata struct usb_device_id device_table[] = { |
1382 | #ifndef CONFIG_USB_SN9C102 | 1559 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1383 | {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)}, | 1560 | {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)}, |
1384 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, | 1561 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, |
1385 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, | 1562 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, |
@@ -1406,15 +1583,17 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
1406 | /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ | 1583 | /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ |
1407 | /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ | 1584 | /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ |
1408 | /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ | 1585 | /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ |
1409 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C325, OV7648, 0x21)}, | 1586 | {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/ |
1410 | /* bw600.inf: | 1587 | /*bw600.inf:*/ |
1411 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C110, OV7648, 0x21)}, */ | 1588 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C110, OV7648, 0x21)}, /*sn9c325?*/ |
1412 | {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)}, | 1589 | {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)}, |
1413 | /* {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x??)}, */ | 1590 | {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)}, |
1414 | /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */ | 1591 | /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */ |
1415 | #ifndef CONFIG_USB_SN9C102 | 1592 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1416 | {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, | 1593 | {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, |
1594 | #endif | ||
1417 | {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, | 1595 | {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, |
1596 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1418 | /* {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x??)}, */ | 1597 | /* {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x??)}, */ |
1419 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, | 1598 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, |
1420 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, | 1599 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, |
@@ -1438,6 +1617,10 @@ static struct usb_driver sd_driver = { | |||
1438 | .id_table = device_table, | 1617 | .id_table = device_table, |
1439 | .probe = sd_probe, | 1618 | .probe = sd_probe, |
1440 | .disconnect = gspca_disconnect, | 1619 | .disconnect = gspca_disconnect, |
1620 | #ifdef CONFIG_PM | ||
1621 | .suspend = gspca_suspend, | ||
1622 | .resume = gspca_resume, | ||
1623 | #endif | ||
1441 | }; | 1624 | }; |
1442 | 1625 | ||
1443 | /* -- module insert / remove -- */ | 1626 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index 17fe2c2a440d..6e733901fcca 100644 --- a/drivers/media/video/gspca/spca500.c +++ b/drivers/media/video/gspca/spca500.c | |||
@@ -645,8 +645,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
645 | return 0; | 645 | return 0; |
646 | } | 646 | } |
647 | 647 | ||
648 | /* this function is called at open time */ | 648 | /* this function is called at probe and resume time */ |
649 | static int sd_open(struct gspca_dev *gspca_dev) | 649 | static int sd_init(struct gspca_dev *gspca_dev) |
650 | { | 650 | { |
651 | struct sd *sd = (struct sd *) gspca_dev; | 651 | struct sd *sd = (struct sd *) gspca_dev; |
652 | 652 | ||
@@ -880,14 +880,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
880 | gspca_dev->usb_buf[0]); | 880 | gspca_dev->usb_buf[0]); |
881 | } | 881 | } |
882 | 882 | ||
883 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
884 | { | ||
885 | } | ||
886 | |||
887 | static void sd_close(struct gspca_dev *gspca_dev) | ||
888 | { | ||
889 | } | ||
890 | |||
891 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 883 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
892 | struct gspca_frame *frame, /* target */ | 884 | struct gspca_frame *frame, /* target */ |
893 | __u8 *data, /* isoc packet */ | 885 | __u8 *data, /* isoc packet */ |
@@ -1051,11 +1043,9 @@ static struct sd_desc sd_desc = { | |||
1051 | .ctrls = sd_ctrls, | 1043 | .ctrls = sd_ctrls, |
1052 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1044 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1053 | .config = sd_config, | 1045 | .config = sd_config, |
1054 | .open = sd_open, | 1046 | .init = sd_init, |
1055 | .start = sd_start, | 1047 | .start = sd_start, |
1056 | .stopN = sd_stopN, | 1048 | .stopN = sd_stopN, |
1057 | .stop0 = sd_stop0, | ||
1058 | .close = sd_close, | ||
1059 | .pkt_scan = sd_pkt_scan, | 1049 | .pkt_scan = sd_pkt_scan, |
1060 | }; | 1050 | }; |
1061 | 1051 | ||
@@ -1093,6 +1083,10 @@ static struct usb_driver sd_driver = { | |||
1093 | .id_table = device_table, | 1083 | .id_table = device_table, |
1094 | .probe = sd_probe, | 1084 | .probe = sd_probe, |
1095 | .disconnect = gspca_disconnect, | 1085 | .disconnect = gspca_disconnect, |
1086 | #ifdef CONFIG_PM | ||
1087 | .suspend = gspca_suspend, | ||
1088 | .resume = gspca_resume, | ||
1089 | #endif | ||
1096 | }; | 1090 | }; |
1097 | 1091 | ||
1098 | /* -- module insert / remove -- */ | 1092 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c index 51a3c3429ef0..e9eb59bae4fb 100644 --- a/drivers/media/video/gspca/spca501.c +++ b/drivers/media/video/gspca/spca501.c | |||
@@ -1953,8 +1953,8 @@ error: | |||
1953 | return -EINVAL; | 1953 | return -EINVAL; |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | /* this function is called at open time */ | 1956 | /* this function is called at probe and resume time */ |
1957 | static int sd_open(struct gspca_dev *gspca_dev) | 1957 | static int sd_init(struct gspca_dev *gspca_dev) |
1958 | { | 1958 | { |
1959 | struct sd *sd = (struct sd *) gspca_dev; | 1959 | struct sd *sd = (struct sd *) gspca_dev; |
1960 | 1960 | ||
@@ -2023,11 +2023,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
2023 | 2023 | ||
2024 | static void sd_stop0(struct gspca_dev *gspca_dev) | 2024 | static void sd_stop0(struct gspca_dev *gspca_dev) |
2025 | { | 2025 | { |
2026 | } | ||
2027 | |||
2028 | /* this function is called at close time */ | ||
2029 | static void sd_close(struct gspca_dev *gspca_dev) | ||
2030 | { | ||
2031 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); | 2026 | reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); |
2032 | } | 2027 | } |
2033 | 2028 | ||
@@ -2120,11 +2115,10 @@ static const struct sd_desc sd_desc = { | |||
2120 | .ctrls = sd_ctrls, | 2115 | .ctrls = sd_ctrls, |
2121 | .nctrls = ARRAY_SIZE(sd_ctrls), | 2116 | .nctrls = ARRAY_SIZE(sd_ctrls), |
2122 | .config = sd_config, | 2117 | .config = sd_config, |
2123 | .open = sd_open, | 2118 | .init = sd_init, |
2124 | .start = sd_start, | 2119 | .start = sd_start, |
2125 | .stopN = sd_stopN, | 2120 | .stopN = sd_stopN, |
2126 | .stop0 = sd_stop0, | 2121 | .stop0 = sd_stop0, |
2127 | .close = sd_close, | ||
2128 | .pkt_scan = sd_pkt_scan, | 2122 | .pkt_scan = sd_pkt_scan, |
2129 | }; | 2123 | }; |
2130 | 2124 | ||
@@ -2154,6 +2148,10 @@ static struct usb_driver sd_driver = { | |||
2154 | .id_table = device_table, | 2148 | .id_table = device_table, |
2155 | .probe = sd_probe, | 2149 | .probe = sd_probe, |
2156 | .disconnect = gspca_disconnect, | 2150 | .disconnect = gspca_disconnect, |
2151 | #ifdef CONFIG_PM | ||
2152 | .suspend = gspca_suspend, | ||
2153 | .resume = gspca_resume, | ||
2154 | #endif | ||
2157 | }; | 2155 | }; |
2158 | 2156 | ||
2159 | /* -- module insert / remove -- */ | 2157 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c index eda29d609359..f601daf19ebe 100644 --- a/drivers/media/video/gspca/spca505.c +++ b/drivers/media/video/gspca/spca505.c | |||
@@ -655,8 +655,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
655 | return 0; | 655 | return 0; |
656 | } | 656 | } |
657 | 657 | ||
658 | /* this function is called at open time */ | 658 | /* this function is called at probe and resume time */ |
659 | static int sd_open(struct gspca_dev *gspca_dev) | 659 | static int sd_init(struct gspca_dev *gspca_dev) |
660 | { | 660 | { |
661 | struct sd *sd = (struct sd *) gspca_dev; | 661 | struct sd *sd = (struct sd *) gspca_dev; |
662 | int ret; | 662 | int ret; |
@@ -743,11 +743,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
743 | 743 | ||
744 | static void sd_stop0(struct gspca_dev *gspca_dev) | 744 | static void sd_stop0(struct gspca_dev *gspca_dev) |
745 | { | 745 | { |
746 | } | ||
747 | |||
748 | /* this function is called at close time */ | ||
749 | static void sd_close(struct gspca_dev *gspca_dev) | ||
750 | { | ||
751 | /* This maybe reset or power control */ | 746 | /* This maybe reset or power control */ |
752 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); | 747 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); |
753 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); | 748 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); |
@@ -825,11 +820,10 @@ static const struct sd_desc sd_desc = { | |||
825 | .ctrls = sd_ctrls, | 820 | .ctrls = sd_ctrls, |
826 | .nctrls = ARRAY_SIZE(sd_ctrls), | 821 | .nctrls = ARRAY_SIZE(sd_ctrls), |
827 | .config = sd_config, | 822 | .config = sd_config, |
828 | .open = sd_open, | 823 | .init = sd_init, |
829 | .start = sd_start, | 824 | .start = sd_start, |
830 | .stopN = sd_stopN, | 825 | .stopN = sd_stopN, |
831 | .stop0 = sd_stop0, | 826 | .stop0 = sd_stop0, |
832 | .close = sd_close, | ||
833 | .pkt_scan = sd_pkt_scan, | 827 | .pkt_scan = sd_pkt_scan, |
834 | }; | 828 | }; |
835 | 829 | ||
@@ -855,6 +849,10 @@ static struct usb_driver sd_driver = { | |||
855 | .id_table = device_table, | 849 | .id_table = device_table, |
856 | .probe = sd_probe, | 850 | .probe = sd_probe, |
857 | .disconnect = gspca_disconnect, | 851 | .disconnect = gspca_disconnect, |
852 | #ifdef CONFIG_PM | ||
853 | .suspend = gspca_suspend, | ||
854 | .resume = gspca_resume, | ||
855 | #endif | ||
858 | }; | 856 | }; |
859 | 857 | ||
860 | /* -- module insert / remove -- */ | 858 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c index f622fa75766d..195dce96ef06 100644 --- a/drivers/media/video/gspca/spca506.c +++ b/drivers/media/video/gspca/spca506.c | |||
@@ -313,8 +313,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
313 | return 0; | 313 | return 0; |
314 | } | 314 | } |
315 | 315 | ||
316 | /* this function is called at open time */ | 316 | /* this function is called at probe and resume time */ |
317 | static int sd_open(struct gspca_dev *gspca_dev) | 317 | static int sd_init(struct gspca_dev *gspca_dev) |
318 | { | 318 | { |
319 | struct usb_device *dev = gspca_dev->dev; | 319 | struct usb_device *dev = gspca_dev->dev; |
320 | 320 | ||
@@ -560,14 +560,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
560 | reg_w(dev, 0x03, 0x00, 0x0003); | 560 | reg_w(dev, 0x03, 0x00, 0x0003); |
561 | } | 561 | } |
562 | 562 | ||
563 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
564 | { | ||
565 | } | ||
566 | |||
567 | static void sd_close(struct gspca_dev *gspca_dev) | ||
568 | { | ||
569 | } | ||
570 | |||
571 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 563 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
572 | struct gspca_frame *frame, /* target */ | 564 | struct gspca_frame *frame, /* target */ |
573 | __u8 *data, /* isoc packet */ | 565 | __u8 *data, /* isoc packet */ |
@@ -740,11 +732,9 @@ static struct sd_desc sd_desc = { | |||
740 | .ctrls = sd_ctrls, | 732 | .ctrls = sd_ctrls, |
741 | .nctrls = ARRAY_SIZE(sd_ctrls), | 733 | .nctrls = ARRAY_SIZE(sd_ctrls), |
742 | .config = sd_config, | 734 | .config = sd_config, |
743 | .open = sd_open, | 735 | .init = sd_init, |
744 | .start = sd_start, | 736 | .start = sd_start, |
745 | .stopN = sd_stopN, | 737 | .stopN = sd_stopN, |
746 | .stop0 = sd_stop0, | ||
747 | .close = sd_close, | ||
748 | .pkt_scan = sd_pkt_scan, | 738 | .pkt_scan = sd_pkt_scan, |
749 | }; | 739 | }; |
750 | 740 | ||
@@ -772,6 +762,10 @@ static struct usb_driver sd_driver = { | |||
772 | .id_table = device_table, | 762 | .id_table = device_table, |
773 | .probe = sd_probe, | 763 | .probe = sd_probe, |
774 | .disconnect = gspca_disconnect, | 764 | .disconnect = gspca_disconnect, |
765 | #ifdef CONFIG_PM | ||
766 | .suspend = gspca_suspend, | ||
767 | .resume = gspca_resume, | ||
768 | #endif | ||
775 | }; | 769 | }; |
776 | 770 | ||
777 | /* -- module insert / remove -- */ | 771 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c index 699340c17dea..281ce02103a3 100644 --- a/drivers/media/video/gspca/spca508.c +++ b/drivers/media/video/gspca/spca508.c | |||
@@ -1521,8 +1521,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1521 | return 0; /* success */ | 1521 | return 0; /* success */ |
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | /* this function is called at open time */ | 1524 | /* this function is called at probe and resume time */ |
1525 | static int sd_open(struct gspca_dev *gspca_dev) | 1525 | static int sd_init(struct gspca_dev *gspca_dev) |
1526 | { | 1526 | { |
1527 | /* write_vector(gspca_dev, spca508_open_data); */ | 1527 | /* write_vector(gspca_dev, spca508_open_data); */ |
1528 | return 0; | 1528 | return 0; |
@@ -1554,15 +1554,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1554 | reg_write(gspca_dev->dev, 0x8112, 0x20); | 1554 | reg_write(gspca_dev->dev, 0x8112, 0x20); |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1558 | { | ||
1559 | } | ||
1560 | |||
1561 | /* this function is called at close time */ | ||
1562 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1563 | { | ||
1564 | } | ||
1565 | |||
1566 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1557 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1567 | struct gspca_frame *frame, /* target */ | 1558 | struct gspca_frame *frame, /* target */ |
1568 | __u8 *data, /* isoc packet */ | 1559 | __u8 *data, /* isoc packet */ |
@@ -1633,11 +1624,9 @@ static const struct sd_desc sd_desc = { | |||
1633 | .ctrls = sd_ctrls, | 1624 | .ctrls = sd_ctrls, |
1634 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1625 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1635 | .config = sd_config, | 1626 | .config = sd_config, |
1636 | .open = sd_open, | 1627 | .init = sd_init, |
1637 | .start = sd_start, | 1628 | .start = sd_start, |
1638 | .stopN = sd_stopN, | 1629 | .stopN = sd_stopN, |
1639 | .stop0 = sd_stop0, | ||
1640 | .close = sd_close, | ||
1641 | .pkt_scan = sd_pkt_scan, | 1630 | .pkt_scan = sd_pkt_scan, |
1642 | }; | 1631 | }; |
1643 | 1632 | ||
@@ -1667,6 +1656,10 @@ static struct usb_driver sd_driver = { | |||
1667 | .id_table = device_table, | 1656 | .id_table = device_table, |
1668 | .probe = sd_probe, | 1657 | .probe = sd_probe, |
1669 | .disconnect = gspca_disconnect, | 1658 | .disconnect = gspca_disconnect, |
1659 | #ifdef CONFIG_PM | ||
1660 | .suspend = gspca_suspend, | ||
1661 | .resume = gspca_resume, | ||
1662 | #endif | ||
1670 | }; | 1663 | }; |
1671 | 1664 | ||
1672 | /* -- module insert / remove -- */ | 1665 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c index 1073ac3d2ec6..cfbc9ebc5c5d 100644 --- a/drivers/media/video/gspca/spca561.c +++ b/drivers/media/video/gspca/spca561.c | |||
@@ -32,69 +32,48 @@ MODULE_LICENSE("GPL"); | |||
32 | struct sd { | 32 | struct sd { |
33 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 33 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
34 | 34 | ||
35 | unsigned short contrast; | 35 | __u16 contrast; /* rev72a only */ |
36 | __u8 brightness; | 36 | #define CONTRAST_MIN 0x0000 |
37 | #define CONTRAST_DEF 0x2000 | ||
38 | #define CONTRAST_MAX 0x3fff | ||
39 | |||
40 | __u16 exposure; /* rev12a only */ | ||
41 | #define EXPOSURE_MIN 1 | ||
42 | #define EXPOSURE_DEF 200 | ||
43 | #define EXPOSURE_MAX (4095 - 900) /* see set_exposure */ | ||
44 | |||
45 | __u8 brightness; /* rev72a only */ | ||
46 | #define BRIGHTNESS_MIN 0 | ||
47 | #define BRIGHTNESS_DEF 32 | ||
48 | #define BRIGHTNESS_MAX 63 | ||
49 | |||
50 | __u8 white; /* rev12a only */ | ||
51 | #define WHITE_MIN 1 | ||
52 | #define WHITE_DEF 0x40 | ||
53 | #define WHITE_MAX 0x7f | ||
54 | |||
37 | __u8 autogain; | 55 | __u8 autogain; |
56 | #define AUTOGAIN_MIN 0 | ||
57 | #define AUTOGAIN_DEF 1 | ||
58 | #define AUTOGAIN_MAX 1 | ||
59 | |||
60 | __u8 gain; /* rev12a only */ | ||
61 | #define GAIN_MIN 0x0 | ||
62 | #define GAIN_DEF 0x24 | ||
63 | #define GAIN_MAX 0x24 | ||
64 | |||
65 | #define EXPO12A_DEF 3 | ||
66 | __u8 expo12a; /* expo/gain? for rev 12a */ | ||
38 | 67 | ||
39 | __u8 chip_revision; | 68 | __u8 chip_revision; |
69 | #define Rev012A 0 | ||
70 | #define Rev072A 1 | ||
71 | |||
40 | signed char ag_cnt; | 72 | signed char ag_cnt; |
41 | #define AG_CNT_START 13 | 73 | #define AG_CNT_START 13 |
42 | }; | 74 | }; |
43 | 75 | ||
44 | /* V4L2 controls supported by the driver */ | 76 | static struct v4l2_pix_format sif_012a_mode[] = { |
45 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
46 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
47 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | ||
48 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
49 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | ||
50 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | ||
51 | |||
52 | static struct ctrl sd_ctrls[] = { | ||
53 | #define SD_BRIGHTNESS 0 | ||
54 | { | ||
55 | { | ||
56 | .id = V4L2_CID_BRIGHTNESS, | ||
57 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
58 | .name = "Brightness", | ||
59 | .minimum = 0, | ||
60 | .maximum = 63, | ||
61 | .step = 1, | ||
62 | .default_value = 32, | ||
63 | }, | ||
64 | .set = sd_setbrightness, | ||
65 | .get = sd_getbrightness, | ||
66 | }, | ||
67 | #define SD_CONTRAST 1 | ||
68 | { | ||
69 | { | ||
70 | .id = V4L2_CID_CONTRAST, | ||
71 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
72 | .name = "Contrast", | ||
73 | .minimum = 0, | ||
74 | .maximum = 0x3fff, | ||
75 | .step = 1, | ||
76 | .default_value = 0x2000, | ||
77 | }, | ||
78 | .set = sd_setcontrast, | ||
79 | .get = sd_getcontrast, | ||
80 | }, | ||
81 | #define SD_AUTOGAIN 2 | ||
82 | { | ||
83 | { | ||
84 | .id = V4L2_CID_AUTOGAIN, | ||
85 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
86 | .name = "Auto Gain", | ||
87 | .minimum = 0, | ||
88 | .maximum = 1, | ||
89 | .step = 1, | ||
90 | .default_value = 1, | ||
91 | }, | ||
92 | .set = sd_setautogain, | ||
93 | .get = sd_getautogain, | ||
94 | }, | ||
95 | }; | ||
96 | |||
97 | static struct v4l2_pix_format sif_mode[] = { | ||
98 | {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | 77 | {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, |
99 | .bytesperline = 160, | 78 | .bytesperline = 160, |
100 | .sizeimage = 160 * 120, | 79 | .sizeimage = 160 * 120, |
@@ -117,6 +96,29 @@ static struct v4l2_pix_format sif_mode[] = { | |||
117 | .priv = 0}, | 96 | .priv = 0}, |
118 | }; | 97 | }; |
119 | 98 | ||
99 | static struct v4l2_pix_format sif_072a_mode[] = { | ||
100 | {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
101 | .bytesperline = 160, | ||
102 | .sizeimage = 160 * 120, | ||
103 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
104 | .priv = 3}, | ||
105 | {176, 144, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
106 | .bytesperline = 176, | ||
107 | .sizeimage = 176 * 144, | ||
108 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
109 | .priv = 2}, | ||
110 | {320, 240, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
111 | .bytesperline = 320, | ||
112 | .sizeimage = 320 * 240, | ||
113 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
114 | .priv = 1}, | ||
115 | {352, 288, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
116 | .bytesperline = 352, | ||
117 | .sizeimage = 352 * 288, | ||
118 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
119 | .priv = 0}, | ||
120 | }; | ||
121 | |||
120 | /* | 122 | /* |
121 | * Initialization data | 123 | * Initialization data |
122 | * I'm not very sure how to split initialization from open data | 124 | * I'm not very sure how to split initialization from open data |
@@ -143,12 +145,8 @@ static struct v4l2_pix_format sif_mode[] = { | |||
143 | #define SPCA561_INDEX_I2C_BASE 0x8800 | 145 | #define SPCA561_INDEX_I2C_BASE 0x8800 |
144 | #define SPCA561_SNAPBIT 0x20 | 146 | #define SPCA561_SNAPBIT 0x20 |
145 | #define SPCA561_SNAPCTRL 0x40 | 147 | #define SPCA561_SNAPCTRL 0x40 |
146 | enum { | ||
147 | Rev072A = 0, | ||
148 | Rev012A, | ||
149 | }; | ||
150 | 148 | ||
151 | static void reg_w_val(struct usb_device *dev, __u16 index, __u16 value) | 149 | static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value) |
152 | { | 150 | { |
153 | int ret; | 151 | int ret; |
154 | 152 | ||
@@ -198,12 +196,6 @@ static void reg_w_buf(struct gspca_dev *gspca_dev, | |||
198 | index, gspca_dev->usb_buf, len, 500); | 196 | index, gspca_dev->usb_buf, len, 500); |
199 | } | 197 | } |
200 | 198 | ||
201 | static void i2c_init(struct gspca_dev *gspca_dev, __u8 mode) | ||
202 | { | ||
203 | reg_w_val(gspca_dev->dev, 0x92, 0x8804); | ||
204 | reg_w_val(gspca_dev->dev, mode, 0x8802); | ||
205 | } | ||
206 | |||
207 | static void i2c_write(struct gspca_dev *gspca_dev, __u16 valeur, __u16 reg) | 199 | static void i2c_write(struct gspca_dev *gspca_dev, __u16 valeur, __u16 reg) |
208 | { | 200 | { |
209 | int retry = 60; | 201 | int retry = 60; |
@@ -212,9 +204,9 @@ static void i2c_write(struct gspca_dev *gspca_dev, __u16 valeur, __u16 reg) | |||
212 | 204 | ||
213 | DataLow = valeur; | 205 | DataLow = valeur; |
214 | DataHight = valeur >> 8; | 206 | DataHight = valeur >> 8; |
215 | reg_w_val(gspca_dev->dev, reg, 0x8801); | 207 | reg_w_val(gspca_dev->dev, 0x8801, reg); |
216 | reg_w_val(gspca_dev->dev, DataLow, 0x8805); | 208 | reg_w_val(gspca_dev->dev, 0x8805, DataLow); |
217 | reg_w_val(gspca_dev->dev, DataHight, 0x8800); | 209 | reg_w_val(gspca_dev->dev, 0x8800, DataHight); |
218 | while (retry--) { | 210 | while (retry--) { |
219 | reg_r(gspca_dev, 0x8803, 1); | 211 | reg_r(gspca_dev, 0x8803, 1); |
220 | if (!gspca_dev->usb_buf[0]) | 212 | if (!gspca_dev->usb_buf[0]) |
@@ -228,14 +220,14 @@ static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode) | |||
228 | __u8 value; | 220 | __u8 value; |
229 | __u8 vallsb; | 221 | __u8 vallsb; |
230 | 222 | ||
231 | reg_w_val(gspca_dev->dev, 0x92, 0x8804); | 223 | reg_w_val(gspca_dev->dev, 0x8804, 0x92); |
232 | reg_w_val(gspca_dev->dev, reg, 0x8801); | 224 | reg_w_val(gspca_dev->dev, 0x8801, reg); |
233 | reg_w_val(gspca_dev->dev, (mode | 0x01), 0x8802); | 225 | reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01)); |
234 | while (retry--) { | 226 | do { |
235 | reg_r(gspca_dev, 0x8803, 1); | 227 | reg_r(gspca_dev, 0x8803, 1); |
236 | if (!gspca_dev->usb_buf) | 228 | if (!gspca_dev->usb_buf) |
237 | break; | 229 | break; |
238 | } | 230 | } while (--retry); |
239 | if (retry == 0) | 231 | if (retry == 0) |
240 | return -1; | 232 | return -1; |
241 | reg_r(gspca_dev, 0x8800, 1); | 233 | reg_r(gspca_dev, 0x8800, 1); |
@@ -438,21 +430,10 @@ static const __u16 spca561_init_data[][2] = { | |||
438 | {0x0035, 0x8801}, /* 0x14 - set gain general */ | 430 | {0x0035, 0x8801}, /* 0x14 - set gain general */ |
439 | {0x001f, 0x8805}, /* 0x14 */ | 431 | {0x001f, 0x8805}, /* 0x14 */ |
440 | {0x0000, 0x8800}, | 432 | {0x0000, 0x8800}, |
441 | {0x0030, 0x8112}, | 433 | {0x000e, 0x8112}, /* white balance - was 30 */ |
442 | {} | 434 | {} |
443 | }; | 435 | }; |
444 | 436 | ||
445 | static void sensor_reset(struct gspca_dev *gspca_dev) | ||
446 | { | ||
447 | reg_w_val(gspca_dev->dev, 0x8631, 0xc8); | ||
448 | reg_w_val(gspca_dev->dev, 0x8634, 0xc8); | ||
449 | reg_w_val(gspca_dev->dev, 0x8112, 0x00); | ||
450 | reg_w_val(gspca_dev->dev, 0x8114, 0x00); | ||
451 | reg_w_val(gspca_dev->dev, 0x8118, 0x21); | ||
452 | i2c_init(gspca_dev, 0x14); | ||
453 | i2c_write(gspca_dev, 1, 0x0d); | ||
454 | i2c_write(gspca_dev, 0, 0x0d); | ||
455 | } | ||
456 | 437 | ||
457 | /******************** QC Express etch2 stuff ********************/ | 438 | /******************** QC Express etch2 stuff ********************/ |
458 | static const __u16 Pb100_1map8300[][2] = { | 439 | static const __u16 Pb100_1map8300[][2] = { |
@@ -462,9 +443,9 @@ static const __u16 Pb100_1map8300[][2] = { | |||
462 | {0x8303, 0x0125}, /* image area */ | 443 | {0x8303, 0x0125}, /* image area */ |
463 | {0x8304, 0x0169}, | 444 | {0x8304, 0x0169}, |
464 | {0x8328, 0x000b}, | 445 | {0x8328, 0x000b}, |
465 | {0x833c, 0x0001}, | 446 | {0x833c, 0x0001}, /*fixme: win:07*/ |
466 | 447 | ||
467 | {0x832f, 0x0419}, | 448 | {0x832f, 0x1904}, /*fixme: was 0419*/ |
468 | {0x8307, 0x00aa}, | 449 | {0x8307, 0x00aa}, |
469 | {0x8301, 0x0003}, | 450 | {0x8301, 0x0003}, |
470 | {0x8302, 0x000e}, | 451 | {0x8302, 0x000e}, |
@@ -478,9 +459,10 @@ static const __u16 Pb100_2map8300[][2] = { | |||
478 | }; | 459 | }; |
479 | 460 | ||
480 | static const __u16 spca561_161rev12A_data1[][2] = { | 461 | static const __u16 spca561_161rev12A_data1[][2] = { |
481 | {0x21, 0x8118}, | 462 | {0x29, 0x8118}, /* white balance - was 21 */ |
482 | {0x01, 0x8114}, | 463 | {0x08, 0x8114}, /* white balance - was 01 */ |
483 | {0x00, 0x8112}, | 464 | {0x0e, 0x8112}, /* white balance - was 00 */ |
465 | {0x00, 0x8102}, /* white balance - new */ | ||
484 | {0x92, 0x8804}, | 466 | {0x92, 0x8804}, |
485 | {0x04, 0x8802}, /* windows uses 08 */ | 467 | {0x04, 0x8802}, /* windows uses 08 */ |
486 | {} | 468 | {} |
@@ -505,14 +487,16 @@ static const __u16 spca561_161rev12A_data2[][2] = { | |||
505 | {0xb0, 0x8603}, | 487 | {0xb0, 0x8603}, |
506 | 488 | ||
507 | /* sensor gains */ | 489 | /* sensor gains */ |
490 | {0x07, 0x8601}, /* white balance - new */ | ||
491 | {0x07, 0x8602}, /* white balance - new */ | ||
508 | {0x00, 0x8610}, /* *red */ | 492 | {0x00, 0x8610}, /* *red */ |
509 | {0x00, 0x8611}, /* 3f *green */ | 493 | {0x00, 0x8611}, /* 3f *green */ |
510 | {0x00, 0x8612}, /* green *blue */ | 494 | {0x00, 0x8612}, /* green *blue */ |
511 | {0x00, 0x8613}, /* blue *green */ | 495 | {0x00, 0x8613}, /* blue *green */ |
512 | {0x35, 0x8614}, /* green *red */ | 496 | {0x43, 0x8614}, /* green *red - white balance - was 0x35 */ |
513 | {0x35, 0x8615}, /* 40 *green */ | 497 | {0x40, 0x8615}, /* 40 *green - white balance - was 0x35 */ |
514 | {0x35, 0x8616}, /* 7a *blue */ | 498 | {0x71, 0x8616}, /* 7a *blue - white balance - was 0x35 */ |
515 | {0x35, 0x8617}, /* 40 *green */ | 499 | {0x40, 0x8617}, /* 40 *green - white balance - was 0x35 */ |
516 | 500 | ||
517 | {0x0c, 0x8620}, /* 0c */ | 501 | {0x0c, 0x8620}, /* 0c */ |
518 | {0xc8, 0x8631}, /* c8 */ | 502 | {0xc8, 0x8631}, /* c8 */ |
@@ -527,6 +511,7 @@ static const __u16 spca561_161rev12A_data2[][2] = { | |||
527 | {0xdf, 0x863c}, /* df */ | 511 | {0xdf, 0x863c}, /* df */ |
528 | {0xf0, 0x8505}, | 512 | {0xf0, 0x8505}, |
529 | {0x32, 0x850a}, | 513 | {0x32, 0x850a}, |
514 | /* {0x99, 0x8700}, * - white balance - new (removed) */ | ||
530 | {} | 515 | {} |
531 | }; | 516 | }; |
532 | 517 | ||
@@ -545,9 +530,10 @@ static void sensor_mapwrite(struct gspca_dev *gspca_dev, | |||
545 | } | 530 | } |
546 | static void init_161rev12A(struct gspca_dev *gspca_dev) | 531 | static void init_161rev12A(struct gspca_dev *gspca_dev) |
547 | { | 532 | { |
548 | sensor_reset(gspca_dev); | 533 | /* sensor_reset(gspca_dev); (not in win) */ |
549 | write_vector(gspca_dev, spca561_161rev12A_data1); | 534 | write_vector(gspca_dev, spca561_161rev12A_data1); |
550 | sensor_mapwrite(gspca_dev, Pb100_1map8300); | 535 | sensor_mapwrite(gspca_dev, Pb100_1map8300); |
536 | /*fixme: should be in sd_start*/ | ||
551 | write_vector(gspca_dev, spca561_161rev12A_data2); | 537 | write_vector(gspca_dev, spca561_161rev12A_data2); |
552 | sensor_mapwrite(gspca_dev, Pb100_2map8300); | 538 | sensor_mapwrite(gspca_dev, Pb100_2map8300); |
553 | } | 539 | } |
@@ -581,35 +567,38 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
581 | } | 567 | } |
582 | 568 | ||
583 | cam = &gspca_dev->cam; | 569 | cam = &gspca_dev->cam; |
584 | cam->dev_name = (char *) id->driver_info; | ||
585 | cam->epaddr = 0x01; | 570 | cam->epaddr = 0x01; |
586 | gspca_dev->nbalt = 7 + 1; /* choose alternate 7 first */ | 571 | gspca_dev->nbalt = 7 + 1; /* choose alternate 7 first */ |
587 | cam->cam_mode = sif_mode; | ||
588 | cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; | ||
589 | 572 | ||
590 | sd->chip_revision = id->driver_info; | 573 | sd->chip_revision = id->driver_info; |
591 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; | 574 | if (sd->chip_revision == Rev012A) { |
592 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; | 575 | cam->cam_mode = sif_012a_mode; |
593 | sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value; | 576 | cam->nmodes = ARRAY_SIZE(sif_012a_mode); |
577 | } else { | ||
578 | cam->cam_mode = sif_072a_mode; | ||
579 | cam->nmodes = ARRAY_SIZE(sif_072a_mode); | ||
580 | } | ||
581 | sd->brightness = BRIGHTNESS_DEF; | ||
582 | sd->contrast = CONTRAST_DEF; | ||
583 | sd->white = WHITE_DEF; | ||
584 | sd->exposure = EXPOSURE_DEF; | ||
585 | sd->autogain = AUTOGAIN_DEF; | ||
586 | sd->gain = GAIN_DEF; | ||
587 | sd->expo12a = EXPO12A_DEF; | ||
594 | return 0; | 588 | return 0; |
595 | } | 589 | } |
596 | 590 | ||
597 | /* this function is called at open time */ | 591 | /* this function is called at probe and resume time */ |
598 | static int sd_open(struct gspca_dev *gspca_dev) | 592 | static int sd_init_12a(struct gspca_dev *gspca_dev) |
599 | { | 593 | { |
600 | struct sd *sd = (struct sd *) gspca_dev; | 594 | PDEBUG(D_STREAM, "Chip revision: 012a"); |
601 | 595 | init_161rev12A(gspca_dev); | |
602 | switch (sd->chip_revision) { | 596 | return 0; |
603 | case Rev072A: | 597 | } |
604 | PDEBUG(D_STREAM, "Chip revision id: 072a"); | 598 | static int sd_init_72a(struct gspca_dev *gspca_dev) |
605 | write_vector(gspca_dev, spca561_init_data); | 599 | { |
606 | break; | 600 | PDEBUG(D_STREAM, "Chip revision: 072a"); |
607 | default: | 601 | write_vector(gspca_dev, spca561_init_data); |
608 | /* case Rev012A: */ | ||
609 | PDEBUG(D_STREAM, "Chip revision id: 012a"); | ||
610 | init_161rev12A(gspca_dev); | ||
611 | break; | ||
612 | } | ||
613 | return 0; | 602 | return 0; |
614 | } | 603 | } |
615 | 604 | ||
@@ -618,25 +607,20 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
618 | struct sd *sd = (struct sd *) gspca_dev; | 607 | struct sd *sd = (struct sd *) gspca_dev; |
619 | struct usb_device *dev = gspca_dev->dev; | 608 | struct usb_device *dev = gspca_dev->dev; |
620 | __u8 lowb; | 609 | __u8 lowb; |
621 | int expotimes; | ||
622 | 610 | ||
623 | switch (sd->chip_revision) { | 611 | switch (sd->chip_revision) { |
624 | case Rev072A: | 612 | case Rev072A: |
625 | lowb = sd->contrast >> 8; | 613 | lowb = sd->contrast >> 8; |
626 | reg_w_val(dev, lowb, 0x8651); | 614 | reg_w_val(dev, 0x8651, lowb); |
627 | reg_w_val(dev, lowb, 0x8652); | 615 | reg_w_val(dev, 0x8652, lowb); |
628 | reg_w_val(dev, lowb, 0x8653); | 616 | reg_w_val(dev, 0x8653, lowb); |
629 | reg_w_val(dev, lowb, 0x8654); | 617 | reg_w_val(dev, 0x8654, lowb); |
630 | break; | 618 | break; |
631 | case Rev012A: { | 619 | default: { |
632 | __u8 Reg8391[] = | 620 | /* case Rev012A: { */ |
633 | { 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00 }; | 621 | static const __u8 Reg8391[] = |
634 | 622 | { 0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00 }; | |
635 | /* Write camera sensor settings */ | 623 | |
636 | expotimes = (sd->contrast >> 5) & 0x07ff; | ||
637 | Reg8391[0] = expotimes & 0xff; /* exposure */ | ||
638 | Reg8391[1] = 0x18 | (expotimes >> 8); | ||
639 | Reg8391[2] = sd->brightness; /* gain */ | ||
640 | reg_w_buf(gspca_dev, 0x8391, Reg8391, 8); | 624 | reg_w_buf(gspca_dev, 0x8391, Reg8391, 8); |
641 | reg_w_buf(gspca_dev, 0x8390, Reg8391, 8); | 625 | reg_w_buf(gspca_dev, 0x8390, Reg8391, 8); |
642 | break; | 626 | break; |
@@ -644,93 +628,151 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
644 | } | 628 | } |
645 | } | 629 | } |
646 | 630 | ||
647 | static void setautogain(struct gspca_dev *gspca_dev) | 631 | /* rev12a only */ |
632 | static void setwhite(struct gspca_dev *gspca_dev) | ||
648 | { | 633 | { |
649 | struct sd *sd = (struct sd *) gspca_dev; | 634 | struct sd *sd = (struct sd *) gspca_dev; |
635 | __u16 white; | ||
636 | __u8 reg8614, reg8616; | ||
637 | |||
638 | white = sd->white; | ||
639 | /* try to emulate MS-win as possible */ | ||
640 | reg8616 = 0x90 - white * 5 / 8; | ||
641 | reg_w_val(gspca_dev->dev, 0x8616, reg8616); | ||
642 | reg8614 = 0x20 + white * 3 / 8; | ||
643 | reg_w_val(gspca_dev->dev, 0x8614, reg8614); | ||
644 | } | ||
650 | 645 | ||
651 | if (sd->chip_revision == Rev072A) { | 646 | /* rev 12a only */ |
652 | if (sd->autogain) | 647 | static void setexposure(struct gspca_dev *gspca_dev) |
653 | sd->ag_cnt = AG_CNT_START; | 648 | { |
654 | else | 649 | struct sd *sd = (struct sd *) gspca_dev; |
655 | sd->ag_cnt = -1; | 650 | int expo; |
651 | int clock_divider; | ||
652 | __u8 data[2]; | ||
653 | |||
654 | /* Register 0x8309 controls exposure for the spca561, | ||
655 | the basic exposure setting goes from 1-2047, where 1 is completely | ||
656 | dark and 2047 is very bright. It not only influences exposure but | ||
657 | also the framerate (to allow for longer exposure) from 1 - 300 it | ||
658 | only raises the exposure time then from 300 - 600 it halves the | ||
659 | framerate to be able to further raise the exposure time and for every | ||
660 | 300 more it halves the framerate again. This allows for a maximum | ||
661 | exposure time of circa 0.2 - 0.25 seconds (30 / (2000/3000) fps). | ||
662 | Sometimes this is not enough, the 1-2047 uses bits 0-10, bits 11-12 | ||
663 | configure a divider for the base framerate which us used at the | ||
664 | exposure setting of 1-300. These bits configure the base framerate | ||
665 | according to the following formula: fps = 60 / (value + 2) */ | ||
666 | if (sd->exposure < 2048) { | ||
667 | expo = sd->exposure; | ||
668 | clock_divider = 0; | ||
669 | } else { | ||
670 | /* Add 900 to make the 0 setting of the second part of the | ||
671 | exposure equal to the 2047 setting of the first part. */ | ||
672 | expo = (sd->exposure - 2048) + 900; | ||
673 | clock_divider = 3; | ||
656 | } | 674 | } |
675 | expo |= clock_divider << 11; | ||
676 | data[0] = expo; | ||
677 | data[1] = expo >> 8; | ||
678 | reg_w_buf(gspca_dev, 0x8309, data, 2); | ||
657 | } | 679 | } |
658 | 680 | ||
659 | static void sd_start(struct gspca_dev *gspca_dev) | 681 | /* rev 12a only */ |
682 | static void setgain(struct gspca_dev *gspca_dev) | ||
660 | { | 683 | { |
661 | struct sd *sd = (struct sd *) gspca_dev; | 684 | struct sd *sd = (struct sd *) gspca_dev; |
685 | __u8 data[2]; | ||
686 | |||
687 | data[0] = sd->gain; | ||
688 | data[1] = 0; | ||
689 | reg_w_buf(gspca_dev, 0x8335, data, 2); | ||
690 | } | ||
691 | |||
692 | static void setautogain(struct gspca_dev *gspca_dev) | ||
693 | { | ||
694 | struct sd *sd = (struct sd *) gspca_dev; | ||
695 | |||
696 | if (sd->autogain) | ||
697 | sd->ag_cnt = AG_CNT_START; | ||
698 | else | ||
699 | sd->ag_cnt = -1; | ||
700 | } | ||
701 | |||
702 | static void sd_start_12a(struct gspca_dev *gspca_dev) | ||
703 | { | ||
662 | struct usb_device *dev = gspca_dev->dev; | 704 | struct usb_device *dev = gspca_dev->dev; |
663 | int Clck; | 705 | int Clck = 0x8a; /* lower 0x8X values lead to fps > 30 */ |
664 | __u8 Reg8307[] = { 0xaa, 0x00 }; | 706 | __u8 Reg8307[] = { 0xaa, 0x00 }; |
665 | int mode; | 707 | int mode; |
666 | 708 | ||
667 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 709 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; |
668 | switch (sd->chip_revision) { | 710 | if (mode <= 1) { |
669 | case Rev072A: | 711 | /* Use compression on 320x240 and above */ |
670 | switch (mode) { | 712 | reg_w_val(dev, 0x8500, 0x10 | mode); |
671 | default: | 713 | } else { |
672 | /* case 0: | 714 | /* I couldn't get the compression to work below 320x240 |
673 | case 1: */ | 715 | * Fortunately at these resolutions the bandwidth |
674 | Clck = 0x25; | 716 | * is sufficient to push raw frames at ~20fps */ |
675 | break; | 717 | reg_w_val(dev, 0x8500, mode); |
676 | case 2: | 718 | } /* -- qq@kuku.eu.org */ |
677 | Clck = 0x22; | 719 | reg_w_buf(gspca_dev, 0x8307, Reg8307, 2); |
678 | break; | 720 | reg_w_val(gspca_dev->dev, 0x8700, Clck); |
679 | case 3: | 721 | /* 0x8f 0x85 0x27 clock */ |
680 | Clck = 0x21; | 722 | reg_w_val(gspca_dev->dev, 0x8112, 0x1e | 0x20); |
681 | break; | 723 | reg_w_val(gspca_dev->dev, 0x850b, 0x03); |
682 | } | 724 | setcontrast(gspca_dev); |
683 | reg_w_val(dev, 0x8500, mode); /* mode */ | 725 | setwhite(gspca_dev); |
684 | reg_w_val(dev, 0x8700, Clck); /* 0x27 clock */ | 726 | setautogain(gspca_dev); |
685 | reg_w_val(dev, 0x8112, 0x10 | 0x20); | 727 | setexposure(gspca_dev); |
686 | setautogain(gspca_dev); | 728 | } |
687 | break; | 729 | static void sd_start_72a(struct gspca_dev *gspca_dev) |
730 | { | ||
731 | struct usb_device *dev = gspca_dev->dev; | ||
732 | int Clck; | ||
733 | int mode; | ||
734 | |||
735 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | ||
736 | switch (mode) { | ||
688 | default: | 737 | default: |
689 | /* case Rev012A: */ | 738 | /* case 0: |
690 | switch (mode) { | 739 | case 1: */ |
691 | case 0: | 740 | Clck = 0x25; |
692 | case 1: | 741 | break; |
693 | Clck = 0x8a; | 742 | case 2: |
694 | break; | 743 | Clck = 0x22; |
695 | case 2: | 744 | break; |
696 | Clck = 0x85; | 745 | case 3: |
697 | break; | 746 | Clck = 0x21; |
698 | default: | ||
699 | Clck = 0x83; | ||
700 | break; | ||
701 | } | ||
702 | if (mode <= 1) { | ||
703 | /* Use compression on 320x240 and above */ | ||
704 | reg_w_val(dev, 0x8500, 0x10 | mode); | ||
705 | } else { | ||
706 | /* I couldn't get the compression to work below 320x240 | ||
707 | * Fortunately at these resolutions the bandwidth | ||
708 | * is sufficient to push raw frames at ~20fps */ | ||
709 | reg_w_val(dev, 0x8500, mode); | ||
710 | } /* -- qq@kuku.eu.org */ | ||
711 | reg_w_buf(gspca_dev, 0x8307, Reg8307, 2); | ||
712 | reg_w_val(gspca_dev->dev, 0x8700, Clck); | ||
713 | /* 0x8f 0x85 0x27 clock */ | ||
714 | reg_w_val(gspca_dev->dev, 0x8112, 0x1e | 0x20); | ||
715 | reg_w_val(gspca_dev->dev, 0x850b, 0x03); | ||
716 | setcontrast(gspca_dev); | ||
717 | break; | 747 | break; |
718 | } | 748 | } |
749 | reg_w_val(dev, 0x8500, mode); /* mode */ | ||
750 | reg_w_val(dev, 0x8700, Clck); /* 0x27 clock */ | ||
751 | reg_w_val(dev, 0x8112, 0x10 | 0x20); | ||
752 | setautogain(gspca_dev); | ||
719 | } | 753 | } |
720 | 754 | ||
721 | static void sd_stopN(struct gspca_dev *gspca_dev) | 755 | static void sd_stopN(struct gspca_dev *gspca_dev) |
722 | { | 756 | { |
723 | reg_w_val(gspca_dev->dev, 0x8112, 0x20); | 757 | struct sd *sd = (struct sd *) gspca_dev; |
758 | |||
759 | if (sd->chip_revision == Rev012A) { | ||
760 | reg_w_val(gspca_dev->dev, 0x8112, 0x0e); | ||
761 | } else { | ||
762 | reg_w_val(gspca_dev->dev, 0x8112, 0x20); | ||
763 | /* reg_w_val(gspca_dev->dev, 0x8102, 0x00); ?? */ | ||
764 | } | ||
724 | } | 765 | } |
725 | 766 | ||
726 | static void sd_stop0(struct gspca_dev *gspca_dev) | 767 | static void sd_stop0(struct gspca_dev *gspca_dev) |
727 | { | 768 | { |
728 | } | 769 | struct sd *sd = (struct sd *) gspca_dev; |
729 | 770 | ||
730 | /* this function is called at close time */ | 771 | if (sd->chip_revision == Rev012A) { |
731 | static void sd_close(struct gspca_dev *gspca_dev) | 772 | reg_w_val(gspca_dev->dev, 0x8118, 0x29); |
732 | { | 773 | reg_w_val(gspca_dev->dev, 0x8114, 0x08); |
733 | reg_w_val(gspca_dev->dev, 0x8114, 0); | 774 | } |
775 | /* reg_w_val(gspca_dev->dev, 0x8114, 0); */ | ||
734 | } | 776 | } |
735 | 777 | ||
736 | static void do_autogain(struct gspca_dev *gspca_dev) | 778 | static void do_autogain(struct gspca_dev *gspca_dev) |
@@ -744,6 +786,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
744 | __u8 luma_mean = 110; | 786 | __u8 luma_mean = 110; |
745 | __u8 luma_delta = 20; | 787 | __u8 luma_delta = 20; |
746 | __u8 spring = 4; | 788 | __u8 spring = 4; |
789 | __u8 reg8339[2]; | ||
747 | 790 | ||
748 | if (sd->ag_cnt < 0) | 791 | if (sd->ag_cnt < 0) |
749 | return; | 792 | return; |
@@ -798,13 +841,16 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
798 | } | 841 | } |
799 | break; | 842 | break; |
800 | case Rev012A: | 843 | case Rev012A: |
801 | /* sensor registers is access and memory mapped to 0x8300 */ | 844 | reg_r(gspca_dev, 0x8330, 2); |
802 | /* readind all 0x83xx block the sensor */ | 845 | if (gspca_dev->usb_buf[1] > 0x08) { |
803 | /* | 846 | reg8339[0] = ++sd->expo12a; |
804 | * The data from the header seem wrong where is the luma | 847 | reg8339[1] = 0; |
805 | * and chroma mean value | 848 | reg_w_buf(gspca_dev, 0x8339, reg8339, 2); |
806 | * at the moment set exposure in contrast set | 849 | } else if (gspca_dev->usb_buf[1] < 0x02) { |
807 | */ | 850 | reg8339[0] = --sd->expo12a; |
851 | reg8339[1] = 0; | ||
852 | reg_w_buf(gspca_dev, 0x8339, reg8339, 2); | ||
853 | } | ||
808 | break; | 854 | break; |
809 | } | 855 | } |
810 | } | 856 | } |
@@ -814,6 +860,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
814 | __u8 *data, /* isoc packet */ | 860 | __u8 *data, /* isoc packet */ |
815 | int len) /* iso packet length */ | 861 | int len) /* iso packet length */ |
816 | { | 862 | { |
863 | struct sd *sd = (struct sd *) gspca_dev; | ||
864 | |||
817 | switch (data[0]) { | 865 | switch (data[0]) { |
818 | case 0: /* start of frame */ | 866 | case 0: /* start of frame */ |
819 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, | 867 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
@@ -826,8 +874,13 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
826 | frame, data, len); | 874 | frame, data, len); |
827 | } else { | 875 | } else { |
828 | /* raw bayer (with a header, which we skip) */ | 876 | /* raw bayer (with a header, which we skip) */ |
829 | data += 20; | 877 | if (sd->chip_revision == Rev012A) { |
830 | len -= 20; | 878 | data += 20; |
879 | len -= 20; | ||
880 | } else { | ||
881 | data += 16; | ||
882 | len -= 16; | ||
883 | } | ||
831 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 884 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
832 | frame, data, len); | 885 | frame, data, len); |
833 | } | 886 | } |
@@ -841,24 +894,17 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
841 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 894 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
842 | } | 895 | } |
843 | 896 | ||
897 | /* rev 72a only */ | ||
844 | static void setbrightness(struct gspca_dev *gspca_dev) | 898 | static void setbrightness(struct gspca_dev *gspca_dev) |
845 | { | 899 | { |
846 | struct sd *sd = (struct sd *) gspca_dev; | 900 | struct sd *sd = (struct sd *) gspca_dev; |
847 | __u8 value; | 901 | __u8 value; |
848 | 902 | ||
849 | switch (sd->chip_revision) { | 903 | value = sd->brightness; |
850 | case Rev072A: | 904 | reg_w_val(gspca_dev->dev, 0x8611, value); |
851 | value = sd->brightness; | 905 | reg_w_val(gspca_dev->dev, 0x8612, value); |
852 | reg_w_val(gspca_dev->dev, value, 0x8611); | 906 | reg_w_val(gspca_dev->dev, 0x8613, value); |
853 | reg_w_val(gspca_dev->dev, value, 0x8612); | 907 | reg_w_val(gspca_dev->dev, 0x8614, value); |
854 | reg_w_val(gspca_dev->dev, value, 0x8613); | ||
855 | reg_w_val(gspca_dev->dev, value, 0x8614); | ||
856 | break; | ||
857 | default: | ||
858 | /* case Rev012A: */ | ||
859 | setcontrast(gspca_dev); | ||
860 | break; | ||
861 | } | ||
862 | } | 908 | } |
863 | 909 | ||
864 | static void getbrightness(struct gspca_dev *gspca_dev) | 910 | static void getbrightness(struct gspca_dev *gspca_dev) |
@@ -866,52 +912,38 @@ static void getbrightness(struct gspca_dev *gspca_dev) | |||
866 | struct sd *sd = (struct sd *) gspca_dev; | 912 | struct sd *sd = (struct sd *) gspca_dev; |
867 | __u16 tot; | 913 | __u16 tot; |
868 | 914 | ||
869 | switch (sd->chip_revision) { | 915 | tot = 0; |
870 | case Rev072A: | 916 | reg_r(gspca_dev, 0x8611, 1); |
871 | tot = 0; | 917 | tot += gspca_dev->usb_buf[0]; |
872 | reg_r(gspca_dev, 0x8611, 1); | 918 | reg_r(gspca_dev, 0x8612, 1); |
873 | tot += gspca_dev->usb_buf[0]; | 919 | tot += gspca_dev->usb_buf[0]; |
874 | reg_r(gspca_dev, 0x8612, 1); | 920 | reg_r(gspca_dev, 0x8613, 1); |
875 | tot += gspca_dev->usb_buf[0]; | 921 | tot += gspca_dev->usb_buf[0]; |
876 | reg_r(gspca_dev, 0x8613, 1); | 922 | reg_r(gspca_dev, 0x8614, 1); |
877 | tot += gspca_dev->usb_buf[0]; | 923 | tot += gspca_dev->usb_buf[0]; |
878 | reg_r(gspca_dev, 0x8614, 1); | 924 | sd->brightness = tot >> 2; |
879 | tot += gspca_dev->usb_buf[0]; | ||
880 | sd->brightness = tot >> 2; | ||
881 | break; | ||
882 | default: | ||
883 | /* case Rev012A: */ | ||
884 | /* no way to read sensor settings */ | ||
885 | break; | ||
886 | } | ||
887 | } | 925 | } |
888 | 926 | ||
927 | /* rev72a only */ | ||
889 | static void getcontrast(struct gspca_dev *gspca_dev) | 928 | static void getcontrast(struct gspca_dev *gspca_dev) |
890 | { | 929 | { |
891 | struct sd *sd = (struct sd *) gspca_dev; | 930 | struct sd *sd = (struct sd *) gspca_dev; |
892 | __u16 tot; | 931 | __u16 tot; |
893 | 932 | ||
894 | switch (sd->chip_revision) { | 933 | tot = 0; |
895 | case Rev072A: | 934 | reg_r(gspca_dev, 0x8651, 1); |
896 | tot = 0; | 935 | tot += gspca_dev->usb_buf[0]; |
897 | reg_r(gspca_dev, 0x8651, 1); | 936 | reg_r(gspca_dev, 0x8652, 1); |
898 | tot += gspca_dev->usb_buf[0]; | 937 | tot += gspca_dev->usb_buf[0]; |
899 | reg_r(gspca_dev, 0x8652, 1); | 938 | reg_r(gspca_dev, 0x8653, 1); |
900 | tot += gspca_dev->usb_buf[0]; | 939 | tot += gspca_dev->usb_buf[0]; |
901 | reg_r(gspca_dev, 0x8653, 1); | 940 | reg_r(gspca_dev, 0x8654, 1); |
902 | tot += gspca_dev->usb_buf[0]; | 941 | tot += gspca_dev->usb_buf[0]; |
903 | reg_r(gspca_dev, 0x8654, 1); | 942 | sd->contrast = tot << 6; |
904 | tot += gspca_dev->usb_buf[0]; | ||
905 | sd->contrast = tot << 6; | ||
906 | break; | ||
907 | default: | ||
908 | /* case Rev012A: */ | ||
909 | /* no way to read sensor settings */ | ||
910 | break; | ||
911 | } | ||
912 | PDEBUG(D_CONF, "get contrast %d", sd->contrast); | 943 | PDEBUG(D_CONF, "get contrast %d", sd->contrast); |
913 | } | 944 | } |
914 | 945 | ||
946 | /* rev 72a only */ | ||
915 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 947 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
916 | { | 948 | { |
917 | struct sd *sd = (struct sd *) gspca_dev; | 949 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -931,6 +963,7 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
931 | return 0; | 963 | return 0; |
932 | } | 964 | } |
933 | 965 | ||
966 | /* rev 72a only */ | ||
934 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | 967 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) |
935 | { | 968 | { |
936 | struct sd *sd = (struct sd *) gspca_dev; | 969 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -968,20 +1001,190 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | |||
968 | return 0; | 1001 | return 0; |
969 | } | 1002 | } |
970 | 1003 | ||
1004 | /* rev12a only */ | ||
1005 | static int sd_setwhite(struct gspca_dev *gspca_dev, __s32 val) | ||
1006 | { | ||
1007 | struct sd *sd = (struct sd *) gspca_dev; | ||
1008 | |||
1009 | sd->white = val; | ||
1010 | if (gspca_dev->streaming) | ||
1011 | setwhite(gspca_dev); | ||
1012 | return 0; | ||
1013 | } | ||
1014 | |||
1015 | static int sd_getwhite(struct gspca_dev *gspca_dev, __s32 *val) | ||
1016 | { | ||
1017 | struct sd *sd = (struct sd *) gspca_dev; | ||
1018 | |||
1019 | *val = sd->white; | ||
1020 | return 0; | ||
1021 | } | ||
1022 | |||
1023 | /* rev12a only */ | ||
1024 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val) | ||
1025 | { | ||
1026 | struct sd *sd = (struct sd *) gspca_dev; | ||
1027 | |||
1028 | sd->exposure = val; | ||
1029 | if (gspca_dev->streaming) | ||
1030 | setexposure(gspca_dev); | ||
1031 | return 0; | ||
1032 | } | ||
1033 | |||
1034 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) | ||
1035 | { | ||
1036 | struct sd *sd = (struct sd *) gspca_dev; | ||
1037 | |||
1038 | *val = sd->exposure; | ||
1039 | return 0; | ||
1040 | } | ||
1041 | |||
1042 | /* rev12a only */ | ||
1043 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | ||
1044 | { | ||
1045 | struct sd *sd = (struct sd *) gspca_dev; | ||
1046 | |||
1047 | sd->gain = val; | ||
1048 | if (gspca_dev->streaming) | ||
1049 | setgain(gspca_dev); | ||
1050 | return 0; | ||
1051 | } | ||
1052 | |||
1053 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | ||
1054 | { | ||
1055 | struct sd *sd = (struct sd *) gspca_dev; | ||
1056 | |||
1057 | *val = sd->gain; | ||
1058 | return 0; | ||
1059 | } | ||
1060 | |||
1061 | /* control tables */ | ||
1062 | static struct ctrl sd_ctrls_12a[] = { | ||
1063 | { | ||
1064 | { | ||
1065 | .id = V4L2_CID_DO_WHITE_BALANCE, | ||
1066 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
1067 | .name = "While Balance", | ||
1068 | .minimum = WHITE_MIN, | ||
1069 | .maximum = WHITE_MAX, | ||
1070 | .step = 1, | ||
1071 | .default_value = WHITE_DEF, | ||
1072 | }, | ||
1073 | .set = sd_setwhite, | ||
1074 | .get = sd_getwhite, | ||
1075 | }, | ||
1076 | { | ||
1077 | { | ||
1078 | .id = V4L2_CID_EXPOSURE, | ||
1079 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
1080 | .name = "Exposure", | ||
1081 | .minimum = EXPOSURE_MIN, | ||
1082 | .maximum = EXPOSURE_MAX, | ||
1083 | .step = 1, | ||
1084 | .default_value = EXPOSURE_DEF, | ||
1085 | }, | ||
1086 | .set = sd_setexposure, | ||
1087 | .get = sd_getexposure, | ||
1088 | }, | ||
1089 | { | ||
1090 | { | ||
1091 | .id = V4L2_CID_AUTOGAIN, | ||
1092 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
1093 | .name = "Auto Gain", | ||
1094 | .minimum = AUTOGAIN_MIN, | ||
1095 | .maximum = AUTOGAIN_MAX, | ||
1096 | .step = 1, | ||
1097 | .default_value = AUTOGAIN_DEF, | ||
1098 | }, | ||
1099 | .set = sd_setautogain, | ||
1100 | .get = sd_getautogain, | ||
1101 | }, | ||
1102 | { | ||
1103 | { | ||
1104 | .id = V4L2_CID_GAIN, | ||
1105 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
1106 | .name = "Gain", | ||
1107 | .minimum = GAIN_MIN, | ||
1108 | .maximum = GAIN_MAX, | ||
1109 | .step = 1, | ||
1110 | .default_value = GAIN_DEF, | ||
1111 | }, | ||
1112 | .set = sd_setgain, | ||
1113 | .get = sd_getgain, | ||
1114 | }, | ||
1115 | }; | ||
1116 | |||
1117 | static struct ctrl sd_ctrls_72a[] = { | ||
1118 | { | ||
1119 | { | ||
1120 | .id = V4L2_CID_BRIGHTNESS, | ||
1121 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
1122 | .name = "Brightness", | ||
1123 | .minimum = BRIGHTNESS_MIN, | ||
1124 | .maximum = BRIGHTNESS_MAX, | ||
1125 | .step = 1, | ||
1126 | .default_value = BRIGHTNESS_DEF, | ||
1127 | }, | ||
1128 | .set = sd_setbrightness, | ||
1129 | .get = sd_getbrightness, | ||
1130 | }, | ||
1131 | { | ||
1132 | { | ||
1133 | .id = V4L2_CID_CONTRAST, | ||
1134 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
1135 | .name = "Contrast", | ||
1136 | .minimum = CONTRAST_MIN, | ||
1137 | .maximum = CONTRAST_MAX, | ||
1138 | .step = 1, | ||
1139 | .default_value = CONTRAST_DEF, | ||
1140 | }, | ||
1141 | .set = sd_setcontrast, | ||
1142 | .get = sd_getcontrast, | ||
1143 | }, | ||
1144 | { | ||
1145 | { | ||
1146 | .id = V4L2_CID_AUTOGAIN, | ||
1147 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
1148 | .name = "Auto Gain", | ||
1149 | .minimum = AUTOGAIN_MIN, | ||
1150 | .maximum = AUTOGAIN_MAX, | ||
1151 | .step = 1, | ||
1152 | .default_value = AUTOGAIN_DEF, | ||
1153 | }, | ||
1154 | .set = sd_setautogain, | ||
1155 | .get = sd_getautogain, | ||
1156 | }, | ||
1157 | }; | ||
1158 | |||
971 | /* sub-driver description */ | 1159 | /* sub-driver description */ |
972 | static const struct sd_desc sd_desc = { | 1160 | static const struct sd_desc sd_desc_12a = { |
1161 | .name = MODULE_NAME, | ||
1162 | .ctrls = sd_ctrls_12a, | ||
1163 | .nctrls = ARRAY_SIZE(sd_ctrls_12a), | ||
1164 | .config = sd_config, | ||
1165 | .init = sd_init_12a, | ||
1166 | .start = sd_start_12a, | ||
1167 | .stopN = sd_stopN, | ||
1168 | .stop0 = sd_stop0, | ||
1169 | .pkt_scan = sd_pkt_scan, | ||
1170 | /* .dq_callback = do_autogain, * fixme */ | ||
1171 | }; | ||
1172 | static const struct sd_desc sd_desc_72a = { | ||
973 | .name = MODULE_NAME, | 1173 | .name = MODULE_NAME, |
974 | .ctrls = sd_ctrls, | 1174 | .ctrls = sd_ctrls_72a, |
975 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1175 | .nctrls = ARRAY_SIZE(sd_ctrls_72a), |
976 | .config = sd_config, | 1176 | .config = sd_config, |
977 | .open = sd_open, | 1177 | .init = sd_init_72a, |
978 | .start = sd_start, | 1178 | .start = sd_start_72a, |
979 | .stopN = sd_stopN, | 1179 | .stopN = sd_stopN, |
980 | .stop0 = sd_stop0, | 1180 | .stop0 = sd_stop0, |
981 | .close = sd_close, | ||
982 | .pkt_scan = sd_pkt_scan, | 1181 | .pkt_scan = sd_pkt_scan, |
983 | .dq_callback = do_autogain, | 1182 | .dq_callback = do_autogain, |
984 | }; | 1183 | }; |
1184 | static const struct sd_desc *sd_desc[2] = { | ||
1185 | &sd_desc_12a, | ||
1186 | &sd_desc_72a | ||
1187 | }; | ||
985 | 1188 | ||
986 | /* -- module initialisation -- */ | 1189 | /* -- module initialisation -- */ |
987 | static const __devinitdata struct usb_device_id device_table[] = { | 1190 | static const __devinitdata struct usb_device_id device_table[] = { |
@@ -1009,7 +1212,9 @@ MODULE_DEVICE_TABLE(usb, device_table); | |||
1009 | static int sd_probe(struct usb_interface *intf, | 1212 | static int sd_probe(struct usb_interface *intf, |
1010 | const struct usb_device_id *id) | 1213 | const struct usb_device_id *id) |
1011 | { | 1214 | { |
1012 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), | 1215 | return gspca_dev_probe(intf, id, |
1216 | sd_desc[id->driver_info], | ||
1217 | sizeof(struct sd), | ||
1013 | THIS_MODULE); | 1218 | THIS_MODULE); |
1014 | } | 1219 | } |
1015 | 1220 | ||
@@ -1018,6 +1223,10 @@ static struct usb_driver sd_driver = { | |||
1018 | .id_table = device_table, | 1223 | .id_table = device_table, |
1019 | .probe = sd_probe, | 1224 | .probe = sd_probe, |
1020 | .disconnect = gspca_disconnect, | 1225 | .disconnect = gspca_disconnect, |
1226 | #ifdef CONFIG_PM | ||
1227 | .suspend = gspca_suspend, | ||
1228 | .resume = gspca_resume, | ||
1229 | #endif | ||
1021 | }; | 1230 | }; |
1022 | 1231 | ||
1023 | /* -- module insert / remove -- */ | 1232 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c index 16219cf6a6d5..2f2de429e273 100644 --- a/drivers/media/video/gspca/stk014.c +++ b/drivers/media/video/gspca/stk014.c | |||
@@ -306,8 +306,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
306 | return 0; | 306 | return 0; |
307 | } | 307 | } |
308 | 308 | ||
309 | /* this function is called at open time */ | 309 | /* this function is called at probe and resume time */ |
310 | static int sd_open(struct gspca_dev *gspca_dev) | 310 | static int sd_init(struct gspca_dev *gspca_dev) |
311 | { | 311 | { |
312 | int ret; | 312 | int ret; |
313 | 313 | ||
@@ -398,14 +398,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
398 | PDEBUG(D_STREAM, "camera stopped"); | 398 | PDEBUG(D_STREAM, "camera stopped"); |
399 | } | 399 | } |
400 | 400 | ||
401 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
402 | { | ||
403 | } | ||
404 | |||
405 | static void sd_close(struct gspca_dev *gspca_dev) | ||
406 | { | ||
407 | } | ||
408 | |||
409 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 401 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
410 | struct gspca_frame *frame, /* target */ | 402 | struct gspca_frame *frame, /* target */ |
411 | __u8 *data, /* isoc packet */ | 403 | __u8 *data, /* isoc packet */ |
@@ -535,11 +527,9 @@ static const struct sd_desc sd_desc = { | |||
535 | .ctrls = sd_ctrls, | 527 | .ctrls = sd_ctrls, |
536 | .nctrls = ARRAY_SIZE(sd_ctrls), | 528 | .nctrls = ARRAY_SIZE(sd_ctrls), |
537 | .config = sd_config, | 529 | .config = sd_config, |
538 | .open = sd_open, | 530 | .init = sd_init, |
539 | .start = sd_start, | 531 | .start = sd_start, |
540 | .stopN = sd_stopN, | 532 | .stopN = sd_stopN, |
541 | .stop0 = sd_stop0, | ||
542 | .close = sd_close, | ||
543 | .pkt_scan = sd_pkt_scan, | 533 | .pkt_scan = sd_pkt_scan, |
544 | .querymenu = sd_querymenu, | 534 | .querymenu = sd_querymenu, |
545 | }; | 535 | }; |
@@ -564,6 +554,10 @@ static struct usb_driver sd_driver = { | |||
564 | .id_table = device_table, | 554 | .id_table = device_table, |
565 | .probe = sd_probe, | 555 | .probe = sd_probe, |
566 | .disconnect = gspca_disconnect, | 556 | .disconnect = gspca_disconnect, |
557 | #ifdef CONFIG_PM | ||
558 | .suspend = gspca_suspend, | ||
559 | .resume = gspca_resume, | ||
560 | #endif | ||
567 | }; | 561 | }; |
568 | 562 | ||
569 | /* -- module insert / remove -- */ | 563 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c index 54efa48bee01..1cfcc6c49558 100644 --- a/drivers/media/video/gspca/sunplus.c +++ b/drivers/media/video/gspca/sunplus.c | |||
@@ -449,31 +449,47 @@ static const __u8 qtable_spca504_default[2][64] = { | |||
449 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} | 449 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} |
450 | }; | 450 | }; |
451 | 451 | ||
452 | static void reg_r(struct usb_device *dev, | 452 | /* read <len> bytes to gspca_dev->usb_buf */ |
453 | __u16 req, | 453 | static void reg_r(struct gspca_dev *gspca_dev, |
454 | __u16 index, | 454 | __u16 req, |
455 | __u8 *buffer, __u16 length) | 455 | __u16 index, |
456 | __u16 len) | ||
456 | { | 457 | { |
457 | usb_control_msg(dev, | 458 | #ifdef GSPCA_DEBUG |
458 | usb_rcvctrlpipe(dev, 0), | 459 | if (len > USB_BUF_SZ) { |
460 | err("reg_r: buffer overflow"); | ||
461 | return; | ||
462 | } | ||
463 | #endif | ||
464 | usb_control_msg(gspca_dev->dev, | ||
465 | usb_rcvctrlpipe(gspca_dev->dev, 0), | ||
459 | req, | 466 | req, |
460 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 467 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
461 | 0, /* value */ | 468 | 0, /* value */ |
462 | index, buffer, length, | 469 | index, |
470 | len ? gspca_dev->usb_buf : NULL, len, | ||
463 | 500); | 471 | 500); |
464 | } | 472 | } |
465 | 473 | ||
466 | static void reg_w(struct usb_device *dev, | 474 | /* write <len> bytes from gspca_dev->usb_buf */ |
467 | __u16 req, | 475 | static void reg_w(struct gspca_dev *gspca_dev, |
468 | __u16 value, | 476 | __u16 req, |
469 | __u16 index, | 477 | __u16 value, |
470 | __u8 *buffer, __u16 length) | 478 | __u16 index, |
479 | __u16 len) | ||
471 | { | 480 | { |
472 | usb_control_msg(dev, | 481 | #ifdef GSPCA_DEBUG |
473 | usb_sndctrlpipe(dev, 0), | 482 | if (len > USB_BUF_SZ) { |
483 | err("reg_w: buffer overflow"); | ||
484 | return; | ||
485 | } | ||
486 | #endif | ||
487 | usb_control_msg(gspca_dev->dev, | ||
488 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
474 | req, | 489 | req, |
475 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 490 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
476 | value, index, buffer, length, | 491 | value, index, |
492 | len ? gspca_dev->usb_buf : NULL, len, | ||
477 | 500); | 493 | 500); |
478 | } | 494 | } |
479 | 495 | ||
@@ -634,7 +650,7 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev) | |||
634 | int count = 10; | 650 | int count = 10; |
635 | 651 | ||
636 | while (--count > 0) { | 652 | while (--count > 0) { |
637 | reg_r(gspca_dev->dev, 0x21, 0, gspca_dev->usb_buf, 1); | 653 | reg_r(gspca_dev, 0x21, 0, 1); |
638 | if ((gspca_dev->usb_buf[0] & 0x01) == 0) | 654 | if ((gspca_dev->usb_buf[0] & 0x01) == 0) |
639 | break; | 655 | break; |
640 | msleep(10); | 656 | msleep(10); |
@@ -644,15 +660,14 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev) | |||
644 | 660 | ||
645 | static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) | 661 | static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) |
646 | { | 662 | { |
647 | struct usb_device *dev = gspca_dev->dev; | ||
648 | int count = 50; | 663 | int count = 50; |
649 | 664 | ||
650 | while (--count > 0) { | 665 | while (--count > 0) { |
651 | reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1); | 666 | reg_r(gspca_dev, 0x21, 1, 1); |
652 | if (gspca_dev->usb_buf[0] != 0) { | 667 | if (gspca_dev->usb_buf[0] != 0) { |
653 | gspca_dev->usb_buf[0] = 0; | 668 | gspca_dev->usb_buf[0] = 0; |
654 | reg_w(dev, 0x21, 0, 1, gspca_dev->usb_buf, 1); | 669 | reg_w(gspca_dev, 0x21, 0, 1, 1); |
655 | reg_r(dev, 0x21, 1, gspca_dev->usb_buf, 1); | 670 | reg_r(gspca_dev, 0x21, 1, 1); |
656 | spca504B_PollingDataReady(gspca_dev); | 671 | spca504B_PollingDataReady(gspca_dev); |
657 | break; | 672 | break; |
658 | } | 673 | } |
@@ -662,16 +677,14 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev) | |||
662 | 677 | ||
663 | static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) | 678 | static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) |
664 | { | 679 | { |
665 | struct usb_device *dev = gspca_dev->dev; | ||
666 | __u8 *data; | 680 | __u8 *data; |
667 | 681 | ||
668 | data = kmalloc(64, GFP_KERNEL); | 682 | data = gspca_dev->usb_buf; |
669 | reg_r(dev, 0x20, 0, data, 5); | 683 | reg_r(gspca_dev, 0x20, 0, 5); |
670 | PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ", | 684 | PDEBUG(D_STREAM, "FirmWare : %d %d %d %d %d ", |
671 | data[0], data[1], data[2], data[3], data[4]); | 685 | data[0], data[1], data[2], data[3], data[4]); |
672 | reg_r(dev, 0x23, 0, data, 64); | 686 | reg_r(gspca_dev, 0x23, 0, 64); |
673 | reg_r(dev, 0x23, 1, data, 64); | 687 | reg_r(gspca_dev, 0x23, 1, 64); |
674 | kfree(data); | ||
675 | } | 688 | } |
676 | 689 | ||
677 | static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) | 690 | static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) |
@@ -686,21 +699,21 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) | |||
686 | Type = 0; | 699 | Type = 0; |
687 | switch (sd->bridge) { | 700 | switch (sd->bridge) { |
688 | case BRIDGE_SPCA533: | 701 | case BRIDGE_SPCA533: |
689 | reg_w(dev, 0x31, 0, 0, NULL, 0); | 702 | reg_w(gspca_dev, 0x31, 0, 0, 0); |
690 | spca504B_WaitCmdStatus(gspca_dev); | 703 | spca504B_WaitCmdStatus(gspca_dev); |
691 | rc = spca504B_PollingDataReady(gspca_dev); | 704 | rc = spca504B_PollingDataReady(gspca_dev); |
692 | spca50x_GetFirmware(gspca_dev); | 705 | spca50x_GetFirmware(gspca_dev); |
693 | gspca_dev->usb_buf[0] = 2; /* type */ | 706 | gspca_dev->usb_buf[0] = 2; /* type */ |
694 | reg_w(dev, 0x24, 0, 8, gspca_dev->usb_buf, 1); | 707 | reg_w(gspca_dev, 0x24, 0, 8, 1); |
695 | reg_r(dev, 0x24, 8, gspca_dev->usb_buf, 1); | 708 | reg_r(gspca_dev, 0x24, 8, 1); |
696 | 709 | ||
697 | gspca_dev->usb_buf[0] = Size; | 710 | gspca_dev->usb_buf[0] = Size; |
698 | reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1); | 711 | reg_w(gspca_dev, 0x25, 0, 4, 1); |
699 | reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */ | 712 | reg_r(gspca_dev, 0x25, 4, 1); /* size */ |
700 | rc = spca504B_PollingDataReady(gspca_dev); | 713 | rc = spca504B_PollingDataReady(gspca_dev); |
701 | 714 | ||
702 | /* Init the cam width height with some values get on init ? */ | 715 | /* Init the cam width height with some values get on init ? */ |
703 | reg_w(dev, 0x31, 0, 4, NULL, 0); | 716 | reg_w(gspca_dev, 0x31, 0, 4, 0); |
704 | spca504B_WaitCmdStatus(gspca_dev); | 717 | spca504B_WaitCmdStatus(gspca_dev); |
705 | rc = spca504B_PollingDataReady(gspca_dev); | 718 | rc = spca504B_PollingDataReady(gspca_dev); |
706 | break; | 719 | break; |
@@ -708,12 +721,12 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev) | |||
708 | /* case BRIDGE_SPCA504B: */ | 721 | /* case BRIDGE_SPCA504B: */ |
709 | /* case BRIDGE_SPCA536: */ | 722 | /* case BRIDGE_SPCA536: */ |
710 | gspca_dev->usb_buf[0] = Size; | 723 | gspca_dev->usb_buf[0] = Size; |
711 | reg_w(dev, 0x25, 0, 4, gspca_dev->usb_buf, 1); | 724 | reg_w(gspca_dev, 0x25, 0, 4, 1); |
712 | reg_r(dev, 0x25, 4, gspca_dev->usb_buf, 1); /* size */ | 725 | reg_r(gspca_dev, 0x25, 4, 1); /* size */ |
713 | Type = 6; | 726 | Type = 6; |
714 | gspca_dev->usb_buf[0] = Type; | 727 | gspca_dev->usb_buf[0] = Type; |
715 | reg_w(dev, 0x27, 0, 0, gspca_dev->usb_buf, 1); | 728 | reg_w(gspca_dev, 0x27, 0, 0, 1); |
716 | reg_r(dev, 0x27, 0, gspca_dev->usb_buf, 1); /* type */ | 729 | reg_r(gspca_dev, 0x27, 0, 1); /* type */ |
717 | rc = spca504B_PollingDataReady(gspca_dev); | 730 | rc = spca504B_PollingDataReady(gspca_dev); |
718 | break; | 731 | break; |
719 | case BRIDGE_SPCA504: | 732 | case BRIDGE_SPCA504: |
@@ -752,18 +765,15 @@ static void spca504_wait_status(struct gspca_dev *gspca_dev) | |||
752 | 765 | ||
753 | static void spca504B_setQtable(struct gspca_dev *gspca_dev) | 766 | static void spca504B_setQtable(struct gspca_dev *gspca_dev) |
754 | { | 767 | { |
755 | struct usb_device *dev = gspca_dev->dev; | ||
756 | |||
757 | gspca_dev->usb_buf[0] = 3; | 768 | gspca_dev->usb_buf[0] = 3; |
758 | reg_w(dev, 0x26, 0, 0, gspca_dev->usb_buf, 1); | 769 | reg_w(gspca_dev, 0x26, 0, 0, 1); |
759 | reg_r(dev, 0x26, 0, gspca_dev->usb_buf, 1); | 770 | reg_r(gspca_dev, 0x26, 0, 1); |
760 | spca504B_PollingDataReady(gspca_dev); | 771 | spca504B_PollingDataReady(gspca_dev); |
761 | } | 772 | } |
762 | 773 | ||
763 | static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) | 774 | static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) |
764 | { | 775 | { |
765 | struct sd *sd = (struct sd *) gspca_dev; | 776 | struct sd *sd = (struct sd *) gspca_dev; |
766 | struct usb_device *dev = gspca_dev->dev; | ||
767 | int pollreg = 1; | 777 | int pollreg = 1; |
768 | 778 | ||
769 | switch (sd->bridge) { | 779 | switch (sd->bridge) { |
@@ -774,20 +784,20 @@ static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) | |||
774 | default: | 784 | default: |
775 | /* case BRIDGE_SPCA533: */ | 785 | /* case BRIDGE_SPCA533: */ |
776 | /* case BRIDGE_SPCA504B: */ | 786 | /* case BRIDGE_SPCA504B: */ |
777 | reg_w(dev, 0, 0, 0x21a7, NULL, 0); /* brightness */ | 787 | reg_w(gspca_dev, 0, 0, 0x21a7, 0); /* brightness */ |
778 | reg_w(dev, 0, 0x20, 0x21a8, NULL, 0); /* contrast */ | 788 | reg_w(gspca_dev, 0, 0x20, 0x21a8, 0); /* contrast */ |
779 | reg_w(dev, 0, 0, 0x21ad, NULL, 0); /* hue */ | 789 | reg_w(gspca_dev, 0, 0, 0x21ad, 0); /* hue */ |
780 | reg_w(dev, 0, 1, 0x21ac, NULL, 0); /* sat/hue */ | 790 | reg_w(gspca_dev, 0, 1, 0x21ac, 0); /* sat/hue */ |
781 | reg_w(dev, 0, 0x20, 0x21ae, NULL, 0); /* saturation */ | 791 | reg_w(gspca_dev, 0, 0x20, 0x21ae, 0); /* saturation */ |
782 | reg_w(dev, 0, 0, 0x21a3, NULL, 0); /* gamma */ | 792 | reg_w(gspca_dev, 0, 0, 0x21a3, 0); /* gamma */ |
783 | break; | 793 | break; |
784 | case BRIDGE_SPCA536: | 794 | case BRIDGE_SPCA536: |
785 | reg_w(dev, 0, 0, 0x20f0, NULL, 0); | 795 | reg_w(gspca_dev, 0, 0, 0x20f0, 0); |
786 | reg_w(dev, 0, 0x21, 0x20f1, NULL, 0); | 796 | reg_w(gspca_dev, 0, 0x21, 0x20f1, 0); |
787 | reg_w(dev, 0, 0x40, 0x20f5, NULL, 0); | 797 | reg_w(gspca_dev, 0, 0x40, 0x20f5, 0); |
788 | reg_w(dev, 0, 1, 0x20f4, NULL, 0); | 798 | reg_w(gspca_dev, 0, 1, 0x20f4, 0); |
789 | reg_w(dev, 0, 0x40, 0x20f6, NULL, 0); | 799 | reg_w(gspca_dev, 0, 0x40, 0x20f6, 0); |
790 | reg_w(dev, 0, 0, 0x2089, NULL, 0); | 800 | reg_w(gspca_dev, 0, 0, 0x2089, 0); |
791 | break; | 801 | break; |
792 | } | 802 | } |
793 | if (pollreg) | 803 | if (pollreg) |
@@ -799,7 +809,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
799 | const struct usb_device_id *id) | 809 | const struct usb_device_id *id) |
800 | { | 810 | { |
801 | struct sd *sd = (struct sd *) gspca_dev; | 811 | struct sd *sd = (struct sd *) gspca_dev; |
802 | struct usb_device *dev = gspca_dev->dev; | ||
803 | struct cam *cam; | 812 | struct cam *cam; |
804 | 813 | ||
805 | cam = &gspca_dev->cam; | 814 | cam = &gspca_dev->cam; |
@@ -811,7 +820,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
811 | if (sd->subtype == AiptekMiniPenCam13) { | 820 | if (sd->subtype == AiptekMiniPenCam13) { |
812 | /* try to get the firmware as some cam answer 2.0.1.2.2 | 821 | /* try to get the firmware as some cam answer 2.0.1.2.2 |
813 | * and should be a spca504b then overwrite that setting */ | 822 | * and should be a spca504b then overwrite that setting */ |
814 | reg_r(dev, 0x20, 0, gspca_dev->usb_buf, 1); | 823 | reg_r(gspca_dev, 0x20, 0, 1); |
815 | switch (gspca_dev->usb_buf[0]) { | 824 | switch (gspca_dev->usb_buf[0]) { |
816 | case 1: | 825 | case 1: |
817 | break; /* (right bridge/subtype) */ | 826 | break; /* (right bridge/subtype) */ |
@@ -848,8 +857,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
848 | return 0; | 857 | return 0; |
849 | } | 858 | } |
850 | 859 | ||
851 | /* this function is called at open time */ | 860 | /* this function is called at probe and resume time */ |
852 | static int sd_open(struct gspca_dev *gspca_dev) | 861 | static int sd_init(struct gspca_dev *gspca_dev) |
853 | { | 862 | { |
854 | struct sd *sd = (struct sd *) gspca_dev; | 863 | struct sd *sd = (struct sd *) gspca_dev; |
855 | struct usb_device *dev = gspca_dev->dev; | 864 | struct usb_device *dev = gspca_dev->dev; |
@@ -860,12 +869,12 @@ static int sd_open(struct gspca_dev *gspca_dev) | |||
860 | 869 | ||
861 | switch (sd->bridge) { | 870 | switch (sd->bridge) { |
862 | case BRIDGE_SPCA504B: | 871 | case BRIDGE_SPCA504B: |
863 | reg_w(dev, 0x1d, 0, 0, NULL, 0); | 872 | reg_w(gspca_dev, 0x1d, 0, 0, 0); |
864 | reg_w(dev, 0, 1, 0x2306, NULL, 0); | 873 | reg_w(gspca_dev, 0, 1, 0x2306, 0); |
865 | reg_w(dev, 0, 0, 0x0d04, NULL, 0); | 874 | reg_w(gspca_dev, 0, 0, 0x0d04, 0); |
866 | reg_w(dev, 0, 0, 0x2000, NULL, 0); | 875 | reg_w(gspca_dev, 0, 0, 0x2000, 0); |
867 | reg_w(dev, 0, 0x13, 0x2301, NULL, 0); | 876 | reg_w(gspca_dev, 0, 0x13, 0x2301, 0); |
868 | reg_w(dev, 0, 0, 0x2306, NULL, 0); | 877 | reg_w(gspca_dev, 0, 0, 0x2306, 0); |
869 | /* fall thru */ | 878 | /* fall thru */ |
870 | case BRIDGE_SPCA533: | 879 | case BRIDGE_SPCA533: |
871 | rc = spca504B_PollingDataReady(gspca_dev); | 880 | rc = spca504B_PollingDataReady(gspca_dev); |
@@ -873,12 +882,12 @@ static int sd_open(struct gspca_dev *gspca_dev) | |||
873 | break; | 882 | break; |
874 | case BRIDGE_SPCA536: | 883 | case BRIDGE_SPCA536: |
875 | spca50x_GetFirmware(gspca_dev); | 884 | spca50x_GetFirmware(gspca_dev); |
876 | reg_r(dev, 0x00, 0x5002, gspca_dev->usb_buf, 1); | 885 | reg_r(gspca_dev, 0x00, 0x5002, 1); |
877 | gspca_dev->usb_buf[0] = 0; | 886 | gspca_dev->usb_buf[0] = 0; |
878 | reg_w(dev, 0x24, 0, 0, gspca_dev->usb_buf, 1); | 887 | reg_w(gspca_dev, 0x24, 0, 0, 1); |
879 | reg_r(dev, 0x24, 0, gspca_dev->usb_buf, 1); | 888 | reg_r(gspca_dev, 0x24, 0, 1); |
880 | rc = spca504B_PollingDataReady(gspca_dev); | 889 | rc = spca504B_PollingDataReady(gspca_dev); |
881 | reg_w(dev, 0x34, 0, 0, NULL, 0); | 890 | reg_w(gspca_dev, 0x34, 0, 0, 0); |
882 | spca504B_WaitCmdStatus(gspca_dev); | 891 | spca504B_WaitCmdStatus(gspca_dev); |
883 | break; | 892 | break; |
884 | case BRIDGE_SPCA504C: /* pccam600 */ | 893 | case BRIDGE_SPCA504C: /* pccam600 */ |
@@ -971,12 +980,12 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
971 | /* case BRIDGE_SPCA536: */ | 980 | /* case BRIDGE_SPCA536: */ |
972 | if (sd->subtype == MegapixV4 || | 981 | if (sd->subtype == MegapixV4 || |
973 | sd->subtype == LogitechClickSmart820) { | 982 | sd->subtype == LogitechClickSmart820) { |
974 | reg_w(dev, 0xf0, 0, 0, NULL, 0); | 983 | reg_w(gspca_dev, 0xf0, 0, 0, 0); |
975 | spca504B_WaitCmdStatus(gspca_dev); | 984 | spca504B_WaitCmdStatus(gspca_dev); |
976 | reg_r(dev, 0xf0, 4, NULL, 0); | 985 | reg_r(gspca_dev, 0xf0, 4, 0); |
977 | spca504B_WaitCmdStatus(gspca_dev); | 986 | spca504B_WaitCmdStatus(gspca_dev); |
978 | } else { | 987 | } else { |
979 | reg_w(dev, 0x31, 0, 4, NULL, 0); | 988 | reg_w(gspca_dev, 0x31, 0, 4, 0); |
980 | spca504B_WaitCmdStatus(gspca_dev); | 989 | spca504B_WaitCmdStatus(gspca_dev); |
981 | rc = spca504B_PollingDataReady(gspca_dev); | 990 | rc = spca504B_PollingDataReady(gspca_dev); |
982 | } | 991 | } |
@@ -1045,7 +1054,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1045 | /* case BRIDGE_SPCA533: */ | 1054 | /* case BRIDGE_SPCA533: */ |
1046 | /* case BRIDGE_SPCA536: */ | 1055 | /* case BRIDGE_SPCA536: */ |
1047 | /* case BRIDGE_SPCA504B: */ | 1056 | /* case BRIDGE_SPCA504B: */ |
1048 | reg_w(dev, 0x31, 0, 0, NULL, 0); | 1057 | reg_w(gspca_dev, 0x31, 0, 0, 0); |
1049 | spca504B_WaitCmdStatus(gspca_dev); | 1058 | spca504B_WaitCmdStatus(gspca_dev); |
1050 | spca504B_PollingDataReady(gspca_dev); | 1059 | spca504B_PollingDataReady(gspca_dev); |
1051 | break; | 1060 | break; |
@@ -1069,14 +1078,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1069 | } | 1078 | } |
1070 | } | 1079 | } |
1071 | 1080 | ||
1072 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1073 | { | ||
1074 | } | ||
1075 | |||
1076 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1077 | { | ||
1078 | } | ||
1079 | |||
1080 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1081 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1081 | struct gspca_frame *frame, /* target */ | 1082 | struct gspca_frame *frame, /* target */ |
1082 | __u8 *data, /* isoc packet */ | 1083 | __u8 *data, /* isoc packet */ |
@@ -1369,11 +1370,9 @@ static const struct sd_desc sd_desc = { | |||
1369 | .ctrls = sd_ctrls, | 1370 | .ctrls = sd_ctrls, |
1370 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1371 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1371 | .config = sd_config, | 1372 | .config = sd_config, |
1372 | .open = sd_open, | 1373 | .init = sd_init, |
1373 | .start = sd_start, | 1374 | .start = sd_start, |
1374 | .stopN = sd_stopN, | 1375 | .stopN = sd_stopN, |
1375 | .stop0 = sd_stop0, | ||
1376 | .close = sd_close, | ||
1377 | .pkt_scan = sd_pkt_scan, | 1376 | .pkt_scan = sd_pkt_scan, |
1378 | }; | 1377 | }; |
1379 | 1378 | ||
@@ -1456,6 +1455,10 @@ static struct usb_driver sd_driver = { | |||
1456 | .id_table = device_table, | 1455 | .id_table = device_table, |
1457 | .probe = sd_probe, | 1456 | .probe = sd_probe, |
1458 | .disconnect = gspca_disconnect, | 1457 | .disconnect = gspca_disconnect, |
1458 | #ifdef CONFIG_PM | ||
1459 | .suspend = gspca_suspend, | ||
1460 | .resume = gspca_resume, | ||
1461 | #endif | ||
1459 | }; | 1462 | }; |
1460 | 1463 | ||
1461 | /* -- module insert / remove -- */ | 1464 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index 91b555c34c68..f034c748fc7e 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #define MAX_GAMMA 0x10 /* 0 to 15 */ | 31 | #define MAX_GAMMA 0x10 /* 0 to 15 */ |
32 | 32 | ||
33 | #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 3) | 33 | #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 0) |
34 | 34 | ||
35 | MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); | 35 | MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); |
36 | MODULE_DESCRIPTION("GSPCA/T613 (JPEG Compliance) USB Camera Driver"); | 36 | MODULE_DESCRIPTION("GSPCA/T613 (JPEG Compliance) USB Camera Driver"); |
@@ -233,7 +233,7 @@ static char *effects_control[] = { | |||
233 | static struct v4l2_pix_format vga_mode_t16[] = { | 233 | static struct v4l2_pix_format vga_mode_t16[] = { |
234 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 234 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
235 | .bytesperline = 160, | 235 | .bytesperline = 160, |
236 | .sizeimage = 160 * 120 * 3 / 8 + 590, | 236 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
237 | .colorspace = V4L2_COLORSPACE_JPEG, | 237 | .colorspace = V4L2_COLORSPACE_JPEG, |
238 | .priv = 4}, | 238 | .priv = 4}, |
239 | {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 239 | {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
@@ -391,7 +391,7 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
391 | NULL, 0, 500); | 391 | NULL, 0, 500); |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | if (len <= sizeof gspca_dev->usb_buf) { | 394 | if (len <= USB_BUF_SZ) { |
395 | memcpy(gspca_dev->usb_buf, buffer, len); | 395 | memcpy(gspca_dev->usb_buf, buffer, len); |
396 | usb_control_msg(gspca_dev->dev, | 396 | usb_control_msg(gspca_dev->dev, |
397 | usb_sndctrlpipe(gspca_dev->dev, 0), | 397 | usb_sndctrlpipe(gspca_dev->dev, 0), |
@@ -552,6 +552,13 @@ static int init_default_parameters(struct gspca_dev *gspca_dev) | |||
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | 554 | ||
555 | /* this function is called at probe and resume time */ | ||
556 | static int sd_init(struct gspca_dev *gspca_dev) | ||
557 | { | ||
558 | init_default_parameters(gspca_dev); | ||
559 | return 0; | ||
560 | } | ||
561 | |||
555 | static void setbrightness(struct gspca_dev *gspca_dev) | 562 | static void setbrightness(struct gspca_dev *gspca_dev) |
556 | { | 563 | { |
557 | struct sd *sd = (struct sd *) gspca_dev; | 564 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -893,18 +900,6 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
893 | setcolors(gspca_dev); | 900 | setcolors(gspca_dev); |
894 | } | 901 | } |
895 | 902 | ||
896 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
897 | { | ||
898 | } | ||
899 | |||
900 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
901 | { | ||
902 | } | ||
903 | |||
904 | static void sd_close(struct gspca_dev *gspca_dev) | ||
905 | { | ||
906 | } | ||
907 | |||
908 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 903 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
909 | struct gspca_frame *frame, /* target */ | 904 | struct gspca_frame *frame, /* target */ |
910 | __u8 *data, /* isoc packet */ | 905 | __u8 *data, /* isoc packet */ |
@@ -972,24 +967,14 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
972 | return -EINVAL; | 967 | return -EINVAL; |
973 | } | 968 | } |
974 | 969 | ||
975 | /* this function is called at open time */ | ||
976 | static int sd_open(struct gspca_dev *gspca_dev) | ||
977 | { | ||
978 | init_default_parameters(gspca_dev); | ||
979 | return 0; | ||
980 | } | ||
981 | |||
982 | /* sub-driver description */ | 970 | /* sub-driver description */ |
983 | static const struct sd_desc sd_desc = { | 971 | static const struct sd_desc sd_desc = { |
984 | .name = MODULE_NAME, | 972 | .name = MODULE_NAME, |
985 | .ctrls = sd_ctrls, | 973 | .ctrls = sd_ctrls, |
986 | .nctrls = ARRAY_SIZE(sd_ctrls), | 974 | .nctrls = ARRAY_SIZE(sd_ctrls), |
987 | .config = sd_config, | 975 | .config = sd_config, |
988 | .open = sd_open, | 976 | .init = sd_init, |
989 | .start = sd_start, | 977 | .start = sd_start, |
990 | .stopN = sd_stopN, | ||
991 | .stop0 = sd_stop0, | ||
992 | .close = sd_close, | ||
993 | .pkt_scan = sd_pkt_scan, | 978 | .pkt_scan = sd_pkt_scan, |
994 | .querymenu = sd_querymenu, | 979 | .querymenu = sd_querymenu, |
995 | }; | 980 | }; |
@@ -1014,6 +999,10 @@ static struct usb_driver sd_driver = { | |||
1014 | .id_table = device_table, | 999 | .id_table = device_table, |
1015 | .probe = sd_probe, | 1000 | .probe = sd_probe, |
1016 | .disconnect = gspca_disconnect, | 1001 | .disconnect = gspca_disconnect, |
1002 | #ifdef CONFIG_PM | ||
1003 | .suspend = gspca_suspend, | ||
1004 | .resume = gspca_resume, | ||
1005 | #endif | ||
1017 | }; | 1006 | }; |
1018 | 1007 | ||
1019 | /* -- module insert / remove -- */ | 1008 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c index 1ff8ba2f7fe5..084af05302a0 100644 --- a/drivers/media/video/gspca/tv8532.c +++ b/drivers/media/video/gspca/tv8532.c | |||
@@ -331,8 +331,8 @@ static void tv_8532_PollReg(struct gspca_dev *gspca_dev) | |||
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | /* this function is called at open time */ | 334 | /* this function is called at probe and resume time */ |
335 | static int sd_open(struct gspca_dev *gspca_dev) | 335 | static int sd_init(struct gspca_dev *gspca_dev) |
336 | { | 336 | { |
337 | reg_w_1(gspca_dev, TV8532_AD_SLOPE, 0x32); | 337 | reg_w_1(gspca_dev, TV8532_AD_SLOPE, 0x32); |
338 | reg_w_1(gspca_dev, TV8532_AD_BITCTRL, 0x00); | 338 | reg_w_1(gspca_dev, TV8532_AD_BITCTRL, 0x00); |
@@ -450,14 +450,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
450 | reg_w_1(gspca_dev, TV8532_GPIO_OE, 0x0b); | 450 | reg_w_1(gspca_dev, TV8532_GPIO_OE, 0x0b); |
451 | } | 451 | } |
452 | 452 | ||
453 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
454 | { | ||
455 | } | ||
456 | |||
457 | static void sd_close(struct gspca_dev *gspca_dev) | ||
458 | { | ||
459 | } | ||
460 | |||
461 | static void tv8532_preprocess(struct gspca_dev *gspca_dev) | 453 | static void tv8532_preprocess(struct gspca_dev *gspca_dev) |
462 | { | 454 | { |
463 | struct sd *sd = (struct sd *) gspca_dev; | 455 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -611,11 +603,9 @@ static const struct sd_desc sd_desc = { | |||
611 | .ctrls = sd_ctrls, | 603 | .ctrls = sd_ctrls, |
612 | .nctrls = ARRAY_SIZE(sd_ctrls), | 604 | .nctrls = ARRAY_SIZE(sd_ctrls), |
613 | .config = sd_config, | 605 | .config = sd_config, |
614 | .open = sd_open, | 606 | .init = sd_init, |
615 | .start = sd_start, | 607 | .start = sd_start, |
616 | .stopN = sd_stopN, | 608 | .stopN = sd_stopN, |
617 | .stop0 = sd_stop0, | ||
618 | .close = sd_close, | ||
619 | .pkt_scan = sd_pkt_scan, | 609 | .pkt_scan = sd_pkt_scan, |
620 | }; | 610 | }; |
621 | 611 | ||
@@ -644,6 +634,10 @@ static struct usb_driver sd_driver = { | |||
644 | .id_table = device_table, | 634 | .id_table = device_table, |
645 | .probe = sd_probe, | 635 | .probe = sd_probe, |
646 | .disconnect = gspca_disconnect, | 636 | .disconnect = gspca_disconnect, |
637 | #ifdef CONFIG_PM | ||
638 | .suspend = gspca_suspend, | ||
639 | .resume = gspca_resume, | ||
640 | #endif | ||
647 | }; | 641 | }; |
648 | 642 | ||
649 | /* -- module insert / remove -- */ | 643 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index f4a52956e0d9..bd4c226c9a07 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c | |||
@@ -69,6 +69,7 @@ static struct ctrl sd_ctrls[] = { | |||
69 | .set = sd_setautogain, | 69 | .set = sd_setautogain, |
70 | .get = sd_getautogain, | 70 | .get = sd_getautogain, |
71 | }, | 71 | }, |
72 | #define LIGHTFREQ_IDX 1 | ||
72 | { | 73 | { |
73 | { | 74 | { |
74 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | 75 | .id = V4L2_CID_POWER_LINE_FREQUENCY, |
@@ -87,12 +88,12 @@ static struct ctrl sd_ctrls[] = { | |||
87 | }; | 88 | }; |
88 | 89 | ||
89 | static struct v4l2_pix_format vc0321_mode[] = { | 90 | static struct v4l2_pix_format vc0321_mode[] = { |
90 | {320, 240, V4L2_PIX_FMT_YUV420, V4L2_FIELD_NONE, | 91 | {320, 240, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, |
91 | .bytesperline = 320, | 92 | .bytesperline = 320, |
92 | .sizeimage = 320 * 240 * 2, | 93 | .sizeimage = 320 * 240 * 2, |
93 | .colorspace = V4L2_COLORSPACE_SRGB, | 94 | .colorspace = V4L2_COLORSPACE_SRGB, |
94 | .priv = 1}, | 95 | .priv = 1}, |
95 | {640, 480, V4L2_PIX_FMT_YUV420, V4L2_FIELD_NONE, | 96 | {640, 480, V4L2_PIX_FMT_YVYU, V4L2_FIELD_NONE, |
96 | .bytesperline = 640, | 97 | .bytesperline = 640, |
97 | .sizeimage = 640 * 480 * 2, | 98 | .sizeimage = 640 * 480 * 2, |
98 | .colorspace = V4L2_COLORSPACE_SRGB, | 99 | .colorspace = V4L2_COLORSPACE_SRGB, |
@@ -1463,6 +1464,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1463 | sd->qindex = 7; | 1464 | sd->qindex = 7; |
1464 | sd->autogain = AUTOGAIN_DEF; | 1465 | sd->autogain = AUTOGAIN_DEF; |
1465 | sd->lightfreq = FREQ_DEF; | 1466 | sd->lightfreq = FREQ_DEF; |
1467 | if (sd->sensor != SENSOR_OV7670) | ||
1468 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); | ||
1466 | 1469 | ||
1467 | if (sd->bridge == BRIDGE_VC0321) { | 1470 | if (sd->bridge == BRIDGE_VC0321) { |
1468 | reg_r(gspca_dev, 0x8a, 0, 3); | 1471 | reg_r(gspca_dev, 0x8a, 0, 3); |
@@ -1474,8 +1477,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1474 | return 0; | 1477 | return 0; |
1475 | } | 1478 | } |
1476 | 1479 | ||
1477 | /* this function is called at open time */ | 1480 | /* this function is called at probe and time */ |
1478 | static int sd_open(struct gspca_dev *gspca_dev) | 1481 | static int sd_init(struct gspca_dev *gspca_dev) |
1479 | { | 1482 | { |
1480 | return 0; | 1483 | return 0; |
1481 | } | 1484 | } |
@@ -1637,19 +1640,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
1637 | reg_w(dev, 0x89, 0xffff, 0xffff); | 1640 | reg_w(dev, 0x89, 0xffff, 0xffff); |
1638 | } | 1641 | } |
1639 | 1642 | ||
1640 | /* this function is called at close time */ | ||
1641 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1642 | { | ||
1643 | /* struct usb_device *dev = gspca_dev->dev; | ||
1644 | __u8 buffread; | ||
1645 | |||
1646 | reg_w(dev, 0x89, 0xffff, 0xffff); | ||
1647 | reg_w(dev, 0xa0, 0x01, 0xb301); | ||
1648 | reg_w(dev, 0xa0, 0x09, 0xb303); | ||
1649 | reg_w(dev, 0x89, 0xffff, 0xffff); | ||
1650 | */ | ||
1651 | } | ||
1652 | |||
1653 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1643 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1654 | struct gspca_frame *frame, /* target */ | 1644 | struct gspca_frame *frame, /* target */ |
1655 | __u8 *data, /* isoc packet */ | 1645 | __u8 *data, /* isoc packet */ |
@@ -1738,11 +1728,10 @@ static const struct sd_desc sd_desc = { | |||
1738 | .ctrls = sd_ctrls, | 1728 | .ctrls = sd_ctrls, |
1739 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1729 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1740 | .config = sd_config, | 1730 | .config = sd_config, |
1741 | .open = sd_open, | 1731 | .init = sd_init, |
1742 | .start = sd_start, | 1732 | .start = sd_start, |
1743 | .stopN = sd_stopN, | 1733 | .stopN = sd_stopN, |
1744 | .stop0 = sd_stop0, | 1734 | .stop0 = sd_stop0, |
1745 | .close = sd_close, | ||
1746 | .pkt_scan = sd_pkt_scan, | 1735 | .pkt_scan = sd_pkt_scan, |
1747 | .querymenu = sd_querymenu, | 1736 | .querymenu = sd_querymenu, |
1748 | }; | 1737 | }; |
@@ -1774,6 +1763,10 @@ static struct usb_driver sd_driver = { | |||
1774 | .id_table = device_table, | 1763 | .id_table = device_table, |
1775 | .probe = sd_probe, | 1764 | .probe = sd_probe, |
1776 | .disconnect = gspca_disconnect, | 1765 | .disconnect = gspca_disconnect, |
1766 | #ifdef CONFIG_PM | ||
1767 | .suspend = gspca_suspend, | ||
1768 | .resume = gspca_resume, | ||
1769 | #endif | ||
1777 | }; | 1770 | }; |
1778 | 1771 | ||
1779 | /* -- module insert / remove -- */ | 1772 | /* -- module insert / remove -- */ |
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index bc7d0eedcd81..8d7c27e6ac77 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -85,6 +85,7 @@ static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | |||
85 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | 85 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); |
86 | 86 | ||
87 | static struct ctrl sd_ctrls[] = { | 87 | static struct ctrl sd_ctrls[] = { |
88 | #define BRIGHTNESS_IDX 0 | ||
88 | #define SD_BRIGHTNESS 0 | 89 | #define SD_BRIGHTNESS 0 |
89 | { | 90 | { |
90 | { | 91 | { |
@@ -141,6 +142,7 @@ static struct ctrl sd_ctrls[] = { | |||
141 | .set = sd_setautogain, | 142 | .set = sd_setautogain, |
142 | .get = sd_getautogain, | 143 | .get = sd_getautogain, |
143 | }, | 144 | }, |
145 | #define LIGHTFREQ_IDX 4 | ||
144 | #define SD_FREQ 4 | 146 | #define SD_FREQ 4 |
145 | { | 147 | { |
146 | { | 148 | { |
@@ -6964,8 +6966,13 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | |||
6964 | case SENSOR_MC501CB: | 6966 | case SENSOR_MC501CB: |
6965 | return -1; /* don't probe */ | 6967 | return -1; /* don't probe */ |
6966 | case SENSOR_TAS5130C_VF0250: | 6968 | case SENSOR_TAS5130C_VF0250: |
6967 | /* may probe but with write in reg 0x0010 */ | 6969 | /* may probe but with no write in reg 0x0010 */ |
6968 | return -1; /* don't probe */ | 6970 | return -1; /* don't probe */ |
6971 | case SENSOR_PAS106: | ||
6972 | sensor = sif_probe(gspca_dev); | ||
6973 | if (sensor >= 0) | ||
6974 | return sensor; | ||
6975 | break; | ||
6969 | } | 6976 | } |
6970 | sensor = vga_2wr_probe(gspca_dev); | 6977 | sensor = vga_2wr_probe(gspca_dev); |
6971 | if (sensor >= 0) { | 6978 | if (sensor >= 0) { |
@@ -6974,12 +6981,10 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev) | |||
6974 | /* next probe is needed for OmniVision ? */ | 6981 | /* next probe is needed for OmniVision ? */ |
6975 | } | 6982 | } |
6976 | sensor2 = vga_3wr_probe(gspca_dev); | 6983 | sensor2 = vga_3wr_probe(gspca_dev); |
6977 | if (sensor2 >= 0) { | 6984 | if (sensor2 >= 0 |
6978 | if (sensor >= 0) | 6985 | && sensor >= 0) |
6979 | return sensor; | 6986 | return sensor; |
6980 | return sensor2; | 6987 | return sensor2; |
6981 | } | ||
6982 | return sif_probe(gspca_dev); | ||
6983 | } | 6988 | } |
6984 | 6989 | ||
6985 | /* this function is called at probe time */ | 6990 | /* this function is called at probe time */ |
@@ -7147,13 +7152,27 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
7147 | sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; | 7152 | sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; |
7148 | sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value; | 7153 | sd->sharpness = sd_ctrls[SD_SHARPNESS].qctrl.default_value; |
7149 | 7154 | ||
7155 | switch (sd->sensor) { | ||
7156 | case SENSOR_GC0305: | ||
7157 | case SENSOR_OV7620: | ||
7158 | case SENSOR_PO2030: | ||
7159 | gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX); | ||
7160 | break; | ||
7161 | case SENSOR_HDCS2020: | ||
7162 | case SENSOR_HV7131B: | ||
7163 | case SENSOR_HV7131C: | ||
7164 | case SENSOR_OV7630C: | ||
7165 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); | ||
7166 | break; | ||
7167 | } | ||
7168 | |||
7150 | /* switch the led off */ | 7169 | /* switch the led off */ |
7151 | reg_w(gspca_dev->dev, 0x01, 0x0000); | 7170 | reg_w(gspca_dev->dev, 0x01, 0x0000); |
7152 | return 0; | 7171 | return 0; |
7153 | } | 7172 | } |
7154 | 7173 | ||
7155 | /* this function is called at open time */ | 7174 | /* this function is called at probe and resume time */ |
7156 | static int sd_open(struct gspca_dev *gspca_dev) | 7175 | static int sd_init(struct gspca_dev *gspca_dev) |
7157 | { | 7176 | { |
7158 | reg_w(gspca_dev->dev, 0x01, 0x0000); | 7177 | reg_w(gspca_dev->dev, 0x01, 0x0000); |
7159 | return 0; | 7178 | return 0; |
@@ -7314,10 +7333,6 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
7314 | } | 7333 | } |
7315 | } | 7334 | } |
7316 | 7335 | ||
7317 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
7318 | { | ||
7319 | } | ||
7320 | |||
7321 | static void sd_stop0(struct gspca_dev *gspca_dev) | 7336 | static void sd_stop0(struct gspca_dev *gspca_dev) |
7322 | { | 7337 | { |
7323 | struct sd *sd = (struct sd *) gspca_dev; | 7338 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -7325,11 +7340,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
7325 | send_unknown(gspca_dev->dev, sd->sensor); | 7340 | send_unknown(gspca_dev->dev, sd->sensor); |
7326 | } | 7341 | } |
7327 | 7342 | ||
7328 | /* this function is called at close time */ | ||
7329 | static void sd_close(struct gspca_dev *gspca_dev) | ||
7330 | { | ||
7331 | } | ||
7332 | |||
7333 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 7343 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
7334 | struct gspca_frame *frame, | 7344 | struct gspca_frame *frame, |
7335 | __u8 *data, | 7345 | __u8 *data, |
@@ -7489,37 +7499,30 @@ static const struct sd_desc sd_desc = { | |||
7489 | .ctrls = sd_ctrls, | 7499 | .ctrls = sd_ctrls, |
7490 | .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], | 7500 | .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], |
7491 | .config = sd_config, | 7501 | .config = sd_config, |
7492 | .open = sd_open, | 7502 | .init = sd_init, |
7493 | .start = sd_start, | 7503 | .start = sd_start, |
7494 | .stopN = sd_stopN, | ||
7495 | .stop0 = sd_stop0, | 7504 | .stop0 = sd_stop0, |
7496 | .close = sd_close, | ||
7497 | .pkt_scan = sd_pkt_scan, | 7505 | .pkt_scan = sd_pkt_scan, |
7498 | .querymenu = sd_querymenu, | 7506 | .querymenu = sd_querymenu, |
7499 | }; | 7507 | }; |
7500 | 7508 | ||
7501 | static const __devinitdata struct usb_device_id device_table[] = { | 7509 | static const __devinitdata struct usb_device_id device_table[] = { |
7502 | {USB_DEVICE(0x041e, 0x041e)}, | 7510 | {USB_DEVICE(0x041e, 0x041e)}, |
7503 | #ifndef CONFIG_USB_ZC0301 | ||
7504 | {USB_DEVICE(0x041e, 0x4017)}, | 7511 | {USB_DEVICE(0x041e, 0x4017)}, |
7505 | {USB_DEVICE(0x041e, 0x401c)}, | 7512 | {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106}, |
7506 | {USB_DEVICE(0x041e, 0x401e)}, | 7513 | {USB_DEVICE(0x041e, 0x401e)}, |
7507 | {USB_DEVICE(0x041e, 0x401f)}, | 7514 | {USB_DEVICE(0x041e, 0x401f)}, |
7508 | #endif | 7515 | {USB_DEVICE(0x041e, 0x4022)}, |
7509 | {USB_DEVICE(0x041e, 0x4029)}, | 7516 | {USB_DEVICE(0x041e, 0x4029)}, |
7510 | #ifndef CONFIG_USB_ZC0301 | 7517 | {USB_DEVICE(0x041e, 0x4034), .driver_info = SENSOR_PAS106}, |
7511 | {USB_DEVICE(0x041e, 0x4034)}, | 7518 | {USB_DEVICE(0x041e, 0x4035), .driver_info = SENSOR_PAS106}, |
7512 | {USB_DEVICE(0x041e, 0x4035)}, | ||
7513 | {USB_DEVICE(0x041e, 0x4036)}, | 7519 | {USB_DEVICE(0x041e, 0x4036)}, |
7514 | {USB_DEVICE(0x041e, 0x403a)}, | 7520 | {USB_DEVICE(0x041e, 0x403a)}, |
7515 | #endif | ||
7516 | {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_TAS5130C_VF0250}, | 7521 | {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_TAS5130C_VF0250}, |
7517 | {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_TAS5130C_VF0250}, | 7522 | {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_TAS5130C_VF0250}, |
7518 | #ifndef CONFIG_USB_ZC0301 | ||
7519 | {USB_DEVICE(0x0458, 0x7007)}, | 7523 | {USB_DEVICE(0x0458, 0x7007)}, |
7520 | {USB_DEVICE(0x0458, 0x700c)}, | 7524 | {USB_DEVICE(0x0458, 0x700c)}, |
7521 | {USB_DEVICE(0x0458, 0x700f)}, | 7525 | {USB_DEVICE(0x0458, 0x700f)}, |
7522 | #endif | ||
7523 | {USB_DEVICE(0x0461, 0x0a00)}, | 7526 | {USB_DEVICE(0x0461, 0x0a00)}, |
7524 | {USB_DEVICE(0x046d, 0x08a0)}, | 7527 | {USB_DEVICE(0x046d, 0x08a0)}, |
7525 | {USB_DEVICE(0x046d, 0x08a1)}, | 7528 | {USB_DEVICE(0x046d, 0x08a1)}, |
@@ -7531,7 +7534,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
7531 | {USB_DEVICE(0x046d, 0x08aa)}, | 7534 | {USB_DEVICE(0x046d, 0x08aa)}, |
7532 | {USB_DEVICE(0x046d, 0x08ac)}, | 7535 | {USB_DEVICE(0x046d, 0x08ac)}, |
7533 | {USB_DEVICE(0x046d, 0x08ad)}, | 7536 | {USB_DEVICE(0x046d, 0x08ad)}, |
7534 | #ifndef CONFIG_USB_ZC0301 | 7537 | #if !defined CONFIG_USB_ZC0301 && !defined CONFIG_USB_ZC0301_MODULE |
7535 | {USB_DEVICE(0x046d, 0x08ae)}, | 7538 | {USB_DEVICE(0x046d, 0x08ae)}, |
7536 | #endif | 7539 | #endif |
7537 | {USB_DEVICE(0x046d, 0x08af)}, | 7540 | {USB_DEVICE(0x046d, 0x08af)}, |
@@ -7541,27 +7544,25 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
7541 | {USB_DEVICE(0x046d, 0x08d8)}, | 7544 | {USB_DEVICE(0x046d, 0x08d8)}, |
7542 | {USB_DEVICE(0x046d, 0x08da)}, | 7545 | {USB_DEVICE(0x046d, 0x08da)}, |
7543 | {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB}, | 7546 | {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB}, |
7544 | {USB_DEVICE(0x0471, 0x0325)}, | 7547 | {USB_DEVICE(0x0471, 0x0325), .driver_info = SENSOR_PAS106}, |
7545 | {USB_DEVICE(0x0471, 0x0326)}, | 7548 | {USB_DEVICE(0x0471, 0x0326), .driver_info = SENSOR_PAS106}, |
7546 | {USB_DEVICE(0x0471, 0x032d)}, | 7549 | {USB_DEVICE(0x0471, 0x032d), .driver_info = SENSOR_PAS106}, |
7547 | {USB_DEVICE(0x0471, 0x032e)}, | 7550 | {USB_DEVICE(0x0471, 0x032e), .driver_info = SENSOR_PAS106}, |
7548 | {USB_DEVICE(0x055f, 0xc005)}, | 7551 | {USB_DEVICE(0x055f, 0xc005)}, |
7549 | #ifndef CONFIG_USB_ZC0301 | ||
7550 | {USB_DEVICE(0x055f, 0xd003)}, | 7552 | {USB_DEVICE(0x055f, 0xd003)}, |
7551 | {USB_DEVICE(0x055f, 0xd004)}, | 7553 | {USB_DEVICE(0x055f, 0xd004)}, |
7552 | #endif | ||
7553 | {USB_DEVICE(0x0698, 0x2003)}, | 7554 | {USB_DEVICE(0x0698, 0x2003)}, |
7555 | {USB_DEVICE(0x0ac8, 0x0301), .driver_info = SENSOR_PAS106}, | ||
7554 | {USB_DEVICE(0x0ac8, 0x0302)}, | 7556 | {USB_DEVICE(0x0ac8, 0x0302)}, |
7555 | #ifndef CONFIG_USB_ZC0301 | ||
7556 | {USB_DEVICE(0x0ac8, 0x301b)}, | 7557 | {USB_DEVICE(0x0ac8, 0x301b)}, |
7558 | #if !defined CONFIG_USB_ZC0301 && !defined CONFIG_USB_ZC0301_MODULE | ||
7557 | {USB_DEVICE(0x0ac8, 0x303b)}, | 7559 | {USB_DEVICE(0x0ac8, 0x303b)}, |
7558 | #endif | 7560 | #endif |
7559 | {USB_DEVICE(0x0ac8, 0x305b), .driver_info = SENSOR_TAS5130C_VF0250}, | 7561 | {USB_DEVICE(0x0ac8, 0x305b), .driver_info = SENSOR_TAS5130C_VF0250}, |
7560 | #ifndef CONFIG_USB_ZC0301 | ||
7561 | {USB_DEVICE(0x0ac8, 0x307b)}, | 7562 | {USB_DEVICE(0x0ac8, 0x307b)}, |
7562 | {USB_DEVICE(0x10fd, 0x0128)}, | 7563 | {USB_DEVICE(0x10fd, 0x0128)}, |
7564 | {USB_DEVICE(0x10fd, 0x804d)}, | ||
7563 | {USB_DEVICE(0x10fd, 0x8050)}, | 7565 | {USB_DEVICE(0x10fd, 0x8050)}, |
7564 | #endif | ||
7565 | {} /* end of entry */ | 7566 | {} /* end of entry */ |
7566 | }; | 7567 | }; |
7567 | #undef DVNAME | 7568 | #undef DVNAME |
@@ -7581,6 +7582,10 @@ static struct usb_driver sd_driver = { | |||
7581 | .id_table = device_table, | 7582 | .id_table = device_table, |
7582 | .probe = sd_probe, | 7583 | .probe = sd_probe, |
7583 | .disconnect = gspca_disconnect, | 7584 | .disconnect = gspca_disconnect, |
7585 | #ifdef CONFIG_PM | ||
7586 | .suspend = gspca_suspend, | ||
7587 | .resume = gspca_resume, | ||
7588 | #endif | ||
7584 | }; | 7589 | }; |
7585 | 7590 | ||
7586 | static int __init sd_mod_init(void) | 7591 | static int __init sd_mod_init(void) |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index aea1664948ce..4afc7ea07e86 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -688,7 +688,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv) | |||
688 | spin_lock_init(&itv->lock); | 688 | spin_lock_init(&itv->lock); |
689 | spin_lock_init(&itv->dma_reg_lock); | 689 | spin_lock_init(&itv->dma_reg_lock); |
690 | 690 | ||
691 | itv->irq_work_queues = create_workqueue(itv->name); | 691 | itv->irq_work_queues = create_singlethread_workqueue(itv->name); |
692 | if (itv->irq_work_queues == NULL) { | 692 | if (itv->irq_work_queues == NULL) { |
693 | IVTV_ERR("Could not create ivtv workqueue\n"); | 693 | IVTV_ERR("Could not create ivtv workqueue\n"); |
694 | return -1; | 694 | return -1; |
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h index ab287b48fc2b..2ceb5227637c 100644 --- a/drivers/media/video/ivtv/ivtv-driver.h +++ b/drivers/media/video/ivtv/ivtv-driver.h | |||
@@ -251,6 +251,7 @@ struct ivtv_mailbox_data { | |||
251 | #define IVTV_F_I_DEC_PAUSED 20 /* the decoder is paused */ | 251 | #define IVTV_F_I_DEC_PAUSED 20 /* the decoder is paused */ |
252 | #define IVTV_F_I_INITED 21 /* set after first open */ | 252 | #define IVTV_F_I_INITED 21 /* set after first open */ |
253 | #define IVTV_F_I_FAILED 22 /* set if first open failed */ | 253 | #define IVTV_F_I_FAILED 22 /* set if first open failed */ |
254 | #define IVTV_F_I_WORK_INITED 23 /* worker thread was initialized */ | ||
254 | 255 | ||
255 | /* Event notifications */ | 256 | /* Event notifications */ |
256 | #define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */ | 257 | #define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */ |
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c index fba150a6cd23..34f3ab827858 100644 --- a/drivers/media/video/ivtv/ivtv-irq.c +++ b/drivers/media/video/ivtv/ivtv-irq.c | |||
@@ -76,6 +76,13 @@ void ivtv_irq_work_handler(struct work_struct *work) | |||
76 | 76 | ||
77 | DEFINE_WAIT(wait); | 77 | DEFINE_WAIT(wait); |
78 | 78 | ||
79 | if (test_and_clear_bit(IVTV_F_I_WORK_INITED, &itv->i_flags)) { | ||
80 | struct sched_param param = { .sched_priority = 99 }; | ||
81 | |||
82 | /* This thread must use the FIFO scheduler as it | ||
83 | is realtime sensitive. */ | ||
84 | sched_setscheduler(current, SCHED_FIFO, ¶m); | ||
85 | } | ||
79 | if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags)) | 86 | if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags)) |
80 | ivtv_pio_work_handler(itv); | 87 | ivtv_pio_work_handler(itv); |
81 | 88 | ||
@@ -678,34 +685,14 @@ static void ivtv_irq_enc_start_cap(struct ivtv *itv) | |||
678 | 685 | ||
679 | static void ivtv_irq_enc_vbi_cap(struct ivtv *itv) | 686 | static void ivtv_irq_enc_vbi_cap(struct ivtv *itv) |
680 | { | 687 | { |
681 | struct ivtv_stream *s_mpg = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG]; | ||
682 | u32 data[CX2341X_MBOX_MAX_DATA]; | 688 | u32 data[CX2341X_MBOX_MAX_DATA]; |
683 | struct ivtv_stream *s; | 689 | struct ivtv_stream *s; |
684 | 690 | ||
685 | IVTV_DEBUG_HI_IRQ("ENC START VBI CAP\n"); | 691 | IVTV_DEBUG_HI_IRQ("ENC START VBI CAP\n"); |
686 | s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; | 692 | s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; |
687 | 693 | ||
688 | /* If more than two VBI buffers are pending, then | 694 | if (!stream_enc_dma_append(s, data)) |
689 | clear the old ones and start with this new one. | ||
690 | This can happen during transition stages when MPEG capturing is | ||
691 | started, but the first interrupts haven't arrived yet. During | ||
692 | that period VBI requests can accumulate without being able to | ||
693 | DMA the data. Since at most four VBI DMA buffers are available, | ||
694 | we just drop the old requests when there are already three | ||
695 | requests queued. */ | ||
696 | if (s->sg_pending_size > 2) { | ||
697 | struct ivtv_buffer *buf; | ||
698 | list_for_each_entry(buf, &s->q_predma.list, list) | ||
699 | ivtv_buf_sync_for_cpu(s, buf); | ||
700 | ivtv_queue_move(s, &s->q_predma, NULL, &s->q_free, 0); | ||
701 | s->sg_pending_size = 0; | ||
702 | } | ||
703 | /* if we can append the data, and the MPEG stream isn't capturing, | ||
704 | then start a DMA request for just the VBI data. */ | ||
705 | if (!stream_enc_dma_append(s, data) && | ||
706 | !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) { | ||
707 | set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags); | 695 | set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags); |
708 | } | ||
709 | } | 696 | } |
710 | 697 | ||
711 | static void ivtv_irq_dec_vbi_reinsert(struct ivtv *itv) | 698 | static void ivtv_irq_dec_vbi_reinsert(struct ivtv *itv) |
diff --git a/drivers/media/video/ivtv/ivtv-queue.h b/drivers/media/video/ivtv/ivtv-queue.h index 7cfc0c9ab050..476556afd39a 100644 --- a/drivers/media/video/ivtv/ivtv-queue.h +++ b/drivers/media/video/ivtv/ivtv-queue.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #define IVTV_QUEUE_H | 23 | #define IVTV_QUEUE_H |
24 | 24 | ||
25 | #define IVTV_DMA_UNMAPPED ((u32) -1) | 25 | #define IVTV_DMA_UNMAPPED ((u32) -1) |
26 | #define SLICED_VBI_PIO 1 | 26 | #define SLICED_VBI_PIO 0 |
27 | 27 | ||
28 | /* ivtv_buffer utility functions */ | 28 | /* ivtv_buffer utility functions */ |
29 | 29 | ||
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 54d2023b26c4..730e85d86fc8 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -363,7 +363,7 @@ static void ivtv_vbi_setup(struct ivtv *itv) | |||
363 | /* Every X number of frames a VBI interrupt arrives (frames as in 25 or 30 fps) */ | 363 | /* Every X number of frames a VBI interrupt arrives (frames as in 25 or 30 fps) */ |
364 | data[1] = 1; | 364 | data[1] = 1; |
365 | /* The VBI frames are stored in a ringbuffer with this size (with a VBI frame as unit) */ | 365 | /* The VBI frames are stored in a ringbuffer with this size (with a VBI frame as unit) */ |
366 | data[2] = raw ? 4 : 8; | 366 | data[2] = raw ? 4 : 4 * (itv->vbi.raw_size / itv->vbi.enc_size); |
367 | /* The start/stop codes determine which VBI lines end up in the raw VBI data area. | 367 | /* The start/stop codes determine which VBI lines end up in the raw VBI data area. |
368 | The codes are from table 24 in the saa7115 datasheet. Each raw/sliced/video line | 368 | The codes are from table 24 in the saa7115 datasheet. Each raw/sliced/video line |
369 | is framed with codes FF0000XX where XX is the SAV/EAV (Start/End of Active Video) | 369 | is framed with codes FF0000XX where XX is the SAV/EAV (Start/End of Active Video) |
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c index 71798f0da27f..1ce9deb1104f 100644 --- a/drivers/media/video/ivtv/ivtv-vbi.c +++ b/drivers/media/video/ivtv/ivtv-vbi.c | |||
@@ -293,6 +293,7 @@ static u32 compress_sliced_buf(struct ivtv *itv, u32 line, u8 *buf, u32 size, u8 | |||
293 | u32 line_size = itv->vbi.sliced_decoder_line_size; | 293 | u32 line_size = itv->vbi.sliced_decoder_line_size; |
294 | struct v4l2_decode_vbi_line vbi; | 294 | struct v4l2_decode_vbi_line vbi; |
295 | int i; | 295 | int i; |
296 | unsigned lines = 0; | ||
296 | 297 | ||
297 | /* find the first valid line */ | 298 | /* find the first valid line */ |
298 | for (i = 0; i < size; i++, buf++) { | 299 | for (i = 0; i < size; i++, buf++) { |
@@ -313,7 +314,8 @@ static u32 compress_sliced_buf(struct ivtv *itv, u32 line, u8 *buf, u32 size, u8 | |||
313 | } | 314 | } |
314 | vbi.p = p + 4; | 315 | vbi.p = p + 4; |
315 | itv->video_dec_func(itv, VIDIOC_INT_DECODE_VBI_LINE, &vbi); | 316 | itv->video_dec_func(itv, VIDIOC_INT_DECODE_VBI_LINE, &vbi); |
316 | if (vbi.type) { | 317 | if (vbi.type && !(lines & (1 << vbi.line))) { |
318 | lines |= 1 << vbi.line; | ||
317 | itv->vbi.sliced_data[line].id = vbi.type; | 319 | itv->vbi.sliced_data[line].id = vbi.type; |
318 | itv->vbi.sliced_data[line].field = vbi.is_second_field; | 320 | itv->vbi.sliced_data[line].field = vbi.is_second_field; |
319 | itv->vbi.sliced_data[line].line = vbi.line; | 321 | itv->vbi.sliced_data[line].line = vbi.line; |
diff --git a/drivers/media/video/ivtv/ivtv-version.h b/drivers/media/video/ivtv/ivtv-version.h index 442f43f11b73..8cd753d30bf7 100644 --- a/drivers/media/video/ivtv/ivtv-version.h +++ b/drivers/media/video/ivtv/ivtv-version.h | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #define IVTV_DRIVER_NAME "ivtv" | 23 | #define IVTV_DRIVER_NAME "ivtv" |
24 | #define IVTV_DRIVER_VERSION_MAJOR 1 | 24 | #define IVTV_DRIVER_VERSION_MAJOR 1 |
25 | #define IVTV_DRIVER_VERSION_MINOR 3 | 25 | #define IVTV_DRIVER_VERSION_MINOR 4 |
26 | #define IVTV_DRIVER_VERSION_PATCHLEVEL 0 | 26 | #define IVTV_DRIVER_VERSION_PATCHLEVEL 0 |
27 | 27 | ||
28 | #define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL) | 28 | #define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL) |
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c index 4895540be195..2fd4b4a44aa9 100644 --- a/drivers/media/video/ks0127.c +++ b/drivers/media/video/ks0127.c | |||
@@ -679,26 +679,27 @@ static int ks0127_command(struct i2c_client *client, | |||
679 | 679 | ||
680 | case DECODER_ENABLE_OUTPUT: | 680 | case DECODER_ENABLE_OUTPUT: |
681 | { | 681 | { |
682 | int enable; | ||
682 | 683 | ||
683 | int *iarg = arg; | 684 | iarg = arg; |
684 | int enable = (*iarg != 0); | 685 | enable = (*iarg != 0); |
685 | if (enable) { | 686 | if (enable) { |
686 | dprintk("ks0127: command " | 687 | dprintk("ks0127: command " |
687 | "DECODER_ENABLE_OUTPUT on " | 688 | "DECODER_ENABLE_OUTPUT on " |
688 | "(%d)\n", enable); | 689 | "(%d)\n", enable); |
689 | /* All output pins on */ | 690 | /* All output pins on */ |
690 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x30); | 691 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x30); |
691 | /* Obey the OEN pin */ | 692 | /* Obey the OEN pin */ |
692 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x00); | 693 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x00); |
693 | } else { | 694 | } else { |
694 | dprintk("ks0127: command " | 695 | dprintk("ks0127: command " |
695 | "DECODER_ENABLE_OUTPUT off " | 696 | "DECODER_ENABLE_OUTPUT off " |
696 | "(%d)\n", enable); | 697 | "(%d)\n", enable); |
697 | /* Video output pins off */ | 698 | /* Video output pins off */ |
698 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x00); | 699 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x00); |
699 | /* Ignore the OEN pin */ | 700 | /* Ignore the OEN pin */ |
700 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x80); | 701 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x80); |
701 | } | 702 | } |
702 | } | 703 | } |
703 | break; | 704 | break; |
704 | 705 | ||
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 7c8ef6ac6c39..a9ef7802eb5f 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
@@ -1806,6 +1806,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev, | |||
1806 | memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); | 1806 | memcpy(meye.video_dev, &meye_template, sizeof(meye_template)); |
1807 | meye.video_dev->parent = &meye.mchip_dev->dev; | 1807 | meye.video_dev->parent = &meye.mchip_dev->dev; |
1808 | 1808 | ||
1809 | ret = -EIO; | ||
1809 | if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { | 1810 | if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) { |
1810 | printk(KERN_ERR "meye: unable to power on the camera\n"); | 1811 | printk(KERN_ERR "meye: unable to power on the camera\n"); |
1811 | printk(KERN_ERR "meye: did you enable the camera in " | 1812 | printk(KERN_ERR "meye: did you enable the camera in " |
@@ -1813,7 +1814,6 @@ static int __devinit meye_probe(struct pci_dev *pcidev, | |||
1813 | goto outsonypienable; | 1814 | goto outsonypienable; |
1814 | } | 1815 | } |
1815 | 1816 | ||
1816 | ret = -EIO; | ||
1817 | if ((ret = pci_enable_device(meye.mchip_dev))) { | 1817 | if ((ret = pci_enable_device(meye.mchip_dev))) { |
1818 | printk(KERN_ERR "meye: pci_enable_device failed\n"); | 1818 | printk(KERN_ERR "meye: pci_enable_device failed\n"); |
1819 | goto outenabledev; | 1819 | goto outenabledev; |
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index f68e91fbe7fb..8ef578caba3b 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
@@ -931,27 +931,29 @@ static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
931 | return 0; | 931 | return 0; |
932 | } | 932 | } |
933 | 933 | ||
934 | static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std) | 934 | static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standard) |
935 | { | 935 | { |
936 | struct mxb* mxb = (struct mxb*)dev->ext_priv; | 936 | struct mxb *mxb = (struct mxb *)dev->ext_priv; |
937 | int zero = 0; | 937 | int zero = 0; |
938 | int one = 1; | 938 | int one = 1; |
939 | 939 | ||
940 | if(V4L2_STD_PAL_I == std->id ) { | 940 | if (V4L2_STD_PAL_I == standard->id) { |
941 | v4l2_std_id std = V4L2_STD_PAL_I; | 941 | v4l2_std_id std = V4L2_STD_PAL_I; |
942 | |||
942 | DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n")); | 943 | DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n")); |
943 | /* set the 7146 gpio register -- I don't know what this does exactly */ | 944 | /* set the 7146 gpio register -- I don't know what this does exactly */ |
944 | saa7146_write(dev, GPIO_CTRL, 0x00404050); | 945 | saa7146_write(dev, GPIO_CTRL, 0x00404050); |
945 | /* unset the 7111 gpio register -- I don't know what this does exactly */ | 946 | /* unset the 7111 gpio register -- I don't know what this does exactly */ |
946 | mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_GPIO, &zero); | 947 | mxb->saa7111a->driver->command(mxb->saa7111a, DECODER_SET_GPIO, &zero); |
947 | mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); | 948 | mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); |
948 | } else { | 949 | } else { |
949 | v4l2_std_id std = V4L2_STD_PAL_BG; | 950 | v4l2_std_id std = V4L2_STD_PAL_BG; |
951 | |||
950 | DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n")); | 952 | DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n")); |
951 | /* set the 7146 gpio register -- I don't know what this does exactly */ | 953 | /* set the 7146 gpio register -- I don't know what this does exactly */ |
952 | saa7146_write(dev, GPIO_CTRL, 0x00404050); | 954 | saa7146_write(dev, GPIO_CTRL, 0x00404050); |
953 | /* set the 7111 gpio register -- I don't know what this does exactly */ | 955 | /* set the 7111 gpio register -- I don't know what this does exactly */ |
954 | mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_GPIO, &one); | 956 | mxb->saa7111a->driver->command(mxb->saa7111a, DECODER_SET_GPIO, &one); |
955 | mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); | 957 | mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); |
956 | } | 958 | } |
957 | return 0; | 959 | return 0; |
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 9edaca4371d7..3d3c48db45d9 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
@@ -626,9 +626,9 @@ ov511_i2c_write_internal(struct usb_ov511 *ov, | |||
626 | break; | 626 | break; |
627 | 627 | ||
628 | /* Retry until idle */ | 628 | /* Retry until idle */ |
629 | do | 629 | do { |
630 | rc = reg_r(ov, R511_I2C_CTL); | 630 | rc = reg_r(ov, R511_I2C_CTL); |
631 | while (rc > 0 && ((rc&1) == 0)); | 631 | } while (rc > 0 && ((rc&1) == 0)); |
632 | if (rc < 0) | 632 | if (rc < 0) |
633 | break; | 633 | break; |
634 | 634 | ||
@@ -703,9 +703,9 @@ ov511_i2c_read_internal(struct usb_ov511 *ov, unsigned char reg) | |||
703 | return rc; | 703 | return rc; |
704 | 704 | ||
705 | /* Retry until idle */ | 705 | /* Retry until idle */ |
706 | do | 706 | do { |
707 | rc = reg_r(ov, R511_I2C_CTL); | 707 | rc = reg_r(ov, R511_I2C_CTL); |
708 | while (rc > 0 && ((rc&1) == 0)); | 708 | } while (rc > 0 && ((rc & 1) == 0)); |
709 | if (rc < 0) | 709 | if (rc < 0) |
710 | return rc; | 710 | return rc; |
711 | 711 | ||
@@ -729,9 +729,9 @@ ov511_i2c_read_internal(struct usb_ov511 *ov, unsigned char reg) | |||
729 | return rc; | 729 | return rc; |
730 | 730 | ||
731 | /* Retry until idle */ | 731 | /* Retry until idle */ |
732 | do | 732 | do { |
733 | rc = reg_r(ov, R511_I2C_CTL); | 733 | rc = reg_r(ov, R511_I2C_CTL); |
734 | while (rc > 0 && ((rc&1) == 0)); | 734 | } while (rc > 0 && ((rc&1) == 0)); |
735 | if (rc < 0) | 735 | if (rc < 0) |
736 | return rc; | 736 | return rc; |
737 | 737 | ||
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index 00425d743656..7c84f795db54 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
@@ -1019,10 +1019,23 @@ static int init_mediavision(void) | |||
1019 | * Initialization and module stuff | 1019 | * Initialization and module stuff |
1020 | */ | 1020 | */ |
1021 | 1021 | ||
1022 | #ifndef MODULE | ||
1023 | static int enable; | ||
1024 | module_param(enable, int, 0); | ||
1025 | #endif | ||
1026 | |||
1022 | static int __init init_pms_cards(void) | 1027 | static int __init init_pms_cards(void) |
1023 | { | 1028 | { |
1024 | printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n"); | 1029 | printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n"); |
1025 | 1030 | ||
1031 | #ifndef MODULE | ||
1032 | if (!enable) { | ||
1033 | printk(KERN_INFO "PMS: not enabled, use pms.enable=1 to " | ||
1034 | "probe\n"); | ||
1035 | return -ENODEV; | ||
1036 | } | ||
1037 | #endif | ||
1038 | |||
1026 | data_port = io_port +1; | 1039 | data_port = io_port +1; |
1027 | 1040 | ||
1028 | if(init_mediavision()) | 1041 | if(init_mediavision()) |
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c index 1cccd5c77048..dbc560742553 100644 --- a/drivers/media/video/pwc/pwc-ctrl.c +++ b/drivers/media/video/pwc/pwc-ctrl.c | |||
@@ -1635,15 +1635,15 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) | |||
1635 | 1635 | ||
1636 | case VIDIOCPWCGVIDCMD: | 1636 | case VIDIOCPWCGVIDCMD: |
1637 | { | 1637 | { |
1638 | ARG_DEF(struct pwc_video_command, cmd); | 1638 | ARG_DEF(struct pwc_video_command, vcmd); |
1639 | 1639 | ||
1640 | ARGR(cmd).type = pdev->type; | 1640 | ARGR(vcmd).type = pdev->type; |
1641 | ARGR(cmd).release = pdev->release; | 1641 | ARGR(vcmd).release = pdev->release; |
1642 | ARGR(cmd).command_len = pdev->cmd_len; | 1642 | ARGR(vcmd).command_len = pdev->cmd_len; |
1643 | memcpy(&ARGR(cmd).command_buf, pdev->cmd_buf, pdev->cmd_len); | 1643 | memcpy(&ARGR(vcmd).command_buf, pdev->cmd_buf, pdev->cmd_len); |
1644 | ARGR(cmd).bandlength = pdev->vbandlength; | 1644 | ARGR(vcmd).bandlength = pdev->vbandlength; |
1645 | ARGR(cmd).frame_size = pdev->frame_size; | 1645 | ARGR(vcmd).frame_size = pdev->frame_size; |
1646 | ARG_OUT(cmd) | 1646 | ARG_OUT(vcmd) |
1647 | break; | 1647 | break; |
1648 | } | 1648 | } |
1649 | /* | 1649 | /* |
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index bcd1c8f6cf6b..ad733caec720 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
@@ -1489,10 +1489,9 @@ static int saa7115_probe(struct i2c_client *client, | |||
1489 | client->addr << 1, client->adapter->name); | 1489 | client->addr << 1, client->adapter->name); |
1490 | 1490 | ||
1491 | state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); | 1491 | state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL); |
1492 | i2c_set_clientdata(client, state); | 1492 | if (state == NULL) |
1493 | if (state == NULL) { | ||
1494 | return -ENOMEM; | 1493 | return -ENOMEM; |
1495 | } | 1494 | i2c_set_clientdata(client, state); |
1496 | state->input = -1; | 1495 | state->input = -1; |
1497 | state->output = SAA7115_IPORT_ON; | 1496 | state->output = SAA7115_IPORT_ON; |
1498 | state->enable = 1; | 1497 | state->enable = 1; |
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c index f481277892da..acceed5d04ae 100644 --- a/drivers/media/video/se401.c +++ b/drivers/media/video/se401.c | |||
@@ -1397,7 +1397,7 @@ static int se401_probe(struct usb_interface *intf, | |||
1397 | mutex_init(&se401->lock); | 1397 | mutex_init(&se401->lock); |
1398 | wmb(); | 1398 | wmb(); |
1399 | 1399 | ||
1400 | if (video_register_device(&se401->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { | 1400 | if (video_register_device(&se401->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
1401 | kfree(se401); | 1401 | kfree(se401); |
1402 | err("video_register_device failed"); | 1402 | err("video_register_device failed"); |
1403 | return -EIO; | 1403 | return -EIO; |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 23408764d0ef..2da6938718f2 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
@@ -3312,6 +3312,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3312 | cam->v4ldev->fops = &sn9c102_fops; | 3312 | cam->v4ldev->fops = &sn9c102_fops; |
3313 | cam->v4ldev->minor = video_nr[dev_nr]; | 3313 | cam->v4ldev->minor = video_nr[dev_nr]; |
3314 | cam->v4ldev->release = video_device_release; | 3314 | cam->v4ldev->release = video_device_release; |
3315 | cam->v4ldev->parent = &udev->dev; | ||
3315 | 3316 | ||
3316 | init_completion(&cam->probe); | 3317 | init_completion(&cam->probe); |
3317 | 3318 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h index 6ff489baacf3..90a401dc3884 100644 --- a/drivers/media/video/sn9c102/sn9c102_devtable.h +++ b/drivers/media/video/sn9c102/sn9c102_devtable.h | |||
@@ -40,11 +40,14 @@ struct sn9c102_device; | |||
40 | 40 | ||
41 | static const struct usb_device_id sn9c102_id_table[] = { | 41 | static const struct usb_device_id sn9c102_id_table[] = { |
42 | /* SN9C101 and SN9C102 */ | 42 | /* SN9C101 and SN9C102 */ |
43 | #if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE | ||
43 | { SN9C102_USB_DEVICE(0x0c45, 0x6001, BRIDGE_SN9C102), }, | 44 | { SN9C102_USB_DEVICE(0x0c45, 0x6001, BRIDGE_SN9C102), }, |
44 | { SN9C102_USB_DEVICE(0x0c45, 0x6005, BRIDGE_SN9C102), }, | 45 | { SN9C102_USB_DEVICE(0x0c45, 0x6005, BRIDGE_SN9C102), }, |
46 | #endif | ||
45 | { SN9C102_USB_DEVICE(0x0c45, 0x6007, BRIDGE_SN9C102), }, | 47 | { SN9C102_USB_DEVICE(0x0c45, 0x6007, BRIDGE_SN9C102), }, |
46 | { SN9C102_USB_DEVICE(0x0c45, 0x6009, BRIDGE_SN9C102), }, | 48 | { SN9C102_USB_DEVICE(0x0c45, 0x6009, BRIDGE_SN9C102), }, |
47 | { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, | 49 | { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, |
50 | /* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */ | ||
48 | { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, | 51 | { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, |
49 | { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, | 52 | { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, |
50 | { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, | 53 | { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, |
@@ -53,29 +56,33 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
53 | { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), }, | 56 | { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), }, |
54 | { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, | 57 | { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, |
55 | { SN9C102_USB_DEVICE(0x0c45, 0x602c, BRIDGE_SN9C102), }, | 58 | { SN9C102_USB_DEVICE(0x0c45, 0x602c, BRIDGE_SN9C102), }, |
56 | { SN9C102_USB_DEVICE(0x0c45, 0x602d, BRIDGE_SN9C102), }, | 59 | /* { SN9C102_USB_DEVICE(0x0c45, 0x602d, BRIDGE_SN9C102), }, HV7131R */ |
57 | { SN9C102_USB_DEVICE(0x0c45, 0x602e, BRIDGE_SN9C102), }, | 60 | { SN9C102_USB_DEVICE(0x0c45, 0x602e, BRIDGE_SN9C102), }, |
58 | { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, | 61 | { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, |
59 | /* SN9C103 */ | 62 | /* SN9C103 */ |
60 | { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, | 63 | { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, |
61 | { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, | 64 | { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, |
62 | { SN9C102_USB_DEVICE(0x0c45, 0x6083, BRIDGE_SN9C103), }, | 65 | /* { SN9C102_USB_DEVICE(0x0c45, 0x6083, BRIDGE_SN9C103), }, HY7131D/E */ |
63 | { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, | 66 | { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, |
64 | { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, | 67 | { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, |
65 | { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, | 68 | { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, |
66 | { SN9C102_USB_DEVICE(0x0c45, 0x608c, BRIDGE_SN9C103), }, | 69 | { SN9C102_USB_DEVICE(0x0c45, 0x608c, BRIDGE_SN9C103), }, |
67 | { SN9C102_USB_DEVICE(0x0c45, 0x608e, BRIDGE_SN9C103), }, | 70 | /* { SN9C102_USB_DEVICE(0x0c45, 0x608e, BRIDGE_SN9C103), }, CISVF10 */ |
71 | #if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE | ||
68 | { SN9C102_USB_DEVICE(0x0c45, 0x608f, BRIDGE_SN9C103), }, | 72 | { SN9C102_USB_DEVICE(0x0c45, 0x608f, BRIDGE_SN9C103), }, |
73 | #endif | ||
69 | { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, | 74 | { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, |
70 | { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, | 75 | { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, |
71 | { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), }, | 76 | { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), }, |
72 | { SN9C102_USB_DEVICE(0x0c45, 0x60a8, BRIDGE_SN9C103), }, | 77 | /* { SN9C102_USB_DEVICE(0x0c45, 0x60a8, BRIDGE_SN9C103), }, PAS106 */ |
73 | { SN9C102_USB_DEVICE(0x0c45, 0x60aa, BRIDGE_SN9C103), }, | 78 | /* { SN9C102_USB_DEVICE(0x0c45, 0x60aa, BRIDGE_SN9C103), }, TAS5130 */ |
74 | { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, | 79 | /* { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, TAS5130 */ |
75 | { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, | 80 | { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, |
76 | { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, | 81 | { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, |
77 | { SN9C102_USB_DEVICE(0x0c45, 0x60af, BRIDGE_SN9C103), }, | 82 | { SN9C102_USB_DEVICE(0x0c45, 0x60af, BRIDGE_SN9C103), }, |
83 | #if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE | ||
78 | { SN9C102_USB_DEVICE(0x0c45, 0x60b0, BRIDGE_SN9C103), }, | 84 | { SN9C102_USB_DEVICE(0x0c45, 0x60b0, BRIDGE_SN9C103), }, |
85 | #endif | ||
79 | { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), }, | 86 | { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), }, |
80 | { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), }, | 87 | { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), }, |
81 | { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), }, | 88 | { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), }, |
@@ -105,7 +112,7 @@ static const struct usb_device_id sn9c102_id_table[] = { | |||
105 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, | 112 | { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, |
106 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, | 113 | { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, |
107 | { SN9C102_USB_DEVICE(0x0c45, 0x6130, BRIDGE_SN9C120), }, | 114 | { SN9C102_USB_DEVICE(0x0c45, 0x6130, BRIDGE_SN9C120), }, |
108 | { SN9C102_USB_DEVICE(0x0c45, 0x6138, BRIDGE_SN9C120), }, | 115 | /* { SN9C102_USB_DEVICE(0x0c45, 0x6138, BRIDGE_SN9C120), }, MO8000 */ |
109 | { SN9C102_USB_DEVICE(0x0c45, 0x613a, BRIDGE_SN9C120), }, | 116 | { SN9C102_USB_DEVICE(0x0c45, 0x613a, BRIDGE_SN9C120), }, |
110 | { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), }, | 117 | { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), }, |
111 | { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), }, | 118 | { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), }, |
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c index 56dc3d6b5b29..dce947439459 100644 --- a/drivers/media/video/stv680.c +++ b/drivers/media/video/stv680.c | |||
@@ -1462,7 +1462,7 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id | |||
1462 | mutex_init (&stv680->lock); | 1462 | mutex_init (&stv680->lock); |
1463 | wmb (); | 1463 | wmb (); |
1464 | 1464 | ||
1465 | if (video_register_device (stv680->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { | 1465 | if (video_register_device(stv680->vdev, VFL_TYPE_GRABBER, video_nr) < 0) { |
1466 | PDEBUG (0, "STV(e): video_register_device failed"); | 1466 | PDEBUG (0, "STV(e): video_register_device failed"); |
1467 | retval = -EIO; | 1467 | retval = -EIO; |
1468 | goto error_vdev; | 1468 | goto error_vdev; |
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c index 59166b760104..cc27efe121dd 100644 --- a/drivers/media/video/usbvideo/ibmcam.c +++ b/drivers/media/video/usbvideo/ibmcam.c | |||
@@ -736,12 +736,12 @@ static enum ParseState ibmcam_model2_320x240_parse_lines( | |||
736 | * make black color and quit the horizontal scanning loop. | 736 | * make black color and quit the horizontal scanning loop. |
737 | */ | 737 | */ |
738 | if (((frame->curline + 2) >= scanHeight) || (i >= scanLength)) { | 738 | if (((frame->curline + 2) >= scanHeight) || (i >= scanLength)) { |
739 | const int j = i * V4L_BYTES_PER_PIXEL; | 739 | const int offset = i * V4L_BYTES_PER_PIXEL; |
740 | #if USES_IBMCAM_PUTPIXEL | 740 | #if USES_IBMCAM_PUTPIXEL |
741 | /* Refresh 'f' because we don't use it much with PUTPIXEL */ | 741 | /* Refresh 'f' because we don't use it much with PUTPIXEL */ |
742 | f = frame->data + (v4l_linesize * frame->curline) + j; | 742 | f = frame->data + (v4l_linesize * frame->curline) + offset; |
743 | #endif | 743 | #endif |
744 | memset(f, 0, v4l_linesize - j); | 744 | memset(f, 0, v4l_linesize - offset); |
745 | break; | 745 | break; |
746 | } | 746 | } |
747 | 747 | ||
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index b7792451a299..2eb45829791c 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
@@ -866,7 +866,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id) | |||
866 | cam->udev = dev; | 866 | cam->udev = dev; |
867 | cam->bulkEndpoint = bulkEndpoint; | 867 | cam->bulkEndpoint = bulkEndpoint; |
868 | 868 | ||
869 | if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1) == -1) { | 869 | if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1) < 0) { |
870 | kfree(cam); | 870 | kfree(cam); |
871 | printk(KERN_WARNING "video_register_device failed\n"); | 871 | printk(KERN_WARNING "video_register_device failed\n"); |
872 | return -EIO; | 872 | return -EIO; |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 6f36006aecda..155fdec9ac7d 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -257,6 +257,9 @@ int video_register_device_index(struct video_device *vfd, int type, int nr, | |||
257 | int ret; | 257 | int ret; |
258 | char *name_base; | 258 | char *name_base; |
259 | 259 | ||
260 | if (vfd == NULL) | ||
261 | return -EINVAL; | ||
262 | |||
260 | switch (type) { | 263 | switch (type) { |
261 | case VFL_TYPE_GRABBER: | 264 | case VFL_TYPE_GRABBER: |
262 | base = MINOR_VFL_TYPE_GRABBER_MIN; | 265 | base = MINOR_VFL_TYPE_GRABBER_MIN; |
@@ -281,7 +284,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr, | |||
281 | default: | 284 | default: |
282 | printk(KERN_ERR "%s called with unknown type: %d\n", | 285 | printk(KERN_ERR "%s called with unknown type: %d\n", |
283 | __func__, type); | 286 | __func__, type); |
284 | return -1; | 287 | return -EINVAL; |
285 | } | 288 | } |
286 | 289 | ||
287 | /* pick a minor number */ | 290 | /* pick a minor number */ |
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index fdfe7739c96e..140ef92c19c1 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -499,7 +499,7 @@ static void dbgbuf(unsigned int cmd, struct video_device *vfd, | |||
499 | p->timestamp.tv_sec / 3600, | 499 | p->timestamp.tv_sec / 3600, |
500 | (int)(p->timestamp.tv_sec / 60) % 60, | 500 | (int)(p->timestamp.tv_sec / 60) % 60, |
501 | (int)(p->timestamp.tv_sec % 60), | 501 | (int)(p->timestamp.tv_sec % 60), |
502 | p->timestamp.tv_usec, | 502 | (long)p->timestamp.tv_usec, |
503 | p->index, | 503 | p->index, |
504 | prt_names(p->type, v4l2_type_names), | 504 | prt_names(p->type, v4l2_type_names), |
505 | p->bytesused, p->flags, | 505 | p->bytesused, p->flags, |
@@ -674,7 +674,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
674 | __video_do_ioctl will be called again, with one or more | 674 | __video_do_ioctl will be called again, with one or more |
675 | V4L2 ioctls. | 675 | V4L2 ioctls. |
676 | ********************************************************/ | 676 | ********************************************************/ |
677 | if (_IOC_TYPE(cmd) == 'v') | 677 | if (_IOC_TYPE(cmd) == 'v' && _IOC_NR(cmd) < BASE_VIDIOCPRIVATE) |
678 | return v4l_compat_translate_ioctl(inode, file, cmd, arg, | 678 | return v4l_compat_translate_ioctl(inode, file, cmd, arg, |
679 | __video_do_ioctl); | 679 | __video_do_ioctl); |
680 | #endif | 680 | #endif |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 3518af071a2e..8ba8daafd7ea 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -1021,13 +1021,13 @@ static int vivi_release(void) | |||
1021 | dev = list_entry(list, struct vivi_dev, vivi_devlist); | 1021 | dev = list_entry(list, struct vivi_dev, vivi_devlist); |
1022 | 1022 | ||
1023 | if (-1 != dev->vfd->minor) { | 1023 | if (-1 != dev->vfd->minor) { |
1024 | video_unregister_device(dev->vfd); | 1024 | printk(KERN_INFO "%s: unregistering /dev/video%d\n", |
1025 | printk(KERN_INFO "%s: /dev/video%d unregistered.\n", | ||
1026 | VIVI_MODULE_NAME, dev->vfd->minor); | 1025 | VIVI_MODULE_NAME, dev->vfd->minor); |
1026 | video_unregister_device(dev->vfd); | ||
1027 | } else { | 1027 | } else { |
1028 | video_device_release(dev->vfd); | 1028 | printk(KERN_INFO "%s: releasing /dev/video%d\n", |
1029 | printk(KERN_INFO "%s: /dev/video%d released.\n", | ||
1030 | VIVI_MODULE_NAME, dev->vfd->minor); | 1029 | VIVI_MODULE_NAME, dev->vfd->minor); |
1030 | video_device_release(dev->vfd); | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | kfree(dev); | 1033 | kfree(dev); |
@@ -1104,19 +1104,29 @@ static struct video_device vivi_template = { | |||
1104 | Initialization and module stuff | 1104 | Initialization and module stuff |
1105 | ------------------------------------------------------------------*/ | 1105 | ------------------------------------------------------------------*/ |
1106 | 1106 | ||
1107 | /* This routine allocates from 1 to n_devs virtual drivers. | ||
1108 | |||
1109 | The real maximum number of virtual drivers will depend on how many drivers | ||
1110 | will succeed. This is limited to the maximum number of devices that | ||
1111 | videodev supports. Since there are 64 minors for video grabbers, this is | ||
1112 | currently the theoretical maximum limit. However, a further limit does | ||
1113 | exist at videodev that forbids any driver to register more than 32 video | ||
1114 | grabbers. | ||
1115 | */ | ||
1107 | static int __init vivi_init(void) | 1116 | static int __init vivi_init(void) |
1108 | { | 1117 | { |
1109 | int ret = -ENOMEM, i; | 1118 | int ret = -ENOMEM, i; |
1110 | struct vivi_dev *dev; | 1119 | struct vivi_dev *dev; |
1111 | struct video_device *vfd; | 1120 | struct video_device *vfd; |
1112 | 1121 | ||
1122 | if (n_devs <= 0) | ||
1123 | n_devs = 1; | ||
1124 | |||
1113 | for (i = 0; i < n_devs; i++) { | 1125 | for (i = 0; i < n_devs; i++) { |
1114 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 1126 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
1115 | if (NULL == dev) | 1127 | if (!dev) |
1116 | break; | 1128 | break; |
1117 | 1129 | ||
1118 | list_add_tail(&dev->vivi_devlist, &vivi_devlist); | ||
1119 | |||
1120 | /* init video dma queues */ | 1130 | /* init video dma queues */ |
1121 | INIT_LIST_HEAD(&dev->vidq.active); | 1131 | INIT_LIST_HEAD(&dev->vidq.active); |
1122 | init_waitqueue_head(&dev->vidq.wq); | 1132 | init_waitqueue_head(&dev->vidq.wq); |
@@ -1126,14 +1136,27 @@ static int __init vivi_init(void) | |||
1126 | mutex_init(&dev->mutex); | 1136 | mutex_init(&dev->mutex); |
1127 | 1137 | ||
1128 | vfd = video_device_alloc(); | 1138 | vfd = video_device_alloc(); |
1129 | if (NULL == vfd) | 1139 | if (!vfd) { |
1140 | kfree(dev); | ||
1130 | break; | 1141 | break; |
1142 | } | ||
1131 | 1143 | ||
1132 | *vfd = vivi_template; | 1144 | *vfd = vivi_template; |
1133 | 1145 | ||
1134 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); | 1146 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); |
1135 | if (ret < 0) | 1147 | if (ret < 0) { |
1148 | video_device_release(vfd); | ||
1149 | kfree(dev); | ||
1150 | |||
1151 | /* If some registers succeeded, keep driver */ | ||
1152 | if (i) | ||
1153 | ret = 0; | ||
1154 | |||
1136 | break; | 1155 | break; |
1156 | } | ||
1157 | |||
1158 | /* Now that everything is fine, let's add it to device list */ | ||
1159 | list_add_tail(&dev->vivi_devlist, &vivi_devlist); | ||
1137 | 1160 | ||
1138 | snprintf(vfd->name, sizeof(vfd->name), "%s (%i)", | 1161 | snprintf(vfd->name, sizeof(vfd->name), "%s (%i)", |
1139 | vivi_template.name, vfd->minor); | 1162 | vivi_template.name, vfd->minor); |
@@ -1149,11 +1172,16 @@ static int __init vivi_init(void) | |||
1149 | if (ret < 0) { | 1172 | if (ret < 0) { |
1150 | vivi_release(); | 1173 | vivi_release(); |
1151 | printk(KERN_INFO "Error %d while loading vivi driver\n", ret); | 1174 | printk(KERN_INFO "Error %d while loading vivi driver\n", ret); |
1152 | } else | 1175 | } else { |
1153 | printk(KERN_INFO "Video Technology Magazine Virtual Video " | 1176 | printk(KERN_INFO "Video Technology Magazine Virtual Video " |
1154 | "Capture Board ver %u.%u.%u successfully loaded.\n", | 1177 | "Capture Board ver %u.%u.%u successfully loaded.\n", |
1155 | (VIVI_VERSION >> 16) & 0xFF, (VIVI_VERSION >> 8) & 0xFF, | 1178 | (VIVI_VERSION >> 16) & 0xFF, (VIVI_VERSION >> 8) & 0xFF, |
1156 | VIVI_VERSION & 0xFF); | 1179 | VIVI_VERSION & 0xFF); |
1180 | |||
1181 | /* n_devs will reflect the actual number of allocated devices */ | ||
1182 | n_devs = i; | ||
1183 | } | ||
1184 | |||
1157 | return ret; | 1185 | return ret; |
1158 | } | 1186 | } |
1159 | 1187 | ||
@@ -1169,10 +1197,10 @@ MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board"); | |||
1169 | MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol"); | 1197 | MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol"); |
1170 | MODULE_LICENSE("Dual BSD/GPL"); | 1198 | MODULE_LICENSE("Dual BSD/GPL"); |
1171 | 1199 | ||
1172 | module_param(video_nr, int, 0); | 1200 | module_param(video_nr, uint, 0444); |
1173 | MODULE_PARM_DESC(video_nr, "video iminor start number"); | 1201 | MODULE_PARM_DESC(video_nr, "video iminor start number"); |
1174 | 1202 | ||
1175 | module_param(n_devs, int, 0); | 1203 | module_param(n_devs, uint, 0444); |
1176 | MODULE_PARM_DESC(n_devs, "number of video devices to create"); | 1204 | MODULE_PARM_DESC(n_devs, "number of video devices to create"); |
1177 | 1205 | ||
1178 | module_param_named(debug, vivi_template.debug, int, 0444); | 1206 | module_param_named(debug, vivi_template.debug, int, 0444); |
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c index 9402f40095b4..2ff00bc5ad64 100644 --- a/drivers/media/video/w9966.c +++ b/drivers/media/video/w9966.c | |||
@@ -334,7 +334,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port) | |||
334 | memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device)); | 334 | memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device)); |
335 | cam->vdev.priv = cam; | 335 | cam->vdev.priv = cam; |
336 | 336 | ||
337 | if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1) | 337 | if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0) |
338 | return -1; | 338 | return -1; |
339 | 339 | ||
340 | w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV); | 340 | w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV); |
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c index 550ce7bd5c87..0c3287734c93 100644 --- a/drivers/media/video/zc0301/zc0301_core.c +++ b/drivers/media/video/zc0301/zc0301_core.c | |||
@@ -1988,6 +1988,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
1988 | cam->v4ldev->fops = &zc0301_fops; | 1988 | cam->v4ldev->fops = &zc0301_fops; |
1989 | cam->v4ldev->minor = video_nr[dev_nr]; | 1989 | cam->v4ldev->minor = video_nr[dev_nr]; |
1990 | cam->v4ldev->release = video_device_release; | 1990 | cam->v4ldev->release = video_device_release; |
1991 | cam->v4ldev->parent = &udev->dev; | ||
1991 | video_set_drvdata(cam->v4ldev, cam); | 1992 | video_set_drvdata(cam->v4ldev, cam); |
1992 | 1993 | ||
1993 | init_completion(&cam->probe); | 1994 | init_completion(&cam->probe); |
diff --git a/drivers/media/video/zc0301/zc0301_sensor.h b/drivers/media/video/zc0301/zc0301_sensor.h index 70fe6fc6cdd5..b0cd49c438a3 100644 --- a/drivers/media/video/zc0301/zc0301_sensor.h +++ b/drivers/media/video/zc0301/zc0301_sensor.h | |||
@@ -60,27 +60,8 @@ zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor); | |||
60 | 60 | ||
61 | #define ZC0301_ID_TABLE \ | 61 | #define ZC0301_ID_TABLE \ |
62 | static const struct usb_device_id zc0301_id_table[] = { \ | 62 | static const struct usb_device_id zc0301_id_table[] = { \ |
63 | { ZC0301_USB_DEVICE(0x041e, 0x4017, 0xff), }, /* ICM105 */ \ | ||
64 | { ZC0301_USB_DEVICE(0x041e, 0x401c, 0xff), }, /* PAS106 */ \ | ||
65 | { ZC0301_USB_DEVICE(0x041e, 0x401e, 0xff), }, /* HV7131 */ \ | ||
66 | { ZC0301_USB_DEVICE(0x041e, 0x401f, 0xff), }, /* TAS5130 */ \ | ||
67 | { ZC0301_USB_DEVICE(0x041e, 0x4022, 0xff), }, \ | ||
68 | { ZC0301_USB_DEVICE(0x041e, 0x4034, 0xff), }, /* PAS106 */ \ | ||
69 | { ZC0301_USB_DEVICE(0x041e, 0x4035, 0xff), }, /* PAS106 */ \ | ||
70 | { ZC0301_USB_DEVICE(0x041e, 0x4036, 0xff), }, /* HV7131 */ \ | ||
71 | { ZC0301_USB_DEVICE(0x041e, 0x403a, 0xff), }, /* HV7131 */ \ | ||
72 | { ZC0301_USB_DEVICE(0x0458, 0x7007, 0xff), }, /* TAS5130 */ \ | ||
73 | { ZC0301_USB_DEVICE(0x0458, 0x700c, 0xff), }, /* TAS5130 */ \ | ||
74 | { ZC0301_USB_DEVICE(0x0458, 0x700f, 0xff), }, /* TAS5130 */ \ | ||
75 | { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \ | 63 | { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \ |
76 | { ZC0301_USB_DEVICE(0x055f, 0xd003, 0xff), }, /* TAS5130 */ \ | ||
77 | { ZC0301_USB_DEVICE(0x055f, 0xd004, 0xff), }, /* TAS5130 */ \ | ||
78 | { ZC0301_USB_DEVICE(0x0ac8, 0x0301, 0xff), }, \ | ||
79 | { ZC0301_USB_DEVICE(0x0ac8, 0x301b, 0xff), }, /* PB-0330/HV7131 */ \ | ||
80 | { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, /* PB-0330 */ \ | 64 | { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, /* PB-0330 */ \ |
81 | { ZC0301_USB_DEVICE(0x10fd, 0x0128, 0xff), }, /* TAS5130 */ \ | ||
82 | { ZC0301_USB_DEVICE(0x10fd, 0x8050, 0xff), }, /* TAS5130 */ \ | ||
83 | { ZC0301_USB_DEVICE(0x10fd, 0x804e, 0xff), }, /* TAS5130 */ \ | ||
84 | { } \ | 65 | { } \ |
85 | }; | 66 | }; |
86 | 67 | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 10c44d3fe01a..5dba1651f9cc 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -50,6 +50,15 @@ config HTC_PASIC3 | |||
50 | HTC Magician devices, respectively. Actual functionality is | 50 | HTC Magician devices, respectively. Actual functionality is |
51 | handled by the leds-pasic3 and ds1wm drivers. | 51 | handled by the leds-pasic3 and ds1wm drivers. |
52 | 52 | ||
53 | config UCB1400_CORE | ||
54 | tristate "Philips UCB1400 Core driver" | ||
55 | help | ||
56 | This enables support for the Philips UCB1400 core functions. | ||
57 | The UCB1400 is an AC97 audio codec. | ||
58 | |||
59 | To compile this driver as a module, choose M here: the | ||
60 | module will be called ucb1400_core. | ||
61 | |||
53 | config MFD_TMIO | 62 | config MFD_TMIO |
54 | bool | 63 | bool |
55 | default n | 64 | default n |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 03ad239ecef0..6abebe364419 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -22,3 +22,4 @@ obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o | |||
22 | ifeq ($(CONFIG_SA1100_ASSABET),y) | 22 | ifeq ($(CONFIG_SA1100_ASSABET),y) |
23 | obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o | 23 | obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o |
24 | endif | 24 | endif |
25 | obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o | ||
diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c new file mode 100644 index 000000000000..178159e264ce --- /dev/null +++ b/drivers/mfd/ucb1400_core.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Core functions for: | ||
3 | * Philips UCB1400 multifunction chip | ||
4 | * | ||
5 | * Based on ucb1400_ts.c: | ||
6 | * Author: Nicolas Pitre | ||
7 | * Created: September 25, 2006 | ||
8 | * Copyright: MontaVista Software, Inc. | ||
9 | * | ||
10 | * Spliting done by: Marek Vasut <marek.vasut@gmail.com> | ||
11 | * If something doesnt work and it worked before spliting, e-mail me, | ||
12 | * dont bother Nicolas please ;-) | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | * | ||
18 | * This code is heavily based on ucb1x00-*.c copyrighted by Russell King | ||
19 | * covering the UCB1100, UCB1200 and UCB1300.. Support for the UCB1400 has | ||
20 | * been made separate from ucb1x00-core/ucb1x00-ts on Russell's request. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/ucb1400.h> | ||
25 | |||
26 | static int ucb1400_core_probe(struct device *dev) | ||
27 | { | ||
28 | int err; | ||
29 | struct ucb1400 *ucb; | ||
30 | struct ucb1400_ts ucb_ts; | ||
31 | struct snd_ac97 *ac97; | ||
32 | |||
33 | memset(&ucb_ts, 0, sizeof(ucb_ts)); | ||
34 | |||
35 | ucb = kzalloc(sizeof(struct ucb1400), GFP_KERNEL); | ||
36 | if (!ucb) { | ||
37 | err = -ENOMEM; | ||
38 | goto err; | ||
39 | } | ||
40 | |||
41 | dev_set_drvdata(dev, ucb); | ||
42 | |||
43 | ac97 = to_ac97_t(dev); | ||
44 | |||
45 | ucb_ts.id = ucb1400_reg_read(ac97, UCB_ID); | ||
46 | if (ucb_ts.id != UCB_ID_1400) { | ||
47 | err = -ENODEV; | ||
48 | goto err0; | ||
49 | } | ||
50 | |||
51 | /* TOUCHSCREEN */ | ||
52 | ucb_ts.ac97 = ac97; | ||
53 | ucb->ucb1400_ts = platform_device_alloc("ucb1400_ts", -1); | ||
54 | if (!ucb->ucb1400_ts) { | ||
55 | err = -ENOMEM; | ||
56 | goto err0; | ||
57 | } | ||
58 | err = platform_device_add_data(ucb->ucb1400_ts, &ucb_ts, | ||
59 | sizeof(ucb_ts)); | ||
60 | if (err) | ||
61 | goto err1; | ||
62 | err = platform_device_add(ucb->ucb1400_ts); | ||
63 | if (err) | ||
64 | goto err1; | ||
65 | |||
66 | return 0; | ||
67 | |||
68 | err1: | ||
69 | platform_device_put(ucb->ucb1400_ts); | ||
70 | err0: | ||
71 | kfree(ucb); | ||
72 | err: | ||
73 | return err; | ||
74 | } | ||
75 | |||
76 | static int ucb1400_core_remove(struct device *dev) | ||
77 | { | ||
78 | struct ucb1400 *ucb = dev_get_drvdata(dev); | ||
79 | |||
80 | platform_device_unregister(ucb->ucb1400_ts); | ||
81 | kfree(ucb); | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static struct device_driver ucb1400_core_driver = { | ||
86 | .name = "ucb1400_core", | ||
87 | .bus = &ac97_bus_type, | ||
88 | .probe = ucb1400_core_probe, | ||
89 | .remove = ucb1400_core_remove, | ||
90 | }; | ||
91 | |||
92 | static int __init ucb1400_core_init(void) | ||
93 | { | ||
94 | return driver_register(&ucb1400_core_driver); | ||
95 | } | ||
96 | |||
97 | static void __exit ucb1400_core_exit(void) | ||
98 | { | ||
99 | driver_unregister(&ucb1400_core_driver); | ||
100 | } | ||
101 | |||
102 | module_init(ucb1400_core_init); | ||
103 | module_exit(ucb1400_core_exit); | ||
104 | |||
105 | MODULE_DESCRIPTION("Philips UCB1400 driver"); | ||
106 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c index c6c77a505ec1..d8b0d326e452 100644 --- a/drivers/misc/acer-wmi.c +++ b/drivers/misc/acer-wmi.c | |||
@@ -1189,7 +1189,7 @@ static int create_debugfs(void) | |||
1189 | return 0; | 1189 | return 0; |
1190 | 1190 | ||
1191 | error_debugfs: | 1191 | error_debugfs: |
1192 | remove_debugfs(); | 1192 | remove_debugfs(); |
1193 | return -ENOMEM; | 1193 | return -ENOMEM; |
1194 | } | 1194 | } |
1195 | 1195 | ||
@@ -1272,6 +1272,7 @@ error_platform_register: | |||
1272 | static void __exit acer_wmi_exit(void) | 1272 | static void __exit acer_wmi_exit(void) |
1273 | { | 1273 | { |
1274 | remove_sysfs(acer_platform_device); | 1274 | remove_sysfs(acer_platform_device); |
1275 | remove_debugfs(); | ||
1275 | platform_device_del(acer_platform_device); | 1276 | platform_device_del(acer_platform_device); |
1276 | platform_driver_unregister(&acer_platform_driver); | 1277 | platform_driver_unregister(&acer_platform_driver); |
1277 | 1278 | ||
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c index 7a1ef6c262de..3e56203e4947 100644 --- a/drivers/misc/fujitsu-laptop.c +++ b/drivers/misc/fujitsu-laptop.c | |||
@@ -463,6 +463,13 @@ static struct dmi_system_id __initdata fujitsu_dmi_table[] = { | |||
463 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"), | 463 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK S6410"), |
464 | }, | 464 | }, |
465 | .callback = dmi_check_cb_s6410}, | 465 | .callback = dmi_check_cb_s6410}, |
466 | { | ||
467 | .ident = "FUJITSU LifeBook P8010", | ||
468 | .matches = { | ||
469 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), | ||
470 | DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P8010"), | ||
471 | }, | ||
472 | .callback = dmi_check_cb_s6410}, | ||
466 | {} | 473 | {} |
467 | }; | 474 | }; |
468 | 475 | ||
diff --git a/drivers/misc/hp-wmi.c b/drivers/misc/hp-wmi.c index 1dbcbcb323a2..6d407c2a4f91 100644 --- a/drivers/misc/hp-wmi.c +++ b/drivers/misc/hp-wmi.c | |||
@@ -49,6 +49,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); | |||
49 | #define HPWMI_ALS_QUERY 0x3 | 49 | #define HPWMI_ALS_QUERY 0x3 |
50 | #define HPWMI_DOCK_QUERY 0x4 | 50 | #define HPWMI_DOCK_QUERY 0x4 |
51 | #define HPWMI_WIRELESS_QUERY 0x5 | 51 | #define HPWMI_WIRELESS_QUERY 0x5 |
52 | #define HPWMI_HOTKEY_QUERY 0xc | ||
52 | 53 | ||
53 | static int __init hp_wmi_bios_setup(struct platform_device *device); | 54 | static int __init hp_wmi_bios_setup(struct platform_device *device); |
54 | static int __exit hp_wmi_bios_remove(struct platform_device *device); | 55 | static int __exit hp_wmi_bios_remove(struct platform_device *device); |
@@ -69,7 +70,7 @@ struct bios_return { | |||
69 | 70 | ||
70 | struct key_entry { | 71 | struct key_entry { |
71 | char type; /* See KE_* below */ | 72 | char type; /* See KE_* below */ |
72 | u8 code; | 73 | u16 code; |
73 | u16 keycode; | 74 | u16 keycode; |
74 | }; | 75 | }; |
75 | 76 | ||
@@ -79,7 +80,9 @@ static struct key_entry hp_wmi_keymap[] = { | |||
79 | {KE_SW, 0x01, SW_DOCK}, | 80 | {KE_SW, 0x01, SW_DOCK}, |
80 | {KE_KEY, 0x02, KEY_BRIGHTNESSUP}, | 81 | {KE_KEY, 0x02, KEY_BRIGHTNESSUP}, |
81 | {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN}, | 82 | {KE_KEY, 0x03, KEY_BRIGHTNESSDOWN}, |
82 | {KE_KEY, 0x04, KEY_HELP}, | 83 | {KE_KEY, 0x20e6, KEY_PROG1}, |
84 | {KE_KEY, 0x2142, KEY_MEDIA}, | ||
85 | {KE_KEY, 0x231b, KEY_HELP}, | ||
83 | {KE_END, 0} | 86 | {KE_END, 0} |
84 | }; | 87 | }; |
85 | 88 | ||
@@ -177,9 +180,9 @@ static int hp_wmi_wifi_state(void) | |||
177 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 180 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
178 | 181 | ||
179 | if (wireless & 0x100) | 182 | if (wireless & 0x100) |
180 | return 1; | 183 | return RFKILL_STATE_UNBLOCKED; |
181 | else | 184 | else |
182 | return 0; | 185 | return RFKILL_STATE_SOFT_BLOCKED; |
183 | } | 186 | } |
184 | 187 | ||
185 | static int hp_wmi_bluetooth_state(void) | 188 | static int hp_wmi_bluetooth_state(void) |
@@ -187,9 +190,9 @@ static int hp_wmi_bluetooth_state(void) | |||
187 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 190 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
188 | 191 | ||
189 | if (wireless & 0x10000) | 192 | if (wireless & 0x10000) |
190 | return 1; | 193 | return RFKILL_STATE_UNBLOCKED; |
191 | else | 194 | else |
192 | return 0; | 195 | return RFKILL_STATE_SOFT_BLOCKED; |
193 | } | 196 | } |
194 | 197 | ||
195 | static int hp_wmi_wwan_state(void) | 198 | static int hp_wmi_wwan_state(void) |
@@ -197,9 +200,9 @@ static int hp_wmi_wwan_state(void) | |||
197 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | 200 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); |
198 | 201 | ||
199 | if (wireless & 0x1000000) | 202 | if (wireless & 0x1000000) |
200 | return 1; | 203 | return RFKILL_STATE_UNBLOCKED; |
201 | else | 204 | else |
202 | return 0; | 205 | return RFKILL_STATE_SOFT_BLOCKED; |
203 | } | 206 | } |
204 | 207 | ||
205 | static ssize_t show_display(struct device *dev, struct device_attribute *attr, | 208 | static ssize_t show_display(struct device *dev, struct device_attribute *attr, |
@@ -318,6 +321,9 @@ void hp_wmi_notify(u32 value, void *context) | |||
318 | 321 | ||
319 | if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) { | 322 | if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) { |
320 | int eventcode = *((u8 *) obj->buffer.pointer); | 323 | int eventcode = *((u8 *) obj->buffer.pointer); |
324 | if (eventcode == 0x4) | ||
325 | eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, | ||
326 | 0); | ||
321 | key = hp_wmi_get_entry_by_scancode(eventcode); | 327 | key = hp_wmi_get_entry_by_scancode(eventcode); |
322 | if (key) { | 328 | if (key) { |
323 | switch (key->type) { | 329 | switch (key->type) { |
@@ -338,12 +344,14 @@ void hp_wmi_notify(u32 value, void *context) | |||
338 | } | 344 | } |
339 | } else if (eventcode == 0x5) { | 345 | } else if (eventcode == 0x5) { |
340 | if (wifi_rfkill) | 346 | if (wifi_rfkill) |
341 | wifi_rfkill->state = hp_wmi_wifi_state(); | 347 | rfkill_force_state(wifi_rfkill, |
348 | hp_wmi_wifi_state()); | ||
342 | if (bluetooth_rfkill) | 349 | if (bluetooth_rfkill) |
343 | bluetooth_rfkill->state = | 350 | rfkill_force_state(bluetooth_rfkill, |
344 | hp_wmi_bluetooth_state(); | 351 | hp_wmi_bluetooth_state()); |
345 | if (wwan_rfkill) | 352 | if (wwan_rfkill) |
346 | wwan_rfkill->state = hp_wmi_wwan_state(); | 353 | rfkill_force_state(wwan_rfkill, |
354 | hp_wmi_wwan_state()); | ||
347 | } else | 355 | } else |
348 | printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", | 356 | printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", |
349 | eventcode); | 357 | eventcode); |
@@ -398,6 +406,7 @@ static void cleanup_sysfs(struct platform_device *device) | |||
398 | static int __init hp_wmi_bios_setup(struct platform_device *device) | 406 | static int __init hp_wmi_bios_setup(struct platform_device *device) |
399 | { | 407 | { |
400 | int err; | 408 | int err; |
409 | int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); | ||
401 | 410 | ||
402 | err = device_create_file(&device->dev, &dev_attr_display); | 411 | err = device_create_file(&device->dev, &dev_attr_display); |
403 | if (err) | 412 | if (err) |
@@ -412,28 +421,33 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) | |||
412 | if (err) | 421 | if (err) |
413 | goto add_sysfs_error; | 422 | goto add_sysfs_error; |
414 | 423 | ||
415 | wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); | 424 | if (wireless & 0x1) { |
416 | wifi_rfkill->name = "hp-wifi"; | 425 | wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); |
417 | wifi_rfkill->state = hp_wmi_wifi_state(); | 426 | wifi_rfkill->name = "hp-wifi"; |
418 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; | 427 | wifi_rfkill->state = hp_wmi_wifi_state(); |
419 | wifi_rfkill->user_claim_unsupported = 1; | 428 | wifi_rfkill->toggle_radio = hp_wmi_wifi_set; |
420 | 429 | wifi_rfkill->user_claim_unsupported = 1; | |
421 | bluetooth_rfkill = rfkill_allocate(&device->dev, | 430 | rfkill_register(wifi_rfkill); |
422 | RFKILL_TYPE_BLUETOOTH); | 431 | } |
423 | bluetooth_rfkill->name = "hp-bluetooth"; | 432 | |
424 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); | 433 | if (wireless & 0x2) { |
425 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; | 434 | bluetooth_rfkill = rfkill_allocate(&device->dev, |
426 | bluetooth_rfkill->user_claim_unsupported = 1; | 435 | RFKILL_TYPE_BLUETOOTH); |
427 | 436 | bluetooth_rfkill->name = "hp-bluetooth"; | |
428 | wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WIMAX); | 437 | bluetooth_rfkill->state = hp_wmi_bluetooth_state(); |
429 | wwan_rfkill->name = "hp-wwan"; | 438 | bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; |
430 | wwan_rfkill->state = hp_wmi_wwan_state(); | 439 | bluetooth_rfkill->user_claim_unsupported = 1; |
431 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; | 440 | rfkill_register(bluetooth_rfkill); |
432 | wwan_rfkill->user_claim_unsupported = 1; | 441 | } |
433 | 442 | ||
434 | rfkill_register(wifi_rfkill); | 443 | if (wireless & 0x4) { |
435 | rfkill_register(bluetooth_rfkill); | 444 | wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WWAN); |
436 | rfkill_register(wwan_rfkill); | 445 | wwan_rfkill->name = "hp-wwan"; |
446 | wwan_rfkill->state = hp_wmi_wwan_state(); | ||
447 | wwan_rfkill->toggle_radio = hp_wmi_wwan_set; | ||
448 | wwan_rfkill->user_claim_unsupported = 1; | ||
449 | rfkill_register(wwan_rfkill); | ||
450 | } | ||
437 | 451 | ||
438 | return 0; | 452 | return 0; |
439 | add_sysfs_error: | 453 | add_sysfs_error: |
@@ -445,9 +459,12 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device) | |||
445 | { | 459 | { |
446 | cleanup_sysfs(device); | 460 | cleanup_sysfs(device); |
447 | 461 | ||
448 | rfkill_unregister(wifi_rfkill); | 462 | if (wifi_rfkill) |
449 | rfkill_unregister(bluetooth_rfkill); | 463 | rfkill_unregister(wifi_rfkill); |
450 | rfkill_unregister(wwan_rfkill); | 464 | if (bluetooth_rfkill) |
465 | rfkill_unregister(bluetooth_rfkill); | ||
466 | if (wwan_rfkill) | ||
467 | rfkill_unregister(wwan_rfkill); | ||
451 | 468 | ||
452 | return 0; | 469 | return 0; |
453 | } | 470 | } |
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index d3eb7903c346..6b9300779a43 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -3086,7 +3086,6 @@ static struct ibm_struct wan_driver_data = { | |||
3086 | .read = wan_read, | 3086 | .read = wan_read, |
3087 | .write = wan_write, | 3087 | .write = wan_write, |
3088 | .exit = wan_exit, | 3088 | .exit = wan_exit, |
3089 | .flags.experimental = 1, | ||
3090 | }; | 3089 | }; |
3091 | 3090 | ||
3092 | /************************************************************************* | 3091 | /************************************************************************* |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 86dbb366415a..6986f3926244 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -103,8 +103,10 @@ static int mmc_blk_open(struct inode *inode, struct file *filp) | |||
103 | check_disk_change(inode->i_bdev); | 103 | check_disk_change(inode->i_bdev); |
104 | ret = 0; | 104 | ret = 0; |
105 | 105 | ||
106 | if ((filp->f_mode & FMODE_WRITE) && md->read_only) | 106 | if ((filp->f_mode & FMODE_WRITE) && md->read_only) { |
107 | mmc_blk_put(md); | ||
107 | ret = -EROFS; | 108 | ret = -EROFS; |
109 | } | ||
108 | } | 110 | } |
109 | 111 | ||
110 | return ret; | 112 | return ret; |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 6915f40ac8ab..1f8b5b36222c 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -621,12 +621,21 @@ static void at91_mci_send_command(struct at91mci_host *host, struct mmc_command | |||
621 | if (cpu_is_at91sam9260 () || cpu_is_at91sam9263()) | 621 | if (cpu_is_at91sam9260 () || cpu_is_at91sam9263()) |
622 | if (host->total_length < 12) | 622 | if (host->total_length < 12) |
623 | host->total_length = 12; | 623 | host->total_length = 12; |
624 | host->buffer = dma_alloc_coherent(NULL, | 624 | |
625 | host->total_length, | 625 | host->buffer = kmalloc(host->total_length, GFP_KERNEL); |
626 | &host->physical_address, GFP_KERNEL); | 626 | if (!host->buffer) { |
627 | pr_debug("Can't alloc tx buffer\n"); | ||
628 | cmd->error = -ENOMEM; | ||
629 | mmc_request_done(host->mmc, host->request); | ||
630 | return; | ||
631 | } | ||
627 | 632 | ||
628 | at91_mci_sg_to_dma(host, data); | 633 | at91_mci_sg_to_dma(host, data); |
629 | 634 | ||
635 | host->physical_address = dma_map_single(NULL, | ||
636 | host->buffer, host->total_length, | ||
637 | DMA_TO_DEVICE); | ||
638 | |||
630 | pr_debug("Transmitting %d bytes\n", host->total_length); | 639 | pr_debug("Transmitting %d bytes\n", host->total_length); |
631 | 640 | ||
632 | at91_mci_write(host, ATMEL_PDC_TPR, host->physical_address); | 641 | at91_mci_write(host, ATMEL_PDC_TPR, host->physical_address); |
@@ -694,7 +703,10 @@ static void at91_mci_completed_command(struct at91mci_host *host, unsigned int s | |||
694 | cmd->resp[3] = at91_mci_read(host, AT91_MCI_RSPR(3)); | 703 | cmd->resp[3] = at91_mci_read(host, AT91_MCI_RSPR(3)); |
695 | 704 | ||
696 | if (host->buffer) { | 705 | if (host->buffer) { |
697 | dma_free_coherent(NULL, host->total_length, host->buffer, host->physical_address); | 706 | dma_unmap_single(NULL, |
707 | host->physical_address, host->total_length, | ||
708 | DMA_TO_DEVICE); | ||
709 | kfree(host->buffer); | ||
698 | host->buffer = NULL; | 710 | host->buffer = NULL; |
699 | } | 711 | } |
700 | 712 | ||
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index d2f331876e4c..e00d424e6575 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -410,16 +410,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
410 | 410 | ||
411 | case MEMGETREGIONINFO: | 411 | case MEMGETREGIONINFO: |
412 | { | 412 | { |
413 | struct region_info_user ur; | 413 | uint32_t ur_idx; |
414 | struct mtd_erase_region_info *kr; | ||
415 | struct region_info_user *ur = (struct region_info_user *) argp; | ||
414 | 416 | ||
415 | if (copy_from_user(&ur, argp, sizeof(struct region_info_user))) | 417 | if (get_user(ur_idx, &(ur->regionindex))) |
416 | return -EFAULT; | 418 | return -EFAULT; |
417 | 419 | ||
418 | if (ur.regionindex >= mtd->numeraseregions) | 420 | kr = &(mtd->eraseregions[ur_idx]); |
419 | return -EINVAL; | 421 | |
420 | if (copy_to_user(argp, &(mtd->eraseregions[ur.regionindex]), | 422 | if (put_user(kr->offset, &(ur->offset)) |
421 | sizeof(struct mtd_erase_region_info))) | 423 | || put_user(kr->erasesize, &(ur->erasesize)) |
424 | || put_user(kr->numblocks, &(ur->numblocks))) | ||
422 | return -EFAULT; | 425 | return -EFAULT; |
426 | |||
423 | break; | 427 | break; |
424 | } | 428 | } |
425 | 429 | ||
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c index 9eba3f04783a..fa129c09bca8 100644 --- a/drivers/mtd/nand/cmx270_nand.c +++ b/drivers/mtd/nand/cmx270_nand.c | |||
@@ -156,7 +156,7 @@ static int cmx270_init(void) | |||
156 | int mtd_parts_nb = 0; | 156 | int mtd_parts_nb = 0; |
157 | int ret; | 157 | int ret; |
158 | 158 | ||
159 | if (!machine_is_armcore()) | 159 | if (!(machine_is_armcore() && cpu_is_pxa27x())) |
160 | return -ENODEV; | 160 | return -ENODEV; |
161 | 161 | ||
162 | ret = gpio_request(GPIO_NAND_CS, "NAND CS"); | 162 | ret = gpio_request(GPIO_NAND_CS, "NAND CS"); |
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c index cbab654b03c8..edb1e322113d 100644 --- a/drivers/mtd/nand/tmio_nand.c +++ b/drivers/mtd/nand/tmio_nand.c | |||
@@ -109,7 +109,7 @@ struct tmio_nand { | |||
109 | 109 | ||
110 | void __iomem *ccr; | 110 | void __iomem *ccr; |
111 | void __iomem *fcr; | 111 | void __iomem *fcr; |
112 | unsigned long fcr_phys; | 112 | unsigned long fcr_base; |
113 | 113 | ||
114 | unsigned int irq; | 114 | unsigned int irq; |
115 | 115 | ||
@@ -316,8 +316,8 @@ static int tmio_hw_init(struct platform_device *dev, struct tmio_nand *tmio) | |||
316 | tmio_iowrite8(0x81, tmio->ccr + CCR_ICC); | 316 | tmio_iowrite8(0x81, tmio->ccr + CCR_ICC); |
317 | 317 | ||
318 | /* (10h)BaseAddress 0x1000 spba.spba2 */ | 318 | /* (10h)BaseAddress 0x1000 spba.spba2 */ |
319 | tmio_iowrite16(tmio->fcr_phys, tmio->ccr + CCR_BASE); | 319 | tmio_iowrite16(tmio->fcr_base, tmio->ccr + CCR_BASE); |
320 | tmio_iowrite16(tmio->fcr_phys >> 16, tmio->ccr + CCR_BASE + 16); | 320 | tmio_iowrite16(tmio->fcr_base >> 16, tmio->ccr + CCR_BASE + 2); |
321 | 321 | ||
322 | /* (04h)Command Register I/O spcmd */ | 322 | /* (04h)Command Register I/O spcmd */ |
323 | tmio_iowrite8(0x02, tmio->ccr + CCR_COMMAND); | 323 | tmio_iowrite8(0x02, tmio->ccr + CCR_COMMAND); |
@@ -395,7 +395,7 @@ static int tmio_probe(struct platform_device *dev) | |||
395 | goto err_iomap_ccr; | 395 | goto err_iomap_ccr; |
396 | } | 396 | } |
397 | 397 | ||
398 | tmio->fcr_phys = (unsigned long)fcr->start; | 398 | tmio->fcr_base = fcr->start & 0xfffff; |
399 | tmio->fcr = ioremap(fcr->start, fcr->end - fcr->start + 1); | 399 | tmio->fcr = ioremap(fcr->start, fcr->end - fcr->start + 1); |
400 | if (!tmio->fcr) { | 400 | if (!tmio->fcr) { |
401 | retval = -EIO; | 401 | retval = -EIO; |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index a5c141cecd4e..4a11296a9514 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -822,14 +822,14 @@ config ULTRA32 | |||
822 | will be called smc-ultra32. | 822 | will be called smc-ultra32. |
823 | 823 | ||
824 | config BFIN_MAC | 824 | config BFIN_MAC |
825 | tristate "Blackfin 527/536/537 on-chip mac support" | 825 | tristate "Blackfin on-chip MAC support" |
826 | depends on NET_ETHERNET && (BF527 || BF537 || BF536) | 826 | depends on NET_ETHERNET && (BF526 || BF527 || BF536 || BF537) |
827 | select CRC32 | 827 | select CRC32 |
828 | select MII | 828 | select MII |
829 | select PHYLIB | 829 | select PHYLIB |
830 | select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE | 830 | select BFIN_MAC_USE_L1 if DMA_UNCACHED_NONE |
831 | help | 831 | help |
832 | This is the driver for blackfin on-chip mac device. Say Y if you want it | 832 | This is the driver for Blackfin on-chip mac device. Say Y if you want it |
833 | compiled into the kernel. This driver is also available as a module | 833 | compiled into the kernel. This driver is also available as a module |
834 | ( = code which can be inserted in and removed from the running kernel | 834 | ( = code which can be inserted in and removed from the running kernel |
835 | whenever you want). The module will be called bfin_mac. | 835 | whenever you want). The module will be called bfin_mac. |
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c index 82d7be1655d3..7685b995ff9b 100644 --- a/drivers/net/atl1e/atl1e_main.c +++ b/drivers/net/atl1e/atl1e_main.c | |||
@@ -2232,10 +2232,11 @@ static int atl1e_resume(struct pci_dev *pdev) | |||
2232 | 2232 | ||
2233 | AT_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); | 2233 | AT_WRITE_REG(&adapter->hw, REG_WOL_CTRL, 0); |
2234 | 2234 | ||
2235 | if (netif_running(netdev)) | 2235 | if (netif_running(netdev)) { |
2236 | err = atl1e_request_irq(adapter); | 2236 | err = atl1e_request_irq(adapter); |
2237 | if (err) | 2237 | if (err) |
2238 | return err; | 2238 | return err; |
2239 | } | ||
2239 | 2240 | ||
2240 | atl1e_reset_hw(&adapter->hw); | 2241 | atl1e_reset_hw(&adapter->hw); |
2241 | 2242 | ||
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c index e6a7bb79d4df..e23ce77712f1 100644 --- a/drivers/net/atlx/atl1.c +++ b/drivers/net/atlx/atl1.c | |||
@@ -3022,7 +3022,6 @@ static int __devinit atl1_probe(struct pci_dev *pdev, | |||
3022 | netdev->features = NETIF_F_HW_CSUM; | 3022 | netdev->features = NETIF_F_HW_CSUM; |
3023 | netdev->features |= NETIF_F_SG; | 3023 | netdev->features |= NETIF_F_SG; |
3024 | netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); | 3024 | netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); |
3025 | netdev->features |= NETIF_F_TSO; | ||
3026 | netdev->features |= NETIF_F_LLTX; | 3025 | netdev->features |= NETIF_F_LLTX; |
3027 | 3026 | ||
3028 | /* | 3027 | /* |
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h index a14dba1afcc5..fd705d1295a7 100644 --- a/drivers/net/bnx2x.h +++ b/drivers/net/bnx2x.h | |||
@@ -151,6 +151,8 @@ struct sw_rx_page { | |||
151 | #define PAGES_PER_SGE_SHIFT 0 | 151 | #define PAGES_PER_SGE_SHIFT 0 |
152 | #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) | 152 | #define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) |
153 | 153 | ||
154 | #define BCM_RX_ETH_PAYLOAD_ALIGN 64 | ||
155 | |||
154 | /* SGE ring related macros */ | 156 | /* SGE ring related macros */ |
155 | #define NUM_RX_SGE_PAGES 2 | 157 | #define NUM_RX_SGE_PAGES 2 |
156 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) | 158 | #define RX_SGE_CNT (BCM_PAGE_SIZE / sizeof(struct eth_rx_sge)) |
@@ -750,8 +752,7 @@ struct bnx2x { | |||
750 | 752 | ||
751 | u32 rx_csum; | 753 | u32 rx_csum; |
752 | u32 rx_offset; | 754 | u32 rx_offset; |
753 | u32 rx_buf_use_size; /* useable size */ | 755 | u32 rx_buf_size; |
754 | u32 rx_buf_size; /* with alignment */ | ||
755 | #define ETH_OVREHEAD (ETH_HLEN + 8) /* 8 for CRC + VLAN */ | 756 | #define ETH_OVREHEAD (ETH_HLEN + 8) /* 8 for CRC + VLAN */ |
756 | #define ETH_MIN_PACKET_SIZE 60 | 757 | #define ETH_MIN_PACKET_SIZE 60 |
757 | #define ETH_MAX_PACKET_SIZE 1500 | 758 | #define ETH_MAX_PACKET_SIZE 1500 |
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c index 82deea0a63f5..a8eb3c4a47c8 100644 --- a/drivers/net/bnx2x_main.c +++ b/drivers/net/bnx2x_main.c | |||
@@ -59,8 +59,8 @@ | |||
59 | #include "bnx2x.h" | 59 | #include "bnx2x.h" |
60 | #include "bnx2x_init.h" | 60 | #include "bnx2x_init.h" |
61 | 61 | ||
62 | #define DRV_MODULE_VERSION "1.45.20" | 62 | #define DRV_MODULE_VERSION "1.45.21" |
63 | #define DRV_MODULE_RELDATE "2008/08/25" | 63 | #define DRV_MODULE_RELDATE "2008/09/03" |
64 | #define BNX2X_BC_VER 0x040200 | 64 | #define BNX2X_BC_VER 0x040200 |
65 | 65 | ||
66 | /* Time in jiffies before concluding the transmitter is hung */ | 66 | /* Time in jiffies before concluding the transmitter is hung */ |
@@ -1027,7 +1027,7 @@ static inline int bnx2x_alloc_rx_skb(struct bnx2x *bp, | |||
1027 | if (unlikely(skb == NULL)) | 1027 | if (unlikely(skb == NULL)) |
1028 | return -ENOMEM; | 1028 | return -ENOMEM; |
1029 | 1029 | ||
1030 | mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, | 1030 | mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_size, |
1031 | PCI_DMA_FROMDEVICE); | 1031 | PCI_DMA_FROMDEVICE); |
1032 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { | 1032 | if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { |
1033 | dev_kfree_skb(skb); | 1033 | dev_kfree_skb(skb); |
@@ -1169,7 +1169,7 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue, | |||
1169 | /* move empty skb from pool to prod and map it */ | 1169 | /* move empty skb from pool to prod and map it */ |
1170 | prod_rx_buf->skb = fp->tpa_pool[queue].skb; | 1170 | prod_rx_buf->skb = fp->tpa_pool[queue].skb; |
1171 | mapping = pci_map_single(bp->pdev, fp->tpa_pool[queue].skb->data, | 1171 | mapping = pci_map_single(bp->pdev, fp->tpa_pool[queue].skb->data, |
1172 | bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); | 1172 | bp->rx_buf_size, PCI_DMA_FROMDEVICE); |
1173 | pci_unmap_addr_set(prod_rx_buf, mapping, mapping); | 1173 | pci_unmap_addr_set(prod_rx_buf, mapping, mapping); |
1174 | 1174 | ||
1175 | /* move partial skb from cons to pool (don't unmap yet) */ | 1175 | /* move partial skb from cons to pool (don't unmap yet) */ |
@@ -1276,7 +1276,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
1276 | pool entry status to BNX2X_TPA_STOP even if new skb allocation | 1276 | pool entry status to BNX2X_TPA_STOP even if new skb allocation |
1277 | fails. */ | 1277 | fails. */ |
1278 | pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping), | 1278 | pci_unmap_single(bp->pdev, pci_unmap_addr(rx_buf, mapping), |
1279 | bp->rx_buf_use_size, PCI_DMA_FROMDEVICE); | 1279 | bp->rx_buf_size, PCI_DMA_FROMDEVICE); |
1280 | 1280 | ||
1281 | if (likely(new_skb)) { | 1281 | if (likely(new_skb)) { |
1282 | /* fix ip xsum and give it to the stack */ | 1282 | /* fix ip xsum and give it to the stack */ |
@@ -1520,7 +1520,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
1520 | } else if (bnx2x_alloc_rx_skb(bp, fp, bd_prod) == 0) { | 1520 | } else if (bnx2x_alloc_rx_skb(bp, fp, bd_prod) == 0) { |
1521 | pci_unmap_single(bp->pdev, | 1521 | pci_unmap_single(bp->pdev, |
1522 | pci_unmap_addr(rx_buf, mapping), | 1522 | pci_unmap_addr(rx_buf, mapping), |
1523 | bp->rx_buf_use_size, | 1523 | bp->rx_buf_size, |
1524 | PCI_DMA_FROMDEVICE); | 1524 | PCI_DMA_FROMDEVICE); |
1525 | skb_reserve(skb, pad); | 1525 | skb_reserve(skb, pad); |
1526 | skb_put(skb, len); | 1526 | skb_put(skb, len); |
@@ -4229,7 +4229,7 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp, | |||
4229 | if (fp->tpa_state[i] == BNX2X_TPA_START) | 4229 | if (fp->tpa_state[i] == BNX2X_TPA_START) |
4230 | pci_unmap_single(bp->pdev, | 4230 | pci_unmap_single(bp->pdev, |
4231 | pci_unmap_addr(rx_buf, mapping), | 4231 | pci_unmap_addr(rx_buf, mapping), |
4232 | bp->rx_buf_use_size, | 4232 | bp->rx_buf_size, |
4233 | PCI_DMA_FROMDEVICE); | 4233 | PCI_DMA_FROMDEVICE); |
4234 | 4234 | ||
4235 | dev_kfree_skb(skb); | 4235 | dev_kfree_skb(skb); |
@@ -4245,15 +4245,14 @@ static void bnx2x_init_rx_rings(struct bnx2x *bp) | |||
4245 | u16 ring_prod, cqe_ring_prod; | 4245 | u16 ring_prod, cqe_ring_prod; |
4246 | int i, j; | 4246 | int i, j; |
4247 | 4247 | ||
4248 | bp->rx_buf_use_size = bp->dev->mtu; | 4248 | bp->rx_buf_size = bp->dev->mtu; |
4249 | bp->rx_buf_use_size += bp->rx_offset + ETH_OVREHEAD; | 4249 | bp->rx_buf_size += bp->rx_offset + ETH_OVREHEAD + |
4250 | bp->rx_buf_size = bp->rx_buf_use_size + 64; | 4250 | BCM_RX_ETH_PAYLOAD_ALIGN; |
4251 | 4251 | ||
4252 | if (bp->flags & TPA_ENABLE_FLAG) { | 4252 | if (bp->flags & TPA_ENABLE_FLAG) { |
4253 | DP(NETIF_MSG_IFUP, | 4253 | DP(NETIF_MSG_IFUP, |
4254 | "rx_buf_use_size %d rx_buf_size %d effective_mtu %d\n", | 4254 | "rx_buf_size %d effective_mtu %d\n", |
4255 | bp->rx_buf_use_size, bp->rx_buf_size, | 4255 | bp->rx_buf_size, bp->dev->mtu + ETH_OVREHEAD); |
4256 | bp->dev->mtu + ETH_OVREHEAD); | ||
4257 | 4256 | ||
4258 | for_each_queue(bp, j) { | 4257 | for_each_queue(bp, j) { |
4259 | struct bnx2x_fastpath *fp = &bp->fp[j]; | 4258 | struct bnx2x_fastpath *fp = &bp->fp[j]; |
@@ -4462,9 +4461,10 @@ static void bnx2x_init_context(struct bnx2x *bp) | |||
4462 | context->ustorm_st_context.common.status_block_id = sb_id; | 4461 | context->ustorm_st_context.common.status_block_id = sb_id; |
4463 | context->ustorm_st_context.common.flags = | 4462 | context->ustorm_st_context.common.flags = |
4464 | USTORM_ETH_ST_CONTEXT_CONFIG_ENABLE_MC_ALIGNMENT; | 4463 | USTORM_ETH_ST_CONTEXT_CONFIG_ENABLE_MC_ALIGNMENT; |
4465 | context->ustorm_st_context.common.mc_alignment_size = 64; | 4464 | context->ustorm_st_context.common.mc_alignment_size = |
4465 | BCM_RX_ETH_PAYLOAD_ALIGN; | ||
4466 | context->ustorm_st_context.common.bd_buff_size = | 4466 | context->ustorm_st_context.common.bd_buff_size = |
4467 | bp->rx_buf_use_size; | 4467 | bp->rx_buf_size; |
4468 | context->ustorm_st_context.common.bd_page_base_hi = | 4468 | context->ustorm_st_context.common.bd_page_base_hi = |
4469 | U64_HI(fp->rx_desc_mapping); | 4469 | U64_HI(fp->rx_desc_mapping); |
4470 | context->ustorm_st_context.common.bd_page_base_lo = | 4470 | context->ustorm_st_context.common.bd_page_base_lo = |
@@ -4717,7 +4717,7 @@ static void bnx2x_init_internal_func(struct bnx2x *bp) | |||
4717 | } | 4717 | } |
4718 | 4718 | ||
4719 | /* Init CQ ring mapping and aggregation size */ | 4719 | /* Init CQ ring mapping and aggregation size */ |
4720 | max_agg_size = min((u32)(bp->rx_buf_use_size + | 4720 | max_agg_size = min((u32)(bp->rx_buf_size + |
4721 | 8*BCM_PAGE_SIZE*PAGES_PER_SGE), | 4721 | 8*BCM_PAGE_SIZE*PAGES_PER_SGE), |
4722 | (u32)0xffff); | 4722 | (u32)0xffff); |
4723 | for_each_queue(bp, i) { | 4723 | for_each_queue(bp, i) { |
@@ -5940,7 +5940,7 @@ static void bnx2x_free_rx_skbs(struct bnx2x *bp) | |||
5940 | 5940 | ||
5941 | pci_unmap_single(bp->pdev, | 5941 | pci_unmap_single(bp->pdev, |
5942 | pci_unmap_addr(rx_buf, mapping), | 5942 | pci_unmap_addr(rx_buf, mapping), |
5943 | bp->rx_buf_use_size, | 5943 | bp->rx_buf_size, |
5944 | PCI_DMA_FROMDEVICE); | 5944 | PCI_DMA_FROMDEVICE); |
5945 | 5945 | ||
5946 | rx_buf->skb = NULL; | 5946 | rx_buf->skb = NULL; |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 19d32a227be1..453115acaad2 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1838,7 +1838,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, | |||
1838 | if ((le16_to_cpu(rfd->command) & cb_el) && | 1838 | if ((le16_to_cpu(rfd->command) & cb_el) && |
1839 | (RU_RUNNING == nic->ru_running)) | 1839 | (RU_RUNNING == nic->ru_running)) |
1840 | 1840 | ||
1841 | if (readb(&nic->csr->scb.status) & rus_no_res) | 1841 | if (ioread8(&nic->csr->scb.status) & rus_no_res) |
1842 | nic->ru_running = RU_SUSPENDED; | 1842 | nic->ru_running = RU_SUSPENDED; |
1843 | return -ENODATA; | 1843 | return -ENODATA; |
1844 | } | 1844 | } |
@@ -1861,7 +1861,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, | |||
1861 | if ((le16_to_cpu(rfd->command) & cb_el) && | 1861 | if ((le16_to_cpu(rfd->command) & cb_el) && |
1862 | (RU_RUNNING == nic->ru_running)) { | 1862 | (RU_RUNNING == nic->ru_running)) { |
1863 | 1863 | ||
1864 | if (readb(&nic->csr->scb.status) & rus_no_res) | 1864 | if (ioread8(&nic->csr->scb.status) & rus_no_res) |
1865 | nic->ru_running = RU_SUSPENDED; | 1865 | nic->ru_running = RU_SUSPENDED; |
1866 | } | 1866 | } |
1867 | 1867 | ||
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c index b9f90a5d3d4d..213437d13154 100644 --- a/drivers/net/e1000/e1000_param.c +++ b/drivers/net/e1000/e1000_param.c | |||
@@ -208,7 +208,7 @@ struct e1000_option { | |||
208 | } r; | 208 | } r; |
209 | struct { /* list_option info */ | 209 | struct { /* list_option info */ |
210 | int nr; | 210 | int nr; |
211 | struct e1000_opt_list { int i; char *str; } *p; | 211 | const struct e1000_opt_list { int i; char *str; } *p; |
212 | } l; | 212 | } l; |
213 | } arg; | 213 | } arg; |
214 | }; | 214 | }; |
@@ -242,7 +242,7 @@ static int __devinit e1000_validate_option(unsigned int *value, | |||
242 | break; | 242 | break; |
243 | case list_option: { | 243 | case list_option: { |
244 | int i; | 244 | int i; |
245 | struct e1000_opt_list *ent; | 245 | const struct e1000_opt_list *ent; |
246 | 246 | ||
247 | for (i = 0; i < opt->arg.l.nr; i++) { | 247 | for (i = 0; i < opt->arg.l.nr; i++) { |
248 | ent = &opt->arg.l.p[i]; | 248 | ent = &opt->arg.l.p[i]; |
@@ -279,7 +279,9 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter); | |||
279 | 279 | ||
280 | void __devinit e1000_check_options(struct e1000_adapter *adapter) | 280 | void __devinit e1000_check_options(struct e1000_adapter *adapter) |
281 | { | 281 | { |
282 | struct e1000_option opt; | ||
282 | int bd = adapter->bd_number; | 283 | int bd = adapter->bd_number; |
284 | |||
283 | if (bd >= E1000_MAX_NIC) { | 285 | if (bd >= E1000_MAX_NIC) { |
284 | DPRINTK(PROBE, NOTICE, | 286 | DPRINTK(PROBE, NOTICE, |
285 | "Warning: no configuration for board #%i\n", bd); | 287 | "Warning: no configuration for board #%i\n", bd); |
@@ -287,19 +289,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
287 | } | 289 | } |
288 | 290 | ||
289 | { /* Transmit Descriptor Count */ | 291 | { /* Transmit Descriptor Count */ |
290 | struct e1000_option opt = { | 292 | struct e1000_tx_ring *tx_ring = adapter->tx_ring; |
293 | int i; | ||
294 | e1000_mac_type mac_type = adapter->hw.mac_type; | ||
295 | |||
296 | opt = (struct e1000_option) { | ||
291 | .type = range_option, | 297 | .type = range_option, |
292 | .name = "Transmit Descriptors", | 298 | .name = "Transmit Descriptors", |
293 | .err = "using default of " | 299 | .err = "using default of " |
294 | __MODULE_STRING(E1000_DEFAULT_TXD), | 300 | __MODULE_STRING(E1000_DEFAULT_TXD), |
295 | .def = E1000_DEFAULT_TXD, | 301 | .def = E1000_DEFAULT_TXD, |
296 | .arg = { .r = { .min = E1000_MIN_TXD }} | 302 | .arg = { .r = { |
303 | .min = E1000_MIN_TXD, | ||
304 | .max = mac_type < e1000_82544 ? E1000_MAX_TXD : E1000_MAX_82544_TXD | ||
305 | }} | ||
297 | }; | 306 | }; |
298 | struct e1000_tx_ring *tx_ring = adapter->tx_ring; | ||
299 | int i; | ||
300 | e1000_mac_type mac_type = adapter->hw.mac_type; | ||
301 | opt.arg.r.max = mac_type < e1000_82544 ? | ||
302 | E1000_MAX_TXD : E1000_MAX_82544_TXD; | ||
303 | 307 | ||
304 | if (num_TxDescriptors > bd) { | 308 | if (num_TxDescriptors > bd) { |
305 | tx_ring->count = TxDescriptors[bd]; | 309 | tx_ring->count = TxDescriptors[bd]; |
@@ -313,19 +317,21 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
313 | tx_ring[i].count = tx_ring->count; | 317 | tx_ring[i].count = tx_ring->count; |
314 | } | 318 | } |
315 | { /* Receive Descriptor Count */ | 319 | { /* Receive Descriptor Count */ |
316 | struct e1000_option opt = { | 320 | struct e1000_rx_ring *rx_ring = adapter->rx_ring; |
321 | int i; | ||
322 | e1000_mac_type mac_type = adapter->hw.mac_type; | ||
323 | |||
324 | opt = (struct e1000_option) { | ||
317 | .type = range_option, | 325 | .type = range_option, |
318 | .name = "Receive Descriptors", | 326 | .name = "Receive Descriptors", |
319 | .err = "using default of " | 327 | .err = "using default of " |
320 | __MODULE_STRING(E1000_DEFAULT_RXD), | 328 | __MODULE_STRING(E1000_DEFAULT_RXD), |
321 | .def = E1000_DEFAULT_RXD, | 329 | .def = E1000_DEFAULT_RXD, |
322 | .arg = { .r = { .min = E1000_MIN_RXD }} | 330 | .arg = { .r = { |
331 | .min = E1000_MIN_RXD, | ||
332 | .max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD | ||
333 | }} | ||
323 | }; | 334 | }; |
324 | struct e1000_rx_ring *rx_ring = adapter->rx_ring; | ||
325 | int i; | ||
326 | e1000_mac_type mac_type = adapter->hw.mac_type; | ||
327 | opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : | ||
328 | E1000_MAX_82544_RXD; | ||
329 | 335 | ||
330 | if (num_RxDescriptors > bd) { | 336 | if (num_RxDescriptors > bd) { |
331 | rx_ring->count = RxDescriptors[bd]; | 337 | rx_ring->count = RxDescriptors[bd]; |
@@ -339,7 +345,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
339 | rx_ring[i].count = rx_ring->count; | 345 | rx_ring[i].count = rx_ring->count; |
340 | } | 346 | } |
341 | { /* Checksum Offload Enable/Disable */ | 347 | { /* Checksum Offload Enable/Disable */ |
342 | struct e1000_option opt = { | 348 | opt = (struct e1000_option) { |
343 | .type = enable_option, | 349 | .type = enable_option, |
344 | .name = "Checksum Offload", | 350 | .name = "Checksum Offload", |
345 | .err = "defaulting to Enabled", | 351 | .err = "defaulting to Enabled", |
@@ -363,7 +369,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
363 | { E1000_FC_FULL, "Flow Control Enabled" }, | 369 | { E1000_FC_FULL, "Flow Control Enabled" }, |
364 | { E1000_FC_DEFAULT, "Flow Control Hardware Default" }}; | 370 | { E1000_FC_DEFAULT, "Flow Control Hardware Default" }}; |
365 | 371 | ||
366 | struct e1000_option opt = { | 372 | opt = (struct e1000_option) { |
367 | .type = list_option, | 373 | .type = list_option, |
368 | .name = "Flow Control", | 374 | .name = "Flow Control", |
369 | .err = "reading default settings from EEPROM", | 375 | .err = "reading default settings from EEPROM", |
@@ -381,7 +387,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
381 | } | 387 | } |
382 | } | 388 | } |
383 | { /* Transmit Interrupt Delay */ | 389 | { /* Transmit Interrupt Delay */ |
384 | struct e1000_option opt = { | 390 | opt = (struct e1000_option) { |
385 | .type = range_option, | 391 | .type = range_option, |
386 | .name = "Transmit Interrupt Delay", | 392 | .name = "Transmit Interrupt Delay", |
387 | .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), | 393 | .err = "using default of " __MODULE_STRING(DEFAULT_TIDV), |
@@ -399,7 +405,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
399 | } | 405 | } |
400 | } | 406 | } |
401 | { /* Transmit Absolute Interrupt Delay */ | 407 | { /* Transmit Absolute Interrupt Delay */ |
402 | struct e1000_option opt = { | 408 | opt = (struct e1000_option) { |
403 | .type = range_option, | 409 | .type = range_option, |
404 | .name = "Transmit Absolute Interrupt Delay", | 410 | .name = "Transmit Absolute Interrupt Delay", |
405 | .err = "using default of " __MODULE_STRING(DEFAULT_TADV), | 411 | .err = "using default of " __MODULE_STRING(DEFAULT_TADV), |
@@ -417,7 +423,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
417 | } | 423 | } |
418 | } | 424 | } |
419 | { /* Receive Interrupt Delay */ | 425 | { /* Receive Interrupt Delay */ |
420 | struct e1000_option opt = { | 426 | opt = (struct e1000_option) { |
421 | .type = range_option, | 427 | .type = range_option, |
422 | .name = "Receive Interrupt Delay", | 428 | .name = "Receive Interrupt Delay", |
423 | .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), | 429 | .err = "using default of " __MODULE_STRING(DEFAULT_RDTR), |
@@ -435,7 +441,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
435 | } | 441 | } |
436 | } | 442 | } |
437 | { /* Receive Absolute Interrupt Delay */ | 443 | { /* Receive Absolute Interrupt Delay */ |
438 | struct e1000_option opt = { | 444 | opt = (struct e1000_option) { |
439 | .type = range_option, | 445 | .type = range_option, |
440 | .name = "Receive Absolute Interrupt Delay", | 446 | .name = "Receive Absolute Interrupt Delay", |
441 | .err = "using default of " __MODULE_STRING(DEFAULT_RADV), | 447 | .err = "using default of " __MODULE_STRING(DEFAULT_RADV), |
@@ -453,7 +459,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
453 | } | 459 | } |
454 | } | 460 | } |
455 | { /* Interrupt Throttling Rate */ | 461 | { /* Interrupt Throttling Rate */ |
456 | struct e1000_option opt = { | 462 | opt = (struct e1000_option) { |
457 | .type = range_option, | 463 | .type = range_option, |
458 | .name = "Interrupt Throttling Rate (ints/sec)", | 464 | .name = "Interrupt Throttling Rate (ints/sec)", |
459 | .err = "using default of " __MODULE_STRING(DEFAULT_ITR), | 465 | .err = "using default of " __MODULE_STRING(DEFAULT_ITR), |
@@ -497,7 +503,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
497 | } | 503 | } |
498 | } | 504 | } |
499 | { /* Smart Power Down */ | 505 | { /* Smart Power Down */ |
500 | struct e1000_option opt = { | 506 | opt = (struct e1000_option) { |
501 | .type = enable_option, | 507 | .type = enable_option, |
502 | .name = "PHY Smart Power Down", | 508 | .name = "PHY Smart Power Down", |
503 | .err = "defaulting to Disabled", | 509 | .err = "defaulting to Disabled", |
@@ -513,7 +519,7 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter) | |||
513 | } | 519 | } |
514 | } | 520 | } |
515 | { /* Kumeran Lock Loss Workaround */ | 521 | { /* Kumeran Lock Loss Workaround */ |
516 | struct e1000_option opt = { | 522 | opt = (struct e1000_option) { |
517 | .type = enable_option, | 523 | .type = enable_option, |
518 | .name = "Kumeran Lock Loss Workaround", | 524 | .name = "Kumeran Lock Loss Workaround", |
519 | .err = "defaulting to Enabled", | 525 | .err = "defaulting to Enabled", |
@@ -578,16 +584,18 @@ static void __devinit e1000_check_fiber_options(struct e1000_adapter *adapter) | |||
578 | 584 | ||
579 | static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) | 585 | static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) |
580 | { | 586 | { |
587 | struct e1000_option opt; | ||
581 | unsigned int speed, dplx, an; | 588 | unsigned int speed, dplx, an; |
582 | int bd = adapter->bd_number; | 589 | int bd = adapter->bd_number; |
583 | 590 | ||
584 | { /* Speed */ | 591 | { /* Speed */ |
585 | struct e1000_opt_list speed_list[] = {{ 0, "" }, | 592 | static const struct e1000_opt_list speed_list[] = { |
586 | { SPEED_10, "" }, | 593 | { 0, "" }, |
587 | { SPEED_100, "" }, | 594 | { SPEED_10, "" }, |
588 | { SPEED_1000, "" }}; | 595 | { SPEED_100, "" }, |
596 | { SPEED_1000, "" }}; | ||
589 | 597 | ||
590 | struct e1000_option opt = { | 598 | opt = (struct e1000_option) { |
591 | .type = list_option, | 599 | .type = list_option, |
592 | .name = "Speed", | 600 | .name = "Speed", |
593 | .err = "parameter ignored", | 601 | .err = "parameter ignored", |
@@ -604,11 +612,12 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) | |||
604 | } | 612 | } |
605 | } | 613 | } |
606 | { /* Duplex */ | 614 | { /* Duplex */ |
607 | struct e1000_opt_list dplx_list[] = {{ 0, "" }, | 615 | static const struct e1000_opt_list dplx_list[] = { |
608 | { HALF_DUPLEX, "" }, | 616 | { 0, "" }, |
609 | { FULL_DUPLEX, "" }}; | 617 | { HALF_DUPLEX, "" }, |
618 | { FULL_DUPLEX, "" }}; | ||
610 | 619 | ||
611 | struct e1000_option opt = { | 620 | opt = (struct e1000_option) { |
612 | .type = list_option, | 621 | .type = list_option, |
613 | .name = "Duplex", | 622 | .name = "Duplex", |
614 | .err = "parameter ignored", | 623 | .err = "parameter ignored", |
@@ -637,7 +646,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) | |||
637 | "parameter ignored\n"); | 646 | "parameter ignored\n"); |
638 | adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; | 647 | adapter->hw.autoneg_advertised = AUTONEG_ADV_DEFAULT; |
639 | } else { /* Autoneg */ | 648 | } else { /* Autoneg */ |
640 | struct e1000_opt_list an_list[] = | 649 | static const struct e1000_opt_list an_list[] = |
641 | #define AA "AutoNeg advertising " | 650 | #define AA "AutoNeg advertising " |
642 | {{ 0x01, AA "10/HD" }, | 651 | {{ 0x01, AA "10/HD" }, |
643 | { 0x02, AA "10/FD" }, | 652 | { 0x02, AA "10/FD" }, |
@@ -671,7 +680,7 @@ static void __devinit e1000_check_copper_options(struct e1000_adapter *adapter) | |||
671 | { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, | 680 | { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, |
672 | { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; | 681 | { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }}; |
673 | 682 | ||
674 | struct e1000_option opt = { | 683 | opt = (struct e1000_option) { |
675 | .type = list_option, | 684 | .type = list_option, |
676 | .name = "AutoNeg", | 685 | .name = "AutoNeg", |
677 | .err = "parameter ignored", | 686 | .err = "parameter ignored", |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 053971e5fc94..0b6ecef9a849 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -5522,7 +5522,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5522 | if (id->driver_data & DEV_HAS_CHECKSUM) { | 5522 | if (id->driver_data & DEV_HAS_CHECKSUM) { |
5523 | np->rx_csum = 1; | 5523 | np->rx_csum = 1; |
5524 | np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; | 5524 | np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; |
5525 | dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; | 5525 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; |
5526 | dev->features |= NETIF_F_TSO; | 5526 | dev->features |= NETIF_F_TSO; |
5527 | } | 5527 | } |
5528 | 5528 | ||
@@ -5835,7 +5835,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5835 | 5835 | ||
5836 | dev_printk(KERN_INFO, &pci_dev->dev, "%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", | 5836 | dev_printk(KERN_INFO, &pci_dev->dev, "%s%s%s%s%s%s%s%s%s%sdesc-v%u\n", |
5837 | dev->features & NETIF_F_HIGHDMA ? "highdma " : "", | 5837 | dev->features & NETIF_F_HIGHDMA ? "highdma " : "", |
5838 | dev->features & (NETIF_F_HW_CSUM | NETIF_F_SG) ? | 5838 | dev->features & (NETIF_F_IP_CSUM | NETIF_F_SG) ? |
5839 | "csum " : "", | 5839 | "csum " : "", |
5840 | dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ? | 5840 | dev->features & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX) ? |
5841 | "vlan " : "", | 5841 | "vlan " : "", |
@@ -5975,10 +5975,12 @@ static void nv_shutdown(struct pci_dev *pdev) | |||
5975 | if (netif_running(dev)) | 5975 | if (netif_running(dev)) |
5976 | nv_close(dev); | 5976 | nv_close(dev); |
5977 | 5977 | ||
5978 | pci_enable_wake(pdev, PCI_D3hot, np->wolenabled); | ||
5979 | pci_enable_wake(pdev, PCI_D3cold, np->wolenabled); | ||
5980 | pci_disable_device(pdev); | 5978 | pci_disable_device(pdev); |
5981 | pci_set_power_state(pdev, PCI_D3hot); | 5979 | if (system_state == SYSTEM_POWER_OFF) { |
5980 | if (pci_enable_wake(pdev, PCI_D3cold, np->wolenabled)) | ||
5981 | pci_enable_wake(pdev, PCI_D3hot, np->wolenabled); | ||
5982 | pci_set_power_state(pdev, PCI_D3hot); | ||
5983 | } | ||
5982 | } | 5984 | } |
5983 | #else | 5985 | #else |
5984 | #define nv_suspend NULL | 5986 | #define nv_suspend NULL |
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 9a51ec8293cc..9d461825bf4c 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -792,6 +792,10 @@ static int fs_enet_open(struct net_device *dev) | |||
792 | int r; | 792 | int r; |
793 | int err; | 793 | int err; |
794 | 794 | ||
795 | /* to initialize the fep->cur_rx,... */ | ||
796 | /* not doing this, will cause a crash in fs_enet_rx_napi */ | ||
797 | fs_init_bds(fep->ndev); | ||
798 | |||
795 | if (fep->fpi->use_napi) | 799 | if (fep->fpi->use_napi) |
796 | napi_enable(&fep->napi); | 800 | napi_enable(&fep->napi); |
797 | 801 | ||
@@ -1167,6 +1171,10 @@ static struct of_device_id fs_enet_match[] = { | |||
1167 | .compatible = "fsl,cpm1-scc-enet", | 1171 | .compatible = "fsl,cpm1-scc-enet", |
1168 | .data = (void *)&fs_scc_ops, | 1172 | .data = (void *)&fs_scc_ops, |
1169 | }, | 1173 | }, |
1174 | { | ||
1175 | .compatible = "fsl,cpm2-scc-enet", | ||
1176 | .data = (void *)&fs_scc_ops, | ||
1177 | }, | ||
1170 | #endif | 1178 | #endif |
1171 | #ifdef CONFIG_FS_ENET_HAS_FCC | 1179 | #ifdef CONFIG_FS_ENET_HAS_FCC |
1172 | { | 1180 | { |
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index 029b3c7ef29c..22f50dd8b277 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include "fs_enet.h" | 47 | #include "fs_enet.h" |
48 | 48 | ||
49 | /*************************************************/ | 49 | /*************************************************/ |
50 | |||
51 | #if defined(CONFIG_CPM1) | 50 | #if defined(CONFIG_CPM1) |
52 | /* for a 8xx __raw_xxx's are sufficient */ | 51 | /* for a 8xx __raw_xxx's are sufficient */ |
53 | #define __fs_out32(addr, x) __raw_writel(x, addr) | 52 | #define __fs_out32(addr, x) __raw_writel(x, addr) |
@@ -62,6 +61,8 @@ | |||
62 | #define __fs_out16(addr, x) out_be16(addr, x) | 61 | #define __fs_out16(addr, x) out_be16(addr, x) |
63 | #define __fs_in32(addr) in_be32(addr) | 62 | #define __fs_in32(addr) in_be32(addr) |
64 | #define __fs_in16(addr) in_be16(addr) | 63 | #define __fs_in16(addr) in_be16(addr) |
64 | #define __fs_out8(addr, x) out_8(addr, x) | ||
65 | #define __fs_in8(addr) in_8(addr) | ||
65 | #endif | 66 | #endif |
66 | 67 | ||
67 | /* write, read, set bits, clear bits */ | 68 | /* write, read, set bits, clear bits */ |
@@ -262,8 +263,13 @@ static void restart(struct net_device *dev) | |||
262 | 263 | ||
263 | /* Initialize function code registers for big-endian. | 264 | /* Initialize function code registers for big-endian. |
264 | */ | 265 | */ |
266 | #ifndef CONFIG_NOT_COHERENT_CACHE | ||
267 | W8(ep, sen_genscc.scc_rfcr, SCC_EB | SCC_GBL); | ||
268 | W8(ep, sen_genscc.scc_tfcr, SCC_EB | SCC_GBL); | ||
269 | #else | ||
265 | W8(ep, sen_genscc.scc_rfcr, SCC_EB); | 270 | W8(ep, sen_genscc.scc_rfcr, SCC_EB); |
266 | W8(ep, sen_genscc.scc_tfcr, SCC_EB); | 271 | W8(ep, sen_genscc.scc_tfcr, SCC_EB); |
272 | #endif | ||
267 | 273 | ||
268 | /* Set maximum bytes per receive buffer. | 274 | /* Set maximum bytes per receive buffer. |
269 | * This appears to be an Ethernet frame size, not the buffer | 275 | * This appears to be an Ethernet frame size, not the buffer |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 999d69168277..4320a983a588 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -105,6 +105,7 @@ const char gfar_driver_version[] = "1.3"; | |||
105 | 105 | ||
106 | static int gfar_enet_open(struct net_device *dev); | 106 | static int gfar_enet_open(struct net_device *dev); |
107 | static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); | 107 | static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); |
108 | static void gfar_reset_task(struct work_struct *work); | ||
108 | static void gfar_timeout(struct net_device *dev); | 109 | static void gfar_timeout(struct net_device *dev); |
109 | static int gfar_close(struct net_device *dev); | 110 | static int gfar_close(struct net_device *dev); |
110 | struct sk_buff *gfar_new_skb(struct net_device *dev); | 111 | struct sk_buff *gfar_new_skb(struct net_device *dev); |
@@ -209,6 +210,7 @@ static int gfar_probe(struct platform_device *pdev) | |||
209 | spin_lock_init(&priv->txlock); | 210 | spin_lock_init(&priv->txlock); |
210 | spin_lock_init(&priv->rxlock); | 211 | spin_lock_init(&priv->rxlock); |
211 | spin_lock_init(&priv->bflock); | 212 | spin_lock_init(&priv->bflock); |
213 | INIT_WORK(&priv->reset_task, gfar_reset_task); | ||
212 | 214 | ||
213 | platform_set_drvdata(pdev, dev); | 215 | platform_set_drvdata(pdev, dev); |
214 | 216 | ||
@@ -1212,6 +1214,7 @@ static int gfar_close(struct net_device *dev) | |||
1212 | 1214 | ||
1213 | napi_disable(&priv->napi); | 1215 | napi_disable(&priv->napi); |
1214 | 1216 | ||
1217 | cancel_work_sync(&priv->reset_task); | ||
1215 | stop_gfar(dev); | 1218 | stop_gfar(dev); |
1216 | 1219 | ||
1217 | /* Disconnect from the PHY */ | 1220 | /* Disconnect from the PHY */ |
@@ -1326,13 +1329,16 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu) | |||
1326 | return 0; | 1329 | return 0; |
1327 | } | 1330 | } |
1328 | 1331 | ||
1329 | /* gfar_timeout gets called when a packet has not been | 1332 | /* gfar_reset_task gets scheduled when a packet has not been |
1330 | * transmitted after a set amount of time. | 1333 | * transmitted after a set amount of time. |
1331 | * For now, assume that clearing out all the structures, and | 1334 | * For now, assume that clearing out all the structures, and |
1332 | * starting over will fix the problem. */ | 1335 | * starting over will fix the problem. |
1333 | static void gfar_timeout(struct net_device *dev) | 1336 | */ |
1337 | static void gfar_reset_task(struct work_struct *work) | ||
1334 | { | 1338 | { |
1335 | dev->stats.tx_errors++; | 1339 | struct gfar_private *priv = container_of(work, struct gfar_private, |
1340 | reset_task); | ||
1341 | struct net_device *dev = priv->dev; | ||
1336 | 1342 | ||
1337 | if (dev->flags & IFF_UP) { | 1343 | if (dev->flags & IFF_UP) { |
1338 | stop_gfar(dev); | 1344 | stop_gfar(dev); |
@@ -1342,6 +1348,14 @@ static void gfar_timeout(struct net_device *dev) | |||
1342 | netif_tx_schedule_all(dev); | 1348 | netif_tx_schedule_all(dev); |
1343 | } | 1349 | } |
1344 | 1350 | ||
1351 | static void gfar_timeout(struct net_device *dev) | ||
1352 | { | ||
1353 | struct gfar_private *priv = netdev_priv(dev); | ||
1354 | |||
1355 | dev->stats.tx_errors++; | ||
1356 | schedule_work(&priv->reset_task); | ||
1357 | } | ||
1358 | |||
1345 | /* Interrupt Handler for Transmit complete */ | 1359 | /* Interrupt Handler for Transmit complete */ |
1346 | static int gfar_clean_tx_ring(struct net_device *dev) | 1360 | static int gfar_clean_tx_ring(struct net_device *dev) |
1347 | { | 1361 | { |
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index d59df98bd636..f46e9b63af13 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h | |||
@@ -756,6 +756,7 @@ struct gfar_private { | |||
756 | 756 | ||
757 | uint32_t msg_enable; | 757 | uint32_t msg_enable; |
758 | 758 | ||
759 | struct work_struct reset_task; | ||
759 | /* Network Statistics */ | 760 | /* Network Statistics */ |
760 | struct gfar_extra_stats extra_stats; | 761 | struct gfar_extra_stats extra_stats; |
761 | }; | 762 | }; |
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index 2e720f26ca83..ccd9d9058f6d 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -663,9 +663,6 @@ static int emac_configure(struct emac_instance *dev) | |||
663 | if (emac_phy_gpcs(dev->phy.mode)) | 663 | if (emac_phy_gpcs(dev->phy.mode)) |
664 | emac_mii_reset_phy(&dev->phy); | 664 | emac_mii_reset_phy(&dev->phy); |
665 | 665 | ||
666 | /* Required for Pause packet support in EMAC */ | ||
667 | dev_mc_add(ndev, default_mcast_addr, sizeof(default_mcast_addr), 1); | ||
668 | |||
669 | return 0; | 666 | return 0; |
670 | } | 667 | } |
671 | 668 | ||
@@ -1150,6 +1147,9 @@ static int emac_open(struct net_device *ndev) | |||
1150 | } else | 1147 | } else |
1151 | netif_carrier_on(dev->ndev); | 1148 | netif_carrier_on(dev->ndev); |
1152 | 1149 | ||
1150 | /* Required for Pause packet support in EMAC */ | ||
1151 | dev_mc_add(ndev, default_mcast_addr, sizeof(default_mcast_addr), 1); | ||
1152 | |||
1153 | emac_configure(dev); | 1153 | emac_configure(dev); |
1154 | mal_poll_add(dev->mal, &dev->commac); | 1154 | mal_poll_add(dev->mal, &dev->commac); |
1155 | mal_enable_tx_channel(dev->mal, dev->mal_tx_chan); | 1155 | mal_enable_tx_channel(dev->mal, dev->mal_tx_chan); |
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index a03fe1fb61ca..c2d57f836088 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -904,8 +904,6 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
904 | unsigned long data_dma_addr; | 904 | unsigned long data_dma_addr; |
905 | 905 | ||
906 | desc.fields.flags_len = IBMVETH_BUF_VALID | skb->len; | 906 | desc.fields.flags_len = IBMVETH_BUF_VALID | skb->len; |
907 | data_dma_addr = dma_map_single(&adapter->vdev->dev, skb->data, | ||
908 | skb->len, DMA_TO_DEVICE); | ||
909 | 907 | ||
910 | if (skb->ip_summed == CHECKSUM_PARTIAL && | 908 | if (skb->ip_summed == CHECKSUM_PARTIAL && |
911 | ip_hdr(skb)->protocol != IPPROTO_TCP && skb_checksum_help(skb)) { | 909 | ip_hdr(skb)->protocol != IPPROTO_TCP && skb_checksum_help(skb)) { |
@@ -924,6 +922,8 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
924 | buf[1] = 0; | 922 | buf[1] = 0; |
925 | } | 923 | } |
926 | 924 | ||
925 | data_dma_addr = dma_map_single(&adapter->vdev->dev, skb->data, | ||
926 | skb->len, DMA_TO_DEVICE); | ||
927 | if (dma_mapping_error(&adapter->vdev->dev, data_dma_addr)) { | 927 | if (dma_mapping_error(&adapter->vdev->dev, data_dma_addr)) { |
928 | if (!firmware_has_feature(FW_FEATURE_CMO)) | 928 | if (!firmware_has_feature(FW_FEATURE_CMO)) |
929 | ibmveth_error_printk("tx: unable to map xmit buffer\n"); | 929 | ibmveth_error_printk("tx: unable to map xmit buffer\n"); |
@@ -932,6 +932,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
932 | desc.fields.address = adapter->bounce_buffer_dma; | 932 | desc.fields.address = adapter->bounce_buffer_dma; |
933 | tx_map_failed++; | 933 | tx_map_failed++; |
934 | used_bounce = 1; | 934 | used_bounce = 1; |
935 | wmb(); | ||
935 | } else | 936 | } else |
936 | desc.fields.address = data_dma_addr; | 937 | desc.fields.address = data_dma_addr; |
937 | 938 | ||
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c index bb823acc7443..f5e2e7235fcb 100644 --- a/drivers/net/igb/e1000_82575.c +++ b/drivers/net/igb/e1000_82575.c | |||
@@ -87,7 +87,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
87 | case E1000_DEV_ID_82576: | 87 | case E1000_DEV_ID_82576: |
88 | case E1000_DEV_ID_82576_FIBER: | 88 | case E1000_DEV_ID_82576_FIBER: |
89 | case E1000_DEV_ID_82576_SERDES: | 89 | case E1000_DEV_ID_82576_SERDES: |
90 | case E1000_DEV_ID_82576_QUAD_COPPER: | ||
91 | mac->type = e1000_82576; | 90 | mac->type = e1000_82576; |
92 | break; | 91 | break; |
93 | default: | 92 | default: |
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h index a65ccc3095c3..99504a600a80 100644 --- a/drivers/net/igb/e1000_hw.h +++ b/drivers/net/igb/e1000_hw.h | |||
@@ -41,7 +41,6 @@ struct e1000_hw; | |||
41 | #define E1000_DEV_ID_82576 0x10C9 | 41 | #define E1000_DEV_ID_82576 0x10C9 |
42 | #define E1000_DEV_ID_82576_FIBER 0x10E6 | 42 | #define E1000_DEV_ID_82576_FIBER 0x10E6 |
43 | #define E1000_DEV_ID_82576_SERDES 0x10E7 | 43 | #define E1000_DEV_ID_82576_SERDES 0x10E7 |
44 | #define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8 | ||
45 | #define E1000_DEV_ID_82575EB_COPPER 0x10A7 | 44 | #define E1000_DEV_ID_82575EB_COPPER 0x10A7 |
46 | #define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9 | 45 | #define E1000_DEV_ID_82575EB_FIBER_SERDES 0x10A9 |
47 | #define E1000_DEV_ID_82575GB_QUAD_COPPER 0x10D6 | 46 | #define E1000_DEV_ID_82575GB_QUAD_COPPER 0x10D6 |
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index 11aee1309951..58906c984be9 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -373,13 +373,17 @@ static void igb_get_regs(struct net_device *netdev, | |||
373 | regs_buff[12] = rd32(E1000_EECD); | 373 | regs_buff[12] = rd32(E1000_EECD); |
374 | 374 | ||
375 | /* Interrupt */ | 375 | /* Interrupt */ |
376 | regs_buff[13] = rd32(E1000_EICR); | 376 | /* Reading EICS for EICR because they read the |
377 | * same but EICS does not clear on read */ | ||
378 | regs_buff[13] = rd32(E1000_EICS); | ||
377 | regs_buff[14] = rd32(E1000_EICS); | 379 | regs_buff[14] = rd32(E1000_EICS); |
378 | regs_buff[15] = rd32(E1000_EIMS); | 380 | regs_buff[15] = rd32(E1000_EIMS); |
379 | regs_buff[16] = rd32(E1000_EIMC); | 381 | regs_buff[16] = rd32(E1000_EIMC); |
380 | regs_buff[17] = rd32(E1000_EIAC); | 382 | regs_buff[17] = rd32(E1000_EIAC); |
381 | regs_buff[18] = rd32(E1000_EIAM); | 383 | regs_buff[18] = rd32(E1000_EIAM); |
382 | regs_buff[19] = rd32(E1000_ICR); | 384 | /* Reading ICS for ICR because they read the |
385 | * same but ICS does not clear on read */ | ||
386 | regs_buff[19] = rd32(E1000_ICS); | ||
383 | regs_buff[20] = rd32(E1000_ICS); | 387 | regs_buff[20] = rd32(E1000_ICS); |
384 | regs_buff[21] = rd32(E1000_IMS); | 388 | regs_buff[21] = rd32(E1000_IMS); |
385 | regs_buff[22] = rd32(E1000_IMC); | 389 | regs_buff[22] = rd32(E1000_IMC); |
@@ -1746,15 +1750,6 @@ static int igb_wol_exclusion(struct igb_adapter *adapter, | |||
1746 | /* return success for non excluded adapter ports */ | 1750 | /* return success for non excluded adapter ports */ |
1747 | retval = 0; | 1751 | retval = 0; |
1748 | break; | 1752 | break; |
1749 | case E1000_DEV_ID_82576_QUAD_COPPER: | ||
1750 | /* quad port adapters only support WoL on port A */ | ||
1751 | if (!(adapter->flags & IGB_FLAG_QUAD_PORT_A)) { | ||
1752 | wol->supported = 0; | ||
1753 | break; | ||
1754 | } | ||
1755 | /* return success for non excluded adapter ports */ | ||
1756 | retval = 0; | ||
1757 | break; | ||
1758 | default: | 1753 | default: |
1759 | /* dual port cards only support WoL on port A from now on | 1754 | /* dual port cards only support WoL on port A from now on |
1760 | * unless it was enabled in the eeprom for port B | 1755 | * unless it was enabled in the eeprom for port B |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 8f66e15ec8d6..634c4c9d87be 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -61,7 +61,6 @@ static struct pci_device_id igb_pci_tbl[] = { | |||
61 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576), board_82575 }, | 61 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576), board_82575 }, |
62 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 }, | 62 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 }, |
63 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 }, | 63 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 }, |
64 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER), board_82575 }, | ||
65 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 }, | 64 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 }, |
66 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 }, | 65 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 }, |
67 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575GB_QUAD_COPPER), board_82575 }, | 66 | { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575GB_QUAD_COPPER), board_82575 }, |
@@ -521,7 +520,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter) | |||
521 | adapter->msix_entries, | 520 | adapter->msix_entries, |
522 | numvecs); | 521 | numvecs); |
523 | if (err == 0) | 522 | if (err == 0) |
524 | return; | 523 | goto out; |
525 | 524 | ||
526 | igb_reset_interrupt_capability(adapter); | 525 | igb_reset_interrupt_capability(adapter); |
527 | 526 | ||
@@ -531,7 +530,7 @@ msi_only: | |||
531 | adapter->num_tx_queues = 1; | 530 | adapter->num_tx_queues = 1; |
532 | if (!pci_enable_msi(adapter->pdev)) | 531 | if (!pci_enable_msi(adapter->pdev)) |
533 | adapter->flags |= IGB_FLAG_HAS_MSI; | 532 | adapter->flags |= IGB_FLAG_HAS_MSI; |
534 | 533 | out: | |
535 | /* Notify the stack of the (possibly) reduced Tx Queue count. */ | 534 | /* Notify the stack of the (possibly) reduced Tx Queue count. */ |
536 | adapter->netdev->real_num_tx_queues = adapter->num_tx_queues; | 535 | adapter->netdev->real_num_tx_queues = adapter->num_tx_queues; |
537 | return; | 536 | return; |
@@ -1217,16 +1216,6 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1217 | if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1) | 1216 | if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1) |
1218 | adapter->eeprom_wol = 0; | 1217 | adapter->eeprom_wol = 0; |
1219 | break; | 1218 | break; |
1220 | case E1000_DEV_ID_82576_QUAD_COPPER: | ||
1221 | /* if quad port adapter, disable WoL on all but port A */ | ||
1222 | if (global_quad_port_a != 0) | ||
1223 | adapter->eeprom_wol = 0; | ||
1224 | else | ||
1225 | adapter->flags |= IGB_FLAG_QUAD_PORT_A; | ||
1226 | /* Reset for multiple quad port adapters */ | ||
1227 | if (++global_quad_port_a == 4) | ||
1228 | global_quad_port_a = 0; | ||
1229 | break; | ||
1230 | } | 1219 | } |
1231 | 1220 | ||
1232 | /* initialize the wol settings based on the eeprom settings */ | 1221 | /* initialize the wol settings based on the eeprom settings */ |
@@ -2290,7 +2279,9 @@ static void igb_watchdog_task(struct work_struct *work) | |||
2290 | struct igb_ring *tx_ring = adapter->tx_ring; | 2279 | struct igb_ring *tx_ring = adapter->tx_ring; |
2291 | struct e1000_mac_info *mac = &adapter->hw.mac; | 2280 | struct e1000_mac_info *mac = &adapter->hw.mac; |
2292 | u32 link; | 2281 | u32 link; |
2282 | u32 eics = 0; | ||
2293 | s32 ret_val; | 2283 | s32 ret_val; |
2284 | int i; | ||
2294 | 2285 | ||
2295 | if ((netif_carrier_ok(netdev)) && | 2286 | if ((netif_carrier_ok(netdev)) && |
2296 | (rd32(E1000_STATUS) & E1000_STATUS_LU)) | 2287 | (rd32(E1000_STATUS) & E1000_STATUS_LU)) |
@@ -2392,7 +2383,13 @@ link_up: | |||
2392 | } | 2383 | } |
2393 | 2384 | ||
2394 | /* Cause software interrupt to ensure rx ring is cleaned */ | 2385 | /* Cause software interrupt to ensure rx ring is cleaned */ |
2395 | wr32(E1000_ICS, E1000_ICS_RXDMT0); | 2386 | if (adapter->msix_entries) { |
2387 | for (i = 0; i < adapter->num_rx_queues; i++) | ||
2388 | eics |= adapter->rx_ring[i].eims_value; | ||
2389 | wr32(E1000_EICS, eics); | ||
2390 | } else { | ||
2391 | wr32(E1000_ICS, E1000_ICS_RXDMT0); | ||
2392 | } | ||
2396 | 2393 | ||
2397 | /* Force detection of hung controller every watchdog period */ | 2394 | /* Force detection of hung controller every watchdog period */ |
2398 | tx_ring->detect_tx_hung = true; | 2395 | tx_ring->detect_tx_hung = true; |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 34bca16d48a6..a417be7f8be5 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -1636,16 +1636,17 @@ static void ixgbe_set_multi(struct net_device *netdev) | |||
1636 | struct ixgbe_hw *hw = &adapter->hw; | 1636 | struct ixgbe_hw *hw = &adapter->hw; |
1637 | struct dev_mc_list *mc_ptr; | 1637 | struct dev_mc_list *mc_ptr; |
1638 | u8 *mta_list; | 1638 | u8 *mta_list; |
1639 | u32 fctrl; | 1639 | u32 fctrl, vlnctrl; |
1640 | int i; | 1640 | int i; |
1641 | 1641 | ||
1642 | /* Check for Promiscuous and All Multicast modes */ | 1642 | /* Check for Promiscuous and All Multicast modes */ |
1643 | 1643 | ||
1644 | fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); | 1644 | fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL); |
1645 | vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL); | ||
1645 | 1646 | ||
1646 | if (netdev->flags & IFF_PROMISC) { | 1647 | if (netdev->flags & IFF_PROMISC) { |
1647 | fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); | 1648 | fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); |
1648 | fctrl &= ~IXGBE_VLNCTRL_VFE; | 1649 | vlnctrl &= ~IXGBE_VLNCTRL_VFE; |
1649 | } else { | 1650 | } else { |
1650 | if (netdev->flags & IFF_ALLMULTI) { | 1651 | if (netdev->flags & IFF_ALLMULTI) { |
1651 | fctrl |= IXGBE_FCTRL_MPE; | 1652 | fctrl |= IXGBE_FCTRL_MPE; |
@@ -1653,10 +1654,11 @@ static void ixgbe_set_multi(struct net_device *netdev) | |||
1653 | } else { | 1654 | } else { |
1654 | fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); | 1655 | fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE); |
1655 | } | 1656 | } |
1656 | fctrl |= IXGBE_VLNCTRL_VFE; | 1657 | vlnctrl |= IXGBE_VLNCTRL_VFE; |
1657 | } | 1658 | } |
1658 | 1659 | ||
1659 | IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl); | 1660 | IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl); |
1661 | IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); | ||
1660 | 1662 | ||
1661 | if (netdev->mc_count) { | 1663 | if (netdev->mc_count) { |
1662 | mta_list = kcalloc(netdev->mc_count, ETH_ALEN, GFP_ATOMIC); | 1664 | mta_list = kcalloc(netdev->mc_count, ETH_ALEN, GFP_ATOMIC); |
@@ -2302,6 +2304,12 @@ static int __devinit ixgbe_set_interrupt_capability(struct ixgbe_adapter | |||
2302 | int vector, v_budget; | 2304 | int vector, v_budget; |
2303 | 2305 | ||
2304 | /* | 2306 | /* |
2307 | * Set the default interrupt throttle rate. | ||
2308 | */ | ||
2309 | adapter->rx_eitr = (1000000 / IXGBE_DEFAULT_ITR_RX_USECS); | ||
2310 | adapter->tx_eitr = (1000000 / IXGBE_DEFAULT_ITR_TX_USECS); | ||
2311 | |||
2312 | /* | ||
2305 | * It's easy to be greedy for MSI-X vectors, but it really | 2313 | * It's easy to be greedy for MSI-X vectors, but it really |
2306 | * doesn't do us much good if we have a lot more vectors | 2314 | * doesn't do us much good if we have a lot more vectors |
2307 | * than CPU's. So let's be conservative and only ask for | 2315 | * than CPU's. So let's be conservative and only ask for |
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 46819af3b062..0a18b9e96da1 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #include <asm/system.h> | 55 | #include <asm/system.h> |
56 | 56 | ||
57 | static char mv643xx_eth_driver_name[] = "mv643xx_eth"; | 57 | static char mv643xx_eth_driver_name[] = "mv643xx_eth"; |
58 | static char mv643xx_eth_driver_version[] = "1.2"; | 58 | static char mv643xx_eth_driver_version[] = "1.3"; |
59 | 59 | ||
60 | #define MV643XX_ETH_CHECKSUM_OFFLOAD_TX | 60 | #define MV643XX_ETH_CHECKSUM_OFFLOAD_TX |
61 | #define MV643XX_ETH_NAPI | 61 | #define MV643XX_ETH_NAPI |
@@ -474,11 +474,19 @@ static void rxq_refill(struct rx_queue *rxq) | |||
474 | /* | 474 | /* |
475 | * Reserve 2+14 bytes for an ethernet header (the | 475 | * Reserve 2+14 bytes for an ethernet header (the |
476 | * hardware automatically prepends 2 bytes of dummy | 476 | * hardware automatically prepends 2 bytes of dummy |
477 | * data to each received packet), 4 bytes for a VLAN | 477 | * data to each received packet), 16 bytes for up to |
478 | * header, and 4 bytes for the trailing FCS -- 24 | 478 | * four VLAN tags, and 4 bytes for the trailing FCS |
479 | * bytes total. | 479 | * -- 36 bytes total. |
480 | */ | 480 | */ |
481 | skb_size = mp->dev->mtu + 24; | 481 | skb_size = mp->dev->mtu + 36; |
482 | |||
483 | /* | ||
484 | * Make sure that the skb size is a multiple of 8 | ||
485 | * bytes, as the lower three bits of the receive | ||
486 | * descriptor's buffer size field are ignored by | ||
487 | * the hardware. | ||
488 | */ | ||
489 | skb_size = (skb_size + 7) & ~7; | ||
482 | 490 | ||
483 | skb = dev_alloc_skb(skb_size + dma_get_cache_alignment() - 1); | 491 | skb = dev_alloc_skb(skb_size + dma_get_cache_alignment() - 1); |
484 | if (skb == NULL) | 492 | if (skb == NULL) |
@@ -509,10 +517,8 @@ static void rxq_refill(struct rx_queue *rxq) | |||
509 | skb_reserve(skb, 2); | 517 | skb_reserve(skb, 2); |
510 | } | 518 | } |
511 | 519 | ||
512 | if (rxq->rx_desc_count != rxq->rx_ring_size) { | 520 | if (rxq->rx_desc_count != rxq->rx_ring_size) |
513 | rxq->rx_oom.expires = jiffies + (HZ / 10); | 521 | mod_timer(&rxq->rx_oom, jiffies + (HZ / 10)); |
514 | add_timer(&rxq->rx_oom); | ||
515 | } | ||
516 | 522 | ||
517 | spin_unlock_irqrestore(&mp->lock, flags); | 523 | spin_unlock_irqrestore(&mp->lock, flags); |
518 | } | 524 | } |
@@ -529,7 +535,7 @@ static int rxq_process(struct rx_queue *rxq, int budget) | |||
529 | int rx; | 535 | int rx; |
530 | 536 | ||
531 | rx = 0; | 537 | rx = 0; |
532 | while (rx < budget) { | 538 | while (rx < budget && rxq->rx_desc_count) { |
533 | struct rx_desc *rx_desc; | 539 | struct rx_desc *rx_desc; |
534 | unsigned int cmd_sts; | 540 | unsigned int cmd_sts; |
535 | struct sk_buff *skb; | 541 | struct sk_buff *skb; |
@@ -554,7 +560,7 @@ static int rxq_process(struct rx_queue *rxq, int budget) | |||
554 | spin_unlock_irqrestore(&mp->lock, flags); | 560 | spin_unlock_irqrestore(&mp->lock, flags); |
555 | 561 | ||
556 | dma_unmap_single(NULL, rx_desc->buf_ptr + 2, | 562 | dma_unmap_single(NULL, rx_desc->buf_ptr + 2, |
557 | mp->dev->mtu + 24, DMA_FROM_DEVICE); | 563 | rx_desc->buf_size, DMA_FROM_DEVICE); |
558 | rxq->rx_desc_count--; | 564 | rxq->rx_desc_count--; |
559 | rx++; | 565 | rx++; |
560 | 566 | ||
@@ -636,9 +642,9 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget) | |||
636 | txq_reclaim(mp->txq + i, 0); | 642 | txq_reclaim(mp->txq + i, 0); |
637 | 643 | ||
638 | if (netif_carrier_ok(mp->dev)) { | 644 | if (netif_carrier_ok(mp->dev)) { |
639 | spin_lock(&mp->lock); | 645 | spin_lock_irq(&mp->lock); |
640 | __txq_maybe_wake(mp->txq + mp->txq_primary); | 646 | __txq_maybe_wake(mp->txq + mp->txq_primary); |
641 | spin_unlock(&mp->lock); | 647 | spin_unlock_irq(&mp->lock); |
642 | } | 648 | } |
643 | } | 649 | } |
644 | #endif | 650 | #endif |
@@ -650,8 +656,6 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget) | |||
650 | 656 | ||
651 | if (rx < budget) { | 657 | if (rx < budget) { |
652 | netif_rx_complete(mp->dev, napi); | 658 | netif_rx_complete(mp->dev, napi); |
653 | wrl(mp, INT_CAUSE(mp->port_num), 0); | ||
654 | wrl(mp, INT_CAUSE_EXT(mp->port_num), 0); | ||
655 | wrl(mp, INT_MASK(mp->port_num), INT_TX_END | INT_RX | INT_EXT); | 659 | wrl(mp, INT_MASK(mp->port_num), INT_TX_END | INT_RX | INT_EXT); |
656 | } | 660 | } |
657 | 661 | ||
@@ -1796,6 +1800,7 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id) | |||
1796 | */ | 1800 | */ |
1797 | #ifdef MV643XX_ETH_NAPI | 1801 | #ifdef MV643XX_ETH_NAPI |
1798 | if (int_cause & INT_RX) { | 1802 | if (int_cause & INT_RX) { |
1803 | wrl(mp, INT_CAUSE(mp->port_num), ~(int_cause & INT_RX)); | ||
1799 | wrl(mp, INT_MASK(mp->port_num), 0x00000000); | 1804 | wrl(mp, INT_MASK(mp->port_num), 0x00000000); |
1800 | rdl(mp, INT_MASK(mp->port_num)); | 1805 | rdl(mp, INT_MASK(mp->port_num)); |
1801 | 1806 | ||
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 54cd89cb0838..d6524db321af 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -75,7 +75,7 @@ | |||
75 | #include "myri10ge_mcp.h" | 75 | #include "myri10ge_mcp.h" |
76 | #include "myri10ge_mcp_gen_header.h" | 76 | #include "myri10ge_mcp_gen_header.h" |
77 | 77 | ||
78 | #define MYRI10GE_VERSION_STR "1.3.99-1.347" | 78 | #define MYRI10GE_VERSION_STR "1.4.3-1.358" |
79 | 79 | ||
80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); | 80 | MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); |
81 | MODULE_AUTHOR("Maintainer: help@myri.com"); | 81 | MODULE_AUTHOR("Maintainer: help@myri.com"); |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 32bb47adbe39..008fd6618a5f 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -359,16 +359,6 @@ static void netxen_pcie_strap_init(struct netxen_adapter *adapter) | |||
359 | int i, pos; | 359 | int i, pos; |
360 | struct pci_dev *pdev; | 360 | struct pci_dev *pdev; |
361 | 361 | ||
362 | pdev = pci_get_device(0x1166, 0x0140, NULL); | ||
363 | if (pdev) { | ||
364 | pci_dev_put(pdev); | ||
365 | adapter->hw_read_wx(adapter, | ||
366 | NETXEN_PCIE_REG(PCIE_TGT_SPLIT_CHICKEN), &chicken, 4); | ||
367 | chicken |= 0x4000; | ||
368 | adapter->hw_write_wx(adapter, | ||
369 | NETXEN_PCIE_REG(PCIE_TGT_SPLIT_CHICKEN), &chicken, 4); | ||
370 | } | ||
371 | |||
372 | pdev = adapter->pdev; | 362 | pdev = adapter->pdev; |
373 | 363 | ||
374 | adapter->hw_read_wx(adapter, | 364 | adapter->hw_read_wx(adapter, |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 3f682d49a4e6..52bf11b73c6e 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -784,6 +784,7 @@ static struct pcmcia_device_id axnet_ids[] = { | |||
784 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEther PCC-TXD", 0x5261440f, 0x436768c5), | 784 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEther PCC-TXD", 0x5261440f, 0x436768c5), |
785 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEtherII PCC-TXD", 0x5261440f, 0x730df72e), | 785 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEtherII PCC-TXD", 0x5261440f, 0x730df72e), |
786 | PCMCIA_DEVICE_PROD_ID12("Dynalink", "L100C16", 0x55632fd5, 0x66bc2a90), | 786 | PCMCIA_DEVICE_PROD_ID12("Dynalink", "L100C16", 0x55632fd5, 0x66bc2a90), |
787 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "ETXPCM", 0x547e66dc, 0x233adac2), | ||
787 | PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8), | 788 | PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8), |
788 | PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609), | 789 | PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609), |
789 | PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04), | 790 | PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04), |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 2d4c4ad89b8d..ebc1ae6bcbe5 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -1626,6 +1626,7 @@ static struct pcmcia_device_id pcnet_ids[] = { | |||
1626 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-TD", 0x5261440f, 0xc49bd73d), | 1626 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-TD", 0x5261440f, 0xc49bd73d), |
1627 | PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), | 1627 | PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), |
1628 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa), | 1628 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa), |
1629 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-TD", 0x5261440f, 0x47d5ca83), | ||
1629 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9), | 1630 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9), |
1630 | PCMCIA_DEVICE_PROD_ID12("Corega,K.K.", "Ethernet LAN Card", 0x110d26d9, 0x9fd2f0a2), | 1631 | PCMCIA_DEVICE_PROD_ID12("Corega,K.K.", "Ethernet LAN Card", 0x110d26d9, 0x9fd2f0a2), |
1631 | PCMCIA_DEVICE_PROD_ID12("corega,K.K.", "Ethernet LAN Card", 0x9791a90e, 0x9fd2f0a2), | 1632 | PCMCIA_DEVICE_PROD_ID12("corega,K.K.", "Ethernet LAN Card", 0x9791a90e, 0x9fd2f0a2), |
@@ -1737,7 +1738,6 @@ static struct pcmcia_device_id pcnet_ids[] = { | |||
1737 | PCMCIA_DEVICE_PROD_ID1("CyQ've 10 Base-T LAN CARD", 0x94faf360), | 1738 | PCMCIA_DEVICE_PROD_ID1("CyQ've 10 Base-T LAN CARD", 0x94faf360), |
1738 | PCMCIA_DEVICE_PROD_ID1("EP-210 PCMCIA LAN CARD.", 0x8850b4de), | 1739 | PCMCIA_DEVICE_PROD_ID1("EP-210 PCMCIA LAN CARD.", 0x8850b4de), |
1739 | PCMCIA_DEVICE_PROD_ID1("ETHER-C16", 0x06a8514f), | 1740 | PCMCIA_DEVICE_PROD_ID1("ETHER-C16", 0x06a8514f), |
1740 | PCMCIA_DEVICE_PROD_ID1("IC-CARD", 0x60cb09a6), | ||
1741 | PCMCIA_DEVICE_PROD_ID1("NE2000 Compatible", 0x75b8ad5a), | 1741 | PCMCIA_DEVICE_PROD_ID1("NE2000 Compatible", 0x75b8ad5a), |
1742 | PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), | 1742 | PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), |
1743 | /* too generic! */ | 1743 | /* too generic! */ |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index a3e3895e5032..0f6f9747d255 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -2792,7 +2792,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
2792 | pkt_size, PCI_DMA_FROMDEVICE); | 2792 | pkt_size, PCI_DMA_FROMDEVICE); |
2793 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 2793 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); |
2794 | } else { | 2794 | } else { |
2795 | pci_unmap_single(pdev, addr, pkt_size, | 2795 | pci_unmap_single(pdev, addr, tp->rx_buf_sz, |
2796 | PCI_DMA_FROMDEVICE); | 2796 | PCI_DMA_FROMDEVICE); |
2797 | tp->Rx_skbuff[entry] = NULL; | 2797 | tp->Rx_skbuff[entry] = NULL; |
2798 | } | 2798 | } |
diff --git a/drivers/net/skfp/ess.c b/drivers/net/skfp/ess.c index 889f98724610..a85efcfd9d0e 100644 --- a/drivers/net/skfp/ess.c +++ b/drivers/net/skfp/ess.c | |||
@@ -510,7 +510,7 @@ static void ess_send_response(struct s_smc *smc, struct smt_header *sm, | |||
510 | chg->path.para.p_type = SMT_P320B ; | 510 | chg->path.para.p_type = SMT_P320B ; |
511 | chg->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; | 511 | chg->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; |
512 | chg->path.mib_index = SBAPATHINDEX ; | 512 | chg->path.mib_index = SBAPATHINDEX ; |
513 | chg->path.path_pad = (u_short)NULL ; | 513 | chg->path.path_pad = 0; |
514 | chg->path.path_index = PRIMARY_RING ; | 514 | chg->path.path_index = PRIMARY_RING ; |
515 | 515 | ||
516 | /* set P320F */ | 516 | /* set P320F */ |
@@ -606,7 +606,7 @@ static void ess_send_alc_req(struct s_smc *smc) | |||
606 | req->path.para.p_type = SMT_P320B ; | 606 | req->path.para.p_type = SMT_P320B ; |
607 | req->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; | 607 | req->path.para.p_len = sizeof(struct smt_p_320b) - PARA_LEN ; |
608 | req->path.mib_index = SBAPATHINDEX ; | 608 | req->path.mib_index = SBAPATHINDEX ; |
609 | req->path.path_pad = (u_short)NULL ; | 609 | req->path.path_pad = 0; |
610 | req->path.path_index = PRIMARY_RING ; | 610 | req->path.path_index = PRIMARY_RING ; |
611 | 611 | ||
612 | /* set P0017 */ | 612 | /* set P0017 */ |
@@ -636,7 +636,7 @@ static void ess_send_alc_req(struct s_smc *smc) | |||
636 | /* set P19 */ | 636 | /* set P19 */ |
637 | req->a_addr.para.p_type = SMT_P0019 ; | 637 | req->a_addr.para.p_type = SMT_P0019 ; |
638 | req->a_addr.para.p_len = sizeof(struct smt_p_0019) - PARA_LEN ; | 638 | req->a_addr.para.p_len = sizeof(struct smt_p_0019) - PARA_LEN ; |
639 | req->a_addr.sba_pad = (u_short)NULL ; | 639 | req->a_addr.sba_pad = 0; |
640 | req->a_addr.alloc_addr = null_addr ; | 640 | req->a_addr.alloc_addr = null_addr ; |
641 | 641 | ||
642 | /* set P1A */ | 642 | /* set P1A */ |
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index 2040965d7724..e332a518efe8 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -1520,7 +1520,9 @@ smc_open(struct net_device *dev) | |||
1520 | /* Setup the default Register Modes */ | 1520 | /* Setup the default Register Modes */ |
1521 | lp->tcr_cur_mode = TCR_DEFAULT; | 1521 | lp->tcr_cur_mode = TCR_DEFAULT; |
1522 | lp->rcr_cur_mode = RCR_DEFAULT; | 1522 | lp->rcr_cur_mode = RCR_DEFAULT; |
1523 | lp->rpc_cur_mode = RPC_DEFAULT; | 1523 | lp->rpc_cur_mode = RPC_DEFAULT | |
1524 | lp->cfg.leda << RPC_LSXA_SHFT | | ||
1525 | lp->cfg.ledb << RPC_LSXB_SHFT; | ||
1524 | 1526 | ||
1525 | /* | 1527 | /* |
1526 | * If we are not using a MII interface, we need to | 1528 | * If we are not using a MII interface, we need to |
@@ -2157,6 +2159,11 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
2157 | lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0; | 2159 | lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0; |
2158 | } | 2160 | } |
2159 | 2161 | ||
2162 | if (!lp->cfg.leda && !lp->cfg.ledb) { | ||
2163 | lp->cfg.leda = RPC_LSA_DEFAULT; | ||
2164 | lp->cfg.ledb = RPC_LSB_DEFAULT; | ||
2165 | } | ||
2166 | |||
2160 | ndev->dma = (unsigned char)-1; | 2167 | ndev->dma = (unsigned char)-1; |
2161 | 2168 | ||
2162 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); | 2169 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); |
@@ -2255,7 +2262,7 @@ static int smc_drv_remove(struct platform_device *pdev) | |||
2255 | 2262 | ||
2256 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); | 2263 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); |
2257 | if (!res) | 2264 | if (!res) |
2258 | platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2265 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2259 | release_mem_region(res->start, SMC_IO_EXTENT); | 2266 | release_mem_region(res->start, SMC_IO_EXTENT); |
2260 | 2267 | ||
2261 | free_netdev(ndev); | 2268 | free_netdev(ndev); |
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index 997e7f1d5c6e..160873f0a817 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h | |||
@@ -43,7 +43,8 @@ | |||
43 | #if defined(CONFIG_ARCH_LUBBOCK) ||\ | 43 | #if defined(CONFIG_ARCH_LUBBOCK) ||\ |
44 | defined(CONFIG_MACH_MAINSTONE) ||\ | 44 | defined(CONFIG_MACH_MAINSTONE) ||\ |
45 | defined(CONFIG_MACH_ZYLONITE) ||\ | 45 | defined(CONFIG_MACH_ZYLONITE) ||\ |
46 | defined(CONFIG_MACH_LITTLETON) | 46 | defined(CONFIG_MACH_LITTLETON) ||\ |
47 | defined(CONFIG_ARCH_VIPER) | ||
47 | 48 | ||
48 | #include <asm/mach-types.h> | 49 | #include <asm/mach-types.h> |
49 | 50 | ||
@@ -778,14 +779,6 @@ smc_pxa_dma_irq(int dma, void *dummy) | |||
778 | #define RPC_ANEG 0x0800 // When 1 PHY is in Auto-Negotiate Mode | 779 | #define RPC_ANEG 0x0800 // When 1 PHY is in Auto-Negotiate Mode |
779 | #define RPC_LSXA_SHFT 5 // Bits to shift LS2A,LS1A,LS0A to lsb | 780 | #define RPC_LSXA_SHFT 5 // Bits to shift LS2A,LS1A,LS0A to lsb |
780 | #define RPC_LSXB_SHFT 2 // Bits to get LS2B,LS1B,LS0B to lsb | 781 | #define RPC_LSXB_SHFT 2 // Bits to get LS2B,LS1B,LS0B to lsb |
781 | #define RPC_LED_100_10 (0x00) // LED = 100Mbps OR's with 10Mbps link detect | ||
782 | #define RPC_LED_RES (0x01) // LED = Reserved | ||
783 | #define RPC_LED_10 (0x02) // LED = 10Mbps link detect | ||
784 | #define RPC_LED_FD (0x03) // LED = Full Duplex Mode | ||
785 | #define RPC_LED_TX_RX (0x04) // LED = TX or RX packet occurred | ||
786 | #define RPC_LED_100 (0x05) // LED = 100Mbps link dectect | ||
787 | #define RPC_LED_TX (0x06) // LED = TX packet occurred | ||
788 | #define RPC_LED_RX (0x07) // LED = RX packet occurred | ||
789 | 782 | ||
790 | #ifndef RPC_LSA_DEFAULT | 783 | #ifndef RPC_LSA_DEFAULT |
791 | #define RPC_LSA_DEFAULT RPC_LED_100 | 784 | #define RPC_LSA_DEFAULT RPC_LED_100 |
@@ -794,7 +787,7 @@ smc_pxa_dma_irq(int dma, void *dummy) | |||
794 | #define RPC_LSB_DEFAULT RPC_LED_FD | 787 | #define RPC_LSB_DEFAULT RPC_LED_FD |
795 | #endif | 788 | #endif |
796 | 789 | ||
797 | #define RPC_DEFAULT (RPC_ANEG | (RPC_LSA_DEFAULT << RPC_LSXA_SHFT) | (RPC_LSB_DEFAULT << RPC_LSXB_SHFT) | RPC_SPEED | RPC_DPLX) | 790 | #define RPC_DEFAULT (RPC_ANEG | RPC_SPEED | RPC_DPLX) |
798 | 791 | ||
799 | 792 | ||
800 | /* Bank 0 0x0C is reserved */ | 793 | /* Bank 0 0x0C is reserved */ |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 1b7cac77159e..6e42b5a8c22b 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -397,7 +397,7 @@ static const struct usb_device_id hso_ids[] = { | |||
397 | {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */ | 397 | {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */ |
398 | {icon321_port_device(0x0af0, 0xd013)}, /* Module HSxPA */ | 398 | {icon321_port_device(0x0af0, 0xd013)}, /* Module HSxPA */ |
399 | {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */ | 399 | {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */ |
400 | {default_port_device(0x0af0, 0xd033)}, /* Icon-322 */ | 400 | {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */ |
401 | {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ | 401 | {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ |
402 | {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ | 402 | {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ |
403 | {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ | 403 | {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ |
@@ -2613,6 +2613,7 @@ static int hso_resume(struct usb_interface *iface) | |||
2613 | "Transmitting lingering data\n"); | 2613 | "Transmitting lingering data\n"); |
2614 | hso_net_start_xmit(hso_net->skb_tx_buf, | 2614 | hso_net_start_xmit(hso_net->skb_tx_buf, |
2615 | hso_net->net); | 2615 | hso_net->net); |
2616 | hso_net->skb_tx_buf = NULL; | ||
2616 | } | 2617 | } |
2617 | result = hso_start_net_device(network_table[i]); | 2618 | result = hso_start_net_device(network_table[i]); |
2618 | if (result) | 2619 | if (result) |
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c index c3d119f997f5..ca9d00c1194e 100644 --- a/drivers/net/usb/mcs7830.c +++ b/drivers/net/usb/mcs7830.c | |||
@@ -46,6 +46,10 @@ | |||
46 | 46 | ||
47 | #define MCS7830_VENDOR_ID 0x9710 | 47 | #define MCS7830_VENDOR_ID 0x9710 |
48 | #define MCS7830_PRODUCT_ID 0x7830 | 48 | #define MCS7830_PRODUCT_ID 0x7830 |
49 | #define MCS7730_PRODUCT_ID 0x7730 | ||
50 | |||
51 | #define SITECOM_VENDOR_ID 0x0DF6 | ||
52 | #define LN_030_PRODUCT_ID 0x0021 | ||
49 | 53 | ||
50 | #define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \ | 54 | #define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \ |
51 | ADVERTISE_100HALF | ADVERTISE_10FULL | \ | 55 | ADVERTISE_100HALF | ADVERTISE_10FULL | \ |
@@ -442,6 +446,29 @@ static struct ethtool_ops mcs7830_ethtool_ops = { | |||
442 | .nway_reset = usbnet_nway_reset, | 446 | .nway_reset = usbnet_nway_reset, |
443 | }; | 447 | }; |
444 | 448 | ||
449 | static int mcs7830_set_mac_address(struct net_device *netdev, void *p) | ||
450 | { | ||
451 | int ret; | ||
452 | struct usbnet *dev = netdev_priv(netdev); | ||
453 | struct sockaddr *addr = p; | ||
454 | |||
455 | if (netif_running(netdev)) | ||
456 | return -EBUSY; | ||
457 | |||
458 | if (!is_valid_ether_addr(addr->sa_data)) | ||
459 | return -EINVAL; | ||
460 | |||
461 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | ||
462 | |||
463 | ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, | ||
464 | netdev->dev_addr); | ||
465 | |||
466 | if (ret < 0) | ||
467 | return ret; | ||
468 | |||
469 | return 0; | ||
470 | } | ||
471 | |||
445 | static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) | 472 | static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) |
446 | { | 473 | { |
447 | struct net_device *net = dev->net; | 474 | struct net_device *net = dev->net; |
@@ -455,6 +482,7 @@ static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) | |||
455 | net->ethtool_ops = &mcs7830_ethtool_ops; | 482 | net->ethtool_ops = &mcs7830_ethtool_ops; |
456 | net->set_multicast_list = mcs7830_set_multicast; | 483 | net->set_multicast_list = mcs7830_set_multicast; |
457 | mcs7830_set_multicast(net); | 484 | mcs7830_set_multicast(net); |
485 | net->set_mac_address = mcs7830_set_mac_address; | ||
458 | 486 | ||
459 | /* reserve space for the status byte on rx */ | 487 | /* reserve space for the status byte on rx */ |
460 | dev->rx_urb_size = ETH_FRAME_LEN + 1; | 488 | dev->rx_urb_size = ETH_FRAME_LEN + 1; |
@@ -491,7 +519,16 @@ static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb) | |||
491 | } | 519 | } |
492 | 520 | ||
493 | static const struct driver_info moschip_info = { | 521 | static const struct driver_info moschip_info = { |
494 | .description = "MOSCHIP 7830 usb-NET adapter", | 522 | .description = "MOSCHIP 7830/7730 usb-NET adapter", |
523 | .bind = mcs7830_bind, | ||
524 | .rx_fixup = mcs7830_rx_fixup, | ||
525 | .flags = FLAG_ETHER, | ||
526 | .in = 1, | ||
527 | .out = 2, | ||
528 | }; | ||
529 | |||
530 | static const struct driver_info sitecom_info = { | ||
531 | .description = "Sitecom LN-30 usb-NET adapter", | ||
495 | .bind = mcs7830_bind, | 532 | .bind = mcs7830_bind, |
496 | .rx_fixup = mcs7830_rx_fixup, | 533 | .rx_fixup = mcs7830_rx_fixup, |
497 | .flags = FLAG_ETHER, | 534 | .flags = FLAG_ETHER, |
@@ -504,6 +541,14 @@ static const struct usb_device_id products[] = { | |||
504 | USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID), | 541 | USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID), |
505 | .driver_info = (unsigned long) &moschip_info, | 542 | .driver_info = (unsigned long) &moschip_info, |
506 | }, | 543 | }, |
544 | { | ||
545 | USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID), | ||
546 | .driver_info = (unsigned long) &moschip_info, | ||
547 | }, | ||
548 | { | ||
549 | USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID), | ||
550 | .driver_info = (unsigned long) &sitecom_info, | ||
551 | }, | ||
507 | {}, | 552 | {}, |
508 | }; | 553 | }; |
509 | MODULE_DEVICE_TABLE(usb, products); | 554 | MODULE_DEVICE_TABLE(usb, products); |
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index a84ba487c713..8c19307e5040 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c | |||
@@ -117,7 +117,7 @@ static void ctrl_callback(struct urb *urb) | |||
117 | case -ENOENT: | 117 | case -ENOENT: |
118 | break; | 118 | break; |
119 | default: | 119 | default: |
120 | if (netif_msg_drv(pegasus)) | 120 | if (netif_msg_drv(pegasus) && printk_ratelimit()) |
121 | dev_dbg(&pegasus->intf->dev, "%s, status %d\n", | 121 | dev_dbg(&pegasus->intf->dev, "%s, status %d\n", |
122 | __FUNCTION__, urb->status); | 122 | __FUNCTION__, urb->status); |
123 | } | 123 | } |
@@ -166,7 +166,7 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size, | |||
166 | set_current_state(TASK_RUNNING); | 166 | set_current_state(TASK_RUNNING); |
167 | if (ret == -ENODEV) | 167 | if (ret == -ENODEV) |
168 | netif_device_detach(pegasus->net); | 168 | netif_device_detach(pegasus->net); |
169 | if (netif_msg_drv(pegasus)) | 169 | if (netif_msg_drv(pegasus) && printk_ratelimit()) |
170 | dev_err(&pegasus->intf->dev, "%s, status %d\n", | 170 | dev_err(&pegasus->intf->dev, "%s, status %d\n", |
171 | __FUNCTION__, ret); | 171 | __FUNCTION__, ret); |
172 | goto out; | 172 | goto out; |
@@ -275,7 +275,7 @@ static int set_register(pegasus_t * pegasus, __u16 indx, __u8 data) | |||
275 | if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { | 275 | if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { |
276 | if (ret == -ENODEV) | 276 | if (ret == -ENODEV) |
277 | netif_device_detach(pegasus->net); | 277 | netif_device_detach(pegasus->net); |
278 | if (netif_msg_drv(pegasus)) | 278 | if (netif_msg_drv(pegasus) && printk_ratelimit()) |
279 | dev_err(&pegasus->intf->dev, "%s, status %d\n", | 279 | dev_err(&pegasus->intf->dev, "%s, status %d\n", |
280 | __FUNCTION__, ret); | 280 | __FUNCTION__, ret); |
281 | goto out; | 281 | goto out; |
@@ -1209,8 +1209,7 @@ static void pegasus_set_multicast(struct net_device *net) | |||
1209 | pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS; | 1209 | pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS; |
1210 | if (netif_msg_link(pegasus)) | 1210 | if (netif_msg_link(pegasus)) |
1211 | pr_info("%s: Promiscuous mode enabled.\n", net->name); | 1211 | pr_info("%s: Promiscuous mode enabled.\n", net->name); |
1212 | } else if (net->mc_count || | 1212 | } else if (net->mc_count || (net->flags & IFF_ALLMULTI)) { |
1213 | (net->flags & IFF_ALLMULTI)) { | ||
1214 | pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST; | 1213 | pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST; |
1215 | pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; | 1214 | pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; |
1216 | if (netif_msg_link(pegasus)) | 1215 | if (netif_msg_link(pegasus)) |
@@ -1220,6 +1219,8 @@ static void pegasus_set_multicast(struct net_device *net) | |||
1220 | pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; | 1219 | pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; |
1221 | } | 1220 | } |
1222 | 1221 | ||
1222 | pegasus->ctrl_urb->status = 0; | ||
1223 | |||
1223 | pegasus->flags |= ETH_REGS_CHANGE; | 1224 | pegasus->flags |= ETH_REGS_CHANGE; |
1224 | ctrl_callback(pegasus->ctrl_urb); | 1225 | ctrl_callback(pegasus->ctrl_urb); |
1225 | } | 1226 | } |
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c index e59255a155a9..6596cd0742b9 100644 --- a/drivers/net/wan/sbni.c +++ b/drivers/net/wan/sbni.c | |||
@@ -1317,7 +1317,7 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) | |||
1317 | break; | 1317 | break; |
1318 | 1318 | ||
1319 | case SIOCDEVRESINSTATS : | 1319 | case SIOCDEVRESINSTATS : |
1320 | if( current->euid != 0 ) /* root only */ | 1320 | if (!capable(CAP_NET_ADMIN)) |
1321 | return -EPERM; | 1321 | return -EPERM; |
1322 | memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); | 1322 | memset( &nl->in_stats, 0, sizeof(struct sbni_in_stats) ); |
1323 | break; | 1323 | break; |
@@ -1334,7 +1334,7 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) | |||
1334 | break; | 1334 | break; |
1335 | 1335 | ||
1336 | case SIOCDEVSHWSTATE : | 1336 | case SIOCDEVSHWSTATE : |
1337 | if( current->euid != 0 ) /* root only */ | 1337 | if (!capable(CAP_NET_ADMIN)) |
1338 | return -EPERM; | 1338 | return -EPERM; |
1339 | 1339 | ||
1340 | spin_lock( &nl->lock ); | 1340 | spin_lock( &nl->lock ); |
@@ -1355,7 +1355,7 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) | |||
1355 | #ifdef CONFIG_SBNI_MULTILINE | 1355 | #ifdef CONFIG_SBNI_MULTILINE |
1356 | 1356 | ||
1357 | case SIOCDEVENSLAVE : | 1357 | case SIOCDEVENSLAVE : |
1358 | if( current->euid != 0 ) /* root only */ | 1358 | if (!capable(CAP_NET_ADMIN)) |
1359 | return -EPERM; | 1359 | return -EPERM; |
1360 | 1360 | ||
1361 | if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) | 1361 | if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) |
@@ -1370,7 +1370,7 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) | |||
1370 | return enslave( dev, slave_dev ); | 1370 | return enslave( dev, slave_dev ); |
1371 | 1371 | ||
1372 | case SIOCDEVEMANSIPATE : | 1372 | case SIOCDEVEMANSIPATE : |
1373 | if( current->euid != 0 ) /* root only */ | 1373 | if (!capable(CAP_NET_ADMIN)) |
1374 | return -EPERM; | 1374 | return -EPERM; |
1375 | 1375 | ||
1376 | return emancipate( dev ); | 1376 | return emancipate( dev ); |
diff --git a/drivers/net/wd.c b/drivers/net/wd.c index 6f9aa1643743..fa14255282af 100644 --- a/drivers/net/wd.c +++ b/drivers/net/wd.c | |||
@@ -337,7 +337,7 @@ static int __init wd_probe1(struct net_device *dev, int ioaddr) | |||
337 | #ifdef CONFIG_NET_POLL_CONTROLLER | 337 | #ifdef CONFIG_NET_POLL_CONTROLLER |
338 | dev->poll_controller = ei_poll; | 338 | dev->poll_controller = ei_poll; |
339 | #endif | 339 | #endif |
340 | NS8390p_init(dev, 0); | 340 | NS8390_init(dev, 0); |
341 | 341 | ||
342 | #if 1 | 342 | #if 1 |
343 | /* Enable interrupt generation on softconfig cards -- M.U */ | 343 | /* Enable interrupt generation on softconfig cards -- M.U */ |
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index b20a45aa8680..0676c6d84383 100644 --- a/drivers/net/wireless/ath5k/base.c +++ b/drivers/net/wireless/ath5k/base.c | |||
@@ -251,7 +251,7 @@ static inline void ath5k_txbuf_free(struct ath5k_softc *sc, | |||
251 | return; | 251 | return; |
252 | pci_unmap_single(sc->pdev, bf->skbaddr, bf->skb->len, | 252 | pci_unmap_single(sc->pdev, bf->skbaddr, bf->skb->len, |
253 | PCI_DMA_TODEVICE); | 253 | PCI_DMA_TODEVICE); |
254 | dev_kfree_skb(bf->skb); | 254 | dev_kfree_skb_any(bf->skb); |
255 | bf->skb = NULL; | 255 | bf->skb = NULL; |
256 | } | 256 | } |
257 | 257 | ||
@@ -466,6 +466,7 @@ ath5k_pci_probe(struct pci_dev *pdev, | |||
466 | mutex_init(&sc->lock); | 466 | mutex_init(&sc->lock); |
467 | spin_lock_init(&sc->rxbuflock); | 467 | spin_lock_init(&sc->rxbuflock); |
468 | spin_lock_init(&sc->txbuflock); | 468 | spin_lock_init(&sc->txbuflock); |
469 | spin_lock_init(&sc->block); | ||
469 | 470 | ||
470 | /* Set private data */ | 471 | /* Set private data */ |
471 | pci_set_drvdata(pdev, hw); | 472 | pci_set_drvdata(pdev, hw); |
@@ -2179,8 +2180,11 @@ ath5k_beacon_config(struct ath5k_softc *sc) | |||
2179 | 2180 | ||
2180 | sc->imask |= AR5K_INT_SWBA; | 2181 | sc->imask |= AR5K_INT_SWBA; |
2181 | 2182 | ||
2182 | if (ath5k_hw_hasveol(ah)) | 2183 | if (ath5k_hw_hasveol(ah)) { |
2184 | spin_lock(&sc->block); | ||
2183 | ath5k_beacon_send(sc); | 2185 | ath5k_beacon_send(sc); |
2186 | spin_unlock(&sc->block); | ||
2187 | } | ||
2184 | } | 2188 | } |
2185 | /* TODO else AP */ | 2189 | /* TODO else AP */ |
2186 | 2190 | ||
@@ -2403,7 +2407,9 @@ ath5k_intr(int irq, void *dev_id) | |||
2403 | TSF_TO_TU(tsf), | 2407 | TSF_TO_TU(tsf), |
2404 | (unsigned long long) tsf); | 2408 | (unsigned long long) tsf); |
2405 | } else { | 2409 | } else { |
2410 | spin_lock(&sc->block); | ||
2406 | ath5k_beacon_send(sc); | 2411 | ath5k_beacon_send(sc); |
2412 | spin_unlock(&sc->block); | ||
2407 | } | 2413 | } |
2408 | } | 2414 | } |
2409 | if (status & AR5K_INT_RXEOL) { | 2415 | if (status & AR5K_INT_RXEOL) { |
@@ -2745,6 +2751,11 @@ static int ath5k_add_interface(struct ieee80211_hw *hw, | |||
2745 | ret = -EOPNOTSUPP; | 2751 | ret = -EOPNOTSUPP; |
2746 | goto end; | 2752 | goto end; |
2747 | } | 2753 | } |
2754 | |||
2755 | /* Set to a reasonable value. Note that this will | ||
2756 | * be set to mac80211's value at ath5k_config(). */ | ||
2757 | sc->bintval = 1000; | ||
2758 | |||
2748 | ret = 0; | 2759 | ret = 0; |
2749 | end: | 2760 | end: |
2750 | mutex_unlock(&sc->lock); | 2761 | mutex_unlock(&sc->lock); |
@@ -2789,9 +2800,6 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
2789 | struct ath5k_hw *ah = sc->ah; | 2800 | struct ath5k_hw *ah = sc->ah; |
2790 | int ret; | 2801 | int ret; |
2791 | 2802 | ||
2792 | /* Set to a reasonable value. Note that this will | ||
2793 | * be set to mac80211's value at ath5k_config(). */ | ||
2794 | sc->bintval = 1000; | ||
2795 | mutex_lock(&sc->lock); | 2803 | mutex_lock(&sc->lock); |
2796 | if (sc->vif != vif) { | 2804 | if (sc->vif != vif) { |
2797 | ret = -EIO; | 2805 | ret = -EIO; |
@@ -3050,6 +3058,7 @@ static int | |||
3050 | ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) | 3058 | ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) |
3051 | { | 3059 | { |
3052 | struct ath5k_softc *sc = hw->priv; | 3060 | struct ath5k_softc *sc = hw->priv; |
3061 | unsigned long flags; | ||
3053 | int ret; | 3062 | int ret; |
3054 | 3063 | ||
3055 | ath5k_debug_dump_skb(sc, skb, "BC ", 1); | 3064 | ath5k_debug_dump_skb(sc, skb, "BC ", 1); |
@@ -3059,12 +3068,14 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
3059 | goto end; | 3068 | goto end; |
3060 | } | 3069 | } |
3061 | 3070 | ||
3071 | spin_lock_irqsave(&sc->block, flags); | ||
3062 | ath5k_txbuf_free(sc, sc->bbuf); | 3072 | ath5k_txbuf_free(sc, sc->bbuf); |
3063 | sc->bbuf->skb = skb; | 3073 | sc->bbuf->skb = skb; |
3064 | ret = ath5k_beacon_setup(sc, sc->bbuf); | 3074 | ret = ath5k_beacon_setup(sc, sc->bbuf); |
3065 | if (ret) | 3075 | if (ret) |
3066 | sc->bbuf->skb = NULL; | 3076 | sc->bbuf->skb = NULL; |
3067 | else { | 3077 | spin_unlock_irqrestore(&sc->block, flags); |
3078 | if (!ret) { | ||
3068 | ath5k_beacon_config(sc); | 3079 | ath5k_beacon_config(sc); |
3069 | mmiowb(); | 3080 | mmiowb(); |
3070 | } | 3081 | } |
diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h index d7e03e6b8271..7ec2f377d5c7 100644 --- a/drivers/net/wireless/ath5k/base.h +++ b/drivers/net/wireless/ath5k/base.h | |||
@@ -172,6 +172,7 @@ struct ath5k_softc { | |||
172 | struct tasklet_struct txtq; /* tx intr tasklet */ | 172 | struct tasklet_struct txtq; /* tx intr tasklet */ |
173 | struct ath5k_led tx_led; /* tx led */ | 173 | struct ath5k_led tx_led; /* tx led */ |
174 | 174 | ||
175 | spinlock_t block; /* protects beacon */ | ||
175 | struct ath5k_buf *bbuf; /* beacon buffer */ | 176 | struct ath5k_buf *bbuf; /* beacon buffer */ |
176 | unsigned int bhalq, /* SW q for outgoing beacons */ | 177 | unsigned int bhalq, /* SW q for outgoing beacons */ |
177 | bmisscount, /* missed beacon transmits */ | 178 | bmisscount, /* missed beacon transmits */ |
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c index a17eb130f574..6dbfed0b4149 100644 --- a/drivers/net/wireless/ath9k/hw.c +++ b/drivers/net/wireless/ath9k/hw.c | |||
@@ -7285,15 +7285,15 @@ ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry, | |||
7285 | } | 7285 | } |
7286 | break; | 7286 | break; |
7287 | case ATH9K_CIPHER_WEP: | 7287 | case ATH9K_CIPHER_WEP: |
7288 | if (k->kv_len < 40 / NBBY) { | 7288 | if (k->kv_len < LEN_WEP40) { |
7289 | DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, | 7289 | DPRINTF(ah->ah_sc, ATH_DBG_KEYCACHE, |
7290 | "%s: WEP key length %u too small\n", | 7290 | "%s: WEP key length %u too small\n", |
7291 | __func__, k->kv_len); | 7291 | __func__, k->kv_len); |
7292 | return false; | 7292 | return false; |
7293 | } | 7293 | } |
7294 | if (k->kv_len <= 40 / NBBY) | 7294 | if (k->kv_len <= LEN_WEP40) |
7295 | keyType = AR_KEYTABLE_TYPE_40; | 7295 | keyType = AR_KEYTABLE_TYPE_40; |
7296 | else if (k->kv_len <= 104 / NBBY) | 7296 | else if (k->kv_len <= LEN_WEP104) |
7297 | keyType = AR_KEYTABLE_TYPE_104; | 7297 | keyType = AR_KEYTABLE_TYPE_104; |
7298 | else | 7298 | else |
7299 | keyType = AR_KEYTABLE_TYPE_128; | 7299 | keyType = AR_KEYTABLE_TYPE_128; |
@@ -7313,7 +7313,7 @@ ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry, | |||
7313 | key2 = get_unaligned_le32(k->kv_val + 6) ^ xorMask; | 7313 | key2 = get_unaligned_le32(k->kv_val + 6) ^ xorMask; |
7314 | key3 = (get_unaligned_le16(k->kv_val + 10) ^ xorMask) & 0xffff; | 7314 | key3 = (get_unaligned_le16(k->kv_val + 10) ^ xorMask) & 0xffff; |
7315 | key4 = get_unaligned_le32(k->kv_val + 12) ^ xorMask; | 7315 | key4 = get_unaligned_le32(k->kv_val + 12) ^ xorMask; |
7316 | if (k->kv_len <= 104 / NBBY) | 7316 | if (k->kv_len <= LEN_WEP104) |
7317 | key4 &= 0xff; | 7317 | key4 &= 0xff; |
7318 | 7318 | ||
7319 | if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { | 7319 | if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) { |
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c index 2888778040e4..c5107f269f24 100644 --- a/drivers/net/wireless/ath9k/main.c +++ b/drivers/net/wireless/ath9k/main.c | |||
@@ -206,7 +206,8 @@ static int ath_key_config(struct ath_softc *sc, | |||
206 | if (!ret) | 206 | if (!ret) |
207 | return -EIO; | 207 | return -EIO; |
208 | 208 | ||
209 | sc->sc_keytype = hk.kv_type; | 209 | if (mac) |
210 | sc->sc_keytype = hk.kv_type; | ||
210 | return 0; | 211 | return 0; |
211 | } | 212 | } |
212 | 213 | ||
@@ -756,7 +757,8 @@ static int ath9k_set_key(struct ieee80211_hw *hw, | |||
756 | key->hw_key_idx = key->keyidx; | 757 | key->hw_key_idx = key->keyidx; |
757 | /* push IV and Michael MIC generation to stack */ | 758 | /* push IV and Michael MIC generation to stack */ |
758 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | 759 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
759 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | 760 | if (key->alg == ALG_TKIP) |
761 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | ||
760 | } | 762 | } |
761 | break; | 763 | break; |
762 | case DISABLE_KEY: | 764 | case DISABLE_KEY: |
@@ -1065,8 +1067,16 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, | |||
1065 | tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; | 1067 | tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; |
1066 | tx_status->flags &= ~ATH_TX_BAR; | 1068 | tx_status->flags &= ~ATH_TX_BAR; |
1067 | } | 1069 | } |
1068 | if (tx_status->flags) | 1070 | |
1069 | tx_info->status.excessive_retries = 1; | 1071 | if (tx_status->flags & (ATH_TX_ERROR | ATH_TX_XRETRY)) { |
1072 | if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK)) { | ||
1073 | /* Frame was not ACKed, but an ACK was expected */ | ||
1074 | tx_info->status.excessive_retries = 1; | ||
1075 | } | ||
1076 | } else { | ||
1077 | /* Frame was ACKed */ | ||
1078 | tx_info->flags |= IEEE80211_TX_STAT_ACK; | ||
1079 | } | ||
1070 | 1080 | ||
1071 | tx_info->status.retry_count = tx_status->retries; | 1081 | tx_info->status.retry_count = tx_status->retries; |
1072 | 1082 | ||
diff --git a/drivers/net/wireless/ath9k/recv.c b/drivers/net/wireless/ath9k/recv.c index 2fe806175c01..20ddb7acdb94 100644 --- a/drivers/net/wireless/ath9k/recv.c +++ b/drivers/net/wireless/ath9k/recv.c | |||
@@ -360,8 +360,9 @@ static void ath_rx_flush_tid(struct ath_softc *sc, | |||
360 | struct ath_arx_tid *rxtid, int drop) | 360 | struct ath_arx_tid *rxtid, int drop) |
361 | { | 361 | { |
362 | struct ath_rxbuf *rxbuf; | 362 | struct ath_rxbuf *rxbuf; |
363 | unsigned long flag; | ||
363 | 364 | ||
364 | spin_lock_bh(&rxtid->tidlock); | 365 | spin_lock_irqsave(&rxtid->tidlock, flag); |
365 | while (rxtid->baw_head != rxtid->baw_tail) { | 366 | while (rxtid->baw_head != rxtid->baw_tail) { |
366 | rxbuf = rxtid->rxbuf + rxtid->baw_head; | 367 | rxbuf = rxtid->rxbuf + rxtid->baw_head; |
367 | if (!rxbuf->rx_wbuf) { | 368 | if (!rxbuf->rx_wbuf) { |
@@ -382,7 +383,7 @@ static void ath_rx_flush_tid(struct ath_softc *sc, | |||
382 | INCR(rxtid->baw_head, ATH_TID_MAX_BUFS); | 383 | INCR(rxtid->baw_head, ATH_TID_MAX_BUFS); |
383 | INCR(rxtid->seq_next, IEEE80211_SEQ_MAX); | 384 | INCR(rxtid->seq_next, IEEE80211_SEQ_MAX); |
384 | } | 385 | } |
385 | spin_unlock_bh(&rxtid->tidlock); | 386 | spin_unlock_irqrestore(&rxtid->tidlock, flag); |
386 | } | 387 | } |
387 | 388 | ||
388 | static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc, | 389 | static struct sk_buff *ath_rxbuf_alloc(struct ath_softc *sc, |
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c index 157f830ee6b8..550129f717e2 100644 --- a/drivers/net/wireless/ath9k/xmit.c +++ b/drivers/net/wireless/ath9k/xmit.c | |||
@@ -357,9 +357,9 @@ static int ath_tx_prepare(struct ath_softc *sc, | |||
357 | txctl->flags = ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */ | 357 | txctl->flags = ATH9K_TXDESC_CLRDMASK; /* needed for crypto errors */ |
358 | 358 | ||
359 | if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) | 359 | if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) |
360 | tx_info->flags |= ATH9K_TXDESC_NOACK; | 360 | txctl->flags |= ATH9K_TXDESC_NOACK; |
361 | if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) | 361 | if (tx_info->flags & IEEE80211_TX_CTL_USE_RTS_CTS) |
362 | tx_info->flags |= ATH9K_TXDESC_RTSENA; | 362 | txctl->flags |= ATH9K_TXDESC_RTSENA; |
363 | 363 | ||
364 | /* | 364 | /* |
365 | * Setup for rate calculations. | 365 | * Setup for rate calculations. |
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index bd35bb0a1480..bd65c485098c 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -1304,7 +1304,7 @@ EXPORT_SYMBOL(atmel_open); | |||
1304 | int atmel_open(struct net_device *dev) | 1304 | int atmel_open(struct net_device *dev) |
1305 | { | 1305 | { |
1306 | struct atmel_private *priv = netdev_priv(dev); | 1306 | struct atmel_private *priv = netdev_priv(dev); |
1307 | int i, channel; | 1307 | int i, channel, err; |
1308 | 1308 | ||
1309 | /* any scheduled timer is no longer needed and might screw things up.. */ | 1309 | /* any scheduled timer is no longer needed and might screw things up.. */ |
1310 | del_timer_sync(&priv->management_timer); | 1310 | del_timer_sync(&priv->management_timer); |
@@ -1328,8 +1328,9 @@ int atmel_open(struct net_device *dev) | |||
1328 | priv->site_survey_state = SITE_SURVEY_IDLE; | 1328 | priv->site_survey_state = SITE_SURVEY_IDLE; |
1329 | priv->station_is_associated = 0; | 1329 | priv->station_is_associated = 0; |
1330 | 1330 | ||
1331 | if (!reset_atmel_card(dev)) | 1331 | err = reset_atmel_card(dev); |
1332 | return -EAGAIN; | 1332 | if (err) |
1333 | return err; | ||
1333 | 1334 | ||
1334 | if (priv->config_reg_domain) { | 1335 | if (priv->config_reg_domain) { |
1335 | priv->reg_domain = priv->config_reg_domain; | 1336 | priv->reg_domain = priv->config_reg_domain; |
@@ -3061,12 +3062,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len) | |||
3061 | } | 3062 | } |
3062 | 3063 | ||
3063 | if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { | 3064 | if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { |
3064 | /* Do opensystem first, then try sharedkey */ | 3065 | /* Flip back and forth between WEP auth modes until the max |
3066 | * authentication tries has been exceeded. | ||
3067 | */ | ||
3065 | if (system == WLAN_AUTH_OPEN) { | 3068 | if (system == WLAN_AUTH_OPEN) { |
3066 | priv->CurrentAuthentTransactionSeqNum = 0x001; | 3069 | priv->CurrentAuthentTransactionSeqNum = 0x001; |
3067 | priv->exclude_unencrypted = 1; | 3070 | priv->exclude_unencrypted = 1; |
3068 | send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0); | 3071 | send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0); |
3069 | return; | 3072 | return; |
3073 | } else if ( system == WLAN_AUTH_SHARED_KEY | ||
3074 | && priv->wep_is_on) { | ||
3075 | priv->CurrentAuthentTransactionSeqNum = 0x001; | ||
3076 | priv->exclude_unencrypted = 0; | ||
3077 | send_authentication_request(priv, WLAN_AUTH_OPEN, NULL, 0); | ||
3078 | return; | ||
3070 | } else if (priv->connect_to_any_BSS) { | 3079 | } else if (priv->connect_to_any_BSS) { |
3071 | int bss_index; | 3080 | int bss_index; |
3072 | 3081 | ||
@@ -3580,12 +3589,12 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) | |||
3580 | 3589 | ||
3581 | if (i == 0) { | 3590 | if (i == 0) { |
3582 | printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name); | 3591 | printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name); |
3583 | return 0; | 3592 | return -EIO; |
3584 | } | 3593 | } |
3585 | 3594 | ||
3586 | if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) { | 3595 | if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) { |
3587 | printk(KERN_ALERT "%s: card missing.\n", priv->dev->name); | 3596 | printk(KERN_ALERT "%s: card missing.\n", priv->dev->name); |
3588 | return 0; | 3597 | return -ENODEV; |
3589 | } | 3598 | } |
3590 | 3599 | ||
3591 | /* now check for completion of MAC initialization through | 3600 | /* now check for completion of MAC initialization through |
@@ -3609,19 +3618,19 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) | |||
3609 | if (i == 0) { | 3618 | if (i == 0) { |
3610 | printk(KERN_ALERT "%s: MAC failed to initialise.\n", | 3619 | printk(KERN_ALERT "%s: MAC failed to initialise.\n", |
3611 | priv->dev->name); | 3620 | priv->dev->name); |
3612 | return 0; | 3621 | return -EIO; |
3613 | } | 3622 | } |
3614 | 3623 | ||
3615 | /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */ | 3624 | /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */ |
3616 | if ((mr3 & MAC_INIT_COMPLETE) && | 3625 | if ((mr3 & MAC_INIT_COMPLETE) && |
3617 | !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) { | 3626 | !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) { |
3618 | printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name); | 3627 | printk(KERN_ALERT "%s: MAC failed MR3 self-test.\n", priv->dev->name); |
3619 | return 0; | 3628 | return -EIO; |
3620 | } | 3629 | } |
3621 | if ((mr1 & MAC_INIT_COMPLETE) && | 3630 | if ((mr1 & MAC_INIT_COMPLETE) && |
3622 | !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) { | 3631 | !(atmel_read16(priv->dev, MR1) & MAC_INIT_OK)) { |
3623 | printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name); | 3632 | printk(KERN_ALERT "%s: MAC failed MR1 self-test.\n", priv->dev->name); |
3624 | return 0; | 3633 | return -EIO; |
3625 | } | 3634 | } |
3626 | 3635 | ||
3627 | atmel_copy_to_host(priv->dev, (unsigned char *)iface, | 3636 | atmel_copy_to_host(priv->dev, (unsigned char *)iface, |
@@ -3642,7 +3651,7 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) | |||
3642 | iface->func_ctrl = le16_to_cpu(iface->func_ctrl); | 3651 | iface->func_ctrl = le16_to_cpu(iface->func_ctrl); |
3643 | iface->mac_status = le16_to_cpu(iface->mac_status); | 3652 | iface->mac_status = le16_to_cpu(iface->mac_status); |
3644 | 3653 | ||
3645 | return 1; | 3654 | return 0; |
3646 | } | 3655 | } |
3647 | 3656 | ||
3648 | /* determine type of memory and MAC address */ | 3657 | /* determine type of memory and MAC address */ |
@@ -3693,7 +3702,7 @@ static int probe_atmel_card(struct net_device *dev) | |||
3693 | /* Standard firmware in flash, boot it up and ask | 3702 | /* Standard firmware in flash, boot it up and ask |
3694 | for the Mac Address */ | 3703 | for the Mac Address */ |
3695 | priv->card_type = CARD_TYPE_SPI_FLASH; | 3704 | priv->card_type = CARD_TYPE_SPI_FLASH; |
3696 | if (atmel_wakeup_firmware(priv)) { | 3705 | if (atmel_wakeup_firmware(priv) == 0) { |
3697 | atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); | 3706 | atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); |
3698 | 3707 | ||
3699 | /* got address, now squash it again until the network | 3708 | /* got address, now squash it again until the network |
@@ -3835,6 +3844,7 @@ static int reset_atmel_card(struct net_device *dev) | |||
3835 | struct atmel_private *priv = netdev_priv(dev); | 3844 | struct atmel_private *priv = netdev_priv(dev); |
3836 | u8 configuration; | 3845 | u8 configuration; |
3837 | int old_state = priv->station_state; | 3846 | int old_state = priv->station_state; |
3847 | int err = 0; | ||
3838 | 3848 | ||
3839 | /* data to add to the firmware names, in priority order | 3849 | /* data to add to the firmware names, in priority order |
3840 | this implemenents firmware versioning */ | 3850 | this implemenents firmware versioning */ |
@@ -3868,11 +3878,12 @@ static int reset_atmel_card(struct net_device *dev) | |||
3868 | dev->name); | 3878 | dev->name); |
3869 | strcpy(priv->firmware_id, "atmel_at76c502.bin"); | 3879 | strcpy(priv->firmware_id, "atmel_at76c502.bin"); |
3870 | } | 3880 | } |
3871 | if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) { | 3881 | err = request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev); |
3882 | if (err != 0) { | ||
3872 | printk(KERN_ALERT | 3883 | printk(KERN_ALERT |
3873 | "%s: firmware %s is missing, cannot continue.\n", | 3884 | "%s: firmware %s is missing, cannot continue.\n", |
3874 | dev->name, priv->firmware_id); | 3885 | dev->name, priv->firmware_id); |
3875 | return 0; | 3886 | return err; |
3876 | } | 3887 | } |
3877 | } else { | 3888 | } else { |
3878 | int fw_index = 0; | 3889 | int fw_index = 0; |
@@ -3901,7 +3912,7 @@ static int reset_atmel_card(struct net_device *dev) | |||
3901 | "%s: firmware %s is missing, cannot start.\n", | 3912 | "%s: firmware %s is missing, cannot start.\n", |
3902 | dev->name, priv->firmware_id); | 3913 | dev->name, priv->firmware_id); |
3903 | priv->firmware_id[0] = '\0'; | 3914 | priv->firmware_id[0] = '\0'; |
3904 | return 0; | 3915 | return -ENOENT; |
3905 | } | 3916 | } |
3906 | } | 3917 | } |
3907 | 3918 | ||
@@ -3926,8 +3937,9 @@ static int reset_atmel_card(struct net_device *dev) | |||
3926 | release_firmware(fw_entry); | 3937 | release_firmware(fw_entry); |
3927 | } | 3938 | } |
3928 | 3939 | ||
3929 | if (!atmel_wakeup_firmware(priv)) | 3940 | err = atmel_wakeup_firmware(priv); |
3930 | return 0; | 3941 | if (err != 0) |
3942 | return err; | ||
3931 | 3943 | ||
3932 | /* Check the version and set the correct flag for wpa stuff, | 3944 | /* Check the version and set the correct flag for wpa stuff, |
3933 | old and new firmware is incompatible. | 3945 | old and new firmware is incompatible. |
@@ -3968,10 +3980,9 @@ static int reset_atmel_card(struct net_device *dev) | |||
3968 | if (!priv->radio_on_broken) { | 3980 | if (!priv->radio_on_broken) { |
3969 | if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) == | 3981 | if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) == |
3970 | CMD_STATUS_REJECTED_RADIO_OFF) { | 3982 | CMD_STATUS_REJECTED_RADIO_OFF) { |
3971 | printk(KERN_INFO | 3983 | printk(KERN_INFO "%s: cannot turn the radio on.\n", |
3972 | "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n", | ||
3973 | dev->name); | 3984 | dev->name); |
3974 | return 0; | 3985 | return -EIO; |
3975 | } | 3986 | } |
3976 | } | 3987 | } |
3977 | 3988 | ||
@@ -4006,7 +4017,7 @@ static int reset_atmel_card(struct net_device *dev) | |||
4006 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); | 4017 | wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); |
4007 | } | 4018 | } |
4008 | 4019 | ||
4009 | return 1; | 4020 | return 0; |
4010 | } | 4021 | } |
4011 | 4022 | ||
4012 | static void atmel_send_command(struct atmel_private *priv, int command, | 4023 | static void atmel_send_command(struct atmel_private *priv, int command, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index e2581229d8b2..23fed3298962 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -474,8 +474,8 @@ static void iwl4965_apm_stop(struct iwl_priv *priv) | |||
474 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | 474 | iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
475 | 475 | ||
476 | udelay(10); | 476 | udelay(10); |
477 | 477 | /* clear "init complete" move adapter D0A* --> D0U state */ | |
478 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 478 | iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
479 | spin_unlock_irqrestore(&priv->lock, flags); | 479 | spin_unlock_irqrestore(&priv->lock, flags); |
480 | } | 480 | } |
481 | 481 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index cbc01a00eaf4..b08036a9d894 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -145,7 +145,8 @@ static void iwl5000_apm_stop(struct iwl_priv *priv) | |||
145 | 145 | ||
146 | udelay(10); | 146 | udelay(10); |
147 | 147 | ||
148 | iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 148 | /* clear "init complete" move adapter D0A* --> D0U state */ |
149 | iwl_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | ||
149 | 150 | ||
150 | spin_unlock_irqrestore(&priv->lock, flags); | 151 | spin_unlock_irqrestore(&priv->lock, flags); |
151 | } | 152 | } |
@@ -577,14 +578,11 @@ static int iwl5000_load_section(struct iwl_priv *priv, | |||
577 | FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), | 578 | FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), |
578 | phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); | 579 | phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); |
579 | 580 | ||
580 | /* FIME: write the MSB of the phy_addr in CTRL1 | ||
581 | * iwl_write_direct32(priv, | ||
582 | IWL_FH_TFDIB_CTRL1_REG(IWL_FH_SRVC_CHNL), | ||
583 | ((phy_addr & MSB_MSK) | ||
584 | << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_count); | ||
585 | */ | ||
586 | iwl_write_direct32(priv, | 581 | iwl_write_direct32(priv, |
587 | FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), byte_cnt); | 582 | FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), |
583 | (iwl_get_dma_hi_address(phy_addr) | ||
584 | << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); | ||
585 | |||
588 | iwl_write_direct32(priv, | 586 | iwl_write_direct32(priv, |
589 | FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), | 587 | FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), |
590 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | | 588 | 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 754fef5b592f..90a2b6dee7c0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -1153,7 +1153,8 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv, | |||
1153 | !sta->ht_info.ht_supported) | 1153 | !sta->ht_info.ht_supported) |
1154 | return -1; | 1154 | return -1; |
1155 | 1155 | ||
1156 | if (priv->current_ht_config.tx_mimo_ps_mode == IWL_MIMO_PS_STATIC) | 1156 | if (((sta->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS) >> 2) |
1157 | == IWL_MIMO_PS_STATIC) | ||
1157 | return -1; | 1158 | return -1; |
1158 | 1159 | ||
1159 | /* Need both Tx chains/antennas to support MIMO */ | 1160 | /* Need both Tx chains/antennas to support MIMO */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 061ffba9c884..e01f048a02dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -181,14 +181,14 @@ static int iwl4965_check_rxon_cmd(struct iwl_rxon_cmd *rxon) | |||
181 | } | 181 | } |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * iwl4965_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed | 184 | * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed |
185 | * @priv: staging_rxon is compared to active_rxon | 185 | * @priv: staging_rxon is compared to active_rxon |
186 | * | 186 | * |
187 | * If the RXON structure is changing enough to require a new tune, | 187 | * If the RXON structure is changing enough to require a new tune, |
188 | * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that | 188 | * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that |
189 | * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. | 189 | * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. |
190 | */ | 190 | */ |
191 | static int iwl4965_full_rxon_required(struct iwl_priv *priv) | 191 | static int iwl_full_rxon_required(struct iwl_priv *priv) |
192 | { | 192 | { |
193 | 193 | ||
194 | /* These items are only settable from the full RXON command */ | 194 | /* These items are only settable from the full RXON command */ |
@@ -207,7 +207,6 @@ static int iwl4965_full_rxon_required(struct iwl_priv *priv) | |||
207 | priv->active_rxon.ofdm_ht_single_stream_basic_rates) || | 207 | priv->active_rxon.ofdm_ht_single_stream_basic_rates) || |
208 | (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates != | 208 | (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates != |
209 | priv->active_rxon.ofdm_ht_dual_stream_basic_rates) || | 209 | priv->active_rxon.ofdm_ht_dual_stream_basic_rates) || |
210 | (priv->staging_rxon.rx_chain != priv->active_rxon.rx_chain) || | ||
211 | (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id)) | 210 | (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id)) |
212 | return 1; | 211 | return 1; |
213 | 212 | ||
@@ -263,7 +262,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv) | |||
263 | /* If we don't need to send a full RXON, we can use | 262 | /* If we don't need to send a full RXON, we can use |
264 | * iwl4965_rxon_assoc_cmd which is used to reconfigure filter | 263 | * iwl4965_rxon_assoc_cmd which is used to reconfigure filter |
265 | * and other flags for the current radio configuration. */ | 264 | * and other flags for the current radio configuration. */ |
266 | if (!iwl4965_full_rxon_required(priv)) { | 265 | if (!iwl_full_rxon_required(priv)) { |
267 | ret = iwl_send_rxon_assoc(priv); | 266 | ret = iwl_send_rxon_assoc(priv); |
268 | if (ret) { | 267 | if (ret) { |
269 | IWL_ERROR("Error setting RXON_ASSOC (%d)\n", ret); | 268 | IWL_ERROR("Error setting RXON_ASSOC (%d)\n", ret); |
@@ -587,8 +586,6 @@ static void iwl4965_ht_conf(struct iwl_priv *priv, | |||
587 | iwl_conf->supported_chan_width = 0; | 586 | iwl_conf->supported_chan_width = 0; |
588 | } | 587 | } |
589 | 588 | ||
590 | iwl_conf->tx_mimo_ps_mode = | ||
591 | (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2); | ||
592 | memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16); | 589 | memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16); |
593 | 590 | ||
594 | iwl_conf->control_channel = ht_bss_conf->primary_channel; | 591 | iwl_conf->control_channel = ht_bss_conf->primary_channel; |
@@ -2190,7 +2187,10 @@ static void __iwl4965_down(struct iwl_priv *priv) | |||
2190 | udelay(5); | 2187 | udelay(5); |
2191 | 2188 | ||
2192 | /* FIXME: apm_ops.suspend(priv) */ | 2189 | /* FIXME: apm_ops.suspend(priv) */ |
2193 | priv->cfg->ops->lib->apm_ops.reset(priv); | 2190 | if (exit_pending || test_bit(STATUS_IN_SUSPEND, &priv->status)) |
2191 | priv->cfg->ops->lib->apm_ops.stop(priv); | ||
2192 | else | ||
2193 | priv->cfg->ops->lib->apm_ops.reset(priv); | ||
2194 | priv->cfg->ops->lib->free_shared_mem(priv); | 2194 | priv->cfg->ops->lib->free_shared_mem(priv); |
2195 | 2195 | ||
2196 | exit: | 2196 | exit: |
@@ -2602,6 +2602,7 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
2602 | { | 2602 | { |
2603 | struct iwl_priv *priv = hw->priv; | 2603 | struct iwl_priv *priv = hw->priv; |
2604 | int ret; | 2604 | int ret; |
2605 | u16 pci_cmd; | ||
2605 | 2606 | ||
2606 | IWL_DEBUG_MAC80211("enter\n"); | 2607 | IWL_DEBUG_MAC80211("enter\n"); |
2607 | 2608 | ||
@@ -2612,6 +2613,13 @@ static int iwl4965_mac_start(struct ieee80211_hw *hw) | |||
2612 | pci_restore_state(priv->pci_dev); | 2613 | pci_restore_state(priv->pci_dev); |
2613 | pci_enable_msi(priv->pci_dev); | 2614 | pci_enable_msi(priv->pci_dev); |
2614 | 2615 | ||
2616 | /* enable interrupts if needed: hw bug w/a */ | ||
2617 | pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); | ||
2618 | if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { | ||
2619 | pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; | ||
2620 | pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); | ||
2621 | } | ||
2622 | |||
2615 | ret = request_irq(priv->pci_dev->irq, iwl4965_isr, IRQF_SHARED, | 2623 | ret = request_irq(priv->pci_dev->irq, iwl4965_isr, IRQF_SHARED, |
2616 | DRV_NAME, priv); | 2624 | DRV_NAME, priv); |
2617 | if (ret) { | 2625 | if (ret) { |
@@ -3580,7 +3588,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk | |||
3580 | 3588 | ||
3581 | priv->assoc_id = 0; | 3589 | priv->assoc_id = 0; |
3582 | timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; | 3590 | timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; |
3583 | priv->timestamp = le64_to_cpu(timestamp) + (priv->beacon_int * 1000); | 3591 | priv->timestamp = le64_to_cpu(timestamp); |
3584 | 3592 | ||
3585 | IWL_DEBUG_MAC80211("leave\n"); | 3593 | IWL_DEBUG_MAC80211("leave\n"); |
3586 | spin_unlock_irqrestore(&priv->lock, flags); | 3594 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -4364,15 +4372,18 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
4364 | iwl_dbgfs_unregister(priv); | 4372 | iwl_dbgfs_unregister(priv); |
4365 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 4373 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
4366 | 4374 | ||
4375 | /* ieee80211_unregister_hw call wil cause iwl4965_mac_stop to | ||
4376 | * to be called and iwl4965_down since we are removing the device | ||
4377 | * we need to set STATUS_EXIT_PENDING bit. | ||
4378 | */ | ||
4379 | set_bit(STATUS_EXIT_PENDING, &priv->status); | ||
4367 | if (priv->mac80211_registered) { | 4380 | if (priv->mac80211_registered) { |
4368 | ieee80211_unregister_hw(priv->hw); | 4381 | ieee80211_unregister_hw(priv->hw); |
4369 | priv->mac80211_registered = 0; | 4382 | priv->mac80211_registered = 0; |
4383 | } else { | ||
4384 | iwl4965_down(priv); | ||
4370 | } | 4385 | } |
4371 | 4386 | ||
4372 | set_bit(STATUS_EXIT_PENDING, &priv->status); | ||
4373 | |||
4374 | iwl4965_down(priv); | ||
4375 | |||
4376 | /* make sure we flush any pending irq or | 4387 | /* make sure we flush any pending irq or |
4377 | * tasklet for the driver | 4388 | * tasklet for the driver |
4378 | */ | 4389 | */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index c72f72579bea..80f2f84defa8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -592,12 +592,11 @@ static void iwlcore_free_geos(struct iwl_priv *priv) | |||
592 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | 592 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); |
593 | } | 593 | } |
594 | 594 | ||
595 | static u8 is_single_rx_stream(struct iwl_priv *priv) | 595 | static bool is_single_rx_stream(struct iwl_priv *priv) |
596 | { | 596 | { |
597 | return !priv->current_ht_config.is_ht || | 597 | return !priv->current_ht_config.is_ht || |
598 | ((priv->current_ht_config.supp_mcs_set[1] == 0) && | 598 | ((priv->current_ht_config.supp_mcs_set[1] == 0) && |
599 | (priv->current_ht_config.supp_mcs_set[2] == 0)) || | 599 | (priv->current_ht_config.supp_mcs_set[2] == 0)); |
600 | priv->ps_mode == IWL_MIMO_PS_STATIC; | ||
601 | } | 600 | } |
602 | 601 | ||
603 | static u8 iwl_is_channel_extension(struct iwl_priv *priv, | 602 | static u8 iwl_is_channel_extension(struct iwl_priv *priv, |
@@ -704,33 +703,39 @@ EXPORT_SYMBOL(iwl_set_rxon_ht); | |||
704 | * MIMO (dual stream) requires at least 2, but works better with 3. | 703 | * MIMO (dual stream) requires at least 2, but works better with 3. |
705 | * This does not determine *which* chains to use, just how many. | 704 | * This does not determine *which* chains to use, just how many. |
706 | */ | 705 | */ |
707 | static int iwlcore_get_rx_chain_counter(struct iwl_priv *priv, | 706 | static int iwl_get_active_rx_chain_count(struct iwl_priv *priv) |
708 | u8 *idle_state, u8 *rx_state) | ||
709 | { | 707 | { |
710 | u8 is_single = is_single_rx_stream(priv); | 708 | bool is_single = is_single_rx_stream(priv); |
711 | u8 is_cam = test_bit(STATUS_POWER_PMI, &priv->status) ? 0 : 1; | 709 | bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); |
712 | 710 | ||
713 | /* # of Rx chains to use when expecting MIMO. */ | 711 | /* # of Rx chains to use when expecting MIMO. */ |
714 | if (is_single || (!is_cam && (priv->ps_mode == IWL_MIMO_PS_STATIC))) | 712 | if (is_single || (!is_cam && (priv->ps_mode == IWL_MIMO_PS_STATIC))) |
715 | *rx_state = 2; | 713 | return 2; |
716 | else | 714 | else |
717 | *rx_state = 3; | 715 | return 3; |
716 | } | ||
718 | 717 | ||
718 | static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) | ||
719 | { | ||
720 | int idle_cnt; | ||
721 | bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); | ||
719 | /* # Rx chains when idling and maybe trying to save power */ | 722 | /* # Rx chains when idling and maybe trying to save power */ |
720 | switch (priv->ps_mode) { | 723 | switch (priv->ps_mode) { |
721 | case IWL_MIMO_PS_STATIC: | 724 | case IWL_MIMO_PS_STATIC: |
722 | case IWL_MIMO_PS_DYNAMIC: | 725 | case IWL_MIMO_PS_DYNAMIC: |
723 | *idle_state = (is_cam) ? 2 : 1; | 726 | idle_cnt = (is_cam) ? 2 : 1; |
724 | break; | 727 | break; |
725 | case IWL_MIMO_PS_NONE: | 728 | case IWL_MIMO_PS_NONE: |
726 | *idle_state = (is_cam) ? *rx_state : 1; | 729 | idle_cnt = (is_cam) ? active_cnt : 1; |
727 | break; | 730 | break; |
731 | case IWL_MIMO_PS_INVALID: | ||
728 | default: | 732 | default: |
729 | *idle_state = 1; | 733 | IWL_ERROR("invalide mimo ps mode %d\n", priv->ps_mode); |
734 | WARN_ON(1); | ||
735 | idle_cnt = -1; | ||
730 | break; | 736 | break; |
731 | } | 737 | } |
732 | 738 | return idle_cnt; | |
733 | return 0; | ||
734 | } | 739 | } |
735 | 740 | ||
736 | /** | 741 | /** |
@@ -741,34 +746,44 @@ static int iwlcore_get_rx_chain_counter(struct iwl_priv *priv, | |||
741 | */ | 746 | */ |
742 | void iwl_set_rxon_chain(struct iwl_priv *priv) | 747 | void iwl_set_rxon_chain(struct iwl_priv *priv) |
743 | { | 748 | { |
744 | u8 is_single = is_single_rx_stream(priv); | 749 | bool is_single = is_single_rx_stream(priv); |
745 | u8 idle_state, rx_state; | 750 | bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); |
746 | 751 | u8 idle_rx_cnt, active_rx_cnt; | |
747 | priv->staging_rxon.rx_chain = 0; | 752 | u16 rx_chain; |
748 | rx_state = idle_state = 3; | ||
749 | 753 | ||
750 | /* Tell uCode which antennas are actually connected. | 754 | /* Tell uCode which antennas are actually connected. |
751 | * Before first association, we assume all antennas are connected. | 755 | * Before first association, we assume all antennas are connected. |
752 | * Just after first association, iwl_chain_noise_calibration() | 756 | * Just after first association, iwl_chain_noise_calibration() |
753 | * checks which antennas actually *are* connected. */ | 757 | * checks which antennas actually *are* connected. */ |
754 | priv->staging_rxon.rx_chain |= | 758 | rx_chain = priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; |
755 | cpu_to_le16(priv->hw_params.valid_rx_ant << | ||
756 | RXON_RX_CHAIN_VALID_POS); | ||
757 | 759 | ||
758 | /* How many receivers should we use? */ | 760 | /* How many receivers should we use? */ |
759 | iwlcore_get_rx_chain_counter(priv, &idle_state, &rx_state); | 761 | active_rx_cnt = iwl_get_active_rx_chain_count(priv); |
760 | priv->staging_rxon.rx_chain |= | 762 | idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt); |
761 | cpu_to_le16(rx_state << RXON_RX_CHAIN_MIMO_CNT_POS); | 763 | |
762 | priv->staging_rxon.rx_chain |= | 764 | /* correct rx chain count accoridng hw settings */ |
763 | cpu_to_le16(idle_state << RXON_RX_CHAIN_CNT_POS); | 765 | if (priv->hw_params.rx_chains_num < active_rx_cnt) |
764 | 766 | active_rx_cnt = priv->hw_params.rx_chains_num; | |
765 | if (!is_single && (rx_state >= 2) && | 767 | |
766 | !test_bit(STATUS_POWER_PMI, &priv->status)) | 768 | if (priv->hw_params.rx_chains_num < idle_rx_cnt) |
769 | idle_rx_cnt = priv->hw_params.rx_chains_num; | ||
770 | |||
771 | rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; | ||
772 | rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; | ||
773 | |||
774 | priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain); | ||
775 | |||
776 | if (!is_single && (active_rx_cnt >= 2) && is_cam) | ||
767 | priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; | 777 | priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; |
768 | else | 778 | else |
769 | priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; | 779 | priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; |
770 | 780 | ||
771 | IWL_DEBUG_ASSOC("rx chain %X\n", priv->staging_rxon.rx_chain); | 781 | IWL_DEBUG_ASSOC("rx_chain=0x%Xi active=%d idle=%d\n", |
782 | priv->staging_rxon.rx_chain, | ||
783 | active_rx_cnt, idle_rx_cnt); | ||
784 | |||
785 | WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || | ||
786 | active_rx_cnt < idle_rx_cnt); | ||
772 | } | 787 | } |
773 | EXPORT_SYMBOL(iwl_set_rxon_chain); | 788 | EXPORT_SYMBOL(iwl_set_rxon_chain); |
774 | 789 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index c19db438306c..cdfb343c7ec6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -412,7 +412,6 @@ struct iwl_ht_info { | |||
412 | /* self configuration data */ | 412 | /* self configuration data */ |
413 | u8 is_ht; | 413 | u8 is_ht; |
414 | u8 supported_chan_width; | 414 | u8 supported_chan_width; |
415 | u16 tx_mimo_ps_mode; | ||
416 | u8 is_green_field; | 415 | u8 is_green_field; |
417 | u8 sgf; /* HT_SHORT_GI_* short guard interval */ | 416 | u8 sgf; /* HT_SHORT_GI_* short guard interval */ |
418 | u8 max_amsdu_size; | 417 | u8 max_amsdu_size; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h index 944642450d3d..cd11c0ca2991 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fh.h +++ b/drivers/net/wireless/iwlwifi/iwl-fh.h | |||
@@ -287,6 +287,7 @@ | |||
287 | 287 | ||
288 | #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) | 288 | #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) |
289 | 289 | ||
290 | #define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 | ||
290 | 291 | ||
291 | /** | 292 | /** |
292 | * Transmit DMA Channel Control/Status Registers (TCSR) | 293 | * Transmit DMA Channel Control/Status Registers (TCSR) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index f3f6ea49fdd2..e81bfc42a7cb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -1173,7 +1173,10 @@ void iwl_rx_reply_rx(struct iwl_priv *priv, | |||
1173 | 1173 | ||
1174 | rx_status.antenna = 0; | 1174 | rx_status.antenna = 0; |
1175 | rx_status.flag = 0; | 1175 | rx_status.flag = 0; |
1176 | rx_status.flag |= RX_FLAG_TSFT; | 1176 | |
1177 | /* TSF isn't reliable. In order to allow smooth user experience, | ||
1178 | * this W/A doesn't propagate it to the mac80211 */ | ||
1179 | /*rx_status.flag |= RX_FLAG_TSFT;*/ | ||
1177 | 1180 | ||
1178 | if ((unlikely(rx_start->cfg_phy_cnt > 20))) { | 1181 | if ((unlikely(rx_start->cfg_phy_cnt > 20))) { |
1179 | IWL_DEBUG_DROP("dsp size out of range [0,20]: %d/n", | 1182 | IWL_DEBUG_DROP("dsp size out of range [0,20]: %d/n", |
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index 9bb6adb28b73..6c8ac3a87d54 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -421,7 +421,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, | |||
421 | else | 421 | else |
422 | scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; | 422 | scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; |
423 | 423 | ||
424 | if ((scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) && n_probes) | 424 | if (n_probes) |
425 | scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes); | 425 | scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes); |
426 | 426 | ||
427 | scan_ch->active_dwell = cpu_to_le16(active_dwell); | 427 | scan_ch->active_dwell = cpu_to_le16(active_dwell); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index d82823b5c8ab..78b1a7a4ca40 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -402,12 +402,11 @@ static int iwl_hw_tx_queue_init(struct iwl_priv *priv, | |||
402 | /** | 402 | /** |
403 | * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue | 403 | * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue |
404 | */ | 404 | */ |
405 | static int iwl_tx_queue_init(struct iwl_priv *priv, | 405 | static int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, |
406 | struct iwl_tx_queue *txq, | ||
407 | int slots_num, u32 txq_id) | 406 | int slots_num, u32 txq_id) |
408 | { | 407 | { |
409 | int i, len; | 408 | int i, len; |
410 | int rc = 0; | 409 | int ret; |
411 | 410 | ||
412 | /* | 411 | /* |
413 | * Alloc buffer array for commands (Tx or other types of commands). | 412 | * Alloc buffer array for commands (Tx or other types of commands). |
@@ -426,19 +425,16 @@ static int iwl_tx_queue_init(struct iwl_priv *priv, | |||
426 | continue; | 425 | continue; |
427 | } | 426 | } |
428 | 427 | ||
429 | txq->cmd[i] = kmalloc(len, GFP_KERNEL | GFP_DMA); | 428 | txq->cmd[i] = kmalloc(len, GFP_KERNEL); |
430 | if (!txq->cmd[i]) | 429 | if (!txq->cmd[i]) |
431 | return -ENOMEM; | 430 | goto err; |
432 | } | 431 | } |
433 | 432 | ||
434 | /* Alloc driver data array and TFD circular buffer */ | 433 | /* Alloc driver data array and TFD circular buffer */ |
435 | rc = iwl_tx_queue_alloc(priv, txq, txq_id); | 434 | ret = iwl_tx_queue_alloc(priv, txq, txq_id); |
436 | if (rc) { | 435 | if (ret) |
437 | for (i = 0; i < slots_num; i++) | 436 | goto err; |
438 | kfree(txq->cmd[i]); | ||
439 | 437 | ||
440 | return -ENOMEM; | ||
441 | } | ||
442 | txq->need_update = 0; | 438 | txq->need_update = 0; |
443 | 439 | ||
444 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | 440 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise |
@@ -452,6 +448,17 @@ static int iwl_tx_queue_init(struct iwl_priv *priv, | |||
452 | iwl_hw_tx_queue_init(priv, txq); | 448 | iwl_hw_tx_queue_init(priv, txq); |
453 | 449 | ||
454 | return 0; | 450 | return 0; |
451 | err: | ||
452 | for (i = 0; i < slots_num; i++) { | ||
453 | kfree(txq->cmd[i]); | ||
454 | txq->cmd[i] = NULL; | ||
455 | } | ||
456 | |||
457 | if (txq_id == IWL_CMD_QUEUE_NUM) { | ||
458 | kfree(txq->cmd[slots_num]); | ||
459 | txq->cmd[slots_num] = NULL; | ||
460 | } | ||
461 | return -ENOMEM; | ||
455 | } | 462 | } |
456 | /** | 463 | /** |
457 | * iwl_hw_txq_ctx_free - Free TXQ Context | 464 | * iwl_hw_txq_ctx_free - Free TXQ Context |
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 04d7a251e3f0..8941919001bb 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -595,7 +595,7 @@ static int if_cs_prog_helper(struct if_cs_card *card) | |||
595 | if (ret < 0) { | 595 | if (ret < 0) { |
596 | lbs_pr_err("can't download helper at 0x%x, ret %d\n", | 596 | lbs_pr_err("can't download helper at 0x%x, ret %d\n", |
597 | sent, ret); | 597 | sent, ret); |
598 | goto done; | 598 | goto err_release; |
599 | } | 599 | } |
600 | 600 | ||
601 | if (count == 0) | 601 | if (count == 0) |
@@ -604,9 +604,8 @@ static int if_cs_prog_helper(struct if_cs_card *card) | |||
604 | sent += count; | 604 | sent += count; |
605 | } | 605 | } |
606 | 606 | ||
607 | err_release: | ||
607 | release_firmware(fw); | 608 | release_firmware(fw); |
608 | ret = 0; | ||
609 | |||
610 | done: | 609 | done: |
611 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); | 610 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
612 | return ret; | 611 | return ret; |
@@ -676,14 +675,8 @@ static int if_cs_prog_real(struct if_cs_card *card) | |||
676 | } | 675 | } |
677 | 676 | ||
678 | ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a); | 677 | ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a); |
679 | if (ret < 0) { | 678 | if (ret < 0) |
680 | lbs_pr_err("firmware download failed\n"); | 679 | lbs_pr_err("firmware download failed\n"); |
681 | goto err_release; | ||
682 | } | ||
683 | |||
684 | ret = 0; | ||
685 | goto done; | ||
686 | |||
687 | 680 | ||
688 | err_release: | 681 | err_release: |
689 | release_firmware(fw); | 682 | release_firmware(fw); |
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c index 1ebcafe7ca5f..36c004e15602 100644 --- a/drivers/net/wireless/orinoco.c +++ b/drivers/net/wireless/orinoco.c | |||
@@ -1970,6 +1970,9 @@ __orinoco_set_multicast_list(struct net_device *dev) | |||
1970 | priv->promiscuous = promisc; | 1970 | priv->promiscuous = promisc; |
1971 | } | 1971 | } |
1972 | 1972 | ||
1973 | /* If we're not in promiscuous mode, then we need to set the | ||
1974 | * group address if either we want to multicast, or if we were | ||
1975 | * multicasting and want to stop */ | ||
1973 | if (! promisc && (mc_count || priv->mc_count) ) { | 1976 | if (! promisc && (mc_count || priv->mc_count) ) { |
1974 | struct dev_mc_list *p = dev->mc_list; | 1977 | struct dev_mc_list *p = dev->mc_list; |
1975 | struct hermes_multicast mclist; | 1978 | struct hermes_multicast mclist; |
@@ -1989,9 +1992,10 @@ __orinoco_set_multicast_list(struct net_device *dev) | |||
1989 | printk(KERN_WARNING "%s: Multicast list is " | 1992 | printk(KERN_WARNING "%s: Multicast list is " |
1990 | "longer than mc_count\n", dev->name); | 1993 | "longer than mc_count\n", dev->name); |
1991 | 1994 | ||
1992 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFGROUPADDRESSES, | 1995 | err = hermes_write_ltv(hw, USER_BAP, |
1993 | HERMES_BYTES_TO_RECLEN(priv->mc_count * ETH_ALEN), | 1996 | HERMES_RID_CNFGROUPADDRESSES, |
1994 | &mclist); | 1997 | HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN), |
1998 | &mclist); | ||
1995 | if (err) | 1999 | if (err) |
1996 | printk(KERN_ERR "%s: Error %d setting multicast list.\n", | 2000 | printk(KERN_ERR "%s: Error %d setting multicast list.\n", |
1997 | dev->name, err); | 2001 | dev->name, err); |
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h index 7e88ce5651b9..2ea7866abd5d 100644 --- a/drivers/net/wireless/rt2x00/rt2x00reg.h +++ b/drivers/net/wireless/rt2x00/rt2x00reg.h | |||
@@ -136,7 +136,7 @@ struct rt2x00_field32 { | |||
136 | */ | 136 | */ |
137 | #define is_power_of_two(x) ( !((x) & ((x)-1)) ) | 137 | #define is_power_of_two(x) ( !((x) & ((x)-1)) ) |
138 | #define low_bit_mask(x) ( ((x)-1) & ~(x) ) | 138 | #define low_bit_mask(x) ( ((x)-1) & ~(x) ) |
139 | #define is_valid_mask(x) is_power_of_two(1 + (x) + low_bit_mask(x)) | 139 | #define is_valid_mask(x) is_power_of_two(1LU + (x) + low_bit_mask(x)) |
140 | 140 | ||
141 | /* | 141 | /* |
142 | * Macro's to find first set bit in a variable. | 142 | * Macro's to find first set bit in a variable. |
@@ -173,8 +173,7 @@ struct rt2x00_field32 { | |||
173 | * does not exceed the given typelimit. | 173 | * does not exceed the given typelimit. |
174 | */ | 174 | */ |
175 | #define FIELD_CHECK(__mask, __type) \ | 175 | #define FIELD_CHECK(__mask, __type) \ |
176 | BUILD_BUG_ON(!__builtin_constant_p(__mask) || \ | 176 | BUILD_BUG_ON(!(__mask) || \ |
177 | !(__mask) || \ | ||
178 | !is_valid_mask(__mask) || \ | 177 | !is_valid_mask(__mask) || \ |
179 | (__mask) != (__type)(__mask)) \ | 178 | (__mask) != (__type)(__mask)) \ |
180 | 179 | ||
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 2450b3a393ff..7ba78e6d210e 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c | |||
@@ -38,8 +38,10 @@ void free_cpu_buffers(void) | |||
38 | { | 38 | { |
39 | int i; | 39 | int i; |
40 | 40 | ||
41 | for_each_online_cpu(i) | 41 | for_each_online_cpu(i) { |
42 | vfree(per_cpu(cpu_buffer, i).buffer); | 42 | vfree(per_cpu(cpu_buffer, i).buffer); |
43 | per_cpu(cpu_buffer, i).buffer = NULL; | ||
44 | } | ||
43 | } | 45 | } |
44 | 46 | ||
45 | int alloc_cpu_buffers(void) | 47 | int alloc_cpu_buffers(void) |
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c index e7fbac529935..8d692a5c8e73 100644 --- a/drivers/oprofile/event_buffer.c +++ b/drivers/oprofile/event_buffer.c | |||
@@ -93,6 +93,8 @@ out: | |||
93 | void free_event_buffer(void) | 93 | void free_event_buffer(void) |
94 | { | 94 | { |
95 | vfree(event_buffer); | 95 | vfree(event_buffer); |
96 | |||
97 | event_buffer = NULL; | ||
96 | } | 98 | } |
97 | 99 | ||
98 | 100 | ||
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 82634a2f1b1d..1aad599816f7 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -352,11 +352,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long | |||
352 | continue; | 352 | continue; |
353 | r_size = r->end - r->start + 1; | 353 | r_size = r->end - r->start + 1; |
354 | /* For bridges size != alignment */ | 354 | /* For bridges size != alignment */ |
355 | align = (i < PCI_BRIDGE_RESOURCES) ? r_size : r->start; | 355 | align = resource_alignment(r); |
356 | order = __ffs(align) - 20; | 356 | order = __ffs(align) - 20; |
357 | if (order > 11) { | 357 | if (order > 11) { |
358 | dev_warn(&dev->dev, "BAR %d too large: " | 358 | dev_warn(&dev->dev, "BAR %d bad alignment %llx: " |
359 | "%#016llx-%#016llx\n", i, | 359 | "%#016llx-%#016llx\n", i, |
360 | (unsigned long long)align, | ||
360 | (unsigned long long)r->start, | 361 | (unsigned long long)r->start, |
361 | (unsigned long long)r->end); | 362 | (unsigned long long)r->end); |
362 | r->flags = 0; | 363 | r->flags = 0; |
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index e0f884034c9f..f57eeae3830a 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -220,7 +220,8 @@ config PCMCIA_PXA2XX | |||
220 | tristate "PXA2xx support" | 220 | tristate "PXA2xx support" |
221 | depends on ARM && ARCH_PXA && PCMCIA | 221 | depends on ARM && ARCH_PXA && PCMCIA |
222 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ | 222 | depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ |
223 | || MACH_ARMCORE || ARCH_PXA_PALM) | 223 | || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ |
224 | || ARCH_VIPER) | ||
224 | help | 225 | help |
225 | Say Y here to include support for the PXA2xx PCMCIA controller | 226 | Say Y here to include support for the PXA2xx PCMCIA controller |
226 | 227 | ||
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 269a9e913ba2..8c2fe94122a2 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -71,6 +71,8 @@ sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o | |||
71 | pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o | 71 | pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK) += pxa2xx_lubbock.o sa1111_generic.o |
72 | pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o | 72 | pxa2xx_cs-$(CONFIG_MACH_MAINSTONE) += pxa2xx_mainstone.o |
73 | pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o | 73 | pxa2xx_cs-$(CONFIG_PXA_SHARPSL) += pxa2xx_sharpsl.o |
74 | pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x270.o | 74 | pxa2xx_cs-$(CONFIG_MACH_ARMCORE) += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o |
75 | pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o | 75 | pxa2xx_cs-$(CONFIG_ARCH_VIPER) += pxa2xx_viper.o |
76 | 76 | pxa2xx_cs-$(CONFIG_TRIZEPS_PCMCIA) += pxa2xx_trizeps.o | |
77 | pxa2xx_cs-$(CONFIG_MACH_PALMTX) += pxa2xx_palmtx.o | ||
78 | pxa2xx_cs-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o | ||
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 1b07af5a2ed3..13f1e0fd3f31 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/system.h> | 30 | #include <asm/system.h> |
31 | #include <mach/pxa-regs.h> | 31 | #include <mach/pxa-regs.h> |
32 | #include <mach/pxa2xx-regs.h> | 32 | #include <mach/pxa2xx-regs.h> |
33 | #include <asm/mach-types.h> | ||
33 | 34 | ||
34 | #include <pcmcia/cs_types.h> | 35 | #include <pcmcia/cs_types.h> |
35 | #include <pcmcia/ss.h> | 36 | #include <pcmcia/ss.h> |
@@ -166,18 +167,32 @@ pxa2xx_pcmcia_frequency_change(struct soc_pcmcia_socket *skt, | |||
166 | } | 167 | } |
167 | #endif | 168 | #endif |
168 | 169 | ||
170 | static void pxa2xx_configure_sockets(struct device *dev) | ||
171 | { | ||
172 | struct pcmcia_low_level *ops = dev->platform_data; | ||
173 | |||
174 | /* | ||
175 | * We have at least one socket, so set MECR:CIT | ||
176 | * (Card Is There) | ||
177 | */ | ||
178 | MECR |= MECR_CIT; | ||
179 | |||
180 | /* Set MECR:NOS (Number Of Sockets) */ | ||
181 | if (ops->nr > 1 || machine_is_viper()) | ||
182 | MECR |= MECR_NOS; | ||
183 | else | ||
184 | MECR &= ~MECR_NOS; | ||
185 | } | ||
186 | |||
169 | int __pxa2xx_drv_pcmcia_probe(struct device *dev) | 187 | int __pxa2xx_drv_pcmcia_probe(struct device *dev) |
170 | { | 188 | { |
171 | int ret; | 189 | int ret; |
172 | struct pcmcia_low_level *ops; | 190 | struct pcmcia_low_level *ops; |
173 | int first, nr; | ||
174 | 191 | ||
175 | if (!dev || !dev->platform_data) | 192 | if (!dev || !dev->platform_data) |
176 | return -ENODEV; | 193 | return -ENODEV; |
177 | 194 | ||
178 | ops = (struct pcmcia_low_level *)dev->platform_data; | 195 | ops = (struct pcmcia_low_level *)dev->platform_data; |
179 | first = ops->first; | ||
180 | nr = ops->nr; | ||
181 | 196 | ||
182 | /* Provide our PXA2xx specific timing routines. */ | 197 | /* Provide our PXA2xx specific timing routines. */ |
183 | ops->set_timing = pxa2xx_pcmcia_set_timing; | 198 | ops->set_timing = pxa2xx_pcmcia_set_timing; |
@@ -185,21 +200,10 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev) | |||
185 | ops->frequency_change = pxa2xx_pcmcia_frequency_change; | 200 | ops->frequency_change = pxa2xx_pcmcia_frequency_change; |
186 | #endif | 201 | #endif |
187 | 202 | ||
188 | ret = soc_common_drv_pcmcia_probe(dev, ops, first, nr); | 203 | ret = soc_common_drv_pcmcia_probe(dev, ops, ops->first, ops->nr); |
189 | 204 | ||
190 | if (ret == 0) { | 205 | if (!ret) |
191 | /* | 206 | pxa2xx_configure_sockets(dev); |
192 | * We have at least one socket, so set MECR:CIT | ||
193 | * (Card Is There) | ||
194 | */ | ||
195 | MECR |= MECR_CIT; | ||
196 | |||
197 | /* Set MECR:NOS (Number Of Sockets) */ | ||
198 | if (nr > 1) | ||
199 | MECR |= MECR_NOS; | ||
200 | else | ||
201 | MECR &= ~MECR_NOS; | ||
202 | } | ||
203 | 207 | ||
204 | return ret; | 208 | return ret; |
205 | } | 209 | } |
@@ -223,11 +227,7 @@ static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t s | |||
223 | 227 | ||
224 | static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev) | 228 | static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev) |
225 | { | 229 | { |
226 | struct pcmcia_low_level *ops = dev->dev.platform_data; | 230 | pxa2xx_configure_sockets(&dev->dev); |
227 | int nr = ops ? ops->nr : 0; | ||
228 | |||
229 | MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0); | ||
230 | |||
231 | return pcmcia_socket_dev_resume(&dev->dev); | 231 | return pcmcia_socket_dev_resume(&dev->dev); |
232 | } | 232 | } |
233 | 233 | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x255.c b/drivers/pcmcia/pxa2xx_cm_x255.c new file mode 100644 index 000000000000..7c8bcb476622 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_cm_x255.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa/pxa_cm_x255.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * Compulab Ltd., 2003, 2007, 2008 | ||
9 | * Mike Rapoport <mike@compulab.co.il> | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/irq.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/gpio.h> | ||
17 | |||
18 | #include <asm/mach-types.h> | ||
19 | #include <mach/pxa-regs.h> | ||
20 | |||
21 | #include "soc_common.h" | ||
22 | |||
23 | #define GPIO_PCMCIA_SKTSEL (54) | ||
24 | #define GPIO_PCMCIA_S0_CD_VALID (16) | ||
25 | #define GPIO_PCMCIA_S1_CD_VALID (17) | ||
26 | #define GPIO_PCMCIA_S0_RDYINT (6) | ||
27 | #define GPIO_PCMCIA_S1_RDYINT (8) | ||
28 | #define GPIO_PCMCIA_RESET (9) | ||
29 | |||
30 | #define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID) | ||
31 | #define PCMCIA_S1_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S1_CD_VALID) | ||
32 | #define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT) | ||
33 | #define PCMCIA_S1_RDYINT IRQ_GPIO(GPIO_PCMCIA_S1_RDYINT) | ||
34 | |||
35 | |||
36 | static struct pcmcia_irqs irqs[] = { | ||
37 | { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" }, | ||
38 | { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD" }, | ||
39 | }; | ||
40 | |||
41 | static int cmx255_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
42 | { | ||
43 | int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset"); | ||
44 | if (ret) | ||
45 | return ret; | ||
46 | gpio_direction_output(GPIO_PCMCIA_RESET, 0); | ||
47 | |||
48 | skt->irq = skt->nr == 0 ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT; | ||
49 | ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
50 | if (!ret) | ||
51 | gpio_free(GPIO_PCMCIA_RESET); | ||
52 | |||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | static void cmx255_pcmcia_shutdown(struct soc_pcmcia_socket *skt) | ||
57 | { | ||
58 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
59 | gpio_free(GPIO_PCMCIA_RESET); | ||
60 | } | ||
61 | |||
62 | |||
63 | static void cmx255_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
64 | struct pcmcia_state *state) | ||
65 | { | ||
66 | int cd = skt->nr ? GPIO_PCMCIA_S1_CD_VALID : GPIO_PCMCIA_S0_CD_VALID; | ||
67 | int rdy = skt->nr ? GPIO_PCMCIA_S0_RDYINT : GPIO_PCMCIA_S1_RDYINT; | ||
68 | |||
69 | state->detect = !gpio_get_value(cd); | ||
70 | state->ready = !!gpio_get_value(rdy); | ||
71 | state->bvd1 = 1; | ||
72 | state->bvd2 = 1; | ||
73 | state->vs_3v = 0; | ||
74 | state->vs_Xv = 0; | ||
75 | state->wrprot = 0; /* not available */ | ||
76 | } | ||
77 | |||
78 | |||
79 | static int cmx255_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
80 | const socket_state_t *state) | ||
81 | { | ||
82 | switch (skt->nr) { | ||
83 | case 0: | ||
84 | if (state->flags & SS_RESET) { | ||
85 | gpio_set_value(GPIO_PCMCIA_SKTSEL, 0); | ||
86 | udelay(1); | ||
87 | gpio_set_value(GPIO_PCMCIA_RESET, 1); | ||
88 | udelay(10); | ||
89 | gpio_set_value(GPIO_PCMCIA_RESET, 0); | ||
90 | } | ||
91 | break; | ||
92 | case 1: | ||
93 | if (state->flags & SS_RESET) { | ||
94 | gpio_set_value(GPIO_PCMCIA_SKTSEL, 1); | ||
95 | udelay(1); | ||
96 | gpio_set_value(GPIO_PCMCIA_RESET, 1); | ||
97 | udelay(10); | ||
98 | gpio_set_value(GPIO_PCMCIA_RESET, 0); | ||
99 | } | ||
100 | break; | ||
101 | } | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static void cmx255_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | static void cmx255_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
111 | { | ||
112 | } | ||
113 | |||
114 | |||
115 | static struct pcmcia_low_level cmx255_pcmcia_ops __initdata = { | ||
116 | .owner = THIS_MODULE, | ||
117 | .hw_init = cmx255_pcmcia_hw_init, | ||
118 | .hw_shutdown = cmx255_pcmcia_shutdown, | ||
119 | .socket_state = cmx255_pcmcia_socket_state, | ||
120 | .configure_socket = cmx255_pcmcia_configure_socket, | ||
121 | .socket_init = cmx255_pcmcia_socket_init, | ||
122 | .socket_suspend = cmx255_pcmcia_socket_suspend, | ||
123 | .nr = 1, | ||
124 | }; | ||
125 | |||
126 | static struct platform_device *cmx255_pcmcia_device; | ||
127 | |||
128 | int __init cmx255_pcmcia_init(void) | ||
129 | { | ||
130 | int ret; | ||
131 | |||
132 | cmx255_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
133 | |||
134 | if (!cmx255_pcmcia_device) | ||
135 | return -ENOMEM; | ||
136 | |||
137 | ret = platform_device_add_data(cmx255_pcmcia_device, &cmx255_pcmcia_ops, | ||
138 | sizeof(cmx255_pcmcia_ops)); | ||
139 | |||
140 | if (ret == 0) { | ||
141 | printk(KERN_INFO "Registering cm-x255 PCMCIA interface.\n"); | ||
142 | ret = platform_device_add(cmx255_pcmcia_device); | ||
143 | } | ||
144 | |||
145 | if (ret) | ||
146 | platform_device_put(cmx255_pcmcia_device); | ||
147 | |||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | void __exit cmx255_pcmcia_exit(void) | ||
152 | { | ||
153 | platform_device_unregister(cmx255_pcmcia_device); | ||
154 | } | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c index bcff5cfed051..6c3aac377126 100644 --- a/drivers/pcmcia/pxa2xx_cm_x270.c +++ b/drivers/pcmcia/pxa2xx_cm_x270.c | |||
@@ -105,13 +105,10 @@ static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = { | |||
105 | 105 | ||
106 | static struct platform_device *cmx270_pcmcia_device; | 106 | static struct platform_device *cmx270_pcmcia_device; |
107 | 107 | ||
108 | static int __init cmx270_pcmcia_init(void) | 108 | int __init cmx270_pcmcia_init(void) |
109 | { | 109 | { |
110 | int ret; | 110 | int ret; |
111 | 111 | ||
112 | if (!machine_is_armcore()) | ||
113 | return -ENODEV; | ||
114 | |||
115 | cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | 112 | cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); |
116 | 113 | ||
117 | if (!cmx270_pcmcia_device) | 114 | if (!cmx270_pcmcia_device) |
@@ -131,14 +128,7 @@ static int __init cmx270_pcmcia_init(void) | |||
131 | return ret; | 128 | return ret; |
132 | } | 129 | } |
133 | 130 | ||
134 | static void __exit cmx270_pcmcia_exit(void) | 131 | void __exit cmx270_pcmcia_exit(void) |
135 | { | 132 | { |
136 | platform_device_unregister(cmx270_pcmcia_device); | 133 | platform_device_unregister(cmx270_pcmcia_device); |
137 | } | 134 | } |
138 | |||
139 | module_init(cmx270_pcmcia_init); | ||
140 | module_exit(cmx270_pcmcia_exit); | ||
141 | |||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | ||
144 | MODULE_DESCRIPTION("CM-x270 PCMCIA driver"); | ||
diff --git a/drivers/pcmcia/pxa2xx_cm_x2xx.c b/drivers/pcmcia/pxa2xx_cm_x2xx.c new file mode 100644 index 000000000000..4f09506ad8d4 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_cm_x2xx.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa/pxa_cm_x2xx.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * Compulab Ltd., 2003, 2007, 2008 | ||
9 | * Mike Rapoport <mike@compulab.co.il> | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | |||
15 | #include <asm/system.h> | ||
16 | #include <asm/mach-types.h> | ||
17 | #include <mach/system.h> | ||
18 | |||
19 | int cmx255_pcmcia_init(void); | ||
20 | int cmx270_pcmcia_init(void); | ||
21 | void cmx255_pcmcia_exit(void); | ||
22 | void cmx270_pcmcia_exit(void); | ||
23 | |||
24 | static int __init cmx2xx_pcmcia_init(void) | ||
25 | { | ||
26 | int ret = -ENODEV; | ||
27 | |||
28 | if (machine_is_armcore() && cpu_is_pxa25x()) | ||
29 | ret = cmx255_pcmcia_init(); | ||
30 | else if (machine_is_armcore() && cpu_is_pxa27x()) | ||
31 | ret = cmx270_pcmcia_init(); | ||
32 | |||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | static void __exit cmx2xx_pcmcia_exit(void) | ||
37 | { | ||
38 | if (machine_is_armcore() && cpu_is_pxa25x()) | ||
39 | cmx255_pcmcia_exit(); | ||
40 | else if (machine_is_armcore() && cpu_is_pxa27x()) | ||
41 | cmx270_pcmcia_exit(); | ||
42 | } | ||
43 | |||
44 | module_init(cmx2xx_pcmcia_init); | ||
45 | module_exit(cmx2xx_pcmcia_exit); | ||
46 | |||
47 | MODULE_LICENSE("GPL"); | ||
48 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | ||
49 | MODULE_DESCRIPTION("CM-x2xx PCMCIA driver"); | ||
diff --git a/drivers/pcmcia/pxa2xx_palmld.c b/drivers/pcmcia/pxa2xx_palmld.c new file mode 100644 index 000000000000..1736c67e547e --- /dev/null +++ b/drivers/pcmcia/pxa2xx_palmld.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa2xx_palmld.c | ||
3 | * | ||
4 | * Driver for Palm LifeDrive PCMCIA | ||
5 | * | ||
6 | * Copyright (C) 2006 Alex Osborne <ato@meshy.org> | ||
7 | * Copyright (C) 2007-2008 Marek Vasut <marek.vasut@gmail.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/gpio.h> | ||
18 | |||
19 | #include <asm/mach-types.h> | ||
20 | #include <mach/palmld.h> | ||
21 | #include "soc_common.h" | ||
22 | |||
23 | static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
24 | { | ||
25 | int ret; | ||
26 | |||
27 | ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_POWER, "PCMCIA PWR"); | ||
28 | if (ret) | ||
29 | goto err1; | ||
30 | ret = gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_POWER, 0); | ||
31 | if (ret) | ||
32 | goto err2; | ||
33 | |||
34 | ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_RESET, "PCMCIA RST"); | ||
35 | if (ret) | ||
36 | goto err2; | ||
37 | ret = gpio_direction_output(GPIO_NR_PALMLD_PCMCIA_RESET, 1); | ||
38 | if (ret) | ||
39 | goto err3; | ||
40 | |||
41 | ret = gpio_request(GPIO_NR_PALMLD_PCMCIA_READY, "PCMCIA RDY"); | ||
42 | if (ret) | ||
43 | goto err3; | ||
44 | ret = gpio_direction_input(GPIO_NR_PALMLD_PCMCIA_READY); | ||
45 | if (ret) | ||
46 | goto err4; | ||
47 | |||
48 | skt->irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY); | ||
49 | return 0; | ||
50 | |||
51 | err4: | ||
52 | gpio_free(GPIO_NR_PALMLD_PCMCIA_READY); | ||
53 | err3: | ||
54 | gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET); | ||
55 | err2: | ||
56 | gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER); | ||
57 | err1: | ||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
62 | { | ||
63 | gpio_free(GPIO_NR_PALMLD_PCMCIA_READY); | ||
64 | gpio_free(GPIO_NR_PALMLD_PCMCIA_RESET); | ||
65 | gpio_free(GPIO_NR_PALMLD_PCMCIA_POWER); | ||
66 | } | ||
67 | |||
68 | static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
69 | struct pcmcia_state *state) | ||
70 | { | ||
71 | state->detect = 1; /* always inserted */ | ||
72 | state->ready = !!gpio_get_value(GPIO_NR_PALMLD_PCMCIA_READY); | ||
73 | state->bvd1 = 1; | ||
74 | state->bvd2 = 1; | ||
75 | state->wrprot = 0; | ||
76 | state->vs_3v = 1; | ||
77 | state->vs_Xv = 0; | ||
78 | } | ||
79 | |||
80 | static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
81 | const socket_state_t *state) | ||
82 | { | ||
83 | gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1); | ||
84 | gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET, | ||
85 | !!(state->flags & SS_RESET)); | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static void palmld_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
91 | { | ||
92 | } | ||
93 | |||
94 | static void palmld_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | static struct pcmcia_low_level palmld_pcmcia_ops = { | ||
99 | .owner = THIS_MODULE, | ||
100 | |||
101 | .first = 0, | ||
102 | .nr = 2, | ||
103 | |||
104 | .hw_init = palmld_pcmcia_hw_init, | ||
105 | .hw_shutdown = palmld_pcmcia_hw_shutdown, | ||
106 | |||
107 | .socket_state = palmld_pcmcia_socket_state, | ||
108 | .configure_socket = palmld_pcmcia_configure_socket, | ||
109 | |||
110 | .socket_init = palmld_pcmcia_socket_init, | ||
111 | .socket_suspend = palmld_pcmcia_socket_suspend, | ||
112 | }; | ||
113 | |||
114 | static struct platform_device *palmld_pcmcia_device; | ||
115 | |||
116 | static int __init palmld_pcmcia_init(void) | ||
117 | { | ||
118 | int ret; | ||
119 | |||
120 | if (!machine_is_palmld()) | ||
121 | return -ENODEV; | ||
122 | |||
123 | palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
124 | if (!palmld_pcmcia_device) | ||
125 | return -ENOMEM; | ||
126 | |||
127 | ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops, | ||
128 | sizeof(palmld_pcmcia_ops)); | ||
129 | |||
130 | if (!ret) | ||
131 | ret = platform_device_add(palmld_pcmcia_device); | ||
132 | |||
133 | if (ret) | ||
134 | platform_device_put(palmld_pcmcia_device); | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | static void __exit palmld_pcmcia_exit(void) | ||
140 | { | ||
141 | platform_device_unregister(palmld_pcmcia_device); | ||
142 | } | ||
143 | |||
144 | module_init(palmld_pcmcia_init); | ||
145 | module_exit(palmld_pcmcia_exit); | ||
146 | |||
147 | MODULE_AUTHOR("Alex Osborne <ato@meshy.org>," | ||
148 | " Marek Vasut <marek.vasut@gmail.com>"); | ||
149 | MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive"); | ||
150 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | ||
151 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/pcmcia/pxa2xx_trizeps4.c b/drivers/pcmcia/pxa2xx_trizeps4.c new file mode 100644 index 000000000000..36c7a0b324d2 --- /dev/null +++ b/drivers/pcmcia/pxa2xx_trizeps4.c | |||
@@ -0,0 +1,256 @@ | |||
1 | /* | ||
2 | * linux/drivers/pcmcia/pxa2xx_trizeps4.c | ||
3 | * | ||
4 | * TRIZEPS PCMCIA specific routines. | ||
5 | * | ||
6 | * Author: Jürgen Schindele | ||
7 | * Created: 20 02, 2006 | ||
8 | * Copyright: Jürgen Schindele | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | |||
22 | #include <asm/mach-types.h> | ||
23 | #include <asm/irq.h> | ||
24 | |||
25 | #include <mach/hardware.h> | ||
26 | #include <mach/pxa-regs.h> | ||
27 | #include <mach/trizeps4.h> | ||
28 | |||
29 | #include "soc_common.h" | ||
30 | |||
31 | extern void board_pcmcia_power(int power); | ||
32 | |||
33 | static struct pcmcia_irqs irqs[] = { | ||
34 | { 0, IRQ_GPIO(GPIO_PCD), "cs0_cd" } | ||
35 | /* on other baseboards we can have more inputs */ | ||
36 | }; | ||
37 | |||
38 | static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
39 | { | ||
40 | int ret, i; | ||
41 | /* we dont have voltage/card/ready detection | ||
42 | * so we dont need interrupts for it | ||
43 | */ | ||
44 | switch (skt->nr) { | ||
45 | case 0: | ||
46 | if (gpio_request(GPIO_PRDY, "cf_irq") < 0) { | ||
47 | pr_err("%s: sock %d unable to request gpio %d\n", __func__, | ||
48 | skt->nr, GPIO_PRDY); | ||
49 | return -EBUSY; | ||
50 | } | ||
51 | if (gpio_direction_input(GPIO_PRDY) < 0) { | ||
52 | pr_err("%s: sock %d unable to set input gpio %d\n", __func__, | ||
53 | skt->nr, GPIO_PRDY); | ||
54 | gpio_free(GPIO_PRDY); | ||
55 | return -EINVAL; | ||
56 | } | ||
57 | skt->irq = IRQ_GPIO(GPIO_PRDY); | ||
58 | break; | ||
59 | |||
60 | #ifndef CONFIG_MACH_TRIZEPS_CONXS | ||
61 | case 1: | ||
62 | #endif | ||
63 | default: | ||
64 | break; | ||
65 | } | ||
66 | /* release the reset of this card */ | ||
67 | pr_debug("%s: sock %d irq %d\n", __func__, skt->nr, skt->irq); | ||
68 | |||
69 | /* supplementory irqs for the socket */ | ||
70 | for (i = 0; i < ARRAY_SIZE(irqs); i++) { | ||
71 | if (irqs[i].sock != skt->nr) | ||
72 | continue; | ||
73 | if (gpio_request(IRQ_TO_GPIO(irqs[i].irq), irqs[i].str) < 0) { | ||
74 | pr_err("%s: sock %d unable to request gpio %d\n", | ||
75 | __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); | ||
76 | ret = -EBUSY; | ||
77 | goto error; | ||
78 | } | ||
79 | if (gpio_direction_input(IRQ_TO_GPIO(irqs[i].irq)) < 0) { | ||
80 | pr_err("%s: sock %d unable to set input gpio %d\n", | ||
81 | __func__, skt->nr, IRQ_TO_GPIO(irqs[i].irq)); | ||
82 | ret = -EINVAL; | ||
83 | goto error; | ||
84 | } | ||
85 | } | ||
86 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
87 | |||
88 | error: | ||
89 | for (; i >= 0; i--) { | ||
90 | gpio_free(IRQ_TO_GPIO(irqs[i].irq)); | ||
91 | } | ||
92 | return (ret); | ||
93 | } | ||
94 | |||
95 | static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
96 | { | ||
97 | int i; | ||
98 | /* free allocated gpio's */ | ||
99 | gpio_free(GPIO_PRDY); | ||
100 | for (i = 0; i < ARRAY_SIZE(irqs); i++) | ||
101 | gpio_free(IRQ_TO_GPIO(irqs[i].irq)); | ||
102 | } | ||
103 | |||
104 | static unsigned long trizeps_pcmcia_status[2]; | ||
105 | |||
106 | static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
107 | struct pcmcia_state *state) | ||
108 | { | ||
109 | unsigned short status = 0, change; | ||
110 | status = CFSR_readw(); | ||
111 | change = (status ^ trizeps_pcmcia_status[skt->nr]) & | ||
112 | ConXS_CFSR_BVD_MASK; | ||
113 | if (change) { | ||
114 | trizeps_pcmcia_status[skt->nr] = status; | ||
115 | if (status & ConXS_CFSR_BVD1) { | ||
116 | /* enable_irq empty */ | ||
117 | } else { | ||
118 | /* disable_irq empty */ | ||
119 | } | ||
120 | } | ||
121 | |||
122 | switch (skt->nr) { | ||
123 | case 0: | ||
124 | /* just fill in fix states */ | ||
125 | state->detect = gpio_get_value(GPIO_PCD) ? 0 : 1; | ||
126 | state->ready = gpio_get_value(GPIO_PRDY) ? 1 : 0; | ||
127 | state->bvd1 = (status & ConXS_CFSR_BVD1) ? 1 : 0; | ||
128 | state->bvd2 = (status & ConXS_CFSR_BVD2) ? 1 : 0; | ||
129 | state->vs_3v = (status & ConXS_CFSR_VS1) ? 0 : 1; | ||
130 | state->vs_Xv = (status & ConXS_CFSR_VS2) ? 0 : 1; | ||
131 | state->wrprot = 0; /* not available */ | ||
132 | break; | ||
133 | |||
134 | #ifndef CONFIG_MACH_TRIZEPS_CONXS | ||
135 | /* on ConXS we only have one slot. Second is inactive */ | ||
136 | case 1: | ||
137 | state->detect = 0; | ||
138 | state->ready = 0; | ||
139 | state->bvd1 = 0; | ||
140 | state->bvd2 = 0; | ||
141 | state->vs_3v = 0; | ||
142 | state->vs_Xv = 0; | ||
143 | state->wrprot = 0; | ||
144 | break; | ||
145 | |||
146 | #endif | ||
147 | } | ||
148 | } | ||
149 | |||
150 | static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
151 | const socket_state_t *state) | ||
152 | { | ||
153 | int ret = 0; | ||
154 | unsigned short power = 0; | ||
155 | |||
156 | /* we do nothing here just check a bit */ | ||
157 | switch (state->Vcc) { | ||
158 | case 0: power &= 0xfc; break; | ||
159 | case 33: power |= ConXS_BCR_S0_VCC_3V3; break; | ||
160 | case 50: | ||
161 | pr_err("%s(): Vcc 5V not supported in socket\n", __func__); | ||
162 | break; | ||
163 | default: | ||
164 | pr_err("%s(): bad Vcc %u\n", __func__, state->Vcc); | ||
165 | ret = -1; | ||
166 | } | ||
167 | |||
168 | switch (state->Vpp) { | ||
169 | case 0: power &= 0xf3; break; | ||
170 | case 33: power |= ConXS_BCR_S0_VPP_3V3; break; | ||
171 | case 120: | ||
172 | pr_err("%s(): Vpp 12V not supported in socket\n", __func__); | ||
173 | break; | ||
174 | default: | ||
175 | if (state->Vpp != state->Vcc) { | ||
176 | pr_err("%s(): bad Vpp %u\n", __func__, state->Vpp); | ||
177 | ret = -1; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | switch (skt->nr) { | ||
182 | case 0: /* we only have 3.3V */ | ||
183 | board_pcmcia_power(power); | ||
184 | break; | ||
185 | |||
186 | #ifndef CONFIG_MACH_TRIZEPS_CONXS | ||
187 | /* on ConXS we only have one slot. Second is inactive */ | ||
188 | case 1: | ||
189 | #endif | ||
190 | default: | ||
191 | break; | ||
192 | } | ||
193 | |||
194 | return ret; | ||
195 | } | ||
196 | |||
197 | static void trizeps_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
198 | { | ||
199 | /* default is on */ | ||
200 | board_pcmcia_power(0x9); | ||
201 | } | ||
202 | |||
203 | static void trizeps_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
204 | { | ||
205 | board_pcmcia_power(0x0); | ||
206 | } | ||
207 | |||
208 | static struct pcmcia_low_level trizeps_pcmcia_ops = { | ||
209 | .owner = THIS_MODULE, | ||
210 | .hw_init = trizeps_pcmcia_hw_init, | ||
211 | .hw_shutdown = trizeps_pcmcia_hw_shutdown, | ||
212 | .socket_state = trizeps_pcmcia_socket_state, | ||
213 | .configure_socket = trizeps_pcmcia_configure_socket, | ||
214 | .socket_init = trizeps_pcmcia_socket_init, | ||
215 | .socket_suspend = trizeps_pcmcia_socket_suspend, | ||
216 | #ifdef CONFIG_MACH_TRIZEPS_CONXS | ||
217 | .nr = 1, | ||
218 | #else | ||
219 | .nr = 2, | ||
220 | #endif | ||
221 | .first = 0, | ||
222 | }; | ||
223 | |||
224 | static struct platform_device *trizeps_pcmcia_device; | ||
225 | |||
226 | static int __init trizeps_pcmcia_init(void) | ||
227 | { | ||
228 | int ret; | ||
229 | |||
230 | trizeps_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
231 | if (!trizeps_pcmcia_device) | ||
232 | return -ENOMEM; | ||
233 | |||
234 | ret = platform_device_add_data(trizeps_pcmcia_device, | ||
235 | &trizeps_pcmcia_ops, sizeof(trizeps_pcmcia_ops)); | ||
236 | |||
237 | if (ret == 0) | ||
238 | ret = platform_device_add(trizeps_pcmcia_device); | ||
239 | |||
240 | if (ret) | ||
241 | platform_device_put(trizeps_pcmcia_device); | ||
242 | |||
243 | return ret; | ||
244 | } | ||
245 | |||
246 | static void __exit trizeps_pcmcia_exit(void) | ||
247 | { | ||
248 | platform_device_unregister(trizeps_pcmcia_device); | ||
249 | } | ||
250 | |||
251 | fs_initcall(trizeps_pcmcia_init); | ||
252 | module_exit(trizeps_pcmcia_exit); | ||
253 | |||
254 | MODULE_LICENSE("GPL"); | ||
255 | MODULE_AUTHOR("Juergen Schindele"); | ||
256 | MODULE_ALIAS("platform:pxa2xx-pcmcia"); | ||
diff --git a/drivers/pcmcia/pxa2xx_viper.c b/drivers/pcmcia/pxa2xx_viper.c new file mode 100644 index 000000000000..dd10481be7bf --- /dev/null +++ b/drivers/pcmcia/pxa2xx_viper.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * VIPER PCMCIA support | ||
3 | * Copyright 2004 Arcom Control Systems | ||
4 | * | ||
5 | * Maintained by Marc Zyngier <maz@misterjones.org> | ||
6 | * <marc.zyngier@altran.com> | ||
7 | * | ||
8 | * Based on: | ||
9 | * iPAQ h2200 PCMCIA support | ||
10 | * Copyright 2004 Koen Kooi <koen@vestingbar.nl> | ||
11 | * | ||
12 | * This file is subject to the terms and conditions of the GNU General Public | ||
13 | * License. See the file COPYING in the main directory of this archive for | ||
14 | * more details. | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/gpio.h> | ||
24 | |||
25 | #include <pcmcia/ss.h> | ||
26 | |||
27 | #include <asm/irq.h> | ||
28 | |||
29 | #include <mach/pxa-regs.h> | ||
30 | #include <mach/viper.h> | ||
31 | #include <asm/mach-types.h> | ||
32 | |||
33 | #include "soc_common.h" | ||
34 | #include "pxa2xx_base.h" | ||
35 | |||
36 | static struct pcmcia_irqs irqs[] = { | ||
37 | { 0, gpio_to_irq(VIPER_CF_CD_GPIO), "PCMCIA_CD" } | ||
38 | }; | ||
39 | |||
40 | static int viper_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | ||
41 | { | ||
42 | unsigned long flags; | ||
43 | |||
44 | skt->irq = gpio_to_irq(VIPER_CF_RDY_GPIO); | ||
45 | |||
46 | if (gpio_request(VIPER_CF_CD_GPIO, "CF detect")) | ||
47 | goto err_request_cd; | ||
48 | |||
49 | if (gpio_request(VIPER_CF_RDY_GPIO, "CF ready")) | ||
50 | goto err_request_rdy; | ||
51 | |||
52 | if (gpio_request(VIPER_CF_POWER_GPIO, "CF power")) | ||
53 | goto err_request_pwr; | ||
54 | |||
55 | local_irq_save(flags); | ||
56 | |||
57 | /* GPIO 82 is the CF power enable line. initially off */ | ||
58 | if (gpio_direction_output(VIPER_CF_POWER_GPIO, 0) || | ||
59 | gpio_direction_input(VIPER_CF_CD_GPIO) || | ||
60 | gpio_direction_input(VIPER_CF_RDY_GPIO)) { | ||
61 | local_irq_restore(flags); | ||
62 | goto err_dir; | ||
63 | } | ||
64 | |||
65 | local_irq_restore(flags); | ||
66 | |||
67 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
68 | |||
69 | err_dir: | ||
70 | gpio_free(VIPER_CF_POWER_GPIO); | ||
71 | err_request_pwr: | ||
72 | gpio_free(VIPER_CF_RDY_GPIO); | ||
73 | err_request_rdy: | ||
74 | gpio_free(VIPER_CF_CD_GPIO); | ||
75 | err_request_cd: | ||
76 | printk(KERN_ERR "viper: Failed to setup PCMCIA GPIOs\n"); | ||
77 | return -1; | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * Release all resources. | ||
82 | */ | ||
83 | static void viper_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) | ||
84 | { | ||
85 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); | ||
86 | gpio_free(VIPER_CF_POWER_GPIO); | ||
87 | gpio_free(VIPER_CF_RDY_GPIO); | ||
88 | gpio_free(VIPER_CF_CD_GPIO); | ||
89 | } | ||
90 | |||
91 | static void viper_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | ||
92 | struct pcmcia_state *state) | ||
93 | { | ||
94 | state->detect = gpio_get_value(VIPER_CF_CD_GPIO) ? 0 : 1; | ||
95 | state->ready = gpio_get_value(VIPER_CF_RDY_GPIO) ? 1 : 0; | ||
96 | state->bvd1 = 1; | ||
97 | state->bvd2 = 1; | ||
98 | state->wrprot = 0; | ||
99 | state->vs_3v = 1; /* Can only apply 3.3V */ | ||
100 | state->vs_Xv = 0; | ||
101 | } | ||
102 | |||
103 | static int viper_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | ||
104 | const socket_state_t *state) | ||
105 | { | ||
106 | /* Silently ignore Vpp, output enable, speaker enable. */ | ||
107 | viper_cf_rst(state->flags & SS_RESET); | ||
108 | |||
109 | /* Apply socket voltage */ | ||
110 | switch (state->Vcc) { | ||
111 | case 0: | ||
112 | gpio_set_value(VIPER_CF_POWER_GPIO, 0); | ||
113 | break; | ||
114 | case 33: | ||
115 | gpio_set_value(VIPER_CF_POWER_GPIO, 1); | ||
116 | break; | ||
117 | default: | ||
118 | printk(KERN_ERR "%s: Unsupported Vcc:%d\n", | ||
119 | __func__, state->Vcc); | ||
120 | return -1; | ||
121 | } | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static void viper_pcmcia_socket_init(struct soc_pcmcia_socket *skt) | ||
127 | { | ||
128 | } | ||
129 | |||
130 | static void viper_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) | ||
131 | { | ||
132 | } | ||
133 | |||
134 | static struct pcmcia_low_level viper_pcmcia_ops __initdata = { | ||
135 | .owner = THIS_MODULE, | ||
136 | .hw_init = viper_pcmcia_hw_init, | ||
137 | .hw_shutdown = viper_pcmcia_hw_shutdown, | ||
138 | .socket_state = viper_pcmcia_socket_state, | ||
139 | .configure_socket = viper_pcmcia_configure_socket, | ||
140 | .socket_init = viper_pcmcia_socket_init, | ||
141 | .socket_suspend = viper_pcmcia_socket_suspend, | ||
142 | .nr = 1, | ||
143 | }; | ||
144 | |||
145 | static struct platform_device *viper_pcmcia_device; | ||
146 | |||
147 | static int __init viper_pcmcia_init(void) | ||
148 | { | ||
149 | int ret; | ||
150 | |||
151 | if (!machine_is_viper()) | ||
152 | return -ENODEV; | ||
153 | |||
154 | viper_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); | ||
155 | if (!viper_pcmcia_device) | ||
156 | return -ENOMEM; | ||
157 | |||
158 | ret = platform_device_add_data(viper_pcmcia_device, | ||
159 | &viper_pcmcia_ops, | ||
160 | sizeof(viper_pcmcia_ops)); | ||
161 | |||
162 | if (!ret) | ||
163 | ret = platform_device_add(viper_pcmcia_device); | ||
164 | |||
165 | if (ret) | ||
166 | platform_device_put(viper_pcmcia_device); | ||
167 | |||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | static void __exit viper_pcmcia_exit(void) | ||
172 | { | ||
173 | platform_device_unregister(viper_pcmcia_device); | ||
174 | } | ||
175 | |||
176 | module_init(viper_pcmcia_init); | ||
177 | module_exit(viper_pcmcia_exit); | ||
178 | |||
179 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index d7e9f2152df0..95015cbfd33f 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -405,8 +405,6 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, | |||
405 | 405 | ||
406 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: | 406 | case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: |
407 | extended_irq = &res->data.extended_irq; | 407 | extended_irq = &res->data.extended_irq; |
408 | if (extended_irq->producer_consumer == ACPI_PRODUCER) | ||
409 | return AE_OK; | ||
410 | 408 | ||
411 | if (extended_irq->interrupt_count == 0) | 409 | if (extended_irq->interrupt_count == 0) |
412 | pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); | 410 | pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); |
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 9ce55850271a..1982f8b42782 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig | |||
@@ -56,10 +56,10 @@ config BATTERY_TOSA | |||
56 | Say Y to enable support for the battery on the Sharp Zaurus | 56 | Say Y to enable support for the battery on the Sharp Zaurus |
57 | SL-6000 (tosa) models. | 57 | SL-6000 (tosa) models. |
58 | 58 | ||
59 | config BATTERY_PALMTX | 59 | config BATTERY_WM97XX |
60 | tristate "Palm T|X battery" | 60 | bool "WM97xx generic battery driver" |
61 | depends on MACH_PALMTX | 61 | depends on TOUCHSCREEN_WM97XX |
62 | help | 62 | help |
63 | Say Y to enable support for the battery in Palm T|X. | 63 | Say Y to enable support for battery measured by WM97xx aux port. |
64 | 64 | ||
65 | endif # POWER_SUPPLY | 65 | endif # POWER_SUPPLY |
diff --git a/drivers/power/Makefile b/drivers/power/Makefile index 4706bf8ff459..4e20026cc45a 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile | |||
@@ -21,4 +21,4 @@ obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o | |||
21 | obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o | 21 | obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o |
22 | obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o | 22 | obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o |
23 | obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o | 23 | obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o |
24 | obj-$(CONFIG_BATTERY_PALMTX) += palmtx_battery.o | 24 | obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o \ No newline at end of file |
diff --git a/drivers/power/palmtx_battery.c b/drivers/power/palmtx_battery.c deleted file mode 100644 index 7035bfa41c62..000000000000 --- a/drivers/power/palmtx_battery.c +++ /dev/null | |||
@@ -1,198 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/power/palmtx_battery.c | ||
3 | * | ||
4 | * Battery measurement code for Palm T|X Handheld computer | ||
5 | * | ||
6 | * based on tosa_battery.c | ||
7 | * | ||
8 | * Copyright (C) 2008 Marek Vasut <marek.vasut@gmail.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | */ | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/power_supply.h> | ||
18 | #include <linux/wm97xx.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/spinlock.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/gpio.h> | ||
23 | |||
24 | #include <asm/mach-types.h> | ||
25 | #include <mach/palmtx.h> | ||
26 | |||
27 | static DEFINE_MUTEX(bat_lock); | ||
28 | static struct work_struct bat_work; | ||
29 | struct mutex work_lock; | ||
30 | int bat_status = POWER_SUPPLY_STATUS_DISCHARGING; | ||
31 | |||
32 | static unsigned long palmtx_read_bat(struct power_supply *bat_ps) | ||
33 | { | ||
34 | return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, | ||
35 | WM97XX_AUX_ID3) * 1000 / 414; | ||
36 | } | ||
37 | |||
38 | static unsigned long palmtx_read_temp(struct power_supply *bat_ps) | ||
39 | { | ||
40 | return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, | ||
41 | WM97XX_AUX_ID2); | ||
42 | } | ||
43 | |||
44 | static int palmtx_bat_get_property(struct power_supply *bat_ps, | ||
45 | enum power_supply_property psp, | ||
46 | union power_supply_propval *val) | ||
47 | { | ||
48 | switch (psp) { | ||
49 | case POWER_SUPPLY_PROP_STATUS: | ||
50 | val->intval = bat_status; | ||
51 | break; | ||
52 | case POWER_SUPPLY_PROP_TECHNOLOGY: | ||
53 | val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO; | ||
54 | break; | ||
55 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | ||
56 | val->intval = palmtx_read_bat(bat_ps); | ||
57 | break; | ||
58 | case POWER_SUPPLY_PROP_VOLTAGE_MAX: | ||
59 | case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: | ||
60 | val->intval = PALMTX_BAT_MAX_VOLTAGE; | ||
61 | break; | ||
62 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: | ||
63 | val->intval = PALMTX_BAT_MIN_VOLTAGE; | ||
64 | break; | ||
65 | case POWER_SUPPLY_PROP_TEMP: | ||
66 | val->intval = palmtx_read_temp(bat_ps); | ||
67 | break; | ||
68 | case POWER_SUPPLY_PROP_PRESENT: | ||
69 | val->intval = 1; | ||
70 | break; | ||
71 | default: | ||
72 | return -EINVAL; | ||
73 | } | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static void palmtx_bat_external_power_changed(struct power_supply *bat_ps) | ||
78 | { | ||
79 | schedule_work(&bat_work); | ||
80 | } | ||
81 | |||
82 | static char *status_text[] = { | ||
83 | [POWER_SUPPLY_STATUS_UNKNOWN] = "Unknown", | ||
84 | [POWER_SUPPLY_STATUS_CHARGING] = "Charging", | ||
85 | [POWER_SUPPLY_STATUS_DISCHARGING] = "Discharging", | ||
86 | }; | ||
87 | |||
88 | static void palmtx_bat_update(struct power_supply *bat_ps) | ||
89 | { | ||
90 | int old_status = bat_status; | ||
91 | |||
92 | mutex_lock(&work_lock); | ||
93 | |||
94 | bat_status = gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT) ? | ||
95 | POWER_SUPPLY_STATUS_CHARGING : | ||
96 | POWER_SUPPLY_STATUS_DISCHARGING; | ||
97 | |||
98 | if (old_status != bat_status) { | ||
99 | pr_debug("%s %s -> %s\n", bat_ps->name, | ||
100 | status_text[old_status], | ||
101 | status_text[bat_status]); | ||
102 | power_supply_changed(bat_ps); | ||
103 | } | ||
104 | |||
105 | mutex_unlock(&work_lock); | ||
106 | } | ||
107 | |||
108 | static enum power_supply_property palmtx_bat_main_props[] = { | ||
109 | POWER_SUPPLY_PROP_STATUS, | ||
110 | POWER_SUPPLY_PROP_TECHNOLOGY, | ||
111 | POWER_SUPPLY_PROP_VOLTAGE_NOW, | ||
112 | POWER_SUPPLY_PROP_VOLTAGE_MAX, | ||
113 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, | ||
114 | POWER_SUPPLY_PROP_TEMP, | ||
115 | POWER_SUPPLY_PROP_PRESENT, | ||
116 | }; | ||
117 | |||
118 | struct power_supply bat_ps = { | ||
119 | .name = "main-battery", | ||
120 | .type = POWER_SUPPLY_TYPE_BATTERY, | ||
121 | .properties = palmtx_bat_main_props, | ||
122 | .num_properties = ARRAY_SIZE(palmtx_bat_main_props), | ||
123 | .get_property = palmtx_bat_get_property, | ||
124 | .external_power_changed = palmtx_bat_external_power_changed, | ||
125 | .use_for_apm = 1, | ||
126 | }; | ||
127 | |||
128 | static void palmtx_bat_work(struct work_struct *work) | ||
129 | { | ||
130 | palmtx_bat_update(&bat_ps); | ||
131 | } | ||
132 | |||
133 | #ifdef CONFIG_PM | ||
134 | static int palmtx_bat_suspend(struct platform_device *dev, pm_message_t state) | ||
135 | { | ||
136 | flush_scheduled_work(); | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static int palmtx_bat_resume(struct platform_device *dev) | ||
141 | { | ||
142 | schedule_work(&bat_work); | ||
143 | return 0; | ||
144 | } | ||
145 | #else | ||
146 | #define palmtx_bat_suspend NULL | ||
147 | #define palmtx_bat_resume NULL | ||
148 | #endif | ||
149 | |||
150 | static int __devinit palmtx_bat_probe(struct platform_device *dev) | ||
151 | { | ||
152 | int ret = 0; | ||
153 | |||
154 | if (!machine_is_palmtx()) | ||
155 | return -ENODEV; | ||
156 | |||
157 | mutex_init(&work_lock); | ||
158 | |||
159 | INIT_WORK(&bat_work, palmtx_bat_work); | ||
160 | |||
161 | ret = power_supply_register(&dev->dev, &bat_ps); | ||
162 | if (!ret) | ||
163 | schedule_work(&bat_work); | ||
164 | |||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | static int __devexit palmtx_bat_remove(struct platform_device *dev) | ||
169 | { | ||
170 | power_supply_unregister(&bat_ps); | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static struct platform_driver palmtx_bat_driver = { | ||
175 | .driver.name = "wm97xx-battery", | ||
176 | .driver.owner = THIS_MODULE, | ||
177 | .probe = palmtx_bat_probe, | ||
178 | .remove = __devexit_p(palmtx_bat_remove), | ||
179 | .suspend = palmtx_bat_suspend, | ||
180 | .resume = palmtx_bat_resume, | ||
181 | }; | ||
182 | |||
183 | static int __init palmtx_bat_init(void) | ||
184 | { | ||
185 | return platform_driver_register(&palmtx_bat_driver); | ||
186 | } | ||
187 | |||
188 | static void __exit palmtx_bat_exit(void) | ||
189 | { | ||
190 | platform_driver_unregister(&palmtx_bat_driver); | ||
191 | } | ||
192 | |||
193 | module_init(palmtx_bat_init); | ||
194 | module_exit(palmtx_bat_exit); | ||
195 | |||
196 | MODULE_LICENSE("GPL"); | ||
197 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
198 | MODULE_DESCRIPTION("Palm T|X battery driver"); | ||
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c new file mode 100644 index 000000000000..8bde92126d34 --- /dev/null +++ b/drivers/power/wm97xx_battery.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * linux/drivers/power/wm97xx_battery.c | ||
3 | * | ||
4 | * Battery measurement code for WM97xx | ||
5 | * | ||
6 | * based on tosa_battery.c | ||
7 | * | ||
8 | * Copyright (C) 2008 Marek Vasut <marek.vasut@gmail.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/power_supply.h> | ||
21 | #include <linux/wm97xx.h> | ||
22 | #include <linux/spinlock.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/gpio.h> | ||
25 | #include <linux/wm97xx_batt.h> | ||
26 | |||
27 | static DEFINE_MUTEX(bat_lock); | ||
28 | static struct work_struct bat_work; | ||
29 | struct mutex work_lock; | ||
30 | static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN; | ||
31 | static struct wm97xx_batt_info *pdata; | ||
32 | static enum power_supply_property *prop; | ||
33 | |||
34 | static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) | ||
35 | { | ||
36 | return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, | ||
37 | pdata->batt_aux) * pdata->batt_mult / | ||
38 | pdata->batt_div; | ||
39 | } | ||
40 | |||
41 | static unsigned long wm97xx_read_temp(struct power_supply *bat_ps) | ||
42 | { | ||
43 | return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data, | ||
44 | pdata->temp_aux) * pdata->temp_mult / | ||
45 | pdata->temp_div; | ||
46 | } | ||
47 | |||
48 | static int wm97xx_bat_get_property(struct power_supply *bat_ps, | ||
49 | enum power_supply_property psp, | ||
50 | union power_supply_propval *val) | ||
51 | { | ||
52 | switch (psp) { | ||
53 | case POWER_SUPPLY_PROP_STATUS: | ||
54 | val->intval = bat_status; | ||
55 | break; | ||
56 | case POWER_SUPPLY_PROP_TECHNOLOGY: | ||
57 | val->intval = pdata->batt_tech; | ||
58 | break; | ||
59 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: | ||
60 | if (pdata->batt_aux >= 0) | ||
61 | val->intval = wm97xx_read_bat(bat_ps); | ||
62 | else | ||
63 | return -EINVAL; | ||
64 | break; | ||
65 | case POWER_SUPPLY_PROP_TEMP: | ||
66 | if (pdata->temp_aux >= 0) | ||
67 | val->intval = wm97xx_read_temp(bat_ps); | ||
68 | else | ||
69 | return -EINVAL; | ||
70 | break; | ||
71 | case POWER_SUPPLY_PROP_VOLTAGE_MAX: | ||
72 | if (pdata->max_voltage >= 0) | ||
73 | val->intval = pdata->max_voltage; | ||
74 | else | ||
75 | return -EINVAL; | ||
76 | break; | ||
77 | case POWER_SUPPLY_PROP_VOLTAGE_MIN: | ||
78 | if (pdata->min_voltage >= 0) | ||
79 | val->intval = pdata->min_voltage; | ||
80 | else | ||
81 | return -EINVAL; | ||
82 | break; | ||
83 | case POWER_SUPPLY_PROP_PRESENT: | ||
84 | val->intval = 1; | ||
85 | break; | ||
86 | default: | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps) | ||
93 | { | ||
94 | schedule_work(&bat_work); | ||
95 | } | ||
96 | |||
97 | static void wm97xx_bat_update(struct power_supply *bat_ps) | ||
98 | { | ||
99 | int old_status = bat_status; | ||
100 | |||
101 | mutex_lock(&work_lock); | ||
102 | |||
103 | bat_status = (pdata->charge_gpio >= 0) ? | ||
104 | (gpio_get_value(pdata->charge_gpio) ? | ||
105 | POWER_SUPPLY_STATUS_DISCHARGING : | ||
106 | POWER_SUPPLY_STATUS_CHARGING) : | ||
107 | POWER_SUPPLY_STATUS_UNKNOWN; | ||
108 | |||
109 | if (old_status != bat_status) { | ||
110 | pr_debug("%s: %i -> %i\n", bat_ps->name, old_status, | ||
111 | bat_status); | ||
112 | power_supply_changed(bat_ps); | ||
113 | } | ||
114 | |||
115 | mutex_unlock(&work_lock); | ||
116 | } | ||
117 | |||
118 | static struct power_supply bat_ps = { | ||
119 | .type = POWER_SUPPLY_TYPE_BATTERY, | ||
120 | .get_property = wm97xx_bat_get_property, | ||
121 | .external_power_changed = wm97xx_bat_external_power_changed, | ||
122 | .use_for_apm = 1, | ||
123 | }; | ||
124 | |||
125 | static void wm97xx_bat_work(struct work_struct *work) | ||
126 | { | ||
127 | wm97xx_bat_update(&bat_ps); | ||
128 | } | ||
129 | |||
130 | #ifdef CONFIG_PM | ||
131 | static int wm97xx_bat_suspend(struct platform_device *dev, pm_message_t state) | ||
132 | { | ||
133 | flush_scheduled_work(); | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static int wm97xx_bat_resume(struct platform_device *dev) | ||
138 | { | ||
139 | schedule_work(&bat_work); | ||
140 | return 0; | ||
141 | } | ||
142 | #else | ||
143 | #define wm97xx_bat_suspend NULL | ||
144 | #define wm97xx_bat_resume NULL | ||
145 | #endif | ||
146 | |||
147 | static int __devinit wm97xx_bat_probe(struct platform_device *dev) | ||
148 | { | ||
149 | int ret = 0; | ||
150 | int props = 1; /* POWER_SUPPLY_PROP_PRESENT */ | ||
151 | int i = 0; | ||
152 | |||
153 | if (dev->id != -1) | ||
154 | return -EINVAL; | ||
155 | |||
156 | mutex_init(&work_lock); | ||
157 | |||
158 | if (!pdata) { | ||
159 | dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n"); | ||
160 | return -EINVAL; | ||
161 | } | ||
162 | |||
163 | if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) { | ||
164 | ret = gpio_request(pdata->charge_gpio, "BATT CHRG"); | ||
165 | if (ret) | ||
166 | goto err; | ||
167 | ret = gpio_direction_input(pdata->charge_gpio); | ||
168 | if (ret) | ||
169 | goto err2; | ||
170 | props++; /* POWER_SUPPLY_PROP_STATUS */ | ||
171 | } | ||
172 | |||
173 | if (pdata->batt_tech >= 0) | ||
174 | props++; /* POWER_SUPPLY_PROP_TECHNOLOGY */ | ||
175 | if (pdata->temp_aux >= 0) | ||
176 | props++; /* POWER_SUPPLY_PROP_TEMP */ | ||
177 | if (pdata->batt_aux >= 0) | ||
178 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_NOW */ | ||
179 | if (pdata->max_voltage >= 0) | ||
180 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MAX */ | ||
181 | if (pdata->min_voltage >= 0) | ||
182 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ | ||
183 | |||
184 | prop = kzalloc(props * sizeof(*prop), GFP_KERNEL); | ||
185 | if (!prop) | ||
186 | goto err2; | ||
187 | |||
188 | prop[i++] = POWER_SUPPLY_PROP_PRESENT; | ||
189 | if (pdata->charge_gpio >= 0) | ||
190 | prop[i++] = POWER_SUPPLY_PROP_STATUS; | ||
191 | if (pdata->batt_tech >= 0) | ||
192 | prop[i++] = POWER_SUPPLY_PROP_TECHNOLOGY; | ||
193 | if (pdata->temp_aux >= 0) | ||
194 | prop[i++] = POWER_SUPPLY_PROP_TEMP; | ||
195 | if (pdata->batt_aux >= 0) | ||
196 | prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_NOW; | ||
197 | if (pdata->max_voltage >= 0) | ||
198 | prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MAX; | ||
199 | if (pdata->min_voltage >= 0) | ||
200 | prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MIN; | ||
201 | |||
202 | INIT_WORK(&bat_work, wm97xx_bat_work); | ||
203 | |||
204 | if (!pdata->batt_name) { | ||
205 | dev_info(&dev->dev, "Please consider setting proper battery " | ||
206 | "name in platform definition file, falling " | ||
207 | "back to name \"wm97xx-batt\"\n"); | ||
208 | bat_ps.name = "wm97xx-batt"; | ||
209 | } else | ||
210 | bat_ps.name = pdata->batt_name; | ||
211 | |||
212 | bat_ps.properties = prop; | ||
213 | bat_ps.num_properties = props; | ||
214 | |||
215 | ret = power_supply_register(&dev->dev, &bat_ps); | ||
216 | if (!ret) | ||
217 | schedule_work(&bat_work); | ||
218 | else | ||
219 | goto err3; | ||
220 | |||
221 | return 0; | ||
222 | err3: | ||
223 | kfree(prop); | ||
224 | err2: | ||
225 | gpio_free(pdata->charge_gpio); | ||
226 | err: | ||
227 | return ret; | ||
228 | } | ||
229 | |||
230 | static int __devexit wm97xx_bat_remove(struct platform_device *dev) | ||
231 | { | ||
232 | if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0) | ||
233 | gpio_free(pdata->charge_gpio); | ||
234 | flush_scheduled_work(); | ||
235 | power_supply_unregister(&bat_ps); | ||
236 | kfree(prop); | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static struct platform_driver wm97xx_bat_driver = { | ||
241 | .driver = { | ||
242 | .name = "wm97xx-battery", | ||
243 | .owner = THIS_MODULE, | ||
244 | }, | ||
245 | .probe = wm97xx_bat_probe, | ||
246 | .remove = __devexit_p(wm97xx_bat_remove), | ||
247 | .suspend = wm97xx_bat_suspend, | ||
248 | .resume = wm97xx_bat_resume, | ||
249 | }; | ||
250 | |||
251 | static int __init wm97xx_bat_init(void) | ||
252 | { | ||
253 | return platform_driver_register(&wm97xx_bat_driver); | ||
254 | } | ||
255 | |||
256 | static void __exit wm97xx_bat_exit(void) | ||
257 | { | ||
258 | platform_driver_unregister(&wm97xx_bat_driver); | ||
259 | } | ||
260 | |||
261 | void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) | ||
262 | { | ||
263 | pdata = data; | ||
264 | } | ||
265 | EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata); | ||
266 | |||
267 | module_init(wm97xx_bat_init); | ||
268 | module_exit(wm97xx_bat_exit); | ||
269 | |||
270 | MODULE_LICENSE("GPL"); | ||
271 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
272 | MODULE_DESCRIPTION("WM97xx battery driver"); | ||
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 6ea349aba3ba..b184367637d0 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -800,7 +800,6 @@ static void __exit cmos_do_remove(struct device *dev) | |||
800 | static int cmos_suspend(struct device *dev, pm_message_t mesg) | 800 | static int cmos_suspend(struct device *dev, pm_message_t mesg) |
801 | { | 801 | { |
802 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 802 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
803 | int do_wake = device_may_wakeup(dev); | ||
804 | unsigned char tmp; | 803 | unsigned char tmp; |
805 | 804 | ||
806 | /* only the alarm might be a wakeup event source */ | 805 | /* only the alarm might be a wakeup event source */ |
@@ -809,7 +808,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg) | |||
809 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { | 808 | if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) { |
810 | unsigned char mask; | 809 | unsigned char mask; |
811 | 810 | ||
812 | if (do_wake) | 811 | if (device_may_wakeup(dev)) |
813 | mask = RTC_IRQMASK & ~RTC_AIE; | 812 | mask = RTC_IRQMASK & ~RTC_AIE; |
814 | else | 813 | else |
815 | mask = RTC_IRQMASK; | 814 | mask = RTC_IRQMASK; |
@@ -837,6 +836,17 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg) | |||
837 | return 0; | 836 | return 0; |
838 | } | 837 | } |
839 | 838 | ||
839 | /* We want RTC alarms to wake us from e.g. ACPI G2/S5 "soft off", even | ||
840 | * after a detour through G3 "mechanical off", although the ACPI spec | ||
841 | * says wakeup should only work from G1/S4 "hibernate". To most users, | ||
842 | * distinctions between S4 and S5 are pointless. So when the hardware | ||
843 | * allows, don't draw that distinction. | ||
844 | */ | ||
845 | static inline int cmos_poweroff(struct device *dev) | ||
846 | { | ||
847 | return cmos_suspend(dev, PMSG_HIBERNATE); | ||
848 | } | ||
849 | |||
840 | static int cmos_resume(struct device *dev) | 850 | static int cmos_resume(struct device *dev) |
841 | { | 851 | { |
842 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 852 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
@@ -884,6 +894,12 @@ static int cmos_resume(struct device *dev) | |||
884 | #else | 894 | #else |
885 | #define cmos_suspend NULL | 895 | #define cmos_suspend NULL |
886 | #define cmos_resume NULL | 896 | #define cmos_resume NULL |
897 | |||
898 | static inline int cmos_poweroff(struct device *dev) | ||
899 | { | ||
900 | return -ENOSYS; | ||
901 | } | ||
902 | |||
887 | #endif | 903 | #endif |
888 | 904 | ||
889 | /*----------------------------------------------------------------*/ | 905 | /*----------------------------------------------------------------*/ |
@@ -903,10 +919,6 @@ static int cmos_resume(struct device *dev) | |||
903 | static int __devinit | 919 | static int __devinit |
904 | cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) | 920 | cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) |
905 | { | 921 | { |
906 | /* REVISIT paranoia argues for a shutdown notifier, since PNP | ||
907 | * drivers can't provide shutdown() methods to disable IRQs. | ||
908 | * Or better yet, fix PNP to allow those methods... | ||
909 | */ | ||
910 | if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) | 922 | if (pnp_port_start(pnp,0) == 0x70 && !pnp_irq_valid(pnp,0)) |
911 | /* Some machines contain a PNP entry for the RTC, but | 923 | /* Some machines contain a PNP entry for the RTC, but |
912 | * don't define the IRQ. It should always be safe to | 924 | * don't define the IRQ. It should always be safe to |
@@ -942,6 +954,13 @@ static int cmos_pnp_resume(struct pnp_dev *pnp) | |||
942 | #define cmos_pnp_resume NULL | 954 | #define cmos_pnp_resume NULL |
943 | #endif | 955 | #endif |
944 | 956 | ||
957 | static void cmos_pnp_shutdown(struct device *pdev) | ||
958 | { | ||
959 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(pdev)) | ||
960 | return; | ||
961 | |||
962 | cmos_do_shutdown(); | ||
963 | } | ||
945 | 964 | ||
946 | static const struct pnp_device_id rtc_ids[] = { | 965 | static const struct pnp_device_id rtc_ids[] = { |
947 | { .id = "PNP0b00", }, | 966 | { .id = "PNP0b00", }, |
@@ -961,6 +980,10 @@ static struct pnp_driver cmos_pnp_driver = { | |||
961 | .flags = PNP_DRIVER_RES_DO_NOT_CHANGE, | 980 | .flags = PNP_DRIVER_RES_DO_NOT_CHANGE, |
962 | .suspend = cmos_pnp_suspend, | 981 | .suspend = cmos_pnp_suspend, |
963 | .resume = cmos_pnp_resume, | 982 | .resume = cmos_pnp_resume, |
983 | .driver = { | ||
984 | .name = (char *)driver_name, | ||
985 | .shutdown = cmos_pnp_shutdown, | ||
986 | } | ||
964 | }; | 987 | }; |
965 | 988 | ||
966 | #endif /* CONFIG_PNP */ | 989 | #endif /* CONFIG_PNP */ |
@@ -986,6 +1009,9 @@ static int __exit cmos_platform_remove(struct platform_device *pdev) | |||
986 | 1009 | ||
987 | static void cmos_platform_shutdown(struct platform_device *pdev) | 1010 | static void cmos_platform_shutdown(struct platform_device *pdev) |
988 | { | 1011 | { |
1012 | if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(&pdev->dev)) | ||
1013 | return; | ||
1014 | |||
989 | cmos_do_shutdown(); | 1015 | cmos_do_shutdown(); |
990 | } | 1016 | } |
991 | 1017 | ||
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 9f996ec881ce..dd70bf73ce9d 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -51,10 +51,11 @@ EXPORT_SYMBOL(rtc_year_days); | |||
51 | */ | 51 | */ |
52 | void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) | 52 | void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) |
53 | { | 53 | { |
54 | unsigned int days, month, year; | 54 | unsigned int month, year; |
55 | int days; | ||
55 | 56 | ||
56 | days = time / 86400; | 57 | days = time / 86400; |
57 | time -= days * 86400; | 58 | time -= (unsigned int) days * 86400; |
58 | 59 | ||
59 | /* day of the week, 1970-01-01 was a Thursday */ | 60 | /* day of the week, 1970-01-01 was a Thursday */ |
60 | tm->tm_wday = (days + 4) % 7; | 61 | tm->tm_wday = (days + 4) % 7; |
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index db85f1fb131e..711b3004b3e6 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c | |||
@@ -384,9 +384,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char | |||
384 | * get minor, add to list | 384 | * get minor, add to list |
385 | */ | 385 | */ |
386 | down_write(&dcssblk_devices_sem); | 386 | down_write(&dcssblk_devices_sem); |
387 | if (dcssblk_get_segment_by_name(local_buf)) { | 387 | if (dcssblk_get_device_by_name(local_buf)) { |
388 | up_write(&dcssblk_devices_sem); | ||
388 | rc = -EEXIST; | 389 | rc = -EEXIST; |
389 | goto release_gd; | 390 | goto unload_seg; |
390 | } | 391 | } |
391 | rc = dcssblk_assign_free_minor(dev_info); | 392 | rc = dcssblk_assign_free_minor(dev_info); |
392 | if (rc) { | 393 | if (rc) { |
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c index db00b0591733..f1216cf6fa8f 100644 --- a/drivers/s390/cio/chp.c +++ b/drivers/s390/cio/chp.c | |||
@@ -423,7 +423,7 @@ int chp_new(struct chp_id chpid) | |||
423 | ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group); | 423 | ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group); |
424 | if (ret) { | 424 | if (ret) { |
425 | device_unregister(&chp->dev); | 425 | device_unregister(&chp->dev); |
426 | goto out_free; | 426 | goto out; |
427 | } | 427 | } |
428 | mutex_lock(&channel_subsystems[chpid.cssid]->mutex); | 428 | mutex_lock(&channel_subsystems[chpid.cssid]->mutex); |
429 | if (channel_subsystems[chpid.cssid]->cm_enabled) { | 429 | if (channel_subsystems[chpid.cssid]->cm_enabled) { |
@@ -432,14 +432,15 @@ int chp_new(struct chp_id chpid) | |||
432 | sysfs_remove_group(&chp->dev.kobj, &chp_attr_group); | 432 | sysfs_remove_group(&chp->dev.kobj, &chp_attr_group); |
433 | device_unregister(&chp->dev); | 433 | device_unregister(&chp->dev); |
434 | mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); | 434 | mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); |
435 | goto out_free; | 435 | goto out; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | channel_subsystems[chpid.cssid]->chps[chpid.id] = chp; | 438 | channel_subsystems[chpid.cssid]->chps[chpid.id] = chp; |
439 | mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); | 439 | mutex_unlock(&channel_subsystems[chpid.cssid]->mutex); |
440 | return ret; | 440 | goto out; |
441 | out_free: | 441 | out_free: |
442 | kfree(chp); | 442 | kfree(chp); |
443 | out: | ||
443 | return ret; | 444 | return ret; |
444 | } | 445 | } |
445 | 446 | ||
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 33bff8fec7d1..5954b905e3ca 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c | |||
@@ -208,8 +208,10 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */ | |||
208 | case 1: /* status pending */ | 208 | case 1: /* status pending */ |
209 | case 2: /* busy */ | 209 | case 2: /* busy */ |
210 | return -EBUSY; | 210 | return -EBUSY; |
211 | default: /* device/path not operational */ | 211 | case 3: /* device/path not operational */ |
212 | return cio_start_handle_notoper(sch, lpm); | 212 | return cio_start_handle_notoper(sch, lpm); |
213 | default: | ||
214 | return ccode; | ||
213 | } | 215 | } |
214 | } | 216 | } |
215 | 217 | ||
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 51489eff6b0b..1261e1a9e8cd 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c | |||
@@ -633,6 +633,11 @@ channel_subsystem_release(struct device *dev) | |||
633 | 633 | ||
634 | css = to_css(dev); | 634 | css = to_css(dev); |
635 | mutex_destroy(&css->mutex); | 635 | mutex_destroy(&css->mutex); |
636 | if (css->pseudo_subchannel) { | ||
637 | /* Implies that it has been generated but never registered. */ | ||
638 | css_subchannel_release(&css->pseudo_subchannel->dev); | ||
639 | css->pseudo_subchannel = NULL; | ||
640 | } | ||
636 | kfree(css); | 641 | kfree(css); |
637 | } | 642 | } |
638 | 643 | ||
@@ -785,11 +790,15 @@ init_channel_subsystem (void) | |||
785 | } | 790 | } |
786 | channel_subsystems[i] = css; | 791 | channel_subsystems[i] = css; |
787 | ret = setup_css(i); | 792 | ret = setup_css(i); |
788 | if (ret) | 793 | if (ret) { |
789 | goto out_free; | 794 | kfree(channel_subsystems[i]); |
795 | goto out_unregister; | ||
796 | } | ||
790 | ret = device_register(&css->device); | 797 | ret = device_register(&css->device); |
791 | if (ret) | 798 | if (ret) { |
792 | goto out_free_all; | 799 | put_device(&css->device); |
800 | goto out_unregister; | ||
801 | } | ||
793 | if (css_chsc_characteristics.secm) { | 802 | if (css_chsc_characteristics.secm) { |
794 | ret = device_create_file(&css->device, | 803 | ret = device_create_file(&css->device, |
795 | &dev_attr_cm_enable); | 804 | &dev_attr_cm_enable); |
@@ -802,7 +811,7 @@ init_channel_subsystem (void) | |||
802 | } | 811 | } |
803 | ret = register_reboot_notifier(&css_reboot_notifier); | 812 | ret = register_reboot_notifier(&css_reboot_notifier); |
804 | if (ret) | 813 | if (ret) |
805 | goto out_pseudo; | 814 | goto out_unregister; |
806 | css_init_done = 1; | 815 | css_init_done = 1; |
807 | 816 | ||
808 | /* Enable default isc for I/O subchannels. */ | 817 | /* Enable default isc for I/O subchannels. */ |
@@ -810,18 +819,12 @@ init_channel_subsystem (void) | |||
810 | 819 | ||
811 | for_each_subchannel(__init_channel_subsystem, NULL); | 820 | for_each_subchannel(__init_channel_subsystem, NULL); |
812 | return 0; | 821 | return 0; |
813 | out_pseudo: | ||
814 | device_unregister(&channel_subsystems[i]->pseudo_subchannel->dev); | ||
815 | out_file: | 822 | out_file: |
816 | device_remove_file(&channel_subsystems[i]->device, | 823 | if (css_chsc_characteristics.secm) |
817 | &dev_attr_cm_enable); | 824 | device_remove_file(&channel_subsystems[i]->device, |
825 | &dev_attr_cm_enable); | ||
818 | out_device: | 826 | out_device: |
819 | device_unregister(&channel_subsystems[i]->device); | 827 | device_unregister(&channel_subsystems[i]->device); |
820 | out_free_all: | ||
821 | kfree(channel_subsystems[i]->pseudo_subchannel->lock); | ||
822 | kfree(channel_subsystems[i]->pseudo_subchannel); | ||
823 | out_free: | ||
824 | kfree(channel_subsystems[i]); | ||
825 | out_unregister: | 828 | out_unregister: |
826 | while (i > 0) { | 829 | while (i > 0) { |
827 | struct channel_subsystem *css; | 830 | struct channel_subsystem *css; |
@@ -829,6 +832,7 @@ out_unregister: | |||
829 | i--; | 832 | i--; |
830 | css = channel_subsystems[i]; | 833 | css = channel_subsystems[i]; |
831 | device_unregister(&css->pseudo_subchannel->dev); | 834 | device_unregister(&css->pseudo_subchannel->dev); |
835 | css->pseudo_subchannel = NULL; | ||
832 | if (css_chsc_characteristics.secm) | 836 | if (css_chsc_characteristics.secm) |
833 | device_remove_file(&css->device, | 837 | device_remove_file(&css->device, |
834 | &dev_attr_cm_enable); | 838 | &dev_attr_cm_enable); |
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c index 550508df952b..84cc9ea346db 100644 --- a/drivers/s390/cio/device_fsm.c +++ b/drivers/s390/cio/device_fsm.c | |||
@@ -658,6 +658,13 @@ ccw_device_offline(struct ccw_device *cdev) | |||
658 | { | 658 | { |
659 | struct subchannel *sch; | 659 | struct subchannel *sch; |
660 | 660 | ||
661 | /* Allow ccw_device_offline while disconnected. */ | ||
662 | if (cdev->private->state == DEV_STATE_DISCONNECTED || | ||
663 | cdev->private->state == DEV_STATE_NOT_OPER) { | ||
664 | cdev->private->flags.donotify = 0; | ||
665 | ccw_device_done(cdev, DEV_STATE_NOT_OPER); | ||
666 | return 0; | ||
667 | } | ||
661 | if (ccw_device_is_orphan(cdev)) { | 668 | if (ccw_device_is_orphan(cdev)) { |
662 | ccw_device_done(cdev, DEV_STATE_OFFLINE); | 669 | ccw_device_done(cdev, DEV_STATE_OFFLINE); |
663 | return 0; | 670 | return 0; |
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c index a08b1682c8e8..e10ac9ab2d44 100644 --- a/drivers/s390/net/claw.c +++ b/drivers/s390/net/claw.c | |||
@@ -133,14 +133,14 @@ claw_register_debug_facility(void) | |||
133 | static inline void | 133 | static inline void |
134 | claw_set_busy(struct net_device *dev) | 134 | claw_set_busy(struct net_device *dev) |
135 | { | 135 | { |
136 | ((struct claw_privbk *) dev->priv)->tbusy=1; | 136 | ((struct claw_privbk *)dev->ml_priv)->tbusy = 1; |
137 | eieio(); | 137 | eieio(); |
138 | } | 138 | } |
139 | 139 | ||
140 | static inline void | 140 | static inline void |
141 | claw_clear_busy(struct net_device *dev) | 141 | claw_clear_busy(struct net_device *dev) |
142 | { | 142 | { |
143 | clear_bit(0, &(((struct claw_privbk *) dev->priv)->tbusy)); | 143 | clear_bit(0, &(((struct claw_privbk *) dev->ml_priv)->tbusy)); |
144 | netif_wake_queue(dev); | 144 | netif_wake_queue(dev); |
145 | eieio(); | 145 | eieio(); |
146 | } | 146 | } |
@@ -149,20 +149,20 @@ static inline int | |||
149 | claw_check_busy(struct net_device *dev) | 149 | claw_check_busy(struct net_device *dev) |
150 | { | 150 | { |
151 | eieio(); | 151 | eieio(); |
152 | return ((struct claw_privbk *) dev->priv)->tbusy; | 152 | return ((struct claw_privbk *) dev->ml_priv)->tbusy; |
153 | } | 153 | } |
154 | 154 | ||
155 | static inline void | 155 | static inline void |
156 | claw_setbit_busy(int nr,struct net_device *dev) | 156 | claw_setbit_busy(int nr,struct net_device *dev) |
157 | { | 157 | { |
158 | netif_stop_queue(dev); | 158 | netif_stop_queue(dev); |
159 | set_bit(nr, (void *)&(((struct claw_privbk *)dev->priv)->tbusy)); | 159 | set_bit(nr, (void *)&(((struct claw_privbk *)dev->ml_priv)->tbusy)); |
160 | } | 160 | } |
161 | 161 | ||
162 | static inline void | 162 | static inline void |
163 | claw_clearbit_busy(int nr,struct net_device *dev) | 163 | claw_clearbit_busy(int nr,struct net_device *dev) |
164 | { | 164 | { |
165 | clear_bit(nr,(void *)&(((struct claw_privbk *)dev->priv)->tbusy)); | 165 | clear_bit(nr, (void *)&(((struct claw_privbk *)dev->ml_priv)->tbusy)); |
166 | netif_wake_queue(dev); | 166 | netif_wake_queue(dev); |
167 | } | 167 | } |
168 | 168 | ||
@@ -171,7 +171,7 @@ claw_test_and_setbit_busy(int nr,struct net_device *dev) | |||
171 | { | 171 | { |
172 | netif_stop_queue(dev); | 172 | netif_stop_queue(dev); |
173 | return test_and_set_bit(nr, | 173 | return test_and_set_bit(nr, |
174 | (void *)&(((struct claw_privbk *) dev->priv)->tbusy)); | 174 | (void *)&(((struct claw_privbk *) dev->ml_priv)->tbusy)); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
@@ -271,6 +271,7 @@ claw_probe(struct ccwgroup_device *cgdev) | |||
271 | if (!get_device(&cgdev->dev)) | 271 | if (!get_device(&cgdev->dev)) |
272 | return -ENODEV; | 272 | return -ENODEV; |
273 | privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); | 273 | privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL); |
274 | cgdev->dev.driver_data = privptr; | ||
274 | if (privptr == NULL) { | 275 | if (privptr == NULL) { |
275 | probe_error(cgdev); | 276 | probe_error(cgdev); |
276 | put_device(&cgdev->dev); | 277 | put_device(&cgdev->dev); |
@@ -305,7 +306,6 @@ claw_probe(struct ccwgroup_device *cgdev) | |||
305 | privptr->p_env->p_priv = privptr; | 306 | privptr->p_env->p_priv = privptr; |
306 | cgdev->cdev[0]->handler = claw_irq_handler; | 307 | cgdev->cdev[0]->handler = claw_irq_handler; |
307 | cgdev->cdev[1]->handler = claw_irq_handler; | 308 | cgdev->cdev[1]->handler = claw_irq_handler; |
308 | cgdev->dev.driver_data = privptr; | ||
309 | CLAW_DBF_TEXT(2, setup, "prbext 0"); | 309 | CLAW_DBF_TEXT(2, setup, "prbext 0"); |
310 | 310 | ||
311 | return 0; | 311 | return 0; |
@@ -319,7 +319,7 @@ static int | |||
319 | claw_tx(struct sk_buff *skb, struct net_device *dev) | 319 | claw_tx(struct sk_buff *skb, struct net_device *dev) |
320 | { | 320 | { |
321 | int rc; | 321 | int rc; |
322 | struct claw_privbk *privptr=dev->priv; | 322 | struct claw_privbk *privptr = dev->ml_priv; |
323 | unsigned long saveflags; | 323 | unsigned long saveflags; |
324 | struct chbk *p_ch; | 324 | struct chbk *p_ch; |
325 | 325 | ||
@@ -404,7 +404,7 @@ claw_pack_skb(struct claw_privbk *privptr) | |||
404 | static int | 404 | static int |
405 | claw_change_mtu(struct net_device *dev, int new_mtu) | 405 | claw_change_mtu(struct net_device *dev, int new_mtu) |
406 | { | 406 | { |
407 | struct claw_privbk *privptr=dev->priv; | 407 | struct claw_privbk *privptr = dev->ml_priv; |
408 | int buff_size; | 408 | int buff_size; |
409 | CLAW_DBF_TEXT(4, trace, "setmtu"); | 409 | CLAW_DBF_TEXT(4, trace, "setmtu"); |
410 | buff_size = privptr->p_env->write_size; | 410 | buff_size = privptr->p_env->write_size; |
@@ -434,7 +434,7 @@ claw_open(struct net_device *dev) | |||
434 | struct ccwbk *p_buf; | 434 | struct ccwbk *p_buf; |
435 | 435 | ||
436 | CLAW_DBF_TEXT(4, trace, "open"); | 436 | CLAW_DBF_TEXT(4, trace, "open"); |
437 | privptr = (struct claw_privbk *)dev->priv; | 437 | privptr = (struct claw_privbk *)dev->ml_priv; |
438 | /* allocate and initialize CCW blocks */ | 438 | /* allocate and initialize CCW blocks */ |
439 | if (privptr->buffs_alloc == 0) { | 439 | if (privptr->buffs_alloc == 0) { |
440 | rc=init_ccw_bk(dev); | 440 | rc=init_ccw_bk(dev); |
@@ -780,7 +780,7 @@ claw_irq_tasklet ( unsigned long data ) | |||
780 | p_ch = (struct chbk *) data; | 780 | p_ch = (struct chbk *) data; |
781 | dev = (struct net_device *)p_ch->ndev; | 781 | dev = (struct net_device *)p_ch->ndev; |
782 | CLAW_DBF_TEXT(4, trace, "IRQtask"); | 782 | CLAW_DBF_TEXT(4, trace, "IRQtask"); |
783 | privptr = (struct claw_privbk *) dev->priv; | 783 | privptr = (struct claw_privbk *)dev->ml_priv; |
784 | unpack_read(dev); | 784 | unpack_read(dev); |
785 | clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a); | 785 | clear_bit(CLAW_BH_ACTIVE, (void *)&p_ch->flag_a); |
786 | CLAW_DBF_TEXT(4, trace, "TskletXt"); | 786 | CLAW_DBF_TEXT(4, trace, "TskletXt"); |
@@ -805,7 +805,7 @@ claw_release(struct net_device *dev) | |||
805 | 805 | ||
806 | if (!dev) | 806 | if (!dev) |
807 | return 0; | 807 | return 0; |
808 | privptr = (struct claw_privbk *) dev->priv; | 808 | privptr = (struct claw_privbk *)dev->ml_priv; |
809 | if (!privptr) | 809 | if (!privptr) |
810 | return 0; | 810 | return 0; |
811 | CLAW_DBF_TEXT(4, trace, "release"); | 811 | CLAW_DBF_TEXT(4, trace, "release"); |
@@ -960,7 +960,7 @@ claw_write_next ( struct chbk * p_ch ) | |||
960 | if (p_ch->claw_state == CLAW_STOP) | 960 | if (p_ch->claw_state == CLAW_STOP) |
961 | return; | 961 | return; |
962 | dev = (struct net_device *) p_ch->ndev; | 962 | dev = (struct net_device *) p_ch->ndev; |
963 | privptr = (struct claw_privbk *) dev->priv; | 963 | privptr = (struct claw_privbk *) dev->ml_priv; |
964 | claw_free_wrt_buf( dev ); | 964 | claw_free_wrt_buf( dev ); |
965 | if ((privptr->write_free_count > 0) && | 965 | if ((privptr->write_free_count > 0) && |
966 | !skb_queue_empty(&p_ch->collect_queue)) { | 966 | !skb_queue_empty(&p_ch->collect_queue)) { |
@@ -1042,7 +1042,7 @@ add_claw_reads(struct net_device *dev, struct ccwbk* p_first, | |||
1042 | struct ccw1 temp_ccw; | 1042 | struct ccw1 temp_ccw; |
1043 | struct endccw * p_end; | 1043 | struct endccw * p_end; |
1044 | CLAW_DBF_TEXT(4, trace, "addreads"); | 1044 | CLAW_DBF_TEXT(4, trace, "addreads"); |
1045 | privptr = dev->priv; | 1045 | privptr = dev->ml_priv; |
1046 | p_end = privptr->p_end_ccw; | 1046 | p_end = privptr->p_end_ccw; |
1047 | 1047 | ||
1048 | /* first CCW and last CCW contains a new set of read channel programs | 1048 | /* first CCW and last CCW contains a new set of read channel programs |
@@ -1212,7 +1212,7 @@ find_link(struct net_device *dev, char *host_name, char *ws_name ) | |||
1212 | int rc=0; | 1212 | int rc=0; |
1213 | 1213 | ||
1214 | CLAW_DBF_TEXT(2, setup, "findlink"); | 1214 | CLAW_DBF_TEXT(2, setup, "findlink"); |
1215 | privptr=dev->priv; | 1215 | privptr = dev->ml_priv; |
1216 | p_env=privptr->p_env; | 1216 | p_env=privptr->p_env; |
1217 | switch (p_env->packing) | 1217 | switch (p_env->packing) |
1218 | { | 1218 | { |
@@ -1264,7 +1264,7 @@ claw_hw_tx(struct sk_buff *skb, struct net_device *dev, long linkid) | |||
1264 | struct chbk *ch; | 1264 | struct chbk *ch; |
1265 | 1265 | ||
1266 | CLAW_DBF_TEXT(4, trace, "hw_tx"); | 1266 | CLAW_DBF_TEXT(4, trace, "hw_tx"); |
1267 | privptr = (struct claw_privbk *) (dev->priv); | 1267 | privptr = (struct claw_privbk *)(dev->ml_priv); |
1268 | p_ch=(struct chbk *)&privptr->channel[WRITE]; | 1268 | p_ch=(struct chbk *)&privptr->channel[WRITE]; |
1269 | p_env =privptr->p_env; | 1269 | p_env =privptr->p_env; |
1270 | claw_free_wrt_buf(dev); /* Clean up free chain if posible */ | 1270 | claw_free_wrt_buf(dev); /* Clean up free chain if posible */ |
@@ -1483,8 +1483,8 @@ init_ccw_bk(struct net_device *dev) | |||
1483 | struct ccwbk*p_last_CCWB; | 1483 | struct ccwbk*p_last_CCWB; |
1484 | struct ccwbk*p_first_CCWB; | 1484 | struct ccwbk*p_first_CCWB; |
1485 | struct endccw *p_endccw=NULL; | 1485 | struct endccw *p_endccw=NULL; |
1486 | addr_t real_address; | 1486 | addr_t real_address; |
1487 | struct claw_privbk *privptr=dev->priv; | 1487 | struct claw_privbk *privptr = dev->ml_priv; |
1488 | struct clawh *pClawH=NULL; | 1488 | struct clawh *pClawH=NULL; |
1489 | addr_t real_TIC_address; | 1489 | addr_t real_TIC_address; |
1490 | int i,j; | 1490 | int i,j; |
@@ -1960,19 +1960,16 @@ init_ccw_bk(struct net_device *dev) | |||
1960 | static void | 1960 | static void |
1961 | probe_error( struct ccwgroup_device *cgdev) | 1961 | probe_error( struct ccwgroup_device *cgdev) |
1962 | { | 1962 | { |
1963 | struct claw_privbk *privptr; | 1963 | struct claw_privbk *privptr; |
1964 | 1964 | ||
1965 | CLAW_DBF_TEXT(4, trace, "proberr"); | 1965 | CLAW_DBF_TEXT(4, trace, "proberr"); |
1966 | privptr=(struct claw_privbk *)cgdev->dev.driver_data; | 1966 | privptr = (struct claw_privbk *) cgdev->dev.driver_data; |
1967 | if (privptr!=NULL) { | 1967 | if (privptr != NULL) { |
1968 | cgdev->dev.driver_data = NULL; | ||
1968 | kfree(privptr->p_env); | 1969 | kfree(privptr->p_env); |
1969 | privptr->p_env=NULL; | 1970 | kfree(privptr->p_mtc_envelope); |
1970 | kfree(privptr->p_mtc_envelope); | 1971 | kfree(privptr); |
1971 | privptr->p_mtc_envelope=NULL; | 1972 | } |
1972 | kfree(privptr); | ||
1973 | privptr=NULL; | ||
1974 | } | ||
1975 | return; | ||
1976 | } /* probe_error */ | 1973 | } /* probe_error */ |
1977 | 1974 | ||
1978 | /*-------------------------------------------------------------------* | 1975 | /*-------------------------------------------------------------------* |
@@ -2000,7 +1997,7 @@ claw_process_control( struct net_device *dev, struct ccwbk * p_ccw) | |||
2000 | CLAW_DBF_TEXT(2, setup, "clw_cntl"); | 1997 | CLAW_DBF_TEXT(2, setup, "clw_cntl"); |
2001 | udelay(1000); /* Wait a ms for the control packets to | 1998 | udelay(1000); /* Wait a ms for the control packets to |
2002 | *catch up to each other */ | 1999 | *catch up to each other */ |
2003 | privptr=dev->priv; | 2000 | privptr = dev->ml_priv; |
2004 | p_env=privptr->p_env; | 2001 | p_env=privptr->p_env; |
2005 | tdev = &privptr->channel[READ].cdev->dev; | 2002 | tdev = &privptr->channel[READ].cdev->dev; |
2006 | memcpy( &temp_host_name, p_env->host_name, 8); | 2003 | memcpy( &temp_host_name, p_env->host_name, 8); |
@@ -2278,7 +2275,7 @@ claw_send_control(struct net_device *dev, __u8 type, __u8 link, | |||
2278 | struct sk_buff *skb; | 2275 | struct sk_buff *skb; |
2279 | 2276 | ||
2280 | CLAW_DBF_TEXT(2, setup, "sndcntl"); | 2277 | CLAW_DBF_TEXT(2, setup, "sndcntl"); |
2281 | privptr=dev->priv; | 2278 | privptr = dev->ml_priv; |
2282 | p_ctl=(struct clawctl *)&privptr->ctl_bk; | 2279 | p_ctl=(struct clawctl *)&privptr->ctl_bk; |
2283 | 2280 | ||
2284 | p_ctl->command=type; | 2281 | p_ctl->command=type; |
@@ -2348,7 +2345,7 @@ static int | |||
2348 | claw_snd_conn_req(struct net_device *dev, __u8 link) | 2345 | claw_snd_conn_req(struct net_device *dev, __u8 link) |
2349 | { | 2346 | { |
2350 | int rc; | 2347 | int rc; |
2351 | struct claw_privbk *privptr=dev->priv; | 2348 | struct claw_privbk *privptr = dev->ml_priv; |
2352 | struct clawctl *p_ctl; | 2349 | struct clawctl *p_ctl; |
2353 | 2350 | ||
2354 | CLAW_DBF_TEXT(2, setup, "snd_conn"); | 2351 | CLAW_DBF_TEXT(2, setup, "snd_conn"); |
@@ -2408,7 +2405,7 @@ claw_snd_sys_validate_rsp(struct net_device *dev, | |||
2408 | int rc; | 2405 | int rc; |
2409 | 2406 | ||
2410 | CLAW_DBF_TEXT(2, setup, "chkresp"); | 2407 | CLAW_DBF_TEXT(2, setup, "chkresp"); |
2411 | privptr = dev->priv; | 2408 | privptr = dev->ml_priv; |
2412 | p_env=privptr->p_env; | 2409 | p_env=privptr->p_env; |
2413 | rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE, | 2410 | rc=claw_send_control(dev, SYSTEM_VALIDATE_RESPONSE, |
2414 | p_ctl->linkid, | 2411 | p_ctl->linkid, |
@@ -2446,7 +2443,7 @@ net_device_stats *claw_stats(struct net_device *dev) | |||
2446 | struct claw_privbk *privptr; | 2443 | struct claw_privbk *privptr; |
2447 | 2444 | ||
2448 | CLAW_DBF_TEXT(4, trace, "stats"); | 2445 | CLAW_DBF_TEXT(4, trace, "stats"); |
2449 | privptr = dev->priv; | 2446 | privptr = dev->ml_priv; |
2450 | return &privptr->stats; | 2447 | return &privptr->stats; |
2451 | } /* end of claw_stats */ | 2448 | } /* end of claw_stats */ |
2452 | 2449 | ||
@@ -2482,7 +2479,7 @@ unpack_read(struct net_device *dev ) | |||
2482 | p_last_ccw=NULL; | 2479 | p_last_ccw=NULL; |
2483 | p_packh=NULL; | 2480 | p_packh=NULL; |
2484 | p_packd=NULL; | 2481 | p_packd=NULL; |
2485 | privptr=dev->priv; | 2482 | privptr = dev->ml_priv; |
2486 | 2483 | ||
2487 | p_dev = &privptr->channel[READ].cdev->dev; | 2484 | p_dev = &privptr->channel[READ].cdev->dev; |
2488 | p_env = privptr->p_env; | 2485 | p_env = privptr->p_env; |
@@ -2651,7 +2648,7 @@ claw_strt_read (struct net_device *dev, int lock ) | |||
2651 | int rc = 0; | 2648 | int rc = 0; |
2652 | __u32 parm; | 2649 | __u32 parm; |
2653 | unsigned long saveflags = 0; | 2650 | unsigned long saveflags = 0; |
2654 | struct claw_privbk *privptr=dev->priv; | 2651 | struct claw_privbk *privptr = dev->ml_priv; |
2655 | struct ccwbk*p_ccwbk; | 2652 | struct ccwbk*p_ccwbk; |
2656 | struct chbk *p_ch; | 2653 | struct chbk *p_ch; |
2657 | struct clawh *p_clawh; | 2654 | struct clawh *p_clawh; |
@@ -2708,7 +2705,7 @@ claw_strt_out_IO( struct net_device *dev ) | |||
2708 | if (!dev) { | 2705 | if (!dev) { |
2709 | return; | 2706 | return; |
2710 | } | 2707 | } |
2711 | privptr=(struct claw_privbk *)dev->priv; | 2708 | privptr = (struct claw_privbk *)dev->ml_priv; |
2712 | p_ch=&privptr->channel[WRITE]; | 2709 | p_ch=&privptr->channel[WRITE]; |
2713 | 2710 | ||
2714 | CLAW_DBF_TEXT(4, trace, "strt_io"); | 2711 | CLAW_DBF_TEXT(4, trace, "strt_io"); |
@@ -2741,7 +2738,7 @@ static void | |||
2741 | claw_free_wrt_buf( struct net_device *dev ) | 2738 | claw_free_wrt_buf( struct net_device *dev ) |
2742 | { | 2739 | { |
2743 | 2740 | ||
2744 | struct claw_privbk *privptr=(struct claw_privbk *)dev->priv; | 2741 | struct claw_privbk *privptr = (struct claw_privbk *)dev->ml_priv; |
2745 | struct ccwbk*p_first_ccw; | 2742 | struct ccwbk*p_first_ccw; |
2746 | struct ccwbk*p_last_ccw; | 2743 | struct ccwbk*p_last_ccw; |
2747 | struct ccwbk*p_this_ccw; | 2744 | struct ccwbk*p_this_ccw; |
@@ -2798,13 +2795,13 @@ claw_free_netdevice(struct net_device * dev, int free_dev) | |||
2798 | if (!dev) | 2795 | if (!dev) |
2799 | return; | 2796 | return; |
2800 | CLAW_DBF_TEXT_(2, setup, "%s", dev->name); | 2797 | CLAW_DBF_TEXT_(2, setup, "%s", dev->name); |
2801 | privptr = dev->priv; | 2798 | privptr = dev->ml_priv; |
2802 | if (dev->flags & IFF_RUNNING) | 2799 | if (dev->flags & IFF_RUNNING) |
2803 | claw_release(dev); | 2800 | claw_release(dev); |
2804 | if (privptr) { | 2801 | if (privptr) { |
2805 | privptr->channel[READ].ndev = NULL; /* say it's free */ | 2802 | privptr->channel[READ].ndev = NULL; /* say it's free */ |
2806 | } | 2803 | } |
2807 | dev->priv=NULL; | 2804 | dev->ml_priv = NULL; |
2808 | #ifdef MODULE | 2805 | #ifdef MODULE |
2809 | if (free_dev) { | 2806 | if (free_dev) { |
2810 | free_netdev(dev); | 2807 | free_netdev(dev); |
@@ -2921,7 +2918,7 @@ claw_new_device(struct ccwgroup_device *cgdev) | |||
2921 | printk(KERN_WARNING "%s:alloc_netdev failed\n",__func__); | 2918 | printk(KERN_WARNING "%s:alloc_netdev failed\n",__func__); |
2922 | goto out; | 2919 | goto out; |
2923 | } | 2920 | } |
2924 | dev->priv = privptr; | 2921 | dev->ml_priv = privptr; |
2925 | cgdev->dev.driver_data = privptr; | 2922 | cgdev->dev.driver_data = privptr; |
2926 | cgdev->cdev[READ]->dev.driver_data = privptr; | 2923 | cgdev->cdev[READ]->dev.driver_data = privptr; |
2927 | cgdev->cdev[WRITE]->dev.driver_data = privptr; | 2924 | cgdev->cdev[WRITE]->dev.driver_data = privptr; |
@@ -3002,7 +2999,7 @@ claw_shutdown_device(struct ccwgroup_device *cgdev) | |||
3002 | ret = claw_release(ndev); | 2999 | ret = claw_release(ndev); |
3003 | ndev->flags &=~IFF_RUNNING; | 3000 | ndev->flags &=~IFF_RUNNING; |
3004 | unregister_netdev(ndev); | 3001 | unregister_netdev(ndev); |
3005 | ndev->priv = NULL; /* cgdev data, not ndev's to free */ | 3002 | ndev->ml_priv = NULL; /* cgdev data, not ndev's to free */ |
3006 | claw_free_netdevice(ndev, 1); | 3003 | claw_free_netdevice(ndev, 1); |
3007 | priv->channel[READ].ndev = NULL; | 3004 | priv->channel[READ].ndev = NULL; |
3008 | priv->channel[WRITE].ndev = NULL; | 3005 | priv->channel[WRITE].ndev = NULL; |
diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c index 0b4e6253abe4..42776550acfd 100644 --- a/drivers/s390/net/ctcm_fsms.c +++ b/drivers/s390/net/ctcm_fsms.c | |||
@@ -245,7 +245,7 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg) | |||
245 | { | 245 | { |
246 | struct channel *ch = arg; | 246 | struct channel *ch = arg; |
247 | struct net_device *dev = ch->netdev; | 247 | struct net_device *dev = ch->netdev; |
248 | struct ctcm_priv *priv = dev->priv; | 248 | struct ctcm_priv *priv = dev->ml_priv; |
249 | struct sk_buff *skb; | 249 | struct sk_buff *skb; |
250 | int first = 1; | 250 | int first = 1; |
251 | int i; | 251 | int i; |
@@ -336,7 +336,7 @@ void ctcm_chx_txidle(fsm_instance *fi, int event, void *arg) | |||
336 | { | 336 | { |
337 | struct channel *ch = arg; | 337 | struct channel *ch = arg; |
338 | struct net_device *dev = ch->netdev; | 338 | struct net_device *dev = ch->netdev; |
339 | struct ctcm_priv *priv = dev->priv; | 339 | struct ctcm_priv *priv = dev->ml_priv; |
340 | 340 | ||
341 | CTCM_PR_DEBUG("%s(%s): %s\n", __func__, ch->id, dev->name); | 341 | CTCM_PR_DEBUG("%s(%s): %s\n", __func__, ch->id, dev->name); |
342 | 342 | ||
@@ -357,7 +357,7 @@ static void chx_rx(fsm_instance *fi, int event, void *arg) | |||
357 | { | 357 | { |
358 | struct channel *ch = arg; | 358 | struct channel *ch = arg; |
359 | struct net_device *dev = ch->netdev; | 359 | struct net_device *dev = ch->netdev; |
360 | struct ctcm_priv *priv = dev->priv; | 360 | struct ctcm_priv *priv = dev->ml_priv; |
361 | int len = ch->max_bufsize - ch->irb->scsw.cmd.count; | 361 | int len = ch->max_bufsize - ch->irb->scsw.cmd.count; |
362 | struct sk_buff *skb = ch->trans_skb; | 362 | struct sk_buff *skb = ch->trans_skb; |
363 | __u16 block_len = *((__u16 *)skb->data); | 363 | __u16 block_len = *((__u16 *)skb->data); |
@@ -459,7 +459,7 @@ static void chx_firstio(fsm_instance *fi, int event, void *arg) | |||
459 | chx_rxidle(fi, event, arg); | 459 | chx_rxidle(fi, event, arg); |
460 | } else { | 460 | } else { |
461 | struct net_device *dev = ch->netdev; | 461 | struct net_device *dev = ch->netdev; |
462 | struct ctcm_priv *priv = dev->priv; | 462 | struct ctcm_priv *priv = dev->ml_priv; |
463 | fsm_newstate(fi, CTC_STATE_TXIDLE); | 463 | fsm_newstate(fi, CTC_STATE_TXIDLE); |
464 | fsm_event(priv->fsm, DEV_EVENT_TXUP, dev); | 464 | fsm_event(priv->fsm, DEV_EVENT_TXUP, dev); |
465 | } | 465 | } |
@@ -496,7 +496,7 @@ static void chx_firstio(fsm_instance *fi, int event, void *arg) | |||
496 | if ((CHANNEL_DIRECTION(ch->flags) == READ) && | 496 | if ((CHANNEL_DIRECTION(ch->flags) == READ) && |
497 | (ch->protocol == CTCM_PROTO_S390)) { | 497 | (ch->protocol == CTCM_PROTO_S390)) { |
498 | struct net_device *dev = ch->netdev; | 498 | struct net_device *dev = ch->netdev; |
499 | struct ctcm_priv *priv = dev->priv; | 499 | struct ctcm_priv *priv = dev->ml_priv; |
500 | fsm_event(priv->fsm, DEV_EVENT_RXUP, dev); | 500 | fsm_event(priv->fsm, DEV_EVENT_RXUP, dev); |
501 | } | 501 | } |
502 | } | 502 | } |
@@ -514,7 +514,7 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg) | |||
514 | { | 514 | { |
515 | struct channel *ch = arg; | 515 | struct channel *ch = arg; |
516 | struct net_device *dev = ch->netdev; | 516 | struct net_device *dev = ch->netdev; |
517 | struct ctcm_priv *priv = dev->priv; | 517 | struct ctcm_priv *priv = dev->ml_priv; |
518 | __u16 buflen; | 518 | __u16 buflen; |
519 | int rc; | 519 | int rc; |
520 | 520 | ||
@@ -699,7 +699,7 @@ static void ctcm_chx_cleanup(fsm_instance *fi, int state, | |||
699 | struct channel *ch) | 699 | struct channel *ch) |
700 | { | 700 | { |
701 | struct net_device *dev = ch->netdev; | 701 | struct net_device *dev = ch->netdev; |
702 | struct ctcm_priv *priv = dev->priv; | 702 | struct ctcm_priv *priv = dev->ml_priv; |
703 | 703 | ||
704 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE, | 704 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE, |
705 | "%s(%s): %s[%d]\n", | 705 | "%s(%s): %s[%d]\n", |
@@ -784,7 +784,7 @@ static void ctcm_chx_setuperr(fsm_instance *fi, int event, void *arg) | |||
784 | { | 784 | { |
785 | struct channel *ch = arg; | 785 | struct channel *ch = arg; |
786 | struct net_device *dev = ch->netdev; | 786 | struct net_device *dev = ch->netdev; |
787 | struct ctcm_priv *priv = dev->priv; | 787 | struct ctcm_priv *priv = dev->ml_priv; |
788 | 788 | ||
789 | /* | 789 | /* |
790 | * Special case: Got UC_RCRESET on setmode. | 790 | * Special case: Got UC_RCRESET on setmode. |
@@ -874,7 +874,7 @@ static void ctcm_chx_rxiniterr(fsm_instance *fi, int event, void *arg) | |||
874 | { | 874 | { |
875 | struct channel *ch = arg; | 875 | struct channel *ch = arg; |
876 | struct net_device *dev = ch->netdev; | 876 | struct net_device *dev = ch->netdev; |
877 | struct ctcm_priv *priv = dev->priv; | 877 | struct ctcm_priv *priv = dev->ml_priv; |
878 | 878 | ||
879 | if (event == CTC_EVENT_TIMER) { | 879 | if (event == CTC_EVENT_TIMER) { |
880 | if (!IS_MPCDEV(dev)) | 880 | if (!IS_MPCDEV(dev)) |
@@ -902,7 +902,7 @@ static void ctcm_chx_rxinitfail(fsm_instance *fi, int event, void *arg) | |||
902 | { | 902 | { |
903 | struct channel *ch = arg; | 903 | struct channel *ch = arg; |
904 | struct net_device *dev = ch->netdev; | 904 | struct net_device *dev = ch->netdev; |
905 | struct ctcm_priv *priv = dev->priv; | 905 | struct ctcm_priv *priv = dev->ml_priv; |
906 | 906 | ||
907 | CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, | 907 | CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, |
908 | "%s(%s): RX %s busy, init. fail", | 908 | "%s(%s): RX %s busy, init. fail", |
@@ -923,7 +923,7 @@ static void ctcm_chx_rxdisc(fsm_instance *fi, int event, void *arg) | |||
923 | struct channel *ch = arg; | 923 | struct channel *ch = arg; |
924 | struct channel *ch2; | 924 | struct channel *ch2; |
925 | struct net_device *dev = ch->netdev; | 925 | struct net_device *dev = ch->netdev; |
926 | struct ctcm_priv *priv = dev->priv; | 926 | struct ctcm_priv *priv = dev->ml_priv; |
927 | 927 | ||
928 | CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE, | 928 | CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE, |
929 | "%s: %s: remote disconnect - re-init ...", | 929 | "%s: %s: remote disconnect - re-init ...", |
@@ -954,7 +954,7 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg) | |||
954 | { | 954 | { |
955 | struct channel *ch = arg; | 955 | struct channel *ch = arg; |
956 | struct net_device *dev = ch->netdev; | 956 | struct net_device *dev = ch->netdev; |
957 | struct ctcm_priv *priv = dev->priv; | 957 | struct ctcm_priv *priv = dev->ml_priv; |
958 | 958 | ||
959 | if (event == CTC_EVENT_TIMER) { | 959 | if (event == CTC_EVENT_TIMER) { |
960 | fsm_deltimer(&ch->timer); | 960 | fsm_deltimer(&ch->timer); |
@@ -984,7 +984,7 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg) | |||
984 | { | 984 | { |
985 | struct channel *ch = arg; | 985 | struct channel *ch = arg; |
986 | struct net_device *dev = ch->netdev; | 986 | struct net_device *dev = ch->netdev; |
987 | struct ctcm_priv *priv = dev->priv; | 987 | struct ctcm_priv *priv = dev->ml_priv; |
988 | struct sk_buff *skb; | 988 | struct sk_buff *skb; |
989 | 989 | ||
990 | CTCM_PR_DEBUG("Enter: %s: cp=%i ch=0x%p id=%s\n", | 990 | CTCM_PR_DEBUG("Enter: %s: cp=%i ch=0x%p id=%s\n", |
@@ -1057,7 +1057,7 @@ static void ctcm_chx_iofatal(fsm_instance *fi, int event, void *arg) | |||
1057 | { | 1057 | { |
1058 | struct channel *ch = arg; | 1058 | struct channel *ch = arg; |
1059 | struct net_device *dev = ch->netdev; | 1059 | struct net_device *dev = ch->netdev; |
1060 | struct ctcm_priv *priv = dev->priv; | 1060 | struct ctcm_priv *priv = dev->ml_priv; |
1061 | int rd = CHANNEL_DIRECTION(ch->flags); | 1061 | int rd = CHANNEL_DIRECTION(ch->flags); |
1062 | 1062 | ||
1063 | fsm_deltimer(&ch->timer); | 1063 | fsm_deltimer(&ch->timer); |
@@ -1207,7 +1207,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) | |||
1207 | { | 1207 | { |
1208 | struct channel *ch = arg; | 1208 | struct channel *ch = arg; |
1209 | struct net_device *dev = ch->netdev; | 1209 | struct net_device *dev = ch->netdev; |
1210 | struct ctcm_priv *priv = dev->priv; | 1210 | struct ctcm_priv *priv = dev->ml_priv; |
1211 | struct mpc_group *grp = priv->mpcg; | 1211 | struct mpc_group *grp = priv->mpcg; |
1212 | struct sk_buff *skb; | 1212 | struct sk_buff *skb; |
1213 | int first = 1; | 1213 | int first = 1; |
@@ -1368,7 +1368,7 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg) | |||
1368 | { | 1368 | { |
1369 | struct channel *ch = arg; | 1369 | struct channel *ch = arg; |
1370 | struct net_device *dev = ch->netdev; | 1370 | struct net_device *dev = ch->netdev; |
1371 | struct ctcm_priv *priv = dev->priv; | 1371 | struct ctcm_priv *priv = dev->ml_priv; |
1372 | struct mpc_group *grp = priv->mpcg; | 1372 | struct mpc_group *grp = priv->mpcg; |
1373 | struct sk_buff *skb = ch->trans_skb; | 1373 | struct sk_buff *skb = ch->trans_skb; |
1374 | struct sk_buff *new_skb; | 1374 | struct sk_buff *new_skb; |
@@ -1471,7 +1471,7 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg) | |||
1471 | { | 1471 | { |
1472 | struct channel *ch = arg; | 1472 | struct channel *ch = arg; |
1473 | struct net_device *dev = ch->netdev; | 1473 | struct net_device *dev = ch->netdev; |
1474 | struct ctcm_priv *priv = dev->priv; | 1474 | struct ctcm_priv *priv = dev->ml_priv; |
1475 | struct mpc_group *gptr = priv->mpcg; | 1475 | struct mpc_group *gptr = priv->mpcg; |
1476 | 1476 | ||
1477 | CTCM_PR_DEBUG("Enter %s: id=%s, ch=0x%p\n", | 1477 | CTCM_PR_DEBUG("Enter %s: id=%s, ch=0x%p\n", |
@@ -1525,7 +1525,7 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg) | |||
1525 | { | 1525 | { |
1526 | struct channel *ch = arg; | 1526 | struct channel *ch = arg; |
1527 | struct net_device *dev = ch->netdev; | 1527 | struct net_device *dev = ch->netdev; |
1528 | struct ctcm_priv *priv = dev->priv; | 1528 | struct ctcm_priv *priv = dev->ml_priv; |
1529 | struct mpc_group *grp = priv->mpcg; | 1529 | struct mpc_group *grp = priv->mpcg; |
1530 | int rc; | 1530 | int rc; |
1531 | unsigned long saveflags = 0; /* avoids compiler warning */ | 1531 | unsigned long saveflags = 0; /* avoids compiler warning */ |
@@ -1580,7 +1580,7 @@ static void ctcmpc_chx_attn(fsm_instance *fsm, int event, void *arg) | |||
1580 | { | 1580 | { |
1581 | struct channel *ch = arg; | 1581 | struct channel *ch = arg; |
1582 | struct net_device *dev = ch->netdev; | 1582 | struct net_device *dev = ch->netdev; |
1583 | struct ctcm_priv *priv = dev->priv; | 1583 | struct ctcm_priv *priv = dev->ml_priv; |
1584 | struct mpc_group *grp = priv->mpcg; | 1584 | struct mpc_group *grp = priv->mpcg; |
1585 | 1585 | ||
1586 | CTCM_PR_DEBUG("%s(%s): %s(ch=0x%p), cp=%i, ChStat:%s, GrpStat:%s\n", | 1586 | CTCM_PR_DEBUG("%s(%s): %s(ch=0x%p), cp=%i, ChStat:%s, GrpStat:%s\n", |
@@ -1639,7 +1639,7 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg) | |||
1639 | { | 1639 | { |
1640 | struct channel *ch = arg; | 1640 | struct channel *ch = arg; |
1641 | struct net_device *dev = ch->netdev; | 1641 | struct net_device *dev = ch->netdev; |
1642 | struct ctcm_priv *priv = dev->priv; | 1642 | struct ctcm_priv *priv = dev->ml_priv; |
1643 | struct mpc_group *grp = priv->mpcg; | 1643 | struct mpc_group *grp = priv->mpcg; |
1644 | 1644 | ||
1645 | CTCM_PR_DEBUG("%s(%s): %s\n ChState:%s GrpState:%s\n", | 1645 | CTCM_PR_DEBUG("%s(%s): %s\n ChState:%s GrpState:%s\n", |
@@ -1724,7 +1724,7 @@ static void ctcmpc_chx_resend(fsm_instance *fsm, int event, void *arg) | |||
1724 | { | 1724 | { |
1725 | struct channel *ch = arg; | 1725 | struct channel *ch = arg; |
1726 | struct net_device *dev = ch->netdev; | 1726 | struct net_device *dev = ch->netdev; |
1727 | struct ctcm_priv *priv = dev->priv; | 1727 | struct ctcm_priv *priv = dev->ml_priv; |
1728 | struct mpc_group *grp = priv->mpcg; | 1728 | struct mpc_group *grp = priv->mpcg; |
1729 | 1729 | ||
1730 | fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch); | 1730 | fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch); |
@@ -1740,7 +1740,7 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg) | |||
1740 | { | 1740 | { |
1741 | struct channel *ach = arg; | 1741 | struct channel *ach = arg; |
1742 | struct net_device *dev = ach->netdev; | 1742 | struct net_device *dev = ach->netdev; |
1743 | struct ctcm_priv *priv = dev->priv; | 1743 | struct ctcm_priv *priv = dev->ml_priv; |
1744 | struct mpc_group *grp = priv->mpcg; | 1744 | struct mpc_group *grp = priv->mpcg; |
1745 | struct channel *wch = priv->channel[WRITE]; | 1745 | struct channel *wch = priv->channel[WRITE]; |
1746 | struct channel *rch = priv->channel[READ]; | 1746 | struct channel *rch = priv->channel[READ]; |
@@ -2050,7 +2050,7 @@ int mpc_ch_fsm_len = ARRAY_SIZE(ctcmpc_ch_fsm); | |||
2050 | static void dev_action_start(fsm_instance *fi, int event, void *arg) | 2050 | static void dev_action_start(fsm_instance *fi, int event, void *arg) |
2051 | { | 2051 | { |
2052 | struct net_device *dev = arg; | 2052 | struct net_device *dev = arg; |
2053 | struct ctcm_priv *priv = dev->priv; | 2053 | struct ctcm_priv *priv = dev->ml_priv; |
2054 | int direction; | 2054 | int direction; |
2055 | 2055 | ||
2056 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); | 2056 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); |
@@ -2076,7 +2076,7 @@ static void dev_action_stop(fsm_instance *fi, int event, void *arg) | |||
2076 | { | 2076 | { |
2077 | int direction; | 2077 | int direction; |
2078 | struct net_device *dev = arg; | 2078 | struct net_device *dev = arg; |
2079 | struct ctcm_priv *priv = dev->priv; | 2079 | struct ctcm_priv *priv = dev->ml_priv; |
2080 | 2080 | ||
2081 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); | 2081 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); |
2082 | 2082 | ||
@@ -2096,7 +2096,7 @@ static void dev_action_restart(fsm_instance *fi, int event, void *arg) | |||
2096 | { | 2096 | { |
2097 | int restart_timer; | 2097 | int restart_timer; |
2098 | struct net_device *dev = arg; | 2098 | struct net_device *dev = arg; |
2099 | struct ctcm_priv *priv = dev->priv; | 2099 | struct ctcm_priv *priv = dev->ml_priv; |
2100 | 2100 | ||
2101 | CTCMY_DBF_DEV_NAME(TRACE, dev, ""); | 2101 | CTCMY_DBF_DEV_NAME(TRACE, dev, ""); |
2102 | 2102 | ||
@@ -2133,12 +2133,12 @@ static void dev_action_restart(fsm_instance *fi, int event, void *arg) | |||
2133 | static void dev_action_chup(fsm_instance *fi, int event, void *arg) | 2133 | static void dev_action_chup(fsm_instance *fi, int event, void *arg) |
2134 | { | 2134 | { |
2135 | struct net_device *dev = arg; | 2135 | struct net_device *dev = arg; |
2136 | struct ctcm_priv *priv = dev->priv; | 2136 | struct ctcm_priv *priv = dev->ml_priv; |
2137 | int dev_stat = fsm_getstate(fi); | 2137 | int dev_stat = fsm_getstate(fi); |
2138 | 2138 | ||
2139 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE, | 2139 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE, |
2140 | "%s(%s): priv = %p [%d,%d]\n ", CTCM_FUNTAIL, | 2140 | "%s(%s): priv = %p [%d,%d]\n ", CTCM_FUNTAIL, |
2141 | dev->name, dev->priv, dev_stat, event); | 2141 | dev->name, dev->ml_priv, dev_stat, event); |
2142 | 2142 | ||
2143 | switch (fsm_getstate(fi)) { | 2143 | switch (fsm_getstate(fi)) { |
2144 | case DEV_STATE_STARTWAIT_RXTX: | 2144 | case DEV_STATE_STARTWAIT_RXTX: |
@@ -2195,7 +2195,7 @@ static void dev_action_chdown(fsm_instance *fi, int event, void *arg) | |||
2195 | { | 2195 | { |
2196 | 2196 | ||
2197 | struct net_device *dev = arg; | 2197 | struct net_device *dev = arg; |
2198 | struct ctcm_priv *priv = dev->priv; | 2198 | struct ctcm_priv *priv = dev->ml_priv; |
2199 | 2199 | ||
2200 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); | 2200 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); |
2201 | 2201 | ||
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 126a3ebb8ab2..b11fec24c7d2 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c | |||
@@ -69,7 +69,7 @@ struct channel *channels; | |||
69 | void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) | 69 | void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) |
70 | { | 70 | { |
71 | struct net_device *dev = ch->netdev; | 71 | struct net_device *dev = ch->netdev; |
72 | struct ctcm_priv *priv = dev->priv; | 72 | struct ctcm_priv *priv = dev->ml_priv; |
73 | __u16 len = *((__u16 *) pskb->data); | 73 | __u16 len = *((__u16 *) pskb->data); |
74 | 74 | ||
75 | skb_put(pskb, 2 + LL_HEADER_LENGTH); | 75 | skb_put(pskb, 2 + LL_HEADER_LENGTH); |
@@ -414,7 +414,7 @@ int ctcm_ch_alloc_buffer(struct channel *ch) | |||
414 | */ | 414 | */ |
415 | int ctcm_open(struct net_device *dev) | 415 | int ctcm_open(struct net_device *dev) |
416 | { | 416 | { |
417 | struct ctcm_priv *priv = dev->priv; | 417 | struct ctcm_priv *priv = dev->ml_priv; |
418 | 418 | ||
419 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); | 419 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); |
420 | if (!IS_MPC(priv)) | 420 | if (!IS_MPC(priv)) |
@@ -432,7 +432,7 @@ int ctcm_open(struct net_device *dev) | |||
432 | */ | 432 | */ |
433 | int ctcm_close(struct net_device *dev) | 433 | int ctcm_close(struct net_device *dev) |
434 | { | 434 | { |
435 | struct ctcm_priv *priv = dev->priv; | 435 | struct ctcm_priv *priv = dev->ml_priv; |
436 | 436 | ||
437 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); | 437 | CTCMY_DBF_DEV_NAME(SETUP, dev, ""); |
438 | if (!IS_MPC(priv)) | 438 | if (!IS_MPC(priv)) |
@@ -573,7 +573,7 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) | |||
573 | skb_pull(skb, LL_HEADER_LENGTH + 2); | 573 | skb_pull(skb, LL_HEADER_LENGTH + 2); |
574 | } else if (ccw_idx == 0) { | 574 | } else if (ccw_idx == 0) { |
575 | struct net_device *dev = ch->netdev; | 575 | struct net_device *dev = ch->netdev; |
576 | struct ctcm_priv *priv = dev->priv; | 576 | struct ctcm_priv *priv = dev->ml_priv; |
577 | priv->stats.tx_packets++; | 577 | priv->stats.tx_packets++; |
578 | priv->stats.tx_bytes += skb->len - LL_HEADER_LENGTH; | 578 | priv->stats.tx_bytes += skb->len - LL_HEADER_LENGTH; |
579 | } | 579 | } |
@@ -592,7 +592,7 @@ static void ctcmpc_send_sweep_req(struct channel *rch) | |||
592 | struct channel *ch; | 592 | struct channel *ch; |
593 | /* int rc = 0; */ | 593 | /* int rc = 0; */ |
594 | 594 | ||
595 | priv = dev->priv; | 595 | priv = dev->ml_priv; |
596 | grp = priv->mpcg; | 596 | grp = priv->mpcg; |
597 | ch = priv->channel[WRITE]; | 597 | ch = priv->channel[WRITE]; |
598 | 598 | ||
@@ -652,7 +652,7 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) | |||
652 | { | 652 | { |
653 | struct pdu *p_header; | 653 | struct pdu *p_header; |
654 | struct net_device *dev = ch->netdev; | 654 | struct net_device *dev = ch->netdev; |
655 | struct ctcm_priv *priv = dev->priv; | 655 | struct ctcm_priv *priv = dev->ml_priv; |
656 | struct mpc_group *grp = priv->mpcg; | 656 | struct mpc_group *grp = priv->mpcg; |
657 | struct th_header *header; | 657 | struct th_header *header; |
658 | struct sk_buff *nskb; | 658 | struct sk_buff *nskb; |
@@ -867,7 +867,7 @@ done: | |||
867 | /* first merge version - leaving both functions separated */ | 867 | /* first merge version - leaving both functions separated */ |
868 | static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) | 868 | static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) |
869 | { | 869 | { |
870 | struct ctcm_priv *priv = dev->priv; | 870 | struct ctcm_priv *priv = dev->ml_priv; |
871 | 871 | ||
872 | if (skb == NULL) { | 872 | if (skb == NULL) { |
873 | CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, | 873 | CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, |
@@ -911,7 +911,7 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) | |||
911 | static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) | 911 | static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) |
912 | { | 912 | { |
913 | int len = 0; | 913 | int len = 0; |
914 | struct ctcm_priv *priv = dev->priv; | 914 | struct ctcm_priv *priv = dev->ml_priv; |
915 | struct mpc_group *grp = priv->mpcg; | 915 | struct mpc_group *grp = priv->mpcg; |
916 | struct sk_buff *newskb = NULL; | 916 | struct sk_buff *newskb = NULL; |
917 | 917 | ||
@@ -1025,7 +1025,7 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu) | |||
1025 | if (new_mtu < 576 || new_mtu > 65527) | 1025 | if (new_mtu < 576 || new_mtu > 65527) |
1026 | return -EINVAL; | 1026 | return -EINVAL; |
1027 | 1027 | ||
1028 | priv = dev->priv; | 1028 | priv = dev->ml_priv; |
1029 | max_bufsize = priv->channel[READ]->max_bufsize; | 1029 | max_bufsize = priv->channel[READ]->max_bufsize; |
1030 | 1030 | ||
1031 | if (IS_MPC(priv)) { | 1031 | if (IS_MPC(priv)) { |
@@ -1050,7 +1050,7 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu) | |||
1050 | */ | 1050 | */ |
1051 | static struct net_device_stats *ctcm_stats(struct net_device *dev) | 1051 | static struct net_device_stats *ctcm_stats(struct net_device *dev) |
1052 | { | 1052 | { |
1053 | return &((struct ctcm_priv *)dev->priv)->stats; | 1053 | return &((struct ctcm_priv *)dev->ml_priv)->stats; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | static void ctcm_free_netdevice(struct net_device *dev) | 1056 | static void ctcm_free_netdevice(struct net_device *dev) |
@@ -1060,7 +1060,7 @@ static void ctcm_free_netdevice(struct net_device *dev) | |||
1060 | 1060 | ||
1061 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, | 1061 | CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, |
1062 | "%s(%s)", CTCM_FUNTAIL, dev->name); | 1062 | "%s(%s)", CTCM_FUNTAIL, dev->name); |
1063 | priv = dev->priv; | 1063 | priv = dev->ml_priv; |
1064 | if (priv) { | 1064 | if (priv) { |
1065 | grp = priv->mpcg; | 1065 | grp = priv->mpcg; |
1066 | if (grp) { | 1066 | if (grp) { |
@@ -1125,7 +1125,7 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv) | |||
1125 | CTCM_FUNTAIL); | 1125 | CTCM_FUNTAIL); |
1126 | return NULL; | 1126 | return NULL; |
1127 | } | 1127 | } |
1128 | dev->priv = priv; | 1128 | dev->ml_priv = priv; |
1129 | priv->fsm = init_fsm("ctcmdev", dev_state_names, dev_event_names, | 1129 | priv->fsm = init_fsm("ctcmdev", dev_state_names, dev_event_names, |
1130 | CTCM_NR_DEV_STATES, CTCM_NR_DEV_EVENTS, | 1130 | CTCM_NR_DEV_STATES, CTCM_NR_DEV_EVENTS, |
1131 | dev_fsm, dev_fsm_len, GFP_KERNEL); | 1131 | dev_fsm, dev_fsm_len, GFP_KERNEL); |
diff --git a/drivers/s390/net/ctcm_main.h b/drivers/s390/net/ctcm_main.h index a72e0feeb27f..8e10ee86a5ee 100644 --- a/drivers/s390/net/ctcm_main.h +++ b/drivers/s390/net/ctcm_main.h | |||
@@ -229,14 +229,14 @@ void ctcm_remove_files(struct device *dev); | |||
229 | */ | 229 | */ |
230 | static inline void ctcm_clear_busy_do(struct net_device *dev) | 230 | static inline void ctcm_clear_busy_do(struct net_device *dev) |
231 | { | 231 | { |
232 | clear_bit(0, &(((struct ctcm_priv *)dev->priv)->tbusy)); | 232 | clear_bit(0, &(((struct ctcm_priv *)dev->ml_priv)->tbusy)); |
233 | netif_wake_queue(dev); | 233 | netif_wake_queue(dev); |
234 | } | 234 | } |
235 | 235 | ||
236 | static inline void ctcm_clear_busy(struct net_device *dev) | 236 | static inline void ctcm_clear_busy(struct net_device *dev) |
237 | { | 237 | { |
238 | struct mpc_group *grp; | 238 | struct mpc_group *grp; |
239 | grp = ((struct ctcm_priv *)dev->priv)->mpcg; | 239 | grp = ((struct ctcm_priv *)dev->ml_priv)->mpcg; |
240 | 240 | ||
241 | if (!(grp && grp->in_sweep)) | 241 | if (!(grp && grp->in_sweep)) |
242 | ctcm_clear_busy_do(dev); | 242 | ctcm_clear_busy_do(dev); |
@@ -246,7 +246,8 @@ static inline void ctcm_clear_busy(struct net_device *dev) | |||
246 | static inline int ctcm_test_and_set_busy(struct net_device *dev) | 246 | static inline int ctcm_test_and_set_busy(struct net_device *dev) |
247 | { | 247 | { |
248 | netif_stop_queue(dev); | 248 | netif_stop_queue(dev); |
249 | return test_and_set_bit(0, &(((struct ctcm_priv *)dev->priv)->tbusy)); | 249 | return test_and_set_bit(0, |
250 | &(((struct ctcm_priv *)dev->ml_priv)->tbusy)); | ||
250 | } | 251 | } |
251 | 252 | ||
252 | extern int loglevel; | 253 | extern int loglevel; |
@@ -292,7 +293,7 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv); | |||
292 | #define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC) | 293 | #define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC) |
293 | 294 | ||
294 | /* test if struct ctcm_priv of struct net_device has MPC protocol setting */ | 295 | /* test if struct ctcm_priv of struct net_device has MPC protocol setting */ |
295 | #define IS_MPCDEV(d) IS_MPC((struct ctcm_priv *)d->priv) | 296 | #define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv) |
296 | 297 | ||
297 | static inline gfp_t gfp_type(void) | 298 | static inline gfp_t gfp_type(void) |
298 | { | 299 | { |
diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 2de1e2fccbf9..cbe470493bf0 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c | |||
@@ -312,10 +312,10 @@ static struct net_device *ctcmpc_get_dev(int port_num) | |||
312 | CTCM_FUNTAIL, device); | 312 | CTCM_FUNTAIL, device); |
313 | return NULL; | 313 | return NULL; |
314 | } | 314 | } |
315 | priv = dev->priv; | 315 | priv = dev->ml_priv; |
316 | if (priv == NULL) { | 316 | if (priv == NULL) { |
317 | CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, | 317 | CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, |
318 | "%s(%s): dev->priv is NULL", | 318 | "%s(%s): dev->ml_priv is NULL", |
319 | CTCM_FUNTAIL, device); | 319 | CTCM_FUNTAIL, device); |
320 | return NULL; | 320 | return NULL; |
321 | } | 321 | } |
@@ -344,7 +344,7 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int)) | |||
344 | dev = ctcmpc_get_dev(port_num); | 344 | dev = ctcmpc_get_dev(port_num); |
345 | if (dev == NULL) | 345 | if (dev == NULL) |
346 | return 1; | 346 | return 1; |
347 | priv = dev->priv; | 347 | priv = dev->ml_priv; |
348 | grp = priv->mpcg; | 348 | grp = priv->mpcg; |
349 | 349 | ||
350 | grp->allochanfunc = callback; | 350 | grp->allochanfunc = callback; |
@@ -416,7 +416,7 @@ void ctc_mpc_establish_connectivity(int port_num, | |||
416 | dev = ctcmpc_get_dev(port_num); | 416 | dev = ctcmpc_get_dev(port_num); |
417 | if (dev == NULL) | 417 | if (dev == NULL) |
418 | return; | 418 | return; |
419 | priv = dev->priv; | 419 | priv = dev->ml_priv; |
420 | grp = priv->mpcg; | 420 | grp = priv->mpcg; |
421 | rch = priv->channel[READ]; | 421 | rch = priv->channel[READ]; |
422 | wch = priv->channel[WRITE]; | 422 | wch = priv->channel[WRITE]; |
@@ -534,7 +534,7 @@ void ctc_mpc_dealloc_ch(int port_num) | |||
534 | dev = ctcmpc_get_dev(port_num); | 534 | dev = ctcmpc_get_dev(port_num); |
535 | if (dev == NULL) | 535 | if (dev == NULL) |
536 | return; | 536 | return; |
537 | priv = dev->priv; | 537 | priv = dev->ml_priv; |
538 | grp = priv->mpcg; | 538 | grp = priv->mpcg; |
539 | 539 | ||
540 | CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_DEBUG, | 540 | CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_DEBUG, |
@@ -570,7 +570,7 @@ void ctc_mpc_flow_control(int port_num, int flowc) | |||
570 | dev = ctcmpc_get_dev(port_num); | 570 | dev = ctcmpc_get_dev(port_num); |
571 | if (dev == NULL) | 571 | if (dev == NULL) |
572 | return; | 572 | return; |
573 | priv = dev->priv; | 573 | priv = dev->ml_priv; |
574 | grp = priv->mpcg; | 574 | grp = priv->mpcg; |
575 | 575 | ||
576 | CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG, | 576 | CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG, |
@@ -619,7 +619,7 @@ static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo) | |||
619 | { | 619 | { |
620 | struct channel *rch = mpcginfo->ch; | 620 | struct channel *rch = mpcginfo->ch; |
621 | struct net_device *dev = rch->netdev; | 621 | struct net_device *dev = rch->netdev; |
622 | struct ctcm_priv *priv = dev->priv; | 622 | struct ctcm_priv *priv = dev->ml_priv; |
623 | struct mpc_group *grp = priv->mpcg; | 623 | struct mpc_group *grp = priv->mpcg; |
624 | struct channel *ch = priv->channel[WRITE]; | 624 | struct channel *ch = priv->channel[WRITE]; |
625 | 625 | ||
@@ -650,7 +650,7 @@ static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo) | |||
650 | static void ctcmpc_send_sweep_resp(struct channel *rch) | 650 | static void ctcmpc_send_sweep_resp(struct channel *rch) |
651 | { | 651 | { |
652 | struct net_device *dev = rch->netdev; | 652 | struct net_device *dev = rch->netdev; |
653 | struct ctcm_priv *priv = dev->priv; | 653 | struct ctcm_priv *priv = dev->ml_priv; |
654 | struct mpc_group *grp = priv->mpcg; | 654 | struct mpc_group *grp = priv->mpcg; |
655 | int rc = 0; | 655 | int rc = 0; |
656 | struct th_sweep *header; | 656 | struct th_sweep *header; |
@@ -712,7 +712,7 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo) | |||
712 | { | 712 | { |
713 | struct channel *rch = mpcginfo->ch; | 713 | struct channel *rch = mpcginfo->ch; |
714 | struct net_device *dev = rch->netdev; | 714 | struct net_device *dev = rch->netdev; |
715 | struct ctcm_priv *priv = dev->priv; | 715 | struct ctcm_priv *priv = dev->ml_priv; |
716 | struct mpc_group *grp = priv->mpcg; | 716 | struct mpc_group *grp = priv->mpcg; |
717 | struct channel *ch = priv->channel[WRITE]; | 717 | struct channel *ch = priv->channel[WRITE]; |
718 | 718 | ||
@@ -846,7 +846,7 @@ static int mpcg_fsm_len = ARRAY_SIZE(mpcg_fsm); | |||
846 | static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) | 846 | static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) |
847 | { | 847 | { |
848 | struct net_device *dev = arg; | 848 | struct net_device *dev = arg; |
849 | struct ctcm_priv *priv = dev->priv; | 849 | struct ctcm_priv *priv = dev->ml_priv; |
850 | struct mpc_group *grp = priv->mpcg; | 850 | struct mpc_group *grp = priv->mpcg; |
851 | 851 | ||
852 | if (grp == NULL) { | 852 | if (grp == NULL) { |
@@ -890,7 +890,7 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) | |||
890 | void mpc_group_ready(unsigned long adev) | 890 | void mpc_group_ready(unsigned long adev) |
891 | { | 891 | { |
892 | struct net_device *dev = (struct net_device *)adev; | 892 | struct net_device *dev = (struct net_device *)adev; |
893 | struct ctcm_priv *priv = dev->priv; | 893 | struct ctcm_priv *priv = dev->ml_priv; |
894 | struct mpc_group *grp = priv->mpcg; | 894 | struct mpc_group *grp = priv->mpcg; |
895 | struct channel *ch = NULL; | 895 | struct channel *ch = NULL; |
896 | 896 | ||
@@ -946,7 +946,7 @@ void mpc_group_ready(unsigned long adev) | |||
946 | void mpc_channel_action(struct channel *ch, int direction, int action) | 946 | void mpc_channel_action(struct channel *ch, int direction, int action) |
947 | { | 947 | { |
948 | struct net_device *dev = ch->netdev; | 948 | struct net_device *dev = ch->netdev; |
949 | struct ctcm_priv *priv = dev->priv; | 949 | struct ctcm_priv *priv = dev->ml_priv; |
950 | struct mpc_group *grp = priv->mpcg; | 950 | struct mpc_group *grp = priv->mpcg; |
951 | 951 | ||
952 | if (grp == NULL) { | 952 | if (grp == NULL) { |
@@ -1056,7 +1056,7 @@ done: | |||
1056 | static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) | 1056 | static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) |
1057 | { | 1057 | { |
1058 | struct net_device *dev = ch->netdev; | 1058 | struct net_device *dev = ch->netdev; |
1059 | struct ctcm_priv *priv = dev->priv; | 1059 | struct ctcm_priv *priv = dev->ml_priv; |
1060 | struct mpc_group *grp = priv->mpcg; | 1060 | struct mpc_group *grp = priv->mpcg; |
1061 | struct pdu *curr_pdu; | 1061 | struct pdu *curr_pdu; |
1062 | struct mpcg_info *mpcginfo; | 1062 | struct mpcg_info *mpcginfo; |
@@ -1254,7 +1254,7 @@ void ctcmpc_bh(unsigned long thischan) | |||
1254 | struct channel *ch = (struct channel *)thischan; | 1254 | struct channel *ch = (struct channel *)thischan; |
1255 | struct sk_buff *skb; | 1255 | struct sk_buff *skb; |
1256 | struct net_device *dev = ch->netdev; | 1256 | struct net_device *dev = ch->netdev; |
1257 | struct ctcm_priv *priv = dev->priv; | 1257 | struct ctcm_priv *priv = dev->ml_priv; |
1258 | struct mpc_group *grp = priv->mpcg; | 1258 | struct mpc_group *grp = priv->mpcg; |
1259 | 1259 | ||
1260 | CTCM_PR_DEBUG("%s cp:%i enter: %s() %s\n", | 1260 | CTCM_PR_DEBUG("%s cp:%i enter: %s() %s\n", |
@@ -1376,7 +1376,7 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg) | |||
1376 | BUG_ON(dev == NULL); | 1376 | BUG_ON(dev == NULL); |
1377 | CTCM_PR_DEBUG("Enter %s: %s\n", __func__, dev->name); | 1377 | CTCM_PR_DEBUG("Enter %s: %s\n", __func__, dev->name); |
1378 | 1378 | ||
1379 | priv = dev->priv; | 1379 | priv = dev->ml_priv; |
1380 | grp = priv->mpcg; | 1380 | grp = priv->mpcg; |
1381 | grp->flow_off_called = 0; | 1381 | grp->flow_off_called = 0; |
1382 | fsm_deltimer(&grp->timer); | 1382 | fsm_deltimer(&grp->timer); |
@@ -1482,7 +1482,7 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg) | |||
1482 | 1482 | ||
1483 | BUG_ON(dev == NULL); | 1483 | BUG_ON(dev == NULL); |
1484 | 1484 | ||
1485 | priv = dev->priv; | 1485 | priv = dev->ml_priv; |
1486 | grp = priv->mpcg; | 1486 | grp = priv->mpcg; |
1487 | wch = priv->channel[WRITE]; | 1487 | wch = priv->channel[WRITE]; |
1488 | rch = priv->channel[READ]; | 1488 | rch = priv->channel[READ]; |
@@ -1520,7 +1520,7 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg) | |||
1520 | if (ch) { | 1520 | if (ch) { |
1521 | dev = ch->netdev; | 1521 | dev = ch->netdev; |
1522 | if (dev) { | 1522 | if (dev) { |
1523 | priv = dev->priv; | 1523 | priv = dev->ml_priv; |
1524 | if (priv) { | 1524 | if (priv) { |
1525 | CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE, | 1525 | CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE, |
1526 | "%s: %s: %s\n", | 1526 | "%s: %s: %s\n", |
@@ -1568,7 +1568,7 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo) | |||
1568 | { | 1568 | { |
1569 | struct channel *ch = mpcginfo->ch; | 1569 | struct channel *ch = mpcginfo->ch; |
1570 | struct net_device *dev = ch->netdev; | 1570 | struct net_device *dev = ch->netdev; |
1571 | struct ctcm_priv *priv = dev->priv; | 1571 | struct ctcm_priv *priv = dev->ml_priv; |
1572 | struct mpc_group *grp = priv->mpcg; | 1572 | struct mpc_group *grp = priv->mpcg; |
1573 | struct xid2 *xid = mpcginfo->xid; | 1573 | struct xid2 *xid = mpcginfo->xid; |
1574 | int rc = 0; | 1574 | int rc = 0; |
@@ -1865,7 +1865,7 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg) | |||
1865 | { | 1865 | { |
1866 | struct channel *ch = arg; | 1866 | struct channel *ch = arg; |
1867 | struct net_device *dev = ch->netdev; | 1867 | struct net_device *dev = ch->netdev; |
1868 | struct ctcm_priv *priv = dev->priv; | 1868 | struct ctcm_priv *priv = dev->ml_priv; |
1869 | struct mpc_group *grp = priv->mpcg; | 1869 | struct mpc_group *grp = priv->mpcg; |
1870 | 1870 | ||
1871 | CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n", | 1871 | CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n", |
@@ -1905,7 +1905,7 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg) | |||
1905 | static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg) | 1905 | static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg) |
1906 | { | 1906 | { |
1907 | struct net_device *dev = arg; | 1907 | struct net_device *dev = arg; |
1908 | struct ctcm_priv *priv = dev->priv; | 1908 | struct ctcm_priv *priv = dev->ml_priv; |
1909 | struct mpc_group *grp = NULL; | 1909 | struct mpc_group *grp = NULL; |
1910 | int direction; | 1910 | int direction; |
1911 | int send = 0; | 1911 | int send = 0; |
@@ -1982,7 +1982,7 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg) | |||
1982 | struct mpcg_info *mpcginfo = arg; | 1982 | struct mpcg_info *mpcginfo = arg; |
1983 | struct channel *ch = mpcginfo->ch; | 1983 | struct channel *ch = mpcginfo->ch; |
1984 | struct net_device *dev = ch->netdev; | 1984 | struct net_device *dev = ch->netdev; |
1985 | struct ctcm_priv *priv = dev->priv; | 1985 | struct ctcm_priv *priv = dev->ml_priv; |
1986 | struct mpc_group *grp = priv->mpcg; | 1986 | struct mpc_group *grp = priv->mpcg; |
1987 | 1987 | ||
1988 | CTCM_PR_DEBUG("%s: ch-id:%s xid2:%i xid7:%i xidt_p2:%i \n", | 1988 | CTCM_PR_DEBUG("%s: ch-id:%s xid2:%i xid7:%i xidt_p2:%i \n", |
@@ -2044,7 +2044,7 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg) | |||
2044 | struct mpcg_info *mpcginfo = arg; | 2044 | struct mpcg_info *mpcginfo = arg; |
2045 | struct channel *ch = mpcginfo->ch; | 2045 | struct channel *ch = mpcginfo->ch; |
2046 | struct net_device *dev = ch->netdev; | 2046 | struct net_device *dev = ch->netdev; |
2047 | struct ctcm_priv *priv = dev->priv; | 2047 | struct ctcm_priv *priv = dev->ml_priv; |
2048 | struct mpc_group *grp = priv->mpcg; | 2048 | struct mpc_group *grp = priv->mpcg; |
2049 | 2049 | ||
2050 | CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n", | 2050 | CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n", |
@@ -2096,7 +2096,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev) | |||
2096 | __u32 new_len = 0; | 2096 | __u32 new_len = 0; |
2097 | struct sk_buff *skb; | 2097 | struct sk_buff *skb; |
2098 | struct qllc *qllcptr; | 2098 | struct qllc *qllcptr; |
2099 | struct ctcm_priv *priv = dev->priv; | 2099 | struct ctcm_priv *priv = dev->ml_priv; |
2100 | struct mpc_group *grp = priv->mpcg; | 2100 | struct mpc_group *grp = priv->mpcg; |
2101 | 2101 | ||
2102 | CTCM_PR_DEBUG("%s: GROUP STATE: %s\n", | 2102 | CTCM_PR_DEBUG("%s: GROUP STATE: %s\n", |
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index 6de28385b354..9bcfa04d863b 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c | |||
@@ -1412,7 +1412,8 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
1412 | } | 1412 | } |
1413 | /* How far in the ccw chain have we processed? */ | 1413 | /* How far in the ccw chain have we processed? */ |
1414 | if ((channel->state != LCS_CH_STATE_INIT) && | 1414 | if ((channel->state != LCS_CH_STATE_INIT) && |
1415 | (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC)) { | 1415 | (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) && |
1416 | (irb->scsw.cmd.cpa != 0)) { | ||
1416 | index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa) | 1417 | index = (struct ccw1 *) __va((addr_t) irb->scsw.cmd.cpa) |
1417 | - channel->ccws; | 1418 | - channel->ccws; |
1418 | if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) || | 1419 | if ((irb->scsw.cmd.actl & SCSW_ACTL_SUSPENDED) || |
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 80971c21ea1a..bf8a75c92f28 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h | |||
@@ -689,6 +689,7 @@ struct qeth_mc_mac { | |||
689 | struct list_head list; | 689 | struct list_head list; |
690 | __u8 mc_addr[MAX_ADDR_LEN]; | 690 | __u8 mc_addr[MAX_ADDR_LEN]; |
691 | unsigned char mc_addrlen; | 691 | unsigned char mc_addrlen; |
692 | int is_vmac; | ||
692 | }; | 693 | }; |
693 | 694 | ||
694 | struct qeth_card { | 695 | struct qeth_card { |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index bd420d1b9a0d..c7ab1b864516 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -3024,7 +3024,7 @@ static inline void __qeth_fill_buffer(struct sk_buff *skb, | |||
3024 | struct qdio_buffer *buffer, int is_tso, int *next_element_to_fill, | 3024 | struct qdio_buffer *buffer, int is_tso, int *next_element_to_fill, |
3025 | int offset) | 3025 | int offset) |
3026 | { | 3026 | { |
3027 | int length = skb->len; | 3027 | int length = skb->len - offset; |
3028 | int length_here; | 3028 | int length_here; |
3029 | int element; | 3029 | int element; |
3030 | char *data; | 3030 | char *data; |
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index b3cee032f578..3ac3cc1e03cc 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
@@ -177,9 +177,10 @@ static int qeth_l2_send_delgroupmac(struct qeth_card *card, __u8 *mac) | |||
177 | qeth_l2_send_delgroupmac_cb); | 177 | qeth_l2_send_delgroupmac_cb); |
178 | } | 178 | } |
179 | 179 | ||
180 | static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac) | 180 | static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac, int vmac) |
181 | { | 181 | { |
182 | struct qeth_mc_mac *mc; | 182 | struct qeth_mc_mac *mc; |
183 | int rc; | ||
183 | 184 | ||
184 | mc = kmalloc(sizeof(struct qeth_mc_mac), GFP_ATOMIC); | 185 | mc = kmalloc(sizeof(struct qeth_mc_mac), GFP_ATOMIC); |
185 | 186 | ||
@@ -188,8 +189,16 @@ static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac) | |||
188 | 189 | ||
189 | memcpy(mc->mc_addr, mac, OSA_ADDR_LEN); | 190 | memcpy(mc->mc_addr, mac, OSA_ADDR_LEN); |
190 | mc->mc_addrlen = OSA_ADDR_LEN; | 191 | mc->mc_addrlen = OSA_ADDR_LEN; |
192 | mc->is_vmac = vmac; | ||
193 | |||
194 | if (vmac) { | ||
195 | rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC, | ||
196 | NULL); | ||
197 | } else { | ||
198 | rc = qeth_l2_send_setgroupmac(card, mac); | ||
199 | } | ||
191 | 200 | ||
192 | if (!qeth_l2_send_setgroupmac(card, mac)) | 201 | if (!rc) |
193 | list_add_tail(&mc->list, &card->mc_list); | 202 | list_add_tail(&mc->list, &card->mc_list); |
194 | else | 203 | else |
195 | kfree(mc); | 204 | kfree(mc); |
@@ -201,7 +210,11 @@ static void qeth_l2_del_all_mc(struct qeth_card *card) | |||
201 | 210 | ||
202 | spin_lock_bh(&card->mclock); | 211 | spin_lock_bh(&card->mclock); |
203 | list_for_each_entry_safe(mc, tmp, &card->mc_list, list) { | 212 | list_for_each_entry_safe(mc, tmp, &card->mc_list, list) { |
204 | qeth_l2_send_delgroupmac(card, mc->mc_addr); | 213 | if (mc->is_vmac) |
214 | qeth_l2_send_setdelmac(card, mc->mc_addr, | ||
215 | IPA_CMD_DELVMAC, NULL); | ||
216 | else | ||
217 | qeth_l2_send_delgroupmac(card, mc->mc_addr); | ||
205 | list_del(&mc->list); | 218 | list_del(&mc->list); |
206 | kfree(mc); | 219 | kfree(mc); |
207 | } | 220 | } |
@@ -590,7 +603,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p) | |||
590 | static void qeth_l2_set_multicast_list(struct net_device *dev) | 603 | static void qeth_l2_set_multicast_list(struct net_device *dev) |
591 | { | 604 | { |
592 | struct qeth_card *card = dev->ml_priv; | 605 | struct qeth_card *card = dev->ml_priv; |
593 | struct dev_mc_list *dm; | 606 | struct dev_addr_list *dm; |
594 | 607 | ||
595 | if (card->info.type == QETH_CARD_TYPE_OSN) | 608 | if (card->info.type == QETH_CARD_TYPE_OSN) |
596 | return ; | 609 | return ; |
@@ -599,7 +612,11 @@ static void qeth_l2_set_multicast_list(struct net_device *dev) | |||
599 | qeth_l2_del_all_mc(card); | 612 | qeth_l2_del_all_mc(card); |
600 | spin_lock_bh(&card->mclock); | 613 | spin_lock_bh(&card->mclock); |
601 | for (dm = dev->mc_list; dm; dm = dm->next) | 614 | for (dm = dev->mc_list; dm; dm = dm->next) |
602 | qeth_l2_add_mc(card, dm->dmi_addr); | 615 | qeth_l2_add_mc(card, dm->da_addr, 0); |
616 | |||
617 | for (dm = dev->uc_list; dm; dm = dm->next) | ||
618 | qeth_l2_add_mc(card, dm->da_addr, 1); | ||
619 | |||
603 | spin_unlock_bh(&card->mclock); | 620 | spin_unlock_bh(&card->mclock); |
604 | if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) | 621 | if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
605 | return; | 622 | return; |
diff --git a/drivers/s390/net/qeth_l3_sys.c b/drivers/s390/net/qeth_l3_sys.c index ac1993708ae9..210ddb639748 100644 --- a/drivers/s390/net/qeth_l3_sys.c +++ b/drivers/s390/net/qeth_l3_sys.c | |||
@@ -136,7 +136,7 @@ static ssize_t qeth_l3_dev_route6_store(struct device *dev, | |||
136 | return -EINVAL; | 136 | return -EINVAL; |
137 | 137 | ||
138 | if (!qeth_is_supported(card, IPA_IPV6)) { | 138 | if (!qeth_is_supported(card, IPA_IPV6)) { |
139 | return -ENOTSUPP; | 139 | return -EOPNOTSUPP; |
140 | } | 140 | } |
141 | 141 | ||
142 | return qeth_l3_dev_route_store(card, &card->options.route6, | 142 | return qeth_l3_dev_route_store(card, &card->options.route6, |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e5e7d7856454..2a2bc89aba83 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1875,6 +1875,7 @@ static int sd_probe(struct device *dev) | |||
1875 | 1875 | ||
1876 | dev_set_drvdata(dev, sdkp); | 1876 | dev_set_drvdata(dev, sdkp); |
1877 | add_disk(gd); | 1877 | add_disk(gd); |
1878 | blk_register_filter(gd); | ||
1878 | sd_dif_config_host(sdkp); | 1879 | sd_dif_config_host(sdkp); |
1879 | 1880 | ||
1880 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", | 1881 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", |
@@ -1908,6 +1909,7 @@ static int sd_remove(struct device *dev) | |||
1908 | struct scsi_disk *sdkp = dev_get_drvdata(dev); | 1909 | struct scsi_disk *sdkp = dev_get_drvdata(dev); |
1909 | 1910 | ||
1910 | device_del(&sdkp->dev); | 1911 | device_del(&sdkp->dev); |
1912 | blk_unregister_filter(sdkp->disk); | ||
1911 | del_gendisk(sdkp->disk); | 1913 | del_gendisk(sdkp->disk); |
1912 | sd_shutdown(dev); | 1914 | sd_shutdown(dev); |
1913 | 1915 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 3d36270a8b4d..661f9f21650a 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -217,6 +217,18 @@ static int sg_last_dev(void); | |||
217 | #define SZ_SG_IOVEC sizeof(sg_iovec_t) | 217 | #define SZ_SG_IOVEC sizeof(sg_iovec_t) |
218 | #define SZ_SG_REQ_INFO sizeof(sg_req_info_t) | 218 | #define SZ_SG_REQ_INFO sizeof(sg_req_info_t) |
219 | 219 | ||
220 | static int sg_allow_access(struct file *filp, unsigned char *cmd) | ||
221 | { | ||
222 | struct sg_fd *sfp = (struct sg_fd *)filp->private_data; | ||
223 | struct request_queue *q = sfp->parentdp->device->request_queue; | ||
224 | |||
225 | if (sfp->parentdp->device->type == TYPE_SCANNER) | ||
226 | return 0; | ||
227 | |||
228 | return blk_verify_command(&q->cmd_filter, | ||
229 | cmd, filp->f_mode & FMODE_WRITE); | ||
230 | } | ||
231 | |||
220 | static int | 232 | static int |
221 | sg_open(struct inode *inode, struct file *filp) | 233 | sg_open(struct inode *inode, struct file *filp) |
222 | { | 234 | { |
@@ -689,7 +701,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, | |||
689 | sg_remove_request(sfp, srp); | 701 | sg_remove_request(sfp, srp); |
690 | return -EFAULT; | 702 | return -EFAULT; |
691 | } | 703 | } |
692 | if (read_only && !blk_verify_command(file, cmnd)) { | 704 | if (read_only && sg_allow_access(file, cmnd)) { |
693 | sg_remove_request(sfp, srp); | 705 | sg_remove_request(sfp, srp); |
694 | return -EPERM; | 706 | return -EPERM; |
695 | } | 707 | } |
@@ -793,6 +805,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
793 | 805 | ||
794 | if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) | 806 | if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) |
795 | return -ENXIO; | 807 | return -ENXIO; |
808 | |||
796 | SCSI_LOG_TIMEOUT(3, printk("sg_ioctl: %s, cmd=0x%x\n", | 809 | SCSI_LOG_TIMEOUT(3, printk("sg_ioctl: %s, cmd=0x%x\n", |
797 | sdp->disk->disk_name, (int) cmd_in)); | 810 | sdp->disk->disk_name, (int) cmd_in)); |
798 | read_only = (O_RDWR != (filp->f_flags & O_ACCMODE)); | 811 | read_only = (O_RDWR != (filp->f_flags & O_ACCMODE)); |
@@ -1061,7 +1074,7 @@ sg_ioctl(struct inode *inode, struct file *filp, | |||
1061 | 1074 | ||
1062 | if (copy_from_user(&opcode, siocp->data, 1)) | 1075 | if (copy_from_user(&opcode, siocp->data, 1)) |
1063 | return -EFAULT; | 1076 | return -EFAULT; |
1064 | if (!blk_verify_command(filp, &opcode)) | 1077 | if (sg_allow_access(filp, &opcode)) |
1065 | return -EPERM; | 1078 | return -EPERM; |
1066 | } | 1079 | } |
1067 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); | 1080 | return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p); |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 27f5bfd1def3..3292965bfd84 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -656,6 +656,7 @@ static int sr_probe(struct device *dev) | |||
656 | dev_set_drvdata(dev, cd); | 656 | dev_set_drvdata(dev, cd); |
657 | disk->flags |= GENHD_FL_REMOVABLE; | 657 | disk->flags |= GENHD_FL_REMOVABLE; |
658 | add_disk(disk); | 658 | add_disk(disk); |
659 | blk_register_filter(disk); | ||
659 | 660 | ||
660 | sdev_printk(KERN_DEBUG, sdev, | 661 | sdev_printk(KERN_DEBUG, sdev, |
661 | "Attached scsi CD-ROM %s\n", cd->cdi.name); | 662 | "Attached scsi CD-ROM %s\n", cd->cdi.name); |
@@ -894,6 +895,7 @@ static int sr_remove(struct device *dev) | |||
894 | { | 895 | { |
895 | struct scsi_cd *cd = dev_get_drvdata(dev); | 896 | struct scsi_cd *cd = dev_get_drvdata(dev); |
896 | 897 | ||
898 | blk_unregister_filter(cd->disk); | ||
897 | del_gendisk(cd->disk); | 899 | del_gendisk(cd->disk); |
898 | 900 | ||
899 | mutex_lock(&sr_ref_mutex); | 901 | mutex_lock(&sr_ref_mutex); |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 342e12fb1c25..9ccc563d8730 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -1908,15 +1908,23 @@ static int serial8250_startup(struct uart_port *port) | |||
1908 | * kick the UART on a regular basis. | 1908 | * kick the UART on a regular basis. |
1909 | */ | 1909 | */ |
1910 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { | 1910 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { |
1911 | up->bugs |= UART_BUG_THRE; | ||
1911 | pr_debug("ttyS%d - using backup timer\n", port->line); | 1912 | pr_debug("ttyS%d - using backup timer\n", port->line); |
1912 | up->timer.function = serial8250_backup_timeout; | ||
1913 | up->timer.data = (unsigned long)up; | ||
1914 | mod_timer(&up->timer, jiffies + | ||
1915 | poll_timeout(up->port.timeout) + HZ / 5); | ||
1916 | } | 1913 | } |
1917 | } | 1914 | } |
1918 | 1915 | ||
1919 | /* | 1916 | /* |
1917 | * The above check will only give an accurate result the first time | ||
1918 | * the port is opened so this value needs to be preserved. | ||
1919 | */ | ||
1920 | if (up->bugs & UART_BUG_THRE) { | ||
1921 | up->timer.function = serial8250_backup_timeout; | ||
1922 | up->timer.data = (unsigned long)up; | ||
1923 | mod_timer(&up->timer, jiffies + | ||
1924 | poll_timeout(up->port.timeout) + HZ / 5); | ||
1925 | } | ||
1926 | |||
1927 | /* | ||
1920 | * If the "interrupt" for this port doesn't correspond with any | 1928 | * If the "interrupt" for this port doesn't correspond with any |
1921 | * hardware interrupt, we use a timer-based system. The original | 1929 | * hardware interrupt, we use a timer-based system. The original |
1922 | * driver used to do this with IRQ0. | 1930 | * driver used to do this with IRQ0. |
diff --git a/drivers/serial/8250.h b/drivers/serial/8250.h index 78c00162b04e..520260326f3d 100644 --- a/drivers/serial/8250.h +++ b/drivers/serial/8250.h | |||
@@ -47,6 +47,7 @@ struct serial8250_config { | |||
47 | #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ | 47 | #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ |
48 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ | 48 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ |
49 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ | 49 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ |
50 | #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */ | ||
50 | 51 | ||
51 | #define PROBE_RSA (1 << 0) | 52 | #define PROBE_RSA (1 << 0) |
52 | #define PROBE_ANY (~0) | 53 | #define PROBE_ANY (~0) |
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c index efcd44344fb1..4a0d30bed9f1 100644 --- a/drivers/serial/bfin_5xx.c +++ b/drivers/serial/bfin_5xx.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <asm/gpio.h> | 30 | #include <asm/gpio.h> |
31 | #include <asm/mach/bfin_serial_5xx.h> | 31 | #include <mach/bfin_serial_5xx.h> |
32 | 32 | ||
33 | #ifdef CONFIG_SERIAL_BFIN_DMA | 33 | #ifdef CONFIG_SERIAL_BFIN_DMA |
34 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 1eb64d08b60a..95b3ec89c126 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -208,7 +208,7 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
208 | if (cpu_is_omap16xx()) | 208 | if (cpu_is_omap16xx()) |
209 | ocpi_enable(); | 209 | ocpi_enable(); |
210 | 210 | ||
211 | #ifdef CONFIG_ARCH_OMAP_OTG | 211 | #ifdef CONFIG_USB_OTG |
212 | if (need_transceiver) { | 212 | if (need_transceiver) { |
213 | ohci->transceiver = otg_get_transceiver(); | 213 | ohci->transceiver = otg_get_transceiver(); |
214 | if (ohci->transceiver) { | 214 | if (ohci->transceiver) { |
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 7b74238ad1c7..e980766bb84b 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c | |||
@@ -161,7 +161,7 @@ static int usb_console_setup(struct console *co, char *options) | |||
161 | if (serial->type->set_termios) { | 161 | if (serial->type->set_termios) { |
162 | termios->c_cflag = cflag; | 162 | termios->c_cflag = cflag; |
163 | tty_termios_encode_baud_rate(termios, baud, baud); | 163 | tty_termios_encode_baud_rate(termios, baud, baud); |
164 | serial->type->set_termios(NULL, port, &dummy); | 164 | serial->type->set_termios(tty, port, &dummy); |
165 | 165 | ||
166 | port->port.tty = NULL; | 166 | port->port.tty = NULL; |
167 | kfree(termios); | 167 | kfree(termios); |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 70d135e0cc47..d85a74c64b54 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -172,11 +172,6 @@ config FB_DEFERRED_IO | |||
172 | bool | 172 | bool |
173 | depends on FB | 173 | depends on FB |
174 | 174 | ||
175 | config FB_METRONOME | ||
176 | tristate | ||
177 | depends on FB | ||
178 | depends on FB_DEFERRED_IO | ||
179 | |||
180 | config FB_HECUBA | 175 | config FB_HECUBA |
181 | tristate | 176 | tristate |
182 | depends on FB | 177 | depends on FB |
@@ -1974,19 +1969,6 @@ config FB_XILINX | |||
1974 | framebuffer. ML300 carries a 640*480 LCD display on the board, | 1969 | framebuffer. ML300 carries a 640*480 LCD display on the board, |
1975 | ML403 uses a standard DB15 VGA connector. | 1970 | ML403 uses a standard DB15 VGA connector. |
1976 | 1971 | ||
1977 | config FB_AM200EPD | ||
1978 | tristate "AM-200 E-Ink EPD devkit support" | ||
1979 | depends on FB && ARCH_PXA && MMU | ||
1980 | select FB_SYS_FILLRECT | ||
1981 | select FB_SYS_COPYAREA | ||
1982 | select FB_SYS_IMAGEBLIT | ||
1983 | select FB_SYS_FOPS | ||
1984 | select FB_DEFERRED_IO | ||
1985 | select FB_METRONOME | ||
1986 | help | ||
1987 | This enables support for the Metronome display controller used on | ||
1988 | the E-Ink AM-200 EPD devkit. | ||
1989 | |||
1990 | config FB_COBALT | 1972 | config FB_COBALT |
1991 | tristate "Cobalt server LCD frame buffer support" | 1973 | tristate "Cobalt server LCD frame buffer support" |
1992 | depends on FB && MIPS_COBALT | 1974 | depends on FB && MIPS_COBALT |
@@ -2041,6 +2023,19 @@ config XEN_FBDEV_FRONTEND | |||
2041 | frame buffer driver. It communicates with a back-end | 2023 | frame buffer driver. It communicates with a back-end |
2042 | in another domain. | 2024 | in another domain. |
2043 | 2025 | ||
2026 | config FB_METRONOME | ||
2027 | tristate "E-Ink Metronome/8track controller support" | ||
2028 | depends on FB | ||
2029 | select FB_SYS_FILLRECT | ||
2030 | select FB_SYS_COPYAREA | ||
2031 | select FB_SYS_IMAGEBLIT | ||
2032 | select FB_SYS_FOPS | ||
2033 | select FB_DEFERRED_IO | ||
2034 | help | ||
2035 | This driver implements support for the E-Ink Metronome | ||
2036 | controller. The pre-release name for this device was 8track | ||
2037 | and could also have been called by some vendors as PVI-nnnn. | ||
2038 | |||
2044 | source "drivers/video/omap/Kconfig" | 2039 | source "drivers/video/omap/Kconfig" |
2045 | 2040 | ||
2046 | source "drivers/video/backlight/Kconfig" | 2041 | source "drivers/video/backlight/Kconfig" |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index a6b55297a7fb..ad0330bf9be3 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -29,7 +29,6 @@ obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o | |||
29 | 29 | ||
30 | # Hardware specific drivers go first | 30 | # Hardware specific drivers go first |
31 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o | 31 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o |
32 | obj-$(CONFIG_FB_AM200EPD) += am200epd.o | ||
33 | obj-$(CONFIG_FB_ARC) += arcfb.o | 32 | obj-$(CONFIG_FB_ARC) += arcfb.o |
34 | obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o | 33 | obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o |
35 | obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o | 34 | obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o |
diff --git a/drivers/video/am200epd.c b/drivers/video/am200epd.c deleted file mode 100644 index 0c35b8b0160e..000000000000 --- a/drivers/video/am200epd.c +++ /dev/null | |||
@@ -1,295 +0,0 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/am200epd.c -- Platform device for AM200 EPD kit | ||
3 | * | ||
4 | * Copyright (C) 2008, Jaya Kumar | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive for | ||
8 | * more details. | ||
9 | * | ||
10 | * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven. | ||
11 | * | ||
12 | * This work was made possible by help and equipment support from E-Ink | ||
13 | * Corporation. http://support.eink.com/community | ||
14 | * | ||
15 | * This driver is written to be used with the Metronome display controller. | ||
16 | * on the AM200 EPD prototype kit/development kit with an E-Ink 800x600 | ||
17 | * Vizplex EPD on a Gumstix board using the Lyre interface board. | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/string.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/fb.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <linux/list.h> | ||
31 | #include <linux/uaccess.h> | ||
32 | #include <linux/irq.h> | ||
33 | |||
34 | #include <video/metronomefb.h> | ||
35 | |||
36 | #include <mach/pxa-regs.h> | ||
37 | |||
38 | /* register offsets for gpio control */ | ||
39 | #define LED_GPIO_PIN 51 | ||
40 | #define STDBY_GPIO_PIN 48 | ||
41 | #define RST_GPIO_PIN 49 | ||
42 | #define RDY_GPIO_PIN 32 | ||
43 | #define ERR_GPIO_PIN 17 | ||
44 | #define PCBPWR_GPIO_PIN 16 | ||
45 | |||
46 | #define AF_SEL_GPIO_N 0x3 | ||
47 | #define GAFR0_U_OFFSET(pin) ((pin - 16) * 2) | ||
48 | #define GAFR1_L_OFFSET(pin) ((pin - 32) * 2) | ||
49 | #define GAFR1_U_OFFSET(pin) ((pin - 48) * 2) | ||
50 | #define GPDR1_OFFSET(pin) (pin - 32) | ||
51 | #define GPCR1_OFFSET(pin) (pin - 32) | ||
52 | #define GPSR1_OFFSET(pin) (pin - 32) | ||
53 | #define GPCR0_OFFSET(pin) (pin) | ||
54 | #define GPSR0_OFFSET(pin) (pin) | ||
55 | |||
56 | static void am200_set_gpio_output(int pin, int val) | ||
57 | { | ||
58 | u8 index; | ||
59 | |||
60 | index = pin >> 4; | ||
61 | |||
62 | switch (index) { | ||
63 | case 1: | ||
64 | if (val) | ||
65 | GPSR0 |= (1 << GPSR0_OFFSET(pin)); | ||
66 | else | ||
67 | GPCR0 |= (1 << GPCR0_OFFSET(pin)); | ||
68 | break; | ||
69 | case 2: | ||
70 | break; | ||
71 | case 3: | ||
72 | if (val) | ||
73 | GPSR1 |= (1 << GPSR1_OFFSET(pin)); | ||
74 | else | ||
75 | GPCR1 |= (1 << GPCR1_OFFSET(pin)); | ||
76 | break; | ||
77 | default: | ||
78 | printk(KERN_ERR "unimplemented\n"); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void __devinit am200_init_gpio_pin(int pin, int dir) | ||
83 | { | ||
84 | u8 index; | ||
85 | /* dir 0 is output, 1 is input | ||
86 | - do 2 things here: | ||
87 | - set gpio alternate function to standard gpio | ||
88 | - set gpio direction to input or output */ | ||
89 | |||
90 | index = pin >> 4; | ||
91 | switch (index) { | ||
92 | case 1: | ||
93 | GAFR0_U &= ~(AF_SEL_GPIO_N << GAFR0_U_OFFSET(pin)); | ||
94 | |||
95 | if (dir) | ||
96 | GPDR0 &= ~(1 << pin); | ||
97 | else | ||
98 | GPDR0 |= (1 << pin); | ||
99 | break; | ||
100 | case 2: | ||
101 | GAFR1_L &= ~(AF_SEL_GPIO_N << GAFR1_L_OFFSET(pin)); | ||
102 | |||
103 | if (dir) | ||
104 | GPDR1 &= ~(1 << GPDR1_OFFSET(pin)); | ||
105 | else | ||
106 | GPDR1 |= (1 << GPDR1_OFFSET(pin)); | ||
107 | break; | ||
108 | case 3: | ||
109 | GAFR1_U &= ~(AF_SEL_GPIO_N << GAFR1_U_OFFSET(pin)); | ||
110 | |||
111 | if (dir) | ||
112 | GPDR1 &= ~(1 << GPDR1_OFFSET(pin)); | ||
113 | else | ||
114 | GPDR1 |= (1 << GPDR1_OFFSET(pin)); | ||
115 | break; | ||
116 | default: | ||
117 | printk(KERN_ERR "unimplemented\n"); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | static void am200_init_gpio_regs(struct metronomefb_par *par) | ||
122 | { | ||
123 | am200_init_gpio_pin(LED_GPIO_PIN, 0); | ||
124 | am200_set_gpio_output(LED_GPIO_PIN, 0); | ||
125 | |||
126 | am200_init_gpio_pin(STDBY_GPIO_PIN, 0); | ||
127 | am200_set_gpio_output(STDBY_GPIO_PIN, 0); | ||
128 | |||
129 | am200_init_gpio_pin(RST_GPIO_PIN, 0); | ||
130 | am200_set_gpio_output(RST_GPIO_PIN, 0); | ||
131 | |||
132 | am200_init_gpio_pin(RDY_GPIO_PIN, 1); | ||
133 | |||
134 | am200_init_gpio_pin(ERR_GPIO_PIN, 1); | ||
135 | |||
136 | am200_init_gpio_pin(PCBPWR_GPIO_PIN, 0); | ||
137 | am200_set_gpio_output(PCBPWR_GPIO_PIN, 0); | ||
138 | } | ||
139 | |||
140 | static void am200_disable_lcd_controller(struct metronomefb_par *par) | ||
141 | { | ||
142 | LCSR = 0xffffffff; /* Clear LCD Status Register */ | ||
143 | LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */ | ||
144 | |||
145 | /* we reset and just wait for things to settle */ | ||
146 | msleep(200); | ||
147 | } | ||
148 | |||
149 | static void am200_enable_lcd_controller(struct metronomefb_par *par) | ||
150 | { | ||
151 | LCSR = 0xffffffff; | ||
152 | FDADR0 = par->metromem_desc_dma; | ||
153 | LCCR0 |= LCCR0_ENB; | ||
154 | } | ||
155 | |||
156 | static void am200_init_lcdc_regs(struct metronomefb_par *par) | ||
157 | { | ||
158 | /* here we do: | ||
159 | - disable the lcd controller | ||
160 | - setup lcd control registers | ||
161 | - setup dma descriptor | ||
162 | - reenable lcd controller | ||
163 | */ | ||
164 | |||
165 | /* disable the lcd controller */ | ||
166 | am200_disable_lcd_controller(par); | ||
167 | |||
168 | /* setup lcd control registers */ | ||
169 | LCCR0 = LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | LCCR0_PAS | ||
170 | | LCCR0_QDM | LCCR0_BM | LCCR0_OUM; | ||
171 | |||
172 | LCCR1 = (par->info->var.xres/2 - 1) /* pixels per line */ | ||
173 | | (27 << 10) /* hsync pulse width - 1 */ | ||
174 | | (33 << 16) /* eol pixel count */ | ||
175 | | (33 << 24); /* bol pixel count */ | ||
176 | |||
177 | LCCR2 = (par->info->var.yres - 1) /* lines per panel */ | ||
178 | | (24 << 10) /* vsync pulse width - 1 */ | ||
179 | | (2 << 16) /* eof pixel count */ | ||
180 | | (0 << 24); /* bof pixel count */ | ||
181 | |||
182 | LCCR3 = 2 /* pixel clock divisor */ | ||
183 | | (24 << 8) /* AC Bias pin freq */ | ||
184 | | LCCR3_16BPP /* BPP */ | ||
185 | | LCCR3_PCP; /* PCP falling edge */ | ||
186 | |||
187 | } | ||
188 | |||
189 | static void am200_post_dma_setup(struct metronomefb_par *par) | ||
190 | { | ||
191 | par->metromem_desc->mFDADR0 = par->metromem_desc_dma; | ||
192 | par->metromem_desc->mFSADR0 = par->metromem_dma; | ||
193 | par->metromem_desc->mFIDR0 = 0; | ||
194 | par->metromem_desc->mLDCMD0 = par->info->var.xres | ||
195 | * par->info->var.yres; | ||
196 | am200_enable_lcd_controller(par); | ||
197 | } | ||
198 | |||
199 | static void am200_free_irq(struct fb_info *info) | ||
200 | { | ||
201 | free_irq(IRQ_GPIO(RDY_GPIO_PIN), info); | ||
202 | } | ||
203 | |||
204 | static irqreturn_t am200_handle_irq(int irq, void *dev_id) | ||
205 | { | ||
206 | struct fb_info *info = dev_id; | ||
207 | struct metronomefb_par *par = info->par; | ||
208 | |||
209 | wake_up_interruptible(&par->waitq); | ||
210 | return IRQ_HANDLED; | ||
211 | } | ||
212 | |||
213 | static int am200_setup_irq(struct fb_info *info) | ||
214 | { | ||
215 | int retval; | ||
216 | |||
217 | retval = request_irq(IRQ_GPIO(RDY_GPIO_PIN), am200_handle_irq, | ||
218 | IRQF_DISABLED, "AM200", info); | ||
219 | if (retval) { | ||
220 | printk(KERN_ERR "am200epd: request_irq failed: %d\n", retval); | ||
221 | return retval; | ||
222 | } | ||
223 | |||
224 | return set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQ_TYPE_EDGE_FALLING); | ||
225 | } | ||
226 | |||
227 | static void am200_set_rst(struct metronomefb_par *par, int state) | ||
228 | { | ||
229 | am200_set_gpio_output(RST_GPIO_PIN, state); | ||
230 | } | ||
231 | |||
232 | static void am200_set_stdby(struct metronomefb_par *par, int state) | ||
233 | { | ||
234 | am200_set_gpio_output(STDBY_GPIO_PIN, state); | ||
235 | } | ||
236 | |||
237 | static int am200_wait_event(struct metronomefb_par *par) | ||
238 | { | ||
239 | return wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ); | ||
240 | } | ||
241 | |||
242 | static int am200_wait_event_intr(struct metronomefb_par *par) | ||
243 | { | ||
244 | return wait_event_interruptible_timeout(par->waitq, (GPLR1 & 0x01), HZ); | ||
245 | } | ||
246 | |||
247 | static struct metronome_board am200_board = { | ||
248 | .owner = THIS_MODULE, | ||
249 | .free_irq = am200_free_irq, | ||
250 | .setup_irq = am200_setup_irq, | ||
251 | .init_gpio_regs = am200_init_gpio_regs, | ||
252 | .init_lcdc_regs = am200_init_lcdc_regs, | ||
253 | .post_dma_setup = am200_post_dma_setup, | ||
254 | .set_rst = am200_set_rst, | ||
255 | .set_stdby = am200_set_stdby, | ||
256 | .met_wait_event = am200_wait_event, | ||
257 | .met_wait_event_intr = am200_wait_event_intr, | ||
258 | }; | ||
259 | |||
260 | static struct platform_device *am200_device; | ||
261 | |||
262 | static int __init am200_init(void) | ||
263 | { | ||
264 | int ret; | ||
265 | |||
266 | /* request our platform independent driver */ | ||
267 | request_module("metronomefb"); | ||
268 | |||
269 | am200_device = platform_device_alloc("metronomefb", -1); | ||
270 | if (!am200_device) | ||
271 | return -ENOMEM; | ||
272 | |||
273 | platform_device_add_data(am200_device, &am200_board, | ||
274 | sizeof(am200_board)); | ||
275 | |||
276 | /* this _add binds metronomefb to am200. metronomefb refcounts am200 */ | ||
277 | ret = platform_device_add(am200_device); | ||
278 | |||
279 | if (ret) | ||
280 | platform_device_put(am200_device); | ||
281 | |||
282 | return ret; | ||
283 | } | ||
284 | |||
285 | static void __exit am200_exit(void) | ||
286 | { | ||
287 | platform_device_unregister(am200_device); | ||
288 | } | ||
289 | |||
290 | module_init(am200_init); | ||
291 | module_exit(am200_exit); | ||
292 | |||
293 | MODULE_DESCRIPTION("board driver for am200 metronome epd kit"); | ||
294 | MODULE_AUTHOR("Jaya Kumar"); | ||
295 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 9c5925927ece..5a24c6411d34 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -939,7 +939,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
939 | ret = register_framebuffer(info); | 939 | ret = register_framebuffer(info); |
940 | if (ret < 0) { | 940 | if (ret < 0) { |
941 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); | 941 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); |
942 | goto free_cmap; | 942 | goto reset_drvdata; |
943 | } | 943 | } |
944 | 944 | ||
945 | /* add selected videomode to modelist */ | 945 | /* add selected videomode to modelist */ |
@@ -955,7 +955,8 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
955 | 955 | ||
956 | return 0; | 956 | return 0; |
957 | 957 | ||
958 | 958 | reset_drvdata: | |
959 | dev_set_drvdata(dev, NULL); | ||
959 | free_cmap: | 960 | free_cmap: |
960 | fb_dealloc_cmap(&info->cmap); | 961 | fb_dealloc_cmap(&info->cmap); |
961 | unregister_irqs: | 962 | unregister_irqs: |
@@ -992,10 +993,11 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev) | |||
992 | { | 993 | { |
993 | struct device *dev = &pdev->dev; | 994 | struct device *dev = &pdev->dev; |
994 | struct fb_info *info = dev_get_drvdata(dev); | 995 | struct fb_info *info = dev_get_drvdata(dev); |
995 | struct atmel_lcdfb_info *sinfo = info->par; | 996 | struct atmel_lcdfb_info *sinfo; |
996 | 997 | ||
997 | if (!sinfo) | 998 | if (!info || !info->par) |
998 | return 0; | 999 | return 0; |
1000 | sinfo = info->par; | ||
999 | 1001 | ||
1000 | cancel_work_sync(&sinfo->task); | 1002 | cancel_work_sync(&sinfo->task); |
1001 | exit_backlight(sinfo); | 1003 | exit_backlight(sinfo); |
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 452b770d8cc9..c72a13562954 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -24,6 +24,13 @@ config LCD_CLASS_DEVICE | |||
24 | To have support for your specific LCD panel you will have to | 24 | To have support for your specific LCD panel you will have to |
25 | select the proper drivers which depend on this option. | 25 | select the proper drivers which depend on this option. |
26 | 26 | ||
27 | config LCD_CORGI | ||
28 | tristate "LCD Panel support for SHARP corgi/spitz model" | ||
29 | depends on LCD_CLASS_DEVICE && SPI_MASTER && PXA_SHARPSL | ||
30 | help | ||
31 | Say y here to support the LCD panels usually found on SHARP | ||
32 | corgi (C7x0) and spitz (Cxx00) models. | ||
33 | |||
27 | config LCD_LTV350QV | 34 | config LCD_LTV350QV |
28 | tristate "Samsung LTV350QV LCD Panel" | 35 | tristate "Samsung LTV350QV LCD Panel" |
29 | depends on LCD_CLASS_DEVICE && SPI_MASTER | 36 | depends on LCD_CLASS_DEVICE && SPI_MASTER |
@@ -44,6 +51,14 @@ config LCD_ILI9320 | |||
44 | If you have a panel based on the ILI9320 controller chip | 51 | If you have a panel based on the ILI9320 controller chip |
45 | then say y to include a power driver for it. | 52 | then say y to include a power driver for it. |
46 | 53 | ||
54 | config LCD_TDO24M | ||
55 | tristate "Toppoly TDO24M LCD Panels support" | ||
56 | depends on LCD_CLASS_DEVICE && SPI_MASTER | ||
57 | default n | ||
58 | help | ||
59 | If you have a Toppoly TDO24M series LCD panel, say y here to | ||
60 | include the support for it. | ||
61 | |||
47 | config LCD_VGG2432A4 | 62 | config LCD_VGG2432A4 |
48 | tristate "VGG2432A4 LCM device support" | 63 | tristate "VGG2432A4 LCM device support" |
49 | depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER | 64 | depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index b405aace803f..3ec551eb472c 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -1,10 +1,12 @@ | |||
1 | # Backlight & LCD drivers | 1 | # Backlight & LCD drivers |
2 | 2 | ||
3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o | 3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o |
4 | obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o | ||
4 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o | 5 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o |
5 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o | 6 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o |
6 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o | 7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o |
7 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o | 8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o |
9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o | ||
8 | 10 | ||
9 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 11 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
10 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | 12 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c new file mode 100644 index 000000000000..2afd47eefe74 --- /dev/null +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -0,0 +1,641 @@ | |||
1 | /* | ||
2 | * LCD/Backlight Driver for Sharp Zaurus Handhelds (various models) | ||
3 | * | ||
4 | * Copyright (c) 2004-2006 Richard Purdie | ||
5 | * | ||
6 | * Based on Sharp's 2.4 Backlight Driver | ||
7 | * | ||
8 | * Copyright (c) 2008 Marvell International Ltd. | ||
9 | * Converted to SPI device based LCD/Backlight device driver | ||
10 | * by Eric Miao <eric.miao@marvell.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/fb.h> | ||
24 | #include <linux/lcd.h> | ||
25 | #include <linux/spi/spi.h> | ||
26 | #include <linux/spi/corgi_lcd.h> | ||
27 | #include <asm/mach/sharpsl_param.h> | ||
28 | |||
29 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
30 | |||
31 | /* Register Addresses */ | ||
32 | #define RESCTL_ADRS 0x00 | ||
33 | #define PHACTRL_ADRS 0x01 | ||
34 | #define DUTYCTRL_ADRS 0x02 | ||
35 | #define POWERREG0_ADRS 0x03 | ||
36 | #define POWERREG1_ADRS 0x04 | ||
37 | #define GPOR3_ADRS 0x05 | ||
38 | #define PICTRL_ADRS 0x06 | ||
39 | #define POLCTRL_ADRS 0x07 | ||
40 | |||
41 | /* Register Bit Definitions */ | ||
42 | #define RESCTL_QVGA 0x01 | ||
43 | #define RESCTL_VGA 0x00 | ||
44 | |||
45 | #define POWER1_VW_ON 0x01 /* VW Supply FET ON */ | ||
46 | #define POWER1_GVSS_ON 0x02 /* GVSS(-8V) Power Supply ON */ | ||
47 | #define POWER1_VDD_ON 0x04 /* VDD(8V),SVSS(-4V) Power Supply ON */ | ||
48 | |||
49 | #define POWER1_VW_OFF 0x00 /* VW Supply FET OFF */ | ||
50 | #define POWER1_GVSS_OFF 0x00 /* GVSS(-8V) Power Supply OFF */ | ||
51 | #define POWER1_VDD_OFF 0x00 /* VDD(8V),SVSS(-4V) Power Supply OFF */ | ||
52 | |||
53 | #define POWER0_COM_DCLK 0x01 /* COM Voltage DC Bias DAC Serial Data Clock */ | ||
54 | #define POWER0_COM_DOUT 0x02 /* COM Voltage DC Bias DAC Serial Data Out */ | ||
55 | #define POWER0_DAC_ON 0x04 /* DAC Power Supply ON */ | ||
56 | #define POWER0_COM_ON 0x08 /* COM Power Supply ON */ | ||
57 | #define POWER0_VCC5_ON 0x10 /* VCC5 Power Supply ON */ | ||
58 | |||
59 | #define POWER0_DAC_OFF 0x00 /* DAC Power Supply OFF */ | ||
60 | #define POWER0_COM_OFF 0x00 /* COM Power Supply OFF */ | ||
61 | #define POWER0_VCC5_OFF 0x00 /* VCC5 Power Supply OFF */ | ||
62 | |||
63 | #define PICTRL_INIT_STATE 0x01 | ||
64 | #define PICTRL_INIOFF 0x02 | ||
65 | #define PICTRL_POWER_DOWN 0x04 | ||
66 | #define PICTRL_COM_SIGNAL_OFF 0x08 | ||
67 | #define PICTRL_DAC_SIGNAL_OFF 0x10 | ||
68 | |||
69 | #define POLCTRL_SYNC_POL_FALL 0x01 | ||
70 | #define POLCTRL_EN_POL_FALL 0x02 | ||
71 | #define POLCTRL_DATA_POL_FALL 0x04 | ||
72 | #define POLCTRL_SYNC_ACT_H 0x08 | ||
73 | #define POLCTRL_EN_ACT_L 0x10 | ||
74 | |||
75 | #define POLCTRL_SYNC_POL_RISE 0x00 | ||
76 | #define POLCTRL_EN_POL_RISE 0x00 | ||
77 | #define POLCTRL_DATA_POL_RISE 0x00 | ||
78 | #define POLCTRL_SYNC_ACT_L 0x00 | ||
79 | #define POLCTRL_EN_ACT_H 0x00 | ||
80 | |||
81 | #define PHACTRL_PHASE_MANUAL 0x01 | ||
82 | #define DEFAULT_PHAD_QVGA (9) | ||
83 | #define DEFAULT_COMADJ (125) | ||
84 | |||
85 | struct corgi_lcd { | ||
86 | struct spi_device *spi_dev; | ||
87 | struct lcd_device *lcd_dev; | ||
88 | struct backlight_device *bl_dev; | ||
89 | |||
90 | int limit_mask; | ||
91 | int intensity; | ||
92 | int power; | ||
93 | int mode; | ||
94 | char buf[2]; | ||
95 | |||
96 | int gpio_backlight_on; | ||
97 | int gpio_backlight_cont; | ||
98 | int gpio_backlight_cont_inverted; | ||
99 | |||
100 | void (*kick_battery)(void); | ||
101 | }; | ||
102 | |||
103 | static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int reg, uint8_t val); | ||
104 | |||
105 | static struct corgi_lcd *the_corgi_lcd; | ||
106 | static unsigned long corgibl_flags; | ||
107 | #define CORGIBL_SUSPENDED 0x01 | ||
108 | #define CORGIBL_BATTLOW 0x02 | ||
109 | |||
110 | /* | ||
111 | * This is only a psuedo I2C interface. We can't use the standard kernel | ||
112 | * routines as the interface is write only. We just assume the data is acked... | ||
113 | */ | ||
114 | static void lcdtg_ssp_i2c_send(struct corgi_lcd *lcd, uint8_t data) | ||
115 | { | ||
116 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, data); | ||
117 | udelay(10); | ||
118 | } | ||
119 | |||
120 | static void lcdtg_i2c_send_bit(struct corgi_lcd *lcd, uint8_t data) | ||
121 | { | ||
122 | lcdtg_ssp_i2c_send(lcd, data); | ||
123 | lcdtg_ssp_i2c_send(lcd, data | POWER0_COM_DCLK); | ||
124 | lcdtg_ssp_i2c_send(lcd, data); | ||
125 | } | ||
126 | |||
127 | static void lcdtg_i2c_send_start(struct corgi_lcd *lcd, uint8_t base) | ||
128 | { | ||
129 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); | ||
130 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); | ||
131 | lcdtg_ssp_i2c_send(lcd, base); | ||
132 | } | ||
133 | |||
134 | static void lcdtg_i2c_send_stop(struct corgi_lcd *lcd, uint8_t base) | ||
135 | { | ||
136 | lcdtg_ssp_i2c_send(lcd, base); | ||
137 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); | ||
138 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); | ||
139 | } | ||
140 | |||
141 | static void lcdtg_i2c_send_byte(struct corgi_lcd *lcd, | ||
142 | uint8_t base, uint8_t data) | ||
143 | { | ||
144 | int i; | ||
145 | for (i = 0; i < 8; i++) { | ||
146 | if (data & 0x80) | ||
147 | lcdtg_i2c_send_bit(lcd, base | POWER0_COM_DOUT); | ||
148 | else | ||
149 | lcdtg_i2c_send_bit(lcd, base); | ||
150 | data <<= 1; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | static void lcdtg_i2c_wait_ack(struct corgi_lcd *lcd, uint8_t base) | ||
155 | { | ||
156 | lcdtg_i2c_send_bit(lcd, base); | ||
157 | } | ||
158 | |||
159 | static void lcdtg_set_common_voltage(struct corgi_lcd *lcd, | ||
160 | uint8_t base_data, uint8_t data) | ||
161 | { | ||
162 | /* Set Common Voltage to M62332FP via I2C */ | ||
163 | lcdtg_i2c_send_start(lcd, base_data); | ||
164 | lcdtg_i2c_send_byte(lcd, base_data, 0x9c); | ||
165 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
166 | lcdtg_i2c_send_byte(lcd, base_data, 0x00); | ||
167 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
168 | lcdtg_i2c_send_byte(lcd, base_data, data); | ||
169 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
170 | lcdtg_i2c_send_stop(lcd, base_data); | ||
171 | } | ||
172 | |||
173 | static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int adrs, uint8_t data) | ||
174 | { | ||
175 | struct spi_message msg; | ||
176 | struct spi_transfer xfer = { | ||
177 | .len = 1, | ||
178 | .cs_change = 1, | ||
179 | .tx_buf = lcd->buf, | ||
180 | }; | ||
181 | |||
182 | lcd->buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f); | ||
183 | spi_message_init(&msg); | ||
184 | spi_message_add_tail(&xfer, &msg); | ||
185 | |||
186 | return spi_sync(lcd->spi_dev, &msg); | ||
187 | } | ||
188 | |||
189 | /* Set Phase Adjust */ | ||
190 | static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode) | ||
191 | { | ||
192 | int adj; | ||
193 | |||
194 | switch(mode) { | ||
195 | case CORGI_LCD_MODE_VGA: | ||
196 | /* Setting for VGA */ | ||
197 | adj = sharpsl_param.phadadj; | ||
198 | adj = (adj < 0) ? PHACTRL_PHASE_MANUAL : | ||
199 | PHACTRL_PHASE_MANUAL | ((adj & 0xf) << 1); | ||
200 | break; | ||
201 | case CORGI_LCD_MODE_QVGA: | ||
202 | default: | ||
203 | /* Setting for QVGA */ | ||
204 | adj = (DEFAULT_PHAD_QVGA << 1) | PHACTRL_PHASE_MANUAL; | ||
205 | break; | ||
206 | } | ||
207 | |||
208 | corgi_ssp_lcdtg_send(lcd, PHACTRL_ADRS, adj); | ||
209 | } | ||
210 | |||
211 | static void corgi_lcd_power_on(struct corgi_lcd *lcd) | ||
212 | { | ||
213 | int comadj; | ||
214 | |||
215 | /* Initialize Internal Logic & Port */ | ||
216 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
217 | PICTRL_POWER_DOWN | PICTRL_INIOFF | | ||
218 | PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF | | ||
219 | PICTRL_DAC_SIGNAL_OFF); | ||
220 | |||
221 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
222 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_OFF | | ||
223 | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
224 | |||
225 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
226 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF); | ||
227 | |||
228 | /* VDD(+8V), SVSS(-4V) ON */ | ||
229 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
230 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON); | ||
231 | mdelay(3); | ||
232 | |||
233 | /* DAC ON */ | ||
234 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
235 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
236 | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
237 | |||
238 | /* INIB = H, INI = L */ | ||
239 | /* PICTL[0] = H , PICTL[1] = PICTL[2] = PICTL[4] = L */ | ||
240 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
241 | PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF); | ||
242 | |||
243 | /* Set Common Voltage */ | ||
244 | comadj = sharpsl_param.comadj; | ||
245 | if (comadj < 0) | ||
246 | comadj = DEFAULT_COMADJ; | ||
247 | |||
248 | lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | | ||
249 | POWER0_VCC5_OFF, comadj); | ||
250 | |||
251 | /* VCC5 ON, DAC ON */ | ||
252 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
253 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
254 | POWER0_COM_OFF | POWER0_VCC5_ON); | ||
255 | |||
256 | /* GVSS(-8V) ON, VDD ON */ | ||
257 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
258 | POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
259 | mdelay(2); | ||
260 | |||
261 | /* COM SIGNAL ON (PICTL[3] = L) */ | ||
262 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_INIT_STATE); | ||
263 | |||
264 | /* COM ON, DAC ON, VCC5_ON */ | ||
265 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
266 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
267 | POWER0_COM_ON | POWER0_VCC5_ON); | ||
268 | |||
269 | /* VW ON, GVSS ON, VDD ON */ | ||
270 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
271 | POWER1_VW_ON | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
272 | |||
273 | /* Signals output enable */ | ||
274 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, 0); | ||
275 | |||
276 | /* Set Phase Adjust */ | ||
277 | lcdtg_set_phadadj(lcd, lcd->mode); | ||
278 | |||
279 | /* Initialize for Input Signals from ATI */ | ||
280 | corgi_ssp_lcdtg_send(lcd, POLCTRL_ADRS, | ||
281 | POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE | | ||
282 | POLCTRL_DATA_POL_RISE | POLCTRL_SYNC_ACT_L | | ||
283 | POLCTRL_EN_ACT_H); | ||
284 | udelay(1000); | ||
285 | |||
286 | switch (lcd->mode) { | ||
287 | case CORGI_LCD_MODE_VGA: | ||
288 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); | ||
289 | break; | ||
290 | case CORGI_LCD_MODE_QVGA: | ||
291 | default: | ||
292 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); | ||
293 | break; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | static void corgi_lcd_power_off(struct corgi_lcd *lcd) | ||
298 | { | ||
299 | /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */ | ||
300 | msleep(34); | ||
301 | |||
302 | /* (1)VW OFF */ | ||
303 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
304 | POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
305 | |||
306 | /* (2)COM OFF */ | ||
307 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF); | ||
308 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
309 | POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON); | ||
310 | |||
311 | /* (3)Set Common Voltage Bias 0V */ | ||
312 | lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | | ||
313 | POWER0_VCC5_ON, 0); | ||
314 | |||
315 | /* (4)GVSS OFF */ | ||
316 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
317 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON); | ||
318 | |||
319 | /* (5)VCC5 OFF */ | ||
320 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
321 | POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
322 | |||
323 | /* (6)Set PDWN, INIOFF, DACOFF */ | ||
324 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
325 | PICTRL_INIOFF | PICTRL_DAC_SIGNAL_OFF | | ||
326 | PICTRL_POWER_DOWN | PICTRL_COM_SIGNAL_OFF); | ||
327 | |||
328 | /* (7)DAC OFF */ | ||
329 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
330 | POWER0_DAC_OFF | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
331 | |||
332 | /* (8)VDD OFF */ | ||
333 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
334 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF); | ||
335 | } | ||
336 | |||
337 | static int corgi_lcd_set_mode(struct lcd_device *ld, struct fb_videomode *m) | ||
338 | { | ||
339 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
340 | int mode = CORGI_LCD_MODE_QVGA; | ||
341 | |||
342 | if (m->xres == 640 || m->xres == 480) | ||
343 | mode = CORGI_LCD_MODE_VGA; | ||
344 | |||
345 | if (lcd->mode == mode) | ||
346 | return 0; | ||
347 | |||
348 | lcdtg_set_phadadj(lcd, mode); | ||
349 | |||
350 | switch (mode) { | ||
351 | case CORGI_LCD_MODE_VGA: | ||
352 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); | ||
353 | break; | ||
354 | case CORGI_LCD_MODE_QVGA: | ||
355 | default: | ||
356 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); | ||
357 | break; | ||
358 | } | ||
359 | |||
360 | lcd->mode = mode; | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static int corgi_lcd_set_power(struct lcd_device *ld, int power) | ||
365 | { | ||
366 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
367 | |||
368 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
369 | corgi_lcd_power_on(lcd); | ||
370 | |||
371 | if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
372 | corgi_lcd_power_off(lcd); | ||
373 | |||
374 | lcd->power = power; | ||
375 | return 0; | ||
376 | } | ||
377 | |||
378 | static int corgi_lcd_get_power(struct lcd_device *ld) | ||
379 | { | ||
380 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
381 | |||
382 | return lcd->power; | ||
383 | } | ||
384 | |||
385 | static struct lcd_ops corgi_lcd_ops = { | ||
386 | .get_power = corgi_lcd_get_power, | ||
387 | .set_power = corgi_lcd_set_power, | ||
388 | .set_mode = corgi_lcd_set_mode, | ||
389 | }; | ||
390 | |||
391 | static int corgi_bl_get_intensity(struct backlight_device *bd) | ||
392 | { | ||
393 | struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev); | ||
394 | |||
395 | return lcd->intensity; | ||
396 | } | ||
397 | |||
398 | static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) | ||
399 | { | ||
400 | int cont; | ||
401 | |||
402 | if (intensity > 0x10) | ||
403 | intensity += 0x10; | ||
404 | |||
405 | corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity); | ||
406 | |||
407 | /* Bit 5 via GPIO_BACKLIGHT_CONT */ | ||
408 | cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted; | ||
409 | |||
410 | if (gpio_is_valid(lcd->gpio_backlight_cont)) | ||
411 | gpio_set_value(lcd->gpio_backlight_cont, cont); | ||
412 | |||
413 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
414 | gpio_set_value(lcd->gpio_backlight_on, intensity); | ||
415 | |||
416 | if (lcd->kick_battery) | ||
417 | lcd->kick_battery(); | ||
418 | |||
419 | lcd->intensity = intensity; | ||
420 | return 0; | ||
421 | } | ||
422 | |||
423 | static int corgi_bl_update_status(struct backlight_device *bd) | ||
424 | { | ||
425 | struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev); | ||
426 | int intensity = bd->props.brightness; | ||
427 | |||
428 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
429 | intensity = 0; | ||
430 | |||
431 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
432 | intensity = 0; | ||
433 | |||
434 | if (corgibl_flags & CORGIBL_SUSPENDED) | ||
435 | intensity = 0; | ||
436 | if (corgibl_flags & CORGIBL_BATTLOW) | ||
437 | intensity &= lcd->limit_mask; | ||
438 | |||
439 | return corgi_bl_set_intensity(lcd, intensity); | ||
440 | } | ||
441 | |||
442 | void corgibl_limit_intensity(int limit) | ||
443 | { | ||
444 | if (limit) | ||
445 | corgibl_flags |= CORGIBL_BATTLOW; | ||
446 | else | ||
447 | corgibl_flags &= ~CORGIBL_BATTLOW; | ||
448 | |||
449 | backlight_update_status(the_corgi_lcd->bl_dev); | ||
450 | } | ||
451 | EXPORT_SYMBOL(corgibl_limit_intensity); | ||
452 | |||
453 | static struct backlight_ops corgi_bl_ops = { | ||
454 | .get_brightness = corgi_bl_get_intensity, | ||
455 | .update_status = corgi_bl_update_status, | ||
456 | }; | ||
457 | |||
458 | #ifdef CONFIG_PM | ||
459 | static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state) | ||
460 | { | ||
461 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
462 | |||
463 | corgibl_flags |= CORGIBL_SUSPENDED; | ||
464 | corgi_bl_set_intensity(lcd, 0); | ||
465 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static int corgi_lcd_resume(struct spi_device *spi) | ||
470 | { | ||
471 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
472 | |||
473 | corgibl_flags &= ~CORGIBL_SUSPENDED; | ||
474 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); | ||
475 | backlight_update_status(lcd->bl_dev); | ||
476 | return 0; | ||
477 | } | ||
478 | #else | ||
479 | #define corgi_lcd_suspend NULL | ||
480 | #define corgi_lcd_resume NULL | ||
481 | #endif | ||
482 | |||
483 | static int setup_gpio_backlight(struct corgi_lcd *lcd, | ||
484 | struct corgi_lcd_platform_data *pdata) | ||
485 | { | ||
486 | struct spi_device *spi = lcd->spi_dev; | ||
487 | int err; | ||
488 | |||
489 | lcd->gpio_backlight_on = -1; | ||
490 | lcd->gpio_backlight_cont = -1; | ||
491 | |||
492 | if (gpio_is_valid(pdata->gpio_backlight_on)) { | ||
493 | err = gpio_request(pdata->gpio_backlight_on, "BL_ON"); | ||
494 | if (err) { | ||
495 | dev_err(&spi->dev, "failed to request GPIO%d for " | ||
496 | "backlight_on\n", pdata->gpio_backlight_on); | ||
497 | return err; | ||
498 | } | ||
499 | |||
500 | lcd->gpio_backlight_on = pdata->gpio_backlight_on; | ||
501 | gpio_direction_output(lcd->gpio_backlight_on, 0); | ||
502 | } | ||
503 | |||
504 | if (gpio_is_valid(pdata->gpio_backlight_cont)) { | ||
505 | err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT"); | ||
506 | if (err) { | ||
507 | dev_err(&spi->dev, "failed to request GPIO%d for " | ||
508 | "backlight_cont\n", pdata->gpio_backlight_cont); | ||
509 | goto err_free_backlight_on; | ||
510 | } | ||
511 | |||
512 | lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; | ||
513 | |||
514 | /* spitz and akita use both GPIOs for backlight, and | ||
515 | * have inverted polarity of GPIO_BACKLIGHT_CONT | ||
516 | */ | ||
517 | if (gpio_is_valid(lcd->gpio_backlight_on)) { | ||
518 | lcd->gpio_backlight_cont_inverted = 1; | ||
519 | gpio_direction_output(lcd->gpio_backlight_cont, 1); | ||
520 | } else { | ||
521 | lcd->gpio_backlight_cont_inverted = 0; | ||
522 | gpio_direction_output(lcd->gpio_backlight_cont, 0); | ||
523 | } | ||
524 | } | ||
525 | return 0; | ||
526 | |||
527 | err_free_backlight_on: | ||
528 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
529 | gpio_free(lcd->gpio_backlight_on); | ||
530 | return err; | ||
531 | } | ||
532 | |||
533 | static int __devinit corgi_lcd_probe(struct spi_device *spi) | ||
534 | { | ||
535 | struct corgi_lcd_platform_data *pdata = spi->dev.platform_data; | ||
536 | struct corgi_lcd *lcd; | ||
537 | int ret = 0; | ||
538 | |||
539 | if (pdata == NULL) { | ||
540 | dev_err(&spi->dev, "platform data not available\n"); | ||
541 | return -EINVAL; | ||
542 | } | ||
543 | |||
544 | lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); | ||
545 | if (!lcd) { | ||
546 | dev_err(&spi->dev, "failed to allocate memory\n"); | ||
547 | return -ENOMEM; | ||
548 | } | ||
549 | |||
550 | lcd->spi_dev = spi; | ||
551 | |||
552 | lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, | ||
553 | lcd, &corgi_lcd_ops); | ||
554 | if (IS_ERR(lcd->lcd_dev)) { | ||
555 | ret = PTR_ERR(lcd->lcd_dev); | ||
556 | goto err_free_lcd; | ||
557 | } | ||
558 | lcd->power = FB_BLANK_POWERDOWN; | ||
559 | lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; | ||
560 | |||
561 | lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, | ||
562 | lcd, &corgi_bl_ops); | ||
563 | if (IS_ERR(lcd->bl_dev)) { | ||
564 | ret = PTR_ERR(lcd->bl_dev); | ||
565 | goto err_unregister_lcd; | ||
566 | } | ||
567 | lcd->bl_dev->props.max_brightness = pdata->max_intensity; | ||
568 | lcd->bl_dev->props.brightness = pdata->default_intensity; | ||
569 | lcd->bl_dev->props.power = FB_BLANK_UNBLANK; | ||
570 | |||
571 | ret = setup_gpio_backlight(lcd, pdata); | ||
572 | if (ret) | ||
573 | goto err_unregister_bl; | ||
574 | |||
575 | lcd->kick_battery = pdata->kick_battery; | ||
576 | |||
577 | dev_set_drvdata(&spi->dev, lcd); | ||
578 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); | ||
579 | backlight_update_status(lcd->bl_dev); | ||
580 | |||
581 | lcd->limit_mask = pdata->limit_mask; | ||
582 | the_corgi_lcd = lcd; | ||
583 | return 0; | ||
584 | |||
585 | err_unregister_bl: | ||
586 | backlight_device_unregister(lcd->bl_dev); | ||
587 | err_unregister_lcd: | ||
588 | lcd_device_unregister(lcd->lcd_dev); | ||
589 | err_free_lcd: | ||
590 | kfree(lcd); | ||
591 | return ret; | ||
592 | } | ||
593 | |||
594 | static int __devexit corgi_lcd_remove(struct spi_device *spi) | ||
595 | { | ||
596 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
597 | |||
598 | lcd->bl_dev->props.power = FB_BLANK_UNBLANK; | ||
599 | lcd->bl_dev->props.brightness = 0; | ||
600 | backlight_update_status(lcd->bl_dev); | ||
601 | backlight_device_unregister(lcd->bl_dev); | ||
602 | |||
603 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
604 | gpio_free(lcd->gpio_backlight_on); | ||
605 | |||
606 | if (gpio_is_valid(lcd->gpio_backlight_cont)) | ||
607 | gpio_free(lcd->gpio_backlight_cont); | ||
608 | |||
609 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | ||
610 | lcd_device_unregister(lcd->lcd_dev); | ||
611 | kfree(lcd); | ||
612 | |||
613 | return 0; | ||
614 | } | ||
615 | |||
616 | static struct spi_driver corgi_lcd_driver = { | ||
617 | .driver = { | ||
618 | .name = "corgi-lcd", | ||
619 | .owner = THIS_MODULE, | ||
620 | }, | ||
621 | .probe = corgi_lcd_probe, | ||
622 | .remove = __devexit_p(corgi_lcd_remove), | ||
623 | .suspend = corgi_lcd_suspend, | ||
624 | .resume = corgi_lcd_resume, | ||
625 | }; | ||
626 | |||
627 | static int __init corgi_lcd_init(void) | ||
628 | { | ||
629 | return spi_register_driver(&corgi_lcd_driver); | ||
630 | } | ||
631 | module_init(corgi_lcd_init); | ||
632 | |||
633 | static void __exit corgi_lcd_exit(void) | ||
634 | { | ||
635 | spi_unregister_driver(&corgi_lcd_driver); | ||
636 | } | ||
637 | module_exit(corgi_lcd_exit); | ||
638 | |||
639 | MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00"); | ||
640 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
641 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index b15b2b84a6f7..8e1731d3b228 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c | |||
@@ -27,14 +27,26 @@ static int fb_notifier_callback(struct notifier_block *self, | |||
27 | struct fb_event *evdata = data; | 27 | struct fb_event *evdata = data; |
28 | 28 | ||
29 | /* If we aren't interested in this event, skip it immediately ... */ | 29 | /* If we aren't interested in this event, skip it immediately ... */ |
30 | if (event != FB_EVENT_BLANK) | 30 | switch (event) { |
31 | case FB_EVENT_BLANK: | ||
32 | case FB_EVENT_MODE_CHANGE: | ||
33 | case FB_EVENT_MODE_CHANGE_ALL: | ||
34 | break; | ||
35 | default: | ||
31 | return 0; | 36 | return 0; |
37 | } | ||
32 | 38 | ||
33 | ld = container_of(self, struct lcd_device, fb_notif); | 39 | ld = container_of(self, struct lcd_device, fb_notif); |
40 | if (!ld->ops) | ||
41 | return 0; | ||
42 | |||
34 | mutex_lock(&ld->ops_lock); | 43 | mutex_lock(&ld->ops_lock); |
35 | if (ld->ops) | 44 | if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { |
36 | if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) | 45 | if (event == FB_EVENT_BLANK) |
37 | ld->ops->set_power(ld, *(int *)evdata->data); | 46 | ld->ops->set_power(ld, *(int *)evdata->data); |
47 | else | ||
48 | ld->ops->set_mode(ld, evdata->data); | ||
49 | } | ||
38 | mutex_unlock(&ld->ops_lock); | 50 | mutex_unlock(&ld->ops_lock); |
39 | return 0; | 51 | return 0; |
40 | } | 52 | } |
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c new file mode 100644 index 000000000000..8427669162ea --- /dev/null +++ b/drivers/video/backlight/tdo24m.c | |||
@@ -0,0 +1,396 @@ | |||
1 | /* | ||
2 | * tdo24m - SPI-based drivers for Toppoly TDO24M series LCD panels | ||
3 | * | ||
4 | * Copyright (C) 2008 Marvell International Ltd. | ||
5 | * Eric Miao <eric.miao@marvell.com> | ||
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 version 2 as | ||
9 | * publishhed by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/fb.h> | ||
18 | #include <linux/lcd.h> | ||
19 | |||
20 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
21 | |||
22 | #define TDO24M_SPI_BUFF_SIZE (4) | ||
23 | #define MODE_QVGA 0 | ||
24 | #define MODE_VGA 1 | ||
25 | |||
26 | struct tdo24m { | ||
27 | struct spi_device *spi_dev; | ||
28 | struct lcd_device *lcd_dev; | ||
29 | |||
30 | struct spi_message msg; | ||
31 | struct spi_transfer xfer; | ||
32 | uint8_t *buf; | ||
33 | |||
34 | int power; | ||
35 | int mode; | ||
36 | }; | ||
37 | |||
38 | /* use bit 30, 31 as the indicator of command parameter number */ | ||
39 | #define CMD0(x) ((0 << 30) | (x)) | ||
40 | #define CMD1(x, x1) ((1 << 30) | ((x) << 9) | 0x100 | (x1)) | ||
41 | #define CMD2(x, x1, x2) ((2 << 30) | ((x) << 18) | 0x20000 |\ | ||
42 | ((x1) << 9) | 0x100 | (x2)) | ||
43 | #define CMD_NULL (-1) | ||
44 | |||
45 | static uint32_t lcd_panel_reset[] = { | ||
46 | CMD0(0x1), /* reset */ | ||
47 | CMD0(0x0), /* nop */ | ||
48 | CMD0(0x0), /* nop */ | ||
49 | CMD0(0x0), /* nop */ | ||
50 | CMD_NULL, | ||
51 | }; | ||
52 | |||
53 | static uint32_t lcd_panel_on[] = { | ||
54 | CMD0(0x29), /* Display ON */ | ||
55 | CMD2(0xB8, 0xFF, 0xF9), /* Output Control */ | ||
56 | CMD0(0x11), /* Sleep out */ | ||
57 | CMD1(0xB0, 0x16), /* Wake */ | ||
58 | CMD_NULL, | ||
59 | }; | ||
60 | |||
61 | static uint32_t lcd_panel_off[] = { | ||
62 | CMD0(0x28), /* Display OFF */ | ||
63 | CMD2(0xB8, 0x80, 0x02), /* Output Control */ | ||
64 | CMD0(0x10), /* Sleep in */ | ||
65 | CMD1(0xB0, 0x00), /* Deep stand by in */ | ||
66 | CMD_NULL, | ||
67 | }; | ||
68 | |||
69 | static uint32_t lcd_vga_pass_through[] = { | ||
70 | CMD1(0xB0, 0x16), | ||
71 | CMD1(0xBC, 0x80), | ||
72 | CMD1(0xE1, 0x00), | ||
73 | CMD1(0x36, 0x50), | ||
74 | CMD1(0x3B, 0x00), | ||
75 | CMD_NULL, | ||
76 | }; | ||
77 | |||
78 | static uint32_t lcd_qvga_pass_through[] = { | ||
79 | CMD1(0xB0, 0x16), | ||
80 | CMD1(0xBC, 0x81), | ||
81 | CMD1(0xE1, 0x00), | ||
82 | CMD1(0x36, 0x50), | ||
83 | CMD1(0x3B, 0x22), | ||
84 | CMD_NULL, | ||
85 | }; | ||
86 | |||
87 | static uint32_t lcd_vga_transfer[] = { | ||
88 | CMD1(0xcf, 0x02), /* Blanking period control (1) */ | ||
89 | CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ | ||
90 | CMD1(0xd1, 0x01), /* CKV timing control on/off */ | ||
91 | CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */ | ||
92 | CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */ | ||
93 | CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */ | ||
94 | CMD1(0xd5, 0x14), /* ASW timing control (2) */ | ||
95 | CMD0(0x21), /* Invert for normally black display */ | ||
96 | CMD0(0x29), /* Display on */ | ||
97 | CMD_NULL, | ||
98 | }; | ||
99 | |||
100 | static uint32_t lcd_qvga_transfer[] = { | ||
101 | CMD1(0xd6, 0x02), /* Blanking period control (1) */ | ||
102 | CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */ | ||
103 | CMD1(0xd8, 0x01), /* CKV timing control on/off */ | ||
104 | CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */ | ||
105 | CMD2(0xde, 0x05, 0x0a), /* OEV timing control */ | ||
106 | CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */ | ||
107 | CMD1(0xe0, 0x0a), /* ASW timing control (2) */ | ||
108 | CMD0(0x21), /* Invert for normally black display */ | ||
109 | CMD0(0x29), /* Display on */ | ||
110 | CMD_NULL, | ||
111 | }; | ||
112 | |||
113 | static uint32_t lcd_panel_config[] = { | ||
114 | CMD2(0xb8, 0xff, 0xf9), /* Output control */ | ||
115 | CMD0(0x11), /* sleep out */ | ||
116 | CMD1(0xba, 0x01), /* Display mode (1) */ | ||
117 | CMD1(0xbb, 0x00), /* Display mode (2) */ | ||
118 | CMD1(0x3a, 0x60), /* Display mode 18-bit RGB */ | ||
119 | CMD1(0xbf, 0x10), /* Drive system change control */ | ||
120 | CMD1(0xb1, 0x56), /* Booster operation setup */ | ||
121 | CMD1(0xb2, 0x33), /* Booster mode setup */ | ||
122 | CMD1(0xb3, 0x11), /* Booster frequency setup */ | ||
123 | CMD1(0xb4, 0x02), /* Op amp/system clock */ | ||
124 | CMD1(0xb5, 0x35), /* VCS voltage */ | ||
125 | CMD1(0xb6, 0x40), /* VCOM voltage */ | ||
126 | CMD1(0xb7, 0x03), /* External display signal */ | ||
127 | CMD1(0xbd, 0x00), /* ASW slew rate */ | ||
128 | CMD1(0xbe, 0x00), /* Dummy data for QuadData operation */ | ||
129 | CMD1(0xc0, 0x11), /* Sleep out FR count (A) */ | ||
130 | CMD1(0xc1, 0x11), /* Sleep out FR count (B) */ | ||
131 | CMD1(0xc2, 0x11), /* Sleep out FR count (C) */ | ||
132 | CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */ | ||
133 | CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */ | ||
134 | CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */ | ||
135 | CMD1(0xc6, 0xc0), /* Sleep out FR count (G) */ | ||
136 | CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */ | ||
137 | CMD1(0xc8, 0x44), /* Gamma 1 fine tuning (2) */ | ||
138 | CMD1(0xc9, 0x33), /* Gamma 1 inclination adjustment */ | ||
139 | CMD1(0xca, 0x00), /* Gamma 1 blue offset adjustment */ | ||
140 | CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */ | ||
141 | CMD_NULL, | ||
142 | }; | ||
143 | |||
144 | static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array) | ||
145 | { | ||
146 | struct spi_transfer *x = &lcd->xfer; | ||
147 | uint32_t data, *p = array; | ||
148 | int nparams, err = 0; | ||
149 | |||
150 | for (; *p != CMD_NULL; p++) { | ||
151 | |||
152 | nparams = (*p >> 30) & 0x3; | ||
153 | |||
154 | data = *p << (7 - nparams); | ||
155 | switch (nparams) { | ||
156 | case 0: | ||
157 | lcd->buf[0] = (data >> 8) & 0xff; | ||
158 | lcd->buf[1] = data & 0xff; | ||
159 | break; | ||
160 | case 1: | ||
161 | lcd->buf[0] = (data >> 16) & 0xff; | ||
162 | lcd->buf[1] = (data >> 8) & 0xff; | ||
163 | lcd->buf[2] = data & 0xff; | ||
164 | break; | ||
165 | case 2: | ||
166 | lcd->buf[0] = (data >> 24) & 0xff; | ||
167 | lcd->buf[1] = (data >> 16) & 0xff; | ||
168 | lcd->buf[2] = (data >> 8) & 0xff; | ||
169 | lcd->buf[3] = data & 0xff; | ||
170 | break; | ||
171 | default: | ||
172 | continue; | ||
173 | } | ||
174 | x->len = nparams + 2; | ||
175 | err = spi_sync(lcd->spi_dev, &lcd->msg); | ||
176 | if (err) | ||
177 | break; | ||
178 | } | ||
179 | |||
180 | return err; | ||
181 | } | ||
182 | |||
183 | static int tdo24m_adj_mode(struct tdo24m *lcd, int mode) | ||
184 | { | ||
185 | switch (mode) { | ||
186 | case MODE_VGA: | ||
187 | tdo24m_writes(lcd, lcd_vga_pass_through); | ||
188 | tdo24m_writes(lcd, lcd_panel_config); | ||
189 | tdo24m_writes(lcd, lcd_vga_transfer); | ||
190 | break; | ||
191 | case MODE_QVGA: | ||
192 | tdo24m_writes(lcd, lcd_qvga_pass_through); | ||
193 | tdo24m_writes(lcd, lcd_panel_config); | ||
194 | tdo24m_writes(lcd, lcd_qvga_transfer); | ||
195 | break; | ||
196 | default: | ||
197 | return -EINVAL; | ||
198 | } | ||
199 | |||
200 | lcd->mode = mode; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static int tdo24m_power_on(struct tdo24m *lcd) | ||
205 | { | ||
206 | int err; | ||
207 | |||
208 | err = tdo24m_writes(lcd, lcd_panel_on); | ||
209 | if (err) | ||
210 | goto out; | ||
211 | |||
212 | err = tdo24m_writes(lcd, lcd_panel_reset); | ||
213 | if (err) | ||
214 | goto out; | ||
215 | |||
216 | err = tdo24m_adj_mode(lcd, lcd->mode); | ||
217 | out: | ||
218 | return err; | ||
219 | } | ||
220 | |||
221 | static int tdo24m_power_off(struct tdo24m *lcd) | ||
222 | { | ||
223 | return tdo24m_writes(lcd, lcd_panel_off); | ||
224 | } | ||
225 | |||
226 | static int tdo24m_power(struct tdo24m *lcd, int power) | ||
227 | { | ||
228 | int ret = 0; | ||
229 | |||
230 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
231 | ret = tdo24m_power_on(lcd); | ||
232 | else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
233 | ret = tdo24m_power_off(lcd); | ||
234 | |||
235 | if (!ret) | ||
236 | lcd->power = power; | ||
237 | |||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | |||
242 | static int tdo24m_set_power(struct lcd_device *ld, int power) | ||
243 | { | ||
244 | struct tdo24m *lcd = lcd_get_data(ld); | ||
245 | return tdo24m_power(lcd, power); | ||
246 | } | ||
247 | |||
248 | static int tdo24m_get_power(struct lcd_device *ld) | ||
249 | { | ||
250 | struct tdo24m *lcd = lcd_get_data(ld); | ||
251 | return lcd->power; | ||
252 | } | ||
253 | |||
254 | static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m) | ||
255 | { | ||
256 | struct tdo24m *lcd = lcd_get_data(ld); | ||
257 | int mode = MODE_QVGA; | ||
258 | |||
259 | if (m->xres == 640 || m->xres == 480) | ||
260 | mode = MODE_VGA; | ||
261 | |||
262 | if (lcd->mode == mode) | ||
263 | return 0; | ||
264 | |||
265 | return tdo24m_adj_mode(lcd, mode); | ||
266 | } | ||
267 | |||
268 | static struct lcd_ops tdo24m_ops = { | ||
269 | .get_power = tdo24m_get_power, | ||
270 | .set_power = tdo24m_set_power, | ||
271 | .set_mode = tdo24m_set_mode, | ||
272 | }; | ||
273 | |||
274 | static int __devinit tdo24m_probe(struct spi_device *spi) | ||
275 | { | ||
276 | struct tdo24m *lcd; | ||
277 | struct spi_message *m; | ||
278 | struct spi_transfer *x; | ||
279 | int err; | ||
280 | |||
281 | spi->bits_per_word = 8; | ||
282 | spi->mode = SPI_MODE_3; | ||
283 | err = spi_setup(spi); | ||
284 | if (err) | ||
285 | return err; | ||
286 | |||
287 | lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); | ||
288 | if (!lcd) | ||
289 | return -ENOMEM; | ||
290 | |||
291 | lcd->spi_dev = spi; | ||
292 | lcd->power = FB_BLANK_POWERDOWN; | ||
293 | lcd->mode = MODE_VGA; /* default to VGA */ | ||
294 | |||
295 | lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, sizeof(GFP_KERNEL)); | ||
296 | if (lcd->buf == NULL) { | ||
297 | kfree(lcd); | ||
298 | return -ENOMEM; | ||
299 | } | ||
300 | |||
301 | m = &lcd->msg; | ||
302 | x = &lcd->xfer; | ||
303 | |||
304 | spi_message_init(m); | ||
305 | |||
306 | x->tx_buf = &lcd->buf[0]; | ||
307 | spi_message_add_tail(x, m); | ||
308 | |||
309 | lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, | ||
310 | lcd, &tdo24m_ops); | ||
311 | if (IS_ERR(lcd->lcd_dev)) { | ||
312 | err = PTR_ERR(lcd->lcd_dev); | ||
313 | goto out_free; | ||
314 | } | ||
315 | |||
316 | dev_set_drvdata(&spi->dev, lcd); | ||
317 | err = tdo24m_power(lcd, FB_BLANK_UNBLANK); | ||
318 | if (err) | ||
319 | goto out_unregister; | ||
320 | |||
321 | return 0; | ||
322 | |||
323 | out_unregister: | ||
324 | lcd_device_unregister(lcd->lcd_dev); | ||
325 | out_free: | ||
326 | kfree(lcd->buf); | ||
327 | kfree(lcd); | ||
328 | return err; | ||
329 | } | ||
330 | |||
331 | static int __devexit tdo24m_remove(struct spi_device *spi) | ||
332 | { | ||
333 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
334 | |||
335 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
336 | lcd_device_unregister(lcd->lcd_dev); | ||
337 | kfree(lcd->buf); | ||
338 | kfree(lcd); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | #ifdef CONFIG_PM | ||
344 | static int tdo24m_suspend(struct spi_device *spi, pm_message_t state) | ||
345 | { | ||
346 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
347 | |||
348 | return tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
349 | } | ||
350 | |||
351 | static int tdo24m_resume(struct spi_device *spi) | ||
352 | { | ||
353 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
354 | |||
355 | return tdo24m_power(lcd, FB_BLANK_UNBLANK); | ||
356 | } | ||
357 | #else | ||
358 | #define tdo24m_suspend NULL | ||
359 | #define tdo24m_resume NULL | ||
360 | #endif | ||
361 | |||
362 | /* Power down all displays on reboot, poweroff or halt */ | ||
363 | static void tdo24m_shutdown(struct spi_device *spi) | ||
364 | { | ||
365 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
366 | |||
367 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
368 | } | ||
369 | |||
370 | static struct spi_driver tdo24m_driver = { | ||
371 | .driver = { | ||
372 | .name = "tdo24m", | ||
373 | .owner = THIS_MODULE, | ||
374 | }, | ||
375 | .probe = tdo24m_probe, | ||
376 | .remove = __devexit_p(tdo24m_remove), | ||
377 | .shutdown = tdo24m_shutdown, | ||
378 | .suspend = tdo24m_suspend, | ||
379 | .resume = tdo24m_resume, | ||
380 | }; | ||
381 | |||
382 | static int __init tdo24m_init(void) | ||
383 | { | ||
384 | return spi_register_driver(&tdo24m_driver); | ||
385 | } | ||
386 | module_init(tdo24m_init); | ||
387 | |||
388 | static void __exit tdo24m_exit(void) | ||
389 | { | ||
390 | spi_unregister_driver(&tdo24m_driver); | ||
391 | } | ||
392 | module_exit(tdo24m_exit); | ||
393 | |||
394 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
395 | MODULE_DESCRIPTION("Driver for Toppoly TDO24M LCD Panel"); | ||
396 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c index 6d5aa806777e..7644ed249564 100644 --- a/drivers/video/bf54x-lq043fb.c +++ b/drivers/video/bf54x-lq043fb.c | |||
@@ -58,7 +58,7 @@ | |||
58 | #include <asm/gpio.h> | 58 | #include <asm/gpio.h> |
59 | #include <asm/portmux.h> | 59 | #include <asm/portmux.h> |
60 | 60 | ||
61 | #include <asm/mach/bf54x-lq043.h> | 61 | #include <mach/bf54x-lq043.h> |
62 | 62 | ||
63 | #define NO_BL_SUPPORT | 63 | #define NO_BL_SUPPORT |
64 | 64 | ||
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index c14b2435d23e..e729fb279645 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -628,27 +628,18 @@ static long cirrusfb_get_mclk(long freq, int bpp, long *div) | |||
628 | static int cirrusfb_check_var(struct fb_var_screeninfo *var, | 628 | static int cirrusfb_check_var(struct fb_var_screeninfo *var, |
629 | struct fb_info *info) | 629 | struct fb_info *info) |
630 | { | 630 | { |
631 | int nom, den; /* translyting from pixels->bytes */ | 631 | int yres; |
632 | int yres, i; | 632 | /* memory size in pixels */ |
633 | static struct { int xres, yres; } modes[] = | 633 | unsigned pixels = info->screen_size * 8 / var->bits_per_pixel; |
634 | { { 1600, 1280 }, | ||
635 | { 1280, 1024 }, | ||
636 | { 1024, 768 }, | ||
637 | { 800, 600 }, | ||
638 | { 640, 480 }, | ||
639 | { -1, -1 } }; | ||
640 | 634 | ||
641 | switch (var->bits_per_pixel) { | 635 | switch (var->bits_per_pixel) { |
642 | case 1: | 636 | case 1: |
643 | nom = 4; | 637 | pixels /= 4; |
644 | den = 8; | ||
645 | break; /* 8 pixel per byte, only 1/4th of mem usable */ | 638 | break; /* 8 pixel per byte, only 1/4th of mem usable */ |
646 | case 8: | 639 | case 8: |
647 | case 16: | 640 | case 16: |
648 | case 24: | 641 | case 24: |
649 | case 32: | 642 | case 32: |
650 | nom = var->bits_per_pixel / 8; | ||
651 | den = 1; | ||
652 | break; /* 1 pixel == 1 byte */ | 643 | break; /* 1 pixel == 1 byte */ |
653 | default: | 644 | default: |
654 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." | 645 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." |
@@ -658,43 +649,29 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var, | |||
658 | return -EINVAL; | 649 | return -EINVAL; |
659 | } | 650 | } |
660 | 651 | ||
661 | if (var->xres * nom / den * var->yres > info->screen_size) { | 652 | if (var->xres_virtual < var->xres) |
662 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." | 653 | var->xres_virtual = var->xres; |
663 | "resolution too high to fit into video memory!\n", | ||
664 | var->xres, var->yres, var->bits_per_pixel); | ||
665 | DPRINTK("EXIT - EINVAL error\n"); | ||
666 | return -EINVAL; | ||
667 | } | ||
668 | |||
669 | /* use highest possible virtual resolution */ | 654 | /* use highest possible virtual resolution */ |
670 | if (var->xres_virtual == -1 && | 655 | if (var->yres_virtual == -1) { |
671 | var->yres_virtual == -1) { | 656 | var->yres_virtual = pixels / var->xres_virtual; |
672 | printk(KERN_INFO | ||
673 | "cirrusfb: using maximum available virtual resolution\n"); | ||
674 | for (i = 0; modes[i].xres != -1; i++) { | ||
675 | int size = modes[i].xres * nom / den * modes[i].yres; | ||
676 | if (size < info->screen_size / 2) | ||
677 | break; | ||
678 | } | ||
679 | if (modes[i].xres == -1) { | ||
680 | printk(KERN_ERR "cirrusfb: could not find a virtual " | ||
681 | "resolution that fits into video memory!!\n"); | ||
682 | DPRINTK("EXIT - EINVAL error\n"); | ||
683 | return -EINVAL; | ||
684 | } | ||
685 | var->xres_virtual = modes[i].xres; | ||
686 | var->yres_virtual = modes[i].yres; | ||
687 | 657 | ||
688 | printk(KERN_INFO "cirrusfb: virtual resolution set to " | 658 | printk(KERN_INFO "cirrusfb: virtual resolution set to " |
689 | "maximum of %dx%d\n", var->xres_virtual, | 659 | "maximum of %dx%d\n", var->xres_virtual, |
690 | var->yres_virtual); | 660 | var->yres_virtual); |
691 | } | 661 | } |
692 | |||
693 | if (var->xres_virtual < var->xres) | ||
694 | var->xres_virtual = var->xres; | ||
695 | if (var->yres_virtual < var->yres) | 662 | if (var->yres_virtual < var->yres) |
696 | var->yres_virtual = var->yres; | 663 | var->yres_virtual = var->yres; |
697 | 664 | ||
665 | if (var->xres_virtual * var->yres_virtual > pixels) { | ||
666 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected... " | ||
667 | "virtual resolution too high to fit into video memory!\n", | ||
668 | var->xres_virtual, var->yres_virtual, | ||
669 | var->bits_per_pixel); | ||
670 | DPRINTK("EXIT - EINVAL error\n"); | ||
671 | return -EINVAL; | ||
672 | } | ||
673 | |||
674 | |||
698 | if (var->xoffset < 0) | 675 | if (var->xoffset < 0) |
699 | var->xoffset = 0; | 676 | var->xoffset = 0; |
700 | if (var->yoffset < 0) | 677 | if (var->yoffset < 0) |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 98843c2ecf73..0737570030f5 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -979,6 +979,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) | |||
979 | 979 | ||
980 | info->flags &= ~FBINFO_MISC_USEREVENT; | 980 | info->flags &= ~FBINFO_MISC_USEREVENT; |
981 | event.info = info; | 981 | event.info = info; |
982 | event.data = &mode; | ||
982 | fb_notifier_call_chain(evnt, &event); | 983 | fb_notifier_call_chain(evnt, &event); |
983 | } | 984 | } |
984 | } | 985 | } |
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c index cc4c038a1b3f..afeed0611e3e 100644 --- a/drivers/video/metronomefb.c +++ b/drivers/video/metronomefb.c | |||
@@ -40,29 +40,63 @@ | |||
40 | 40 | ||
41 | #include <asm/unaligned.h> | 41 | #include <asm/unaligned.h> |
42 | 42 | ||
43 | |||
44 | #define DEBUG 1 | ||
45 | #ifdef DEBUG | ||
46 | #define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a) | ||
47 | #else | ||
48 | #define DPRINTK(f, a...) | ||
49 | #endif | ||
50 | |||
51 | |||
52 | /* Display specific information */ | 43 | /* Display specific information */ |
53 | #define DPY_W 832 | 44 | #define DPY_W 832 |
54 | #define DPY_H 622 | 45 | #define DPY_H 622 |
55 | 46 | ||
47 | static int user_wfm_size; | ||
48 | |||
56 | /* frame differs from image. frame includes non-visible pixels */ | 49 | /* frame differs from image. frame includes non-visible pixels */ |
57 | struct epd_frame { | 50 | struct epd_frame { |
58 | int fw; /* frame width */ | 51 | int fw; /* frame width */ |
59 | int fh; /* frame height */ | 52 | int fh; /* frame height */ |
53 | u16 config[4]; | ||
54 | int wfm_size; | ||
60 | }; | 55 | }; |
61 | 56 | ||
62 | static struct epd_frame epd_frame_table[] = { | 57 | static struct epd_frame epd_frame_table[] = { |
63 | { | 58 | { |
64 | .fw = 832, | 59 | .fw = 832, |
65 | .fh = 622 | 60 | .fh = 622, |
61 | .config = { | ||
62 | 15 /* sdlew */ | ||
63 | | 2 << 8 /* sdosz */ | ||
64 | | 0 << 11 /* sdor */ | ||
65 | | 0 << 12 /* sdces */ | ||
66 | | 0 << 15, /* sdcer */ | ||
67 | 42 /* gdspl */ | ||
68 | | 1 << 8 /* gdr1 */ | ||
69 | | 1 << 9 /* sdshr */ | ||
70 | | 0 << 15, /* gdspp */ | ||
71 | 18 /* gdspw */ | ||
72 | | 0 << 15, /* dispc */ | ||
73 | 599 /* vdlc */ | ||
74 | | 0 << 11 /* dsi */ | ||
75 | | 0 << 12, /* dsic */ | ||
76 | }, | ||
77 | .wfm_size = 47001, | ||
78 | }, | ||
79 | { | ||
80 | .fw = 1088, | ||
81 | .fh = 791, | ||
82 | .config = { | ||
83 | 0x0104, | ||
84 | 0x031f, | ||
85 | 0x0088, | ||
86 | 0x02ff, | ||
87 | }, | ||
88 | .wfm_size = 46770, | ||
89 | }, | ||
90 | { | ||
91 | .fw = 1200, | ||
92 | .fh = 842, | ||
93 | .config = { | ||
94 | 0x0101, | ||
95 | 0x030e, | ||
96 | 0x0012, | ||
97 | 0x0280, | ||
98 | }, | ||
99 | .wfm_size = 46770, | ||
66 | }, | 100 | }, |
67 | }; | 101 | }; |
68 | 102 | ||
@@ -134,9 +168,8 @@ static u16 calc_img_cksum(u16 *start, int length) | |||
134 | } | 168 | } |
135 | 169 | ||
136 | /* here we decode the incoming waveform file and populate metromem */ | 170 | /* here we decode the incoming waveform file and populate metromem */ |
137 | #define EXP_WFORM_SIZE 47001 | 171 | static int __devinit load_waveform(u8 *mem, size_t size, int m, int t, |
138 | static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | 172 | struct metronomefb_par *par) |
139 | u8 *frame_count) | ||
140 | { | 173 | { |
141 | int tta; | 174 | int tta; |
142 | int wmta; | 175 | int wmta; |
@@ -148,26 +181,31 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
148 | int wfm_idx, owfm_idx; | 181 | int wfm_idx, owfm_idx; |
149 | int mem_idx = 0; | 182 | int mem_idx = 0; |
150 | struct waveform_hdr *wfm_hdr; | 183 | struct waveform_hdr *wfm_hdr; |
184 | u8 *metromem = par->metromem_wfm; | ||
185 | struct device *dev = par->info->dev; | ||
151 | 186 | ||
152 | if (size != EXP_WFORM_SIZE) { | 187 | if (user_wfm_size) |
153 | printk(KERN_ERR "Error: unexpected size %d != %d\n", size, | 188 | epd_frame_table[par->dt].wfm_size = user_wfm_size; |
154 | EXP_WFORM_SIZE); | 189 | |
190 | if (size != epd_frame_table[par->dt].wfm_size) { | ||
191 | dev_err(dev, "Error: unexpected size %d != %d\n", size, | ||
192 | epd_frame_table[par->dt].wfm_size); | ||
155 | return -EINVAL; | 193 | return -EINVAL; |
156 | } | 194 | } |
157 | 195 | ||
158 | wfm_hdr = (struct waveform_hdr *) mem; | 196 | wfm_hdr = (struct waveform_hdr *) mem; |
159 | 197 | ||
160 | if (wfm_hdr->fvsn != 1) { | 198 | if (wfm_hdr->fvsn != 1) { |
161 | printk(KERN_ERR "Error: bad fvsn %x\n", wfm_hdr->fvsn); | 199 | dev_err(dev, "Error: bad fvsn %x\n", wfm_hdr->fvsn); |
162 | return -EINVAL; | 200 | return -EINVAL; |
163 | } | 201 | } |
164 | if (wfm_hdr->luts != 0) { | 202 | if (wfm_hdr->luts != 0) { |
165 | printk(KERN_ERR "Error: bad luts %x\n", wfm_hdr->luts); | 203 | dev_err(dev, "Error: bad luts %x\n", wfm_hdr->luts); |
166 | return -EINVAL; | 204 | return -EINVAL; |
167 | } | 205 | } |
168 | cksum = calc_cksum(32, 47, mem); | 206 | cksum = calc_cksum(32, 47, mem); |
169 | if (cksum != wfm_hdr->wfm_cs) { | 207 | if (cksum != wfm_hdr->wfm_cs) { |
170 | printk(KERN_ERR "Error: bad cksum %x != %x\n", cksum, | 208 | dev_err(dev, "Error: bad cksum %x != %x\n", cksum, |
171 | wfm_hdr->wfm_cs); | 209 | wfm_hdr->wfm_cs); |
172 | return -EINVAL; | 210 | return -EINVAL; |
173 | } | 211 | } |
@@ -175,7 +213,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
175 | wfm_hdr->trc += 1; | 213 | wfm_hdr->trc += 1; |
176 | for (i = 0; i < 5; i++) { | 214 | for (i = 0; i < 5; i++) { |
177 | if (*(wfm_hdr->stuff2a + i) != 0) { | 215 | if (*(wfm_hdr->stuff2a + i) != 0) { |
178 | printk(KERN_ERR "Error: unexpected value in padding\n"); | 216 | dev_err(dev, "Error: unexpected value in padding\n"); |
179 | return -EINVAL; | 217 | return -EINVAL; |
180 | } | 218 | } |
181 | } | 219 | } |
@@ -200,7 +238,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
200 | return -EINVAL; | 238 | return -EINVAL; |
201 | cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem); | 239 | cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem); |
202 | if (cksum != mem[cksum_idx]) { | 240 | if (cksum != mem[cksum_idx]) { |
203 | printk(KERN_ERR "Error: bad temperature range table cksum" | 241 | dev_err(dev, "Error: bad temperature range table cksum" |
204 | " %x != %x\n", cksum, mem[cksum_idx]); | 242 | " %x != %x\n", cksum, mem[cksum_idx]); |
205 | return -EINVAL; | 243 | return -EINVAL; |
206 | } | 244 | } |
@@ -212,7 +250,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
212 | return -EINVAL; | 250 | return -EINVAL; |
213 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); | 251 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); |
214 | if (cksum != mem[cksum_idx]) { | 252 | if (cksum != mem[cksum_idx]) { |
215 | printk(KERN_ERR "Error: bad mode table address cksum" | 253 | dev_err(dev, "Error: bad mode table address cksum" |
216 | " %x != %x\n", cksum, mem[cksum_idx]); | 254 | " %x != %x\n", cksum, mem[cksum_idx]); |
217 | return -EINVAL; | 255 | return -EINVAL; |
218 | } | 256 | } |
@@ -224,7 +262,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
224 | return -EINVAL; | 262 | return -EINVAL; |
225 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); | 263 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); |
226 | if (cksum != mem[cksum_idx]) { | 264 | if (cksum != mem[cksum_idx]) { |
227 | printk(KERN_ERR "Error: bad temperature table address cksum" | 265 | dev_err(dev, "Error: bad temperature table address cksum" |
228 | " %x != %x\n", cksum, mem[cksum_idx]); | 266 | " %x != %x\n", cksum, mem[cksum_idx]); |
229 | return -EINVAL; | 267 | return -EINVAL; |
230 | } | 268 | } |
@@ -259,11 +297,11 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
259 | return -EINVAL; | 297 | return -EINVAL; |
260 | cksum = calc_cksum(owfm_idx, cksum_idx, mem); | 298 | cksum = calc_cksum(owfm_idx, cksum_idx, mem); |
261 | if (cksum != mem[cksum_idx]) { | 299 | if (cksum != mem[cksum_idx]) { |
262 | printk(KERN_ERR "Error: bad waveform data cksum" | 300 | dev_err(dev, "Error: bad waveform data cksum" |
263 | " %x != %x\n", cksum, mem[cksum_idx]); | 301 | " %x != %x\n", cksum, mem[cksum_idx]); |
264 | return -EINVAL; | 302 | return -EINVAL; |
265 | } | 303 | } |
266 | *frame_count = (mem_idx/64); | 304 | par->frame_count = (mem_idx/64); |
267 | 305 | ||
268 | return 0; | 306 | return 0; |
269 | } | 307 | } |
@@ -274,15 +312,12 @@ static int metronome_display_cmd(struct metronomefb_par *par) | |||
274 | u16 cs; | 312 | u16 cs; |
275 | u16 opcode; | 313 | u16 opcode; |
276 | static u8 borderval; | 314 | static u8 borderval; |
277 | u8 *ptr; | ||
278 | 315 | ||
279 | /* setup display command | 316 | /* setup display command |
280 | we can't immediately set the opcode since the controller | 317 | we can't immediately set the opcode since the controller |
281 | will try parse the command before we've set it all up | 318 | will try parse the command before we've set it all up |
282 | so we just set cs here and set the opcode at the end */ | 319 | so we just set cs here and set the opcode at the end */ |
283 | 320 | ||
284 | ptr = par->metromem; | ||
285 | |||
286 | if (par->metromem_cmd->opcode == 0xCC40) | 321 | if (par->metromem_cmd->opcode == 0xCC40) |
287 | opcode = cs = 0xCC41; | 322 | opcode = cs = 0xCC41; |
288 | else | 323 | else |
@@ -335,44 +370,17 @@ static int __devinit metronome_powerup_cmd(struct metronomefb_par *par) | |||
335 | 370 | ||
336 | static int __devinit metronome_config_cmd(struct metronomefb_par *par) | 371 | static int __devinit metronome_config_cmd(struct metronomefb_par *par) |
337 | { | 372 | { |
338 | int i; | ||
339 | u16 cs; | ||
340 | |||
341 | /* setup config command | 373 | /* setup config command |
342 | we can't immediately set the opcode since the controller | 374 | we can't immediately set the opcode since the controller |
343 | will try parse the command before we've set it all up | 375 | will try parse the command before we've set it all up */ |
344 | so we just set cs here and set the opcode at the end */ | ||
345 | |||
346 | cs = 0xCC10; | ||
347 | |||
348 | /* set the 12 args ( 8 bytes ) for config. see spec for meanings */ | ||
349 | i = 0; | ||
350 | par->metromem_cmd->args[i] = 15 /* sdlew */ | ||
351 | | 2 << 8 /* sdosz */ | ||
352 | | 0 << 11 /* sdor */ | ||
353 | | 0 << 12 /* sdces */ | ||
354 | | 0 << 15; /* sdcer */ | ||
355 | cs += par->metromem_cmd->args[i++]; | ||
356 | |||
357 | par->metromem_cmd->args[i] = 42 /* gdspl */ | ||
358 | | 1 << 8 /* gdr1 */ | ||
359 | | 1 << 9 /* sdshr */ | ||
360 | | 0 << 15; /* gdspp */ | ||
361 | cs += par->metromem_cmd->args[i++]; | ||
362 | |||
363 | par->metromem_cmd->args[i] = 18 /* gdspw */ | ||
364 | | 0 << 15; /* dispc */ | ||
365 | cs += par->metromem_cmd->args[i++]; | ||
366 | |||
367 | par->metromem_cmd->args[i] = 599 /* vdlc */ | ||
368 | | 0 << 11 /* dsi */ | ||
369 | | 0 << 12; /* dsic */ | ||
370 | cs += par->metromem_cmd->args[i++]; | ||
371 | 376 | ||
377 | memcpy(par->metromem_cmd->args, epd_frame_table[par->dt].config, | ||
378 | sizeof(epd_frame_table[par->dt].config)); | ||
372 | /* the rest are 0 */ | 379 | /* the rest are 0 */ |
373 | memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2); | 380 | memset((u8 *) (par->metromem_cmd->args + 4), 0, (32-4)*2); |
374 | 381 | ||
375 | par->metromem_cmd->csum = cs; | 382 | par->metromem_cmd->csum = 0xCC10; |
383 | par->metromem_cmd->csum += calc_img_cksum(par->metromem_cmd->args, 4); | ||
376 | par->metromem_cmd->opcode = 0xCC10; /* config cmd */ | 384 | par->metromem_cmd->opcode = 0xCC10; /* config cmd */ |
377 | 385 | ||
378 | return par->board->met_wait_event(par); | 386 | return par->board->met_wait_event(par); |
@@ -408,12 +416,9 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par) | |||
408 | { | 416 | { |
409 | int res; | 417 | int res; |
410 | 418 | ||
411 | par->board->init_gpio_regs(par); | 419 | res = par->board->setup_io(par); |
412 | 420 | if (res) | |
413 | par->board->init_lcdc_regs(par); | 421 | return res; |
414 | |||
415 | /* now that lcd is setup, setup dma descriptor */ | ||
416 | par->board->post_dma_setup(par); | ||
417 | 422 | ||
418 | res = metronome_powerup_cmd(par); | 423 | res = metronome_powerup_cmd(par); |
419 | if (res) | 424 | if (res) |
@@ -430,16 +435,16 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par) | |||
430 | 435 | ||
431 | static void metronomefb_dpy_update(struct metronomefb_par *par) | 436 | static void metronomefb_dpy_update(struct metronomefb_par *par) |
432 | { | 437 | { |
438 | int fbsize; | ||
433 | u16 cksum; | 439 | u16 cksum; |
434 | unsigned char *buf = (unsigned char __force *)par->info->screen_base; | 440 | unsigned char *buf = (unsigned char __force *)par->info->screen_base; |
435 | 441 | ||
442 | fbsize = par->info->fix.smem_len; | ||
436 | /* copy from vm to metromem */ | 443 | /* copy from vm to metromem */ |
437 | memcpy(par->metromem_img, buf, DPY_W*DPY_H); | 444 | memcpy(par->metromem_img, buf, fbsize); |
438 | 445 | ||
439 | cksum = calc_img_cksum((u16 *) par->metromem_img, | 446 | cksum = calc_img_cksum((u16 *) par->metromem_img, fbsize/2); |
440 | (epd_frame_table[0].fw * DPY_H)/2); | 447 | *((u16 *)(par->metromem_img) + fbsize/2) = cksum; |
441 | *((u16 *)(par->metromem_img) + | ||
442 | (epd_frame_table[0].fw * DPY_H)/2) = cksum; | ||
443 | metronome_display_cmd(par); | 448 | metronome_display_cmd(par); |
444 | } | 449 | } |
445 | 450 | ||
@@ -574,8 +579,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
574 | unsigned char *videomemory; | 579 | unsigned char *videomemory; |
575 | struct metronomefb_par *par; | 580 | struct metronomefb_par *par; |
576 | const struct firmware *fw_entry; | 581 | const struct firmware *fw_entry; |
577 | int cmd_size, wfm_size, img_size, padding_size, totalsize; | ||
578 | int i; | 582 | int i; |
583 | int panel_type; | ||
584 | int fw, fh; | ||
585 | int epd_dt_index; | ||
579 | 586 | ||
580 | /* pick up board specific routines */ | 587 | /* pick up board specific routines */ |
581 | board = dev->dev.platform_data; | 588 | board = dev->dev.platform_data; |
@@ -586,96 +593,108 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
586 | if (!try_module_get(board->owner)) | 593 | if (!try_module_get(board->owner)) |
587 | return -ENODEV; | 594 | return -ENODEV; |
588 | 595 | ||
596 | info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev); | ||
597 | if (!info) | ||
598 | goto err; | ||
599 | |||
589 | /* we have two blocks of memory. | 600 | /* we have two blocks of memory. |
590 | info->screen_base which is vm, and is the fb used by apps. | 601 | info->screen_base which is vm, and is the fb used by apps. |
591 | par->metromem which is physically contiguous memory and | 602 | par->metromem which is physically contiguous memory and |
592 | contains the display controller commands, waveform, | 603 | contains the display controller commands, waveform, |
593 | processed image data and padding. this is the data pulled | 604 | processed image data and padding. this is the data pulled |
594 | by the device's LCD controller and pushed to Metronome */ | 605 | by the device's LCD controller and pushed to Metronome. |
606 | the metromem memory is allocated by the board driver and | ||
607 | is provided to us */ | ||
608 | |||
609 | panel_type = board->get_panel_type(); | ||
610 | switch (panel_type) { | ||
611 | case 6: | ||
612 | epd_dt_index = 0; | ||
613 | break; | ||
614 | case 8: | ||
615 | epd_dt_index = 1; | ||
616 | break; | ||
617 | case 97: | ||
618 | epd_dt_index = 2; | ||
619 | break; | ||
620 | default: | ||
621 | dev_err(&dev->dev, "Unexpected panel type. Defaulting to 6\n"); | ||
622 | epd_dt_index = 0; | ||
623 | break; | ||
624 | } | ||
625 | |||
626 | fw = epd_frame_table[epd_dt_index].fw; | ||
627 | fh = epd_frame_table[epd_dt_index].fh; | ||
595 | 628 | ||
596 | videomemorysize = (DPY_W*DPY_H); | 629 | /* we need to add a spare page because our csum caching scheme walks |
630 | * to the end of the page */ | ||
631 | videomemorysize = PAGE_SIZE + (fw * fh); | ||
597 | videomemory = vmalloc(videomemorysize); | 632 | videomemory = vmalloc(videomemorysize); |
598 | if (!videomemory) | 633 | if (!videomemory) |
599 | return -ENOMEM; | 634 | goto err_fb_rel; |
600 | 635 | ||
601 | memset(videomemory, 0, videomemorysize); | 636 | memset(videomemory, 0, videomemorysize); |
602 | 637 | ||
603 | info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev); | ||
604 | if (!info) | ||
605 | goto err_vfree; | ||
606 | |||
607 | info->screen_base = (char __force __iomem *)videomemory; | 638 | info->screen_base = (char __force __iomem *)videomemory; |
608 | info->fbops = &metronomefb_ops; | 639 | info->fbops = &metronomefb_ops; |
609 | 640 | ||
641 | metronomefb_fix.line_length = fw; | ||
642 | metronomefb_var.xres = fw; | ||
643 | metronomefb_var.yres = fh; | ||
644 | metronomefb_var.xres_virtual = fw; | ||
645 | metronomefb_var.yres_virtual = fh; | ||
610 | info->var = metronomefb_var; | 646 | info->var = metronomefb_var; |
611 | info->fix = metronomefb_fix; | 647 | info->fix = metronomefb_fix; |
612 | info->fix.smem_len = videomemorysize; | 648 | info->fix.smem_len = videomemorysize; |
613 | par = info->par; | 649 | par = info->par; |
614 | par->info = info; | 650 | par->info = info; |
615 | par->board = board; | 651 | par->board = board; |
652 | par->dt = epd_dt_index; | ||
616 | init_waitqueue_head(&par->waitq); | 653 | init_waitqueue_head(&par->waitq); |
617 | 654 | ||
618 | /* this table caches per page csum values. */ | 655 | /* this table caches per page csum values. */ |
619 | par->csum_table = vmalloc(videomemorysize/PAGE_SIZE); | 656 | par->csum_table = vmalloc(videomemorysize/PAGE_SIZE); |
620 | if (!par->csum_table) | 657 | if (!par->csum_table) |
658 | goto err_vfree; | ||
659 | |||
660 | /* the physical framebuffer that we use is setup by | ||
661 | * the platform device driver. It will provide us | ||
662 | * with cmd, wfm and image memory in a contiguous area. */ | ||
663 | retval = board->setup_fb(par); | ||
664 | if (retval) { | ||
665 | dev_err(&dev->dev, "Failed to setup fb\n"); | ||
621 | goto err_csum_table; | 666 | goto err_csum_table; |
667 | } | ||
622 | 668 | ||
623 | /* the metromem buffer is divided as follows: | 669 | /* after this point we should have a framebuffer */ |
624 | command | CRC | padding | 670 | if ((!par->metromem_wfm) || (!par->metromem_img) || |
625 | 16kb waveform data | CRC | padding | 671 | (!par->metromem_dma)) { |
626 | image data | CRC | 672 | dev_err(&dev->dev, "fb access failure\n"); |
627 | and an extra 256 bytes for dma descriptors | 673 | retval = -EINVAL; |
628 | eg: IW=832 IH=622 WS=128 | 674 | goto err_csum_table; |
629 | */ | ||
630 | |||
631 | cmd_size = 1 * epd_frame_table[0].fw; | ||
632 | wfm_size = ((16*1024 + 2 + epd_frame_table[0].fw - 1) | ||
633 | / epd_frame_table[0].fw) * epd_frame_table[0].fw; | ||
634 | img_size = epd_frame_table[0].fh * epd_frame_table[0].fw; | ||
635 | padding_size = 4 * epd_frame_table[0].fw; | ||
636 | totalsize = cmd_size + wfm_size + img_size + padding_size; | ||
637 | par->metromemsize = PAGE_ALIGN(totalsize + 256); | ||
638 | DPRINTK("desired memory size = %d\n", par->metromemsize); | ||
639 | dev->dev.coherent_dma_mask = 0xffffffffull; | ||
640 | par->metromem = dma_alloc_writecombine(&dev->dev, par->metromemsize, | ||
641 | &par->metromem_dma, GFP_KERNEL); | ||
642 | if (!par->metromem) { | ||
643 | printk(KERN_ERR | ||
644 | "metronomefb: unable to allocate dma buffer\n"); | ||
645 | goto err_vfree; | ||
646 | } | 675 | } |
647 | 676 | ||
648 | info->fix.smem_start = par->metromem_dma; | 677 | info->fix.smem_start = par->metromem_dma; |
649 | par->metromem_cmd = (struct metromem_cmd *) par->metromem; | ||
650 | par->metromem_wfm = par->metromem + cmd_size; | ||
651 | par->metromem_img = par->metromem + cmd_size + wfm_size; | ||
652 | par->metromem_img_csum = (u16 *) (par->metromem_img + | ||
653 | (epd_frame_table[0].fw * DPY_H)); | ||
654 | DPRINTK("img offset=0x%x\n", cmd_size + wfm_size); | ||
655 | par->metromem_desc = (struct metromem_desc *) (par->metromem + cmd_size | ||
656 | + wfm_size + img_size + padding_size); | ||
657 | par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size | ||
658 | + img_size + padding_size; | ||
659 | 678 | ||
660 | /* load the waveform in. assume mode 3, temp 31 for now | 679 | /* load the waveform in. assume mode 3, temp 31 for now |
661 | a) request the waveform file from userspace | 680 | a) request the waveform file from userspace |
662 | b) process waveform and decode into metromem */ | 681 | b) process waveform and decode into metromem */ |
663 | retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev); | 682 | retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev); |
664 | if (retval < 0) { | 683 | if (retval < 0) { |
665 | printk(KERN_ERR "metronomefb: couldn't get waveform\n"); | 684 | dev_err(&dev->dev, "Failed to get waveform\n"); |
666 | goto err_dma_free; | 685 | goto err_csum_table; |
667 | } | 686 | } |
668 | 687 | ||
669 | retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, | 688 | retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 3, 31, |
670 | par->metromem_wfm, 3, 31, &par->frame_count); | 689 | par); |
671 | release_firmware(fw_entry); | 690 | release_firmware(fw_entry); |
672 | if (retval < 0) { | 691 | if (retval < 0) { |
673 | printk(KERN_ERR "metronomefb: couldn't process waveform\n"); | 692 | dev_err(&dev->dev, "Failed processing waveform\n"); |
674 | goto err_dma_free; | 693 | goto err_csum_table; |
675 | } | 694 | } |
676 | 695 | ||
677 | if (board->setup_irq(info)) | 696 | if (board->setup_irq(info)) |
678 | goto err_dma_free; | 697 | goto err_csum_table; |
679 | 698 | ||
680 | retval = metronome_init_regs(par); | 699 | retval = metronome_init_regs(par); |
681 | if (retval < 0) | 700 | if (retval < 0) |
@@ -688,8 +707,8 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
688 | 707 | ||
689 | retval = fb_alloc_cmap(&info->cmap, 8, 0); | 708 | retval = fb_alloc_cmap(&info->cmap, 8, 0); |
690 | if (retval < 0) { | 709 | if (retval < 0) { |
691 | printk(KERN_ERR "Failed to allocate colormap\n"); | 710 | dev_err(&dev->dev, "Failed to allocate colormap\n"); |
692 | goto err_fb_rel; | 711 | goto err_free_irq; |
693 | } | 712 | } |
694 | 713 | ||
695 | /* set cmap */ | 714 | /* set cmap */ |
@@ -704,7 +723,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
704 | 723 | ||
705 | platform_set_drvdata(dev, info); | 724 | platform_set_drvdata(dev, info); |
706 | 725 | ||
707 | printk(KERN_INFO | 726 | dev_dbg(&dev->dev, |
708 | "fb%d: Metronome frame buffer device, using %dK of video" | 727 | "fb%d: Metronome frame buffer device, using %dK of video" |
709 | " memory\n", info->node, videomemorysize >> 10); | 728 | " memory\n", info->node, videomemorysize >> 10); |
710 | 729 | ||
@@ -712,17 +731,15 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
712 | 731 | ||
713 | err_cmap: | 732 | err_cmap: |
714 | fb_dealloc_cmap(&info->cmap); | 733 | fb_dealloc_cmap(&info->cmap); |
715 | err_fb_rel: | ||
716 | framebuffer_release(info); | ||
717 | err_free_irq: | 734 | err_free_irq: |
718 | board->free_irq(info); | 735 | board->cleanup(par); |
719 | err_dma_free: | ||
720 | dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem, | ||
721 | par->metromem_dma); | ||
722 | err_csum_table: | 736 | err_csum_table: |
723 | vfree(par->csum_table); | 737 | vfree(par->csum_table); |
724 | err_vfree: | 738 | err_vfree: |
725 | vfree(videomemory); | 739 | vfree(videomemory); |
740 | err_fb_rel: | ||
741 | framebuffer_release(info); | ||
742 | err: | ||
726 | module_put(board->owner); | 743 | module_put(board->owner); |
727 | return retval; | 744 | return retval; |
728 | } | 745 | } |
@@ -733,15 +750,15 @@ static int __devexit metronomefb_remove(struct platform_device *dev) | |||
733 | 750 | ||
734 | if (info) { | 751 | if (info) { |
735 | struct metronomefb_par *par = info->par; | 752 | struct metronomefb_par *par = info->par; |
753 | |||
754 | unregister_framebuffer(info); | ||
736 | fb_deferred_io_cleanup(info); | 755 | fb_deferred_io_cleanup(info); |
737 | dma_free_writecombine(&dev->dev, par->metromemsize, | ||
738 | par->metromem, par->metromem_dma); | ||
739 | fb_dealloc_cmap(&info->cmap); | 756 | fb_dealloc_cmap(&info->cmap); |
757 | par->board->cleanup(par); | ||
740 | vfree(par->csum_table); | 758 | vfree(par->csum_table); |
741 | unregister_framebuffer(info); | ||
742 | vfree((void __force *)info->screen_base); | 759 | vfree((void __force *)info->screen_base); |
743 | par->board->free_irq(info); | ||
744 | module_put(par->board->owner); | 760 | module_put(par->board->owner); |
761 | dev_dbg(&dev->dev, "calling release\n"); | ||
745 | framebuffer_release(info); | 762 | framebuffer_release(info); |
746 | } | 763 | } |
747 | return 0; | 764 | return 0; |
@@ -766,6 +783,9 @@ static void __exit metronomefb_exit(void) | |||
766 | platform_driver_unregister(&metronomefb_driver); | 783 | platform_driver_unregister(&metronomefb_driver); |
767 | } | 784 | } |
768 | 785 | ||
786 | module_param(user_wfm_size, uint, 0); | ||
787 | MODULE_PARM_DESC(user_wfm_size, "Set custom waveform size"); | ||
788 | |||
769 | module_init(metronomefb_init); | 789 | module_init(metronomefb_init); |
770 | module_exit(metronomefb_exit); | 790 | module_exit(metronomefb_exit); |
771 | 791 | ||
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c index 77aafcfae037..4599a4385bc9 100644 --- a/drivers/video/tdfxfb.c +++ b/drivers/video/tdfxfb.c | |||
@@ -95,7 +95,6 @@ static inline int mtrr_del(int reg, unsigned long base, | |||
95 | #define VOODOO5_MAX_PIXCLOCK 350000 | 95 | #define VOODOO5_MAX_PIXCLOCK 350000 |
96 | 96 | ||
97 | static struct fb_fix_screeninfo tdfx_fix __devinitdata = { | 97 | static struct fb_fix_screeninfo tdfx_fix __devinitdata = { |
98 | .id = "3Dfx", | ||
99 | .type = FB_TYPE_PACKED_PIXELS, | 98 | .type = FB_TYPE_PACKED_PIXELS, |
100 | .visual = FB_VISUAL_PSEUDOCOLOR, | 99 | .visual = FB_VISUAL_PSEUDOCOLOR, |
101 | .ypanstep = 1, | 100 | .ypanstep = 1, |
@@ -426,7 +425,7 @@ static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id) | |||
426 | if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) { | 425 | if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) { |
427 | /* Banshee/Voodoo3 */ | 426 | /* Banshee/Voodoo3 */ |
428 | chip_size = 2; | 427 | chip_size = 2; |
429 | if (has_sgram && (draminit0 & DRAMINIT0_SGRAM_TYPE)) | 428 | if (has_sgram && !(draminit0 & DRAMINIT0_SGRAM_TYPE)) |
430 | chip_size = 1; | 429 | chip_size = 1; |
431 | } else { | 430 | } else { |
432 | /* Voodoo4/5 */ | 431 | /* Voodoo4/5 */ |
@@ -1200,15 +1199,15 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev, | |||
1200 | /* Configure the default fb_fix_screeninfo first */ | 1199 | /* Configure the default fb_fix_screeninfo first */ |
1201 | switch (pdev->device) { | 1200 | switch (pdev->device) { |
1202 | case PCI_DEVICE_ID_3DFX_BANSHEE: | 1201 | case PCI_DEVICE_ID_3DFX_BANSHEE: |
1203 | strcat(tdfx_fix.id, " Banshee"); | 1202 | strcpy(tdfx_fix.id, "3Dfx Banshee"); |
1204 | default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK; | 1203 | default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK; |
1205 | break; | 1204 | break; |
1206 | case PCI_DEVICE_ID_3DFX_VOODOO3: | 1205 | case PCI_DEVICE_ID_3DFX_VOODOO3: |
1207 | strcat(tdfx_fix.id, " Voodoo3"); | 1206 | strcpy(tdfx_fix.id, "3Dfx Voodoo3"); |
1208 | default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK; | 1207 | default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK; |
1209 | break; | 1208 | break; |
1210 | case PCI_DEVICE_ID_3DFX_VOODOO5: | 1209 | case PCI_DEVICE_ID_3DFX_VOODOO5: |
1211 | strcat(tdfx_fix.id, " Voodoo5"); | 1210 | strcpy(tdfx_fix.id, "3Dfx Voodoo5"); |
1212 | default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK; | 1211 | default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK; |
1213 | break; | 1212 | break; |
1214 | } | 1213 | } |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index db20542796bf..c51036716700 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -465,6 +465,16 @@ config PC87413_WDT | |||
465 | 465 | ||
466 | Most people will say N. | 466 | Most people will say N. |
467 | 467 | ||
468 | config RDC321X_WDT | ||
469 | tristate "RDC R-321x SoC watchdog" | ||
470 | depends on X86_RDC321X | ||
471 | help | ||
472 | This is the driver for the built in hardware watchdog | ||
473 | in the RDC R-321x SoC. | ||
474 | |||
475 | To compile this driver as a module, choose M here: the | ||
476 | module will be called rdc321x_wdt. | ||
477 | |||
468 | config 60XX_WDT | 478 | config 60XX_WDT |
469 | tristate "SBC-60XX Watchdog Timer" | 479 | tristate "SBC-60XX Watchdog Timer" |
470 | depends on X86 | 480 | depends on X86 |
@@ -633,6 +643,16 @@ config SBC_EPX_C3_WATCHDOG | |||
633 | 643 | ||
634 | # MIPS Architecture | 644 | # MIPS Architecture |
635 | 645 | ||
646 | config RC32434_WDT | ||
647 | tristate "IDT RC32434 SoC Watchdog Timer" | ||
648 | depends on MIKROTIK_RB532 | ||
649 | help | ||
650 | Hardware driver for the IDT RC32434 SoC built-in | ||
651 | watchdog timer. | ||
652 | |||
653 | To compile this driver as a module, choose M here: the | ||
654 | module will be called rc32434_wdt. | ||
655 | |||
636 | config INDYDOG | 656 | config INDYDOG |
637 | tristate "Indy/I2 Hardware Watchdog" | 657 | tristate "Indy/I2 Hardware Watchdog" |
638 | depends on SGI_HAS_INDYDOG | 658 | depends on SGI_HAS_INDYDOG |
@@ -692,10 +712,6 @@ config MPC5200_WDT | |||
692 | tristate "MPC5200 Watchdog Timer" | 712 | tristate "MPC5200 Watchdog Timer" |
693 | depends on PPC_MPC52xx | 713 | depends on PPC_MPC52xx |
694 | 714 | ||
695 | config 8xx_WDT | ||
696 | tristate "MPC8xx Watchdog Timer" | ||
697 | depends on 8xx | ||
698 | |||
699 | config 8xxx_WDT | 715 | config 8xxx_WDT |
700 | tristate "MPC8xxx Platform Watchdog Timer" | 716 | tristate "MPC8xxx Platform Watchdog Timer" |
701 | depends on PPC_8xx || PPC_83xx || PPC_86xx | 717 | depends on PPC_8xx || PPC_83xx || PPC_86xx |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ca3dc043d786..e0ef123fbdea 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
@@ -75,6 +75,7 @@ obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o | |||
75 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 75 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o |
76 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | 76 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o |
77 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o | 77 | obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o |
78 | obj-$(CONFIG_RDC321X_WDT) += rdc321x_wdt.o | ||
78 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | 79 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o |
79 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o | 80 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o |
80 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o | 81 | obj-$(CONFIG_SBC7240_WDT) += sbc7240_wdt.o |
@@ -94,6 +95,7 @@ obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o | |||
94 | # M68KNOMMU Architecture | 95 | # M68KNOMMU Architecture |
95 | 96 | ||
96 | # MIPS Architecture | 97 | # MIPS Architecture |
98 | obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o | ||
97 | obj-$(CONFIG_INDYDOG) += indydog.o | 99 | obj-$(CONFIG_INDYDOG) += indydog.o |
98 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o | 100 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o |
99 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o | 101 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o |
@@ -104,7 +106,6 @@ obj-$(CONFIG_TXX9_WDT) += txx9wdt.o | |||
104 | # PARISC Architecture | 106 | # PARISC Architecture |
105 | 107 | ||
106 | # POWERPC Architecture | 108 | # POWERPC Architecture |
107 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o | ||
108 | obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o | 109 | obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o |
109 | obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o | 110 | obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o |
110 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o | 111 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o |
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index d061f0ad2d20..993e5f52afef 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -241,7 +241,7 @@ static int at91wdt_resume(struct platform_device *pdev) | |||
241 | { | 241 | { |
242 | if (at91wdt_busy) | 242 | if (at91wdt_busy) |
243 | at91_wdt_start(); | 243 | at91_wdt_start(); |
244 | return 0; | 244 | return 0; |
245 | } | 245 | } |
246 | 246 | ||
247 | #else | 247 | #else |
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index d039d5f2fd1c..a3765e0be4a8 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
@@ -116,6 +116,7 @@ static unsigned int reload; /* the computed soft_margin */ | |||
116 | static int nowayout = WATCHDOG_NOWAYOUT; | 116 | static int nowayout = WATCHDOG_NOWAYOUT; |
117 | static char expect_release; | 117 | static char expect_release; |
118 | static unsigned long hpwdt_is_open; | 118 | static unsigned long hpwdt_is_open; |
119 | static unsigned int allow_kdump; | ||
119 | 120 | ||
120 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ | 121 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ |
121 | static unsigned long __iomem *hpwdt_timer_reg; | 122 | static unsigned long __iomem *hpwdt_timer_reg; |
@@ -221,19 +222,19 @@ static int __devinit cru_detect(unsigned long map_entry, | |||
221 | 222 | ||
222 | if (cmn_regs.u1.ral != 0) { | 223 | if (cmn_regs.u1.ral != 0) { |
223 | printk(KERN_WARNING | 224 | printk(KERN_WARNING |
224 | "hpwdt: Call succeeded but with an error: 0x%x\n", | 225 | "hpwdt: Call succeeded but with an error: 0x%x\n", |
225 | cmn_regs.u1.ral); | 226 | cmn_regs.u1.ral); |
226 | } else { | 227 | } else { |
227 | physical_bios_base = cmn_regs.u2.rebx; | 228 | physical_bios_base = cmn_regs.u2.rebx; |
228 | physical_bios_offset = cmn_regs.u4.redx; | 229 | physical_bios_offset = cmn_regs.u4.redx; |
229 | cru_length = cmn_regs.u3.recx; | 230 | cru_length = cmn_regs.u3.recx; |
230 | cru_physical_address = | 231 | cru_physical_address = |
231 | physical_bios_base + physical_bios_offset; | 232 | physical_bios_base + physical_bios_offset; |
232 | 233 | ||
233 | /* If the values look OK, then map it in. */ | 234 | /* If the values look OK, then map it in. */ |
234 | if ((physical_bios_base + physical_bios_offset)) { | 235 | if ((physical_bios_base + physical_bios_offset)) { |
235 | cru_rom_addr = | 236 | cru_rom_addr = |
236 | ioremap(cru_physical_address, cru_length); | 237 | ioremap(cru_physical_address, cru_length); |
237 | if (cru_rom_addr) | 238 | if (cru_rom_addr) |
238 | retval = 0; | 239 | retval = 0; |
239 | } | 240 | } |
@@ -356,7 +357,6 @@ asm(".text \n\t" | |||
356 | "call *%r12 \n\t" | 357 | "call *%r12 \n\t" |
357 | "pushfq \n\t" | 358 | "pushfq \n\t" |
358 | "popq %r12 \n\t" | 359 | "popq %r12 \n\t" |
359 | "popfq \n\t" | ||
360 | "movl %eax, (%r9) \n\t" | 360 | "movl %eax, (%r9) \n\t" |
361 | "movl %ebx, 4(%r9) \n\t" | 361 | "movl %ebx, 4(%r9) \n\t" |
362 | "movl %ecx, 8(%r9) \n\t" | 362 | "movl %ecx, 8(%r9) \n\t" |
@@ -390,10 +390,10 @@ static void __devinit dmi_find_cru(const struct dmi_header *dm) | |||
390 | smbios_cru64_ptr = (struct smbios_cru64_info *) dm; | 390 | smbios_cru64_ptr = (struct smbios_cru64_info *) dm; |
391 | if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { | 391 | if (smbios_cru64_ptr->signature == CRU_BIOS_SIGNATURE_VALUE) { |
392 | cru_physical_address = | 392 | cru_physical_address = |
393 | smbios_cru64_ptr->physical_address + | 393 | smbios_cru64_ptr->physical_address + |
394 | smbios_cru64_ptr->double_offset; | 394 | smbios_cru64_ptr->double_offset; |
395 | cru_rom_addr = ioremap(cru_physical_address, | 395 | cru_rom_addr = ioremap(cru_physical_address, |
396 | smbios_cru64_ptr->double_length); | 396 | smbios_cru64_ptr->double_length); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
@@ -405,7 +405,7 @@ static int __devinit detect_cru_service(void) | |||
405 | dmi_walk(dmi_find_cru); | 405 | dmi_walk(dmi_find_cru); |
406 | 406 | ||
407 | /* if cru_rom_addr has been set then we found a CRU service */ | 407 | /* if cru_rom_addr has been set then we found a CRU service */ |
408 | return ((cru_rom_addr != NULL) ? 0: -ENODEV); | 408 | return ((cru_rom_addr != NULL) ? 0 : -ENODEV); |
409 | } | 409 | } |
410 | 410 | ||
411 | /* ------------------------------------------------------------------------- */ | 411 | /* ------------------------------------------------------------------------- */ |
@@ -413,34 +413,6 @@ static int __devinit detect_cru_service(void) | |||
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | /* | 415 | /* |
416 | * NMI Handler | ||
417 | */ | ||
418 | static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason, | ||
419 | void *data) | ||
420 | { | ||
421 | unsigned long rom_pl; | ||
422 | static int die_nmi_called; | ||
423 | |||
424 | if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI) | ||
425 | return NOTIFY_OK; | ||
426 | |||
427 | spin_lock_irqsave(&rom_lock, rom_pl); | ||
428 | if (!die_nmi_called) | ||
429 | asminline_call(&cmn_regs, cru_rom_addr); | ||
430 | die_nmi_called = 1; | ||
431 | spin_unlock_irqrestore(&rom_lock, rom_pl); | ||
432 | if (cmn_regs.u1.ral == 0) { | ||
433 | printk(KERN_WARNING "hpwdt: An NMI occurred, " | ||
434 | "but unable to determine source.\n"); | ||
435 | } else { | ||
436 | panic("An NMI occurred, please see the Integrated " | ||
437 | "Management Log for details.\n"); | ||
438 | } | ||
439 | |||
440 | return NOTIFY_STOP; | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | * Watchdog operations | 416 | * Watchdog operations |
445 | */ | 417 | */ |
446 | static void hpwdt_start(void) | 418 | static void hpwdt_start(void) |
@@ -484,6 +456,36 @@ static int hpwdt_change_timer(int new_margin) | |||
484 | } | 456 | } |
485 | 457 | ||
486 | /* | 458 | /* |
459 | * NMI Handler | ||
460 | */ | ||
461 | static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason, | ||
462 | void *data) | ||
463 | { | ||
464 | unsigned long rom_pl; | ||
465 | static int die_nmi_called; | ||
466 | |||
467 | if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI) | ||
468 | return NOTIFY_OK; | ||
469 | |||
470 | spin_lock_irqsave(&rom_lock, rom_pl); | ||
471 | if (!die_nmi_called) | ||
472 | asminline_call(&cmn_regs, cru_rom_addr); | ||
473 | die_nmi_called = 1; | ||
474 | spin_unlock_irqrestore(&rom_lock, rom_pl); | ||
475 | if (cmn_regs.u1.ral == 0) { | ||
476 | printk(KERN_WARNING "hpwdt: An NMI occurred, " | ||
477 | "but unable to determine source.\n"); | ||
478 | } else { | ||
479 | if (allow_kdump) | ||
480 | hpwdt_stop(); | ||
481 | panic("An NMI occurred, please see the Integrated " | ||
482 | "Management Log for details.\n"); | ||
483 | } | ||
484 | |||
485 | return NOTIFY_STOP; | ||
486 | } | ||
487 | |||
488 | /* | ||
487 | * /dev/watchdog handling | 489 | * /dev/watchdog handling |
488 | */ | 490 | */ |
489 | static int hpwdt_open(struct inode *inode, struct file *file) | 491 | static int hpwdt_open(struct inode *inode, struct file *file) |
@@ -625,17 +627,18 @@ static struct notifier_block die_notifier = { | |||
625 | */ | 627 | */ |
626 | 628 | ||
627 | static int __devinit hpwdt_init_one(struct pci_dev *dev, | 629 | static int __devinit hpwdt_init_one(struct pci_dev *dev, |
628 | const struct pci_device_id *ent) | 630 | const struct pci_device_id *ent) |
629 | { | 631 | { |
630 | int retval; | 632 | int retval; |
631 | 633 | ||
632 | /* | 634 | /* |
633 | * First let's find out if we are on an iLO2 server. We will | 635 | * First let's find out if we are on an iLO2 server. We will |
634 | * not run on a legacy ASM box. | 636 | * not run on a legacy ASM box. |
637 | * So we only support the G5 ProLiant servers and higher. | ||
635 | */ | 638 | */ |
636 | if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) { | 639 | if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) { |
637 | dev_warn(&dev->dev, | 640 | dev_warn(&dev->dev, |
638 | "This server does not have an iLO2 ASIC.\n"); | 641 | "This server does not have an iLO2 ASIC.\n"); |
639 | return -ENODEV; | 642 | return -ENODEV; |
640 | } | 643 | } |
641 | 644 | ||
@@ -669,7 +672,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
669 | retval = detect_cru_service(); | 672 | retval = detect_cru_service(); |
670 | if (retval < 0) { | 673 | if (retval < 0) { |
671 | dev_warn(&dev->dev, | 674 | dev_warn(&dev->dev, |
672 | "Unable to detect the %d Bit CRU Service.\n", | 675 | "Unable to detect the %d Bit CRU Service.\n", |
673 | HPWDT_ARCH); | 676 | HPWDT_ARCH); |
674 | goto error_get_cru; | 677 | goto error_get_cru; |
675 | } | 678 | } |
@@ -684,7 +687,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
684 | retval = register_die_notifier(&die_notifier); | 687 | retval = register_die_notifier(&die_notifier); |
685 | if (retval != 0) { | 688 | if (retval != 0) { |
686 | dev_warn(&dev->dev, | 689 | dev_warn(&dev->dev, |
687 | "Unable to register a die notifier (err=%d).\n", | 690 | "Unable to register a die notifier (err=%d).\n", |
688 | retval); | 691 | retval); |
689 | goto error_die_notifier; | 692 | goto error_die_notifier; |
690 | } | 693 | } |
@@ -699,8 +702,9 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
699 | 702 | ||
700 | printk(KERN_INFO | 703 | printk(KERN_INFO |
701 | "hp Watchdog Timer Driver: 1.00" | 704 | "hp Watchdog Timer Driver: 1.00" |
702 | ", timer margin: %d seconds( nowayout=%d).\n", | 705 | ", timer margin: %d seconds (nowayout=%d)" |
703 | soft_margin, nowayout); | 706 | ", allow kernel dump: %s (default = 0/OFF).\n", |
707 | soft_margin, nowayout, (allow_kdump == 0) ? "OFF" : "ON"); | ||
704 | 708 | ||
705 | return 0; | 709 | return 0; |
706 | 710 | ||
@@ -755,6 +759,9 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | |||
755 | module_param(soft_margin, int, 0); | 759 | module_param(soft_margin, int, 0); |
756 | MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); | 760 | MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds"); |
757 | 761 | ||
762 | module_param(allow_kdump, int, 0); | ||
763 | MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs"); | ||
764 | |||
758 | module_param(nowayout, int, 0); | 765 | module_param(nowayout, int, 0); |
759 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 766 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
760 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 767 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c deleted file mode 100644 index 1336425acf20..000000000000 --- a/drivers/watchdog/mpc8xx_wdt.c +++ /dev/null | |||
@@ -1,170 +0,0 @@ | |||
1 | /* | ||
2 | * mpc8xx_wdt.c - MPC8xx watchdog userspace interface | ||
3 | * | ||
4 | * Author: Florian Schirmer <jolt@tuxbox.org> | ||
5 | * | ||
6 | * 2002 (c) Florian Schirmer <jolt@tuxbox.org> This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | */ | ||
11 | |||
12 | #include <linux/fs.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/miscdevice.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/watchdog.h> | ||
18 | #include <asm/8xx_immap.h> | ||
19 | #include <linux/uaccess.h> | ||
20 | #include <linux/io.h> | ||
21 | #include <syslib/m8xx_wdt.h> | ||
22 | |||
23 | static unsigned long wdt_opened; | ||
24 | static int wdt_status; | ||
25 | static spinlock_t wdt_lock; | ||
26 | |||
27 | static void mpc8xx_wdt_handler_disable(void) | ||
28 | { | ||
29 | volatile uint __iomem *piscr; | ||
30 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; | ||
31 | |||
32 | if (!m8xx_has_internal_rtc) | ||
33 | m8xx_wdt_stop_timer(); | ||
34 | else | ||
35 | out_be32(piscr, in_be32(piscr) & ~(PISCR_PIE | PISCR_PTE)); | ||
36 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler deactivated\n"); | ||
37 | } | ||
38 | |||
39 | static void mpc8xx_wdt_handler_enable(void) | ||
40 | { | ||
41 | volatile uint __iomem *piscr; | ||
42 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; | ||
43 | |||
44 | if (!m8xx_has_internal_rtc) | ||
45 | m8xx_wdt_install_timer(); | ||
46 | else | ||
47 | out_be32(piscr, in_be32(piscr) | PISCR_PIE | PISCR_PTE); | ||
48 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler activated\n"); | ||
49 | } | ||
50 | |||
51 | static int mpc8xx_wdt_open(struct inode *inode, struct file *file) | ||
52 | { | ||
53 | if (test_and_set_bit(0, &wdt_opened)) | ||
54 | return -EBUSY; | ||
55 | m8xx_wdt_reset(); | ||
56 | mpc8xx_wdt_handler_disable(); | ||
57 | return nonseekable_open(inode, file); | ||
58 | } | ||
59 | |||
60 | static int mpc8xx_wdt_release(struct inode *inode, struct file *file) | ||
61 | { | ||
62 | m8xx_wdt_reset(); | ||
63 | #if !defined(CONFIG_WATCHDOG_NOWAYOUT) | ||
64 | mpc8xx_wdt_handler_enable(); | ||
65 | #endif | ||
66 | clear_bit(0, &wdt_opened); | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static ssize_t mpc8xx_wdt_write(struct file *file, const char *data, | ||
71 | size_t len, loff_t *ppos) | ||
72 | { | ||
73 | if (len) { | ||
74 | spin_lock(&wdt_lock); | ||
75 | m8xx_wdt_reset(); | ||
76 | spin_unlock(&wdt_lock); | ||
77 | } | ||
78 | return len; | ||
79 | } | ||
80 | |||
81 | static long mpc8xx_wdt_ioctl(struct file *file, | ||
82 | unsigned int cmd, unsigned long arg) | ||
83 | { | ||
84 | int timeout; | ||
85 | static struct watchdog_info info = { | ||
86 | .options = WDIOF_KEEPALIVEPING, | ||
87 | .firmware_version = 0, | ||
88 | .identity = "MPC8xx watchdog", | ||
89 | }; | ||
90 | |||
91 | switch (cmd) { | ||
92 | case WDIOC_GETSUPPORT: | ||
93 | if (copy_to_user((void *)arg, &info, sizeof(info))) | ||
94 | return -EFAULT; | ||
95 | break; | ||
96 | |||
97 | case WDIOC_GETSTATUS: | ||
98 | case WDIOC_GETBOOTSTATUS: | ||
99 | if (put_user(wdt_status, (int *)arg)) | ||
100 | return -EFAULT; | ||
101 | wdt_status &= ~WDIOF_KEEPALIVEPING; | ||
102 | break; | ||
103 | |||
104 | case WDIOC_GETTEMP: | ||
105 | return -EOPNOTSUPP; | ||
106 | |||
107 | case WDIOC_SETOPTIONS: | ||
108 | return -EOPNOTSUPP; | ||
109 | |||
110 | case WDIOC_KEEPALIVE: | ||
111 | spin_lock(&wdt_lock); | ||
112 | m8xx_wdt_reset(); | ||
113 | wdt_status |= WDIOF_KEEPALIVEPING; | ||
114 | spin_unlock(&wdt_lock); | ||
115 | break; | ||
116 | |||
117 | case WDIOC_SETTIMEOUT: | ||
118 | return -EOPNOTSUPP; | ||
119 | |||
120 | case WDIOC_GETTIMEOUT: | ||
121 | spin_lock(&wdt_lock); | ||
122 | timeout = m8xx_wdt_get_timeout(); | ||
123 | spin_unlock(&wdt_lock); | ||
124 | if (put_user(timeout, (int *)arg)) | ||
125 | return -EFAULT; | ||
126 | break; | ||
127 | |||
128 | default: | ||
129 | return -ENOTTY; | ||
130 | } | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static const struct file_operations mpc8xx_wdt_fops = { | ||
136 | .owner = THIS_MODULE, | ||
137 | .llseek = no_llseek, | ||
138 | .write = mpc8xx_wdt_write, | ||
139 | .unlocked_ioctl = mpc8xx_wdt_ioctl, | ||
140 | .open = mpc8xx_wdt_open, | ||
141 | .release = mpc8xx_wdt_release, | ||
142 | }; | ||
143 | |||
144 | static struct miscdevice mpc8xx_wdt_miscdev = { | ||
145 | .minor = WATCHDOG_MINOR, | ||
146 | .name = "watchdog", | ||
147 | .fops = &mpc8xx_wdt_fops, | ||
148 | }; | ||
149 | |||
150 | static int __init mpc8xx_wdt_init(void) | ||
151 | { | ||
152 | spin_lock_init(&wdt_lock); | ||
153 | return misc_register(&mpc8xx_wdt_miscdev); | ||
154 | } | ||
155 | |||
156 | static void __exit mpc8xx_wdt_exit(void) | ||
157 | { | ||
158 | misc_deregister(&mpc8xx_wdt_miscdev); | ||
159 | |||
160 | m8xx_wdt_reset(); | ||
161 | mpc8xx_wdt_handler_enable(); | ||
162 | } | ||
163 | |||
164 | module_init(mpc8xx_wdt_init); | ||
165 | module_exit(mpc8xx_wdt_exit); | ||
166 | |||
167 | MODULE_AUTHOR("Florian Schirmer <jolt@tuxbox.org>"); | ||
168 | MODULE_DESCRIPTION("MPC8xx watchdog driver"); | ||
169 | MODULE_LICENSE("GPL"); | ||
170 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index f2094960e662..38c588ee694f 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c | |||
@@ -48,6 +48,7 @@ struct mpc8xxx_wdt_type { | |||
48 | }; | 48 | }; |
49 | 49 | ||
50 | static struct mpc8xxx_wdt __iomem *wd_base; | 50 | static struct mpc8xxx_wdt __iomem *wd_base; |
51 | static int mpc8xxx_wdt_init_late(void); | ||
51 | 52 | ||
52 | static u16 timeout = 0xffff; | 53 | static u16 timeout = 0xffff; |
53 | module_param(timeout, ushort, 0); | 54 | module_param(timeout, ushort, 0); |
@@ -213,6 +214,12 @@ static int __devinit mpc8xxx_wdt_probe(struct of_device *ofdev, | |||
213 | else | 214 | else |
214 | timeout_sec = timeout / freq; | 215 | timeout_sec = timeout / freq; |
215 | 216 | ||
217 | #ifdef MODULE | ||
218 | ret = mpc8xxx_wdt_init_late(); | ||
219 | if (ret) | ||
220 | goto err_unmap; | ||
221 | #endif | ||
222 | |||
216 | pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d " | 223 | pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d " |
217 | "(%d seconds)\n", reset ? "reset" : "interrupt", timeout, | 224 | "(%d seconds)\n", reset ? "reset" : "interrupt", timeout, |
218 | timeout_sec); | 225 | timeout_sec); |
@@ -280,7 +287,7 @@ static struct of_platform_driver mpc8xxx_wdt_driver = { | |||
280 | * very early to start pinging the watchdog (misc devices are not yet | 287 | * very early to start pinging the watchdog (misc devices are not yet |
281 | * available), and later module_init() just registers the misc device. | 288 | * available), and later module_init() just registers the misc device. |
282 | */ | 289 | */ |
283 | static int __init mpc8xxx_wdt_init_late(void) | 290 | static int mpc8xxx_wdt_init_late(void) |
284 | { | 291 | { |
285 | int ret; | 292 | int ret; |
286 | 293 | ||
@@ -295,7 +302,9 @@ static int __init mpc8xxx_wdt_init_late(void) | |||
295 | } | 302 | } |
296 | return 0; | 303 | return 0; |
297 | } | 304 | } |
305 | #ifndef MODULE | ||
298 | module_init(mpc8xxx_wdt_init_late); | 306 | module_init(mpc8xxx_wdt_init_late); |
307 | #endif | ||
299 | 308 | ||
300 | static int __init mpc8xxx_wdt_init(void) | 309 | static int __init mpc8xxx_wdt_init(void) |
301 | { | 310 | { |
diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c index e91ada72da1d..484c215e9f3f 100644 --- a/drivers/watchdog/pc87413_wdt.c +++ b/drivers/watchdog/pc87413_wdt.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
33 | #include <linux/version.h> | ||
34 | #include <linux/io.h> | 33 | #include <linux/io.h> |
35 | #include <linux/uaccess.h> | 34 | #include <linux/uaccess.h> |
36 | 35 | ||
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c new file mode 100644 index 000000000000..6756bcb009ed --- /dev/null +++ b/drivers/watchdog/rc32434_wdt.c | |||
@@ -0,0 +1,344 @@ | |||
1 | /* | ||
2 | * IDT Interprise 79RC32434 watchdog driver | ||
3 | * | ||
4 | * Copyright (C) 2006, Ondrej Zajicek <santiago@crfreenet.org> | ||
5 | * Copyright (C) 2008, Florian Fainelli <florian@openwrt.org> | ||
6 | * | ||
7 | * based on | ||
8 | * SoftDog 0.05: A Software Watchdog Device | ||
9 | * | ||
10 | * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #include <linux/module.h> | ||
20 | #include <linux/types.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/fs.h> | ||
23 | #include <linux/mm.h> | ||
24 | #include <linux/miscdevice.h> | ||
25 | #include <linux/watchdog.h> | ||
26 | #include <linux/reboot.h> | ||
27 | #include <linux/smp_lock.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <linux/uaccess.h> | ||
31 | |||
32 | #include <asm/bootinfo.h> | ||
33 | #include <asm/time.h> | ||
34 | #include <asm/mach-rc32434/integ.h> | ||
35 | |||
36 | #define MAX_TIMEOUT 20 | ||
37 | #define RC32434_WDT_INTERVAL (15 * HZ) | ||
38 | |||
39 | #define VERSION "0.2" | ||
40 | |||
41 | static struct { | ||
42 | struct completion stop; | ||
43 | int running; | ||
44 | struct timer_list timer; | ||
45 | int queue; | ||
46 | int default_ticks; | ||
47 | unsigned long inuse; | ||
48 | } rc32434_wdt_device; | ||
49 | |||
50 | static struct integ __iomem *wdt_reg; | ||
51 | static int ticks = 100 * HZ; | ||
52 | |||
53 | static int expect_close; | ||
54 | static int timeout; | ||
55 | |||
56 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
57 | module_param(nowayout, int, 0); | ||
58 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
59 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
60 | |||
61 | |||
62 | static void rc32434_wdt_start(void) | ||
63 | { | ||
64 | u32 val; | ||
65 | |||
66 | if (!rc32434_wdt_device.inuse) { | ||
67 | writel(0, &wdt_reg->wtcount); | ||
68 | |||
69 | val = RC32434_ERR_WRE; | ||
70 | writel(readl(&wdt_reg->errcs) | val, &wdt_reg->errcs); | ||
71 | |||
72 | val = RC32434_WTC_EN; | ||
73 | writel(readl(&wdt_reg->wtc) | val, &wdt_reg->wtc); | ||
74 | } | ||
75 | rc32434_wdt_device.running++; | ||
76 | } | ||
77 | |||
78 | static void rc32434_wdt_stop(void) | ||
79 | { | ||
80 | u32 val; | ||
81 | |||
82 | if (rc32434_wdt_device.running) { | ||
83 | |||
84 | val = ~RC32434_WTC_EN; | ||
85 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | ||
86 | |||
87 | val = ~RC32434_ERR_WRE; | ||
88 | writel(readl(&wdt_reg->errcs) & val, &wdt_reg->errcs); | ||
89 | |||
90 | rc32434_wdt_device.running = 0; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | static void rc32434_wdt_set(int new_timeout) | ||
95 | { | ||
96 | u32 cmp = new_timeout * HZ; | ||
97 | u32 state, val; | ||
98 | |||
99 | timeout = new_timeout; | ||
100 | /* | ||
101 | * store and disable WTC | ||
102 | */ | ||
103 | state = (u32)(readl(&wdt_reg->wtc) & RC32434_WTC_EN); | ||
104 | val = ~RC32434_WTC_EN; | ||
105 | writel(readl(&wdt_reg->wtc) & val, &wdt_reg->wtc); | ||
106 | |||
107 | writel(0, &wdt_reg->wtcount); | ||
108 | writel(cmp, &wdt_reg->wtcompare); | ||
109 | |||
110 | /* | ||
111 | * restore WTC | ||
112 | */ | ||
113 | |||
114 | writel(readl(&wdt_reg->wtc) | state, &wdt_reg); | ||
115 | } | ||
116 | |||
117 | static void rc32434_wdt_reset(void) | ||
118 | { | ||
119 | ticks = rc32434_wdt_device.default_ticks; | ||
120 | } | ||
121 | |||
122 | static void rc32434_wdt_update(unsigned long unused) | ||
123 | { | ||
124 | if (rc32434_wdt_device.running) | ||
125 | ticks--; | ||
126 | |||
127 | writel(0, &wdt_reg->wtcount); | ||
128 | |||
129 | if (rc32434_wdt_device.queue && ticks) | ||
130 | mod_timer(&rc32434_wdt_device.timer, | ||
131 | jiffies + RC32434_WDT_INTERVAL); | ||
132 | else | ||
133 | complete(&rc32434_wdt_device.stop); | ||
134 | } | ||
135 | |||
136 | static int rc32434_wdt_open(struct inode *inode, struct file *file) | ||
137 | { | ||
138 | if (test_and_set_bit(0, &rc32434_wdt_device.inuse)) | ||
139 | return -EBUSY; | ||
140 | |||
141 | if (nowayout) | ||
142 | __module_get(THIS_MODULE); | ||
143 | |||
144 | return nonseekable_open(inode, file); | ||
145 | } | ||
146 | |||
147 | static int rc32434_wdt_release(struct inode *inode, struct file *file) | ||
148 | { | ||
149 | if (expect_close && nowayout == 0) { | ||
150 | rc32434_wdt_stop(); | ||
151 | printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n"); | ||
152 | module_put(THIS_MODULE); | ||
153 | } else | ||
154 | printk(KERN_CRIT KBUILD_MODNAME | ||
155 | ": device closed unexpectedly. WDT will not stop !\n"); | ||
156 | |||
157 | clear_bit(0, &rc32434_wdt_device.inuse); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static ssize_t rc32434_wdt_write(struct file *file, const char *data, | ||
162 | size_t len, loff_t *ppos) | ||
163 | { | ||
164 | if (len) { | ||
165 | if (!nowayout) { | ||
166 | size_t i; | ||
167 | |||
168 | /* In case it was set long ago */ | ||
169 | expect_close = 0; | ||
170 | |||
171 | for (i = 0; i != len; i++) { | ||
172 | char c; | ||
173 | if (get_user(c, data + i)) | ||
174 | return -EFAULT; | ||
175 | if (c == 'V') | ||
176 | expect_close = 1; | ||
177 | } | ||
178 | } | ||
179 | rc32434_wdt_update(0); | ||
180 | return len; | ||
181 | } | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int rc32434_wdt_ioctl(struct inode *inode, struct file *file, | ||
186 | unsigned int cmd, unsigned long arg) | ||
187 | { | ||
188 | void __user *argp = (void __user *)arg; | ||
189 | int new_timeout; | ||
190 | unsigned int value; | ||
191 | static struct watchdog_info ident = { | ||
192 | .options = WDIOF_SETTIMEOUT | | ||
193 | WDIOF_KEEPALIVEPING | | ||
194 | WDIOF_MAGICCLOSE, | ||
195 | .identity = "RC32434_WDT Watchdog", | ||
196 | }; | ||
197 | switch (cmd) { | ||
198 | case WDIOC_KEEPALIVE: | ||
199 | rc32434_wdt_reset(); | ||
200 | break; | ||
201 | case WDIOC_GETSTATUS: | ||
202 | case WDIOC_GETBOOTSTATUS: | ||
203 | value = readl(&wdt_reg->wtcount); | ||
204 | if (copy_to_user(argp, &value, sizeof(int))) | ||
205 | return -EFAULT; | ||
206 | break; | ||
207 | case WDIOC_GETSUPPORT: | ||
208 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
209 | return -EFAULT; | ||
210 | break; | ||
211 | case WDIOC_SETOPTIONS: | ||
212 | if (copy_from_user(&value, argp, sizeof(int))) | ||
213 | return -EFAULT; | ||
214 | switch (value) { | ||
215 | case WDIOS_ENABLECARD: | ||
216 | rc32434_wdt_start(); | ||
217 | break; | ||
218 | case WDIOS_DISABLECARD: | ||
219 | rc32434_wdt_stop(); | ||
220 | default: | ||
221 | return -EINVAL; | ||
222 | } | ||
223 | break; | ||
224 | case WDIOC_SETTIMEOUT: | ||
225 | if (copy_from_user(&new_timeout, argp, sizeof(int))) | ||
226 | return -EFAULT; | ||
227 | if (new_timeout < 1) | ||
228 | return -EINVAL; | ||
229 | if (new_timeout > MAX_TIMEOUT) | ||
230 | return -EINVAL; | ||
231 | rc32434_wdt_set(new_timeout); | ||
232 | case WDIOC_GETTIMEOUT: | ||
233 | return copy_to_user(argp, &timeout, sizeof(int)); | ||
234 | default: | ||
235 | return -ENOTTY; | ||
236 | } | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static struct file_operations rc32434_wdt_fops = { | ||
242 | .owner = THIS_MODULE, | ||
243 | .llseek = no_llseek, | ||
244 | .write = rc32434_wdt_write, | ||
245 | .ioctl = rc32434_wdt_ioctl, | ||
246 | .open = rc32434_wdt_open, | ||
247 | .release = rc32434_wdt_release, | ||
248 | }; | ||
249 | |||
250 | static struct miscdevice rc32434_wdt_miscdev = { | ||
251 | .minor = WATCHDOG_MINOR, | ||
252 | .name = "watchdog", | ||
253 | .fops = &rc32434_wdt_fops, | ||
254 | }; | ||
255 | |||
256 | static char banner[] = KERN_INFO KBUILD_MODNAME | ||
257 | ": Watchdog Timer version " VERSION ", timer margin: %d sec\n"; | ||
258 | |||
259 | static int rc32434_wdt_probe(struct platform_device *pdev) | ||
260 | { | ||
261 | int ret; | ||
262 | struct resource *r; | ||
263 | |||
264 | r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb500_wdt_res"); | ||
265 | if (!r) { | ||
266 | printk(KERN_ERR KBUILD_MODNAME | ||
267 | "failed to retrieve resources\n"); | ||
268 | return -ENODEV; | ||
269 | } | ||
270 | |||
271 | wdt_reg = ioremap_nocache(r->start, r->end - r->start); | ||
272 | if (!wdt_reg) { | ||
273 | printk(KERN_ERR KBUILD_MODNAME | ||
274 | "failed to remap I/O resources\n"); | ||
275 | return -ENXIO; | ||
276 | } | ||
277 | |||
278 | ret = misc_register(&rc32434_wdt_miscdev); | ||
279 | |||
280 | if (ret < 0) { | ||
281 | printk(KERN_ERR KBUILD_MODNAME | ||
282 | "failed to register watchdog device\n"); | ||
283 | goto unmap; | ||
284 | } | ||
285 | |||
286 | init_completion(&rc32434_wdt_device.stop); | ||
287 | rc32434_wdt_device.queue = 0; | ||
288 | |||
289 | clear_bit(0, &rc32434_wdt_device.inuse); | ||
290 | |||
291 | setup_timer(&rc32434_wdt_device.timer, rc32434_wdt_update, 0L); | ||
292 | |||
293 | rc32434_wdt_device.default_ticks = ticks; | ||
294 | |||
295 | rc32434_wdt_start(); | ||
296 | |||
297 | printk(banner, timeout); | ||
298 | |||
299 | return 0; | ||
300 | |||
301 | unmap: | ||
302 | iounmap(wdt_reg); | ||
303 | return ret; | ||
304 | } | ||
305 | |||
306 | static int rc32434_wdt_remove(struct platform_device *pdev) | ||
307 | { | ||
308 | if (rc32434_wdt_device.queue) { | ||
309 | rc32434_wdt_device.queue = 0; | ||
310 | wait_for_completion(&rc32434_wdt_device.stop); | ||
311 | } | ||
312 | misc_deregister(&rc32434_wdt_miscdev); | ||
313 | |||
314 | iounmap(wdt_reg); | ||
315 | |||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static struct platform_driver rc32434_wdt = { | ||
320 | .probe = rc32434_wdt_probe, | ||
321 | .remove = rc32434_wdt_remove, | ||
322 | .driver = { | ||
323 | .name = "rc32434_wdt", | ||
324 | } | ||
325 | }; | ||
326 | |||
327 | static int __init rc32434_wdt_init(void) | ||
328 | { | ||
329 | return platform_driver_register(&rc32434_wdt); | ||
330 | } | ||
331 | |||
332 | static void __exit rc32434_wdt_exit(void) | ||
333 | { | ||
334 | platform_driver_unregister(&rc32434_wdt); | ||
335 | } | ||
336 | |||
337 | module_init(rc32434_wdt_init); | ||
338 | module_exit(rc32434_wdt_exit); | ||
339 | |||
340 | MODULE_AUTHOR("Ondrej Zajicek <santiago@crfreenet.org>," | ||
341 | "Florian Fainelli <florian@openwrt.org>"); | ||
342 | MODULE_DESCRIPTION("Driver for the IDT RC32434 SoC watchdog"); | ||
343 | MODULE_LICENSE("GPL"); | ||
344 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c new file mode 100644 index 000000000000..9108efa73e7d --- /dev/null +++ b/drivers/watchdog/rdc321x_wdt.c | |||
@@ -0,0 +1,285 @@ | |||
1 | /* | ||
2 | * RDC321x watchdog driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org> | ||
5 | * | ||
6 | * This driver is highly inspired from the cpu5_wdt driver | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include <linux/module.h> | ||
25 | #include <linux/moduleparam.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/errno.h> | ||
28 | #include <linux/miscdevice.h> | ||
29 | #include <linux/fs.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/ioport.h> | ||
32 | #include <linux/timer.h> | ||
33 | #include <linux/completion.h> | ||
34 | #include <linux/jiffies.h> | ||
35 | #include <linux/platform_device.h> | ||
36 | #include <linux/watchdog.h> | ||
37 | #include <linux/io.h> | ||
38 | #include <linux/uaccess.h> | ||
39 | |||
40 | #include <asm/mach-rdc321x/rdc321x_defs.h> | ||
41 | |||
42 | #define RDC_WDT_MASK 0x80000000 /* Mask */ | ||
43 | #define RDC_WDT_EN 0x00800000 /* Enable bit */ | ||
44 | #define RDC_WDT_WTI 0x00200000 /* Generate CPU reset/NMI/WDT on timeout */ | ||
45 | #define RDC_WDT_RST 0x00100000 /* Reset bit */ | ||
46 | #define RDC_WDT_WIF 0x00040000 /* WDT IRQ Flag */ | ||
47 | #define RDC_WDT_IRT 0x00000100 /* IRQ Routing table */ | ||
48 | #define RDC_WDT_CNT 0x00000001 /* WDT count */ | ||
49 | |||
50 | #define RDC_CLS_TMR 0x80003844 /* Clear timer */ | ||
51 | |||
52 | #define RDC_WDT_INTERVAL (HZ/10+1) | ||
53 | |||
54 | static int ticks = 1000; | ||
55 | |||
56 | /* some device data */ | ||
57 | |||
58 | static struct { | ||
59 | struct completion stop; | ||
60 | int running; | ||
61 | struct timer_list timer; | ||
62 | int queue; | ||
63 | int default_ticks; | ||
64 | unsigned long inuse; | ||
65 | spinlock_t lock; | ||
66 | } rdc321x_wdt_device; | ||
67 | |||
68 | /* generic helper functions */ | ||
69 | |||
70 | static void rdc321x_wdt_trigger(unsigned long unused) | ||
71 | { | ||
72 | unsigned long flags; | ||
73 | |||
74 | if (rdc321x_wdt_device.running) | ||
75 | ticks--; | ||
76 | |||
77 | /* keep watchdog alive */ | ||
78 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
79 | outl(RDC_WDT_EN | inl(RDC3210_CFGREG_DATA), | ||
80 | RDC3210_CFGREG_DATA); | ||
81 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
82 | |||
83 | /* requeue?? */ | ||
84 | if (rdc321x_wdt_device.queue && ticks) | ||
85 | mod_timer(&rdc321x_wdt_device.timer, | ||
86 | jiffies + RDC_WDT_INTERVAL); | ||
87 | else { | ||
88 | /* ticks doesn't matter anyway */ | ||
89 | complete(&rdc321x_wdt_device.stop); | ||
90 | } | ||
91 | |||
92 | } | ||
93 | |||
94 | static void rdc321x_wdt_reset(void) | ||
95 | { | ||
96 | ticks = rdc321x_wdt_device.default_ticks; | ||
97 | } | ||
98 | |||
99 | static void rdc321x_wdt_start(void) | ||
100 | { | ||
101 | unsigned long flags; | ||
102 | |||
103 | if (!rdc321x_wdt_device.queue) { | ||
104 | rdc321x_wdt_device.queue = 1; | ||
105 | |||
106 | /* Clear the timer */ | ||
107 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
108 | outl(RDC_CLS_TMR, RDC3210_CFGREG_ADDR); | ||
109 | |||
110 | /* Enable watchdog and set the timeout to 81.92 us */ | ||
111 | outl(RDC_WDT_EN | RDC_WDT_CNT, RDC3210_CFGREG_DATA); | ||
112 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
113 | |||
114 | mod_timer(&rdc321x_wdt_device.timer, | ||
115 | jiffies + RDC_WDT_INTERVAL); | ||
116 | } | ||
117 | |||
118 | /* if process dies, counter is not decremented */ | ||
119 | rdc321x_wdt_device.running++; | ||
120 | } | ||
121 | |||
122 | static int rdc321x_wdt_stop(void) | ||
123 | { | ||
124 | if (rdc321x_wdt_device.running) | ||
125 | rdc321x_wdt_device.running = 0; | ||
126 | |||
127 | ticks = rdc321x_wdt_device.default_ticks; | ||
128 | |||
129 | return -EIO; | ||
130 | } | ||
131 | |||
132 | /* filesystem operations */ | ||
133 | static int rdc321x_wdt_open(struct inode *inode, struct file *file) | ||
134 | { | ||
135 | if (test_and_set_bit(0, &rdc321x_wdt_device.inuse)) | ||
136 | return -EBUSY; | ||
137 | |||
138 | return nonseekable_open(inode, file); | ||
139 | } | ||
140 | |||
141 | static int rdc321x_wdt_release(struct inode *inode, struct file *file) | ||
142 | { | ||
143 | clear_bit(0, &rdc321x_wdt_device.inuse); | ||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | static int rdc321x_wdt_ioctl(struct inode *inode, struct file *file, | ||
148 | unsigned int cmd, unsigned long arg) | ||
149 | { | ||
150 | void __user *argp = (void __user *)arg; | ||
151 | unsigned int value; | ||
152 | static struct watchdog_info ident = { | ||
153 | .options = WDIOF_CARDRESET, | ||
154 | .identity = "RDC321x WDT", | ||
155 | }; | ||
156 | unsigned long flags; | ||
157 | |||
158 | switch (cmd) { | ||
159 | case WDIOC_KEEPALIVE: | ||
160 | rdc321x_wdt_reset(); | ||
161 | break; | ||
162 | case WDIOC_GETSTATUS: | ||
163 | /* Read the value from the DATA register */ | ||
164 | spin_lock_irqsave(&rdc321x_wdt_device.lock, flags); | ||
165 | value = inl(RDC3210_CFGREG_DATA); | ||
166 | spin_unlock_irqrestore(&rdc321x_wdt_device.lock, flags); | ||
167 | if (copy_to_user(argp, &value, sizeof(int))) | ||
168 | return -EFAULT; | ||
169 | break; | ||
170 | case WDIOC_GETSUPPORT: | ||
171 | if (copy_to_user(argp, &ident, sizeof(ident))) | ||
172 | return -EFAULT; | ||
173 | break; | ||
174 | case WDIOC_SETOPTIONS: | ||
175 | if (copy_from_user(&value, argp, sizeof(int))) | ||
176 | return -EFAULT; | ||
177 | switch (value) { | ||
178 | case WDIOS_ENABLECARD: | ||
179 | rdc321x_wdt_start(); | ||
180 | break; | ||
181 | case WDIOS_DISABLECARD: | ||
182 | return rdc321x_wdt_stop(); | ||
183 | default: | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | break; | ||
187 | default: | ||
188 | return -ENOTTY; | ||
189 | } | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static ssize_t rdc321x_wdt_write(struct file *file, const char __user *buf, | ||
194 | size_t count, loff_t *ppos) | ||
195 | { | ||
196 | if (!count) | ||
197 | return -EIO; | ||
198 | |||
199 | rdc321x_wdt_reset(); | ||
200 | |||
201 | return count; | ||
202 | } | ||
203 | |||
204 | static const struct file_operations rdc321x_wdt_fops = { | ||
205 | .owner = THIS_MODULE, | ||
206 | .llseek = no_llseek, | ||
207 | .ioctl = rdc321x_wdt_ioctl, | ||
208 | .open = rdc321x_wdt_open, | ||
209 | .write = rdc321x_wdt_write, | ||
210 | .release = rdc321x_wdt_release, | ||
211 | }; | ||
212 | |||
213 | static struct miscdevice rdc321x_wdt_misc = { | ||
214 | .minor = WATCHDOG_MINOR, | ||
215 | .name = "watchdog", | ||
216 | .fops = &rdc321x_wdt_fops, | ||
217 | }; | ||
218 | |||
219 | static int __devinit rdc321x_wdt_probe(struct platform_device *pdev) | ||
220 | { | ||
221 | int err; | ||
222 | |||
223 | err = misc_register(&rdc321x_wdt_misc); | ||
224 | if (err < 0) { | ||
225 | printk(KERN_ERR PFX "watchdog misc_register failed\n"); | ||
226 | return err; | ||
227 | } | ||
228 | |||
229 | spin_lock_init(&rdc321x_wdt_device.lock); | ||
230 | |||
231 | /* Reset the watchdog */ | ||
232 | outl(RDC_WDT_RST, RDC3210_CFGREG_DATA); | ||
233 | |||
234 | init_completion(&rdc321x_wdt_device.stop); | ||
235 | rdc321x_wdt_device.queue = 0; | ||
236 | |||
237 | clear_bit(0, &rdc321x_wdt_device.inuse); | ||
238 | |||
239 | setup_timer(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0); | ||
240 | |||
241 | rdc321x_wdt_device.default_ticks = ticks; | ||
242 | |||
243 | printk(KERN_INFO PFX "watchdog init success\n"); | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int rdc321x_wdt_remove(struct platform_device *pdev) | ||
249 | { | ||
250 | if (rdc321x_wdt_device.queue) { | ||
251 | rdc321x_wdt_device.queue = 0; | ||
252 | wait_for_completion(&rdc321x_wdt_device.stop); | ||
253 | } | ||
254 | |||
255 | misc_deregister(&rdc321x_wdt_misc); | ||
256 | |||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | static struct platform_driver rdc321x_wdt_driver = { | ||
261 | .probe = rdc321x_wdt_probe, | ||
262 | .remove = rdc321x_wdt_remove, | ||
263 | .driver = { | ||
264 | .owner = THIS_MODULE, | ||
265 | .name = "rdc321x-wdt", | ||
266 | }, | ||
267 | }; | ||
268 | |||
269 | static int __init rdc321x_wdt_init(void) | ||
270 | { | ||
271 | return platform_driver_register(&rdc321x_wdt_driver); | ||
272 | } | ||
273 | |||
274 | static void __exit rdc321x_wdt_exit(void) | ||
275 | { | ||
276 | platform_driver_unregister(&rdc321x_wdt_driver); | ||
277 | } | ||
278 | |||
279 | module_init(rdc321x_wdt_init); | ||
280 | module_exit(rdc321x_wdt_exit); | ||
281 | |||
282 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); | ||
283 | MODULE_DESCRIPTION("RDC321x watchdog driver"); | ||
284 | MODULE_LICENSE("GPL"); | ||
285 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 22715e3be5e7..86d42801de45 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c | |||
@@ -21,18 +21,6 @@ | |||
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | * | ||
25 | * Changelog: | ||
26 | * 05-Oct-2004 BJD Added semaphore init to stop crashes on open | ||
27 | * Fixed tmr_count / wdt_count confusion | ||
28 | * Added configurable debug | ||
29 | * | ||
30 | * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code | ||
31 | * | ||
32 | * 25-Jan-2005 DA Added suspend/resume support | ||
33 | * Replaced reboot notifier with .shutdown method | ||
34 | * | ||
35 | * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA | ||
36 | */ | 24 | */ |
37 | 25 | ||
38 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -365,7 +353,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
365 | return -ENOENT; | 353 | return -ENOENT; |
366 | } | 354 | } |
367 | 355 | ||
368 | size = (res->end-res->start)+1; | 356 | size = (res->end - res->start) + 1; |
369 | wdt_mem = request_mem_region(res->start, size, pdev->name); | 357 | wdt_mem = request_mem_region(res->start, size, pdev->name); |
370 | if (wdt_mem == NULL) { | 358 | if (wdt_mem == NULL) { |
371 | dev_err(dev, "failed to get memory region\n"); | 359 | dev_err(dev, "failed to get memory region\n"); |
@@ -374,7 +362,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) | |||
374 | } | 362 | } |
375 | 363 | ||
376 | wdt_base = ioremap(res->start, size); | 364 | wdt_base = ioremap(res->start, size); |
377 | if (wdt_base == 0) { | 365 | if (wdt_base == NULL) { |
378 | dev_err(dev, "failed to ioremap() region\n"); | 366 | dev_err(dev, "failed to ioremap() region\n"); |
379 | ret = -EINVAL; | 367 | ret = -EINVAL; |
380 | goto err_req; | 368 | goto err_req; |
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index d4427cb86979..2e15da5459cf 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -60,7 +60,7 @@ | |||
60 | 60 | ||
61 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) | 61 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) |
62 | 62 | ||
63 | #define BALLOON_CLASS_NAME "memory" | 63 | #define BALLOON_CLASS_NAME "xen_memory" |
64 | 64 | ||
65 | struct balloon_stats { | 65 | struct balloon_stats { |
66 | /* We aim for 'current allocation' == 'target allocation'. */ | 66 | /* We aim for 'current allocation' == 'target allocation'. */ |