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

1 // SPDX-License-Identifier: GPL-2.0
5 // Copyright 2013-2015 Maxim Integrated Products
6 // Copyright 2018 Ladislav Michl <ladis@linux-mips.org>
42 "Butterworth/8-24"
55 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max9867_adc_dac_event()
71 max9867->adc_dac_active |= BIT(adc_dac); in max9867_adc_dac_event()
73 max9867->adc_dac_active &= ~BIT(adc_dac); in max9867_adc_dac_event()
86 ret = regmap_read(max9867->regmap, MAX9867_CODECFLTR, &reg); in max9867_filter_get()
88 return -EINVAL; in max9867_filter_get()
91 ucontrol->value.enumerated.item[0] = 1; in max9867_filter_get()
93 ucontrol->value.enumerated.item[0] = 0; in max9867_filter_get()
103 unsigned int reg, mode = ucontrol->value.enumerated.item[0]; in max9867_filter_set() local
106 if (mode > 1) in max9867_filter_set()
107 return -EINVAL; in max9867_filter_set()
110 if (max9867->adc_dac_active) in max9867_filter_set()
111 return -EBUSY; in max9867_filter_set()
113 /* read current filter mode */ in max9867_filter_set()
114 ret = regmap_read(max9867->regmap, MAX9867_CODECFLTR, &reg); in max9867_filter_set()
116 return -EINVAL; in max9867_filter_set()
118 if (mode) in max9867_filter_set()
119 mode = MAX9867_CODECFLTR_MODE; in max9867_filter_set()
122 if ((reg & MAX9867_CODECFLTR_MODE) == mode) in max9867_filter_set()
125 /* shutdown codec before switching filter mode */ in max9867_filter_set()
126 regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, in max9867_filter_set()
129 /* switch filter mode */ in max9867_filter_set()
130 regmap_update_bits(max9867->regmap, MAX9867_CODECFLTR, in max9867_filter_set()
131 MAX9867_CODECFLTR_MODE, mode); in max9867_filter_set()
134 regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, in max9867_filter_set()
148 0, 2, TLV_DB_SCALE_ITEM(-8600, 200, 1),
149 3, 17, TLV_DB_SCALE_ITEM(-7800, 400, 0),
150 18, 25, TLV_DB_SCALE_ITEM(-2000, 200, 0),
151 26, 34, TLV_DB_SCALE_ITEM( -500, 100, 0),
155 static DECLARE_TLV_DB_SCALE(max9867_line_tlv, -600, 200, 0);
156 static DECLARE_TLV_DB_SCALE(max9867_adc_tlv, -1200, 100, 0);
157 static DECLARE_TLV_DB_SCALE(max9867_dac_tlv, -1500, 100, 0);
160 0, 2, TLV_DB_SCALE_ITEM(-2000, 2000, 1),
180 SOC_ENUM("Speaker Mode", max9867_spkmode),
181 SOC_SINGLE("Volume Smoothing Switch", MAX9867_MODECONFIG, 6, 1, 0),
182 SOC_SINGLE("Line ZC Switch", MAX9867_MODECONFIG, 5, 1, 0),
186 SOC_SINGLE("Mono Playback Switch", MAX9867_IFC1B, 3, 1, 0),
191 SOC_DAPM_DOUBLE("Line Capture Switch", MAX9867_INPUTCONFIG, 7, 5, 1, 0),
192 SOC_DAPM_DOUBLE("Mic Capture Switch", MAX9867_INPUTCONFIG, 6, 4, 1, 0),
197 SOC_DAPM_DOUBLE_R("Line Bypass Switch",
203 SOC_DAPM_DOUBLE("Sidetone Switch", MAX9867_SIDETONE, 6, 7, 1, 0),
206 /* Line out switch */
208 SOC_DAPM_DOUBLE_R("Switch",
269 {"Input Mixer", "Mic Capture Switch", "MICL"},
270 {"Input Mixer", "Mic Capture Switch", "MICR"},
271 {"Input Mixer", "Line Capture Switch", "Left Line Input"},
272 {"Input Mixer", "Line Capture Switch", "Right Line Input"},
280 {"Digital", "Sidetone Switch", "ADCL"},
281 {"Digital", "Sidetone Switch", "ADCR"},
285 {"Output Mixer", "Line Bypass Switch", "Left Line Input"},
286 {"Output Mixer", "Line Bypass Switch", "Right Line Input"},
289 {"Master Playback", "Switch", "Output Mixer"},
316 snd_soc_component_get_drvdata(dai->component); in max9867_startup()
318 if (max9867->constraints) in max9867_startup()
319 snd_pcm_hw_constraint_list(substream->runtime, 0, in max9867_startup()
320 SNDRV_PCM_HW_PARAM_RATE, max9867->constraints); in max9867_startup()
330 struct snd_soc_component *component = dai->component; in max9867_dai_hw_params()
333 max9867->pclk); in max9867_dai_hw_params()
336 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, in max9867_dai_hw_params()
338 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, in max9867_dai_hw_params()
340 if (max9867->provider) { in max9867_dai_hw_params()
341 if (max9867->dsp_a) { in max9867_dai_hw_params()
345 ratio = max9867->pclk / rate; in max9867_dai_hw_params()
346 switch (params_width(params)) { in max9867_dai_hw_params()
349 switch (ratio) { in max9867_dai_hw_params()
363 return -EINVAL; in max9867_dai_hw_params()
373 return -EINVAL; in max9867_dai_hw_params()
376 regmap_update_bits(max9867->regmap, MAX9867_IFC1B, in max9867_dai_hw_params()
379 /* Exact integer mode available for 8kHz and 16kHz sample rates in max9867_dai_hw_params()
384 switch (max9867->pclk) { in max9867_dai_hw_params()
402 /* If exact integer mode not available, the freq value in max9867_dai_hw_params()
403 * remains zero, i.e. normal mode is used. in max9867_dai_hw_params()
405 regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, in max9867_dai_hw_params()
410 * and also enable rapid lock mode. in max9867_dai_hw_params()
412 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKLOW, in max9867_dai_hw_params()
414 regmap_update_bits(max9867->regmap, MAX9867_AUDIOCLKHIGH, in max9867_dai_hw_params()
422 struct snd_soc_component *component = dai->component; in max9867_mute()
425 return regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, in max9867_mute()
432 struct snd_soc_component *component = codec_dai->component; in max9867_set_dai_sysclk()
439 max9867->pclk = freq; in max9867_set_dai_sysclk()
442 max9867->pclk = freq / 2; in max9867_set_dai_sysclk()
445 max9867->pclk = freq / 4; in max9867_set_dai_sysclk()
447 dev_err(component->dev, in max9867_set_dai_sysclk()
448 "Invalid clock frequency %uHz (required 10-60MHz)\n", in max9867_set_dai_sysclk()
450 return -EINVAL; in max9867_set_dai_sysclk()
453 max9867->constraints = &max9867_constraints_48k; in max9867_set_dai_sysclk()
455 max9867->constraints = &max9867_constraints_44k1; in max9867_set_dai_sysclk()
457 dev_warn(component->dev, in max9867_set_dai_sysclk()
460 max9867->sysclk = freq; in max9867_set_dai_sysclk()
462 regmap_update_bits(max9867->regmap, MAX9867_SYSCLK, in max9867_set_dai_sysclk()
470 struct snd_soc_component *component = codec_dai->component; in max9867_dai_set_fmt()
474 switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in max9867_dai_set_fmt()
476 max9867->provider = true; in max9867_dai_set_fmt()
481 max9867->provider = false; in max9867_dai_set_fmt()
485 return -EINVAL; in max9867_dai_set_fmt()
488 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in max9867_dai_set_fmt()
490 max9867->dsp_a = false; in max9867_dai_set_fmt()
494 max9867->dsp_a = true; in max9867_dai_set_fmt()
498 return -EINVAL; in max9867_dai_set_fmt()
502 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in max9867_dai_set_fmt()
515 return -EINVAL; in max9867_dai_set_fmt()
518 regmap_write(max9867->regmap, MAX9867_IFC1A, iface1A); in max9867_dai_set_fmt()
519 regmap_update_bits(max9867->regmap, MAX9867_IFC1B, in max9867_dai_set_fmt()
536 .name = "max9867-aif1",
581 switch (level) { in max9867_set_bias_level()
583 err = clk_prepare_enable(max9867->mclk); in max9867_set_bias_level()
589 err = regcache_sync(max9867->regmap); in max9867_set_bias_level()
593 err = regmap_write(max9867->regmap, in max9867_set_bias_level()
600 err = regmap_write(max9867->regmap, MAX9867_PWRMAN, 0); in max9867_set_bias_level()
604 regcache_mark_dirty(max9867->regmap); in max9867_set_bias_level()
605 clk_disable_unprepare(max9867->mclk); in max9867_set_bias_level()
631 switch (reg) { in max9867_volatile_register()
655 max9867 = devm_kzalloc(&i2c->dev, sizeof(*max9867), GFP_KERNEL); in max9867_i2c_probe()
657 return -ENOMEM; in max9867_i2c_probe()
660 max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap); in max9867_i2c_probe()
661 if (IS_ERR(max9867->regmap)) { in max9867_i2c_probe()
662 ret = PTR_ERR(max9867->regmap); in max9867_i2c_probe()
663 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); in max9867_i2c_probe()
666 ret = regmap_read(max9867->regmap, MAX9867_REVISION, &reg); in max9867_i2c_probe()
668 dev_err(&i2c->dev, "Failed to read: %d\n", ret); in max9867_i2c_probe()
671 dev_info(&i2c->dev, "device revision: %x\n", reg); in max9867_i2c_probe()
672 ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component, in max9867_i2c_probe()
675 dev_err(&i2c->dev, "Failed to register component: %d\n", ret); in max9867_i2c_probe()
679 max9867->mclk = devm_clk_get(&i2c->dev, NULL); in max9867_i2c_probe()
680 if (IS_ERR(max9867->mclk)) in max9867_i2c_probe()
681 return PTR_ERR(max9867->mclk); in max9867_i2c_probe()
711 MODULE_AUTHOR("Ladislav Michl <ladis@linux-mips.org>");