Lines Matching full:mvc

3 // tegra210_mvc.c - Tegra210 MVC driver
53 struct tegra210_mvc *mvc = dev_get_drvdata(dev); in tegra210_mvc_runtime_suspend() local
55 regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &(mvc->ctrl_value)); in tegra210_mvc_runtime_suspend()
57 regcache_cache_only(mvc->regmap, true); in tegra210_mvc_runtime_suspend()
58 regcache_mark_dirty(mvc->regmap); in tegra210_mvc_runtime_suspend()
65 struct tegra210_mvc *mvc = dev_get_drvdata(dev); in tegra210_mvc_runtime_resume() local
67 regcache_cache_only(mvc->regmap, false); in tegra210_mvc_runtime_resume()
68 regcache_sync(mvc->regmap); in tegra210_mvc_runtime_resume()
70 regmap_write(mvc->regmap, TEGRA210_MVC_CTRL, mvc->ctrl_value); in tegra210_mvc_runtime_resume()
71 regmap_update_bits(mvc->regmap, in tegra210_mvc_runtime_resume()
93 static void tegra210_mvc_conv_vol(struct tegra210_mvc *mvc, u8 chan, s32 val) in tegra210_mvc_conv_vol() argument
101 if (mvc->curve_type == CURVE_POLY) { in tegra210_mvc_conv_vol()
104 mvc->volume[chan] = ((val * (1<<8)) / 100) << 16; in tegra210_mvc_conv_vol()
107 mvc->volume[chan] = (val * (1<<8)) / 100; in tegra210_mvc_conv_vol()
114 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_get_ctrl_reg() local
118 regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &val); in tegra210_mvc_get_ctrl_reg()
179 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_volume_switch_timeout() local
183 err = regmap_read_poll_timeout(mvc->regmap, TEGRA210_MVC_SWITCH, in tegra210_mvc_volume_switch_timeout()
199 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_update_mute() local
220 regmap_update_bits_check(mvc->regmap, TEGRA210_MVC_CTRL, in tegra210_mvc_update_mute()
226 regmap_update_bits(mvc->regmap, TEGRA210_MVC_CTRL, in tegra210_mvc_update_mute()
230 regmap_update_bits(mvc->regmap, TEGRA210_MVC_SWITCH, in tegra210_mvc_update_mute()
265 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_get_vol() local
267 s32 val = mvc->volume[chan]; in tegra210_mvc_get_vol()
269 if (mvc->curve_type == CURVE_POLY) { in tegra210_mvc_get_vol()
294 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_update_vol() local
296 int old_volume = mvc->volume[chan]; in tegra210_mvc_update_vol()
305 tegra210_mvc_conv_vol(mvc, chan, ucontrol->value.integer.value[0]); in tegra210_mvc_update_vol()
307 if (mvc->volume[chan] == old_volume) { in tegra210_mvc_update_vol()
313 regmap_update_bits(mvc->regmap, TEGRA210_MVC_CTRL, in tegra210_mvc_update_vol()
317 regmap_update_bits(mvc->regmap, TEGRA210_MVC_CTRL, in tegra210_mvc_update_vol()
321 mvc->volume[i] = mvc->volume[chan]; in tegra210_mvc_update_vol()
325 regmap_write(mvc->regmap, in tegra210_mvc_update_vol()
327 mvc->volume[chan]); in tegra210_mvc_update_vol()
329 regmap_write(mvc->regmap, mc->reg, mvc->volume[chan]); in tegra210_mvc_update_vol()
331 regmap_update_bits(mvc->regmap, TEGRA210_MVC_SWITCH, in tegra210_mvc_update_vol()
355 static void tegra210_mvc_reset_vol_settings(struct tegra210_mvc *mvc, in tegra210_mvc_reset_vol_settings() argument
361 if (mvc->curve_type == CURVE_POLY) { in tegra210_mvc_reset_vol_settings()
363 mvc->volume[i] = TEGRA210_MVC_INIT_VOL_DEFAULT_POLY; in tegra210_mvc_reset_vol_settings()
366 mvc->volume[i] = TEGRA210_MVC_INIT_VOL_DEFAULT_LINEAR; in tegra210_mvc_reset_vol_settings()
372 regmap_update_bits(mvc->regmap, TEGRA210_MVC_CTRL, in tegra210_mvc_reset_vol_settings()
374 mvc->curve_type << in tegra210_mvc_reset_vol_settings()
379 regmap_write(mvc->regmap, in tegra210_mvc_reset_vol_settings()
381 mvc->volume[i]); in tegra210_mvc_reset_vol_settings()
382 regmap_write(mvc->regmap, in tegra210_mvc_reset_vol_settings()
384 mvc->volume[i]); in tegra210_mvc_reset_vol_settings()
388 regmap_update_bits(mvc->regmap, TEGRA210_MVC_SWITCH, in tegra210_mvc_reset_vol_settings()
399 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_get_curve_type() local
401 ucontrol->value.enumerated.item[0] = mvc->curve_type; in tegra210_mvc_get_curve_type()
410 struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt); in tegra210_mvc_put_curve_type() local
413 regmap_read(mvc->regmap, TEGRA210_MVC_ENABLE, &value); in tegra210_mvc_put_curve_type()
416 "Curve type can't be set when MVC is running\n"); in tegra210_mvc_put_curve_type()
420 if (mvc->curve_type == ucontrol->value.enumerated.item[0]) in tegra210_mvc_put_curve_type()
423 mvc->curve_type = ucontrol->value.enumerated.item[0]; in tegra210_mvc_put_curve_type()
425 tegra210_mvc_reset_vol_settings(mvc, cmpnt->dev); in tegra210_mvc_put_curve_type()
430 static int tegra210_mvc_set_audio_cif(struct tegra210_mvc *mvc, in tegra210_mvc_set_audio_cif() argument
457 tegra_set_cif(mvc->regmap, reg, &cif_conf); in tegra210_mvc_set_audio_cif()
467 struct tegra210_mvc *mvc = snd_soc_dai_get_drvdata(dai); in tegra210_mvc_hw_params() local
476 regmap_write(mvc->regmap, TEGRA210_MVC_SOFT_RESET, 1); in tegra210_mvc_hw_params()
478 err = regmap_read_poll_timeout(mvc->regmap, TEGRA210_MVC_SOFT_RESET, in tegra210_mvc_hw_params()
486 err = tegra210_mvc_set_audio_cif(mvc, params, TEGRA210_MVC_RX_CIF_CTRL); in tegra210_mvc_hw_params()
488 dev_err(dev, "Can't set MVC RX CIF: %d\n", err); in tegra210_mvc_hw_params()
493 err = tegra210_mvc_set_audio_cif(mvc, params, TEGRA210_MVC_TX_CIF_CTRL); in tegra210_mvc_hw_params()
495 dev_err(dev, "Can't set MVC TX CIF: %d\n", err); in tegra210_mvc_hw_params()
499 tegra210_mvc_write_ram(mvc->regmap); in tegra210_mvc_hw_params()
502 regmap_write(mvc->regmap, TEGRA210_MVC_POLY_N1, gain_params.poly_n1); in tegra210_mvc_hw_params()
503 regmap_write(mvc->regmap, TEGRA210_MVC_POLY_N2, gain_params.poly_n2); in tegra210_mvc_hw_params()
504 regmap_write(mvc->regmap, TEGRA210_MVC_DURATION, gain_params.duration); in tegra210_mvc_hw_params()
507 regmap_write(mvc->regmap, TEGRA210_MVC_DURATION_INV, in tegra210_mvc_hw_params()
565 .name = "MVC-RX-CIF",
588 .name = "MVC-TX-CIF",
702 { .compatible = "nvidia,tegra210-mvc" },
710 struct tegra210_mvc *mvc; in tegra210_mvc_platform_probe() local
714 mvc = devm_kzalloc(dev, sizeof(*mvc), GFP_KERNEL); in tegra210_mvc_platform_probe()
715 if (!mvc) in tegra210_mvc_platform_probe()
718 dev_set_drvdata(dev, mvc); in tegra210_mvc_platform_probe()
720 mvc->curve_type = CURVE_LINEAR; in tegra210_mvc_platform_probe()
721 mvc->ctrl_value = TEGRA210_MVC_CTRL_DEFAULT; in tegra210_mvc_platform_probe()
727 mvc->regmap = devm_regmap_init_mmio(dev, regs, in tegra210_mvc_platform_probe()
729 if (IS_ERR(mvc->regmap)) { in tegra210_mvc_platform_probe()
731 return PTR_ERR(mvc->regmap); in tegra210_mvc_platform_probe()
734 regcache_cache_only(mvc->regmap, true); in tegra210_mvc_platform_probe()
740 dev_err(dev, "can't register MVC component, err: %d\n", err); in tegra210_mvc_platform_probe()
746 tegra210_mvc_reset_vol_settings(mvc, &pdev->dev); in tegra210_mvc_platform_probe()
765 .name = "tegra210-mvc",
775 MODULE_DESCRIPTION("Tegra210 MVC ASoC driver");