diff options
Diffstat (limited to 'sound/soc/ux500/ux500_pcm.c')
-rw-r--r-- | sound/soc/ux500/ux500_pcm.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/sound/soc/ux500/ux500_pcm.c b/sound/soc/ux500/ux500_pcm.c index ce554de5d9dc..51a66a87305a 100644 --- a/sound/soc/ux500/ux500_pcm.c +++ b/sound/soc/ux500/ux500_pcm.c | |||
@@ -28,12 +28,6 @@ | |||
28 | #include "ux500_msp_i2s.h" | 28 | #include "ux500_msp_i2s.h" |
29 | #include "ux500_pcm.h" | 29 | #include "ux500_pcm.h" |
30 | 30 | ||
31 | #define UX500_PLATFORM_MIN_RATE 8000 | ||
32 | #define UX500_PLATFORM_MAX_RATE 48000 | ||
33 | |||
34 | #define UX500_PLATFORM_MIN_CHANNELS 1 | ||
35 | #define UX500_PLATFORM_MAX_CHANNELS 8 | ||
36 | |||
37 | #define UX500_PLATFORM_PERIODS_BYTES_MIN 128 | 31 | #define UX500_PLATFORM_PERIODS_BYTES_MIN 128 |
38 | #define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE) | 32 | #define UX500_PLATFORM_PERIODS_BYTES_MAX (64 * PAGE_SIZE) |
39 | #define UX500_PLATFORM_PERIODS_MIN 2 | 33 | #define UX500_PLATFORM_PERIODS_MIN 2 |
@@ -45,15 +39,6 @@ static const struct snd_pcm_hardware ux500_pcm_hw = { | |||
45 | SNDRV_PCM_INFO_MMAP | | 39 | SNDRV_PCM_INFO_MMAP | |
46 | SNDRV_PCM_INFO_RESUME | | 40 | SNDRV_PCM_INFO_RESUME | |
47 | SNDRV_PCM_INFO_PAUSE, | 41 | SNDRV_PCM_INFO_PAUSE, |
48 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | ||
49 | SNDRV_PCM_FMTBIT_U16_LE | | ||
50 | SNDRV_PCM_FMTBIT_S16_BE | | ||
51 | SNDRV_PCM_FMTBIT_U16_BE, | ||
52 | .rates = SNDRV_PCM_RATE_KNOT, | ||
53 | .rate_min = UX500_PLATFORM_MIN_RATE, | ||
54 | .rate_max = UX500_PLATFORM_MAX_RATE, | ||
55 | .channels_min = UX500_PLATFORM_MIN_CHANNELS, | ||
56 | .channels_max = UX500_PLATFORM_MAX_CHANNELS, | ||
57 | .buffer_bytes_max = UX500_PLATFORM_BUFFER_BYTES_MAX, | 42 | .buffer_bytes_max = UX500_PLATFORM_BUFFER_BYTES_MAX, |
58 | .period_bytes_min = UX500_PLATFORM_PERIODS_BYTES_MIN, | 43 | .period_bytes_min = UX500_PLATFORM_PERIODS_BYTES_MIN, |
59 | .period_bytes_max = UX500_PLATFORM_PERIODS_BYTES_MAX, | 44 | .period_bytes_max = UX500_PLATFORM_PERIODS_BYTES_MAX, |
@@ -65,14 +50,10 @@ static struct dma_chan *ux500_pcm_request_chan(struct snd_soc_pcm_runtime *rtd, | |||
65 | struct snd_pcm_substream *substream) | 50 | struct snd_pcm_substream *substream) |
66 | { | 51 | { |
67 | struct snd_soc_dai *dai = rtd->cpu_dai; | 52 | struct snd_soc_dai *dai = rtd->cpu_dai; |
68 | struct device *dev = dai->dev; | ||
69 | u16 per_data_width, mem_data_width; | 53 | u16 per_data_width, mem_data_width; |
70 | struct stedma40_chan_cfg *dma_cfg; | 54 | struct stedma40_chan_cfg *dma_cfg; |
71 | struct ux500_msp_dma_params *dma_params; | 55 | struct ux500_msp_dma_params *dma_params; |
72 | 56 | ||
73 | dev_dbg(dev, "%s: MSP %d (%s): Enter.\n", __func__, dai->id, | ||
74 | snd_pcm_stream_str(substream)); | ||
75 | |||
76 | dma_params = snd_soc_dai_get_dma_data(dai, substream); | 57 | dma_params = snd_soc_dai_get_dma_data(dai, substream); |
77 | dma_cfg = dma_params->dma_cfg; | 58 | dma_cfg = dma_params->dma_cfg; |
78 | 59 | ||
@@ -108,26 +89,36 @@ static int ux500_pcm_prepare_slave_config(struct snd_pcm_substream *substream, | |||
108 | struct dma_slave_config *slave_config) | 89 | struct dma_slave_config *slave_config) |
109 | { | 90 | { |
110 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 91 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
111 | struct ux500_msp_dma_params *dma_params; | 92 | struct msp_i2s_platform_data *pdata = rtd->cpu_dai->dev->platform_data; |
112 | struct stedma40_chan_cfg *dma_cfg; | 93 | struct snd_dmaengine_dai_dma_data *snd_dma_params; |
94 | struct ux500_msp_dma_params *ste_dma_params; | ||
95 | dma_addr_t dma_addr; | ||
113 | int ret; | 96 | int ret; |
114 | 97 | ||
115 | dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | 98 | if (pdata) { |
116 | dma_cfg = dma_params->dma_cfg; | 99 | ste_dma_params = |
100 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
101 | dma_addr = ste_dma_params->tx_rx_addr; | ||
102 | } else { | ||
103 | snd_dma_params = | ||
104 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
105 | dma_addr = snd_dma_params->addr; | ||
106 | } | ||
117 | 107 | ||
118 | ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); | 108 | ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); |
119 | if (ret) | 109 | if (ret) |
120 | return ret; | 110 | return ret; |
121 | 111 | ||
122 | slave_config->dst_maxburst = 4; | 112 | slave_config->dst_maxburst = 4; |
123 | slave_config->dst_addr_width = dma_cfg->dst_info.data_width; | ||
124 | slave_config->src_maxburst = 4; | 113 | slave_config->src_maxburst = 4; |
125 | slave_config->src_addr_width = dma_cfg->src_info.data_width; | 114 | |
115 | slave_config->src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
116 | slave_config->dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
126 | 117 | ||
127 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 118 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
128 | slave_config->dst_addr = dma_params->tx_rx_addr; | 119 | slave_config->dst_addr = dma_addr; |
129 | else | 120 | else |
130 | slave_config->src_addr = dma_params->tx_rx_addr; | 121 | slave_config->src_addr = dma_addr; |
131 | 122 | ||
132 | return 0; | 123 | return 0; |
133 | } | 124 | } |
@@ -139,15 +130,25 @@ static const struct snd_dmaengine_pcm_config ux500_dmaengine_pcm_config = { | |||
139 | .prepare_slave_config = ux500_pcm_prepare_slave_config, | 130 | .prepare_slave_config = ux500_pcm_prepare_slave_config, |
140 | }; | 131 | }; |
141 | 132 | ||
133 | static const struct snd_dmaengine_pcm_config ux500_dmaengine_of_pcm_config = { | ||
134 | .compat_request_channel = ux500_pcm_request_chan, | ||
135 | .prepare_slave_config = ux500_pcm_prepare_slave_config, | ||
136 | }; | ||
137 | |||
142 | int ux500_pcm_register_platform(struct platform_device *pdev) | 138 | int ux500_pcm_register_platform(struct platform_device *pdev) |
143 | { | 139 | { |
140 | const struct snd_dmaengine_pcm_config *pcm_config; | ||
141 | struct device_node *np = pdev->dev.of_node; | ||
144 | int ret; | 142 | int ret; |
145 | 143 | ||
146 | ret = snd_dmaengine_pcm_register(&pdev->dev, | 144 | if (np) |
147 | &ux500_dmaengine_pcm_config, | 145 | pcm_config = &ux500_dmaengine_of_pcm_config; |
148 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | 146 | else |
149 | SND_DMAENGINE_PCM_FLAG_COMPAT | | 147 | pcm_config = &ux500_dmaengine_pcm_config; |
150 | SND_DMAENGINE_PCM_FLAG_NO_DT); | 148 | |
149 | ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config, | ||
150 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | ||
151 | SND_DMAENGINE_PCM_FLAG_COMPAT); | ||
151 | if (ret < 0) { | 152 | if (ret < 0) { |
152 | dev_err(&pdev->dev, | 153 | dev_err(&pdev->dev, |
153 | "%s: ERROR: Failed to register platform '%s' (%d)!\n", | 154 | "%s: ERROR: Failed to register platform '%s' (%d)!\n", |