.. | .. |
---|
330 | 330 | } |
---|
331 | 331 | #endif |
---|
332 | 332 | |
---|
333 | | -static int snd_dmaengine_mpcm_trigger(struct snd_pcm_substream *substream, int cmd) |
---|
| 333 | +static int snd_dmaengine_mpcm_trigger(struct snd_soc_component *component, |
---|
| 334 | + struct snd_pcm_substream *substream, int cmd) |
---|
334 | 335 | { |
---|
335 | 336 | struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream); |
---|
336 | 337 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
.. | .. |
---|
377 | 378 | return 0; |
---|
378 | 379 | } |
---|
379 | 380 | |
---|
380 | | -static int dmaengine_mpcm_hw_params(struct snd_pcm_substream *substream, |
---|
| 381 | +static int dmaengine_mpcm_hw_params(struct snd_soc_component *component, |
---|
| 382 | + struct snd_pcm_substream *substream, |
---|
381 | 383 | struct snd_pcm_hw_params *params) |
---|
382 | 384 | { |
---|
383 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
384 | | - struct snd_soc_component *component = |
---|
385 | | - snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME); |
---|
386 | 385 | struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component); |
---|
387 | 386 | struct dma_chan *chan; |
---|
388 | 387 | struct snd_dmaengine_dai_dma_data *dma_data; |
---|
.. | .. |
---|
420 | 419 | sz = snd_pcm_format_size(format, maps[i]); |
---|
421 | 420 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
---|
422 | 421 | chan = pcm->tx_chans[i]; |
---|
| 422 | +#ifdef CONFIG_NO_GKI |
---|
423 | 423 | if (sz) { |
---|
424 | 424 | slave_config.src_interlace_size = frame_bytes - sz; |
---|
425 | 425 | if (slave_config.src_interlace_size) |
---|
426 | 426 | slave_config.dst_maxburst = sz / slave_config.dst_addr_width; |
---|
427 | 427 | } |
---|
| 428 | +#endif |
---|
428 | 429 | } else { |
---|
429 | 430 | chan = pcm->rx_chans[i]; |
---|
| 431 | +#ifdef CONFIG_NO_GKI |
---|
430 | 432 | if (sz) { |
---|
431 | 433 | slave_config.dst_interlace_size = frame_bytes - sz; |
---|
432 | 434 | if (slave_config.dst_interlace_size) |
---|
433 | 435 | slave_config.src_maxburst = sz / slave_config.src_addr_width; |
---|
434 | 436 | } |
---|
| 437 | +#endif |
---|
435 | 438 | } |
---|
436 | 439 | if (!chan) |
---|
437 | 440 | continue; |
---|
.. | .. |
---|
515 | 518 | return snd_soc_set_runtime_hwparams(substream, &hw); |
---|
516 | 519 | } |
---|
517 | 520 | |
---|
518 | | -static int dmaengine_mpcm_open(struct snd_pcm_substream *substream) |
---|
| 521 | +static int dmaengine_mpcm_open(struct snd_soc_component *component, |
---|
| 522 | + struct snd_pcm_substream *substream) |
---|
519 | 523 | { |
---|
520 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
---|
521 | | - struct snd_soc_component *component = |
---|
522 | | - snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME); |
---|
523 | 524 | struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component); |
---|
524 | 525 | struct dmaengine_mpcm_runtime_data *prtd; |
---|
525 | 526 | int ret, i; |
---|
.. | .. |
---|
554 | 555 | return 0; |
---|
555 | 556 | } |
---|
556 | 557 | |
---|
557 | | -static int dmaengine_mpcm_new(struct snd_soc_pcm_runtime *rtd) |
---|
| 558 | +static int dmaengine_mpcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) |
---|
558 | 559 | { |
---|
559 | | - struct snd_soc_component *component = |
---|
560 | | - snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_MPCM_DRV_NAME); |
---|
561 | 560 | struct dmaengine_mpcm *pcm = soc_component_to_mpcm(component); |
---|
562 | 561 | struct snd_pcm_substream *substream; |
---|
563 | 562 | size_t prealloc_buffer_size; |
---|
564 | 563 | size_t max_buffer_size; |
---|
565 | 564 | unsigned int i; |
---|
566 | | - int ret; |
---|
567 | 565 | |
---|
568 | 566 | prealloc_buffer_size = 512 * 1024; |
---|
569 | 567 | max_buffer_size = SIZE_MAX; |
---|
.. | .. |
---|
573 | 571 | if (!substream) |
---|
574 | 572 | continue; |
---|
575 | 573 | |
---|
576 | | - ret = snd_pcm_lib_preallocate_pages(substream, |
---|
577 | | - SNDRV_DMA_TYPE_DEV_IRAM, |
---|
578 | | - dmaengine_dma_dev(pcm, substream), |
---|
579 | | - prealloc_buffer_size, |
---|
580 | | - max_buffer_size); |
---|
581 | | - if (ret) |
---|
582 | | - return ret; |
---|
| 574 | + snd_pcm_lib_preallocate_pages(substream, |
---|
| 575 | + SNDRV_DMA_TYPE_DEV_IRAM, |
---|
| 576 | + dmaengine_dma_dev(pcm, substream), |
---|
| 577 | + prealloc_buffer_size, |
---|
| 578 | + max_buffer_size); |
---|
583 | 579 | } |
---|
584 | 580 | |
---|
585 | 581 | return 0; |
---|
586 | 582 | } |
---|
587 | 583 | |
---|
588 | | -static snd_pcm_uframes_t dmaengine_mpcm_pointer(struct snd_pcm_substream *substream) |
---|
| 584 | +static snd_pcm_uframes_t dmaengine_mpcm_pointer(struct snd_soc_component *component, |
---|
| 585 | + struct snd_pcm_substream *substream) |
---|
589 | 586 | { |
---|
590 | 587 | struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream); |
---|
591 | 588 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
.. | .. |
---|
601 | 598 | pos = buf_size - state.residue; |
---|
602 | 599 | |
---|
603 | 600 | frames = bytes_to_frames(substream->runtime, pos); |
---|
| 601 | + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
---|
| 602 | + return frames; |
---|
| 603 | + |
---|
604 | 604 | #ifdef CONFIG_SND_SOC_ROCKCHIP_VAD |
---|
605 | 605 | if (prtd->vpos) |
---|
606 | 606 | frames = bytes_to_frames(substream->runtime, prtd->vpos); |
---|
.. | .. |
---|
620 | 620 | return frames; |
---|
621 | 621 | } |
---|
622 | 622 | |
---|
623 | | -static int dmaengine_mpcm_close(struct snd_pcm_substream *substream) |
---|
| 623 | +static int dmaengine_mpcm_ioctl(struct snd_soc_component *component, |
---|
| 624 | + struct snd_pcm_substream *substream, |
---|
| 625 | + unsigned int cmd, void *arg) |
---|
| 626 | +{ |
---|
| 627 | + return snd_pcm_lib_ioctl(substream, cmd, arg); |
---|
| 628 | +} |
---|
| 629 | + |
---|
| 630 | +static int dmaengine_mpcm_hw_free(struct snd_soc_component *component, |
---|
| 631 | + struct snd_pcm_substream *substream) |
---|
| 632 | +{ |
---|
| 633 | + return snd_pcm_lib_free_pages(substream); |
---|
| 634 | +} |
---|
| 635 | + |
---|
| 636 | +static int dmaengine_mpcm_close(struct snd_soc_component *component, |
---|
| 637 | + struct snd_pcm_substream *substream) |
---|
624 | 638 | { |
---|
625 | 639 | struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream); |
---|
626 | 640 | |
---|
.. | .. |
---|
629 | 643 | return 0; |
---|
630 | 644 | } |
---|
631 | 645 | |
---|
632 | | -static const struct snd_pcm_ops dmaengine_mpcm_ops = { |
---|
633 | | - .open = dmaengine_mpcm_open, |
---|
634 | | - .close = dmaengine_mpcm_close, |
---|
635 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
636 | | - .hw_params = dmaengine_mpcm_hw_params, |
---|
637 | | - .hw_free = snd_pcm_lib_free_pages, |
---|
638 | | - .trigger = snd_dmaengine_mpcm_trigger, |
---|
639 | | - .pointer = dmaengine_mpcm_pointer, |
---|
640 | | -}; |
---|
641 | | - |
---|
642 | 646 | static const struct snd_soc_component_driver dmaengine_mpcm_platform = { |
---|
643 | 647 | .name = SND_DMAENGINE_MPCM_DRV_NAME, |
---|
644 | 648 | .probe_order = SND_SOC_COMP_ORDER_LATE, |
---|
645 | | - .ops = &dmaengine_mpcm_ops, |
---|
646 | | - .pcm_new = dmaengine_mpcm_new, |
---|
| 649 | + .pcm_construct = dmaengine_mpcm_new, |
---|
| 650 | + .open = dmaengine_mpcm_open, |
---|
| 651 | + .close = dmaengine_mpcm_close, |
---|
| 652 | + .ioctl = dmaengine_mpcm_ioctl, |
---|
| 653 | + .hw_params = dmaengine_mpcm_hw_params, |
---|
| 654 | + .hw_free = dmaengine_mpcm_hw_free, |
---|
| 655 | + .trigger = snd_dmaengine_mpcm_trigger, |
---|
| 656 | + .pointer = dmaengine_mpcm_pointer, |
---|
647 | 657 | }; |
---|
648 | 658 | |
---|
649 | 659 | static void dmaengine_mpcm_release_chan(struct dmaengine_mpcm *pcm) |
---|
.. | .. |
---|
693 | 703 | } |
---|
694 | 704 | } |
---|
695 | 705 | |
---|
696 | | - ret = snd_soc_add_component(dev, &pcm->component, |
---|
697 | | - &dmaengine_mpcm_platform, NULL, 0); |
---|
| 706 | + ret = snd_soc_component_initialize(&pcm->component, &dmaengine_mpcm_platform, |
---|
| 707 | + dev); |
---|
| 708 | + if (ret) |
---|
| 709 | + goto err_free_dma; |
---|
| 710 | + |
---|
| 711 | + ret = snd_soc_add_component(&pcm->component, NULL, 0); |
---|
698 | 712 | if (ret) |
---|
699 | 713 | goto err_free_dma; |
---|
700 | 714 | |
---|