Lines Matching full:ak4458

3 // Audio driver for AK4458 DAC
23 #include "ak4458.h"
32 AK4458 = 0, enumerator
42 /* AK4458 Codec Private Data */
191 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in get_digfil() local
193 ucontrol->value.enumerated.item[0] = ak4458->digfil; in get_digfil()
202 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in set_digfil() local
209 ak4458->digfil = num; in set_digfil()
214 ((ak4458->digfil & 0x02) << 4)); in set_digfil()
219 (ak4458->digfil & 0x01)); in set_digfil()
224 ((ak4458->digfil & 0x04) >> 2)); in set_digfil()
238 SOC_ENUM("AK4458 De-emphasis Response DAC1", ak4458_dac1_dem_enum),
239 SOC_ENUM("AK4458 De-emphasis Response DAC2", ak4458_dac2_dem_enum),
240 SOC_ENUM("AK4458 De-emphasis Response DAC3", ak4458_dac3_dem_enum),
241 SOC_ENUM("AK4458 De-emphasis Response DAC4", ak4458_dac4_dem_enum),
242 SOC_ENUM_EXT("AK4458 Digital Filter Setting", ak4458_digfil_enum,
244 SOC_ENUM("AK4458 Inverting Enable of DZFB", ak4458_dzfb_enum),
245 SOC_ENUM("AK4458 Sound Mode", ak4458_sm_enum),
246 SOC_ENUM("AK4458 FIR Filter Mode Setting", ak4458_fir_enum),
247 SOC_ENUM("AK4458 Attenuation transition Time Setting",
249 SOC_ENUM("AK4458 BICK fs Setting", ak4458_dif_enum),
252 /* ak4458 dapm widgets */
254 SND_SOC_DAPM_DAC("AK4458 DAC1", NULL, AK4458_0A_CONTROL6, 2, 0),/*pw*/
255 SND_SOC_DAPM_AIF_IN("AK4458 SDTI", "Playback", 0, SND_SOC_NOPM, 0, 0),
256 SND_SOC_DAPM_OUTPUT("AK4458 AOUTA"),
258 SND_SOC_DAPM_DAC("AK4458 DAC2", NULL, AK4458_0A_CONTROL6, 3, 0),/*pw*/
259 SND_SOC_DAPM_OUTPUT("AK4458 AOUTB"),
261 SND_SOC_DAPM_DAC("AK4458 DAC3", NULL, AK4458_0B_CONTROL7, 2, 0),/*pw*/
262 SND_SOC_DAPM_OUTPUT("AK4458 AOUTC"),
264 SND_SOC_DAPM_DAC("AK4458 DAC4", NULL, AK4458_0B_CONTROL7, 3, 0),/*pw*/
265 SND_SOC_DAPM_OUTPUT("AK4458 AOUTD"),
269 {"AK4458 DAC1", NULL, "AK4458 SDTI"},
270 {"AK4458 AOUTA", NULL, "AK4458 DAC1"},
272 {"AK4458 DAC2", NULL, "AK4458 SDTI"},
273 {"AK4458 AOUTB", NULL, "AK4458 DAC2"},
275 {"AK4458 DAC3", NULL, "AK4458 SDTI"},
276 {"AK4458 AOUTC", NULL, "AK4458 DAC3"},
278 {"AK4458 DAC4", NULL, "AK4458 SDTI"},
279 {"AK4458 AOUTD", NULL, "AK4458 DAC4"},
309 static int ak4458_get_tdm_mode(struct ak4458_priv *ak4458) in ak4458_get_tdm_mode() argument
311 switch (ak4458->slots * ak4458->slot_width) { in ak4458_get_tdm_mode()
348 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in ak4458_hw_params() local
349 int pcm_width = max(params_physical_width(params), ak4458->slot_width); in ak4458_hw_params()
354 ak4458->fs = nfs1; in ak4458_hw_params()
381 if (ak4458->drvdata->type == AK4497) { in ak4458_hw_params()
406 if (ak4458->fmt == SND_SOC_DAIFMT_I2S) in ak4458_hw_params()
412 switch (ak4458->fmt) { in ak4458_hw_params()
443 dchn = ak4458_get_tdm_mode(ak4458) && in ak4458_hw_params()
444 (ak4458->fmt == SND_SOC_DAIFMT_DSP_B) && in ak4458_hw_params()
450 if (ak4458->drvdata->type == AK4497) { in ak4458_hw_params()
452 0x4, (ak4458->dsd_path << 2)); in ak4458_hw_params()
471 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in ak4458_set_dai_fmt() local
491 ak4458->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in ak4458_set_dai_fmt()
502 ak4458->fmt == SND_SOC_DAIFMT_PDM ? in ak4458_set_dai_fmt()
521 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in ak4458_set_dai_mute() local
525 nfs = ak4458->fs; in ak4458_set_dai_mute()
535 if (ak4458->mute_gpiod) in ak4458_set_dai_mute()
536 gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); in ak4458_set_dai_mute()
538 if (ak4458->mute_gpiod) in ak4458_set_dai_mute()
539 gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); in ak4458_set_dai_mute()
551 struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); in ak4458_set_tdm_slot() local
554 ak4458->slots = slots; in ak4458_set_tdm_slot()
555 ak4458->slot_width = slot_width; in ak4458_set_tdm_slot()
557 mode = ak4458_get_tdm_mode(ak4458) << AK4458_MODE_SHIFT; in ak4458_set_tdm_slot()
608 .name = "ak4458-aif",
631 static void ak4458_reset(struct ak4458_priv *ak4458, bool active) in ak4458_reset() argument
633 if (!IS_ERR_OR_NULL(ak4458->reset)) { in ak4458_reset()
635 reset_control_assert(ak4458->reset); in ak4458_reset()
637 reset_control_deassert(ak4458->reset); in ak4458_reset()
645 struct ak4458_priv *ak4458 = dev_get_drvdata(dev); in ak4458_runtime_suspend() local
647 regcache_cache_only(ak4458->regmap, true); in ak4458_runtime_suspend()
649 ak4458_reset(ak4458, true); in ak4458_runtime_suspend()
651 if (ak4458->mute_gpiod) in ak4458_runtime_suspend()
652 gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); in ak4458_runtime_suspend()
654 regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), in ak4458_runtime_suspend()
655 ak4458->supplies); in ak4458_runtime_suspend()
661 struct ak4458_priv *ak4458 = dev_get_drvdata(dev); in ak4458_runtime_resume() local
664 ret = regulator_bulk_enable(ARRAY_SIZE(ak4458->supplies), in ak4458_runtime_resume()
665 ak4458->supplies); in ak4458_runtime_resume()
667 dev_err(ak4458->dev, "Failed to enable supplies: %d\n", ret); in ak4458_runtime_resume()
671 if (ak4458->mute_gpiod) in ak4458_runtime_resume()
672 gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); in ak4458_runtime_resume()
674 ak4458_reset(ak4458, false); in ak4458_runtime_resume()
676 regcache_cache_only(ak4458->regmap, false); in ak4458_runtime_resume()
677 regcache_mark_dirty(ak4458->regmap); in ak4458_runtime_resume()
679 return regcache_sync(ak4458->regmap); in ak4458_runtime_resume()
720 .type = AK4458,
737 struct ak4458_priv *ak4458; in ak4458_i2c_probe() local
740 ak4458 = devm_kzalloc(&i2c->dev, sizeof(*ak4458), GFP_KERNEL); in ak4458_i2c_probe()
741 if (!ak4458) in ak4458_i2c_probe()
744 ak4458->regmap = devm_regmap_init_i2c(i2c, &ak4458_regmap); in ak4458_i2c_probe()
745 if (IS_ERR(ak4458->regmap)) in ak4458_i2c_probe()
746 return PTR_ERR(ak4458->regmap); in ak4458_i2c_probe()
748 i2c_set_clientdata(i2c, ak4458); in ak4458_i2c_probe()
749 ak4458->dev = &i2c->dev; in ak4458_i2c_probe()
751 ak4458->drvdata = of_device_get_match_data(&i2c->dev); in ak4458_i2c_probe()
753 ak4458->reset = devm_reset_control_get_optional_shared(ak4458->dev, NULL); in ak4458_i2c_probe()
754 if (IS_ERR(ak4458->reset)) in ak4458_i2c_probe()
755 return PTR_ERR(ak4458->reset); in ak4458_i2c_probe()
757 ak4458->mute_gpiod = devm_gpiod_get_optional(ak4458->dev, "mute", in ak4458_i2c_probe()
759 if (IS_ERR(ak4458->mute_gpiod)) in ak4458_i2c_probe()
760 return PTR_ERR(ak4458->mute_gpiod); in ak4458_i2c_probe()
763 of_property_read_u32(i2c->dev.of_node, "dsd-path", &ak4458->dsd_path); in ak4458_i2c_probe()
765 for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++) in ak4458_i2c_probe()
766 ak4458->supplies[i].supply = ak4458_supply_names[i]; in ak4458_i2c_probe()
768 ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies), in ak4458_i2c_probe()
769 ak4458->supplies); in ak4458_i2c_probe()
771 dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret); in ak4458_i2c_probe()
775 ret = devm_snd_soc_register_component(ak4458->dev, in ak4458_i2c_probe()
776 ak4458->drvdata->comp_drv, in ak4458_i2c_probe()
777 ak4458->drvdata->dai_drv, 1); in ak4458_i2c_probe()
779 dev_err(ak4458->dev, "Failed to register CODEC: %d\n", ret); in ak4458_i2c_probe()
784 regcache_cache_only(ak4458->regmap, true); in ak4458_i2c_probe()
785 ak4458_reset(ak4458, false); in ak4458_i2c_probe()
792 struct ak4458_priv *ak4458 = i2c_get_clientdata(i2c); in ak4458_i2c_remove() local
794 ak4458_reset(ak4458, true); in ak4458_i2c_remove()
799 { .compatible = "asahi-kasei,ak4458", .data = &ak4458_drvdata},
807 .name = "ak4458",
819 MODULE_DESCRIPTION("ASoC AK4458 DAC driver");