|
19 | 19 | #include <sound/soc.h> |
20 | 20 |
|
21 | 21 | #include "loongson_i2s.h" |
| 22 | +#include "loongson_dma.h" |
22 | 23 |
|
23 | 24 | #define LOONGSON_I2S_RX_DMA_OFFSET 21 |
24 | 25 | #define LOONGSON_I2S_TX_DMA_OFFSET 18 |
|
29 | 30 | #define LOONGSON_DMA3_CONF 0x3 |
30 | 31 | #define LOONGSON_DMA4_CONF 0x4 |
31 | 32 |
|
32 | | -/* periods_max = PAGE_SIZE / sizeof(struct ls_dma_chan_reg) */ |
33 | | -static const struct snd_pcm_hardware loongson_pcm_hardware = { |
34 | | - .info = SNDRV_PCM_INFO_MMAP | |
35 | | - SNDRV_PCM_INFO_INTERLEAVED | |
36 | | - SNDRV_PCM_INFO_MMAP_VALID | |
37 | | - SNDRV_PCM_INFO_RESUME | |
38 | | - SNDRV_PCM_INFO_PAUSE, |
39 | | - .formats = SNDRV_PCM_FMTBIT_S16_LE | |
40 | | - SNDRV_PCM_FMTBIT_S20_3LE | |
41 | | - SNDRV_PCM_FMTBIT_S24_LE, |
42 | | - .period_bytes_min = 128, |
43 | | - .period_bytes_max = 128 * 1024, |
44 | | - .periods_min = 1, |
45 | | - .periods_max = 64, |
46 | | - .buffer_bytes_max = 1024 * 1024, |
47 | | -}; |
48 | | - |
49 | | -static const struct snd_dmaengine_pcm_config loongson_dmaengine_pcm_config = { |
50 | | - .pcm_hardware = &loongson_pcm_hardware, |
51 | | - .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, |
52 | | - .prealloc_buffer_size = 128 * 1024, |
53 | | -}; |
54 | | - |
55 | | -static int loongson_pcm_open(struct snd_soc_component *component, |
56 | | - struct snd_pcm_substream *substream) |
57 | | -{ |
58 | | - struct snd_pcm_runtime *runtime = substream->runtime; |
59 | | - |
60 | | - if (substream->pcm->device & 1) { |
61 | | - runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; |
62 | | - runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; |
63 | | - } |
64 | | - |
65 | | - if (substream->pcm->device & 2) |
66 | | - runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | |
67 | | - SNDRV_PCM_INFO_MMAP_VALID); |
68 | | - /* |
69 | | - * For mysterious reasons (and despite what the manual says) |
70 | | - * playback samples are lost if the DMA count is not a multiple |
71 | | - * of the DMA burst size. Let's add a rule to enforce that. |
72 | | - */ |
73 | | - snd_pcm_hw_constraint_step(runtime, 0, |
74 | | - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 128); |
75 | | - snd_pcm_hw_constraint_step(runtime, 0, |
76 | | - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 128); |
77 | | - snd_pcm_hw_constraint_integer(substream->runtime, |
78 | | - SNDRV_PCM_HW_PARAM_PERIODS); |
79 | | - |
80 | | - return 0; |
81 | | -} |
82 | | - |
83 | | -static const struct snd_soc_component_driver loongson_i2s_component_driver = { |
84 | | - .name = LS_I2S_DRVNAME, |
85 | | - .open = loongson_pcm_open, |
86 | | -}; |
87 | | - |
88 | 33 | static int loongson_i2s_apbdma_config(struct platform_device *pdev) |
89 | 34 | { |
90 | 35 | int val; |
@@ -147,7 +92,7 @@ static int loongson_i2s_plat_probe(struct platform_device *pdev) |
147 | 92 | dev_set_name(dev, LS_I2S_DRVNAME); |
148 | 93 | dev_set_drvdata(dev, i2s); |
149 | 94 |
|
150 | | - ret = devm_snd_soc_register_component(dev, &loongson_i2s_component_driver, |
| 95 | + ret = devm_snd_soc_register_component(dev, &loongson_i2s_edma_component, |
151 | 96 | &loongson_i2s_dai, 1); |
152 | 97 | if (ret) |
153 | 98 | return dev_err_probe(dev, ret, "failed to register DAI\n"); |
|
0 commit comments