| .. | .. |
|---|
| 207 | 207 | static struct cygnus_aio_port *cygnus_dai_get_dma_data( |
|---|
| 208 | 208 | struct snd_pcm_substream *substream) |
|---|
| 209 | 209 | { |
|---|
| 210 | | - struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; |
|---|
| 210 | + struct snd_soc_pcm_runtime *soc_runtime = asoc_substream_to_rtd(substream); |
|---|
| 211 | 211 | |
|---|
| 212 | | - return snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream); |
|---|
| 212 | + return snd_soc_dai_get_dma_data(asoc_rtd_to_cpu(soc_runtime, 0), substream); |
|---|
| 213 | 213 | } |
|---|
| 214 | 214 | |
|---|
| 215 | 215 | static void ringbuf_set_initial(void __iomem *audio_io, |
|---|
| .. | .. |
|---|
| 353 | 353 | |
|---|
| 354 | 354 | static void disable_intr(struct snd_pcm_substream *substream) |
|---|
| 355 | 355 | { |
|---|
| 356 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 356 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 357 | 357 | struct cygnus_aio_port *aio; |
|---|
| 358 | 358 | u32 set_mask; |
|---|
| 359 | 359 | |
|---|
| 360 | 360 | aio = cygnus_dai_get_dma_data(substream); |
|---|
| 361 | 361 | |
|---|
| 362 | | - dev_dbg(rtd->cpu_dai->dev, "%s on port %d\n", __func__, aio->portnum); |
|---|
| 362 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s on port %d\n", __func__, aio->portnum); |
|---|
| 363 | 363 | |
|---|
| 364 | 364 | /* The port number maps to the bit position to be set */ |
|---|
| 365 | 365 | set_mask = BIT(aio->portnum); |
|---|
| .. | .. |
|---|
| 376 | 376 | |
|---|
| 377 | 377 | } |
|---|
| 378 | 378 | |
|---|
| 379 | | -static int cygnus_pcm_trigger(struct snd_pcm_substream *substream, int cmd) |
|---|
| 379 | +static int cygnus_pcm_trigger(struct snd_soc_component *component, |
|---|
| 380 | + struct snd_pcm_substream *substream, int cmd) |
|---|
| 380 | 381 | { |
|---|
| 381 | 382 | int ret = 0; |
|---|
| 382 | 383 | |
|---|
| .. | .. |
|---|
| 577 | 578 | return IRQ_HANDLED; |
|---|
| 578 | 579 | } |
|---|
| 579 | 580 | |
|---|
| 580 | | -static int cygnus_pcm_open(struct snd_pcm_substream *substream) |
|---|
| 581 | +static int cygnus_pcm_open(struct snd_soc_component *component, |
|---|
| 582 | + struct snd_pcm_substream *substream) |
|---|
| 581 | 583 | { |
|---|
| 582 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 584 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 583 | 585 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 584 | 586 | struct cygnus_aio_port *aio; |
|---|
| 585 | 587 | int ret; |
|---|
| .. | .. |
|---|
| 588 | 590 | if (!aio) |
|---|
| 589 | 591 | return -ENODEV; |
|---|
| 590 | 592 | |
|---|
| 591 | | - dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 593 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 592 | 594 | |
|---|
| 593 | 595 | snd_soc_set_runtime_hwparams(substream, &cygnus_pcm_hw); |
|---|
| 594 | 596 | |
|---|
| .. | .. |
|---|
| 613 | 615 | return 0; |
|---|
| 614 | 616 | } |
|---|
| 615 | 617 | |
|---|
| 616 | | -static int cygnus_pcm_close(struct snd_pcm_substream *substream) |
|---|
| 618 | +static int cygnus_pcm_close(struct snd_soc_component *component, |
|---|
| 619 | + struct snd_pcm_substream *substream) |
|---|
| 617 | 620 | { |
|---|
| 618 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 621 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 619 | 622 | struct cygnus_aio_port *aio; |
|---|
| 620 | 623 | |
|---|
| 621 | 624 | aio = cygnus_dai_get_dma_data(substream); |
|---|
| 622 | 625 | |
|---|
| 623 | | - dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 626 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 624 | 627 | |
|---|
| 625 | 628 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
|---|
| 626 | 629 | aio->play_stream = NULL; |
|---|
| .. | .. |
|---|
| 628 | 631 | aio->capture_stream = NULL; |
|---|
| 629 | 632 | |
|---|
| 630 | 633 | if (!aio->play_stream && !aio->capture_stream) |
|---|
| 631 | | - dev_dbg(rtd->cpu_dai->dev, "freed port %d\n", aio->portnum); |
|---|
| 634 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "freed port %d\n", aio->portnum); |
|---|
| 632 | 635 | |
|---|
| 633 | 636 | return 0; |
|---|
| 634 | 637 | } |
|---|
| 635 | 638 | |
|---|
| 636 | | -static int cygnus_pcm_hw_params(struct snd_pcm_substream *substream, |
|---|
| 637 | | - struct snd_pcm_hw_params *params) |
|---|
| 639 | +static int cygnus_pcm_hw_params(struct snd_soc_component *component, |
|---|
| 640 | + struct snd_pcm_substream *substream, |
|---|
| 641 | + struct snd_pcm_hw_params *params) |
|---|
| 638 | 642 | { |
|---|
| 639 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 643 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 640 | 644 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 641 | 645 | struct cygnus_aio_port *aio; |
|---|
| 642 | | - int ret = 0; |
|---|
| 643 | 646 | |
|---|
| 644 | 647 | aio = cygnus_dai_get_dma_data(substream); |
|---|
| 645 | | - dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 648 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 646 | 649 | |
|---|
| 647 | 650 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
|---|
| 648 | 651 | runtime->dma_bytes = params_buffer_bytes(params); |
|---|
| 649 | 652 | |
|---|
| 650 | | - return ret; |
|---|
| 653 | + return 0; |
|---|
| 651 | 654 | } |
|---|
| 652 | 655 | |
|---|
| 653 | | -static int cygnus_pcm_hw_free(struct snd_pcm_substream *substream) |
|---|
| 656 | +static int cygnus_pcm_hw_free(struct snd_soc_component *component, |
|---|
| 657 | + struct snd_pcm_substream *substream) |
|---|
| 654 | 658 | { |
|---|
| 655 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 659 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 656 | 660 | struct cygnus_aio_port *aio; |
|---|
| 657 | 661 | |
|---|
| 658 | 662 | aio = cygnus_dai_get_dma_data(substream); |
|---|
| 659 | | - dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 663 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 660 | 664 | |
|---|
| 661 | 665 | snd_pcm_set_runtime_buffer(substream, NULL); |
|---|
| 662 | 666 | return 0; |
|---|
| 663 | 667 | } |
|---|
| 664 | 668 | |
|---|
| 665 | | -static int cygnus_pcm_prepare(struct snd_pcm_substream *substream) |
|---|
| 669 | +static int cygnus_pcm_prepare(struct snd_soc_component *component, |
|---|
| 670 | + struct snd_pcm_substream *substream) |
|---|
| 666 | 671 | { |
|---|
| 667 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 672 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 668 | 673 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 669 | 674 | struct cygnus_aio_port *aio; |
|---|
| 670 | 675 | unsigned long bufsize, periodsize; |
|---|
| 671 | | - int ret = 0; |
|---|
| 672 | 676 | bool is_play; |
|---|
| 673 | 677 | u32 start; |
|---|
| 674 | 678 | struct ringbuf_regs *p_rbuf = NULL; |
|---|
| 675 | 679 | |
|---|
| 676 | 680 | aio = cygnus_dai_get_dma_data(substream); |
|---|
| 677 | | - dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 681 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s port %d\n", __func__, aio->portnum); |
|---|
| 678 | 682 | |
|---|
| 679 | 683 | bufsize = snd_pcm_lib_buffer_bytes(substream); |
|---|
| 680 | 684 | periodsize = snd_pcm_lib_period_bytes(substream); |
|---|
| 681 | 685 | |
|---|
| 682 | | - dev_dbg(rtd->cpu_dai->dev, "%s (buf_size %lu) (period_size %lu)\n", |
|---|
| 686 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s (buf_size %lu) (period_size %lu)\n", |
|---|
| 683 | 687 | __func__, bufsize, periodsize); |
|---|
| 684 | 688 | |
|---|
| 685 | 689 | configure_ringbuf_regs(substream); |
|---|
| .. | .. |
|---|
| 693 | 697 | ringbuf_set_initial(aio->cygaud->audio, p_rbuf, is_play, start, |
|---|
| 694 | 698 | periodsize, bufsize); |
|---|
| 695 | 699 | |
|---|
| 696 | | - return ret; |
|---|
| 700 | + return 0; |
|---|
| 697 | 701 | } |
|---|
| 698 | 702 | |
|---|
| 699 | | -static snd_pcm_uframes_t cygnus_pcm_pointer(struct snd_pcm_substream *substream) |
|---|
| 703 | +static snd_pcm_uframes_t cygnus_pcm_pointer(struct snd_soc_component *component, |
|---|
| 704 | + struct snd_pcm_substream *substream) |
|---|
| 700 | 705 | { |
|---|
| 701 | 706 | struct cygnus_aio_port *aio; |
|---|
| 702 | 707 | unsigned int res = 0, cur = 0, base = 0; |
|---|
| .. | .. |
|---|
| 728 | 733 | static int cygnus_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) |
|---|
| 729 | 734 | { |
|---|
| 730 | 735 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; |
|---|
| 731 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 736 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 732 | 737 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
|---|
| 733 | 738 | size_t size; |
|---|
| 734 | 739 | |
|---|
| .. | .. |
|---|
| 740 | 745 | buf->area = dma_alloc_coherent(pcm->card->dev, size, |
|---|
| 741 | 746 | &buf->addr, GFP_KERNEL); |
|---|
| 742 | 747 | |
|---|
| 743 | | - dev_dbg(rtd->cpu_dai->dev, "%s: size 0x%zx @ %pK\n", |
|---|
| 748 | + dev_dbg(asoc_rtd_to_cpu(rtd, 0)->dev, "%s: size 0x%zx @ %pK\n", |
|---|
| 744 | 749 | __func__, size, buf->area); |
|---|
| 745 | 750 | |
|---|
| 746 | 751 | if (!buf->area) { |
|---|
| 747 | | - dev_err(rtd->cpu_dai->dev, "%s: dma_alloc failed\n", __func__); |
|---|
| 752 | + dev_err(asoc_rtd_to_cpu(rtd, 0)->dev, "%s: dma_alloc failed\n", __func__); |
|---|
| 748 | 753 | return -ENOMEM; |
|---|
| 749 | 754 | } |
|---|
| 750 | 755 | buf->bytes = size; |
|---|
| .. | .. |
|---|
| 752 | 757 | return 0; |
|---|
| 753 | 758 | } |
|---|
| 754 | 759 | |
|---|
| 755 | | - |
|---|
| 756 | | -static const struct snd_pcm_ops cygnus_pcm_ops = { |
|---|
| 757 | | - .open = cygnus_pcm_open, |
|---|
| 758 | | - .close = cygnus_pcm_close, |
|---|
| 759 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 760 | | - .hw_params = cygnus_pcm_hw_params, |
|---|
| 761 | | - .hw_free = cygnus_pcm_hw_free, |
|---|
| 762 | | - .prepare = cygnus_pcm_prepare, |
|---|
| 763 | | - .trigger = cygnus_pcm_trigger, |
|---|
| 764 | | - .pointer = cygnus_pcm_pointer, |
|---|
| 765 | | -}; |
|---|
| 766 | | - |
|---|
| 767 | | -static void cygnus_dma_free_dma_buffers(struct snd_pcm *pcm) |
|---|
| 760 | +static void cygnus_dma_free_dma_buffers(struct snd_soc_component *component, |
|---|
| 761 | + struct snd_pcm *pcm) |
|---|
| 768 | 762 | { |
|---|
| 769 | 763 | struct snd_pcm_substream *substream; |
|---|
| 770 | 764 | struct snd_dma_buffer *buf; |
|---|
| .. | .. |
|---|
| 790 | 784 | } |
|---|
| 791 | 785 | } |
|---|
| 792 | 786 | |
|---|
| 793 | | -static int cygnus_dma_new(struct snd_soc_pcm_runtime *rtd) |
|---|
| 787 | +static int cygnus_dma_new(struct snd_soc_component *component, |
|---|
| 788 | + struct snd_soc_pcm_runtime *rtd) |
|---|
| 794 | 789 | { |
|---|
| 795 | 790 | struct snd_card *card = rtd->card->snd_card; |
|---|
| 796 | 791 | struct snd_pcm *pcm = rtd->pcm; |
|---|
| .. | .. |
|---|
| 812 | 807 | ret = cygnus_pcm_preallocate_dma_buffer(pcm, |
|---|
| 813 | 808 | SNDRV_PCM_STREAM_CAPTURE); |
|---|
| 814 | 809 | if (ret) { |
|---|
| 815 | | - cygnus_dma_free_dma_buffers(pcm); |
|---|
| 810 | + cygnus_dma_free_dma_buffers(component, pcm); |
|---|
| 816 | 811 | return ret; |
|---|
| 817 | 812 | } |
|---|
| 818 | 813 | } |
|---|
| .. | .. |
|---|
| 821 | 816 | } |
|---|
| 822 | 817 | |
|---|
| 823 | 818 | static struct snd_soc_component_driver cygnus_soc_platform = { |
|---|
| 824 | | - .ops = &cygnus_pcm_ops, |
|---|
| 825 | | - .pcm_new = cygnus_dma_new, |
|---|
| 826 | | - .pcm_free = cygnus_dma_free_dma_buffers, |
|---|
| 819 | + .open = cygnus_pcm_open, |
|---|
| 820 | + .close = cygnus_pcm_close, |
|---|
| 821 | + .hw_params = cygnus_pcm_hw_params, |
|---|
| 822 | + .hw_free = cygnus_pcm_hw_free, |
|---|
| 823 | + .prepare = cygnus_pcm_prepare, |
|---|
| 824 | + .trigger = cygnus_pcm_trigger, |
|---|
| 825 | + .pointer = cygnus_pcm_pointer, |
|---|
| 826 | + .pcm_construct = cygnus_dma_new, |
|---|
| 827 | + .pcm_destruct = cygnus_dma_free_dma_buffers, |
|---|
| 827 | 828 | }; |
|---|
| 828 | 829 | |
|---|
| 829 | 830 | int cygnus_soc_platform_register(struct device *dev, |
|---|