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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'sound-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"Mostly HD-audio and USB-audio regression fixes:
- Oops fix at unloading of snd-hda-codec-conexant module
- A few trivial regression fixes for Cirrus and Conexant HD-audio
codecs
- Relax the USB-audio descriptor parse errors as non-fatal
- Fix locking of HD-audio CA0132 DSP loader
- Fix the generic HD-audio parser for VIA codecs"

* tag 'sound-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda - Fix DAC assignment for independent HP
ALSA: hda - Fix abuse of snd_hda_lock_devices() for DSP loader
ALSA: hda - Fix typo in checking IEC958 emphasis bit
ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls()
ALSA: snd-usb: mixer: propagate errors up the call chain
ALSA: usb: Parse UAC2 extension unit like for UAC1
ALSA: hda - Fix yet missing GPIO/EAPD setup in cirrus driver
ALSA: hda/cirrus - Fix the digital beep registration
ALSA: hda - Fix missing beep detach in patch_conexant.c
ALSA: documentation: Fix typo in Documentation/sound

+184 -41
+1 -1
Documentation/sound/alsa/ALSA-Configuration.txt
··· 912 912 models depending on the codec chip. The list of available models 913 913 is found in HD-Audio-Models.txt 914 914 915 - The model name "genric" is treated as a special case. When this 915 + The model name "generic" is treated as a special case. When this 916 916 model is given, the driver uses the generic codec parser without 917 917 "codec-patch". It's sometimes good for testing and debugging. 918 918
+1 -1
Documentation/sound/alsa/seq_oss.html
··· 285 285 <H4> 286 286 7.2.4 Close Callback</H4> 287 287 The <TT>close</TT> callback is called when this device is closed by the 288 - applicaion. If any private data was allocated in open callback, it must 288 + application. If any private data was allocated in open callback, it must 289 289 be released in the close callback. The deletion of ALSA port should be 290 290 done here, too. This callback must not be NULL. 291 291 <H4>
+1 -1
sound/pci/hda/hda_codec.c
··· 3144 3144 if (val & AC_DIG1_PROFESSIONAL) 3145 3145 sbits |= IEC958_AES0_PROFESSIONAL; 3146 3146 if (sbits & IEC958_AES0_PROFESSIONAL) { 3147 - if (sbits & AC_DIG1_EMPHASIS) 3147 + if (val & AC_DIG1_EMPHASIS) 3148 3148 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 3149 3149 } else { 3150 3150 if (val & AC_DIG1_EMPHASIS)
+46
sound/pci/hda/hda_generic.c
··· 995 995 BAD_NO_EXTRA_SURR_DAC = 0x101, 996 996 /* Primary DAC shared with main surrounds */ 997 997 BAD_SHARED_SURROUND = 0x100, 998 + /* No independent HP possible */ 999 + BAD_NO_INDEP_HP = 0x40, 998 1000 /* Primary DAC shared with main CLFE */ 999 1001 BAD_SHARED_CLFE = 0x10, 1000 1002 /* Primary DAC shared with extra surrounds */ ··· 1394 1392 return snd_hda_get_path_idx(codec, path); 1395 1393 } 1396 1394 1395 + /* check whether the independent HP is available with the current config */ 1396 + static bool indep_hp_possible(struct hda_codec *codec) 1397 + { 1398 + struct hda_gen_spec *spec = codec->spec; 1399 + struct auto_pin_cfg *cfg = &spec->autocfg; 1400 + struct nid_path *path; 1401 + int i, idx; 1402 + 1403 + if (cfg->line_out_type == AUTO_PIN_HP_OUT) 1404 + idx = spec->out_paths[0]; 1405 + else 1406 + idx = spec->hp_paths[0]; 1407 + path = snd_hda_get_path_from_idx(codec, idx); 1408 + if (!path) 1409 + return false; 1410 + 1411 + /* assume no path conflicts unless aamix is involved */ 1412 + if (!spec->mixer_nid || !is_nid_contained(path, spec->mixer_nid)) 1413 + return true; 1414 + 1415 + /* check whether output paths contain aamix */ 1416 + for (i = 0; i < cfg->line_outs; i++) { 1417 + if (spec->out_paths[i] == idx) 1418 + break; 1419 + path = snd_hda_get_path_from_idx(codec, spec->out_paths[i]); 1420 + if (path && is_nid_contained(path, spec->mixer_nid)) 1421 + return false; 1422 + } 1423 + for (i = 0; i < cfg->speaker_outs; i++) { 1424 + path = snd_hda_get_path_from_idx(codec, spec->speaker_paths[i]); 1425 + if (path && is_nid_contained(path, spec->mixer_nid)) 1426 + return false; 1427 + } 1428 + 1429 + return true; 1430 + } 1431 + 1397 1432 /* fill the empty entries in the dac array for speaker/hp with the 1398 1433 * shared dac pointed by the paths 1399 1434 */ ··· 1583 1544 spec->multi_ios = 0; 1584 1545 badness += BAD_MULTI_IO; 1585 1546 } 1547 + 1548 + if (spec->indep_hp && !indep_hp_possible(codec)) 1549 + badness += BAD_NO_INDEP_HP; 1586 1550 1587 1551 /* re-fill the shared DAC for speaker / headphone */ 1588 1552 if (cfg->line_out_type != AUTO_PIN_HP_OUT) ··· 1799 1757 set_pin_targets(codec, cfg->speaker_outs, 1800 1758 cfg->speaker_pins, val); 1801 1759 } 1760 + 1761 + /* clear indep_hp flag if not available */ 1762 + if (spec->indep_hp && !indep_hp_possible(codec)) 1763 + spec->indep_hp = 0; 1802 1764 1803 1765 kfree(best_cfg); 1804 1766 return 0;
+109 -23
sound/pci/hda/hda_intel.c
··· 415 415 unsigned int opened :1; 416 416 unsigned int running :1; 417 417 unsigned int irq_pending :1; 418 + unsigned int prepared:1; 419 + unsigned int locked:1; 418 420 /* 419 421 * For VIA: 420 422 * A flag to ensure DMA position is 0 ··· 428 426 429 427 struct timecounter azx_tc; 430 428 struct cyclecounter azx_cc; 429 + 430 + #ifdef CONFIG_SND_HDA_DSP_LOADER 431 + struct mutex dsp_mutex; 432 + #endif 431 433 }; 434 + 435 + /* DSP lock helpers */ 436 + #ifdef CONFIG_SND_HDA_DSP_LOADER 437 + #define dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex) 438 + #define dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex) 439 + #define dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex) 440 + #define dsp_is_locked(dev) ((dev)->locked) 441 + #else 442 + #define dsp_lock_init(dev) do {} while (0) 443 + #define dsp_lock(dev) do {} while (0) 444 + #define dsp_unlock(dev) do {} while (0) 445 + #define dsp_is_locked(dev) 0 446 + #endif 432 447 433 448 /* CORB/RIRB */ 434 449 struct azx_rb { ··· 546 527 547 528 /* card list (for power_save trigger) */ 548 529 struct list_head list; 530 + 531 + #ifdef CONFIG_SND_HDA_DSP_LOADER 532 + struct azx_dev saved_azx_dev; 533 + #endif 549 534 }; 550 535 551 536 #define CREATE_TRACE_POINTS ··· 1816 1793 dev = chip->capture_index_offset; 1817 1794 nums = chip->capture_streams; 1818 1795 } 1819 - for (i = 0; i < nums; i++, dev++) 1820 - if (!chip->azx_dev[dev].opened) { 1821 - res = &chip->azx_dev[dev]; 1822 - if (res->assigned_key == key) 1823 - break; 1796 + for (i = 0; i < nums; i++, dev++) { 1797 + struct azx_dev *azx_dev = &chip->azx_dev[dev]; 1798 + dsp_lock(azx_dev); 1799 + if (!azx_dev->opened && !dsp_is_locked(azx_dev)) { 1800 + res = azx_dev; 1801 + if (res->assigned_key == key) { 1802 + res->opened = 1; 1803 + res->assigned_key = key; 1804 + dsp_unlock(azx_dev); 1805 + return azx_dev; 1806 + } 1824 1807 } 1808 + dsp_unlock(azx_dev); 1809 + } 1825 1810 if (res) { 1811 + dsp_lock(res); 1826 1812 res->opened = 1; 1827 1813 res->assigned_key = key; 1814 + dsp_unlock(res); 1828 1815 } 1829 1816 return res; 1830 1817 } ··· 2042 2009 struct azx_dev *azx_dev = get_azx_dev(substream); 2043 2010 int ret; 2044 2011 2012 + dsp_lock(azx_dev); 2013 + if (dsp_is_locked(azx_dev)) { 2014 + ret = -EBUSY; 2015 + goto unlock; 2016 + } 2017 + 2045 2018 mark_runtime_wc(chip, azx_dev, substream, false); 2046 2019 azx_dev->bufsize = 0; 2047 2020 azx_dev->period_bytes = 0; ··· 2055 2016 ret = snd_pcm_lib_malloc_pages(substream, 2056 2017 params_buffer_bytes(hw_params)); 2057 2018 if (ret < 0) 2058 - return ret; 2019 + goto unlock; 2059 2020 mark_runtime_wc(chip, azx_dev, substream, true); 2021 + unlock: 2022 + dsp_unlock(azx_dev); 2060 2023 return ret; 2061 2024 } 2062 2025 ··· 2070 2029 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 2071 2030 2072 2031 /* reset BDL address */ 2073 - azx_sd_writel(azx_dev, SD_BDLPL, 0); 2074 - azx_sd_writel(azx_dev, SD_BDLPU, 0); 2075 - azx_sd_writel(azx_dev, SD_CTL, 0); 2076 - azx_dev->bufsize = 0; 2077 - azx_dev->period_bytes = 0; 2078 - azx_dev->format_val = 0; 2032 + dsp_lock(azx_dev); 2033 + if (!dsp_is_locked(azx_dev)) { 2034 + azx_sd_writel(azx_dev, SD_BDLPL, 0); 2035 + azx_sd_writel(azx_dev, SD_BDLPU, 0); 2036 + azx_sd_writel(azx_dev, SD_CTL, 0); 2037 + azx_dev->bufsize = 0; 2038 + azx_dev->period_bytes = 0; 2039 + azx_dev->format_val = 0; 2040 + } 2079 2041 2080 2042 snd_hda_codec_cleanup(apcm->codec, hinfo, substream); 2081 2043 2082 2044 mark_runtime_wc(chip, azx_dev, substream, false); 2045 + azx_dev->prepared = 0; 2046 + dsp_unlock(azx_dev); 2083 2047 return snd_pcm_lib_free_pages(substream); 2084 2048 } 2085 2049 ··· 2101 2055 snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid); 2102 2056 unsigned short ctls = spdif ? spdif->ctls : 0; 2103 2057 2058 + dsp_lock(azx_dev); 2059 + if (dsp_is_locked(azx_dev)) { 2060 + err = -EBUSY; 2061 + goto unlock; 2062 + } 2063 + 2104 2064 azx_stream_reset(chip, azx_dev); 2105 2065 format_val = snd_hda_calc_stream_format(runtime->rate, 2106 2066 runtime->channels, ··· 2117 2065 snd_printk(KERN_ERR SFX 2118 2066 "%s: invalid format_val, rate=%d, ch=%d, format=%d\n", 2119 2067 pci_name(chip->pci), runtime->rate, runtime->channels, runtime->format); 2120 - return -EINVAL; 2068 + err = -EINVAL; 2069 + goto unlock; 2121 2070 } 2122 2071 2123 2072 bufsize = snd_pcm_lib_buffer_bytes(substream); ··· 2137 2084 azx_dev->no_period_wakeup = runtime->no_period_wakeup; 2138 2085 err = azx_setup_periods(chip, substream, azx_dev); 2139 2086 if (err < 0) 2140 - return err; 2087 + goto unlock; 2141 2088 } 2142 2089 2143 2090 /* wallclk has 24Mhz clock source */ ··· 2154 2101 if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) && 2155 2102 stream_tag > chip->capture_streams) 2156 2103 stream_tag -= chip->capture_streams; 2157 - return snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag, 2104 + err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag, 2158 2105 azx_dev->format_val, substream); 2106 + 2107 + unlock: 2108 + if (!err) 2109 + azx_dev->prepared = 1; 2110 + dsp_unlock(azx_dev); 2111 + return err; 2159 2112 } 2160 2113 2161 2114 static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) ··· 2175 2116 2176 2117 azx_dev = get_azx_dev(substream); 2177 2118 trace_azx_pcm_trigger(chip, azx_dev, cmd); 2119 + 2120 + if (dsp_is_locked(azx_dev) || !azx_dev->prepared) 2121 + return -EPIPE; 2178 2122 2179 2123 switch (cmd) { 2180 2124 case SNDRV_PCM_TRIGGER_START: ··· 2683 2621 struct azx_dev *azx_dev; 2684 2622 int err; 2685 2623 2686 - if (snd_hda_lock_devices(bus)) 2687 - return -EBUSY; 2624 + azx_dev = azx_get_dsp_loader_dev(chip); 2625 + 2626 + dsp_lock(azx_dev); 2627 + spin_lock_irq(&chip->reg_lock); 2628 + if (azx_dev->running || azx_dev->locked) { 2629 + spin_unlock_irq(&chip->reg_lock); 2630 + err = -EBUSY; 2631 + goto unlock; 2632 + } 2633 + azx_dev->prepared = 0; 2634 + chip->saved_azx_dev = *azx_dev; 2635 + azx_dev->locked = 1; 2636 + spin_unlock_irq(&chip->reg_lock); 2688 2637 2689 2638 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, 2690 2639 snd_dma_pci_data(chip->pci), 2691 2640 byte_size, bufp); 2692 2641 if (err < 0) 2693 - goto unlock; 2642 + goto err_alloc; 2694 2643 2695 2644 mark_pages_wc(chip, bufp, true); 2696 - azx_dev = azx_get_dsp_loader_dev(chip); 2697 2645 azx_dev->bufsize = byte_size; 2698 2646 azx_dev->period_bytes = byte_size; 2699 2647 azx_dev->format_val = format; ··· 2721 2649 goto error; 2722 2650 2723 2651 azx_setup_controller(chip, azx_dev); 2652 + dsp_unlock(azx_dev); 2724 2653 return azx_dev->stream_tag; 2725 2654 2726 2655 error: 2727 2656 mark_pages_wc(chip, bufp, false); 2728 2657 snd_dma_free_pages(bufp); 2729 - unlock: 2730 - snd_hda_unlock_devices(bus); 2658 + err_alloc: 2659 + spin_lock_irq(&chip->reg_lock); 2660 + if (azx_dev->opened) 2661 + *azx_dev = chip->saved_azx_dev; 2662 + azx_dev->locked = 0; 2663 + spin_unlock_irq(&chip->reg_lock); 2664 + unlock: 2665 + dsp_unlock(azx_dev); 2731 2666 return err; 2732 2667 } 2733 2668 ··· 2756 2677 struct azx *chip = bus->private_data; 2757 2678 struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip); 2758 2679 2759 - if (!dmab->area) 2680 + if (!dmab->area || !azx_dev->locked) 2760 2681 return; 2761 2682 2683 + dsp_lock(azx_dev); 2762 2684 /* reset BDL address */ 2763 2685 azx_sd_writel(azx_dev, SD_BDLPL, 0); 2764 2686 azx_sd_writel(azx_dev, SD_BDLPU, 0); ··· 2772 2692 snd_dma_free_pages(dmab); 2773 2693 dmab->area = NULL; 2774 2694 2775 - snd_hda_unlock_devices(bus); 2695 + spin_lock_irq(&chip->reg_lock); 2696 + if (azx_dev->opened) 2697 + *azx_dev = chip->saved_azx_dev; 2698 + azx_dev->locked = 0; 2699 + spin_unlock_irq(&chip->reg_lock); 2700 + dsp_unlock(azx_dev); 2776 2701 } 2777 2702 #endif /* CONFIG_SND_HDA_DSP_LOADER */ 2778 2703 ··· 3566 3481 } 3567 3482 3568 3483 for (i = 0; i < chip->num_streams; i++) { 3484 + dsp_lock_init(&chip->azx_dev[i]); 3569 3485 /* allocate memory for the BDL for each stream */ 3570 3486 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, 3571 3487 snd_dma_pci_data(chip->pci),
+2 -2
sound/pci/hda/patch_cirrus.c
··· 168 168 snd_hda_gen_update_outputs(codec); 169 169 170 170 if (spec->gpio_eapd_hp) { 171 - unsigned int gpio = spec->gen.hp_jack_present ? 171 + spec->gpio_data = spec->gen.hp_jack_present ? 172 172 spec->gpio_eapd_hp : spec->gpio_eapd_speaker; 173 173 snd_hda_codec_write(codec, 0x01, 0, 174 - AC_VERB_SET_GPIO_DATA, gpio); 174 + AC_VERB_SET_GPIO_DATA, spec->gpio_data); 175 175 } 176 176 } 177 177
+11 -5
sound/pci/hda/patch_conexant.c
··· 1142 1142 } 1143 1143 1144 1144 if (spec->beep_amp) 1145 - snd_hda_attach_beep_device(codec, spec->beep_amp); 1145 + snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 1146 1146 1147 1147 return 0; 1148 1148 } ··· 1921 1921 } 1922 1922 1923 1923 if (spec->beep_amp) 1924 - snd_hda_attach_beep_device(codec, spec->beep_amp); 1924 + snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 1925 1925 1926 1926 return 0; 1927 1927 } ··· 3099 3099 } 3100 3100 3101 3101 if (spec->beep_amp) 3102 - snd_hda_attach_beep_device(codec, spec->beep_amp); 3102 + snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 3103 3103 3104 3104 return 0; 3105 3105 } ··· 3191 3191 return 0; 3192 3192 } 3193 3193 3194 + static void cx_auto_free(struct hda_codec *codec) 3195 + { 3196 + snd_hda_detach_beep_device(codec); 3197 + snd_hda_gen_free(codec); 3198 + } 3199 + 3194 3200 static const struct hda_codec_ops cx_auto_patch_ops = { 3195 3201 .build_controls = cx_auto_build_controls, 3196 3202 .build_pcms = snd_hda_gen_build_pcms, 3197 3203 .init = snd_hda_gen_init, 3198 - .free = snd_hda_gen_free, 3204 + .free = cx_auto_free, 3199 3205 .unsol_event = snd_hda_jack_unsol_event, 3200 3206 #ifdef CONFIG_PM 3201 3207 .check_power_status = snd_hda_gen_check_power_status, ··· 3397 3391 3398 3392 codec->patch_ops = cx_auto_patch_ops; 3399 3393 if (spec->beep_amp) 3400 - snd_hda_attach_beep_device(codec, spec->beep_amp); 3394 + snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); 3401 3395 3402 3396 /* Some laptops with Conexant chips show stalls in S3 resume, 3403 3397 * which falls into the single-cmd mode.
+13 -8
sound/usb/mixer.c
··· 715 715 case UAC2_CLOCK_SELECTOR: { 716 716 struct uac_selector_unit_descriptor *d = p1; 717 717 /* call recursively to retrieve the channel info */ 718 - if (check_input_term(state, d->baSourceID[0], term) < 0) 719 - return -ENODEV; 718 + err = check_input_term(state, d->baSourceID[0], term); 719 + if (err < 0) 720 + return err; 720 721 term->type = d->bDescriptorSubtype << 16; /* virtual type */ 721 722 term->id = id; 722 723 term->name = uac_selector_unit_iSelector(d); ··· 726 725 case UAC1_PROCESSING_UNIT: 727 726 case UAC1_EXTENSION_UNIT: 728 727 /* UAC2_PROCESSING_UNIT_V2 */ 729 - /* UAC2_EFFECT_UNIT */ { 728 + /* UAC2_EFFECT_UNIT */ 729 + case UAC2_EXTENSION_UNIT_V2: { 730 730 struct uac_processing_unit_descriptor *d = p1; 731 731 732 732 if (state->mixer->protocol == UAC_VERSION_2 && ··· 1358 1356 return err; 1359 1357 1360 1358 /* determine the input source type and name */ 1361 - if (check_input_term(state, hdr->bSourceID, &iterm) < 0) 1362 - return -EINVAL; 1359 + err = check_input_term(state, hdr->bSourceID, &iterm); 1360 + if (err < 0) 1361 + return err; 1363 1362 1364 1363 master_bits = snd_usb_combine_bytes(bmaControls, csize); 1365 1364 /* master configuration quirks */ ··· 2055 2052 return parse_audio_extension_unit(state, unitid, p1); 2056 2053 else /* UAC_VERSION_2 */ 2057 2054 return parse_audio_processing_unit(state, unitid, p1); 2055 + case UAC2_EXTENSION_UNIT_V2: 2056 + return parse_audio_extension_unit(state, unitid, p1); 2058 2057 default: 2059 2058 snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]); 2060 2059 return -EINVAL; ··· 2123 2118 state.oterm.type = le16_to_cpu(desc->wTerminalType); 2124 2119 state.oterm.name = desc->iTerminal; 2125 2120 err = parse_audio_unit(&state, desc->bSourceID); 2126 - if (err < 0) 2121 + if (err < 0 && err != -EINVAL) 2127 2122 return err; 2128 2123 } else { /* UAC_VERSION_2 */ 2129 2124 struct uac2_output_terminal_descriptor *desc = p; ··· 2135 2130 state.oterm.type = le16_to_cpu(desc->wTerminalType); 2136 2131 state.oterm.name = desc->iTerminal; 2137 2132 err = parse_audio_unit(&state, desc->bSourceID); 2138 - if (err < 0) 2133 + if (err < 0 && err != -EINVAL) 2139 2134 return err; 2140 2135 2141 2136 /* for UAC2, use the same approach to also add the clock selectors */ 2142 2137 err = parse_audio_unit(&state, desc->bCSourceID); 2143 - if (err < 0) 2138 + if (err < 0 && err != -EINVAL) 2144 2139 return err; 2145 2140 } 2146 2141 }