@@ -2148,11 +2148,10 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_read);
2148
2148
2149
2149
static int codec_amp_update (struct hda_codec * codec , hda_nid_t nid , int ch ,
2150
2150
int direction , int idx , int mask , int val ,
2151
- bool init_only )
2151
+ bool init_only , bool cache_only )
2152
2152
{
2153
2153
struct hda_amp_info * info ;
2154
2154
unsigned int caps ;
2155
- unsigned int cache_only ;
2156
2155
2157
2156
if (snd_BUG_ON (mask & ~0xff ))
2158
2157
mask &= 0xff ;
@@ -2170,7 +2169,7 @@ static int codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
2170
2169
return 0 ;
2171
2170
}
2172
2171
info -> vol [ch ] = val ;
2173
- cache_only = info -> head .dirty = codec -> cached_write ;
2172
+ info -> head .dirty |= cache_only ;
2174
2173
caps = info -> amp_caps ;
2175
2174
mutex_unlock (& codec -> hash_mutex );
2176
2175
if (!cache_only )
@@ -2194,7 +2193,8 @@ static int codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
2194
2193
int snd_hda_codec_amp_update (struct hda_codec * codec , hda_nid_t nid , int ch ,
2195
2194
int direction , int idx , int mask , int val )
2196
2195
{
2197
- return codec_amp_update (codec , nid , ch , direction , idx , mask , val , false);
2196
+ return codec_amp_update (codec , nid , ch , direction , idx , mask , val ,
2197
+ false, codec -> cached_write );
2198
2198
}
2199
2199
EXPORT_SYMBOL_GPL (snd_hda_codec_amp_update );
2200
2200
@@ -2241,7 +2241,8 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo);
2241
2241
int snd_hda_codec_amp_init (struct hda_codec * codec , hda_nid_t nid , int ch ,
2242
2242
int dir , int idx , int mask , int val )
2243
2243
{
2244
- return codec_amp_update (codec , nid , ch , dir , idx , mask , val , true);
2244
+ return codec_amp_update (codec , nid , ch , dir , idx , mask , val , true,
2245
+ codec -> cached_write );
2245
2246
}
2246
2247
EXPORT_SYMBOL_GPL (snd_hda_codec_amp_init );
2247
2248
@@ -2383,8 +2384,8 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid,
2383
2384
maxval = get_amp_max_value (codec , nid , dir , 0 );
2384
2385
if (val > maxval )
2385
2386
val = maxval ;
2386
- return snd_hda_codec_amp_update (codec , nid , ch , dir , idx ,
2387
- HDA_AMP_VOLMASK , val );
2387
+ return codec_amp_update (codec , nid , ch , dir , idx , HDA_AMP_VOLMASK , val ,
2388
+ false, ! hda_codec_is_power_on ( codec ) );
2388
2389
}
2389
2390
2390
2391
/**
@@ -2434,14 +2435,12 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
2434
2435
long * valp = ucontrol -> value .integer .value ;
2435
2436
int change = 0 ;
2436
2437
2437
- snd_hda_power_up (codec );
2438
2438
if (chs & 1 ) {
2439
2439
change = update_amp_value (codec , nid , 0 , dir , idx , ofs , * valp );
2440
2440
valp ++ ;
2441
2441
}
2442
2442
if (chs & 2 )
2443
2443
change |= update_amp_value (codec , nid , 1 , dir , idx , ofs , * valp );
2444
- snd_hda_power_down (codec );
2445
2444
return change ;
2446
2445
}
2447
2446
EXPORT_SYMBOL_GPL (snd_hda_mixer_amp_volume_put );
@@ -3109,19 +3108,19 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
3109
3108
long * valp = ucontrol -> value .integer .value ;
3110
3109
int change = 0 ;
3111
3110
3112
- snd_hda_power_up (codec );
3113
3111
if (chs & 1 ) {
3114
- change = snd_hda_codec_amp_update (codec , nid , 0 , dir , idx ,
3115
- HDA_AMP_MUTE ,
3116
- * valp ? 0 : HDA_AMP_MUTE );
3112
+ change = codec_amp_update (codec , nid , 0 , dir , idx ,
3113
+ HDA_AMP_MUTE ,
3114
+ * valp ? 0 : HDA_AMP_MUTE , false,
3115
+ !hda_codec_is_power_on (codec ));
3117
3116
valp ++ ;
3118
3117
}
3119
3118
if (chs & 2 )
3120
- change |= snd_hda_codec_amp_update (codec , nid , 1 , dir , idx ,
3121
- HDA_AMP_MUTE ,
3122
- * valp ? 0 : HDA_AMP_MUTE );
3119
+ change |= codec_amp_update (codec , nid , 1 , dir , idx ,
3120
+ HDA_AMP_MUTE ,
3121
+ * valp ? 0 : HDA_AMP_MUTE , false,
3122
+ !hda_codec_is_power_on (codec ));
3123
3123
hda_call_check_power_status (codec , nid );
3124
- snd_hda_power_down (codec );
3125
3124
return change ;
3126
3125
}
3127
3126
EXPORT_SYMBOL_GPL (snd_hda_mixer_amp_switch_put );
0 commit comments