.. | .. |
---|
30 | 30 | return snd_soc_dai_get_drvdata(dai); |
---|
31 | 31 | } |
---|
32 | 32 | |
---|
| 33 | +static inline unsigned int *mdais_channel_maps(struct rk_mdais_dev *mdais, |
---|
| 34 | + struct snd_pcm_substream *substream) |
---|
| 35 | +{ |
---|
| 36 | + return substream->stream ? mdais->capture_channel_maps : |
---|
| 37 | + mdais->playback_channel_maps; |
---|
| 38 | +} |
---|
| 39 | + |
---|
33 | 40 | static void hw_refine_channels(struct snd_pcm_hw_params *params, |
---|
34 | 41 | unsigned int channel) |
---|
35 | 42 | { |
---|
.. | .. |
---|
54 | 61 | if (IS_ERR(cparams)) |
---|
55 | 62 | return PTR_ERR(cparams); |
---|
56 | 63 | |
---|
57 | | - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
---|
58 | | - channel_maps = mdais->playback_channel_maps; |
---|
59 | | - else |
---|
60 | | - channel_maps = mdais->capture_channel_maps; |
---|
| 64 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
61 | 65 | |
---|
62 | 66 | for (i = 0; i < mdais->num_dais; i++) { |
---|
63 | 67 | child = mdais->dais[i].dai; |
---|
64 | | - if (channel_maps[i]) |
---|
65 | | - hw_refine_channels(cparams, channel_maps[i]); |
---|
| 68 | + if (!channel_maps[i]) |
---|
| 69 | + continue; |
---|
| 70 | + |
---|
| 71 | + hw_refine_channels(cparams, channel_maps[i]); |
---|
66 | 72 | if (child->driver->ops && child->driver->ops->hw_params) { |
---|
67 | 73 | ret = child->driver->ops->hw_params(substream, cparams, child); |
---|
68 | 74 | if (ret < 0) { |
---|
69 | | - dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n", |
---|
| 75 | + dev_err(dai->dev, "Failed to set %s hw params: %d\n", |
---|
70 | 76 | dai->name, ret); |
---|
71 | | - return ret; |
---|
| 77 | + break; |
---|
72 | 78 | } |
---|
73 | 79 | } |
---|
74 | 80 | } |
---|
75 | 81 | |
---|
76 | 82 | kfree(cparams); |
---|
| 83 | + |
---|
| 84 | + return ret; |
---|
| 85 | +} |
---|
| 86 | + |
---|
| 87 | +static int rockchip_mdais_hw_free(struct snd_pcm_substream *substream, |
---|
| 88 | + struct snd_soc_dai *dai) |
---|
| 89 | +{ |
---|
| 90 | + struct rk_mdais_dev *mdais = to_info(dai); |
---|
| 91 | + struct snd_soc_dai *child; |
---|
| 92 | + unsigned int *channel_maps; |
---|
| 93 | + int ret = 0, i = 0; |
---|
| 94 | + |
---|
| 95 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
| 96 | + |
---|
| 97 | + for (i = 0; i < mdais->num_dais; i++) { |
---|
| 98 | + child = mdais->dais[i].dai; |
---|
| 99 | + if (!channel_maps[i]) |
---|
| 100 | + continue; |
---|
| 101 | + |
---|
| 102 | + if (child->driver->ops && child->driver->ops->hw_free) { |
---|
| 103 | + ret = child->driver->ops->hw_free(substream, child); |
---|
| 104 | + if (ret < 0) |
---|
| 105 | + return ret; |
---|
| 106 | + } |
---|
| 107 | + } |
---|
| 108 | + |
---|
77 | 109 | return 0; |
---|
78 | 110 | } |
---|
79 | 111 | |
---|
.. | .. |
---|
85 | 117 | unsigned int *channel_maps; |
---|
86 | 118 | int ret = 0, i = 0; |
---|
87 | 119 | |
---|
88 | | - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
---|
89 | | - channel_maps = mdais->playback_channel_maps; |
---|
90 | | - else |
---|
91 | | - channel_maps = mdais->capture_channel_maps; |
---|
| 120 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
92 | 121 | |
---|
93 | 122 | for (i = 0; i < mdais->num_dais; i++) { |
---|
94 | 123 | /* skip DAIs which have no channel mapping */ |
---|
.. | .. |
---|
112 | 141 | { |
---|
113 | 142 | struct rk_mdais_dev *mdais = to_info(dai); |
---|
114 | 143 | struct snd_soc_dai *child; |
---|
| 144 | + unsigned int *channel_maps; |
---|
115 | 145 | int ret = 0, i = 0; |
---|
116 | 146 | |
---|
| 147 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
| 148 | + |
---|
117 | 149 | for (i = 0; i < mdais->num_dais; i++) { |
---|
| 150 | + if (!channel_maps[i]) |
---|
| 151 | + continue; |
---|
| 152 | + |
---|
118 | 153 | child = mdais->dais[i].dai; |
---|
119 | 154 | if (child->driver->ops && child->driver->ops->startup) { |
---|
120 | 155 | ret = child->driver->ops->startup(substream, child); |
---|
.. | .. |
---|
131 | 166 | { |
---|
132 | 167 | struct rk_mdais_dev *mdais = to_info(dai); |
---|
133 | 168 | struct snd_soc_dai *child; |
---|
| 169 | + unsigned int *channel_maps; |
---|
134 | 170 | int i = 0; |
---|
135 | 171 | |
---|
| 172 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
| 173 | + |
---|
136 | 174 | for (i = 0; i < mdais->num_dais; i++) { |
---|
| 175 | + if (!channel_maps[i]) |
---|
| 176 | + continue; |
---|
| 177 | + |
---|
137 | 178 | child = mdais->dais[i].dai; |
---|
138 | 179 | if (child->driver->ops && child->driver->ops->shutdown) { |
---|
139 | 180 | child->driver->ops->shutdown(substream, child); |
---|
.. | .. |
---|
146 | 187 | { |
---|
147 | 188 | struct rk_mdais_dev *mdais = to_info(dai); |
---|
148 | 189 | struct snd_soc_dai *child; |
---|
| 190 | + unsigned int *channel_maps; |
---|
149 | 191 | int ret = 0, i = 0; |
---|
150 | 192 | |
---|
| 193 | + channel_maps = mdais_channel_maps(mdais, substream); |
---|
| 194 | + |
---|
151 | 195 | for (i = 0; i < mdais->num_dais; i++) { |
---|
| 196 | + if (!channel_maps[i]) |
---|
| 197 | + continue; |
---|
| 198 | + |
---|
152 | 199 | child = mdais->dais[i].dai; |
---|
153 | 200 | if (child->driver->ops && child->driver->ops->prepare) { |
---|
154 | 201 | ret = child->driver->ops->prepare(substream, child); |
---|
.. | .. |
---|
242 | 289 | ret = child->driver->probe(child); |
---|
243 | 290 | if (ret < 0) { |
---|
244 | 291 | dev_err(child->dev, |
---|
245 | | - "ASoC: failed to probe DAI %s: %d\n", |
---|
| 292 | + "Failed to probe DAI %s: %d\n", |
---|
246 | 293 | child->name, ret); |
---|
247 | 294 | return ret; |
---|
248 | 295 | } |
---|
.. | .. |
---|
263 | 310 | |
---|
264 | 311 | static const struct snd_soc_dai_ops rockchip_mdais_dai_ops = { |
---|
265 | 312 | .hw_params = rockchip_mdais_hw_params, |
---|
| 313 | + .hw_free = rockchip_mdais_hw_free, |
---|
266 | 314 | .set_sysclk = rockchip_mdais_set_sysclk, |
---|
267 | 315 | .set_fmt = rockchip_mdais_set_fmt, |
---|
268 | 316 | .set_tdm_slot = rockchip_mdais_tdm_slot, |
---|