25 #include <linux/slab.h>
26 #include <linux/module.h>
50 dev_dbg(dev,
"rate: %d\n", rate);
51 dev_dbg(dev,
"width: %d\n", width);
83 dev_err(dev,
"Sampling rate: %d not supported\n", rate);
117 dev_err(dev,
"Data width: %d not supported\n", width);
124 dev_dbg(dev,
"mode: 0x%04x\n", mode);
143 static int snd_wl1273_fm_set_channel_number(
struct wl1273_core *core,
149 dev_dbg(dev,
"%s\n", __func__);
172 static int snd_wl1273_get_audio_route(
struct snd_kcontrol *kcontrol,
176 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
178 ucontrol->
value.integer.value[0] = wl1273->
mode;
188 static const char *
const wl1273_audio_route[] = {
"Bt",
"FmRx",
"FmTx" };
190 static int snd_wl1273_set_audio_route(
struct snd_kcontrol *kcontrol,
194 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
196 if (wl1273->
mode == ucontrol->
value.integer.value[0])
203 if (ucontrol->
value.integer.value[0] < 0 ||
207 wl1273->
mode = ucontrol->
value.integer.value[0];
212 static const struct soc_enum wl1273_enum =
215 static int snd_wl1273_fm_audio_get(
struct snd_kcontrol *kcontrol,
219 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
221 dev_dbg(codec->
dev,
"%s: enter.\n", __func__);
223 ucontrol->
value.integer.value[0] = wl1273->
core->audio_mode;
228 static int snd_wl1273_fm_audio_put(
struct snd_kcontrol *kcontrol,
232 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
235 dev_dbg(codec->
dev,
"%s: enter.\n", __func__);
237 val = ucontrol->
value.integer.value[0];
238 if (wl1273->
core->audio_mode == val)
241 r = wl1273->
core->set_audio(wl1273->
core, val);
248 static const char *
const wl1273_audio_strings[] = {
"Digital",
"Analog" };
250 static const struct soc_enum wl1273_audio_enum =
252 wl1273_audio_strings);
254 static int snd_wl1273_fm_volume_get(
struct snd_kcontrol *kcontrol,
258 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
260 dev_dbg(codec->
dev,
"%s: enter.\n", __func__);
262 ucontrol->
value.integer.value[0] = wl1273->
core->volume;
267 static int snd_wl1273_fm_volume_put(
struct snd_kcontrol *kcontrol,
271 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
274 dev_dbg(codec->
dev,
"%s: enter.\n", __func__);
276 r = wl1273->
core->set_volume(wl1273->
core,
277 ucontrol->
value.integer.value[0]);
286 snd_wl1273_get_audio_route, snd_wl1273_set_audio_route),
288 snd_wl1273_fm_audio_get, snd_wl1273_fm_audio_put),
290 snd_wl1273_fm_volume_get, snd_wl1273_fm_volume_put),
297 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
299 switch (wl1273->
mode) {
309 pr_err(
"Cannot play in RX mode.\n");
315 pr_err(
"Cannot capture in TX mode.\n");
336 pr_err(
"Only SNDRV_PCM_FORMAT_S16_LE supported.\n");
350 pr_err(
"Only mono supported.\n");
359 pr_err(
"Only playback supported with TX.\n");
365 pr_err(
"Only capture supported with RX.\n");
371 pr_err(
"Unexpected mode: %d.\n", wl1273->
mode);
375 r = snd_wl1273_fm_set_i2s_mode(core, rate, width);
380 r = snd_wl1273_fm_set_channel_number(core, wl1273->
channels);
388 .startup = wl1273_startup,
389 .hw_params = wl1273_hw_params,
395 .stream_name =
"Playback",
401 .stream_name =
"Capture",
406 .ops = &wl1273_dai_ops,
417 wl1273 = snd_soc_codec_get_drvdata(codec);
419 switch (wl1273->
mode) {
450 dev_err(codec->
dev,
"Platform data is missing.\n");
455 if (wl1273 ==
NULL) {
456 dev_err(codec->
dev,
"Cannot allocate memory.\n");
463 snd_soc_codec_set_drvdata(codec, wl1273);
475 struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
484 .probe = wl1273_probe,
485 .remove = wl1273_remove,
504 .name =
"wl1273-codec",
507 .probe = wl1273_platform_probe,