@@ -762,10 +762,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
762
762
return 0 ;
763
763
764
764
trace_hda_unsol_event (bus , res , res_ex );
765
- unsol = bus -> unsol ;
766
- if (!unsol )
767
- return 0 ;
768
-
765
+ unsol = & bus -> unsol ;
769
766
wp = (unsol -> wp + 1 ) % HDA_UNSOL_QUEUE_SIZE ;
770
767
unsol -> wp = wp ;
771
768
@@ -784,9 +781,8 @@ EXPORT_SYMBOL_GPL(snd_hda_queue_unsol_event);
784
781
*/
785
782
static void process_unsol_events (struct work_struct * work )
786
783
{
787
- struct hda_bus_unsolicited * unsol =
788
- container_of (work , struct hda_bus_unsolicited , work );
789
- struct hda_bus * bus = unsol -> bus ;
784
+ struct hda_bus * bus = container_of (work , struct hda_bus , unsol .work );
785
+ struct hda_bus_unsolicited * unsol = & bus -> unsol ;
790
786
struct hda_codec * codec ;
791
787
unsigned int rp , caddr , res ;
792
788
@@ -804,27 +800,6 @@ static void process_unsol_events(struct work_struct *work)
804
800
}
805
801
}
806
802
807
- /*
808
- * initialize unsolicited queue
809
- */
810
- static int init_unsol_queue (struct hda_bus * bus )
811
- {
812
- struct hda_bus_unsolicited * unsol ;
813
-
814
- if (bus -> unsol ) /* already initialized */
815
- return 0 ;
816
-
817
- unsol = kzalloc (sizeof (* unsol ), GFP_KERNEL );
818
- if (!unsol ) {
819
- dev_err (bus -> card -> dev , "can't allocate unsolicited queue\n" );
820
- return - ENOMEM ;
821
- }
822
- INIT_WORK (& unsol -> work , process_unsol_events );
823
- unsol -> bus = bus ;
824
- bus -> unsol = unsol ;
825
- return 0 ;
826
- }
827
-
828
803
/*
829
804
* destructor
830
805
*/
@@ -836,7 +811,6 @@ static void snd_hda_bus_free(struct hda_bus *bus)
836
811
WARN_ON (!list_empty (& bus -> codec_list ));
837
812
if (bus -> workq )
838
813
flush_workqueue (bus -> workq );
839
- kfree (bus -> unsol );
840
814
if (bus -> ops .private_free )
841
815
bus -> ops .private_free (bus );
842
816
if (bus -> workq )
@@ -861,14 +835,12 @@ static int snd_hda_bus_dev_disconnect(struct snd_device *device)
861
835
/**
862
836
* snd_hda_bus_new - create a HDA bus
863
837
* @card: the card entry
864
- * @temp: the template for hda_bus information
865
838
* @busp: the pointer to store the created bus instance
866
839
*
867
840
* Returns 0 if successful, or a negative error code.
868
841
*/
869
842
int snd_hda_bus_new (struct snd_card * card ,
870
- const struct hda_bus_template * temp ,
871
- struct hda_bus * * busp )
843
+ struct hda_bus * * busp )
872
844
{
873
845
struct hda_bus * bus ;
874
846
int err ;
@@ -877,11 +849,6 @@ int snd_hda_bus_new(struct snd_card *card,
877
849
.dev_free = snd_hda_bus_dev_free ,
878
850
};
879
851
880
- if (snd_BUG_ON (!temp ))
881
- return - EINVAL ;
882
- if (snd_BUG_ON (!temp -> ops .command || !temp -> ops .get_response ))
883
- return - EINVAL ;
884
-
885
852
if (busp )
886
853
* busp = NULL ;
887
854
@@ -892,15 +859,10 @@ int snd_hda_bus_new(struct snd_card *card,
892
859
}
893
860
894
861
bus -> card = card ;
895
- bus -> private_data = temp -> private_data ;
896
- bus -> pci = temp -> pci ;
897
- bus -> modelname = temp -> modelname ;
898
- bus -> power_save = temp -> power_save ;
899
- bus -> ops = temp -> ops ;
900
-
901
862
mutex_init (& bus -> cmd_mutex );
902
863
mutex_init (& bus -> prepare_mutex );
903
864
INIT_LIST_HEAD (& bus -> codec_list );
865
+ INIT_WORK (& bus -> unsol .work , process_unsol_events );
904
866
905
867
snprintf (bus -> workq_name , sizeof (bus -> workq_name ),
906
868
"hd-audio%d" , card -> number );
@@ -1702,12 +1664,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
1702
1664
return err ;
1703
1665
}
1704
1666
1705
- if (codec -> patch_ops .unsol_event ) {
1706
- err = init_unsol_queue (codec -> bus );
1707
- if (err < 0 )
1708
- return err ;
1709
- }
1710
-
1711
1667
/* audio codec should override the mixer name */
1712
1668
if (codec -> afg || !* codec -> bus -> card -> mixername )
1713
1669
snprintf (codec -> bus -> card -> mixername ,
@@ -2192,11 +2148,10 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_read);
2192
2148
2193
2149
static int codec_amp_update (struct hda_codec * codec , hda_nid_t nid , int ch ,
2194
2150
int direction , int idx , int mask , int val ,
2195
- bool init_only )
2151
+ bool init_only , bool cache_only )
2196
2152
{
2197
2153
struct hda_amp_info * info ;
2198
2154
unsigned int caps ;
2199
- unsigned int cache_only ;
2200
2155
2201
2156
if (snd_BUG_ON (mask & ~0xff ))
2202
2157
mask &= 0xff ;
@@ -2214,7 +2169,7 @@ static int codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
2214
2169
return 0 ;
2215
2170
}
2216
2171
info -> vol [ch ] = val ;
2217
- cache_only = info -> head .dirty = codec -> cached_write ;
2172
+ info -> head .dirty |= cache_only ;
2218
2173
caps = info -> amp_caps ;
2219
2174
mutex_unlock (& codec -> hash_mutex );
2220
2175
if (!cache_only )
@@ -2238,7 +2193,8 @@ static int codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
2238
2193
int snd_hda_codec_amp_update (struct hda_codec * codec , hda_nid_t nid , int ch ,
2239
2194
int direction , int idx , int mask , int val )
2240
2195
{
2241
- 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 );
2242
2198
}
2243
2199
EXPORT_SYMBOL_GPL (snd_hda_codec_amp_update );
2244
2200
@@ -2285,7 +2241,8 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo);
2285
2241
int snd_hda_codec_amp_init (struct hda_codec * codec , hda_nid_t nid , int ch ,
2286
2242
int dir , int idx , int mask , int val )
2287
2243
{
2288
- 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 );
2289
2246
}
2290
2247
EXPORT_SYMBOL_GPL (snd_hda_codec_amp_init );
2291
2248
@@ -2427,8 +2384,8 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid,
2427
2384
maxval = get_amp_max_value (codec , nid , dir , 0 );
2428
2385
if (val > maxval )
2429
2386
val = maxval ;
2430
- return snd_hda_codec_amp_update (codec , nid , ch , dir , idx ,
2431
- 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 ) );
2432
2389
}
2433
2390
2434
2391
/**
@@ -2478,14 +2435,12 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
2478
2435
long * valp = ucontrol -> value .integer .value ;
2479
2436
int change = 0 ;
2480
2437
2481
- snd_hda_power_up (codec );
2482
2438
if (chs & 1 ) {
2483
2439
change = update_amp_value (codec , nid , 0 , dir , idx , ofs , * valp );
2484
2440
valp ++ ;
2485
2441
}
2486
2442
if (chs & 2 )
2487
2443
change |= update_amp_value (codec , nid , 1 , dir , idx , ofs , * valp );
2488
- snd_hda_power_down (codec );
2489
2444
return change ;
2490
2445
}
2491
2446
EXPORT_SYMBOL_GPL (snd_hda_mixer_amp_volume_put );
@@ -3153,19 +3108,19 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
3153
3108
long * valp = ucontrol -> value .integer .value ;
3154
3109
int change = 0 ;
3155
3110
3156
- snd_hda_power_up (codec );
3157
3111
if (chs & 1 ) {
3158
- change = snd_hda_codec_amp_update (codec , nid , 0 , dir , idx ,
3159
- HDA_AMP_MUTE ,
3160
- * 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 ));
3161
3116
valp ++ ;
3162
3117
}
3163
3118
if (chs & 2 )
3164
- change |= snd_hda_codec_amp_update (codec , nid , 1 , dir , idx ,
3165
- HDA_AMP_MUTE ,
3166
- * 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 ));
3167
3123
hda_call_check_power_status (codec , nid );
3168
- snd_hda_power_down (codec );
3169
3124
return change ;
3170
3125
}
3171
3126
EXPORT_SYMBOL_GPL (snd_hda_mixer_amp_switch_put );
0 commit comments