ALSA: hda: Cleanups aboug GPIO handling code
Subsystems (2)
cover ALSA: hda: Cleanups aboug GPIO handling code
Hi,
this is a series of cleanup patches for the GPIO verb handlings in HD-audio codec drivers. Supposed to be no behavior change but only the code refactoring / cleanup.
Takashi
===
Takashi Iwai (10):
ALSA: hda: Add sync version of snd_hda_codec_write()
ALSA: hda: Add a simple GPIO setup helper function
ALSA: hda/realtek: Clean up with snd_hda_codec_set_gpio()
ALSA: hda/alc662: Simplify the quirk for CSL Unity BF24B
ALSA: hda/analog: Fix GPIO verb orders
ALSA: hda/sigmatel: Clean up with the new GPIO helper
ALSA: hda/ca0132: Clean up with the new GPIO helper
ALSA: hda/cirrus: Clean up with the new GPIO helper
ALSA: hda/conexant: Clean up with the new GPIO helper
ALSA: hda/senarytech: Clean up with the new GPIO helper
include/sound/hda_codec.h | 15 +++++++++++ sound/hda/codecs/analog.c | 18 +++++++------- sound/hda/codecs/ca0132.c | 14 ++--------- sound/hda/codecs/cirrus/cs420x.c | 11 +++----- sound/hda/codecs/cirrus/cs421x.c | 11 +++----- sound/hda/codecs/cirrus/cs8409.c | 22 +++++----------- sound/hda/codecs/conexant.c | 14 +++-------- sound/hda/codecs/generic.c | 2 +- sound/hda/codecs/hdmi/intelhdmi.c | 2 +- sound/hda/codecs/realtek/alc662.c | 14 +++-------- sound/hda/codecs/realtek/realtek.c | 16 ++++-------- sound/hda/codecs/realtek/realtek.h | 1 - sound/hda/codecs/senarytech.c | 10 ++------ sound/hda/codecs/sigmatel.c | 10 +------- sound/hda/common/codec.c | 40 +++++++++++++++++++++++++----- 15 files changed, 88 insertions(+), 112 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/10 ALSA: hda: Add sync version of snd_hda_codec_write()
We used snd_hda_codec_read() for the verb write when a synchronization is needed after the write, e.g. for the power state toggle or such cases. It works in principle, but it looks rather confusing and too hackish.
For improving the code readability, introduce a new helper function, snd_hda_codec_write_sync(), which is another variant of snd_hda_codec_write(), and replace the existing snd_hda_codec_read() calls with this one.
No behavior change but just the code refactoring.
--- include/sound/hda_codec.h | 11 +++++++++++ sound/hda/codecs/generic.c | 2 +- sound/hda/codecs/hdmi/intelhdmi.c | 2 +- sound/hda/codecs/realtek/realtek.c | 3 +-- sound/hda/codecs/sigmatel.c | 4 ++-- sound/hda/common/codec.c | 11 +++++------ 6 files changed, 21 insertions(+), 12 deletions(-)
include/sound/hda_codec.h +11 -0
@@ -336,6 +336,17 @@ snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,return snd_hdac_codec_write (&codec->core, nid, flags, verb, parm); } +/* sync after write */ +static inline int +snd_hda_codec_write_sync (struct hda_codec *codec,hda_nid_t nid,int flags, +unsigned int verb,unsigned int parm) +{ +/* use snd_hda_codec_read() for writing; +* the returned value is usually discarded +*/ +return snd_hdac_codec_read (&codec->core, nid, flags, verb, parm); +} +#define snd_hda_param_read (codec, nid, param) \ snd_hdac_read_parm(&(codec)->core, nid, param)#define snd_hda_get_sub_nodes (codec, nid, start_nid) \
sound/hda/codecs/generic.c +1 -1
@@ -863,7 +863,7 @@ static void sync_power_state_change(struct hda_codec *codec, hda_nid_t nid) {if (nid) {msleep (10 ); -snd_hda_codec_read (codec, nid,0 ,AC_VERB_GET_POWER_STATE ,0 ); +snd_hda_codec_write_sync (codec, nid,0 ,AC_VERB_GET_POWER_STATE ,0 ); } }
sound/hda/codecs/hdmi/intelhdmi.c +1 -1
@@ -85,7 +85,7 @@ static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, } } -snd_hda_codec_read (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state); +snd_hda_codec_write_sync (codec, fg,0 ,AC_VERB_SET_POWER_STATE , power_state);snd_hda_codec_set_power_to_all (codec, fg, power_state); }
sound/hda/codecs/realtek/realtek.c +1 -2
@@ -411,9 +411,8 @@ void alc_headset_mic_no_shutup(struct hda_codec *codec)return ;snd_array_for_each (&codec->init_pins, i, pin) { -/* use read here for syncing after issuing each verb */ if (pin->nid != mic_pin) -snd_hda_codec_read (codec, pin->nid,0 , +snd_hda_codec_write_sync (codec, pin->nid,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0 ); }
sound/hda/codecs/sigmatel.c +2 -2
@@ -311,12 +311,12 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,snd_hda_codec_write (codec, fg,0 ,AC_VERB_SET_GPIO_MASK , gpiomask); -snd_hda_codec_read (codec, fg,0 , +snd_hda_codec_write_sync (codec, fg,0 ,AC_VERB_SET_GPIO_DIRECTION , gpiodir);/* sync */ msleep (1 ); -snd_hda_codec_read (codec, fg,0 , +snd_hda_codec_write_sync (codec, fg,0 ,AC_VERB_SET_GPIO_DATA , gpiostate);/* sync */ }
sound/hda/common/codec.c +5 -6
@@ -606,9 +606,8 @@ void snd_hda_shutup_pins(struct hda_codec *codec)if (codec->bus->shutdown)return ;snd_array_for_each (&codec->init_pins, i, pin) { -/* use read here for syncing after issuing each verb */ -snd_hda_codec_read (codec, pin->nid,0 , -AC_VERB_SET_PIN_WIDGET_CONTROL ,0 ); +snd_hda_codec_write_sync (codec, pin->nid,0 , +AC_VERB_SET_PIN_WIDGET_CONTROL ,0 ); } codec->pins_shutup =1 ; }
@@ -2794,9 +2793,9 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,if (codec->power_filter) state = codec->power_filter (codec, fg, state);if (state == power_state || power_state !=AC_PWRST_D3 ) -snd_hda_codec_read (codec, fg, flags, -AC_VERB_SET_POWER_STATE , - state); +snd_hda_codec_write_sync (codec, fg, flags, +AC_VERB_SET_POWER_STATE , + state);snd_hda_codec_set_power_to_all (codec, fg, power_state); } state =snd_hda_sync_power_state (codec, fg, power_state);
Signature · 1 line
2.53.0
PATCH 2/10 ALSA: hda: Add a simple GPIO setup helper function
In reply to Takashi IwaiIntroduce a common GPIO setup helper function, so that we can clean up the open code found in many codec drivers later.
--- include/sound/hda_codec.h | 4 ++++ sound/hda/common/codec.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/sound/hda_codec.h +4 -0
@@ -481,6 +481,10 @@ void snd_hda_unlock_devices(struct hda_bus *bus);void snd_hda_bus_reset (struct hda_bus *bus);void snd_hda_bus_reset_codecs (struct hda_bus *bus); +void snd_hda_codec_set_gpio (struct hda_codec *codec,unsigned int mask, +unsigned int dir,unsigned int data, +unsigned int delay); +int snd_hda_codec_set_name (struct hda_codec *codec,const char *name);/*
sound/hda/common/codec.c +29 -0
@@ -4052,6 +4052,35 @@ void snd_hda_bus_reset_codecs(struct hda_bus *bus) } } +/** +* snd_hda_codec_set_gpio - Set up GPIO bits for AFG +* @codec: the HDA codec +* @mask: GPIO bitmask +* @dir: GPIO direction bits +* @data: GPIO data bits +* @delay: the delay in msec before writing GPIO data bits +*/ +void snd_hda_codec_set_gpio (struct hda_codec *codec,unsigned int mask, +unsigned int dir,unsigned int data, +unsigned int delay) +{ +snd_hda_codec_write (codec, codec->core.afg,0 , +AC_VERB_SET_GPIO_MASK , mask); +if (delay) { +snd_hda_codec_write_sync (codec, codec->core.afg,0 , +AC_VERB_SET_GPIO_DIRECTION , dir); +msleep (delay); +snd_hda_codec_write_sync (codec, codec->core.afg,0 , +AC_VERB_SET_GPIO_DATA , data); + }else { +snd_hda_codec_write (codec, codec->core.afg,0 , +AC_VERB_SET_GPIO_DIRECTION , dir); +snd_hda_codec_write (codec, codec->core.afg,0 , +AC_VERB_SET_GPIO_DATA , data); + } +} +EXPORT_SYMBOL_GPL (snd_hda_codec_set_gpio); +/** * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer * @pcm: PCM caps bits
Signature · 1 line
2.53.0
PATCH 3/10 ALSA: hda/realtek: Clean up with snd_hda_codec_set_gpio()
In reply to Takashi IwaiUse a new helper function to clean up the code.
Along with it, make alc_write_gpio() static as well, which is used only locally in realtek.c.
--- sound/hda/codecs/realtek/realtek.c | 13 ++++--------- sound/hda/codecs/realtek/realtek.h | 1 - 2 files changed, 4 insertions(+), 10 deletions(-)
sound/hda/codecs/realtek/realtek.c +4 -9
@@ -123,22 +123,17 @@ void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask, }EXPORT_SYMBOL_NS_GPL (alc_update_gpio_data,"SND_HDA_CODEC_REALTEK" ); -void alc_write_gpio (struct hda_codec *codec) +static void alc_write_gpio (struct hda_codec *codec) {struct alc_spec *spec = codec->spec;if (!spec->gpio_mask)return ; -snd_hda_codec_write (codec, codec->core.afg,0 , -AC_VERB_SET_GPIO_MASK , spec->gpio_mask); -snd_hda_codec_write (codec, codec->core.afg,0 , -AC_VERB_SET_GPIO_DIRECTION , spec->gpio_dir); -if (spec->gpio_write_delay) -msleep (1 ); -alc_write_gpio_data (codec); +snd_hda_codec_set_gpio (codec, spec->gpio_mask, spec->gpio_dir, + spec->gpio_data, + spec->gpio_write_delay ?1 :0 ); } -EXPORT_SYMBOL_NS_GPL (alc_write_gpio,"SND_HDA_CODEC_REALTEK" );void alc_fixup_gpio (struct hda_codec *codec,int action,unsigned int mask) {
sound/hda/codecs/realtek/realtek.h +0 -1
@@ -171,7 +171,6 @@ void alc_setup_gpio(struct hda_codec *codec, unsigned int mask);void alc_write_gpio_data (struct hda_codec *codec);void alc_update_gpio_data (struct hda_codec *codec,unsigned int mask,bool on); -void alc_write_gpio (struct hda_codec *codec);/* common GPIO fixups */ void alc_fixup_gpio (struct hda_codec *codec,int action,unsigned int mask);
Signature · 1 line
2.53.0
PATCH 4/10 ALSA: hda/alc662: Simplify the quirk for CSL Unity BF24B
In reply to Takashi IwaiThe previous implementation of the quirk for CSL Unity BF24B in commit de65275fc94e ("ALSA: hda/realtek: Add quirk for CSL Unity BF24B") introduced the unnecessary GPIO caching which leads to a superfluous write at each init/resume.
Use the new helper to write GPIO bits directly for optimization.
--- sound/hda/codecs/realtek/alc662.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
sound/hda/codecs/realtek/alc662.c +3 -11
@@ -258,19 +258,11 @@ static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,static void alc662_fixup_csl_amp (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -struct alc_spec *spec = codec->spec; - -switch (action) { -case HDA_FIXUP_ACT_PRE_PROBE : - spec->gpio_mask |=0x03 ; - spec->gpio_dir |=0x03 ; -break ; -case HDA_FIXUP_ACT_INIT : +if (action ==HDA_FIXUP_ACT_INIT ) {/* need to toggle GPIO to enable the amp */ -alc_update_gpio_data (codec,0x03 , true); +snd_hda_codec_set_gpio (codec,0x03 ,0x03 ,0x03 ,0 );msleep (100 ); -alc_update_gpio_data (codec,0x03 , false); -break ; +snd_hda_codec_set_gpio (codec,0x03 ,0x03 ,0x00 ,0 ); } }
Signature · 1 line
2.53.0
PATCH 5/10 ALSA: hda/analog: Fix GPIO verb orders
In reply to Takashi IwaiSo far we used the verb cache to restore the GPIO mask, direction and data bits at PM resume. But, due to the nature of the cache resume mechanism, the calling order isn't guaranteed, and this might lead to some inconsistency at the restored state.
For assuring the GPIO verb orders, use the new GPIO helper function to explicitly set up the GPIO bits, instead of using the codec verb caches, while keeping the current data bits in ad198x_spec.
--- sound/hda/codecs/analog.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/hda/codecs/analog.c +9 -9
@@ -38,6 +38,8 @@ struct ad198x_spec {unsigned int beep_amp;/* beep amp value, set via set_beep_amp() */ int num_smux_conns; + +unsigned int gpio_data; };
@@ -934,9 +936,9 @@ static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled)if (spec->eapd_nid)ad_vmaster_eapd_hook (private_data, enabled); -snd_hda_codec_write_cache (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DATA , - enabled ?0x00 :0x02 ); + spec->gpio_data = enabled ?0x00 :0x02 ; +snd_hda_codec_write (codec,0x01 ,0 , +AC_VERB_SET_GPIO_DATA , spec->gpio_data); } static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
@@ -948,12 +950,7 @@ static void ad1884_fixup_hp_eapd(struct hda_codec *codec,case HDA_FIXUP_ACT_PRE_PROBE : spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook; spec->gen.own_eapd_ctl =1 ; -snd_hda_codec_write_cache (codec,0x01 ,0 , -AC_VERB_SET_GPIO_MASK ,0x02 ); -snd_hda_codec_write_cache (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DIRECTION ,0x02 ); -snd_hda_codec_write_cache (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DATA ,0x02 ); + spec->gpio_data =0x02 ;break ;case HDA_FIXUP_ACT_PROBE :if (spec->gen.autocfg.line_out_type ==AUTO_PIN_SPEAKER_OUT )
@@ -961,6 +958,9 @@ static void ad1884_fixup_hp_eapd(struct hda_codec *codec,else spec->eapd_nid = spec->gen.autocfg.speaker_pins[0 ];break ; +case HDA_FIXUP_ACT_INIT : +snd_hda_codec_set_gpio (codec,0x02 ,0x02 , spec->gpio_data,0 ); +break ; } }
Signature · 1 line
2.53.0
PATCH 6/10 ALSA: hda/sigmatel: Clean up with the new GPIO helper
In reply to Takashi IwaiUse the new GPIO helper function to clean up the open code.
Merely a code refactoring, and no behavior change.
--- sound/hda/codecs/sigmatel.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
sound/hda/codecs/sigmatel.c +1 -9
@@ -309,15 +309,7 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,/* Configure GPIOx as CMOS */ snd_hda_codec_write (codec, fg,0 ,0x7e7 ,0 ); -snd_hda_codec_write (codec, fg,0 , -AC_VERB_SET_GPIO_MASK , gpiomask); -snd_hda_codec_write_sync (codec, fg,0 , -AC_VERB_SET_GPIO_DIRECTION , gpiodir);/* sync */ - -msleep (1 ); - -snd_hda_codec_write_sync (codec, fg,0 , -AC_VERB_SET_GPIO_DATA , gpiostate);/* sync */ +snd_hda_codec_set_gpio (codec, gpiomask, gpiodir, gpiostate,1 ); }/* hook for controlling mic-mute LED GPIO */
Signature · 1 line
2.53.0
PATCH 7/10 ALSA: hda/ca0132: Clean up with the new GPIO helper
In reply to Takashi IwaiUse the new GPIO helper function to clean up the open code.
Merely a code refactoring, and no behavior change.
--- sound/hda/codecs/ca0132.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
sound/hda/codecs/ca0132.c +2 -12
@@ -3755,22 +3755,12 @@ static void ca0132_gpio_setup(struct hda_codec *codec)switch (ca0132_quirk (spec)) {case QUIRK_SBZ : -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DIRECTION ,0x07 ); -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_MASK ,0x07 ); -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DATA ,0x04 ); +snd_hda_codec_set_gpio (codec,0x07 ,0x07 ,0x04 ,0 );snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DATA ,0x06 );break ;case QUIRK_R3DI : -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DIRECTION ,0x1E ); -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_MASK ,0x1F ); -snd_hda_codec_write (codec,0x01 ,0 , -AC_VERB_SET_GPIO_DATA ,0x0C ); +snd_hda_codec_set_gpio (codec,0x1F ,0x1E ,0x0C ,0 );break ;default :break ;
Signature · 1 line
2.53.0
PATCH 8/10 ALSA: hda/cirrus: Clean up with the new GPIO helper
In reply to Takashi IwaiUse the new GPIO helper function to clean up the open code.
Merely a code refactoring, and no behavior change.
--- sound/hda/codecs/cirrus/cs420x.c | 11 +++-------- sound/hda/codecs/cirrus/cs421x.c | 11 +++-------- sound/hda/codecs/cirrus/cs8409.c | 22 ++++++---------------- 3 files changed, 12 insertions(+), 32 deletions(-)
sound/hda/codecs/cirrus/cs420x.c +3 -8
@@ -264,14 +264,9 @@ static int cs_init(struct hda_codec *codec)snd_hda_gen_init (codec); -if (spec->gpio_mask) { -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_MASK , - spec->gpio_mask); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DIRECTION , - spec->gpio_dir); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_data); - } +if (spec->gpio_mask) +snd_hda_codec_set_gpio (codec, spec->gpio_mask, spec->gpio_dir, + spec->gpio_data,0 );if (spec->vendor_nid ==CS420X_VENDOR_NID ) {init_input_coef (codec);
sound/hda/codecs/cirrus/cs421x.c +3 -8
@@ -442,14 +442,9 @@ static int cs421x_init(struct hda_codec *codec)snd_hda_gen_init (codec); -if (spec->gpio_mask) { -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_MASK , - spec->gpio_mask); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DIRECTION , - spec->gpio_dir); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_data); - } +if (spec->gpio_mask) +snd_hda_codec_set_gpio (codec, spec->gpio_mask, spec->gpio_dir, + spec->gpio_data,0 );cs4210_spdif_automute (codec,NULL );
sound/hda/codecs/cirrus/cs8409.c +6 -16
@@ -1042,14 +1042,9 @@ static void cs8409_cs42l42_hw_init(struct hda_codec *codec)struct cs8409_spec *spec = codec->spec;struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0 ]; -if (spec->gpio_mask) { -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_MASK , - spec->gpio_mask); -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_DIRECTION , - spec->gpio_dir); -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_data); - } +if (spec->gpio_mask) +snd_hda_codec_set_gpio (codec, spec->gpio_mask, spec->gpio_dir, + spec->gpio_data,0 );for (; seq->nid; seq++)cs8409_vendor_coef_set (codec, seq->cir, seq->coeff);
@@ -1442,14 +1437,9 @@ static void dolphin_hw_init(struct hda_codec *codec)struct sub_codec *cs42l42;int i; -if (spec->gpio_mask) { -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_MASK , - spec->gpio_mask); -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_DIRECTION , - spec->gpio_dir); -snd_hda_codec_write (codec,CS8409_PIN_AFG ,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_data); - } +if (spec->gpio_mask) +snd_hda_codec_set_gpio (codec, spec->gpio_mask, spec->gpio_dir, + spec->gpio_data,0 );for (; seq->nid; seq++)cs8409_vendor_coef_set (codec, seq->cir, seq->coeff);
Signature · 1 line
2.53.0
PATCH 9/10 ALSA: hda/conexant: Clean up with the new GPIO helper
In reply to Takashi IwaiUse the new GPIO helper function to clean up the open code.
Merely a code refactoring, and no behavior change.
--- sound/hda/codecs/conexant.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
sound/hda/codecs/conexant.c +3 -11
@@ -154,14 +154,8 @@ static void cxt_init_gpio_led(struct hda_codec *codec)struct conexant_spec *spec = codec->spec;unsigned int mask = spec->gpio_mute_led_mask | spec->gpio_mic_led_mask; -if (mask) { -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_MASK , - mask); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DIRECTION , - mask); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_led); - } +if (mask) +snd_hda_codec_set_gpio (codec, mask, mask, spec->gpio_led,0 ); }static void cx_fixup_headset_recog (struct hda_codec *codec)
@@ -775,9 +769,7 @@ static void cxt_setup_gpio_unmute(struct hda_codec *codec, {if (gpio_mute_mask) {// set gpio data to 0. -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DATA ,0 ); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_MASK , gpio_mute_mask); -snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_DIRECTION , gpio_mute_mask); +snd_hda_codec_set_gpio (codec, gpio_mute_mask, gpio_mute_mask,0 ,0 );snd_hda_codec_write (codec,0x01 ,0 ,AC_VERB_SET_GPIO_STICKY_MASK ,0 ); } }
Signature · 1 line
2.53.0
PATCH 10/10 ALSA: hda/senarytech: Clean up with the new GPIO helper
In reply to Takashi IwaiUse the new GPIO helper function to clean up the open code.
Merely a code refactoring, and no behavior change.
--- sound/hda/codecs/senarytech.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
sound/hda/codecs/senarytech.c +2 -8
@@ -159,14 +159,8 @@ static void senary_init_gpio_led(struct hda_codec *codec)struct senary_spec *spec = codec->spec;unsigned int mask = spec->gpio_mute_led_mask | spec->gpio_mic_led_mask; -if (mask) { -snd_hda_codec_write (codec, codec->core.afg,0 ,AC_VERB_SET_GPIO_MASK , - mask); -snd_hda_codec_write (codec, codec->core.afg,0 ,AC_VERB_SET_GPIO_DIRECTION , - mask); -snd_hda_codec_write (codec, codec->core.afg,0 ,AC_VERB_SET_GPIO_DATA , - spec->gpio_led); - } +if (mask) +snd_hda_codec_set_gpio (codec, mask, mask, spec->gpio_led,0 ); }static int senary_init (struct hda_codec *codec)
Signature · 1 line
2.53.0