diff options
Diffstat (limited to 'sound/pci/ymfpci/ymfpci_main.c')
-rw-r--r-- | sound/pci/ymfpci/ymfpci_main.c | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 27fa523639ae..88a43e091d77 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
@@ -92,9 +92,9 @@ static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary) | |||
92 | if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0) | 92 | if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0) |
93 | return 0; | 93 | return 0; |
94 | set_current_state(TASK_UNINTERRUPTIBLE); | 94 | set_current_state(TASK_UNINTERRUPTIBLE); |
95 | schedule_timeout(1); | 95 | schedule_timeout_uninterruptible(1); |
96 | } while (time_before(jiffies, end_time)); | 96 | } while (time_before(jiffies, end_time)); |
97 | snd_printk("codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg)); | 97 | snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg)); |
98 | return -EBUSY; | 98 | return -EBUSY; |
99 | } | 99 | } |
100 | 100 | ||
@@ -728,8 +728,7 @@ static void snd_ymfpci_irq_wait(ymfpci_t *chip) | |||
728 | init_waitqueue_entry(&wait, current); | 728 | init_waitqueue_entry(&wait, current); |
729 | add_wait_queue(&chip->interrupt_sleep, &wait); | 729 | add_wait_queue(&chip->interrupt_sleep, &wait); |
730 | atomic_inc(&chip->interrupt_sleep_count); | 730 | atomic_inc(&chip->interrupt_sleep_count); |
731 | set_current_state(TASK_UNINTERRUPTIBLE); | 731 | schedule_timeout_uninterruptible(msecs_to_jiffies(50)); |
732 | schedule_timeout(HZ/20); | ||
733 | remove_wait_queue(&chip->interrupt_sleep, &wait); | 732 | remove_wait_queue(&chip->interrupt_sleep, &wait); |
734 | } | 733 | } |
735 | } | 734 | } |
@@ -1421,15 +1420,18 @@ static snd_kcontrol_new_t snd_ymfpci_drec_source __devinitdata = { | |||
1421 | * Mixer controls | 1420 | * Mixer controls |
1422 | */ | 1421 | */ |
1423 | 1422 | ||
1424 | #define YMFPCI_SINGLE(xname, xindex, reg) \ | 1423 | #define YMFPCI_SINGLE(xname, xindex, reg, shift) \ |
1425 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 1424 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
1426 | .info = snd_ymfpci_info_single, \ | 1425 | .info = snd_ymfpci_info_single, \ |
1427 | .get = snd_ymfpci_get_single, .put = snd_ymfpci_put_single, \ | 1426 | .get = snd_ymfpci_get_single, .put = snd_ymfpci_put_single, \ |
1428 | .private_value = reg } | 1427 | .private_value = ((reg) | ((shift) << 16)) } |
1429 | 1428 | ||
1430 | static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 1429 | static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, |
1430 | snd_ctl_elem_info_t *uinfo) | ||
1431 | { | 1431 | { |
1432 | switch (kcontrol->private_value) { | 1432 | int reg = kcontrol->private_value & 0xffff; |
1433 | |||
1434 | switch (reg) { | ||
1433 | case YDSXGR_SPDIFOUTCTRL: break; | 1435 | case YDSXGR_SPDIFOUTCTRL: break; |
1434 | case YDSXGR_SPDIFINCTRL: break; | 1436 | case YDSXGR_SPDIFINCTRL: break; |
1435 | default: return -EINVAL; | 1437 | default: return -EINVAL; |
@@ -1441,30 +1443,35 @@ static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t | |||
1441 | return 0; | 1443 | return 0; |
1442 | } | 1444 | } |
1443 | 1445 | ||
1444 | static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1446 | static int snd_ymfpci_get_single(snd_kcontrol_t *kcontrol, |
1447 | snd_ctl_elem_value_t *ucontrol) | ||
1445 | { | 1448 | { |
1446 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1449 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1447 | int reg = kcontrol->private_value; | 1450 | int reg = kcontrol->private_value & 0xffff; |
1448 | unsigned int shift = 0, mask = 1; | 1451 | unsigned int shift = (kcontrol->private_value >> 16) & 0xff; |
1452 | unsigned int mask = 1; | ||
1449 | 1453 | ||
1450 | switch (kcontrol->private_value) { | 1454 | switch (reg) { |
1451 | case YDSXGR_SPDIFOUTCTRL: break; | 1455 | case YDSXGR_SPDIFOUTCTRL: break; |
1452 | case YDSXGR_SPDIFINCTRL: break; | 1456 | case YDSXGR_SPDIFINCTRL: break; |
1453 | default: return -EINVAL; | 1457 | default: return -EINVAL; |
1454 | } | 1458 | } |
1455 | ucontrol->value.integer.value[0] = (snd_ymfpci_readl(chip, reg) >> shift) & mask; | 1459 | ucontrol->value.integer.value[0] = |
1460 | (snd_ymfpci_readl(chip, reg) >> shift) & mask; | ||
1456 | return 0; | 1461 | return 0; |
1457 | } | 1462 | } |
1458 | 1463 | ||
1459 | static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 1464 | static int snd_ymfpci_put_single(snd_kcontrol_t *kcontrol, |
1465 | snd_ctl_elem_value_t *ucontrol) | ||
1460 | { | 1466 | { |
1461 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); | 1467 | ymfpci_t *chip = snd_kcontrol_chip(kcontrol); |
1462 | int reg = kcontrol->private_value; | 1468 | int reg = kcontrol->private_value & 0xffff; |
1463 | unsigned int shift = 0, mask = 1; | 1469 | unsigned int shift = (kcontrol->private_value >> 16) & 0xff; |
1470 | unsigned int mask = 1; | ||
1464 | int change; | 1471 | int change; |
1465 | unsigned int val, oval; | 1472 | unsigned int val, oval; |
1466 | 1473 | ||
1467 | switch (kcontrol->private_value) { | 1474 | switch (reg) { |
1468 | case YDSXGR_SPDIFOUTCTRL: break; | 1475 | case YDSXGR_SPDIFOUTCTRL: break; |
1469 | case YDSXGR_SPDIFINCTRL: break; | 1476 | case YDSXGR_SPDIFINCTRL: break; |
1470 | default: return -EINVAL; | 1477 | default: return -EINVAL; |
@@ -1583,8 +1590,9 @@ YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ", PLAYBACK,VOLUME), 0, YDSXGR_ZVOUTVO | |||
1583 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("", CAPTURE,VOLUME), 0, YDSXGR_ZVLOOPVOL), | 1590 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("", CAPTURE,VOLUME), 0, YDSXGR_ZVLOOPVOL), |
1584 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ",PLAYBACK,VOLUME), 1, YDSXGR_SPDIFOUTVOL), | 1591 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("AC97 ",PLAYBACK,VOLUME), 1, YDSXGR_SPDIFOUTVOL), |
1585 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,VOLUME), 1, YDSXGR_SPDIFLOOPVOL), | 1592 | YMFPCI_DOUBLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,VOLUME), 1, YDSXGR_SPDIFLOOPVOL), |
1586 | YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 0, YDSXGR_SPDIFOUTCTRL), | 1593 | YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 0, YDSXGR_SPDIFOUTCTRL, 0), |
1587 | YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, YDSXGR_SPDIFINCTRL), | 1594 | YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, YDSXGR_SPDIFINCTRL, 0), |
1595 | YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("Loop",NONE,NONE), 0, YDSXGR_SPDIFINCTRL, 4), | ||
1588 | { | 1596 | { |
1589 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1597 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1590 | .name = "4ch Duplication", | 1598 | .name = "4ch Duplication", |
@@ -1842,9 +1850,7 @@ static int snd_ymfpci_timer_start(snd_timer_t *timer) | |||
1842 | unsigned int count; | 1850 | unsigned int count; |
1843 | 1851 | ||
1844 | chip = snd_timer_chip(timer); | 1852 | chip = snd_timer_chip(timer); |
1845 | count = timer->sticks - 1; | 1853 | count = (timer->sticks << 1) - 1; |
1846 | if (count == 0) /* minimum time is 20.8 us */ | ||
1847 | count = 1; | ||
1848 | spin_lock_irqsave(&chip->reg_lock, flags); | 1854 | spin_lock_irqsave(&chip->reg_lock, flags); |
1849 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); | 1855 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); |
1850 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); | 1856 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); |
@@ -1868,14 +1874,14 @@ static int snd_ymfpci_timer_precise_resolution(snd_timer_t *timer, | |||
1868 | unsigned long *num, unsigned long *den) | 1874 | unsigned long *num, unsigned long *den) |
1869 | { | 1875 | { |
1870 | *num = 1; | 1876 | *num = 1; |
1871 | *den = 96000; | 1877 | *den = 48000; |
1872 | return 0; | 1878 | return 0; |
1873 | } | 1879 | } |
1874 | 1880 | ||
1875 | static struct _snd_timer_hardware snd_ymfpci_timer_hw = { | 1881 | static struct _snd_timer_hardware snd_ymfpci_timer_hw = { |
1876 | .flags = SNDRV_TIMER_HW_AUTO, | 1882 | .flags = SNDRV_TIMER_HW_AUTO, |
1877 | .resolution = 10417, /* 1/2fs = 10.41666...us */ | 1883 | .resolution = 20833, /* 1/fs = 20.8333...us */ |
1878 | .ticks = 65536, | 1884 | .ticks = 0x8000, |
1879 | .start = snd_ymfpci_timer_start, | 1885 | .start = snd_ymfpci_timer_start, |
1880 | .stop = snd_ymfpci_timer_stop, | 1886 | .stop = snd_ymfpci_timer_stop, |
1881 | .precise_resolution = snd_ymfpci_timer_precise_resolution, | 1887 | .precise_resolution = snd_ymfpci_timer_precise_resolution, |
@@ -2142,14 +2148,8 @@ static int snd_ymfpci_free(ymfpci_t *chip) | |||
2142 | #ifdef CONFIG_PM | 2148 | #ifdef CONFIG_PM |
2143 | vfree(chip->saved_regs); | 2149 | vfree(chip->saved_regs); |
2144 | #endif | 2150 | #endif |
2145 | if (chip->mpu_res) { | 2151 | release_and_free_resource(chip->mpu_res); |
2146 | release_resource(chip->mpu_res); | 2152 | release_and_free_resource(chip->fm_res); |
2147 | kfree_nocheck(chip->mpu_res); | ||
2148 | } | ||
2149 | if (chip->fm_res) { | ||
2150 | release_resource(chip->fm_res); | ||
2151 | kfree_nocheck(chip->fm_res); | ||
2152 | } | ||
2153 | snd_ymfpci_free_gameport(chip); | 2153 | snd_ymfpci_free_gameport(chip); |
2154 | if (chip->reg_area_virt) | 2154 | if (chip->reg_area_virt) |
2155 | iounmap(chip->reg_area_virt); | 2155 | iounmap(chip->reg_area_virt); |
@@ -2158,10 +2158,7 @@ static int snd_ymfpci_free(ymfpci_t *chip) | |||
2158 | 2158 | ||
2159 | if (chip->irq >= 0) | 2159 | if (chip->irq >= 0) |
2160 | free_irq(chip->irq, (void *)chip); | 2160 | free_irq(chip->irq, (void *)chip); |
2161 | if (chip->res_reg_area) { | 2161 | release_and_free_resource(chip->res_reg_area); |
2162 | release_resource(chip->res_reg_area); | ||
2163 | kfree_nocheck(chip->res_reg_area); | ||
2164 | } | ||
2165 | 2162 | ||
2166 | pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); | 2163 | pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); |
2167 | 2164 | ||
@@ -2290,12 +2287,12 @@ int __devinit snd_ymfpci_create(snd_card_t * card, | |||
2290 | pci_set_master(pci); | 2287 | pci_set_master(pci); |
2291 | 2288 | ||
2292 | if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { | 2289 | if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { |
2293 | snd_printk("unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); | 2290 | snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); |
2294 | snd_ymfpci_free(chip); | 2291 | snd_ymfpci_free(chip); |
2295 | return -EBUSY; | 2292 | return -EBUSY; |
2296 | } | 2293 | } |
2297 | if (request_irq(pci->irq, snd_ymfpci_interrupt, SA_INTERRUPT|SA_SHIRQ, "YMFPCI", (void *) chip)) { | 2294 | if (request_irq(pci->irq, snd_ymfpci_interrupt, SA_INTERRUPT|SA_SHIRQ, "YMFPCI", (void *) chip)) { |
2298 | snd_printk("unable to grab IRQ %d\n", pci->irq); | 2295 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); |
2299 | snd_ymfpci_free(chip); | 2296 | snd_ymfpci_free(chip); |
2300 | return -EBUSY; | 2297 | return -EBUSY; |
2301 | } | 2298 | } |