11 #include <linux/slab.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/device.h>
41 static const char *ad1836_deemp[] = {
"None",
"44.1kHz",
"32kHz",
"48kHz"};
43 static const struct soc_enum ad1836_deemp_enum =
46 #define AD1836_DAC_VOLUME(x) \
47 SOC_DOUBLE_R("DAC" #x " Playback Volume", AD1836_DAC_L_VOL(x), \
48 AD1836_DAC_R_VOL(x), 0, 0x3FF, 0)
50 #define AD1836_DAC_SWITCH(x) \
51 SOC_DOUBLE("DAC" #x " Playback Switch", AD1836_DAC_CTRL2, \
52 AD1836_MUTE_LEFT(x), AD1836_MUTE_RIGHT(x), 1, 1)
54 #define AD1836_ADC_SWITCH(x) \
55 SOC_DOUBLE("ADC" #x " Capture Switch", AD1836_ADC_CTRL2, \
56 AD1836_MUTE_LEFT(x), AD1836_MUTE_RIGHT(x), 1, 1)
77 {
"DAC1OUT",
NULL,
"DAC" },
78 {
"DAC2OUT",
NULL,
"DAC" },
79 {
"DAC3OUT",
NULL,
"DAC" },
80 {
"DAC4OUT",
NULL,
"DAC" },
95 {
"ADC",
NULL,
"ADC1IN" },
96 {
"ADC",
NULL,
"ADC2IN" },
105 SOC_ENUM(
"Playback Deemphasis", ad1836_deemp_enum),
117 {
"DAC",
NULL,
"ADC_PWR" },
118 {
"ADC",
NULL,
"ADC_PWR" },
132 static int ad1836_set_dai_fmt(
struct snd_soc_dai *codec_dai,
196 .hw_params = ad1836_hw_params,
197 .set_fmt = ad1836_set_dai_fmt,
200 #define AD183X_DAI(_name, num_dacs, num_adcs) \
202 .name = _name "-hifi", \
204 .stream_name = "Playback", \
206 .channels_max = (num_dacs) * 2, \
207 .rates = SNDRV_PCM_RATE_48000, \
208 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | \
209 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, \
212 .stream_name = "Capture", \
214 .channels_max = (num_adcs) * 2, \
215 .rates = SNDRV_PCM_RATE_48000, \
216 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | \
217 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, \
219 .ops = &ad1836_dai_ops, \
231 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
239 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
245 #define ad1836_suspend NULL
246 #define ad1836_resume NULL
251 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
253 int num_dacs, num_adcs;
257 num_dacs = ad183x_dais[ad1836->
type].
playback.channels_max / 2;
258 num_adcs = ad183x_dais[ad1836->
type].
capture.channels_max / 2;
270 for (i = 1; i <= num_dacs; ++
i) {
316 struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec);
323 .probe = ad1836_probe,
324 .remove = ad1836_remove,
328 .controls = ad183x_controls,
330 .dapm_widgets = ad183x_dapm_widgets,
331 .num_dapm_widgets =
ARRAY_SIZE(ad183x_dapm_widgets),
332 .dapm_routes = ad183x_dapm_routes,
333 .num_dapm_routes =
ARRAY_SIZE(ad183x_dapm_routes),
336 static const struct reg_default ad1836_reg_defaults[] = {
352 static const struct regmap_config ad1836_regmap_config = {
355 .read_flag_mask = 0x08,
358 .reg_defaults = ad1836_reg_defaults,
359 .num_reg_defaults =
ARRAY_SIZE(ad1836_reg_defaults),
374 if (IS_ERR(ad1836->
regmap))
375 return PTR_ERR(ad1836->
regmap);
379 spi_set_drvdata(spi, ad1836);
382 &soc_codec_dev_ad1836, &ad183x_dais[ad1836->
type], 1);
402 static struct spi_driver ad1836_spi_driver = {
407 .probe = ad1836_spi_probe,
409 .id_table = ad1836_ids,