From: Sasha Levin Date: Thu, 21 May 2020 19:21:11 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v4.4.225~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa91c6f56e65cc432e8f325b36be46936c275247;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/alsa-hda-constify-and-cleanup-static-nodeid-tables.patch b/queue-5.4/alsa-hda-constify-and-cleanup-static-nodeid-tables.patch new file mode 100644 index 00000000000..2c553ae4dd8 --- /dev/null +++ b/queue-5.4/alsa-hda-constify-and-cleanup-static-nodeid-tables.patch @@ -0,0 +1,356 @@ +From 1b5f3e4d5268fc524d2b255a458c9cf7a0493e32 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 3 Jan 2020 10:23:48 +0100 +Subject: ALSA: hda - constify and cleanup static NodeID tables +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michał Mirosław + +[ Upstream commit caf3c0437aaf2e63624c4aaf94c0dd38d1f897e3 ] + +Make hda_nid_t tables static const, as they are not intended to be +modified by callees. + +Signed-off-by: Michał Mirosław +Link: https://lore.kernel.org/r/5150c94101c9534f4c8e987324f6912c16d459f6.1578043216.git.mirq-linux@rere.qmqm.pl +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/hda_generic.c | 4 +-- + sound/pci/hda/patch_analog.c | 6 ++-- + sound/pci/hda/patch_ca0132.c | 12 +++---- + sound/pci/hda/patch_conexant.c | 6 ++-- + sound/pci/hda/patch_realtek.c | 62 +++++++++++++++++----------------- + sound/pci/hda/patch_sigmatel.c | 4 +-- + sound/pci/hda/patch_via.c | 4 +-- + 7 files changed, 49 insertions(+), 49 deletions(-) + +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c +index 10d502328b76..fc001c64ef20 100644 +--- a/sound/pci/hda/hda_generic.c ++++ b/sound/pci/hda/hda_generic.c +@@ -4401,7 +4401,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_fix_pin_power); + */ + + /* check each pin in the given array; returns true if any of them is plugged */ +-static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) ++static bool detect_jacks(struct hda_codec *codec, int num_pins, const hda_nid_t *pins) + { + int i; + bool present = false; +@@ -4420,7 +4420,7 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) + } + + /* standard HP/line-out auto-mute helper */ +-static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, ++static void do_automute(struct hda_codec *codec, int num_pins, const hda_nid_t *pins, + int *paths, bool mute) + { + struct hda_gen_spec *spec = codec->spec; +diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c +index bc9dd8e6fd86..c64895f99299 100644 +--- a/sound/pci/hda/patch_analog.c ++++ b/sound/pci/hda/patch_analog.c +@@ -389,7 +389,7 @@ static int patch_ad1986a(struct hda_codec *codec) + { + int err; + struct ad198x_spec *spec; +- static hda_nid_t preferred_pairs[] = { ++ static const hda_nid_t preferred_pairs[] = { + 0x1a, 0x03, + 0x1b, 0x03, + 0x1c, 0x04, +@@ -519,9 +519,9 @@ static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec) + + static int patch_ad1983(struct hda_codec *codec) + { ++ static const hda_nid_t conn_0c[] = { 0x08 }; ++ static const hda_nid_t conn_0d[] = { 0x09 }; + struct ad198x_spec *spec; +- static hda_nid_t conn_0c[] = { 0x08 }; +- static hda_nid_t conn_0d[] = { 0x09 }; + int err; + + err = alloc_ad_spec(codec); +diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c +index adad3651889e..1e904dd15ab3 100644 +--- a/sound/pci/hda/patch_ca0132.c ++++ b/sound/pci/hda/patch_ca0132.c +@@ -7803,23 +7803,23 @@ static void sbz_region2_exit(struct hda_codec *codec) + + static void sbz_set_pin_ctl_default(struct hda_codec *codec) + { +- hda_nid_t pins[5] = {0x0B, 0x0C, 0x0E, 0x12, 0x13}; ++ static const hda_nid_t pins[] = {0x0B, 0x0C, 0x0E, 0x12, 0x13}; + unsigned int i; + + snd_hda_codec_write(codec, 0x11, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40); + +- for (i = 0; i < 5; i++) ++ for (i = 0; i < ARRAY_SIZE(pins); i++) + snd_hda_codec_write(codec, pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00); + } + + static void ca0132_clear_unsolicited(struct hda_codec *codec) + { +- hda_nid_t pins[7] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}; ++ static const hda_nid_t pins[] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}; + unsigned int i; + +- for (i = 0; i < 7; i++) { ++ for (i = 0; i < ARRAY_SIZE(pins); i++) { + snd_hda_codec_write(codec, pins[i], 0, + AC_VERB_SET_UNSOLICITED_ENABLE, 0x00); + } +@@ -7843,10 +7843,10 @@ static void sbz_gpio_shutdown_commands(struct hda_codec *codec, int dir, + + static void zxr_dbpro_power_state_shutdown(struct hda_codec *codec) + { +- hda_nid_t pins[7] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01}; ++ static const hda_nid_t pins[] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01}; + unsigned int i; + +- for (i = 0; i < 7; i++) ++ for (i = 0; i < ARRAY_SIZE(pins); i++) + snd_hda_codec_write(codec, pins[i], 0, + AC_VERB_SET_POWER_STATE, 0x03); + } +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c +index 1e20e85e9b46..396b5503038a 100644 +--- a/sound/pci/hda/patch_conexant.c ++++ b/sound/pci/hda/patch_conexant.c +@@ -116,7 +116,7 @@ static void cx_auto_parse_eapd(struct hda_codec *codec) + } + + static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, +- hda_nid_t *pins, bool on) ++ const hda_nid_t *pins, bool on) + { + int i; + for (i = 0; i < num_pins; i++) { +@@ -960,10 +960,10 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = { + static void add_cx5051_fake_mutes(struct hda_codec *codec) + { + struct conexant_spec *spec = codec->spec; +- static hda_nid_t out_nids[] = { ++ static const hda_nid_t out_nids[] = { + 0x10, 0x11, 0 + }; +- hda_nid_t *p; ++ const hda_nid_t *p; + + for (p = out_nids; *p; p++) + snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 004d2f638cf2..151099b8c394 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -465,10 +465,10 @@ static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) + static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) + { + /* We currently only handle front, HP */ +- static hda_nid_t pins[] = { ++ static const hda_nid_t pins[] = { + 0x0f, 0x10, 0x14, 0x15, 0x17, 0 + }; +- hda_nid_t *p; ++ const hda_nid_t *p; + for (p = pins; *p; p++) + set_eapd(codec, *p, on); + } +@@ -1939,19 +1939,19 @@ static void alc889_fixup_dac_route(struct hda_codec *codec, + { + if (action == HDA_FIXUP_ACT_PRE_PROBE) { + /* fake the connections during parsing the tree */ +- hda_nid_t conn1[2] = { 0x0c, 0x0d }; +- hda_nid_t conn2[2] = { 0x0e, 0x0f }; +- snd_hda_override_conn_list(codec, 0x14, 2, conn1); +- snd_hda_override_conn_list(codec, 0x15, 2, conn1); +- snd_hda_override_conn_list(codec, 0x18, 2, conn2); +- snd_hda_override_conn_list(codec, 0x1a, 2, conn2); ++ static const hda_nid_t conn1[] = { 0x0c, 0x0d }; ++ static const hda_nid_t conn2[] = { 0x0e, 0x0f }; ++ snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); ++ snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1); ++ snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2); ++ snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2); + } else if (action == HDA_FIXUP_ACT_PROBE) { + /* restore the connections */ +- hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; +- snd_hda_override_conn_list(codec, 0x14, 5, conn); +- snd_hda_override_conn_list(codec, 0x15, 5, conn); +- snd_hda_override_conn_list(codec, 0x18, 5, conn); +- snd_hda_override_conn_list(codec, 0x1a, 5, conn); ++ static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; ++ snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn); ++ snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn); ++ snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn); ++ snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn); + } + } + +@@ -1959,8 +1959,8 @@ static void alc889_fixup_dac_route(struct hda_codec *codec, + static void alc889_fixup_mbp_vref(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { ++ static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 }; + struct alc_spec *spec = codec->spec; +- static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 }; + int i; + + if (action != HDA_FIXUP_ACT_INIT) +@@ -1996,7 +1996,7 @@ static void alc889_fixup_mac_pins(struct hda_codec *codec, + static void alc889_fixup_imac91_vref(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { +- static hda_nid_t nids[2] = { 0x18, 0x1a }; ++ static const hda_nid_t nids[] = { 0x18, 0x1a }; + + if (action == HDA_FIXUP_ACT_INIT) + alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); +@@ -2006,7 +2006,7 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec, + static void alc889_fixup_mba11_vref(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { +- static hda_nid_t nids[1] = { 0x18 }; ++ static const hda_nid_t nids[] = { 0x18 }; + + if (action == HDA_FIXUP_ACT_INIT) + alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); +@@ -2016,7 +2016,7 @@ static void alc889_fixup_mba11_vref(struct hda_codec *codec, + static void alc889_fixup_mba21_vref(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { +- static hda_nid_t nids[2] = { 0x18, 0x19 }; ++ static const hda_nid_t nids[] = { 0x18, 0x19 }; + + if (action == HDA_FIXUP_ACT_INIT) + alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); +@@ -2098,7 +2098,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec, + const struct hda_fixup *fix, + int action) + { +- hda_nid_t conn1[1] = { 0x0c }; ++ static const hda_nid_t conn1[] = { 0x0c }; + + if (action != HDA_FIXUP_ACT_PRE_PROBE) + return; +@@ -2107,8 +2107,8 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec, + /* We therefore want to make sure 0x14 (front headphone) and + * 0x1b (speakers) use the stereo DAC 0x02 + */ +- snd_hda_override_conn_list(codec, 0x14, 1, conn1); +- snd_hda_override_conn_list(codec, 0x1b, 1, conn1); ++ snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); ++ snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1); + } + + static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, +@@ -5371,7 +5371,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec, + * the speaker output becomes too low by some reason on Thinkpads with + * ALC298 codec + */ +- static hda_nid_t preferred_pairs[] = { ++ static const hda_nid_t preferred_pairs[] = { + 0x14, 0x03, 0x17, 0x02, 0x21, 0x02, + 0 + }; +@@ -5632,9 +5632,9 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec, + /* DAC node 0x03 is giving mono output. We therefore want to + make sure 0x14 (front speaker) and 0x15 (headphones) use the + stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */ +- hda_nid_t conn1[2] = { 0x0c }; +- snd_hda_override_conn_list(codec, 0x14, 1, conn1); +- snd_hda_override_conn_list(codec, 0x15, 1, conn1); ++ static const hda_nid_t conn1[] = { 0x0c }; ++ snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); ++ snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1); + } + } + +@@ -5649,8 +5649,8 @@ static void alc298_fixup_speaker_volume(struct hda_codec *codec, + Pin Complex), since Node 0x02 has Amp-out caps, we can adjust + speaker's volume now. */ + +- hda_nid_t conn1[1] = { 0x0c }; +- snd_hda_override_conn_list(codec, 0x17, 1, conn1); ++ static const hda_nid_t conn1[] = { 0x0c }; ++ snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1); + } + } + +@@ -5659,8 +5659,8 @@ static void alc295_fixup_disable_dac3(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { + if (action == HDA_FIXUP_ACT_PRE_PROBE) { +- hda_nid_t conn[2] = { 0x02, 0x03 }; +- snd_hda_override_conn_list(codec, 0x17, 2, conn); ++ static const hda_nid_t conn[] = { 0x02, 0x03 }; ++ snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); + } + } + +@@ -5669,8 +5669,8 @@ static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { + if (action == HDA_FIXUP_ACT_PRE_PROBE) { +- hda_nid_t conn[1] = { 0x02 }; +- snd_hda_override_conn_list(codec, 0x17, 1, conn); ++ static const hda_nid_t conn[] = { 0x02 }; ++ snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); + } + } + +@@ -5757,7 +5757,7 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { + struct alc_spec *spec = codec->spec; +- static hda_nid_t preferred_pairs[] = { ++ static const hda_nid_t preferred_pairs[] = { + 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02, + 0 + }; +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c +index 894f3f509e76..4b9300babc7d 100644 +--- a/sound/pci/hda/patch_sigmatel.c ++++ b/sound/pci/hda/patch_sigmatel.c +@@ -795,7 +795,7 @@ static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity) + static bool has_builtin_speaker(struct hda_codec *codec) + { + struct sigmatel_spec *spec = codec->spec; +- hda_nid_t *nid_pin; ++ const hda_nid_t *nid_pin; + int nids, i; + + if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) { +@@ -2182,7 +2182,7 @@ static void hp_envy_ts_fixup_dac_bind(struct hda_codec *codec, + int action) + { + struct sigmatel_spec *spec = codec->spec; +- static hda_nid_t preferred_pairs[] = { ++ static const hda_nid_t preferred_pairs[] = { + 0xd, 0x13, + 0 + }; +diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c +index 29dcdb8b36db..b40d01e01832 100644 +--- a/sound/pci/hda/patch_via.c ++++ b/sound/pci/hda/patch_via.c +@@ -1038,8 +1038,8 @@ static const struct snd_pci_quirk vt2002p_fixups[] = { + */ + static void fix_vt1802_connections(struct hda_codec *codec) + { +- static hda_nid_t conn_24[] = { 0x14, 0x1c }; +- static hda_nid_t conn_33[] = { 0x1c }; ++ static const hda_nid_t conn_24[] = { 0x14, 0x1c }; ++ static const hda_nid_t conn_33[] = { 0x1c }; + + snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); + snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-manage-concurrent-reg-access-more-properly.patch b/queue-5.4/alsa-hda-manage-concurrent-reg-access-more-properly.patch new file mode 100644 index 00000000000..b74ff47eda3 --- /dev/null +++ b/queue-5.4/alsa-hda-manage-concurrent-reg-access-more-properly.patch @@ -0,0 +1,444 @@ +From 851451831d187191c76c3e38de8c5b4548e2cb44 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 9 Jan 2020 10:01:04 +0100 +Subject: ALSA: hda: Manage concurrent reg access more properly + +From: Takashi Iwai + +[ Upstream commit 1a462be52f4505a2719631fb5aa7bfdbd37bfd8d ] + +In the commit 8e85def5723e ("ALSA: hda: enable regmap internal +locking"), we re-enabled the regmap lock due to the reported +regression that showed the possible concurrent accesses. It was a +temporary workaround, and there are still a few opened races even +after the revert. In this patch, we cover those still opened windows +with a proper mutex lock and disable the regmap internal lock again. + +First off, the patch introduces a new snd_hdac_device.regmap_lock +mutex that is applied for each snd_hdac_regmap_*() call, including +read, write and update helpers. The mutex is applied carefully so +that it won't block the self-power-up procedure in the helper +function. Also, this assures the protection for the accesses without +regmap, too. + +The snd_hdac_regmap_update_raw() is refactored to use the standard +regmap_update_bits_check() function instead of the open-code. The +non-regmap case is still open-coded but it's an easy part. The all +read and write operations are in the single mutex protection, so it's +now race-free. + +In addition, a couple of new helper functions are added: +snd_hdac_regmap_update_raw_once() and snd_hdac_regmap_sync(). Both +are called from HD-audio legacy driver. The former is to initialize +the given verb bits but only once when it's not initialized yet. Due +to this condition, the function invokes regcache_cache_only(), and +it's now performed inside the regmap_lock (formerly it was racy) too. +The latter function is for simply invoking regcache_sync() inside the +regmap_lock, which is called from the codec resume call path. +Along with that, the HD-audio codec driver code is slightly modified / +simplified to adapt those new functions. + +And finally, snd_hdac_regmap_read_raw(), *_write_raw(), etc are +rewritten with the helper macro. It's just for simplification because +the code logic is identical among all those functions. + +Tested-by: Kai Vehmanen +Link: https://lore.kernel.org/r/20200109090104.26073-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + include/sound/hda_regmap.h | 3 + + include/sound/hdaudio.h | 1 + + sound/hda/hdac_device.c | 1 + + sound/hda/hdac_regmap.c | 142 +++++++++++++++++++++++++--------- + sound/pci/hda/hda_codec.c | 30 +++---- + sound/pci/hda/hda_generic.c | 2 +- + sound/pci/hda/hda_local.h | 2 + + sound/pci/hda/patch_hdmi.c | 2 +- + sound/pci/hda/patch_realtek.c | 4 +- + sound/pci/hda/patch_via.c | 2 +- + 10 files changed, 135 insertions(+), 54 deletions(-) + +diff --git a/include/sound/hda_regmap.h b/include/sound/hda_regmap.h +index 5141f8ffbb12..4c1b9bebbd60 100644 +--- a/include/sound/hda_regmap.h ++++ b/include/sound/hda_regmap.h +@@ -24,6 +24,9 @@ int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg, + unsigned int val); + int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val); ++int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg, ++ unsigned int mask, unsigned int val); ++void snd_hdac_regmap_sync(struct hdac_device *codec); + + /** + * snd_hdac_regmap_encode_verb - encode the verb to a pseudo register +diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h +index fb9dce4c6928..44e57bcc4a57 100644 +--- a/include/sound/hdaudio.h ++++ b/include/sound/hdaudio.h +@@ -87,6 +87,7 @@ struct hdac_device { + + /* regmap */ + struct regmap *regmap; ++ struct mutex regmap_lock; + struct snd_array vendor_verbs; + bool lazy_cache:1; /* don't wake up for writes */ + bool caps_overwriting:1; /* caps overwrite being in process */ +diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c +index 9f3e37511408..c946fd8beebc 100644 +--- a/sound/hda/hdac_device.c ++++ b/sound/hda/hdac_device.c +@@ -57,6 +57,7 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, + codec->addr = addr; + codec->type = HDA_DEV_CORE; + mutex_init(&codec->widget_lock); ++ mutex_init(&codec->regmap_lock); + pm_runtime_set_active(&codec->dev); + pm_runtime_get_noresume(&codec->dev); + atomic_set(&codec->in_pm, 0); +diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c +index 286361ecd640..2596a881186f 100644 +--- a/sound/hda/hdac_regmap.c ++++ b/sound/hda/hdac_regmap.c +@@ -363,6 +363,7 @@ static const struct regmap_config hda_regmap_cfg = { + .reg_write = hda_reg_write, + .use_single_read = true, + .use_single_write = true, ++ .disable_locking = true, + }; + + /** +@@ -425,12 +426,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_add_vendor_verb); + static int reg_raw_write(struct hdac_device *codec, unsigned int reg, + unsigned int val) + { ++ int err; ++ ++ mutex_lock(&codec->regmap_lock); + if (!codec->regmap) +- return hda_reg_write(codec, reg, val); ++ err = hda_reg_write(codec, reg, val); + else +- return regmap_write(codec->regmap, reg, val); ++ err = regmap_write(codec->regmap, reg, val); ++ mutex_unlock(&codec->regmap_lock); ++ return err; + } + ++/* a helper macro to call @func_call; retry with power-up if failed */ ++#define CALL_RAW_FUNC(codec, func_call) \ ++ ({ \ ++ int _err = func_call; \ ++ if (_err == -EAGAIN) { \ ++ _err = snd_hdac_power_up_pm(codec); \ ++ if (_err >= 0) \ ++ _err = func_call; \ ++ snd_hdac_power_down_pm(codec); \ ++ } \ ++ _err;}) ++ + /** + * snd_hdac_regmap_write_raw - write a pseudo register with power mgmt + * @codec: the codec object +@@ -442,42 +460,29 @@ static int reg_raw_write(struct hdac_device *codec, unsigned int reg, + int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg, + unsigned int val) + { +- int err; +- +- err = reg_raw_write(codec, reg, val); +- if (err == -EAGAIN) { +- err = snd_hdac_power_up_pm(codec); +- if (err >= 0) +- err = reg_raw_write(codec, reg, val); +- snd_hdac_power_down_pm(codec); +- } +- return err; ++ return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val)); + } + EXPORT_SYMBOL_GPL(snd_hdac_regmap_write_raw); + + static int reg_raw_read(struct hdac_device *codec, unsigned int reg, + unsigned int *val, bool uncached) + { ++ int err; ++ ++ mutex_lock(&codec->regmap_lock); + if (uncached || !codec->regmap) +- return hda_reg_read(codec, reg, val); ++ err = hda_reg_read(codec, reg, val); + else +- return regmap_read(codec->regmap, reg, val); ++ err = regmap_read(codec->regmap, reg, val); ++ mutex_unlock(&codec->regmap_lock); ++ return err; + } + + static int __snd_hdac_regmap_read_raw(struct hdac_device *codec, + unsigned int reg, unsigned int *val, + bool uncached) + { +- int err; +- +- err = reg_raw_read(codec, reg, val, uncached); +- if (err == -EAGAIN) { +- err = snd_hdac_power_up_pm(codec); +- if (err >= 0) +- err = reg_raw_read(codec, reg, val, uncached); +- snd_hdac_power_down_pm(codec); +- } +- return err; ++ return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached)); + } + + /** +@@ -504,6 +509,35 @@ int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, + return __snd_hdac_regmap_read_raw(codec, reg, val, true); + } + ++static int reg_raw_update(struct hdac_device *codec, unsigned int reg, ++ unsigned int mask, unsigned int val) ++{ ++ unsigned int orig; ++ bool change; ++ int err; ++ ++ mutex_lock(&codec->regmap_lock); ++ if (codec->regmap) { ++ err = regmap_update_bits_check(codec->regmap, reg, mask, val, ++ &change); ++ if (!err) ++ err = change ? 1 : 0; ++ } else { ++ err = hda_reg_read(codec, reg, &orig); ++ if (!err) { ++ val &= mask; ++ val |= orig & ~mask; ++ if (val != orig) { ++ err = hda_reg_write(codec, reg, val); ++ if (!err) ++ err = 1; ++ } ++ } ++ } ++ mutex_unlock(&codec->regmap_lock); ++ return err; ++} ++ + /** + * snd_hdac_regmap_update_raw - update a pseudo register with power mgmt + * @codec: the codec object +@@ -515,20 +549,58 @@ int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, + */ + int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val) ++{ ++ return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val)); ++} ++EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); ++ ++static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg, ++ unsigned int mask, unsigned int val) + { + unsigned int orig; + int err; + +- val &= mask; +- err = snd_hdac_regmap_read_raw(codec, reg, &orig); +- if (err < 0) +- return err; +- val |= orig & ~mask; +- if (val == orig) +- return 0; +- err = snd_hdac_regmap_write_raw(codec, reg, val); ++ if (!codec->regmap) ++ return reg_raw_update(codec, reg, mask, val); ++ ++ mutex_lock(&codec->regmap_lock); ++ regcache_cache_only(codec->regmap, true); ++ err = regmap_read(codec->regmap, reg, &orig); ++ regcache_cache_only(codec->regmap, false); + if (err < 0) +- return err; +- return 1; ++ err = regmap_update_bits(codec->regmap, reg, mask, val); ++ mutex_unlock(&codec->regmap_lock); ++ return err; + } +-EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); ++ ++/** ++ * snd_hdac_regmap_update_raw_once - initialize the register value only once ++ * @codec: the codec object ++ * @reg: pseudo register ++ * @mask: bit mask to update ++ * @val: value to update ++ * ++ * Performs the update of the register bits only once when the register ++ * hasn't been initialized yet. Used in HD-audio legacy driver. ++ * Returns zero if successful or a negative error code ++ */ ++int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg, ++ unsigned int mask, unsigned int val) ++{ ++ return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val)); ++} ++EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once); ++ ++/** ++ * snd_hdac_regmap_sync - sync out the cached values for PM resume ++ * @codec: the codec object ++ */ ++void snd_hdac_regmap_sync(struct hdac_device *codec) ++{ ++ if (codec->regmap) { ++ mutex_lock(&codec->regmap_lock); ++ regcache_sync(codec->regmap); ++ mutex_unlock(&codec->regmap_lock); ++ } ++} ++EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync); +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c +index 6cb72336433a..07c03c32715a 100644 +--- a/sound/pci/hda/hda_codec.c ++++ b/sound/pci/hda/hda_codec.c +@@ -1267,6 +1267,18 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, + } + EXPORT_SYMBOL_GPL(snd_hda_override_amp_caps); + ++static unsigned int encode_amp(struct hda_codec *codec, hda_nid_t nid, ++ int ch, int dir, int idx) ++{ ++ unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx); ++ ++ /* enable fake mute if no h/w mute but min=mute */ ++ if ((query_amp_caps(codec, nid, dir) & ++ (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) == AC_AMPCAP_MIN_MUTE) ++ cmd |= AC_AMP_FAKE_MUTE; ++ return cmd; ++} ++ + /** + * snd_hda_codec_amp_update - update the AMP mono value + * @codec: HD-audio codec +@@ -1282,12 +1294,8 @@ EXPORT_SYMBOL_GPL(snd_hda_override_amp_caps); + int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, + int ch, int dir, int idx, int mask, int val) + { +- unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx); ++ unsigned int cmd = encode_amp(codec, nid, ch, dir, idx); + +- /* enable fake mute if no h/w mute but min=mute */ +- if ((query_amp_caps(codec, nid, dir) & +- (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) == AC_AMPCAP_MIN_MUTE) +- cmd |= AC_AMP_FAKE_MUTE; + return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val); + } + EXPORT_SYMBOL_GPL(snd_hda_codec_amp_update); +@@ -1335,16 +1343,11 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo); + int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch, + int dir, int idx, int mask, int val) + { +- int orig; ++ unsigned int cmd = encode_amp(codec, nid, ch, dir, idx); + + if (!codec->core.regmap) + return -EINVAL; +- regcache_cache_only(codec->core.regmap, true); +- orig = snd_hda_codec_amp_read(codec, nid, ch, dir, idx); +- regcache_cache_only(codec->core.regmap, false); +- if (orig >= 0) +- return 0; +- return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, mask, val); ++ return snd_hdac_regmap_update_raw_once(&codec->core, cmd, mask, val); + } + EXPORT_SYMBOL_GPL(snd_hda_codec_amp_init); + +@@ -2905,8 +2908,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) + else { + if (codec->patch_ops.init) + codec->patch_ops.init(codec); +- if (codec->core.regmap) +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + } + + if (codec->jackpoll_interval) +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c +index fc001c64ef20..6815f9dc8545 100644 +--- a/sound/pci/hda/hda_generic.c ++++ b/sound/pci/hda/hda_generic.c +@@ -6027,7 +6027,7 @@ int snd_hda_gen_init(struct hda_codec *codec) + /* call init functions of standard auto-mute helpers */ + update_automute_all(codec); + +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + + if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) + snd_hda_sync_vmaster_hook(&spec->vmaster_mute); +diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h +index 3942e1b528d8..3dca65d79b02 100644 +--- a/sound/pci/hda/hda_local.h ++++ b/sound/pci/hda/hda_local.h +@@ -138,6 +138,8 @@ int snd_hda_codec_reset(struct hda_codec *codec); + void snd_hda_codec_register(struct hda_codec *codec); + void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); + ++#define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core) ++ + enum { + HDA_VMUTE_OFF, + HDA_VMUTE_ON, +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c +index d48263d1f6a2..d41c91468ab3 100644 +--- a/sound/pci/hda/patch_hdmi.c ++++ b/sound/pci/hda/patch_hdmi.c +@@ -2359,7 +2359,7 @@ static int generic_hdmi_resume(struct hda_codec *codec) + int pin_idx; + + codec->patch_ops.init(codec); +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + + for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { + struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index a0e7d711cbb5..499c8150ebb8 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -908,7 +908,7 @@ static int alc_resume(struct hda_codec *codec) + if (!spec->no_depop_delay) + msleep(150); /* to avoid pop noise */ + codec->patch_ops.init(codec); +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + hda_call_check_power_status(codec, 0x01); + return 0; + } +@@ -3756,7 +3756,7 @@ static int alc269_resume(struct hda_codec *codec) + msleep(200); + } + +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + hda_call_check_power_status(codec, 0x01); + + /* on some machine, the BIOS will clear the codec gpio data when enter +diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c +index b40d01e01832..7ef8f3105cdb 100644 +--- a/sound/pci/hda/patch_via.c ++++ b/sound/pci/hda/patch_via.c +@@ -396,7 +396,7 @@ static int via_resume(struct hda_codec *codec) + /* some delay here to make jack detection working (bko#98921) */ + msleep(10); + codec->patch_ops.init(codec); +- regcache_sync(codec->core.regmap); ++ snd_hda_regmap_sync(codec); + return 0; + } + #endif +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-patch_realtek-fix-empty-macro-usage-in-if-b.patch b/queue-5.4/alsa-hda-patch_realtek-fix-empty-macro-usage-in-if-b.patch new file mode 100644 index 00000000000..d614985d1b6 --- /dev/null +++ b/queue-5.4/alsa-hda-patch_realtek-fix-empty-macro-usage-in-if-b.patch @@ -0,0 +1,56 @@ +From d1134bb2725f579df9c28f45d31a475ea6b7ed4c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 11 Jan 2020 15:47:35 -0600 +Subject: ALSA: hda: patch_realtek: fix empty macro usage in if block +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pierre-Louis Bossart + +[ Upstream commit 8a71821f12a010d7100f9cc1f7b218aff0313c4a ] + +GCC reports the following warning with W=1 + +sound/pci/hda/patch_realtek.c: In function ‘alc269_suspend’: +sound/pci/hda/patch_realtek.c:3616:29: warning: suggest braces around +empty body in an ‘if’ statement [-Wempty-body] + 3616 | alc5505_dsp_suspend(codec); + | ^ + +sound/pci/hda/patch_realtek.c: In function ‘alc269_resume’: +sound/pci/hda/patch_realtek.c:3651:28: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] + 3651 | alc5505_dsp_resume(codec); + | ^ + +This is a classic macro problem and can indeed lead to bad program +flows. + +Fix by using the usual "do { } while (0)" pattern + +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20200111214736.3002-2-pierre-louis.bossart@linux.intel.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 151099b8c394..a0e7d711cbb5 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -3719,8 +3719,8 @@ static void alc5505_dsp_init(struct hda_codec *codec) + } + + #ifdef HALT_REALTEK_ALC5505 +-#define alc5505_dsp_suspend(codec) /* NOP */ +-#define alc5505_dsp_resume(codec) /* NOP */ ++#define alc5505_dsp_suspend(codec) do { } while (0) /* NOP */ ++#define alc5505_dsp_resume(codec) do { } while (0) /* NOP */ + #else + #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec) + #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec) +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-add-hp-new-mute-led-supported-for-a.patch b/queue-5.4/alsa-hda-realtek-add-hp-new-mute-led-supported-for-a.patch new file mode 100644 index 00000000000..9d89cb71ac6 --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-add-hp-new-mute-led-supported-for-a.patch @@ -0,0 +1,116 @@ +From 95265b38e7214982f4fdee0a258e5ce39a867ccb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 Apr 2020 14:52:42 +0800 +Subject: ALSA: hda/realtek - Add HP new mute led supported for ALC236 + +From: Kailang Yang + +[ Upstream commit 24164f434dc9c23cd34fca1e36acea9d0581bdde ] + +HP new platform has new mute led feature. +COEF index 0x34 bit 5 to control playback mute led. +COEF index 0x35 bit 2 and bit 3 to control Mic mute led. + +[ corrected typos by tiwai ] + +Signed-off-by: Kailang Yang +Link: https://lore.kernel.org/r/6741211598ba499687362ff2aa30626b@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 44 +++++++++++++++++++++++++++++++++++ + 1 file changed, 44 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 16f548cdf290..dab0c5b6bb61 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -4223,6 +4223,23 @@ static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec, + } + } + ++static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec, ++ const struct hda_fixup *fix, ++ int action) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) { ++ spec->mute_led_polarity = 0; ++ spec->mute_led_coef_idx = 0x34; ++ spec->mute_led_coefbit_mask = 1<<5; ++ spec->mute_led_coefbit_on = 0; ++ spec->mute_led_coefbit_off = 1<<5; ++ spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook; ++ spec->gen.vmaster_mute_enum = 1; ++ } ++} ++ + /* turn on/off mic-mute LED per capture hook by coef bit */ + static void alc_hp_cap_micmute_update(struct hda_codec *codec) + { +@@ -4250,6 +4267,20 @@ static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, + } + } + ++static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec, ++ const struct hda_fixup *fix, int action) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) { ++ spec->mic_led_coef_idx = 0x35; ++ spec->mic_led_coefbit_mask = 3<<2; ++ spec->mic_led_coefbit_on = 2<<2; ++ spec->mic_led_coefbit_off = 1<<2; ++ snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); ++ } ++} ++ + static void alc285_fixup_hp_mute_led(struct hda_codec *codec, + const struct hda_fixup *fix, int action) + { +@@ -4257,6 +4288,13 @@ static void alc285_fixup_hp_mute_led(struct hda_codec *codec, + alc285_fixup_hp_coef_micmute_led(codec, fix, action); + } + ++static void alc236_fixup_hp_mute_led(struct hda_codec *codec, ++ const struct hda_fixup *fix, int action) ++{ ++ alc236_fixup_hp_mute_led_coefbit(codec, fix, action); ++ alc236_fixup_hp_coef_micmute_led(codec, fix, action); ++} ++ + #if IS_REACHABLE(CONFIG_INPUT) + static void gpio2_mic_hotkey_event(struct hda_codec *codec, + struct hda_jack_callback *event) +@@ -6056,6 +6094,7 @@ enum { + ALC294_FIXUP_ASUS_COEF_1B, + ALC285_FIXUP_HP_GPIO_LED, + ALC285_FIXUP_HP_MUTE_LED, ++ ALC236_FIXUP_HP_MUTE_LED, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -7208,6 +7247,10 @@ static const struct hda_fixup alc269_fixups[] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc285_fixup_hp_mute_led, + }, ++ [ALC236_FIXUP_HP_MUTE_LED] = { ++ .type = HDA_FIXUP_FUNC, ++ .v.func = alc236_fixup_hp_mute_led, ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -7354,6 +7397,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), + SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED), ++ SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED), + SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), + SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), + SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-add-quirk-for-samsung-notebook.patch b/queue-5.4/alsa-hda-realtek-add-quirk-for-samsung-notebook.patch new file mode 100644 index 00000000000..42df2a6d740 --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-add-quirk-for-samsung-notebook.patch @@ -0,0 +1,62 @@ +From 8a05a1bfece3bcab9a07ef3782602fa17a37c59e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 9 May 2020 20:28:37 -0700 +Subject: ALSA: hda/realtek: Add quirk for Samsung Notebook + +From: Mike Pozulp + +[ Upstream commit 14425f1f521fdfe274a7bb390637c786432e08b4 ] + +Some models of the Samsung Notebook 9 have very quiet and distorted +headphone output. This quirk changes the VREF value of the ALC298 +codec NID 0x1a from default HIZ to new 100. + +[ adjusted to 5.7-base and rearranged in SSID order -- tiwai ] + +Signed-off-by: Mike Pozulp +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207423 +Link: https://lore.kernel.org/r/20200510032838.1989130-1-pozulp.kernel@gmail.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index dab0c5b6bb61..736ddab16512 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -6095,6 +6095,7 @@ enum { + ALC285_FIXUP_HP_GPIO_LED, + ALC285_FIXUP_HP_MUTE_LED, + ALC236_FIXUP_HP_MUTE_LED, ++ ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -7251,6 +7252,13 @@ static const struct hda_fixup alc269_fixups[] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc236_fixup_hp_mute_led, + }, ++ [ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = { ++ .type = HDA_FIXUP_VERBS, ++ .v.verbs = (const struct hda_verb[]) { ++ { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 }, ++ { } ++ }, ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -7446,6 +7454,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), + SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE), + SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), ++ SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET), ++ SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET), + SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8), + SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), + SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC), +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-add-supported-new-mute-led-for-hp.patch b/queue-5.4/alsa-hda-realtek-add-supported-new-mute-led-for-hp.patch new file mode 100644 index 00000000000..eae4a8b4022 --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-add-supported-new-mute-led-for-hp.patch @@ -0,0 +1,149 @@ +From 68ab39a8b7d172615b467bcc4fe19fae70239fd1 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 7 Apr 2020 14:40:20 +0800 +Subject: ALSA: hda/realtek - Add supported new mute Led for HP + +From: Kailang Yang + +[ Upstream commit 431e76c3edd76d84a0ed1eb81a286b2ddecc5ee4 ] + +HP Note Book supported new mute Led. +Hardware PIN was not enough to meet old LED rule. +JD2 to control playback mute led. +GPO3 to control capture mute led. +(ALC285 didn't control GPO3 via verb command) +This two PIN just could control by COEF registers. + +[ corrected typos by tiwai ] + +Signed-off-by: Kailang Yang +Link: https://lore.kernel.org/r/6741211598ba499687362ff2aa30626b@realtek.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 81 +++++++++++++++++++++++++++++++++++ + 1 file changed, 81 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 499c8150ebb8..16f548cdf290 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -86,6 +86,14 @@ struct alc_spec { + + unsigned int gpio_mute_led_mask; + unsigned int gpio_mic_led_mask; ++ unsigned int mute_led_coef_idx; ++ unsigned int mute_led_coefbit_mask; ++ unsigned int mute_led_coefbit_on; ++ unsigned int mute_led_coefbit_off; ++ unsigned int mic_led_coef_idx; ++ unsigned int mic_led_coefbit_mask; ++ unsigned int mic_led_coefbit_on; ++ unsigned int mic_led_coefbit_off; + + hda_nid_t headset_mic_pin; + hda_nid_t headphone_mic_pin; +@@ -4182,6 +4190,73 @@ static void alc280_fixup_hp_gpio4(struct hda_codec *codec, + } + } + ++/* update mute-LED according to the speaker mute state via COEF bit */ ++static void alc_fixup_mute_led_coefbit_hook(void *private_data, int enabled) ++{ ++ struct hda_codec *codec = private_data; ++ struct alc_spec *spec = codec->spec; ++ ++ if (spec->mute_led_polarity) ++ enabled = !enabled; ++ ++ /* temporarily power up/down for setting COEF bit */ ++ enabled ? alc_update_coef_idx(codec, spec->mute_led_coef_idx, ++ spec->mute_led_coefbit_mask, spec->mute_led_coefbit_off) : ++ alc_update_coef_idx(codec, spec->mute_led_coef_idx, ++ spec->mute_led_coefbit_mask, spec->mute_led_coefbit_on); ++} ++ ++static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec, ++ const struct hda_fixup *fix, ++ int action) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) { ++ spec->mute_led_polarity = 0; ++ spec->mute_led_coef_idx = 0x0b; ++ spec->mute_led_coefbit_mask = 1<<3; ++ spec->mute_led_coefbit_on = 1<<3; ++ spec->mute_led_coefbit_off = 0; ++ spec->gen.vmaster_mute.hook = alc_fixup_mute_led_coefbit_hook; ++ spec->gen.vmaster_mute_enum = 1; ++ } ++} ++ ++/* turn on/off mic-mute LED per capture hook by coef bit */ ++static void alc_hp_cap_micmute_update(struct hda_codec *codec) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ if (spec->gen.micmute_led.led_value) ++ alc_update_coef_idx(codec, spec->mic_led_coef_idx, ++ spec->mic_led_coefbit_mask, spec->mic_led_coefbit_on); ++ else ++ alc_update_coef_idx(codec, spec->mic_led_coef_idx, ++ spec->mic_led_coefbit_mask, spec->mic_led_coefbit_off); ++} ++ ++static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec, ++ const struct hda_fixup *fix, int action) ++{ ++ struct alc_spec *spec = codec->spec; ++ ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) { ++ spec->mic_led_coef_idx = 0x19; ++ spec->mic_led_coefbit_mask = 1<<13; ++ spec->mic_led_coefbit_on = 1<<13; ++ spec->mic_led_coefbit_off = 0; ++ snd_hda_gen_add_micmute_led(codec, alc_hp_cap_micmute_update); ++ } ++} ++ ++static void alc285_fixup_hp_mute_led(struct hda_codec *codec, ++ const struct hda_fixup *fix, int action) ++{ ++ alc285_fixup_hp_mute_led_coefbit(codec, fix, action); ++ alc285_fixup_hp_coef_micmute_led(codec, fix, action); ++} ++ + #if IS_REACHABLE(CONFIG_INPUT) + static void gpio2_mic_hotkey_event(struct hda_codec *codec, + struct hda_jack_callback *event) +@@ -5980,6 +6055,7 @@ enum { + ALC294_FIXUP_ASUS_HPE, + ALC294_FIXUP_ASUS_COEF_1B, + ALC285_FIXUP_HP_GPIO_LED, ++ ALC285_FIXUP_HP_MUTE_LED, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -7128,6 +7204,10 @@ static const struct hda_fixup alc269_fixups[] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc285_fixup_hp_gpio_led, + }, ++ [ALC285_FIXUP_HP_MUTE_LED] = { ++ .type = HDA_FIXUP_FUNC, ++ .v.func = alc285_fixup_hp_mute_led, ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -7273,6 +7353,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3), + SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), + SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_LED), ++ SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED), + SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), + SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), + SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-gl503vm-.patch b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-gl503vm-.patch new file mode 100644 index 00000000000..bb5bb01a76e --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-gl503vm-.patch @@ -0,0 +1,68 @@ +From 9ecdea3a6a20f17eba24813273cb87ebecc853a4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 May 2020 14:15:24 +0800 +Subject: ALSA: hda/realtek - Enable headset mic of ASUS GL503VM with ALC295 + +From: Chris Chiu + +[ Upstream commit 9e43342b464f1de570a3ad8256ac77645749ef45 ] + +The ASUS laptop GL503VM with ALC295 can't detect the headset microphone. +The headset microphone does not work until pin 0x19 is enabled for it. + +Signed-off-by: Chris Chiu +Signed-off-by: Daniel Drake +Signed-off-by: Jian-Hong Pan +Link: https://lore.kernel.org/r/20200512061525.133985-1-jian-hong@endlessm.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 736ddab16512..bc2352a3baba 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -6096,6 +6096,7 @@ enum { + ALC285_FIXUP_HP_MUTE_LED, + ALC236_FIXUP_HP_MUTE_LED, + ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, ++ ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -7259,6 +7260,15 @@ static const struct hda_fixup alc269_fixups[] = { + { } + }, + }, ++ [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = { ++ .type = HDA_FIXUP_PINS, ++ .v.pins = (const struct hda_pintbl[]) { ++ { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ ++ { } ++ }, ++ .chained = true, ++ .chain_id = ALC269_FIXUP_HEADSET_MODE ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -8072,6 +8082,14 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { + {0x12, 0x90a60130}, + {0x17, 0x90170110}, + {0x21, 0x03211020}), ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, ++ {0x12, 0x90a60130}, ++ {0x17, 0x90170110}, ++ {0x21, 0x03211020}), ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, ++ {0x12, 0x90a60130}, ++ {0x17, 0x90170110}, ++ {0x21, 0x03211020}), + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, + {0x14, 0x90170110}, + {0x21, 0x04211020}), +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux550ge-.patch b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux550ge-.patch new file mode 100644 index 00000000000..18e93e9767a --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux550ge-.patch @@ -0,0 +1,39 @@ +From 506abb03df987660f6827f1f2691f253ea4e00b8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 May 2020 14:15:26 +0800 +Subject: ALSA: hda/realtek - Enable headset mic of ASUS UX550GE with ALC295 + +From: Jian-Hong Pan + +[ Upstream commit ad97d667854c2fbce05a004e107f358ef4b04cf6 ] + +The ASUS laptop UX550GE with ALC295 can't detect the headset microphone +until ALC295_FIXUP_ASUS_MIC_NO_PRESENCE quirk applied. + +Signed-off-by: Jian-Hong Pan +Signed-off-by: Daniel Drake +Link: https://lore.kernel.org/r/20200512061525.133985-2-jian-hong@endlessm.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index bc2352a3baba..1efaeb09ec3f 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -8082,6 +8082,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { + {0x12, 0x90a60130}, + {0x17, 0x90170110}, + {0x21, 0x03211020}), ++ SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, ++ {0x12, 0x90a60120}, ++ {0x17, 0x90170110}, ++ {0x21, 0x04211030}), + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE, + {0x12, 0x90a60130}, + {0x17, 0x90170110}, +-- +2.25.1 + diff --git a/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux581lv-.patch b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux581lv-.patch new file mode 100644 index 00000000000..34536415706 --- /dev/null +++ b/queue-5.4/alsa-hda-realtek-enable-headset-mic-of-asus-ux581lv-.patch @@ -0,0 +1,36 @@ +From 0ccfdb70efb56d600b1773fdf306974742a80ebe Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 12 May 2020 14:15:28 +0800 +Subject: ALSA: hda/realtek: Enable headset mic of ASUS UX581LV with ALC295 + +From: Jian-Hong Pan + +[ Upstream commit 7900e81797613b92f855f9921392a7430cbdf88c ] + +The ASUS UX581LV laptop's audio (1043:19e1) with ALC295 can't detect the +headset microphone until ALC295_FIXUP_ASUS_MIC_NO_PRESENCE quirk +applied. + +Signed-off-by: Jian-Hong Pan +Link: https://lore.kernel.org/r/20200512061525.133985-3-jian-hong@endlessm.com +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 1efaeb09ec3f..afc20f73b42d 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -7436,6 +7436,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC), + SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC), + SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE), ++ SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE), + SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), + SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC), + SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B), +-- +2.25.1 + diff --git a/queue-5.4/series b/queue-5.4/series index 01ea50d1d5e..28aaa22bac3 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -46,3 +46,12 @@ drm-amd-display-prevent-dpcd-reads-with-passive-dong.patch kvm-selftests-fix-build-for-evmcs.h.patch arm-futex-address-build-warning.patch scripts-gdb-repair-rb_first-and-rb_last.patch +alsa-hda-constify-and-cleanup-static-nodeid-tables.patch +alsa-hda-patch_realtek-fix-empty-macro-usage-in-if-b.patch +alsa-hda-manage-concurrent-reg-access-more-properly.patch +alsa-hda-realtek-add-supported-new-mute-led-for-hp.patch +alsa-hda-realtek-add-hp-new-mute-led-supported-for-a.patch +alsa-hda-realtek-add-quirk-for-samsung-notebook.patch +alsa-hda-realtek-enable-headset-mic-of-asus-gl503vm-.patch +alsa-hda-realtek-enable-headset-mic-of-asus-ux550ge-.patch +alsa-hda-realtek-enable-headset-mic-of-asus-ux581lv-.patch