aboutsummaryrefslogtreecommitdiffstats
path: root/sound/arm/aaci.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-01-13 17:25:10 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-01-26 15:24:52 -0500
commit5d350cba486de34eff99d0394d8fb436af54522e (patch)
tree2acda06b2425eb5c2e2dd8b663dd5ce44170f273 /sound/arm/aaci.c
parentea51d0b164040ad594c1f9c4c6faf23c19c977b9 (diff)
ALSA: AACI: make fifo variables more explanitory
Improve commenting and change fifo variable names to reflect their meanings. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'sound/arm/aaci.c')
-rw-r--r--sound/arm/aaci.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 393ce08b0e11..a148e275c80f 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -219,7 +219,7 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
219 219
220 ptr = aacirun->ptr; 220 ptr = aacirun->ptr;
221 do { 221 do {
222 unsigned int len = aacirun->fifosz; 222 unsigned int len = aacirun->fifo_bytes;
223 u32 val; 223 u32 val;
224 224
225 if (aacirun->bytes <= 0) { 225 if (aacirun->bytes <= 0) {
@@ -279,7 +279,7 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
279 279
280 ptr = aacirun->ptr; 280 ptr = aacirun->ptr;
281 do { 281 do {
282 unsigned int len = aacirun->fifosz; 282 unsigned int len = aacirun->fifo_bytes;
283 u32 val; 283 u32 val;
284 284
285 if (aacirun->bytes <= 0) { 285 if (aacirun->bytes <= 0) {
@@ -430,13 +430,11 @@ static int aaci_pcm_open(struct snd_pcm_substream *substream)
430 } 430 }
431 431
432 /* 432 /*
433 * FIXME: ALSA specifies fifo_size in bytes. If we're in normal 433 * ALSA wants the byte-size of the FIFOs. As we only support
434 * mode, each 32-bit word contains one sample. If we're in 434 * 16-bit samples, this is twice the FIFO depth irrespective
435 * compact mode, each 32-bit word contains two samples, effectively 435 * of whether it's in compact mode or not.
436 * halving the FIFO size. However, we don't know for sure which
437 * we'll be using at this point. We set this to the lower limit.
438 */ 436 */
439 runtime->hw.fifo_size = aaci->fifosize * 2; 437 runtime->hw.fifo_size = aaci->fifo_depth * 2;
440 438
441 mutex_lock(&aaci->irq_lock); 439 mutex_lock(&aaci->irq_lock);
442 if (!aaci->users++) { 440 if (!aaci->users++) {
@@ -529,10 +527,13 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
529 aacirun->pcm_open = err == 0; 527 aacirun->pcm_open = err == 0;
530 aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; 528 aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
531 aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; 529 aacirun->cr |= channels_to_slotmask[channels + dbl * 2];
532 aacirun->fifosz = aaci->fifosize * 4;
533 530
534 if (aacirun->cr & CR_COMPACT) 531 /*
535 aacirun->fifosz >>= 1; 532 * fifo_bytes is the number of bytes we transfer to/from
533 * the FIFO, including padding. So that's x4. As we're
534 * in compact mode, the FIFO is half the size.
535 */
536 aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2;
536 } 537 }
537 538
538 return err; 539 return err;
@@ -948,6 +949,10 @@ static unsigned int __devinit aaci_size_fifo(struct aaci *aaci)
948 struct aaci_runtime *aacirun = &aaci->playback; 949 struct aaci_runtime *aacirun = &aaci->playback;
949 int i; 950 int i;
950 951
952 /*
953 * Enable the channel, but don't assign it to any slots, so
954 * it won't empty onto the AC'97 link.
955 */
951 writel(CR_FEN | CR_SZ16 | CR_EN, aacirun->base + AACI_TXCR); 956 writel(CR_FEN | CR_SZ16 | CR_EN, aacirun->base + AACI_TXCR);
952 957
953 for (i = 0; !(readl(aacirun->base + AACI_SR) & SR_TXFF) && i < 4096; i++) 958 for (i = 0; !(readl(aacirun->base + AACI_SR) & SR_TXFF) && i < 4096; i++)
@@ -964,7 +969,7 @@ static unsigned int __devinit aaci_size_fifo(struct aaci *aaci)
964 writel(aaci->maincr, aaci->base + AACI_MAINCR); 969 writel(aaci->maincr, aaci->base + AACI_MAINCR);
965 970
966 /* 971 /*
967 * If we hit 4096, we failed. Go back to the specified 972 * If we hit 4096 entries, we failed. Go back to the specified
968 * fifo depth. 973 * fifo depth.
969 */ 974 */
970 if (i == 4096) 975 if (i == 4096)
@@ -1029,11 +1034,12 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id)
1029 1034
1030 /* 1035 /*
1031 * Size the FIFOs (must be multiple of 16). 1036 * Size the FIFOs (must be multiple of 16).
1037 * This is the number of entries in the FIFO.
1032 */ 1038 */
1033 aaci->fifosize = aaci_size_fifo(aaci); 1039 aaci->fifo_depth = aaci_size_fifo(aaci);
1034 if (aaci->fifosize & 15) { 1040 if (aaci->fifo_depth & 15) {
1035 printk(KERN_WARNING "AACI: fifosize = %d not supported\n", 1041 printk(KERN_WARNING "AACI: FIFO depth %d not supported\n",
1036 aaci->fifosize); 1042 aaci->fifo_depth);
1037 ret = -ENODEV; 1043 ret = -ENODEV;
1038 goto out; 1044 goto out;
1039 } 1045 }
@@ -1046,8 +1052,8 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id)
1046 1052
1047 ret = snd_card_register(aaci->card); 1053 ret = snd_card_register(aaci->card);
1048 if (ret == 0) { 1054 if (ret == 0) {
1049 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, 1055 dev_info(&dev->dev, "%s\n", aaci->card->longname);
1050 aaci->fifosize); 1056 dev_info(&dev->dev, "FIFO %u entries\n", aaci->fifo_depth);
1051 amba_set_drvdata(dev, aaci->card); 1057 amba_set_drvdata(dev, aaci->card);
1052 return ret; 1058 return ret;
1053 } 1059 }