@@ -2486,6 +2486,45 @@ static int rt1320_rae_update_put(struct snd_kcontrol *kcontrol,
24862486 return 0 ;
24872487}
24882488
2489+ static int rt1320_brown_out_put (struct snd_kcontrol * kcontrol ,
2490+ struct snd_ctl_elem_value * ucontrol )
2491+ {
2492+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
2493+ struct rt1320_sdw_priv * rt1320 = snd_soc_component_get_drvdata (component );
2494+ int ret , changed = 0 ;
2495+
2496+ if (!rt1320 -> hw_init )
2497+ return 0 ;
2498+
2499+ ret = pm_runtime_resume (component -> dev );
2500+ if (ret < 0 && ret != - EACCES )
2501+ return ret ;
2502+
2503+ if (rt1320 -> brown_out != ucontrol -> value .integer .value [0 ]) {
2504+ changed = 1 ;
2505+ rt1320 -> brown_out = ucontrol -> value .integer .value [0 ];
2506+ }
2507+
2508+ if (rt1320 -> brown_out == 0 )
2509+ regmap_write (rt1320 -> regmap , 0xdb03 , 0x00 );
2510+ else
2511+ regmap_write (rt1320 -> regmap , 0xdb03 , 0xf0 );
2512+
2513+
2514+ return changed ;
2515+ }
2516+
2517+ static int rt1320_brown_out_get (struct snd_kcontrol * kcontrol ,
2518+ struct snd_ctl_elem_value * ucontrol )
2519+ {
2520+ struct snd_soc_component * component = snd_kcontrol_chip (kcontrol );
2521+ struct rt1320_sdw_priv * rt1320 = snd_soc_component_get_drvdata (component );
2522+
2523+ ucontrol -> value .integer .value [0 ] = rt1320 -> brown_out ;
2524+
2525+ return 0 ;
2526+ }
2527+
24892528static int rt1320_r0_temperature_get (struct snd_kcontrol * kcontrol ,
24902529 struct snd_ctl_elem_value * ucontrol )
24912530{
@@ -2545,6 +2584,8 @@ static const struct snd_kcontrol_new rt1320_snd_controls[] = {
25452584 rt1320_r0_temperature_get , rt1320_r0_temperature_put ),
25462585 SOC_SINGLE_EXT ("RAE Update" , SND_SOC_NOPM , 0 , 1 , 0 ,
25472586 rt1320_rae_update_get , rt1320_rae_update_put ),
2587+ SOC_SINGLE_EXT ("Brown Out Switch" , SND_SOC_NOPM , 0 , 1 , 0 ,
2588+ rt1320_brown_out_get , rt1320_brown_out_put ),
25482589};
25492590
25502591static const struct snd_kcontrol_new rt1320_spk_l_dac =
@@ -2904,6 +2945,7 @@ static int rt1320_sdw_init(struct device *dev, struct regmap *regmap,
29042945 rt1320 -> fu_dapm_mute = true;
29052946 rt1320 -> fu_mixer_mute [0 ] = rt1320 -> fu_mixer_mute [1 ] =
29062947 rt1320 -> fu_mixer_mute [2 ] = rt1320 -> fu_mixer_mute [3 ] = true;
2948+ rt1320 -> brown_out = 1 ;
29072949
29082950 INIT_WORK (& rt1320 -> load_dspfw_work , rt1320_load_dspfw_work );
29092951
0 commit comments