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-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"Lots of small fixes for various drivers at this time, hopefully it
will be the last big bump before 6.0 release.

The significant changes are regression fixes for (yet again) HD-audio
memory allocations and USB-audio PCM parameter handling, while there
are many small ASoC device-specific fixes as well as a few
out-of-bounds and race issues spotted by fuzzers"

* tag 'sound-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (29 commits)
ALSA: usb-audio: Clear fixed clock rate at closing EP
ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc()
ALSA: hda: Once again fix regression of page allocations with IOMMU
ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface()
ALSA: hda/tegra: Align BDL entry to 4KB boundary
ALSA: hda/sigmatel: Fix unused variable warning for beep power change
ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC
ALSA: hda/sigmatel: Keep power up while beep is enabled
ALSA: aloop: Fix random zeros in capture data when using jiffies timer
ALSA: usb-audio: Split endpoint setups for hw_params and prepare
ALSA: usb-audio: Register card again for iface over delayed_register option
ALSA: usb-audio: Inform the delayed registration more properly
ASoC: fsl_aud2htx: Add error handler for pm_runtime_enable
ASoC: fsl_aud2htx: register platform component before registering cpu dai
ASoC: SOF: ipc4-topology: fix alh_group_ida max value
ASoC: mchp-spdiftx: Fix clang -Wbitfield-constant-conversion
ASoC: SOF: Kconfig: Make IPC_MESSAGE_INJECTOR depend on SND_SOC_SOF
ASoC: SOF: Kconfig: Make IPC_FLOOD_TEST depend on SND_SOC_SOF
ASoC: fsl_mqs: Fix supported clock DAI format
ASoC: nau8540: Implement hw constraint for rates
...

+258 -169
+7 -2
sound/core/memalloc.c
··· 543 543 dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, 544 544 sg_dma_address(sgt->sgl)); 545 545 p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt); 546 - if (p) 546 + if (p) { 547 547 dmab->private_data = sgt; 548 - else 548 + /* store the first page address for convenience */ 549 + dmab->addr = snd_sgbuf_get_addr(dmab, 0); 550 + } else { 549 551 dma_free_noncontiguous(dmab->dev.dev, size, sgt, dmab->dev.dir); 552 + } 550 553 return p; 551 554 } 552 555 ··· 783 780 if (!p) 784 781 goto error; 785 782 dmab->private_data = sgbuf; 783 + /* store the first page address for convenience */ 784 + dmab->addr = snd_sgbuf_get_addr(dmab, 0); 786 785 return p; 787 786 788 787 error:
+3 -3
sound/core/oss/pcm_oss.c
··· 1672 1672 runtime = substream->runtime; 1673 1673 if (atomic_read(&substream->mmap_count)) 1674 1674 goto __direct; 1675 - err = snd_pcm_oss_make_ready(substream); 1676 - if (err < 0) 1677 - return err; 1678 1675 atomic_inc(&runtime->oss.rw_ref); 1679 1676 if (mutex_lock_interruptible(&runtime->oss.params_lock)) { 1680 1677 atomic_dec(&runtime->oss.rw_ref); 1681 1678 return -ERESTARTSYS; 1682 1679 } 1680 + err = snd_pcm_oss_make_ready_locked(substream); 1681 + if (err < 0) 1682 + goto unlock; 1683 1683 format = snd_pcm_oss_format_from(runtime->oss.format); 1684 1684 width = snd_pcm_format_physical_width(format); 1685 1685 if (runtime->oss.buffer_used > 0) {
+4 -3
sound/drivers/aloop.c
··· 605 605 cable->streams[SNDRV_PCM_STREAM_PLAYBACK]; 606 606 struct loopback_pcm *dpcm_capt = 607 607 cable->streams[SNDRV_PCM_STREAM_CAPTURE]; 608 - unsigned long delta_play = 0, delta_capt = 0; 608 + unsigned long delta_play = 0, delta_capt = 0, cur_jiffies; 609 609 unsigned int running, count1, count2; 610 610 611 + cur_jiffies = jiffies; 611 612 running = cable->running ^ cable->pause; 612 613 if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { 613 - delta_play = jiffies - dpcm_play->last_jiffies; 614 + delta_play = cur_jiffies - dpcm_play->last_jiffies; 614 615 dpcm_play->last_jiffies += delta_play; 615 616 } 616 617 617 618 if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) { 618 - delta_capt = jiffies - dpcm_capt->last_jiffies; 619 + delta_capt = cur_jiffies - dpcm_capt->last_jiffies; 619 620 dpcm_capt->last_jiffies += delta_capt; 620 621 } 621 622
+1 -1
sound/pci/emu10k1/emupcm.c
··· 124 124 epcm->voices[0]->epcm = epcm; 125 125 if (voices > 1) { 126 126 for (i = 1; i < voices; i++) { 127 - epcm->voices[i] = &epcm->emu->voices[epcm->voices[0]->number + i]; 127 + epcm->voices[i] = &epcm->emu->voices[(epcm->voices[0]->number + i) % NUM_G]; 128 128 epcm->voices[i]->epcm = epcm; 129 129 } 130 130 }
+1 -1
sound/pci/hda/hda_intel.c
··· 1817 1817 1818 1818 /* use the non-cached pages in non-snoop mode */ 1819 1819 if (!azx_snoop(chip)) 1820 - azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC; 1820 + azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG; 1821 1821 1822 1822 if (chip->driver_type == AZX_DRIVER_NVIDIA) { 1823 1823 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
+2 -1
sound/pci/hda/hda_tegra.c
··· 474 474 static int hda_tegra_probe(struct platform_device *pdev) 475 475 { 476 476 const unsigned int driver_flags = AZX_DCAPS_CORBRP_SELF_CLEAR | 477 - AZX_DCAPS_PM_RUNTIME; 477 + AZX_DCAPS_PM_RUNTIME | 478 + AZX_DCAPS_4K_BDLE_BOUNDARY; 478 479 struct snd_card *card; 479 480 struct azx *chip; 480 481 struct hda_tegra *hda;
+24
sound/pci/hda/patch_sigmatel.c
··· 209 209 210 210 /* beep widgets */ 211 211 hda_nid_t anabeep_nid; 212 + bool beep_power_on; 212 213 213 214 /* SPDIF-out mux */ 214 215 const char * const *spdif_labels; ··· 4444 4443 4445 4444 return 0; 4446 4445 } 4446 + 4447 + static int stac_check_power_status(struct hda_codec *codec, hda_nid_t nid) 4448 + { 4449 + #ifdef CONFIG_SND_HDA_INPUT_BEEP 4450 + struct sigmatel_spec *spec = codec->spec; 4451 + #endif 4452 + int ret = snd_hda_gen_check_power_status(codec, nid); 4453 + 4454 + #ifdef CONFIG_SND_HDA_INPUT_BEEP 4455 + if (nid == spec->gen.beep_nid && codec->beep) { 4456 + if (codec->beep->enabled != spec->beep_power_on) { 4457 + spec->beep_power_on = codec->beep->enabled; 4458 + if (spec->beep_power_on) 4459 + snd_hda_power_up_pm(codec); 4460 + else 4461 + snd_hda_power_down_pm(codec); 4462 + } 4463 + ret |= spec->beep_power_on; 4464 + } 4465 + #endif 4466 + return ret; 4467 + } 4447 4468 #else 4448 4469 #define stac_suspend NULL 4449 4470 #endif /* CONFIG_PM */ ··· 4478 4455 .unsol_event = snd_hda_jack_unsol_event, 4479 4456 #ifdef CONFIG_PM 4480 4457 .suspend = stac_suspend, 4458 + .check_power_status = stac_check_power_status, 4481 4459 #endif 4482 4460 }; 4483 4461
+1 -1
sound/soc/atmel/mchp-spdiftx.c
··· 196 196 struct clk *pclk; 197 197 struct clk *gclk; 198 198 unsigned int fmt; 199 - int gclk_enabled:1; 199 + unsigned int gclk_enabled:1; 200 200 }; 201 201 202 202 static inline int mchp_spdiftx_is_running(struct mchp_spdiftx_dev *dev)
+7 -6
sound/soc/codecs/cs42l42.c
··· 1617 1617 unsigned int current_plug_status; 1618 1618 unsigned int current_button_status; 1619 1619 unsigned int i; 1620 - int report = 0; 1621 1620 1622 1621 mutex_lock(&cs42l42->irq_lock); 1623 1622 if (cs42l42->suspended) { ··· 1710 1711 1711 1712 if (current_button_status & CS42L42_M_DETECT_TF_MASK) { 1712 1713 dev_dbg(cs42l42->dev, "Button released\n"); 1713 - report = 0; 1714 + snd_soc_jack_report(cs42l42->jack, 0, 1715 + SND_JACK_BTN_0 | SND_JACK_BTN_1 | 1716 + SND_JACK_BTN_2 | SND_JACK_BTN_3); 1714 1717 } else if (current_button_status & CS42L42_M_DETECT_FT_MASK) { 1715 - report = cs42l42_handle_button_press(cs42l42); 1716 - 1718 + snd_soc_jack_report(cs42l42->jack, 1719 + cs42l42_handle_button_press(cs42l42), 1720 + SND_JACK_BTN_0 | SND_JACK_BTN_1 | 1721 + SND_JACK_BTN_2 | SND_JACK_BTN_3); 1717 1722 } 1718 - snd_soc_jack_report(cs42l42->jack, report, SND_JACK_BTN_0 | SND_JACK_BTN_1 | 1719 - SND_JACK_BTN_2 | SND_JACK_BTN_3); 1720 1723 } 1721 1724 } 1722 1725
+30 -12
sound/soc/codecs/nau8540.c
··· 357 357 {"AIFTX", NULL, "Digital CH4 Mux"}, 358 358 }; 359 359 360 - static int nau8540_clock_check(struct nau8540 *nau8540, int rate, int osr) 360 + static const struct nau8540_osr_attr * 361 + nau8540_get_osr(struct nau8540 *nau8540) 361 362 { 363 + unsigned int osr; 364 + 365 + regmap_read(nau8540->regmap, NAU8540_REG_ADC_SAMPLE_RATE, &osr); 366 + osr &= NAU8540_ADC_OSR_MASK; 362 367 if (osr >= ARRAY_SIZE(osr_adc_sel)) 368 + return NULL; 369 + return &osr_adc_sel[osr]; 370 + } 371 + 372 + static int nau8540_dai_startup(struct snd_pcm_substream *substream, 373 + struct snd_soc_dai *dai) 374 + { 375 + struct snd_soc_component *component = dai->component; 376 + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); 377 + const struct nau8540_osr_attr *osr; 378 + 379 + osr = nau8540_get_osr(nau8540); 380 + if (!osr || !osr->osr) 363 381 return -EINVAL; 364 382 365 - if (rate * osr > CLK_ADC_MAX) { 366 - dev_err(nau8540->dev, "exceed the maximum frequency of CLK_ADC\n"); 367 - return -EINVAL; 368 - } 369 - 370 - return 0; 383 + return snd_pcm_hw_constraint_minmax(substream->runtime, 384 + SNDRV_PCM_HW_PARAM_RATE, 385 + 0, CLK_ADC_MAX / osr->osr); 371 386 } 372 387 373 388 static int nau8540_hw_params(struct snd_pcm_substream *substream, ··· 390 375 { 391 376 struct snd_soc_component *component = dai->component; 392 377 struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); 393 - unsigned int val_len = 0, osr; 378 + unsigned int val_len = 0; 379 + const struct nau8540_osr_attr *osr; 394 380 395 381 /* CLK_ADC = OSR * FS 396 382 * ADC clock frequency is defined as Over Sampling Rate (OSR) ··· 399 383 * values must be selected such that the maximum frequency is less 400 384 * than 6.144 MHz. 401 385 */ 402 - regmap_read(nau8540->regmap, NAU8540_REG_ADC_SAMPLE_RATE, &osr); 403 - osr &= NAU8540_ADC_OSR_MASK; 404 - if (nau8540_clock_check(nau8540, params_rate(params), osr)) 386 + osr = nau8540_get_osr(nau8540); 387 + if (!osr || !osr->osr) 388 + return -EINVAL; 389 + if (params_rate(params) * osr->osr > CLK_ADC_MAX) 405 390 return -EINVAL; 406 391 regmap_update_bits(nau8540->regmap, NAU8540_REG_CLOCK_SRC, 407 392 NAU8540_CLK_ADC_SRC_MASK, 408 - osr_adc_sel[osr].clk_src << NAU8540_CLK_ADC_SRC_SFT); 393 + osr->clk_src << NAU8540_CLK_ADC_SRC_SFT); 409 394 410 395 switch (params_width(params)) { 411 396 case 16: ··· 532 515 533 516 534 517 static const struct snd_soc_dai_ops nau8540_dai_ops = { 518 + .startup = nau8540_dai_startup, 535 519 .hw_params = nau8540_hw_params, 536 520 .set_fmt = nau8540_set_fmt, 537 521 .set_tdm_slot = nau8540_set_tdm_slot,
+36 -30
sound/soc/codecs/nau8821.c
··· 670 670 {"HPOR", NULL, "Class G"}, 671 671 }; 672 672 673 - static int nau8821_clock_check(struct nau8821 *nau8821, 674 - int stream, int rate, int osr) 673 + static const struct nau8821_osr_attr * 674 + nau8821_get_osr(struct nau8821 *nau8821, int stream) 675 675 { 676 - int osrate = 0; 676 + unsigned int osr; 677 677 678 678 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 679 + regmap_read(nau8821->regmap, NAU8821_R2C_DAC_CTRL1, &osr); 680 + osr &= NAU8821_DAC_OVERSAMPLE_MASK; 679 681 if (osr >= ARRAY_SIZE(osr_dac_sel)) 680 - return -EINVAL; 681 - osrate = osr_dac_sel[osr].osr; 682 + return NULL; 683 + return &osr_dac_sel[osr]; 682 684 } else { 685 + regmap_read(nau8821->regmap, NAU8821_R2B_ADC_RATE, &osr); 686 + osr &= NAU8821_ADC_SYNC_DOWN_MASK; 683 687 if (osr >= ARRAY_SIZE(osr_adc_sel)) 684 - return -EINVAL; 685 - osrate = osr_adc_sel[osr].osr; 688 + return NULL; 689 + return &osr_adc_sel[osr]; 686 690 } 691 + } 687 692 688 - if (!osrate || rate * osrate > CLK_DA_AD_MAX) { 689 - dev_err(nau8821->dev, 690 - "exceed the maximum frequency of CLK_ADC or CLK_DAC"); 693 + static int nau8821_dai_startup(struct snd_pcm_substream *substream, 694 + struct snd_soc_dai *dai) 695 + { 696 + struct snd_soc_component *component = dai->component; 697 + struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); 698 + const struct nau8821_osr_attr *osr; 699 + 700 + osr = nau8821_get_osr(nau8821, substream->stream); 701 + if (!osr || !osr->osr) 691 702 return -EINVAL; 692 - } 693 703 694 - return 0; 704 + return snd_pcm_hw_constraint_minmax(substream->runtime, 705 + SNDRV_PCM_HW_PARAM_RATE, 706 + 0, CLK_DA_AD_MAX / osr->osr); 695 707 } 696 708 697 709 static int nau8821_hw_params(struct snd_pcm_substream *substream, ··· 711 699 { 712 700 struct snd_soc_component *component = dai->component; 713 701 struct nau8821 *nau8821 = snd_soc_component_get_drvdata(component); 714 - unsigned int val_len = 0, osr, ctrl_val, bclk_fs, clk_div; 702 + unsigned int val_len = 0, ctrl_val, bclk_fs, clk_div; 703 + const struct nau8821_osr_attr *osr; 715 704 716 705 nau8821->fs = params_rate(params); 717 706 /* CLK_DAC or CLK_ADC = OSR * FS ··· 721 708 * values must be selected such that the maximum frequency is less 722 709 * than 6.144 MHz. 723 710 */ 724 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 725 - regmap_read(nau8821->regmap, NAU8821_R2C_DAC_CTRL1, &osr); 726 - osr &= NAU8821_DAC_OVERSAMPLE_MASK; 727 - if (nau8821_clock_check(nau8821, substream->stream, 728 - nau8821->fs, osr)) { 729 - return -EINVAL; 730 - } 711 + osr = nau8821_get_osr(nau8821, substream->stream); 712 + if (!osr || !osr->osr) 713 + return -EINVAL; 714 + if (nau8821->fs * osr->osr > CLK_DA_AD_MAX) 715 + return -EINVAL; 716 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 731 717 regmap_update_bits(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, 732 718 NAU8821_CLK_DAC_SRC_MASK, 733 - osr_dac_sel[osr].clk_src << NAU8821_CLK_DAC_SRC_SFT); 734 - } else { 735 - regmap_read(nau8821->regmap, NAU8821_R2B_ADC_RATE, &osr); 736 - osr &= NAU8821_ADC_SYNC_DOWN_MASK; 737 - if (nau8821_clock_check(nau8821, substream->stream, 738 - nau8821->fs, osr)) { 739 - return -EINVAL; 740 - } 719 + osr->clk_src << NAU8821_CLK_DAC_SRC_SFT); 720 + else 741 721 regmap_update_bits(nau8821->regmap, NAU8821_R03_CLK_DIVIDER, 742 722 NAU8821_CLK_ADC_SRC_MASK, 743 - osr_adc_sel[osr].clk_src << NAU8821_CLK_ADC_SRC_SFT); 744 - } 723 + osr->clk_src << NAU8821_CLK_ADC_SRC_SFT); 745 724 746 725 /* make BCLK and LRC divde configuration if the codec as master. */ 747 726 regmap_read(nau8821->regmap, NAU8821_R1D_I2S_PCM_CTRL2, &ctrl_val); ··· 848 843 } 849 844 850 845 static const struct snd_soc_dai_ops nau8821_dai_ops = { 846 + .startup = nau8821_dai_startup, 851 847 .hw_params = nau8821_hw_params, 852 848 .set_fmt = nau8821_set_dai_fmt, 853 849 .mute_stream = nau8821_digital_mute,
+46 -34
sound/soc/codecs/nau8824.c
··· 1014 1014 return IRQ_HANDLED; 1015 1015 } 1016 1016 1017 - static int nau8824_clock_check(struct nau8824 *nau8824, 1018 - int stream, int rate, int osr) 1017 + static const struct nau8824_osr_attr * 1018 + nau8824_get_osr(struct nau8824 *nau8824, int stream) 1019 1019 { 1020 - int osrate; 1020 + unsigned int osr; 1021 1021 1022 1022 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 1023 + regmap_read(nau8824->regmap, 1024 + NAU8824_REG_DAC_FILTER_CTRL_1, &osr); 1025 + osr &= NAU8824_DAC_OVERSAMPLE_MASK; 1023 1026 if (osr >= ARRAY_SIZE(osr_dac_sel)) 1024 - return -EINVAL; 1025 - osrate = osr_dac_sel[osr].osr; 1027 + return NULL; 1028 + return &osr_dac_sel[osr]; 1026 1029 } else { 1030 + regmap_read(nau8824->regmap, 1031 + NAU8824_REG_ADC_FILTER_CTRL, &osr); 1032 + osr &= NAU8824_ADC_SYNC_DOWN_MASK; 1027 1033 if (osr >= ARRAY_SIZE(osr_adc_sel)) 1028 - return -EINVAL; 1029 - osrate = osr_adc_sel[osr].osr; 1034 + return NULL; 1035 + return &osr_adc_sel[osr]; 1030 1036 } 1037 + } 1031 1038 1032 - if (!osrate || rate * osr > CLK_DA_AD_MAX) { 1033 - dev_err(nau8824->dev, "exceed the maximum frequency of CLK_ADC or CLK_DAC\n"); 1039 + static int nau8824_dai_startup(struct snd_pcm_substream *substream, 1040 + struct snd_soc_dai *dai) 1041 + { 1042 + struct snd_soc_component *component = dai->component; 1043 + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); 1044 + const struct nau8824_osr_attr *osr; 1045 + 1046 + osr = nau8824_get_osr(nau8824, substream->stream); 1047 + if (!osr || !osr->osr) 1034 1048 return -EINVAL; 1035 - } 1036 1049 1037 - return 0; 1050 + return snd_pcm_hw_constraint_minmax(substream->runtime, 1051 + SNDRV_PCM_HW_PARAM_RATE, 1052 + 0, CLK_DA_AD_MAX / osr->osr); 1038 1053 } 1039 1054 1040 1055 static int nau8824_hw_params(struct snd_pcm_substream *substream, ··· 1057 1042 { 1058 1043 struct snd_soc_component *component = dai->component; 1059 1044 struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); 1060 - unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; 1045 + unsigned int val_len = 0, ctrl_val, bclk_fs, bclk_div; 1046 + const struct nau8824_osr_attr *osr; 1047 + int err = -EINVAL; 1061 1048 1062 1049 nau8824_sema_acquire(nau8824, HZ); 1063 1050 ··· 1070 1053 * than 6.144 MHz. 1071 1054 */ 1072 1055 nau8824->fs = params_rate(params); 1073 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1074 - regmap_read(nau8824->regmap, 1075 - NAU8824_REG_DAC_FILTER_CTRL_1, &osr); 1076 - osr &= NAU8824_DAC_OVERSAMPLE_MASK; 1077 - if (nau8824_clock_check(nau8824, substream->stream, 1078 - nau8824->fs, osr)) 1079 - return -EINVAL; 1056 + osr = nau8824_get_osr(nau8824, substream->stream); 1057 + if (!osr || !osr->osr) 1058 + goto error; 1059 + if (nau8824->fs * osr->osr > CLK_DA_AD_MAX) 1060 + goto error; 1061 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1080 1062 regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER, 1081 1063 NAU8824_CLK_DAC_SRC_MASK, 1082 - osr_dac_sel[osr].clk_src << NAU8824_CLK_DAC_SRC_SFT); 1083 - } else { 1084 - regmap_read(nau8824->regmap, 1085 - NAU8824_REG_ADC_FILTER_CTRL, &osr); 1086 - osr &= NAU8824_ADC_SYNC_DOWN_MASK; 1087 - if (nau8824_clock_check(nau8824, substream->stream, 1088 - nau8824->fs, osr)) 1089 - return -EINVAL; 1064 + osr->clk_src << NAU8824_CLK_DAC_SRC_SFT); 1065 + else 1090 1066 regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER, 1091 1067 NAU8824_CLK_ADC_SRC_MASK, 1092 - osr_adc_sel[osr].clk_src << NAU8824_CLK_ADC_SRC_SFT); 1093 - } 1068 + osr->clk_src << NAU8824_CLK_ADC_SRC_SFT); 1094 1069 1095 1070 /* make BCLK and LRC divde configuration if the codec as master. */ 1096 1071 regmap_read(nau8824->regmap, ··· 1099 1090 else if (bclk_fs <= 256) 1100 1091 bclk_div = 0; 1101 1092 else 1102 - return -EINVAL; 1093 + goto error; 1103 1094 regmap_update_bits(nau8824->regmap, 1104 1095 NAU8824_REG_PORT0_I2S_PCM_CTRL_2, 1105 1096 NAU8824_I2S_LRC_DIV_MASK | NAU8824_I2S_BLK_DIV_MASK, ··· 1120 1111 val_len |= NAU8824_I2S_DL_32; 1121 1112 break; 1122 1113 default: 1123 - return -EINVAL; 1114 + goto error; 1124 1115 } 1125 1116 1126 1117 regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1, 1127 1118 NAU8824_I2S_DL_MASK, val_len); 1119 + err = 0; 1128 1120 1121 + error: 1129 1122 nau8824_sema_release(nau8824); 1130 1123 1131 - return 0; 1124 + return err; 1132 1125 } 1133 1126 1134 1127 static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ··· 1138 1127 struct snd_soc_component *component = dai->component; 1139 1128 struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); 1140 1129 unsigned int ctrl1_val = 0, ctrl2_val = 0; 1141 - 1142 - nau8824_sema_acquire(nau8824, HZ); 1143 1130 1144 1131 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 1145 1132 case SND_SOC_DAIFMT_CBM_CFM: ··· 1179 1170 default: 1180 1171 return -EINVAL; 1181 1172 } 1173 + 1174 + nau8824_sema_acquire(nau8824, HZ); 1182 1175 1183 1176 regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1, 1184 1177 NAU8824_I2S_DF_MASK | NAU8824_I2S_BP_MASK | ··· 1558 1547 }; 1559 1548 1560 1549 static const struct snd_soc_dai_ops nau8824_dai_ops = { 1550 + .startup = nau8824_dai_startup, 1561 1551 .hw_params = nau8824_hw_params, 1562 1552 .set_fmt = nau8824_set_fmt, 1563 1553 .set_tdm_slot = nau8824_set_tdm_slot,
+45 -38
sound/soc/codecs/nau8825.c
··· 1247 1247 {"HPOR", NULL, "Class G"}, 1248 1248 }; 1249 1249 1250 - static int nau8825_clock_check(struct nau8825 *nau8825, 1251 - int stream, int rate, int osr) 1250 + static const struct nau8825_osr_attr * 1251 + nau8825_get_osr(struct nau8825 *nau8825, int stream) 1252 1252 { 1253 - int osrate; 1253 + unsigned int osr; 1254 1254 1255 1255 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 1256 + regmap_read(nau8825->regmap, 1257 + NAU8825_REG_DAC_CTRL1, &osr); 1258 + osr &= NAU8825_DAC_OVERSAMPLE_MASK; 1256 1259 if (osr >= ARRAY_SIZE(osr_dac_sel)) 1257 - return -EINVAL; 1258 - osrate = osr_dac_sel[osr].osr; 1260 + return NULL; 1261 + return &osr_dac_sel[osr]; 1259 1262 } else { 1263 + regmap_read(nau8825->regmap, 1264 + NAU8825_REG_ADC_RATE, &osr); 1265 + osr &= NAU8825_ADC_SYNC_DOWN_MASK; 1260 1266 if (osr >= ARRAY_SIZE(osr_adc_sel)) 1261 - return -EINVAL; 1262 - osrate = osr_adc_sel[osr].osr; 1267 + return NULL; 1268 + return &osr_adc_sel[osr]; 1263 1269 } 1270 + } 1264 1271 1265 - if (!osrate || rate * osr > CLK_DA_AD_MAX) { 1266 - dev_err(nau8825->dev, "exceed the maximum frequency of CLK_ADC or CLK_DAC\n"); 1272 + static int nau8825_dai_startup(struct snd_pcm_substream *substream, 1273 + struct snd_soc_dai *dai) 1274 + { 1275 + struct snd_soc_component *component = dai->component; 1276 + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); 1277 + const struct nau8825_osr_attr *osr; 1278 + 1279 + osr = nau8825_get_osr(nau8825, substream->stream); 1280 + if (!osr || !osr->osr) 1267 1281 return -EINVAL; 1268 - } 1269 1282 1270 - return 0; 1283 + return snd_pcm_hw_constraint_minmax(substream->runtime, 1284 + SNDRV_PCM_HW_PARAM_RATE, 1285 + 0, CLK_DA_AD_MAX / osr->osr); 1271 1286 } 1272 1287 1273 1288 static int nau8825_hw_params(struct snd_pcm_substream *substream, ··· 1291 1276 { 1292 1277 struct snd_soc_component *component = dai->component; 1293 1278 struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); 1294 - unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; 1279 + unsigned int val_len = 0, ctrl_val, bclk_fs, bclk_div; 1280 + const struct nau8825_osr_attr *osr; 1281 + int err = -EINVAL; 1295 1282 1296 1283 nau8825_sema_acquire(nau8825, 3 * HZ); 1297 1284 ··· 1303 1286 * values must be selected such that the maximum frequency is less 1304 1287 * than 6.144 MHz. 1305 1288 */ 1306 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1307 - regmap_read(nau8825->regmap, NAU8825_REG_DAC_CTRL1, &osr); 1308 - osr &= NAU8825_DAC_OVERSAMPLE_MASK; 1309 - if (nau8825_clock_check(nau8825, substream->stream, 1310 - params_rate(params), osr)) { 1311 - nau8825_sema_release(nau8825); 1312 - return -EINVAL; 1313 - } 1289 + osr = nau8825_get_osr(nau8825, substream->stream); 1290 + if (!osr || !osr->osr) 1291 + goto error; 1292 + if (params_rate(params) * osr->osr > CLK_DA_AD_MAX) 1293 + goto error; 1294 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 1314 1295 regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER, 1315 1296 NAU8825_CLK_DAC_SRC_MASK, 1316 - osr_dac_sel[osr].clk_src << NAU8825_CLK_DAC_SRC_SFT); 1317 - } else { 1318 - regmap_read(nau8825->regmap, NAU8825_REG_ADC_RATE, &osr); 1319 - osr &= NAU8825_ADC_SYNC_DOWN_MASK; 1320 - if (nau8825_clock_check(nau8825, substream->stream, 1321 - params_rate(params), osr)) { 1322 - nau8825_sema_release(nau8825); 1323 - return -EINVAL; 1324 - } 1297 + osr->clk_src << NAU8825_CLK_DAC_SRC_SFT); 1298 + else 1325 1299 regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER, 1326 1300 NAU8825_CLK_ADC_SRC_MASK, 1327 - osr_adc_sel[osr].clk_src << NAU8825_CLK_ADC_SRC_SFT); 1328 - } 1301 + osr->clk_src << NAU8825_CLK_ADC_SRC_SFT); 1329 1302 1330 1303 /* make BCLK and LRC divde configuration if the codec as master. */ 1331 1304 regmap_read(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, &ctrl_val); ··· 1328 1321 bclk_div = 1; 1329 1322 else if (bclk_fs <= 128) 1330 1323 bclk_div = 0; 1331 - else { 1332 - nau8825_sema_release(nau8825); 1333 - return -EINVAL; 1334 - } 1324 + else 1325 + goto error; 1335 1326 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 1336 1327 NAU8825_I2S_LRC_DIV_MASK | NAU8825_I2S_BLK_DIV_MASK, 1337 1328 ((bclk_div + 1) << NAU8825_I2S_LRC_DIV_SFT) | bclk_div); ··· 1349 1344 val_len |= NAU8825_I2S_DL_32; 1350 1345 break; 1351 1346 default: 1352 - nau8825_sema_release(nau8825); 1353 - return -EINVAL; 1347 + goto error; 1354 1348 } 1355 1349 1356 1350 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, 1357 1351 NAU8825_I2S_DL_MASK, val_len); 1352 + err = 0; 1358 1353 1354 + error: 1359 1355 /* Release the semaphore. */ 1360 1356 nau8825_sema_release(nau8825); 1361 1357 1362 - return 0; 1358 + return err; 1363 1359 } 1364 1360 1365 1361 static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ··· 1426 1420 } 1427 1421 1428 1422 static const struct snd_soc_dai_ops nau8825_dai_ops = { 1423 + .startup = nau8825_dai_startup, 1429 1424 .hw_params = nau8825_hw_params, 1430 1425 .set_fmt = nau8825_set_dai_fmt, 1431 1426 };
+12 -4
sound/soc/fsl/fsl_aud2htx.c
··· 234 234 235 235 regcache_cache_only(aud2htx->regmap, true); 236 236 237 + /* 238 + * Register platform component before registering cpu dai for there 239 + * is not defer probe for platform component in snd_soc_add_pcm_runtime(). 240 + */ 241 + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); 242 + if (ret) { 243 + dev_err(&pdev->dev, "failed to pcm register\n"); 244 + pm_runtime_disable(&pdev->dev); 245 + return ret; 246 + } 247 + 237 248 ret = devm_snd_soc_register_component(&pdev->dev, 238 249 &fsl_aud2htx_component, 239 250 &fsl_aud2htx_dai, 1); 240 251 if (ret) { 241 252 dev_err(&pdev->dev, "failed to register ASoC DAI\n"); 253 + pm_runtime_disable(&pdev->dev); 242 254 return ret; 243 255 } 244 - 245 - ret = imx_pcm_dma_init(pdev); 246 - if (ret) 247 - dev_err(&pdev->dev, "failed to init imx pcm dma: %d\n", ret); 248 256 249 257 return ret; 250 258 }
+1 -1
sound/soc/fsl/fsl_mqs.c
··· 122 122 } 123 123 124 124 switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { 125 - case SND_SOC_DAIFMT_BP_FP: 125 + case SND_SOC_DAIFMT_CBC_CFC: 126 126 break; 127 127 default: 128 128 return -EINVAL;
+1 -1
sound/soc/fsl/fsl_sai.c
··· 1306 1306 sai->mclk_clk[i] = devm_clk_get(dev, tmp); 1307 1307 if (IS_ERR(sai->mclk_clk[i])) { 1308 1308 dev_err(dev, "failed to get mclk%d clock: %ld\n", 1309 - i + 1, PTR_ERR(sai->mclk_clk[i])); 1309 + i, PTR_ERR(sai->mclk_clk[i])); 1310 1310 sai->mclk_clk[i] = NULL; 1311 1311 } 1312 1312 }
-3
sound/soc/mediatek/mt8186/mt8186-dai-adda.c
··· 271 271 /* should delayed 1/fs(smallest is 8k) = 125us before afe off */ 272 272 usleep_range(125, 135); 273 273 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_ADDA, 1); 274 - 275 - /* reset dmic */ 276 - afe_priv->mtkaif_dmic = 0; 277 274 break; 278 275 default: 279 276 break;
+1
sound/soc/qcom/sm8250.c
··· 270 270 if (!card) 271 271 return -ENOMEM; 272 272 273 + card->owner = THIS_MODULE; 273 274 /* Allocate the private data */ 274 275 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 275 276 if (!data)
+2
sound/soc/sof/Kconfig
··· 196 196 197 197 config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST 198 198 tristate "SOF enable IPC flood test" 199 + depends on SND_SOC_SOF 199 200 select SND_SOC_SOF_CLIENT 200 201 help 201 202 This option enables a separate client device for IPC flood test ··· 215 214 216 215 config SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR 217 216 tristate "SOF enable IPC message injector" 217 + depends on SND_SOC_SOF 218 218 select SND_SOC_SOF_CLIENT 219 219 help 220 220 This option enables the IPC message injector which can be used to send
+2 -2
sound/soc/sof/ipc4-topology.c
··· 771 771 goto err; 772 772 773 773 ret = sof_update_ipc_object(scomp, src, SOF_SRC_TOKENS, swidget->tuples, 774 - swidget->num_tuples, sizeof(src), 1); 774 + swidget->num_tuples, sizeof(*src), 1); 775 775 if (ret) { 776 776 dev_err(scomp->dev, "Parsing SRC tokens failed\n"); 777 777 goto err; ··· 1251 1251 if (blob->alh_cfg.count > 1) { 1252 1252 int group_id; 1253 1253 1254 - group_id = ida_alloc_max(&alh_group_ida, ALH_MULTI_GTW_COUNT, 1254 + group_id = ida_alloc_max(&alh_group_ida, ALH_MULTI_GTW_COUNT - 1, 1255 1255 GFP_KERNEL); 1256 1256 1257 1257 if (group_id < 0)
+1 -1
sound/usb/card.c
··· 699 699 if (delayed_register[i] && 700 700 sscanf(delayed_register[i], "%x:%x", &id, &inum) == 2 && 701 701 id == chip->usb_id) 702 - return inum != iface; 702 + return iface < inum; 703 703 } 704 704 705 705 return false;
+11 -14
sound/usb/endpoint.c
··· 758 758 * The endpoint needs to be closed via snd_usb_endpoint_close() later. 759 759 * 760 760 * Note that this function doesn't configure the endpoint. The substream 761 - * needs to set it up later via snd_usb_endpoint_configure(). 761 + * needs to set it up later via snd_usb_endpoint_set_params() and 762 + * snd_usb_endpoint_prepare(). 762 763 */ 763 764 struct snd_usb_endpoint * 764 765 snd_usb_endpoint_open(struct snd_usb_audio *chip, ··· 925 924 endpoint_set_interface(chip, ep, false); 926 925 927 926 if (!--ep->opened) { 927 + if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) 928 + ep->clock_ref->rate = 0; 928 929 ep->iface = 0; 929 930 ep->altsetting = 0; 930 931 ep->cur_audiofmt = NULL; ··· 1293 1290 /* 1294 1291 * snd_usb_endpoint_set_params: configure an snd_usb_endpoint 1295 1292 * 1293 + * It's called either from hw_params callback. 1296 1294 * Determine the number of URBs to be used on this endpoint. 1297 1295 * An endpoint must be configured before it can be started. 1298 1296 * An endpoint that is already running can not be reconfigured. 1299 1297 */ 1300 - static int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, 1301 - struct snd_usb_endpoint *ep) 1298 + int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, 1299 + struct snd_usb_endpoint *ep) 1302 1300 { 1303 1301 const struct audioformat *fmt = ep->cur_audiofmt; 1304 1302 int err; ··· 1382 1378 } 1383 1379 1384 1380 /* 1385 - * snd_usb_endpoint_configure: Configure the endpoint 1381 + * snd_usb_endpoint_prepare: Prepare the endpoint 1386 1382 * 1387 1383 * This function sets up the EP to be fully usable state. 1388 - * It's called either from hw_params or prepare callback. 1384 + * It's called either from prepare callback. 1389 1385 * The function checks need_setup flag, and performs nothing unless needed, 1390 1386 * so it's safe to call this multiple times. 1391 1387 * 1392 1388 * This returns zero if unchanged, 1 if the configuration has changed, 1393 1389 * or a negative error code. 1394 1390 */ 1395 - int snd_usb_endpoint_configure(struct snd_usb_audio *chip, 1396 - struct snd_usb_endpoint *ep) 1391 + int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, 1392 + struct snd_usb_endpoint *ep) 1397 1393 { 1398 1394 bool iface_first; 1399 1395 int err = 0; ··· 1414 1410 if (err < 0) 1415 1411 goto unlock; 1416 1412 } 1417 - err = snd_usb_endpoint_set_params(chip, ep); 1418 - if (err < 0) 1419 - goto unlock; 1420 1413 goto done; 1421 1414 } 1422 1415 ··· 1438 1437 goto unlock; 1439 1438 1440 1439 err = init_sample_rate(chip, ep); 1441 - if (err < 0) 1442 - goto unlock; 1443 - 1444 - err = snd_usb_endpoint_set_params(chip, ep); 1445 1440 if (err < 0) 1446 1441 goto unlock; 1447 1442
+4 -2
sound/usb/endpoint.h
··· 17 17 bool is_sync_ep); 18 18 void snd_usb_endpoint_close(struct snd_usb_audio *chip, 19 19 struct snd_usb_endpoint *ep); 20 - int snd_usb_endpoint_configure(struct snd_usb_audio *chip, 21 - struct snd_usb_endpoint *ep); 20 + int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, 21 + struct snd_usb_endpoint *ep); 22 + int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, 23 + struct snd_usb_endpoint *ep); 22 24 int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock); 23 25 24 26 bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip,
+10 -4
sound/usb/pcm.c
··· 443 443 if (stop_endpoints(subs, false)) 444 444 sync_pending_stops(subs); 445 445 if (subs->sync_endpoint) { 446 - err = snd_usb_endpoint_configure(chip, subs->sync_endpoint); 446 + err = snd_usb_endpoint_prepare(chip, subs->sync_endpoint); 447 447 if (err < 0) 448 448 return err; 449 449 } 450 - err = snd_usb_endpoint_configure(chip, subs->data_endpoint); 450 + err = snd_usb_endpoint_prepare(chip, subs->data_endpoint); 451 451 if (err < 0) 452 452 return err; 453 453 snd_usb_set_format_quirk(subs, subs->cur_audiofmt); 454 454 } else { 455 455 if (subs->sync_endpoint) { 456 - err = snd_usb_endpoint_configure(chip, subs->sync_endpoint); 456 + err = snd_usb_endpoint_prepare(chip, subs->sync_endpoint); 457 457 if (err < 0) 458 458 return err; 459 459 } ··· 551 551 subs->cur_audiofmt = fmt; 552 552 mutex_unlock(&chip->mutex); 553 553 554 - ret = configure_endpoints(chip, subs); 554 + if (subs->sync_endpoint) { 555 + ret = snd_usb_endpoint_set_params(chip, subs->sync_endpoint); 556 + if (ret < 0) 557 + goto unlock; 558 + } 559 + 560 + ret = snd_usb_endpoint_set_params(chip, subs->data_endpoint); 555 561 556 562 unlock: 557 563 if (ret < 0)
+1 -1
sound/usb/quirks.c
··· 1764 1764 1765 1765 for (q = registration_quirks; q->usb_id; q++) 1766 1766 if (chip->usb_id == q->usb_id) 1767 - return iface != q->interface; 1767 + return iface < q->interface; 1768 1768 1769 1769 /* Register as normal */ 1770 1770 return false;
+5 -4
sound/usb/stream.c
··· 495 495 return 0; 496 496 } 497 497 } 498 + 499 + if (chip->card->registered) 500 + chip->need_delayed_register = true; 501 + 498 502 /* look for an empty stream */ 499 503 list_for_each_entry(as, &chip->pcm_list, list) { 500 504 if (as->fmt_type != fp->fmt_type) ··· 506 502 subs = &as->substream[stream]; 507 503 if (subs->ep_num) 508 504 continue; 509 - if (snd_device_get_state(chip->card, as->pcm) != 510 - SNDRV_DEV_BUILD) 511 - chip->need_delayed_register = true; 512 505 err = snd_pcm_new_stream(as->pcm, stream, 1); 513 506 if (err < 0) 514 507 return err; ··· 1106 1105 * Dallas DS4201 workaround: It presents 5 altsettings, but the last 1107 1106 * one misses syncpipe, and does not produce any sound. 1108 1107 */ 1109 - if (chip->usb_id == USB_ID(0x04fa, 0x4201)) 1108 + if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4) 1110 1109 num = 4; 1111 1110 1112 1111 for (i = 0; i < num; i++) {