lkml.org 
[lkml]   [2021]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] ALSA: hda/cirrus: Add Headphone and Headset MIC Volume Control
On Wed, 03 Mar 2021 19:29:59 +0100,
Vitaly Rodionov wrote:
>
> +static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
> + hda_nid_t nid = get_amp_nid(kcontrol);
> + int chs = get_amp_channels(kcontrol);
> + long *valp = ucontrol->value.integer.value;
> + char vol = 0;
> +
> + codec_dbg(codec, "%s() nid: %d\n", __func__, nid);
> + snd_hda_power_up(codec);
> + switch (nid) {
> + case CS8409_CS42L42_HP_PIN_NID:
> + mutex_lock(&cs8409_i2c_mux);
> + if (chs & 1) {
> + vol = -(cs8409_i2c_read(codec, CS42L42_I2C_ADDR,
> + CS8409_CS42L42_REG_HS_VOLUME_CHA, 1));

Better to cache the values instead of i2c read at each time?
Then the unnecessary power up/down sequence can be avoided, too.


thanks,

Takashi

\
 
 \ /
  Last update: 2021-03-04 14:52    [W:0.073 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site