aaci.c (62578cbfaa50df06b3bb6e4231adc3b911a3d4b4) | aaci.c (41762b8ca9e16c7443d8348ec53daddbe940cdcc) |
---|---|
1/* 2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver 3 * 4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. 5 * 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 2 as 8 * published by the Free Software Foundation. --- 152 unchanged lines hidden (view full) --- 161 162 163 164/* 165 * Interrupt support. 166 */ 167static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) 168{ | 1/* 2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver 3 * 4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. 5 * 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 2 as 8 * published by the Free Software Foundation. --- 152 unchanged lines hidden (view full) --- 161 162 163 164/* 165 * Interrupt support. 166 */ 167static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask) 168{ |
169 if (mask & ISR_ORINTR) { 170 dev_warn(&aaci->dev->dev, "RX overrun on chan %d\n", channel); 171 writel(ICLR_RXOEC1 << channel, aaci->base + AACI_INTCLR); 172 } 173 174 if (mask & ISR_RXTOINTR) { 175 dev_warn(&aaci->dev->dev, "RX timeout on chan %d\n", channel); 176 writel(ICLR_RXTOFEC1 << channel, aaci->base + AACI_INTCLR); 177 } 178 179 if (mask & ISR_RXINTR) { 180 struct aaci_runtime *aacirun = &aaci->capture; 181 void *ptr; 182 183 if (!aacirun->substream || !aacirun->start) { 184 dev_warn(&aaci->dev->dev, "RX interrupt???"); 185 writel(0, aacirun->base + AACI_IE); 186 return; 187 } 188 ptr = aacirun->ptr; 189 190 do { 191 unsigned int len = aacirun->fifosz; 192 u32 val; 193 194 if (aacirun->bytes <= 0) { 195 aacirun->bytes += aacirun->period; 196 aacirun->ptr = ptr; 197 spin_unlock(&aaci->lock); 198 snd_pcm_period_elapsed(aacirun->substream); 199 spin_lock(&aaci->lock); 200 } 201 if (!(aacirun->cr & CR_EN)) 202 break; 203 204 val = readl(aacirun->base + AACI_SR); 205 if (!(val & SR_RXHF)) 206 break; 207 if (!(val & SR_RXFF)) 208 len >>= 1; 209 210 aacirun->bytes -= len; 211 212 /* reading 16 bytes at a time */ 213 for( ; len > 0; len -= 16) { 214 asm( 215 "ldmia %1, {r0, r1, r2, r3}\n\t" 216 "stmia %0!, {r0, r1, r2, r3}" 217 : "+r" (ptr) 218 : "r" (aacirun->fifo) 219 : "r0", "r1", "r2", "r3", "cc"); 220 221 if (ptr >= aacirun->end) 222 ptr = aacirun->start; 223 } 224 } while(1); 225 aacirun->ptr = ptr; 226 } 227 |
|
169 if (mask & ISR_URINTR) { 170 dev_dbg(&aaci->dev->dev, "TX underrun on chan %d\n", channel); 171 writel(ICLR_TXUEC1 << channel, aaci->base + AACI_INTCLR); 172 } 173 174 if (mask & ISR_TXINTR) { 175 struct aaci_runtime *aacirun = &aaci->playback; 176 void *ptr; --- 11 unchanged lines hidden (view full) --- 188 189 if (aacirun->bytes <= 0) { 190 aacirun->bytes += aacirun->period; 191 aacirun->ptr = ptr; 192 spin_unlock(&aaci->lock); 193 snd_pcm_period_elapsed(aacirun->substream); 194 spin_lock(&aaci->lock); 195 } | 228 if (mask & ISR_URINTR) { 229 dev_dbg(&aaci->dev->dev, "TX underrun on chan %d\n", channel); 230 writel(ICLR_TXUEC1 << channel, aaci->base + AACI_INTCLR); 231 } 232 233 if (mask & ISR_TXINTR) { 234 struct aaci_runtime *aacirun = &aaci->playback; 235 void *ptr; --- 11 unchanged lines hidden (view full) --- 247 248 if (aacirun->bytes <= 0) { 249 aacirun->bytes += aacirun->period; 250 aacirun->ptr = ptr; 251 spin_unlock(&aaci->lock); 252 snd_pcm_period_elapsed(aacirun->substream); 253 spin_lock(&aaci->lock); 254 } |
196 if (!(aacirun->cr & TXCR_TXEN)) | 255 if (!(aacirun->cr & CR_EN)) |
197 break; 198 199 val = readl(aacirun->base + AACI_SR); 200 if (!(val & SR_TXHE)) 201 break; 202 if (!(val & SR_TXFE)) 203 len >>= 1; 204 --- 121 unchanged lines hidden (view full) --- 326 .channels_max = 6, 327 .buffer_bytes_max = 64 * 1024, 328 .period_bytes_min = 256, 329 .period_bytes_max = PAGE_SIZE, 330 .periods_min = 4, 331 .periods_max = PAGE_SIZE / 16, 332}; 333 | 256 break; 257 258 val = readl(aacirun->base + AACI_SR); 259 if (!(val & SR_TXHE)) 260 break; 261 if (!(val & SR_TXFE)) 262 len >>= 1; 263 --- 121 unchanged lines hidden (view full) --- 385 .channels_max = 6, 386 .buffer_bytes_max = 64 * 1024, 387 .period_bytes_min = 256, 388 .period_bytes_max = PAGE_SIZE, 389 .periods_min = 4, 390 .periods_max = PAGE_SIZE / 16, 391}; 392 |
334static int aaci_pcm_open(struct aaci *aaci, struct snd_pcm_substream *substream, 335 struct aaci_runtime *aacirun) | 393static int __aaci_pcm_open(struct aaci *aaci, 394 struct snd_pcm_substream *substream, 395 struct aaci_runtime *aacirun) |
336{ 337 struct snd_pcm_runtime *runtime = substream->runtime; 338 int ret; 339 340 aacirun->substream = substream; 341 runtime->private_data = aacirun; 342 runtime->hw = aaci_hw_info; 343 --- 32 unchanged lines hidden (view full) --- 376/* 377 * Common ALSA stuff 378 */ 379static int aaci_pcm_close(struct snd_pcm_substream *substream) 380{ 381 struct aaci *aaci = substream->private_data; 382 struct aaci_runtime *aacirun = substream->runtime->private_data; 383 | 396{ 397 struct snd_pcm_runtime *runtime = substream->runtime; 398 int ret; 399 400 aacirun->substream = substream; 401 runtime->private_data = aacirun; 402 runtime->hw = aaci_hw_info; 403 --- 32 unchanged lines hidden (view full) --- 436/* 437 * Common ALSA stuff 438 */ 439static int aaci_pcm_close(struct snd_pcm_substream *substream) 440{ 441 struct aaci *aaci = substream->private_data; 442 struct aaci_runtime *aacirun = substream->runtime->private_data; 443 |
384 WARN_ON(aacirun->cr & TXCR_TXEN); | 444 WARN_ON(aacirun->cr & CR_EN); |
385 386 aacirun->substream = NULL; 387 free_irq(aaci->dev->irq[0], aaci); 388 389 return 0; 390} 391 392static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) 393{ 394 struct aaci_runtime *aacirun = substream->runtime->private_data; 395 396 /* 397 * This must not be called with the device enabled. 398 */ | 445 446 aacirun->substream = NULL; 447 free_irq(aaci->dev->irq[0], aaci); 448 449 return 0; 450} 451 452static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) 453{ 454 struct aaci_runtime *aacirun = substream->runtime->private_data; 455 456 /* 457 * This must not be called with the device enabled. 458 */ |
399 WARN_ON(aacirun->cr & TXCR_TXEN); | 459 WARN_ON(aacirun->cr & CR_EN); |
400 401 if (aacirun->pcm_open) 402 snd_ac97_pcm_close(aacirun->pcm); 403 aacirun->pcm_open = 0; 404 405 /* 406 * Clear out the DMA and any allocated buffers. 407 */ --- 10 unchanged lines hidden (view full) --- 418 419 aaci_pcm_hw_free(substream); 420 421 err = devdma_hw_alloc(NULL, substream, 422 params_buffer_bytes(params)); 423 if (err < 0) 424 goto out; 425 | 460 461 if (aacirun->pcm_open) 462 snd_ac97_pcm_close(aacirun->pcm); 463 aacirun->pcm_open = 0; 464 465 /* 466 * Clear out the DMA and any allocated buffers. 467 */ --- 10 unchanged lines hidden (view full) --- 478 479 aaci_pcm_hw_free(substream); 480 481 err = devdma_hw_alloc(NULL, substream, 482 params_buffer_bytes(params)); 483 if (err < 0) 484 goto out; 485 |
426 err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), 427 params_channels(params), 428 aacirun->pcm->r[0].slots); | 486 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 487 err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), 488 params_channels(params), 489 aacirun->pcm->r[0].slots); 490 else 491 err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params), 492 params_channels(params), 493 aacirun->pcm->r[1].slots); 494 |
429 if (err) 430 goto out; 431 432 aacirun->pcm_open = 1; 433 434 out: 435 return err; 436} --- 26 unchanged lines hidden (view full) --- 463 return devdma_mmap(NULL, substream, vma); 464} 465 466 467/* 468 * Playback specific ALSA stuff 469 */ 470static const u32 channels_to_txmask[] = { | 495 if (err) 496 goto out; 497 498 aacirun->pcm_open = 1; 499 500 out: 501 return err; 502} --- 26 unchanged lines hidden (view full) --- 529 return devdma_mmap(NULL, substream, vma); 530} 531 532 533/* 534 * Playback specific ALSA stuff 535 */ 536static const u32 channels_to_txmask[] = { |
471 [2] = TXCR_TX3 | TXCR_TX4, 472 [4] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8, 473 [6] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8 | TXCR_TX6 | TXCR_TX9, | 537 [2] = CR_SL3 | CR_SL4, 538 [4] = CR_SL3 | CR_SL4 | CR_SL7 | CR_SL8, 539 [6] = CR_SL3 | CR_SL4 | CR_SL7 | CR_SL8 | CR_SL6 | CR_SL9, |
474}; 475 476/* 477 * We can support two and four channel audio. Unfortunately 478 * six channel audio requires a non-standard channel ordering: 479 * 2 -> FL(3), FR(4) 480 * 4 -> FL(3), FR(4), SL(7), SR(8) 481 * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required) --- 18 unchanged lines hidden (view full) --- 500 chan_mask |= 1 << 2; 501 } 502 503 return snd_interval_list(hw_param_interval(p, rule->var), 504 ARRAY_SIZE(channel_list), channel_list, 505 chan_mask); 506} 507 | 540}; 541 542/* 543 * We can support two and four channel audio. Unfortunately 544 * six channel audio requires a non-standard channel ordering: 545 * 2 -> FL(3), FR(4) 546 * 4 -> FL(3), FR(4), SL(7), SR(8) 547 * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required) --- 18 unchanged lines hidden (view full) --- 566 chan_mask |= 1 << 2; 567 } 568 569 return snd_interval_list(hw_param_interval(p, rule->var), 570 ARRAY_SIZE(channel_list), channel_list, 571 chan_mask); 572} 573 |
508static int aaci_pcm_playback_open(struct snd_pcm_substream *substream) | 574static int aaci_pcm_open(struct snd_pcm_substream *substream) |
509{ 510 struct aaci *aaci = substream->private_data; 511 int ret; 512 513 /* 514 * Add rule describing channel dependency. 515 */ 516 ret = snd_pcm_hw_rule_add(substream->runtime, 0, 517 SNDRV_PCM_HW_PARAM_CHANNELS, 518 aaci_rule_channels, aaci, 519 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 520 if (ret) 521 return ret; 522 | 575{ 576 struct aaci *aaci = substream->private_data; 577 int ret; 578 579 /* 580 * Add rule describing channel dependency. 581 */ 582 ret = snd_pcm_hw_rule_add(substream->runtime, 0, 583 SNDRV_PCM_HW_PARAM_CHANNELS, 584 aaci_rule_channels, aaci, 585 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 586 if (ret) 587 return ret; 588 |
523 return aaci_pcm_open(aaci, substream, &aaci->playback); | 589 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 590 ret = __aaci_pcm_open(aaci, substream, &aaci->playback); 591 } else { 592 ret = __aaci_pcm_open(aaci, substream, &aaci->capture); 593 } 594 return ret; |
524} 525 526static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream, 527 struct snd_pcm_hw_params *params) 528{ 529 struct aaci *aaci = substream->private_data; 530 struct aaci_runtime *aacirun = substream->runtime->private_data; 531 unsigned int channels = params_channels(params); --- 4 unchanged lines hidden (view full) --- 536 537 ret = aaci_pcm_hw_params(substream, aacirun, params); 538 539 /* 540 * Enable FIFO, compact mode, 16 bits per sample. 541 * FIXME: double rate slots? 542 */ 543 if (ret >= 0) { | 595} 596 597static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream, 598 struct snd_pcm_hw_params *params) 599{ 600 struct aaci *aaci = substream->private_data; 601 struct aaci_runtime *aacirun = substream->runtime->private_data; 602 unsigned int channels = params_channels(params); --- 4 unchanged lines hidden (view full) --- 607 608 ret = aaci_pcm_hw_params(substream, aacirun, params); 609 610 /* 611 * Enable FIFO, compact mode, 16 bits per sample. 612 * FIXME: double rate slots? 613 */ 614 if (ret >= 0) { |
544 aacirun->cr = TXCR_FEN | TXCR_COMPACT | TXCR_TSZ16; | 615 aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; |
545 aacirun->cr |= channels_to_txmask[channels]; 546 547 aacirun->fifosz = aaci->fifosize * 4; | 616 aacirun->cr |= channels_to_txmask[channels]; 617 618 aacirun->fifosz = aaci->fifosize * 4; |
548 if (aacirun->cr & TXCR_COMPACT) | 619 if (aacirun->cr & CR_COMPACT) |
549 aacirun->fifosz >>= 1; 550 } 551 return ret; 552} 553 554static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun) 555{ 556 u32 ie; 557 558 ie = readl(aacirun->base + AACI_IE); 559 ie &= ~(IE_URIE|IE_TXIE); 560 writel(ie, aacirun->base + AACI_IE); | 620 aacirun->fifosz >>= 1; 621 } 622 return ret; 623} 624 625static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun) 626{ 627 u32 ie; 628 629 ie = readl(aacirun->base + AACI_IE); 630 ie &= ~(IE_URIE|IE_TXIE); 631 writel(ie, aacirun->base + AACI_IE); |
561 aacirun->cr &= ~TXCR_TXEN; | 632 aacirun->cr &= ~CR_EN; |
562 aaci_chan_wait_ready(aacirun); 563 writel(aacirun->cr, aacirun->base + AACI_TXCR); 564} 565 566static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) 567{ 568 u32 ie; 569 570 aaci_chan_wait_ready(aacirun); | 633 aaci_chan_wait_ready(aacirun); 634 writel(aacirun->cr, aacirun->base + AACI_TXCR); 635} 636 637static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) 638{ 639 u32 ie; 640 641 aaci_chan_wait_ready(aacirun); |
571 aacirun->cr |= TXCR_TXEN; | 642 aacirun->cr |= CR_EN; |
572 573 ie = readl(aacirun->base + AACI_IE); 574 ie |= IE_URIE | IE_TXIE; 575 writel(ie, aacirun->base + AACI_IE); 576 writel(aacirun->cr, aacirun->base + AACI_TXCR); 577} 578 579static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) --- 31 unchanged lines hidden (view full) --- 611 ret = -EINVAL; 612 } 613 spin_unlock_irqrestore(&aaci->lock, flags); 614 615 return ret; 616} 617 618static struct snd_pcm_ops aaci_playback_ops = { | 643 644 ie = readl(aacirun->base + AACI_IE); 645 ie |= IE_URIE | IE_TXIE; 646 writel(ie, aacirun->base + AACI_IE); 647 writel(aacirun->cr, aacirun->base + AACI_TXCR); 648} 649 650static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) --- 31 unchanged lines hidden (view full) --- 682 ret = -EINVAL; 683 } 684 spin_unlock_irqrestore(&aaci->lock, flags); 685 686 return ret; 687} 688 689static struct snd_pcm_ops aaci_playback_ops = { |
619 .open = aaci_pcm_playback_open, | 690 .open = aaci_pcm_open, |
620 .close = aaci_pcm_close, 621 .ioctl = snd_pcm_lib_ioctl, 622 .hw_params = aaci_pcm_playback_hw_params, 623 .hw_free = aaci_pcm_hw_free, 624 .prepare = aaci_pcm_prepare, 625 .trigger = aaci_pcm_playback_trigger, 626 .pointer = aaci_pcm_pointer, 627 .mmap = aaci_pcm_mmap, 628}; 629 | 691 .close = aaci_pcm_close, 692 .ioctl = snd_pcm_lib_ioctl, 693 .hw_params = aaci_pcm_playback_hw_params, 694 .hw_free = aaci_pcm_hw_free, 695 .prepare = aaci_pcm_prepare, 696 .trigger = aaci_pcm_playback_trigger, 697 .pointer = aaci_pcm_pointer, 698 .mmap = aaci_pcm_mmap, 699}; 700 |
701static int aaci_pcm_capture_hw_params(snd_pcm_substream_t *substream, 702 snd_pcm_hw_params_t *params) 703{ 704 struct aaci *aaci = substream->private_data; 705 struct aaci_runtime *aacirun = substream->runtime->private_data; 706 int ret; |
|
630 | 707 |
708 ret = aaci_pcm_hw_params(substream, aacirun, params); |
|
631 | 709 |
710 if (ret >= 0) { 711 aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; 712 713 /* Line in record: slot 3 and 4 */ 714 aacirun->cr |= CR_SL3 | CR_SL4; 715 716 aacirun->fifosz = aaci->fifosize * 4; 717 718 if (aacirun->cr & CR_COMPACT) 719 aacirun->fifosz >>= 1; 720 } 721 return ret; 722} 723 724static void aaci_pcm_capture_stop(struct aaci_runtime *aacirun) 725{ 726 u32 ie; 727 728 aaci_chan_wait_ready(aacirun); 729 730 ie = readl(aacirun->base + AACI_IE); 731 ie &= ~(IE_ORIE | IE_RXIE); 732 writel(ie, aacirun->base+AACI_IE); 733 734 aacirun->cr &= ~CR_EN; 735 736 writel(aacirun->cr, aacirun->base + AACI_RXCR); 737} 738 739static void aaci_pcm_capture_start(struct aaci_runtime *aacirun) 740{ 741 u32 ie; 742 743 aaci_chan_wait_ready(aacirun); 744 745#ifdef DEBUG 746 /* RX Timeout value: bits 28:17 in RXCR */ 747 aacirun->cr |= 0xf << 17; 748#endif 749 750 aacirun->cr |= CR_EN; 751 writel(aacirun->cr, aacirun->base + AACI_RXCR); 752 753 ie = readl(aacirun->base + AACI_IE); 754 ie |= IE_ORIE |IE_RXIE; // overrun and rx interrupt -- half full 755 writel(ie, aacirun->base + AACI_IE); 756} 757 758static int aaci_pcm_capture_trigger(snd_pcm_substream_t *substream, int cmd){ 759 760 struct aaci *aaci = substream->private_data; 761 struct aaci_runtime *aacirun = substream->runtime->private_data; 762 unsigned long flags; 763 int ret = 0; 764 765 spin_lock_irqsave(&aaci->lock, flags); 766 767 switch (cmd) { 768 case SNDRV_PCM_TRIGGER_START: 769 aaci_pcm_capture_start(aacirun); 770 break; 771 772 case SNDRV_PCM_TRIGGER_RESUME: 773 aaci_pcm_capture_start(aacirun); 774 break; 775 776 case SNDRV_PCM_TRIGGER_STOP: 777 aaci_pcm_capture_stop(aacirun); 778 break; 779 780 case SNDRV_PCM_TRIGGER_SUSPEND: 781 aaci_pcm_capture_stop(aacirun); 782 break; 783 784 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 785 break; 786 787 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 788 break; 789 790 default: 791 ret = -EINVAL; 792 } 793 794 spin_unlock_irqrestore(&aaci->lock, flags); 795 796 return ret; 797} 798 799static int aaci_pcm_capture_prepare(snd_pcm_substream_t *substream) 800{ 801 struct snd_pcm_runtime *runtime = substream->runtime; 802 struct aaci *aaci = substream->private_data; 803 804 aaci_pcm_prepare(substream); 805 806 /* allow changing of sample rate */ 807 aaci_ac97_write(aaci->ac97, AC97_EXTENDED_STATUS, 0x0001); /* VRA */ 808 aaci_ac97_write(aaci->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); 809 aaci_ac97_write(aaci->ac97, AC97_PCM_MIC_ADC_RATE, runtime->rate); 810 811 /* Record select: Mic: 0, Aux: 3, Line: 4 */ 812 aaci_ac97_write(aaci->ac97, AC97_REC_SEL, 0x0404); 813 814 return 0; 815} 816 817static snd_pcm_ops_t aaci_capture_ops = { 818 .open = aaci_pcm_open, 819 .close = aaci_pcm_close, 820 .ioctl = snd_pcm_lib_ioctl, 821 .hw_params = aaci_pcm_capture_hw_params, 822 .hw_free = aaci_pcm_hw_free, 823 .prepare = aaci_pcm_capture_prepare, 824 .trigger = aaci_pcm_capture_trigger, 825 .pointer = aaci_pcm_pointer, 826 .mmap = aaci_pcm_mmap, 827}; 828 |
|
632/* 633 * Power Management. 634 */ 635#ifdef CONFIG_PM 636static int aaci_do_suspend(struct snd_card *card, unsigned int state) 637{ 638 struct aaci *aaci = card->private_data; 639 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); --- 22 unchanged lines hidden (view full) --- 662#define aaci_do_suspend NULL 663#define aaci_do_resume NULL 664#define aaci_suspend NULL 665#define aaci_resume NULL 666#endif 667 668 669static struct ac97_pcm ac97_defs[] __devinitdata = { | 829/* 830 * Power Management. 831 */ 832#ifdef CONFIG_PM 833static int aaci_do_suspend(struct snd_card *card, unsigned int state) 834{ 835 struct aaci *aaci = card->private_data; 836 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); --- 22 unchanged lines hidden (view full) --- 859#define aaci_do_suspend NULL 860#define aaci_do_resume NULL 861#define aaci_suspend NULL 862#define aaci_resume NULL 863#endif 864 865 866static struct ac97_pcm ac97_defs[] __devinitdata = { |
670 [0] = { /* Front PCM */ | 867 [0] = { /* Front PCM */ |
671 .exclusive = 1, 672 .r = { 673 [0] = { 674 .slots = (1 << AC97_SLOT_PCM_LEFT) | 675 (1 << AC97_SLOT_PCM_RIGHT) | 676 (1 << AC97_SLOT_PCM_CENTER) | 677 (1 << AC97_SLOT_PCM_SLEFT) | 678 (1 << AC97_SLOT_PCM_SRIGHT) | --- 57 unchanged lines hidden (view full) --- 736 memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); 737 ac97_template.private_data = aaci; 738 ac97_template.num = 0; 739 ac97_template.scaps = AC97_SCAP_SKIP_MODEM; 740 741 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97); 742 if (ret) 743 goto out; | 868 .exclusive = 1, 869 .r = { 870 [0] = { 871 .slots = (1 << AC97_SLOT_PCM_LEFT) | 872 (1 << AC97_SLOT_PCM_RIGHT) | 873 (1 << AC97_SLOT_PCM_CENTER) | 874 (1 << AC97_SLOT_PCM_SLEFT) | 875 (1 << AC97_SLOT_PCM_SRIGHT) | --- 57 unchanged lines hidden (view full) --- 933 memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); 934 ac97_template.private_data = aaci; 935 ac97_template.num = 0; 936 ac97_template.scaps = AC97_SCAP_SKIP_MODEM; 937 938 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97); 939 if (ret) 940 goto out; |
941 aaci->ac97 = ac97; |
|
744 745 /* 746 * Disable AC97 PC Beep input on audio codecs. 747 */ 748 if (ac97_is_audio(ac97)) 749 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x801e); 750 751 ret = snd_ac97_pcm_assign(ac97_bus, ARRAY_SIZE(ac97_defs), ac97_defs); 752 if (ret) 753 goto out; 754 755 aaci->playback.pcm = &ac97_bus->pcms[0]; | 942 943 /* 944 * Disable AC97 PC Beep input on audio codecs. 945 */ 946 if (ac97_is_audio(ac97)) 947 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x801e); 948 949 ret = snd_ac97_pcm_assign(ac97_bus, ARRAY_SIZE(ac97_defs), ac97_defs); 950 if (ret) 951 goto out; 952 953 aaci->playback.pcm = &ac97_bus->pcms[0]; |
954 aaci->capture.pcm = &ac97_bus->pcms[1]; |
|
756 757 out: 758 return ret; 759} 760 761static void aaci_free_card(struct snd_card *card) 762{ 763 struct aaci *aaci = card->private_data; --- 33 unchanged lines hidden (view full) --- 797 return aaci; 798} 799 800static int __devinit aaci_init_pcm(struct aaci *aaci) 801{ 802 struct snd_pcm *pcm; 803 int ret; 804 | 955 956 out: 957 return ret; 958} 959 960static void aaci_free_card(struct snd_card *card) 961{ 962 struct aaci *aaci = card->private_data; --- 33 unchanged lines hidden (view full) --- 996 return aaci; 997} 998 999static int __devinit aaci_init_pcm(struct aaci *aaci) 1000{ 1001 struct snd_pcm *pcm; 1002 int ret; 1003 |
805 ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm); | 1004 ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 1, &pcm); |
806 if (ret == 0) { 807 aaci->pcm = pcm; 808 pcm->private_data = aaci; 809 pcm->info_flags = 0; 810 811 strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name)); 812 813 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); | 1005 if (ret == 0) { 1006 aaci->pcm = pcm; 1007 pcm->private_data = aaci; 1008 pcm->info_flags = 0; 1009 1010 strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name)); 1011 1012 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); |
1013 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); |
|
814 } 815 816 return ret; 817} 818 819static unsigned int __devinit aaci_size_fifo(struct aaci *aaci) 820{ | 1014 } 1015 1016 return ret; 1017} 1018 1019static unsigned int __devinit aaci_size_fifo(struct aaci *aaci) 1020{ |
821 void __iomem *base = aaci->base + AACI_CSCH1; | 1021 struct aaci_runtime *aacirun = &aaci->playback; |
822 int i; 823 | 1022 int i; 1023 |
824 writel(TXCR_FEN | TXCR_TSZ16 | TXCR_TXEN, base + AACI_TXCR); | 1024 writel(CR_FEN | CR_SZ16 | CR_EN, aacirun->base + AACI_TXCR); |
825 | 1025 |
826 for (i = 0; !(readl(base + AACI_SR) & SR_TXFF) && i < 4096; i++) 827 writel(0, aaci->base + AACI_DR1); | 1026 for (i = 0; !(readl(aacirun->base + AACI_SR) & SR_TXFF) && i < 4096; i++) 1027 writel(0, aacirun->fifo); |
828 | 1028 |
829 writel(0, base + AACI_TXCR); | 1029 writel(0, aacirun->base + AACI_TXCR); |
830 831 /* 832 * Re-initialise the AACI after the FIFO depth test, to 833 * ensure that the FIFOs are empty. Unfortunately, merely 834 * disabling the channel doesn't clear the FIFO. 835 */ 836 writel(aaci->maincr & ~MAINCR_IE, aaci->base + AACI_MAINCR); 837 writel(aaci->maincr, aaci->base + AACI_MAINCR); --- 30 unchanged lines hidden (view full) --- 868 } 869 870 /* 871 * Playback uses AACI channel 0 872 */ 873 aaci->playback.base = aaci->base + AACI_CSCH1; 874 aaci->playback.fifo = aaci->base + AACI_DR1; 875 | 1030 1031 /* 1032 * Re-initialise the AACI after the FIFO depth test, to 1033 * ensure that the FIFOs are empty. Unfortunately, merely 1034 * disabling the channel doesn't clear the FIFO. 1035 */ 1036 writel(aaci->maincr & ~MAINCR_IE, aaci->base + AACI_MAINCR); 1037 writel(aaci->maincr, aaci->base + AACI_MAINCR); --- 30 unchanged lines hidden (view full) --- 1068 } 1069 1070 /* 1071 * Playback uses AACI channel 0 1072 */ 1073 aaci->playback.base = aaci->base + AACI_CSCH1; 1074 aaci->playback.fifo = aaci->base + AACI_DR1; 1075 |
1076 /* 1077 * Capture uses AACI channel 0 1078 */ 1079 aaci->capture.base = aaci->base + AACI_CSCH1; 1080 aaci->capture.fifo = aaci->base + AACI_DR1; 1081 |
|
876 for (i = 0; i < 4; i++) { 877 void __iomem *base = aaci->base + i * 0x14; 878 879 writel(0, base + AACI_IE); 880 writel(0, base + AACI_TXCR); 881 writel(0, base + AACI_RXCR); 882 } 883 --- 19 unchanged lines hidden (view full) --- 903 if (ret) 904 goto out; 905 906 snd_card_set_dev(aaci->card, &dev->dev); 907 908 ret = snd_card_register(aaci->card); 909 if (ret == 0) { 910 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, | 1082 for (i = 0; i < 4; i++) { 1083 void __iomem *base = aaci->base + i * 0x14; 1084 1085 writel(0, base + AACI_IE); 1086 writel(0, base + AACI_TXCR); 1087 writel(0, base + AACI_RXCR); 1088 } 1089 --- 19 unchanged lines hidden (view full) --- 1109 if (ret) 1110 goto out; 1111 1112 snd_card_set_dev(aaci->card, &dev->dev); 1113 1114 ret = snd_card_register(aaci->card); 1115 if (ret == 0) { 1116 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname, |
911 aaci->fifosize); | 1117 aaci->fifosize); |
912 amba_set_drvdata(dev, aaci->card); 913 return ret; 914 } 915 916 out: 917 if (aaci) 918 snd_card_free(aaci->card); 919 amba_release_regions(dev); --- 54 unchanged lines hidden --- | 1118 amba_set_drvdata(dev, aaci->card); 1119 return ret; 1120 } 1121 1122 out: 1123 if (aaci) 1124 snd_card_free(aaci->card); 1125 amba_release_regions(dev); --- 54 unchanged lines hidden --- |