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

1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright 2013-2015 Maxim Integrated Products
6 // Copyright 2018 Ladislav Michl <ladis@linux-mips.org>
40 "Butterworth/8-24"
53 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max9867_adc_dac_event()
57 if (!strcmp(w->name, "ADCL")) in max9867_adc_dac_event()
59 else if (!strcmp(w->name, "ADCR")) in max9867_adc_dac_event()
61 else if (!strcmp(w->name, "DACL")) in max9867_adc_dac_event()
63 else if (!strcmp(w->name, "DACR")) in max9867_adc_dac_event()
69 max9867->adc_dac_active |= BIT(adc_dac); in max9867_adc_dac_event()
71 max9867->adc_dac_active &= ~BIT(adc_dac); in max9867_adc_dac_event()
84 ret = regmap_read(max9867->regmap, MAX9867_CODECFLTR, &reg); in max9867_filter_get()
86 return -EINVAL; in max9867_filter_get()
89 ucontrol->value.enumerated.item[0] = 1; in max9867_filter_get()
91 ucontrol->value.enumerated.item[0] = 0; in max9867_filter_get()
101 unsigned int reg, mode = ucontrol->value.enumerated.item[0]; in max9867_filter_set() local
104 if (mode > 1) in max9867_filter_set()
105 return -EINVAL; in max9867_filter_set()
108 if (max9867->adc_dac_active) in max9867_filter_set()
109 return -EBUSY; in max9867_filter_set()
111 /* read current filter mode */ in max9867_filter_set()
112 ret = regmap_read(max9867->regmap, MAX9867_CODECFLTR, &reg); in max9867_filter_set()
114 return -EINVAL; in max9867_filter_set()
116 if (mode) in max9867_filter_set()
117 mode = MAX9867_CODECFLTR_MODE; in max9867_filter_set()
120 if ((reg & MAX9867_CODECFLTR_MODE) == mode) in max9867_filter_set()
123 /* shutdown codec before switching filter mode */ in max9867_filter_set()
124 regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, in max9867_filter_set()
127 /* switch filter mode */ in max9867_filter_set()
128 regmap_update_bits(max9867->regmap, MAX9867_CODECFLTR, in max9867_filter_set()
129 MAX9867_CODECFLTR_MODE, mode); in max9867_filter_set()
132 regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, in max9867_filter_set()
146 0, 2, TLV_DB_SCALE_ITEM(-8600, 200, 1),
147 3, 17, TLV_DB_SCALE_ITEM(-7800, 400, 0),
148 18, 25, TLV_DB_SCALE_ITEM(-2000, 200, 0),
149 26, 34, TLV_DB_SCALE_ITEM( -500, 100, 0),
153 static DECLARE_TLV_DB_SCALE(max9867_line_tlv, -600, 200, 0);
154 static DECLARE_TLV_DB_SCALE(max9867_adc_tlv, -1200, 100, 0);
155 static DECLARE_TLV_DB_SCALE(max9867_dac_tlv, -1500, 100, 0);
158 0, 2, TLV_DB_SCALE_ITEM(-2000, 2000, 1),
178 SOC_ENUM("Speaker Mode", max9867_spkmode),
209 /* DMIC mux */
211 "ADC", "DMIC"
271 {"DMICL Mux", "DMIC", "DMICL"},
272 {"DMICR Mux", "DMIC", "DMICR"},
314 snd_soc_component_get_drvdata(dai->component); in max9867_startup()
316 if (max9867->constraints) in max9867_startup()
317 snd_pcm_hw_constraint_list(substream->runtime, 0, in max9867_startup()
318 SNDRV_PCM_HW_PARAM_RATE, max9867->constraints); in max9867_startup()
328 struct snd_soc_component *component = dai->component; in max9867_dai_hw_params()
331 max9867->pclk); in max9867_dai_hw_params()
334 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, in max9867_dai_hw_params()
336 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, in max9867_dai_hw_params()
338 if (max9867->master) { in max9867_dai_hw_params()
339 if (max9867->dsp_a) { in max9867_dai_hw_params()
343 ratio = max9867->pclk / rate; in max9867_dai_hw_params()
361 return -EINVAL; in max9867_dai_hw_params()
371 return -EINVAL; in max9867_dai_hw_params()
374 regmap_update_bits(max9867->regmap, MAX9867_IFC1B, in max9867_dai_hw_params()
379 * and also enable rapid lock mode. in max9867_dai_hw_params()
381 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, in max9867_dai_hw_params()
383 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, in max9867_dai_hw_params()
391 struct snd_soc_component *component = dai->component; in max9867_mute()
394 return regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, in max9867_mute()
401 struct snd_soc_component *component = codec_dai->component; in max9867_set_dai_sysclk()
408 max9867->pclk = freq; in max9867_set_dai_sysclk()
411 max9867->pclk = freq / 2; in max9867_set_dai_sysclk()
414 max9867->pclk = freq / 4; in max9867_set_dai_sysclk()
416 dev_err(component->dev, in max9867_set_dai_sysclk()
417 "Invalid clock frequency %uHz (required 10-60MHz)\n", in max9867_set_dai_sysclk()
419 return -EINVAL; in max9867_set_dai_sysclk()
422 max9867->constraints = &max9867_constraints_48k; in max9867_set_dai_sysclk()
424 max9867->constraints = &max9867_constraints_44k1; in max9867_set_dai_sysclk()
426 dev_warn(component->dev, in max9867_set_dai_sysclk()
429 max9867->sysclk = freq; in max9867_set_dai_sysclk()
431 /* exact integer mode is not supported */ in max9867_set_dai_sysclk()
433 regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, in max9867_set_dai_sysclk()
441 struct snd_soc_component *component = codec_dai->component; in max9867_dai_set_fmt()
447 max9867->master = true; in max9867_dai_set_fmt()
452 max9867->master = false; in max9867_dai_set_fmt()
456 return -EINVAL; in max9867_dai_set_fmt()
461 max9867->dsp_a = false; in max9867_dai_set_fmt()
465 max9867->dsp_a = true; in max9867_dai_set_fmt()
469 return -EINVAL; in max9867_dai_set_fmt()
486 return -EINVAL; in max9867_dai_set_fmt()
489 regmap_write(max9867->regmap, MAX9867_IFC1A, iface1A); in max9867_dai_set_fmt()
490 regmap_update_bits(max9867->regmap, MAX9867_IFC1B, in max9867_dai_set_fmt()
507 .name = "max9867-aif1",
555 err = regcache_sync(max9867->regmap); in max9867_set_bias_level()
559 err = regmap_write(max9867->regmap, in max9867_set_bias_level()
566 err = regmap_write(max9867->regmap, MAX9867_PWRMAN, 0); in max9867_set_bias_level()
570 regcache_mark_dirty(max9867->regmap); in max9867_set_bias_level()
622 max9867 = devm_kzalloc(&i2c->dev, sizeof(*max9867), GFP_KERNEL); in max9867_i2c_probe()
624 return -ENOMEM; in max9867_i2c_probe()
627 max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap); in max9867_i2c_probe()
628 if (IS_ERR(max9867->regmap)) { in max9867_i2c_probe()
629 ret = PTR_ERR(max9867->regmap); in max9867_i2c_probe()
630 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); in max9867_i2c_probe()
633 ret = regmap_read(max9867->regmap, MAX9867_REVISION, &reg); in max9867_i2c_probe()
635 dev_err(&i2c->dev, "Failed to read: %d\n", ret); in max9867_i2c_probe()
638 dev_info(&i2c->dev, "device revision: %x\n", reg); in max9867_i2c_probe()
639 ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component, in max9867_i2c_probe()
642 dev_err(&i2c->dev, "Failed to register component: %d\n", ret); in max9867_i2c_probe()
669 MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>");