Lines Matching +full:switch +full:- +full:freq +full:- +full:select
1 // SPDX-License-Identifier: GPL-2.0-only
3 // rt1019.c -- RT1019 ALSA SoC audio amplifier driver
26 #include <sound/soc-dapm.h>
62 switch (reg) { in rt1019_volatile_register()
78 switch (reg) { in rt1019_readable_register()
109 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9525, 75, 0);
123 SOC_ENUM("Mono LR Select", rt1019_mono_lr_sel),
129 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in r1019_dac_event()
131 switch (event) { in r1019_dac_event()
160 struct snd_soc_component *component = dai->component; in rt1019_hw_params()
167 rt1019->lrck = params_rate(params); in rt1019_hw_params()
168 pre_div = rl6231_get_clk_info(rt1019->sysclk, rt1019->lrck); in rt1019_hw_params()
170 dev_err(component->dev, "Unsupported clock setting\n"); in rt1019_hw_params()
171 return -EINVAL; in rt1019_hw_params()
176 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt1019_hw_params()
177 return -EINVAL; in rt1019_hw_params()
181 rt1019->bclk = rt1019->lrck * (32 << bclk_ms); in rt1019_hw_params()
183 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt1019_hw_params()
184 rt1019->bclk, rt1019->lrck); in rt1019_hw_params()
185 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt1019_hw_params()
186 bclk_ms, pre_div, dai->id); in rt1019_hw_params()
188 switch (pre_div) { in rt1019_hw_params()
211 return -EINVAL; in rt1019_hw_params()
214 switch (params_width(params)) { in rt1019_hw_params()
230 return -EINVAL; in rt1019_hw_params()
249 struct snd_soc_component *component = dai->component; in rt1019_set_dai_fmt()
252 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in rt1019_set_dai_fmt()
259 return -EINVAL; in rt1019_set_dai_fmt()
262 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in rt1019_set_dai_fmt()
279 return -EINVAL; in rt1019_set_dai_fmt()
291 int clk_id, unsigned int freq, int dir) in rt1019_set_dai_sysclk() argument
293 struct snd_soc_component *component = dai->component; in rt1019_set_dai_sysclk()
297 if (freq == rt1019->sysclk && clk_id == rt1019->sysclk_src) in rt1019_set_dai_sysclk()
300 switch (clk_id) { in rt1019_set_dai_sysclk()
310 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt1019_set_dai_sysclk()
311 return -EINVAL; in rt1019_set_dai_sysclk()
314 rt1019->sysclk = freq; in rt1019_set_dai_sysclk()
315 rt1019->sysclk_src = clk_id; in rt1019_set_dai_sysclk()
317 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt1019_set_dai_sysclk()
328 struct snd_soc_component *component = dai->component; in rt1019_set_dai_pll()
334 dev_dbg(component->dev, "PLL disabled\n"); in rt1019_set_dai_pll()
335 rt1019->pll_in = 0; in rt1019_set_dai_pll()
336 rt1019->pll_out = 0; in rt1019_set_dai_pll()
340 if (source == rt1019->pll_src && freq_in == rt1019->pll_in && in rt1019_set_dai_pll()
341 freq_out == rt1019->pll_out) in rt1019_set_dai_pll()
344 switch (source) { in rt1019_set_dai_pll()
356 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt1019_set_dai_pll()
357 return -EINVAL; in rt1019_set_dai_pll()
362 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt1019_set_dai_pll()
366 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt1019_set_dai_pll()
383 rt1019->pll_in = freq_in; in rt1019_set_dai_pll()
384 rt1019->pll_out = freq_out; in rt1019_set_dai_pll()
385 rt1019->pll_src = source; in rt1019_set_dai_pll()
393 struct snd_soc_component *component = dai->component; in rt1019_set_tdm_slot()
397 switch (slots) { in rt1019_set_tdm_slot()
410 return -EINVAL; in rt1019_set_tdm_slot()
413 switch (slot_width) { in rt1019_set_tdm_slot()
429 return -EINVAL; in rt1019_set_tdm_slot()
435 ret = -EINVAL; in rt1019_set_tdm_slot()
436 dev_err(component->dev, "too many rx slots or zero slot\n"); in rt1019_set_tdm_slot()
441 * as the starting slot. The users could select the channel from in rt1019_set_tdm_slot()
442 * L/R/L+R by "Mono LR Select" control. in rt1019_set_tdm_slot()
445 switch (first_bit) { in rt1019_set_tdm_slot()
465 ((first_bit - 1) << RT1019_TDM_I2S_TX_L_DAC1_1_SFT) | in rt1019_set_tdm_slot()
469 ret = -EINVAL; in rt1019_set_tdm_slot()
486 rt1019->component = component; in rt1019_probe()
506 .name = "rt1019-aif",
569 rt1019 = devm_kzalloc(&i2c->dev, sizeof(struct rt1019_priv), in rt1019_i2c_probe()
572 return -ENOMEM; in rt1019_i2c_probe()
576 rt1019->regmap = devm_regmap_init_i2c(i2c, &rt1019_regmap); in rt1019_i2c_probe()
577 if (IS_ERR(rt1019->regmap)) { in rt1019_i2c_probe()
578 ret = PTR_ERR(rt1019->regmap); in rt1019_i2c_probe()
579 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt1019_i2c_probe()
584 regmap_read(rt1019->regmap, RT1019_DEV_ID_1, &val); in rt1019_i2c_probe()
585 regmap_read(rt1019->regmap, RT1019_DEV_ID_2, &val2); in rt1019_i2c_probe()
588 dev_err(&i2c->dev, in rt1019_i2c_probe()
590 return -ENODEV; in rt1019_i2c_probe()
593 return devm_snd_soc_register_component(&i2c->dev, in rt1019_i2c_probe()