Commit 51cdc8b6 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: hda: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 841bdb7c
...@@ -1493,10 +1493,10 @@ static void get_ctl_amp_tlv(struct snd_kcontrol *kcontrol, unsigned int *tlv) ...@@ -1493,10 +1493,10 @@ static void get_ctl_amp_tlv(struct snd_kcontrol *kcontrol, unsigned int *tlv)
val1 = ((int)val1) * ((int)val2); val1 = ((int)val1) * ((int)val2);
if (min_mute || (caps & AC_AMPCAP_MIN_MUTE)) if (min_mute || (caps & AC_AMPCAP_MIN_MUTE))
val2 |= TLV_DB_SCALE_MUTE; val2 |= TLV_DB_SCALE_MUTE;
tlv[0] = SNDRV_CTL_TLVT_DB_SCALE; tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_SCALE;
tlv[1] = 2 * sizeof(unsigned int); tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
tlv[2] = val1; tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = val1;
tlv[3] = val2; tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] = val2;
} }
/** /**
...@@ -1544,10 +1544,10 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, ...@@ -1544,10 +1544,10 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
step = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT; step = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
step = (step + 1) * 25; step = (step + 1) * 25;
tlv[0] = SNDRV_CTL_TLVT_DB_SCALE; tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_SCALE;
tlv[1] = 2 * sizeof(unsigned int); tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
tlv[2] = -nums * step; tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = -nums * step;
tlv[3] = step; tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] = step;
} }
EXPORT_SYMBOL_GPL(snd_hda_set_vmaster_tlv); EXPORT_SYMBOL_GPL(snd_hda_set_vmaster_tlv);
...@@ -1845,10 +1845,10 @@ static int init_slave_0dB(struct snd_kcontrol *slave, ...@@ -1845,10 +1845,10 @@ static int init_slave_0dB(struct snd_kcontrol *slave,
} else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
tlv = kctl->tlv.p; tlv = kctl->tlv.p;
if (!tlv || tlv[0] != SNDRV_CTL_TLVT_DB_SCALE) if (!tlv || tlv[SNDRV_CTL_TLVO_TYPE] != SNDRV_CTL_TLVT_DB_SCALE)
return 0; return 0;
step = tlv[3]; step = tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP];
step &= ~TLV_DB_SCALE_MUTE; step &= ~TLV_DB_SCALE_MUTE;
if (!step) if (!step)
return 0; return 0;
...@@ -1860,7 +1860,7 @@ static int init_slave_0dB(struct snd_kcontrol *slave, ...@@ -1860,7 +1860,7 @@ static int init_slave_0dB(struct snd_kcontrol *slave,
} }
arg->step = step; arg->step = step;
val = -tlv[2] / step; val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step;
if (val > 0) { if (val > 0) {
put_kctl_with_value(slave, val); put_kctl_with_value(slave, val);
return val; return val;
......
...@@ -2065,7 +2065,7 @@ static int parse_output_paths(struct hda_codec *codec) ...@@ -2065,7 +2065,7 @@ static int parse_output_paths(struct hda_codec *codec)
snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
HDA_OUTPUT, spec->vmaster_tlv); HDA_OUTPUT, spec->vmaster_tlv);
if (spec->dac_min_mute) if (spec->dac_min_mute)
spec->vmaster_tlv[3] |= TLV_DB_SCALE_MUTE; spec->vmaster_tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] |= TLV_DB_SCALE_MUTE;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment