void update_hpvol(struct snd_soc_codec *codec) { unsigned short val; short steps; unsigned short hp_level_old; // read previous level val = snd_soc_read(codec, WM8903_ANALOGUE_OUT1_LEFT); val &= ~(WM8903_HPOUTVU_MASK); val &= ~(WM8903_HPOUTLZC_MASK); val &= ~(WM8903_HPL_MUTE_MASK); hp_level_old = val; // calculate number of steps for volume fade steps = audio_params[EP101].analog_headset_volume - hp_level_old; while (steps != 0) { if (audio_params[EP101].analog_headset_volume < hp_level_old) steps++; else steps--; write_hpvol(codec, audio_params[EP101].analog_headset_volume - steps); if (steps != 0) udelay(1000); } }
void update_hpvol(bool with_fade) { unsigned short val; unsigned short i; short steps; int hp_level_old[2]; unsigned short hp_level_registers[2] = { WM8994_LEFT_OUTPUT_VOLUME, WM8994_RIGHT_OUTPUT_VOLUME }; DECLARE_WM8994(codec); // don't affect headphone amplifier volume // when not on heapdhones or if call is active if (!is_path(HEADPHONES) || (wm8994->codec_state & CALL_ACTIVE)) return; if (!with_fade) { bypass_write_extension = true; write_hpvol(hpvol(0), hpvol(1)); bypass_write_extension = false; return; } // read previous levels for (i = 0; i < 2; i++) { val = wm8994_read(codec, hp_level_registers[i]); val &= ~(WM8994_HPOUT1_VU_MASK); val &= ~(WM8994_HPOUT1L_ZC_MASK); val &= ~(WM8994_HPOUT1L_MUTE_N_MASK); hp_level_old[i] = val + (digital_gain / 1000); if (hp_level_old[i] < 0) hp_level_old[i] = 0; if (debug_log(LOG_INFOS)) printk("wm8994_extensions: previous hp_level[%hu]: %d\n", i, hp_level_old[i]); } // calculate number of steps for volume fade steps = hp_level[0] - hp_level_old[0]; if (debug_log(LOG_INFOS)) printk("wm8994_extensions: volume change steps: %hd " "start: %hu, end: %hu\n", steps, hp_level_old[0], hp_level[0]); while (steps != 0) { if (hp_level[0] < hp_level_old[0]) steps++; else steps--; if (debug_log(LOG_INFOS)) printk("wm8994_extensions: volume: %hu\n", (hpvol(0) - steps)); bypass_write_extension = true; write_hpvol(hpvol(0) - steps, hpvol(1) - steps); bypass_write_extension = false; if (steps != 0) udelay(1000); } }