Skip to content

Commit 81f3011

Browse files
committed
Merge tag 'sound-5.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "The only common change is the regression fix of the previous PCM fix patch for managed buffers while the rest are usual suspects, USB-audio and HD-audio device-specific quirks. The change for UAC2 clock validation workaround became a bit big, but the changes are fairly straightforward" * tag 'sound-5.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: pcm: Fix double hw_free calls ALSA: usb-audio: Add clock validity quirk for Denon MC7000/MCX8000 ALSA: hda/realtek - Fix silent output on MSI-GL73 ALSA: hda/realtek - Add more codec supported Headset Button ALSA: usb-audio: Apply sample rate quirk for Audioengine D1 ALSA: usb-audio: Fix UAC2/3 effect unit parsing ALSA: usb-audio: Apply 48kHz fixed rate playback for Jabra Evolve 65 headset
2 parents 3f0d329 + 0fbb027 commit 81f3011

File tree

7 files changed

+105
-46
lines changed

7 files changed

+105
-46
lines changed

sound/core/pcm_native.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,8 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream)
25942594

25952595
snd_pcm_drop(substream);
25962596
if (substream->hw_opened) {
2597-
do_hw_free(substream);
2597+
if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
2598+
do_hw_free(substream);
25982599
substream->ops->close(substream);
25992600
substream->hw_opened = 0;
26002601
}

sound/pci/hda/patch_realtek.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
24472447
SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
24482448
SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
24492449
SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2450+
SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
24502451
SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
24512452
SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
24522453
SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
@@ -5701,8 +5702,11 @@ static void alc_fixup_headset_jack(struct hda_codec *codec,
57015702
break;
57025703
case HDA_FIXUP_ACT_INIT:
57035704
switch (codec->core.vendor_id) {
5705+
case 0x10ec0215:
57045706
case 0x10ec0225:
5707+
case 0x10ec0285:
57055708
case 0x10ec0295:
5709+
case 0x10ec0289:
57065710
case 0x10ec0299:
57075711
alc_write_coef_idx(codec, 0x48, 0xd011);
57085712
alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);

sound/usb/clock.c

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,42 @@ static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_i
151151
return ret;
152152
}
153153

154+
/*
155+
* Assume the clock is valid if clock source supports only one single sample
156+
* rate, the terminal is connected directly to it (there is no clock selector)
157+
* and clock type is internal. This is to deal with some Denon DJ controllers
158+
* that always reports that clock is invalid.
159+
*/
160+
static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip,
161+
struct audioformat *fmt,
162+
int source_id)
163+
{
164+
if (fmt->protocol == UAC_VERSION_2) {
165+
struct uac_clock_source_descriptor *cs_desc =
166+
snd_usb_find_clock_source(chip->ctrl_intf, source_id);
167+
168+
if (!cs_desc)
169+
return false;
170+
171+
return (fmt->nr_rates == 1 &&
172+
(fmt->clock & 0xff) == cs_desc->bClockID &&
173+
(cs_desc->bmAttributes & 0x3) !=
174+
UAC_CLOCK_SOURCE_TYPE_EXT);
175+
}
176+
177+
return false;
178+
}
179+
154180
static bool uac_clock_source_is_valid(struct snd_usb_audio *chip,
155-
int protocol,
181+
struct audioformat *fmt,
156182
int source_id)
157183
{
158184
int err;
159185
unsigned char data;
160186
struct usb_device *dev = chip->dev;
161187
u32 bmControls;
162188

163-
if (protocol == UAC_VERSION_3) {
189+
if (fmt->protocol == UAC_VERSION_3) {
164190
struct uac3_clock_source_descriptor *cs_desc =
165191
snd_usb_find_clock_source_v3(chip->ctrl_intf, source_id);
166192

@@ -194,10 +220,14 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip,
194220
return false;
195221
}
196222

197-
return data ? true : false;
223+
if (data)
224+
return true;
225+
else
226+
return uac_clock_source_is_valid_quirk(chip, fmt, source_id);
198227
}
199228

200-
static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
229+
static int __uac_clock_find_source(struct snd_usb_audio *chip,
230+
struct audioformat *fmt, int entity_id,
201231
unsigned long *visited, bool validate)
202232
{
203233
struct uac_clock_source_descriptor *source;
@@ -217,7 +247,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
217247
source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id);
218248
if (source) {
219249
entity_id = source->bClockID;
220-
if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_2,
250+
if (validate && !uac_clock_source_is_valid(chip, fmt,
221251
entity_id)) {
222252
usb_audio_err(chip,
223253
"clock source %d is not valid, cannot use\n",
@@ -248,8 +278,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
248278
}
249279

250280
cur = ret;
251-
ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1],
252-
visited, validate);
281+
ret = __uac_clock_find_source(chip, fmt,
282+
selector->baCSourceID[ret - 1],
283+
visited, validate);
253284
if (!validate || ret > 0 || !chip->autoclock)
254285
return ret;
255286

@@ -260,8 +291,9 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
260291
if (i == cur)
261292
continue;
262293

263-
ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1],
264-
visited, true);
294+
ret = __uac_clock_find_source(chip, fmt,
295+
selector->baCSourceID[i - 1],
296+
visited, true);
265297
if (ret < 0)
266298
continue;
267299

@@ -281,14 +313,16 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id,
281313
/* FIXME: multipliers only act as pass-thru element for now */
282314
multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id);
283315
if (multiplier)
284-
return __uac_clock_find_source(chip, multiplier->bCSourceID,
285-
visited, validate);
316+
return __uac_clock_find_source(chip, fmt,
317+
multiplier->bCSourceID,
318+
visited, validate);
286319

287320
return -EINVAL;
288321
}
289322

290-
static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
291-
unsigned long *visited, bool validate)
323+
static int __uac3_clock_find_source(struct snd_usb_audio *chip,
324+
struct audioformat *fmt, int entity_id,
325+
unsigned long *visited, bool validate)
292326
{
293327
struct uac3_clock_source_descriptor *source;
294328
struct uac3_clock_selector_descriptor *selector;
@@ -307,7 +341,7 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
307341
source = snd_usb_find_clock_source_v3(chip->ctrl_intf, entity_id);
308342
if (source) {
309343
entity_id = source->bClockID;
310-
if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_3,
344+
if (validate && !uac_clock_source_is_valid(chip, fmt,
311345
entity_id)) {
312346
usb_audio_err(chip,
313347
"clock source %d is not valid, cannot use\n",
@@ -338,7 +372,8 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
338372
}
339373

340374
cur = ret;
341-
ret = __uac3_clock_find_source(chip, selector->baCSourceID[ret - 1],
375+
ret = __uac3_clock_find_source(chip, fmt,
376+
selector->baCSourceID[ret - 1],
342377
visited, validate);
343378
if (!validate || ret > 0 || !chip->autoclock)
344379
return ret;
@@ -350,8 +385,9 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
350385
if (i == cur)
351386
continue;
352387

353-
ret = __uac3_clock_find_source(chip, selector->baCSourceID[i - 1],
354-
visited, true);
388+
ret = __uac3_clock_find_source(chip, fmt,
389+
selector->baCSourceID[i - 1],
390+
visited, true);
355391
if (ret < 0)
356392
continue;
357393

@@ -372,7 +408,8 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
372408
multiplier = snd_usb_find_clock_multiplier_v3(chip->ctrl_intf,
373409
entity_id);
374410
if (multiplier)
375-
return __uac3_clock_find_source(chip, multiplier->bCSourceID,
411+
return __uac3_clock_find_source(chip, fmt,
412+
multiplier->bCSourceID,
376413
visited, validate);
377414

378415
return -EINVAL;
@@ -389,18 +426,18 @@ static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id,
389426
*
390427
* Returns the clock source UnitID (>=0) on success, or an error.
391428
*/
392-
int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol,
393-
int entity_id, bool validate)
429+
int snd_usb_clock_find_source(struct snd_usb_audio *chip,
430+
struct audioformat *fmt, bool validate)
394431
{
395432
DECLARE_BITMAP(visited, 256);
396433
memset(visited, 0, sizeof(visited));
397434

398-
switch (protocol) {
435+
switch (fmt->protocol) {
399436
case UAC_VERSION_2:
400-
return __uac_clock_find_source(chip, entity_id, visited,
437+
return __uac_clock_find_source(chip, fmt, fmt->clock, visited,
401438
validate);
402439
case UAC_VERSION_3:
403-
return __uac3_clock_find_source(chip, entity_id, visited,
440+
return __uac3_clock_find_source(chip, fmt, fmt->clock, visited,
404441
validate);
405442
default:
406443
return -EINVAL;
@@ -501,17 +538,15 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, int iface,
501538
* automatic clock selection if the current clock is not
502539
* valid.
503540
*/
504-
clock = snd_usb_clock_find_source(chip, fmt->protocol,
505-
fmt->clock, true);
541+
clock = snd_usb_clock_find_source(chip, fmt, true);
506542
if (clock < 0) {
507543
/* We did not find a valid clock, but that might be
508544
* because the current sample rate does not match an
509545
* external clock source. Try again without validation
510546
* and we will do another validation after setting the
511547
* rate.
512548
*/
513-
clock = snd_usb_clock_find_source(chip, fmt->protocol,
514-
fmt->clock, false);
549+
clock = snd_usb_clock_find_source(chip, fmt, false);
515550
if (clock < 0)
516551
return clock;
517552
}
@@ -577,7 +612,7 @@ static int set_sample_rate_v2v3(struct snd_usb_audio *chip, int iface,
577612

578613
validation:
579614
/* validate clock after rate change */
580-
if (!uac_clock_source_is_valid(chip, fmt->protocol, clock))
615+
if (!uac_clock_source_is_valid(chip, fmt, clock))
581616
return -ENXIO;
582617
return 0;
583618
}

sound/usb/clock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
66
struct usb_host_interface *alts,
77
struct audioformat *fmt, int rate);
88

9-
int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol,
10-
int entity_id, bool validate);
9+
int snd_usb_clock_find_source(struct snd_usb_audio *chip,
10+
struct audioformat *fmt, bool validate);
1111

1212
#endif /* __USBAUDIO_CLOCK_H */

sound/usb/format.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
151151
return pcm_formats;
152152
}
153153

154+
static int set_fixed_rate(struct audioformat *fp, int rate, int rate_bits)
155+
{
156+
kfree(fp->rate_table);
157+
fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL);
158+
if (!fp->rate_table)
159+
return -ENOMEM;
160+
fp->nr_rates = 1;
161+
fp->rate_min = rate;
162+
fp->rate_max = rate;
163+
fp->rates = rate_bits;
164+
fp->rate_table[0] = rate;
165+
return 0;
166+
}
154167

155168
/*
156169
* parse the format descriptor and stores the possible sample rates
@@ -223,6 +236,14 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
223236
fp->rate_min = combine_triple(&fmt[offset + 1]);
224237
fp->rate_max = combine_triple(&fmt[offset + 4]);
225238
}
239+
240+
/* Jabra Evolve 65 headset */
241+
if (chip->usb_id == USB_ID(0x0b0e, 0x030b)) {
242+
/* only 48kHz for playback while keeping 16kHz for capture */
243+
if (fp->nr_rates != 1)
244+
return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000);
245+
}
246+
226247
return 0;
227248
}
228249

@@ -299,17 +320,7 @@ static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip,
299320
case USB_ID(0x0e41, 0x4248): /* Line6 Helix >= fw 2.82 */
300321
case USB_ID(0x0e41, 0x4249): /* Line6 Helix Rack >= fw 2.82 */
301322
case USB_ID(0x0e41, 0x424a): /* Line6 Helix LT >= fw 2.82 */
302-
/* supported rates: 48Khz */
303-
kfree(fp->rate_table);
304-
fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL);
305-
if (!fp->rate_table)
306-
return -ENOMEM;
307-
fp->nr_rates = 1;
308-
fp->rate_min = 48000;
309-
fp->rate_max = 48000;
310-
fp->rates = SNDRV_PCM_RATE_48000;
311-
fp->rate_table[0] = 48000;
312-
return 0;
323+
return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000);
313324
}
314325

315326
return -ENODEV;
@@ -325,8 +336,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip,
325336
struct usb_device *dev = chip->dev;
326337
unsigned char tmp[2], *data;
327338
int nr_triplets, data_size, ret = 0, ret_l6;
328-
int clock = snd_usb_clock_find_source(chip, fp->protocol,
329-
fp->clock, false);
339+
int clock = snd_usb_clock_find_source(chip, fp, false);
330340

331341
if (clock < 0) {
332342
dev_err(&dev->dev,

sound/usb/mixer.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,15 @@ static int parse_term_proc_unit(struct mixer_build *state,
897897
return 0;
898898
}
899899

900+
static int parse_term_effect_unit(struct mixer_build *state,
901+
struct usb_audio_term *term,
902+
void *p1, int id)
903+
{
904+
term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */
905+
term->id = id;
906+
return 0;
907+
}
908+
900909
static int parse_term_uac2_clock_source(struct mixer_build *state,
901910
struct usb_audio_term *term,
902911
void *p1, int id)
@@ -981,8 +990,7 @@ static int __check_input_term(struct mixer_build *state, int id,
981990
UAC3_PROCESSING_UNIT);
982991
case PTYPE(UAC_VERSION_2, UAC2_EFFECT_UNIT):
983992
case PTYPE(UAC_VERSION_3, UAC3_EFFECT_UNIT):
984-
return parse_term_proc_unit(state, term, p1, id,
985-
UAC3_EFFECT_UNIT);
993+
return parse_term_effect_unit(state, term, p1, id);
986994
case PTYPE(UAC_VERSION_1, UAC1_EXTENSION_UNIT):
987995
case PTYPE(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2):
988996
case PTYPE(UAC_VERSION_3, UAC3_EXTENSION_UNIT):

sound/usb/quirks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
14401440
case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
14411441
case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
14421442
case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */
1443+
case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */
14431444
return true;
14441445
}
14451446

0 commit comments

Comments
 (0)