aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/cmipci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/cmipci.c')
-rw-r--r--sound/pci/cmipci.c116
1 files changed, 88 insertions, 28 deletions
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 1fa5f004e858..135f30860753 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -20,7 +20,6 @@
20/* Does not work. Warning may block system in capture mode */ 20/* Does not work. Warning may block system in capture mode */
21/* #define USE_VAR48KRATE */ 21/* #define USE_VAR48KRATE */
22 22
23#include <sound/driver.h>
24#include <asm/io.h> 23#include <asm/io.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
@@ -150,6 +149,8 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address.");
150#define CM_CH0_SRATE_176K 0x00000200 149#define CM_CH0_SRATE_176K 0x00000200
151#define CM_CH0_SRATE_96K 0x00000200 /* model 055? */ 150#define CM_CH0_SRATE_96K 0x00000200 /* model 055? */
152#define CM_CH0_SRATE_88K 0x00000100 151#define CM_CH0_SRATE_88K 0x00000100
152#define CM_CH0_SRATE_128K 0x00000300
153#define CM_CH0_SRATE_MASK 0x00000300
153 154
154#define CM_SPDIF_INVERSE2 0x00000080 /* model 055? */ 155#define CM_SPDIF_INVERSE2 0x00000080 /* model 055? */
155#define CM_DBLSPDS 0x00000040 /* double SPDIF sample rate 88.2/96 */ 156#define CM_DBLSPDS 0x00000040 /* double SPDIF sample rate 88.2/96 */
@@ -473,6 +474,7 @@ struct cmipci {
473 unsigned int can_ac3_sw: 1; 474 unsigned int can_ac3_sw: 1;
474 unsigned int can_ac3_hw: 1; 475 unsigned int can_ac3_hw: 1;
475 unsigned int can_multi_ch: 1; 476 unsigned int can_multi_ch: 1;
477 unsigned int can_96k: 1; /* samplerate above 48k */
476 unsigned int do_soft_ac3: 1; 478 unsigned int do_soft_ac3: 1;
477 479
478 unsigned int spdif_playback_avail: 1; /* spdif ready? */ 480 unsigned int spdif_playback_avail: 1; /* spdif ready? */
@@ -603,8 +605,6 @@ static unsigned int snd_cmipci_rate_freq(unsigned int rate)
603{ 605{
604 unsigned int i; 606 unsigned int i;
605 607
606 if (rate > 48000)
607 rate /= 2;
608 for (i = 0; i < ARRAY_SIZE(rates); i++) { 608 for (i = 0; i < ARRAY_SIZE(rates); i++) {
609 if (rates[i] == rate) 609 if (rates[i] == rate)
610 return i; 610 return i;
@@ -782,7 +782,7 @@ static int set_dac_channels(struct cmipci *cm, struct cmipci_pcm *rec, int chann
782static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec, 782static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
783 struct snd_pcm_substream *substream) 783 struct snd_pcm_substream *substream)
784{ 784{
785 unsigned int reg, freq, val; 785 unsigned int reg, freq, freq_ext, val;
786 unsigned int period_size; 786 unsigned int period_size;
787 struct snd_pcm_runtime *runtime = substream->runtime; 787 struct snd_pcm_runtime *runtime = substream->runtime;
788 788
@@ -830,7 +830,17 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
830 //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl); 830 //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl);
831 831
832 /* set sample rate */ 832 /* set sample rate */
833 freq = snd_cmipci_rate_freq(runtime->rate); 833 freq = 0;
834 freq_ext = 0;
835 if (runtime->rate > 48000)
836 switch (runtime->rate) {
837 case 88200: freq_ext = CM_CH0_SRATE_88K; break;
838 case 96000: freq_ext = CM_CH0_SRATE_96K; break;
839 case 128000: freq_ext = CM_CH0_SRATE_128K; break;
840 default: snd_BUG(); break;
841 }
842 else
843 freq = snd_cmipci_rate_freq(runtime->rate);
834 val = snd_cmipci_read(cm, CM_REG_FUNCTRL1); 844 val = snd_cmipci_read(cm, CM_REG_FUNCTRL1);
835 if (rec->ch) { 845 if (rec->ch) {
836 val &= ~CM_DSFC_MASK; 846 val &= ~CM_DSFC_MASK;
@@ -851,19 +861,20 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
851 val &= ~CM_CH0FMT_MASK; 861 val &= ~CM_CH0FMT_MASK;
852 val |= rec->fmt << CM_CH0FMT_SHIFT; 862 val |= rec->fmt << CM_CH0FMT_SHIFT;
853 } 863 }
854 if (cm->chip_version == 68) { 864 if (cm->can_96k) {
855 if (runtime->rate == 88200) 865 val &= ~(CM_CH0_SRATE_MASK << (rec->ch * 2));
856 val |= CM_CH0_SRATE_88K << (rec->ch * 2); 866 val |= freq_ext << (rec->ch * 2);
857 else
858 val &= ~(CM_CH0_SRATE_88K << (rec->ch * 2));
859 if (runtime->rate == 96000)
860 val |= CM_CH0_SRATE_96K << (rec->ch * 2);
861 else
862 val &= ~(CM_CH0_SRATE_96K << (rec->ch * 2));
863 } 867 }
864 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); 868 snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
865 //snd_printd("cmipci: chformat = %08x\n", val); 869 //snd_printd("cmipci: chformat = %08x\n", val);
866 870
871 if (!rec->is_dac && cm->chip_version) {
872 if (runtime->rate > 44100)
873 snd_cmipci_set_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K);
874 else
875 snd_cmipci_clear_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K);
876 }
877
867 rec->running = 0; 878 rec->running = 0;
868 spin_unlock_irq(&cm->reg_lock); 879 spin_unlock_irq(&cm->reg_lock);
869 880
@@ -1280,7 +1291,7 @@ static int snd_cmipci_playback_prepare(struct snd_pcm_substream *substream)
1280 int rate = substream->runtime->rate; 1291 int rate = substream->runtime->rate;
1281 int err, do_spdif, do_ac3 = 0; 1292 int err, do_spdif, do_ac3 = 0;
1282 1293
1283 do_spdif = (rate >= 44100 && 1294 do_spdif = (rate >= 44100 && rate <= 96000 &&
1284 substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE && 1295 substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE &&
1285 substream->runtime->channels == 2); 1296 substream->runtime->channels == 2);
1286 if (do_spdif && cm->can_ac3_hw) 1297 if (do_spdif && cm->can_ac3_hw)
@@ -1336,10 +1347,8 @@ static void snd_cmipci_silence_hack(struct cmipci *cm, struct cmipci_pcm *rec)
1336 val = snd_cmipci_read(cm, CM_REG_CHFORMAT); 1347 val = snd_cmipci_read(cm, CM_REG_CHFORMAT);
1337 val &= ~(CM_CH0FMT_MASK << (rec->ch * 2)); 1348 val &= ~(CM_CH0FMT_MASK << (rec->ch * 2));
1338 val |= (3 << CM_CH0FMT_SHIFT) << (rec->ch * 2); 1349 val |= (3 << CM_CH0FMT_SHIFT) << (rec->ch * 2);
1339 if (cm->chip_version == 68) { 1350 if (cm->can_96k)
1340 val &= ~(CM_CH0_SRATE_88K << (rec->ch * 2)); 1351 val &= ~(CM_CH0_SRATE_MASK << (rec->ch * 2));
1341 val &= ~(CM_CH0_SRATE_96K << (rec->ch * 2));
1342 }
1343 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); 1352 snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
1344 1353
1345 /* start stream (we don't need interrupts) */ 1354 /* start stream (we don't need interrupts) */
@@ -1391,6 +1400,17 @@ static int snd_cmipci_capture_spdif_prepare(struct snd_pcm_substream *substream)
1391 1400
1392 spin_lock_irq(&cm->reg_lock); 1401 spin_lock_irq(&cm->reg_lock);
1393 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); 1402 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF);
1403 if (cm->can_96k) {
1404 if (substream->runtime->rate > 48000)
1405 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
1406 else
1407 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS);
1408 }
1409 if (snd_pcm_format_width(substream->runtime->format) > 16)
1410 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
1411 else
1412 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
1413
1394 spin_unlock_irq(&cm->reg_lock); 1414 spin_unlock_irq(&cm->reg_lock);
1395 1415
1396 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream); 1416 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream);
@@ -1402,6 +1422,7 @@ static int snd_cmipci_capture_spdif_hw_free(struct snd_pcm_substream *subs)
1402 1422
1403 spin_lock_irq(&cm->reg_lock); 1423 spin_lock_irq(&cm->reg_lock);
1404 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); 1424 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF);
1425 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL);
1405 spin_unlock_irq(&cm->reg_lock); 1426 spin_unlock_irq(&cm->reg_lock);
1406 1427
1407 return snd_cmipci_hw_free(subs); 1428 return snd_cmipci_hw_free(subs);
@@ -1553,7 +1574,8 @@ static struct snd_pcm_hardware snd_cmipci_capture_spdif =
1553 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1574 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1554 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | 1575 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE |
1555 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), 1576 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
1556 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1577 .formats = SNDRV_PCM_FMTBIT_S16_LE |
1578 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE,
1557 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, 1579 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000,
1558 .rate_min = 44100, 1580 .rate_min = 44100,
1559 .rate_max = 48000, 1581 .rate_max = 48000,
@@ -1567,6 +1589,14 @@ static struct snd_pcm_hardware snd_cmipci_capture_spdif =
1567 .fifo_size = 0, 1589 .fifo_size = 0,
1568}; 1590};
1569 1591
1592static unsigned int rate_constraints[] = { 5512, 8000, 11025, 16000, 22050,
1593 32000, 44100, 48000, 88200, 96000, 128000 };
1594static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
1595 .count = ARRAY_SIZE(rate_constraints),
1596 .list = rate_constraints,
1597 .mask = 0,
1598};
1599
1570/* 1600/*
1571 * check device open/close 1601 * check device open/close
1572 */ 1602 */
@@ -1636,6 +1666,13 @@ static int snd_cmipci_playback_open(struct snd_pcm_substream *substream)
1636 runtime->hw.rates |= SNDRV_PCM_RATE_88200 | 1666 runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
1637 SNDRV_PCM_RATE_96000; 1667 SNDRV_PCM_RATE_96000;
1638 runtime->hw.rate_max = 96000; 1668 runtime->hw.rate_max = 96000;
1669 } else if (cm->chip_version == 55) {
1670 err = snd_pcm_hw_constraint_list(runtime, 0,
1671 SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
1672 if (err < 0)
1673 return err;
1674 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
1675 runtime->hw.rate_max = 128000;
1639 } 1676 }
1640 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000); 1677 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
1641 cm->dig_pcm_status = cm->dig_status; 1678 cm->dig_pcm_status = cm->dig_status;
@@ -1654,6 +1691,13 @@ static int snd_cmipci_capture_open(struct snd_pcm_substream *substream)
1654 if (cm->chip_version == 68) { // 8768 only supports 44k/48k recording 1691 if (cm->chip_version == 68) { // 8768 only supports 44k/48k recording
1655 runtime->hw.rate_min = 41000; 1692 runtime->hw.rate_min = 41000;
1656 runtime->hw.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 1693 runtime->hw.rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
1694 } else if (cm->chip_version == 55) {
1695 err = snd_pcm_hw_constraint_list(runtime, 0,
1696 SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
1697 if (err < 0)
1698 return err;
1699 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
1700 runtime->hw.rate_max = 128000;
1657 } 1701 }
1658 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000); 1702 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
1659 return 0; 1703 return 0;
@@ -1685,6 +1729,13 @@ static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream)
1685 runtime->hw.rates |= SNDRV_PCM_RATE_88200 | 1729 runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
1686 SNDRV_PCM_RATE_96000; 1730 SNDRV_PCM_RATE_96000;
1687 runtime->hw.rate_max = 96000; 1731 runtime->hw.rate_max = 96000;
1732 } else if (cm->chip_version == 55) {
1733 err = snd_pcm_hw_constraint_list(runtime, 0,
1734 SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates);
1735 if (err < 0)
1736 return err;
1737 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
1738 runtime->hw.rate_max = 128000;
1688 } 1739 }
1689 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000); 1740 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x10000);
1690 return 0; 1741 return 0;
@@ -1704,7 +1755,7 @@ static int snd_cmipci_playback_spdif_open(struct snd_pcm_substream *substream)
1704 runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE; 1755 runtime->hw.formats |= SNDRV_PCM_FMTBIT_S32_LE;
1705 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 1756 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
1706 } 1757 }
1707 if (cm->chip_version == 68) { 1758 if (cm->can_96k) {
1708 runtime->hw.rates |= SNDRV_PCM_RATE_88200 | 1759 runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
1709 SNDRV_PCM_RATE_96000; 1760 SNDRV_PCM_RATE_96000;
1710 runtime->hw.rate_max = 96000; 1761 runtime->hw.rate_max = 96000;
@@ -1726,6 +1777,11 @@ static int snd_cmipci_capture_spdif_open(struct snd_pcm_substream *substream)
1726 if ((err = open_device_check(cm, CM_OPEN_SPDIF_CAPTURE, substream)) < 0) /* use channel B */ 1777 if ((err = open_device_check(cm, CM_OPEN_SPDIF_CAPTURE, substream)) < 0) /* use channel B */
1727 return err; 1778 return err;
1728 runtime->hw = snd_cmipci_capture_spdif; 1779 runtime->hw = snd_cmipci_capture_spdif;
1780 if (cm->can_96k && !(cm->chip_version == 68)) {
1781 runtime->hw.rates |= SNDRV_PCM_RATE_88200 |
1782 SNDRV_PCM_RATE_96000;
1783 runtime->hw.rate_max = 96000;
1784 }
1729 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x40000); 1785 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 0x40000);
1730 return 0; 1786 return 0;
1731} 1787}
@@ -2594,10 +2650,8 @@ static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] __devinitdata =
2594}; 2650};
2595 2651
2596/* card control switches */ 2652/* card control switches */
2597static struct snd_kcontrol_new snd_cmipci_control_switches[] __devinitdata = { 2653static struct snd_kcontrol_new snd_cmipci_modem_switch __devinitdata =
2598 // DEFINE_CARD_SWITCH("Joystick", joystick), /* now module option */ 2654DEFINE_CARD_SWITCH("Modem", modem);
2599 DEFINE_CARD_SWITCH("Modem", modem),
2600};
2601 2655
2602 2656
2603static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) 2657static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device)
@@ -2678,9 +2732,13 @@ static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_devic
2678 } 2732 }
2679 2733
2680 /* card switches */ 2734 /* card switches */
2681 sw = snd_cmipci_control_switches; 2735 /*
2682 for (idx = 0; idx < ARRAY_SIZE(snd_cmipci_control_switches); idx++, sw++) { 2736 * newer chips don't have the register bits to force modem link
2683 err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm)); 2737 * detection; the bit that was FLINKON now mutes CH1
2738 */
2739 if (cm->chip_version < 39) {
2740 err = snd_ctl_add(cm->card,
2741 snd_ctl_new1(&snd_cmipci_modem_switch, cm));
2684 if (err < 0) 2742 if (err < 0)
2685 return err; 2743 return err;
2686 } 2744 }
@@ -2785,9 +2843,11 @@ static void __devinit query_chip(struct cmipci *cm)
2785 } else if (detect & CM_CHIP_8768) { 2843 } else if (detect & CM_CHIP_8768) {
2786 cm->chip_version = 68; 2844 cm->chip_version = 68;
2787 cm->max_channels = 8; 2845 cm->max_channels = 8;
2846 cm->can_96k = 1;
2788 } else { 2847 } else {
2789 cm->chip_version = 55; 2848 cm->chip_version = 55;
2790 cm->max_channels = 6; 2849 cm->max_channels = 6;
2850 cm->can_96k = 1;
2791 } 2851 }
2792 cm->can_ac3_hw = 1; 2852 cm->can_ac3_hw = 1;
2793 cm->can_multi_ch = 1; 2853 cm->can_multi_ch = 1;