16 #include <linux/module.h>
18 #include <linux/slab.h>
30 #define UDA134X_RATES SNDRV_PCM_RATE_8000_48000
31 #define UDA134X_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \
32 SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S20_3LE)
45 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x83, 0x00, 0x40, 0x80, 0xC0, 0x00,
66 static inline void uda134x_write_reg_cache(
struct snd_soc_codec *codec,
80 static int uda134x_write(
struct snd_soc_codec *codec,
unsigned int reg,
88 pr_debug(
"%s reg: %02X, value:%02X\n", __func__, reg, value);
96 uda134x_write_reg_cache(codec, reg, value);
134 static inline void uda134x_reset(
struct snd_soc_codec *codec)
147 pr_debug(
"%s mute: %d\n", __func__, mute);
163 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
169 pr_debug(
"%s constraining to %d bits at %d\n", __func__,
171 master_runtime->
rate);
175 master_runtime->
rate,
176 master_runtime->
rate);
194 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
208 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
212 pr_debug(
"%s ignoring hw_params for slave substream\n",
221 pr_debug(
"%s sysclk: %d, rate:%d\n", __func__,
239 pr_debug(
"%s dai_fmt: %d, params_format:%d\n", __func__,
255 hw_params |= ((1<<2) | (1<<1));
276 static int uda134x_set_dai_sysclk(
struct snd_soc_dai *codec_dai,
277 int clk_id,
unsigned int freq,
int dir)
280 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
282 pr_debug(
"%s clk_id: %d, freq: %u, dir: %d\n", __func__,
289 if ((freq >= (256 * 8000)) && (freq <= (512 * 48000))) {
298 static int uda134x_set_dai_fmt(
struct snd_soc_dai *codec_dai,
302 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
304 pr_debug(
"%s fmt: %08X\n", __func__, fmt);
325 static int uda134x_set_bias_level(
struct snd_soc_codec *codec,
333 pr_debug(
"%s bias level %d\n", __func__, level);
351 "unsupported model %d\n", pd->
model);
361 codec->
driver->write(codec, i, *cache++);
379 "unsupported model %d\n", pd->
model);
393 static const char *uda134x_dsp_setting[] = {
"Flat",
"Minimum1",
394 "Minimum2",
"Maximum"};
395 static const char *uda134x_deemph[] = {
"None",
"32Khz",
"44.1Khz",
"48Khz"};
396 static const char *uda134x_mixmode[] = {
"Differential",
"Analog1",
399 static const struct soc_enum uda134x_mixer_enum[] = {
417 SOC_ENUM(
"Sound Processing Filter", uda134x_mixer_enum[0]),
418 SOC_ENUM(
"PCM Playback De-emphasis", uda134x_mixer_enum[1]),
419 SOC_ENUM(
"Input Mux", uda134x_mixer_enum[2]),
439 SOC_ENUM(
"Sound Processing Filter", uda134x_mixer_enum[0]),
440 SOC_ENUM(
"PCM Playback De-emphasis", uda134x_mixer_enum[1]),
448 SOC_ENUM(
"PCM Playback De-emphasis", uda134x_mixer_enum[1]),
454 .startup = uda134x_startup,
455 .shutdown = uda134x_shutdown,
456 .hw_params = uda134x_hw_params,
457 .digital_mute = uda134x_mute,
458 .set_sysclk = uda134x_set_dai_sysclk,
459 .set_fmt = uda134x_set_dai_fmt,
463 .name =
"uda134x-hifi",
466 .stream_name =
"Playback",
474 .stream_name =
"Capture",
481 .ops = &uda134x_dai_ops,
495 "missing L3 bitbang function\n");
507 "unsupported model %d\n",
515 snd_soc_codec_set_drvdata(codec, uda134x);
522 uda134x_reset(codec);
545 __func__, pd->
model);
562 struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
571 #if defined(CONFIG_PM)
586 #define uda134x_soc_suspend NULL
587 #define uda134x_soc_resume NULL
591 .probe = uda134x_soc_probe,
592 .remove = uda134x_soc_remove,
595 .reg_cache_size =
sizeof(uda134x_reg),
597 .reg_cache_default = uda134x_reg,
599 .read = uda134x_read_reg_cache,
600 .write = uda134x_write,
601 .set_bias_level = uda134x_set_bias_level,
607 &soc_codec_dev_uda134x, &uda134x_dai, 1);
618 .name =
"uda134x-codec",
621 .probe = uda134x_codec_probe,