Lines Matching +full:- +full:- +full:mode +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/mfd/wl1273-core.h>
24 enum wl1273_mode mode; member
32 struct device *dev = &core->client->dev; in snd_wl1273_fm_set_i2s_mode()
34 u16 mode; in snd_wl1273_fm_set_i2s_mode() local
39 mutex_lock(&core->lock); in snd_wl1273_fm_set_i2s_mode()
41 mode = core->i2s_mode & ~WL1273_IS2_WIDTH & ~WL1273_IS2_RATE; in snd_wl1273_fm_set_i2s_mode()
45 mode |= WL1273_IS2_RATE_48K; in snd_wl1273_fm_set_i2s_mode()
48 mode |= WL1273_IS2_RATE_44_1K; in snd_wl1273_fm_set_i2s_mode()
51 mode |= WL1273_IS2_RATE_32K; in snd_wl1273_fm_set_i2s_mode()
54 mode |= WL1273_IS2_RATE_22_05K; in snd_wl1273_fm_set_i2s_mode()
57 mode |= WL1273_IS2_RATE_16K; in snd_wl1273_fm_set_i2s_mode()
60 mode |= WL1273_IS2_RATE_12K; in snd_wl1273_fm_set_i2s_mode()
63 mode |= WL1273_IS2_RATE_11_025; in snd_wl1273_fm_set_i2s_mode()
66 mode |= WL1273_IS2_RATE_8K; in snd_wl1273_fm_set_i2s_mode()
70 r = -EINVAL; in snd_wl1273_fm_set_i2s_mode()
76 mode |= WL1273_IS2_WIDTH_32; in snd_wl1273_fm_set_i2s_mode()
79 mode |= WL1273_IS2_WIDTH_40; in snd_wl1273_fm_set_i2s_mode()
82 mode |= WL1273_IS2_WIDTH_48; in snd_wl1273_fm_set_i2s_mode()
85 mode |= WL1273_IS2_WIDTH_50; in snd_wl1273_fm_set_i2s_mode()
88 mode |= WL1273_IS2_WIDTH_60; in snd_wl1273_fm_set_i2s_mode()
91 mode |= WL1273_IS2_WIDTH_64; in snd_wl1273_fm_set_i2s_mode()
94 mode |= WL1273_IS2_WIDTH_80; in snd_wl1273_fm_set_i2s_mode()
97 mode |= WL1273_IS2_WIDTH_96; in snd_wl1273_fm_set_i2s_mode()
100 mode |= WL1273_IS2_WIDTH_128; in snd_wl1273_fm_set_i2s_mode()
104 r = -EINVAL; in snd_wl1273_fm_set_i2s_mode()
109 dev_dbg(dev, "core->i2s_mode: 0x%04x\n", core->i2s_mode); in snd_wl1273_fm_set_i2s_mode()
110 dev_dbg(dev, "mode: 0x%04x\n", mode); in snd_wl1273_fm_set_i2s_mode()
112 if (core->i2s_mode != mode) { in snd_wl1273_fm_set_i2s_mode()
113 r = core->write(core, WL1273_I2S_MODE_CONFIG_SET, mode); in snd_wl1273_fm_set_i2s_mode()
117 core->i2s_mode = mode; in snd_wl1273_fm_set_i2s_mode()
118 r = core->write(core, WL1273_AUDIO_ENABLE, in snd_wl1273_fm_set_i2s_mode()
124 mutex_unlock(&core->lock); in snd_wl1273_fm_set_i2s_mode()
132 struct device *dev = &core->client->dev; in snd_wl1273_fm_set_channel_number()
137 mutex_lock(&core->lock); in snd_wl1273_fm_set_channel_number()
139 if (core->channel_number == channel_number) in snd_wl1273_fm_set_channel_number()
142 if (channel_number == 1 && core->mode == WL1273_MODE_RX) in snd_wl1273_fm_set_channel_number()
143 r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_MONO); in snd_wl1273_fm_set_channel_number()
144 else if (channel_number == 1 && core->mode == WL1273_MODE_TX) in snd_wl1273_fm_set_channel_number()
145 r = core->write(core, WL1273_MONO_SET, WL1273_TX_MONO); in snd_wl1273_fm_set_channel_number()
146 else if (channel_number == 2 && core->mode == WL1273_MODE_RX) in snd_wl1273_fm_set_channel_number()
147 r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_STEREO); in snd_wl1273_fm_set_channel_number()
148 else if (channel_number == 2 && core->mode == WL1273_MODE_TX) in snd_wl1273_fm_set_channel_number()
149 r = core->write(core, WL1273_MONO_SET, WL1273_TX_STEREO); in snd_wl1273_fm_set_channel_number()
151 r = -EINVAL; in snd_wl1273_fm_set_channel_number()
153 mutex_unlock(&core->lock); in snd_wl1273_fm_set_channel_number()
164 ucontrol->value.enumerated.item[0] = wl1273->mode; in snd_wl1273_get_audio_route()
182 if (wl1273->mode == ucontrol->value.enumerated.item[0]) in snd_wl1273_set_audio_route()
187 return -EPERM; in snd_wl1273_set_audio_route()
189 if (ucontrol->value.enumerated.item[0] >= ARRAY_SIZE(wl1273_audio_route)) in snd_wl1273_set_audio_route()
190 return -EINVAL; in snd_wl1273_set_audio_route()
192 wl1273->mode = ucontrol->value.enumerated.item[0]; in snd_wl1273_set_audio_route()
205 dev_dbg(component->dev, "%s: enter.\n", __func__); in snd_wl1273_fm_audio_get()
207 ucontrol->value.enumerated.item[0] = wl1273->core->audio_mode; in snd_wl1273_fm_audio_get()
219 dev_dbg(component->dev, "%s: enter.\n", __func__); in snd_wl1273_fm_audio_put()
221 val = ucontrol->value.enumerated.item[0]; in snd_wl1273_fm_audio_put()
222 if (wl1273->core->audio_mode == val) in snd_wl1273_fm_audio_put()
225 r = wl1273->core->set_audio(wl1273->core, val); in snd_wl1273_fm_audio_put()
242 dev_dbg(component->dev, "%s: enter.\n", __func__); in snd_wl1273_fm_volume_get()
244 ucontrol->value.integer.value[0] = wl1273->core->volume; in snd_wl1273_fm_volume_get()
256 dev_dbg(component->dev, "%s: enter.\n", __func__); in snd_wl1273_fm_volume_put()
258 r = wl1273->core->set_volume(wl1273->core, in snd_wl1273_fm_volume_put()
259 ucontrol->value.integer.value[0]); in snd_wl1273_fm_volume_put()
267 SOC_ENUM_EXT("Codec Mode", wl1273_enum,
290 struct snd_soc_component *component = dai->component; in wl1273_startup()
293 switch (wl1273->mode) { in wl1273_startup()
295 snd_pcm_hw_constraint_single(substream->runtime, in wl1273_startup()
297 snd_pcm_hw_constraint_single(substream->runtime, in wl1273_startup()
301 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in wl1273_startup()
302 pr_err("Cannot play in RX mode.\n"); in wl1273_startup()
303 return -EINVAL; in wl1273_startup()
307 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in wl1273_startup()
308 pr_err("Cannot capture in TX mode.\n"); in wl1273_startup()
309 return -EINVAL; in wl1273_startup()
313 return -EINVAL; in wl1273_startup()
323 struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(dai->component); in wl1273_hw_params()
324 struct wl1273_core *core = wl1273->core; in wl1273_hw_params()
328 dev_err(dai->dev, "%d bits/sample not supported\n", in wl1273_hw_params()
330 return -EINVAL; in wl1273_hw_params()
334 width = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; in wl1273_hw_params()
336 if (wl1273->mode == WL1273_MODE_BT) { in wl1273_hw_params()
339 return -EINVAL; in wl1273_hw_params()
344 return -EINVAL; in wl1273_hw_params()
350 if (wl1273->mode == WL1273_MODE_FM_TX && in wl1273_hw_params()
351 substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in wl1273_hw_params()
353 return -EINVAL; in wl1273_hw_params()
356 if (wl1273->mode == WL1273_MODE_FM_RX && in wl1273_hw_params()
357 substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in wl1273_hw_params()
359 return -EINVAL; in wl1273_hw_params()
362 if (wl1273->mode != WL1273_MODE_FM_RX && in wl1273_hw_params()
363 wl1273->mode != WL1273_MODE_FM_TX) { in wl1273_hw_params()
364 pr_err("Unexpected mode: %d.\n", wl1273->mode); in wl1273_hw_params()
365 return -EINVAL; in wl1273_hw_params()
372 wl1273->channels = params_channels(params); in wl1273_hw_params()
373 r = snd_wl1273_fm_set_channel_number(core, wl1273->channels); in wl1273_hw_params()
386 .name = "wl1273-fm",
408 return -EINVAL; in wl1273_get_format()
412 switch (wl1273->mode) { in wl1273_get_format()
427 return -EINVAL; in wl1273_get_format()
436 struct wl1273_core **core = component->dev->platform_data; in wl1273_probe()
439 dev_dbg(component->dev, "%s.\n", __func__); in wl1273_probe()
442 dev_err(component->dev, "Platform data is missing.\n"); in wl1273_probe()
443 return -EINVAL; in wl1273_probe()
448 return -ENOMEM; in wl1273_probe()
450 wl1273->mode = WL1273_MODE_BT; in wl1273_probe()
451 wl1273->core = *core; in wl1273_probe()
462 dev_dbg(component->dev, "%s\n", __func__); in wl1273_remove()
482 return devm_snd_soc_register_component(&pdev->dev, in wl1273_platform_probe()
487 MODULE_ALIAS("platform:wl1273-codec");
491 .name = "wl1273-codec",