Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+105 -46
+2 -1
sound/core/pcm_native.c
··· 2594 2594 2595 2595 snd_pcm_drop(substream); 2596 2596 if (substream->hw_opened) { 2597 - do_hw_free(substream); 2597 + if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) 2598 + do_hw_free(substream); 2598 2599 substream->ops->close(substream); 2599 2600 substream->hw_opened = 0; 2600 2601 }
+4
sound/pci/hda/patch_realtek.c
··· 2447 2447 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), 2448 2448 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), 2449 2449 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), 2450 2451 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), 2451 2452 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), 2452 2453 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), ··· 5702 5701 break; 5703 5702 case HDA_FIXUP_ACT_INIT: 5704 5703 switch (codec->core.vendor_id) { 5704 + case 0x10ec0215: 5705 5705 case 0x10ec0225: 5706 + case 0x10ec0285: 5706 5707 case 0x10ec0295: 5708 + case 0x10ec0289: 5707 5709 case 0x10ec0299: 5708 5710 alc_write_coef_idx(codec, 0x48, 0xd011); 5709 5711 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
+63 -28
sound/usb/clock.c
··· 151 151 return ret; 152 152 } 153 153 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 + 154 180 static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, 155 - int protocol, 181 + struct audioformat *fmt, 156 182 int source_id) 157 183 { 158 184 int err; ··· 186 160 struct usb_device *dev = chip->dev; 187 161 u32 bmControls; 188 162 189 - if (protocol == UAC_VERSION_3) { 163 + if (fmt->protocol == UAC_VERSION_3) { 190 164 struct uac3_clock_source_descriptor *cs_desc = 191 165 snd_usb_find_clock_source_v3(chip->ctrl_intf, source_id); 192 166 ··· 220 194 return false; 221 195 } 222 196 223 - return data ? true : false; 197 + if (data) 198 + return true; 199 + else 200 + return uac_clock_source_is_valid_quirk(chip, fmt, source_id); 224 201 } 225 202 226 - static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, 203 + static int __uac_clock_find_source(struct snd_usb_audio *chip, 204 + struct audioformat *fmt, int entity_id, 227 205 unsigned long *visited, bool validate) 228 206 { 229 207 struct uac_clock_source_descriptor *source; ··· 247 217 source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); 248 218 if (source) { 249 219 entity_id = source->bClockID; 250 - if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_2, 220 + if (validate && !uac_clock_source_is_valid(chip, fmt, 251 221 entity_id)) { 252 222 usb_audio_err(chip, 253 223 "clock source %d is not valid, cannot use\n", ··· 278 248 } 279 249 280 250 cur = ret; 281 - ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1], 282 - visited, validate); 251 + ret = __uac_clock_find_source(chip, fmt, 252 + selector->baCSourceID[ret - 1], 253 + visited, validate); 283 254 if (!validate || ret > 0 || !chip->autoclock) 284 255 return ret; 285 256 ··· 291 260 if (i == cur) 292 261 continue; 293 262 294 - ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1], 295 - visited, true); 263 + ret = __uac_clock_find_source(chip, fmt, 264 + selector->baCSourceID[i - 1], 265 + visited, true); 296 266 if (ret < 0) 297 267 continue; 298 268 ··· 313 281 /* FIXME: multipliers only act as pass-thru element for now */ 314 282 multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); 315 283 if (multiplier) 316 - return __uac_clock_find_source(chip, multiplier->bCSourceID, 317 - visited, validate); 284 + return __uac_clock_find_source(chip, fmt, 285 + multiplier->bCSourceID, 286 + visited, validate); 318 287 319 288 return -EINVAL; 320 289 } 321 290 322 - static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, 323 - unsigned long *visited, bool validate) 291 + static int __uac3_clock_find_source(struct snd_usb_audio *chip, 292 + struct audioformat *fmt, int entity_id, 293 + unsigned long *visited, bool validate) 324 294 { 325 295 struct uac3_clock_source_descriptor *source; 326 296 struct uac3_clock_selector_descriptor *selector; ··· 341 307 source = snd_usb_find_clock_source_v3(chip->ctrl_intf, entity_id); 342 308 if (source) { 343 309 entity_id = source->bClockID; 344 - if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_3, 310 + if (validate && !uac_clock_source_is_valid(chip, fmt, 345 311 entity_id)) { 346 312 usb_audio_err(chip, 347 313 "clock source %d is not valid, cannot use\n", ··· 372 338 } 373 339 374 340 cur = ret; 375 - ret = __uac3_clock_find_source(chip, selector->baCSourceID[ret - 1], 341 + ret = __uac3_clock_find_source(chip, fmt, 342 + selector->baCSourceID[ret - 1], 376 343 visited, validate); 377 344 if (!validate || ret > 0 || !chip->autoclock) 378 345 return ret; ··· 385 350 if (i == cur) 386 351 continue; 387 352 388 - ret = __uac3_clock_find_source(chip, selector->baCSourceID[i - 1], 389 - visited, true); 353 + ret = __uac3_clock_find_source(chip, fmt, 354 + selector->baCSourceID[i - 1], 355 + visited, true); 390 356 if (ret < 0) 391 357 continue; 392 358 ··· 408 372 multiplier = snd_usb_find_clock_multiplier_v3(chip->ctrl_intf, 409 373 entity_id); 410 374 if (multiplier) 411 - return __uac3_clock_find_source(chip, multiplier->bCSourceID, 375 + return __uac3_clock_find_source(chip, fmt, 376 + multiplier->bCSourceID, 412 377 visited, validate); 413 378 414 379 return -EINVAL; ··· 426 389 * 427 390 * Returns the clock source UnitID (>=0) on success, or an error. 428 391 */ 429 - int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol, 430 - int entity_id, bool validate) 392 + int snd_usb_clock_find_source(struct snd_usb_audio *chip, 393 + struct audioformat *fmt, bool validate) 431 394 { 432 395 DECLARE_BITMAP(visited, 256); 433 396 memset(visited, 0, sizeof(visited)); 434 397 435 - switch (protocol) { 398 + switch (fmt->protocol) { 436 399 case UAC_VERSION_2: 437 - return __uac_clock_find_source(chip, entity_id, visited, 400 + return __uac_clock_find_source(chip, fmt, fmt->clock, visited, 438 401 validate); 439 402 case UAC_VERSION_3: 440 - return __uac3_clock_find_source(chip, entity_id, visited, 403 + return __uac3_clock_find_source(chip, fmt, fmt->clock, visited, 441 404 validate); 442 405 default: 443 406 return -EINVAL; ··· 538 501 * automatic clock selection if the current clock is not 539 502 * valid. 540 503 */ 541 - clock = snd_usb_clock_find_source(chip, fmt->protocol, 542 - fmt->clock, true); 504 + clock = snd_usb_clock_find_source(chip, fmt, true); 543 505 if (clock < 0) { 544 506 /* We did not find a valid clock, but that might be 545 507 * because the current sample rate does not match an ··· 546 510 * and we will do another validation after setting the 547 511 * rate. 548 512 */ 549 - clock = snd_usb_clock_find_source(chip, fmt->protocol, 550 - fmt->clock, false); 513 + clock = snd_usb_clock_find_source(chip, fmt, false); 551 514 if (clock < 0) 552 515 return clock; 553 516 } ··· 612 577 613 578 validation: 614 579 /* validate clock after rate change */ 615 - if (!uac_clock_source_is_valid(chip, fmt->protocol, clock)) 580 + if (!uac_clock_source_is_valid(chip, fmt, clock)) 616 581 return -ENXIO; 617 582 return 0; 618 583 }
+2 -2
sound/usb/clock.h
··· 6 6 struct usb_host_interface *alts, 7 7 struct audioformat *fmt, int rate); 8 8 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); 11 11 12 12 #endif /* __USBAUDIO_CLOCK_H */
+23 -13
sound/usb/format.c
··· 151 151 return pcm_formats; 152 152 } 153 153 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 + } 154 167 155 168 /* 156 169 * parse the format descriptor and stores the possible sample rates ··· 236 223 fp->rate_min = combine_triple(&fmt[offset + 1]); 237 224 fp->rate_max = combine_triple(&fmt[offset + 4]); 238 225 } 226 + 227 + /* Jabra Evolve 65 headset */ 228 + if (chip->usb_id == USB_ID(0x0b0e, 0x030b)) { 229 + /* only 48kHz for playback while keeping 16kHz for capture */ 230 + if (fp->nr_rates != 1) 231 + return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000); 232 + } 233 + 239 234 return 0; 240 235 } 241 236 ··· 320 299 case USB_ID(0x0e41, 0x4248): /* Line6 Helix >= fw 2.82 */ 321 300 case USB_ID(0x0e41, 0x4249): /* Line6 Helix Rack >= fw 2.82 */ 322 301 case USB_ID(0x0e41, 0x424a): /* Line6 Helix LT >= fw 2.82 */ 323 - /* supported rates: 48Khz */ 324 - kfree(fp->rate_table); 325 - fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); 326 - if (!fp->rate_table) 327 - return -ENOMEM; 328 - fp->nr_rates = 1; 329 - fp->rate_min = 48000; 330 - fp->rate_max = 48000; 331 - fp->rates = SNDRV_PCM_RATE_48000; 332 - fp->rate_table[0] = 48000; 333 - return 0; 302 + return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000); 334 303 } 335 304 336 305 return -ENODEV; ··· 336 325 struct usb_device *dev = chip->dev; 337 326 unsigned char tmp[2], *data; 338 327 int nr_triplets, data_size, ret = 0, ret_l6; 339 - int clock = snd_usb_clock_find_source(chip, fp->protocol, 340 - fp->clock, false); 328 + int clock = snd_usb_clock_find_source(chip, fp, false); 341 329 342 330 if (clock < 0) { 343 331 dev_err(&dev->dev,
+10 -2
sound/usb/mixer.c
··· 897 897 return 0; 898 898 } 899 899 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 + 900 909 static int parse_term_uac2_clock_source(struct mixer_build *state, 901 910 struct usb_audio_term *term, 902 911 void *p1, int id) ··· 990 981 UAC3_PROCESSING_UNIT); 991 982 case PTYPE(UAC_VERSION_2, UAC2_EFFECT_UNIT): 992 983 case PTYPE(UAC_VERSION_3, UAC3_EFFECT_UNIT): 993 - return parse_term_proc_unit(state, term, p1, id, 994 - UAC3_EFFECT_UNIT); 984 + return parse_term_effect_unit(state, term, p1, id); 995 985 case PTYPE(UAC_VERSION_1, UAC1_EXTENSION_UNIT): 996 986 case PTYPE(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2): 997 987 case PTYPE(UAC_VERSION_3, UAC3_EXTENSION_UNIT):
+1
sound/usb/quirks.c
··· 1440 1440 case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ 1441 1441 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ 1442 1442 case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ 1443 + case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ 1443 1444 return true; 1444 1445 } 1445 1446