diff options
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/cs4270.c | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 8beae65d083c..43d50a4d8089 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
@@ -56,35 +56,6 @@ static unsigned int mclk_ratios[NUM_MCLK_RATIOS] = | |||
56 | {64, 96, 128, 192, 256, 384, 512, 768, 1024}; | 56 | {64, 96, 128, 192, 256, 384, 512, 768, 1024}; |
57 | 57 | ||
58 | /* | 58 | /* |
59 | * Sampling rate <-> bit patter mapping | ||
60 | * | ||
61 | * This array maps sampling rates to their SNDRV_PCM_RATE_x equivalent. | ||
62 | * | ||
63 | * This is really something that ALSA should provide. | ||
64 | * | ||
65 | * This table is used by cs4270_set_dai_sysclk() to tell ALSA which sampling | ||
66 | * rates the CS4270 currently supports. | ||
67 | */ | ||
68 | static struct { | ||
69 | unsigned int rate; | ||
70 | unsigned int bit; | ||
71 | } rate_map[] = { | ||
72 | {5512, SNDRV_PCM_RATE_5512}, | ||
73 | {8000, SNDRV_PCM_RATE_8000}, | ||
74 | {11025, SNDRV_PCM_RATE_11025}, | ||
75 | {16000, SNDRV_PCM_RATE_16000}, | ||
76 | {22050, SNDRV_PCM_RATE_22050}, | ||
77 | {32000, SNDRV_PCM_RATE_32000}, | ||
78 | {44100, SNDRV_PCM_RATE_44100}, | ||
79 | {48000, SNDRV_PCM_RATE_48000}, | ||
80 | {64000, SNDRV_PCM_RATE_64000}, | ||
81 | {88200, SNDRV_PCM_RATE_88200}, | ||
82 | {96000, SNDRV_PCM_RATE_96000}, | ||
83 | {176400, SNDRV_PCM_RATE_176400}, | ||
84 | {192000, SNDRV_PCM_RATE_192000} | ||
85 | }; | ||
86 | |||
87 | /* | ||
88 | * Determine the CS4270 samples rates. | 59 | * Determine the CS4270 samples rates. |
89 | * | 60 | * |
90 | * 'freq' is the input frequency to MCLK. The other parameters are ignored. | 61 | * 'freq' is the input frequency to MCLK. The other parameters are ignored. |
@@ -126,19 +97,15 @@ static int cs4270_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai, | |||
126 | cs4270->mclk = freq; | 97 | cs4270->mclk = freq; |
127 | 98 | ||
128 | for (i = 0; i < NUM_MCLK_RATIOS; i++) { | 99 | for (i = 0; i < NUM_MCLK_RATIOS; i++) { |
129 | unsigned int rate; | 100 | unsigned int rate = freq / mclk_ratios[i]; |
130 | unsigned int j; | 101 | rates |= snd_pcm_rate_to_rate_bit(rate); |
131 | rate = freq / mclk_ratios[i]; | 102 | if (rate < rate_min) |
132 | for (j = 0; j < ARRAY_SIZE(rate_map); j++) { | 103 | rate_min = rate; |
133 | if (rate == rate_map[j].rate) { | 104 | if (rate > rate_max) |
134 | rates |= rate_map[j].bit; | 105 | rate_max = rate; |
135 | if (rate < rate_min) | ||
136 | rate_min = rate; | ||
137 | if (rate > rate_max) | ||
138 | rate_max = rate; | ||
139 | } | ||
140 | } | ||
141 | } | 106 | } |
107 | /* FIXME: soc should support a rate list */ | ||
108 | rates &= ~SNDRV_PCM_RATE_KNOT; | ||
142 | 109 | ||
143 | if (!rates) { | 110 | if (!rates) { |
144 | printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); | 111 | printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); |