Skip to content

Commit

Permalink
Merge tag 'sound-fix-5.7-rc1' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
 "A collection of small fixes gathered since the previous update.

  ALSA core:
   - Regression fix for OSS PCM emulation

  ASoC:
   - Trivial fixes in reg bit mask ops, DAPM, DPCM and topology
   - Lots of fixes for Intel-based devices
   - Minor fixes for AMD, STM32, Qualcomm, Realtek

  Others:
   - Fixes for the bugs in mixer handling in HD-audio and ice1724
     drivers that were caught by the recent kctl validator
   - New quirks for HD-audio and USB-audio

  Also this contains a fix for EDD firmware fix, which slipped from
  anyone's hands"

* tag 'sound-fix-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (35 commits)
  ALSA: hda: Add driver blacklist
  ALSA: usb-audio: Add mixer workaround for TRX40 and co
  ALSA: hda/realtek - Add quirk for MSI GL63
  ALSA: ice1724: Fix invalid access for enumerated ctl items
  ALSA: hda: Fix potential access overflow in beep helper
  ASoC: cs4270: pull reset GPIO low then high
  ALSA: hda/realtek - Add HP new mute led supported for ALC236
  ALSA: hda/realtek - Add supported new mute Led for HP
  ASoC: rt5645: Add platform-data for Medion E1239T
  ASoC: Intel: bytcr_rt5640: Add quirk for MPMAN MPWIN895CL tablet
  ASoC: stm32: sai: Add missing cleanup
  ALSA: usb-audio: Add registration quirk for Kingston HyperX Cloud Alpha S
  ASoC: Intel: atom: Fix uninitialized variable compiler warning
  ASoC: Intel: atom: Check drv->lock is locked in sst_fill_and_send_cmd_unlocked
  ASoC: Intel: atom: Take the drv->lock mutex before calling sst_send_slot_map()
  ASoC: SOF: Turn "firmware boot complete" message into a dbg message
  ALSA: usb-audio: Add Pioneer DJ DJM-250MK2 quirk
  ALSA: pcm: oss: Fix regression by buffer overflow fix (again)
  ALSA: pcm: oss: Fix regression by buffer overflow fix
  edd: Use scnprintf() for avoiding potential buffer overflow
  ...
  • Loading branch information
torvalds committed Apr 10, 2020
2 parents 93f3321 + ddd5609 commit 4aafdf6
Show file tree
Hide file tree
Showing 32 changed files with 329 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ required:
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c@0 {
i2c {
#address-cells = <1>;
#size-cells = <0>;
Expand Down
6 changes: 3 additions & 3 deletions drivers/firmware/edd.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ edd_show_legacy_max_cylinder(struct edd_device *edev, char *buf)
if (!info || !buf)
return -EINVAL;

p += snprintf(p, left, "%u\n", info->legacy_max_cylinder);
p += scnprintf(p, left, "%u\n", info->legacy_max_cylinder);
return (p - buf);
}

Expand All @@ -356,7 +356,7 @@ edd_show_legacy_max_head(struct edd_device *edev, char *buf)
if (!info || !buf)
return -EINVAL;

p += snprintf(p, left, "%u\n", info->legacy_max_head);
p += scnprintf(p, left, "%u\n", info->legacy_max_head);
return (p - buf);
}

Expand All @@ -371,7 +371,7 @@ edd_show_legacy_sectors_per_track(struct edd_device *edev, char *buf)
if (!info || !buf)
return -EINVAL;

p += snprintf(p, left, "%u\n", info->legacy_sectors_per_track);
p += scnprintf(p, left, "%u\n", info->legacy_sectors_per_track);
return (p - buf);
}

Expand Down
2 changes: 1 addition & 1 deletion include/sound/soc-dai.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ struct snd_soc_dai {

/* bit field */
unsigned int probed:1;
unsigned int started:1;
unsigned int started[SNDRV_PCM_STREAM_LAST + 1];
};

static inline struct snd_soc_pcm_stream *
Expand Down
22 changes: 12 additions & 10 deletions sound/core/oss/pcm_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
}

static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
snd_pcm_sframes_t frames)
snd_pcm_sframes_t frames,
bool check_size)
{
struct snd_pcm_plugin *plugin, *plugin_next;

Expand All @@ -209,21 +210,22 @@ static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
if (frames < 0)
return frames;
}
if (frames > plugin->buf_frames)
if (check_size && frames > plugin->buf_frames)
frames = plugin->buf_frames;
plugin = plugin_next;
}
return frames;
}

static snd_pcm_sframes_t calc_src_frames(struct snd_pcm_substream *plug,
snd_pcm_sframes_t frames)
snd_pcm_sframes_t frames,
bool check_size)
{
struct snd_pcm_plugin *plugin, *plugin_prev;

plugin = snd_pcm_plug_last(plug);
while (plugin && frames > 0) {
if (frames > plugin->buf_frames)
if (check_size && frames > plugin->buf_frames)
frames = plugin->buf_frames;
plugin_prev = plugin->prev;
if (plugin->src_frames) {
Expand All @@ -242,9 +244,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
return -ENXIO;
switch (snd_pcm_plug_stream(plug)) {
case SNDRV_PCM_STREAM_PLAYBACK:
return calc_src_frames(plug, drv_frames);
return calc_src_frames(plug, drv_frames, false);
case SNDRV_PCM_STREAM_CAPTURE:
return calc_dst_frames(plug, drv_frames);
return calc_dst_frames(plug, drv_frames, false);
default:
snd_BUG();
return -EINVAL;
Expand All @@ -257,9 +259,9 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
return -ENXIO;
switch (snd_pcm_plug_stream(plug)) {
case SNDRV_PCM_STREAM_PLAYBACK:
return calc_dst_frames(plug, clt_frames);
return calc_dst_frames(plug, clt_frames, false);
case SNDRV_PCM_STREAM_CAPTURE:
return calc_src_frames(plug, clt_frames);
return calc_src_frames(plug, clt_frames, false);
default:
snd_BUG();
return -EINVAL;
Expand Down Expand Up @@ -622,7 +624,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st
src_channels = dst_channels;
plugin = next;
}
return snd_pcm_plug_client_size(plug, frames);
return calc_src_frames(plug, frames, true);
}

snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, struct snd_pcm_plugin_channel *dst_channels_final, snd_pcm_uframes_t size)
Expand All @@ -632,7 +634,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str
snd_pcm_sframes_t frames = size;
int err;

frames = snd_pcm_plug_slave_size(plug, frames);
frames = calc_src_frames(plug, frames, true);
if (frames < 0)
return frames;

Expand Down
6 changes: 5 additions & 1 deletion sound/pci/hda/hda_beep.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct hda_beep *beep = codec->beep;
int chs = get_amp_channels(kcontrol);

if (beep && (!beep->enabled || !ctl_has_mute(kcontrol))) {
ucontrol->value.integer.value[0] =
if (chs & 1)
ucontrol->value.integer.value[0] = beep->enabled;
if (chs & 2)
ucontrol->value.integer.value[1] = beep->enabled;
return 0;
}
Expand Down
16 changes: 16 additions & 0 deletions sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,17 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
#endif
}

/* Blacklist for skipping the whole probe:
* some HD-audio PCI entries are exposed without any codecs, and such devices
* should be ignored from the beginning.
*/
static const struct snd_pci_quirk driver_blacklist[] = {
SND_PCI_QUIRK(0x1043, 0x874f, "ASUS ROG Zenith II / Strix", 0),
SND_PCI_QUIRK(0x1462, 0xcb59, "MSI TRX40 Creator", 0),
SND_PCI_QUIRK(0x1462, 0xcb60, "MSI TRX40", 0),
{}
};

static const struct hda_controller_ops pci_hda_ops = {
.disable_msi_reset_irq = disable_msi_reset_irq,
.pcm_mmap_prepare = pcm_mmap_prepare,
Expand All @@ -2092,6 +2103,11 @@ static int azx_probe(struct pci_dev *pci,
bool schedule_probe;
int err;

if (snd_pci_quirk_lookup(pci, driver_blacklist)) {
dev_info(&pci->dev, "Skipping the blacklisted device\n");
return -ENODEV;
}

if (dev >= SNDRV_CARDS)
return -ENODEV;
if (!enable[dev]) {
Expand Down
127 changes: 127 additions & 0 deletions sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2447,6 +2455,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
Expand Down Expand Up @@ -4178,6 +4187,111 @@ 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;
}
}

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)
{
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 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)
{
alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
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)
Expand Down Expand Up @@ -5964,6 +6078,8 @@ enum {
ALC285_FIXUP_THINKPAD_HEADSET_JACK,
ALC294_FIXUP_ASUS_HPE,
ALC285_FIXUP_HP_GPIO_LED,
ALC285_FIXUP_HP_MUTE_LED,
ALC236_FIXUP_HP_MUTE_LED,
};

static const struct hda_fixup alc269_fixups[] = {
Expand Down Expand Up @@ -7089,6 +7205,14 @@ 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,
},
[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[] = {
Expand Down Expand Up @@ -7234,6 +7358,8 @@ 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(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),
Expand Down Expand Up @@ -7325,6 +7451,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Yoga 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
SND_PCI_QUIRK(0x17aa, 0x2293, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
Expand Down
4 changes: 2 additions & 2 deletions sound/pci/ice1712/prodigy_hifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ static int wm_adc_mux_enum_get(struct snd_kcontrol *kcontrol,
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);

mutex_lock(&ice->gpio_mutex);
ucontrol->value.integer.value[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
ucontrol->value.enumerated.item[0] = wm_get(ice, WM_ADC_MUX) & 0x1f;
mutex_unlock(&ice->gpio_mutex);
return 0;
}
Expand All @@ -550,7 +550,7 @@ static int wm_adc_mux_enum_put(struct snd_kcontrol *kcontrol,

mutex_lock(&ice->gpio_mutex);
oval = wm_get(ice, WM_ADC_MUX);
nval = (oval & 0xe0) | ucontrol->value.integer.value[0];
nval = (oval & 0xe0) | ucontrol->value.enumerated.item[0];
if (nval != oval) {
wm_put(ice, WM_ADC_MUX, nval);
change = 1;
Expand Down
1 change: 1 addition & 0 deletions sound/soc/amd/raven/acp3x-i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream,
rv_writel(adata->tdm_fmt, rtd->acp3x_base + frmt_reg);
}
val = rv_readl(rtd->acp3x_base + reg_val);
val &= ~ACP3x_ITER_IRER_SAMP_LEN_MASK;
val = val | (rtd->xfer_resolution << 3);
rv_writel(val, rtd->acp3x_base + reg_val);
return 0;
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/amd/raven/acp3x.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#define ACP_POWERED_OFF 0x02
#define ACP_POWER_OFF_IN_PROGRESS 0x03

#define ACP3x_ITER_IRER_SAMP_LEN_MASK 0x38

struct acp3x_platform_info {
u16 play_i2s_instance;
u16 cap_i2s_instance;
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/bcm/bcm63xx-pcm-whistler.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ bcm63xx_pcm_pointer(struct snd_soc_component *component,
snd_pcm_uframes_t x;
struct bcm63xx_runtime_data *prtd = substream->runtime->private_data;

if ((void *)prtd->dma_addr_next == NULL)
if (!prtd->dma_addr_next)
prtd->dma_addr_next = substream->runtime->dma_addr;

x = bytes_to_frames(substream->runtime,
Expand Down
Loading

0 comments on commit 4aafdf6

Please sign in to comment.