From c68e07970eca79106b0c35b88a12298569590081 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Nujella Date: Tue, 26 Nov 2019 08:32:03 -0600 Subject: ASoC: intel: sof_rt5682: Add quirk for number of HDMI DAI's TGL supports one more HDMI DAI than previous models. So add quirk support for number of HDMI DAI's. Signed-off-by: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126143205.21987-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/sof_rt5682.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 751b8ea6ae1f..57adadacbf43 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -35,6 +35,10 @@ #define SOF_RT5682_SSP_AMP(quirk) \ (((quirk) << SOF_RT5682_SSP_AMP_SHIFT) & SOF_RT5682_SSP_AMP_MASK) #define SOF_RT5682_MCLK_BYTCHT_EN BIT(9) +#define SOF_RT5682_NUM_HDMIDEV_SHIFT 10 +#define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10)) +#define SOF_RT5682_NUM_HDMIDEV(quirk) \ + ((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK) /* Default: MCLK on, MCLK 19.2M, SSP0 */ static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN | @@ -594,6 +598,8 @@ static int sof_audio_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; + dmi_check_system(sof_rt5682_quirk_table); + if (soc_intel_is_byt() || soc_intel_is_cht()) { is_legacy_cpu = 1; dmic_be_num = 0; @@ -604,11 +610,13 @@ static int sof_audio_probe(struct platform_device *pdev) SOF_RT5682_SSP_CODEC(2); } else { dmic_be_num = 2; - hdmi_num = 3; + hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >> + SOF_RT5682_NUM_HDMIDEV_SHIFT; + /* default number of HDMI DAI's */ + if (!hdmi_num) + hdmi_num = 3; } - dmi_check_system(sof_rt5682_quirk_table); - /* need to get main clock from pmc */ if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { ctx->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); -- cgit v1.2.3 From 6605f0ca3af3b964635287ec7c9dadc812b78eb0 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Nujella Date: Tue, 26 Nov 2019 08:32:04 -0600 Subject: ASoC: intel: sof_rt5682: Add support for tgl-max98357a-rt5682 This patch adds the driver data and updates quirk info for tgl with max98357a speaker amp and ALC5682 headset codec. Signed-off-by: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126143205.21987-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/sof_rt5682.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 57adadacbf43..ad8a2b4bc709 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -598,6 +598,9 @@ static int sof_audio_probe(struct platform_device *pdev) if (!ctx) return -ENOMEM; + if (pdev->id_entry && pdev->id_entry->driver_data) + sof_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; + dmi_check_system(sof_rt5682_quirk_table); if (soc_intel_is_byt() || soc_intel_is_cht()) { @@ -691,6 +694,21 @@ static int sof_rt5682_remove(struct platform_device *pdev) return 0; } +static const struct platform_device_id board_ids[] = { + { + .name = "sof_rt5682", + }, + { + .name = "tgl_max98357a_rt5682", + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(0) | + SOF_SPEAKER_AMP_PRESENT | + SOF_RT5682_SSP_AMP(1) | + SOF_RT5682_NUM_HDMIDEV(4)), + }, + { } +}; + static struct platform_driver sof_audio = { .probe = sof_audio_probe, .remove = sof_rt5682_remove, @@ -698,6 +716,7 @@ static struct platform_driver sof_audio = { .name = "sof_rt5682", .pm = &snd_soc_pm_ops, }, + .id_table = board_ids, }; module_platform_driver(sof_audio) @@ -707,3 +726,4 @@ MODULE_AUTHOR("Bard Liao "); MODULE_AUTHOR("Sathya Prakash M R "); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:sof_rt5682"); +MODULE_ALIAS("platform:tgl_max98357a_rt5682"); -- cgit v1.2.3 From 903e9d372887ab046b7da2252ae8bb814c900de0 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Nujella Date: Tue, 26 Nov 2019 08:32:05 -0600 Subject: ASoC: Intel: common: Add mach table for tgl-max98357a-rt5682 Update tgl mach table to include machine with max98357a & ALC5682. Signed-off-by: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126143205.21987-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/common/soc-acpi-intel-tgl-match.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c index 57a6298d6dca..b4687a5d1962 100644 --- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c @@ -9,6 +9,11 @@ #include #include +static struct snd_soc_acpi_codecs tgl_codecs = { + .num_codecs = 1, + .codecs = {"MX98357A"} +}; + struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { { .id = "10EC1308", @@ -16,6 +21,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { .sof_fw_filename = "sof-tgl.ri", .sof_tplg_filename = "sof-tgl-rt1308.tplg", }, + { + .id = "10EC5682", + .drv_name = "tgl_max98357a_rt5682", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &tgl_codecs, + .sof_fw_filename = "sof-tgl.ri", + .sof_tplg_filename = "sof-tgl-max98357a-rt5682.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines); -- cgit v1.2.3 From 179d5811c2fcadf3f07032bb76ed47c59b91ce1d Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 Nov 2019 08:53:02 -0600 Subject: ASoC: SOF: Intel: make common HDMI driver default Use the common HDMI driver by default if the codec driver is selected in kernel build. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126145304.24204-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig index cc09bb606f7d..56a837d2cb95 100644 --- a/sound/soc/sof/intel/Kconfig +++ b/sound/soc/sof/intel/Kconfig @@ -319,6 +319,7 @@ config SND_SOC_SOF_HDA_COMMON_HDMI_CODEC bool "SOF common HDA HDMI codec driver" depends on SND_SOC_SOF_HDA_LINK depends on SND_HDA_CODEC_HDMI + default SND_HDA_CODEC_HDMI help This adds support for HDMI audio by using the common HDA HDMI/DisplayPort codec driver. -- cgit v1.2.3 From e3d8f8ae5b1ef0d470b70f65174bbf670bc74130 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 Nov 2019 08:53:03 -0600 Subject: ASoC: Intel: boards: make common HDMI driver the default for SOF Modify Kconfig rules for machine drivers used by SOF to pick SND_HDA_CODEC_HDMI by default if other conditions are met. For shared machine drivers used also by older SST driver, keep using HDAC_HDMI. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126145304.24204-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index ef20316e83d1..575064b315ef 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -261,6 +261,7 @@ config SND_SOC_INTEL_DA7219_MAX98357A_GENERIC select SND_SOC_DA7219 select SND_SOC_MAX98357A select SND_SOC_DMIC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC select SND_SOC_HDAC_HDMI config SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON @@ -387,6 +388,7 @@ config SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH select SND_SOC_RT5682 select SND_SOC_MAX98357A select SND_SOC_DMIC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC select SND_SOC_HDAC_HDMI help This adds support for ASoC machine driver for Geminilake platforms @@ -400,6 +402,7 @@ if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC || SND_SOC_SOF_HDA_AUDIO_CODEC config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH tristate "SKL/KBL/BXT/APL with HDA Codecs" + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC select SND_SOC_HDAC_HDMI select SND_SOC_DMIC # SND_SOC_HDAC_HDA is already selected @@ -419,6 +422,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH (SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST)) select SND_SOC_RT5682 select SND_SOC_DMIC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC select SND_SOC_HDAC_HDMI help This adds support for ASoC machine driver for SOF platforms @@ -448,6 +452,7 @@ config SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH select SND_SOC_RT5682 select SND_SOC_DMIC select SND_SOC_HDAC_HDMI + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC help This adds support for ASoC machine driver for SOF platform with RT1011 + RT5682 I2S codec. -- cgit v1.2.3 From 573892b6e66114898a1e3838c74603dba6bf0fbc Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 26 Nov 2019 08:53:04 -0600 Subject: ASoC: hdac_hdmi: Drop support for Icelake This reverts commit 019033c854a2 ("ASoC: Intel: hdac_hdmi: add Icelake support"). Icelake HDMI audio is supported by the HDMI codec driver, which can be used both in non-DSP (legacy HDA) and with DSP (SOF) configurations. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191126145304.24204-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 63 +++++++------------------------------------- 1 file changed, 9 insertions(+), 54 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 18c173e6a13b..e6558475e006 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -115,16 +115,8 @@ struct hdac_hdmi_dai_port_map { struct hdac_hdmi_cvt *cvt; }; -/* - * pin to port mapping table where the value indicate the pin number and - * the index indicate the port number with 1 base. - */ -static const int icl_pin2port_map[] = {0x4, 0x6, 0x8, 0xa, 0xb}; - struct hdac_hdmi_drv_data { unsigned int vendor_nid; - const int *port_map; /* pin to port mapping table */ - int port_num; }; struct hdac_hdmi_priv { @@ -1374,12 +1366,11 @@ static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid) return 0; } -#define INTEL_VENDOR_NID_0x2 0x02 -#define INTEL_VENDOR_NID_0x8 0x08 -#define INTEL_VENDOR_NID_0xb 0x0b +#define INTEL_VENDOR_NID 0x08 +#define INTEL_GLK_VENDOR_NID 0x0b #define INTEL_GET_VENDOR_VERB 0xf81 #define INTEL_SET_VENDOR_VERB 0x781 -#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */ +#define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */ #define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */ static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdev) @@ -1566,26 +1557,7 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_device *hdev, static int hdac_hdmi_pin2port(void *aptr, int pin) { - struct hdac_device *hdev = aptr; - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); - const int *map = hdmi->drv_data->port_map; - int i; - - if (!hdmi->drv_data->port_num) - return pin - 4; /* map NID 0x05 -> port #1 */ - - /* - * looking for the pin number in the mapping table and return - * the index which indicate the port number - */ - for (i = 0; i < hdmi->drv_data->port_num; i++) { - if (pin == map[i]) - return i + 1; - } - - /* return -1 if pin number exceeds our expectation */ - dev_err(&hdev->dev, "Can't find the port for pin %d\n", pin); - return -1; + return pin - 4; /* map NID 0x05 -> port #1 */ } static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) @@ -1596,18 +1568,9 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) struct hdac_hdmi_port *hport = NULL; struct snd_soc_component *component = hdmi->component; int i; - hda_nid_t pin_nid; - - if (!hdmi->drv_data->port_num) { - /* for legacy platforms */ - pin_nid = port + 0x04; - } else if (port < hdmi->drv_data->port_num) { - /* get pin number from the pin2port mapping table */ - pin_nid = hdmi->drv_data->port_map[port - 1]; - } else { - dev_err(&hdev->dev, "Can't find the pin for port %d\n", port); - return; - } + + /* Don't know how this mapping is derived */ + hda_nid_t pin_nid = port + 0x04; dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, pin_nid, pipe); @@ -2025,18 +1988,12 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdev, int pcm_idx) return port->eld.info.spk_alloc; } -static struct hdac_hdmi_drv_data intel_icl_drv_data = { - .vendor_nid = INTEL_VENDOR_NID_0x2, - .port_map = icl_pin2port_map, - .port_num = ARRAY_SIZE(icl_pin2port_map), -}; - static struct hdac_hdmi_drv_data intel_glk_drv_data = { - .vendor_nid = INTEL_VENDOR_NID_0xb, + .vendor_nid = INTEL_GLK_VENDOR_NID, }; static struct hdac_hdmi_drv_data intel_drv_data = { - .vendor_nid = INTEL_VENDOR_NID_0x8, + .vendor_nid = INTEL_VENDOR_NID, }; static int hdac_hdmi_dev_probe(struct hdac_device *hdev) @@ -2216,8 +2173,6 @@ static const struct hda_device_id hdmi_list[] = { &intel_glk_drv_data), HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI", &intel_glk_drv_data), - HDA_CODEC_EXT_ENTRY(0x8086280f, 0x100000, "Icelake HDMI", - &intel_icl_drv_data), {} }; -- cgit v1.2.3 From 9cdf85a19b3a67433fff2c8c798dc80e81d34a94 Mon Sep 17 00:00:00 2001 From: Eason Yen Date: Fri, 15 Nov 2019 18:48:45 +0800 Subject: ASoC: mediatek: common: add some helpers to control mtk_memif 1. Add the following helper in mtk-afe-fe-dai to control to control mtk_memif - mtk_memif_set_enable - mtk_memif_set_disable - mtk_memif_set_addr - mtk_memif_set_channel - mtk_memif_set_rate - mtk_memif_set_rate_substream - mtk_memif_set_format - mtk_memif_set_pbuf_size 2.extend mtk_base_memif_data struct for new platform Signed-off-by: Eason Yen Link: https://lore.kernel.org/r/1573814926-15805-2-git-send-email-eason.yen@mediatek.com Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 216 +++++++++++++++++++++++++++++ sound/soc/mediatek/common/mtk-afe-fe-dai.h | 16 +++ sound/soc/mediatek/common/mtk-base-afe.h | 28 +++- 3 files changed, 259 insertions(+), 1 deletion(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index 10ea4fdbeb1e..309dc1ef6841 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -361,6 +361,222 @@ int mtk_afe_dai_resume(struct snd_soc_dai *dai) } EXPORT_SYMBOL_GPL(mtk_afe_dai_resume); +int mtk_memif_set_enable(struct mtk_base_afe *afe, int id) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + + if (memif->data->enable_shift < 0) { + dev_warn(afe->dev, "%s(), error, id %d, enable_shift < 0\n", + __func__, id); + return 0; + } + return mtk_regmap_update_bits(afe->regmap, memif->data->enable_reg, + 1, 1, memif->data->enable_shift); +} +EXPORT_SYMBOL_GPL(mtk_memif_set_enable); + +int mtk_memif_set_disable(struct mtk_base_afe *afe, int id) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + + if (memif->data->enable_shift < 0) { + dev_warn(afe->dev, "%s(), error, id %d, enable_shift < 0\n", + __func__, id); + return 0; + } + return mtk_regmap_update_bits(afe->regmap, memif->data->enable_reg, + 1, 0, memif->data->enable_shift); +} +EXPORT_SYMBOL_GPL(mtk_memif_set_disable); + +int mtk_memif_set_addr(struct mtk_base_afe *afe, int id, + unsigned char *dma_area, + dma_addr_t dma_addr, + size_t dma_bytes) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + int msb_at_bit33 = upper_32_bits(dma_addr) ? 1 : 0; + unsigned int phys_buf_addr = lower_32_bits(dma_addr); + unsigned int phys_buf_addr_upper_32 = upper_32_bits(dma_addr); + + memif->dma_area = dma_area; + memif->dma_addr = dma_addr; + memif->dma_bytes = dma_bytes; + + /* start */ + mtk_regmap_write(afe->regmap, memif->data->reg_ofs_base, + phys_buf_addr); + /* end */ + if (memif->data->reg_ofs_end) + mtk_regmap_write(afe->regmap, + memif->data->reg_ofs_end, + phys_buf_addr + dma_bytes - 1); + else + mtk_regmap_write(afe->regmap, + memif->data->reg_ofs_base + + AFE_BASE_END_OFFSET, + phys_buf_addr + dma_bytes - 1); + + /* set start, end, upper 32 bits */ + if (memif->data->reg_ofs_base_msb) { + mtk_regmap_write(afe->regmap, memif->data->reg_ofs_base_msb, + phys_buf_addr_upper_32); + mtk_regmap_write(afe->regmap, + memif->data->reg_ofs_end_msb, + phys_buf_addr_upper_32); + } + + /* set MSB to 33-bit */ + if (memif->data->msb_reg >= 0) + mtk_regmap_update_bits(afe->regmap, memif->data->msb_reg, + 1, msb_at_bit33, memif->data->msb_shift); + + return 0; +} +EXPORT_SYMBOL_GPL(mtk_memif_set_addr); + +int mtk_memif_set_channel(struct mtk_base_afe *afe, + int id, unsigned int channel) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + unsigned int mono; + + if (memif->data->mono_shift < 0) + return 0; + + if (memif->data->quad_ch_mask) { + unsigned int quad_ch = (channel == 4) ? 1 : 0; + + mtk_regmap_update_bits(afe->regmap, memif->data->quad_ch_reg, + memif->data->quad_ch_mask, + quad_ch, memif->data->quad_ch_shift); + } + + if (memif->data->mono_invert) + mono = (channel == 1) ? 0 : 1; + else + mono = (channel == 1) ? 1 : 0; + + return mtk_regmap_update_bits(afe->regmap, memif->data->mono_reg, + 1, mono, memif->data->mono_shift); +} +EXPORT_SYMBOL_GPL(mtk_memif_set_channel); + +static int mtk_memif_set_rate_fs(struct mtk_base_afe *afe, + int id, int fs) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + + if (memif->data->fs_shift >= 0) + mtk_regmap_update_bits(afe->regmap, memif->data->fs_reg, + memif->data->fs_maskbit, + fs, memif->data->fs_shift); + + return 0; +} + +int mtk_memif_set_rate(struct mtk_base_afe *afe, + int id, unsigned int rate) +{ + int fs = 0; + + if (!afe->get_dai_fs) { + dev_err(afe->dev, "%s(), error, afe->get_dai_fs == NULL\n", + __func__); + return -EINVAL; + } + + fs = afe->get_dai_fs(afe, id, rate); + + if (fs < 0) + return -EINVAL; + + return mtk_memif_set_rate_fs(afe, id, fs); +} +EXPORT_SYMBOL_GPL(mtk_memif_set_rate); + +int mtk_memif_set_rate_substream(struct snd_pcm_substream *substream, + int id, unsigned int rate) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); + + int fs = 0; + + if (!afe->memif_fs) { + dev_err(afe->dev, "%s(), error, afe->memif_fs == NULL\n", + __func__); + return -EINVAL; + } + + fs = afe->memif_fs(substream, rate); + + if (fs < 0) + return -EINVAL; + + return mtk_memif_set_rate_fs(afe, id, fs); +} +EXPORT_SYMBOL_GPL(mtk_memif_set_rate_substream); + +int mtk_memif_set_format(struct mtk_base_afe *afe, + int id, snd_pcm_format_t format) +{ + struct mtk_base_afe_memif *memif = &afe->memif[id]; + int hd_audio = 0; + int hd_align = 0; + + /* set hd mode */ + switch (format) { + case SNDRV_PCM_FORMAT_S16_LE: + case SNDRV_PCM_FORMAT_U16_LE: + hd_audio = 0; + break; + case SNDRV_PCM_FORMAT_S32_LE: + case SNDRV_PCM_FORMAT_U32_LE: + hd_audio = 1; + hd_align = 1; + break; + case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_U24_LE: + hd_audio = 1; + break; + default: + dev_err(afe->dev, "%s() error: unsupported format %d\n", + __func__, format); + break; + } + + mtk_regmap_update_bits(afe->regmap, memif->data->hd_reg, + 1, hd_audio, memif->data->hd_shift); + + mtk_regmap_update_bits(afe->regmap, memif->data->hd_align_reg, + 1, hd_align, memif->data->hd_align_mshift); + + return 0; +} +EXPORT_SYMBOL_GPL(mtk_memif_set_format); + +int mtk_memif_set_pbuf_size(struct mtk_base_afe *afe, + int id, int pbuf_size) +{ + const struct mtk_base_memif_data *memif_data = afe->memif[id].data; + + if (memif_data->pbuf_mask == 0 || memif_data->minlen_mask == 0) + return 0; + + mtk_regmap_update_bits(afe->regmap, memif_data->pbuf_reg, + memif_data->pbuf_mask, + pbuf_size, memif_data->pbuf_shift); + + mtk_regmap_update_bits(afe->regmap, memif_data->minlen_reg, + memif_data->minlen_mask, + pbuf_size, memif_data->minlen_shift); + return 0; +} +EXPORT_SYMBOL_GPL(mtk_memif_set_pbuf_size); + MODULE_DESCRIPTION("Mediatek simple fe dai operator"); MODULE_AUTHOR("Garlic Tseng "); MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.h b/sound/soc/mediatek/common/mtk-afe-fe-dai.h index 55074fb9861a..507e3e7c3c7d 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.h +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.h @@ -34,4 +34,20 @@ int mtk_dynamic_irq_release(struct mtk_base_afe *afe, int irq_id); int mtk_afe_dai_suspend(struct snd_soc_dai *dai); int mtk_afe_dai_resume(struct snd_soc_dai *dai); +int mtk_memif_set_enable(struct mtk_base_afe *afe, int id); +int mtk_memif_set_disable(struct mtk_base_afe *afe, int id); +int mtk_memif_set_addr(struct mtk_base_afe *afe, int id, + unsigned char *dma_area, + dma_addr_t dma_addr, + size_t dma_bytes); +int mtk_memif_set_channel(struct mtk_base_afe *afe, + int id, unsigned int channel); +int mtk_memif_set_rate(struct mtk_base_afe *afe, + int id, unsigned int rate); +int mtk_memif_set_rate_substream(struct snd_pcm_substream *substream, + int id, unsigned int rate); +int mtk_memif_set_format(struct mtk_base_afe *afe, + int id, snd_pcm_format_t format); +int mtk_memif_set_pbuf_size(struct mtk_base_afe *afe, + int id, int pbuf_size); #endif diff --git a/sound/soc/mediatek/common/mtk-base-afe.h b/sound/soc/mediatek/common/mtk-base-afe.h index 60cb609a9790..a8cf44d98244 100644 --- a/sound/soc/mediatek/common/mtk-base-afe.h +++ b/sound/soc/mediatek/common/mtk-base-afe.h @@ -16,21 +16,38 @@ struct mtk_base_memif_data { const char *name; int reg_ofs_base; int reg_ofs_cur; + int reg_ofs_end; + int reg_ofs_base_msb; + int reg_ofs_cur_msb; + int reg_ofs_end_msb; int fs_reg; int fs_shift; int fs_maskbit; int mono_reg; int mono_shift; + int mono_invert; + int quad_ch_reg; + int quad_ch_mask; + int quad_ch_shift; int enable_reg; int enable_shift; int hd_reg; - int hd_align_reg; int hd_shift; + int hd_align_reg; int hd_align_mshift; int msb_reg; int msb_shift; + int msb2_reg; + int msb2_shift; int agent_disable_reg; int agent_disable_shift; + /* playback memif only */ + int pbuf_reg; + int pbuf_mask; + int pbuf_shift; + int minlen_reg; + int minlen_mask; + int minlen_shift; }; struct mtk_base_irq_data { @@ -84,6 +101,12 @@ struct mtk_base_afe { unsigned int rate); int (*irq_fs)(struct snd_pcm_substream *substream, unsigned int rate); + int (*get_dai_fs)(struct mtk_base_afe *afe, + int dai_id, unsigned int rate); + int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream); + + int (*request_dram_resource)(struct device *dev); + int (*release_dram_resource)(struct device *dev); void *platform_priv; }; @@ -95,6 +118,9 @@ struct mtk_base_afe_memif { const struct mtk_base_memif_data *data; int irq_usage; int const_irq; + unsigned char *dma_area; + dma_addr_t dma_addr; + size_t dma_bytes; }; struct mtk_base_afe_irq { -- cgit v1.2.3 From df799b9502edf84a6f5bf2476917ce1ebdead4a2 Mon Sep 17 00:00:00 2001 From: Eason Yen Date: Fri, 15 Nov 2019 18:48:46 +0800 Subject: ASoC: mediatek: common: refine hw_params and hw_prepare Refine mtk_afe_fe_hw_params and mtk_afe_fe_prepare by these helpers. - mtk_memif_set_enable - mtk_memif_set_disable - mtk_memif_set_addr - mtk_memif_set_channel - mtk_memif_set_rate - mtk_memif_set_rate_substream - mtk_memif_set_format - mtk_memif_set_pbuf_size Signed-off-by: Eason Yen Link: https://lore.kernel.org/r/1573814926-15805-3-git-send-email-eason.yen@mediatek.com Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 143 ++++++++++++++++------------- 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index 309dc1ef6841..e761cb66be5d 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -6,11 +6,13 @@ * Author: Garlic Tseng */ +#include #include #include #include #include #include "mtk-afe-platform-driver.h" +#include #include "mtk-afe-fe-dai.h" #include "mtk-base-afe.h" @@ -120,50 +122,64 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); - struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; - int msb_at_bit33 = 0; - int ret, fs = 0; + int id = rtd->cpu_dai->id; + struct mtk_base_afe_memif *memif = &afe->memif[id]; + int ret; + unsigned int channels = params_channels(params); + unsigned int rate = params_rate(params); + snd_pcm_format_t format = params_format(params); ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); if (ret < 0) return ret; - msb_at_bit33 = upper_32_bits(substream->runtime->dma_addr) ? 1 : 0; - memif->phys_buf_addr = lower_32_bits(substream->runtime->dma_addr); - memif->buffer_size = substream->runtime->dma_bytes; - - /* start */ - mtk_regmap_write(afe->regmap, memif->data->reg_ofs_base, - memif->phys_buf_addr); - /* end */ - mtk_regmap_write(afe->regmap, - memif->data->reg_ofs_base + AFE_BASE_END_OFFSET, - memif->phys_buf_addr + memif->buffer_size - 1); - - /* set MSB to 33-bit */ - mtk_regmap_update_bits(afe->regmap, memif->data->msb_reg, - 1, msb_at_bit33, memif->data->msb_shift); + if (afe->request_dram_resource) + afe->request_dram_resource(afe->dev); + + dev_dbg(afe->dev, "%s(), %s, ch %d, rate %d, fmt %d, dma_addr %pad, dma_area %p, dma_bytes 0x%zx\n", + __func__, memif->data->name, + channels, rate, format, + &substream->runtime->dma_addr, + substream->runtime->dma_area, + substream->runtime->dma_bytes); + + memset_io(substream->runtime->dma_area, 0, + substream->runtime->dma_bytes); + + /* set addr */ + ret = mtk_memif_set_addr(afe, id, + substream->runtime->dma_area, + substream->runtime->dma_addr, + substream->runtime->dma_bytes); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, set addr, ret %d\n", + __func__, id, ret); + return ret; + } /* set channel */ - if (memif->data->mono_shift >= 0) { - unsigned int mono = (params_channels(params) == 1) ? 1 : 0; - - mtk_regmap_update_bits(afe->regmap, memif->data->mono_reg, - 1, mono, memif->data->mono_shift); + ret = mtk_memif_set_channel(afe, id, channels); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, set channel %d, ret %d\n", + __func__, id, channels, ret); + return ret; } /* set rate */ - if (memif->data->fs_shift < 0) - return 0; - - fs = afe->memif_fs(substream, params_rate(params)); - - if (fs < 0) - return -EINVAL; + ret = mtk_memif_set_rate_substream(substream, id, rate); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, set rate %d, ret %d\n", + __func__, id, rate, ret); + return ret; + } - mtk_regmap_update_bits(afe->regmap, memif->data->fs_reg, - memif->data->fs_maskbit, fs, - memif->data->fs_shift); + /* set format */ + ret = mtk_memif_set_format(afe, id, format); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, set format %d, ret %d\n", + __func__, id, format, ret); + return ret; + } return 0; } @@ -172,6 +188,11 @@ EXPORT_SYMBOL_GPL(mtk_afe_fe_hw_params); int mtk_afe_fe_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + + if (afe->release_dram_resource) + afe->release_dram_resource(afe->dev); + return snd_pcm_lib_free_pages(substream); } EXPORT_SYMBOL_GPL(mtk_afe_fe_hw_free); @@ -182,20 +203,25 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); - struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; + int id = rtd->cpu_dai->id; + struct mtk_base_afe_memif *memif = &afe->memif[id]; struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; const struct mtk_base_irq_data *irq_data = irqs->irq_data; unsigned int counter = runtime->period_size; int fs; + int ret; dev_dbg(afe->dev, "%s %s cmd=%d\n", __func__, memif->data->name, cmd); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: - mtk_regmap_update_bits(afe->regmap, - memif->data->enable_reg, - 1, 1, memif->data->enable_shift); + ret = mtk_memif_set_enable(afe, id); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, memif enable, ret %d\n", + __func__, id, ret); + return ret; + } /* set irq counter */ mtk_regmap_update_bits(afe->regmap, irq_data->irq_cnt_reg, @@ -219,15 +245,19 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, return 0; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: - mtk_regmap_update_bits(afe->regmap, memif->data->enable_reg, - 1, 0, memif->data->enable_shift); + ret = mtk_memif_set_disable(afe, id); + if (ret) { + dev_err(afe->dev, "%s(), error, id %d, memif enable, ret %d\n", + __func__, id, ret); + } + /* disable interrupt */ mtk_regmap_update_bits(afe->regmap, irq_data->irq_en_reg, 1, 0, irq_data->irq_en_shift); /* and clear pending IRQ */ mtk_regmap_write(afe->regmap, irq_data->irq_clr_reg, 1 << irq_data->irq_clr_shift); - return 0; + return ret; default: return -EINVAL; } @@ -239,34 +269,15 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); - struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; - int hd_audio = 0; - int hd_align = 0; + int id = rtd->cpu_dai->id; + int pbuf_size; - /* set hd mode */ - switch (substream->runtime->format) { - case SNDRV_PCM_FORMAT_S16_LE: - hd_audio = 0; - break; - case SNDRV_PCM_FORMAT_S32_LE: - hd_audio = 1; - hd_align = 1; - break; - case SNDRV_PCM_FORMAT_S24_LE: - hd_audio = 1; - break; - default: - dev_err(afe->dev, "%s() error: unsupported format %d\n", - __func__, substream->runtime->format); - break; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (afe->get_memif_pbuf_size) { + pbuf_size = afe->get_memif_pbuf_size(substream); + mtk_memif_set_pbuf_size(afe, id, pbuf_size); + } } - - mtk_regmap_update_bits(afe->regmap, memif->data->hd_reg, - 1, hd_audio, memif->data->hd_shift); - - mtk_regmap_update_bits(afe->regmap, memif->data->hd_align_reg, - 1, hd_align, memif->data->hd_align_mshift); - return 0; } EXPORT_SYMBOL_GPL(mtk_afe_fe_prepare); -- cgit v1.2.3 From 0bb1306f22fb8da72f3d1ba63854489cc8cfe0dd Mon Sep 17 00:00:00 2001 From: Nikita Yushchenko Date: Thu, 28 Nov 2019 16:54:47 +0300 Subject: ASoC: tlv320aic31xx: Add HP output driver pop reduction controls HP output driver has two parameters that can be configured to reduce pop noise: power-on delay and ramp-up step time. Two new kcontrols have been added to set these parameters. Also have to alter timeout in aic31xx_dapm_power_event() because default timeout does fire when higher supported power-on delay are configured. Signed-off-by: Nikita Yushchenko Link: https://lore.kernel.org/r/20191128135447.26458-1-nikita.yoush@cogentembedded.com Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index f6f19fdc72f5..d6c462f21370 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -262,6 +262,19 @@ static SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2, static SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4, mic_select_text); +static const char * const hp_poweron_time_text[] = { + "0us", "15.3us", "153us", "1.53ms", "15.3ms", "76.2ms", + "153ms", "304ms", "610ms", "1.22s", "3.04s", "6.1s" }; + +static SOC_ENUM_SINGLE_DECL(hp_poweron_time_enum, AIC31XX_HPPOP, 3, + hp_poweron_time_text); + +static const char * const hp_rampup_step_text[] = { + "0ms", "0.98ms", "1.95ms", "3.9ms" }; + +static SOC_ENUM_SINGLE_DECL(hp_rampup_step_enum, AIC31XX_HPPOP, 1, + hp_rampup_step_text); + static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0); static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0); static const DECLARE_TLV_DB_SCALE(adc_cgain_tlv, -2000, 50, 0); @@ -285,6 +298,14 @@ static const struct snd_kcontrol_new common31xx_snd_controls[] = { SOC_DOUBLE_R_TLV("HP Analog Playback Volume", AIC31XX_LANALOGHPL, AIC31XX_RANALOGHPR, 0, 0x7F, 1, hp_vol_tlv), + + /* HP de-pop control: apply power not immediately but via ramp + * function with these psarameters. Note that power up sequence + * has to wait for this to complete; this is implemented by + * polling HP driver status in aic31xx_dapm_power_event() + */ + SOC_ENUM("HP Output Driver Power-On time", hp_poweron_time_enum), + SOC_ENUM("HP Output Driver Ramp-up step", hp_rampup_step_enum), }; static const struct snd_kcontrol_new aic31xx_snd_controls[] = { @@ -357,6 +378,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); unsigned int reg = AIC31XX_DACFLAG1; unsigned int mask; + unsigned int timeout = 500 * USEC_PER_MSEC; switch (WIDGET_BIT(w->reg, w->shift)) { case WIDGET_BIT(AIC31XX_DACSETUP, 7): @@ -367,9 +389,13 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, break; case WIDGET_BIT(AIC31XX_HPDRIVER, 7): mask = AIC31XX_HPLDRVPWRSTATUS_MASK; + if (event == SND_SOC_DAPM_POST_PMU) + timeout = 7 * USEC_PER_SEC; break; case WIDGET_BIT(AIC31XX_HPDRIVER, 6): mask = AIC31XX_HPRDRVPWRSTATUS_MASK; + if (event == SND_SOC_DAPM_POST_PMU) + timeout = 7 * USEC_PER_SEC; break; case WIDGET_BIT(AIC31XX_SPKAMP, 7): mask = AIC31XX_SPLDRVPWRSTATUS_MASK; @@ -389,9 +415,11 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - return aic31xx_wait_bits(aic31xx, reg, mask, mask, 5000, 100); + return aic31xx_wait_bits(aic31xx, reg, mask, mask, + 5000, timeout / 5000); case SND_SOC_DAPM_POST_PMD: - return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); + return aic31xx_wait_bits(aic31xx, reg, mask, 0, + 5000, timeout / 5000); default: dev_dbg(component->dev, "Unhandled dapm widget event %d from %s\n", -- cgit v1.2.3 From 2eb2d314a80eb8bb1a6faf2a74321d4497e1687d Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Thu, 28 Nov 2019 23:38:02 +0100 Subject: ASoC: fsl_sai: add IRQF_SHARED The LS1028A SoC uses the same interrupt line for adjacent SAIs. Use IRQF_SHARED to be able to use these SAIs simultaneously. Signed-off-by: Michael Walle Reviewed-by: Fabio Estevam Acked-by: Nicolin Chen Acked-by: Daniel Baluta Link: https://lore.kernel.org/r/20191128223802.18228-1-michael@walle.cc Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index b517e4bc1b87..8c3ea7300972 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -958,7 +958,8 @@ static int fsl_sai_probe(struct platform_device *pdev) if (irq < 0) return irq; - ret = devm_request_irq(&pdev->dev, irq, fsl_sai_isr, 0, np->name, sai); + ret = devm_request_irq(&pdev->dev, irq, fsl_sai_isr, IRQF_SHARED, + np->name, sai); if (ret) { dev_err(&pdev->dev, "failed to claim irq %u\n", irq); return ret; -- cgit v1.2.3 From 62d5ae4cafb7ffeeec6ba2dd1814cafeeea7dd8f Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Thu, 28 Nov 2019 23:19:08 +0800 Subject: ASoC: max98090: save and restore SHDN when changing sensitive registers According to the datasheet, there are some registers can only be changed when SHDN is 0. Changing these settings during SHDN = 1 can compromise device stability and performance specifications. Saves SHDN before writing to these sensitive registers and restores SHDN afterward. Here is the register list codec driver of max98090 wants to change: M98090_REG_QUICK_SYSTEM_CLOCK 0x04 M98090_REG_QUICK_SAMPLE_RATE 0x05 M98090_REG_DAI_INTERFACE 0x06 M98090_REG_DAC_PATH 0x07 M98090_REG_MIC_DIRECT_TO_ADC 0x08 M98090_REG_LINE_TO_ADC 0x09 M98090_REG_ANALOG_MIC_LOOP 0x0A M98090_REG_ANALOG_LINE_LOOP 0x0B M98090_REG_SYSTEM_CLOCK 0x1B M98090_REG_CLOCK_MODE 0x1C M98090_REG_CLOCK_RATIO_NI_MSB 0x1D M98090_REG_CLOCK_RATIO_NI_LSB 0x1E M98090_REG_CLOCK_RATIO_MI_MSB 0x1F M98090_REG_CLOCK_RATIO_MI_LSB 0x20 M98090_REG_MASTER_MODE 0x21 M98090_REG_INTERFACE_FORMAT 0x22 M98090_REG_TDM_CONTROL 0x23 M98090_REG_TDM_FORMAT 0x24 M98090_REG_IO_CONFIGURATION 0x25 M98090_REG_FILTER_CONFIG 0x26 M98090_REG_INPUT_ENABLE 0x3E M98090_REG_OUTPUT_ENABLE 0x3F M98090_REG_BIAS_CONTROL 0x42 M98090_REG_DAC_CONTROL 0x43 M98090_REG_ADC_CONTROL 0x44 M98090_REG_DRC_TIMING 0x33 M98090_REG_DRC_COMPRESSOR 0x34 M98090_REG_DRC_EXPANDER 0x35 M98090_REG_DSP_FILTER_ENABLE 0x41 M98090_REG_EQUALIZER_BASE 0x46 M98090_REG_RECORD_BIQUAD_BASE 0xAF M98090_REG_DIGITAL_MIC_ENABLE 0x13 M98090_REG_DIGITAL_MIC_CONFIG 0x14 Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20191128151908.180871-1-tzungbi@google.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 433 +++++++++++++++++++++++++++++++------------- sound/soc/codecs/max98090.h | 3 +- 2 files changed, 312 insertions(+), 124 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f6bf4cfbea23..be1fc8a4aee9 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -5,24 +5,149 @@ * Copyright 2011-2012 Maxim Integrated Products */ +#include +#include #include #include #include +#include #include #include #include #include #include -#include -#include #include +#include #include #include #include #include -#include #include "max98090.h" +static void max98090_shdn_save_locked(struct max98090_priv *max98090) +{ + int shdn = 0; + + /* saved_shdn, saved_count, SHDN are protected by card->dapm_mutex */ + regmap_read(max98090->regmap, M98090_REG_DEVICE_SHUTDOWN, &shdn); + max98090->saved_shdn |= shdn; + ++max98090->saved_count; + + if (shdn) + regmap_write(max98090->regmap, M98090_REG_DEVICE_SHUTDOWN, 0x0); +} + +static void max98090_shdn_restore_locked(struct max98090_priv *max98090) +{ + /* saved_shdn, saved_count, SHDN are protected by card->dapm_mutex */ + if (--max98090->saved_count == 0) { + if (max98090->saved_shdn) { + regmap_write(max98090->regmap, + M98090_REG_DEVICE_SHUTDOWN, + M98090_SHDNN_MASK); + max98090->saved_shdn = 0; + } + } +} + +static void max98090_shdn_save(struct max98090_priv *max98090) +{ + mutex_lock(&max98090->component->card->dapm_mutex); + max98090_shdn_save_locked(max98090); +} + +static void max98090_shdn_restore(struct max98090_priv *max98090) +{ + max98090_shdn_restore_locked(max98090); + mutex_unlock(&max98090->component->card->dapm_mutex); +} + +static int max98090_put_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = + snd_soc_component_get_drvdata(component); + int ret; + + max98090_shdn_save(max98090); + ret = snd_soc_put_volsw(kcontrol, ucontrol); + max98090_shdn_restore(max98090); + + return ret; +} + +static int max98090_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = + snd_soc_component_get_drvdata(component); + int ret; + + max98090_shdn_save(max98090); + ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); + max98090_shdn_restore(max98090); + + return ret; +} + +static int max98090_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = + snd_soc_component_get_drvdata(component); + int ret; + + max98090_shdn_save(max98090); + ret = snd_soc_put_enum_double(kcontrol, ucontrol); + max98090_shdn_restore(max98090); + + return ret; +} + +static int max98090_bytes_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = + snd_soc_component_get_drvdata(component); + int ret; + + max98090_shdn_save(max98090); + ret = snd_soc_bytes_put(kcontrol, ucontrol); + max98090_shdn_restore(max98090); + + return ret; +} + +static int max98090_dapm_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct max98090_priv *max98090 = + snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + case SND_SOC_DAPM_PRE_PMD: + max98090_shdn_save_locked(max98090); + break; + case SND_SOC_DAPM_POST_PMU: + case SND_SOC_DAPM_POST_PMD: + max98090_shdn_restore_locked(max98090); + break; + } + + return 0; +} + /* Allows for sparsely populated register maps */ static const struct reg_default max98090_reg[] = { { 0x00, 0x00 }, /* 00 Software Reset */ @@ -506,10 +631,13 @@ static SOC_ENUM_SINGLE_DECL(max98090_adchp_enum, max98090_pwr_perf_text); static const struct snd_kcontrol_new max98090_snd_controls[] = { - SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum), + SOC_ENUM_EXT("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum, + snd_soc_get_enum_double, max98090_put_enum_double), - SOC_SINGLE("DMIC MIC Comp Filter Config", M98090_REG_DIGITAL_MIC_CONFIG, - M98090_DMIC_COMP_SHIFT, M98090_DMIC_COMP_NUM - 1, 0), + SOC_SINGLE_EXT("DMIC MIC Comp Filter Config", + M98090_REG_DIGITAL_MIC_CONFIG, + M98090_DMIC_COMP_SHIFT, M98090_DMIC_COMP_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), SOC_SINGLE_EXT_TLV("MIC1 Boost Volume", M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, @@ -564,24 +692,34 @@ static const struct snd_kcontrol_new max98090_snd_controls[] = { M98090_AVR_SHIFT, M98090_AVR_NUM - 1, 1, max98090_av_tlv), - SOC_ENUM("ADC Oversampling Rate", max98090_osr128_enum), - SOC_SINGLE("ADC Quantizer Dither", M98090_REG_ADC_CONTROL, - M98090_ADCDITHER_SHIFT, M98090_ADCDITHER_NUM - 1, 0), - SOC_ENUM("ADC High Performance Mode", max98090_adchp_enum), - - SOC_SINGLE("DAC Mono Mode", M98090_REG_IO_CONFIGURATION, - M98090_DMONO_SHIFT, M98090_DMONO_NUM - 1, 0), - SOC_SINGLE("SDIN Mode", M98090_REG_IO_CONFIGURATION, - M98090_SDIEN_SHIFT, M98090_SDIEN_NUM - 1, 0), - SOC_SINGLE("SDOUT Mode", M98090_REG_IO_CONFIGURATION, - M98090_SDOEN_SHIFT, M98090_SDOEN_NUM - 1, 0), - SOC_SINGLE("SDOUT Hi-Z Mode", M98090_REG_IO_CONFIGURATION, - M98090_HIZOFF_SHIFT, M98090_HIZOFF_NUM - 1, 1), - SOC_ENUM("Filter Mode", max98090_mode_enum), - SOC_SINGLE("Record Path DC Blocking", M98090_REG_FILTER_CONFIG, - M98090_AHPF_SHIFT, M98090_AHPF_NUM - 1, 0), - SOC_SINGLE("Playback Path DC Blocking", M98090_REG_FILTER_CONFIG, - M98090_DHPF_SHIFT, M98090_DHPF_NUM - 1, 0), + SOC_ENUM_EXT("ADC Oversampling Rate", max98090_osr128_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_SINGLE_EXT("ADC Quantizer Dither", M98090_REG_ADC_CONTROL, + M98090_ADCDITHER_SHIFT, M98090_ADCDITHER_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_ENUM_EXT("ADC High Performance Mode", max98090_adchp_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + + SOC_SINGLE_EXT("DAC Mono Mode", M98090_REG_IO_CONFIGURATION, + M98090_DMONO_SHIFT, M98090_DMONO_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("SDIN Mode", M98090_REG_IO_CONFIGURATION, + M98090_SDIEN_SHIFT, M98090_SDIEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("SDOUT Mode", M98090_REG_IO_CONFIGURATION, + M98090_SDOEN_SHIFT, M98090_SDOEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("SDOUT Hi-Z Mode", M98090_REG_IO_CONFIGURATION, + M98090_HIZOFF_SHIFT, M98090_HIZOFF_NUM - 1, 1, + snd_soc_get_volsw, max98090_put_volsw), + SOC_ENUM_EXT("Filter Mode", max98090_mode_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_SINGLE_EXT("Record Path DC Blocking", M98090_REG_FILTER_CONFIG, + M98090_AHPF_SHIFT, M98090_AHPF_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("Playback Path DC Blocking", M98090_REG_FILTER_CONFIG, + M98090_DHPF_SHIFT, M98090_DHPF_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), SOC_SINGLE_TLV("Digital BQ Volume", M98090_REG_ADC_BIQUAD_LEVEL, M98090_AVBQ_SHIFT, M98090_AVBQ_NUM - 1, 1, max98090_dv_tlv), SOC_SINGLE_EXT_TLV("Digital Sidetone Volume", @@ -594,13 +732,17 @@ static const struct snd_kcontrol_new max98090_snd_controls[] = { SOC_SINGLE_TLV("Digital Volume", M98090_REG_DAI_PLAYBACK_LEVEL, M98090_DV_SHIFT, M98090_DV_NUM - 1, 1, max98090_dv_tlv), - SND_SOC_BYTES("EQ Coefficients", M98090_REG_EQUALIZER_BASE, 105), - SOC_SINGLE("Digital EQ 3 Band Switch", M98090_REG_DSP_FILTER_ENABLE, - M98090_EQ3BANDEN_SHIFT, M98090_EQ3BANDEN_NUM - 1, 0), - SOC_SINGLE("Digital EQ 5 Band Switch", M98090_REG_DSP_FILTER_ENABLE, - M98090_EQ5BANDEN_SHIFT, M98090_EQ5BANDEN_NUM - 1, 0), - SOC_SINGLE("Digital EQ 7 Band Switch", M98090_REG_DSP_FILTER_ENABLE, - M98090_EQ7BANDEN_SHIFT, M98090_EQ7BANDEN_NUM - 1, 0), + SND_SOC_BYTES_E("EQ Coefficients", M98090_REG_EQUALIZER_BASE, 105, + snd_soc_bytes_get, max98090_bytes_put), + SOC_SINGLE_EXT("Digital EQ 3 Band Switch", M98090_REG_DSP_FILTER_ENABLE, + M98090_EQ3BANDEN_SHIFT, M98090_EQ3BANDEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("Digital EQ 5 Band Switch", M98090_REG_DSP_FILTER_ENABLE, + M98090_EQ5BANDEN_SHIFT, M98090_EQ5BANDEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_SINGLE_EXT("Digital EQ 7 Band Switch", M98090_REG_DSP_FILTER_ENABLE, + M98090_EQ7BANDEN_SHIFT, M98090_EQ7BANDEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), SOC_SINGLE("Digital EQ Clipping Detection", M98090_REG_DAI_PLAYBACK_LEVEL_EQ, M98090_EQCLPN_SHIFT, M98090_EQCLPN_NUM - 1, 1), @@ -608,25 +750,34 @@ static const struct snd_kcontrol_new max98090_snd_controls[] = { M98090_DVEQ_SHIFT, M98090_DVEQ_NUM - 1, 1, max98090_dv_tlv), - SOC_SINGLE("ALC Enable", M98090_REG_DRC_TIMING, - M98090_DRCEN_SHIFT, M98090_DRCEN_NUM - 1, 0), - SOC_ENUM("ALC Attack Time", max98090_drcatk_enum), - SOC_ENUM("ALC Release Time", max98090_drcrls_enum), + SOC_SINGLE_EXT("ALC Enable", M98090_REG_DRC_TIMING, + M98090_DRCEN_SHIFT, M98090_DRCEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), + SOC_ENUM_EXT("ALC Attack Time", max98090_drcatk_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_ENUM_EXT("ALC Release Time", max98090_drcrls_enum, + snd_soc_get_enum_double, max98090_put_enum_double), SOC_SINGLE_TLV("ALC Make Up Volume", M98090_REG_DRC_GAIN, M98090_DRCG_SHIFT, M98090_DRCG_NUM - 1, 0, max98090_alcmakeup_tlv), - SOC_ENUM("ALC Compression Ratio", max98090_alccmp_enum), - SOC_ENUM("ALC Expansion Ratio", max98090_drcexp_enum), - SOC_SINGLE_TLV("ALC Compression Threshold Volume", + SOC_ENUM_EXT("ALC Compression Ratio", max98090_alccmp_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_ENUM_EXT("ALC Expansion Ratio", max98090_drcexp_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_SINGLE_EXT_TLV("ALC Compression Threshold Volume", M98090_REG_DRC_COMPRESSOR, M98090_DRCTHC_SHIFT, - M98090_DRCTHC_NUM - 1, 1, max98090_alccomp_tlv), - SOC_SINGLE_TLV("ALC Expansion Threshold Volume", + M98090_DRCTHC_NUM - 1, 1, + snd_soc_get_volsw, max98090_put_volsw, max98090_alccomp_tlv), + SOC_SINGLE_EXT_TLV("ALC Expansion Threshold Volume", M98090_REG_DRC_EXPANDER, M98090_DRCTHE_SHIFT, - M98090_DRCTHE_NUM - 1, 1, max98090_drcexp_tlv), + M98090_DRCTHE_NUM - 1, 1, + snd_soc_get_volsw, max98090_put_volsw, max98090_drcexp_tlv), - SOC_ENUM("DAC HP Playback Performance Mode", - max98090_dac_perfmode_enum), - SOC_ENUM("DAC High Performance Mode", max98090_dachp_enum), + SOC_ENUM_EXT("DAC HP Playback Performance Mode", + max98090_dac_perfmode_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_ENUM_EXT("DAC High Performance Mode", max98090_dachp_enum, + snd_soc_get_enum_double, max98090_put_enum_double), SOC_SINGLE_TLV("Headphone Left Mixer Volume", M98090_REG_HP_CONTROL, M98090_MIXHPLG_SHIFT, @@ -684,9 +835,12 @@ static const struct snd_kcontrol_new max98090_snd_controls[] = { SOC_SINGLE("Volume Adjustment Smoothing", M98090_REG_LEVEL_CONTROL, M98090_VSENN_SHIFT, M98090_VSENN_NUM - 1, 1), - SND_SOC_BYTES("Biquad Coefficients", M98090_REG_RECORD_BIQUAD_BASE, 15), - SOC_SINGLE("Biquad Switch", M98090_REG_DSP_FILTER_ENABLE, - M98090_ADCBQEN_SHIFT, M98090_ADCBQEN_NUM - 1, 0), + SND_SOC_BYTES_E("Biquad Coefficients", + M98090_REG_RECORD_BIQUAD_BASE, 15, + snd_soc_bytes_get, max98090_bytes_put), + SOC_SINGLE_EXT("Biquad Switch", M98090_REG_DSP_FILTER_ENABLE, + M98090_ADCBQEN_SHIFT, M98090_ADCBQEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), }; static const struct snd_kcontrol_new max98091_snd_controls[] = { @@ -695,10 +849,12 @@ static const struct snd_kcontrol_new max98091_snd_controls[] = { M98090_DMIC34_ZEROPAD_SHIFT, M98090_DMIC34_ZEROPAD_NUM - 1, 0), - SOC_ENUM("Filter DMIC34 Mode", max98090_filter_dmic34mode_enum), - SOC_SINGLE("DMIC34 DC Blocking", M98090_REG_FILTER_CONFIG, + SOC_ENUM_EXT("Filter DMIC34 Mode", max98090_filter_dmic34mode_enum, + snd_soc_get_enum_double, max98090_put_enum_double), + SOC_SINGLE_EXT("DMIC34 DC Blocking", M98090_REG_FILTER_CONFIG, M98090_FLT_DMIC34HPF_SHIFT, - M98090_FLT_DMIC34HPF_NUM - 1, 0), + M98090_FLT_DMIC34HPF_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), SOC_SINGLE_TLV("DMIC3 Boost Volume", M98090_REG_DMIC3_VOLUME, M98090_DMIC_AV3G_SHIFT, M98090_DMIC_AV3G_NUM - 1, 0, @@ -716,8 +872,9 @@ static const struct snd_kcontrol_new max98091_snd_controls[] = { SND_SOC_BYTES("DMIC34 Biquad Coefficients", M98090_REG_DMIC34_BIQUAD_BASE, 15), - SOC_SINGLE("DMIC34 Biquad Switch", M98090_REG_DSP_FILTER_ENABLE, - M98090_DMIC34BQEN_SHIFT, M98090_DMIC34BQEN_NUM - 1, 0), + SOC_SINGLE_EXT("DMIC34 Biquad Switch", M98090_REG_DSP_FILTER_ENABLE, + M98090_DMIC34BQEN_SHIFT, M98090_DMIC34BQEN_NUM - 1, 0, + snd_soc_get_volsw, max98090_put_volsw), SOC_SINGLE_TLV("DMIC34 BQ PreAttenuation Volume", M98090_REG_DMIC34_BQ_PREATTEN, M98090_AV34BQ_SHIFT, @@ -771,19 +928,6 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, return 0; } -static int max98090_shdn_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); - - if (event & SND_SOC_DAPM_POST_PMU) - max98090->shdn_pending = true; - - return 0; - -} - static const char *mic1_mux_text[] = { "IN12", "IN56" }; static SOC_ENUM_SINGLE_DECL(mic1_mux_enum, @@ -884,10 +1028,14 @@ static SOC_ENUM_SINGLE_DECL(ltenr_mux_enum, lten_mux_text); static const struct snd_kcontrol_new max98090_ltenl_mux = - SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum); + SOC_DAPM_ENUM_EXT("LTENL Mux", ltenl_mux_enum, + snd_soc_dapm_get_enum_double, + max98090_dapm_put_enum_double); static const struct snd_kcontrol_new max98090_ltenr_mux = - SOC_DAPM_ENUM("LTENR Mux", ltenr_mux_enum); + SOC_DAPM_ENUM_EXT("LTENR Mux", ltenr_mux_enum, + snd_soc_dapm_get_enum_double, + max98090_dapm_put_enum_double); static const char *lben_mux_text[] = { "Normal", "Loopback" }; @@ -902,10 +1050,14 @@ static SOC_ENUM_SINGLE_DECL(lbenr_mux_enum, lben_mux_text); static const struct snd_kcontrol_new max98090_lbenl_mux = - SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum); + SOC_DAPM_ENUM_EXT("LBENL Mux", lbenl_mux_enum, + snd_soc_dapm_get_enum_double, + max98090_dapm_put_enum_double); static const struct snd_kcontrol_new max98090_lbenr_mux = - SOC_DAPM_ENUM("LBENR Mux", lbenr_mux_enum); + SOC_DAPM_ENUM_EXT("LBENR Mux", lbenr_mux_enum, + snd_soc_dapm_get_enum_double, + max98090_dapm_put_enum_double); static const char *stenl_mux_text[] = { "Normal", "Sidetone Left" }; @@ -1072,21 +1224,25 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_INPUT("IN56"), SND_SOC_DAPM_SUPPLY("MICBIAS", M98090_REG_INPUT_ENABLE, - M98090_MBEN_SHIFT, 0, NULL, 0), + M98090_MBEN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("SHDN", M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("SDIEN", M98090_REG_IO_CONFIGURATION, - M98090_SDIEN_SHIFT, 0, NULL, 0), + M98090_SDIEN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("SDOEN", M98090_REG_IO_CONFIGURATION, - M98090_SDOEN_SHIFT, 0, NULL, 0), + M98090_SDOEN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("DMICL_ENA", M98090_REG_DIGITAL_MIC_ENABLE, - M98090_DIGMICL_SHIFT, 0, max98090_shdn_event, - SND_SOC_DAPM_POST_PMU), + M98090_DIGMICL_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("DMICR_ENA", M98090_REG_DIGITAL_MIC_ENABLE, - M98090_DIGMICR_SHIFT, 0, max98090_shdn_event, - SND_SOC_DAPM_POST_PMU), + M98090_DIGMICR_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("AHPF", M98090_REG_FILTER_CONFIG, - M98090_AHPF_SHIFT, 0, NULL, 0), + M98090_AHPF_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), /* * Note: Sysclk and misc power supplies are taken care of by SHDN @@ -1116,10 +1272,12 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { &max98090_lineb_mixer_controls[0], ARRAY_SIZE(max98090_lineb_mixer_controls)), - SND_SOC_DAPM_PGA("LINEA Input", M98090_REG_INPUT_ENABLE, - M98090_LINEAEN_SHIFT, 0, NULL, 0), - SND_SOC_DAPM_PGA("LINEB Input", M98090_REG_INPUT_ENABLE, - M98090_LINEBEN_SHIFT, 0, NULL, 0), + SND_SOC_DAPM_PGA_E("LINEA Input", M98090_REG_INPUT_ENABLE, + M98090_LINEAEN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_PGA_E("LINEB Input", M98090_REG_INPUT_ENABLE, + M98090_LINEBEN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_MIXER("Left ADC Mixer", SND_SOC_NOPM, 0, 0, &max98090_left_adc_mixer_controls[0], @@ -1130,11 +1288,11 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { ARRAY_SIZE(max98090_right_adc_mixer_controls)), SND_SOC_DAPM_ADC_E("ADCL", NULL, M98090_REG_INPUT_ENABLE, - M98090_ADLEN_SHIFT, 0, max98090_shdn_event, - SND_SOC_DAPM_POST_PMU), + M98090_ADLEN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_ADC_E("ADCR", NULL, M98090_REG_INPUT_ENABLE, - M98090_ADREN_SHIFT, 0, max98090_shdn_event, - SND_SOC_DAPM_POST_PMU), + M98090_ADREN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_AIF_OUT("AIFOUTL", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0), @@ -1162,10 +1320,12 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_AIF_IN("AIFINL", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_IN("AIFINR", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0), - SND_SOC_DAPM_DAC("DACL", NULL, M98090_REG_OUTPUT_ENABLE, - M98090_DALEN_SHIFT, 0), - SND_SOC_DAPM_DAC("DACR", NULL, M98090_REG_OUTPUT_ENABLE, - M98090_DAREN_SHIFT, 0), + SND_SOC_DAPM_DAC_E("DACL", NULL, M98090_REG_OUTPUT_ENABLE, + M98090_DALEN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_DAC_E("DACR", NULL, M98090_REG_OUTPUT_ENABLE, + M98090_DAREN_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_MIXER("Left Headphone Mixer", SND_SOC_NOPM, 0, 0, &max98090_left_hp_mixer_controls[0], @@ -1200,20 +1360,26 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_MUX("MIXHPRSEL Mux", SND_SOC_NOPM, 0, 0, &max98090_mixhprsel_mux), - SND_SOC_DAPM_PGA("HP Left Out", M98090_REG_OUTPUT_ENABLE, - M98090_HPLEN_SHIFT, 0, NULL, 0), - SND_SOC_DAPM_PGA("HP Right Out", M98090_REG_OUTPUT_ENABLE, - M98090_HPREN_SHIFT, 0, NULL, 0), - - SND_SOC_DAPM_PGA("SPK Left Out", M98090_REG_OUTPUT_ENABLE, - M98090_SPLEN_SHIFT, 0, NULL, 0), - SND_SOC_DAPM_PGA("SPK Right Out", M98090_REG_OUTPUT_ENABLE, - M98090_SPREN_SHIFT, 0, NULL, 0), - - SND_SOC_DAPM_PGA("RCV Left Out", M98090_REG_OUTPUT_ENABLE, - M98090_RCVLEN_SHIFT, 0, NULL, 0), - SND_SOC_DAPM_PGA("RCV Right Out", M98090_REG_OUTPUT_ENABLE, - M98090_RCVREN_SHIFT, 0, NULL, 0), + SND_SOC_DAPM_PGA_E("HP Left Out", M98090_REG_OUTPUT_ENABLE, + M98090_HPLEN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_PGA_E("HP Right Out", M98090_REG_OUTPUT_ENABLE, + M98090_HPREN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + + SND_SOC_DAPM_PGA_E("SPK Left Out", M98090_REG_OUTPUT_ENABLE, + M98090_SPLEN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_PGA_E("SPK Right Out", M98090_REG_OUTPUT_ENABLE, + M98090_SPREN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + + SND_SOC_DAPM_PGA_E("RCV Left Out", M98090_REG_OUTPUT_ENABLE, + M98090_RCVLEN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_PGA_E("RCV Right Out", M98090_REG_OUTPUT_ENABLE, + M98090_RCVREN_SHIFT, 0, NULL, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_OUTPUT("HPL"), SND_SOC_DAPM_OUTPUT("HPR"), @@ -1228,9 +1394,11 @@ static const struct snd_soc_dapm_widget max98091_dapm_widgets[] = { SND_SOC_DAPM_INPUT("DMIC4"), SND_SOC_DAPM_SUPPLY("DMIC3_ENA", M98090_REG_DIGITAL_MIC_ENABLE, - M98090_DIGMIC3_SHIFT, 0, NULL, 0), + M98090_DIGMIC3_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), SND_SOC_DAPM_SUPPLY("DMIC4_ENA", M98090_REG_DIGITAL_MIC_ENABLE, - M98090_DIGMIC4_SHIFT, 0, NULL, 0), + M98090_DIGMIC4_SHIFT, 0, max98090_dapm_event, + SND_SOC_DAPM_PRE_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), }; static const struct snd_soc_dapm_route max98090_dapm_routes[] = { @@ -1501,6 +1669,11 @@ static void max98090_configure_bclk(struct snd_soc_component *component) return; } + /* + * Master mode: no need to save and restore SHDN for the following + * sensitive registers. + */ + /* Check for supported PCLK to LRCLK ratios */ for (i = 0; i < ARRAY_SIZE(pclk_rates); i++) { if ((pclk_rates[i] == max98090->sysclk) && @@ -1587,12 +1760,14 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Set to slave mode PLL - MAS mode off */ + max98090_shdn_save(max98090); snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB, 0x00); snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB, 0x00); snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_USE_M1_MASK, 0); + max98090_shdn_restore(max98090); max98090->master = false; break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1618,7 +1793,9 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, dev_err(component->dev, "DAI clock mode unsupported"); return -EINVAL; } + max98090_shdn_save(max98090); snd_soc_component_write(component, M98090_REG_MASTER_MODE, regval); + max98090_shdn_restore(max98090); regval = 0; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -1663,8 +1840,10 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, if (max98090->tdm_slots > 1) regval ^= M98090_BCI_MASK; + max98090_shdn_save(max98090); snd_soc_component_write(component, M98090_REG_INTERFACE_FORMAT, regval); + max98090_shdn_restore(max98090); } return 0; @@ -1676,6 +1855,7 @@ static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, struct snd_soc_component *component = codec_dai->component; struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct max98090_cdata *cdata; + cdata = &max98090->dai[0]; if (slots < 0 || slots > 4) @@ -1685,6 +1865,7 @@ static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, max98090->tdm_width = slot_width; if (max98090->tdm_slots > 1) { + max98090_shdn_save(max98090); /* SLOTL SLOTR SLOTDLY */ snd_soc_component_write(component, M98090_REG_TDM_FORMAT, 0 << M98090_TDM_SLOTL_SHIFT | @@ -1695,6 +1876,7 @@ static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, snd_soc_component_update_bits(component, M98090_REG_TDM_CONTROL, M98090_TDM_MASK, M98090_TDM_MASK); + max98090_shdn_restore(max98090); } /* @@ -1894,6 +2076,7 @@ static int max98090_configure_dmic(struct max98090_priv *max98090, dmic_freq = dmic_table[pclk_index].settings[micclk_index].freq; dmic_comp = dmic_table[pclk_index].settings[micclk_index].comp[i]; + max98090_shdn_save(max98090); regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE, M98090_MICCLK_MASK, micclk_index << M98090_MICCLK_SHIFT); @@ -1902,6 +2085,7 @@ static int max98090_configure_dmic(struct max98090_priv *max98090, M98090_DMIC_COMP_MASK | M98090_DMIC_FREQ_MASK, dmic_comp << M98090_DMIC_COMP_SHIFT | dmic_freq << M98090_DMIC_FREQ_SHIFT); + max98090_shdn_restore(max98090); return 0; } @@ -1938,8 +2122,10 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: + max98090_shdn_save(max98090); snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT, M98090_WS_MASK, 0); + max98090_shdn_restore(max98090); break; default: return -EINVAL; @@ -1950,6 +2136,7 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, cdata->rate = max98090->lrclk; + max98090_shdn_save(max98090); /* Update filter mode */ if (max98090->lrclk < 24000) snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, @@ -1965,6 +2152,7 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, else snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, M98090_DHF_MASK, M98090_DHF_MASK); + max98090_shdn_restore(max98090); max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, max98090->lrclk); @@ -1995,6 +2183,7 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, * 0x02 (when master clk is 20MHz to 40MHz).. * 0x03 (when master clk is 40MHz to 60MHz).. */ + max98090_shdn_save(max98090); if ((freq >= 10000000) && (freq <= 20000000)) { snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK, M98090_PSCLK_DIV1); @@ -2009,8 +2198,10 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, max98090->pclk = freq >> 2; } else { dev_err(component->dev, "Invalid master clock frequency\n"); + max98090_shdn_restore(max98090); return -EINVAL; } + max98090_shdn_restore(max98090); max98090->sysclk = freq; @@ -2115,11 +2306,13 @@ static void max98090_pll_work(struct work_struct *work) dev_info_ratelimited(component->dev, "PLL unlocked\n"); /* Toggle shutdown OFF then ON */ + mutex_lock(&component->card->dapm_mutex); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, 0); msleep(10); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, M98090_SHDNN_MASK); + mutex_unlock(&component->card->dapm_mutex); /* Give PLL time to lock */ msleep(10); @@ -2435,7 +2628,12 @@ static int max98090_probe(struct snd_soc_component *component) */ snd_soc_component_read32(component, M98090_REG_DEVICE_STATUS); - /* High Performance is default */ + /* + * SHDN should be 0 at the point, no need to save/restore for the + * following registers. + * + * High Performance is default + */ snd_soc_component_update_bits(component, M98090_REG_DAC_CONTROL, M98090_DACHP_MASK, 1 << M98090_DACHP_SHIFT); @@ -2446,7 +2644,12 @@ static int max98090_probe(struct snd_soc_component *component) M98090_ADCHP_MASK, 1 << M98090_ADCHP_SHIFT); - /* Turn on VCM bandgap reference */ + /* + * SHDN should be 0 at the point, no need to save/restore for the + * following registers. + * + * Turn on VCM bandgap reference + */ snd_soc_component_write(component, M98090_REG_BIAS_CONTROL, M98090_VCM_MODE_MASK); @@ -2479,25 +2682,9 @@ static void max98090_remove(struct snd_soc_component *component) max98090->component = NULL; } -static void max98090_seq_notifier(struct snd_soc_component *component, - enum snd_soc_dapm_type event, int subseq) -{ - struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); - - if (max98090->shdn_pending) { - snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, - M98090_SHDNN_MASK, 0); - msleep(40); - snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, - M98090_SHDNN_MASK, M98090_SHDNN_MASK); - max98090->shdn_pending = false; - } -} - static const struct snd_soc_component_driver soc_component_dev_max98090 = { .probe = max98090_probe, .remove = max98090_remove, - .seq_notifier = max98090_seq_notifier, .set_bias_level = max98090_set_bias_level, .idle_bias_on = 1, .use_pmdown_time = 1, diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index 57965cd678b4..697cb568ac25 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h @@ -1540,7 +1540,8 @@ struct max98090_priv { unsigned int pa2en; unsigned int sidetone; bool master; - bool shdn_pending; + int saved_count; + int saved_shdn; }; int max98090_mic_detect(struct snd_soc_component *component, -- cgit v1.2.3 From 3176f94c467cf89f74120c34a3ddd9aaf8941be2 Mon Sep 17 00:00:00 2001 From: Nikita Yushchenko Date: Fri, 29 Nov 2019 16:27:19 +0300 Subject: ASoC: tlv320aic31xx: Add Volume Soft Stepping control Chip supports soft stepping of volume changes and it is enabled by default. This patch adds a control for it, so it could be either made slower (two sample periods per step instead of one), or disabled. Signed-off-by: Nikita Yushchenko Link: https://lore.kernel.org/r/20191129132719.11603-1-nikita.yoush@cogentembedded.com Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 8 ++++++++ sound/soc/codecs/tlv320aic31xx.h | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index d6c462f21370..31daa60695bd 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -275,6 +275,12 @@ static const char * const hp_rampup_step_text[] = { static SOC_ENUM_SINGLE_DECL(hp_rampup_step_enum, AIC31XX_HPPOP, 1, hp_rampup_step_text); +static const char * const vol_soft_step_mode_text[] = { + "fast", "slow", "disabled" }; + +static SOC_ENUM_SINGLE_DECL(vol_soft_step_mode_enum, AIC31XX_DACSETUP, 0, + vol_soft_step_mode_text); + static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0); static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0); static const DECLARE_TLV_DB_SCALE(adc_cgain_tlv, -2000, 50, 0); @@ -306,6 +312,8 @@ static const struct snd_kcontrol_new common31xx_snd_controls[] = { */ SOC_ENUM("HP Output Driver Power-On time", hp_poweron_time_enum), SOC_ENUM("HP Output Driver Ramp-up step", hp_rampup_step_enum), + + SOC_ENUM("Volume Soft Stepping", vol_soft_step_mode_enum), }; static const struct snd_kcontrol_new aic31xx_snd_controls[] = { diff --git a/sound/soc/codecs/tlv320aic31xx.h b/sound/soc/codecs/tlv320aic31xx.h index 83a8c7604cc3..0523884cee74 100644 --- a/sound/soc/codecs/tlv320aic31xx.h +++ b/sound/soc/codecs/tlv320aic31xx.h @@ -218,9 +218,6 @@ struct aic31xx_pdata { #define AIC31XX_GPIO1_ADC_MOD_CLK 0x10 #define AIC31XX_GPIO1_SDOUT 0x11 -/* AIC31XX_DACSETUP */ -#define AIC31XX_SOFTSTEP_MASK GENMASK(1, 0) - /* AIC31XX_DACMUTE */ #define AIC31XX_DACMUTE_MASK GENMASK(3, 2) -- cgit v1.2.3 From 49df1e3925824cf44e590daac635974270185841 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 2 Dec 2019 16:58:34 +0100 Subject: ASoC: rsnd: Calculate DALIGN inversion at run-time There is no need to store the inverted DALIGN values in the table, as they can easily be calculated at run-time. This also protects against the introduction of inconsistencies between normal and inverted values by a future table modification. Reorder the two subexpressions in the AND check, to perform the least expensive check first. Signed-off-by: Geert Uytterhoeven Reviewed-by: Eugeniu Rosca Acked-by: Kuninori Morimoto Link: https://lore.kernel.org/r/20191202155834.22582-1-geert+renesas@glider.be Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 399dc6e9bde5..d20f03dfdee6 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -376,20 +376,15 @@ u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io) */ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) { - static const u32 dalign_values[8][2] = { - {0x76543210, 0x67452301}, - {0x00000032, 0x00000023}, - {0x00007654, 0x00006745}, - {0x00000076, 0x00000067}, - {0xfedcba98, 0xefcdab89}, - {0x000000ba, 0x000000ab}, - {0x0000fedc, 0x0000efcd}, - {0x000000fe, 0x000000ef}, + static const u32 dalign_values[8] = { + 0x76543210, 0x00000032, 0x00007654, 0x00000076, + 0xfedcba98, 0x000000ba, 0x0000fedc, 0x000000fe, }; - int id = 0, inv; + int id = 0; struct rsnd_mod *ssiu = rsnd_io_to_mod_ssiu(io); struct rsnd_mod *target; struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); + u32 dalign; /* * *Hardware* L/R and *Software* L/R are inverted for 16bit data. @@ -425,15 +420,15 @@ u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) if (mod == ssiu) id = rsnd_mod_id_sub(mod); - /* Non target mod or non 16bit needs normal DALIGN */ - if ((snd_pcm_format_width(runtime->format) != 16) || - (mod != target)) - inv = 0; - /* Target mod needs inverted DALIGN when 16bit */ - else - inv = 1; + dalign = dalign_values[id]; + + if (mod == target && snd_pcm_format_width(runtime->format) == 16) { + /* Target mod needs inverted DALIGN when 16bit */ + dalign = (dalign & 0xf0f0f0f0) >> 4 | + (dalign & 0x0f0f0f0f) << 4; + } - return dalign_values[id][inv]; + return dalign; } u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod) -- cgit v1.2.3 From abe3b6727b653307c27870a2d4ecbf9de4e914a5 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Tue, 3 Dec 2019 15:16:27 +0100 Subject: ASoC: cs42l51: add dac mux widget in codec routes Add "DAC mux" DAPM widget in CS42l51 audio codec routes, to support DAC mux control and to remove error trace "DAC Mux has no paths" at widget creation. Note: ADC path of DAC mux is not routed in this patch. Signed-off-by: Olivier Moysan Link: https://lore.kernel.org/r/20191203141627.29471-1-olivier.moysan@st.com Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l51.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 55408c8fcb4e..e47758e4fb36 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -214,12 +214,10 @@ static const struct snd_soc_dapm_widget cs42l51_dapm_widgets[] = { SND_SOC_DAPM_ADC_E("Right ADC", "Right HiFi Capture", CS42L51_POWER_CTL1, 2, 1, cs42l51_pdn_event, SND_SOC_DAPM_PRE_POST_PMD), - SND_SOC_DAPM_DAC_E("Left DAC", "Left HiFi Playback", - CS42L51_POWER_CTL1, 5, 1, - cs42l51_pdn_event, SND_SOC_DAPM_PRE_POST_PMD), - SND_SOC_DAPM_DAC_E("Right DAC", "Right HiFi Playback", - CS42L51_POWER_CTL1, 6, 1, - cs42l51_pdn_event, SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_DAC_E("Left DAC", NULL, CS42L51_POWER_CTL1, 5, 1, + cs42l51_pdn_event, SND_SOC_DAPM_PRE_POST_PMD), + SND_SOC_DAPM_DAC_E("Right DAC", NULL, CS42L51_POWER_CTL1, 6, 1, + cs42l51_pdn_event, SND_SOC_DAPM_PRE_POST_PMD), /* analog/mic */ SND_SOC_DAPM_INPUT("AIN1L"), @@ -255,6 +253,12 @@ static const struct snd_soc_dapm_route cs42l51_routes[] = { {"HPL", NULL, "Left DAC"}, {"HPR", NULL, "Right DAC"}, + {"Right DAC", NULL, "DAC Mux"}, + {"Left DAC", NULL, "DAC Mux"}, + + {"DAC Mux", "Direct PCM", "Playback"}, + {"DAC Mux", "DSP PCM", "Playback"}, + {"Left ADC", NULL, "Left PGA"}, {"Right ADC", NULL, "Right PGA"}, -- cgit v1.2.3 From 253f584a0699d12a90bde9d524d499a921cc7827 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 4 Dec 2019 21:20:05 +0200 Subject: ASoC: ti: davinci-mcasp: Improve the sysclk selection When McASP is master the bclk can be generated from two main source: AUXCLK: functional clock for McASP or AHCLK: from external source or internal mux in dra7x family With this patch it is possible to select between the two source. The patch is not breaking existing machine drivers since historically the clk_id was ignored and left as 0 in all cases. When output clock is configured - which can be only the AHCLK, we select the AUXCLK as source for the internal HCLK. In this case the HCLK rate is the same as the output clock. Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20191204192005.31210-1-peter.ujfalusi@ti.com Signed-off-by: Mark Brown --- sound/soc/ti/davinci-mcasp.c | 35 ++++++++++++++++++++++++++++------- sound/soc/ti/davinci-mcasp.h | 4 ++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/sound/soc/ti/davinci-mcasp.c b/sound/soc/ti/davinci-mcasp.c index 8e5371801d88..e1e937eb1dc1 100644 --- a/sound/soc/ti/davinci-mcasp.c +++ b/sound/soc/ti/davinci-mcasp.c @@ -664,18 +664,39 @@ static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id, struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); pm_runtime_get_sync(mcasp->dev); - if (dir == SND_SOC_CLOCK_OUT) { + + if (dir == SND_SOC_CLOCK_IN) { + switch (clk_id) { + case MCASP_CLK_HCLK_AHCLK: + mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, + AHCLKXE); + mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, + AHCLKRE); + clear_bit(PIN_BIT_AHCLKX, &mcasp->pdir); + break; + case MCASP_CLK_HCLK_AUXCLK: + mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, + AHCLKXE); + mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, + AHCLKRE); + set_bit(PIN_BIT_AHCLKX, &mcasp->pdir); + break; + default: + dev_err(mcasp->dev, "Invalid clk id: %d\n", clk_id); + goto out; + } + } else { + /* Select AUXCLK as HCLK */ mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); set_bit(PIN_BIT_AHCLKX, &mcasp->pdir); - } else { - mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE); - clear_bit(PIN_BIT_AHCLKX, &mcasp->pdir); } - + /* + * When AHCLK X/R is selected to be output it means that the HCLK is + * the same clock - coming via AUXCLK. + */ mcasp->sysclk_freq = freq; - +out: pm_runtime_put(mcasp->dev); return 0; } diff --git a/sound/soc/ti/davinci-mcasp.h b/sound/soc/ti/davinci-mcasp.h index bc705d6ca48b..5de2b8a31061 100644 --- a/sound/soc/ti/davinci-mcasp.h +++ b/sound/soc/ti/davinci-mcasp.h @@ -295,6 +295,10 @@ #define NUMEVT(x) (((x) & 0xFF) << 8) #define NUMDMA_MASK (0xFF) +/* Source of High-frequency transmit/receive clock */ +#define MCASP_CLK_HCLK_AHCLK 0 /* AHCLKX/R */ +#define MCASP_CLK_HCLK_AUXCLK 1 /* Internal functional clock */ + /* clock divider IDs */ #define MCASP_CLKDIV_AUXCLK 0 /* HCLK divider from AUXCLK */ #define MCASP_CLKDIV_BCLK 1 /* BCLK divider from HCLK */ -- cgit v1.2.3 From 7c11af9fcdc425b80f140a218d4fef9f17734bfc Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 4 Dec 2019 15:28:59 -0600 Subject: ASoC: SOF: Intel: hda: solve MSI issues by merging ipc and stream irq handlers The existing code uses two handlers for a shared edge-based MSI interrupts. In corner cases, interrupts are lost, leading to IPC timeouts. Those timeouts do not appear in legacy mode. This patch merges the two handlers and threads into a single one, and simplifies the mask/unmask operations by using a single top-level mask (Global Interrupt Enable). The handler only checks for interrupt sources using the Global Interrupt Status (GIS) field, and all the actual work happens in the thread. This also enables us to remove the use of spin locks. Stream events are prioritized over IPC ones. This patch was tested with HDaudio and SoundWire platforms, and all known IPC timeout issues are solved in MSI mode. The SoundWire-specific patches will be provided in follow-up patches, where the SoundWire interrupts are handled in the same thread as IPC and stream interrupts. Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204212859.13239-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/apl.c | 1 - sound/soc/sof/intel/cnl.c | 5 --- sound/soc/sof/intel/hda-ipc.c | 23 +++----------- sound/soc/sof/intel/hda-stream.c | 20 ++++++------ sound/soc/sof/intel/hda.c | 69 ++++++++++++++++++++++++++++------------ sound/soc/sof/intel/hda.h | 11 ++++--- 6 files changed, 70 insertions(+), 59 deletions(-) diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 7daa8eb456c8..6f45e14f2b2e 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -41,7 +41,6 @@ const struct snd_sof_dsp_ops sof_apl_ops = { .block_write = sof_block_write, /* doorbell */ - .irq_handler = hda_dsp_ipc_irq_handler, .irq_thread = hda_dsp_ipc_irq_thread, /* ipc */ diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 0e1e265f3f3b..9bd169e2691e 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -106,10 +106,6 @@ static irqreturn_t cnl_ipc_irq_thread(int irq, void *context) "nothing to do in IPC IRQ thread\n"); } - /* re-enable IPC interrupt */ - snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, - HDA_DSP_ADSPIC_IPC, HDA_DSP_ADSPIC_IPC); - return IRQ_HANDLED; } @@ -231,7 +227,6 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { .block_write = sof_block_write, /* doorbell */ - .irq_handler = hda_dsp_ipc_irq_handler, .irq_thread = cnl_ipc_irq_thread, /* ipc */ diff --git a/sound/soc/sof/intel/hda-ipc.c b/sound/soc/sof/intel/hda-ipc.c index 0fd2153c1769..1837f66e361f 100644 --- a/sound/soc/sof/intel/hda-ipc.c +++ b/sound/soc/sof/intel/hda-ipc.c @@ -230,22 +230,15 @@ irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context) "nothing to do in IPC IRQ thread\n"); } - /* re-enable IPC interrupt */ - snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIC, - HDA_DSP_ADSPIC_IPC, HDA_DSP_ADSPIC_IPC); - return IRQ_HANDLED; } -/* is this IRQ for ADSP ? - we only care about IPC here */ -irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context) +/* Check if an IPC IRQ occurred */ +bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev) { - struct snd_sof_dev *sdev = context; - int ret = IRQ_NONE; + bool ret = false; u32 irq_status; - spin_lock(&sdev->hw_lock); - /* store status */ irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS); dev_vdbg(sdev->dev, "irq handler: irq_status:0x%x\n", irq_status); @@ -255,16 +248,10 @@ irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context) goto out; /* IPC message ? */ - if (irq_status & HDA_DSP_ADSPIS_IPC) { - /* disable IPC interrupt */ - snd_sof_dsp_update_bits_unlocked(sdev, HDA_DSP_BAR, - HDA_DSP_REG_ADSPIC, - HDA_DSP_ADSPIC_IPC, 0); - ret = IRQ_WAKE_THREAD; - } + if (irq_status & HDA_DSP_ADSPIS_IPC) + ret = true; out: - spin_unlock(&sdev->hw_lock); return ret; } diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 29ab43281670..927a36f92c24 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -549,22 +549,23 @@ int hda_dsp_stream_hw_free(struct snd_sof_dev *sdev, return 0; } -irqreturn_t hda_dsp_stream_interrupt(int irq, void *context) +bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev) { - struct hdac_bus *bus = context; - int ret = IRQ_WAKE_THREAD; + struct hdac_bus *bus = sof_to_bus(sdev); + bool ret = false; u32 status; - spin_lock(&bus->reg_lock); + /* The function can be called at irq thread, so use spin_lock_irq */ + spin_lock_irq(&bus->reg_lock); status = snd_hdac_chip_readl(bus, INTSTS); dev_vdbg(bus->dev, "stream irq, INTSTS status: 0x%x\n", status); - /* Register inaccessible, ignore it.*/ - if (status == 0xffffffff) - ret = IRQ_NONE; + /* if Register inaccessible, ignore it.*/ + if (status != 0xffffffff) + ret = true; - spin_unlock(&bus->reg_lock); + spin_unlock_irq(&bus->reg_lock); return ret; } @@ -602,7 +603,8 @@ static bool hda_dsp_stream_check(struct hdac_bus *bus, u32 status) irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context) { - struct hdac_bus *bus = context; + struct snd_sof_dev *sdev = context; + struct hdac_bus *bus = sof_to_bus(sdev); #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) u32 rirb_status; #endif diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 91bd88fddac7..4596239c63d8 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -499,6 +499,49 @@ static const struct sof_intel_dsp_desc return chip_info; } +static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context) +{ + struct snd_sof_dev *sdev = context; + + /* + * Get global interrupt status. It includes all hardware interrupt + * sources in the Intel HD Audio controller. + */ + if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) & + SOF_HDA_INTSTS_GIS) { + + /* disable GIE interrupt */ + snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, + SOF_HDA_INTCTL, + SOF_HDA_INT_GLOBAL_EN, + 0); + + return IRQ_WAKE_THREAD; + } + + return IRQ_NONE; +} + +static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context) +{ + struct snd_sof_dev *sdev = context; + + /* deal with streams and controller first */ + if (hda_dsp_check_stream_irq(sdev)) + hda_dsp_stream_threaded_handler(irq, sdev); + + if (hda_dsp_check_ipc_irq(sdev)) + sof_ops(sdev)->irq_thread(irq, sdev); + + /* enable GIE interrupt */ + snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, + SOF_HDA_INTCTL, + SOF_HDA_INT_GLOBAL_EN, + SOF_HDA_INT_GLOBAL_EN); + + return IRQ_HANDLED; +} + int hda_dsp_probe(struct snd_sof_dev *sdev) { struct pci_dev *pci = to_pci_dev(sdev->dev); @@ -603,9 +646,7 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) */ if (hda_use_msi && pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) > 0) { dev_info(sdev->dev, "use msi interrupt mode\n"); - hdev->irq = pci_irq_vector(pci, 0); - /* ipc irq number is the same of hda irq */ - sdev->ipc_irq = hdev->irq; + sdev->ipc_irq = pci_irq_vector(pci, 0); /* initialised to "false" by kzalloc() */ sdev->msi_enabled = true; } @@ -616,28 +657,17 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) * in IO-APIC mode, hda->irq and ipc_irq are using the same * irq number of pci->irq */ - hdev->irq = pci->irq; sdev->ipc_irq = pci->irq; } - dev_dbg(sdev->dev, "using HDA IRQ %d\n", hdev->irq); - ret = request_threaded_irq(hdev->irq, hda_dsp_stream_interrupt, - hda_dsp_stream_threaded_handler, - IRQF_SHARED, "AudioHDA", bus); - if (ret < 0) { - dev_err(sdev->dev, "error: failed to register HDA IRQ %d\n", - hdev->irq); - goto free_irq_vector; - } - dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); - ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_ipc_irq_handler, - sof_ops(sdev)->irq_thread, IRQF_SHARED, - "AudioDSP", sdev); + ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, + hda_dsp_interrupt_thread, + IRQF_SHARED, "AudioDSP", sdev); if (ret < 0) { dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", sdev->ipc_irq); - goto free_hda_irq; + goto free_irq_vector; } pci_set_master(pci); @@ -668,8 +698,6 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) free_ipc_irq: free_irq(sdev->ipc_irq, sdev); -free_hda_irq: - free_irq(hdev->irq, bus); free_irq_vector: if (sdev->msi_enabled) pci_free_irq_vectors(pci); @@ -715,7 +743,6 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) SOF_HDA_PPCTL_GPROCEN, 0); free_irq(sdev->ipc_irq, sdev); - free_irq(hda->irq, bus); if (sdev->msi_enabled) pci_free_irq_vectors(pci); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 18d7e72bf9b7..63df888dddb6 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -43,11 +43,14 @@ /* SOF_HDA_GCTL register bist */ #define SOF_HDA_GCTL_RESET BIT(0) -/* SOF_HDA_INCTL and SOF_HDA_INTSTS regs */ +/* SOF_HDA_INCTL regs */ #define SOF_HDA_INT_GLOBAL_EN BIT(31) #define SOF_HDA_INT_CTRL_EN BIT(30) #define SOF_HDA_INT_ALL_STREAM 0xff +/* SOF_HDA_INTSTS regs */ +#define SOF_HDA_INTSTS_GIS BIT(31) + #define SOF_HDA_MAX_CAPS 10 #define SOF_HDA_CAP_ID_OFF 16 #define SOF_HDA_CAP_ID_MASK GENMASK(SOF_HDA_CAP_ID_OFF + 11,\ @@ -406,8 +409,6 @@ struct sof_intel_hda_dev { /* the maximum number of streams (playback + capture) supported */ u32 stream_max; - int irq; - /* PM related */ bool l1_support_changed;/* during suspend, is L1SEN changed or not */ @@ -511,11 +512,12 @@ int hda_dsp_stream_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw_params *params); int hda_dsp_stream_trigger(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream, int cmd); -irqreturn_t hda_dsp_stream_interrupt(int irq, void *context); irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context); int hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, struct hdac_stream *stream); +bool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev); +bool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev); struct hdac_ext_stream * hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction); @@ -540,7 +542,6 @@ void hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev); int hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev); int hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id); -irqreturn_t hda_dsp_ipc_irq_handler(int irq, void *context); irqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context); int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir); -- cgit v1.2.3 From bc9a665581b3c6c82c9220a47f6573b49ce2df0b Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 8 Dec 2019 20:37:04 -0800 Subject: ASoC: fix soc-core.c kernel-doc warning Fix a kernel-doc warning in soc-core.c by adding notation for @legacy_dai_naming. ../sound/soc/soc-core.c:2509: warning: Function parameter or member 'legacy_dai_naming' not described in 'snd_soc_register_dai' Signed-off-by: Randy Dunlap Cc: Liam Girdwood Cc: Mark Brown Cc: alsa-devel@alsa-project.org Link: https://lore.kernel.org/r/2215ee04-e870-5eea-a00c-9a5caf06faae@infradead.org Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 062653ab03a3..1a362a799dbb 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2498,6 +2498,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai); * * @component: The component the DAIs are registered for * @dai_drv: DAI driver to use for the DAI + * @legacy_dai_naming: if %true, use legacy single-name format; + * if %false, use multiple-name format; * * Topology can use this API to register DAIs when probing a component. * These DAIs's widgets will be freed in the card cleanup and the DAIs -- cgit v1.2.3 From 1442842952ccfe4178602c7a8459ac2ecb9d9e1a Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Fri, 6 Dec 2019 11:35:42 +0100 Subject: ASoC: hdmi-codec: re-introduce mutex locking again The dai codec needs to ensure that on one dai is used at any time. This is currently protected by bit atomic operation. With this change, it done with a mutex instead. This change is not about functionality or efficiency. It is done with the hope that it help maintainability in the future. Suggested-by: Mark Brown Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20191206103542.485224-1-jbrunet@baylibre.com Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index f8b5b960e597..543363102d03 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -274,7 +274,8 @@ struct hdmi_codec_priv { uint8_t eld[MAX_ELD_BYTES]; struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; - unsigned long busy; + struct mutex lock; + bool busy; struct snd_soc_jack *jack; unsigned int jack_status; }; @@ -390,9 +391,10 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); int ret = 0; - ret = test_and_set_bit(0, &hcp->busy); - if (ret) { + mutex_lock(&hcp->lock); + if (hcp->busy) { dev_err(dai->dev, "Only one simultaneous stream supported!\n"); + mutex_unlock(&hcp->lock); return -EINVAL; } @@ -405,21 +407,21 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, if (hcp->hcd.ops->get_eld) { ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); + if (ret) + goto err; + + ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); + if (ret) + goto err; - if (!ret) { - ret = snd_pcm_hw_constraint_eld(substream->runtime, - hcp->eld); - if (ret) - goto err; - } /* Select chmap supported */ hdmi_codec_eld_chmap(hcp); } - return 0; + + hcp->busy = true; err: - /* Release the exclusive lock on error */ - clear_bit(0, &hcp->busy); + mutex_unlock(&hcp->lock); return ret; } @@ -431,7 +433,9 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); - clear_bit(0, &hcp->busy); + mutex_lock(&hcp->lock); + hcp->busy = false; + mutex_unlock(&hcp->lock); } static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, @@ -811,6 +815,8 @@ static int hdmi_codec_probe(struct platform_device *pdev) return -ENOMEM; hcp->hcd = *hcd; + mutex_init(&hcp->lock); + daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL); if (!daidrv) return -ENOMEM; -- cgit v1.2.3 From 8cd9956f61c65022209ce6d1e55ed12aea12357d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Dec 2019 15:15:44 -0600 Subject: ASoC: intel/skl/hda - export number of digital microphones via control components It is required for the auto-detection in the user space (for UCM). Signed-off-by: Jaroslav Kysela Signed-off-by: Pierre-Louis Bossart Cc: Mark Brown Link: https://lore.kernel.org/r/20191204211556.12671-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_hda_dsp_generic.c | 8 ++++++++ sound/soc/sof/intel/hda.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c index 4e45901e3a2f..11eaee9ae41f 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_generic.c +++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c @@ -100,6 +100,8 @@ static struct snd_soc_card hda_soc_card = { .late_probe = skl_hda_card_late_probe, }; +static char hda_soc_components[30]; + #define IDISP_DAI_COUNT 3 #define HDAC_DAI_COUNT 2 #define DMIC_DAI_COUNT 2 @@ -183,6 +185,12 @@ static int skl_hda_audio_probe(struct platform_device *pdev) hda_soc_card.dev = &pdev->dev; snd_soc_card_set_drvdata(&hda_soc_card, ctx); + if (mach->mach_params.dmic_num > 0) { + snprintf(hda_soc_components, sizeof(hda_soc_components), + "cfg-dmics:%d", mach->mach_params.dmic_num); + hda_soc_card.components = hda_soc_components; + } + return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card); } diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 4596239c63d8..98512a338748 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -351,7 +351,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) const char *tplg_filename; const char *idisp_str; const char *dmic_str; - int dmic_num; + int dmic_num = 0; int codec_num = 0; int i; #endif @@ -472,6 +472,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) mach_params->codec_mask = bus->codec_mask; mach_params->platform = dev_name(sdev->dev); mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; + mach_params->dmic_num = dmic_num; } /* create codec instances */ -- cgit v1.2.3 From 0d5c8187562848b619a35f2ffc5e18ce703e9f3d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Dec 2019 15:15:45 -0600 Subject: ASoC: Intel - use control components to describe card config Use the control interface (field 'components' in the info structure) to pass the I/O configuration details. The goal is to replace the card long name with this. Signed-off-by: Jaroslav Kysela Signed-off-by: Pierre-Louis Bossart Cc: Mark Brown Link: https://lore.kernel.org/r/20191204211556.12671-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcht_es8316.c | 9 ++++++++- sound/soc/intel/boards/bytcr_rt5640.c | 6 ++++++ sound/soc/intel/boards/bytcr_rt5651.c | 18 +++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index 46612331f5ea..efa33f30dcac 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -361,6 +361,7 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = { /* SoC card */ static char codec_name[SND_ACPI_I2C_ID_LEN]; static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */ +static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */ static int byt_cht_es8316_suspend(struct snd_soc_card *card) { @@ -572,11 +573,17 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) } } - /* register the soc card */ + snprintf(components_string, sizeof(components_string), + "cfg-spk:%s cfg-mic:%s", + (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "1" : "2", + mic_name[BYT_CHT_ES8316_MAP(quirk)]); + byt_cht_es8316_card.components = components_string; snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic", (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo", mic_name[BYT_CHT_ES8316_MAP(quirk)]); byt_cht_es8316_card.long_name = long_name; + + /* register the soc card */ snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv); ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card); diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index dd2b5ad08659..7bc6d3cec94c 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1083,6 +1083,7 @@ static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN]; static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */ static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */ +static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */ static int byt_rt5640_suspend(struct snd_soc_card *card) { @@ -1305,6 +1306,11 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) } } + snprintf(byt_rt5640_components, sizeof(byt_rt5640_components), + "cfg-spk:%s cfg-mic:%s", + (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2", + map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); + byt_rt5640_card.components = byt_rt5640_components; snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name), "bytcr-rt5640-%s-spk-%s-mic", (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 4606f6f582d6..80a5674ddb1b 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -798,6 +798,7 @@ static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */ +static char byt_rt5651_components[50]; /* = "cfg-spk:* cfg-mic:*" */ static int byt_rt5651_suspend(struct snd_soc_card *card) { @@ -876,7 +877,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) const char *platform_name; struct acpi_device *adev; struct device *codec_dev; - const char *hp_swapped; bool is_bytcr = false; int ret_val = 0; int dai_index = 0; @@ -1080,16 +1080,20 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) } } - if (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) - hp_swapped = "-hp-swapped"; - else - hp_swapped = ""; - + snprintf(byt_rt5651_components, sizeof(byt_rt5651_components), + "cfg-spk:%s cfg-mic:%s%s", + (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? "1" : "2", + mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], + (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ? + " cfg-hp:lrswap" : ""); + byt_rt5651_card.components = byt_rt5651_components; snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name), "bytcr-rt5651-%s-spk-%s-mic%s", (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? "mono" : "stereo", - mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], hp_swapped); + mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], + (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ? + "-hp-swapped" : ""); byt_rt5651_card.long_name = byt_rt5651_long_name; /* override plaform name, if required */ -- cgit v1.2.3 From b5706f8ec29fb461571d25e3e813ede121fe31cd Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Dec 2019 15:15:46 -0600 Subject: ASoC: Intel - do not describe I/O configuration in the long card name The long card name might be used in GUI. This information should be hidden. Add CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES configuration option. Signed-off-by: Jaroslav Kysela Signed-off-by: Pierre-Louis Bossart Cc: Mark Brown Link: https://lore.kernel.org/r/20191204211556.12671-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 13 +++++++++++++ sound/soc/intel/boards/bytcht_es8316.c | 4 ++++ sound/soc/intel/boards/bytcr_rt5640.c | 4 ++++ sound/soc/intel/boards/bytcr_rt5651.c | 4 ++++ 4 files changed, 25 insertions(+) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 575064b315ef..a8d71b5ed41e 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -13,6 +13,19 @@ menuconfig SND_SOC_INTEL_MACH if SND_SOC_INTEL_MACH +config SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES + bool "Use more user friendly long card names" + help + Some drivers report the I/O configuration to userspace through the + soundcard's long card name in the control user space AP. An unfortunate + side effect is that this long name may also be used by the GUI, + confusing users with information they don't need. + This option prevents the long name from being modified, and the I/O + configuration will be provided through a different component interface. + Select Y if userspace like UCM (Use Case Manager) uses the component + interface. + If unsure select N. + if SND_SOC_INTEL_HASWELL config SND_SOC_INTEL_HASWELL_MACH diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index efa33f30dcac..12a1c5255484 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -360,7 +360,9 @@ static struct snd_soc_dai_link byt_cht_es8316_dais[] = { /* SoC card */ static char codec_name[SND_ACPI_I2C_ID_LEN]; +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) static char long_name[50]; /* = "bytcht-es8316-*-spk-*-mic" */ +#endif static char components_string[32]; /* = "cfg-spk:* cfg-mic:* */ static int byt_cht_es8316_suspend(struct snd_soc_card *card) @@ -578,10 +580,12 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "1" : "2", mic_name[BYT_CHT_ES8316_MAP(quirk)]); byt_cht_es8316_card.components = components_string; +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) snprintf(long_name, sizeof(long_name), "bytcht-es8316-%s-spk-%s-mic", (quirk & BYT_CHT_ES8316_MONO_SPEAKER) ? "mono" : "stereo", mic_name[BYT_CHT_ES8316_MAP(quirk)]); byt_cht_es8316_card.long_name = long_name; +#endif /* register the soc card */ snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv); diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index 7bc6d3cec94c..648fcc1d07b5 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1082,7 +1082,9 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = { static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN]; static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */ static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */ +#endif static char byt_rt5640_components[32]; /* = "cfg-spk:* cfg-mic:*" */ static int byt_rt5640_suspend(struct snd_soc_card *card) @@ -1311,12 +1313,14 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2", map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); byt_rt5640_card.components = byt_rt5640_components; +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name), "bytcr-rt5640-%s-spk-%s-mic", (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "mono" : "stereo", map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); byt_rt5640_card.long_name = byt_rt5640_long_name; +#endif /* override plaform name, if required */ platform_name = mach->mach_params.platform; diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 80a5674ddb1b..c0d322a859f7 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -797,7 +797,9 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = { static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */ +#endif static char byt_rt5651_components[50]; /* = "cfg-spk:* cfg-mic:*" */ static int byt_rt5651_suspend(struct snd_soc_card *card) @@ -1087,6 +1089,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ? " cfg-hp:lrswap" : ""); byt_rt5651_card.components = byt_rt5651_components; +#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name), "bytcr-rt5651-%s-spk-%s-mic%s", (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ? @@ -1095,6 +1098,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED) ? "-hp-swapped" : ""); byt_rt5651_card.long_name = byt_rt5651_long_name; +#endif /* override plaform name, if required */ platform_name = mach->mach_params.platform; -- cgit v1.2.3 From 78fd4ffd75eed354c1c8b567dd0b384053c933da Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:47 -0600 Subject: ASoC: SOF: topology: remove snd_sof_init_topology() Remove snd_sof_init_topology() as it is never used. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/sof-priv.h | 2 -- sound/soc/sof/topology.c | 9 --------- 2 files changed, 11 deletions(-) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index c7c2c70ee4d0..31f0eb31598a 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -585,8 +585,6 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_ipc *ipc, * There is no snd_sof_free_topology since topology components will * be freed by snd_soc_unregister_component, */ -int snd_sof_init_topology(struct snd_sof_dev *sdev, - struct snd_soc_tplg_ops *ops); int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file); int snd_sof_complete_pipeline(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index d82ab981e840..b8701d3407ad 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3463,15 +3463,6 @@ static struct snd_soc_tplg_ops sof_tplg_ops = { .bytes_ext_ops_count = ARRAY_SIZE(sof_bytes_ext_ops), }; -int snd_sof_init_topology(struct snd_sof_dev *sdev, - struct snd_soc_tplg_ops *ops) -{ - /* TODO: support linked list of topologies */ - sdev->tplg_ops = ops; - return 0; -} -EXPORT_SYMBOL(snd_sof_init_topology); - int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file) { const struct firmware *fw; -- cgit v1.2.3 From 3e62579436c6a7fc35de7318e6c5f495b8d0046c Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:48 -0600 Subject: ASoC: SOF: core: modify the signature for snd_sof_create_page_table Modify the signature for snd_sof_create_page_table to take struct device pointer as an argument instead of struct snd_sof_dev as this will be used by both the SOF core device and its clients. Also, move the definition out of core.c to utils.c. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/core.c | 59 ----------------------------------------------- sound/soc/sof/pcm.c | 2 +- sound/soc/sof/sof-priv.h | 2 +- sound/soc/sof/trace.c | 4 ++-- sound/soc/sof/utils.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 805918d3bcc0..6a7f342203e9 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include "sof-priv.h" @@ -213,64 +212,6 @@ out: } EXPORT_SYMBOL(snd_sof_get_status); -/* - * Generic buffer page table creation. - * Take the each physical page address and drop the least significant unused - * bits from each (based on PAGE_SIZE). Then pack valid page address bits - * into compressed page table. - */ - -int snd_sof_create_page_table(struct snd_sof_dev *sdev, - struct snd_dma_buffer *dmab, - unsigned char *page_table, size_t size) -{ - int i, pages; - - pages = snd_sgbuf_aligned_pages(size); - - dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n", - dmab->area, size, pages); - - for (i = 0; i < pages; i++) { - /* - * The number of valid address bits for each page is 20. - * idx determines the byte position within page_table - * where the current page's address is stored - * in the compressed page_table. - * This can be calculated by multiplying the page number by 2.5. - */ - u32 idx = (5 * i) >> 1; - u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT; - u8 *pg_table; - - dev_vdbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn); - - pg_table = (u8 *)(page_table + idx); - - /* - * pagetable compression: - * byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 - * ___________pfn 0__________ __________pfn 1___________ _pfn 2... - * .... .... .... .... .... .... .... .... .... .... .... - * It is created by: - * 1. set current location to 0, PFN index i to 0 - * 2. put pfn[i] at current location in Little Endian byte order - * 3. calculate an intermediate value as - * x = (pfn[i+1] << 4) | (pfn[i] & 0xf) - * 4. put x at offset (current location + 2) in LE byte order - * 5. increment current location by 5 bytes, increment i by 2 - * 6. continue to (2) - */ - if (i & 1) - put_unaligned_le32((pg_table[0] & 0xf) | pfn << 4, - pg_table); - else - put_unaligned_le32(pfn, pg_table); - } - - return pages; -} - /* * SOF Driver enumeration. */ diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 549238a98b2a..9fd73ef08904 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -33,7 +33,7 @@ static int create_page_table(struct snd_soc_component *component, if (!spcm) return -EINVAL; - return snd_sof_create_page_table(sdev, dmab, + return snd_sof_create_page_table(sdev->dev, dmab, spcm->stream[stream].page_table.area, size); } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 31f0eb31598a..18dd832f2053 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -499,7 +499,7 @@ int snd_sof_set_d0_substate(struct snd_sof_dev *sdev, void snd_sof_new_platform_drv(struct snd_sof_dev *sdev); -int snd_sof_create_page_table(struct snd_sof_dev *sdev, +int snd_sof_create_page_table(struct device *dev, struct snd_dma_buffer *dmab, unsigned char *page_table, size_t size); diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c index b0e4556c8536..4bb65030819d 100644 --- a/sound/soc/sof/trace.c +++ b/sound/soc/sof/trace.c @@ -250,8 +250,8 @@ int snd_sof_init_trace(struct snd_sof_dev *sdev) } /* create compressed page table for audio firmware */ - ret = snd_sof_create_page_table(sdev, &sdev->dmatb, sdev->dmatp.area, - sdev->dmatb.bytes); + ret = snd_sof_create_page_table(sdev->dev, &sdev->dmatb, + sdev->dmatp.area, sdev->dmatb.bytes); if (ret < 0) goto table_err; diff --git a/sound/soc/sof/utils.c b/sound/soc/sof/utils.c index 2ac4c3da0320..9831eb57df6c 100644 --- a/sound/soc/sof/utils.c +++ b/sound/soc/sof/utils.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include "sof-priv.h" @@ -110,3 +111,62 @@ void sof_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *dest, memcpy_fromio(dest, src, size); } EXPORT_SYMBOL(sof_block_read); + +/* + * Generic buffer page table creation. + * Take the each physical page address and drop the least significant unused + * bits from each (based on PAGE_SIZE). Then pack valid page address bits + * into compressed page table. + */ + +int snd_sof_create_page_table(struct device *dev, + struct snd_dma_buffer *dmab, + unsigned char *page_table, size_t size) +{ + int i, pages; + + pages = snd_sgbuf_aligned_pages(size); + + dev_dbg(dev, "generating page table for %p size 0x%zx pages %d\n", + dmab->area, size, pages); + + for (i = 0; i < pages; i++) { + /* + * The number of valid address bits for each page is 20. + * idx determines the byte position within page_table + * where the current page's address is stored + * in the compressed page_table. + * This can be calculated by multiplying the page number by 2.5. + */ + u32 idx = (5 * i) >> 1; + u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT; + u8 *pg_table; + + dev_vdbg(dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn); + + pg_table = (u8 *)(page_table + idx); + + /* + * pagetable compression: + * byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 + * ___________pfn 0__________ __________pfn 1___________ _pfn 2... + * .... .... .... .... .... .... .... .... .... .... .... + * It is created by: + * 1. set current location to 0, PFN index i to 0 + * 2. put pfn[i] at current location in Little Endian byte order + * 3. calculate an intermediate value as + * x = (pfn[i+1] << 4) | (pfn[i] & 0xf) + * 4. put x at offset (current location + 2) in LE byte order + * 5. increment current location by 5 bytes, increment i by 2 + * 6. continue to (2) + */ + if (i & 1) + put_unaligned_le32((pg_table[0] & 0xf) | pfn << 4, + pg_table); + else + put_unaligned_le32(pfn, pg_table); + } + + return pages; +} +EXPORT_SYMBOL(snd_sof_create_page_table); -- cgit v1.2.3 From 8c583f526ee9df5c6693f54ac272b7e103b5f1d2 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:49 -0600 Subject: ASoC: SOF: core: move check for runtime callbacks to core For some platforms, the refcount is explicitly incremented to prevent it from entering runtime suspend. This should be be done during probe in the core instead of being done in the PCM driver. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/core.c | 8 ++++++++ sound/soc/sof/pcm.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 6a7f342203e9..d8446fb9fdde 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -355,6 +355,14 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) dev_dbg(sdev->dev, "created machine %s\n", dev_name(&plat_data->pdev_mach->dev)); + /* + * Some platforms in SOF, ex: BYT, may not have their platform PM + * callbacks set. Increment the usage count so as to + * prevent the device from entering runtime suspend. + */ + if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) + pm_runtime_get_noresume(sdev->dev); + if (plat_data->sof_probe_complete) plat_data->sof_probe_complete(sdev->dev); diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 9fd73ef08904..a9c47f6bf657 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -741,14 +741,6 @@ static int sof_pcm_probe(struct snd_soc_component *component) return ret; } - /* - * Some platforms in SOF, ex: BYT, may not have their platform PM - * callbacks set. Increment the usage count so as to - * prevent the device from entering runtime suspend. - */ - if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume) - pm_runtime_get_noresume(sdev->dev); - return ret; } -- cgit v1.2.3 From 03eec9b4eb897dde5985579508c978e7a29052bd Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:50 -0600 Subject: ASoC: SOF: Introduce default_fw_filename member in sof_dev_desc Currently the FW filename is obtained from the ACPI matching table when determining which machine driver to use. In preparation for making the machine driver ACPI match optional for Device Tree platforms and moving the machine driver selection out of the SOF core, this patch introduces the default_fw_filename member in struct sof_dev_desc. Once the machine driver selection is moved out of SOF core, the nocodec_fw_filename will become obsolete and will be removed. Signed-off-by: Ranjani Sridharan Signed-off-by: Daniel Baluta Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof.h | 3 +++ sound/soc/sof/sof-acpi-dev.c | 5 +++++ sound/soc/sof/sof-of-dev.c | 1 + sound/soc/sof/sof-pci-dev.c | 9 +++++++++ 4 files changed, 18 insertions(+) diff --git a/include/sound/sof.h b/include/sound/sof.h index 479101736ee0..1723478db4a2 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -91,6 +91,9 @@ struct sof_dev_desc { const char *default_fw_path; const char *default_tplg_path; + /* default firmware name */ + const char *default_fw_filename; + const struct snd_sof_dsp_ops *ops; const struct sof_arch_ops *arch_ops; }; diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index df318f50dd0b..22e13ef09811 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -45,6 +45,7 @@ static const struct sof_dev_desc sof_acpi_haswell_desc = { .chip_info = &hsw_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-hsw.ri", .nocodec_fw_filename = "sof-hsw.ri", .nocodec_tplg_filename = "sof-hsw-nocodec.tplg", .ops = &sof_hsw_ops, @@ -62,6 +63,7 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .chip_info = &bdw_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-bdw.ri", .nocodec_fw_filename = "sof-bdw.ri", .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", .ops = &sof_bdw_ops, @@ -81,6 +83,7 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .chip_info = &byt_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-byt.ri", .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, @@ -96,6 +99,7 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .chip_info = &byt_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-byt.ri", .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, @@ -111,6 +115,7 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .chip_info = &cht_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-cht.ri", .nocodec_fw_filename = "sof-cht.ri", .nocodec_tplg_filename = "sof-cht-nocodec.tplg", .ops = &sof_cht_ops, diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 28a9692974e5..81deb5582d77 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -19,6 +19,7 @@ extern struct snd_sof_dsp_ops sof_imx8_ops; static struct sof_dev_desc sof_of_imx8qxp_desc = { .default_fw_path = "imx/sof", .default_tplg_path = "imx/sof-tplg", + .default_fw_filename = "sof-imx8.ri", .nocodec_fw_filename = "sof-imx8.ri", .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8_ops, diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index bbeffd932de7..046bd57657ca 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -47,6 +47,7 @@ static const struct sof_dev_desc bxt_desc = { .chip_info = &apl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-apl.ri", .nocodec_fw_filename = "sof-apl.ri", .nocodec_tplg_filename = "sof-apl-nocodec.tplg", .ops = &sof_apl_ops, @@ -65,6 +66,7 @@ static const struct sof_dev_desc glk_desc = { .chip_info = &apl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-glk.ri", .nocodec_fw_filename = "sof-glk.ri", .nocodec_tplg_filename = "sof-glk-nocodec.tplg", .ops = &sof_apl_ops, @@ -93,6 +95,7 @@ static const struct sof_dev_desc tng_desc = { .chip_info = &tng_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-byt.ri", .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt.tplg", .ops = &sof_tng_ops, @@ -111,6 +114,7 @@ static const struct sof_dev_desc cnl_desc = { .chip_info = &cnl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-cnl.ri", .nocodec_fw_filename = "sof-cnl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, @@ -129,6 +133,7 @@ static const struct sof_dev_desc cfl_desc = { .chip_info = &cnl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-cfl.ri", .nocodec_fw_filename = "sof-cfl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, @@ -149,6 +154,7 @@ static const struct sof_dev_desc cml_desc = { .chip_info = &cnl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-cml.ri", .nocodec_fw_filename = "sof-cml.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, @@ -167,6 +173,7 @@ static const struct sof_dev_desc icl_desc = { .chip_info = &icl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-icl.ri", .nocodec_fw_filename = "sof-icl.ri", .nocodec_tplg_filename = "sof-icl-nocodec.tplg", .ops = &sof_cnl_ops, @@ -185,6 +192,7 @@ static const struct sof_dev_desc tgl_desc = { .chip_info = &tgl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-tgl.ri", .nocodec_fw_filename = "sof-tgl.ri", .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_cnl_ops, @@ -203,6 +211,7 @@ static const struct sof_dev_desc ehl_desc = { .chip_info = &ehl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", + .default_fw_filename = "sof-ehl.ri", .nocodec_fw_filename = "sof-ehl.ri", .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_cnl_ops, -- cgit v1.2.3 From ee1e79b72e3cf5eac42ba9de827536f91d4c04e2 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:51 -0600 Subject: ASoC: SOF: partition audio-related parts from SOF core Move all the audio-specific code in the core, audio-specific logic in the top-level PM callbacks and the core header files into a separate file (sof-audio.*) in preparation for adding an audio client device. In the process of moving all structure definitions for widget, routes, pcm's etc, the snd_sof_dev member in all these structs is replaced with the snd_soc_component member. Also, use the component device instead of the snd_sof_dev device wherever possible in the PCM component driver, control IO functions and the topology parser as the component device will be moved over to the client device later on. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/Makefile | 2 +- sound/soc/sof/control.c | 55 +++--- sound/soc/sof/core.c | 120 ------------- sound/soc/sof/intel/hda-dai.c | 1 + sound/soc/sof/intel/hda-pcm.c | 4 +- sound/soc/sof/intel/hda-stream.c | 1 + sound/soc/sof/ipc.c | 16 +- sound/soc/sof/pcm.c | 123 ++++++------- sound/soc/sof/pm.c | 219 +---------------------- sound/soc/sof/sof-audio.c | 362 ++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-audio.h | 207 ++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 187 -------------------- sound/soc/sof/topology.c | 365 +++++++++++++++++++-------------------- 13 files changed, 861 insertions(+), 801 deletions(-) create mode 100644 sound/soc/sof/sof-audio.c create mode 100644 sound/soc/sof/sof-audio.h diff --git a/sound/soc/sof/Makefile b/sound/soc/sof/Makefile index b0a6f01bdc44..0a8bc72c28a5 100644 --- a/sound/soc/sof/Makefile +++ b/sound/soc/sof/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) snd-sof-objs := core.o ops.o loader.o ipc.o pcm.o pm.o debug.o topology.o\ - control.o trace.o utils.o + control.o trace.o utils.o sof-audio.o snd-sof-pci-objs := sof-pci-dev.o snd-sof-acpi-objs := sof-acpi-dev.o diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index 7baf7f1507c3..dfc412e2d956 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -13,6 +13,7 @@ #include #include #include "sof-priv.h" +#include "sof-audio.h" static void update_mute_led(struct snd_sof_control *scontrol, struct snd_kcontrol *kcontrol, @@ -88,7 +89,7 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol, struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value; struct snd_sof_control *scontrol = sm->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; unsigned int i, channels = scontrol->num_channels; bool change = false; @@ -104,8 +105,8 @@ int snd_sof_volume_put(struct snd_kcontrol *kcontrol, } /* notify DSP of mixer updates */ - if (pm_runtime_active(sdev->dev)) - snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + if (pm_runtime_active(scomp->dev)) + snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_SET_VALUE, SOF_CTRL_TYPE_VALUE_CHAN_GET, SOF_CTRL_CMD_VOLUME, @@ -135,7 +136,7 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol, struct soc_mixer_control *sm = (struct soc_mixer_control *)kcontrol->private_value; struct snd_sof_control *scontrol = sm->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; unsigned int i, channels = scontrol->num_channels; bool change = false; @@ -153,8 +154,8 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol, update_mute_led(scontrol, kcontrol, ucontrol); /* notify DSP of mixer updates */ - if (pm_runtime_active(sdev->dev)) - snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + if (pm_runtime_active(scomp->dev)) + snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_SET_VALUE, SOF_CTRL_TYPE_VALUE_CHAN_GET, SOF_CTRL_CMD_SWITCH, @@ -185,7 +186,7 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol, struct soc_enum *se = (struct soc_enum *)kcontrol->private_value; struct snd_sof_control *scontrol = se->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; unsigned int i, channels = scontrol->num_channels; bool change = false; @@ -200,8 +201,8 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol, } /* notify DSP of enum updates */ - if (pm_runtime_active(sdev->dev)) - snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + if (pm_runtime_active(scomp->dev)) + snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_SET_VALUE, SOF_CTRL_TYPE_VALUE_CHAN_GET, SOF_CTRL_CMD_ENUM, @@ -216,14 +217,14 @@ int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value; struct snd_sof_control *scontrol = be->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct sof_abi_hdr *data = cdata->data; size_t size; int ret = 0; if (be->max > sizeof(ucontrol->value.bytes.data)) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: data max %d exceeds ucontrol data array size\n", be->max); return -EINVAL; @@ -231,7 +232,7 @@ int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, size = data->size + sizeof(*data); if (size > be->max) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: DSP sent %zu bytes max is %d\n", size, be->max); ret = -EINVAL; @@ -251,20 +252,20 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value; struct snd_sof_control *scontrol = be->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct sof_abi_hdr *data = cdata->data; size_t size = data->size + sizeof(*data); if (be->max > sizeof(ucontrol->value.bytes.data)) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: data max %d exceeds ucontrol data array size\n", be->max); return -EINVAL; } if (size > be->max) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: size too big %zu bytes max is %d\n", size, be->max); return -EINVAL; @@ -274,8 +275,8 @@ int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, memcpy(data, ucontrol->value.bytes.data, size); /* notify DSP of byte control updates */ - if (pm_runtime_active(sdev->dev)) - snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + if (pm_runtime_active(scomp->dev)) + snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_SET_DATA, SOF_CTRL_TYPE_DATA_SET, scontrol->cmd, @@ -291,7 +292,7 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value; struct snd_sof_control *scontrol = be->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct snd_ctl_tlv header; const struct snd_ctl_tlv __user *tlvd = @@ -307,14 +308,14 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, /* be->max is coming from topology */ if (header.length > be->max) { - dev_err_ratelimited(sdev->dev, "error: Bytes data size %d exceeds max %d.\n", + dev_err_ratelimited(scomp->dev, "error: Bytes data size %d exceeds max %d.\n", header.length, be->max); return -EINVAL; } /* Check that header id matches the command */ if (header.numid != scontrol->cmd) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: incorrect numid %d\n", header.numid); return -EINVAL; @@ -324,26 +325,26 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, return -EFAULT; if (cdata->data->magic != SOF_ABI_MAGIC) { - dev_err_ratelimited(sdev->dev, + dev_err_ratelimited(scomp->dev, "error: Wrong ABI magic 0x%08x.\n", cdata->data->magic); return -EINVAL; } if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) { - dev_err_ratelimited(sdev->dev, "error: Incompatible ABI version 0x%08x.\n", + dev_err_ratelimited(scomp->dev, "error: Incompatible ABI version 0x%08x.\n", cdata->data->abi); return -EINVAL; } if (cdata->data->size + sizeof(const struct sof_abi_hdr) > be->max) { - dev_err_ratelimited(sdev->dev, "error: Mismatch in ABI data size (truncated?).\n"); + dev_err_ratelimited(scomp->dev, "error: Mismatch in ABI data size (truncated?).\n"); return -EINVAL; } /* notify DSP of byte control updates */ - if (pm_runtime_active(sdev->dev)) - snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + if (pm_runtime_active(scomp->dev)) + snd_sof_ipc_set_get_comp_data(scontrol, SOF_IPC_COMP_SET_DATA, SOF_CTRL_TYPE_DATA_SET, scontrol->cmd, @@ -359,7 +360,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *be = (struct soc_bytes_ext *)kcontrol->private_value; struct snd_sof_control *scontrol = be->dobj.private; - struct snd_sof_dev *sdev = scontrol->sdev; + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; struct snd_ctl_tlv header; struct snd_ctl_tlv __user *tlvd = @@ -382,7 +383,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, /* check data size doesn't exceed max coming from topology */ if (data_size > be->max) { - dev_err_ratelimited(sdev->dev, "error: user data size %d exceeds max size %d.\n", + dev_err_ratelimited(scomp->dev, "error: user data size %d exceeds max size %d.\n", data_size, be->max); ret = -EINVAL; goto out; diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index d8446fb9fdde..9832322adbec 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -24,126 +24,6 @@ MODULE_PARM_DESC(sof_debug, "SOF core debug options (0x0 all off)"); #define TIMEOUT_DEFAULT_IPC_MS 500 #define TIMEOUT_DEFAULT_BOOT_MS 2000 -/* - * Generic object lookup APIs. - */ - -struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_sof_dev *sdev, - const char *name) -{ - struct snd_sof_pcm *spcm; - - list_for_each_entry(spcm, &sdev->pcm_list, list) { - /* match with PCM dai name */ - if (strcmp(spcm->pcm.dai_name, name) == 0) - return spcm; - - /* match with playback caps name if set */ - if (*spcm->pcm.caps[0].name && - !strcmp(spcm->pcm.caps[0].name, name)) - return spcm; - - /* match with capture caps name if set */ - if (*spcm->pcm.caps[1].name && - !strcmp(spcm->pcm.caps[1].name, name)) - return spcm; - } - - return NULL; -} - -struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_sof_dev *sdev, - unsigned int comp_id, - int *direction) -{ - struct snd_sof_pcm *spcm; - - list_for_each_entry(spcm, &sdev->pcm_list, list) { - if (spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].comp_id == comp_id) { - *direction = SNDRV_PCM_STREAM_PLAYBACK; - return spcm; - } - if (spcm->stream[SNDRV_PCM_STREAM_CAPTURE].comp_id == comp_id) { - *direction = SNDRV_PCM_STREAM_CAPTURE; - return spcm; - } - } - - return NULL; -} - -struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_sof_dev *sdev, - unsigned int pcm_id) -{ - struct snd_sof_pcm *spcm; - - list_for_each_entry(spcm, &sdev->pcm_list, list) { - if (le32_to_cpu(spcm->pcm.pcm_id) == pcm_id) - return spcm; - } - - return NULL; -} - -struct snd_sof_widget *snd_sof_find_swidget(struct snd_sof_dev *sdev, - const char *name) -{ - struct snd_sof_widget *swidget; - - list_for_each_entry(swidget, &sdev->widget_list, list) { - if (strcmp(name, swidget->widget->name) == 0) - return swidget; - } - - return NULL; -} - -/* find widget by stream name and direction */ -struct snd_sof_widget *snd_sof_find_swidget_sname(struct snd_sof_dev *sdev, - const char *pcm_name, int dir) -{ - struct snd_sof_widget *swidget; - enum snd_soc_dapm_type type; - - if (dir == SNDRV_PCM_STREAM_PLAYBACK) - type = snd_soc_dapm_aif_in; - else - type = snd_soc_dapm_aif_out; - - list_for_each_entry(swidget, &sdev->widget_list, list) { - if (!strcmp(pcm_name, swidget->widget->sname) && swidget->id == type) - return swidget; - } - - return NULL; -} - -struct snd_sof_dai *snd_sof_find_dai(struct snd_sof_dev *sdev, - const char *name) -{ - struct snd_sof_dai *dai; - - list_for_each_entry(dai, &sdev->dai_list, list) { - if (dai->name && (strcmp(name, dai->name) == 0)) - return dai; - } - - return NULL; -} - -bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev) -{ - struct snd_sof_pcm *spcm; - - list_for_each_entry(spcm, &sdev->pcm_list, list) { - if (spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].suspend_ignored || - spcm->stream[SNDRV_PCM_STREAM_CAPTURE].suspend_ignored) - return true; - } - - return false; -} - /* * FW Panic/fault handling. */ diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 8796f385be76..2d9ac0035bd2 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -11,6 +11,7 @@ #include #include #include "../sof-priv.h" +#include "../sof-audio.h" #include "hda.h" #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) diff --git a/sound/soc/sof/intel/hda-pcm.c b/sound/soc/sof/intel/hda-pcm.c index 575f5f5877d8..23872f6e708d 100644 --- a/sound/soc/sof/intel/hda-pcm.c +++ b/sound/soc/sof/intel/hda-pcm.c @@ -17,6 +17,7 @@ #include #include +#include "../sof-audio.h" #include "../ops.h" #include "hda.h" @@ -147,12 +148,13 @@ snd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *scomp = sdev->component; struct hdac_stream *hstream = substream->runtime->private_data; struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; struct snd_sof_pcm *spcm; snd_pcm_uframes_t pos; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(scomp, rtd); if (!spcm) { dev_warn_ratelimited(sdev->dev, "warn: can't find PCM with DAI ID %d\n", rtd->dai_link->id); diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 927a36f92c24..c0ab9bb2a797 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -20,6 +20,7 @@ #include #include #include "../ops.h" +#include "../sof-audio.h" #include "hda.h" /* diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 5994e1073364..293c5ae8e882 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -15,6 +15,7 @@ #include #include "sof-priv.h" +#include "sof-audio.h" #include "ops.h" static void ipc_trace_message(struct snd_sof_dev *sdev, u32 msg_id); @@ -412,12 +413,13 @@ static void ipc_trace_message(struct snd_sof_dev *sdev, u32 msg_id) static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id) { + struct snd_soc_component *scomp = sdev->component; struct snd_sof_pcm_stream *stream; struct sof_ipc_stream_posn posn; struct snd_sof_pcm *spcm; int direction; - spcm = snd_sof_find_spcm_comp(sdev, msg_id, &direction); + spcm = snd_sof_find_spcm_comp(scomp, msg_id, &direction); if (!spcm) { dev_err(sdev->dev, "error: period elapsed for unknown stream, msg_id %d\n", @@ -441,12 +443,13 @@ static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id) /* DSP notifies host of an XRUN within FW */ static void ipc_xrun(struct snd_sof_dev *sdev, u32 msg_id) { + struct snd_soc_component *scomp = sdev->component; struct snd_sof_pcm_stream *stream; struct sof_ipc_stream_posn posn; struct snd_sof_pcm *spcm; int direction; - spcm = snd_sof_find_spcm_comp(sdev, msg_id, &direction); + spcm = snd_sof_find_spcm_comp(scomp, msg_id, &direction); if (!spcm) { dev_err(sdev->dev, "error: XRUN for unknown stream, msg_id %d\n", msg_id); @@ -488,10 +491,11 @@ static void ipc_stream_message(struct snd_sof_dev *sdev, u32 msg_cmd) } /* get stream position IPC - use faster MMIO method if available on platform */ -int snd_sof_ipc_stream_posn(struct snd_sof_dev *sdev, +int snd_sof_ipc_stream_posn(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm, int direction, struct sof_ipc_stream_posn *posn) { + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct sof_ipc_stream stream; int err; @@ -620,15 +624,15 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev, /* * IPC get()/set() for kcontrols. */ -int snd_sof_ipc_set_get_comp_data(struct snd_sof_ipc *ipc, - struct snd_sof_control *scontrol, +int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, u32 ipc_cmd, enum sof_ipc_ctrl_type ctrl_type, enum sof_ipc_ctrl_cmd ctrl_cmd, bool send) { + struct snd_soc_component *scomp = scontrol->scomp; struct sof_ipc_ctrl_data *cdata = scontrol->control_data; - struct snd_sof_dev *sdev = ipc->sdev; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct sof_ipc_fw_ready *ready = &sdev->fw_ready; struct sof_ipc_fw_version *v = &ready->version; struct sof_ipc_ctrl_data_params sparams; diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index a9c47f6bf657..54ec78799c30 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -14,38 +14,38 @@ #include #include #include "sof-priv.h" +#include "sof-audio.h" #include "ops.h" -#define DRV_NAME "sof-audio-component" - /* Create DMA buffer page table for DSP */ static int create_page_table(struct snd_soc_component *component, struct snd_pcm_substream *substream, unsigned char *dma_area, size_t size) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm; struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream); int stream = substream->stream; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - return snd_sof_create_page_table(sdev->dev, dmab, + return snd_sof_create_page_table(component->dev, dmab, spcm->stream[stream].page_table.area, size); } static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream *substream, const struct sof_ipc_pcm_params_reply *reply) { - struct snd_sof_dev *sdev = spcm->sdev; + struct snd_soc_component *scomp = spcm->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + /* validate offset */ int ret = snd_sof_ipc_pcm_params(sdev, substream, reply); if (ret < 0) - dev_err(sdev->dev, "error: got wrong reply for PCM %d\n", + dev_err(scomp->dev, "error: got wrong reply for PCM %d\n", spcm->pcm.pcm_id); return ret; @@ -70,13 +70,12 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, DRV_NAME); - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); struct snd_sof_pcm *spcm; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) { - dev_err(sdev->dev, + dev_err(component->dev, "error: period elapsed for unknown stream!\n"); return; } @@ -110,11 +109,11 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - dev_dbg(sdev->dev, "pcm: hw params stream %d dir %d\n", + dev_dbg(component->dev, "pcm: hw params stream %d dir %d\n", spcm->pcm.pcm_id, substream->stream); memset(&pcm, 0, sizeof(pcm)); @@ -122,7 +121,7 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, /* allocate audio buffer pages */ ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); if (ret < 0) { - dev_err(sdev->dev, "error: could not allocate %d bytes for PCM %d\n", + dev_err(component->dev, "error: could not allocate %d bytes for PCM %d\n", params_buffer_bytes(params), spcm->pcm.pcm_id); return ret; } @@ -187,17 +186,17 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, params, &pcm.params); if (ret < 0) { - dev_err(sdev->dev, "error: platform hw params failed\n"); + dev_err(component->dev, "error: platform hw params failed\n"); return ret; } - dev_dbg(sdev->dev, "stream_tag %d", pcm.params.stream_tag); + dev_dbg(component->dev, "stream_tag %d", pcm.params.stream_tag); /* send IPC to the DSP */ ret = sof_ipc_tx_message(sdev->ipc, pcm.hdr.cmd, &pcm, sizeof(pcm), &ipc_params_reply, sizeof(ipc_params_reply)); if (ret < 0) { - dev_err(sdev->dev, "error: hw params ipc failed for stream %d\n", + dev_err(component->dev, "error: hw params ipc failed for stream %d\n", pcm.params.stream_tag); return ret; } @@ -247,12 +246,12 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - dev_dbg(sdev->dev, "pcm: free stream %d dir %d\n", spcm->pcm.pcm_id, - substream->stream); + dev_dbg(component->dev, "pcm: free stream %d dir %d\n", + spcm->pcm.pcm_id, substream->stream); if (spcm->prepared[substream->stream]) { ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm); @@ -266,7 +265,7 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, ret = snd_sof_pcm_platform_hw_free(sdev, substream); if (ret < 0) { - dev_err(sdev->dev, "error: platform hw free failed\n"); + dev_err(component->dev, "error: platform hw free failed\n"); err = ret; } @@ -277,7 +276,6 @@ static int sof_pcm_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); struct snd_sof_pcm *spcm; int ret; @@ -285,21 +283,22 @@ static int sof_pcm_prepare(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; if (spcm->prepared[substream->stream]) return 0; - dev_dbg(sdev->dev, "pcm: prepare stream %d dir %d\n", spcm->pcm.pcm_id, - substream->stream); + dev_dbg(component->dev, "pcm: prepare stream %d dir %d\n", + spcm->pcm.pcm_id, substream->stream); /* set hw_params */ ret = sof_pcm_hw_params(component, substream, &spcm->params[substream->stream]); if (ret < 0) { - dev_err(sdev->dev, "error: set pcm hw_params after resume\n"); + dev_err(component->dev, + "error: set pcm hw_params after resume\n"); return ret; } @@ -326,11 +325,11 @@ static int sof_pcm_trigger(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - dev_dbg(sdev->dev, "pcm: trigger stream %d dir %d cmd %d\n", + dev_dbg(component->dev, "pcm: trigger stream %d dir %d cmd %d\n", spcm->pcm.pcm_id, substream->stream, cmd); stream.hdr.size = sizeof(stream); @@ -359,7 +358,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component, /* set up hw_params */ ret = sof_pcm_prepare(component, substream); if (ret < 0) { - dev_err(sdev->dev, + dev_err(component->dev, "error: failed to set up hw_params upon resume\n"); return ret; } @@ -396,7 +395,8 @@ static int sof_pcm_trigger(struct snd_soc_component *component, reset_hw_params = true; break; default: - dev_err(sdev->dev, "error: unhandled trigger cmd %d\n", cmd); + dev_err(component->dev, "error: unhandled trigger cmd %d\n", + cmd); return -EINVAL; } @@ -438,7 +438,7 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component, if (sof_ops(sdev)->pcm_pointer) return sof_ops(sdev)->pcm_pointer(sdev, substream); - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; @@ -448,7 +448,8 @@ static snd_pcm_uframes_t sof_pcm_pointer(struct snd_soc_component *component, dai = bytes_to_frames(substream->runtime, spcm->stream[substream->stream].posn.dai_posn); - dev_dbg(sdev->dev, "PCM: stream %d dir %d DMA position %lu DAI position %lu\n", + dev_dbg(component->dev, + "PCM: stream %d dir %d DMA position %lu DAI position %lu\n", spcm->pcm.pcm_id, substream->stream, host, dai); return host; @@ -469,12 +470,12 @@ static int sof_pcm_open(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - dev_dbg(sdev->dev, "pcm: open stream %d dir %d\n", spcm->pcm.pcm_id, - substream->stream); + dev_dbg(component->dev, "pcm: open stream %d dir %d\n", + spcm->pcm.pcm_id, substream->stream); INIT_WORK(&spcm->stream[substream->stream].period_elapsed_work, sof_pcm_period_elapsed_work); @@ -504,13 +505,13 @@ static int sof_pcm_open(struct snd_soc_component *component, */ runtime->hw.buffer_bytes_max = le32_to_cpu(caps->buffer_size_max); - dev_dbg(sdev->dev, "period min %zd max %zd bytes\n", + dev_dbg(component->dev, "period min %zd max %zd bytes\n", runtime->hw.period_bytes_min, runtime->hw.period_bytes_max); - dev_dbg(sdev->dev, "period count %d max %d\n", + dev_dbg(component->dev, "period count %d max %d\n", runtime->hw.periods_min, runtime->hw.periods_max); - dev_dbg(sdev->dev, "buffer max %zd bytes\n", + dev_dbg(component->dev, "buffer max %zd bytes\n", runtime->hw.buffer_bytes_max); /* set wait time - TODO: come from topology */ @@ -523,7 +524,7 @@ static int sof_pcm_open(struct snd_soc_component *component, ret = snd_sof_pcm_platform_open(sdev, substream); if (ret < 0) - dev_err(sdev->dev, "error: pcm open failed %d\n", ret); + dev_err(component->dev, "error: pcm open failed %d\n", ret); return ret; } @@ -540,16 +541,16 @@ static int sof_pcm_close(struct snd_soc_component *component, if (rtd->dai_link->no_pcm) return 0; - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) return -EINVAL; - dev_dbg(sdev->dev, "pcm: close stream %d dir %d\n", spcm->pcm.pcm_id, - substream->stream); + dev_dbg(component->dev, "pcm: close stream %d dir %d\n", + spcm->pcm.pcm_id, substream->stream); err = snd_sof_pcm_platform_close(sdev, substream); if (err < 0) { - dev_err(sdev->dev, "error: pcm close failed %d\n", + dev_err(component->dev, "error: pcm close failed %d\n", err); /* * keep going, no point in preventing the close @@ -575,14 +576,14 @@ static int sof_pcm_new(struct snd_soc_component *component, int stream = SNDRV_PCM_STREAM_PLAYBACK; /* find SOF PCM for this RTD */ - spcm = snd_sof_find_spcm_dai(sdev, rtd); + spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) { - dev_warn(sdev->dev, "warn: can't find PCM with DAI ID %d\n", + dev_warn(component->dev, "warn: can't find PCM with DAI ID %d\n", rtd->dai_link->id); return 0; } - dev_dbg(sdev->dev, "creating new PCM %s\n", spcm->pcm.pcm_name); + dev_dbg(component->dev, "creating new PCM %s\n", spcm->pcm.pcm_name); /* do we need to pre-allocate playback audio buffer pages */ if (!spcm->pcm.playback) @@ -591,7 +592,8 @@ static int sof_pcm_new(struct snd_soc_component *component, caps = &spcm->pcm.caps[stream]; /* pre-allocate playback audio buffer pages */ - dev_dbg(sdev->dev, "spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n", + dev_dbg(component->dev, + "spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n", caps->name, caps->buffer_size_min, caps->buffer_size_max); snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream, @@ -608,7 +610,8 @@ capture: caps = &spcm->pcm.caps[stream]; /* pre-allocate capture audio buffer pages */ - dev_dbg(sdev->dev, "spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n", + dev_dbg(component->dev, + "spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n", caps->name, caps->buffer_size_min, caps->buffer_size_max); snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream, @@ -629,14 +632,14 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); struct snd_soc_component *component = - snd_soc_rtdcom_lookup(rtd, DRV_NAME); - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); struct snd_sof_dai *dai = - snd_sof_find_dai(sdev, (char *)rtd->dai_link->name); + snd_sof_find_dai(component, (char *)rtd->dai_link->name); /* no topology exists for this BE, try a common configuration */ if (!dai) { - dev_warn(sdev->dev, "warning: no topology found for BE DAI %s config\n", + dev_warn(component->dev, + "warning: no topology found for BE DAI %s config\n", rtd->dai_link->name); /* set 48k, stereo, 16bits by default */ @@ -666,7 +669,7 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S32_LE); break; default: - dev_err(sdev->dev, "error: No available DAI format!\n"); + dev_err(component->dev, "error: No available DAI format!\n"); return -EINVAL; } @@ -678,9 +681,9 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, channels->min = dai->dai_config->ssp.tdm_slots; channels->max = dai->dai_config->ssp.tdm_slots; - dev_dbg(sdev->dev, + dev_dbg(component->dev, "rate_min: %d rate_max: %d\n", rate->min, rate->max); - dev_dbg(sdev->dev, + dev_dbg(component->dev, "channels_min: %d channels_max: %d\n", channels->min, channels->max); @@ -688,7 +691,7 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, case SOF_DAI_INTEL_DMIC: /* DMIC only supports 16 or 32 bit formats */ if (dai->comp_dai.config.frame_fmt == SOF_IPC_FRAME_S24_4LE) { - dev_err(sdev->dev, + dev_err(component->dev, "error: invalid fmt %d for DAI type %d\n", dai->comp_dai.config.frame_fmt, dai->dai_config->type); @@ -704,12 +707,12 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, channels->min = dai->dai_config->esai.tdm_slots; channels->max = dai->dai_config->esai.tdm_slots; - dev_dbg(sdev->dev, + dev_dbg(component->dev, "channels_min: %d channels_max: %d\n", channels->min, channels->max); break; default: - dev_err(sdev->dev, "error: invalid DAI type %d\n", + dev_err(component->dev, "error: invalid DAI type %d\n", dai->dai_config->type); break; } @@ -734,9 +737,9 @@ static int sof_pcm_probe(struct snd_soc_component *component) if (!tplg_filename) return -ENOMEM; - ret = snd_sof_load_topology(sdev, tplg_filename); + ret = snd_sof_load_topology(component, tplg_filename); if (ret < 0) { - dev_err(sdev->dev, "error: failed to load DSP topology %d\n", + dev_err(component->dev, "error: failed to load DSP topology %d\n", ret); return ret; } diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index 0fd5567237a8..d1a7b98886d1 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -10,192 +10,7 @@ #include "ops.h" #include "sof-priv.h" - -static int sof_restore_kcontrols(struct snd_sof_dev *sdev) -{ - struct snd_sof_control *scontrol; - int ipc_cmd, ctrl_type; - int ret = 0; - - /* restore kcontrol values */ - list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { - /* reset readback offset for scontrol after resuming */ - scontrol->readback_offset = 0; - - /* notify DSP of kcontrol values */ - switch (scontrol->cmd) { - case SOF_CTRL_CMD_VOLUME: - case SOF_CTRL_CMD_ENUM: - case SOF_CTRL_CMD_SWITCH: - ipc_cmd = SOF_IPC_COMP_SET_VALUE; - ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET; - ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, - ipc_cmd, ctrl_type, - scontrol->cmd, - true); - break; - case SOF_CTRL_CMD_BINARY: - ipc_cmd = SOF_IPC_COMP_SET_DATA; - ctrl_type = SOF_CTRL_TYPE_DATA_SET; - ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, - ipc_cmd, ctrl_type, - scontrol->cmd, - true); - break; - - default: - break; - } - - if (ret < 0) { - dev_err(sdev->dev, - "error: failed kcontrol value set for widget: %d\n", - scontrol->comp_id); - - return ret; - } - } - - return 0; -} - -static int sof_restore_pipelines(struct snd_sof_dev *sdev) -{ - struct snd_sof_widget *swidget; - struct snd_sof_route *sroute; - struct sof_ipc_pipe_new *pipeline; - struct snd_sof_dai *dai; - struct sof_ipc_comp_dai *comp_dai; - struct sof_ipc_cmd_hdr *hdr; - int ret; - - /* restore pipeline components */ - list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { - struct sof_ipc_comp_reply r; - - /* skip if there is no private data */ - if (!swidget->private) - continue; - - switch (swidget->id) { - case snd_soc_dapm_dai_in: - case snd_soc_dapm_dai_out: - dai = swidget->private; - comp_dai = &dai->comp_dai; - ret = sof_ipc_tx_message(sdev->ipc, - comp_dai->comp.hdr.cmd, - comp_dai, sizeof(*comp_dai), - &r, sizeof(r)); - break; - case snd_soc_dapm_scheduler: - - /* - * During suspend, all DSP cores are powered off. - * Therefore upon resume, create the pipeline comp - * and power up the core that the pipeline is - * scheduled on. - */ - pipeline = swidget->private; - ret = sof_load_pipeline_ipc(sdev, pipeline, &r); - break; - default: - hdr = swidget->private; - ret = sof_ipc_tx_message(sdev->ipc, hdr->cmd, - swidget->private, hdr->size, - &r, sizeof(r)); - break; - } - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to load widget type %d with ID: %d\n", - swidget->widget->id, swidget->comp_id); - - return ret; - } - } - - /* restore pipeline connections */ - list_for_each_entry_reverse(sroute, &sdev->route_list, list) { - struct sof_ipc_pipe_comp_connect *connect; - struct sof_ipc_reply reply; - - /* skip if there's no private data */ - if (!sroute->private) - continue; - - connect = sroute->private; - - /* send ipc */ - ret = sof_ipc_tx_message(sdev->ipc, - connect->hdr.cmd, - connect, sizeof(*connect), - &reply, sizeof(reply)); - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to load route sink %s control %s source %s\n", - sroute->route->sink, - sroute->route->control ? sroute->route->control - : "none", - sroute->route->source); - - return ret; - } - } - - /* restore dai links */ - list_for_each_entry_reverse(dai, &sdev->dai_list, list) { - struct sof_ipc_reply reply; - struct sof_ipc_dai_config *config = dai->dai_config; - - if (!config) { - dev_err(sdev->dev, "error: no config for DAI %s\n", - dai->name); - continue; - } - - /* - * The link DMA channel would be invalidated for running - * streams but not for streams that were in the PAUSED - * state during suspend. So invalidate it here before setting - * the dai config in the DSP. - */ - if (config->type == SOF_DAI_INTEL_HDA) - config->hda.link_dma_ch = DMA_CHAN_INVALID; - - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, - config->hdr.size, - &reply, sizeof(reply)); - - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to set dai config for %s\n", - dai->name); - - return ret; - } - } - - /* complete pipeline */ - list_for_each_entry(swidget, &sdev->widget_list, list) { - switch (swidget->id) { - case snd_soc_dapm_scheduler: - swidget->complete = - snd_sof_complete_pipeline(sdev, swidget); - break; - default: - break; - } - } - - /* restore pipeline kcontrols */ - ret = sof_restore_kcontrols(sdev); - if (ret < 0) - dev_err(sdev->dev, - "error: restoring kcontrols after resume\n"); - - return ret; -} +#include "sof-audio.h" static int sof_send_pm_ctx_ipc(struct snd_sof_dev *sdev, int cmd) { @@ -213,34 +28,6 @@ static int sof_send_pm_ctx_ipc(struct snd_sof_dev *sdev, int cmd) sizeof(pm_ctx), &reply, sizeof(reply)); } -static int sof_set_hw_params_upon_resume(struct snd_sof_dev *sdev) -{ - struct snd_pcm_substream *substream; - struct snd_sof_pcm *spcm; - snd_pcm_state_t state; - int dir; - - /* - * SOF requires hw_params to be set-up internally upon resume. - * So, set the flag to indicate this for those streams that - * have been suspended. - */ - list_for_each_entry(spcm, &sdev->pcm_list, list) { - for (dir = 0; dir <= SNDRV_PCM_STREAM_CAPTURE; dir++) { - substream = spcm->stream[dir].substream; - if (!substream || !substream->runtime) - continue; - - state = substream->runtime->status->state; - if (state == SNDRV_PCM_STATE_SUSPENDED) - spcm->prepared[dir] = false; - } - } - - /* set internal flag for BE */ - return snd_sof_dsp_hw_params_upon_resume(sdev); -} - #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) static void sof_cache_debugfs(struct snd_sof_dev *sdev) { @@ -311,7 +98,7 @@ static int sof_resume(struct device *dev, bool runtime_resume) } /* restore pipelines */ - ret = sof_restore_pipelines(sdev); + ret = sof_restore_pipelines(sdev->dev); if (ret < 0) { dev_err(sdev->dev, "error: failed to restore pipeline after resume %d\n", @@ -346,7 +133,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) /* set restore_stream for all streams during system suspend */ if (!runtime_suspend) { - ret = sof_set_hw_params_upon_resume(sdev); + ret = sof_set_hw_params_upon_resume(sdev->dev); if (ret < 0) { dev_err(sdev->dev, "error: setting hw_params flag during suspend %d\n", diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c new file mode 100644 index 000000000000..bf99d040c9c1 --- /dev/null +++ b/sound/soc/sof/sof-audio.c @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) +// +// This file is provided under a dual BSD/GPLv2 license. When using or +// redistributing this file, you may do so under either license. +// +// Copyright(c) 2019 Intel Corporation. All rights reserved. +// +// Author: Ranjani Sridharan +// + +#include "sof-audio.h" +#include "ops.h" + +bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev) +{ + struct snd_sof_pcm *spcm; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + if (spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].suspend_ignored || + spcm->stream[SNDRV_PCM_STREAM_CAPTURE].suspend_ignored) + return true; + } + + return false; +} + +int sof_set_hw_params_upon_resume(struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + struct snd_pcm_substream *substream; + struct snd_sof_pcm *spcm; + snd_pcm_state_t state; + int dir; + + /* + * SOF requires hw_params to be set-up internally upon resume. + * So, set the flag to indicate this for those streams that + * have been suspended. + */ + list_for_each_entry(spcm, &sdev->pcm_list, list) { + for (dir = 0; dir <= SNDRV_PCM_STREAM_CAPTURE; dir++) { + substream = spcm->stream[dir].substream; + if (!substream || !substream->runtime) + continue; + + state = substream->runtime->status->state; + if (state == SNDRV_PCM_STATE_SUSPENDED) + spcm->prepared[dir] = false; + } + } + + /* set internal flag for BE */ + return snd_sof_dsp_hw_params_upon_resume(sdev); +} + +static int sof_restore_kcontrols(struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + struct snd_sof_control *scontrol; + int ipc_cmd, ctrl_type; + int ret = 0; + + /* restore kcontrol values */ + list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { + /* reset readback offset for scontrol after resuming */ + scontrol->readback_offset = 0; + + /* notify DSP of kcontrol values */ + switch (scontrol->cmd) { + case SOF_CTRL_CMD_VOLUME: + case SOF_CTRL_CMD_ENUM: + case SOF_CTRL_CMD_SWITCH: + ipc_cmd = SOF_IPC_COMP_SET_VALUE; + ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET; + ret = snd_sof_ipc_set_get_comp_data(scontrol, + ipc_cmd, ctrl_type, + scontrol->cmd, + true); + break; + case SOF_CTRL_CMD_BINARY: + ipc_cmd = SOF_IPC_COMP_SET_DATA; + ctrl_type = SOF_CTRL_TYPE_DATA_SET; + ret = snd_sof_ipc_set_get_comp_data(scontrol, + ipc_cmd, ctrl_type, + scontrol->cmd, + true); + break; + + default: + break; + } + + if (ret < 0) { + dev_err(dev, + "error: failed kcontrol value set for widget: %d\n", + scontrol->comp_id); + + return ret; + } + } + + return 0; +} + +int sof_restore_pipelines(struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + struct snd_sof_widget *swidget; + struct snd_sof_route *sroute; + struct sof_ipc_pipe_new *pipeline; + struct snd_sof_dai *dai; + struct sof_ipc_comp_dai *comp_dai; + struct sof_ipc_cmd_hdr *hdr; + int ret; + + /* restore pipeline components */ + list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { + struct sof_ipc_comp_reply r; + + /* skip if there is no private data */ + if (!swidget->private) + continue; + + switch (swidget->id) { + case snd_soc_dapm_dai_in: + case snd_soc_dapm_dai_out: + dai = swidget->private; + comp_dai = &dai->comp_dai; + ret = sof_ipc_tx_message(sdev->ipc, + comp_dai->comp.hdr.cmd, + comp_dai, sizeof(*comp_dai), + &r, sizeof(r)); + break; + case snd_soc_dapm_scheduler: + + /* + * During suspend, all DSP cores are powered off. + * Therefore upon resume, create the pipeline comp + * and power up the core that the pipeline is + * scheduled on. + */ + pipeline = swidget->private; + ret = sof_load_pipeline_ipc(dev, pipeline, &r); + break; + default: + hdr = swidget->private; + ret = sof_ipc_tx_message(sdev->ipc, hdr->cmd, + swidget->private, hdr->size, + &r, sizeof(r)); + break; + } + if (ret < 0) { + dev_err(dev, + "error: failed to load widget type %d with ID: %d\n", + swidget->widget->id, swidget->comp_id); + + return ret; + } + } + + /* restore pipeline connections */ + list_for_each_entry_reverse(sroute, &sdev->route_list, list) { + struct sof_ipc_pipe_comp_connect *connect; + struct sof_ipc_reply reply; + + /* skip if there's no private data */ + if (!sroute->private) + continue; + + connect = sroute->private; + + /* send ipc */ + ret = sof_ipc_tx_message(sdev->ipc, + connect->hdr.cmd, + connect, sizeof(*connect), + &reply, sizeof(reply)); + if (ret < 0) { + dev_err(dev, + "error: failed to load route sink %s control %s source %s\n", + sroute->route->sink, + sroute->route->control ? sroute->route->control + : "none", + sroute->route->source); + + return ret; + } + } + + /* restore dai links */ + list_for_each_entry_reverse(dai, &sdev->dai_list, list) { + struct sof_ipc_reply reply; + struct sof_ipc_dai_config *config = dai->dai_config; + + if (!config) { + dev_err(dev, "error: no config for DAI %s\n", + dai->name); + continue; + } + + /* + * The link DMA channel would be invalidated for running + * streams but not for streams that were in the PAUSED + * state during suspend. So invalidate it here before setting + * the dai config in the DSP. + */ + if (config->type == SOF_DAI_INTEL_HDA) + config->hda.link_dma_ch = DMA_CHAN_INVALID; + + ret = sof_ipc_tx_message(sdev->ipc, + config->hdr.cmd, config, + config->hdr.size, + &reply, sizeof(reply)); + + if (ret < 0) { + dev_err(dev, + "error: failed to set dai config for %s\n", + dai->name); + + return ret; + } + } + + /* complete pipeline */ + list_for_each_entry(swidget, &sdev->widget_list, list) { + switch (swidget->id) { + case snd_soc_dapm_scheduler: + swidget->complete = + snd_sof_complete_pipeline(dev, swidget); + break; + default: + break; + } + } + + /* restore pipeline kcontrols */ + ret = sof_restore_kcontrols(dev); + if (ret < 0) + dev_err(dev, + "error: restoring kcontrols after resume\n"); + + return ret; +} + +/* + * Generic object lookup APIs. + */ + +struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp, + const char *name) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_pcm *spcm; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + /* match with PCM dai name */ + if (strcmp(spcm->pcm.dai_name, name) == 0) + return spcm; + + /* match with playback caps name if set */ + if (*spcm->pcm.caps[0].name && + !strcmp(spcm->pcm.caps[0].name, name)) + return spcm; + + /* match with capture caps name if set */ + if (*spcm->pcm.caps[1].name && + !strcmp(spcm->pcm.caps[1].name, name)) + return spcm; + } + + return NULL; +} + +struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp, + unsigned int comp_id, + int *direction) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_pcm *spcm; + int dir; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + dir = SNDRV_PCM_STREAM_PLAYBACK; + if (spcm->stream[dir].comp_id == comp_id) { + *direction = dir; + return spcm; + } + + dir = SNDRV_PCM_STREAM_CAPTURE; + if (spcm->stream[dir].comp_id == comp_id) { + *direction = dir; + return spcm; + } + } + + return NULL; +} + +struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp, + unsigned int pcm_id) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_pcm *spcm; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + if (le32_to_cpu(spcm->pcm.pcm_id) == pcm_id) + return spcm; + } + + return NULL; +} + +struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp, + const char *name) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_widget *swidget; + + list_for_each_entry(swidget, &sdev->widget_list, list) { + if (strcmp(name, swidget->widget->name) == 0) + return swidget; + } + + return NULL; +} + +/* find widget by stream name and direction */ +struct snd_sof_widget * +snd_sof_find_swidget_sname(struct snd_soc_component *scomp, + const char *pcm_name, int dir) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_widget *swidget; + enum snd_soc_dapm_type type; + + if (dir == SNDRV_PCM_STREAM_PLAYBACK) + type = snd_soc_dapm_aif_in; + else + type = snd_soc_dapm_aif_out; + + list_for_each_entry(swidget, &sdev->widget_list, list) { + if (!strcmp(pcm_name, swidget->widget->sname) && + swidget->id == type) + return swidget; + } + + return NULL; +} + +struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp, + const char *name) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_sof_dai *dai; + + list_for_each_entry(dai, &sdev->dai_list, list) { + if (dai->name && (strcmp(name, dai->name) == 0)) + return dai; + } + + return NULL; +} + diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h new file mode 100644 index 000000000000..5703698633af --- /dev/null +++ b/sound/soc/sof/sof-audio.h @@ -0,0 +1,207 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * Copyright(c) 2019 Intel Corporation. All rights reserved. + * + * Author: Ranjani Sridharan + */ + +#ifndef __SOUND_SOC_SOF_AUDIO_H +#define __SOUND_SOC_SOF_AUDIO_H + +#include +#include +#include /* needs to be included before control.h */ +#include +#include +#include +#include "sof-priv.h" + +#define SOF_AUDIO_PCM_DRV_NAME "sof-audio-component" + +/* max number of FE PCMs before BEs */ +#define SOF_BE_PCM_BASE 16 + +#define DMA_CHAN_INVALID 0xFFFFFFFF + +/* PCM stream, mapped to FW component */ +struct snd_sof_pcm_stream { + u32 comp_id; + struct snd_dma_buffer page_table; + struct sof_ipc_stream_posn posn; + struct snd_pcm_substream *substream; + struct work_struct period_elapsed_work; + bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */ + /* + * flag to indicate that the DSP pipelines should be kept + * active or not while suspending the stream + */ + bool suspend_ignored; +}; + +/* ALSA SOF PCM device */ +struct snd_sof_pcm { + struct snd_soc_component *scomp; + struct snd_soc_tplg_pcm pcm; + struct snd_sof_pcm_stream stream[2]; + struct list_head list; /* list in sdev pcm list */ + struct snd_pcm_hw_params params[2]; + bool prepared[2]; /* PCM_PARAMS set successfully */ +}; + +struct snd_sof_led_control { + unsigned int use_led; + unsigned int direction; + unsigned int led_value; +}; + +/* ALSA SOF Kcontrol device */ +struct snd_sof_control { + struct snd_soc_component *scomp; + int comp_id; + int min_volume_step; /* min volume step for volume_table */ + int max_volume_step; /* max volume step for volume_table */ + int num_channels; + u32 readback_offset; /* offset to mmapped data if used */ + struct sof_ipc_ctrl_data *control_data; + u32 size; /* cdata size */ + enum sof_ipc_ctrl_cmd cmd; + u32 *volume_table; /* volume table computed from tlv data*/ + + struct list_head list; /* list in sdev control list */ + + struct snd_sof_led_control led_ctl; +}; + +/* ASoC SOF DAPM widget */ +struct snd_sof_widget { + struct snd_soc_component *scomp; + int comp_id; + int pipeline_id; + int complete; + int id; + + struct snd_soc_dapm_widget *widget; + struct list_head list; /* list in sdev widget list */ + + void *private; /* core does not touch this */ +}; + +/* ASoC SOF DAPM route */ +struct snd_sof_route { + struct snd_soc_component *scomp; + + struct snd_soc_dapm_route *route; + struct list_head list; /* list in sdev route list */ + + void *private; +}; + +/* ASoC DAI device */ +struct snd_sof_dai { + struct snd_soc_component *scomp; + const char *name; + const char *cpu_dai_name; + + struct sof_ipc_comp_dai comp_dai; + struct sof_ipc_dai_config *dai_config; + struct list_head list; /* list in sdev dai list */ +}; + +/* + * Kcontrols. + */ + +int snd_sof_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_switch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_switch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, + const unsigned int __user *binary_data, + unsigned int size); +int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, + unsigned int __user *binary_data, + unsigned int size); + +/* + * Topology. + * There is no snd_sof_free_topology since topology components will + * be freed by snd_soc_unregister_component, + */ +int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file); +int snd_sof_complete_pipeline(struct device *dev, + struct snd_sof_widget *swidget); + +int sof_load_pipeline_ipc(struct device *dev, + struct sof_ipc_pipe_new *pipeline, + struct sof_ipc_comp_reply *r); + +/* + * Stream IPC + */ +int snd_sof_ipc_stream_posn(struct snd_soc_component *scomp, + struct snd_sof_pcm *spcm, int direction, + struct sof_ipc_stream_posn *posn); + +struct snd_sof_widget *snd_sof_find_swidget(struct snd_soc_component *scomp, + const char *name); +struct snd_sof_widget * +snd_sof_find_swidget_sname(struct snd_soc_component *scomp, + const char *pcm_name, int dir); +struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp, + const char *name); + +static inline +struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_soc_component *scomp, + struct snd_soc_pcm_runtime *rtd) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + + struct snd_sof_pcm *spcm = NULL; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id) + return spcm; + } + + return NULL; +} + +struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_soc_component *scomp, + const char *name); +struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp, + unsigned int comp_id, + int *direction); +struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp, + unsigned int pcm_id); +void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream); + +/* + * Mixer IPC + */ +int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, + u32 ipc_cmd, + enum sof_ipc_ctrl_type ctrl_type, + enum sof_ipc_ctrl_cmd ctrl_cmd, + bool send); + +/* PM */ +int sof_restore_pipelines(struct device *dev); +int sof_set_hw_params_upon_resume(struct device *dev); +bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev); + +#endif diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 18dd832f2053..eae1fc209a65 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -12,20 +12,11 @@ #define __SOUND_SOC_SOF_PRIV_H #include - #include -#include -#include - #include -#include /* needs to be included before control.h */ -#include -#include #include #include -#include #include - #include /* debug flags */ @@ -48,9 +39,6 @@ extern int sof_core_debug; /* DMA buffer size for trace */ #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16) -/* max number of FE PCMs before BEs */ -#define SOF_BE_PCM_BASE 16 - #define SOF_IPC_DSP_REPLY 0 #define SOF_IPC_HOST_REPLY 1 @@ -66,8 +54,6 @@ extern int sof_core_debug; (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \ IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST)) -#define DMA_CHAN_INVALID 0xFFFFFFFF - /* DSP D0ix sub-state */ enum sof_d0_substate { SOF_DSP_D0I0 = 0, /* DSP default D0 substate */ @@ -303,90 +289,6 @@ struct snd_sof_ipc_msg { bool ipc_complete; }; -/* PCM stream, mapped to FW component */ -struct snd_sof_pcm_stream { - u32 comp_id; - struct snd_dma_buffer page_table; - struct sof_ipc_stream_posn posn; - struct snd_pcm_substream *substream; - struct work_struct period_elapsed_work; - bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */ - /* - * flag to indicate that the DSP pipelines should be kept - * active or not while suspending the stream - */ - bool suspend_ignored; -}; - -/* ALSA SOF PCM device */ -struct snd_sof_pcm { - struct snd_sof_dev *sdev; - struct snd_soc_tplg_pcm pcm; - struct snd_sof_pcm_stream stream[2]; - struct list_head list; /* list in sdev pcm list */ - struct snd_pcm_hw_params params[2]; - bool prepared[2]; /* PCM_PARAMS set successfully */ -}; - -struct snd_sof_led_control { - unsigned int use_led; - unsigned int direction; - unsigned int led_value; -}; - -/* ALSA SOF Kcontrol device */ -struct snd_sof_control { - struct snd_sof_dev *sdev; - int comp_id; - int min_volume_step; /* min volume step for volume_table */ - int max_volume_step; /* max volume step for volume_table */ - int num_channels; - u32 readback_offset; /* offset to mmaped data if used */ - struct sof_ipc_ctrl_data *control_data; - u32 size; /* cdata size */ - enum sof_ipc_ctrl_cmd cmd; - u32 *volume_table; /* volume table computed from tlv data*/ - - struct list_head list; /* list in sdev control list */ - - struct snd_sof_led_control led_ctl; -}; - -/* ASoC SOF DAPM widget */ -struct snd_sof_widget { - struct snd_sof_dev *sdev; - int comp_id; - int pipeline_id; - int complete; - int id; - - struct snd_soc_dapm_widget *widget; - struct list_head list; /* list in sdev widget list */ - - void *private; /* core does not touch this */ -}; - -/* ASoC SOF DAPM route */ -struct snd_sof_route { - struct snd_sof_dev *sdev; - - struct snd_soc_dapm_route *route; - struct list_head list; /* list in sdev route list */ - - void *private; -}; - -/* ASoC DAI device */ -struct snd_sof_dai { - struct snd_sof_dev *sdev; - const char *name; - const char *cpu_dai_name; - - struct sof_ipc_comp_dai comp_dai; - struct sof_ipc_dai_config *dai_config; - struct list_head list; /* list in sdev dai list */ -}; - /* * SOF Device Level. */ @@ -531,67 +433,6 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev); int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header, void *msg_data, size_t msg_bytes, void *reply_data, size_t reply_bytes); -struct snd_sof_widget *snd_sof_find_swidget(struct snd_sof_dev *sdev, - const char *name); -struct snd_sof_widget *snd_sof_find_swidget_sname(struct snd_sof_dev *sdev, - const char *pcm_name, - int dir); -struct snd_sof_dai *snd_sof_find_dai(struct snd_sof_dev *sdev, - const char *name); - -static inline -struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev, - struct snd_soc_pcm_runtime *rtd) -{ - struct snd_sof_pcm *spcm = NULL; - - list_for_each_entry(spcm, &sdev->pcm_list, list) { - if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id) - return spcm; - } - - return NULL; -} - -bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev); - -struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_sof_dev *sdev, - const char *name); -struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_sof_dev *sdev, - unsigned int comp_id, - int *direction); -struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_sof_dev *sdev, - unsigned int pcm_id); -void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream); - -/* - * Stream IPC - */ -int snd_sof_ipc_stream_posn(struct snd_sof_dev *sdev, - struct snd_sof_pcm *spcm, int direction, - struct sof_ipc_stream_posn *posn); - -/* - * Mixer IPC - */ -int snd_sof_ipc_set_get_comp_data(struct snd_sof_ipc *ipc, - struct snd_sof_control *scontrol, u32 ipc_cmd, - enum sof_ipc_ctrl_type ctrl_type, - enum sof_ipc_ctrl_cmd ctrl_cmd, - bool send); - -/* - * Topology. - * There is no snd_sof_free_topology since topology components will - * be freed by snd_soc_unregister_component, - */ -int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file); -int snd_sof_complete_pipeline(struct snd_sof_dev *sdev, - struct snd_sof_widget *swidget); - -int sof_load_pipeline_ipc(struct snd_sof_dev *sdev, - struct sof_ipc_pipe_new *pipeline, - struct sof_ipc_comp_reply *r); /* * Trace/debug @@ -623,40 +464,12 @@ void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev); */ extern struct snd_compr_ops sof_compressed_ops; -/* - * Kcontrols. - */ - -int snd_sof_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_switch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_switch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_enum_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_enum_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, - const unsigned int __user *binary_data, - unsigned int size); -int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, - unsigned int __user *binary_data, - unsigned int size); - /* * DSP Architectures. */ static inline void sof_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack, u32 stack_words) { - if (sof_arch_ops(sdev)->dsp_stack) sof_arch_ops(sdev)->dsp_stack(sdev, oops, stack, stack_words); } diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index b8701d3407ad..1ae06a1f9b0b 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -13,6 +13,7 @@ #include #include #include "sof-priv.h" +#include "sof-audio.h" #include "ops.h" #define COMP_ID_UNASSIGNED 0xffffffff @@ -53,7 +54,8 @@ struct sof_widget_data { static int ipc_pcm_params(struct snd_sof_widget *swidget, int dir) { struct sof_ipc_pcm_params_reply ipc_params_reply; - struct snd_sof_dev *sdev = swidget->sdev; + struct snd_soc_component *scomp = swidget->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct sof_ipc_pcm_params pcm; struct snd_pcm_hw_params *params; struct snd_sof_pcm *spcm; @@ -62,9 +64,9 @@ static int ipc_pcm_params(struct snd_sof_widget *swidget, int dir) memset(&pcm, 0, sizeof(pcm)); /* get runtime PCM params using widget's stream name */ - spcm = snd_sof_find_spcm_name(sdev, swidget->widget->sname); + spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); if (!spcm) { - dev_err(sdev->dev, "error: cannot find PCM for %s\n", + dev_err(scomp->dev, "error: cannot find PCM for %s\n", swidget->widget->name); return -EINVAL; } @@ -102,7 +104,7 @@ static int ipc_pcm_params(struct snd_sof_widget *swidget, int dir) ret = sof_ipc_tx_message(sdev->ipc, pcm.hdr.cmd, &pcm, sizeof(pcm), &ipc_params_reply, sizeof(ipc_params_reply)); if (ret < 0) - dev_err(sdev->dev, "error: pcm params failed for %s\n", + dev_err(scomp->dev, "error: pcm params failed for %s\n", swidget->widget->name); return ret; @@ -111,7 +113,8 @@ static int ipc_pcm_params(struct snd_sof_widget *swidget, int dir) /* send stream trigger ipc */ static int ipc_trigger(struct snd_sof_widget *swidget, int cmd) { - struct snd_sof_dev *sdev = swidget->sdev; + struct snd_soc_component *scomp = swidget->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct sof_ipc_stream stream; struct sof_ipc_reply reply; int ret = 0; @@ -125,7 +128,7 @@ static int ipc_trigger(struct snd_sof_widget *swidget, int cmd) ret = sof_ipc_tx_message(sdev->ipc, stream.hdr.cmd, &stream, sizeof(stream), &reply, sizeof(reply)); if (ret < 0) - dev_err(sdev->dev, "error: failed to trigger %s\n", + dev_err(scomp->dev, "error: failed to trigger %s\n", swidget->widget->name); return ret; @@ -135,23 +138,23 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { struct snd_sof_widget *swidget = w->dobj.private; + struct snd_soc_component *scomp; int stream = SNDRV_PCM_STREAM_CAPTURE; - struct snd_sof_dev *sdev; struct snd_sof_pcm *spcm; int ret = 0; if (!swidget) return 0; - sdev = swidget->sdev; + scomp = swidget->scomp; - dev_dbg(sdev->dev, "received event %d for widget %s\n", + dev_dbg(scomp->dev, "received event %d for widget %s\n", event, w->name); /* get runtime PCM params using widget's stream name */ - spcm = snd_sof_find_spcm_name(sdev, swidget->widget->sname); + spcm = snd_sof_find_spcm_name(scomp, swidget->widget->sname); if (!spcm) { - dev_err(sdev->dev, "error: cannot find PCM for %s\n", + dev_err(scomp->dev, "error: cannot find PCM for %s\n", swidget->widget->name); return -EINVAL; } @@ -160,14 +163,14 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: if (spcm->stream[stream].suspend_ignored) { - dev_dbg(sdev->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n"); + dev_dbg(scomp->dev, "PRE_PMU event ignored, KWD pipeline is already RUNNING\n"); return 0; } /* set pcm params */ ret = ipc_pcm_params(swidget, stream); if (ret < 0) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: failed to set pcm params for widget %s\n", swidget->widget->name); break; @@ -176,27 +179,27 @@ static int sof_keyword_dapm_event(struct snd_soc_dapm_widget *w, /* start trigger */ ret = ipc_trigger(swidget, SOF_IPC_STREAM_TRIG_START); if (ret < 0) - dev_err(sdev->dev, + dev_err(scomp->dev, "error: failed to trigger widget %s\n", swidget->widget->name); break; case SND_SOC_DAPM_POST_PMD: if (spcm->stream[stream].suspend_ignored) { - dev_dbg(sdev->dev, "POST_PMD even ignored, KWD pipeline will remain RUNNING\n"); + dev_dbg(scomp->dev, "POST_PMD even ignored, KWD pipeline will remain RUNNING\n"); return 0; } /* stop trigger */ ret = ipc_trigger(swidget, SOF_IPC_STREAM_TRIG_STOP); if (ret < 0) - dev_err(sdev->dev, + dev_err(scomp->dev, "error: failed to trigger widget %s\n", swidget->widget->name); /* pcm free */ ret = ipc_trigger(swidget, SOF_IPC_STREAM_PCM_FREE); if (ret < 0) - dev_err(sdev->dev, + dev_err(scomp->dev, "error: failed to trigger widget %s\n", swidget->widget->name); break; @@ -838,7 +841,7 @@ static void sof_parse_word_tokens(struct snd_soc_component *scomp, /* check if array index is valid */ if (!index || *index == 0) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: invalid array offset\n"); continue; } else { @@ -866,7 +869,6 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, struct snd_soc_tplg_vendor_array *array, int priv_size) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); int asize; while (priv_size > 0) { @@ -874,7 +876,7 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, /* validate asize */ if (asize < 0) { /* FIXME: A zero-size array makes no sense */ - dev_err(sdev->dev, "error: invalid array size 0x%x\n", + dev_err(scomp->dev, "error: invalid array size 0x%x\n", asize); return -EINVAL; } @@ -882,7 +884,7 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, /* make sure there is enough data before parsing */ priv_size -= asize; if (priv_size < 0) { - dev_err(sdev->dev, "error: invalid array size 0x%x\n", + dev_err(scomp->dev, "error: invalid array size 0x%x\n", asize); return -EINVAL; } @@ -905,7 +907,7 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, array); break; default: - dev_err(sdev->dev, "error: unknown token type %d\n", + dev_err(scomp->dev, "error: unknown token type %d\n", array->type); return -EINVAL; } @@ -920,9 +922,7 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, static void sof_dbg_comp_config(struct snd_soc_component *scomp, struct sof_ipc_comp_config *config) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); - - dev_dbg(sdev->dev, " config: periods snk %d src %d fmt %d\n", + dev_dbg(scomp->dev, " config: periods snk %d src %d fmt %d\n", config->periods_sink, config->periods_source, config->frame_fmt); } @@ -974,7 +974,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, /* extract tlv data */ if (get_tlv_data(kc->tlv.p, tlv) < 0) { - dev_err(sdev->dev, "error: invalid TLV data\n"); + dev_err(scomp->dev, "error: invalid TLV data\n"); ret = -EINVAL; goto out_free; } @@ -982,7 +982,7 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, /* set up volume table */ ret = set_up_volume_table(scontrol, tlv, le32_to_cpu(mc->max) + 1); if (ret < 0) { - dev_err(sdev->dev, "error: setting up volume table\n"); + dev_err(scomp->dev, "error: setting up volume table\n"); goto out_free; } @@ -999,12 +999,12 @@ skip: ARRAY_SIZE(led_tokens), mc->priv.array, le32_to_cpu(mc->priv.size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse led tokens failed %d\n", + dev_err(scomp->dev, "error: parse led tokens failed %d\n", le32_to_cpu(mc->priv.size)); goto out_free_table; } - dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d\n", + dev_dbg(scomp->dev, "tplg: load kcontrol index %d chans %d\n", scontrol->comp_id, scontrol->num_channels); return ret; @@ -1043,7 +1043,7 @@ static int sof_control_load_enum(struct snd_soc_component *scomp, scontrol->cmd = SOF_CTRL_CMD_ENUM; - dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d comp_id %d\n", + dev_dbg(scomp->dev, "tplg: load kcontrol index %d chans %d comp_id %d\n", scontrol->comp_id, scontrol->num_channels, scontrol->comp_id); return 0; @@ -1067,7 +1067,7 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp, le32_to_cpu(control->priv.size); if (scontrol->size > max_size) { - dev_err(sdev->dev, "err: bytes data size %d exceeds max %d.\n", + dev_err(scomp->dev, "err: bytes data size %d exceeds max %d.\n", scontrol->size, max_size); ret = -EINVAL; goto out; @@ -1083,7 +1083,7 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp, scontrol->comp_id = sdev->next_comp_id; scontrol->cmd = SOF_CTRL_CMD_BINARY; - dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d\n", + dev_dbg(scomp->dev, "tplg: load kcontrol index %d chans %d\n", scontrol->comp_id, scontrol->num_channels); if (le32_to_cpu(control->priv.size) > 0) { @@ -1091,14 +1091,14 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp, le32_to_cpu(control->priv.size)); if (cdata->data->magic != SOF_ABI_MAGIC) { - dev_err(sdev->dev, "error: Wrong ABI magic 0x%08x.\n", + dev_err(scomp->dev, "error: Wrong ABI magic 0x%08x.\n", cdata->data->magic); ret = -EINVAL; goto out_free; } if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi)) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: Incompatible ABI version 0x%08x.\n", cdata->data->abi); ret = -EINVAL; @@ -1106,7 +1106,7 @@ static int sof_control_load_bytes(struct snd_soc_component *scomp, } if (cdata->data->size + sizeof(const struct sof_abi_hdr) != le32_to_cpu(control->priv.size)) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: Conflict in bytes vs. priv size.\n"); ret = -EINVAL; goto out_free; @@ -1134,14 +1134,14 @@ static int sof_control_load(struct snd_soc_component *scomp, int index, struct snd_sof_control *scontrol; int ret = -EINVAL; - dev_dbg(sdev->dev, "tplg: load control type %d name : %s\n", + dev_dbg(scomp->dev, "tplg: load control type %d name : %s\n", hdr->type, hdr->name); scontrol = kzalloc(sizeof(*scontrol), GFP_KERNEL); if (!scontrol) return -ENOMEM; - scontrol->sdev = sdev; + scontrol->scomp = scomp; switch (le32_to_cpu(hdr->ops.info)) { case SND_SOC_TPLG_CTL_VOLSW: @@ -1170,7 +1170,7 @@ static int sof_control_load(struct snd_soc_component *scomp, int index, case SND_SOC_TPLG_DAPM_CTL_ENUM_VALUE: case SND_SOC_TPLG_DAPM_CTL_PIN: default: - dev_warn(sdev->dev, "control type not supported %d:%d:%d\n", + dev_warn(scomp->dev, "control type not supported %d:%d:%d\n", hdr->ops.get, hdr->ops.put, hdr->ops.info); kfree(scontrol); return 0; @@ -1193,7 +1193,7 @@ static int sof_control_unload(struct snd_soc_component *scomp, struct sof_ipc_free fcomp; struct snd_sof_control *scontrol = dobj->private; - dev_dbg(sdev->dev, "tplg: unload control name : %s\n", scomp->name); + dev_dbg(scomp->dev, "tplg: unload control name : %s\n", scomp->name); fcomp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_FREE; fcomp.hdr.size = sizeof(fcomp); @@ -1217,12 +1217,11 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp, struct snd_soc_tplg_dapm_widget *tw, struct snd_sof_dai *dai) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_card *card = scomp->card; struct snd_soc_pcm_runtime *rtd; list_for_each_entry(rtd, &card->rtd_list, list) { - dev_vdbg(sdev->dev, "tplg: check widget: %s stream: %s dai stream: %s\n", + dev_vdbg(scomp->dev, "tplg: check widget: %s stream: %s dai stream: %s\n", w->name, w->sname, rtd->dai_link->stream_name); if (!w->sname || !rtd->dai_link->stream_name) @@ -1236,13 +1235,13 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp, case snd_soc_dapm_dai_out: rtd->cpu_dai->capture_widget = w; dai->name = rtd->dai_link->name; - dev_dbg(sdev->dev, "tplg: connected widget %s -> DAI link %s\n", + dev_dbg(scomp->dev, "tplg: connected widget %s -> DAI link %s\n", w->name, rtd->dai_link->name); break; case snd_soc_dapm_dai_in: rtd->cpu_dai->playback_widget = w; dai->name = rtd->dai_link->name; - dev_dbg(sdev->dev, "tplg: connected widget %s -> DAI link %s\n", + dev_dbg(scomp->dev, "tplg: connected widget %s -> DAI link %s\n", w->name, rtd->dai_link->name); break; default: @@ -1252,7 +1251,7 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp, /* check we have a connection */ if (!dai->name) { - dev_err(sdev->dev, "error: can't connect DAI %s stream %s\n", + dev_err(scomp->dev, "error: can't connect DAI %s stream %s\n", w->name, w->sname); return -EINVAL; } @@ -1284,7 +1283,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, ARRAY_SIZE(dai_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse dai tokens failed %d\n", + dev_err(scomp->dev, "error: parse dai tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -1293,12 +1292,12 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse dai.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse dai.cfg tokens failed %d\n", private->size); return ret; } - dev_dbg(sdev->dev, "dai %s: type %d index %d\n", + dev_dbg(scomp->dev, "dai %s: type %d index %d\n", swidget->widget->name, comp_dai.type, comp_dai.dai_index); sof_dbg_comp_config(scomp, &comp_dai.config); @@ -1306,7 +1305,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, &comp_dai, sizeof(comp_dai), r, sizeof(*r)); if (ret == 0 && dai) { - dai->sdev = sdev; + dai->scomp = scomp; memcpy(&dai->comp_dai, &comp_dai, sizeof(comp_dai)); } @@ -1342,13 +1341,13 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index, ARRAY_SIZE(buffer_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse buffer tokens failed %d\n", + dev_err(scomp->dev, "error: parse buffer tokens failed %d\n", private->size); kfree(buffer); return ret; } - dev_dbg(sdev->dev, "buffer %s: size %d caps 0x%x\n", + dev_dbg(scomp->dev, "buffer %s: size %d caps 0x%x\n", swidget->widget->name, buffer->size, buffer->caps); swidget->private = buffer; @@ -1356,7 +1355,7 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index, ret = sof_ipc_tx_message(sdev->ipc, buffer->comp.hdr.cmd, buffer, sizeof(*buffer), r, sizeof(*r)); if (ret < 0) { - dev_err(sdev->dev, "error: buffer %s load failed\n", + dev_err(scomp->dev, "error: buffer %s load failed\n", swidget->widget->name); kfree(buffer); } @@ -1365,16 +1364,16 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index, } /* bind PCM ID to host component ID */ -static int spcm_bind(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, +static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm, int dir) { struct snd_sof_widget *host_widget; - host_widget = snd_sof_find_swidget_sname(sdev, + host_widget = snd_sof_find_swidget_sname(scomp, spcm->pcm.caps[dir].name, dir); if (!host_widget) { - dev_err(sdev->dev, "can't find host comp to bind pcm\n"); + dev_err(scomp->dev, "can't find host comp to bind pcm\n"); return -EINVAL; } @@ -1415,7 +1414,7 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index, ARRAY_SIZE(pcm_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse host tokens failed %d\n", + dev_err(scomp->dev, "error: parse host tokens failed %d\n", private->size); goto err; } @@ -1424,12 +1423,12 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse host.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse host.cfg tokens failed %d\n", le32_to_cpu(private->size)); goto err; } - dev_dbg(sdev->dev, "loaded host %s\n", swidget->widget->name); + dev_dbg(scomp->dev, "loaded host %s\n", swidget->widget->name); sof_dbg_comp_config(scomp, &host->config); swidget->private = host; @@ -1446,24 +1445,25 @@ err: /* * Pipeline Topology */ -int sof_load_pipeline_ipc(struct snd_sof_dev *sdev, +int sof_load_pipeline_ipc(struct device *dev, struct sof_ipc_pipe_new *pipeline, struct sof_ipc_comp_reply *r) { + struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct sof_ipc_pm_core_config pm_core_config; int ret; ret = sof_ipc_tx_message(sdev->ipc, pipeline->hdr.cmd, pipeline, sizeof(*pipeline), r, sizeof(*r)); if (ret < 0) { - dev_err(sdev->dev, "error: load pipeline ipc failure\n"); + dev_err(dev, "error: load pipeline ipc failure\n"); return ret; } /* power up the core that this pipeline is scheduled on */ ret = snd_sof_dsp_core_power_up(sdev, 1 << pipeline->core); if (ret < 0) { - dev_err(sdev->dev, "error: powering up pipeline schedule core %d\n", + dev_err(dev, "error: powering up pipeline schedule core %d\n", pipeline->core); return ret; } @@ -1487,7 +1487,7 @@ int sof_load_pipeline_ipc(struct snd_sof_dev *sdev, &pm_core_config, sizeof(pm_core_config), &pm_core_config, sizeof(pm_core_config)); if (ret < 0) - dev_err(sdev->dev, "error: core enable ipc failure\n"); + dev_err(dev, "error: core enable ipc failure\n"); return ret; } @@ -1497,7 +1497,6 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, struct snd_soc_tplg_dapm_widget *tw, struct sof_ipc_comp_reply *r) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_pipe_new *pipeline; struct snd_sof_widget *comp_swidget; @@ -1514,9 +1513,9 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, pipeline->comp_id = swidget->comp_id; /* component at start of pipeline is our stream id */ - comp_swidget = snd_sof_find_swidget(sdev, tw->sname); + comp_swidget = snd_sof_find_swidget(scomp, tw->sname); if (!comp_swidget) { - dev_err(sdev->dev, "error: widget %s refers to non existent widget %s\n", + dev_err(scomp->dev, "error: widget %s refers to non existent widget %s\n", tw->name, tw->sname); ret = -EINVAL; goto err; @@ -1524,26 +1523,26 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, pipeline->sched_id = comp_swidget->comp_id; - dev_dbg(sdev->dev, "tplg: pipeline id %d comp %d scheduling comp id %d\n", + dev_dbg(scomp->dev, "tplg: pipeline id %d comp %d scheduling comp id %d\n", pipeline->pipeline_id, pipeline->comp_id, pipeline->sched_id); ret = sof_parse_tokens(scomp, pipeline, sched_tokens, ARRAY_SIZE(sched_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse pipeline tokens failed %d\n", + dev_err(scomp->dev, "error: parse pipeline tokens failed %d\n", private->size); goto err; } - dev_dbg(sdev->dev, "pipeline %s: period %d pri %d mips %d core %d frames %d\n", + dev_dbg(scomp->dev, "pipeline %s: period %d pri %d mips %d core %d frames %d\n", swidget->widget->name, pipeline->period, pipeline->priority, pipeline->period_mips, pipeline->core, pipeline->frames_per_sched); swidget->private = pipeline; /* send ipc's to create pipeline comp and power up schedule core */ - ret = sof_load_pipeline_ipc(sdev, pipeline, r); + ret = sof_load_pipeline_ipc(scomp->dev, pipeline, r); if (ret >= 0) return ret; err: @@ -1581,7 +1580,7 @@ static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse mixer.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse mixer.cfg tokens failed %d\n", private->size); kfree(mixer); return ret; @@ -1628,7 +1627,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse mux.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse mux.cfg tokens failed %d\n", private->size); kfree(mux); return ret; @@ -1668,7 +1667,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, return -ENOMEM; if (!le32_to_cpu(tw->num_kcontrols)) { - dev_err(sdev->dev, "error: invalid kcontrol count %d for volume\n", + dev_err(scomp->dev, "error: invalid kcontrol count %d for volume\n", tw->num_kcontrols); ret = -EINVAL; goto err; @@ -1686,7 +1685,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, ARRAY_SIZE(volume_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse volume tokens failed %d\n", + dev_err(scomp->dev, "error: parse volume tokens failed %d\n", private->size); goto err; } @@ -1694,7 +1693,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse volume.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse volume.cfg tokens failed %d\n", le32_to_cpu(private->size)); goto err; } @@ -1754,7 +1753,7 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index, ARRAY_SIZE(src_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse src tokens failed %d\n", + dev_err(scomp->dev, "error: parse src tokens failed %d\n", private->size); goto err; } @@ -1763,12 +1762,12 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse src.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse src.cfg tokens failed %d\n", le32_to_cpu(private->size)); goto err; } - dev_dbg(sdev->dev, "src %s: source rate %d sink rate %d\n", + dev_dbg(scomp->dev, "src %s: source rate %d sink rate %d\n", swidget->widget->name, src->source_rate, src->sink_rate); sof_dbg_comp_config(scomp, &src->config); @@ -1813,7 +1812,7 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index, ARRAY_SIZE(tone_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse tone tokens failed %d\n", + dev_err(scomp->dev, "error: parse tone tokens failed %d\n", le32_to_cpu(private->size)); goto err; } @@ -1822,12 +1821,12 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse tone.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse tone.cfg tokens failed %d\n", le32_to_cpu(private->size)); goto err; } - dev_dbg(sdev->dev, "tone %s: frequency %d amplitude %d\n", + dev_dbg(scomp->dev, "tone %s: frequency %d amplitude %d\n", swidget->widget->name, tone->frequency, tone->amplitude); sof_dbg_comp_config(scomp, &tone->config); @@ -1842,7 +1841,7 @@ err: return ret; } -static int sof_get_control_data(struct snd_sof_dev *sdev, +static int sof_get_control_data(struct snd_soc_component *scomp, struct snd_soc_dapm_widget *widget, struct sof_widget_data *wdata, size_t *size) @@ -1872,14 +1871,14 @@ static int sof_get_control_data(struct snd_sof_dev *sdev, wdata[i].control = se->dobj.private; break; default: - dev_err(sdev->dev, "error: unknown kcontrol type %d in widget %s\n", + dev_err(scomp->dev, "error: unknown kcontrol type %d in widget %s\n", widget->dobj.widget.kcontrol_type, widget->name); return -EINVAL; } if (!wdata[i].control) { - dev_err(sdev->dev, "error: no scontrol for widget %s\n", + dev_err(scomp->dev, "error: no scontrol for widget %s\n", widget->name); return -EINVAL; } @@ -1932,7 +1931,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, int i; if (type == SOF_COMP_NONE) { - dev_err(sdev->dev, "error: invalid process comp type %d\n", + dev_err(scomp->dev, "error: invalid process comp type %d\n", type); return -EINVAL; } @@ -1947,7 +1946,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, return -ENOMEM; /* get possible component controls and get size of all pdata */ - ret = sof_get_control_data(sdev, widget, wdata, + ret = sof_get_control_data(scomp, widget, wdata, &ipc_data_size); if (ret < 0) @@ -1982,7 +1981,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(comp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse process.cfg tokens failed %d\n", + dev_err(scomp->dev, "error: parse process.cfg tokens failed %d\n", le32_to_cpu(private->size)); goto err; } @@ -2010,7 +2009,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, ipc_size, r, sizeof(*r)); if (ret < 0) { - dev_err(sdev->dev, "error: create process failed\n"); + dev_err(scomp->dev, "error: create process failed\n"); goto err; } @@ -2021,13 +2020,13 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, /* send control data with large message supported method */ for (i = 0; i < widget->num_kcontrols; i++) { wdata[i].control->readback_offset = 0; - ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, wdata[i].control, + ret = snd_sof_ipc_set_get_comp_data(wdata[i].control, wdata[i].ipc_cmd, wdata[i].ctrl_type, wdata[i].control->cmd, true); if (ret != 0) { - dev_err(sdev->dev, "error: send control failed\n"); + dev_err(scomp->dev, "error: send control failed\n"); break; } } @@ -2050,14 +2049,13 @@ static int sof_widget_load_process(struct snd_soc_component *scomp, int index, struct snd_soc_tplg_dapm_widget *tw, struct sof_ipc_comp_reply *r) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_process config; int ret; /* check we have some tokens - we need at least process type */ if (le32_to_cpu(private->size) == 0) { - dev_err(sdev->dev, "error: process tokens not found\n"); + dev_err(scomp->dev, "error: process tokens not found\n"); return -EINVAL; } @@ -2068,7 +2066,7 @@ static int sof_widget_load_process(struct snd_soc_component *scomp, int index, ARRAY_SIZE(process_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse process tokens failed %d\n", + dev_err(scomp->dev, "error: parse process tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -2077,14 +2075,14 @@ static int sof_widget_load_process(struct snd_soc_component *scomp, int index, ret = sof_process_load(scomp, index, swidget, tw, r, find_process_comp_type(config.type)); if (ret < 0) { - dev_err(sdev->dev, "error: process loading failed\n"); + dev_err(scomp->dev, "error: process loading failed\n"); return ret; } return 0; } -static int sof_widget_bind_event(struct snd_sof_dev *sdev, +static int sof_widget_bind_event(struct snd_soc_component *scomp, struct snd_sof_widget *swidget, u16 event_type) { @@ -2110,7 +2108,7 @@ static int sof_widget_bind_event(struct snd_sof_dev *sdev, break; } - dev_err(sdev->dev, + dev_err(scomp->dev, "error: invalid event type %d for widget %s\n", event_type, swidget->widget->name); return -EINVAL; @@ -2132,7 +2130,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, if (!swidget) return -ENOMEM; - swidget->sdev = sdev; + swidget->scomp = scomp; swidget->widget = w; swidget->comp_id = sdev->next_comp_id++; swidget->complete = 0; @@ -2141,7 +2139,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, swidget->private = NULL; memset(&reply, 0, sizeof(reply)); - dev_dbg(sdev->dev, "tplg: ready widget id %d pipe %d type %d name : %s stream %s\n", + dev_dbg(scomp->dev, "tplg: ready widget id %d pipe %d type %d name : %s stream %s\n", swidget->comp_id, index, swidget->id, tw->name, strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0 ? tw->sname : "none"); @@ -2212,14 +2210,14 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, case snd_soc_dapm_dai_link: case snd_soc_dapm_kcontrol: default: - dev_warn(sdev->dev, "warning: widget type %d name %s not handled\n", + dev_warn(scomp->dev, "warning: widget type %d name %s not handled\n", swidget->id, tw->name); break; } /* check IPC reply */ if (ret < 0 || reply.rhdr.error < 0) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: DSP failed to add widget id %d type %d name : %s stream %s reply %d\n", tw->shift, swidget->id, tw->name, strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0 @@ -2230,10 +2228,10 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, /* bind widget to external event */ if (tw->event_type) { - ret = sof_widget_bind_event(sdev, swidget, + ret = sof_widget_bind_event(scomp, swidget, le16_to_cpu(tw->event_type)); if (ret) { - dev_err(sdev->dev, "error: widget event binding failed\n"); + dev_err(scomp->dev, "error: widget event binding failed\n"); kfree(swidget->private); kfree(swidget); return ret; @@ -2301,7 +2299,7 @@ static int sof_widget_unload(struct snd_soc_component *scomp, pipeline = swidget->private; ret = snd_sof_dsp_core_power_down(sdev, 1 << pipeline->core); if (ret < 0) - dev_err(sdev->dev, "error: powering down pipeline schedule core %d\n", + dev_err(scomp->dev, "error: powering down pipeline schedule core %d\n", pipeline->core); /* update enabled cores mask */ @@ -2329,7 +2327,7 @@ static int sof_widget_unload(struct snd_soc_component *scomp, scontrol = sbe->dobj.private; break; default: - dev_warn(sdev->dev, "unsupported kcontrol_type\n"); + dev_warn(scomp->dev, "unsupported kcontrol_type\n"); goto out; } kfree(scontrol->control_data); @@ -2372,12 +2370,12 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index, if (!spcm) return -ENOMEM; - spcm->sdev = sdev; + spcm->scomp = scomp; spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].comp_id = COMP_ID_UNASSIGNED; spcm->stream[SNDRV_PCM_STREAM_CAPTURE].comp_id = COMP_ID_UNASSIGNED; spcm->pcm = *pcm; - dev_dbg(sdev->dev, "tplg: load pcm %s\n", pcm->dai_name); + dev_dbg(scomp->dev, "tplg: load pcm %s\n", pcm->dai_name); dai_drv->dobj.private = spcm; list_add(&spcm->list, &sdev->pcm_list); @@ -2386,7 +2384,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(stream_tokens), private->array, le32_to_cpu(private->size)); if (ret) { - dev_err(sdev->dev, "error: parse stream tokens failed %d\n", + dev_err(scomp->dev, "error: parse stream tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -2395,7 +2393,7 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index, if (!spcm->pcm.playback) goto capture; - dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: playback d0i3:%d\n", + dev_vdbg(scomp->dev, "tplg: pcm %s stream tokens: playback d0i3:%d\n", spcm->pcm.pcm_name, spcm->stream[0].d0i3_compatible); caps = &spcm->pcm.caps[stream]; @@ -2404,16 +2402,16 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index, ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, sdev->dev, PAGE_SIZE, &spcm->stream[stream].page_table); if (ret < 0) { - dev_err(sdev->dev, "error: can't alloc page table for %s %d\n", + dev_err(scomp->dev, "error: can't alloc page table for %s %d\n", caps->name, ret); return ret; } /* bind pcm to host comp */ - ret = spcm_bind(sdev, spcm, stream); + ret = spcm_bind(scomp, spcm, stream); if (ret) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: can't bind pcm to host\n"); goto free_playback_tables; } @@ -2425,7 +2423,7 @@ capture: if (!spcm->pcm.capture) return ret; - dev_vdbg(sdev->dev, "tplg: pcm %s stream tokens: capture d0i3:%d\n", + dev_vdbg(scomp->dev, "tplg: pcm %s stream tokens: capture d0i3:%d\n", spcm->pcm.pcm_name, spcm->stream[1].d0i3_compatible); caps = &spcm->pcm.caps[stream]; @@ -2434,15 +2432,15 @@ capture: ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, sdev->dev, PAGE_SIZE, &spcm->stream[stream].page_table); if (ret < 0) { - dev_err(sdev->dev, "error: can't alloc page table for %s %d\n", + dev_err(scomp->dev, "error: can't alloc page table for %s %d\n", caps->name, ret); goto free_playback_tables; } /* bind pcm to host comp */ - ret = spcm_bind(sdev, spcm, stream); + ret = spcm_bind(scomp, spcm, stream); if (ret) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: can't bind pcm to host\n"); snd_dma_free_pages(&spcm->stream[stream].page_table); goto free_playback_tables; @@ -2568,7 +2566,7 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(ssp_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse ssp tokens failed %d\n", + dev_err(scomp->dev, "error: parse ssp tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -2582,7 +2580,7 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, config->ssp.rx_slots = le32_to_cpu(hw_config->rx_slots); config->ssp.tx_slots = le32_to_cpu(hw_config->tx_slots); - dev_dbg(sdev->dev, "tplg: config SSP%d fmt 0x%x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk id %d quirks %d\n", + dev_dbg(scomp->dev, "tplg: config SSP%d fmt 0x%x mclk %d bclk %d fclk %d width (%d)%d slots %d mclk id %d quirks %d\n", config->dai_index, config->format, config->ssp.mclk_rate, config->ssp.bclk_rate, config->ssp.fsync_rate, config->ssp.sample_valid_bits, @@ -2591,13 +2589,13 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, /* validate SSP fsync rate and channel count */ if (config->ssp.fsync_rate < 8000 || config->ssp.fsync_rate > 192000) { - dev_err(sdev->dev, "error: invalid fsync rate for SSP%d\n", + dev_err(scomp->dev, "error: invalid fsync rate for SSP%d\n", config->dai_index); return -EINVAL; } if (config->ssp.tdm_slots < 1 || config->ssp.tdm_slots > 8) { - dev_err(sdev->dev, "error: invalid channel count for SSP%d\n", + dev_err(scomp->dev, "error: invalid channel count for SSP%d\n", config->dai_index); return -EINVAL; } @@ -2608,7 +2606,7 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, sizeof(reply)); if (ret < 0) { - dev_err(sdev->dev, "error: failed to set DAI config for SSP%d\n", + dev_err(scomp->dev, "error: failed to set DAI config for SSP%d\n", config->dai_index); return ret; } @@ -2616,7 +2614,7 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) - dev_err(sdev->dev, "error: failed to save DAI config for SSP%d\n", + dev_err(scomp->dev, "error: failed to save DAI config for SSP%d\n", config->dai_index); return ret; @@ -2655,7 +2653,7 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(esai_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse esai tokens failed %d\n", + dev_err(scomp->dev, "error: parse esai tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -2669,14 +2667,14 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, config->esai.rx_slots = le32_to_cpu(hw_config->rx_slots); config->esai.tx_slots = le32_to_cpu(hw_config->tx_slots); - dev_info(sdev->dev, + dev_info(scomp->dev, "tplg: config ESAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n", config->dai_index, config->format, config->esai.mclk_rate, config->esai.tdm_slot_width, config->esai.tdm_slots, config->esai.mclk_id); if (config->esai.tdm_slots < 1 || config->esai.tdm_slots > 8) { - dev_err(sdev->dev, "error: invalid channel count for ESAI%d\n", + dev_err(scomp->dev, "error: invalid channel count for ESAI%d\n", config->dai_index); return -EINVAL; } @@ -2686,7 +2684,7 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, config->hdr.cmd, config, size, &reply, sizeof(reply)); if (ret < 0) { - dev_err(sdev->dev, "error: failed to set DAI config for ESAI%d\n", + dev_err(scomp->dev, "error: failed to set DAI config for ESAI%d\n", config->dai_index); return ret; } @@ -2694,7 +2692,7 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) - dev_err(sdev->dev, "error: failed to save DAI config for ESAI%d\n", + dev_err(scomp->dev, "error: failed to save DAI config for ESAI%d\n", config->dai_index); return ret; @@ -2727,7 +2725,7 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(dmic_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse dmic tokens failed %d\n", + dev_err(scomp->dev, "error: parse dmic tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -2762,7 +2760,7 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(dmic_pdm_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse dmic pdm tokens failed %d\n", + dev_err(scomp->dev, "error: parse dmic pdm tokens failed %d\n", le32_to_cpu(private->size)); goto err; } @@ -2771,27 +2769,27 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, ipc_config->hdr.size = size; /* debug messages */ - dev_dbg(sdev->dev, "tplg: config DMIC%d driver version %d\n", + dev_dbg(scomp->dev, "tplg: config DMIC%d driver version %d\n", ipc_config->dai_index, ipc_config->dmic.driver_ipc_version); - dev_dbg(sdev->dev, "pdmclk_min %d pdm_clkmax %d duty_min %hd\n", + dev_dbg(scomp->dev, "pdmclk_min %d pdm_clkmax %d duty_min %hd\n", ipc_config->dmic.pdmclk_min, ipc_config->dmic.pdmclk_max, ipc_config->dmic.duty_min); - dev_dbg(sdev->dev, "duty_max %hd fifo_fs %d num_pdms active %d\n", + dev_dbg(scomp->dev, "duty_max %hd fifo_fs %d num_pdms active %d\n", ipc_config->dmic.duty_max, ipc_config->dmic.fifo_fs, ipc_config->dmic.num_pdm_active); - dev_dbg(sdev->dev, "fifo word length %hd\n", + dev_dbg(scomp->dev, "fifo word length %hd\n", ipc_config->dmic.fifo_bits); for (j = 0; j < ipc_config->dmic.num_pdm_active; j++) { - dev_dbg(sdev->dev, "pdm %hd mic a %hd mic b %hd\n", + dev_dbg(scomp->dev, "pdm %hd mic a %hd mic b %hd\n", ipc_config->dmic.pdm[j].id, ipc_config->dmic.pdm[j].enable_mic_a, ipc_config->dmic.pdm[j].enable_mic_b); - dev_dbg(sdev->dev, "pdm %hd polarity a %hd polarity b %hd\n", + dev_dbg(scomp->dev, "pdm %hd polarity a %hd polarity b %hd\n", ipc_config->dmic.pdm[j].id, ipc_config->dmic.pdm[j].polarity_mic_a, ipc_config->dmic.pdm[j].polarity_mic_b); - dev_dbg(sdev->dev, "pdm %hd clk_edge %hd skew %hd\n", + dev_dbg(scomp->dev, "pdm %hd clk_edge %hd skew %hd\n", ipc_config->dmic.pdm[j].id, ipc_config->dmic.pdm[j].clk_edge, ipc_config->dmic.pdm[j].skew); @@ -2808,7 +2806,7 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, sizeof(reply)); if (ret < 0) { - dev_err(sdev->dev, + dev_err(scomp->dev, "error: failed to set DAI config for DMIC%d\n", config->dai_index); goto err; @@ -2817,7 +2815,7 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, ipc_config); if (ret < 0) - dev_err(sdev->dev, "error: failed to save DAI config for DMIC%d\n", + dev_err(scomp->dev, "error: failed to save DAI config for DMIC%d\n", config->dai_index); err: @@ -2908,21 +2906,21 @@ static int sof_link_hda_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(hda_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse hda tokens failed %d\n", + dev_err(scomp->dev, "error: parse hda tokens failed %d\n", le32_to_cpu(private->size)); return ret; } dai = snd_soc_find_dai(link->cpus); if (!dai) { - dev_err(sdev->dev, "error: failed to find dai %s in %s", + dev_err(scomp->dev, "error: failed to find dai %s in %s", link->cpus->dai_name, __func__); return -EINVAL; } ret = sof_link_hda_process(sdev, link, config); if (ret < 0) - dev_err(sdev->dev, "error: failed to process hda dai link %s", + dev_err(scomp->dev, "error: failed to process hda dai link %s", link->name); return ret; @@ -2948,7 +2946,7 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, sizeof(reply)); if (ret < 0) { - dev_err(sdev->dev, "error: failed to set DAI config for ALH %d\n", + dev_err(scomp->dev, "error: failed to set DAI config for ALH %d\n", config->dai_index); return ret; } @@ -2956,7 +2954,7 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, /* set config for all DAI's with name matching the link name */ ret = sof_set_dai_config(sdev, size, link, config); if (ret < 0) - dev_err(sdev->dev, "error: failed to save DAI config for ALH %d\n", + dev_err(scomp->dev, "error: failed to save DAI config for ALH %d\n", config->dai_index); return ret; @@ -2967,7 +2965,6 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &cfg->priv; struct sof_ipc_dai_config config; struct snd_soc_tplg_hw_config *hw_config; @@ -2976,10 +2973,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, int i = 0; if (!link->platforms) { - dev_err(sdev->dev, "error: no platforms\n"); + dev_err(scomp->dev, "error: no platforms\n"); return -EINVAL; } - link->platforms->name = dev_name(sdev->dev); + link->platforms->name = dev_name(scomp->dev); /* * Set nonatomic property for FE dai links as their trigger action @@ -2998,7 +2995,7 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, /* check we have some tokens - we need at least DAI type */ if (le32_to_cpu(private->size) == 0) { - dev_err(sdev->dev, "error: expected tokens for DAI, none found\n"); + dev_err(scomp->dev, "error: expected tokens for DAI, none found\n"); return -EINVAL; } @@ -3010,7 +3007,7 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, ARRAY_SIZE(dai_link_tokens), private->array, le32_to_cpu(private->size)); if (ret != 0) { - dev_err(sdev->dev, "error: parse link tokens failed %d\n", + dev_err(scomp->dev, "error: parse link tokens failed %d\n", le32_to_cpu(private->size)); return ret; } @@ -3022,12 +3019,12 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, num_hw_configs = le32_to_cpu(cfg->num_hw_configs); if (!num_hw_configs) { if (config.type != SOF_DAI_INTEL_HDA) { - dev_err(sdev->dev, "error: unexpected DAI config count %d!\n", + dev_err(scomp->dev, "error: unexpected DAI config count %d!\n", le32_to_cpu(cfg->num_hw_configs)); return -EINVAL; } } else { - dev_dbg(sdev->dev, "tplg: %d hw_configs found, default id: %d!\n", + dev_dbg(scomp->dev, "tplg: %d hw_configs found, default id: %d!\n", cfg->num_hw_configs, le32_to_cpu(cfg->default_hw_config_id)); for (i = 0; i < num_hw_configs; i++) { @@ -3036,7 +3033,7 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, } if (i == num_hw_configs) { - dev_err(sdev->dev, "error: default hw_config id: %d not found!\n", + dev_err(scomp->dev, "error: default hw_config id: %d not found!\n", le32_to_cpu(cfg->default_hw_config_id)); return -EINVAL; } @@ -3075,7 +3072,8 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, &config); break; default: - dev_err(sdev->dev, "error: invalid DAI type %d\n", config.type); + dev_err(scomp->dev, "error: invalid DAI type %d\n", + config.type); ret = -EINVAL; break; } @@ -3123,7 +3121,7 @@ static int sof_link_unload(struct snd_soc_component *scomp, goto found; } - dev_err(sdev->dev, "error: failed to find dai %s in %s", + dev_err(scomp->dev, "error: failed to find dai %s in %s", link->name, __func__); return -EINVAL; found: @@ -3138,7 +3136,7 @@ found: ret = sof_link_hda_unload(sdev, link); break; default: - dev_err(sdev->dev, "error: invalid DAI type %d\n", + dev_err(scomp->dev, "error: invalid DAI type %d\n", sof_dai->dai_config->type); ret = -EINVAL; break; @@ -3164,7 +3162,7 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, if (!sroute) return -ENOMEM; - sroute->sdev = sdev; + sroute->scomp = scomp; connect = kzalloc(sizeof(*connect), GFP_KERNEL); if (!connect) { @@ -3175,14 +3173,14 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, connect->hdr.size = sizeof(*connect); connect->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT; - dev_dbg(sdev->dev, "sink %s control %s source %s\n", + dev_dbg(scomp->dev, "sink %s control %s source %s\n", route->sink, route->control ? route->control : "none", route->source); /* source component */ - source_swidget = snd_sof_find_swidget(sdev, (char *)route->source); + source_swidget = snd_sof_find_swidget(scomp, (char *)route->source); if (!source_swidget) { - dev_err(sdev->dev, "error: source %s not found\n", + dev_err(scomp->dev, "error: source %s not found\n", route->source); ret = -EINVAL; goto err; @@ -3201,9 +3199,9 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, connect->source_id = source_swidget->comp_id; /* sink component */ - sink_swidget = snd_sof_find_swidget(sdev, (char *)route->sink); + sink_swidget = snd_sof_find_swidget(scomp, (char *)route->sink); if (!sink_swidget) { - dev_err(sdev->dev, "error: sink %s not found\n", + dev_err(scomp->dev, "error: sink %s not found\n", route->sink); ret = -EINVAL; goto err; @@ -3227,7 +3225,7 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, */ if (source_swidget->id != snd_soc_dapm_buffer && sink_swidget->id != snd_soc_dapm_buffer) { - dev_dbg(sdev->dev, "warning: neither Linked source component %s nor sink component %s is of buffer type, ignoring link\n", + dev_dbg(scomp->dev, "warning: neither Linked source component %s nor sink component %s is of buffer type, ignoring link\n", route->source, route->sink); ret = 0; goto err; @@ -3239,7 +3237,7 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, /* check IPC return value */ if (ret < 0) { - dev_err(sdev->dev, "error: failed to add route sink %s control %s source %s\n", + dev_err(scomp->dev, "error: failed to add route sink %s control %s source %s\n", route->sink, route->control ? route->control : "none", route->source); @@ -3248,7 +3246,7 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, /* check IPC reply */ if (reply.error < 0) { - dev_err(sdev->dev, "error: DSP failed to add route sink %s control %s source %s result %d\n", + dev_err(scomp->dev, "error: DSP failed to add route sink %s control %s source %s result %d\n", route->sink, route->control ? route->control : "none", route->source, reply.error); @@ -3275,8 +3273,9 @@ err: /* Function to set the initial value of SOF kcontrols. * The value will be stored in scontrol->control_data */ -static int snd_sof_cache_kcontrol_val(struct snd_sof_dev *sdev) +static int snd_sof_cache_kcontrol_val(struct snd_soc_component *scomp) { + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_control *scontrol = NULL; int ipc_cmd, ctrl_type; int ret = 0; @@ -3296,33 +3295,34 @@ static int snd_sof_cache_kcontrol_val(struct snd_sof_dev *sdev) ctrl_type = SOF_CTRL_TYPE_DATA_GET; break; default: - dev_err(sdev->dev, + dev_err(scomp->dev, "error: Invalid scontrol->cmd: %d\n", scontrol->cmd); return -EINVAL; } - ret = snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol, + ret = snd_sof_ipc_set_get_comp_data(scontrol, ipc_cmd, ctrl_type, scontrol->cmd, false); if (ret < 0) { - dev_warn(sdev->dev, - "error: kcontrol value get for widget: %d\n", - scontrol->comp_id); + dev_warn(scomp->dev, + "error: kcontrol value get for widget: %d\n", + scontrol->comp_id); } } return ret; } -int snd_sof_complete_pipeline(struct snd_sof_dev *sdev, +int snd_sof_complete_pipeline(struct device *dev, struct snd_sof_widget *swidget) { + struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct sof_ipc_pipe_ready ready; struct sof_ipc_reply reply; int ret; - dev_dbg(sdev->dev, "tplg: complete pipeline %s id %d\n", + dev_dbg(dev, "tplg: complete pipeline %s id %d\n", swidget->widget->name, swidget->comp_id); memset(&ready, 0, sizeof(ready)); @@ -3352,7 +3352,7 @@ static void sof_complete(struct snd_soc_component *scomp) switch (swidget->id) { case snd_soc_dapm_scheduler: swidget->complete = - snd_sof_complete_pipeline(sdev, swidget); + snd_sof_complete_pipeline(scomp->dev, swidget); break; default: break; @@ -3362,14 +3362,13 @@ static void sof_complete(struct snd_soc_component *scomp) * cache initial values of SOF kcontrols by reading DSP value over * IPC. It may be overwritten by alsa-mixer after booting up */ - snd_sof_cache_kcontrol_val(sdev); + snd_sof_cache_kcontrol_val(scomp); } /* manifest - optional to inform component of manifest */ static int sof_manifest(struct snd_soc_component *scomp, int index, struct snd_soc_tplg_manifest *man) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); u32 size; u32 abi_version; @@ -3377,16 +3376,16 @@ static int sof_manifest(struct snd_soc_component *scomp, int index, /* backward compatible with tplg without ABI info */ if (!size) { - dev_dbg(sdev->dev, "No topology ABI info\n"); + dev_dbg(scomp->dev, "No topology ABI info\n"); return 0; } if (size != SOF_TPLG_ABI_SIZE) { - dev_err(sdev->dev, "error: invalid topology ABI size\n"); + dev_err(scomp->dev, "error: invalid topology ABI size\n"); return -EINVAL; } - dev_info(sdev->dev, + dev_info(scomp->dev, "Topology: ABI %d:%d:%d Kernel ABI %d:%d:%d\n", man->priv.data[0], man->priv.data[1], man->priv.data[2], SOF_ABI_MAJOR, SOF_ABI_MINOR, @@ -3397,15 +3396,15 @@ static int sof_manifest(struct snd_soc_component *scomp, int index, man->priv.data[2]); if (SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, abi_version)) { - dev_err(sdev->dev, "error: incompatible topology ABI version\n"); + dev_err(scomp->dev, "error: incompatible topology ABI version\n"); return -EINVAL; } if (abi_version > SOF_ABI_VERSION) { if (!IS_ENABLED(CONFIG_SND_SOC_SOF_STRICT_ABI_CHECKS)) { - dev_warn(sdev->dev, "warn: topology ABI is more recent than kernel\n"); + dev_warn(scomp->dev, "warn: topology ABI is more recent than kernel\n"); } else { - dev_err(sdev->dev, "error: topology ABI is more recent than kernel\n"); + dev_err(scomp->dev, "error: topology ABI is more recent than kernel\n"); return -EINVAL; } } @@ -3463,25 +3462,25 @@ static struct snd_soc_tplg_ops sof_tplg_ops = { .bytes_ext_ops_count = ARRAY_SIZE(sof_bytes_ext_ops), }; -int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file) +int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file) { const struct firmware *fw; int ret; - dev_dbg(sdev->dev, "loading topology:%s\n", file); + dev_dbg(scomp->dev, "loading topology:%s\n", file); - ret = request_firmware(&fw, file, sdev->dev); + ret = request_firmware(&fw, file, scomp->dev); if (ret < 0) { - dev_err(sdev->dev, "error: tplg request firmware %s failed err: %d\n", + dev_err(scomp->dev, "error: tplg request firmware %s failed err: %d\n", file, ret); return ret; } - ret = snd_soc_tplg_component_load(sdev->component, + ret = snd_soc_tplg_component_load(scomp, &sof_tplg_ops, fw, SND_SOC_TPLG_INDEX_ALL); if (ret < 0) { - dev_err(sdev->dev, "error: tplg component load failed %d\n", + dev_err(scomp->dev, "error: tplg component load failed %d\n", ret); ret = -EINVAL; } -- cgit v1.2.3 From 80acdd4f8ff763183dc1cd7f1cd31db9eaaecdc8 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:52 -0600 Subject: ASoC: SOF: intel: hda: Modify signature for hda_codec_probe_bus() The machine driver selection for HDA platforms will be consolidated and moved out of the SOF DSP probe callback. In preparation for that, modify the signature for hda_codec_probe_bus() to pass the hda_codec_use_common_hdmi as a variable while probing the HDA codecs. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-10-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-codec.c | 16 ++++++---------- sound/soc/sof/intel/hda.c | 2 +- sound/soc/sof/intel/hda.h | 3 ++- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 827f84a0722e..65761e095184 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -80,12 +80,11 @@ EXPORT_SYMBOL(hda_codec_jack_wake_enable); EXPORT_SYMBOL(hda_codec_jack_check); /* probe individual codec */ -static int hda_codec_probe(struct snd_sof_dev *sdev, int address) +static int hda_codec_probe(struct snd_sof_dev *sdev, int address, + bool hda_codec_use_common_hdmi) { #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) struct hdac_hda_priv *hda_priv; - struct snd_soc_acpi_mach_params *mach_params = NULL; - struct snd_sof_pdata *pdata = sdev->pdata; #endif struct hda_bus *hbus = sof_to_hbus(sdev); struct hdac_device *hdev; @@ -115,10 +114,6 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) if (ret < 0) return ret; - if (pdata->machine) - mach_params = (struct snd_soc_acpi_mach_params *) - &pdata->machine->mach_params; - if ((resp & 0xFFFF0000) == IDISP_VID_INTEL) hda_priv->need_display_power = true; @@ -126,7 +121,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) * if common HDMI codec driver is not used, codec load * is skipped here and hdac_hdmi is used instead */ - if ((mach_params && mach_params->common_hdmi_codec_drv) || + if (hda_codec_use_common_hdmi || (resp & 0xFFFF0000) != IDISP_VID_INTEL) { hdev->type = HDA_DEV_LEGACY; hda_codec_load_module(&hda_priv->codec); @@ -145,7 +140,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) } /* Codec initialization */ -int hda_codec_probe_bus(struct snd_sof_dev *sdev) +int hda_codec_probe_bus(struct snd_sof_dev *sdev, + bool hda_codec_use_common_hdmi) { struct hdac_bus *bus = sof_to_bus(sdev); int i, ret; @@ -156,7 +152,7 @@ int hda_codec_probe_bus(struct snd_sof_dev *sdev) if (!(bus->codec_mask & (1 << i))) continue; - ret = hda_codec_probe(sdev, i); + ret = hda_codec_probe(sdev, i, hda_codec_use_common_hdmi); if (ret < 0) { dev_err(bus->dev, "error: codec #%d probe error, ret: %d\n", i, ret); diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 98512a338748..bfdb817b3780 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -476,7 +476,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) } /* create codec instances */ - hda_codec_probe_bus(sdev); + hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi); hda_codec_i915_put(sdev); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 63df888dddb6..4a6f76572658 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -575,7 +575,8 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev); /* * HDA Codec operations. */ -int hda_codec_probe_bus(struct snd_sof_dev *sdev); +int hda_codec_probe_bus(struct snd_sof_dev *sdev, + bool hda_codec_use_common_hdmi); void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev); void hda_codec_jack_check(struct snd_sof_dev *sdev); -- cgit v1.2.3 From 285880a23d105e5d34b311b0c44061dffb07e405 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Wed, 4 Dec 2019 15:15:53 -0600 Subject: ASoC: SOF: Make creation of machine device from SOF core optional Currently, SOF probes machine drivers by creating a platform device and passing the machine description as private data. This is driven by the ACPI restrictions. Ideally, ACPI tables should contain the description for the machine driver. This is not possible because ACPI tables are frozen and used on multiple OS-es (e.g Windows). In the case of Device Tree we don't have this restriction, so we choose to probe the machine drivers by creating a DT node as is the standard ALSA way. This patch makes the probing of machine drivers from SOF core optional allowing for Device Tree platforms to decouple the SOF core from machine driver probing. Along with this, it also consolidates the machine driver selection for Intel platforms by defining optional ops for selecting the machine driver based on the ACPI match for HDA and non-HDA platforms and setting the mach params. Signed-off-by: Daniel Baluta Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-11-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/core.c | 59 +---------- sound/soc/sof/intel/apl.c | 7 ++ sound/soc/sof/intel/bdw.c | 33 +++++++ sound/soc/sof/intel/byt.c | 45 +++++++++ sound/soc/sof/intel/cnl.c | 7 ++ sound/soc/sof/intel/hda.c | 227 ++++++++++++++++++++++++------------------- sound/soc/sof/intel/hda.h | 5 + sound/soc/sof/nocodec.c | 1 - sound/soc/sof/ops.h | 34 +++++++ sound/soc/sof/sof-acpi-dev.c | 29 +----- sound/soc/sof/sof-audio.c | 80 +++++++++++++++ sound/soc/sof/sof-audio.h | 4 + sound/soc/sof/sof-of-dev.c | 22 +---- sound/soc/sof/sof-pci-dev.c | 28 +----- sound/soc/sof/sof-priv.h | 11 +++ 15 files changed, 361 insertions(+), 231 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 9832322adbec..e258f6a8e7a5 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -92,47 +92,9 @@ out: } EXPORT_SYMBOL(snd_sof_get_status); -/* - * SOF Driver enumeration. - */ -static int sof_machine_check(struct snd_sof_dev *sdev) -{ - struct snd_sof_pdata *plat_data = sdev->pdata; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) - struct snd_soc_acpi_mach *machine; - int ret; -#endif - - if (plat_data->machine) - return 0; - -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) - dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); - return -ENODEV; -#else - /* fallback to nocodec mode */ - dev_warn(sdev->dev, "No ASoC machine driver found - using nocodec\n"); - machine = devm_kzalloc(sdev->dev, sizeof(*machine), GFP_KERNEL); - if (!machine) - return -ENOMEM; - - ret = sof_nocodec_setup(sdev->dev, plat_data, machine, - plat_data->desc, plat_data->desc->ops); - if (ret < 0) - return ret; - - plat_data->machine = machine; - - return 0; -#endif -} - static int sof_probe_continue(struct snd_sof_dev *sdev) { struct snd_sof_pdata *plat_data = sdev->pdata; - const char *drv_name; - const void *mach; - int size; int ret; /* probe the DSP hardware */ @@ -218,22 +180,9 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) goto fw_run_err; } - drv_name = plat_data->machine->drv_name; - mach = (const void *)plat_data->machine; - size = sizeof(*plat_data->machine); - - /* register machine driver, pass machine info as pdata */ - plat_data->pdev_mach = - platform_device_register_data(sdev->dev, drv_name, - PLATFORM_DEVID_NONE, mach, size); - - if (IS_ERR(plat_data->pdev_mach)) { - ret = PTR_ERR(plat_data->pdev_mach); + ret = snd_sof_machine_register(sdev, plat_data); + if (ret < 0) goto fw_run_err; - } - - dev_dbg(sdev->dev, "created machine %s\n", - dev_name(&plat_data->pdev_mach->dev)); /* * Some platforms in SOF, ex: BYT, may not have their platform PM @@ -363,9 +312,7 @@ int snd_sof_device_remove(struct device *dev) * will remove the component driver and unload the topology * before freeing the snd_card. */ - if (!IS_ERR_OR_NULL(pdata->pdev_mach)) - platform_device_unregister(pdata->pdev_mach); - + snd_sof_machine_unregister(sdev, pdata); /* * Unregistering the machine driver results in unloading the topology. * Some widgets, ex: scheduler, attempt to power down the core they are diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 6f45e14f2b2e..aeed1422900b 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -17,6 +17,7 @@ #include "../sof-priv.h" #include "hda.h" +#include "../sof-audio.h" static const struct snd_sof_debugfs_map apl_dsp_debugfs[] = { {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, @@ -52,6 +53,12 @@ const struct snd_sof_dsp_ops sof_apl_ops = { .ipc_msg_data = hda_ipc_msg_data, .ipc_pcm_params = hda_ipc_pcm_params, + /* machine driver */ + .machine_select = hda_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = hda_set_mach_params, + /* debug */ .debug_map = apl_dsp_debugfs, .debug_map_count = ARRAY_SIZE(apl_dsp_debugfs), diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 141dad554764..c09885c0eb7d 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -17,6 +17,7 @@ #include #include "../ops.h" #include "shim.h" +#include "../sof-audio.h" /* BARs */ #define BDW_DSP_BAR 0 @@ -536,6 +537,32 @@ static int bdw_probe(struct snd_sof_dev *sdev) return ret; } +static void bdw_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; + + mach = snd_soc_acpi_find_machine(desc->machines); + if (!mach) { + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); + return; + } + + sof_pdata->tplg_filename = mach->sof_tplg_filename; + mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; + sof_pdata->machine = mach; +} + +static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct device *dev) +{ + struct snd_soc_acpi_mach_params *mach_params; + + mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; + mach_params->platform = dev_name(dev); +} + /* Broadwell DAIs */ static struct snd_soc_dai_driver bdw_dai[] = { { @@ -574,6 +601,12 @@ const struct snd_sof_dsp_ops sof_bdw_ops = { .ipc_msg_data = intel_ipc_msg_data, .ipc_pcm_params = intel_ipc_pcm_params, + /* machine driver */ + .machine_select = bdw_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = bdw_set_mach_params, + /* debug */ .debug_map = bdw_debugfs, .debug_map_count = ARRAY_SIZE(bdw_debugfs), diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index 2abf80b3eb52..2f5db1a8c701 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -17,6 +17,7 @@ #include #include "../ops.h" #include "shim.h" +#include "../sof-audio.h" /* DSP memories */ #define IRAM_OFFSET 0x0C0000 @@ -382,6 +383,32 @@ static int byt_reset(struct snd_sof_dev *sdev) return 0; } +static void byt_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; + + mach = snd_soc_acpi_find_machine(desc->machines); + if (!mach) { + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); + return; + } + + sof_pdata->tplg_filename = mach->sof_tplg_filename; + mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; + sof_pdata->machine = mach; +} + +static void byt_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct device *dev) +{ + struct snd_soc_acpi_mach_params *mach_params; + + mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; + mach_params->platform = dev_name(dev); +} + /* Baytrail DAIs */ static struct snd_soc_dai_driver byt_dai[] = { { @@ -514,6 +541,12 @@ const struct snd_sof_dsp_ops sof_tng_ops = { .ipc_msg_data = intel_ipc_msg_data, .ipc_pcm_params = intel_ipc_pcm_params, + /* machine driver */ + .machine_select = byt_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = byt_set_mach_params, + /* debug */ .debug_map = byt_debugfs, .debug_map_count = ARRAY_SIZE(byt_debugfs), @@ -682,6 +715,12 @@ const struct snd_sof_dsp_ops sof_byt_ops = { .ipc_msg_data = intel_ipc_msg_data, .ipc_pcm_params = intel_ipc_pcm_params, + /* machine driver */ + .machine_select = byt_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = byt_set_mach_params, + /* debug */ .debug_map = byt_debugfs, .debug_map_count = ARRAY_SIZE(byt_debugfs), @@ -748,6 +787,12 @@ const struct snd_sof_dsp_ops sof_cht_ops = { .ipc_msg_data = intel_ipc_msg_data, .ipc_pcm_params = intel_ipc_pcm_params, + /* machine driver */ + .machine_select = byt_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = byt_set_mach_params, + /* debug */ .debug_map = cht_debugfs, .debug_map_count = ARRAY_SIZE(cht_debugfs), diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 9bd169e2691e..6b44f6d02082 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -18,6 +18,7 @@ #include "../ops.h" #include "hda.h" #include "hda-ipc.h" +#include "../sof-audio.h" static const struct snd_sof_debugfs_map cnl_dsp_debugfs[] = { {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, @@ -238,6 +239,12 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { .ipc_msg_data = hda_ipc_msg_data, .ipc_pcm_params = hda_ipc_pcm_params, + /* machine driver */ + .machine_select = hda_machine_select, + .machine_register = sof_machine_register, + .machine_unregister = sof_machine_unregister, + .set_mach_params = hda_set_mach_params, + /* debug */ .debug_map = cnl_dsp_debugfs, .debug_map_count = ARRAY_SIZE(cnl_dsp_debugfs), diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index bfdb817b3780..8d27846d9048 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -344,16 +344,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev) struct hdac_bus *bus = sof_to_bus(sdev); #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) struct hdac_ext_link *hlink; - struct snd_soc_acpi_mach_params *mach_params; - struct snd_soc_acpi_mach *hda_mach; - struct snd_sof_pdata *pdata = sdev->pdata; - struct snd_soc_acpi_mach *mach; - const char *tplg_filename; - const char *idisp_str; - const char *dmic_str; - int dmic_num = 0; - int codec_num = 0; - int i; #endif int ret = 0; @@ -387,94 +377,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev) if (bus->mlcap) snd_hdac_ext_bus_get_ml_capabilities(bus); - /* codec detection */ - if (!bus->codec_mask) { - dev_info(bus->dev, "no hda codecs found!\n"); - } else { - dev_info(bus->dev, "hda codecs found, mask %lx\n", - bus->codec_mask); - - for (i = 0; i < HDA_MAX_CODECS; i++) { - if (bus->codec_mask & (1 << i)) - codec_num++; - } - - /* - * If no machine driver is found, then: - * - * hda machine driver is used if : - * 1. there is one HDMI codec and one external HDAudio codec - * 2. only HDMI codec - */ - if (!pdata->machine && codec_num <= 2 && - HDA_IDISP_CODEC(bus->codec_mask)) { - hda_mach = snd_soc_acpi_intel_hda_machines; - pdata->machine = hda_mach; - - /* topology: use the info from hda_machines */ - pdata->tplg_filename = - hda_mach->sof_tplg_filename; - - /* - * firmware: pick the first in machine list, - * or use nocodec firmware name if list is empty - */ - mach = pdata->desc->machines; - if (mach->id[0]) - pdata->fw_filename = mach->sof_fw_filename; - else - pdata->fw_filename = - pdata->desc->nocodec_fw_filename; - - dev_info(bus->dev, "using HDA machine driver %s now\n", - hda_mach->drv_name); - - if (codec_num == 1) - idisp_str = "-idisp"; - else - idisp_str = ""; - - /* first check NHLT for DMICs */ - dmic_num = check_nhlt_dmic(sdev); - - /* allow for module parameter override */ - if (hda_dmic_num != -1) - dmic_num = hda_dmic_num; - - switch (dmic_num) { - case 2: - dmic_str = "-2ch"; - break; - case 4: - dmic_str = "-4ch"; - break; - default: - dmic_num = 0; - dmic_str = ""; - break; - } - - tplg_filename = pdata->tplg_filename; - tplg_filename = fixup_tplg_name(sdev, tplg_filename, - idisp_str, dmic_str); - if (!tplg_filename) { - hda_codec_i915_exit(sdev); - return ret; - } - pdata->tplg_filename = tplg_filename; - } - } - - /* used by hda machine driver to create dai links */ - if (pdata->machine) { - mach_params = (struct snd_soc_acpi_mach_params *) - &pdata->machine->mach_params; - mach_params->codec_mask = bus->codec_mask; - mach_params->platform = dev_name(sdev->dev); - mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; - mach_params->dmic_num = dmic_num; - } - /* create codec instances */ hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi); @@ -763,4 +665,133 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) return 0; } +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +static int hda_generic_machine_select(struct snd_sof_dev *sdev) +{ + struct hdac_bus *bus = sof_to_bus(sdev); + struct snd_soc_acpi_mach_params *mach_params; + struct snd_soc_acpi_mach *hda_mach; + struct snd_sof_pdata *pdata = sdev->pdata; + const char *tplg_filename; + const char *idisp_str; + const char *dmic_str; + int dmic_num = 0; + int codec_num = 0; + int i; + + /* codec detection */ + if (!bus->codec_mask) { + dev_info(bus->dev, "no hda codecs found!\n"); + } else { + dev_info(bus->dev, "hda codecs found, mask %lx\n", + bus->codec_mask); + + for (i = 0; i < HDA_MAX_CODECS; i++) { + if (bus->codec_mask & (1 << i)) + codec_num++; + } + + /* + * If no machine driver is found, then: + * + * hda machine driver is used if : + * 1. there is one HDMI codec and one external HDAudio codec + * 2. only HDMI codec + */ + if (!pdata->machine && codec_num <= 2 && + HDA_IDISP_CODEC(bus->codec_mask)) { + hda_mach = snd_soc_acpi_intel_hda_machines; + + /* topology: use the info from hda_machines */ + pdata->tplg_filename = + hda_mach->sof_tplg_filename; + + dev_info(bus->dev, "using HDA machine driver %s now\n", + hda_mach->drv_name); + + if (codec_num == 1) + idisp_str = "-idisp"; + else + idisp_str = ""; + + /* first check NHLT for DMICs */ + dmic_num = check_nhlt_dmic(sdev); + + /* allow for module parameter override */ + if (hda_dmic_num != -1) + dmic_num = hda_dmic_num; + + switch (dmic_num) { + case 2: + dmic_str = "-2ch"; + break; + case 4: + dmic_str = "-4ch"; + break; + default: + dmic_num = 0; + dmic_str = ""; + break; + } + + tplg_filename = pdata->tplg_filename; + tplg_filename = fixup_tplg_name(sdev, tplg_filename, + idisp_str, dmic_str); + if (!tplg_filename) + return -EINVAL; + + pdata->machine = hda_mach; + pdata->tplg_filename = tplg_filename; + } + } + + /* used by hda machine driver to create dai links */ + if (pdata->machine) { + mach_params = (struct snd_soc_acpi_mach_params *) + &pdata->machine->mach_params; + mach_params->codec_mask = bus->codec_mask; + mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; + mach_params->dmic_num = dmic_num; + } + + return 0; +} +#else +static int hda_generic_machine_select(struct snd_sof_dev *sdev) +{ + return 0; +} +#endif + +void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct device *dev) +{ + struct snd_soc_acpi_mach_params *mach_params; + + mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; + mach_params->platform = dev_name(dev); +} + +void hda_machine_select(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; + + mach = snd_soc_acpi_find_machine(desc->machines); + if (mach) { + sof_pdata->tplg_filename = mach->sof_tplg_filename; + sof_pdata->machine = mach; + } + + /* + * Choose HDA generic machine driver if mach is NULL. + * Otherwise, set certain mach params. + */ + hda_generic_machine_select(sdev); + + if (!sof_pdata->machine) + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); +} + MODULE_LICENSE("Dual BSD/GPL"); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 4a6f76572658..01529c7058f3 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -624,4 +624,9 @@ extern const struct sof_intel_dsp_desc tgl_chip_info; extern const struct sof_intel_dsp_desc ehl_chip_info; extern const struct sof_intel_dsp_desc jsl_chip_info; +/* machine driver select */ +void hda_machine_select(struct snd_sof_dev *sdev); +void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct device *dev); + #endif diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c index 3d128e5a132c..0a2167f19f25 100644 --- a/sound/soc/sof/nocodec.c +++ b/sound/soc/sof/nocodec.c @@ -77,7 +77,6 @@ int sof_nocodec_setup(struct device *dev, sof_pdata->drv_name = "sof-nocodec"; mach->drv_name = "sof-nocodec"; - sof_pdata->fw_filename = desc->nocodec_fw_filename; sof_pdata->tplg_filename = desc->nocodec_tplg_filename; /* create dummy BE dai_links */ diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 93512dcbaacd..e929a6e0058f 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -391,6 +391,40 @@ snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev, return 0; } +/* machine driver */ +static inline int +snd_sof_machine_register(struct snd_sof_dev *sdev, void *pdata) +{ + if (sof_ops(sdev) && sof_ops(sdev)->machine_register) + return sof_ops(sdev)->machine_register(sdev, pdata); + + return 0; +} + +static inline void +snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) +{ + if (sof_ops(sdev) && sof_ops(sdev)->machine_unregister) + sof_ops(sdev)->machine_unregister(sdev, pdata); +} + +static inline void +snd_sof_machine_select(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev) && sof_ops(sdev)->machine_select) + sof_ops(sdev)->machine_select(sdev); +} + +static inline void +snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, + struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + + if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params) + sof_ops(sdev)->set_mach_params(mach, dev); +} + static inline const struct snd_sof_dsp_ops *sof_get_ops(const struct sof_dev_desc *d, const struct sof_ops_table mach_ops[], int asize) diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 22e13ef09811..8174b9a7da95 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -145,7 +145,6 @@ static int sof_acpi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct sof_dev_desc *desc; - struct snd_soc_acpi_mach *mach; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; int ret; @@ -172,35 +171,9 @@ static int sof_acpi_probe(struct platform_device *pdev) return -ENODEV; } -#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) - /* force nocodec mode */ - dev_warn(dev, "Force to use nocodec mode\n"); - mach = devm_kzalloc(dev, sizeof(*mach), GFP_KERNEL); - if (!mach) - return -ENOMEM; - ret = sof_nocodec_setup(dev, sof_pdata, mach, desc, ops); - if (ret < 0) - return ret; -#else - /* find machine */ - mach = snd_soc_acpi_find_machine(desc->machines); - if (!mach) { - dev_warn(dev, "warning: No matching ASoC machine driver found\n"); - } else { - sof_pdata->fw_filename = mach->sof_fw_filename; - sof_pdata->tplg_filename = mach->sof_tplg_filename; - } -#endif - - if (mach) { - mach->mach_params.platform = dev_name(dev); - mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; - } - - sof_pdata->machine = mach; sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->platform = dev_name(dev); + sof_pdata->fw_filename = desc->default_fw_filename; /* alternate fw and tplg filenames ? */ if (fw_path) diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index bf99d040c9c1..9c3851bfe788 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -360,3 +360,83 @@ struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp, return NULL; } +/* + * SOF Driver enumeration. + */ +int sof_machine_check(struct snd_sof_dev *sdev) +{ + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; + int ret; + + /* force nocodec mode */ +#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) + dev_warn(sdev->dev, "Force to use nocodec mode\n"); + goto nocodec; +#endif + + /* find machine */ + snd_sof_machine_select(sdev); + if (sof_pdata->machine) { + snd_sof_set_mach_params(sof_pdata->machine, sdev->dev); + return 0; + } + +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) + dev_err(sdev->dev, "error: no matching ASoC machine driver found - aborting probe\n"); + return -ENODEV; +#endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) +nocodec: +#endif + /* select nocodec mode */ + dev_warn(sdev->dev, "Using nocodec machine driver\n"); + mach = devm_kzalloc(sdev->dev, sizeof(*mach), GFP_KERNEL); + if (!mach) + return -ENOMEM; + + ret = sof_nocodec_setup(sdev->dev, sof_pdata, mach, desc, desc->ops); + if (ret < 0) + return ret; + + sof_pdata->machine = mach; + snd_sof_set_mach_params(sof_pdata->machine, sdev->dev); + + return 0; +} +EXPORT_SYMBOL(sof_machine_check); + +int sof_machine_register(struct snd_sof_dev *sdev, void *pdata) +{ + struct snd_sof_pdata *plat_data = (struct snd_sof_pdata *)pdata; + const char *drv_name; + const void *mach; + int size; + + drv_name = plat_data->machine->drv_name; + mach = (const void *)plat_data->machine; + size = sizeof(*plat_data->machine); + + /* register machine driver, pass machine info as pdata */ + plat_data->pdev_mach = + platform_device_register_data(sdev->dev, drv_name, + PLATFORM_DEVID_NONE, mach, size); + if (IS_ERR(plat_data->pdev_mach)) + return PTR_ERR(plat_data->pdev_mach); + + dev_dbg(sdev->dev, "created machine %s\n", + dev_name(&plat_data->pdev_mach->dev)); + + return 0; +} +EXPORT_SYMBOL(sof_machine_register); + +void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) +{ + struct snd_sof_pdata *plat_data = (struct snd_sof_pdata *)pdata; + + if (!IS_ERR_OR_NULL(plat_data->pdev_mach)) + platform_device_unregister(plat_data->pdev_mach); +} +EXPORT_SYMBOL(sof_machine_unregister); diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 5703698633af..a62fb2da6a6e 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -204,4 +204,8 @@ int sof_restore_pipelines(struct device *dev); int sof_set_hw_params_upon_resume(struct device *dev); bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev); +/* Machine driver enumeration */ +int sof_machine_register(struct snd_sof_dev *sdev, void *pdata); +void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata); + #endif diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 81deb5582d77..170a5839150f 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -44,8 +44,6 @@ static int sof_of_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct sof_dev_desc *desc; - /*TODO: create a generic snd_soc_xxx_mach */ - struct snd_soc_acpi_mach *mach; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; int ret; @@ -67,27 +65,9 @@ static int sof_of_probe(struct platform_device *pdev) return -ENODEV; } -#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) - /* force nocodec mode */ - dev_warn(dev, "Force to use nocodec mode\n"); - mach = devm_kzalloc(dev, sizeof(*mach), GFP_KERNEL); - if (!mach) - return -ENOMEM; - ret = sof_nocodec_setup(dev, sof_pdata, mach, desc, ops); - if (ret < 0) - return ret; -#else - /* TODO: implement case where we actually have a codec */ - return -ENODEV; -#endif - - if (mach) - mach->mach_params.platform = dev_name(dev); - - sof_pdata->machine = mach; sof_pdata->desc = desc; sof_pdata->dev = &pdev->dev; - sof_pdata->platform = dev_name(dev); + sof_pdata->fw_filename = desc->default_fw_filename; /* TODO: read alternate fw and tplg filenames from DT */ sof_pdata->fw_filename_prefix = sof_pdata->desc->default_fw_path; diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 046bd57657ca..1c7b87392708 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -275,7 +275,6 @@ static int sof_pci_probe(struct pci_dev *pci, struct device *dev = &pci->dev; const struct sof_dev_desc *desc = (const struct sof_dev_desc *)pci_id->driver_data; - struct snd_soc_acpi_mach *mach; struct snd_sof_pdata *sof_pdata; const struct snd_sof_dsp_ops *ops; int ret; @@ -306,35 +305,10 @@ static int sof_pci_probe(struct pci_dev *pci, if (ret < 0) return ret; -#if IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE) - /* force nocodec mode */ - dev_warn(dev, "Force to use nocodec mode\n"); - mach = devm_kzalloc(dev, sizeof(*mach), GFP_KERNEL); - if (!mach) { - ret = -ENOMEM; - goto release_regions; - } - ret = sof_nocodec_setup(dev, sof_pdata, mach, desc, ops); - if (ret < 0) - goto release_regions; - -#else - /* find machine */ - mach = snd_soc_acpi_find_machine(desc->machines); - if (!mach) { - dev_warn(dev, "warning: No matching ASoC machine driver found\n"); - } else { - mach->mach_params.platform = dev_name(dev); - sof_pdata->fw_filename = mach->sof_fw_filename; - sof_pdata->tplg_filename = mach->sof_tplg_filename; - } -#endif /* CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE */ - sof_pdata->name = pci_name(pci); - sof_pdata->machine = mach; sof_pdata->desc = (struct sof_dev_desc *)pci_id->driver_data; sof_pdata->dev = dev; - sof_pdata->platform = dev_name(dev); + sof_pdata->fw_filename = desc->default_fw_filename; /* alternate fw and tplg filenames ? */ if (fw_path) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index eae1fc209a65..54dd6d4b4c12 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -202,6 +202,15 @@ struct snd_sof_dsp_ops { int (*get_window_offset)(struct snd_sof_dev *sdev, u32 id);/* mandatory for common loader code */ + /* machine driver ops */ + int (*machine_register)(struct snd_sof_dev *sdev, + void *pdata); /* optional */ + void (*machine_unregister)(struct snd_sof_dev *sdev, + void *pdata); /* optional */ + void (*machine_select)(struct snd_sof_dev *sdev); /* optional */ + void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, + struct device *dev); /* optional */ + /* DAI ops */ struct snd_soc_dai_driver *drv; int num_drv; @@ -511,4 +520,6 @@ int intel_pcm_open(struct snd_sof_dev *sdev, int intel_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); +int sof_machine_check(struct snd_sof_dev *sdev); + #endif -- cgit v1.2.3 From f4e4113b2aec2d344276ac07f78e80460eb8ebf8 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:54 -0600 Subject: ASoC: SOF: remove nocodec_fw_filename Remove nocodec_fw_filename from struct sof_dev_desc as it is not longer needed. Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof.h | 1 - sound/soc/sof/sof-acpi-dev.c | 5 ----- sound/soc/sof/sof-of-dev.c | 1 - sound/soc/sof/sof-pci-dev.c | 10 ---------- 4 files changed, 17 deletions(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 1723478db4a2..98a757d3a67d 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -84,7 +84,6 @@ struct sof_dev_desc { const void *chip_info; /* defaults for no codec mode */ - const char *nocodec_fw_filename; const char *nocodec_tplg_filename; /* defaults paths for firmware and topology files */ diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 8174b9a7da95..9c0a4eed5cc8 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -46,7 +46,6 @@ static const struct sof_dev_desc sof_acpi_haswell_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-hsw.ri", - .nocodec_fw_filename = "sof-hsw.ri", .nocodec_tplg_filename = "sof-hsw-nocodec.tplg", .ops = &sof_hsw_ops, .arch_ops = &sof_xtensa_arch_ops @@ -64,7 +63,6 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-bdw.ri", - .nocodec_fw_filename = "sof-bdw.ri", .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", .ops = &sof_bdw_ops, .arch_ops = &sof_xtensa_arch_ops @@ -84,7 +82,6 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-byt.ri", - .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, .arch_ops = &sof_xtensa_arch_ops @@ -100,7 +97,6 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-byt.ri", - .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, .arch_ops = &sof_xtensa_arch_ops @@ -116,7 +112,6 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-cht.ri", - .nocodec_fw_filename = "sof-cht.ri", .nocodec_tplg_filename = "sof-cht-nocodec.tplg", .ops = &sof_cht_ops, .arch_ops = &sof_xtensa_arch_ops diff --git a/sound/soc/sof/sof-of-dev.c b/sound/soc/sof/sof-of-dev.c index 170a5839150f..39ea8af6213f 100644 --- a/sound/soc/sof/sof-of-dev.c +++ b/sound/soc/sof/sof-of-dev.c @@ -20,7 +20,6 @@ static struct sof_dev_desc sof_of_imx8qxp_desc = { .default_fw_path = "imx/sof", .default_tplg_path = "imx/sof-tplg", .default_fw_filename = "sof-imx8.ri", - .nocodec_fw_filename = "sof-imx8.ri", .nocodec_tplg_filename = "sof-imx8-nocodec.tplg", .ops = &sof_imx8_ops, }; diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 1c7b87392708..5f08a9ca6bf8 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -48,7 +48,6 @@ static const struct sof_dev_desc bxt_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-apl.ri", - .nocodec_fw_filename = "sof-apl.ri", .nocodec_tplg_filename = "sof-apl-nocodec.tplg", .ops = &sof_apl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -67,7 +66,6 @@ static const struct sof_dev_desc glk_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-glk.ri", - .nocodec_fw_filename = "sof-glk.ri", .nocodec_tplg_filename = "sof-glk-nocodec.tplg", .ops = &sof_apl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -96,7 +94,6 @@ static const struct sof_dev_desc tng_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-byt.ri", - .nocodec_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt.tplg", .ops = &sof_tng_ops, .arch_ops = &sof_xtensa_arch_ops @@ -115,7 +112,6 @@ static const struct sof_dev_desc cnl_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-cnl.ri", - .nocodec_fw_filename = "sof-cnl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -134,7 +130,6 @@ static const struct sof_dev_desc cfl_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-cfl.ri", - .nocodec_fw_filename = "sof-cfl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -155,7 +150,6 @@ static const struct sof_dev_desc cml_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-cml.ri", - .nocodec_fw_filename = "sof-cml.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -174,7 +168,6 @@ static const struct sof_dev_desc icl_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-icl.ri", - .nocodec_fw_filename = "sof-icl.ri", .nocodec_tplg_filename = "sof-icl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -193,7 +186,6 @@ static const struct sof_dev_desc tgl_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-tgl.ri", - .nocodec_fw_filename = "sof-tgl.ri", .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -212,7 +204,6 @@ static const struct sof_dev_desc ehl_desc = { .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", .default_fw_filename = "sof-ehl.ri", - .nocodec_fw_filename = "sof-ehl.ri", .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops @@ -230,7 +221,6 @@ static const struct sof_dev_desc jsl_desc = { .chip_info = &jsl_chip_info, .default_fw_path = "intel/sof", .default_tplg_path = "intel/sof-tplg", - .nocodec_fw_filename = "sof-jsl.ri", .nocodec_tplg_filename = "sof-jsl-nocodec.tplg", .ops = &sof_cnl_ops, .arch_ops = &sof_xtensa_arch_ops -- cgit v1.2.3 From 5ad1cece81db9b389526499ae2e784013c85f136 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Wed, 4 Dec 2019 15:15:55 -0600 Subject: ASoC: SOF: Remove unused drv_name in sof_pdata This field is only set but never used. Let's remove it to make code cleaner. Signed-off-by: Daniel Baluta Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-13-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof.h | 1 - sound/soc/sof/nocodec.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 98a757d3a67d..96625355aa94 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -22,7 +22,6 @@ struct snd_sof_dsp_ops; */ struct snd_sof_pdata { const struct firmware *fw; - const char *drv_name; const char *name; const char *platform; diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c index 0a2167f19f25..56d887545da3 100644 --- a/sound/soc/sof/nocodec.c +++ b/sound/soc/sof/nocodec.c @@ -74,8 +74,6 @@ int sof_nocodec_setup(struct device *dev, if (!mach) return -EINVAL; - sof_pdata->drv_name = "sof-nocodec"; - mach->drv_name = "sof-nocodec"; sof_pdata->tplg_filename = desc->nocodec_tplg_filename; -- cgit v1.2.3 From d612b455f120d05a42c95ccd7469fa13efb8d307 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 4 Dec 2019 15:15:56 -0600 Subject: ASoC: SOF: nocodec: Amend arguments for sof_nocodec_setup() Set the drv_name and tplg_filename for nocodec machine driver in sof_machine_check(). This means the sof_nocodec_setup() does not need the mach, plat_data or desc arguments any longer. Signed-off-by: Daniel Baluta Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191204211556.12671-14-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof.h | 3 --- sound/soc/sof/nocodec.c | 9 --------- sound/soc/sof/sof-audio.c | 5 ++++- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 96625355aa94..6ea74f1a9ec2 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -97,8 +97,5 @@ struct sof_dev_desc { }; int sof_nocodec_setup(struct device *dev, - struct snd_sof_pdata *sof_pdata, - struct snd_soc_acpi_mach *mach, - const struct sof_dev_desc *desc, const struct snd_sof_dsp_ops *ops); #endif diff --git a/sound/soc/sof/nocodec.c b/sound/soc/sof/nocodec.c index 56d887545da3..2233146386cc 100644 --- a/sound/soc/sof/nocodec.c +++ b/sound/soc/sof/nocodec.c @@ -63,20 +63,11 @@ static int sof_nocodec_bes_setup(struct device *dev, } int sof_nocodec_setup(struct device *dev, - struct snd_sof_pdata *sof_pdata, - struct snd_soc_acpi_mach *mach, - const struct sof_dev_desc *desc, const struct snd_sof_dsp_ops *ops) { struct snd_soc_dai_link *links; int ret; - if (!mach) - return -EINVAL; - - mach->drv_name = "sof-nocodec"; - sof_pdata->tplg_filename = desc->nocodec_tplg_filename; - /* create dummy BE dai_links */ links = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link) * ops->num_drv, GFP_KERNEL); diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 9c3851bfe788..0d8f65b9ae25 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -396,7 +396,10 @@ nocodec: if (!mach) return -ENOMEM; - ret = sof_nocodec_setup(sdev->dev, sof_pdata, mach, desc, desc->ops); + mach->drv_name = "sof-nocodec"; + sof_pdata->tplg_filename = desc->nocodec_tplg_filename; + + ret = sof_nocodec_setup(sdev->dev, desc->ops); if (ret < 0) return ret; -- cgit v1.2.3 From 433363e779ecb772c2e9ffea5c9f266115c24441 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 9 Dec 2019 18:48:47 -0600 Subject: ASoC: SOF: Add asynchronous sample rate converter topology support This patch adds into SOF topology the handling of ASRC DAPM type, adds the tokens to configure the ASRC, and implement component IPC into the driver. Signed-off-by: Seppo Ingalsuo Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191210004854.16845-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof/topology.h | 27 ++++++++++++++ include/uapi/sound/sof/abi.h | 2 +- include/uapi/sound/sof/tokens.h | 6 ++++ sound/soc/sof/topology.c | 78 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) diff --git a/include/sound/sof/topology.h b/include/sound/sof/topology.h index c47b36240920..8e76178fedf0 100644 --- a/include/sound/sof/topology.h +++ b/include/sound/sof/topology.h @@ -36,6 +36,7 @@ enum sof_comp_type { SOF_COMP_KPB, /* A key phrase buffer component */ SOF_COMP_SELECTOR, /**< channel selector component */ SOF_COMP_DEMUX, + SOF_COMP_ASRC, /**< Asynchronous sample rate converter */ /* keep FILEREAD/FILEWRITE as the last ones */ SOF_COMP_FILEREAD = 10000, /**< host test based file IO */ SOF_COMP_FILEWRITE = 10001, /**< host test based file IO */ @@ -147,6 +148,32 @@ struct sof_ipc_comp_src { uint32_t rate_mask; /**< SOF_RATE_ supported rates */ } __packed; +/* generic ASRC component */ +struct sof_ipc_comp_asrc { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + /* either source or sink rate must be non zero */ + uint32_t source_rate; /**< Define fixed source rate or */ + /**< use 0 to indicate need to get */ + /**< the rate from stream */ + uint32_t sink_rate; /**< Define fixed sink rate or */ + /**< use 0 to indicate need to get */ + /**< the rate from stream */ + uint32_t asynchronous_mode; /**< synchronous 0, asynchronous 1 */ + /**< When 1 the ASRC tracks and */ + /**< compensates for drift. */ + uint32_t operation_mode; /**< push 0, pull 1, In push mode the */ + /**< ASRC consumes a defined number */ + /**< of frames at input, with varying */ + /**< number of frames at output. */ + /**< In pull mode the ASRC outputs */ + /**< a defined number of frames while */ + /**< number of input frames varies. */ + + /* reserved for future use */ + uint32_t reserved[4]; +} __attribute__((packed)); + /* generic MUX component */ struct sof_ipc_comp_mux { struct sof_ipc_comp comp; diff --git a/include/uapi/sound/sof/abi.h b/include/uapi/sound/sof/abi.h index ebfdc20ca081..c0ef1643c753 100644 --- a/include/uapi/sound/sof/abi.h +++ b/include/uapi/sound/sof/abi.h @@ -26,7 +26,7 @@ /* SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 11 +#define SOF_ABI_MINOR 12 #define SOF_ABI_PATCH 0 /* SOF ABI version number. Format within 32bit word is MMmmmppp */ diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h index 76883e6fb750..a9a5c4d0a892 100644 --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h @@ -57,6 +57,12 @@ #define SOF_TKN_SRC_RATE_IN 300 #define SOF_TKN_SRC_RATE_OUT 301 +/* ASRC */ +#define SOF_TKN_ASRC_RATE_IN 320 +#define SOF_TKN_ASRC_RATE_OUT 321 +#define SOF_TKN_ASRC_ASYNCHRONOUS_MODE 322 +#define SOF_TKN_ASRC_OPERATION_MODE 323 + /* PCM */ #define SOF_TKN_PCM_DMAC_CONFIG 353 diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 1ae06a1f9b0b..215f4d23ddfe 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -573,6 +573,20 @@ static const struct sof_topology_token src_tokens[] = { offsetof(struct sof_ipc_comp_src, sink_rate), 0}, }; +/* ASRC */ +static const struct sof_topology_token asrc_tokens[] = { + {SOF_TKN_ASRC_RATE_IN, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_comp_asrc, source_rate), 0}, + {SOF_TKN_ASRC_RATE_OUT, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_comp_asrc, sink_rate), 0}, + {SOF_TKN_ASRC_ASYNCHRONOUS_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, + get_token_u32, + offsetof(struct sof_ipc_comp_asrc, asynchronous_mode), 0}, + {SOF_TKN_ASRC_OPERATION_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, + get_token_u32, + offsetof(struct sof_ipc_comp_asrc, operation_mode), 0}, +}; + /* Tone */ static const struct sof_topology_token tone_tokens[] = { }; @@ -1782,6 +1796,67 @@ err: return ret; } +/* + * ASRC Topology + */ + +static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index, + struct snd_sof_widget *swidget, + struct snd_soc_tplg_dapm_widget *tw, + struct sof_ipc_comp_reply *r) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_soc_tplg_private *private = &tw->priv; + struct sof_ipc_comp_asrc *asrc; + int ret; + + asrc = kzalloc(sizeof(*asrc), GFP_KERNEL); + if (!asrc) + return -ENOMEM; + + /* configure ASRC IPC message */ + asrc->comp.hdr.size = sizeof(*asrc); + asrc->comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW; + asrc->comp.id = swidget->comp_id; + asrc->comp.type = SOF_COMP_ASRC; + asrc->comp.pipeline_id = index; + asrc->config.hdr.size = sizeof(asrc->config); + + ret = sof_parse_tokens(scomp, asrc, asrc_tokens, + ARRAY_SIZE(asrc_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse asrc tokens failed %d\n", + private->size); + goto err; + } + + ret = sof_parse_tokens(scomp, &asrc->config, comp_tokens, + ARRAY_SIZE(comp_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse asrc.cfg tokens failed %d\n", + le32_to_cpu(private->size)); + goto err; + } + + dev_dbg(scomp->dev, "asrc %s: source rate %d sink rate %d " + "asynch %d operation %d\n", + swidget->widget->name, asrc->source_rate, asrc->sink_rate, + asrc->asynchronous_mode, asrc->operation_mode); + sof_dbg_comp_config(scomp, &asrc->config); + + swidget->private = asrc; + + ret = sof_ipc_tx_message(sdev->ipc, asrc->comp.hdr.cmd, asrc, + sizeof(*asrc), r, sizeof(*r)); + if (ret >= 0) + return ret; +err: + kfree(asrc); + return ret; +} + /* * Signal Generator Topology */ @@ -2195,6 +2270,9 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, case snd_soc_dapm_src: ret = sof_widget_load_src(scomp, index, swidget, tw, &reply); break; + case snd_soc_dapm_asrc: + ret = sof_widget_load_asrc(scomp, index, swidget, tw, &reply); + break; case snd_soc_dapm_siggen: ret = sof_widget_load_siggen(scomp, index, swidget, tw, &reply); break; -- cgit v1.2.3 From b7c5986489b5c55ebebc430037dd4691a6bbc99c Mon Sep 17 00:00:00 2001 From: Slawomir Blauciak Date: Mon, 9 Dec 2019 18:48:50 -0600 Subject: ASoC: SOF: ipc: channel map structures This change adds stream map and channel map structures used for channel re-routing and stream aggregation. Signed-off-by: Slawomir Blauciak Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191210004854.16845-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof/channel_map.h | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 include/sound/sof/channel_map.h diff --git a/include/sound/sof/channel_map.h b/include/sound/sof/channel_map.h new file mode 100644 index 000000000000..21044eb5f377 --- /dev/null +++ b/include/sound/sof/channel_map.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * Copyright(c) 2019 Intel Corporation. All rights reserved. + */ + +#ifndef __IPC_CHANNEL_MAP_H__ +#define __IPC_CHANNEL_MAP_H__ + +#include +#include + +/** + * \brief Channel map, specifies transformation of one-to-many or many-to-one. + * + * In case of one-to-many specifies how the output channels are computed out of + * a single source channel, + * in case of many-to-one specifies how a single target channel is computed + * from a multichannel input stream. + * + * Channel index specifies position of the channel in the stream on the 'one' + * side. + * + * Ext ID is the identifier of external part of the transformation. Depending + * on the context, it may be pipeline ID, dai ID, ... + * + * Channel mask describes which channels are taken into account on the "many" + * side. Bit[i] set to 1 means that i-th channel is used for computation + * (either as source or as a target). + * + * Channel mask is followed by array of coefficients in Q2.30 format, + * one per each channel set in the mask (left to right, LS bit set in the + * mask corresponds to ch_coeffs[0]). + */ +struct sof_ipc_channel_map { + uint32_t ch_index; + uint32_t ext_id; + uint32_t ch_mask; + uint32_t reserved; + int32_t ch_coeffs[0]; +} __packed; + +/** + * \brief Complete map for each channel of a multichannel stream. + * + * num_ch_map Specifies number of items in the ch_map. + * More than one transformation per a single channel is allowed (in case + * multiple external entities are transformed). + * A channel may be skipped in the transformation list, then it is filled + * with 0's by the transformation function. + */ +struct sof_ipc_stream_map { + struct sof_ipc_cmd_hdr hdr; + uint32_t num_ch_map; + uint32_t reserved[3]; + struct sof_ipc_channel_map ch_map[0]; +} __packed; + +#endif /* __IPC_CHANNEL_MAP_H__ */ -- cgit v1.2.3 From 4f6250b82cb8f950a1b1bea62843a88bbb208187 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Mon, 9 Dec 2019 18:48:51 -0600 Subject: ASoC: SOF: Intel: add codec_mask module parameter Add a module parameter 'codec_mask' to filter out unwanted HDA codecs from driver probe. E.g. on most systems, codec_mask=4 will limit to HDMI audio and exclude any external HDA codecs. Similar to 'probe_mask' module parameter of snd-hda-intel. Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191210004854.16845-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-ctrl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/sof/intel/hda-ctrl.c b/sound/soc/sof/intel/hda-ctrl.c index df1909e1d950..871b71a15a63 100644 --- a/sound/soc/sof/intel/hda-ctrl.c +++ b/sound/soc/sof/intel/hda-ctrl.c @@ -15,11 +15,18 @@ * Hardware interface for generic Intel audio DSP HDA IP */ +#include #include #include #include "../ops.h" #include "hda.h" +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +static int hda_codec_mask = -1; +module_param_named(codec_mask, hda_codec_mask, int, 0444); +MODULE_PARM_DESC(codec_mask, "SOF HDA codec mask for probing"); +#endif + /* * HDA Operations. */ @@ -206,6 +213,12 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev, bool full_reset) bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS); dev_dbg(bus->dev, "codec_mask = 0x%lx\n", bus->codec_mask); } + + if (hda_codec_mask != -1) { + bus->codec_mask &= hda_codec_mask; + dev_dbg(bus->dev, "filtered codec_mask = 0x%lx\n", + bus->codec_mask); + } #endif /* clear stream status */ -- cgit v1.2.3 From cc73390008c9a47c49ad73c459b5590fd4c4c890 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:33:40 +0900 Subject: ASoC: soc-core: remove dai_link_list ASoC is using many lists. Now, used dai_link is listed to card as dai_link_list. [card]->[dai_link]->[dai_link]->... BTW, this "dai_link" is used to create "rtd". And this rtd is listed to card as rtd_list. [card]->[rtd]->[rtd]->... Here, each rtd has dai_link. This means, we can track all dai_link via rtd list. This patch removes card dai_link_list, and uses rtd_list instead of it. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87fthtyq6z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 7 ------- sound/soc/soc-core.c | 17 +++++++---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index c28a1ed5e8df..b7ba3b91d080 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -852,7 +852,6 @@ struct snd_soc_dai_link { /* Do not create a PCM for this DAI link (Backend link) */ unsigned int ignore:1; - struct list_head list; /* DAI link list of the soc card */ #ifdef CONFIG_SND_SOC_TOPOLOGY struct snd_soc_dobj dobj; /* For topology */ #endif @@ -1037,7 +1036,6 @@ struct snd_soc_card { /* CPU <--> Codec DAI links */ struct snd_soc_dai_link *dai_link; /* predefined links only */ int num_links; /* predefined links only */ - struct list_head dai_link_list; /* all links */ struct list_head rtd_list; int num_rtd; @@ -1107,11 +1105,6 @@ struct snd_soc_card { ((i) < (card)->num_aux_devs) && ((aux) = &(card)->aux_dev[i]); \ (i)++) -#define for_each_card_links(card, link) \ - list_for_each_entry(link, &(card)->dai_link_list, list) -#define for_each_card_links_safe(card, link, _link) \ - list_for_each_entry_safe(link, _link, &(card)->dai_link_list, list) - #define for_each_card_rtds(card, rtd) \ list_for_each_entry(rtd, &(card)->rtd_list, list) #define for_each_card_rtds_safe(card, rtd, _rtd) \ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1a362a799dbb..9483bfe17260 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -934,11 +934,14 @@ struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, int id, const char *name, const char *stream_name) { + struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link *link; lockdep_assert_held(&client_mutex); - for_each_card_links(card, link) { + for_each_card_rtds(card, rtd) { + link = rtd->dai_link; + if (link->id != id) continue; @@ -1075,8 +1078,6 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, if (card->remove_dai_link) card->remove_dai_link(card, dai_link); - list_del(&dai_link->list); - rtd = snd_soc_get_pcm_runtime(card, dai_link->name); if (rtd) soc_free_pcm_runtime(rtd); @@ -1158,9 +1159,6 @@ int snd_soc_add_dai_link(struct snd_soc_card *card, } } - /* see for_each_card_links */ - list_add_tail(&dai_link->list, &card->dai_link_list); - return 0; _err_defer: @@ -1931,7 +1929,7 @@ static void __soc_setup_card_name(char *name, int len, static void soc_cleanup_card_resources(struct snd_soc_card *card, int card_probed) { - struct snd_soc_dai_link *link, *_link; + struct snd_soc_pcm_runtime *rtd, *n; if (card->snd_card) snd_card_disconnect_sync(card->snd_card); @@ -1942,8 +1940,8 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, soc_remove_link_dais(card); soc_remove_link_components(card); - for_each_card_links_safe(card, link, _link) - snd_soc_remove_dai_link(card, link); + for_each_card_rtds_safe(card, rtd, n) + snd_soc_remove_dai_link(card, rtd->dai_link); /* remove auxiliary devices */ soc_remove_aux_devices(card); @@ -2393,7 +2391,6 @@ int snd_soc_register_card(struct snd_soc_card *card) INIT_LIST_HEAD(&card->aux_comp_list); INIT_LIST_HEAD(&card->component_dev_list); INIT_LIST_HEAD(&card->list); - INIT_LIST_HEAD(&card->dai_link_list); INIT_LIST_HEAD(&card->rtd_list); INIT_LIST_HEAD(&card->dapm_dirty); INIT_LIST_HEAD(&card->dobj_list); -- cgit v1.2.3 From b553bd238da23041bf39110e58ee80f8efe034e0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:33:50 +0900 Subject: ASoC: soc-core: remove snd_soc_disconnect_sync() Sound card disconnecting operation was needed when "sound driver" was unbinded without unbinding "sound card". In such case, sound driver should be stopped even though it was playbacking/capturing. Otherwise clock open/close counter mismatch happen. One headache was that we can't skip unbind in error case because unbind operation doesn't check return value from each drivers. snd_soc_disconnect_sync() was added for these purpose, and Renesas sound card only is used it. But now, ALSA SoC automatically disconnect sound card when sound driver was unbinded. Thus, snd_soc_disconnect_sync() is no longer needed. This patch removes it. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87eexdyq6p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 2 -- sound/soc/soc-core.c | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index d20f03dfdee6..6aac25095218 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1819,8 +1819,6 @@ static int rsnd_remove(struct platform_device *pdev) }; int ret = 0, i; - snd_soc_disconnect_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); for_each_rsnd_dai(rdai, priv, i) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9483bfe17260..0d436a2560e4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1444,18 +1444,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; } -void snd_soc_disconnect_sync(struct device *dev) -{ - struct snd_soc_component *component = - snd_soc_lookup_component(dev, NULL); - - if (!component || !component->card) - return; - - snd_card_disconnect_sync(component->card->snd_card); -} -EXPORT_SYMBOL_GPL(snd_soc_disconnect_sync); - static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, struct snd_soc_pcm_runtime *rtd) { -- cgit v1.2.3 From 8babfb7030573f7338b141d038c2094b7bb95034 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:33:55 +0900 Subject: ASoC: soc-core: remove snd_soc_get_dai_substream() No driver is using snd_soc_get_dai_substream(), and snd_soc_get_pcm_runtime() is enough for such purpose. We can revival it if it was needed in the future. Let's remove unused function. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87d0cxyq6k.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 2 -- sound/soc/soc-core.c | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index b7ba3b91d080..68ec5a051afe 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -464,8 +464,6 @@ static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) void snd_soc_disconnect_sync(struct device *dev); -struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, - const char *dai_link, int stream); struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, const char *dai_link); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0d436a2560e4..16265d0e48de 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -389,21 +389,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, } EXPORT_SYMBOL_GPL(snd_soc_lookup_component); -struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, - const char *dai_link, int stream) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (rtd->dai_link->no_pcm && - !strcmp(rtd->dai_link->name, dai_link)) - return rtd->pcm->streams[stream].substream; - } - dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link); - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); - static const struct snd_soc_ops null_snd_soc_ops; static void soc_release_rtd_dev(struct device *dev) -- cgit v1.2.3 From 94def8ea66be2ea9f6aac61549b6b5874bca6235 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:01 +0900 Subject: ASoC: soc-core: move snd_soc_get_pcm_runtime() This patch moves snd_soc_get_pcm_runtime() next to snd_soc_get_dai_substream(). This is prepare for snd_soc_get_pcm_runtime() cleanup. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87blshyq6e.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16265d0e48de..f215a37fd3d6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -391,6 +391,21 @@ EXPORT_SYMBOL_GPL(snd_soc_lookup_component); static const struct snd_soc_ops null_snd_soc_ops; +struct snd_soc_pcm_runtime +*snd_soc_get_pcm_runtime(struct snd_soc_card *card, + const char *dai_link) +{ + struct snd_soc_pcm_runtime *rtd; + + for_each_card_rtds(card, rtd) { + if (!strcmp(rtd->dai_link->name, dai_link)) + return rtd; + } + dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); + return NULL; +} +EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); + static void soc_release_rtd_dev(struct device *dev) { /* "dev" means "rtd->dev" */ @@ -491,20 +506,6 @@ free_rtd: return NULL; } -struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link) -{ - struct snd_soc_pcm_runtime *rtd; - - for_each_card_rtds(card, rtd) { - if (!strcmp(rtd->dai_link->name, dai_link)) - return rtd; - } - dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); - static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; -- cgit v1.2.3 From 4468189ff307f294491628a49702a04de22bffb8 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:08 +0900 Subject: ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime() Current snd_soc_get_pcm_runtime() is finding rtd by checking dai_link name. But, it is strange and waste of CPU power, because its user want to get from rtd from dai_link, not from dai_link name. This patch find rtd via dai_link pointer instead of its name. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87a781yq67.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 2 +- sound/soc/fsl/fsl-asoc-card.c | 2 +- sound/soc/pxa/mioa701_wm9713.c | 2 +- sound/soc/samsung/bells.c | 12 ++++++------ sound/soc/samsung/littlemill.c | 10 +++++----- sound/soc/samsung/snow.c | 2 +- sound/soc/samsung/speyside.c | 4 ++-- sound/soc/samsung/tm2_wm5110.c | 6 +++--- sound/soc/samsung/tobermory.c | 6 +++--- sound/soc/soc-core.c | 8 ++++---- sound/soc/tegra/tegra_wm8903.c | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 68ec5a051afe..40c2a677f531 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -465,7 +465,7 @@ static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) void snd_soc_disconnect_sync(struct device *dev); struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link); + struct snd_soc_dai_link *dai_link); bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd); void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream); diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 39ea9bda1394..9ce55feaac22 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -256,7 +256,7 @@ static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card, unsigned int pll_out; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) return 0; diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index 129eb5251a5f..76e054d514a8 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -72,7 +72,7 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget, struct snd_soc_pcm_runtime *rtd; struct snd_soc_component *component; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event)); } diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c index b60b2268b608..58d8a81aa0ea 100644 --- a/sound/soc/samsung/bells.c +++ b/sound/soc/samsung/bells.c @@ -59,7 +59,7 @@ static int bells_set_bias_level(struct snd_soc_card *card, struct bells_drvdata *bells = card->drvdata; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); codec_dai = rtd->codec_dai; component = codec_dai->component; @@ -105,7 +105,7 @@ static int bells_set_bias_level_post(struct snd_soc_card *card, struct bells_drvdata *bells = card->drvdata; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); codec_dai = rtd->codec_dai; component = codec_dai->component; @@ -151,10 +151,10 @@ static int bells_late_probe(struct snd_soc_card *card) struct snd_soc_dai *wm9081_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_AP_DSP].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_AP_DSP]); wm0010 = rtd->codec_dai->component; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_DSP_CODEC].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_DSP_CODEC]); component = rtd->codec_dai->component; aif1_dai = rtd->codec_dai; @@ -194,7 +194,7 @@ static int bells_late_probe(struct snd_soc_card *card) return ret; } - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_CP].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_CP]); aif2_dai = rtd->cpu_dai; ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); @@ -206,7 +206,7 @@ static int bells_late_probe(struct snd_soc_card *card) if (card->num_rtd == DAI_CODEC_SUB) return 0; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[DAI_CODEC_SUB].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[DAI_CODEC_SUB]); aif3_dai = rtd->cpu_dai; wm9081_dai = rtd->codec_dai; diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c index 6132cee8550b..59904f44118b 100644 --- a/sound/soc/samsung/littlemill.c +++ b/sound/soc/samsung/littlemill.c @@ -22,7 +22,7 @@ static int littlemill_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *aif1_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); aif1_dai = rtd->codec_dai; if (dapm->dev != aif1_dai->dev) @@ -69,7 +69,7 @@ static int littlemill_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *aif1_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); aif1_dai = rtd->codec_dai; if (dapm->dev != aif1_dai->dev) @@ -180,7 +180,7 @@ static int bbclk_ev(struct snd_soc_dapm_widget *w, struct snd_soc_dai *aif2_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); aif2_dai = rtd->cpu_dai; switch (event) { @@ -263,11 +263,11 @@ static int littlemill_late_probe(struct snd_soc_card *card) struct snd_soc_dai *aif2_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; aif1_dai = rtd->codec_dai; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); aif2_dai = rtd->cpu_dai; ret = snd_soc_dai_set_sysclk(aif1_dai, WM8994_SYSCLK_MCLK2, diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index 8ea7799df028..f075aae9561a 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c @@ -106,7 +106,7 @@ static int snow_late_probe(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai *codec_dai; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); /* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */ if (rtd->num_codecs > 1) diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 9e58cbed942a..5ccdfe0eb6fe 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c @@ -24,7 +24,7 @@ static int speyside_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) @@ -60,7 +60,7 @@ static int speyside_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[1]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c index bb9910d4cbe2..10ff14b856f2 100644 --- a/sound/soc/samsung/tm2_wm5110.c +++ b/sound/soc/samsung/tm2_wm5110.c @@ -282,7 +282,7 @@ static int tm2_set_bias_level(struct snd_soc_card *card, { struct snd_soc_pcm_runtime *rtd; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); if (dapm->dev != rtd->codec_dai->dev) return 0; @@ -314,7 +314,7 @@ static int tm2_late_probe(struct snd_soc_card *card) struct snd_soc_dai *aif2_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF1].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF1]); aif1_dai = rtd->codec_dai; priv->component = rtd->codec_dai->component; @@ -324,7 +324,7 @@ static int tm2_late_probe(struct snd_soc_card *card) return ret; } - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF2].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF2]); aif2_dai = rtd->codec_dai; ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c index ef51f289fbc7..fdce28cc26c4 100644 --- a/sound/soc/samsung/tobermory.c +++ b/sound/soc/samsung/tobermory.c @@ -22,7 +22,7 @@ static int tobermory_set_bias_level(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) @@ -65,7 +65,7 @@ static int tobermory_set_bias_level_post(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); codec_dai = rtd->codec_dai; if (dapm->dev != codec_dai->dev) @@ -180,7 +180,7 @@ static int tobermory_late_probe(struct snd_soc_card *card) struct snd_soc_dai *codec_dai; int ret; - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); component = rtd->codec_dai->component; codec_dai = rtd->codec_dai; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f215a37fd3d6..9ee7d5d118c0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -393,15 +393,15 @@ static const struct snd_soc_ops null_snd_soc_ops; struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, - const char *dai_link) + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; for_each_card_rtds(card, rtd) { - if (!strcmp(rtd->dai_link->name, dai_link)) + if (rtd->dai_link == dai_link) return rtd; } - dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); + dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link->name); return NULL; } EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); @@ -1064,7 +1064,7 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, if (card->remove_dai_link) card->remove_dai_link(card, dai_link); - rtd = snd_soc_get_pcm_runtime(card, dai_link->name); + rtd = snd_soc_get_pcm_runtime(card, dai_link); if (rtd) soc_free_pcm_runtime(rtd); } diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 6211dfda2195..f08d3489c3cf 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -186,7 +186,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) static int tegra_wm8903_remove(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd = - snd_soc_get_pcm_runtime(card, card->dai_link[0].name); + snd_soc_get_pcm_runtime(card, &card->dai_link[0]); struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_component *component = codec_dai->component; -- cgit v1.2.3 From d6f31e0e6d09594717ed21c7c9238d9fbdb30ccb Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:14 +0900 Subject: ASoC: soc-core: move snd_soc_find_dai_link() snd_soc_find_dai_link() is soc-topology specific function. We don't need to have it at soc-core. This patch moves it to soc-topology.c Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/878snlyq61.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 3 --- sound/soc/soc-core.c | 44 -------------------------------------------- sound/soc/soc-topology.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 40c2a677f531..09d3d9b615c2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1327,9 +1327,6 @@ int snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); void snd_soc_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); -struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, - int id, const char *name, - const char *stream_name); struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9ee7d5d118c0..bf5bbb1f3cdb 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -901,50 +901,6 @@ struct snd_soc_dai *snd_soc_find_dai( } EXPORT_SYMBOL_GPL(snd_soc_find_dai); -/** - * snd_soc_find_dai_link - Find a DAI link - * - * @card: soc card - * @id: DAI link ID to match - * @name: DAI link name to match, optional - * @stream_name: DAI link stream name to match, optional - * - * This function will search all existing DAI links of the soc card to - * find the link of the same ID. Since DAI links may not have their - * unique ID, so name and stream name should also match if being - * specified. - * - * Return: pointer of DAI link, or NULL if not found. - */ -struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, - int id, const char *name, - const char *stream_name) -{ - struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai_link *link; - - lockdep_assert_held(&client_mutex); - - for_each_card_rtds(card, rtd) { - link = rtd->dai_link; - - if (link->id != id) - continue; - - if (name && (!link->name || strcmp(name, link->name))) - continue; - - if (stream_name && (!link->stream_name - || strcmp(stream_name, link->stream_name))) - continue; - - return link; - } - - return NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_find_dai_link); - static int soc_dai_link_sanity_check(struct snd_soc_card *card, struct snd_soc_dai_link *link) { diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 81d2af000a5c..cbd605b96722 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -2207,6 +2207,47 @@ static int link_new_ver(struct soc_tplg *tplg, return 0; } +/** + * snd_soc_find_dai_link - Find a DAI link + * + * @card: soc card + * @id: DAI link ID to match + * @name: DAI link name to match, optional + * @stream_name: DAI link stream name to match, optional + * + * This function will search all existing DAI links of the soc card to + * find the link of the same ID. Since DAI links may not have their + * unique ID, so name and stream name should also match if being + * specified. + * + * Return: pointer of DAI link, or NULL if not found. + */ +static struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card, + int id, const char *name, + const char *stream_name) +{ + struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dai_link *link; + + for_each_card_rtds(card, rtd) { + link = rtd->dai_link; + + if (link->id != id) + continue; + + if (name && (!link->name || strcmp(name, link->name))) + continue; + + if (stream_name && (!link->stream_name + || strcmp(stream_name, link->stream_name))) + continue; + + return link; + } + + return NULL; +} + /* Find and configure an existing physical DAI link */ static int soc_tplg_link_config(struct soc_tplg *tplg, struct snd_soc_tplg_link_config *cfg) -- cgit v1.2.3 From 0c04800424c42ec3fbe87422d3e04b5c978fc177 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:19 +0900 Subject: ASoC: soc-core: rename snd_soc_add_dai_link() to snd_soc_add_pcm_runtime() Now soc-core and soc-topology is using snd_soc_add_dai_link(). The abstract of this function is "create pcm_runtime from dai_link information and connect it to card". Thus, "add dai_link" is wrong/confusable naming. This patch renames function name. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/877e35yq5w.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 4 ++-- sound/soc/soc-core.c | 18 +++++++++--------- sound/soc/soc-topology.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 09d3d9b615c2..b223b2d39950 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1323,8 +1323,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, struct snd_soc_dai_link *dai_link); void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); -int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link); +int snd_soc_add_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link); void snd_soc_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index bf5bbb1f3cdb..af9da991d99e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1027,18 +1027,18 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card, EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); /** - * snd_soc_add_dai_link - Add a DAI link dynamically - * @card: The ASoC card to which the DAI link is added - * @dai_link: The new DAI link to add + * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link + * @card: The ASoC card to which the pcm_runtime is added + * @dai_link: The DAI link to find pcm_runtime * - * This function adds a DAI link to the ASoC card's link list. + * This function adds a pcm_runtime ASoC card by using dai_link. * - * Note: Topology can use this API to add DAI links when probing the + * Note: Topology can use this API to add pcm_runtime when probing the * topology component. And machine drivers can still define static * DAI links in dai_link array. */ -int snd_soc_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +int snd_soc_add_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codec, *platform; @@ -1107,7 +1107,7 @@ _err_defer: soc_free_pcm_runtime(rtd); return -EPROBE_DEFER; } -EXPORT_SYMBOL_GPL(snd_soc_add_dai_link); +EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); static void soc_set_of_name_prefix(struct snd_soc_component *component) { @@ -1929,7 +1929,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) /* add predefined DAI links to the list */ card->num_rtd = 0; for_each_card_prelinks(card, i, dai_link) { - ret = snd_soc_add_dai_link(card, dai_link); + ret = snd_soc_add_pcm_runtime(card, dai_link); if (ret < 0) goto probe_end; } diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index cbd605b96722..de427881a2ae 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1945,7 +1945,7 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, link->dobj.type = SND_SOC_DOBJ_DAI_LINK; list_add(&link->dobj.list, &tplg->comp->dobj_list); - snd_soc_add_dai_link(tplg->comp->card, link); + snd_soc_add_pcm_runtime(tplg->comp->card, link); return 0; } -- cgit v1.2.3 From 50cd9b5317d5593d0a33f4227f56ddcc1bf66604 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:23 +0900 Subject: ASoC: soc-core: rename snd_soc_remove_dai_link() to snd_soc_remove_pcm_runtime() Now soc-core and soc-topology is using snd_soc_remove_dai_link(). It removes pcm_runtime (= rtd) and disconnect it from card. The purpose is removing pcm_runtime, not dai_link. This patch renames function name. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/875zipyq5s.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 4 ++-- sound/soc/soc-core.c | 29 +++++++++++------------------ sound/soc/soc-topology.c | 4 +++- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index b223b2d39950..3923178ad050 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1325,8 +1325,8 @@ void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); int snd_soc_add_pcm_runtime(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link); +void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd); struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component, struct snd_soc_dai_driver *dai_drv, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index af9da991d99e..f82d521306b7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -998,33 +998,26 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card, } /** - * snd_soc_remove_dai_link - Remove a DAI link from the list - * @card: The ASoC card that owns the link - * @dai_link: The DAI link to remove + * snd_soc_remove_pcm_runtime - Remove a pcm_runtime from card + * @card: The ASoC card to which the pcm_runtime has + * @rtd: The pcm_runtime to remove * - * This function removes a DAI link from the ASoC card's link list. - * - * For DAI links previously added by topology, topology should - * remove them by using the dobj embedded in the link. + * This function removes a pcm_runtime from the ASoC card. */ -void snd_soc_remove_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *dai_link) +void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd; - lockdep_assert_held(&client_mutex); /* * Notify the machine driver for extra destruction */ if (card->remove_dai_link) - card->remove_dai_link(card, dai_link); + card->remove_dai_link(card, rtd->dai_link); - rtd = snd_soc_get_pcm_runtime(card, dai_link); - if (rtd) - soc_free_pcm_runtime(rtd); + soc_free_pcm_runtime(rtd); } -EXPORT_SYMBOL_GPL(snd_soc_remove_dai_link); +EXPORT_SYMBOL_GPL(snd_soc_remove_pcm_runtime); /** * snd_soc_add_pcm_runtime - Add a pcm_runtime dynamically via dai_link @@ -1104,7 +1097,7 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, return 0; _err_defer: - soc_free_pcm_runtime(rtd); + snd_soc_remove_pcm_runtime(card, rtd); return -EPROBE_DEFER; } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); @@ -1871,7 +1864,7 @@ static void soc_cleanup_card_resources(struct snd_soc_card *card, soc_remove_link_components(card); for_each_card_rtds_safe(card, rtd, n) - snd_soc_remove_dai_link(card, rtd->dai_link); + snd_soc_remove_pcm_runtime(card, rtd); /* remove auxiliary devices */ soc_remove_aux_devices(card); diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index de427881a2ae..e9b660f3116f 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -553,7 +553,9 @@ static void remove_link(struct snd_soc_component *comp, kfree(link->cpus->dai_name); list_del(&dobj->list); - snd_soc_remove_dai_link(comp->card, link); + + snd_soc_remove_pcm_runtime(comp->card, + snd_soc_get_pcm_runtime(comp->card, link)); kfree(link); } -- cgit v1.2.3 From 9e9c70a5dd0194f6a30a04d96dd8c1f6ff44f6c4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:27 +0900 Subject: ASoC: soc-core: move soc_link_dai_pcm_new() This patch moves soc_link_dai_pcm_new() to upper side. This is prepare for its cleanup. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/874ky9yq5o.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f82d521306b7..8ace5f5b251c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1102,6 +1102,27 @@ _err_defer: } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); +static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, + struct snd_soc_pcm_runtime *rtd) +{ + int i, ret = 0; + + for (i = 0; i < num_dais; ++i) { + struct snd_soc_dai_driver *drv = dais[i]->driver; + + if (drv->pcm_new) + ret = drv->pcm_new(rtd, dais[i]); + if (ret < 0) { + dev_err(dais[i]->dev, + "ASoC: Failed to bind %s with pcm device\n", + dais[i]->name); + return ret; + } + } + + return 0; +} + static void soc_set_of_name_prefix(struct snd_soc_component *component) { struct device_node *of_node = soc_component_to_node(component); @@ -1379,27 +1400,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; } -static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, - struct snd_soc_pcm_runtime *rtd) -{ - int i, ret = 0; - - for (i = 0; i < num_dais; ++i) { - struct snd_soc_dai_driver *drv = dais[i]->driver; - - if (drv->pcm_new) - ret = drv->pcm_new(rtd, dais[i]); - if (ret < 0) { - dev_err(dais[i]->dev, - "ASoC: Failed to bind %s with pcm device\n", - dais[i]->name); - return ret; - } - } - - return 0; -} - static int soc_link_init(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd) { -- cgit v1.2.3 From bfa0dd89536026e17b074eb2c42089f3455ea1a3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:32 +0900 Subject: ASoC: soc-core: rename soc_link_dai_pcm_new() to soc_dai_pcm_new() soc_link_dai_pcm_new() sounds like dai_link function, but it is not related to it. This patch rename soc_link_dai_pcm_new() to soc_dai_pcm_new(). Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/8736dtyq5j.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8ace5f5b251c..81164b54632a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1102,8 +1102,8 @@ _err_defer: } EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime); -static int soc_link_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, - struct snd_soc_pcm_runtime *rtd) +static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, + struct snd_soc_pcm_runtime *rtd) { int i, ret = 0; @@ -1464,11 +1464,11 @@ static int soc_link_init(struct snd_soc_card *card, dai_link->stream_name, ret); return ret; } - ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); + ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); if (ret < 0) return ret; - ret = soc_link_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); + ret = soc_dai_pcm_new(rtd->codec_dais, + rtd->num_codecs, rtd); return ret; } -- cgit v1.2.3 From 46496acbe1c43cd26f5515b51b5d3c46a97d785d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:36 +0900 Subject: ASoC: soc-core: move soc_link_init() This patch moves soc_link_init() to upper side. This is prepare for its cleanup. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/871rtdyq5g.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 144 +++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 81164b54632a..04cb69072f80 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,6 +1123,78 @@ static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; } +static int soc_link_init(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_component *component; + int ret, num; + + /* set default power off timeout */ + rtd->pmdown_time = pmdown_time; + + /* do machine specific initialization */ + if (dai_link->init) { + ret = dai_link->init(rtd); + if (ret < 0) { + dev_err(card->dev, "ASoC: failed to init %s: %d\n", + dai_link->name, ret); + return ret; + } + } + + if (dai_link->dai_fmt) { + ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); + if (ret) + return ret; + } + + /* add DPCM sysfs entries */ + soc_dpcm_debugfs_add(rtd); + + num = rtd->num; + + /* + * most drivers will register their PCMs using DAI link ordering but + * topology based drivers can use the DAI link id field to set PCM + * device number and then use rtd + a base offset of the BEs. + */ + for_each_rtd_components(rtd, rtdcom, component) { + if (!component->driver->use_dai_pcm_id) + continue; + + if (rtd->dai_link->no_pcm) + num += component->driver->be_pcm_base; + else + num = rtd->dai_link->id; + } + + /* create compress_device if possible */ + ret = snd_soc_dai_compress_new(cpu_dai, rtd, num); + if (ret != -ENOTSUPP) { + if (ret < 0) + dev_err(card->dev, "ASoC: can't create compress %s\n", + dai_link->stream_name); + return ret; + } + + /* create the pcm */ + ret = soc_new_pcm(rtd, num); + if (ret < 0) { + dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", + dai_link->stream_name, ret); + return ret; + } + ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); + if (ret < 0) + return ret; + ret = soc_dai_pcm_new(rtd->codec_dais, + rtd->num_codecs, rtd); + return ret; +} + static void soc_set_of_name_prefix(struct snd_soc_component *component) { struct device_node *of_node = soc_component_to_node(component); @@ -1400,78 +1472,6 @@ static int soc_probe_link_components(struct snd_soc_card *card) return 0; } -static int soc_link_init(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai_link *dai_link = rtd->dai_link; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; - struct snd_soc_component *component; - int ret, num; - - /* set default power off timeout */ - rtd->pmdown_time = pmdown_time; - - /* do machine specific initialization */ - if (dai_link->init) { - ret = dai_link->init(rtd); - if (ret < 0) { - dev_err(card->dev, "ASoC: failed to init %s: %d\n", - dai_link->name, ret); - return ret; - } - } - - if (dai_link->dai_fmt) { - ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); - if (ret) - return ret; - } - - /* add DPCM sysfs entries */ - soc_dpcm_debugfs_add(rtd); - - num = rtd->num; - - /* - * most drivers will register their PCMs using DAI link ordering but - * topology based drivers can use the DAI link id field to set PCM - * device number and then use rtd + a base offset of the BEs. - */ - for_each_rtd_components(rtd, rtdcom, component) { - if (!component->driver->use_dai_pcm_id) - continue; - - if (rtd->dai_link->no_pcm) - num += component->driver->be_pcm_base; - else - num = rtd->dai_link->id; - } - - /* create compress_device if possible */ - ret = snd_soc_dai_compress_new(cpu_dai, rtd, num); - if (ret != -ENOTSUPP) { - if (ret < 0) - dev_err(card->dev, "ASoC: can't create compress %s\n", - dai_link->stream_name); - return ret; - } - - /* create the pcm */ - ret = soc_new_pcm(rtd, num); - if (ret < 0) { - dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", - dai_link->stream_name, ret); - return ret; - } - ret = soc_dai_pcm_new(&cpu_dai, 1, rtd); - if (ret < 0) - return ret; - ret = soc_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); - return ret; -} - static void soc_unbind_aux_dev(struct snd_soc_card *card) { struct snd_soc_component *component, *_component; -- cgit v1.2.3 From 626c2e57a33a7565af03b2eb95989c43be651a03 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:40 +0900 Subject: ASoC: soc-core: add missing return value check for soc_link_init() soc_link_init() returns error code, but snd_soc_bind_card() is not cheking it. This patch adds missing return value check for it. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87zhg1xbkv.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 04cb69072f80..2af3df5d0d72 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; } - for_each_card_rtds(card, rtd) - soc_link_init(card, rtd); + for_each_card_rtds(card, rtd) { + ret = soc_link_init(card, rtd); + if (ret < 0) + goto probe_end; + } snd_soc_dapm_link_dai_widgets(card); snd_soc_dapm_connect_dai_link_widgets(card); -- cgit v1.2.3 From eaffeefbd042a44ca31f60f299a27d899aa4ec26 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:44 +0900 Subject: ASoC: soc-core: rename soc_link_init() to soc_init_pcm_runtime() soc-core is using soc_link_init(). It sounds like dai_link function, but it is for pcm_runtime. This patch renames soc_link_init() to soc_init_pcm_runtime(). Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87y2vlxbkr.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2af3df5d0d72..d18e30ec5a12 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1123,8 +1123,8 @@ static int soc_dai_pcm_new(struct snd_soc_dai **dais, int num_dais, return 0; } -static int soc_link_init(struct snd_soc_card *card, - struct snd_soc_pcm_runtime *rtd) +static int soc_init_pcm_runtime(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; @@ -1984,7 +1984,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card) } for_each_card_rtds(card, rtd) { - ret = soc_link_init(card, rtd); + ret = soc_init_pcm_runtime(card, rtd); if (ret < 0) goto probe_end; } -- cgit v1.2.3 From 4702f99148dae94b00bcb7bbba6cd9ca01651e69 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:48 +0900 Subject: ASoC: soc-core: soc_set_name_prefix(): tidyup loop condition Current soc_set_name_prefix() for loop is checking both codec_conf pointer and its number for (...; i < card->num_configs && card->codec_conf; ...) But, if card->num_configs exists but card->codec_conf was NULL, it is just bug. This patch cleanups for loop condition. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87wob5xbkn.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d18e30ec5a12..a483f6fc50a0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1211,7 +1211,7 @@ static void soc_set_name_prefix(struct snd_soc_card *card, { int i; - for (i = 0; i < card->num_configs && card->codec_conf; i++) { + for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; struct device_node *of_node = soc_component_to_node(component); -- cgit v1.2.3 From aec3ff99ce4a02d9bbe8b7311136edc69bdb739d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 10 Dec 2019 09:34:52 +0900 Subject: ASoC: soc-core: soc_set_name_prefix(): get component device_node at out of loop Component device_node is not related to codec_conf loop at soc_set_name_prefix(). This patch moves it to out of loop. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87v9qpxbkj.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a483f6fc50a0..f662d677229b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1209,11 +1209,11 @@ static void soc_set_of_name_prefix(struct snd_soc_component *component) static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_component *component) { + struct device_node *of_node = soc_component_to_node(component); int i; for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; - struct device_node *of_node = soc_component_to_node(component); if (map->of_node && of_node != map->of_node) continue; -- cgit v1.2.3 From 2aae447a4c100d2a7b7cae26b1df8b329e730d8b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 9 Dec 2019 18:48:53 -0600 Subject: ASoC: SOF: Intel: byt: fixup topology filename for BYT-CR On Baytrail-CR, SSP0 needs to be used instead of SSP2. The substitution is assumed to be done in the topology file. When Baytrail-CR is detected, add -ssp0 suffix to the topology file name so that the topology code picks up the correct file. Tested on Asus T100TAF Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191210004854.16845-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/byt.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index 2f5db1a8c701..ec6ca863243c 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -18,6 +18,7 @@ #include "../ops.h" #include "shim.h" #include "../sof-audio.h" +#include "../../intel/common/soc-intel-quirks.h" /* DSP memories */ #define IRAM_OFFSET 0x0C0000 @@ -383,11 +384,37 @@ static int byt_reset(struct snd_sof_dev *sdev) return 0; } +static const char *fixup_tplg_name(struct snd_sof_dev *sdev, + const char *sof_tplg_filename, + const char *ssp_str) +{ + const char *tplg_filename = NULL; + char *filename; + char *split_ext; + + filename = devm_kstrdup(sdev->dev, sof_tplg_filename, GFP_KERNEL); + if (!filename) + return NULL; + + /* this assumes a .tplg extension */ + split_ext = strsep(&filename, "."); + if (split_ext) { + tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, + "%s-%s.tplg", + split_ext, ssp_str); + if (!tplg_filename) + return NULL; + } + return tplg_filename; +} + static void byt_machine_select(struct snd_sof_dev *sdev) { struct snd_sof_pdata *sof_pdata = sdev->pdata; const struct sof_dev_desc *desc = sof_pdata->desc; struct snd_soc_acpi_mach *mach; + struct platform_device *pdev; + const char *tplg_filename; mach = snd_soc_acpi_find_machine(desc->machines); if (!mach) { @@ -395,7 +422,25 @@ static void byt_machine_select(struct snd_sof_dev *sdev) return; } - sof_pdata->tplg_filename = mach->sof_tplg_filename; + pdev = to_platform_device(sdev->dev); + if (soc_intel_is_byt_cr(pdev)) { + dev_dbg(sdev->dev, + "BYT-CR detected, SSP0 used instead of SSP2\n"); + + tplg_filename = fixup_tplg_name(sdev, + mach->sof_tplg_filename, + "ssp0"); + } else { + tplg_filename = mach->sof_tplg_filename; + } + + if (!tplg_filename) { + dev_dbg(sdev->dev, + "error: no topology filename\n"); + return; + } + + sof_pdata->tplg_filename = tplg_filename; mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; sof_pdata->machine = mach; } -- cgit v1.2.3 From 88452da92ba2b264a3922218c2cec13aac51c502 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:57:27 +0100 Subject: ALSA: hda: Use standard waitqueue for RIRB wakeup The HD-audio CORB/RIRB communication was programmed in a way that was documented in the reference in decades ago, which is essentially a polling in the waiter side. It's working fine but costs CPU cycles on some platforms that support only slow communications. Also, for some platforms that had unreliable communications, we put longer wait time (2 ms), which accumulate quite long time if you execute many verbs in a shot (e.g. at the initialization or resume phase). This patch attempts to improve the situation by introducing the standard waitqueue in the RIRB waiter side instead of polling. The test results on my machine show significant improvements. The time spent for "cat /proc/asound/card*/codec#*" were changed like: * Intel SKL + Realtek codec before the patch: 0.00user 0.04system 0:00.10elapsed 40.0%CPU after the patch: 0.00user 0.01system 0:00.10elapsed 10.0%CPU * Nvidia GP107GL + Nvidia HDMI codec before the patch: 0.00user 0.00system 0:02.76elapsed 0.0%CPU after the patch: 0.00user 0.00system 0:00.01elapsed 17.0%CPU So, for Intel chips, the total time is same, while the total time is greatly reduced (from 2.76 to 0.01s) for Nvidia chips. The only negative data here is the increase of CPU time for Nvidia, but this is the unavoidable cost for faster wakeups, supposedly. Link: https://lore.kernel.org/r/20191210145727.22054-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/hdaudio.h | 1 + sound/hda/hdac_bus.c | 1 + sound/hda/hdac_controller.c | 3 +++ sound/pci/hda/hda_controller.c | 29 ++++++++++++++--------------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index e05b95e83d5a..81373a2efd96 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -317,6 +317,7 @@ struct hdac_bus { struct hdac_rb corb; struct hdac_rb rirb; unsigned int last_cmd[HDA_MAX_CODECS]; /* last sent command */ + wait_queue_head_t rirb_wq; /* CORB/RIRB and position buffers */ struct snd_dma_buffer rb; diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c index 8f19876244eb..48b227fff204 100644 --- a/sound/hda/hdac_bus.c +++ b/sound/hda/hdac_bus.c @@ -43,6 +43,7 @@ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, mutex_init(&bus->cmd_mutex); mutex_init(&bus->lock); INIT_LIST_HEAD(&bus->hlink_list); + init_waitqueue_head(&bus->rirb_wq); bus->irq = -1; return 0; } diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index 7e7be8e4dcf9..cd1c3b282657 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -216,6 +216,9 @@ void snd_hdac_bus_update_rirb(struct hdac_bus *bus) else if (bus->rirb.cmds[addr]) { bus->rirb.res[addr] = res; bus->rirb.cmds[addr]--; + if (!bus->rirb.cmds[addr] && + waitqueue_active(&bus->rirb_wq)) + wake_up(&bus->rirb_wq); } else { dev_err_ratelimited(bus->dev, "spurious response %#x:%#x, last cmd=%#08x\n", diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 2f3b7a35f2d9..f30a053d981e 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -792,21 +792,25 @@ static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr, struct hda_bus *hbus = &chip->bus; unsigned long timeout; unsigned long loopcounter; - int do_poll = 0; + wait_queue_entry_t wait; bool warned = false; + init_wait_entry(&wait, 0); again: timeout = jiffies + msecs_to_jiffies(1000); for (loopcounter = 0;; loopcounter++) { spin_lock_irq(&bus->reg_lock); - if (bus->polling_mode || do_poll) + if (!bus->polling_mode) + prepare_to_wait(&bus->rirb_wq, &wait, + TASK_UNINTERRUPTIBLE); + if (bus->polling_mode) snd_hdac_bus_update_rirb(bus); if (!bus->rirb.cmds[addr]) { - if (!do_poll) - bus->poll_count = 0; if (res) *res = bus->rirb.res[addr]; /* the last value */ + if (!bus->polling_mode) + finish_wait(&bus->rirb_wq, &wait); spin_unlock_irq(&bus->reg_lock); return 0; } @@ -814,7 +818,9 @@ static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr, if (time_after(jiffies, timeout)) break; #define LOOP_COUNT_MAX 3000 - if (hbus->needs_damn_long_delay || + if (!bus->polling_mode) { + schedule_timeout(msecs_to_jiffies(2)); + } else if (hbus->needs_damn_long_delay || loopcounter > LOOP_COUNT_MAX) { if (loopcounter > LOOP_COUNT_MAX && !warned) { dev_dbg_ratelimited(chip->card->dev, @@ -829,19 +835,12 @@ static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr, } } + if (!bus->polling_mode) + finish_wait(&bus->rirb_wq, &wait); + if (hbus->no_response_fallback) return -EIO; - if (!bus->polling_mode && bus->poll_count < 2) { - dev_dbg(chip->card->dev, - "azx_get_response timeout, polling the codec once: last cmd=0x%08x\n", - bus->last_cmd[addr]); - do_poll = 1; - bus->poll_count++; - goto again; - } - - if (!bus->polling_mode) { dev_warn(chip->card->dev, "azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n", -- cgit v1.2.3 From 9b2433a9c5b3921ea08c451e85c8783d7033825b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:33 +0100 Subject: ALSA: aoa: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/pcm.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index a94e4023fadf..44397e72c868 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -294,12 +294,6 @@ void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev) } #endif -static int i2sbus_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in) { struct i2sbus_dev *i2sdev = snd_pcm_substream_chip(substream); @@ -308,7 +302,6 @@ static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in) get_pcm_info(i2sdev, in, &pi, NULL); if (pi->dbdma_ring.stopping) i2sbus_wait_for_stop(i2sdev, pi); - snd_pcm_lib_free_pages(substream); return 0; } @@ -781,7 +774,6 @@ static const struct snd_pcm_ops i2sbus_playback_ops = { .open = i2sbus_playback_open, .close = i2sbus_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = i2sbus_hw_params, .hw_free = i2sbus_playback_hw_free, .prepare = i2sbus_playback_prepare, .trigger = i2sbus_playback_trigger, @@ -851,7 +843,6 @@ static const struct snd_pcm_ops i2sbus_record_ops = { .open = i2sbus_record_open, .close = i2sbus_record_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = i2sbus_hw_params, .hw_free = i2sbus_record_hw_free, .prepare = i2sbus_record_prepare, .trigger = i2sbus_record_trigger, @@ -1026,7 +1017,7 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, dev->pcm->private_free = i2sbus_private_free; /* well, we really should support scatter/gather DMA */ - snd_pcm_lib_preallocate_pages_for_all( + snd_pcm_set_managed_buffer_all( dev->pcm, SNDRV_DMA_TYPE_DEV, &macio_get_pci_dev(i2sdev->macio)->dev, 64 * 1024, 64 * 1024); -- cgit v1.2.3 From 8ee0c7586959551025cb5b894539003340a352ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:34 +0100 Subject: ALSA: aaci: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, and the if block is flattened accordingly. Link: https://lore.kernel.org/r/20191209094943.14984-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index b5399b0090a7..1e9ea0fe4f49 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -483,11 +483,6 @@ static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) snd_ac97_pcm_close(aacirun->pcm); aacirun->pcm_open = 0; - /* - * Clear out the DMA and any allocated buffers. - */ - snd_pcm_lib_free_pages(substream); - return 0; } @@ -502,6 +497,7 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct aaci_runtime *aacirun = substream->runtime->private_data; + struct aaci *aaci = substream->private_data; unsigned int channels = params_channels(params); unsigned int rate = params_rate(params); int dbl = rate > 48000; @@ -517,25 +513,19 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, if (dbl && channels != 2) return -EINVAL; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(params)); - if (err >= 0) { - struct aaci *aaci = substream->private_data; + err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, + aacirun->pcm->r[dbl].slots); - err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, - aacirun->pcm->r[dbl].slots); + aacirun->pcm_open = err == 0; + aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; + aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; - aacirun->pcm_open = err == 0; - aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16; - aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; - - /* - * fifo_bytes is the number of bytes we transfer to/from - * the FIFO, including padding. So that's x4. As we're - * in compact mode, the FIFO is half the size. - */ - aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2; - } + /* + * fifo_bytes is the number of bytes we transfer to/from + * the FIFO, including padding. So that's x4. As we're + * in compact mode, the FIFO is half the size. + */ + aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2; return err; } @@ -937,9 +927,9 @@ static int aaci_init_pcm(struct aaci *aaci) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - aaci->card->dev, - 0, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + aaci->card->dev, + 0, 64 * 1024); } return ret; -- cgit v1.2.3 From 37b9b9a5078aa2efe2131d7b0084ebd4192fb1f5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:35 +0100 Subject: ALSA: atmel: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index eef7ec77db1a..44507e43ed28 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -159,12 +159,6 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval; /* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -172,19 +166,13 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex); - return retval; + return 0; } static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval; /* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -192,7 +180,7 @@ static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex); - return retval; + return 0; } static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream) @@ -461,7 +449,6 @@ static const struct snd_pcm_ops atmel_ac97_playback_ops = { .close = atmel_ac97c_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_playback_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_playback_prepare, .trigger = atmel_ac97c_playback_trigger, .pointer = atmel_ac97c_playback_pointer, @@ -472,7 +459,6 @@ static const struct snd_pcm_ops atmel_ac97_capture_ops = { .close = atmel_ac97c_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_capture_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_capture_prepare, .trigger = atmel_ac97c_capture_trigger, .pointer = atmel_ac97c_capture_pointer, @@ -600,7 +586,7 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pdev->dev, hw.periods_min * hw.period_bytes_min, hw.buffer_bytes_max); -- cgit v1.2.3 From 39729889b1f58ae42036383fc51abd067eeb4af9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:36 +0100 Subject: ALSA: aloop: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 6bb46423f5ae..104fb738cf48 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -905,12 +905,6 @@ static void loopback_runtime_free(struct snd_pcm_runtime *runtime) kfree(dpcm); } -static int loopback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - static int loopback_hw_free(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -920,7 +914,7 @@ static int loopback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&dpcm->loopback->cable_lock); cable->valid &= ~(1 << substream->stream); mutex_unlock(&dpcm->loopback->cable_lock); - return snd_pcm_lib_free_pages(substream); + return 0; } static unsigned int get_cable_index(struct snd_pcm_substream *substream) @@ -1306,7 +1300,6 @@ static const struct snd_pcm_ops loopback_pcm_ops = { .open = loopback_open, .close = loopback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = loopback_hw_params, .hw_free = loopback_hw_free, .prepare = loopback_prepare, .trigger = loopback_trigger, @@ -1325,8 +1318,7 @@ static int loopback_pcm_new(struct loopback *loopback, return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &loopback_pcm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &loopback_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); pcm->private_data = loopback; pcm->info_flags = 0; -- cgit v1.2.3 From ef1545b8f35e230e7e7aae7d01647d151fd8e87a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:37 +0100 Subject: ALSA: dummy: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/dummy.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 022a0db692e0..ab6062dcd1b3 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -529,15 +529,7 @@ static int dummy_pcm_hw_params(struct snd_pcm_substream *substream, substream->runtime->dma_bytes = params_buffer_bytes(hw_params); return 0; } - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int dummy_pcm_hw_free(struct snd_pcm_substream *substream) -{ - if (fake_buffer) - return 0; - return snd_pcm_lib_free_pages(substream); + return 0; } static int dummy_pcm_open(struct snd_pcm_substream *substream) @@ -657,7 +649,6 @@ static struct snd_pcm_ops dummy_pcm_ops = { .close = dummy_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, - .hw_free = dummy_pcm_hw_free, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, .pointer = dummy_pcm_pointer, @@ -668,7 +659,6 @@ static struct snd_pcm_ops dummy_pcm_ops_no_buf = { .close = dummy_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, - .hw_free = dummy_pcm_hw_free, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, .pointer = dummy_pcm_pointer, @@ -700,7 +690,7 @@ static int snd_card_dummy_pcm(struct snd_dummy *dummy, int device, pcm->info_flags = 0; strcpy(pcm->name, "Dummy PCM"); if (!fake_buffer) { - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, NULL, 0, 64*1024); -- cgit v1.2.3 From cbd0719d5115a70bd1a1a8958eef504ddb867368 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:38 +0100 Subject: ALSA: ml403: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous (they were only useless debug prints) and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-7-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/ml403-ac97cr.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index 70a6d1832698..fad63783b4ae 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -670,23 +670,6 @@ snd_ml403_ac97cr_pcm_capture_prepare(struct snd_pcm_substream *substream) return 0; } -static int snd_ml403_ac97cr_hw_free(struct snd_pcm_substream *substream) -{ - PDEBUG(WORK_INFO, "hw_free()\n"); - return snd_pcm_lib_free_pages(substream); -} - -static int -snd_ml403_ac97cr_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - PDEBUG(WORK_INFO, "hw_params(): desired buffer bytes=%d, desired " - "period bytes=%d\n", - params_buffer_bytes(hw_params), params_period_bytes(hw_params)); - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - static int snd_ml403_ac97cr_playback_open(struct snd_pcm_substream *substream) { struct snd_ml403_ac97cr *ml403_ac97cr; @@ -749,8 +732,6 @@ static const struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { .open = snd_ml403_ac97cr_playback_open, .close = snd_ml403_ac97cr_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ml403_ac97cr_hw_params, - .hw_free = snd_ml403_ac97cr_hw_free, .prepare = snd_ml403_ac97cr_pcm_playback_prepare, .trigger = snd_ml403_ac97cr_pcm_playback_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, @@ -760,8 +741,6 @@ static const struct snd_pcm_ops snd_ml403_ac97cr_capture_ops = { .open = snd_ml403_ac97cr_capture_open, .close = snd_ml403_ac97cr_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ml403_ac97cr_hw_params, - .hw_free = snd_ml403_ac97cr_hw_free, .prepare = snd_ml403_ac97cr_pcm_capture_prepare, .trigger = snd_ml403_ac97cr_pcm_capture_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, @@ -1241,10 +1220,10 @@ snd_ml403_ac97cr_pcm(struct snd_ml403_ac97cr *ml403_ac97cr, int device) strcpy(pcm->name, "ML403AC97CR DAC/ADC"); ml403_ac97cr->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64 * 1024, - 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64 * 1024, + 128 * 1024); return 0; } -- cgit v1.2.3 From d635f09e919e6ea9214a7676e26ef6755b3453a0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:39 +0100 Subject: ALSA: pcsp: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-8-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/pcsp/pcsp_lib.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index f91316bf01cb..4fdc4dbdae57 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -214,12 +214,7 @@ static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_pcsp *chip = snd_pcm_substream_chip(substream); - int err; pcsp_sync_stop(chip); - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; return 0; } @@ -230,7 +225,7 @@ static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream) printk(KERN_INFO "PCSP: hw_free called\n"); #endif pcsp_sync_stop(chip); - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream) @@ -350,11 +345,11 @@ int snd_pcsp_new_pcm(struct snd_pcsp *chip) chip->pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; strcpy(chip->pcm->name, "pcsp"); - snd_pcm_lib_preallocate_pages_for_all(chip->pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - PCSP_BUFFER_SIZE, - PCSP_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(chip->pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + PCSP_BUFFER_SIZE, + PCSP_BUFFER_SIZE); return 0; } -- cgit v1.2.3 From 8f326303b0d89a6f7efaa56e4c02d6584c6d61df Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:40 +0100 Subject: ALSA: vx: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-9-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/vx/vx_pcm.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index f17e0a76c73c..615e8b2b85f6 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -772,23 +772,6 @@ static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs) return pipe->position; } -/* - * vx_pcm_hw_params - hw_params callback for playback and capture - */ -static int vx_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * vx_pcm_hw_free - hw_free callback for playback and capture - */ -static int vx_pcm_hw_free(struct snd_pcm_substream *subs) -{ - return snd_pcm_lib_free_pages(subs); -} - /* * vx_pcm_prepare - prepare callback for playback and capture */ @@ -861,8 +844,6 @@ static const struct snd_pcm_ops vx_pcm_playback_ops = { .open = vx_pcm_playback_open, .close = vx_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = vx_pcm_hw_params, - .hw_free = vx_pcm_hw_free, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_playback_pointer, @@ -1081,8 +1062,6 @@ static const struct snd_pcm_ops vx_pcm_capture_ops = { .open = vx_pcm_capture_open, .close = vx_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = vx_pcm_hw_params, - .hw_free = vx_pcm_hw_free, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_capture_pointer, @@ -1230,9 +1209,9 @@ int snd_vx_pcm_new(struct vx_core *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &vx_pcm_playback_ops); if (ins) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &vx_pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), - 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), + 0, 0); pcm->private_data = chip; pcm->private_free = snd_vx_pcm_free; -- cgit v1.2.3 From 7641d549b13bbb1dcc6c7759c010c1ca288c90be Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:41 +0100 Subject: ALSA: firewire: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Acked-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191209192422.23902-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/firewire/bebob/bebob_pcm.c | 11 +++-------- sound/firewire/dice/dice-pcm.c | 13 ++++--------- sound/firewire/digi00x/digi00x-pcm.c | 11 +++-------- sound/firewire/fireface/ff-pcm.c | 11 +++-------- sound/firewire/fireworks/fireworks_pcm.c | 11 +++-------- sound/firewire/isight.c | 10 ++-------- sound/firewire/motu/motu-pcm.c | 11 +++-------- sound/firewire/oxfw/oxfw-pcm.c | 19 +++++-------------- sound/firewire/tascam/tascam-pcm.c | 11 +++-------- 9 files changed, 29 insertions(+), 79 deletions(-) diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..5fbf1d74c544 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_bebob *bebob = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&bebob->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int @@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) "%s PCM", bebob->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index be79d659eedf..2700f7f6f754 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -264,11 +264,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_dice *dice = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&dice->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int capture_prepare(struct snd_pcm_substream *substream) @@ -457,9 +453,8 @@ int snd_dice_create_pcm(struct snd_dice *dice) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); } return 0; diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index 57cbce4fd836..bacf9b860f3f 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -188,11 +188,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_dg00x *dg00x = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&dg00x->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) "%s PCM", dg00x->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index bd91c6ecb112..a52a4344ec6f 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -228,11 +228,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_ff *ff = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&ff->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) "%s PCM", ff->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index e69896d748df..8e60d22acbcc 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -248,11 +248,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_efw *efw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&efw->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index d9f1b962bfef..214f77b0e8b7 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct isight *isight = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; WRITE_ONCE(isight->pcm_active, true); @@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream) isight_stop_streaming(isight); mutex_unlock(&isight->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int isight_start_streaming(struct isight *isight) @@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight) strcpy(pcm->name, "iSight"); isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; isight->pcm->ops = &ops; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index 005970931030..931978eb30c9 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_motu *motu = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&motu->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int capture_prepare(struct snd_pcm_substream *substream) @@ -374,8 +370,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 67fd3e844dd6..974e53bbae10 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -237,11 +237,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_oxfw *oxfw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -264,11 +260,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_oxfw *oxfw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&oxfw->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_playback_hw_free(struct snd_pcm_substream *substream) { @@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&oxfw->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); if (cap > 0) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c index 8e9b444c8bff..92551ca3460c 100644 --- a/sound/firewire/tascam/tascam-pcm.c +++ b/sound/firewire/tascam/tascam-pcm.c @@ -117,11 +117,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_tscm *tscm = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0; if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) mutex_unlock(&tscm->mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) "%s PCM", tscm->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } -- cgit v1.2.3 From d577b6c8cf8ccaafda419a40af05c2eadac27bf7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:42 +0100 Subject: ALSA: ad1816a: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-11-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index c4c60ebe2417..adc35051c5e9 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -206,17 +206,6 @@ static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int SNDRV_PCM_STREAM_CAPTURE, cmd, 1); } -static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream) { struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); @@ -645,8 +634,6 @@ static const struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1816a_hw_params, - .hw_free = snd_ad1816a_hw_free, .prepare = snd_ad1816a_playback_prepare, .trigger = snd_ad1816a_playback_trigger, .pointer = snd_ad1816a_playback_pointer, @@ -656,8 +643,6 @@ static const struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1816a_hw_params, - .hw_free = snd_ad1816a_hw_free, .prepare = snd_ad1816a_capture_prepare, .trigger = snd_ad1816a_capture_trigger, .pointer = snd_ad1816a_capture_pointer, @@ -680,9 +665,8 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device) strcpy(pcm->name, snd_ad1816a_chip_id(chip)); snd_ad1816a_init(chip); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->card->dev, - 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, + 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); chip->pcm = pcm; return 0; -- cgit v1.2.3 From 427f0ea46fb041c5397abc83906b910ec9b96825 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:43 +0100 Subject: ALSA: cmi8330: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The actual removal of superfluous code will be done in ad1848 and sb codec drivers later. Link: https://lore.kernel.org/r/20191209094943.14984-12-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/cmi8330.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index bb7d4940ac25..f8ec59a5bb8f 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -455,9 +455,8 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &chip->streams[SNDRV_PCM_STREAM_PLAYBACK].ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + card->dev, 64*1024, 128*1024); chip->pcm = pcm; return 0; -- cgit v1.2.3 From eb40b64f289717e0e9d07bc57a241e692ff31640 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:44 +0100 Subject: ALSA: es1688: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-13-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688_lib.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index a28dabaae0d3..d2c268595168 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -341,17 +341,6 @@ static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char va return 0; } -static int snd_es1688_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_es1688_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; @@ -693,8 +682,6 @@ static const struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, .ioctl = snd_es1688_ioctl, - .hw_params = snd_es1688_hw_params, - .hw_free = snd_es1688_hw_free, .prepare = snd_es1688_playback_prepare, .trigger = snd_es1688_playback_trigger, .pointer = snd_es1688_playback_pointer, @@ -704,8 +691,6 @@ static const struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, .ioctl = snd_es1688_ioctl, - .hw_params = snd_es1688_hw_params, - .hw_free = snd_es1688_hw_free, .prepare = snd_es1688_capture_prepare, .trigger = snd_es1688_capture_trigger, .pointer = snd_es1688_capture_pointer, @@ -728,9 +713,8 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device) strcpy(pcm->name, snd_es1688_chip_id(chip)); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, 64*1024); return 0; } -- cgit v1.2.3 From 9ce57056d8ce15972b5547559e8f4e5d2013c4ec Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:45 +0100 Subject: ALSA: es18xx: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-14-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 01ad15086c4a..1346447ffe01 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -434,7 +434,7 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); - int shift, err; + int shift; shift = 0; if (params_channels(hw_params) == 2) @@ -453,16 +453,9 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, } else { chip->dma1_shift = shift; } - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; return 0; } -static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, struct snd_pcm_substream *substream) { @@ -543,7 +536,7 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); - int shift, err; + int shift; shift = 0; if ((chip->caps & ES18XX_DUPLEX_MONO) && @@ -557,8 +550,6 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, if (snd_pcm_format_width(params_format(hw_params)) == 16) shift++; chip->dma1_shift = shift; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; return 0; } @@ -915,7 +906,6 @@ static int snd_es18xx_playback_close(struct snd_pcm_substream *substream) else chip->playback_b_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } @@ -924,7 +914,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) struct snd_es18xx *chip = snd_pcm_substream_chip(substream); chip->capture_a_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } @@ -1656,7 +1645,6 @@ static const struct snd_pcm_ops snd_es18xx_playback_ops = { .close = snd_es18xx_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_playback_hw_params, - .hw_free = snd_es18xx_pcm_hw_free, .prepare = snd_es18xx_playback_prepare, .trigger = snd_es18xx_playback_trigger, .pointer = snd_es18xx_playback_pointer, @@ -1667,7 +1655,6 @@ static const struct snd_pcm_ops snd_es18xx_capture_ops = { .close = snd_es18xx_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_capture_hw_params, - .hw_free = snd_es18xx_pcm_hw_free, .prepare = snd_es18xx_capture_prepare, .trigger = snd_es18xx_capture_trigger, .pointer = snd_es18xx_capture_pointer, @@ -1701,10 +1688,9 @@ static int snd_es18xx_pcm(struct snd_card *card, int device) sprintf(pcm->name, "ESS AudioDrive ES%x", chip->version); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, - chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, + chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); return 0; } -- cgit v1.2.3 From 07ed72ba4d45601313848664e97cb2fc5d71f45d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:46 +0100 Subject: ALSA: sb: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-15-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16_main.c | 21 ++------------------- sound/isa/sb/sb8_main.c | 21 ++------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 0768bbf8fd71..07ebf2c49443 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -232,18 +232,6 @@ static void snd_sb16_setup_rate(struct snd_sb *chip, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static int snd_sb16_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_sb16_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; @@ -830,8 +818,6 @@ static const struct snd_pcm_ops snd_sb16_playback_ops = { .open = snd_sb16_playback_open, .close = snd_sb16_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sb16_hw_params, - .hw_free = snd_sb16_hw_free, .prepare = snd_sb16_playback_prepare, .trigger = snd_sb16_playback_trigger, .pointer = snd_sb16_playback_pointer, @@ -841,8 +827,6 @@ static const struct snd_pcm_ops snd_sb16_capture_ops = { .open = snd_sb16_capture_open, .close = snd_sb16_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sb16_hw_params, - .hw_free = snd_sb16_hw_free, .prepare = snd_sb16_capture_prepare, .trigger = snd_sb16_capture_trigger, .pointer = snd_sb16_capture_pointer, @@ -873,9 +857,8 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device) pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; } - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + card->dev, 64*1024, 128*1024); return 0; } diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 8221b85bb330..5804fa523600 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -225,18 +225,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, return 0; } -static int snd_sb8_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_sb8_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; @@ -559,8 +547,6 @@ static const struct snd_pcm_ops snd_sb8_playback_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sb8_hw_params, - .hw_free = snd_sb8_hw_free, .prepare = snd_sb8_playback_prepare, .trigger = snd_sb8_playback_trigger, .pointer = snd_sb8_playback_pointer, @@ -570,8 +556,6 @@ static const struct snd_pcm_ops snd_sb8_capture_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sb8_hw_params, - .hw_free = snd_sb8_hw_free, .prepare = snd_sb8_capture_prepare, .trigger = snd_sb8_capture_trigger, .pointer = snd_sb8_capture_pointer, @@ -595,9 +579,8 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device) if (chip->dma8 > 3 || chip->dma16 >= 0) max_prealloc = 128 * 1024; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, max_prealloc); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + card->dev, 64*1024, max_prealloc); return 0; } -- cgit v1.2.3 From a57214e5486254d3242b863fe82309633c4cdb06 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:47 +0100 Subject: ALSA: gus: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-16-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_pcm.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 6385b61aa094..bd3a54bc4a94 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -423,11 +423,8 @@ static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_gus_card *gus = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct gus_pcm_private *pcmp = runtime->private_data; - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - if (err > 0) { /* change */ + + if (runtime->buffer_changed) { struct snd_gf1_mem_block *block; if (pcmp->memory > 0) { snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory); @@ -471,7 +468,6 @@ static int snd_gf1_pcm_playback_hw_free(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct gus_pcm_private *pcmp = runtime->private_data; - snd_pcm_lib_free_pages(substream); if (pcmp->pvoices[0]) { snd_gf1_free_voice(pcmp->gus, pcmp->pvoices[0]); pcmp->pvoices[0] = NULL; @@ -574,12 +570,7 @@ static int snd_gf1_pcm_capture_hw_params(struct snd_pcm_substream *substream, gus->gf1.pcm_rcntrl_reg |= 4; if (snd_pcm_format_unsigned(params_format(hw_params))) gus->gf1.pcm_rcntrl_reg |= 0x80; - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_gf1_pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -846,7 +837,6 @@ static const struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .close = snd_gf1_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_gf1_pcm_capture_hw_params, - .hw_free = snd_gf1_pcm_capture_hw_free, .prepare = snd_gf1_pcm_capture_prepare, .trigger = snd_gf1_pcm_capture_trigger, .pointer = snd_gf1_pcm_capture_pointer, @@ -875,9 +865,9 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops); for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + card->dev, + 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024); pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; @@ -885,9 +875,9 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_gf1_pcm_capture_ops); if (gus->gf1.dma2 == gus->gf1.dma1) pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, card->dev, - 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024); } strcpy(pcm->name, pcm->id); if (gus->interwave) { -- cgit v1.2.3 From 15fbacfe3d32d60044e27e7d00f24bfaca943449 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:48 +0100 Subject: ALSA: wss: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-17-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index c43f2602249b..0ef89c97ccd2 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -982,10 +982,7 @@ static int snd_wss_playback_hw_params(struct snd_pcm_substream *substream, { struct snd_wss *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; - int err; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; new_pdfr = snd_wss_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_wss_get_rate(params_rate(hw_params)); @@ -993,11 +990,6 @@ static int snd_wss_playback_hw_params(struct snd_pcm_substream *substream, return 0; } -static int snd_wss_playback_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_wss_playback_prepare(struct snd_pcm_substream *substream) { struct snd_wss *chip = snd_pcm_substream_chip(substream); @@ -1025,10 +1017,7 @@ static int snd_wss_capture_hw_params(struct snd_pcm_substream *substream, { struct snd_wss *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; - int err; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; new_cdfr = snd_wss_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_wss_get_rate(params_rate(hw_params)); @@ -1036,11 +1025,6 @@ static int snd_wss_capture_hw_params(struct snd_pcm_substream *substream, return 0; } -static int snd_wss_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_wss_capture_prepare(struct snd_pcm_substream *substream) { struct snd_wss *chip = snd_pcm_substream_chip(substream); @@ -1889,7 +1873,6 @@ static const struct snd_pcm_ops snd_wss_playback_ops = { .close = snd_wss_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_playback_hw_params, - .hw_free = snd_wss_playback_hw_free, .prepare = snd_wss_playback_prepare, .trigger = snd_wss_trigger, .pointer = snd_wss_playback_pointer, @@ -1900,7 +1883,6 @@ static const struct snd_pcm_ops snd_wss_capture_ops = { .close = snd_wss_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_capture_hw_params, - .hw_free = snd_wss_capture_hw_free, .prepare = snd_wss_capture_prepare, .trigger = snd_wss_trigger, .pointer = snd_wss_capture_pointer, @@ -1927,9 +1909,8 @@ int snd_wss_pcm(struct snd_wss *chip, int device) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_wss_chip_id(chip)); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->card->dev, - 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, + 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); chip->pcm = pcm; return 0; -- cgit v1.2.3 From ee88f4ebe57523889fc437bc42f95d9ab89bdd9f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:49 +0100 Subject: ALSA: mips: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-18-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/mips/hal2.c | 25 ++----------------------- sound/mips/sgio2audio.c | 20 ++------------------ 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index c9e060939708..e80ebe521218 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -505,23 +505,6 @@ static const struct snd_pcm_hardware hal2_pcm_hw = { .periods_max = 1024, }; -static int hal2_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - - return 0; -} - -static int hal2_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int hal2_playback_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -702,8 +685,6 @@ static const struct snd_pcm_ops hal2_playback_ops = { .open = hal2_playback_open, .close = hal2_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hal2_pcm_hw_params, - .hw_free = hal2_pcm_hw_free, .prepare = hal2_playback_prepare, .trigger = hal2_playback_trigger, .pointer = hal2_playback_pointer, @@ -714,8 +695,6 @@ static const struct snd_pcm_ops hal2_capture_ops = { .open = hal2_capture_open, .close = hal2_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hal2_pcm_hw_params, - .hw_free = hal2_pcm_hw_free, .prepare = hal2_capture_prepare, .trigger = hal2_capture_trigger, .pointer = hal2_capture_pointer, @@ -740,8 +719,8 @@ static int hal2_pcm_create(struct snd_hal2 *hal2) &hal2_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &hal2_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 0, 1024 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 0, 1024 * 1024); return 0; } diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 9d20ce6118a0..481f5ffff61b 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -577,20 +577,6 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream) return 0; } - -/* hw_params callback */ -static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -/* hw_free callback */ -static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* prepare callback */ static int snd_sgio2audio_pcm_prepare(struct snd_pcm_substream *substream) { @@ -716,8 +702,7 @@ static int snd_sgio2audio_new_pcm(struct snd_sgio2audio *chip) &snd_sgio2audio_playback1_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sgio2audio_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); /* create second pcm device with one outputs and no input */ err = snd_pcm_new(chip->card, "SGI O2 Audio", 1, 1, 0, &pcm); @@ -730,8 +715,7 @@ static int snd_sgio2audio_new_pcm(struct snd_sgio2audio *chip) /* set operators */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sgio2audio_playback2_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); return 0; } -- cgit v1.2.3 From 005f3e67a855f6d1deaea84e0ab8e40c597ad10c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:50 +0100 Subject: ALSA: parisc: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-19-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 6acc59c25379..1a4c40aafcbe 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -567,20 +567,12 @@ static int snd_harmony_hw_params(struct snd_pcm_substream *ss, struct snd_pcm_hw_params *hw) { - int err; struct snd_harmony *h = snd_pcm_substream_chip(ss); - err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); - if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) + if (h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) ss->runtime->dma_addr = __pa(ss->runtime->dma_area); - - return err; -} -static int -snd_harmony_hw_free(struct snd_pcm_substream *ss) -{ - return snd_pcm_lib_free_pages(ss); + return 0; } static const struct snd_pcm_ops snd_harmony_playback_ops = { @@ -588,7 +580,6 @@ static const struct snd_pcm_ops snd_harmony_playback_ops = { .close = snd_harmony_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, - .hw_free = snd_harmony_hw_free, .prepare = snd_harmony_playback_prepare, .trigger = snd_harmony_playback_trigger, .pointer = snd_harmony_playback_pointer, @@ -599,7 +590,6 @@ static const struct snd_pcm_ops snd_harmony_capture_ops = { .close = snd_harmony_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, - .hw_free = snd_harmony_hw_free, .prepare = snd_harmony_capture_prepare, .trigger = snd_harmony_capture_trigger, .pointer = snd_harmony_capture_pointer, @@ -656,8 +646,8 @@ snd_harmony_pcm_init(struct snd_harmony *h) } /* pre-allocate space for DMA */ - snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev, - MAX_BUF_SIZE, MAX_BUF_SIZE); + snd_pcm_set_managed_buffer_all(pcm, h->dma.type, h->dma.dev, + MAX_BUF_SIZE, MAX_BUF_SIZE); h->st.format = snd_harmony_set_data_format(h, SNDRV_PCM_FORMAT_S16_BE, 1); -- cgit v1.2.3 From 93d6487f7a81527d0d43028bc805d3b1aa9f80fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:51 +0100 Subject: ALSA: ad1889: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-20-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 5b6452df8bbd..12c6a7975100 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -257,20 +257,6 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip) return 0; } -static int -snd_ad1889_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int -snd_ad1889_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static const struct snd_pcm_hardware snd_ad1889_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, @@ -563,8 +549,6 @@ static const struct snd_pcm_ops snd_ad1889_playback_ops = { .open = snd_ad1889_playback_open, .close = snd_ad1889_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1889_hw_params, - .hw_free = snd_ad1889_hw_free, .prepare = snd_ad1889_playback_prepare, .trigger = snd_ad1889_playback_trigger, .pointer = snd_ad1889_playback_pointer, @@ -574,8 +558,6 @@ static const struct snd_pcm_ops snd_ad1889_capture_ops = { .open = snd_ad1889_capture_open, .close = snd_ad1889_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1889_hw_params, - .hw_free = snd_ad1889_hw_free, .prepare = snd_ad1889_capture_prepare, .trigger = snd_ad1889_capture_trigger, .pointer = snd_ad1889_capture_pointer, @@ -632,10 +614,8 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device) chip->psubs = NULL; chip->csubs = NULL; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - BUFFER_BYTES_MAX / 2, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + BUFFER_BYTES_MAX / 2, BUFFER_BYTES_MAX); return 0; } -- cgit v1.2.3 From e695745437a4e2635ea18100c93a3115b7c0fd36 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:52 +0100 Subject: ALSA: ali5451: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-21-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index ae29df085ae1..8d8d54be331b 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1138,13 +1138,7 @@ static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_ali_voice *pvoice = runtime->private_data; struct snd_ali_voice *evoice = pvoice->extra; - int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - /* voice management */ if (params_buffer_size(hw_params) / 2 != @@ -1175,7 +1169,6 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream) struct snd_ali_voice *pvoice = runtime->private_data; struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; - snd_pcm_lib_free_pages(substream); if (evoice) { snd_ali_free_voice(codec, evoice); pvoice->extra = NULL; @@ -1183,18 +1176,6 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream) return 0; } -static int snd_ali_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int snd_ali_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ali_playback_prepare(struct snd_pcm_substream *substream) { struct snd_ali *codec = snd_pcm_substream_chip(substream); @@ -1538,8 +1519,6 @@ static const struct snd_pcm_ops snd_ali_capture_ops = { .open = snd_ali_capture_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ali_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1557,7 +1536,7 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream, snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); - return snd_ali_hw_params(substream, hw_params); + return 0; } static struct snd_pcm_hardware snd_ali_modem = @@ -1614,7 +1593,6 @@ static const struct snd_pcm_ops snd_ali_modem_playback_ops = { .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1625,7 +1603,6 @@ static const struct snd_pcm_ops snd_ali_modem_capture_ops = { .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1671,9 +1648,8 @@ static int snd_ali_pcm(struct snd_ali *codec, int device, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &codec->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &codec->pci->dev, 64*1024, 128*1024); pcm->info_flags = 0; pcm->dev_class = desc->class; -- cgit v1.2.3 From 909c7d2cccc386f087cb4dcc4207b9931ddd6601 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:53 +0100 Subject: ALSA: als300: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-22-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/als300.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/sound/pci/als300.c b/sound/pci/als300.c index cfbb8cacaaac..0bb5a0fea23a 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -378,7 +378,6 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream) data = substream->runtime->private_data; kfree(data); chip->playback_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } @@ -407,22 +406,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream) data = substream->runtime->private_data; kfree(data); chip->capture_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } -static int snd_als300_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int snd_als300_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_als300_playback_prepare(struct snd_pcm_substream *substream) { u32 tmp; @@ -554,8 +540,6 @@ static const struct snd_pcm_ops snd_als300_playback_ops = { .open = snd_als300_playback_open, .close = snd_als300_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als300_pcm_hw_params, - .hw_free = snd_als300_pcm_hw_free, .prepare = snd_als300_playback_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, @@ -565,8 +549,6 @@ static const struct snd_pcm_ops snd_als300_capture_ops = { .open = snd_als300_capture_open, .close = snd_als300_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als300_pcm_hw_params, - .hw_free = snd_als300_pcm_hw_free, .prepare = snd_als300_capture_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, @@ -591,9 +573,8 @@ static int snd_als300_new_pcm(struct snd_als300 *chip) &snd_als300_capture_ops); /* pre-allocation of buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024); return 0; } -- cgit v1.2.3 From 96bcfde13a1cb8979c0e4fb35f99be2d072c21bd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:54 +0100 Subject: ALSA: als4000: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-23-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index d6f5487afe52..ea51913ea134 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -354,18 +354,6 @@ CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S16L_STEREO */ }; #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format]) -static int snd_als4000_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_als4000_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int snd_als4000_capture_prepare(struct snd_pcm_substream *substream) { struct snd_sb *chip = snd_pcm_substream_chip(substream); @@ -633,7 +621,6 @@ static int snd_als4000_playback_close(struct snd_pcm_substream *substream) struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } @@ -652,7 +639,6 @@ static int snd_als4000_capture_close(struct snd_pcm_substream *substream) struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; } @@ -662,8 +648,6 @@ static const struct snd_pcm_ops snd_als4000_playback_ops = { .open = snd_als4000_playback_open, .close = snd_als4000_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als4000_hw_params, - .hw_free = snd_als4000_hw_free, .prepare = snd_als4000_playback_prepare, .trigger = snd_als4000_playback_trigger, .pointer = snd_als4000_playback_pointer @@ -673,8 +657,6 @@ static const struct snd_pcm_ops snd_als4000_capture_ops = { .open = snd_als4000_capture_open, .close = snd_als4000_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als4000_hw_params, - .hw_free = snd_als4000_hw_free, .prepare = snd_als4000_capture_prepare, .trigger = snd_als4000_capture_trigger, .pointer = snd_als4000_capture_pointer @@ -693,9 +675,8 @@ static int snd_als4000_pcm(struct snd_sb *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024); chip->pcm = pcm; -- cgit v1.2.3 From 7ae11ecf0dfeac445024fe9af6a2c1cdaea21f64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:55 +0100 Subject: ALSA: asihpi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-24-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 147005fdd3ea..ccdaaf28dcf8 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -449,9 +449,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, unsigned int bytes_per_sec; print_hwparams(substream, params); - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; err = snd_card_asihpi_format_alsa2hpi(params_format(params), &format); if (err) return err; @@ -509,7 +506,6 @@ snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) if (dpcm->hpi_buffer_attached) hpi_stream_host_buffer_detach(dpcm->h_stream); - snd_pcm_lib_free_pages(substream); return 0; } @@ -1324,9 +1320,9 @@ static int snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, int device) /*? do we want to emulate MMAP for non-BBM cards? Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &asihpi->pci->dev, - 64*1024, BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &asihpi->pci->dev, + 64*1024, BUFFER_BYTES_MAX); return 0; } -- cgit v1.2.3 From 801bf05747642fcc1039efaf5f00d36ed52d9dd5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:56 +0100 Subject: ALSA: atiixp: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-25-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 14 ++++---------- sound/pci/atiixp_modem.c | 9 ++------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 1e1ededf8eb2..6fb56952c9c7 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -952,9 +952,6 @@ static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, struct atiixp_dma *dma = substream->runtime->private_data; int err; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params); @@ -994,7 +991,6 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) dma->pcm_open_flag = 0; } atiixp_clear_dma_packets(chip, dma, substream); - snd_pcm_lib_free_pages(substream); return 0; } @@ -1283,9 +1279,8 @@ static int snd_atiixp_pcm_new(struct atiixp *chip) strcpy(pcm->name, "ATI IXP AC97"); chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024); err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, chip->max_channels, 0, @@ -1316,9 +1311,8 @@ static int snd_atiixp_pcm_new(struct atiixp *chip) strcpy(pcm->name, "ATI IXP IEC958 (Direct)"); chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024); /* pre-select AC97 SPDIF slots 10/11 */ for (i = 0; i < NUM_ATI_CODECS; i++) { diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 6f088c1949f3..dc40fdaa71cb 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -783,9 +783,6 @@ static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, int err; int i; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params); @@ -812,7 +809,6 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) struct atiixp_dma *dma = substream->runtime->private_data; atiixp_clear_dma_packets(chip, dma, substream); - snd_pcm_lib_free_pages(substream); return 0; } @@ -994,9 +990,8 @@ static int snd_atiixp_pcm_new(struct atiixp_modem *chip) strcpy(pcm->name, "ATI IXP MC97"); chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From 8c847a423572e816629f67bea2e13717b3470409 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:57 +0100 Subject: ALSA: au88x0: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-26-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_pcm.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index a2dcf43beedf..9d7436cd7b0f 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -209,15 +209,7 @@ snd_vortex_pcm_hw_params(struct snd_pcm_substream *substream, { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) (substream->runtime->private_data); - int err; - // Alloc buffer memory. - err = - snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) { - dev_err(chip->card->dev, "Vortex: pcm page alloc failed!\n"); - return err; - } /* pr_info( "Vortex: periods %d, period_bytes %d, channels = %d\n", params_periods(hw_params), params_period_bytes(hw_params), params_channels(hw_params)); @@ -304,7 +296,7 @@ static int snd_vortex_pcm_hw_free(struct snd_pcm_substream *substream) substream->runtime->private_data = NULL; spin_unlock_irq(&chip->lock); - return snd_pcm_lib_free_pages(substream); + return 0; } /* prepare callback */ @@ -636,9 +628,8 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr) /* pre-allocation of Scatter-Gather buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci_dev->dev, - 0x10000, 0x10000); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci_dev->dev, 0x10000, 0x10000); switch (VORTEX_PCM_TYPE(pcm)) { case VORTEX_PCM_ADB: -- cgit v1.2.3 From 817790cc3dfe53b48266f65a73b2153615318d55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:58 +0100 Subject: ALSA: aw2: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-27-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/aw2/aw2-alsa.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 1cbfae856a2a..d68ae91650a7 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -109,9 +109,6 @@ static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream); static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream); static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream); static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream); -static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params); -static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream); static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream); static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream); static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream, @@ -170,8 +167,6 @@ static const struct snd_pcm_ops snd_aw2_playback_ops = { .open = snd_aw2_pcm_playback_open, .close = snd_aw2_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_aw2_pcm_hw_params, - .hw_free = snd_aw2_pcm_hw_free, .prepare = snd_aw2_pcm_prepare_playback, .trigger = snd_aw2_pcm_trigger_playback, .pointer = snd_aw2_pcm_pointer_playback, @@ -182,8 +177,6 @@ static const struct snd_pcm_ops snd_aw2_capture_ops = { .open = snd_aw2_pcm_capture_open, .close = snd_aw2_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_aw2_pcm_hw_params, - .hw_free = snd_aw2_pcm_hw_free, .prepare = snd_aw2_pcm_prepare_capture, .trigger = snd_aw2_pcm_trigger_capture, .pointer = snd_aw2_pcm_pointer_capture, @@ -411,20 +404,6 @@ static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream) return 0; } - /* hw_params callback */ -static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -/* hw_free callback */ -static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* prepare callback for playback */ static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream) { @@ -611,10 +590,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip) /* pre-allocation of buffers */ /* Preallocate continuous pages. */ - snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_playback_ana, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024); err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, &pcm_playback_num); @@ -643,10 +622,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip) /* pre-allocation of buffers */ /* Preallocate continuous pages. */ - snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_playback_num, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024); err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, &pcm_capture); @@ -676,10 +655,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip) /* pre-allocation of buffers */ /* Preallocate continuous pages. */ - snd_pcm_lib_preallocate_pages_for_all(pcm_capture, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_capture, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024); /* Create control */ err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); -- cgit v1.2.3 From 830e7b0076814a414ab96ac555cfdd5247e6f568 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:48:59 +0100 Subject: ALSA: azt3328: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-28-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/azt3328.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index f475370faaaa..5fac2d60ba2d 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1205,20 +1205,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip) } #endif /* AZF_USE_AC97_LAYER */ -static int -snd_azf3328_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int -snd_azf3328_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static void snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec, enum azf_freq_t bitrate, @@ -2080,8 +2066,6 @@ static const struct snd_pcm_ops snd_azf3328_playback_ops = { .open = snd_azf3328_pcm_playback_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2091,8 +2075,6 @@ static const struct snd_pcm_ops snd_azf3328_capture_ops = { .open = snd_azf3328_pcm_capture_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2102,8 +2084,6 @@ static const struct snd_pcm_ops snd_azf3328_i2s_out_ops = { .open = snd_azf3328_pcm_i2s_out_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2134,9 +2114,8 @@ snd_azf3328_pcm(struct snd_azf3328 *chip) chip->pcm[AZF_CODEC_PLAYBACK] = pcm; chip->pcm[AZF_CODEC_CAPTURE] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024); err = snd_pcm_new(chip->card, "AZF3328 I2S OUT", AZF_PCMDEV_I2S_OUT, 1, 0, &pcm); @@ -2150,9 +2129,8 @@ snd_azf3328_pcm(struct snd_azf3328 *chip) strcpy(pcm->name, chip->card->shortname); chip->pcm[AZF_CODEC_I2S_OUT] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024); return 0; } -- cgit v1.2.3 From b87ddad2773eb9a1951dd1513bee9f8a6aef7614 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:00 +0100 Subject: ALSA: bt87x: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-29-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/bt87x.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 6bf5ac3600c5..3fe522b32426 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -452,12 +452,7 @@ static int snd_bt87x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_bt87x *chip = snd_pcm_substream_chip(substream); - int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; return snd_bt87x_create_risc(chip, substream, params_periods(hw_params), params_period_bytes(hw_params)); @@ -468,7 +463,6 @@ static int snd_bt87x_hw_free(struct snd_pcm_substream *substream) struct snd_bt87x *chip = snd_pcm_substream_chip(substream); snd_bt87x_free_risc(chip); - snd_pcm_lib_free_pages(substream); return 0; } @@ -699,10 +693,10 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) pcm->private_data = chip; strcpy(pcm->name, name); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 128 * 1024, - ALIGN(255 * 4092, 1024)); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 128 * 1024, + ALIGN(255 * 4092, 1024)); return 0; } -- cgit v1.2.3 From fc97aef32338c5d5d9454f49655a275af03b2911 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:01 +0100 Subject: ALSA: ca0106: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-30-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 56 +++++------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index abc2440dc2d9..758cb4dd4b00 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -707,34 +707,6 @@ static int snd_ca0106_pcm_open_3_capture(struct snd_pcm_substream *substream) return snd_ca0106_pcm_open_capture_channel(substream, 3); } -/* hw_params callback */ -static int snd_ca0106_pcm_hw_params_playback(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -/* hw_free callback */ -static int snd_ca0106_pcm_hw_free_playback(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - -/* hw_params callback */ -static int snd_ca0106_pcm_hw_params_capture(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -/* hw_free callback */ -static int snd_ca0106_pcm_hw_free_capture(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* prepare playback callback */ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) { @@ -1097,8 +1069,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_front_ops = { .open = snd_ca0106_pcm_open_playback_front, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1108,8 +1078,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_0_ops = { .open = snd_ca0106_pcm_open_0_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1119,8 +1087,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_1_ops = { .open = snd_ca0106_pcm_open_1_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1130,8 +1096,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_2_ops = { .open = snd_ca0106_pcm_open_2_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1141,8 +1105,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_3_ops = { .open = snd_ca0106_pcm_open_3_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1152,8 +1114,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { .open = snd_ca0106_pcm_open_playback_center_lfe, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1163,8 +1123,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { .open = snd_ca0106_pcm_open_playback_unknown, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1174,8 +1132,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_rear_ops = { .open = snd_ca0106_pcm_open_playback_rear, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1388,17 +1344,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device) for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 64*1024, 64*1024); } for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 64*1024, 64*1024); } err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, -- cgit v1.2.3 From d841e2e88f00310b2602da3095700a0226983953 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:02 +0100 Subject: ALSA: cmipci: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-31-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index dd9d62e2b633..1eac076f4692 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -666,12 +666,6 @@ static void snd_cmipci_set_pll(struct cmipci *cm, unsigned int rate, unsigned in } #endif /* USE_VAR48KRATE */ -static int snd_cmipci_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { @@ -686,7 +680,7 @@ static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream, cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI; mutex_unlock(&cm->open_mutex); } - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; } static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) @@ -697,11 +691,6 @@ static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) udelay(10); } -static int snd_cmipci_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* */ @@ -1371,14 +1360,14 @@ static int snd_cmipci_playback_hw_free(struct snd_pcm_substream *substream) setup_spdif_playback(cm, substream, 0, 0); restore_mixer_state(cm); snd_cmipci_silence_hack(cm, &cm->channel[0]); - return snd_cmipci_hw_free(substream); + return 0; } static int snd_cmipci_playback2_hw_free(struct snd_pcm_substream *substream) { struct cmipci *cm = snd_pcm_substream_chip(substream); snd_cmipci_silence_hack(cm, &cm->channel[1]); - return snd_cmipci_hw_free(substream); + return 0; } /* capture */ @@ -1420,7 +1409,7 @@ static int snd_cmipci_capture_spdif_hw_free(struct snd_pcm_substream *subs) snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); spin_unlock_irq(&cm->reg_lock); - return snd_cmipci_hw_free(subs); + return 0; } @@ -1829,7 +1818,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_ops = { .open = snd_cmipci_playback_open, .close = snd_cmipci_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_prepare, .trigger = snd_cmipci_playback_trigger, @@ -1840,8 +1828,6 @@ static const struct snd_pcm_ops snd_cmipci_capture_ops = { .open = snd_cmipci_capture_open, .close = snd_cmipci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, - .hw_free = snd_cmipci_hw_free, .prepare = snd_cmipci_capture_prepare, .trigger = snd_cmipci_capture_trigger, .pointer = snd_cmipci_capture_pointer, @@ -1862,7 +1848,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { .open = snd_cmipci_playback_spdif_open, .close = snd_cmipci_playback_spdif_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_spdif_prepare, /* set up rate */ .trigger = snd_cmipci_playback_trigger, @@ -1873,7 +1858,6 @@ static const struct snd_pcm_ops snd_cmipci_capture_spdif_ops = { .open = snd_cmipci_capture_spdif_open, .close = snd_cmipci_capture_spdif_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_capture_spdif_hw_free, .prepare = snd_cmipci_capture_spdif_prepare, .trigger = snd_cmipci_capture_trigger, @@ -1901,8 +1885,8 @@ static int snd_cmipci_pcm_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI DAC/ADC"); cm->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024); return 0; } @@ -1923,8 +1907,8 @@ static int snd_cmipci_pcm2_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI 2nd DAC"); cm->pcm2 = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024); return 0; } @@ -1946,8 +1930,8 @@ static int snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI IEC958"); cm->pcm_spdif = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024); err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, cm->max_channels, 0, -- cgit v1.2.3 From 44e78a1a85ad5b893dda6cbf866e9e14acf71e0d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:03 +0100 Subject: ALSA: cs4281: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-32-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 058c1414b777..ea665d42107e 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -780,17 +780,6 @@ static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma, snd_cs4281_pokeBA0(chip, dma->regFSIC, 0); } -static int snd_cs4281_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_cs4281_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_cs4281_playback_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -939,8 +928,6 @@ static const struct snd_pcm_ops snd_cs4281_playback_ops = { .open = snd_cs4281_playback_open, .close = snd_cs4281_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cs4281_hw_params, - .hw_free = snd_cs4281_hw_free, .prepare = snd_cs4281_playback_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, @@ -950,8 +937,6 @@ static const struct snd_pcm_ops snd_cs4281_capture_ops = { .open = snd_cs4281_capture_open, .close = snd_cs4281_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cs4281_hw_params, - .hw_free = snd_cs4281_hw_free, .prepare = snd_cs4281_capture_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, @@ -974,9 +959,8 @@ static int snd_cs4281_pcm(struct cs4281 *chip, int device) strcpy(pcm->name, "CS4281"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 512*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 512*1024); return 0; } -- cgit v1.2.3 From c6071300ac85b0db5cce715fa5bc3727251fb65a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:04 +0100 Subject: ALSA: cs5535: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-33-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_pcm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 4642e5384e83..0b2a23c6d277 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -236,10 +236,6 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, struct cs5535audio_dma *dma = substream->runtime->private_data; int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params); @@ -267,7 +263,7 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) dma->pcm_open_flag = 0; } cs5535audio_clear_dma_packets(cs5535au, dma, substream); - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_cs5535audio_playback_prepare(struct snd_pcm_substream *substream) @@ -431,9 +427,9 @@ int snd_cs5535audio_pcm(struct cs5535audio *cs5535au) pcm->info_flags = 0; strcpy(pcm->name, "CS5535 Audio"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cs5535au->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cs5535au->pci->dev, + 64*1024, 128*1024); cs5535au->pcm = pcm; return 0; -- cgit v1.2.3 From 76178cc7d5eb6dc881c3fccab882802e5d16f790 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:05 +0100 Subject: ALSA: ctxfi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-34-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctpcm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 7ae5b238703c..5ee2316827d8 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -178,15 +178,10 @@ static int ct_pcm_hw_params(struct snd_pcm_substream *substream, { struct ct_atc *atc = snd_pcm_substream_chip(substream); struct ct_atc_pcm *apcm = substream->runtime->private_data; - int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; /* clear previous resources */ atc->pcm_release_resources(atc, apcm); - return err; + return 0; } static int ct_pcm_hw_free(struct snd_pcm_substream *substream) @@ -196,8 +191,7 @@ static int ct_pcm_hw_free(struct snd_pcm_substream *substream) /* clear previous resources */ atc->pcm_release_resources(atc, apcm); - /* Free snd-allocated pages */ - return snd_pcm_lib_free_pages(substream); + return 0; } @@ -449,9 +443,8 @@ int ct_alsa_pcm_create(struct ct_atc *atc, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &ct_pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &atc->pci->dev, - 128*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &atc->pci->dev, 128*1024, 128*1024); chs = 2; switch (device) { -- cgit v1.2.3 From 11f63ca3995b8099aa9d6d039d729c91a9122112 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:06 +0100 Subject: ALSA: echoaudio: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-35-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 1465813bf7c6..f8a4a8f6982e 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -547,16 +547,6 @@ static int init_engine(struct snd_pcm_substream *substream, "pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n", params_buffer_bytes(hw_params), params_periods(hw_params), params_period_bytes(hw_params)); - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) { - dev_err(chip->card->dev, "malloc_pages err=%d\n", err); - spin_lock_irq(&chip->lock); - free_pipes(chip, pipe); - spin_unlock_irq(&chip->lock); - pipe->index = -1; - return err; - } sglist_init(chip, pipe); edge = PAGE_SIZE; @@ -671,7 +661,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) } spin_unlock_irq(&chip->lock); - snd_pcm_lib_free_pages(substream); return 0; } @@ -872,10 +861,10 @@ static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) for (stream = 0; stream < 2; stream++) for (ss = pcm->streams[stream].substream; ss; ss = ss->next) - snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG, - dev, - ss->number ? 0 : 128<<10, - 256<<10); + snd_pcm_set_managed_buffer(ss, SNDRV_DMA_TYPE_DEV_SG, + dev, + ss->number ? 0 : 128<<10, + 256<<10); } -- cgit v1.2.3 From 63832bd951d2c1deed3ea2dd5a74604902a1a0d1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:07 +0100 Subject: ALSA: emu10k1x: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-36-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1x.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 241b4a0631ab..ef34fe711813 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -411,8 +411,7 @@ static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, epcm->voice->epcm = epcm; } - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; } /* hw_free callback */ @@ -432,7 +431,7 @@ static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) epcm->voice = NULL; } - return snd_pcm_lib_free_pages(substream); + return 0; } /* prepare callback */ @@ -594,8 +593,7 @@ static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substrea epcm->voice->use = 1; } - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; } /* hw_free callback */ @@ -615,7 +613,7 @@ static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) epcm->voice = NULL; } - return snd_pcm_lib_free_pages(substream); + return 0; } /* prepare capture callback */ @@ -876,9 +874,8 @@ static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device) } emu->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, 32*1024, 32*1024); return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 1 << 2, NULL); -- cgit v1.2.3 From cbf7dcd949d7ff820232d67fff314fb556718870 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:08 +0100 Subject: ALSA: emu10k1: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The normal playback streams need a workaround for the aligned buffer, and cannot apply the straight snd_pcm_lib_malloc() stuff, so they remain untouched, while other streams are converted to the new managed mode. Most of hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-37-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emupcm.c | 41 +++++++-------------------------------- sound/pci/emu10k1/p16v.c | 48 +++++++--------------------------------------- 2 files changed, 14 insertions(+), 75 deletions(-) diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 9a8cf3c7dd67..3a68148f6ecf 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -569,17 +569,6 @@ static const struct snd_pcm_hardware snd_emu10k1_efx_playback = .fifo_size = 0, }; -static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); @@ -1372,8 +1361,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1410,15 +1397,15 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device) strcpy(pcm->name, "ADC Capture/Standard PCM Playback"); emu->pcm = pcm; + /* playback substream can't use managed buffers due to alignment */ for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, &emu->pci->dev, 64*1024, 64*1024); for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, 64*1024, 64*1024); return 0; } @@ -1454,8 +1441,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1477,9 +1462,8 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device) strcpy(pcm->name, "Mic Capture"); emu->pcm_mic = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, + 64*1024, 64*1024); return 0; } @@ -1551,8 +1535,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1633,12 +1615,6 @@ static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substr fx8010_pb_trans_copy); } -static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); @@ -1647,7 +1623,6 @@ static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substre for (i = 0; i < pcm->channels; i++) snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); - snd_pcm_lib_free_pages(substream); return 0; } @@ -1793,7 +1768,6 @@ static const struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_fx8010_playback_hw_params, .hw_free = snd_emu10k1_fx8010_playback_hw_free, .prepare = snd_emu10k1_fx8010_playback_prepare, .trigger = snd_emu10k1_fx8010_playback_trigger, @@ -1852,9 +1826,8 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device) if (err < 0) return err; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, + 64*1024, 64*1024); return 0; } diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index ab8876855989..2263db4c954b 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -282,36 +282,6 @@ static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream) return snd_p16v_pcm_open_capture_channel(substream, 0); } -/* hw_params callback */ -static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -/* hw_params callback */ -static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - - -/* hw_free callback */ -static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - -/* hw_free callback */ -static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - /* prepare playback callback */ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) { @@ -583,8 +553,6 @@ static const struct snd_pcm_ops snd_p16v_playback_front_ops = { .open = snd_p16v_pcm_open_playback_front, .close = snd_p16v_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_p16v_pcm_hw_params_playback, - .hw_free = snd_p16v_pcm_hw_free_playback, .prepare = snd_p16v_pcm_prepare_playback, .trigger = snd_p16v_pcm_trigger_playback, .pointer = snd_p16v_pcm_pointer_playback, @@ -594,8 +562,6 @@ static const struct snd_pcm_ops snd_p16v_capture_ops = { .open = snd_p16v_pcm_open_capture, .close = snd_p16v_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_p16v_pcm_hw_params_capture, - .hw_free = snd_p16v_pcm_hw_free_capture, .prepare = snd_p16v_pcm_prepare_capture, .trigger = snd_p16v_pcm_trigger_capture, .pointer = snd_p16v_pcm_pointer_capture, @@ -642,10 +608,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - (65536 - 64) * 8, - (65536 - 64) * 8); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + (65536 - 64) * 8, + (65536 - 64) * 8); /* dev_dbg(emu->card->dev, "preallocate playback substream: err=%d\n", err); @@ -655,9 +621,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 65536 - 64, 65536 - 64); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 65536 - 64, 65536 - 64); /* dev_dbg(emu->card->dev, "preallocate capture substream: err=%d\n", err); -- cgit v1.2.3 From b22b2478125120e0110049ac53fdcef38ea0a167 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:09 +0100 Subject: ALSA: ens137x: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-38-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 0499dc863202..19d8238e130c 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -856,17 +856,6 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd) * PCM part */ -static int snd_ensoniq_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_ensoniq_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) { struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); @@ -1216,8 +1205,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { .open = snd_ensoniq_playback1_open, .close = snd_ensoniq_playback1_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_playback1_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback1_pointer, @@ -1227,8 +1214,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { .open = snd_ensoniq_playback2_open, .close = snd_ensoniq_playback2_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_playback2_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback2_pointer, @@ -1238,8 +1223,6 @@ static const struct snd_pcm_ops snd_ensoniq_capture_ops = { .open = snd_ensoniq_capture_open, .close = snd_ensoniq_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_capture_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_capture_pointer, @@ -1274,9 +1257,8 @@ static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) strcpy(pcm->name, CHIP_NAME " DAC2/ADC"); ensoniq->pcm1 = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ensoniq->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ensoniq->pci->dev, 64*1024, 128*1024); #ifdef CHIP1370 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -1307,9 +1289,8 @@ static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) strcpy(pcm->name, CHIP_NAME " DAC1"); ensoniq->pcm2 = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ensoniq->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ensoniq->pci->dev, 64*1024, 128*1024); #ifdef CHIP1370 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, -- cgit v1.2.3 From d244a1db6f64ad69a04f835e70c1be156c2d7cbe Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:10 +0100 Subject: ALSA: es1938: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-39-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index c571c5d380ca..95d562fff06c 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -863,25 +863,6 @@ static int snd_es1938_capture_copy_kernel(struct snd_pcm_substream *substream, return 0; } -/* - * buffer management - */ -static int snd_es1938_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) - -{ - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - return 0; -} - -static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* ---------------------------------------------------------------------- * Audio1 Capture (ADC) * ----------------------------------------------------------------------*/ @@ -997,8 +978,6 @@ static const struct snd_pcm_ops snd_es1938_playback_ops = { .open = snd_es1938_playback_open, .close = snd_es1938_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_es1938_pcm_hw_params, - .hw_free = snd_es1938_pcm_hw_free, .prepare = snd_es1938_playback_prepare, .trigger = snd_es1938_playback_trigger, .pointer = snd_es1938_playback_pointer, @@ -1008,8 +987,6 @@ static const struct snd_pcm_ops snd_es1938_capture_ops = { .open = snd_es1938_capture_open, .close = snd_es1938_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_es1938_pcm_hw_params, - .hw_free = snd_es1938_pcm_hw_free, .prepare = snd_es1938_capture_prepare, .trigger = snd_es1938_capture_trigger, .pointer = snd_es1938_capture_pointer, @@ -1031,9 +1008,8 @@ static int snd_es1938_new_pcm(struct es1938 *chip, int device) pcm->info_flags = 0; strcpy(pcm->name, "ESS Solo-1"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024); chip->pcm = pcm; return 0; -- cgit v1.2.3 From 247ed1020476bfdec52459f4019c75d596e27156 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:11 +0100 Subject: ALSA: fm801: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-40-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index a7f8109acced..707173254c55 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -435,17 +435,6 @@ static int snd_fm801_capture_trigger(struct snd_pcm_substream *substream, return 0; } -static int snd_fm801_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_fm801_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_fm801_playback_prepare(struct snd_pcm_substream *substream) { struct fm801 *chip = snd_pcm_substream_chip(substream); @@ -685,8 +674,6 @@ static const struct snd_pcm_ops snd_fm801_playback_ops = { .open = snd_fm801_playback_open, .close = snd_fm801_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_fm801_hw_params, - .hw_free = snd_fm801_hw_free, .prepare = snd_fm801_playback_prepare, .trigger = snd_fm801_playback_trigger, .pointer = snd_fm801_playback_pointer, @@ -696,8 +683,6 @@ static const struct snd_pcm_ops snd_fm801_capture_ops = { .open = snd_fm801_capture_open, .close = snd_fm801_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_fm801_hw_params, - .hw_free = snd_fm801_hw_free, .prepare = snd_fm801_capture_prepare, .trigger = snd_fm801_capture_trigger, .pointer = snd_fm801_capture_pointer, @@ -720,9 +705,8 @@ static int snd_fm801_pcm(struct fm801 *chip, int device) strcpy(pcm->name, "FM801"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &pdev->dev, - chip->multichannel ? 128*1024 : 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &pdev->dev, + chip->multichannel ? 128*1024 : 64*1024, 128*1024); return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, -- cgit v1.2.3 From 7a6d4a5ac89fcc775b0bc7acb8656aec6b4d82b1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:12 +0100 Subject: ALSA: hda: Use managed buffer allocation Clean up the common driver module with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-41-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_controller.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index f30a053d981e..5301bb94f631 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -107,7 +107,7 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream, struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx *chip = apcm->chip; struct azx_dev *azx_dev = get_azx_dev(substream); - int ret; + int ret = 0; trace_azx_pcm_hw_params(chip, azx_dev); dsp_lock(azx_dev); @@ -119,8 +119,6 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream, azx_dev->core.bufsize = 0; azx_dev->core.period_bytes = 0; azx_dev->core.format_val = 0; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); unlock: dsp_unlock(azx_dev); @@ -132,7 +130,6 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream); - int err; /* reset BDL address */ dsp_lock(azx_dev); @@ -141,10 +138,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) snd_hda_codec_cleanup(apcm->codec, hinfo, substream); - err = snd_pcm_lib_free_pages(substream); azx_stream(azx_dev)->prepared = 0; dsp_unlock(azx_dev); - return err; + return 0; } static int azx_pcm_prepare(struct snd_pcm_substream *substream) @@ -766,9 +762,8 @@ int snd_hda_attach_pcm_stream(struct hda_bus *_bus, struct hda_codec *codec, size = MAX_PREALLOC_SIZE; if (chip->uc_buffer) type = SNDRV_DMA_TYPE_DEV_UC_SG; - snd_pcm_lib_preallocate_pages_for_all(pcm, type, - chip->card->dev, - size, MAX_PREALLOC_SIZE); + snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev, + size, MAX_PREALLOC_SIZE); return 0; } -- cgit v1.2.3 From 60b8918ba5f51ff1702b502e859b94130f7331f3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:13 +0100 Subject: ALSA: ice1712: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-42-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1712.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index deadba40131c..1783584e90c5 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -479,21 +479,6 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id) } -/* - * PCM part - misc - */ - -static int snd_ice1712_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_ice1712_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* * PCM part - consumer I/O */ @@ -837,8 +822,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ops = { .open = snd_ice1712_playback_open, .close = snd_ice1712_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_prepare, .trigger = snd_ice1712_playback_trigger, .pointer = snd_ice1712_playback_pointer, @@ -848,8 +831,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ds_ops = { .open = snd_ice1712_playback_ds_open, .close = snd_ice1712_playback_ds_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_ds_prepare, .trigger = snd_ice1712_playback_ds_trigger, .pointer = snd_ice1712_playback_ds_pointer, @@ -859,8 +840,6 @@ static const struct snd_pcm_ops snd_ice1712_capture_ops = { .open = snd_ice1712_capture_open, .close = snd_ice1712_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_capture_prepare, .trigger = snd_ice1712_capture_trigger, .pointer = snd_ice1712_capture_pointer, @@ -883,9 +862,8 @@ static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device) strcpy(pcm->name, "ICE1712 consumer"); ice->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 64*1024, 64*1024); dev_warn(ice->card->dev, "Consumer PCM code does not work well at the moment --jk\n"); @@ -909,9 +887,8 @@ static int snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device) strcpy(pcm->name, "ICE1712 consumer (DS)"); ice->pcm_ds = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 64*1024, 128*1024); return 0; } @@ -1063,7 +1040,7 @@ static int snd_ice1712_playback_pro_hw_params(struct snd_pcm_substream *substrea struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; } static int snd_ice1712_capture_pro_prepare(struct snd_pcm_substream *substream) @@ -1085,7 +1062,7 @@ static int snd_ice1712_capture_pro_hw_params(struct snd_pcm_substream *substream struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; } static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substream *substream) @@ -1221,7 +1198,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_pro_ops = { .close = snd_ice1712_playback_pro_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_playback_pro_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_pro_prepare, .trigger = snd_ice1712_pro_trigger, .pointer = snd_ice1712_playback_pro_pointer, @@ -1232,7 +1208,6 @@ static const struct snd_pcm_ops snd_ice1712_capture_pro_ops = { .close = snd_ice1712_capture_pro_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_capture_pro_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_capture_pro_prepare, .trigger = snd_ice1712_pro_trigger, .pointer = snd_ice1712_capture_pro_pointer, @@ -1254,9 +1229,8 @@ static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1712 multi"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024); ice->pcm_pro = pcm; -- cgit v1.2.3 From 09e263cd4a1d16f12e5bca8a5575ed2a2dddbf11 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:14 +0100 Subject: ALSA: ice1724: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-43-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1724.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index c80a16ee6e76..ba992ce47282 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -704,7 +704,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); - int i, chs, err; + int i, chs; chs = params_channels(hw_params); mutex_lock(&ice->open_mutex); @@ -740,11 +740,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, } mutex_unlock(&ice->open_mutex); - err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); } static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) @@ -758,7 +754,7 @@ static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) if (ice->pcm_reserved[i] == substream) ice->pcm_reserved[i] = NULL; mutex_unlock(&ice->open_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream) @@ -1142,9 +1138,8 @@ static int snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1724"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024); ice->pcm_pro = pcm; @@ -1340,9 +1335,8 @@ static int snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, name); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024); ice->pcm = pcm; @@ -1454,9 +1448,8 @@ static int snd_vt1724_pcm_indep(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1724 Surround PCM"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024); ice->pcm_ds = pcm; -- cgit v1.2.3 From 28d52aa55436630327d938b165b7c37febcbd36f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:15 +0100 Subject: ALSA: intel8x0: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-44-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 11 ++++------- sound/pci/intel8x0m.c | 23 ++++------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 12374ba08ca2..b171816e58a8 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -901,9 +901,6 @@ static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream, int dbl = params_rate(hw_params) > 48000; int err; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; if (ichdev->pcm_open_flag) { snd_ac97_pcm_close(ichdev->pcm); ichdev->pcm_open_flag = 0; @@ -929,7 +926,7 @@ static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream) snd_ac97_pcm_close(ichdev->pcm); ichdev->pcm_open_flag = 0; } - return snd_pcm_lib_free_pages(substream); + return 0; } static void snd_intel8x0_setup_pcm_out(struct intel8x0 *chip, @@ -1487,9 +1484,9 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, strcpy(pcm->name, chip->card->shortname); chip->pcm[device] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, intel8x0_dma_type(chip), - &chip->pci->dev, - rec->prealloc_size, rec->prealloc_max_size); + snd_pcm_set_managed_buffer_all(pcm, intel8x0_dma_type(chip), + &chip->pci->dev, + rec->prealloc_size, rec->prealloc_max_size); if (rec->playback_ops && rec->playback_ops->open == snd_intel8x0_playback_open) { diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index a9add5fedfcb..897c989bedd1 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -553,17 +553,6 @@ static int snd_intel8x0m_pcm_trigger(struct snd_pcm_substream *substream, int cm return 0; } -static int snd_intel8x0m_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_intel8x0m_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static snd_pcm_uframes_t snd_intel8x0m_pcm_pointer(struct snd_pcm_substream *substream) { struct intel8x0m *chip = snd_pcm_substream_chip(substream); @@ -674,8 +663,6 @@ static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { .open = snd_intel8x0m_playback_open, .close = snd_intel8x0m_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_intel8x0m_hw_params, - .hw_free = snd_intel8x0m_hw_free, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, @@ -685,8 +672,6 @@ static const struct snd_pcm_ops snd_intel8x0m_capture_ops = { .open = snd_intel8x0m_capture_open, .close = snd_intel8x0m_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_intel8x0m_hw_params, - .hw_free = snd_intel8x0m_hw_free, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, @@ -733,10 +718,10 @@ static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, strcpy(pcm->name, chip->card->shortname); chip->pcm[device] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - rec->prealloc_size, - rec->prealloc_max_size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + rec->prealloc_size, + rec->prealloc_max_size); return 0; } -- cgit v1.2.3 From 224a40c7511f1095d2b6cfd261cd84510b7cbe43 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:16 +0100 Subject: ALSA: lola: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-45-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/lola/lola_pcm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c index 856bcca60128..a01a06896084 100644 --- a/sound/pci/lola/lola_pcm.c +++ b/sound/pci/lola/lola_pcm.c @@ -282,8 +282,7 @@ static int lola_pcm_hw_params(struct snd_pcm_substream *substream, str->bufsize = 0; str->period_bytes = 0; str->format_verb = 0; - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; } static int lola_pcm_hw_free(struct snd_pcm_substream *substream) @@ -296,7 +295,7 @@ static int lola_pcm_hw_free(struct snd_pcm_substream *substream) lola_stream_reset(chip, str); lola_cleanup_slave_streams(pcm, str); mutex_unlock(&chip->open_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } /* @@ -610,9 +609,9 @@ int lola_create_pcm(struct lola *chip) snd_pcm_set_ops(pcm, i, &lola_pcm_ops); } /* buffer pre-allocation */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 1024 * 64, 32 * 1024 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 1024 * 64, 32 * 1024 * 1024); return 0; } -- cgit v1.2.3 From a747db239010bcabe48e3429556b782988a11797 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:17 +0100 Subject: ALSA: lx6464es: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-46-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx6464es.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index d0f63fa54121..a74d8eade3e2 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -342,23 +342,18 @@ static int lx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, int is_capture) { struct lx6464es *chip = snd_pcm_substream_chip(substream); - int err = 0; dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n"); mutex_lock(&chip->setup_mutex); - /* set dma buffer */ - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (is_capture) chip->capture_stream.stream = substream; else chip->playback_stream.stream = substream; mutex_unlock(&chip->setup_mutex); - return err; + return 0; } static int lx_pcm_hw_params_playback(struct snd_pcm_substream *substream, @@ -400,8 +395,6 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream) chip->hardware_running[is_capture] = 0; } - err = snd_pcm_lib_free_pages(substream); - if (is_capture) chip->capture_stream.stream = NULL; else @@ -845,9 +838,8 @@ static int lx_pcm_create(struct lx6464es *chip) pcm->nonatomic = true; strcpy(pcm->name, card_name); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, size, size); chip->pcm = pcm; chip->capture_stream.is_capture = 1; -- cgit v1.2.3 From e485e5386d3df5f76ef2f81a09361309314da558 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:18 +0100 Subject: ALSA: maestro3: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-47-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/maestro3.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index cc8594d76c70..f4076e2a6400 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -1381,10 +1381,7 @@ static int snd_m3_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct m3_dma *s = substream->runtime->private_data; - int err; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; /* set buffer address */ s->buffer_addr = substream->runtime->dma_addr; if (s->buffer_addr & 0x3) { @@ -1401,7 +1398,6 @@ static int snd_m3_pcm_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->private_data == NULL) return 0; s = substream->runtime->private_data; - snd_pcm_lib_free_pages(substream); s->buffer_addr = 0; return 0; } @@ -1860,9 +1856,8 @@ snd_m3_pcm(struct snd_m3 * chip, int device) strcpy(pcm->name, chip->card->driver); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024); return 0; } -- cgit v1.2.3 From c6312f3926d77d9f5e8aaf1fc5dc7eca6b42f131 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:19 +0100 Subject: ALSA: mixart: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-48-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 674d37ec96b3..79a57f3761c5 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -624,10 +624,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs, return err; } - /* allocate buffer */ - err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); - - if (err > 0) { + if (subs->runtime->buffer_changed) { struct mixart_bufferinfo *bufferinfo; int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number; if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) { @@ -647,13 +644,12 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs, } mutex_unlock(&mgr->setup_mutex); - return err; + return 0; } static int snd_mixart_hw_free(struct snd_pcm_substream *subs) { struct snd_mixart *chip = snd_pcm_substream_chip(subs); - snd_pcm_lib_free_pages(subs); mixart_sync_nonblock_events(chip->mgr); return 0; } @@ -947,9 +943,9 @@ static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm) (chip->chip_idx + 1) << 24; } #endif - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->mgr->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->mgr->pci->dev, + 32*1024, 32*1024); } /* -- cgit v1.2.3 From fdaad162a4f32cedbfacdf45589f30be6beae1fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:20 +0100 Subject: ALSA: oxygen: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-49-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_pcm.c | 52 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 203c8fe48a01..4c2bf6952e21 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -304,12 +304,6 @@ static int oxygen_hw_params(struct snd_pcm_substream *substream, { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); - int err; - - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; oxygen_write32(chip, channel_base_registers[channel], (u32)substream->runtime->dma_addr); @@ -529,7 +523,7 @@ static int oxygen_hw_free(struct snd_pcm_substream *substream) oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); spin_unlock_irq(&chip->reg_lock); - return snd_pcm_lib_free_pages(substream); + return 0; } static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream) @@ -711,17 +705,17 @@ int oxygen_pcm_init(struct oxygen *chip) pcm->private_data = chip; strcpy(pcm->name, "Multichannel"); if (outs) - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES_MULTICH, - BUFFER_BYTES_MAX_MULTICH); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES_MULTICH, + BUFFER_BYTES_MAX_MULTICH); if (ins) - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); } outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF); @@ -738,10 +732,10 @@ int oxygen_pcm_init(struct oxygen *chip) &oxygen_rec_c_ops); pcm->private_data = chip; strcpy(pcm->name, "Digital"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); } if (chip->has_ac97_1) { @@ -768,10 +762,10 @@ int oxygen_pcm_init(struct oxygen *chip) &oxygen_rec_b_ops); pcm->private_data = chip; strcpy(pcm->name, outs ? "Front Panel" : "Analog 2"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); } ins = !!(chip->model.device_config & CAPTURE_3_FROM_I2S_3); @@ -786,10 +780,10 @@ int oxygen_pcm_init(struct oxygen *chip) OXYGEN_REC_C_ROUTE_MASK); pcm->private_data = chip; strcpy(pcm->name, "Analog 3"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); } return 0; } -- cgit v1.2.3 From 0dd323695c7b8dc33c6dc2d23bbe99a8ecd5d627 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:22 +0100 Subject: ALSA: riptide: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-51-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index abcea86045ec..b855de52e198 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1558,8 +1558,7 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream, return err; } data->sgdbuf = (struct sgd *)sgdlist->area; - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; } static int snd_riptide_hw_free(struct snd_pcm_substream *substream) @@ -1581,7 +1580,7 @@ static int snd_riptide_hw_free(struct snd_pcm_substream *substream) data->sgdlist.area = NULL; } } - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_riptide_playback_open(struct snd_pcm_substream *substream) @@ -1692,9 +1691,8 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device) pcm->info_flags = 0; strcpy(pcm->name, "RIPTIDE"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, 64 * 1024, 128 * 1024); return 0; } -- cgit v1.2.3 From 7ceebdc87c63cfdbbdd38b58a16d7597e1b3c9f6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:23 +0100 Subject: ALSA: rme32: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-52-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme32.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 58a4b8df25d4..aab47e5d96dc 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -662,11 +662,7 @@ snd_rme32_playback_hw_params(struct snd_pcm_substream *substream, struct rme32 *rme32 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; - if (rme32->fullduplex_mode) { - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - } else { + if (!rme32->fullduplex_mode) { runtime->dma_area = (void __force *)(rme32->iobase + RME32_IO_DATA_BUFFER); runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; @@ -717,11 +713,7 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, struct rme32 *rme32 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; - if (rme32->fullduplex_mode) { - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - } else { + if (!rme32->fullduplex_mode) { runtime->dma_area = (void __force *)rme32->iobase + RME32_IO_DATA_BUFFER; runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; @@ -771,14 +763,6 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, return 0; } -static int snd_rme32_pcm_hw_free(struct snd_pcm_substream *substream) -{ - struct rme32 *rme32 = snd_pcm_substream_chip(substream); - if (! rme32->fullduplex_mode) - return 0; - return snd_pcm_lib_free_pages(substream); -} - static void snd_rme32_pcm_start(struct rme32 * rme32, int from_pause) { if (!from_pause) { @@ -1195,7 +1179,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_ops = { .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_playback_pointer, @@ -1210,7 +1193,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_ops = { .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_pointer, @@ -1252,7 +1234,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops = { .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_playback_fd_pointer, @@ -1264,7 +1245,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops = { .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_fd_pointer, @@ -1374,9 +1354,8 @@ static int snd_rme32_create(struct rme32 *rme32) &snd_rme32_playback_spdif_fd_ops); snd_pcm_set_ops(rme32->spdif_pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_rme32_capture_spdif_fd_ops); - snd_pcm_lib_preallocate_pages_for_all(rme32->spdif_pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 0, RME32_MID_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(rme32->spdif_pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 0, RME32_MID_BUFFER_SIZE); rme32->spdif_pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; } else { snd_pcm_set_ops(rme32->spdif_pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -1406,9 +1385,9 @@ static int snd_rme32_create(struct rme32 *rme32) &snd_rme32_playback_adat_fd_ops); snd_pcm_set_ops(rme32->adat_pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_rme32_capture_adat_fd_ops); - snd_pcm_lib_preallocate_pages_for_all(rme32->adat_pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 0, RME32_MID_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(rme32->adat_pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 0, RME32_MID_BUFFER_SIZE); rme32->adat_pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; } else { snd_pcm_set_ops(rme32->adat_pcm, SNDRV_PCM_STREAM_PLAYBACK, -- cgit v1.2.3 From ff3eb3d51be9d191fe3e663d0e95ed8b28824a89 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:24 +0100 Subject: ALSA: sis7019: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-53-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/sis7019.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index ef7dd290ae05..4639bc21b42d 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -499,18 +499,6 @@ static int sis_substream_close(struct snd_pcm_substream *substream) return 0; } -static int sis_playback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int sis_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int sis_pcm_playback_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -701,11 +689,6 @@ static int sis_capture_hw_params(struct snd_pcm_substream *substream, if (rc) goto out; - rc = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (rc < 0) - goto out; - rc = sis_alloc_timing_voice(substream, hw_params); out: @@ -864,8 +847,6 @@ static const struct snd_pcm_ops sis_playback_ops = { .open = sis_playback_open, .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = sis_playback_hw_params, - .hw_free = sis_hw_free, .prepare = sis_pcm_playback_prepare, .trigger = sis_pcm_trigger, .pointer = sis_pcm_pointer, @@ -876,7 +857,6 @@ static const struct snd_pcm_ops sis_capture_ops = { .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = sis_capture_hw_params, - .hw_free = sis_hw_free, .prepare = sis_pcm_capture_prepare, .trigger = sis_pcm_trigger, .pointer = sis_pcm_pointer, @@ -904,9 +884,8 @@ static int sis_pcm_create(struct sis7019 *sis) /* Try to preallocate some memory, but it's not the end of the * world if this fails. */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &sis->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &sis->pci->dev, 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From 3e1ee04ba9ea9129c8d5bb8809866ea38e7794c2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:25 +0100 Subject: ALSA: sonicvibes: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-54-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/sonicvibes.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 31cbc811ad37..e117d8450b2d 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -681,17 +681,6 @@ static int snd_sonicvibes_capture_trigger(struct snd_pcm_substream *substream, return snd_sonicvibes_trigger(sonic, 2, cmd); } -static int snd_sonicvibes_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_sonicvibes_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_sonicvibes_playback_prepare(struct snd_pcm_substream *substream) { struct sonicvibes *sonic = snd_pcm_substream_chip(substream); @@ -847,8 +836,6 @@ static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { .open = snd_sonicvibes_playback_open, .close = snd_sonicvibes_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sonicvibes_hw_params, - .hw_free = snd_sonicvibes_hw_free, .prepare = snd_sonicvibes_playback_prepare, .trigger = snd_sonicvibes_playback_trigger, .pointer = snd_sonicvibes_playback_pointer, @@ -858,8 +845,6 @@ static const struct snd_pcm_ops snd_sonicvibes_capture_ops = { .open = snd_sonicvibes_capture_open, .close = snd_sonicvibes_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sonicvibes_hw_params, - .hw_free = snd_sonicvibes_hw_free, .prepare = snd_sonicvibes_capture_prepare, .trigger = snd_sonicvibes_capture_trigger, .pointer = snd_sonicvibes_capture_pointer, @@ -883,9 +868,8 @@ static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) strcpy(pcm->name, "S3 SonicVibes"); sonic->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &sonic->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &sonic->pci->dev, 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From c79eafa095b192e251ece9e8016c8012e47fe303 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:26 +0100 Subject: ALSA: trident: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-55-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 49 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 07022c0dad40..93789069e78f 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -808,12 +808,9 @@ static int snd_trident_allocate_pcm_mem(struct snd_pcm_substream *substream, struct snd_trident *trident = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_trident_voice *voice = runtime->private_data; - int err; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; if (trident->tlb.entries) { - if (err > 0) { /* change */ + if (runtime->buffer_changed) { if (voice->memblk) snd_trident_free_pages(trident, voice->memblk); voice->memblk = snd_trident_alloc_pages(trident, substream); @@ -911,7 +908,6 @@ static int snd_trident_hw_free(struct snd_pcm_substream *substream) voice->memblk = NULL; } } - snd_pcm_lib_free_pages(substream); if (evoice != NULL) { snd_trident_free_voice(trident, evoice); voice->extra = NULL; @@ -1128,11 +1124,6 @@ static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) static int snd_trident_si7018_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - return snd_trident_allocate_evoice(substream, hw_params); } @@ -1154,7 +1145,6 @@ static int snd_trident_si7018_capture_hw_free(struct snd_pcm_substream *substrea struct snd_trident_voice *voice = runtime->private_data; struct snd_trident_voice *evoice = voice ? voice->extra : NULL; - snd_pcm_lib_free_pages(substream); if (evoice != NULL) { snd_trident_free_voice(trident, evoice); voice->extra = NULL; @@ -2183,17 +2173,17 @@ int snd_trident_pcm(struct snd_trident *trident, int device) if (trident->tlb.entries) { struct snd_pcm_substream *substream; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, - &trident->pci->dev, - 64*1024, 128*1024); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_SG, + &trident->pci->dev, + 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024); } else { - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024); } return 0; @@ -2242,13 +2232,13 @@ int snd_trident_foldback_pcm(struct snd_trident *trident, int device) trident->foldback = foldback; if (trident->tlb.entries) - snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV_SG, - &trident->pci->dev, - 0, 128*1024); + snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV_SG, + &trident->pci->dev, + 0, 128*1024); else - snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024); return 0; } @@ -2282,9 +2272,8 @@ int snd_trident_spdif_pcm(struct snd_trident *trident, int device) strcpy(spdif->name, "Trident 4DWave IEC958"); trident->spdif = spdif; - snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(spdif, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From 8e2c75249d066ff365d8dc5028ce3c402c3a7230 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:27 +0100 Subject: ALSA: via82xx: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-56-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 45 ++++++++++++++++++--------------------------- sound/pci/via82xx_modem.c | 9 ++------- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 30c817b6b635..d116f32096c1 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -919,18 +919,10 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, { struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; - int err; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - err = build_via_table(viadev, substream, chip->pci, - params_periods(hw_params), - params_period_bytes(hw_params)); - if (err < 0) - return err; - - return 0; + return build_via_table(viadev, substream, chip->pci, + params_periods(hw_params), + params_period_bytes(hw_params)); } /* @@ -943,7 +935,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) struct viadev *viadev = substream->runtime->private_data; clean_via_table(viadev, substream, chip->pci); - snd_pcm_lib_free_pages(substream); return 0; } @@ -1453,9 +1444,9 @@ static int snd_via8233_pcm_new(struct via82xx *chip) /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, @@ -1477,9 +1468,9 @@ static int snd_via8233_pcm_new(struct via82xx *chip) /* set up capture */ init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, 6, 0, @@ -1520,9 +1511,9 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, 6, 0, @@ -1546,9 +1537,9 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) /* set up playback */ init_viadev(chip, chip->playback_devno, 0x30, 3, 0); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); return 0; } @@ -1576,9 +1567,9 @@ static int snd_via686_pcm_new(struct via82xx *chip) init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); return 0; } diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 0edb9ea6e8a6..22eaa9216598 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -642,9 +642,6 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct viadev *viadev = substream->runtime->private_data; int err; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; err = build_via_table(viadev, substream, chip->pci, params_periods(hw_params), params_period_bytes(hw_params)); @@ -667,7 +664,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) struct viadev *viadev = substream->runtime->private_data; clean_via_table(viadev, substream, chip->pci); - snd_pcm_lib_free_pages(substream); return 0; } @@ -849,9 +845,8 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip) init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From b6ed90c0dd764ac83b4d775e48669c95e93f77ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:28 +0100 Subject: ALSA: ymfpci: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-57-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci_main.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 125c11ed5064..748bbdcb2c52 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -628,8 +628,6 @@ static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream, struct snd_ymfpci_pcm *ypcm = runtime->private_data; int err; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0) return err; return 0; @@ -647,7 +645,6 @@ static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream) /* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); - snd_pcm_lib_free_pages(substream); if (ypcm->voices[1]) { snd_ymfpci_voice_free(chip, ypcm->voices[1]); ypcm->voices[1] = NULL; @@ -683,19 +680,13 @@ static int snd_ymfpci_playback_prepare(struct snd_pcm_substream *substream) return 0; } -static int snd_ymfpci_capture_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - static int snd_ymfpci_capture_hw_free(struct snd_pcm_substream *substream) { struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); /* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_ymfpci_capture_prepare(struct snd_pcm_substream *substream) @@ -1124,7 +1115,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { .open = snd_ymfpci_capture_rec_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ymfpci_capture_hw_params, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1148,9 +1138,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024); return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, NULL); @@ -1160,7 +1149,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { .open = snd_ymfpci_capture_ac97_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ymfpci_capture_hw_params, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1184,9 +1172,8 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) chip->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97"); chip->pcm2 = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024); return 0; } @@ -1218,9 +1205,8 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI - IEC958"); chip->pcm_spdif = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024); return 0; } @@ -1260,9 +1246,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI - Rear PCM"); chip->pcm_4ch = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024); return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, surround_map, 2, 0, NULL); -- cgit v1.2.3 From 6dfa8fd598ecf732768ae77e7e08516efd6e71ab Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:29 +0100 Subject: ALSA: pdaudiocf: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-58-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index 067b1c3a3e02..a4be4d1b0f7d 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -83,23 +83,6 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd) return ret; } -/* - * pdacf_pcm_hw_params - hw_params callback for playback and capture - */ -static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * pdacf_pcm_hw_free - hw_free callback for playback and capture - */ -static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) -{ - return snd_pcm_lib_free_pages(subs); -} - /* * pdacf_pcm_prepare - prepare callback for playback and capture */ @@ -256,8 +239,6 @@ static const struct snd_pcm_ops pdacf_pcm_capture_ops = { .open = pdacf_pcm_capture_open, .close = pdacf_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = pdacf_pcm_hw_params, - .hw_free = pdacf_pcm_hw_free, .prepare = pdacf_pcm_prepare, .trigger = pdacf_pcm_trigger, .pointer = pdacf_pcm_capture_pointer, @@ -277,9 +258,9 @@ int snd_pdacf_pcm_new(struct snd_pdacf *chip) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pdacf_pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), - 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), + 0, 0); pcm->private_data = chip; pcm->info_flags = 0; -- cgit v1.2.3 From 01001fa1c79e2bb6698c289010352cae7b0a142d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:30 +0100 Subject: ALSA: pmac: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-59-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 1b11e53f6a62..1629f91d7ae2 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -107,24 +107,6 @@ static inline int another_stream(int stream) SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; } -/* - * allocate buffers - */ -static int snd_pmac_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * release buffers - */ -static int snd_pmac_pcm_hw_free(struct snd_pcm_substream *subs) -{ - snd_pcm_lib_free_pages(subs); - return 0; -} - /* * get a stream of the opposite direction */ @@ -672,8 +654,6 @@ static const struct snd_pcm_ops snd_pmac_playback_ops = { .open = snd_pmac_playback_open, .close = snd_pmac_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_pmac_pcm_hw_params, - .hw_free = snd_pmac_pcm_hw_free, .prepare = snd_pmac_playback_prepare, .trigger = snd_pmac_playback_trigger, .pointer = snd_pmac_playback_pointer, @@ -683,8 +663,6 @@ static const struct snd_pcm_ops snd_pmac_capture_ops = { .open = snd_pmac_capture_open, .close = snd_pmac_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_pmac_pcm_hw_params, - .hw_free = snd_pmac_pcm_hw_free, .prepare = snd_pmac_capture_prepare, .trigger = snd_pmac_capture_trigger, .pointer = snd_pmac_capture_pointer, @@ -721,9 +699,9 @@ int snd_pmac_pcm_new(struct snd_pmac *chip) chip->capture.cur_freqs = chip->freqs_ok; /* preallocate 64k buffer */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pdev->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pdev->dev, + 64 * 1024, 64 * 1024); return 0; } -- cgit v1.2.3 From 377d870e5456ba202dacaf9b730fe68d369f7099 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:31 +0100 Subject: ALSA: ps3: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-60-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/snd_ps3.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index c213eb7ca23c..c6c004958e6f 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -535,22 +535,6 @@ static int snd_ps3_pcm_close(struct snd_pcm_substream *substream) return 0; }; -static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - size_t size; - - /* alloc transport buffer */ - size = params_buffer_bytes(hw_params); - snd_pcm_lib_malloc_pages(substream, size); - return 0; -}; - -static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -}; - static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream, unsigned int delay_ms) { @@ -759,8 +743,6 @@ static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { .open = snd_ps3_pcm_open, .close = snd_ps3_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ps3_pcm_hw_params, - .hw_free = snd_ps3_pcm_hw_free, .prepare = snd_ps3_pcm_prepare, .trigger = snd_ps3_pcm_trigger, .pointer = snd_ps3_pcm_pointer, @@ -1007,11 +989,11 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev) the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; /* pre-alloc PCM DMA buffer*/ - snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, - SNDRV_DMA_TYPE_DEV, - &dev->core, - SND_PS3_PCM_PREALLOC_SIZE, - SND_PS3_PCM_PREALLOC_SIZE); + snd_pcm_set_managed_buffer_all(the_card.pcm, + SNDRV_DMA_TYPE_DEV, + &dev->core, + SND_PS3_PCM_PREALLOC_SIZE, + SND_PS3_PCM_PREALLOC_SIZE); /* * allocate null buffer -- cgit v1.2.3 From 403d026c43763241e0d44086cdce3df4706c9454 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:32 +0100 Subject: ALSA: aica: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-61-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/sound/sh/aica.c b/sound/sh/aica.c index bf1fb0d8a930..8ff88d71439e 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -363,23 +363,6 @@ static int snd_aicapcm_pcm_close(struct snd_pcm_substream return 0; } -static int snd_aicapcm_pcm_hw_free(struct snd_pcm_substream - *substream) -{ - /* Free the DMA buffer */ - return snd_pcm_lib_free_pages(substream); -} - -static int snd_aicapcm_pcm_hw_params(struct snd_pcm_substream - *substream, struct snd_pcm_hw_params - *hw_params) -{ - /* Allocate a DMA buffer using ALSA built-ins */ - return - snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - static int snd_aicapcm_pcm_prepare(struct snd_pcm_substream *substream) { @@ -417,8 +400,6 @@ static const struct snd_pcm_ops snd_aicapcm_playback_ops = { .open = snd_aicapcm_pcm_open, .close = snd_aicapcm_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_aicapcm_pcm_hw_params, - .hw_free = snd_aicapcm_pcm_hw_free, .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, @@ -441,11 +422,11 @@ static int __init snd_aicapcmchip(struct snd_card_aica snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_aicapcm_playback_ops); /* Allocate the DMA buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - AICA_BUFFER_SIZE, - AICA_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + AICA_BUFFER_SIZE, + AICA_BUFFER_SIZE); return 0; } -- cgit v1.2.3 From 50cdf3a0961fd0d0bcb71b85eeccb3a9783bf1b6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:33 +0100 Subject: ALSA: sh: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-62-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/sh_dac_audio.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index f9e36abc98ac..1406b50f3f78 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -125,18 +125,6 @@ static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream) return 0; } -static int snd_sh_dac_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int snd_sh_dac_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); @@ -241,8 +229,6 @@ static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { .open = snd_sh_dac_pcm_open, .close = snd_sh_dac_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sh_dac_pcm_hw_params, - .hw_free = snd_sh_dac_pcm_hw_free, .prepare = snd_sh_dac_pcm_prepare, .trigger = snd_sh_dac_pcm_trigger, .pointer = snd_sh_dac_pcm_pointer, @@ -267,10 +253,8 @@ static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops); /* buffer size=48K */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 48 * 1024, - 48 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 48 * 1024, 48 * 1024); return 0; } -- cgit v1.2.3 From 786e90b0d0f4ffc16237c05ac5cfc7285bf4e1bc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:34 +0100 Subject: ALSA: sparc: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and dropped. Link: https://lore.kernel.org/r/20191209094943.14984-63-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 20 ++------------------ sound/sparc/cs4231.c | 17 ++--------------- sound/sparc/dbri.c | 13 +++---------- 3 files changed, 7 insertions(+), 43 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index d4b8ccc61dc2..d39973605cca 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -723,23 +723,10 @@ static int snd_amd7930_capture_close(struct snd_pcm_substream *substream) return 0; } -static int snd_amd7930_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_amd7930_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static const struct snd_pcm_ops snd_amd7930_playback_ops = { .open = snd_amd7930_playback_open, .close = snd_amd7930_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_amd7930_hw_params, - .hw_free = snd_amd7930_hw_free, .prepare = snd_amd7930_playback_prepare, .trigger = snd_amd7930_playback_trigger, .pointer = snd_amd7930_playback_pointer, @@ -749,8 +736,6 @@ static const struct snd_pcm_ops snd_amd7930_capture_ops = { .open = snd_amd7930_capture_open, .close = snd_amd7930_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_amd7930_hw_params, - .hw_free = snd_amd7930_hw_free, .prepare = snd_amd7930_capture_prepare, .trigger = snd_amd7930_capture_trigger, .pointer = snd_amd7930_capture_pointer, @@ -776,9 +761,8 @@ static int snd_amd7930_pcm(struct snd_amd7930 *amd) strcpy(pcm->name, amd->card->shortname); amd->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64*1024, 64*1024); return 0; } diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 138841e0f2ae..874da942b662 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -889,12 +889,7 @@ static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; - int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_cs4231_get_rate(params_rate(hw_params)); @@ -933,12 +928,7 @@ static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; - int err; - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_cs4231_get_rate(params_rate(hw_params)); @@ -1205,7 +1195,6 @@ static const struct snd_pcm_ops snd_cs4231_playback_ops = { .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_playback_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = snd_cs4231_playback_prepare, .trigger = snd_cs4231_trigger, .pointer = snd_cs4231_playback_pointer, @@ -1216,7 +1205,6 @@ static const struct snd_pcm_ops snd_cs4231_capture_ops = { .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_capture_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = snd_cs4231_capture_prepare, .trigger = snd_cs4231_trigger, .pointer = snd_cs4231_capture_pointer, @@ -1242,9 +1230,8 @@ static int snd_cs4231_pcm(struct snd_card *card) pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, "CS4231"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->op->dev, - 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->op->dev, 64 * 1024, 128 * 1024); chip->pcm = pcm; diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 4911103421ff..315d5a04a33e 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2099,12 +2099,6 @@ static int snd_dbri_hw_params(struct snd_pcm_substream *substream, if (ret != 0) return ret; - if ((ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params))) < 0) { - printk(KERN_ERR "malloc_pages failed with %d\n", ret); - return ret; - } - /* hw_params can get called multiple times. Only map the DMA once. */ if (info->dvma_buffer == 0) { @@ -2151,7 +2145,7 @@ static int snd_dbri_hw_free(struct snd_pcm_substream *substream) info->pipe = -1; } - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_dbri_prepare(struct snd_pcm_substream *substream) @@ -2248,9 +2242,8 @@ static int snd_dbri_pcm(struct snd_card *card) pcm->info_flags = 0; strcpy(pcm->name, card->shortname); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64 * 1024, 64 * 1024); return 0; } -- cgit v1.2.3 From ce747f864268981e5db12c638265a0ddfd9c7f78 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:35 +0100 Subject: ALSA: spi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-64-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 4de1ba9a418d..8b1b5c86cebf 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -242,13 +242,7 @@ static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream, val = SSC_BFINS(TFMR_DATNB, channels - 1, val); ssc_writel(chip->ssc->regs, TFMR, val); - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int snd_at73c213_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; } static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream) @@ -324,7 +318,6 @@ static const struct snd_pcm_ops at73c213_playback_ops = { .close = snd_at73c213_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_at73c213_pcm_hw_params, - .hw_free = snd_at73c213_pcm_hw_free, .prepare = snd_at73c213_pcm_prepare, .trigger = snd_at73c213_pcm_trigger, .pointer = snd_at73c213_pcm_pointer, @@ -347,7 +340,7 @@ static int snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops); - snd_pcm_lib_preallocate_pages_for_all(chip->pcm, + snd_pcm_set_managed_buffer_all(chip->pcm, SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, 64 * 1024, 64 * 1024); out: -- cgit v1.2.3 From a3c10ea47e6dd087e92e8ebbc7844ea48c4c17c3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:36 +0100 Subject: ALSA: 6fire: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-65-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/6fire/pcm.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index cdc5dd7fbe16..706aa3fac351 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c @@ -446,18 +446,6 @@ static int usb6fire_pcm_close(struct snd_pcm_substream *alsa_sub) return 0; } -static int usb6fire_pcm_hw_params(struct snd_pcm_substream *alsa_sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(alsa_sub, - params_buffer_bytes(hw_params)); -} - -static int usb6fire_pcm_hw_free(struct snd_pcm_substream *alsa_sub) -{ - return snd_pcm_lib_free_pages(alsa_sub); -} - static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub) { struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); @@ -555,8 +543,6 @@ static const struct snd_pcm_ops pcm_ops = { .open = usb6fire_pcm_open, .close = usb6fire_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = usb6fire_pcm_hw_params, - .hw_free = usb6fire_pcm_hw_free, .prepare = usb6fire_pcm_prepare, .trigger = usb6fire_pcm_trigger, .pointer = usb6fire_pcm_pointer, @@ -658,8 +644,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip) strcpy(pcm->name, "DMX 6Fire USB"); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); rt->instance = pcm; -- cgit v1.2.3 From 1075b321ab4300e5ee73eeb97980b45bc2ce13b6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:37 +0100 Subject: ALSA: caiaq: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and dropped. The hw_free callback still remains because of the substream deactivation sync call. Link: https://lore.kernel.org/r/20191209094943.14984-66-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/caiaq/audio.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 970eb0865ba3..8513b120e57e 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -167,17 +167,11 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) return 0; } -static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); -} - static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) { struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); deactivate_substream(cdev, sub); - return snd_pcm_lib_free_pages(sub); + return 0; } /* this should probably go upstream */ @@ -328,7 +322,6 @@ static const struct snd_pcm_ops snd_usb_caiaq_ops = { .open = snd_usb_caiaq_substream_open, .close = snd_usb_caiaq_substream_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_usb_caiaq_pcm_hw_params, .hw_free = snd_usb_caiaq_pcm_hw_free, .prepare = snd_usb_caiaq_pcm_prepare, .trigger = snd_usb_caiaq_pcm_trigger, @@ -841,8 +834,8 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) &snd_usb_caiaq_ops); snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usb_caiaq_ops); - snd_pcm_lib_preallocate_pages_for_all(cdev->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(cdev->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); cdev->data_cb_info = kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info), -- cgit v1.2.3 From d0aa558cde353f400dbe910840a87953bc3e11e2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:38 +0100 Subject: ALSA: hiface: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-67-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/hiface/pcm.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index e0de71917274..cc0639a1b419 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -415,18 +415,6 @@ static int hiface_pcm_close(struct snd_pcm_substream *alsa_sub) return 0; } -static int hiface_pcm_hw_params(struct snd_pcm_substream *alsa_sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(alsa_sub, - params_buffer_bytes(hw_params)); -} - -static int hiface_pcm_hw_free(struct snd_pcm_substream *alsa_sub) -{ - return snd_pcm_lib_free_pages(alsa_sub); -} - static int hiface_pcm_prepare(struct snd_pcm_substream *alsa_sub) { struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); @@ -513,8 +501,6 @@ static const struct snd_pcm_ops pcm_ops = { .open = hiface_pcm_open, .close = hiface_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hiface_pcm_hw_params, - .hw_free = hiface_pcm_hw_free, .prepare = hiface_pcm_prepare, .trigger = hiface_pcm_trigger, .pointer = hiface_pcm_pointer, @@ -613,8 +599,8 @@ int hiface_pcm_init(struct hiface_chip *chip, u8 extra_freq) strlcpy(pcm->name, "USB-SPDIF Audio", sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); rt->instance = pcm; -- cgit v1.2.3 From b9626bd6238256bd6f122f42400a143c2bf06b02 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:39 +0100 Subject: ALSA: line6: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-68-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/line6/pcm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 9c437c716cfd..fdbdfb7bce92 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -359,13 +359,6 @@ int snd_line6_hw_params(struct snd_pcm_substream *substream, if (ret < 0) goto error; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) { - line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM); - goto error; - } - pstr->period = params_period_bytes(hw_params); error: mutex_unlock(&line6pcm->state_mutex); @@ -381,7 +374,7 @@ int snd_line6_hw_free(struct snd_pcm_substream *substream) mutex_lock(&line6pcm->state_mutex); line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM); mutex_unlock(&line6pcm->state_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } @@ -501,8 +494,8 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_line6_capture_ops); /* pre-allocation of buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64 * 1024, 128 * 1024); return 0; } -- cgit v1.2.3 From 8aa77f9cab9aead9f684d2a19d11515f468465f1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:40 +0100 Subject: ALSA: ua101: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-69-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/misc/ua101.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index 566a4a31528a..a7b68447f3ad 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -730,11 +730,7 @@ static int capture_pcm_hw_params(struct snd_pcm_substream *substream, mutex_lock(&ua->mutex); err = start_usb_capture(ua); mutex_unlock(&ua->mutex); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return err; } static int playback_pcm_hw_params(struct snd_pcm_substream *substream, @@ -748,16 +744,7 @@ static int playback_pcm_hw_params(struct snd_pcm_substream *substream, if (err >= 0) err = start_usb_playback(ua); mutex_unlock(&ua->mutex); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return err; } static int capture_pcm_prepare(struct snd_pcm_substream *substream) @@ -885,7 +872,6 @@ static const struct snd_pcm_ops capture_pcm_ops = { .close = capture_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = capture_pcm_hw_params, - .hw_free = ua101_pcm_hw_free, .prepare = capture_pcm_prepare, .trigger = capture_pcm_trigger, .pointer = capture_pcm_pointer, @@ -896,7 +882,6 @@ static const struct snd_pcm_ops playback_pcm_ops = { .close = playback_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = playback_pcm_hw_params, - .hw_free = ua101_pcm_hw_free, .prepare = playback_pcm_prepare, .trigger = playback_pcm_trigger, .pointer = playback_pcm_pointer, @@ -1294,8 +1279,8 @@ static int ua101_probe(struct usb_interface *interface, strcpy(ua->pcm->name, name); snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], &ua->midi_list, &midi_quirk); -- cgit v1.2.3 From 3f0c972ad828b5b1a44563c2ceea0f140827013b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:41 +0100 Subject: ALSA: usx2y: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-70-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usbusx2yaudio.c | 26 +++++++++----------------- sound/usb/usx2y/usx2yhwdeppcm.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 25a0939f410a..7eb9805a4326 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -764,14 +764,6 @@ static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream, } } - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) { - snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", - substream, params_buffer_bytes(hw_params), err); - goto error; - } - error: mutex_unlock(&usX2Y(card)->pcm_mutex); return err; @@ -806,7 +798,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream) } } mutex_unlock(&subs->usX2Y->pcm_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } /* * prepare callback @@ -968,16 +960,16 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs); if (playback_endpoint) { - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); } - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); usX2Y(card)->pcm_devs++; return 0; diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 997493e839ee..419d9f07d197 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -376,7 +376,7 @@ static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream) } } mutex_unlock(&subs->usX2Y->pcm_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs) @@ -726,14 +726,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card) pcm->info_flags = 0; sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); return 0; } -- cgit v1.2.3 From 6dd9486ca9b8dde3a91e4c5231b8c83df27ba753 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:42 +0100 Subject: ALSA: usb-audio: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-71-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/pcm.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 9c8930bb00c8..7caaa04ae546 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -785,11 +785,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, if (ret) return ret; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - goto stop_pipeline; - subs->pcm_format = params_format(hw_params); subs->period_bytes = params_period_bytes(hw_params); subs->period_frames = params_period_size(hw_params); @@ -853,7 +848,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) snd_usb_unlock_shutdown(subs->stream->chip); } - return snd_pcm_lib_free_pages(substream); + return 0; } /* @@ -1803,9 +1798,9 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs) struct device *dev = subs->dev->bus->controller; if (snd_usb_use_vmalloc) - snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer(s, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); else - snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_DEV_SG, - dev, 64*1024, 512*1024); + snd_pcm_set_managed_buffer(s, SNDRV_DMA_TYPE_DEV_SG, + dev, 64*1024, 512*1024); } -- cgit v1.2.3 From dd21bf512b648b7f5241557b59f8fd22221e2f76 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:21 +0100 Subject: ALSA: pcxhr: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Link: https://lore.kernel.org/r/20191209094943.14984-50-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 4af34d6d92df..72c0d1552f30 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -940,32 +940,16 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs, struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); struct pcxhr_mgr *mgr = chip->mgr; struct pcxhr_stream *stream = subs->runtime->private_data; - snd_pcm_format_t format; - int err; - int channels; - - /* set up channels */ - channels = params_channels(hw); - - /* set up format for the stream */ - format = params_format(hw); mutex_lock(&mgr->setup_mutex); - stream->channels = channels; - stream->format = format; - - /* allocate buffer */ - err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); + /* set up channels */ + stream->channels = params_channels(hw); + /* set up format for the stream */ + stream->format = params_format(hw); mutex_unlock(&mgr->setup_mutex); - return err; -} - -static int pcxhr_hw_free(struct snd_pcm_substream *subs) -{ - snd_pcm_lib_free_pages(subs); return 0; } @@ -1139,7 +1123,6 @@ static const struct snd_pcm_ops pcxhr_ops = { .ioctl = snd_pcm_lib_ioctl, .prepare = pcxhr_prepare, .hw_params = pcxhr_hw_params, - .hw_free = pcxhr_hw_free, .trigger = pcxhr_trigger, .pointer = pcxhr_stream_pointer, }; @@ -1170,9 +1153,9 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip) pcm->nonatomic = true; strcpy(pcm->name, name); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->mgr->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->mgr->pci->dev, + 32*1024, 32*1024); chip->pcm = pcm; return 0; } -- cgit v1.2.3 From cc6c69126e38d3880b72400cfe29e52cc1a7fa2b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Dec 2019 10:49:43 +0100 Subject: ALSA: hdml-lpe-audio: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Link: https://lore.kernel.org/r/20191209094943.14984-72-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/x86/intel_hdmi_audio.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index cd389d21219a..a67692ca08af 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -1132,16 +1132,13 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_intelhad *intelhaddata; - int buf_size, retval; + int buf_size; intelhaddata = snd_pcm_substream_chip(substream); buf_size = params_buffer_bytes(hw_params); - retval = snd_pcm_lib_malloc_pages(substream, buf_size); - if (retval < 0) - return retval; dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", __func__, buf_size); - return retval; + return 0; } /* @@ -1154,7 +1151,7 @@ static int had_pcm_hw_free(struct snd_pcm_substream *substream) intelhaddata = snd_pcm_substream_chip(substream); had_do_reset(intelhaddata); - return snd_pcm_lib_free_pages(substream); + return 0; } /* @@ -1801,10 +1798,9 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) /* allocate dma pages; * try to allocate 600k buffer as default which is large enough */ - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_DEV_UC, - card->dev, - HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_UC, + card->dev, HAD_DEFAULT_BUFFER, + HAD_MAX_BUFFER); /* create controls */ for (i = 0; i < ARRAY_SIZE(had_controls); i++) { -- cgit v1.2.3 From f2b44229268f93f3648e9c37e35bef0fc2d86eb2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:23 +0100 Subject: ALSA: aoa: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/pcm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index 44397e72c868..d350dbd24305 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -773,7 +773,6 @@ static snd_pcm_uframes_t i2sbus_playback_pointer(struct snd_pcm_substream static const struct snd_pcm_ops i2sbus_playback_ops = { .open = i2sbus_playback_open, .close = i2sbus_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = i2sbus_playback_hw_free, .prepare = i2sbus_playback_prepare, .trigger = i2sbus_playback_trigger, @@ -842,7 +841,6 @@ static snd_pcm_uframes_t i2sbus_record_pointer(struct snd_pcm_substream static const struct snd_pcm_ops i2sbus_record_ops = { .open = i2sbus_record_open, .close = i2sbus_record_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = i2sbus_record_hw_free, .prepare = i2sbus_record_prepare, .trigger = i2sbus_record_trigger, -- cgit v1.2.3 From 94c0ff8bd1e305e5c3437c83e8230c605f2e4c18 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:24 +0100 Subject: ALSA: arm: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 -- sound/arm/pxa2xx-ac97.c | 1 - 2 files changed, 3 deletions(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 1e9ea0fe4f49..d1b5dbcd9e87 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -625,7 +625,6 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm static const struct snd_pcm_ops aaci_playback_ops = { .open = aaci_pcm_open, .close = aaci_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = aaci_pcm_hw_params, .hw_free = aaci_pcm_hw_free, .prepare = aaci_pcm_prepare, @@ -728,7 +727,6 @@ static int aaci_pcm_capture_prepare(struct snd_pcm_substream *substream) static const struct snd_pcm_ops aaci_capture_ops = { .open = aaci_pcm_open, .close = aaci_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = aaci_pcm_hw_params, .hw_free = aaci_pcm_hw_free, .prepare = aaci_pcm_capture_prepare, diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index acfaf1d4ec25..08ae55166890 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -173,7 +173,6 @@ static SIMPLE_DEV_PM_OPS(pxa2xx_ac97_pm_ops, pxa2xx_ac97_suspend, pxa2xx_ac97_re static const struct snd_pcm_ops pxa2xx_ac97_pcm_ops = { .open = pxa2xx_ac97_pcm_open, .close = pxa2xx_ac97_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pxa2xx_pcm_hw_params, .hw_free = pxa2xx_pcm_hw_free, .prepare = pxa2xx_ac97_pcm_prepare, -- cgit v1.2.3 From 1eb1a950f6201f308566bd58d2b9c97ec99210da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:25 +0100 Subject: ALSA: atmel: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 44507e43ed28..658b4d385249 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -447,7 +447,6 @@ atmel_ac97c_capture_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops atmel_ac97_playback_ops = { .open = atmel_ac97c_playback_open, .close = atmel_ac97c_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_playback_hw_params, .prepare = atmel_ac97c_playback_prepare, .trigger = atmel_ac97c_playback_trigger, @@ -457,7 +456,6 @@ static const struct snd_pcm_ops atmel_ac97_playback_ops = { static const struct snd_pcm_ops atmel_ac97_capture_ops = { .open = atmel_ac97c_capture_open, .close = atmel_ac97c_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_capture_hw_params, .prepare = atmel_ac97c_capture_prepare, .trigger = atmel_ac97c_capture_trigger, -- cgit v1.2.3 From ae531486d77061fcc227455c8bcdcc278350b0c4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:26 +0100 Subject: ALSA: drivers: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 1 - sound/drivers/dummy.c | 2 -- sound/drivers/ml403-ac97cr.c | 2 -- sound/drivers/pcsp/pcsp_lib.c | 1 - sound/drivers/vx/vx_pcm.c | 2 -- 5 files changed, 8 deletions(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 104fb738cf48..8090812dcecb 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1299,7 +1299,6 @@ static int loopback_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops loopback_pcm_ops = { .open = loopback_open, .close = loopback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = loopback_hw_free, .prepare = loopback_prepare, .trigger = loopback_trigger, diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index ab6062dcd1b3..cef5b391cc44 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -647,7 +647,6 @@ static struct page *dummy_pcm_page(struct snd_pcm_substream *substream, static struct snd_pcm_ops dummy_pcm_ops = { .open = dummy_pcm_open, .close = dummy_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, @@ -657,7 +656,6 @@ static struct snd_pcm_ops dummy_pcm_ops = { static struct snd_pcm_ops dummy_pcm_ops_no_buf = { .open = dummy_pcm_open, .close = dummy_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index fad63783b4ae..d1e01d89c722 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -731,7 +731,6 @@ static int snd_ml403_ac97cr_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { .open = snd_ml403_ac97cr_playback_open, .close = snd_ml403_ac97cr_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ml403_ac97cr_pcm_playback_prepare, .trigger = snd_ml403_ac97cr_pcm_playback_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, @@ -740,7 +739,6 @@ static const struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { static const struct snd_pcm_ops snd_ml403_ac97cr_capture_ops = { .open = snd_ml403_ac97cr_capture_open, .close = snd_ml403_ac97cr_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ml403_ac97cr_pcm_capture_prepare, .trigger = snd_ml403_ac97cr_pcm_capture_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index 4fdc4dbdae57..05244b11ed5e 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -322,7 +322,6 @@ static int snd_pcsp_playback_open(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_pcsp_playback_ops = { .open = snd_pcsp_playback_open, .close = snd_pcsp_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_pcsp_playback_hw_params, .hw_free = snd_pcsp_playback_hw_free, .prepare = snd_pcsp_playback_prepare, diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 615e8b2b85f6..664b9efa9a50 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -843,7 +843,6 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs) static const struct snd_pcm_ops vx_pcm_playback_ops = { .open = vx_pcm_playback_open, .close = vx_pcm_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_playback_pointer, @@ -1061,7 +1060,6 @@ static snd_pcm_uframes_t vx_pcm_capture_pointer(struct snd_pcm_substream *subs) static const struct snd_pcm_ops vx_pcm_capture_ops = { .open = vx_pcm_capture_open, .close = vx_pcm_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_capture_pointer, -- cgit v1.2.3 From d45b3aaea26c8bc43ca5bc8cba05cb399096d631 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:27 +0100 Subject: ALSA: firewire: Drop superfluous ioctl PCM ops All the PCM ioctl ops of ALSA FireWire drivers do nothing but calling the default handler. Now PCM core accepts NULL as the default ioctl ops(*), so let's drop altogether. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Acked-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191210061145.24641-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/firewire/bebob/bebob_pcm.c | 2 -- sound/firewire/dice/dice-pcm.c | 2 -- sound/firewire/digi00x/digi00x-pcm.c | 2 -- sound/firewire/fireface/ff-pcm.c | 2 -- sound/firewire/fireworks/fireworks_pcm.c | 2 -- sound/firewire/isight.c | 1 - sound/firewire/motu/motu-pcm.c | 2 -- sound/firewire/oxfw/oxfw-pcm.c | 2 -- sound/firewire/tascam/tascam-pcm.c | 2 -- 9 files changed, 17 deletions(-) diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index 5fbf1d74c544..f8d9a2041264 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -342,7 +342,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, @@ -353,7 +352,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index 2700f7f6f754..af8a90ee40f3 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -405,7 +405,6 @@ int snd_dice_create_pcm(struct snd_dice *dice) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = capture_prepare, @@ -416,7 +415,6 @@ int snd_dice_create_pcm(struct snd_dice *dice) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = playback_prepare, diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index bacf9b860f3f..b7f6eda09f9f 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -325,7 +325,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, @@ -336,7 +335,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index a52a4344ec6f..f978cc2fed7d 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -365,7 +365,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) static const struct snd_pcm_ops pcm_capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, @@ -376,7 +375,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) static const struct snd_pcm_ops pcm_playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index 8e60d22acbcc..980580dfbb39 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -372,7 +372,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, @@ -383,7 +382,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index 214f77b0e8b7..6655af53b367 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -441,7 +441,6 @@ static int isight_create_pcm(struct isight *isight) static const struct snd_pcm_ops ops = { .open = isight_open, .close = isight_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = isight_hw_params, .hw_free = isight_hw_free, .prepare = isight_prepare, diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index 931978eb30c9..2d41a1a4052c 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -340,7 +340,6 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = capture_prepare, @@ -351,7 +350,6 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = playback_prepare, diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 974e53bbae10..2dfa7e179cb6 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -411,7 +411,6 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_capture_hw_params, .hw_free = pcm_capture_hw_free, .prepare = pcm_capture_prepare, @@ -422,7 +421,6 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_playback_hw_params, .hw_free = pcm_playback_hw_free, .prepare = pcm_playback_prepare, diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c index 92551ca3460c..36c1353f2494 100644 --- a/sound/firewire/tascam/tascam-pcm.c +++ b/sound/firewire/tascam/tascam-pcm.c @@ -254,7 +254,6 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_capture_prepare, @@ -265,7 +264,6 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_playback_prepare, -- cgit v1.2.3 From 2251612e2f992092e9f010d30c8820fcf47d7f29 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:28 +0100 Subject: ALSA: es1688: Drop superfluous ioctl PCM ops snd_es1688_ioctl() does nothing but calling the default handler. Now PCM core accepts NULL as the default ioctl ops(*), so let's drop altogether. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-7-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688_lib.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index d2c268595168..474d713085c7 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -309,12 +309,6 @@ static void snd_es1688_set_rate(struct snd_es1688 *chip, struct snd_pcm_substrea snd_es1688_write(chip, 0xa2, divider); } -static int snd_es1688_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value) { int val; @@ -681,7 +675,6 @@ exit: static const struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, - .ioctl = snd_es1688_ioctl, .prepare = snd_es1688_playback_prepare, .trigger = snd_es1688_playback_trigger, .pointer = snd_es1688_playback_pointer, @@ -690,7 +683,6 @@ static const struct snd_pcm_ops snd_es1688_playback_ops = { static const struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, - .ioctl = snd_es1688_ioctl, .prepare = snd_es1688_capture_prepare, .trigger = snd_es1688_capture_trigger, .pointer = snd_es1688_capture_pointer, -- cgit v1.2.3 From 86940651eaf4ae596e83ea68070e60462f387b6f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:29 +0100 Subject: ALSA: isa: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-8-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 2 -- sound/isa/es18xx.c | 2 -- sound/isa/gus/gus_pcm.c | 2 -- sound/isa/msnd/msnd.c | 2 -- sound/isa/sb/emu8000_pcm.c | 1 - sound/isa/sb/sb16_main.c | 2 -- sound/isa/sb/sb8_main.c | 2 -- sound/isa/wss/wss_lib.c | 2 -- 8 files changed, 15 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index adc35051c5e9..b9d340c752b4 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -633,7 +633,6 @@ int snd_ad1816a_create(struct snd_card *card, static const struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ad1816a_playback_prepare, .trigger = snd_ad1816a_playback_trigger, .pointer = snd_ad1816a_playback_pointer, @@ -642,7 +641,6 @@ static const struct snd_pcm_ops snd_ad1816a_playback_ops = { static const struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ad1816a_capture_prepare, .trigger = snd_ad1816a_capture_trigger, .pointer = snd_ad1816a_capture_pointer, diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 1346447ffe01..87a0a33807e7 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1643,7 +1643,6 @@ static int snd_es18xx_probe(struct snd_es18xx *chip, static const struct snd_pcm_ops snd_es18xx_playback_ops = { .open = snd_es18xx_playback_open, .close = snd_es18xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_playback_hw_params, .prepare = snd_es18xx_playback_prepare, .trigger = snd_es18xx_playback_trigger, @@ -1653,7 +1652,6 @@ static const struct snd_pcm_ops snd_es18xx_playback_ops = { static const struct snd_pcm_ops snd_es18xx_capture_ops = { .open = snd_es18xx_capture_open, .close = snd_es18xx_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_capture_hw_params, .prepare = snd_es18xx_capture_prepare, .trigger = snd_es18xx_capture_trigger, diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index bd3a54bc4a94..aca4ab90e5bc 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -821,7 +821,6 @@ static const struct snd_kcontrol_new snd_gf1_pcm_volume_control1 = static const struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .open = snd_gf1_pcm_playback_open, .close = snd_gf1_pcm_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_gf1_pcm_playback_hw_params, .hw_free = snd_gf1_pcm_playback_hw_free, .prepare = snd_gf1_pcm_playback_prepare, @@ -835,7 +834,6 @@ static const struct snd_pcm_ops snd_gf1_pcm_playback_ops = { static const struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .open = snd_gf1_pcm_capture_open, .close = snd_gf1_pcm_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_gf1_pcm_capture_hw_params, .prepare = snd_gf1_pcm_capture_prepare, .trigger = snd_gf1_pcm_capture_trigger, diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c index 82d071492201..4fbc22a5bc5a 100644 --- a/sound/isa/msnd/msnd.c +++ b/sound/isa/msnd/msnd.c @@ -562,7 +562,6 @@ snd_msnd_playback_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_msnd_playback_ops = { .open = snd_msnd_playback_open, .close = snd_msnd_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_msnd_playback_hw_params, .prepare = snd_msnd_playback_prepare, .trigger = snd_msnd_playback_trigger, @@ -659,7 +658,6 @@ static int snd_msnd_capture_hw_params(struct snd_pcm_substream *substream, static const struct snd_pcm_ops snd_msnd_capture_ops = { .open = snd_msnd_capture_open, .close = snd_msnd_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_msnd_capture_hw_params, .prepare = snd_msnd_capture_prepare, .trigger = snd_msnd_capture_trigger, diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 83b7ff5e9880..e377ac93f37f 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -660,7 +660,6 @@ static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs) static const struct snd_pcm_ops emu8k_pcm_ops = { .open = emu8k_pcm_open, .close = emu8k_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = emu8k_pcm_hw_params, .hw_free = emu8k_pcm_hw_free, .prepare = emu8k_pcm_prepare, diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 07ebf2c49443..38dc1fde25f3 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -817,7 +817,6 @@ int snd_sb16dsp_configure(struct snd_sb * chip) static const struct snd_pcm_ops snd_sb16_playback_ops = { .open = snd_sb16_playback_open, .close = snd_sb16_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sb16_playback_prepare, .trigger = snd_sb16_playback_trigger, .pointer = snd_sb16_playback_pointer, @@ -826,7 +825,6 @@ static const struct snd_pcm_ops snd_sb16_playback_ops = { static const struct snd_pcm_ops snd_sb16_capture_ops = { .open = snd_sb16_capture_open, .close = snd_sb16_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sb16_capture_prepare, .trigger = snd_sb16_capture_trigger, .pointer = snd_sb16_capture_pointer, diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 5804fa523600..e33dfe165276 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -546,7 +546,6 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_sb8_playback_ops = { .open = snd_sb8_open, .close = snd_sb8_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sb8_playback_prepare, .trigger = snd_sb8_playback_trigger, .pointer = snd_sb8_playback_pointer, @@ -555,7 +554,6 @@ static const struct snd_pcm_ops snd_sb8_playback_ops = { static const struct snd_pcm_ops snd_sb8_capture_ops = { .open = snd_sb8_open, .close = snd_sb8_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sb8_capture_prepare, .trigger = snd_sb8_capture_trigger, .pointer = snd_sb8_capture_pointer, diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 0ef89c97ccd2..9114e8911712 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1871,7 +1871,6 @@ EXPORT_SYMBOL(snd_wss_create); static const struct snd_pcm_ops snd_wss_playback_ops = { .open = snd_wss_playback_open, .close = snd_wss_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_playback_hw_params, .prepare = snd_wss_playback_prepare, .trigger = snd_wss_trigger, @@ -1881,7 +1880,6 @@ static const struct snd_pcm_ops snd_wss_playback_ops = { static const struct snd_pcm_ops snd_wss_capture_ops = { .open = snd_wss_capture_open, .close = snd_wss_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_capture_hw_params, .prepare = snd_wss_capture_prepare, .trigger = snd_wss_trigger, -- cgit v1.2.3 From 9a4df8251ac0aed09d67405c7dfa59f14bde82ed Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:30 +0100 Subject: ALSA: mips: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-9-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/mips/hal2.c | 2 -- sound/mips/sgio2audio.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index e80ebe521218..db44d9d691db 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -684,7 +684,6 @@ static int hal2_capture_ack(struct snd_pcm_substream *substream) static const struct snd_pcm_ops hal2_playback_ops = { .open = hal2_playback_open, .close = hal2_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = hal2_playback_prepare, .trigger = hal2_playback_trigger, .pointer = hal2_playback_pointer, @@ -694,7 +693,6 @@ static const struct snd_pcm_ops hal2_playback_ops = { static const struct snd_pcm_ops hal2_capture_ops = { .open = hal2_capture_open, .close = hal2_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = hal2_capture_prepare, .trigger = hal2_capture_trigger, .pointer = hal2_capture_pointer, diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 481f5ffff61b..f10a08a8777f 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -649,7 +649,6 @@ snd_sgio2audio_pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_sgio2audio_playback1_ops = { .open = snd_sgio2audio_playback1_open, .close = snd_sgio2audio_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_sgio2audio_pcm_hw_params, .hw_free = snd_sgio2audio_pcm_hw_free, .prepare = snd_sgio2audio_pcm_prepare, @@ -660,7 +659,6 @@ static const struct snd_pcm_ops snd_sgio2audio_playback1_ops = { static const struct snd_pcm_ops snd_sgio2audio_playback2_ops = { .open = snd_sgio2audio_playback2_open, .close = snd_sgio2audio_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_sgio2audio_pcm_hw_params, .hw_free = snd_sgio2audio_pcm_hw_free, .prepare = snd_sgio2audio_pcm_prepare, @@ -671,7 +669,6 @@ static const struct snd_pcm_ops snd_sgio2audio_playback2_ops = { static const struct snd_pcm_ops snd_sgio2audio_capture_ops = { .open = snd_sgio2audio_capture_open, .close = snd_sgio2audio_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_sgio2audio_pcm_hw_params, .hw_free = snd_sgio2audio_pcm_hw_free, .prepare = snd_sgio2audio_pcm_prepare, -- cgit v1.2.3 From c02644684ca11b904c5105f06c988a62ef0c6dde Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:31 +0100 Subject: ALSA: parisc: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-10-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 1a4c40aafcbe..ea3630217d39 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -578,7 +578,6 @@ snd_harmony_hw_params(struct snd_pcm_substream *ss, static const struct snd_pcm_ops snd_harmony_playback_ops = { .open = snd_harmony_playback_open, .close = snd_harmony_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, .prepare = snd_harmony_playback_prepare, .trigger = snd_harmony_playback_trigger, @@ -588,7 +587,6 @@ static const struct snd_pcm_ops snd_harmony_playback_ops = { static const struct snd_pcm_ops snd_harmony_capture_ops = { .open = snd_harmony_capture_open, .close = snd_harmony_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, .prepare = snd_harmony_capture_prepare, .trigger = snd_harmony_capture_trigger, -- cgit v1.2.3 From 4ab6596a32b198dc2d9b5499ae63f069564c178c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:32 +0100 Subject: ALSA: intel8x0: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-11-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 12 ------------ sound/pci/intel8x0m.c | 2 -- 2 files changed, 14 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index b171816e58a8..2a3551deee74 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1311,7 +1311,6 @@ static int snd_intel8x0_ali_spdifout_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_intel8x0_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1322,7 +1321,6 @@ static const struct snd_pcm_ops snd_intel8x0_playback_ops = { static const struct snd_pcm_ops snd_intel8x0_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1333,7 +1331,6 @@ static const struct snd_pcm_ops snd_intel8x0_capture_ops = { static const struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1344,7 +1341,6 @@ static const struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { static const struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { .open = snd_intel8x0_mic2_open, .close = snd_intel8x0_mic2_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1355,7 +1351,6 @@ static const struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { static const struct snd_pcm_ops snd_intel8x0_capture2_ops = { .open = snd_intel8x0_capture2_open, .close = snd_intel8x0_capture2_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1366,7 +1361,6 @@ static const struct snd_pcm_ops snd_intel8x0_capture2_ops = { static const struct snd_pcm_ops snd_intel8x0_spdif_ops = { .open = snd_intel8x0_spdif_open, .close = snd_intel8x0_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1377,7 +1371,6 @@ static const struct snd_pcm_ops snd_intel8x0_spdif_ops = { static const struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1388,7 +1381,6 @@ static const struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { static const struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1399,7 +1391,6 @@ static const struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { static const struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1410,7 +1401,6 @@ static const struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { static const struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = { .open = snd_intel8x0_ali_ac97spdifout_open, .close = snd_intel8x0_ali_ac97spdifout_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1422,7 +1412,6 @@ static const struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = { static struct snd_pcm_ops snd_intel8x0_ali_spdifin_ops = { .open = snd_intel8x0_ali_spdifin_open, .close = snd_intel8x0_ali_spdifin_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, @@ -1433,7 +1422,6 @@ static struct snd_pcm_ops snd_intel8x0_ali_spdifin_ops = { static struct snd_pcm_ops snd_intel8x0_ali_spdifout_ops = { .open = snd_intel8x0_ali_spdifout_open, .close = snd_intel8x0_ali_spdifout_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_intel8x0_hw_params, .hw_free = snd_intel8x0_hw_free, .prepare = snd_intel8x0_pcm_prepare, diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 897c989bedd1..13dd3d873e95 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -662,7 +662,6 @@ static int snd_intel8x0m_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { .open = snd_intel8x0m_playback_open, .close = snd_intel8x0m_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, @@ -671,7 +670,6 @@ static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { static const struct snd_pcm_ops snd_intel8x0m_capture_ops = { .open = snd_intel8x0m_capture_open, .close = snd_intel8x0m_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, -- cgit v1.2.3 From 64395f83297a314b5a9178dfddceac47ecfe602f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:33 +0100 Subject: ALSA: via82xx: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-12-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 5 ----- sound/pci/via82xx_modem.c | 2 -- 2 files changed, 7 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index d116f32096c1..3009c26ea8b9 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1348,7 +1348,6 @@ static int snd_via8233_playback_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_via686_playback_ops = { .open = snd_via686_playback_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via686_playback_prepare, @@ -1360,7 +1359,6 @@ static const struct snd_pcm_ops snd_via686_playback_ops = { static const struct snd_pcm_ops snd_via686_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via686_capture_prepare, @@ -1372,7 +1370,6 @@ static const struct snd_pcm_ops snd_via686_capture_ops = { static const struct snd_pcm_ops snd_via8233_playback_ops = { .open = snd_via8233_playback_open, .close = snd_via8233_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_playback_prepare, @@ -1384,7 +1381,6 @@ static const struct snd_pcm_ops snd_via8233_playback_ops = { static const struct snd_pcm_ops snd_via8233_multi_ops = { .open = snd_via8233_multi_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_multi_prepare, @@ -1396,7 +1392,6 @@ static const struct snd_pcm_ops snd_via8233_multi_ops = { static const struct snd_pcm_ops snd_via8233_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via8233_capture_prepare, diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 22eaa9216598..67614a8311e0 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -791,7 +791,6 @@ static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_via686_playback_ops = { .open = snd_via82xx_playback_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via82xx_pcm_prepare, @@ -803,7 +802,6 @@ static const struct snd_pcm_ops snd_via686_playback_ops = { static const struct snd_pcm_ops snd_via686_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_via82xx_hw_params, .hw_free = snd_via82xx_hw_free, .prepare = snd_via82xx_pcm_prepare, -- cgit v1.2.3 From 6c9239e4c705421079909ecf08de0fe397435684 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:34 +0100 Subject: ALSA: atiixp: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-13-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 3 --- sound/pci/atiixp_modem.c | 2 -- 2 files changed, 5 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 6fb56952c9c7..977cdaf92f53 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1140,7 +1140,6 @@ static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_atiixp_playback_ops = { .open = snd_atiixp_playback_open, .close = snd_atiixp_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_atiixp_pcm_hw_params, .hw_free = snd_atiixp_pcm_hw_free, .prepare = snd_atiixp_playback_prepare, @@ -1152,7 +1151,6 @@ static const struct snd_pcm_ops snd_atiixp_playback_ops = { static const struct snd_pcm_ops snd_atiixp_capture_ops = { .open = snd_atiixp_capture_open, .close = snd_atiixp_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_atiixp_pcm_hw_params, .hw_free = snd_atiixp_pcm_hw_free, .prepare = snd_atiixp_capture_prepare, @@ -1164,7 +1162,6 @@ static const struct snd_pcm_ops snd_atiixp_capture_ops = { static const struct snd_pcm_ops snd_atiixp_spdif_ops = { .open = snd_atiixp_spdif_open, .close = snd_atiixp_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_atiixp_pcm_hw_params, .hw_free = snd_atiixp_pcm_hw_free, .prepare = snd_atiixp_spdif_prepare, diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index dc40fdaa71cb..a27ce41f10d3 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -932,7 +932,6 @@ static int snd_atiixp_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_atiixp_playback_ops = { .open = snd_atiixp_playback_open, .close = snd_atiixp_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_atiixp_pcm_hw_params, .hw_free = snd_atiixp_pcm_hw_free, .prepare = snd_atiixp_playback_prepare, @@ -944,7 +943,6 @@ static const struct snd_pcm_ops snd_atiixp_playback_ops = { static const struct snd_pcm_ops snd_atiixp_capture_ops = { .open = snd_atiixp_capture_open, .close = snd_atiixp_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_atiixp_pcm_hw_params, .hw_free = snd_atiixp_pcm_hw_free, .prepare = snd_atiixp_capture_prepare, -- cgit v1.2.3 From b1b375b062b4322c26a86c9b5ed53911e658da5c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:35 +0100 Subject: ALSA: asihpi: Drop superfluous ioctl PCM ops snd_card_asihpi_playback_ioctl() and snd_card_asihpi_capture_ioctl() do nothing but calling the default handler. Now PCM core accepts NULL as the default ioctl ops(*), so let's drop altogether. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-14-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index ccdaaf28dcf8..1fdb9f9f0ae0 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -943,15 +943,6 @@ static void snd_card_asihpi_isr(struct hpi_adapter *a) } /***************************** PLAYBACK OPS ****************/ -static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - char name[16]; - snd_pcm_debug_name(substream, name, sizeof(name)); - snd_printddd(KERN_INFO "%s ioctl %d\n", name, cmd); - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * substream) { @@ -1118,7 +1109,6 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_card_asihpi_playback_mmap_ops = { .open = snd_card_asihpi_playback_open, .close = snd_card_asihpi_playback_close, - .ioctl = snd_card_asihpi_playback_ioctl, .hw_params = snd_card_asihpi_pcm_hw_params, .hw_free = snd_card_asihpi_hw_free, .prepare = snd_card_asihpi_playback_prepare, @@ -1143,12 +1133,6 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); } -static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -1284,7 +1268,6 @@ static int snd_card_asihpi_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = { .open = snd_card_asihpi_capture_open, .close = snd_card_asihpi_capture_close, - .ioctl = snd_card_asihpi_capture_ioctl, .hw_params = snd_card_asihpi_pcm_hw_params, .hw_free = snd_card_asihpi_hw_free, .prepare = snd_card_asihpi_capture_prepare, -- cgit v1.2.3 From 6b07ea052a5a4c56225c65e5d2c07b1af20a09bb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:36 +0100 Subject: ALSA: trident: Drop superfluous ioctl PCM ops snd_trident_ioctl() does nothing but calling the default handler. Now PCM core accepts NULL as the default ioctl ops(*), so let's drop altogether. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-15-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 93789069e78f..0e02578c2b3d 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -767,29 +767,6 @@ static unsigned int snd_trident_control_mode(struct snd_pcm_substream *substream * PCM part */ -/*--------------------------------------------------------------------------- - snd_trident_ioctl - - Description: Device I/O control handler for playback/capture parameters. - - Parameters: substream - PCM substream class - cmd - what ioctl message to process - arg - additional message infoarg - - Returns: Error status - - ---------------------------------------------------------------------------*/ - -static int snd_trident_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, - void *arg) -{ - /* FIXME: it seems that with small periods the behaviour of - trident hardware is unpredictable and interrupt generator - is broken */ - return snd_pcm_lib_ioctl(substream, cmd, arg); -} - /*--------------------------------------------------------------------------- snd_trident_allocate_pcm_mem @@ -2049,7 +2026,6 @@ static int snd_trident_foldback_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_trident_playback_ops = { .open = snd_trident_playback_open, .close = snd_trident_playback_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_playback_prepare, @@ -2060,7 +2036,6 @@ static const struct snd_pcm_ops snd_trident_playback_ops = { static const struct snd_pcm_ops snd_trident_nx_playback_ops = { .open = snd_trident_playback_open, .close = snd_trident_playback_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_playback_prepare, @@ -2071,7 +2046,6 @@ static const struct snd_pcm_ops snd_trident_nx_playback_ops = { static const struct snd_pcm_ops snd_trident_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_capture_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_capture_prepare, @@ -2082,7 +2056,6 @@ static const struct snd_pcm_ops snd_trident_capture_ops = { static const struct snd_pcm_ops snd_trident_si7018_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_si7018_capture_hw_params, .hw_free = snd_trident_si7018_capture_hw_free, .prepare = snd_trident_si7018_capture_prepare, @@ -2093,7 +2066,6 @@ static const struct snd_pcm_ops snd_trident_si7018_capture_ops = { static const struct snd_pcm_ops snd_trident_foldback_ops = { .open = snd_trident_foldback_open, .close = snd_trident_foldback_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_foldback_prepare, @@ -2104,7 +2076,6 @@ static const struct snd_pcm_ops snd_trident_foldback_ops = { static const struct snd_pcm_ops snd_trident_nx_foldback_ops = { .open = snd_trident_foldback_open, .close = snd_trident_foldback_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_foldback_prepare, @@ -2115,7 +2086,6 @@ static const struct snd_pcm_ops snd_trident_nx_foldback_ops = { static const struct snd_pcm_ops snd_trident_spdif_ops = { .open = snd_trident_spdif_open, .close = snd_trident_spdif_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_spdif_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_spdif_prepare, @@ -2126,7 +2096,6 @@ static const struct snd_pcm_ops snd_trident_spdif_ops = { static const struct snd_pcm_ops snd_trident_spdif_7018_ops = { .open = snd_trident_spdif_open, .close = snd_trident_spdif_close, - .ioctl = snd_trident_ioctl, .hw_params = snd_trident_spdif_hw_params, .hw_free = snd_trident_hw_free, .prepare = snd_trident_spdif_prepare, -- cgit v1.2.3 From d34e1b7b9a7fa87fc5309447e4a14bd511de4bc9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:37 +0100 Subject: ALSA: pci: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-16-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 2 -- sound/pci/ali5451/ali5451.c | 4 ---- sound/pci/als300.c | 2 -- sound/pci/als4000.c | 2 -- sound/pci/au88x0/au88x0_pcm.c | 1 - sound/pci/aw2/aw2-alsa.c | 2 -- sound/pci/azt3328.c | 3 --- sound/pci/bt87x.c | 1 - sound/pci/ca0106/ca0106_main.c | 8 -------- sound/pci/cmipci.c | 5 ----- sound/pci/cs4281.c | 2 -- sound/pci/cs46xx/cs46xx_lib.c | 10 ---------- sound/pci/cs5535audio/cs5535audio_pcm.c | 2 -- sound/pci/ctxfi/ctpcm.c | 2 -- sound/pci/echoaudio/echoaudio.c | 4 ---- sound/pci/emu10k1/emu10k1x.c | 2 -- sound/pci/emu10k1/emupcm.c | 6 ------ sound/pci/emu10k1/p16v.c | 2 -- sound/pci/ens1370.c | 3 --- sound/pci/es1938.c | 2 -- sound/pci/es1968.c | 2 -- sound/pci/fm801.c | 2 -- sound/pci/hda/hda_controller.c | 1 - sound/pci/ice1712/ice1712.c | 5 ----- sound/pci/ice1712/ice1724.c | 5 ----- sound/pci/lola/lola_pcm.c | 1 - sound/pci/lx6464es/lx6464es.c | 2 -- sound/pci/maestro3.c | 2 -- sound/pci/mixart/mixart.c | 2 -- sound/pci/nm256/nm256.c | 2 -- sound/pci/oxygen/oxygen_pcm.c | 6 ------ sound/pci/pcxhr/pcxhr.c | 1 - sound/pci/riptide/riptide.c | 2 -- sound/pci/rme32.c | 8 -------- sound/pci/rme96.c | 4 ---- sound/pci/sis7019.c | 2 -- sound/pci/sonicvibes.c | 2 -- sound/pci/ymfpci/ymfpci_main.c | 5 ----- 38 files changed, 119 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 12c6a7975100..4b902c163fd3 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -548,7 +548,6 @@ snd_ad1889_capture_pointer(struct snd_pcm_substream *ss) static const struct snd_pcm_ops snd_ad1889_playback_ops = { .open = snd_ad1889_playback_open, .close = snd_ad1889_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ad1889_playback_prepare, .trigger = snd_ad1889_playback_trigger, .pointer = snd_ad1889_playback_pointer, @@ -557,7 +556,6 @@ static const struct snd_pcm_ops snd_ad1889_playback_ops = { static const struct snd_pcm_ops snd_ad1889_capture_ops = { .open = snd_ad1889_capture_open, .close = snd_ad1889_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ad1889_capture_prepare, .trigger = snd_ad1889_capture_trigger, .pointer = snd_ad1889_capture_pointer, diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 8d8d54be331b..2cf37670e9a9 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1507,7 +1507,6 @@ static int snd_ali_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ali_playback_ops = { .open = snd_ali_playback_open, .close = snd_ali_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_playback_hw_params, .hw_free = snd_ali_playback_hw_free, .prepare = snd_ali_playback_prepare, @@ -1518,7 +1517,6 @@ static const struct snd_pcm_ops snd_ali_playback_ops = { static const struct snd_pcm_ops snd_ali_capture_ops = { .open = snd_ali_capture_open, .close = snd_ali_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1591,7 +1589,6 @@ static int snd_ali_modem_capture_open(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ali_modem_playback_ops = { .open = snd_ali_modem_playback_open, .close = snd_ali_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, @@ -1601,7 +1598,6 @@ static const struct snd_pcm_ops snd_ali_modem_playback_ops = { static const struct snd_pcm_ops snd_ali_modem_capture_ops = { .open = snd_ali_modem_capture_open, .close = snd_ali_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 0bb5a0fea23a..0fb84d1d1dbe 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -539,7 +539,6 @@ static snd_pcm_uframes_t snd_als300_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_als300_playback_ops = { .open = snd_als300_playback_open, .close = snd_als300_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_als300_playback_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, @@ -548,7 +547,6 @@ static const struct snd_pcm_ops snd_als300_playback_ops = { static const struct snd_pcm_ops snd_als300_capture_ops = { .open = snd_als300_capture_open, .close = snd_als300_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_als300_capture_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index ea51913ea134..ba6390e9a694 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -647,7 +647,6 @@ static int snd_als4000_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_als4000_playback_ops = { .open = snd_als4000_playback_open, .close = snd_als4000_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_als4000_playback_prepare, .trigger = snd_als4000_playback_trigger, .pointer = snd_als4000_playback_pointer @@ -656,7 +655,6 @@ static const struct snd_pcm_ops snd_als4000_playback_ops = { static const struct snd_pcm_ops snd_als4000_capture_ops = { .open = snd_als4000_capture_open, .close = snd_als4000_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_als4000_capture_prepare, .trigger = snd_als4000_capture_trigger, .pointer = snd_als4000_capture_pointer diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 9d7436cd7b0f..787c79aba441 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -422,7 +422,6 @@ static snd_pcm_uframes_t snd_vortex_pcm_pointer(struct snd_pcm_substream *substr static const struct snd_pcm_ops snd_vortex_playback_ops = { .open = snd_vortex_pcm_open, .close = snd_vortex_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vortex_pcm_hw_params, .hw_free = snd_vortex_pcm_hw_free, .prepare = snd_vortex_pcm_prepare, diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index d68ae91650a7..7df55797c2f6 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -166,7 +166,6 @@ module_pci_driver(aw2_driver); static const struct snd_pcm_ops snd_aw2_playback_ops = { .open = snd_aw2_pcm_playback_open, .close = snd_aw2_pcm_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_aw2_pcm_prepare_playback, .trigger = snd_aw2_pcm_trigger_playback, .pointer = snd_aw2_pcm_pointer_playback, @@ -176,7 +175,6 @@ static const struct snd_pcm_ops snd_aw2_playback_ops = { static const struct snd_pcm_ops snd_aw2_capture_ops = { .open = snd_aw2_pcm_capture_open, .close = snd_aw2_pcm_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_aw2_pcm_prepare_capture, .trigger = snd_aw2_pcm_trigger_capture, .pointer = snd_aw2_pcm_pointer_capture, diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 5fac2d60ba2d..1a852d893e98 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -2065,7 +2065,6 @@ snd_azf3328_pcm_close(struct snd_pcm_substream *substream static const struct snd_pcm_ops snd_azf3328_playback_ops = { .open = snd_azf3328_pcm_playback_open, .close = snd_azf3328_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2074,7 +2073,6 @@ static const struct snd_pcm_ops snd_azf3328_playback_ops = { static const struct snd_pcm_ops snd_azf3328_capture_ops = { .open = snd_azf3328_pcm_capture_open, .close = snd_azf3328_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2083,7 +2081,6 @@ static const struct snd_pcm_ops snd_azf3328_capture_ops = { static const struct snd_pcm_ops snd_azf3328_i2s_out_ops = { .open = snd_azf3328_pcm_i2s_out_open, .close = snd_azf3328_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 3fe522b32426..de4af1ab87c6 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -533,7 +533,6 @@ static snd_pcm_uframes_t snd_bt87x_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_bt87x_pcm_ops = { .open = snd_bt87x_pcm_open, .close = snd_bt87x_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_bt87x_hw_params, .hw_free = snd_bt87x_hw_free, .prepare = snd_bt87x_prepare, diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 758cb4dd4b00..9466ee9d2f42 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1068,7 +1068,6 @@ snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ca0106_playback_front_ops = { .open = snd_ca0106_pcm_open_playback_front, .close = snd_ca0106_pcm_close_playback, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1077,7 +1076,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_front_ops = { static const struct snd_pcm_ops snd_ca0106_capture_0_ops = { .open = snd_ca0106_pcm_open_0_capture, .close = snd_ca0106_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1086,7 +1084,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_0_ops = { static const struct snd_pcm_ops snd_ca0106_capture_1_ops = { .open = snd_ca0106_pcm_open_1_capture, .close = snd_ca0106_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1095,7 +1092,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_1_ops = { static const struct snd_pcm_ops snd_ca0106_capture_2_ops = { .open = snd_ca0106_pcm_open_2_capture, .close = snd_ca0106_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1104,7 +1100,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_2_ops = { static const struct snd_pcm_ops snd_ca0106_capture_3_ops = { .open = snd_ca0106_pcm_open_3_capture, .close = snd_ca0106_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1113,7 +1108,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_3_ops = { static const struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { .open = snd_ca0106_pcm_open_playback_center_lfe, .close = snd_ca0106_pcm_close_playback, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1122,7 +1116,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { static const struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { .open = snd_ca0106_pcm_open_playback_unknown, .close = snd_ca0106_pcm_close_playback, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1131,7 +1124,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { static const struct snd_pcm_ops snd_ca0106_playback_rear_ops = { .open = snd_ca0106_pcm_open_playback_rear, .close = snd_ca0106_pcm_close_playback, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 1eac076f4692..0e0f528805bf 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -1817,7 +1817,6 @@ static int snd_cmipci_capture_spdif_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_cmipci_playback_ops = { .open = snd_cmipci_playback_open, .close = snd_cmipci_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_prepare, .trigger = snd_cmipci_playback_trigger, @@ -1827,7 +1826,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_ops = { static const struct snd_pcm_ops snd_cmipci_capture_ops = { .open = snd_cmipci_capture_open, .close = snd_cmipci_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_cmipci_capture_prepare, .trigger = snd_cmipci_capture_trigger, .pointer = snd_cmipci_capture_pointer, @@ -1836,7 +1834,6 @@ static const struct snd_pcm_ops snd_cmipci_capture_ops = { static const struct snd_pcm_ops snd_cmipci_playback2_ops = { .open = snd_cmipci_playback2_open, .close = snd_cmipci_playback2_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cmipci_playback2_hw_params, .hw_free = snd_cmipci_playback2_hw_free, .prepare = snd_cmipci_capture_prepare, /* channel B */ @@ -1847,7 +1844,6 @@ static const struct snd_pcm_ops snd_cmipci_playback2_ops = { static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { .open = snd_cmipci_playback_spdif_open, .close = snd_cmipci_playback_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_spdif_prepare, /* set up rate */ .trigger = snd_cmipci_playback_trigger, @@ -1857,7 +1853,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { static const struct snd_pcm_ops snd_cmipci_capture_spdif_ops = { .open = snd_cmipci_capture_spdif_open, .close = snd_cmipci_capture_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_cmipci_capture_spdif_hw_free, .prepare = snd_cmipci_capture_spdif_prepare, .trigger = snd_cmipci_capture_trigger, diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index ea665d42107e..0dcb2d15b560 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -927,7 +927,6 @@ static int snd_cs4281_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_cs4281_playback_ops = { .open = snd_cs4281_playback_open, .close = snd_cs4281_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_cs4281_playback_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, @@ -936,7 +935,6 @@ static const struct snd_pcm_ops snd_cs4281_playback_ops = { static const struct snd_pcm_ops snd_cs4281_capture_ops = { .open = snd_cs4281_capture_open, .close = snd_cs4281_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_cs4281_capture_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 102a62965ac1..1192115b71ef 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1645,7 +1645,6 @@ static int snd_cs46xx_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_cs46xx_playback_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1656,7 +1655,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_rear_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1668,7 +1666,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1679,7 +1676,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1691,7 +1687,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1702,7 +1697,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1716,7 +1710,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1727,7 +1720,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_ops = { static const struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_playback_hw_params, .hw_free = snd_cs46xx_playback_hw_free, .prepare = snd_cs46xx_playback_prepare, @@ -1739,7 +1731,6 @@ static const struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = { static const struct snd_pcm_ops snd_cs46xx_capture_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_capture_hw_params, .hw_free = snd_cs46xx_capture_hw_free, .prepare = snd_cs46xx_capture_prepare, @@ -1750,7 +1741,6 @@ static const struct snd_pcm_ops snd_cs46xx_capture_ops = { static const struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs46xx_capture_hw_params, .hw_free = snd_cs46xx_capture_hw_free, .prepare = snd_cs46xx_capture_prepare, diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 0b2a23c6d277..4032b89b1fc1 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -366,7 +366,6 @@ static int snd_cs5535audio_capture_prepare(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_cs5535audio_playback_ops = { .open = snd_cs5535audio_playback_open, .close = snd_cs5535audio_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs5535audio_hw_params, .hw_free = snd_cs5535audio_hw_free, .prepare = snd_cs5535audio_playback_prepare, @@ -377,7 +376,6 @@ static const struct snd_pcm_ops snd_cs5535audio_playback_ops = { static const struct snd_pcm_ops snd_cs5535audio_capture_ops = { .open = snd_cs5535audio_capture_open, .close = snd_cs5535audio_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs5535audio_hw_params, .hw_free = snd_cs5535audio_hw_free, .prepare = snd_cs5535audio_capture_prepare, diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 5ee2316827d8..6ee6a9675ca5 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -367,7 +367,6 @@ ct_pcm_capture_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops ct_pcm_playback_ops = { .open = ct_pcm_playback_open, .close = ct_pcm_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = ct_pcm_hw_params, .hw_free = ct_pcm_hw_free, .prepare = ct_pcm_playback_prepare, @@ -379,7 +378,6 @@ static const struct snd_pcm_ops ct_pcm_playback_ops = { static const struct snd_pcm_ops ct_pcm_capture_ops = { .open = ct_pcm_capture_open, .close = ct_pcm_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = ct_pcm_hw_params, .hw_free = ct_pcm_hw_free, .prepare = ct_pcm_capture_prepare, diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index f8a4a8f6982e..bfc3ffffb917 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -807,7 +807,6 @@ static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops analog_playback_ops = { .open = pcm_analog_out_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_analog_out_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_prepare, @@ -817,7 +816,6 @@ static const struct snd_pcm_ops analog_playback_ops = { static const struct snd_pcm_ops analog_capture_ops = { .open = pcm_analog_in_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_analog_in_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_prepare, @@ -829,7 +827,6 @@ static const struct snd_pcm_ops analog_capture_ops = { static const struct snd_pcm_ops digital_playback_ops = { .open = pcm_digital_out_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_digital_out_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_prepare, @@ -840,7 +837,6 @@ static const struct snd_pcm_ops digital_playback_ops = { static const struct snd_pcm_ops digital_capture_ops = { .open = pcm_digital_in_open, .close = pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = pcm_digital_in_hw_params, .hw_free = pcm_hw_free, .prepare = pcm_prepare, diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index ef34fe711813..19fc74e94727 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -536,7 +536,6 @@ snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_emu10k1x_playback_ops = { .open = snd_emu10k1x_playback_open, .close = snd_emu10k1x_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1x_pcm_hw_params, .hw_free = snd_emu10k1x_pcm_hw_free, .prepare = snd_emu10k1x_pcm_prepare, @@ -681,7 +680,6 @@ snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_emu10k1x_capture_ops = { .open = snd_emu10k1x_pcm_open_capture, .close = snd_emu10k1x_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1x_pcm_hw_params_capture, .hw_free = snd_emu10k1x_pcm_hw_free_capture, .prepare = snd_emu10k1x_pcm_prepare_capture, diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 3a68148f6ecf..b934c6ac52dd 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1349,7 +1349,6 @@ static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_emu10k1_playback_ops = { .open = snd_emu10k1_playback_open, .close = snd_emu10k1_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_playback_hw_params, .hw_free = snd_emu10k1_playback_hw_free, .prepare = snd_emu10k1_playback_prepare, @@ -1360,7 +1359,6 @@ static const struct snd_pcm_ops snd_emu10k1_playback_ops = { static const struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1370,7 +1368,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_ops = { static const struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { .open = snd_emu10k1_efx_playback_open, .close = snd_emu10k1_efx_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_emu10k1_playback_hw_params, .hw_free = snd_emu10k1_efx_playback_hw_free, .prepare = snd_emu10k1_efx_playback_prepare, @@ -1440,7 +1437,6 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device) static const struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1534,7 +1530,6 @@ static const struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { static const struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1767,7 +1762,6 @@ static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream *substream static const struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_emu10k1_fx8010_playback_hw_free, .prepare = snd_emu10k1_fx8010_playback_prepare, .trigger = snd_emu10k1_fx8010_playback_trigger, diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 2263db4c954b..1cdbad494e13 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -552,7 +552,6 @@ snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_p16v_playback_front_ops = { .open = snd_p16v_pcm_open_playback_front, .close = snd_p16v_pcm_close_playback, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_p16v_pcm_prepare_playback, .trigger = snd_p16v_pcm_trigger_playback, .pointer = snd_p16v_pcm_pointer_playback, @@ -561,7 +560,6 @@ static const struct snd_pcm_ops snd_p16v_playback_front_ops = { static const struct snd_pcm_ops snd_p16v_capture_ops = { .open = snd_p16v_pcm_open_capture, .close = snd_p16v_pcm_close_capture, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_p16v_pcm_prepare_capture, .trigger = snd_p16v_pcm_trigger_capture, .pointer = snd_p16v_pcm_pointer_capture, diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 19d8238e130c..f69555c95263 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1204,7 +1204,6 @@ static int snd_ensoniq_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { .open = snd_ensoniq_playback1_open, .close = snd_ensoniq_playback1_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ensoniq_playback1_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback1_pointer, @@ -1213,7 +1212,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { .open = snd_ensoniq_playback2_open, .close = snd_ensoniq_playback2_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ensoniq_playback2_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback2_pointer, @@ -1222,7 +1220,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { static const struct snd_pcm_ops snd_ensoniq_capture_ops = { .open = snd_ensoniq_capture_open, .close = snd_ensoniq_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ensoniq_capture_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_capture_pointer, diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 95d562fff06c..ae405bc38c65 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -977,7 +977,6 @@ static int snd_es1938_playback_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_es1938_playback_ops = { .open = snd_es1938_playback_open, .close = snd_es1938_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_es1938_playback_prepare, .trigger = snd_es1938_playback_trigger, .pointer = snd_es1938_playback_pointer, @@ -986,7 +985,6 @@ static const struct snd_pcm_ops snd_es1938_playback_ops = { static const struct snd_pcm_ops snd_es1938_capture_ops = { .open = snd_es1938_capture_open, .close = snd_es1938_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_es1938_capture_prepare, .trigger = snd_es1938_capture_trigger, .pointer = snd_es1938_capture_pointer, diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 7017ca9dea4a..4f5063ebce89 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -1664,7 +1664,6 @@ static int snd_es1968_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_es1968_playback_ops = { .open = snd_es1968_playback_open, .close = snd_es1968_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es1968_hw_params, .hw_free = snd_es1968_hw_free, .prepare = snd_es1968_pcm_prepare, @@ -1675,7 +1674,6 @@ static const struct snd_pcm_ops snd_es1968_playback_ops = { static const struct snd_pcm_ops snd_es1968_capture_ops = { .open = snd_es1968_capture_open, .close = snd_es1968_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es1968_hw_params, .hw_free = snd_es1968_hw_free, .prepare = snd_es1968_pcm_prepare, diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 707173254c55..3ea10c972682 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -673,7 +673,6 @@ static int snd_fm801_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_fm801_playback_ops = { .open = snd_fm801_playback_open, .close = snd_fm801_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_fm801_playback_prepare, .trigger = snd_fm801_playback_trigger, .pointer = snd_fm801_playback_pointer, @@ -682,7 +681,6 @@ static const struct snd_pcm_ops snd_fm801_playback_ops = { static const struct snd_pcm_ops snd_fm801_capture_ops = { .open = snd_fm801_capture_open, .close = snd_fm801_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_fm801_capture_prepare, .trigger = snd_fm801_capture_trigger, .pointer = snd_fm801_capture_pointer, diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 5301bb94f631..870102f00efd 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -689,7 +689,6 @@ static int azx_pcm_mmap(struct snd_pcm_substream *substream, static const struct snd_pcm_ops azx_pcm_ops = { .open = azx_pcm_open, .close = azx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = azx_pcm_hw_params, .hw_free = azx_pcm_hw_free, .prepare = azx_pcm_prepare, diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 1783584e90c5..d6e55bf0df16 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -821,7 +821,6 @@ static int snd_ice1712_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ice1712_playback_ops = { .open = snd_ice1712_playback_open, .close = snd_ice1712_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ice1712_playback_prepare, .trigger = snd_ice1712_playback_trigger, .pointer = snd_ice1712_playback_pointer, @@ -830,7 +829,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ops = { static const struct snd_pcm_ops snd_ice1712_playback_ds_ops = { .open = snd_ice1712_playback_ds_open, .close = snd_ice1712_playback_ds_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ice1712_playback_ds_prepare, .trigger = snd_ice1712_playback_ds_trigger, .pointer = snd_ice1712_playback_ds_pointer, @@ -839,7 +837,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ds_ops = { static const struct snd_pcm_ops snd_ice1712_capture_ops = { .open = snd_ice1712_capture_open, .close = snd_ice1712_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ice1712_capture_prepare, .trigger = snd_ice1712_capture_trigger, .pointer = snd_ice1712_capture_pointer, @@ -1196,7 +1193,6 @@ static int snd_ice1712_capture_pro_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ice1712_playback_pro_ops = { .open = snd_ice1712_playback_pro_open, .close = snd_ice1712_playback_pro_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_playback_pro_hw_params, .prepare = snd_ice1712_playback_pro_prepare, .trigger = snd_ice1712_pro_trigger, @@ -1206,7 +1202,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_pro_ops = { static const struct snd_pcm_ops snd_ice1712_capture_pro_ops = { .open = snd_ice1712_capture_pro_open, .close = snd_ice1712_capture_pro_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_capture_pro_hw_params, .prepare = snd_ice1712_capture_pro_prepare, .trigger = snd_ice1712_pro_trigger, diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index ba992ce47282..d5590a82e7fd 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -1096,7 +1096,6 @@ static int snd_vt1724_capture_pro_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_vt1724_playback_pro_ops = { .open = snd_vt1724_playback_pro_open, .close = snd_vt1724_playback_pro_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vt1724_pcm_hw_params, .hw_free = snd_vt1724_pcm_hw_free, .prepare = snd_vt1724_playback_pro_prepare, @@ -1107,7 +1106,6 @@ static const struct snd_pcm_ops snd_vt1724_playback_pro_ops = { static const struct snd_pcm_ops snd_vt1724_capture_pro_ops = { .open = snd_vt1724_capture_pro_open, .close = snd_vt1724_capture_pro_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vt1724_pcm_hw_params, .hw_free = snd_vt1724_pcm_hw_free, .prepare = snd_vt1724_pcm_prepare, @@ -1274,7 +1272,6 @@ static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_vt1724_playback_spdif_ops = { .open = snd_vt1724_playback_spdif_open, .close = snd_vt1724_playback_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vt1724_pcm_hw_params, .hw_free = snd_vt1724_pcm_hw_free, .prepare = snd_vt1724_playback_spdif_prepare, @@ -1285,7 +1282,6 @@ static const struct snd_pcm_ops snd_vt1724_playback_spdif_ops = { static const struct snd_pcm_ops snd_vt1724_capture_spdif_ops = { .open = snd_vt1724_capture_spdif_open, .close = snd_vt1724_capture_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vt1724_pcm_hw_params, .hw_free = snd_vt1724_pcm_hw_free, .prepare = snd_vt1724_pcm_prepare, @@ -1418,7 +1414,6 @@ static int snd_vt1724_playback_indep_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_vt1724_playback_indep_ops = { .open = snd_vt1724_playback_indep_open, .close = snd_vt1724_playback_indep_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_vt1724_pcm_hw_params, .hw_free = snd_vt1724_pcm_hw_free, .prepare = snd_vt1724_playback_indep_prepare, diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c index a01a06896084..f647c7ed00c4 100644 --- a/sound/pci/lola/lola_pcm.c +++ b/sound/pci/lola/lola_pcm.c @@ -575,7 +575,6 @@ void lola_pcm_update(struct lola *chip, struct lola_pcm *pcm, unsigned int bits) static const struct snd_pcm_ops lola_pcm_ops = { .open = lola_pcm_open, .close = lola_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = lola_pcm_hw_params, .hw_free = lola_pcm_hw_free, .prepare = lola_pcm_prepare, diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index a74d8eade3e2..0ac078d1b27a 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -791,7 +791,6 @@ mac_ready: static const struct snd_pcm_ops lx_ops_playback = { .open = lx_pcm_open, .close = lx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = lx_pcm_prepare, .hw_params = lx_pcm_hw_params_playback, .hw_free = lx_pcm_hw_free, @@ -802,7 +801,6 @@ static const struct snd_pcm_ops lx_ops_playback = { static const struct snd_pcm_ops lx_ops_capture = { .open = lx_pcm_open, .close = lx_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = lx_pcm_prepare, .hw_params = lx_pcm_hw_params_capture, .hw_free = lx_pcm_hw_free, diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index f4076e2a6400..501f1871f776 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -1818,7 +1818,6 @@ snd_m3_capture_close(struct snd_pcm_substream *subs) static const struct snd_pcm_ops snd_m3_playback_ops = { .open = snd_m3_playback_open, .close = snd_m3_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_m3_pcm_hw_params, .hw_free = snd_m3_pcm_hw_free, .prepare = snd_m3_pcm_prepare, @@ -1829,7 +1828,6 @@ static const struct snd_pcm_ops snd_m3_playback_ops = { static const struct snd_pcm_ops snd_m3_capture_ops = { .open = snd_m3_capture_open, .close = snd_m3_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_m3_pcm_hw_params, .hw_free = snd_m3_pcm_hw_free, .prepare = snd_m3_pcm_prepare, diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 79a57f3761c5..05e2c8ea8480 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -909,7 +909,6 @@ static snd_pcm_uframes_t snd_mixart_stream_pointer(struct snd_pcm_substream *sub static const struct snd_pcm_ops snd_mixart_playback_ops = { .open = snd_mixart_playback_open, .close = snd_mixart_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_mixart_prepare, .hw_params = snd_mixart_hw_params, .hw_free = snd_mixart_hw_free, @@ -920,7 +919,6 @@ static const struct snd_pcm_ops snd_mixart_playback_ops = { static const struct snd_pcm_ops snd_mixart_capture_ops = { .open = snd_mixart_capture_open, .close = snd_mixart_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_mixart_prepare, .hw_params = snd_mixart_hw_params, .hw_free = snd_mixart_hw_free, diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 1201c9c95660..02767f33deb7 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -906,7 +906,6 @@ snd_nm256_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_nm256_playback_ops = { .open = snd_nm256_playback_open, .close = snd_nm256_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_nm256_pcm_hw_params, .prepare = snd_nm256_pcm_prepare, .trigger = snd_nm256_playback_trigger, @@ -922,7 +921,6 @@ static const struct snd_pcm_ops snd_nm256_playback_ops = { static const struct snd_pcm_ops snd_nm256_capture_ops = { .open = snd_nm256_capture_open, .close = snd_nm256_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_nm256_pcm_hw_params, .prepare = snd_nm256_pcm_prepare, .trigger = snd_nm256_capture_trigger, diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 4c2bf6952e21..75b25ecf83a9 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -616,7 +616,6 @@ static snd_pcm_uframes_t oxygen_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops oxygen_rec_a_ops = { .open = oxygen_rec_a_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_a_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, @@ -627,7 +626,6 @@ static const struct snd_pcm_ops oxygen_rec_a_ops = { static const struct snd_pcm_ops oxygen_rec_b_ops = { .open = oxygen_rec_b_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_b_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, @@ -638,7 +636,6 @@ static const struct snd_pcm_ops oxygen_rec_b_ops = { static const struct snd_pcm_ops oxygen_rec_c_ops = { .open = oxygen_rec_c_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_rec_c_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, @@ -649,7 +646,6 @@ static const struct snd_pcm_ops oxygen_rec_c_ops = { static const struct snd_pcm_ops oxygen_spdif_ops = { .open = oxygen_spdif_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_spdif_hw_params, .hw_free = oxygen_spdif_hw_free, .prepare = oxygen_prepare, @@ -660,7 +656,6 @@ static const struct snd_pcm_ops oxygen_spdif_ops = { static const struct snd_pcm_ops oxygen_multich_ops = { .open = oxygen_multich_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_multich_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, @@ -671,7 +666,6 @@ static const struct snd_pcm_ops oxygen_multich_ops = { static const struct snd_pcm_ops oxygen_ac97_ops = { .open = oxygen_ac97_open, .close = oxygen_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = oxygen_hw_params, .hw_free = oxygen_hw_free, .prepare = oxygen_prepare, diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 72c0d1552f30..e691c372b960 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1120,7 +1120,6 @@ static snd_pcm_uframes_t pcxhr_stream_pointer(struct snd_pcm_substream *subs) static const struct snd_pcm_ops pcxhr_ops = { .open = pcxhr_open, .close = pcxhr_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = pcxhr_prepare, .hw_params = pcxhr_hw_params, .trigger = pcxhr_trigger, diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index b855de52e198..be0283f8bda0 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1656,7 +1656,6 @@ static int snd_riptide_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_riptide_playback_ops = { .open = snd_riptide_playback_open, .close = snd_riptide_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_riptide_hw_params, .hw_free = snd_riptide_hw_free, .prepare = snd_riptide_prepare, @@ -1666,7 +1665,6 @@ static const struct snd_pcm_ops snd_riptide_playback_ops = { static const struct snd_pcm_ops snd_riptide_capture_ops = { .open = snd_riptide_capture_open, .close = snd_riptide_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_riptide_hw_params, .hw_free = snd_riptide_hw_free, .prepare = snd_riptide_prepare, diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index aab47e5d96dc..849eede15f8e 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1177,7 +1177,6 @@ snd_rme32_capture_fd_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_rme32_playback_spdif_ops = { .open = snd_rme32_playback_spdif_open, .close = snd_rme32_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1191,7 +1190,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_ops = { static const struct snd_pcm_ops snd_rme32_capture_spdif_ops = { .open = snd_rme32_capture_spdif_open, .close = snd_rme32_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1204,7 +1202,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_ops = { static const struct snd_pcm_ops snd_rme32_playback_adat_ops = { .open = snd_rme32_playback_adat_open, .close = snd_rme32_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1218,7 +1215,6 @@ static const struct snd_pcm_ops snd_rme32_playback_adat_ops = { static const struct snd_pcm_ops snd_rme32_capture_adat_ops = { .open = snd_rme32_capture_adat_open, .close = snd_rme32_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1232,7 +1228,6 @@ static const struct snd_pcm_ops snd_rme32_capture_adat_ops = { static const struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops = { .open = snd_rme32_playback_spdif_open, .close = snd_rme32_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1243,7 +1238,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops = { static const struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops = { .open = snd_rme32_capture_spdif_open, .close = snd_rme32_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1254,7 +1248,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops = { static const struct snd_pcm_ops snd_rme32_playback_adat_fd_ops = { .open = snd_rme32_playback_adat_open, .close = snd_rme32_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, @@ -1265,7 +1258,6 @@ static const struct snd_pcm_ops snd_rme32_playback_adat_fd_ops = { static const struct snd_pcm_ops snd_rme32_capture_adat_fd_ops = { .open = snd_rme32_capture_adat_open, .close = snd_rme32_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 64ab55772eae..f52195791a8b 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -1508,7 +1508,6 @@ snd_rme96_capture_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_rme96_playback_spdif_ops = { .open = snd_rme96_playback_spdif_open, .close = snd_rme96_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme96_playback_hw_params, .prepare = snd_rme96_playback_prepare, .trigger = snd_rme96_playback_trigger, @@ -1522,7 +1521,6 @@ static const struct snd_pcm_ops snd_rme96_playback_spdif_ops = { static const struct snd_pcm_ops snd_rme96_capture_spdif_ops = { .open = snd_rme96_capture_spdif_open, .close = snd_rme96_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme96_capture_hw_params, .prepare = snd_rme96_capture_prepare, .trigger = snd_rme96_capture_trigger, @@ -1535,7 +1533,6 @@ static const struct snd_pcm_ops snd_rme96_capture_spdif_ops = { static const struct snd_pcm_ops snd_rme96_playback_adat_ops = { .open = snd_rme96_playback_adat_open, .close = snd_rme96_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme96_playback_hw_params, .prepare = snd_rme96_playback_prepare, .trigger = snd_rme96_playback_trigger, @@ -1549,7 +1546,6 @@ static const struct snd_pcm_ops snd_rme96_playback_adat_ops = { static const struct snd_pcm_ops snd_rme96_capture_adat_ops = { .open = snd_rme96_capture_adat_open, .close = snd_rme96_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme96_capture_hw_params, .prepare = snd_rme96_capture_prepare, .trigger = snd_rme96_capture_trigger, diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 4639bc21b42d..06dccf080bcc 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -846,7 +846,6 @@ static int sis_pcm_capture_prepare(struct snd_pcm_substream *substream) static const struct snd_pcm_ops sis_playback_ops = { .open = sis_playback_open, .close = sis_substream_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = sis_pcm_playback_prepare, .trigger = sis_pcm_trigger, .pointer = sis_pcm_pointer, @@ -855,7 +854,6 @@ static const struct snd_pcm_ops sis_playback_ops = { static const struct snd_pcm_ops sis_capture_ops = { .open = sis_capture_open, .close = sis_substream_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = sis_capture_hw_params, .prepare = sis_pcm_capture_prepare, .trigger = sis_pcm_trigger, diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index e117d8450b2d..bc650c8e85b0 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -835,7 +835,6 @@ static int snd_sonicvibes_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { .open = snd_sonicvibes_playback_open, .close = snd_sonicvibes_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sonicvibes_playback_prepare, .trigger = snd_sonicvibes_playback_trigger, .pointer = snd_sonicvibes_playback_pointer, @@ -844,7 +843,6 @@ static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { static const struct snd_pcm_ops snd_sonicvibes_capture_ops = { .open = snd_sonicvibes_capture_open, .close = snd_sonicvibes_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sonicvibes_capture_prepare, .trigger = snd_sonicvibes_capture_trigger, .pointer = snd_sonicvibes_capture_pointer, diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 748bbdcb2c52..61604277ae35 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1103,7 +1103,6 @@ static int snd_ymfpci_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_ymfpci_playback_ops = { .open = snd_ymfpci_playback_open, .close = snd_ymfpci_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ymfpci_playback_hw_params, .hw_free = snd_ymfpci_playback_hw_free, .prepare = snd_ymfpci_playback_prepare, @@ -1114,7 +1113,6 @@ static const struct snd_pcm_ops snd_ymfpci_playback_ops = { static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { .open = snd_ymfpci_capture_rec_open, .close = snd_ymfpci_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1148,7 +1146,6 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { .open = snd_ymfpci_capture_ac97_open, .close = snd_ymfpci_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1181,7 +1178,6 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) static const struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { .open = snd_ymfpci_playback_spdif_open, .close = snd_ymfpci_playback_spdif_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ymfpci_playback_hw_params, .hw_free = snd_ymfpci_playback_hw_free, .prepare = snd_ymfpci_playback_prepare, @@ -1214,7 +1210,6 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) static const struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { .open = snd_ymfpci_playback_4ch_open, .close = snd_ymfpci_playback_4ch_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ymfpci_playback_hw_params, .hw_free = snd_ymfpci_playback_hw_free, .prepare = snd_ymfpci_playback_prepare, -- cgit v1.2.3 From 1a0fa90f9c01f83ec4c215dca67ef9e8444b19d0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:38 +0100 Subject: ALSA: pcmcia: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-17-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index a4be4d1b0f7d..6cbe5cb34358 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -238,7 +238,6 @@ static snd_pcm_uframes_t pdacf_pcm_capture_pointer(struct snd_pcm_substream *sub static const struct snd_pcm_ops pdacf_pcm_capture_ops = { .open = pdacf_pcm_capture_open, .close = pdacf_pcm_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = pdacf_pcm_prepare, .trigger = pdacf_pcm_trigger, .pointer = pdacf_pcm_capture_pointer, -- cgit v1.2.3 From 5b6e996a6218eb91b8b44c3821b3ae109e9aca52 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:39 +0100 Subject: ALSA: ppc: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-18-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 2 -- sound/ppc/snd_ps3.c | 1 - 2 files changed, 3 deletions(-) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 1629f91d7ae2..026410c7dd71 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -653,7 +653,6 @@ static int snd_pmac_capture_close(struct snd_pcm_substream *subs) static const struct snd_pcm_ops snd_pmac_playback_ops = { .open = snd_pmac_playback_open, .close = snd_pmac_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_pmac_playback_prepare, .trigger = snd_pmac_playback_trigger, .pointer = snd_pmac_playback_pointer, @@ -662,7 +661,6 @@ static const struct snd_pcm_ops snd_pmac_playback_ops = { static const struct snd_pcm_ops snd_pmac_capture_ops = { .open = snd_pmac_capture_open, .close = snd_pmac_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_pmac_capture_prepare, .trigger = snd_pmac_capture_trigger, .pointer = snd_pmac_capture_pointer, diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index c6c004958e6f..2b4c0268a86b 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -742,7 +742,6 @@ static struct snd_kcontrol_new spdif_ctls[] = { static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { .open = snd_ps3_pcm_open, .close = snd_ps3_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_ps3_pcm_prepare, .trigger = snd_ps3_pcm_trigger, .pointer = snd_ps3_pcm_pointer, -- cgit v1.2.3 From 9fafc5259b430e9f2d3900dc163e9d22a4b56c86 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:40 +0100 Subject: ALSA: sh: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-19-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 1 - sound/sh/sh_dac_audio.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sound/sh/aica.c b/sound/sh/aica.c index 8ff88d71439e..f3cd12ff09c3 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -399,7 +399,6 @@ static unsigned long snd_aicapcm_pcm_pointer(struct snd_pcm_substream static const struct snd_pcm_ops snd_aicapcm_playback_ops = { .open = snd_aicapcm_pcm_open, .close = snd_aicapcm_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index 1406b50f3f78..b1e171dfe361 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -228,7 +228,6 @@ snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { .open = snd_sh_dac_pcm_open, .close = snd_sh_dac_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_sh_dac_pcm_prepare, .trigger = snd_sh_dac_pcm_trigger, .pointer = snd_sh_dac_pcm_pointer, -- cgit v1.2.3 From 5fcd1aeee587f6582e66572d12fb0b9c4c2583fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:41 +0100 Subject: ALSA: sparc: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-20-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 2 -- sound/sparc/cs4231.c | 2 -- sound/sparc/dbri.c | 1 - 3 files changed, 5 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index d39973605cca..df1b16c97d16 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -726,7 +726,6 @@ static int snd_amd7930_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_amd7930_playback_ops = { .open = snd_amd7930_playback_open, .close = snd_amd7930_playback_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_amd7930_playback_prepare, .trigger = snd_amd7930_playback_trigger, .pointer = snd_amd7930_playback_pointer, @@ -735,7 +734,6 @@ static const struct snd_pcm_ops snd_amd7930_playback_ops = { static const struct snd_pcm_ops snd_amd7930_capture_ops = { .open = snd_amd7930_capture_open, .close = snd_amd7930_capture_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = snd_amd7930_capture_prepare, .trigger = snd_amd7930_capture_trigger, .pointer = snd_amd7930_capture_pointer, diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 874da942b662..1676d44769ad 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1193,7 +1193,6 @@ static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_playback_hw_params, .prepare = snd_cs4231_playback_prepare, .trigger = snd_cs4231_trigger, @@ -1203,7 +1202,6 @@ static const struct snd_pcm_ops snd_cs4231_playback_ops = { static const struct snd_pcm_ops snd_cs4231_capture_ops = { .open = snd_cs4231_capture_open, .close = snd_cs4231_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_capture_hw_params, .prepare = snd_cs4231_capture_prepare, .trigger = snd_cs4231_trigger, diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 315d5a04a33e..1390a52d6cfd 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2215,7 +2215,6 @@ static snd_pcm_uframes_t snd_dbri_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops snd_dbri_ops = { .open = snd_dbri_open, .close = snd_dbri_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_dbri_hw_params, .hw_free = snd_dbri_hw_free, .prepare = snd_dbri_prepare, -- cgit v1.2.3 From 6bddc9ef588555a9ed25c735fa8b277d966df78a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:42 +0100 Subject: ALSA: spi: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-21-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 8b1b5c86cebf..77563baf7a8f 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -316,7 +316,6 @@ snd_at73c213_pcm_pointer(struct snd_pcm_substream *substream) static const struct snd_pcm_ops at73c213_playback_ops = { .open = snd_at73c213_pcm_open, .close = snd_at73c213_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_at73c213_pcm_hw_params, .prepare = snd_at73c213_pcm_prepare, .trigger = snd_at73c213_pcm_trigger, -- cgit v1.2.3 From 9c0d064a1e1906bf18a4d641145df004d16a10dd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:43 +0100 Subject: ALSA: usb: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-22-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/6fire/pcm.c | 1 - sound/usb/caiaq/audio.c | 1 - sound/usb/hiface/pcm.c | 1 - sound/usb/line6/capture.c | 1 - sound/usb/line6/playback.c | 1 - sound/usb/misc/ua101.c | 2 -- sound/usb/pcm.c | 2 -- sound/usb/usx2y/usbusx2yaudio.c | 1 - sound/usb/usx2y/usx2yhwdeppcm.c | 1 - 9 files changed, 11 deletions(-) diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index 706aa3fac351..7168f1c6a37a 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c @@ -542,7 +542,6 @@ static snd_pcm_uframes_t usb6fire_pcm_pointer( static const struct snd_pcm_ops pcm_ops = { .open = usb6fire_pcm_open, .close = usb6fire_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = usb6fire_pcm_prepare, .trigger = usb6fire_pcm_trigger, .pointer = usb6fire_pcm_pointer, diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 8513b120e57e..72212153cb1f 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -321,7 +321,6 @@ unlock: static const struct snd_pcm_ops snd_usb_caiaq_ops = { .open = snd_usb_caiaq_substream_open, .close = snd_usb_caiaq_substream_close, - .ioctl = snd_pcm_lib_ioctl, .hw_free = snd_usb_caiaq_pcm_hw_free, .prepare = snd_usb_caiaq_pcm_prepare, .trigger = snd_usb_caiaq_pcm_trigger, diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index cc0639a1b419..a148caa5f48e 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -500,7 +500,6 @@ static snd_pcm_uframes_t hiface_pcm_pointer(struct snd_pcm_substream *alsa_sub) static const struct snd_pcm_ops pcm_ops = { .open = hiface_pcm_open, .close = hiface_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .prepare = hiface_pcm_prepare, .trigger = hiface_pcm_trigger, .pointer = hiface_pcm_pointer, diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 82abef3fe90d..663d608c4287 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c @@ -247,7 +247,6 @@ static int snd_line6_capture_close(struct snd_pcm_substream *substream) const struct snd_pcm_ops snd_line6_capture_ops = { .open = snd_line6_capture_open, .close = snd_line6_capture_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_line6_hw_params, .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 2e8ead3f9bc2..01930ce7bd75 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -392,7 +392,6 @@ static int snd_line6_playback_close(struct snd_pcm_substream *substream) const struct snd_pcm_ops snd_line6_playback_ops = { .open = snd_line6_playback_open, .close = snd_line6_playback_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_line6_hw_params, .hw_free = snd_line6_hw_free, .prepare = snd_line6_prepare, diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index a7b68447f3ad..884e740a785c 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -870,7 +870,6 @@ static snd_pcm_uframes_t playback_pcm_pointer(struct snd_pcm_substream *subs) static const struct snd_pcm_ops capture_pcm_ops = { .open = capture_pcm_open, .close = capture_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = capture_pcm_hw_params, .prepare = capture_pcm_prepare, .trigger = capture_pcm_trigger, @@ -880,7 +879,6 @@ static const struct snd_pcm_ops capture_pcm_ops = { static const struct snd_pcm_ops playback_pcm_ops = { .open = playback_pcm_open, .close = playback_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = playback_pcm_hw_params, .prepare = playback_pcm_prepare, .trigger = playback_pcm_trigger, diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 7caaa04ae546..33c1e971e61e 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1763,7 +1763,6 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream static const struct snd_pcm_ops snd_usb_playback_ops = { .open = snd_usb_pcm_open, .close = snd_usb_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_usb_hw_params, .hw_free = snd_usb_hw_free, .prepare = snd_usb_pcm_prepare, @@ -1774,7 +1773,6 @@ static const struct snd_pcm_ops snd_usb_playback_ops = { static const struct snd_pcm_ops snd_usb_capture_ops = { .open = snd_usb_pcm_open, .close = snd_usb_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_usb_hw_params, .hw_free = snd_usb_hw_free, .prepare = snd_usb_pcm_prepare, diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 7eb9805a4326..8ac4ce0e8965 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -893,7 +893,6 @@ static const struct snd_pcm_ops snd_usX2Y_pcm_ops = { .open = snd_usX2Y_pcm_open, .close = snd_usX2Y_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_usX2Y_pcm_hw_params, .hw_free = snd_usX2Y_pcm_hw_free, .prepare = snd_usX2Y_pcm_prepare, diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 419d9f07d197..d8d91f2fb799 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -581,7 +581,6 @@ static const struct snd_pcm_ops snd_usX2Y_usbpcm_ops = { .open = snd_usX2Y_usbpcm_open, .close = snd_usX2Y_usbpcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_usX2Y_pcm_hw_params, .hw_free = snd_usX2Y_usbpcm_hw_free, .prepare = snd_usX2Y_usbpcm_prepare, -- cgit v1.2.3 From 63d5cda7f55bb3537d30642c1cf7e5afccb6e6c7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:44 +0100 Subject: ALSA: x86: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-23-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/x86/intel_hdmi_audio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index a67692ca08af..741cf611ea30 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -1286,7 +1286,6 @@ static int had_pcm_mmap(struct snd_pcm_substream *substream, static const struct snd_pcm_ops had_pcm_ops = { .open = had_pcm_open, .close = had_pcm_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = had_pcm_hw_params, .hw_free = had_pcm_hw_free, .prepare = had_pcm_prepare, -- cgit v1.2.3 From 4bb1e4e7ccc2a955e933d0cec630da40012dcd42 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:11:45 +0100 Subject: ALSA: xen: Drop superfluous ioctl PCM ops PCM core deals the empty ioctl field now as default(*). Let's kill the redundant lines. (*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops") Link: https://lore.kernel.org/r/20191210061145.24641-24-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/xen/xen_snd_front_alsa.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c index e01631959ed8..db917453a473 100644 --- a/sound/xen/xen_snd_front_alsa.c +++ b/sound/xen/xen_snd_front_alsa.c @@ -692,7 +692,6 @@ static int alsa_pb_fill_silence(struct snd_pcm_substream *substream, static const struct snd_pcm_ops snd_drv_alsa_playback_ops = { .open = alsa_open, .close = alsa_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = alsa_hw_params, .hw_free = alsa_hw_free, .prepare = alsa_prepare, @@ -706,7 +705,6 @@ static const struct snd_pcm_ops snd_drv_alsa_playback_ops = { static const struct snd_pcm_ops snd_drv_alsa_capture_ops = { .open = alsa_open, .close = alsa_close, - .ioctl = snd_pcm_lib_ioctl, .hw_params = alsa_hw_params, .hw_free = alsa_hw_free, .prepare = alsa_prepare, -- cgit v1.2.3 From 164d0738248ac0befb4ce11ca60a06a41838af47 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:00 +0100 Subject: ALSA: ad1889: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 4b902c163fd3..7770157a3a8c 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -899,7 +899,7 @@ snd_ad1889_create(struct snd_card *card, } chip->irq = pci->irq; - synchronize_irq(chip->irq); + card->sync_irq = chip->irq; /* (2) initialization of the chip hardware */ if ((err = snd_ad1889_init(chip)) < 0) { -- cgit v1.2.3 From 5110bc701b4aa839f461aa5a1a6259bf91b07036 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:01 +0100 Subject: ALSA: ali5451: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 2cf37670e9a9..9f78cf9e0b47 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -2026,6 +2026,7 @@ static int snd_ali_resources(struct snd_ali *codec) return -EBUSY; } codec->irq = codec->pci->irq; + codec->card->sync_irq = codec->irq; dev_dbg(codec->card->dev, "resources allocated.\n"); return 0; } @@ -2099,8 +2100,6 @@ static int snd_ali_create(struct snd_card *card, return -EBUSY; } - synchronize_irq(pci->irq); - codec->synth.chmap = 0; codec->synth.chcnt = 0; codec->spdif_mask = 0; -- cgit v1.2.3 From ea2eab50a0e1a868a87b407f51a6b45b9062ee08 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:02 +0100 Subject: ALSA: als300: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/als300.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 0fb84d1d1dbe..6573a2259cb6 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -664,7 +664,7 @@ static int snd_als300_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; - + card->sync_irq = chip->irq; snd_als300_init(chip); -- cgit v1.2.3 From 4504487d928d5801e8cc52f70e77392cc94d45f5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:03 +0100 Subject: ALSA: atiixp: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 977cdaf92f53..684b4f18e52c 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1597,8 +1597,8 @@ static int snd_atiixp_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); - synchronize_irq(chip->irq); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_atiixp_free(chip); diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index a27ce41f10d3..40cda5c3bfeb 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1227,8 +1227,8 @@ static int snd_atiixp_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); - synchronize_irq(chip->irq); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_atiixp_free(chip); -- cgit v1.2.3 From 662a7441316d584d8bf62004ff55d978004a97ec Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:04 +0100 Subject: ALSA: au88x0: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 782333c90223..c9e0159af2b1 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -202,6 +202,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) goto irq_out; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); // End of PCI setup. -- cgit v1.2.3 From f8582e001f72bbd279f2559122e12741fda90619 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:05 +0100 Subject: ALSA: aw2: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-7-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/aw2/aw2-alsa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 7df55797c2f6..819b148573a6 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -287,6 +287,7 @@ static int snd_aw2_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { -- cgit v1.2.3 From aefd1860acd553efb6d7cb00654a4963e4a73bd6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:06 +0100 Subject: ALSA: azt3328: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-8-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/azt3328.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 1a852d893e98..b36e7a64e268 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -2423,8 +2423,8 @@ snd_azf3328_create(struct snd_card *card, goto out_err; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); - synchronize_irq(chip->irq); snd_azf3328_debug_show_ports(chip); -- cgit v1.2.3 From d2625a62fe7534c6acb4ca3b668d4d46a98beab8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:07 +0100 Subject: ALSA: bt87x: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-9-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/bt87x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index de4af1ab87c6..2e16604c31ce 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -751,8 +751,8 @@ static int snd_bt87x_create(struct snd_card *card, goto fail; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); - synchronize_irq(chip->irq); err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) -- cgit v1.2.3 From 339ede502a00af9c32ce1b585a6be94f2d4f96c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:08 +0100 Subject: ALSA: ca0106: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-10-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 9466ee9d2f42..a14e9b1e50b0 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1638,6 +1638,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; /* This stores the periods table. */ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, -- cgit v1.2.3 From 3663984e07a4806c891db66c1ac4fed5c36d38f2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:09 +0100 Subject: ALSA: cmipci: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-11-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 0e0f528805bf..4bfab21c53f4 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -3024,6 +3024,7 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, return -EBUSY; } cm->irq = pci->irq; + card->sync_irq = cm->irq; pci_set_master(cm->pci); -- cgit v1.2.3 From 5afff8c1bbc7c5d9a092b217dd27040ccd5b347a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:10 +0100 Subject: ALSA: cs4281: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-12-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 0dcb2d15b560..e7294b9d2cb6 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1268,9 +1268,6 @@ static int snd_cs4281_free(struct cs4281 *chip) { snd_cs4281_free_gameport(chip); - if (chip->irq >= 0) - synchronize_irq(chip->irq); - /* Mask interrupts */ snd_cs4281_pokeBA0(chip, BA0_HIMR, 0x7fffffff); /* Stop the DLL Clock logic. */ @@ -1352,6 +1349,7 @@ static int snd_cs4281_create(struct snd_card *card, return -ENOMEM; } chip->irq = pci->irq; + card->sync_irq = chip->irq; tmp = snd_cs4281_chip_init(chip); if (tmp) { @@ -1600,7 +1598,6 @@ static int snd_cs4281_chip_init(struct cs4281 *chip) BA0_HISR_DMA(1) | BA0_HISR_DMA(2) | BA0_HISR_DMA(3))); - synchronize_irq(chip->irq); return 0; } -- cgit v1.2.3 From 763ae53d2ae40feccc7edbeb0067b7f6978699a5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:11 +0100 Subject: ALSA: cs46xx: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-13-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/cs46xx_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 1192115b71ef..adfc750bc61c 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3989,6 +3989,7 @@ int snd_cs46xx_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; #ifdef CONFIG_SND_CS46XX_NEW_DSP chip->dsp_spos_instance = cs46xx_dsp_spos_create(chip); -- cgit v1.2.3 From 25ec679b90782aed4894a1c3cc36c0a4ed350a20 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:12 +0100 Subject: ALSA: cs5535audio: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-14-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 68db7dec90b3..15126aff63fc 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -237,7 +237,6 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id) static int snd_cs5535audio_free(struct cs5535audio *cs5535au) { - synchronize_irq(cs5535au->irq); pci_set_power_state(cs5535au->pci, PCI_D3hot); if (cs5535au->irq >= 0) @@ -303,6 +302,7 @@ static int snd_cs5535audio_create(struct snd_card *card, } cs5535au->irq = pci->irq; + card->sync_irq = cs5535au->irq; pci_set_master(pci); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, -- cgit v1.2.3 From 5e0890c1cb7dbcb9779fb664e8f3c579911c9283 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:13 +0100 Subject: ALSA: ctxfi: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-15-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/cthw20k1.c | 4 +--- sound/pci/ctxfi/cthw20k2.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 4ff7ecd92709..6e3177bcc709 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -1937,6 +1937,7 @@ static int hw_card_start(struct hw *hw) goto error2; } hw->irq = pci->irq; + hw->card->sync_irq = hw->irq; } pci_set_master(pci); @@ -1962,9 +1963,6 @@ static int hw_card_stop(struct hw *hw) data = hw_read_20kx(hw, PLLCTL); hw_write_20kx(hw, PLLCTL, (data & (~(0x0F<<12)))); - /* TODO: Disable interrupt and so on... */ - if (hw->irq >= 0) - synchronize_irq(hw->irq); return 0; } diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 3cd4b7dad945..ce44cbe6459f 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -2061,6 +2061,7 @@ static int hw_card_start(struct hw *hw) goto error2; } hw->irq = pci->irq; + hw->card->sync_irq = hw->irq; } pci_set_master(pci); -- cgit v1.2.3 From d4cad99fda9bc5ba6de3a56aedb572a008d1856a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:14 +0100 Subject: ALSA: echoaudio: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-16-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index bfc3ffffb917..a9ac9fc635aa 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1928,6 +1928,7 @@ static int snd_echo_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; dev_dbg(card->dev, "pci=%p irq=%d subdev=%04x Init hardware...\n", chip->pci, chip->irq, chip->pci->subsystem_device); @@ -2151,6 +2152,7 @@ static int snd_echo_suspend(struct device *dev) chip->dsp_code = NULL; free_irq(chip->irq, chip); chip->irq = -1; + chip->card->sync_irq = -1; return 0; } @@ -2204,6 +2206,7 @@ static int snd_echo_resume(struct device *dev) return -EBUSY; } chip->irq = pci->irq; + chip->card->sync_irq = chip->irq; dev_dbg(dev, "resume irq=%d\n", chip->irq); #ifdef ECHOCARD_HAS_MIDI -- cgit v1.2.3 From 66471aa715f0d4207c61e27e6333d6f453df554b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:15 +0100 Subject: ALSA: emu10k1: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-17-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1_main.c | 1 + sound/pci/emu10k1/emu10k1x.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 8c1e968b9c96..65e9ec94b807 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1984,6 +1984,7 @@ int snd_emu10k1_create(struct snd_card *card, goto error; } emu->irq = pci->irq; + card->sync_irq = emu->irq; /* * Init to 0x02109204 : diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 19fc74e94727..6467142ec460 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -930,6 +930,7 @@ static int snd_emu10k1x_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 4 * 1024, &chip->dma_buffer) < 0) { -- cgit v1.2.3 From 83720eef264bbfb6fa94b3eeb2671ffd0bd2dde7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:16 +0100 Subject: ALSA: ens137x: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-18-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index f69555c95263..378141aa7c7d 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1888,8 +1888,6 @@ static int snd_ensoniq_free(struct ensoniq *ensoniq) outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */ outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ #endif - if (ensoniq->irq >= 0) - synchronize_irq(ensoniq->irq); pci_set_power_state(ensoniq->pci, PCI_D3hot); __hw_end: #ifdef CHIP1370 @@ -1990,7 +1988,6 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL)); outb(0x00, ES_REG(ensoniq, UART_RES)); outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); - synchronize_irq(ensoniq->irq); } #ifdef CONFIG_PM_SLEEP @@ -2074,6 +2071,7 @@ static int snd_ensoniq_create(struct snd_card *card, return -EBUSY; } ensoniq->irq = pci->irq; + card->sync_irq = ensoniq->irq; #ifdef CHIP1370 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev, 16, &ensoniq->dma_bug) < 0) { -- cgit v1.2.3 From 6b276e6281b6df9b3a74905dab2ead9aaca3fc55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:17 +0100 Subject: ALSA: es1938: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-19-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index ae405bc38c65..d9fba07d36d0 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1444,6 +1444,7 @@ static int es1938_suspend(struct device *dev) if (chip->irq >= 0) { free_irq(chip->irq, chip); chip->irq = -1; + card->sync_irq = -1; } return 0; } @@ -1463,6 +1464,7 @@ static int es1938_resume(struct device *dev) return -EIO; } chip->irq = pci->irq; + card->sync_irq = chip->irq; snd_es1938_chip_init(chip); /* restore mixer-related registers */ @@ -1591,6 +1593,7 @@ static int snd_es1938_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; dev_dbg(card->dev, "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n", chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port); -- cgit v1.2.3 From dbb71ab05f39162e7e65dbde36cd60be50a4bd5c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:18 +0100 Subject: ALSA: es1968: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-20-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 4f5063ebce89..3610aa1da94c 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2602,8 +2602,6 @@ static int snd_es1968_free(struct es1968 *chip) #endif if (chip->io_port) { - if (chip->irq >= 0) - synchronize_irq(chip->irq); outw(1, chip->io_port + 0x04); /* clear WP interrupts */ outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */ } @@ -2712,6 +2710,7 @@ static int snd_es1968_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; /* Clear Maestro_map */ for (i = 0; i < 32; i++) -- cgit v1.2.3 From e41dbd20383d0dda8813ef6186b142be4de0ddb6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:19 +0100 Subject: ALSA: fm801: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-21-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 3ea10c972682..152fbc352123 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1223,6 +1223,7 @@ static int snd_fm801_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; pci_set_master(pci); } -- cgit v1.2.3 From f36da9406e6698a97ea643aeeab6307863094967 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:20 +0100 Subject: ALSA: hda: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-22-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 4 +++- sound/pci/hda/hda_tegra.c | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index b856b89378ac..c86539cdbd4b 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -790,6 +790,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect) return -1; } bus->irq = chip->pci->irq; + chip->card->sync_irq = bus->irq; pci_intx(chip->pci, !chip->msi); return 0; } @@ -1028,6 +1029,7 @@ static int azx_suspend(struct device *dev) if (bus->irq >= 0) { free_irq(bus->irq, chip); bus->irq = -1; + chip->card->sync_irq = -1; } if (chip->msi) @@ -1883,7 +1885,6 @@ static int azx_first_init(struct azx *chip) } pci_set_master(pci); - synchronize_irq(bus->irq); gcap = azx_readw(chip, GCAP); dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); @@ -2042,6 +2043,7 @@ static int disable_msi_reset_irq(struct azx *chip) free_irq(bus->irq, chip); bus->irq = -1; + chip->card->sync_irq = -1; pci_disable_msi(chip->pci); chip->msi = 0; err = azx_acquire_irq(chip, 1); diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 8350954b7986..fc2e0a294bc1 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -170,7 +170,6 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev) if (chip && chip->running) { azx_stop_chip(chip); - synchronize_irq(bus->irq); azx_enter_link_reset(chip); } hda_tegra_disable_clocks(hda); @@ -298,8 +297,7 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) return err; } bus->irq = irq_id; - - synchronize_irq(bus->irq); + card->sync_irq = bus->irq; gcap = azx_readw(chip, GCAP); dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); -- cgit v1.2.3 From 1b97a87f44d848253d1249f0bcbe804ed677edc4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:21 +0100 Subject: ALSA: ice1712: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-23-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1712.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index d6e55bf0df16..ffacf5e6ac9a 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2528,7 +2528,6 @@ static int snd_ice1712_create(struct snd_card *card, pci_write_config_word(ice->pci, 0x40, 0x807f); pci_write_config_word(ice->pci, 0x42, 0x0006); snd_ice1712_proc_init(ice); - synchronize_irq(pci->irq); card->private_data = ice; @@ -2551,6 +2550,7 @@ static int snd_ice1712_create(struct snd_card *card, } ice->irq = pci->irq; + card->sync_irq = ice->irq; if (snd_ice1712_read_eeprom(ice, modelname) < 0) { snd_ice1712_free(ice); -- cgit v1.2.3 From b0ad3bbc1e1ba112adff0eafac59811abf7a9686 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:22 +0100 Subject: ALSA: ice1724: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-24-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1724.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index d5590a82e7fd..14e4da08adfd 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2534,7 +2534,6 @@ static int snd_vt1724_create(struct snd_card *card, ice->irq = -1; pci_set_master(pci); snd_vt1724_proc_init(ice); - synchronize_irq(pci->irq); card->private_data = ice; @@ -2555,6 +2554,7 @@ static int snd_vt1724_create(struct snd_card *card, } ice->irq = pci->irq; + card->sync_irq = ice->irq; snd_vt1724_chip_reset(ice); if (snd_vt1724_read_eeprom(ice, modelname) < 0) { -- cgit v1.2.3 From be1391c7858ffd7c5c1b4f004431cfbffb3e923c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:23 +0100 Subject: ALSA: intel8x0: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-25-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 4 +++- sound/pci/intel8x0m.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 2a3551deee74..f88008465c44 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2592,6 +2592,7 @@ static int intel8x0_suspend(struct device *dev) if (chip->irq >= 0) { free_irq(chip->irq, chip); chip->irq = -1; + card->sync_irq = -1; } return 0; } @@ -2612,7 +2613,7 @@ static int intel8x0_resume(struct device *dev) return -EIO; } chip->irq = pci->irq; - synchronize_irq(chip->irq); + card->sync_irq = chip->irq; /* re-initialize mixer stuff */ if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { @@ -3092,6 +3093,7 @@ static int snd_intel8x0_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_intel8x0_free(chip); diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 13dd3d873e95..2f73b45c845c 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -999,6 +999,7 @@ static int intel8x0m_suspend(struct device *dev) if (chip->irq >= 0) { free_irq(chip->irq, chip); chip->irq = -1; + card->sync_irq = -1; } return 0; } @@ -1017,6 +1018,7 @@ static int intel8x0m_resume(struct device *dev) return -EIO; } chip->irq = pci->irq; + card->sync_irq = chip->irq; snd_intel8x0m_chip_init(chip, 0); snd_ac97_resume(chip->ac97); @@ -1191,6 +1193,7 @@ static int snd_intel8x0m_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_intel8x0m_free(chip); -- cgit v1.2.3 From 67ceac17e87780d7879fecd4dc0ac52bf99b164a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:24 +0100 Subject: ALSA: korg1212: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-26-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/korg1212/korg1212.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 2b8204a13c69..5d48ff0b32a7 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2237,6 +2237,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, } korg1212->irq = pci->irq; + card->sync_irq = korg1212->irq; pci_set_master(korg1212->pci); -- cgit v1.2.3 From aec9f0cc057ece110be244fc5d2f10ba3176a8db Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:25 +0100 Subject: ALSA: lola: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-27-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/lola/lola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index 21ac9d003e8e..e7c620caa935 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c @@ -638,7 +638,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci, goto errout; } chip->irq = pci->irq; - synchronize_irq(chip->irq); + card->sync_irq = chip->irq; dever = lola_readl(chip, BAR1, DEVER); chip->pcm[CAPT].num_streams = (dever >> 0) & 0x3ff; -- cgit v1.2.3 From a20b8bfe557c794ae3a35c1ca9cb25d3abaf7784 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:26 +0100 Subject: ALSA: maestro3: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-28-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/maestro3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 501f1871f776..9f75cc0c01dd 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2633,6 +2633,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, goto free_chip; } chip->irq = pci->irq; + card->sync_irq = chip->irq; #ifdef CONFIG_PM_SLEEP chip->suspend_mem = -- cgit v1.2.3 From 1478eb63654b367399f79edc0734a3bda1b0324b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:27 +0100 Subject: ALSA: nm256: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. It's cleared and reset dynamically at IRQ re-acquiring for the PM resume, too. Link: https://lore.kernel.org/r/20191210063454.31603-29-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 02767f33deb7..ac194485aa78 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -460,6 +460,7 @@ static int snd_nm256_acquire_irq(struct nm256 *chip) return -EBUSY; } chip->irq = chip->pci->irq; + chip->card->sync_irq = chip->irq; } chip->irq_acks++; mutex_unlock(&chip->irq_mutex); @@ -475,6 +476,7 @@ static void snd_nm256_release_irq(struct nm256 *chip) if (chip->irq_acks == 0 && chip->irq >= 0) { free_irq(chip->irq, chip); chip->irq = -1; + chip->card->sync_irq = -1; } mutex_unlock(&chip->irq_mutex); } -- cgit v1.2.3 From bf17d20adea74015628a1db0c658d256697b8d83 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:28 +0100 Subject: ALSA: oxygen: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-30-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index ed65d9fd4938..afc6dd329c09 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -661,6 +661,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, goto err_card; } chip->irq = pci->irq; + card->sync_irq = chip->irq; strcpy(card->driver, chip->model.chip); strcpy(card->shortname, chip->model.shortname); @@ -743,7 +744,6 @@ static int oxygen_pci_suspend(struct device *dev) oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); spin_unlock_irq(&chip->reg_lock); - synchronize_irq(chip->irq); flush_work(&chip->spdif_input_bits_work); flush_work(&chip->gpio_work); chip->interrupt_mask = saved_interrupt_mask; -- cgit v1.2.3 From 3992f78f349f7f1565b43d244177f3975edb9aa1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:29 +0100 Subject: ALSA: riptide: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-31-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index be0283f8bda0..af6956e26c29 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1864,6 +1864,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; chip->device_id = pci->device; pci_set_master(pci); if ((err = snd_riptide_initialize(chip)) < 0) { -- cgit v1.2.3 From 1dad75b9823c77aa7e1020f011c72fcc15a90144 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:30 +0100 Subject: ALSA: rme32: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-32-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 849eede15f8e..15029b2be233 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1330,6 +1330,7 @@ static int snd_rme32_create(struct rme32 *rme32) return -EBUSY; } rme32->irq = pci->irq; + rme32->card->sync_irq = rme32->irq; /* read the card's revision number */ pci_read_config_byte(pci, 8, &rme32->rev); -- cgit v1.2.3 From 5fcf46bc8333409018f29966d736034c587d7aa6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:31 +0100 Subject: ALSA: rme96: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-33-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index f52195791a8b..537381632be7 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -1629,6 +1629,7 @@ snd_rme96_create(struct rme96 *rme96) return -EBUSY; } rme96->irq = pci->irq; + rme96->card->sync_irq = rme96->irq; /* read the card's revision number */ pci_read_config_byte(pci, 8, &rme96->rev); -- cgit v1.2.3 From 39cccf4511fd00c591c989edb47c8ed51aba0282 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:32 +0100 Subject: ALSA: rme9652: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-34-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 1 + sound/pci/rme9652/hdspm.c | 1 + sound/pci/rme9652/rme9652.c | 1 + 3 files changed, 3 insertions(+) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index cd20af465d8e..87e60dd13066 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5233,6 +5233,7 @@ static int snd_hdsp_create(struct snd_card *card, } hdsp->irq = pci->irq; + card->sync_irq = hdsp->irq; hdsp->precise_ptr = 0; hdsp->use_midi_tasklet = 1; hdsp->dds_value = 0; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 75c06a7cc779..56ae14c90a2c 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6613,6 +6613,7 @@ static int snd_hdspm_create(struct snd_card *card, dev_dbg(card->dev, "use IRQ %d\n", pci->irq); hdspm->irq = pci->irq; + card->sync_irq = hdspm->irq; dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", sizeof(*hdspm->mixer)); diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index ef5c2f8e17c7..6fda027d28a4 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2479,6 +2479,7 @@ static int snd_rme9652_create(struct snd_card *card, return -EBUSY; } rme9652->irq = pci->irq; + card->sync_irq = rme9652->irq; rme9652->precise_ptr = precise_ptr; /* Determine the h/w rev level of the card. This seems like -- cgit v1.2.3 From 39b77268c8cdfff171c09c22f7ee8069139d4f20 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:33 +0100 Subject: ALSA: sis7019: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-35-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/sis7019.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 06dccf080bcc..515598e3cacf 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1335,6 +1335,7 @@ static int sis_chip_create(struct snd_card *card, } sis->irq = pci->irq; + card->sync_irq = sis->irq; pci_set_master(pci); for (i = 0; i < 64; i++) { -- cgit v1.2.3 From 93042ac2bc40658e8e2cd809644e37bda05cf4fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:34 +0100 Subject: ALSA: sonicvibes: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-36-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/sonicvibes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index bc650c8e85b0..a2bff9431512 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1267,6 +1267,7 @@ static int snd_sonicvibes_create(struct snd_card *card, return -EBUSY; } sonic->irq = pci->irq; + card->sync_irq = sonic->irq; pci_read_config_dword(pci, 0x40, &dmaa); pci_read_config_dword(pci, 0x48, &dmac); -- cgit v1.2.3 From 4a9ff148bd348f7489fcc9d1a1ef3723b6f329be Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:35 +0100 Subject: ALSA: trident: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-37-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 0e02578c2b3d..0d039eacbf0a 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3543,6 +3543,7 @@ int snd_trident_create(struct snd_card *card, return -EBUSY; } trident->irq = pci->irq; + card->sync_irq = trident->irq; /* allocate 16k-aligned TLB for NX cards */ trident->tlb.entries = NULL; -- cgit v1.2.3 From c47583b0eb6847b0507a93b6dddc39dd1b15172f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:36 +0100 Subject: ALSA: via82xx: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation, as well as removing the superfluous synchronize_irq() call. Link: https://lore.kernel.org/r/20191210063454.31603-38-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 3 +-- sound/pci/via82xx_modem.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 3009c26ea8b9..e72050a9ffdb 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2245,7 +2245,6 @@ static int snd_via82xx_suspend(struct device *dev) snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); - synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); /* save misc values */ @@ -2376,9 +2375,9 @@ static int snd_via82xx_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if (ac97_clock >= 8000 && ac97_clock <= 48000) chip->ac97_clock = ac97_clock; - synchronize_irq(chip->irq); if ((err = snd_via82xx_chip_init(chip)) < 0) { snd_via82xx_free(chip); diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 67614a8311e0..4e0858f8e372 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1013,7 +1013,6 @@ static int snd_via82xx_suspend(struct device *dev) snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); - synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); return 0; } @@ -1105,9 +1104,9 @@ static int snd_via82xx_create(struct snd_card *card, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if (ac97_clock >= 8000 && ac97_clock <= 48000) chip->ac97_clock = ac97_clock; - synchronize_irq(chip->irq); if ((err = snd_via82xx_chip_init(chip)) < 0) { snd_via82xx_free(chip); -- cgit v1.2.3 From b7a03a1e14595aa806c33000bfb4fea4eb8acdc5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:37 +0100 Subject: ALSA: ymfpci: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-39-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 61604277ae35..3bc92d236508 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2371,6 +2371,7 @@ int snd_ymfpci_create(struct snd_card *card, goto free_chip; } chip->irq = pci->irq; + card->sync_irq = chip->irq; snd_ymfpci_aclink_reset(pci); if (snd_ymfpci_codec_ready(chip, 0) < 0) { -- cgit v1.2.3 From 0dbba47eb4e9428d8563278123992243c3c62c3e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:38 +0100 Subject: ALSA: ad1816a: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-40-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index b9d340c752b4..e1aa5372c483 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -597,6 +597,7 @@ int snd_ad1816a_create(struct snd_card *card, return -EBUSY; } chip->irq = irq; + card->sync_irq = chip->irq; if (request_dma(dma1, "AD1816A - 1")) { snd_printk(KERN_ERR "ad1816a: can't grab DMA1 %d\n", dma1); snd_ad1816a_free(chip); -- cgit v1.2.3 From f5ac512085b5c2667f8db5f09ce8b87648e5cce4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:39 +0100 Subject: ALSA: es1688: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-41-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 474d713085c7..632e867c5766 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -638,6 +638,7 @@ int snd_es1688_create(struct snd_card *card, } chip->irq = irq; + card->sync_irq = chip->irq; err = request_dma(dma8, "ES1688"); if (err < 0) { -- cgit v1.2.3 From 58dad836f98cdba69bb4f0b0a9a19af8e39e9fbf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:40 +0100 Subject: ALSA: es18xx: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-42-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 87a0a33807e7..a581083b876b 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1781,6 +1781,7 @@ static int snd_es18xx_new_device(struct snd_card *card, return -EBUSY; } chip->irq = irq; + card->sync_irq = chip->irq; if (request_dma(dma1, "ES18xx DMA 1")) { snd_es18xx_free(card); -- cgit v1.2.3 From 914da689090c094dd1ffce02b1fa13d7e9411ea0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:41 +0100 Subject: ALSA: gus: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-43-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_main.c | 1 + sound/isa/gus/gusmax.c | 3 ++- sound/isa/gus/interwave.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index af6b4d89d695..9f94b5f3b029 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -181,6 +181,7 @@ int snd_gus_create(struct snd_card *card, return -EBUSY; } gus->gf1.irq = irq; + card->sync_irq = irq; if (request_dma(dma1, "GUS - 1")) { snd_printk(KERN_ERR "gus: can't grab DMA1 %d\n", dma1); snd_gus_free(gus); diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 53eca205f870..efe576625f48 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -282,7 +282,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) goto _err; } maxcard->irq = xirq; - + card->sync_irq = maxcard->irq; + err = snd_wss_create(card, gus->gf1.port + 0x10c, -1, xirq, xdma2 < 0 ? xdma1 : xdma2, xdma1, diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index bc006dcf8de3..5cd4aa477ba7 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -667,6 +667,7 @@ static int snd_interwave_probe(struct snd_card *card, int dev) return -EBUSY; } iwcard->irq = xirq; + card->sync_irq = iwcard->irq; err = snd_wss_create(card, gus->gf1.port + 0x10c, -1, xirq, -- cgit v1.2.3 From 52f623d0a84d7c6240e53e964caaaec61b62aa9d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:42 +0100 Subject: ALSA: msnd: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-44-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/msnd/msnd_pinnacle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index e435ebd0ced4..9e7f03eec7e6 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -538,6 +538,7 @@ static int snd_msnd_attach(struct snd_card *card) printk(KERN_ERR LOGNAME ": Couldn't grab IRQ %d\n", chip->irq); return err; } + card->sync_irq = chip->irq; if (request_region(chip->io, DSP_NUMIO, card->shortname) == NULL) { free_irq(chip->irq, chip); return -EBUSY; -- cgit v1.2.3 From d3e163bfff972f810c67d766219807eee2d23c82 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:43 +0100 Subject: ALSA: opl3sa2: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-45-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/opl3sa2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 941d0bd5460b..6d19ab458291 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -659,6 +659,7 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev) return -ENODEV; } chip->irq = xirq; + card->sync_irq = chip->irq; err = snd_wss_create(card, wss_port[dev] + 4, -1, xirq, xdma1, xdma2, -- cgit v1.2.3 From 16d9fb1deef8cf0c83c86a6538f8522a89676d4c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:44 +0100 Subject: ALSA: opti9xx: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-46-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/opti92x-ad1848.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index fb36bb5d55df..b40ab806c349 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -869,6 +869,7 @@ static int snd_opti9xx_probe(struct snd_card *card) } #endif chip->irq = irq; + card->sync_irq = chip->irq; strcpy(card->driver, chip->name); sprintf(card->shortname, "OPTi %s", card->driver); #if defined(CS4231) || defined(OPTi93X) -- cgit v1.2.3 From f9236dd027b85846f2fb7f959cc4baaf165d339f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:45 +0100 Subject: ALSA: sb: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-47-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/sb/sb_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index ff031d670400..4aaf9ab82afe 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -233,6 +233,7 @@ int snd_sbdsp_create(struct snd_card *card, return -EBUSY; } chip->irq = irq; + card->sync_irq = chip->irq; if (hardware == SB_HW_ALS4000) goto __skip_allocation; -- cgit v1.2.3 From 48094a75cd7090aecc1b9b0dd0c5f1f70c7443cb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:46 +0100 Subject: ALSA: wavefront: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-48-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/wavefront/wavefront.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 95e6deb7b8d4..9e0f6b226775 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -409,6 +409,7 @@ snd_wavefront_probe (struct snd_card *card, int dev) } acard->wavefront.irq = ics2115_irq[dev]; + card->sync_irq = acard->wavefront.irq; acard->wavefront.base = ics2115_port[dev]; wavefront_synth = snd_wavefront_new_synth(card, hw_dev, acard); -- cgit v1.2.3 From 959d4c806d386cd28aa74d65db8f0a226defab10 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:47 +0100 Subject: ALSA: wss: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-49-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 9114e8911712..100e8b547d27 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1811,6 +1811,7 @@ int snd_wss_create(struct snd_card *card, return -EBUSY; } chip->irq = irq; + card->sync_irq = chip->irq; if (!(hwshare & WSS_HWSHARE_DMA1) && request_dma(dma1, "WSS - 1")) { snd_printk(KERN_ERR "wss: can't grab DMA1 %d\n", dma1); snd_wss_free(chip); -- cgit v1.2.3 From 41094b243e621fb67b81a49bab53f5f7e699f429 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:48 +0100 Subject: ALSA: lx6464es: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-50-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx6464es.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 0ac078d1b27a..7f6b1c6c2afe 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -1002,6 +1002,7 @@ static int snd_lx6464es_create(struct snd_card *card, goto request_irq_failed; } chip->irq = pci->irq; + card->sync_irq = chip->irq; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) -- cgit v1.2.3 From cefeaa5053d937f28116f8a53bd422f92d0c7475 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:49 +0100 Subject: ALSA: mixart: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-51-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 05e2c8ea8480..18124bd97d80 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1041,6 +1041,7 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int chip->card = card; chip->chip_idx = idx; chip->mgr = mgr; + card->sync_irq = mgr->irq; if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_mixart_chip_free(chip); -- cgit v1.2.3 From 271213ef4d0d3a3b80d4cf95c5f2bebb5643e666 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:50 +0100 Subject: ALSA: pcxhr: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-52-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index e691c372b960..f4330832e520 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1190,6 +1190,7 @@ static int pcxhr_create(struct pcxhr_mgr *mgr, chip->card = card; chip->chip_idx = idx; chip->mgr = mgr; + card->sync_irq = mgr->irq; if (idx < mgr->playback_chips) /* stereo or mono streams */ -- cgit v1.2.3 From 59fdf8e96c03261d5b32166a49be9d7daaf7ef73 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:51 +0100 Subject: ALSA: vx222: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-53-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/vx222/vx222.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index b502c2403a02..bc451224df16 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -163,6 +163,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, return -EBUSY; } chip->irq = pci->irq; + card->sync_irq = chip->irq; if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_vx222_free(chip); -- cgit v1.2.3 From 2f44742ca1dedf28a832f98199600f945ec90726 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:52 +0100 Subject: ALSA: pdaudiocf: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-54-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 022db0479908..eed2d60178e4 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -224,6 +224,7 @@ static int pdacf_config(struct pcmcia_device *link) link->irq) < 0) goto failed; + pdacf->card->sync_irq = link->irq; return 0; failed: -- cgit v1.2.3 From 0ca4cefad185da4b1a5ebf1f03a2ec92b7825551 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:53 +0100 Subject: ALSA: vxpocket: Support PCM sync_stop The driver invokes snd_pcm_period_elapsed() simply from the threaded interrupt handler. Set card->sync_irq for enabling the missing sync_stop PCM operation. Link: https://lore.kernel.org/r/20191210063454.31603-55-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/vx/vxpocket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 4e08863c3045..f924d8819f9d 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -185,6 +185,7 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq card->shortname, port, irq); chip->irq = irq; + card->sync_irq = chip->irq; if ((err = snd_vx_setup_firmware(chip)) < 0) return err; -- cgit v1.2.3 From dc5eafe7787c6c4ffab6c6b8a5f78859a249880e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 07:34:54 +0100 Subject: ALSA: usb-audio: Support PCM sync_stop USB-audio driver had some implementation of its own sync-stop mechanism. This patch moved a part of it to the common PCM sync_stop ops. Link: https://lore.kernel.org/r/20191210063454.31603-56-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/pcm.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 33c1e971e61e..8a52996041e9 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -260,18 +260,31 @@ static int start_endpoints(struct snd_usb_substream *subs) return 0; } -static void stop_endpoints(struct snd_usb_substream *subs, bool wait) +static void sync_pending_stops(struct snd_usb_substream *subs) +{ + snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint); + snd_usb_endpoint_sync_pending_stop(subs->data_endpoint); +} + +static void stop_endpoints(struct snd_usb_substream *subs) { if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) snd_usb_endpoint_stop(subs->sync_endpoint); if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) snd_usb_endpoint_stop(subs->data_endpoint); +} - if (wait) { - snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint); - snd_usb_endpoint_sync_pending_stop(subs->data_endpoint); +/* PCM sync_stop callback */ +static int snd_usb_pcm_sync_stop(struct snd_pcm_substream *substream) +{ + struct snd_usb_substream *subs = substream->runtime->private_data; + + if (!snd_usb_lock_shutdown(subs->stream->chip)) { + sync_pending_stops(subs); + snd_usb_unlock_shutdown(subs->stream->chip); } + return 0; } static int search_roland_implicit_fb(struct usb_device *dev, int ifnum, @@ -697,7 +710,8 @@ static int configure_endpoint(struct snd_usb_substream *subs) int ret; /* format changed */ - stop_endpoints(subs, true); + stop_endpoints(subs); + sync_pending_stops(subs); ret = snd_usb_endpoint_set_params(subs->data_endpoint, subs->pcm_format, subs->channels, @@ -842,7 +856,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) subs->cur_rate = 0; subs->period_bytes = 0; if (!snd_usb_lock_shutdown(subs->stream->chip)) { - stop_endpoints(subs, true); + stop_endpoints(subs); + sync_pending_stops(subs); snd_usb_endpoint_deactivate(subs->sync_endpoint); snd_usb_endpoint_deactivate(subs->data_endpoint); snd_usb_unlock_shutdown(subs->stream->chip); @@ -877,9 +892,6 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) goto unlock; } - snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint); - snd_usb_endpoint_sync_pending_stop(subs->data_endpoint); - ret = snd_usb_pcm_change_state(subs, UAC3_PD_STATE_D0); if (ret < 0) goto unlock; @@ -1337,7 +1349,6 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream) struct snd_usb_substream *subs = &as->substream[direction]; int ret; - stop_endpoints(subs, true); snd_media_stop_pipeline(subs); if (!as->chip->keep_iface && @@ -1714,7 +1725,7 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea subs->running = 1; return 0; case SNDRV_PCM_TRIGGER_STOP: - stop_endpoints(subs, false); + stop_endpoints(subs); subs->running = 0; return 0; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: @@ -1744,7 +1755,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream subs->running = 1; return 0; case SNDRV_PCM_TRIGGER_STOP: - stop_endpoints(subs, false); + stop_endpoints(subs); subs->running = 0; return 0; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: @@ -1767,6 +1778,7 @@ static const struct snd_pcm_ops snd_usb_playback_ops = { .hw_free = snd_usb_hw_free, .prepare = snd_usb_pcm_prepare, .trigger = snd_usb_substream_playback_trigger, + .sync_stop = snd_usb_pcm_sync_stop, .pointer = snd_usb_pcm_pointer, }; @@ -1777,6 +1789,7 @@ static const struct snd_pcm_ops snd_usb_capture_ops = { .hw_free = snd_usb_hw_free, .prepare = snd_usb_pcm_prepare, .trigger = snd_usb_substream_capture_trigger, + .sync_stop = snd_usb_pcm_sync_stop, .pointer = snd_usb_pcm_pointer, }; -- cgit v1.2.3 From 7f4aee8fa79c2d753aa1b2e9ffcad24689317f75 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:52 +0100 Subject: ASoC: amd: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-2-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 58 +++++++++++++------------------------ sound/soc/amd/raven/acp3x-pcm-dma.c | 30 ++++--------------- 2 files changed, 26 insertions(+), 62 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 4b9a27e25206..98400aaf0305 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -836,7 +836,6 @@ static int acp_dma_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - int status; uint64_t size; u32 val = 0; struct snd_pcm_runtime *runtime; @@ -967,35 +966,19 @@ static int acp_dma_hw_params(struct snd_soc_component *component, } size = params_buffer_bytes(params); - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; - - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - if (substream->dma_buffer.area) { - acp_set_sram_bank_state(rtd->acp_mmio, 0, true); - /* Save for runtime private data */ - rtd->dma_addr = substream->dma_buffer.addr; - rtd->order = get_order(size); + acp_set_sram_bank_state(rtd->acp_mmio, 0, true); + /* Save for runtime private data */ + rtd->dma_addr = substream->dma_buffer.addr; + rtd->order = get_order(size); - /* Fill the page table entries in ACP SRAM */ - rtd->size = size; - rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; - rtd->direction = substream->stream; + /* Fill the page table entries in ACP SRAM */ + rtd->size = size; + rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; + rtd->direction = substream->stream; - config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type); - status = 0; - } else { - status = -ENOMEM; - } - return status; -} - -static int acp_dma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type); + return 0; } static u64 acp_get_byte_count(struct audio_substream_data *rtd) @@ -1142,18 +1125,18 @@ static int acp_dma_new(struct snd_soc_component *component, switch (adata->asic_type) { case CHIP_STONEY: - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, - SNDRV_DMA_TYPE_DEV, - parent, - ST_MIN_BUFFER, - ST_MAX_BUFFER); + snd_pcm_set_managed_buffer_all(rtd->pcm, + SNDRV_DMA_TYPE_DEV, + parent, + ST_MIN_BUFFER, + ST_MAX_BUFFER); break; default: - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, - SNDRV_DMA_TYPE_DEV, - parent, - MIN_BUFFER, - MAX_BUFFER); + snd_pcm_set_managed_buffer_all(rtd->pcm, + SNDRV_DMA_TYPE_DEV, + parent, + MIN_BUFFER, + MAX_BUFFER); break; } return 0; @@ -1221,7 +1204,6 @@ static const struct snd_soc_component_driver acp_asoc_platform = { .close = acp_dma_close, .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = acp_dma_hw_params, - .hw_free = acp_dma_hw_free, .trigger = acp_dma_trigger, .pointer = acp_dma_pointer, .mmap = acp_dma_mmap, diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 60709e3ba99d..98b76c38dae0 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -334,7 +334,6 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - int status; u64 size; struct snd_pcm_runtime *runtime = substream->runtime; struct i2s_stream_instance *rtd = runtime->private_data; @@ -343,20 +342,10 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, return -EINVAL; size = params_buffer_bytes(params); - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; - - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - if (substream->dma_buffer.area) { - rtd->dma_addr = substream->dma_buffer.addr; - rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); - config_acp3x_dma(rtd, substream->stream); - status = 0; - } else { - status = -ENOMEM; - } - return status; + rtd->dma_addr = substream->dma_buffer.addr; + rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); + config_acp3x_dma(rtd, substream->stream); + return 0; } static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_soc_component *component, @@ -381,17 +370,11 @@ static int acp3x_dma_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { struct device *parent = component->dev->parent; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, - parent, MIN_BUFFER, MAX_BUFFER); + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, + parent, MIN_BUFFER, MAX_BUFFER); return 0; } -static int acp3x_dma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int acp3x_dma_mmap(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct vm_area_struct *vma) @@ -601,7 +584,6 @@ static const struct snd_soc_component_driver acp3x_i2s_component = { .close = acp3x_dma_close, .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = acp3x_dma_hw_params, - .hw_free = acp3x_dma_hw_free, .pointer = acp3x_dma_pointer, .mmap = acp3x_dma_mmap, .pcm_construct = acp3x_dma_new, -- cgit v1.2.3 From 66a7caaf354edd35089dcaabd277b38f036b783b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:44 +0100 Subject: ASoC: amd: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-2-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 1 - sound/soc/amd/raven/acp3x-pcm-dma.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 98400aaf0305..f54beb7f39a8 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -1202,7 +1202,6 @@ static const struct snd_soc_component_driver acp_asoc_platform = { .name = DRV_NAME, .open = acp_dma_open, .close = acp_dma_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = acp_dma_hw_params, .trigger = acp_dma_trigger, .pointer = acp_dma_pointer, diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 98b76c38dae0..97921046afff 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -582,7 +582,6 @@ static const struct snd_soc_component_driver acp3x_i2s_component = { .name = DRV_NAME, .open = acp3x_dma_open, .close = acp3x_dma_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = acp3x_dma_hw_params, .pointer = acp3x_dma_pointer, .mmap = acp3x_dma_mmap, -- cgit v1.2.3 From 7aff4224ff6b603c432de56139b621d68e0307fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:45 +0100 Subject: ASoC: atmel: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Codrin Ciubotariu Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Takashi Iwai Acked-by: Alexandre Belloni Link: https://lore.kernel.org/r/20191210145406.21419-3-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-pcm-pdc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c index 18a2fd02fffe..59c1331a6984 100644 --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c @@ -379,7 +379,6 @@ static int atmel_pcm_close(struct snd_soc_component *component, static const struct snd_soc_component_driver atmel_soc_platform = { .open = atmel_pcm_open, .close = atmel_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = atmel_pcm_hw_params, .hw_free = atmel_pcm_hw_free, .prepare = atmel_pcm_prepare, -- cgit v1.2.3 From 4000fc0b5a7f277ed6f83b1673a833b67a4cfa71 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:46 +0100 Subject: ASoC: au1x: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-4-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 1 - sound/soc/au1x/dma.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 4553108ec92a..4c74698d31b3 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -326,7 +326,6 @@ static struct snd_soc_component_driver au1xpsc_soc_component = { .name = DRV_NAME, .open = au1xpsc_pcm_open, .close = au1xpsc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = au1xpsc_pcm_hw_params, .hw_free = au1xpsc_pcm_hw_free, .prepare = au1xpsc_pcm_prepare, diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 054dfda89d3e..520eb7b24a92 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -302,7 +302,6 @@ static struct snd_soc_component_driver alchemy_pcm_soc_component = { .name = DRV_NAME, .open = alchemy_pcm_open, .close = alchemy_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = alchemy_pcm_hw_params, .hw_free = alchemy_pcm_hw_free, .trigger = alchemy_pcm_trigger, -- cgit v1.2.3 From e7a83dfcb33d36463def773c101051d63d5593ef Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:47 +0100 Subject: ASoC: bcm: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Ray Jui Cc: Scott Branden Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-5-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-pcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index c65408085c1d..3a80c613bc3f 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -818,7 +818,6 @@ static int cygnus_dma_new(struct snd_soc_component *component, static struct snd_soc_component_driver cygnus_soc_platform = { .open = cygnus_pcm_open, .close = cygnus_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = cygnus_pcm_hw_params, .hw_free = cygnus_pcm_hw_free, .prepare = cygnus_pcm_prepare, -- cgit v1.2.3 From f6201a314fc780bda83ffc5338c7bc0326749e84 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:48 +0100 Subject: ASoC: dwc: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-6-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-pcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c index 4771eb5fbe2a..bf36c1d29642 100644 --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c @@ -271,7 +271,6 @@ static void dw_pcm_free(struct snd_soc_component *component, static const struct snd_soc_component_driver dw_pcm_component = { .open = dw_pcm_open, .close = dw_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = dw_pcm_hw_params, .hw_free = dw_pcm_hw_free, .trigger = dw_pcm_trigger, -- cgit v1.2.3 From 6ac44ce9dfd6ba4dfb1d5e571131d132c53f23f1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:49 +0100 Subject: ASoC: fsl: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Timur Tabi Cc: Nicolin Chen Cc: Xiubo Li Signed-off-by: Takashi Iwai Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/20191210145406.21419-7-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc_dma.c | 1 - sound/soc/fsl/fsl_dma.c | 1 - sound/soc/fsl/imx-pcm-fiq.c | 1 - sound/soc/fsl/mpc5200_dma.c | 1 - 4 files changed, 4 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index d6146de9acd2..79d66224c0a8 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -428,7 +428,6 @@ static void fsl_asrc_dma_pcm_free(struct snd_soc_component *component, struct snd_soc_component_driver fsl_asrc_component = { .name = DRV_NAME, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = fsl_asrc_dma_hw_params, .hw_free = fsl_asrc_dma_hw_free, .trigger = fsl_asrc_dma_trigger, diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 2868c4f97cb2..13ae089c1911 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -903,7 +903,6 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) dma->dai.name = DRV_NAME; dma->dai.open = fsl_dma_open; dma->dai.close = fsl_dma_close; - dma->dai.ioctl = snd_soc_pcm_lib_ioctl; dma->dai.hw_params = fsl_dma_hw_params; dma->dai.hw_free = fsl_dma_hw_free; dma->dai.pointer = fsl_dma_pointer; diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 08131d147983..f20d5b1c3848 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -338,7 +338,6 @@ static void snd_imx_pcm_free(struct snd_soc_component *component, static const struct snd_soc_component_driver imx_soc_component_fiq = { .open = snd_imx_open, .close = snd_imx_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = snd_imx_pcm_hw_params, .prepare = snd_imx_pcm_prepare, .trigger = snd_imx_pcm_trigger, diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 5237ac96b756..ed7211d744b3 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -360,7 +360,6 @@ static const struct snd_soc_component_driver mpc5200_audio_dma_component = { .open = psc_dma_open, .close = psc_dma_close, .hw_free = psc_dma_hw_free, - .ioctl = snd_soc_pcm_lib_ioctl, .pointer = psc_dma_pointer, .trigger = psc_dma_trigger, .hw_params = psc_dma_hw_params, -- cgit v1.2.3 From aa4708d97e74d161502c9a5bc07532b34e727370 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:50 +0100 Subject: ASoC: intel: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Cezary Rojewski Cc: Pierre-Louis Bossart Cc: Liam Girdwood Cc: Jie Yang Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-8-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 1 - sound/soc/intel/baytrail/sst-baytrail-pcm.c | 1 - sound/soc/intel/haswell/sst-haswell-pcm.c | 1 - sound/soc/intel/skylake/skl-pcm.c | 1 - 4 files changed, 4 deletions(-) diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 47e3d1943d7e..607c8f50c3f3 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -705,7 +705,6 @@ static const struct snd_soc_component_driver sst_soc_platform_drv = { .probe = sst_soc_probe, .remove = sst_soc_remove, .open = sst_soc_open, - .ioctl = snd_soc_pcm_lib_ioctl, .trigger = sst_soc_trigger, .pointer = sst_soc_pointer, .compr_ops = &sst_platform_compr_ops, diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index 1d780fcc448c..775c3b0b209e 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -373,7 +373,6 @@ static const struct snd_soc_component_driver byt_dai_component = { .probe = sst_byt_pcm_probe, .open = sst_byt_pcm_open, .close = sst_byt_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = sst_byt_pcm_hw_params, .hw_free = sst_byt_pcm_hw_free, .trigger = sst_byt_pcm_trigger, diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index a3a5bba2fbd9..31fb38067f8f 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -1117,7 +1117,6 @@ static const struct snd_soc_component_driver hsw_dai_component = { .hw_free = hsw_pcm_hw_free, .trigger = hsw_pcm_trigger, .pointer = hsw_pcm_pointer, - .ioctl = snd_soc_pcm_lib_ioctl, .pcm_construct = hsw_pcm_new, .controls = hsw_volume_controls, .num_controls = ARRAY_SIZE(hsw_volume_controls), diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 8b9abb79a69e..bec5cee19566 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1477,7 +1477,6 @@ static const struct snd_soc_component_driver skl_component = { .probe = skl_platform_soc_probe, .remove = skl_platform_soc_remove, .open = skl_platform_soc_open, - .ioctl = snd_soc_pcm_lib_ioctl, .trigger = skl_platform_soc_trigger, .pointer = skl_platform_soc_pointer, .get_time_info = skl_platform_soc_get_time_info, -- cgit v1.2.3 From 13fd6f07f5b1cab528271f908df531a49e0bdcde Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:51 +0100 Subject: ASoC: kirkwood: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-9-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index e28fb3449f1d..f882b4003edf 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -316,7 +316,6 @@ const struct snd_soc_component_driver kirkwood_soc_component = { .name = DRV_NAME, .open = kirkwood_dma_open, .close = kirkwood_dma_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = kirkwood_dma_hw_params, .hw_free = kirkwood_dma_hw_free, .prepare = kirkwood_dma_prepare, -- cgit v1.2.3 From a1b175b0828de15e04b551a8406affcddc552d7d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:52 +0100 Subject: ASoC: mediatek: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Matthias Brugger Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-10-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 1 - sound/soc/mediatek/common/mtk-btcvsd.c | 1 - sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 1 - sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 1 - 4 files changed, 4 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index b6624d8d084b..86c09165fae1 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -135,7 +135,6 @@ EXPORT_SYMBOL_GPL(mtk_afe_pcm_free); const struct snd_soc_component_driver mtk_afe_pcm_platform = { .name = AFE_PCM_NAME, - .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, .pcm_destruct = mtk_afe_pcm_free, diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c index 2b490ae2e642..668fef3e319a 100644 --- a/sound/soc/mediatek/common/mtk-btcvsd.c +++ b/sound/soc/mediatek/common/mtk-btcvsd.c @@ -1271,7 +1271,6 @@ static const struct snd_soc_component_driver mtk_btcvsd_snd_platform = { .probe = mtk_btcvsd_snd_component_probe, .open = mtk_pcm_btcvsd_open, .close = mtk_pcm_btcvsd_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = mtk_pcm_btcvsd_hw_params, .hw_free = mtk_pcm_btcvsd_hw_free, .prepare = mtk_pcm_btcvsd_prepare, diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c index 033c07fb599c..cd7c5fabc605 100644 --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c @@ -712,7 +712,6 @@ static int mt6797_afe_component_probe(struct snd_soc_component *component) static const struct snd_soc_component_driver mt6797_afe_component = { .name = AFE_PCM_NAME, .probe = mt6797_afe_component_probe, - .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, .pcm_destruct = mtk_afe_pcm_free, diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index 76af09d8f1af..f6a0fadeb3cc 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1050,7 +1050,6 @@ static int mt8183_afe_component_probe(struct snd_soc_component *component) static const struct snd_soc_component_driver mt8183_afe_component = { .name = AFE_PCM_NAME, .probe = mt8183_afe_component_probe, - .ioctl = snd_soc_pcm_lib_ioctl, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, .pcm_destruct = mtk_afe_pcm_free, -- cgit v1.2.3 From a984e214de0c5d592a50bc6bd04b32a335d48a55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:53 +0100 Subject: ASoC: meson: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Jerome Brunet Cc: Kevin Hilman Signed-off-by: Takashi Iwai Acked-by: Jerome Brunet Link: https://lore.kernel.org/r/20191210145406.21419-11-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/meson/axg-frddr.c | 3 --- sound/soc/meson/axg-toddr.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c index 665d75d49d7b..0a7d41257a38 100644 --- a/sound/soc/meson/axg-frddr.c +++ b/sound/soc/meson/axg-frddr.c @@ -151,7 +151,6 @@ static const struct snd_soc_component_driver axg_frddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(axg_frddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = axg_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, @@ -275,7 +274,6 @@ static const struct snd_soc_component_driver g12a_frddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(g12a_frddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = g12a_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, @@ -345,7 +343,6 @@ static const struct snd_soc_component_driver sm1_frddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(g12a_frddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = g12a_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c index 7fef0b961496..f6023397c8fe 100644 --- a/sound/soc/meson/axg-toddr.c +++ b/sound/soc/meson/axg-toddr.c @@ -183,7 +183,6 @@ static const struct snd_soc_component_driver axg_toddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(axg_toddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = axg_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, @@ -222,7 +221,6 @@ static const struct snd_soc_component_driver g12a_toddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(axg_toddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = g12a_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, @@ -292,7 +290,6 @@ static const struct snd_soc_component_driver sm1_toddr_component_drv = { .num_dapm_routes = ARRAY_SIZE(sm1_toddr_dapm_routes), .open = axg_fifo_pcm_open, .close = axg_fifo_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = g12a_fifo_pcm_hw_params, .hw_free = axg_fifo_pcm_hw_free, .pointer = axg_fifo_pcm_pointer, -- cgit v1.2.3 From 92e63b552822b51aac65348b7ae46749590a3c8e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:54 +0100 Subject: ASoC: pxa: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-12-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-pcm.c | 1 - sound/soc/pxa/pxa-ssp.c | 1 - sound/soc/pxa/pxa2xx-ac97.c | 1 - sound/soc/pxa/pxa2xx-i2s.c | 1 - sound/soc/pxa/pxa2xx-pcm.c | 1 - 5 files changed, 5 deletions(-) diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 54a4c9213e83..287b5da739e5 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -225,7 +225,6 @@ static const struct snd_soc_component_driver mmp_soc_component = { .name = DRV_NAME, .open = mmp_pcm_open, .close = mmp_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = mmp_pcm_hw_params, .trigger = mmp_pcm_trigger, .pointer = mmp_pcm_pointer, diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 76fdce54f007..f37ea0fb4f3f 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -873,7 +873,6 @@ static const struct snd_soc_component_driver pxa_ssp_component = { .pcm_destruct = pxa2xx_soc_pcm_free, .open = pxa2xx_soc_pcm_open, .close = pxa2xx_soc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = pxa2xx_soc_pcm_hw_params, .hw_free = pxa2xx_soc_pcm_hw_free, .prepare = pxa2xx_soc_pcm_prepare, diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 31e81a6f616f..22fe77955c2c 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -208,7 +208,6 @@ static const struct snd_soc_component_driver pxa_ac97_component = { .pcm_destruct = pxa2xx_soc_pcm_free, .open = pxa2xx_soc_pcm_open, .close = pxa2xx_soc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = pxa2xx_soc_pcm_hw_params, .hw_free = pxa2xx_soc_pcm_hw_free, .prepare = pxa2xx_soc_pcm_prepare, diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index e77d707efde7..d9d366a8df11 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -364,7 +364,6 @@ static const struct snd_soc_component_driver pxa_i2s_component = { .pcm_destruct = pxa2xx_soc_pcm_free, .open = pxa2xx_soc_pcm_open, .close = pxa2xx_soc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = pxa2xx_soc_pcm_hw_params, .hw_free = pxa2xx_soc_pcm_hw_free, .prepare = pxa2xx_soc_pcm_prepare, diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index 07b3455a6f23..2b7839715dd5 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -22,7 +22,6 @@ static const struct snd_soc_component_driver pxa2xx_soc_platform = { .pcm_destruct = pxa2xx_soc_pcm_free, .open = pxa2xx_soc_pcm_open, .close = pxa2xx_soc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = pxa2xx_soc_pcm_hw_params, .hw_free = pxa2xx_soc_pcm_hw_free, .prepare = pxa2xx_soc_pcm_prepare, -- cgit v1.2.3 From 29da4698399eceaac0bfcf1f180e21a51d5d7aed Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:55 +0100 Subject: ASoC: qcom: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Patrick Lai Cc: Banajit Goswami Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-13-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-platform.c | 1 - sound/soc/qcom/qdsp6/q6asm-dai.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index 2e8892316423..b05091c283b7 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -543,7 +543,6 @@ static const struct snd_soc_component_driver lpass_component_driver = { .name = DRV_NAME, .open = lpass_platform_pcmops_open, .close = lpass_platform_pcmops_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = lpass_platform_pcmops_hw_params, .hw_free = lpass_platform_pcmops_hw_free, .prepare = lpass_platform_pcmops_prepare, diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index 8150c10f081e..5e2327708772 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -880,7 +880,6 @@ static const struct snd_soc_component_driver q6asm_fe_dai_component = { .open = q6asm_dai_open, .hw_params = q6asm_dai_hw_params, .close = q6asm_dai_close, - .ioctl = snd_soc_pcm_lib_ioctl, .prepare = q6asm_dai_prepare, .trigger = q6asm_dai_trigger, .pointer = q6asm_dai_pointer, -- cgit v1.2.3 From c4d14046650087f6495ab6855cf1a0090325c48a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:56 +0100 Subject: ASoC: samsung: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Sylwester Nawrocki Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-14-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/samsung/idma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index 294dce111b05..66bcc2f97544 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -394,7 +394,6 @@ EXPORT_SYMBOL_GPL(idma_reg_addr_init); static const struct snd_soc_component_driver asoc_idma_platform = { .open = idma_open, .close = idma_close, - .ioctl = snd_soc_pcm_lib_ioctl, .trigger = idma_trigger, .pointer = idma_pointer, .mmap = idma_mmap, -- cgit v1.2.3 From 2680c3127c3995c7cbd920c87fbc3411685e7717 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:58 +0100 Subject: ASoC: generic-dmaengine: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Lars-Peter Clausen Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-16-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index a428ff393ea2..4616cab2117c 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -329,7 +329,6 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = { .probe_order = SND_SOC_COMP_ORDER_LATE, .open = dmaengine_pcm_open, .close = dmaengine_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = dmaengine_pcm_hw_params, .hw_free = dmaengine_pcm_hw_free, .trigger = dmaengine_pcm_trigger, @@ -342,7 +341,6 @@ static const struct snd_soc_component_driver dmaengine_pcm_component_process = { .probe_order = SND_SOC_COMP_ORDER_LATE, .open = dmaengine_pcm_open, .close = dmaengine_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = dmaengine_pcm_hw_params, .hw_free = dmaengine_pcm_hw_free, .trigger = dmaengine_pcm_trigger, -- cgit v1.2.3 From 620ea8d26b99a5857b12a26f3673ad1fcd8abe9f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:59 +0100 Subject: ASoC: SOF: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-17-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sof/pcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 54ec78799c30..67ba317942d3 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -766,7 +766,6 @@ void snd_sof_new_platform_drv(struct snd_sof_dev *sdev) pd->remove = sof_pcm_remove; pd->open = sof_pcm_open; pd->close = sof_pcm_close; - pd->ioctl = snd_soc_pcm_lib_ioctl; pd->hw_params = sof_pcm_hw_params; pd->prepare = sof_pcm_prepare; pd->hw_free = sof_pcm_hw_free; -- cgit v1.2.3 From 01ac8ada97120b582580a7b3059329ddf659d033 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:00 +0100 Subject: ASoC: sprd: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Orson Zhai Cc: Baolin Wang Cc: Chunyan Zhang Signed-off-by: Takashi Iwai Reviewed-by: Baolin Wang Link: https://lore.kernel.org/r/20191210145406.21419-18-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sprd/sprd-pcm-dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/sprd/sprd-pcm-dma.c b/sound/soc/sprd/sprd-pcm-dma.c index da4b8f5f192b..2284558684bc 100644 --- a/sound/soc/sprd/sprd-pcm-dma.c +++ b/sound/soc/sprd/sprd-pcm-dma.c @@ -508,7 +508,6 @@ static const struct snd_soc_component_driver sprd_soc_component = { .name = DRV_NAME, .open = sprd_pcm_open, .close = sprd_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = sprd_pcm_hw_params, .hw_free = sprd_pcm_hw_free, .trigger = sprd_pcm_trigger, -- cgit v1.2.3 From 88b79e98cfc83290c12dd0455743ff84c556628e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:01 +0100 Subject: ASoC: txx9: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-19-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 33c78d33e5a1..043d9ec1c2b5 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -406,7 +406,6 @@ static const struct snd_soc_component_driver txx9aclc_soc_component = { .remove = txx9aclc_pcm_remove, .open = txx9aclc_pcm_open, .close = txx9aclc_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = txx9aclc_pcm_hw_params, .hw_free = txx9aclc_pcm_hw_free, .prepare = txx9aclc_pcm_prepare, -- cgit v1.2.3 From 71bfaea3d6d921f4e35e185f7dbd488110e9ce2e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:03 +0100 Subject: ASoC: xilinx: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Michal Simek Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-21-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/xilinx/xlnx_formatter_pcm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index 296c4caf96a0..14767f507cea 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -543,7 +543,6 @@ static const struct snd_soc_component_driver xlnx_asoc_component = { .name = DRV_NAME, .open = xlnx_formatter_pcm_open, .close = xlnx_formatter_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = xlnx_formatter_pcm_hw_params, .hw_free = xlnx_formatter_pcm_hw_free, .trigger = xlnx_formatter_pcm_trigger, -- cgit v1.2.3 From 6a8228d07ca022b6099b3a2b1432cdfb94bb36c4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:04 +0100 Subject: ASoC: xtensa: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Max Filippov Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-22-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/xtensa/xtfpga-i2s.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index e08f4fee932a..5dae9c8583b7 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -481,7 +481,6 @@ static const struct snd_soc_component_driver xtfpga_i2s_component = { .name = DRV_NAME, .open = xtfpga_pcm_open, .close = xtfpga_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = xtfpga_pcm_hw_params, .trigger = xtfpga_pcm_trigger, .pointer = xtfpga_pcm_pointer, -- cgit v1.2.3 From 93ec6953c1d7b3c5f62d35c76fe6670c6d9b3c8c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:05 +0100 Subject: ASoC: utils: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-23-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 2fd4562f5e63..922eac930df9 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -77,7 +77,6 @@ static int dummy_dma_open(struct snd_soc_component *component, static const struct snd_soc_component_driver dummy_platform = { .open = dummy_dma_open, - .ioctl = snd_soc_pcm_lib_ioctl, }; static const struct snd_soc_component_driver dummy_codec = { -- cgit v1.2.3 From 29d9fc7acacbb985daa1b4c662c619dc959a11b0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 11 Dec 2019 13:31:39 +0900 Subject: ASoC: soc-core: merge soc_set_name_prefix() and soc_set_of_name_prefix() soc_set_name_prefix() is calling soc_set_of_name_prefix(). We don't need to separate these operation. This patch merges these. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87fthrbhzo.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 750469acd5b4..f8090bd2cf73 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1206,22 +1206,12 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, return ret; } -static void soc_set_of_name_prefix(struct snd_soc_component *component) -{ - struct device_node *of_node = soc_component_to_node(component); - const char *str; - int ret; - - ret = of_property_read_string(of_node, "sound-name-prefix", &str); - if (!ret) - component->name_prefix = str; -} - static void soc_set_name_prefix(struct snd_soc_card *card, struct snd_soc_component *component) { struct device_node *of_node = soc_component_to_node(component); - int i; + const char *str; + int ret, i; for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; @@ -1238,7 +1228,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card, * If there is no configuration table or no match in the table, * check if a prefix is provided in the node */ - soc_set_of_name_prefix(component); + ret = of_property_read_string(of_node, "sound-name-prefix", &str); + if (ret < 0) + return; + + component->name_prefix = str; } static void soc_remove_component(struct snd_soc_component *component, -- cgit v1.2.3 From 8a6a6a38f86885982891197840e7b8eccad5ef50 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 11 Dec 2019 13:32:05 +0900 Subject: ASoC: soc-core: tidyup for CONFIG_DMI soc-core.c has 2 #ifdef CONFIG_DMI, but we can merge these. OTOH, soc.h has dmi_longname, but it is needed if CONFIG_DMI was defined. In other words, It is not needed if CONFIG_DMI was not defined. This patch tidyup these. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87eexbbhyy.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 32 +++++++++++++++----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index c920f17a5647..a6a3a7d54c70 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -986,7 +986,9 @@ struct snd_soc_card { const char *long_name; const char *driver_name; const char *components; +#ifdef CONFIG_DMI char dmi_longname[80]; +#endif /* CONFIG_DMI */ char topology_shortname[32]; struct device *dev; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f8090bd2cf73..51a404fb89e2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -73,23 +73,6 @@ static int pmdown_time = 5000; module_param(pmdown_time, int, 0); MODULE_PARM_DESC(pmdown_time, "DAPM stream powerdown time (msecs)"); -#ifdef CONFIG_DMI -/* - * If a DMI filed contain strings in this blacklist (e.g. - * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken - * as invalid and dropped when setting the card long name from DMI info. - */ -static const char * const dmi_blacklist[] = { - "To be filled by OEM", - "TBD by OEM", - "Default String", - "Board Manufacturer", - "Board Vendor Name", - "Board Product Name", - NULL, /* terminator */ -}; -#endif - static ssize_t pmdown_time_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1607,6 +1590,21 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt); #ifdef CONFIG_DMI +/* + * If a DMI filed contain strings in this blacklist (e.g. + * "Type2 - Board Manufacturer" or "Type1 - TBD by OEM"), it will be taken + * as invalid and dropped when setting the card long name from DMI info. + */ +static const char * const dmi_blacklist[] = { + "To be filled by OEM", + "TBD by OEM", + "Default String", + "Board Manufacturer", + "Board Vendor Name", + "Board Product Name", + NULL, /* terminator */ +}; + /* * Trim special characters, and replace '-' with '_' since '-' is used to * separate different DMI fields in the card long name. Only number and -- cgit v1.2.3 From a4072cdfa9fe79adcd41320355847e77de22baf0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 11 Dec 2019 13:32:20 +0900 Subject: ASoC: soc-core: tidyup for CONFIG_DEBUG_FS soc-core.c has 2 #ifdef CONFIG_DEBUG_FS, but we can merge these. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87d0cvbhyj.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 51a404fb89e2..3eb874c4a340 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -45,11 +45,6 @@ #define NAME_SIZE 32 -#ifdef CONFIG_DEBUG_FS -struct dentry *snd_soc_debugfs_root; -EXPORT_SYMBOL_GPL(snd_soc_debugfs_root); -#endif - static DEFINE_MUTEX(client_mutex); static LIST_HEAD(component_list); static LIST_HEAD(unbind_card_list); @@ -133,6 +128,9 @@ static const struct attribute_group *soc_dev_attr_groups[] = { }; #ifdef CONFIG_DEBUG_FS +struct dentry *snd_soc_debugfs_root; +EXPORT_SYMBOL_GPL(snd_soc_debugfs_root); + static void soc_init_component_debugfs(struct snd_soc_component *component) { if (!component->card->debugfs_card_root) -- cgit v1.2.3 From fe9912ac58e4fa205faabcccc980eb834cc5f1aa Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:53 +0100 Subject: ASoC: au1x: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-3-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 14 +------------- sound/soc/au1x/dma.c | 21 ++++++--------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 4c74698d31b3..8f855644c6b4 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -197,10 +197,6 @@ static int au1xpsc_pcm_hw_params(struct snd_soc_component *component, struct au1xpsc_audio_dmadata *pcd; int stype, ret; - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - goto out; - stype = substream->stream; pcd = to_dmadata(substream, component); @@ -232,13 +228,6 @@ out: return ret; } -static int au1xpsc_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int au1xpsc_pcm_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -315,7 +304,7 @@ static int au1xpsc_pcm_new(struct snd_soc_component *component, struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, AU1XPSC_BUFFER_MIN_BYTES, (4096 * 1024) - 1); return 0; @@ -327,7 +316,6 @@ static struct snd_soc_component_driver au1xpsc_soc_component = { .open = au1xpsc_pcm_open, .close = au1xpsc_pcm_close, .hw_params = au1xpsc_pcm_hw_params, - .hw_free = au1xpsc_pcm_hw_free, .prepare = au1xpsc_pcm_prepare, .trigger = au1xpsc_pcm_trigger, .pointer = au1xpsc_pcm_pointer, diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 520eb7b24a92..c9a038a5e2d3 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -231,19 +231,10 @@ static int alchemy_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_hw_params *hw_params) { struct audio_stream *stream = ss_to_as(substream, component); - int err; - - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - err = au1000_setup_dma_link(stream, - params_period_bytes(hw_params), - params_periods(hw_params)); - if (err) - snd_pcm_lib_free_pages(substream); - return err; + return au1000_setup_dma_link(stream, + params_period_bytes(hw_params), + params_periods(hw_params)); } static int alchemy_pcm_hw_free(struct snd_soc_component *component, @@ -251,7 +242,7 @@ static int alchemy_pcm_hw_free(struct snd_soc_component *component, { struct audio_stream *stream = ss_to_as(substream, component); au1000_release_dma_link(stream); - return snd_pcm_lib_free_pages(substream); + return 0; } static int alchemy_pcm_trigger(struct snd_soc_component *component, @@ -292,8 +283,8 @@ static int alchemy_pcm_new(struct snd_soc_component *component, { struct snd_pcm *pcm = rtd->pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 65536, (4096 * 1024) - 1); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 65536, (4096 * 1024) - 1); return 0; } -- cgit v1.2.3 From fcf306efab32975e4f8bdf5e9d3e7c34fe4ce48c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:54 +0100 Subject: ASoC: dwc: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. As of the result, hw_free and pcm_destruct ops became empty and got removed. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-4-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-pcm.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c index bf36c1d29642..4b25aca3804f 100644 --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c @@ -162,7 +162,6 @@ static int dw_pcm_hw_params(struct snd_soc_component *component, { struct snd_pcm_runtime *runtime = substream->runtime; struct dw_i2s_dev *dev = runtime->private_data; - int ret; switch (params_channels(hw_params)) { case 2: @@ -187,18 +186,7 @@ static int dw_pcm_hw_params(struct snd_soc_component *component, return -EINVAL; } - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - return ret; - else - return 0; -} - -static int dw_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; } static int dw_pcm_trigger(struct snd_soc_component *component, @@ -256,27 +244,19 @@ static int dw_pcm_new(struct snd_soc_component *component, { size_t size = dw_pcm_hardware.buffer_bytes_max; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_CONTINUOUS, NULL, size, size); return 0; } -static void dw_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static const struct snd_soc_component_driver dw_pcm_component = { .open = dw_pcm_open, .close = dw_pcm_close, .hw_params = dw_pcm_hw_params, - .hw_free = dw_pcm_hw_free, .trigger = dw_pcm_trigger, .pointer = dw_pcm_pointer, .pcm_construct = dw_pcm_new, - .pcm_destruct = dw_pcm_free, }; int dw_pcm_register(struct platform_device *pdev) -- cgit v1.2.3 From bace3caa82e1f0b5b667e35b532534b9cbdc4338 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:56 +0100 Subject: ASoC: meson: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Jerome Brunet Cc: Kevin Hilman Signed-off-by: Takashi Iwai Acked-by: Jerome Brunet Link: https://lore.kernel.org/r/20191210142614.19405-6-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/meson/axg-fifo.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index d6f3eefb8f09..772eda857019 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -115,11 +115,6 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component, struct axg_fifo *fifo = axg_fifo_data(ss); dma_addr_t end_ptr; unsigned int burst_num; - int ret; - - ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(params)); - if (ret < 0) - return ret; /* Setup dma memory pointers */ end_ptr = runtime->dma_addr + runtime->dma_bytes - AXG_FIFO_BURST; @@ -167,7 +162,7 @@ int axg_fifo_pcm_hw_free(struct snd_soc_component *component, regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), 0); - return snd_pcm_lib_free_pages(ss); + return 0; } EXPORT_SYMBOL_GPL(axg_fifo_pcm_hw_free); @@ -287,9 +282,9 @@ int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type) struct snd_card *card = rtd->card->snd_card; size_t size = axg_fifo_hw.buffer_bytes_max; - snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream, - SNDRV_DMA_TYPE_DEV, card->dev, - size, size); + snd_pcm_set_managed_buffer(rtd->pcm->streams[type].substream, + SNDRV_DMA_TYPE_DEV, card->dev, + size, size); return 0; } EXPORT_SYMBOL_GPL(axg_fifo_pcm_new); -- cgit v1.2.3 From d23a16584b4f4cc7226c75793d1797e5505a193b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:57 +0100 Subject: ASoC: dma-sh7760: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-7-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 2b0eca02a8b9..4d0f2f738ffa 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -179,11 +179,6 @@ static int camelot_hw_params(struct snd_soc_component *component, int recv = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0:1; int ret; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - return ret; - if (recv) { cam->rx_period_size = params_period_bytes(hw_params); cam->rx_period = 0; @@ -194,12 +189,6 @@ static int camelot_hw_params(struct snd_soc_component *component, return 0; } -static int camelot_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int camelot_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -307,7 +296,7 @@ static int camelot_pcm_new(struct snd_soc_component *component, /* dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel * in MMAP mode (i.e. aplay -M) */ - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, NULL, DMABRG_PREALLOC_BUFFER, DMABRG_PREALLOC_BUFFER_MAX); @@ -320,7 +309,6 @@ static const struct snd_soc_component_driver sh7760_soc_component = { .close = camelot_pcm_close, .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = camelot_hw_params, - .hw_free = camelot_hw_free, .prepare = camelot_prepare, .trigger = camelot_trigger, .pointer = camelot_pos, -- cgit v1.2.3 From e494dbcd9be743f41cf842f94ffbc7c56b6b072a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:59 +0100 Subject: ASoC: rcar: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-9-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 6aac25095218..3dfc02092f76 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1218,10 +1218,10 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd, for (substream = rtd->pcm->streams[stream].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, - SNDRV_DMA_TYPE_DEV, - dev, - PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); + snd_pcm_set_managed_buffer(substream, + SNDRV_DMA_TYPE_DEV, + dev, + PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } return 0; @@ -1400,7 +1400,6 @@ static int rsnd_hw_params(struct snd_soc_component *component, struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); struct snd_soc_pcm_runtime *fe = substream->private_data; - int ret; /* * rsnd assumes that it might be used under DPCM if user want to use @@ -1433,12 +1432,7 @@ static int rsnd_hw_params(struct snd_soc_component *component, dev_dbg(dev, "convert rate = %d\n", io->converted_rate); } - ret = rsnd_dai_call(hw_params, io, substream, hw_params); - if (ret) - return ret; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return rsnd_dai_call(hw_params, io, substream, hw_params); } static int rsnd_hw_free(struct snd_soc_component *component, @@ -1447,13 +1441,8 @@ static int rsnd_hw_free(struct snd_soc_component *component, struct snd_soc_dai *dai = rsnd_substream_to_dai(substream); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); - int ret; - - ret = rsnd_dai_call(hw_free, io, substream); - if (ret) - return ret; - return snd_pcm_lib_free_pages(substream); + return rsnd_dai_call(hw_free, io, substream); } static snd_pcm_uframes_t rsnd_pointer(struct snd_soc_component *component, -- cgit v1.2.3 From d708c2b36b5d23a7266ca9bfe648533a0f61bdfd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:01 +0100 Subject: ASoC: generic-dmaengine-pcm: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Cc: Lars-Peter Clausen Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-11-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 4616cab2117c..df57ec47ad60 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -104,7 +104,7 @@ static int dmaengine_pcm_hw_params(struct snd_soc_component *component, return ret; } - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); + return 0; } static int @@ -168,12 +168,6 @@ static int dmaengine_pcm_close(struct snd_soc_component *component, return snd_dmaengine_pcm_close(substream); } -static int dmaengine_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int dmaengine_pcm_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) { @@ -261,7 +255,7 @@ static int dmaengine_pcm_new(struct snd_soc_component *component, return -EINVAL; } - snd_pcm_lib_preallocate_pages(substream, + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_IRAM, dmaengine_dma_dev(pcm, substream), prealloc_buffer_size, @@ -330,7 +324,6 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = { .open = dmaengine_pcm_open, .close = dmaengine_pcm_close, .hw_params = dmaengine_pcm_hw_params, - .hw_free = dmaengine_pcm_hw_free, .trigger = dmaengine_pcm_trigger, .pointer = dmaengine_pcm_pointer, .pcm_construct = dmaengine_pcm_new, @@ -342,7 +335,6 @@ static const struct snd_soc_component_driver dmaengine_pcm_component_process = { .open = dmaengine_pcm_open, .close = dmaengine_pcm_close, .hw_params = dmaengine_pcm_hw_params, - .hw_free = dmaengine_pcm_hw_free, .trigger = dmaengine_pcm_trigger, .pointer = dmaengine_pcm_pointer, .copy_user = dmaengine_copy_user, -- cgit v1.2.3 From 6f7aff352e690bd167d97f8354543855cf6c34b8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:03 +0100 Subject: ASoC: stm32: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. As of the result, hw_free and pcm_destruct ops became empty and got removed. Cc: Olivier Moysan Cc: Arnaud Pouliquen Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-13-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/stm/stm32_adfsdm.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index 81c407da15c5..807fee1eac66 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -252,7 +252,6 @@ static int stm32_adfsdm_pcm_close(struct snd_soc_component *component, struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(rtd->cpu_dai); - snd_pcm_lib_free_pages(substream); priv->substream = NULL; return 0; @@ -276,25 +275,13 @@ static int stm32_adfsdm_pcm_hw_params(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(rtd->cpu_dai); - int ret; - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - return ret; priv->pcm_buff = substream->runtime->dma_area; return iio_channel_cb_set_buffer_watermark(priv->iio_cb, params_period_size(params)); } -static int stm32_adfsdm_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - - return 0; -} - static int stm32_adfsdm_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { @@ -303,30 +290,18 @@ static int stm32_adfsdm_pcm_new(struct snd_soc_component *component, snd_soc_dai_get_drvdata(rtd->cpu_dai); unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - priv->dev, size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + priv->dev, size, size); return 0; } -static void stm32_adfsdm_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - - substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; - if (substream) - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static struct snd_soc_component_driver stm32_adfsdm_soc_platform = { .open = stm32_adfsdm_pcm_open, .close = stm32_adfsdm_pcm_close, .hw_params = stm32_adfsdm_pcm_hw_params, - .hw_free = stm32_adfsdm_pcm_hw_free, .trigger = stm32_adfsdm_trigger, .pointer = stm32_adfsdm_pcm_pointer, .pcm_construct = stm32_adfsdm_pcm_new, - .pcm_destruct = stm32_adfsdm_pcm_free, }; static const struct of_device_id stm32_adfsdm_of_match[] = { -- cgit v1.2.3 From ffe119308cf6f174eb65e2a7c023c85178f5109c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:04 +0100 Subject: ASoC: txx9: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-14-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 043d9ec1c2b5..dba13543911c 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -54,11 +54,6 @@ static int txx9aclc_pcm_hw_params(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct txx9aclc_dmadata *dmadata = runtime->private_data; - int ret; - - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - return ret; dev_dbg(component->dev, "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " @@ -76,12 +71,6 @@ static int txx9aclc_pcm_hw_params(struct snd_soc_component *component, return 0; } -static int txx9aclc_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int txx9aclc_pcm_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -306,7 +295,7 @@ static int txx9aclc_pcm_new(struct snd_soc_component *component, goto exit; } - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, 64 * 1024, 4 * 1024 * 1024); return 0; @@ -407,7 +396,6 @@ static const struct snd_soc_component_driver txx9aclc_soc_component = { .open = txx9aclc_pcm_open, .close = txx9aclc_pcm_close, .hw_params = txx9aclc_pcm_hw_params, - .hw_free = txx9aclc_pcm_hw_free, .prepare = txx9aclc_pcm_prepare, .trigger = txx9aclc_pcm_trigger, .pointer = txx9aclc_pcm_pointer, -- cgit v1.2.3 From 52f0ac153d12beb5af9d8a1ad3013762e919ffa6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:06 +0100 Subject: ASoC: xilinx: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Cc: Michal Simek Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-16-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/xilinx/xlnx_formatter_pcm.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index 14767f507cea..1d59fb668c77 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -426,7 +426,6 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, { u32 low, high, active_ch, val, bytes_per_ch, bits_per_sample; u32 aes_reg1_val, aes_reg2_val; - int status; u64 size; struct snd_pcm_runtime *runtime = substream->runtime; struct xlnx_pcm_stream_param *stream_data = runtime->private_data; @@ -450,9 +449,6 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, } size = params_buffer_bytes(params); - status = snd_pcm_lib_malloc_pages(substream, size); - if (status < 0) - return status; stream_data->buffer_size = size; @@ -495,12 +491,6 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, return 0; } -static int xlnx_formatter_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int xlnx_formatter_pcm_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) @@ -532,7 +522,7 @@ static int xlnx_formatter_pcm_trigger(struct snd_soc_component *component, static int xlnx_formatter_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, component->dev, xlnx_pcm_hardware.buffer_bytes_max, xlnx_pcm_hardware.buffer_bytes_max); @@ -544,7 +534,6 @@ static const struct snd_soc_component_driver xlnx_asoc_component = { .open = xlnx_formatter_pcm_open, .close = xlnx_formatter_pcm_close, .hw_params = xlnx_formatter_pcm_hw_params, - .hw_free = xlnx_formatter_pcm_hw_free, .trigger = xlnx_formatter_pcm_trigger, .pointer = xlnx_formatter_pcm_pointer, .pcm_construct = xlnx_formatter_pcm_new, -- cgit v1.2.3 From bfddcaffd8858973385ec11c6051bb04fa685e6c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:07 +0100 Subject: ASoC: xtensa: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Max Filippov Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-17-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/xtensa/xtfpga-i2s.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index 5dae9c8583b7..bcf442faff7c 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -390,7 +390,6 @@ static int xtfpga_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - int ret; struct snd_pcm_runtime *runtime = substream->runtime; struct xtfpga_i2s *i2s = runtime->private_data; unsigned channels = params_channels(hw_params); @@ -422,9 +421,7 @@ static int xtfpga_pcm_hw_params(struct snd_soc_component *component, return -EINVAL; } - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - return ret; + return 0; } static int xtfpga_pcm_trigger(struct snd_soc_component *component, @@ -472,8 +469,8 @@ static int xtfpga_pcm_new(struct snd_soc_component *component, struct snd_card *card = rtd->card->snd_card; size_t size = xtfpga_pcm_hardware.buffer_bytes_max; - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, - card->dev, size, size); + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_DEV, + card->dev, size, size); return 0; } -- cgit v1.2.3 From 66b3621b8b6f3e184b5dd34358de41bcd5a73bb5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:08 +0100 Subject: ASoC: cros_ec_codec: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Cheng-Yi Chiang Cc: Benson Leung Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-18-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/codecs/cros_ec_codec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros_ec_codec.c index 7b17f39a6a10..c81bbef2367a 100644 --- a/sound/soc/codecs/cros_ec_codec.c +++ b/sound/soc/codecs/cros_ec_codec.c @@ -918,7 +918,7 @@ static int wov_pcm_hw_params(struct snd_soc_component *component, priv->wov_burst_read = true; mutex_unlock(&priv->wov_dma_lock); - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; } static int wov_pcm_hw_free(struct snd_soc_component *component, @@ -934,7 +934,7 @@ static int wov_pcm_hw_free(struct snd_soc_component *component, cancel_delayed_work_sync(&priv->wov_copy_work); - return snd_pcm_lib_free_pages(substream); + return 0; } static snd_pcm_uframes_t wov_pcm_pointer(struct snd_soc_component *component, @@ -950,8 +950,8 @@ static snd_pcm_uframes_t wov_pcm_pointer(struct snd_soc_component *component, static int wov_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); return 0; } -- cgit v1.2.3 From cae8055e065644fd1d92d2f0c23a39b6768d168a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:09 +0100 Subject: ASoC: rt5514-spi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Oder Chiou Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-19-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index f1b7b947ecbd..1a25a3787935 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -215,11 +215,9 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component, { struct rt5514_dsp *rt5514_dsp = snd_soc_component_get_drvdata(component); - int ret; u8 buf[8]; mutex_lock(&rt5514_dsp->dma_lock); - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); rt5514_dsp->substream = substream; rt5514_dsp->dma_offset = 0; @@ -230,7 +228,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component, mutex_unlock(&rt5514_dsp->dma_lock); - return ret; + return 0; } static int rt5514_spi_hw_free(struct snd_soc_component *component, @@ -245,7 +243,7 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component, cancel_delayed_work_sync(&rt5514_dsp->copy_work); - return snd_pcm_lib_free_pages(substream); + return 0; } static snd_pcm_uframes_t rt5514_spi_pcm_pointer( @@ -294,8 +292,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component) static int rt5514_spi_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); return 0; } -- cgit v1.2.3 From 9a560089e964c47f9be11cfb174c47aab0db64a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:10 +0100 Subject: ASoC: rt5677-spi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Oder Chiou Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-20-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677-spi.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c index 7810b1d7de32..3f40d2751833 100644 --- a/sound/soc/codecs/rt5677-spi.c +++ b/sound/soc/codecs/rt5677-spi.c @@ -132,14 +132,12 @@ static int rt5677_spi_hw_params( { struct rt5677_dsp *rt5677_dsp = snd_soc_component_get_drvdata(component); - int ret; mutex_lock(&rt5677_dsp->dma_lock); - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); rt5677_dsp->substream = substream; mutex_unlock(&rt5677_dsp->dma_lock); - return ret; + return 0; } static int rt5677_spi_hw_free( @@ -153,7 +151,7 @@ static int rt5677_spi_hw_free( rt5677_dsp->substream = NULL; mutex_unlock(&rt5677_dsp->dma_lock); - return snd_pcm_lib_free_pages(substream); + return 0; } static int rt5677_spi_prepare( @@ -376,8 +374,8 @@ done: static int rt5677_spi_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { - snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); return 0; } -- cgit v1.2.3 From 02298145559f824b31a4bada8071e59c55b7df88 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:11 +0100 Subject: ASoC: intel: atom: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Cc: Cezary Rojewski Cc: Pierre-Louis Bossart Cc: Liam Girdwood Cc: Jie Yang Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-21-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 607c8f50c3f3..340bd2be39a7 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -387,27 +387,6 @@ static int sst_media_prepare(struct snd_pcm_substream *substream, return ret_val; } -static int sst_media_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - int ret; - - ret = - snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(params)); - if (ret) - return ret; - memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); - return 0; -} - -static int sst_media_hw_free(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - return snd_pcm_lib_free_pages(substream); -} - static int sst_enable_ssp(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -473,8 +452,6 @@ static const struct snd_soc_dai_ops sst_media_dai_ops = { .startup = sst_media_open, .shutdown = sst_media_close, .prepare = sst_media_prepare, - .hw_params = sst_media_hw_params, - .hw_free = sst_media_hw_free, .mute_stream = sst_media_digital_mute, }; @@ -677,7 +654,7 @@ static int sst_soc_pcm_new(struct snd_soc_component *component, if (dai->driver->playback.channels_min || dai->driver->capture.channels_min) { - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_DMA), SST_MIN_BUFFER, SST_MAX_BUFFER); -- cgit v1.2.3 From d9c7824aa29d064b205957033463563ac3205fcb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:12 +0100 Subject: ASoC: intel: baytrail: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Cc: Cezary Rojewski Cc: Pierre-Louis Bossart Cc: Liam Girdwood Cc: Jie Yang Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-22-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index 775c3b0b209e..53383055c8dc 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -102,8 +102,6 @@ static int sst_byt_pcm_hw_params(struct snd_soc_component *component, return ret; } - snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - ret = sst_byt_stream_buffer(byt, pcm_data->stream, substream->dma_buffer.addr, params_buffer_bytes(params)); @@ -121,17 +119,6 @@ static int sst_byt_pcm_hw_params(struct snd_soc_component *component, return 0; } -static int sst_byt_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - - dev_dbg(rtd->dev, "PCM: hw_free\n"); - snd_pcm_lib_free_pages(substream); - - return 0; -} - static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -315,9 +302,8 @@ static int sst_byt_pcm_new(struct snd_soc_component *component, if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { size = sst_byt_pcm_hardware.buffer_bytes_max; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - pdata->dma_dev, - size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + pdata->dma_dev, size, size); } return 0; @@ -374,7 +360,6 @@ static const struct snd_soc_component_driver byt_dai_component = { .open = sst_byt_pcm_open, .close = sst_byt_pcm_close, .hw_params = sst_byt_pcm_hw_params, - .hw_free = sst_byt_pcm_hw_free, .trigger = sst_byt_pcm_trigger, .pointer = sst_byt_pcm_pointer, .mmap = sst_byt_pcm_mmap, -- cgit v1.2.3 From 3f93b1ed4ac1e285eafc6da8b354d3577977059a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:13 +0100 Subject: ASoC: intel: haswell: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped. Cc: Cezary Rojewski Cc: Pierre-Louis Bossart Cc: Liam Girdwood Cc: Jie Yang Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-23-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/haswell/sst-haswell-pcm.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index 31fb38067f8f..033d7c05d7fb 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -592,13 +592,6 @@ static int hsw_pcm_hw_params(struct snd_soc_component *component, return ret; } - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) { - dev_err(rtd->dev, "error: could not allocate %d bytes for PCM %d\n", - params_buffer_bytes(params), ret); - return ret; - } - dmab = snd_pcm_get_dma_buf(substream); ret = create_adsp_page_table(substream, pdata, rtd, runtime->dma_area, @@ -656,13 +649,6 @@ static int hsw_pcm_hw_params(struct snd_soc_component *component, return 0; } -static int hsw_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int hsw_pcm_trigger(struct snd_soc_component *component, struct snd_pcm_substream *substream, int cmd) { @@ -930,7 +916,7 @@ static int hsw_pcm_new(struct snd_soc_component *component, if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, dev, hsw_pcm_hardware.buffer_bytes_max, @@ -1114,7 +1100,6 @@ static const struct snd_soc_component_driver hsw_dai_component = { .open = hsw_pcm_open, .close = hsw_pcm_close, .hw_params = hsw_pcm_hw_params, - .hw_free = hsw_pcm_hw_free, .trigger = hsw_pcm_trigger, .pointer = hsw_pcm_pointer, .pcm_construct = hsw_pcm_new, -- cgit v1.2.3 From 51240953f28e0528a975db686d4e9e5938d55829 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:14 +0100 Subject: ASoC: intel: skylake: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. The pcm_construct ops contains only the superfluous call of snd_pcm_lib_preallocate_free_for_all(), so dropped, too. Cc: Cezary Rojewski Cc: Pierre-Louis Bossart Cc: Liam Girdwood Cc: Jie Yang Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-24-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index bec5cee19566..355165fd6b6a 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -77,13 +77,7 @@ static int skl_substream_alloc_pages(struct hdac_bus *bus, hdac_stream(stream)->period_bytes = 0; hdac_stream(stream)->format_val = 0; - return snd_pcm_lib_malloc_pages(substream, size); -} - -static int skl_substream_free_pages(struct hdac_bus *bus, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; } static void skl_set_pcm_constrains(struct hdac_bus *bus, @@ -385,7 +379,6 @@ static void skl_pcm_close(struct snd_pcm_substream *substream, static int skl_pcm_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct hdac_bus *bus = dev_get_drvdata(dai->dev); struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); struct skl_dev *skl = get_skl_ctx(dai->dev); struct skl_module_cfg *mconfig; @@ -405,7 +398,7 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream, snd_hdac_stream_cleanup(hdac_stream(stream)); hdac_stream(stream)->prepared = 0; - return skl_substream_free_pages(bus, substream); + return 0; } static int skl_be_hw_params(struct snd_pcm_substream *substream, @@ -1289,12 +1282,6 @@ static int skl_platform_soc_get_time_info( return 0; } -static void skl_platform_soc_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - #define MAX_PREALLOC_SIZE (32 * 1024 * 1024) static int skl_platform_soc_new(struct snd_soc_component *component, @@ -1312,10 +1299,10 @@ static int skl_platform_soc_new(struct snd_soc_component *component, size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024; if (size > MAX_PREALLOC_SIZE) size = MAX_PREALLOC_SIZE; - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_DEV_SG, - &skl->pci->dev, - size, MAX_PREALLOC_SIZE); + snd_pcm_set_managed_buffer_all(pcm, + SNDRV_DMA_TYPE_DEV_SG, + &skl->pci->dev, + size, MAX_PREALLOC_SIZE); } return 0; @@ -1482,7 +1469,6 @@ static const struct snd_soc_component_driver skl_component = { .get_time_info = skl_platform_soc_get_time_info, .mmap = skl_platform_soc_mmap, .pcm_construct = skl_platform_soc_new, - .pcm_destruct = skl_platform_soc_free, .module_get_upon_open = 1, /* increment refcount when a pcm is opened */ }; -- cgit v1.2.3 From 55df47f2300e7cdb2bb3ca1209ec0b938459fc8f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:25:58 +0100 Subject: ASoC: fsi: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-8-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index e384fdc8d60e..1cebddd76d12 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1732,20 +1732,6 @@ static int fsi_pcm_open(struct snd_soc_component *component, return ret; } -static int fsi_hw_params(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int fsi_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static snd_pcm_uframes_t fsi_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -1765,7 +1751,7 @@ static snd_pcm_uframes_t fsi_pointer(struct snd_soc_component *component, static int fsi_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd) { - snd_pcm_lib_preallocate_pages_for_all( + snd_pcm_set_managed_buffer_all( rtd->pcm, SNDRV_DMA_TYPE_DEV, rtd->card->snd_card->dev, @@ -1816,8 +1802,6 @@ static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", .open = fsi_pcm_open, .ioctl = snd_soc_pcm_lib_ioctl, - .hw_params = fsi_hw_params, - .hw_free = fsi_hw_free, .pointer = fsi_pointer, .pcm_construct = fsi_pcm_new, }; -- cgit v1.2.3 From 2c7c9630db45129838ed09f0ada718b0ac222377 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:00 +0100 Subject: ASoC: siu_pcm: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous (the rest were only debug prints) and got dropped. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-10-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sh/siu_pcm.c | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index a5e21e554da2..65637ad93630 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -281,41 +281,6 @@ static int siu_pcm_stmread_stop(struct siu_port *port_info) return 0; } -static int siu_pcm_hw_params(struct snd_soc_component *component, - struct snd_pcm_substream *ss, - struct snd_pcm_hw_params *hw_params) -{ - struct siu_info *info = siu_i2s_data; - struct device *dev = ss->pcm->card->dev; - int ret; - - dev_dbg(dev, "%s: port=%d\n", __func__, info->port_id); - - ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw_params)); - if (ret < 0) - dev_err(dev, "snd_pcm_lib_malloc_pages() failed\n"); - - return ret; -} - -static int siu_pcm_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *ss) -{ - struct siu_info *info = siu_i2s_data; - struct siu_port *port_info = siu_port_info(ss); - struct device *dev = ss->pcm->card->dev; - struct siu_stream *siu_stream; - - if (ss->stream == SNDRV_PCM_STREAM_PLAYBACK) - siu_stream = &port_info->playback; - else - siu_stream = &port_info->capture; - - dev_dbg(dev, "%s: port=%d\n", __func__, info->port_id); - - return snd_pcm_lib_free_pages(ss); -} - static bool filter(struct dma_chan *chan, void *slave) { struct sh_dmae_slave *param = slave; @@ -548,7 +513,7 @@ static int siu_pcm_new(struct snd_soc_component *component, if (ret < 0) return ret; - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX); @@ -584,8 +549,6 @@ struct const snd_soc_component_driver siu_component = { .open = siu_pcm_open, .close = siu_pcm_close, .ioctl = snd_soc_pcm_lib_ioctl, - .hw_params = siu_pcm_hw_params, - .hw_free = siu_pcm_hw_free, .prepare = siu_pcm_prepare, .trigger = siu_pcm_trigger, .pointer = siu_pcm_pointer_dma, -- cgit v1.2.3 From d55894bc27636ebaf66c7c6eca8da5548911f8c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:26:05 +0100 Subject: ASoC: uniphier: Use managed buffer allocation Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped, as well as the pcm_destruct callback just containing the superfluous snd_pcm_lib_preallocate_free_for_all() call. Cc: Masahiro Yamada Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210142614.19405-15-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-dma.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c index 700d936ed94e..388f4785d93a 100644 --- a/sound/soc/uniphier/aio-dma.c +++ b/sound/soc/uniphier/aio-dma.c @@ -104,25 +104,6 @@ static int uniphier_aiodma_open(struct snd_soc_component *component, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256); } -static int uniphier_aiodma_hw_params(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - substream->runtime->dma_bytes = params_buffer_bytes(params); - - return 0; -} - -static int uniphier_aiodma_hw_free(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - snd_pcm_set_runtime_buffer(substream, NULL); - substream->runtime->dma_bytes = 0; - - return 0; -} - static int uniphier_aiodma_prepare(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -232,30 +213,21 @@ static int uniphier_aiodma_new(struct snd_soc_component *component, if (ret) return ret; - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, dev, uniphier_aiodma_hw.buffer_bytes_max, uniphier_aiodma_hw.buffer_bytes_max); return 0; } -static void uniphier_aiodma_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static const struct snd_soc_component_driver uniphier_soc_platform = { .open = uniphier_aiodma_open, .ioctl = snd_soc_pcm_lib_ioctl, - .hw_params = uniphier_aiodma_hw_params, - .hw_free = uniphier_aiodma_hw_free, .prepare = uniphier_aiodma_prepare, .trigger = uniphier_aiodma_trigger, .pointer = uniphier_aiodma_pointer, .mmap = uniphier_aiodma_mmap, .pcm_construct = uniphier_aiodma_new, - .pcm_destruct = uniphier_aiodma_free, .compr_ops = &uniphier_aio_compr_ops, }; -- cgit v1.2.3 From e91f134c83b1b3319db4c14bb5d9d23dc567b283 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:53:57 +0100 Subject: ASoC: sh: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-15-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 1 - sound/soc/sh/fsi.c | 1 - sound/soc/sh/rcar/core.c | 1 - sound/soc/sh/siu_pcm.c | 1 - 4 files changed, 4 deletions(-) diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 4d0f2f738ffa..eee1a1e994cb 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -307,7 +307,6 @@ static int camelot_pcm_new(struct snd_soc_component *component, static const struct snd_soc_component_driver sh7760_soc_component = { .open = camelot_pcm_open, .close = camelot_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = camelot_hw_params, .prepare = camelot_prepare, .trigger = camelot_trigger, diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 1cebddd76d12..89119acfa911 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1801,7 +1801,6 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", .open = fsi_pcm_open, - .ioctl = snd_soc_pcm_lib_ioctl, .pointer = fsi_pointer, .pcm_construct = fsi_pcm_new, }; diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 3dfc02092f76..0bfcb77e5f65 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1652,7 +1652,6 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, */ static const struct snd_soc_component_driver rsnd_soc_component = { .name = "rsnd", - .ioctl = snd_soc_pcm_lib_ioctl, .hw_params = rsnd_hw_params, .hw_free = rsnd_hw_free, .pointer = rsnd_pointer, diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 65637ad93630..6a6ffd6d3192 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -548,7 +548,6 @@ struct const snd_soc_component_driver siu_component = { .name = DRV_NAME, .open = siu_pcm_open, .close = siu_pcm_close, - .ioctl = snd_soc_pcm_lib_ioctl, .prepare = siu_pcm_prepare, .trigger = siu_pcm_trigger, .pointer = siu_pcm_pointer_dma, -- cgit v1.2.3 From c0bd504dfbe697228f9a087f209cb6931157a97c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:02 +0100 Subject: ASoC: uniphier: Drop superfluous ioctl PCM ops ASoC PCM core deals the empty ioctl field now as default. Let's kill the redundant lines. Cc: Masahiro Yamada Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-20-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-dma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c index 388f4785d93a..da83423c52e2 100644 --- a/sound/soc/uniphier/aio-dma.c +++ b/sound/soc/uniphier/aio-dma.c @@ -222,7 +222,6 @@ static int uniphier_aiodma_new(struct snd_soc_component *component, static const struct snd_soc_component_driver uniphier_soc_platform = { .open = uniphier_aiodma_open, - .ioctl = snd_soc_pcm_lib_ioctl, .prepare = uniphier_aiodma_prepare, .trigger = uniphier_aiodma_trigger, .pointer = uniphier_aiodma_pointer, -- cgit v1.2.3 From 01fec8cce7cc68bb88b1ff55bc03da5f3e6625e3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 10 Dec 2019 15:54:06 +0100 Subject: ASoC: Drop snd_soc_pcm_lib_ioctl() Now all snd_soc_pcm_lib_ioctl() calls were dropped, and it became superfluous. Let's kill it. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191210145406.21419-24-tiwai@suse.de Signed-off-by: Mark Brown --- include/sound/soc.h | 5 ----- sound/soc/soc-core.c | 12 ------------ 2 files changed, 17 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index a6a3a7d54c70..82e65235c60d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1399,11 +1399,6 @@ static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) mutex_unlock(&dapm->card->dapm_mutex); } -/* bypass */ -int snd_soc_pcm_lib_ioctl(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - unsigned int cmd, void *arg); - #include #endif diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3eb874c4a340..ee77db253bcc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -258,18 +258,6 @@ static inline void snd_soc_debugfs_exit(void) #endif -/* - * This is glue code between snd_pcm_lib_ioctl() and - * snd_soc_component_driver :: ioctl - */ -int snd_soc_pcm_lib_ioctl(struct snd_soc_component *component, - struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - return snd_pcm_lib_ioctl(substream, cmd, arg); -} -EXPORT_SYMBOL_GPL(snd_soc_pcm_lib_ioctl); - static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, struct snd_soc_component *component) { -- cgit v1.2.3 From fcae40c99fb3d09f4407f549a7f17761abe5e1bc Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:08 +0800 Subject: ALSA: Replace timespec with timespec64 Since timespec is not year 2038 safe on 32bit system, and we need to convert all timespec variables to timespec64 type for sound subsystem. This patch is used to do preparation for following patches, that will convert all structures defined in uapi/sound/asound.h to use 64-bit time_t. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/sound/pcm.h | 18 +++++++++--------- include/sound/soc-component.h | 4 ++-- include/sound/timer.h | 4 ++-- sound/core/pcm_lib.c | 36 ++++++++++++++++++++++-------------- sound/core/pcm_native.c | 12 ++++++++---- sound/core/timer.c | 28 ++++++++++++++-------------- sound/drivers/aloop.c | 2 +- sound/pci/hda/hda_controller.c | 10 +++++----- sound/soc/intel/skylake/skl-pcm.c | 4 ++-- 9 files changed, 65 insertions(+), 53 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 8a89fa6fdd5e..cb407fade933 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -62,7 +62,7 @@ struct snd_pcm_ops { int (*sync_stop)(struct snd_pcm_substream *substream); snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); int (*get_time_info)(struct snd_pcm_substream *substream, - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, struct snd_pcm_audio_tstamp_config *audio_tstamp_config, struct snd_pcm_audio_tstamp_report *audio_tstamp_report); int (*fill_silence)(struct snd_pcm_substream *substream, int channel, @@ -343,7 +343,7 @@ static inline void snd_pcm_pack_audio_tstamp_report(__u32 *data, __u32 *accuracy struct snd_pcm_runtime { /* -- Status -- */ struct snd_pcm_substream *trigger_master; - struct timespec trigger_tstamp; /* trigger timestamp */ + struct timespec64 trigger_tstamp; /* trigger timestamp */ bool trigger_tstamp_latched; /* trigger timestamp latched in low-level driver/hardware */ int overrange; snd_pcm_uframes_t avail_max; @@ -421,7 +421,7 @@ struct snd_pcm_runtime { /* -- audio timestamp config -- */ struct snd_pcm_audio_tstamp_config audio_tstamp_config; struct snd_pcm_audio_tstamp_report audio_tstamp_report; - struct timespec driver_tstamp; + struct timespec64 driver_tstamp; #if IS_ENABLED(CONFIG_SND_PCM_OSS) /* -- OSS things -- */ @@ -1155,22 +1155,22 @@ static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substrea } /** - * snd_pcm_gettime - Fill the timespec depending on the timestamp mode + * snd_pcm_gettime - Fill the timespec64 depending on the timestamp mode * @runtime: PCM runtime instance - * @tv: timespec to fill + * @tv: timespec64 to fill */ static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime, - struct timespec *tv) + struct timespec64 *tv) { switch (runtime->tstamp_type) { case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC: - ktime_get_ts(tv); + ktime_get_ts64(tv); break; case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW: - getrawmonotonic(tv); + ktime_get_raw_ts64(tv); break; default: - getnstimeofday(tv); + ktime_get_real_ts64(tv); break; } } diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 506f72a6b2c2..154d02fbbfed 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -93,8 +93,8 @@ struct snd_soc_component_driver { snd_pcm_uframes_t (*pointer)(struct snd_soc_component *component, struct snd_pcm_substream *substream); int (*get_time_info)(struct snd_soc_component *component, - struct snd_pcm_substream *substream, struct timespec *system_ts, - struct timespec *audio_ts, + struct snd_pcm_substream *substream, struct timespec64 *system_ts, + struct timespec64 *audio_ts, struct snd_pcm_audio_tstamp_config *audio_tstamp_config, struct snd_pcm_audio_tstamp_report *audio_tstamp_report); int (*copy_user)(struct snd_soc_component *component, diff --git a/include/sound/timer.h b/include/sound/timer.h index a53e37bcd746..23e885d31525 100644 --- a/include/sound/timer.h +++ b/include/sound/timer.h @@ -89,7 +89,7 @@ struct snd_timer_instance { unsigned long ticks, unsigned long resolution); void (*ccallback) (struct snd_timer_instance * timeri, int event, - struct timespec * tstamp, + struct timespec64 * tstamp, unsigned long resolution); void (*disconnect)(struct snd_timer_instance *timeri); void *callback_data; @@ -113,7 +113,7 @@ struct snd_timer_instance { */ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer); -void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp); +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp); int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer); int snd_timer_global_free(struct snd_timer *timer); int snd_timer_global_register(struct snd_timer *timer); diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 2236b5e0c1f2..ea5518d44e66 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -144,8 +144,12 @@ void __snd_pcm_xrun(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; trace_xrun(substream); - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); + if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { + struct timespec64 tstamp; + + snd_pcm_gettime(runtime, &tstamp); + runtime->status->tstamp = timespec64_to_timespec(tstamp); + } snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { char name[16]; @@ -200,12 +204,12 @@ int snd_pcm_update_state(struct snd_pcm_substream *substream, } static void update_audio_tstamp(struct snd_pcm_substream *substream, - struct timespec *curr_tstamp, - struct timespec *audio_tstamp) + struct timespec64 *curr_tstamp, + struct timespec64 *audio_tstamp) { struct snd_pcm_runtime *runtime = substream->runtime; u64 audio_frames, audio_nsecs; - struct timespec driver_tstamp; + struct timespec64 driver_tstamp; if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) return; @@ -229,18 +233,22 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream, } audio_nsecs = div_u64(audio_frames * 1000000000LL, runtime->rate); - *audio_tstamp = ns_to_timespec(audio_nsecs); + *audio_tstamp = ns_to_timespec64(audio_nsecs); } - if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) { - runtime->status->audio_tstamp = *audio_tstamp; - runtime->status->tstamp = *curr_tstamp; + + if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || + runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { + runtime->status->audio_tstamp = + timespec64_to_timespec(*audio_tstamp); + runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp); } + /* * re-take a driver timestamp to let apps detect if the reference tstamp * read by low-level hardware was provided with a delay */ - snd_pcm_gettime(substream->runtime, (struct timespec *)&driver_tstamp); + snd_pcm_gettime(substream->runtime, &driver_tstamp); runtime->driver_tstamp = driver_tstamp; } @@ -253,8 +261,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, snd_pcm_sframes_t hdelta, delta; unsigned long jdelta; unsigned long curr_jiffies; - struct timespec curr_tstamp; - struct timespec audio_tstamp; + struct timespec64 curr_tstamp; + struct timespec64 audio_tstamp; int crossed_boundary = 0; old_hw_ptr = runtime->status->hw_ptr; @@ -277,9 +285,9 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, /* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */ if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) - snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); + snd_pcm_gettime(runtime, &curr_tstamp); } else - snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp); + snd_pcm_gettime(runtime, &curr_tstamp); } if (pos == SNDRV_PCM_POS_XRUN) { diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 1fe581167b7b..67fe14bad7cb 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -918,12 +918,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream, status->suspended_state = runtime->status->suspended_state; if (status->state == SNDRV_PCM_STATE_OPEN) goto _end; - status->trigger_tstamp = runtime->trigger_tstamp; + status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp); if (snd_pcm_running(substream)) { snd_pcm_update_hw_ptr(substream); if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { status->tstamp = runtime->status->tstamp; - status->driver_tstamp = runtime->driver_tstamp; + status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp); status->audio_tstamp = runtime->status->audio_tstamp; if (runtime->audio_tstamp_report.valid == 1) @@ -936,8 +936,12 @@ int snd_pcm_status(struct snd_pcm_substream *substream, } } else { /* get tstamp only in fallback mode and only if enabled */ - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - snd_pcm_gettime(runtime, &status->tstamp); + if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { + struct timespec64 tstamp; + + snd_pcm_gettime(runtime, &tstamp); + status->tstamp = timespec64_to_timespec(tstamp); + } } _tstamp_end: status->appl_ptr = runtime->control->appl_ptr; diff --git a/sound/core/timer.c b/sound/core/timer.c index 24fed5c78273..d808d5554c7a 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -59,7 +59,7 @@ struct snd_timer_user { spinlock_t qlock; unsigned long last_resolution; unsigned int filter; - struct timespec tstamp; /* trigger tstamp */ + struct timespec64 tstamp; /* trigger tstamp */ wait_queue_head_t qchange_sleep; struct fasync_struct *fasync; struct mutex ioctl_lock; @@ -453,12 +453,12 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) struct snd_timer *timer = ti->timer; unsigned long resolution = 0; struct snd_timer_instance *ts; - struct timespec tstamp; + struct timespec64 tstamp; if (timer_tstamp_monotonic) - ktime_get_ts(&tstamp); + ktime_get_ts64(&tstamp); else - getnstimeofday(&tstamp); + ktime_get_real_ts64(&tstamp); if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_START || event > SNDRV_TIMER_EVENT_PAUSE)) return; @@ -1025,7 +1025,7 @@ static int snd_timer_dev_disconnect(struct snd_device *device) return 0; } -void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp) +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec64 *tstamp) { unsigned long flags; unsigned long resolution = 0; @@ -1318,7 +1318,7 @@ static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, int event, - struct timespec *tstamp, + struct timespec64 *tstamp, unsigned long resolution) { struct snd_timer_user *tu = timeri->callback_data; @@ -1332,7 +1332,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, return; memset(&r1, 0, sizeof(r1)); r1.event = event; - r1.tstamp = *tstamp; + r1.tstamp = timespec64_to_timespec(*tstamp); r1.val = resolution; spin_lock_irqsave(&tu->qlock, flags); snd_timer_user_append_to_tqueue(tu, &r1); @@ -1355,7 +1355,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, { struct snd_timer_user *tu = timeri->callback_data; struct snd_timer_tread *r, r1; - struct timespec tstamp; + struct timespec64 tstamp; int prev, append = 0; memset(&r1, 0, sizeof(r1)); @@ -1368,14 +1368,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, } if (tu->last_resolution != resolution || ticks > 0) { if (timer_tstamp_monotonic) - ktime_get_ts(&tstamp); + ktime_get_ts64(&tstamp); else - getnstimeofday(&tstamp); + ktime_get_real_ts64(&tstamp); } if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && tu->last_resolution != resolution) { r1.event = SNDRV_TIMER_EVENT_RESOLUTION; - r1.tstamp = tstamp; + r1.tstamp = timespec64_to_timespec(tstamp); r1.val = resolution; snd_timer_user_append_to_tqueue(tu, &r1); tu->last_resolution = resolution; @@ -1389,14 +1389,14 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; r = &tu->tqueue[prev]; if (r->event == SNDRV_TIMER_EVENT_TICK) { - r->tstamp = tstamp; + r->tstamp = timespec64_to_timespec(tstamp); r->val += ticks; append++; goto __wake; } } r1.event = SNDRV_TIMER_EVENT_TICK; - r1.tstamp = tstamp; + r1.tstamp = timespec64_to_timespec(tstamp); r1.val = ticks; snd_timer_user_append_to_tqueue(tu, &r1); append++; @@ -1885,7 +1885,7 @@ static int snd_timer_user_status(struct file *file, if (!tu->timeri) return -EBADFD; memset(&status, 0, sizeof(status)); - status.tstamp = tu->tstamp; + status.tstamp = timespec64_to_timespec(tu->tstamp); status.resolution = snd_timer_resolution(tu->timeri); status.lost = tu->timeri->lost; status.overrun = tu->overrun; diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 6bb46423f5ae..bc83b1731541 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -804,7 +804,7 @@ static void loopback_snd_timer_tasklet(unsigned long arg) static void loopback_snd_timer_event(struct snd_timer_instance *timeri, int event, - struct timespec *tstamp, + struct timespec64 *tstamp, unsigned long resolution) { /* Do not lock cable->lock here because timer->lock is already hold. diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 2f3b7a35f2d9..e95c3ae7aa93 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -491,7 +491,7 @@ static inline bool is_link_time_supported(struct snd_pcm_runtime *runtime, } static int azx_get_time_info(struct snd_pcm_substream *substream, - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, struct snd_pcm_audio_tstamp_config *audio_tstamp_config, struct snd_pcm_audio_tstamp_report *audio_tstamp_report) { @@ -511,7 +511,7 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, if (audio_tstamp_config->report_delay) nsec = azx_adjust_codec_delay(substream, nsec); - *audio_ts = ns_to_timespec(nsec); + *audio_ts = ns_to_timespec64(nsec); audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK; audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */ @@ -528,16 +528,16 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, return -EINVAL; case SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW: - *system_ts = ktime_to_timespec(xtstamp.sys_monoraw); + *system_ts = ktime_to_timespec64(xtstamp.sys_monoraw); break; default: - *system_ts = ktime_to_timespec(xtstamp.sys_realtime); + *system_ts = ktime_to_timespec64(xtstamp.sys_realtime); break; } - *audio_ts = ktime_to_timespec(xtstamp.device); + *audio_ts = ktime_to_timespec64(xtstamp.device); audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 8b9abb79a69e..900746c30bff 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1258,7 +1258,7 @@ static u64 skl_adjust_codec_delay(struct snd_pcm_substream *substream, static int skl_platform_soc_get_time_info( struct snd_soc_component *component, struct snd_pcm_substream *substream, - struct timespec *system_ts, struct timespec *audio_ts, + struct timespec64 *system_ts, struct timespec64 *audio_ts, struct snd_pcm_audio_tstamp_config *audio_tstamp_config, struct snd_pcm_audio_tstamp_report *audio_tstamp_report) { @@ -1276,7 +1276,7 @@ static int skl_platform_soc_get_time_info( if (audio_tstamp_config->report_delay) nsec = skl_adjust_codec_delay(substream, nsec); - *audio_ts = ns_to_timespec(nsec); + *audio_ts = ns_to_timespec64(nsec); audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK; audio_tstamp_report->accuracy_report = 1; /* rest of struct is valid */ -- cgit v1.2.3 From a07804cc7472d8aa5db03ea5d75f3d8d80abb687 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:09 +0800 Subject: ALSA: Avoid using timespec for struct snd_timer_status struct snd_timer_status uses 'timespec' type variables to record timestamp, which will be changed to an incompatible layout with updated user space using 64-bit time_t. To handle both the old and the new layout on 32-bit architectures, this patch introduces 'struct snd_timer_status32' and 'struct snd_timer_status64' to handle 32bit time_t and 64bit time_t in native mode and compat mode, which replaces timespec with s64 type. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. In the public uapi header, snd_timer_status is now guarded by an #ifndef __KERNEL__ to avoid referencing 'struct timespec'. The timespec definition will be removed from the kernel to prevent new y2038 bugs and to avoid the conflict with an incompatible libc type of the same name. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 2 ++ sound/core/timer.c | 62 ++++++++++++++++++++++++++++++++++++++++----- sound/core/timer_compat.c | 57 +++++------------------------------------ 3 files changed, 64 insertions(+), 57 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index df1153cea0b7..930854f67fd3 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -761,6 +761,7 @@ struct snd_timer_params { unsigned char reserved[60]; /* reserved */ }; +#ifndef __KERNEL__ struct snd_timer_status { struct timespec tstamp; /* Timestamp - last update */ unsigned int resolution; /* current period resolution in ns */ @@ -769,6 +770,7 @@ struct snd_timer_status { unsigned int queue; /* used queue size */ unsigned char reserved[64]; /* reserved */ }; +#endif #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) diff --git a/sound/core/timer.c b/sound/core/timer.c index d808d5554c7a..d2f69039f941 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -65,6 +65,30 @@ struct snd_timer_user { struct mutex ioctl_lock; }; +struct snd_timer_status32 { + s32 tstamp_sec; /* Timestamp - last update */ + s32 tstamp_nsec; + unsigned int resolution; /* current period resolution in ns */ + unsigned int lost; /* counter of master tick lost */ + unsigned int overrun; /* count of read queue overruns */ + unsigned int queue; /* used queue size */ + unsigned char reserved[64]; /* reserved */ +}; + +#define SNDRV_TIMER_IOCTL_STATUS32 _IOR('T', 0x14, struct snd_timer_status32) + +struct snd_timer_status64 { + s64 tstamp_sec; /* Timestamp - last update */ + s64 tstamp_nsec; + unsigned int resolution; /* current period resolution in ns */ + unsigned int lost; /* counter of master tick lost */ + unsigned int overrun; /* count of read queue overruns */ + unsigned int queue; /* used queue size */ + unsigned char reserved[64]; /* reserved */ +}; + +#define SNDRV_TIMER_IOCTL_STATUS64 _IOR('T', 0x14, struct snd_timer_status64) + /* list of timers */ static LIST_HEAD(snd_timer_list); @@ -1875,17 +1899,41 @@ static int snd_timer_user_params(struct file *file, return err; } -static int snd_timer_user_status(struct file *file, - struct snd_timer_status __user *_status) +static int snd_timer_user_status32(struct file *file, + struct snd_timer_status32 __user *_status) + { + struct snd_timer_user *tu; + struct snd_timer_status32 status; + + tu = file->private_data; + if (!tu->timeri) + return -EBADFD; + memset(&status, 0, sizeof(status)); + status.tstamp_sec = tu->tstamp.tv_sec; + status.tstamp_nsec = tu->tstamp.tv_nsec; + status.resolution = snd_timer_resolution(tu->timeri); + status.lost = tu->timeri->lost; + status.overrun = tu->overrun; + spin_lock_irq(&tu->qlock); + status.queue = tu->qused; + spin_unlock_irq(&tu->qlock); + if (copy_to_user(_status, &status, sizeof(status))) + return -EFAULT; + return 0; +} + +static int snd_timer_user_status64(struct file *file, + struct snd_timer_status64 __user *_status) { struct snd_timer_user *tu; - struct snd_timer_status status; + struct snd_timer_status64 status; tu = file->private_data; if (!tu->timeri) return -EBADFD; memset(&status, 0, sizeof(status)); - status.tstamp = timespec64_to_timespec(tu->tstamp); + status.tstamp_sec = tu->tstamp.tv_sec; + status.tstamp_nsec = tu->tstamp.tv_nsec; status.resolution = snd_timer_resolution(tu->timeri); status.lost = tu->timeri->lost; status.overrun = tu->overrun; @@ -2009,8 +2057,10 @@ static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd, return snd_timer_user_info(file, argp); case SNDRV_TIMER_IOCTL_PARAMS: return snd_timer_user_params(file, argp); - case SNDRV_TIMER_IOCTL_STATUS: - return snd_timer_user_status(file, argp); + case SNDRV_TIMER_IOCTL_STATUS32: + return snd_timer_user_status32(file, argp); + case SNDRV_TIMER_IOCTL_STATUS64: + return snd_timer_user_status64(file, argp); case SNDRV_TIMER_IOCTL_START: case SNDRV_TIMER_IOCTL_START_OLD: return snd_timer_user_start(file); diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index bb6be484dfd3..20eef5bc304b 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c @@ -69,54 +69,11 @@ static int snd_timer_user_info_compat(struct file *file, return 0; } -struct snd_timer_status32 { - struct compat_timespec tstamp; - u32 resolution; - u32 lost; - u32 overrun; - u32 queue; - unsigned char reserved[64]; -}; - -static int snd_timer_user_status_compat(struct file *file, - struct snd_timer_status32 __user *_status) -{ - struct snd_timer_user *tu; - struct snd_timer_status32 status; - - tu = file->private_data; - if (!tu->timeri) - return -EBADFD; - memset(&status, 0, sizeof(status)); - status.tstamp.tv_sec = tu->tstamp.tv_sec; - status.tstamp.tv_nsec = tu->tstamp.tv_nsec; - status.resolution = snd_timer_resolution(tu->timeri); - status.lost = tu->timeri->lost; - status.overrun = tu->overrun; - spin_lock_irq(&tu->qlock); - status.queue = tu->qused; - spin_unlock_irq(&tu->qlock); - if (copy_to_user(_status, &status, sizeof(status))) - return -EFAULT; - return 0; -} - -#ifdef CONFIG_X86_X32 -/* X32 ABI has the same struct as x86-64 */ -#define snd_timer_user_status_x32(file, s) \ - snd_timer_user_status(file, s) -#endif /* CONFIG_X86_X32 */ - -/* - */ - enum { SNDRV_TIMER_IOCTL_GPARAMS32 = _IOW('T', 0x04, struct snd_timer_gparams32), SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32), - SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32), -#ifdef CONFIG_X86_X32 - SNDRV_TIMER_IOCTL_STATUS_X32 = _IOW('T', 0x14, struct snd_timer_status), -#endif /* CONFIG_X86_X32 */ + SNDRV_TIMER_IOCTL_STATUS_COMPAT32 = _IOW('T', 0x14, struct snd_timer_status32), + SNDRV_TIMER_IOCTL_STATUS_COMPAT64 = _IOW('T', 0x14, struct snd_timer_status64), }; static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, @@ -145,12 +102,10 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, return snd_timer_user_gparams_compat(file, argp); case SNDRV_TIMER_IOCTL_INFO32: return snd_timer_user_info_compat(file, argp); - case SNDRV_TIMER_IOCTL_STATUS32: - return snd_timer_user_status_compat(file, argp); -#ifdef CONFIG_X86_X32 - case SNDRV_TIMER_IOCTL_STATUS_X32: - return snd_timer_user_status_x32(file, argp); -#endif /* CONFIG_X86_X32 */ + case SNDRV_TIMER_IOCTL_STATUS_COMPAT32: + return snd_timer_user_status32(file, argp); + case SNDRV_TIMER_IOCTL_STATUS_COMPAT64: + return snd_timer_user_status64(file, argp); } return -ENOIOCTLCMD; } -- cgit v1.2.3 From a4e7dd35b9dac21fa7b33e8788b51c7fbc7a49f1 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:10 +0800 Subject: ALSA: Avoid using timespec for struct snd_ctl_elem_value The struct snd_ctl_elem_value will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Since there are no drivers will implemented the tstamp member of the struct snd_ctl_elem_value, and also the stucture size will not be changed if we change timespec to s64 for tstamp member of struct snd_ctl_elem_value. From Takashi's comments, "In the library, applications are not expected to access to this structure directly. The applications get opaque pointer to the structure and must use any control APIs to operate it. Actually the library produce no API to handle 'struct snd_ctl_elem_value.tstamp'. This means that we can drop this member from alsa-lib without decline of functionality." Thus we can simply remove the tstamp member to avoid using the type which is not year 2038 safe on 32bits system. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 930854f67fd3..40a23d8418fe 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -957,8 +957,7 @@ struct snd_ctl_elem_value { } bytes; struct snd_aes_iec958 iec958; } value; /* RO */ - struct timespec tstamp; - unsigned char reserved[128-sizeof(struct timespec)]; + unsigned char reserved[128]; }; struct snd_ctl_tlv { -- cgit v1.2.3 From 3ddee7f88aaf2dee38f7016ac8fd48dd9fdb43e3 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:11 +0800 Subject: ALSA: Avoid using timespec for struct snd_pcm_status The struct snd_pcm_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Userspace will use SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT as commands to issue ioctl() to fill the 'snd_pcm_status' structure in userspace. The command number is always defined through _IOR/_IOW/IORW, so when userspace changes the definition of 'struct timespec' to use 64-bit types, the command number also changes. Thus in the kernel, we now need to define two versions of each such ioctl and corresponding ioctl commands to handle 32bit time_t and 64bit time_t in native mode: struct snd_pcm_status32 { ...... s32 trigger_tstamp_sec; s32 trigger_tstamp_nsec; ...... s32 audio_tstamp_sec; s32 audio_tstamp_nsec; ...... }; struct snd_pcm_status64 { ...... s32 trigger_tstamp_sec; s32 trigger_tstamp_nsec; ...... s32 audio_tstamp_sec; s32 audio_tstamp_nsec; ...... }; Moreover in compat file, we renamed or introduced new structures to handle 32bit/64bit time_t in compatible mode. The 'struct snd_pcm_status32' and snd_pcm_status_user32() are used to handle 32bit time_t in compat mode. 'struct compat_snd_pcm_status64' and snd_pcm_status_user_compat64() are used to handle 64bit time_t. The implicit padding before timespec is made explicit to avoid incompatible structure layout between 32-bit and 64-bit x86 due to the different alignment requirements, and the snd_pcm_status structure is now hidden from the kernel to avoid relying on the timespec definitio definitionn Finally we can replace SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT with new commands and introduce new functions to fill new 'struct snd_pcm_status64' instead of using unsafe 'struct snd_pcm_status'. Then in future, the new commands can be matched when userspace changes 'timespec' to 64bit type to make a size change of 'struct snd_pcm_status'. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/sound/pcm.h | 56 +++++++++++++++- include/uapi/sound/asound.h | 6 ++ sound/core/pcm.c | 12 ++-- sound/core/pcm_compat.c | 154 +++++++++++++++----------------------------- sound/core/pcm_native.c | 96 ++++++++++++++++++++++----- 5 files changed, 198 insertions(+), 126 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index cb407fade933..5a31525e2df6 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -44,6 +44,7 @@ struct snd_pcm_hardware { size_t fifo_size; /* fifo size in bytes */ }; +struct snd_pcm_status64; struct snd_pcm_substream; struct snd_pcm_audio_tstamp_config; /* definitions further down */ @@ -558,8 +559,8 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree); int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info); int snd_pcm_info_user(struct snd_pcm_substream *substream, struct snd_pcm_info __user *info); -int snd_pcm_status(struct snd_pcm_substream *substream, - struct snd_pcm_status *status); +int snd_pcm_status64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 *status); int snd_pcm_start(struct snd_pcm_substream *substream); int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status); int snd_pcm_drain_done(struct snd_pcm_substream *substream); @@ -1422,4 +1423,55 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format) #define pcm_dbg(pcm, fmt, args...) \ dev_dbg((pcm)->card->dev, fmt, ##args) +struct snd_pcm_status64 { + snd_pcm_state_t state; /* stream state */ + u8 rsvd[4]; + s64 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ + s64 trigger_tstamp_nsec; + s64 tstamp_sec; /* reference timestamp */ + s64 tstamp_nsec; + snd_pcm_uframes_t appl_ptr; /* appl ptr */ + snd_pcm_uframes_t hw_ptr; /* hw ptr */ + snd_pcm_sframes_t delay; /* current delay in frames */ + snd_pcm_uframes_t avail; /* number of frames available */ + snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ + snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ + snd_pcm_state_t suspended_state; /* suspended stream state */ + __u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ + s64 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */ + s64 audio_tstamp_nsec; + s64 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ + s64 driver_tstamp_nsec; + __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ + unsigned char reserved[52-4*sizeof(s64)]; /* must be filled with zero */ +}; + +#define SNDRV_PCM_IOCTL_STATUS64 _IOR('A', 0x20, struct snd_pcm_status64) +#define SNDRV_PCM_IOCTL_STATUS_EXT64 _IOWR('A', 0x24, struct snd_pcm_status64) + +struct snd_pcm_status32 { + s32 state; /* stream state */ + s32 trigger_tstamp_sec; /* time when stream was started/stopped/paused */ + s32 trigger_tstamp_nsec; + s32 tstamp_sec; /* reference timestamp */ + s32 tstamp_nsec; + u32 appl_ptr; /* appl ptr */ + u32 hw_ptr; /* hw ptr */ + s32 delay; /* current delay in frames */ + u32 avail; /* number of frames available */ + u32 avail_max; /* max frames available on hw since last status */ + u32 overrange; /* count of ADC (capture) overrange detections from last status */ + s32 suspended_state; /* suspended stream state */ + u32 audio_tstamp_data; /* needed for 64-bit alignment, used for configs/report to/from userspace */ + s32 audio_tstamp_sec; /* sample counter, wall clock, PHC or on-demand sync'ed */ + s32 audio_tstamp_nsec; + s32 driver_tstamp_sec; /* useful in case reference system tstamp is reported with delay */ + s32 driver_tstamp_nsec; + u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ + unsigned char reserved[52-4*sizeof(s32)]; /* must be filled with zero */ +}; + +#define SNDRV_PCM_IOCTL_STATUS32 _IOR('A', 0x20, struct snd_pcm_status32) +#define SNDRV_PCM_IOCTL_STATUS_EXT32 _IOWR('A', 0x24, struct snd_pcm_status32) + #endif /* __SOUND_PCM_H */ diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 40a23d8418fe..d2c88c098b20 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -456,8 +456,13 @@ enum { SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED }; +#ifndef __KERNEL__ +/* explicit padding avoids incompatibility between i386 and x86-64 */ +typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] __time_pad; + struct snd_pcm_status { snd_pcm_state_t state; /* stream state */ + __time_pad pad1; /* align to timespec */ struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */ struct timespec tstamp; /* reference timestamp */ snd_pcm_uframes_t appl_ptr; /* appl ptr */ @@ -473,6 +478,7 @@ struct snd_pcm_status { __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */ }; +#endif struct snd_pcm_mmap_status { snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9a72d641743d..85db55ea49fd 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -443,7 +443,7 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, { struct snd_pcm_substream *substream = entry->private_data; struct snd_pcm_runtime *runtime; - struct snd_pcm_status status; + struct snd_pcm_status64 status; int err; mutex_lock(&substream->pcm->open_mutex); @@ -453,17 +453,17 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, goto unlock; } memset(&status, 0, sizeof(status)); - err = snd_pcm_status(substream, &status); + err = snd_pcm_status64(substream, &status); if (err < 0) { snd_iprintf(buffer, "error %d\n", err); goto unlock; } snd_iprintf(buffer, "state: %s\n", snd_pcm_state_name(status.state)); snd_iprintf(buffer, "owner_pid : %d\n", pid_vnr(substream->pid)); - snd_iprintf(buffer, "trigger_time: %ld.%09ld\n", - status.trigger_tstamp.tv_sec, status.trigger_tstamp.tv_nsec); - snd_iprintf(buffer, "tstamp : %ld.%09ld\n", - status.tstamp.tv_sec, status.tstamp.tv_nsec); + snd_iprintf(buffer, "trigger_time: %lld.%09lld\n", + status.trigger_tstamp_sec, status.trigger_tstamp_nsec); + snd_iprintf(buffer, "tstamp : %lld.%09lld\n", + status.tstamp_sec, status.tstamp_nsec); snd_iprintf(buffer, "delay : %ld\n", status.delay); snd_iprintf(buffer, "avail : %ld\n", status.avail); snd_iprintf(buffer, "avail_max : %ld\n", status.avail_max); diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 6f9003b1869a..2671658442ea 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -168,73 +168,13 @@ static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, snd_pcm_channel_info_user(s, p) #endif /* CONFIG_X86_X32 */ -struct snd_pcm_status32 { +struct compat_snd_pcm_status64 { s32 state; - struct compat_timespec trigger_tstamp; - struct compat_timespec tstamp; - u32 appl_ptr; - u32 hw_ptr; - s32 delay; - u32 avail; - u32 avail_max; - u32 overrange; - s32 suspended_state; - u32 audio_tstamp_data; - struct compat_timespec audio_tstamp; - struct compat_timespec driver_tstamp; - u32 audio_tstamp_accuracy; - unsigned char reserved[52-2*sizeof(struct compat_timespec)]; -} __attribute__((packed)); - - -static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream, - struct snd_pcm_status32 __user *src, - bool ext) -{ - struct snd_pcm_status status; - int err; - - memset(&status, 0, sizeof(status)); - /* - * with extension, parameters are read/write, - * get audio_tstamp_data from user, - * ignore rest of status structure - */ - if (ext && get_user(status.audio_tstamp_data, - (u32 __user *)(&src->audio_tstamp_data))) - return -EFAULT; - err = snd_pcm_status(substream, &status); - if (err < 0) - return err; - - if (clear_user(src, sizeof(*src))) - return -EFAULT; - if (put_user(status.state, &src->state) || - compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || - compat_put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.appl_ptr, &src->appl_ptr) || - put_user(status.hw_ptr, &src->hw_ptr) || - put_user(status.delay, &src->delay) || - put_user(status.avail, &src->avail) || - put_user(status.avail_max, &src->avail_max) || - put_user(status.overrange, &src->overrange) || - put_user(status.suspended_state, &src->suspended_state) || - put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || - compat_put_timespec(&status.audio_tstamp, &src->audio_tstamp) || - compat_put_timespec(&status.driver_tstamp, &src->driver_tstamp) || - put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) - return -EFAULT; - - return err; -} - -#ifdef CONFIG_X86_X32 -/* X32 ABI has 64bit timespec and 64bit alignment */ -struct snd_pcm_status_x32 { - s32 state; - u32 rsvd; /* alignment */ - struct timespec trigger_tstamp; - struct timespec tstamp; + u8 rsvd[4]; /* alignment */ + s64 trigger_tstamp_sec; + s64 trigger_tstamp_nsec; + s64 tstamp_sec; + s64 tstamp_nsec; u32 appl_ptr; u32 hw_ptr; s32 delay; @@ -243,22 +183,26 @@ struct snd_pcm_status_x32 { u32 overrange; s32 suspended_state; u32 audio_tstamp_data; - struct timespec audio_tstamp; - struct timespec driver_tstamp; + s64 audio_tstamp_sec; + s64 audio_tstamp_nsec; + s64 driver_tstamp_sec; + s64 driver_tstamp_nsec; u32 audio_tstamp_accuracy; - unsigned char reserved[52-2*sizeof(struct timespec)]; + unsigned char reserved[52-4*sizeof(s64)]; } __packed; #define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) -static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream, - struct snd_pcm_status_x32 __user *src, - bool ext) +static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, + struct compat_snd_pcm_status64 __user *src, + bool ext) { - struct snd_pcm_status status; + struct snd_pcm_status64 status; + struct compat_snd_pcm_status64 compat_status64; int err; memset(&status, 0, sizeof(status)); + memset(&compat_status64, 0, sizeof(compat_status64)); /* * with extension, parameters are read/write, * get audio_tstamp_data from user, @@ -267,31 +211,39 @@ static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream, if (ext && get_user(status.audio_tstamp_data, (u32 __user *)(&src->audio_tstamp_data))) return -EFAULT; - err = snd_pcm_status(substream, &status); + err = snd_pcm_status64(substream, &status); if (err < 0) return err; if (clear_user(src, sizeof(*src))) return -EFAULT; - if (put_user(status.state, &src->state) || - put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || - put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.appl_ptr, &src->appl_ptr) || - put_user(status.hw_ptr, &src->hw_ptr) || - put_user(status.delay, &src->delay) || - put_user(status.avail, &src->avail) || - put_user(status.avail_max, &src->avail_max) || - put_user(status.overrange, &src->overrange) || - put_user(status.suspended_state, &src->suspended_state) || - put_user(status.audio_tstamp_data, &src->audio_tstamp_data) || - put_timespec(&status.audio_tstamp, &src->audio_tstamp) || - put_timespec(&status.driver_tstamp, &src->driver_tstamp) || - put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy)) + + compat_status64 = (struct compat_snd_pcm_status64) { + .state = status.state, + .trigger_tstamp_sec = status.trigger_tstamp_sec, + .trigger_tstamp_nsec = status.trigger_tstamp_nsec, + .tstamp_sec = status.tstamp_sec, + .tstamp_nsec = status.tstamp_nsec, + .appl_ptr = status.appl_ptr, + .hw_ptr = status.hw_ptr, + .delay = status.delay, + .avail = status.avail, + .avail_max = status.avail_max, + .overrange = status.overrange, + .suspended_state = status.suspended_state, + .audio_tstamp_data = status.audio_tstamp_data, + .audio_tstamp_sec = status.audio_tstamp_sec, + .audio_tstamp_nsec = status.audio_tstamp_nsec, + .driver_tstamp_sec = status.audio_tstamp_sec, + .driver_tstamp_nsec = status.audio_tstamp_nsec, + .audio_tstamp_accuracy = status.audio_tstamp_accuracy, + }; + + if (copy_to_user(src, &compat_status64, sizeof(compat_status64))) return -EFAULT; return err; } -#endif /* CONFIG_X86_X32 */ /* both for HW_PARAMS and HW_REFINE */ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, @@ -616,8 +568,8 @@ enum { SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct snd_pcm_hw_params32), SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct snd_pcm_hw_params32), SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct snd_pcm_sw_params32), - SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct snd_pcm_status32), - SNDRV_PCM_IOCTL_STATUS_EXT32 = _IOWR('A', 0x24, struct snd_pcm_status32), + SNDRV_PCM_IOCTL_STATUS_COMPAT32 = _IOR('A', 0x20, struct snd_pcm_status32), + SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32 = _IOWR('A', 0x24, struct snd_pcm_status32), SNDRV_PCM_IOCTL_DELAY32 = _IOR('A', 0x21, s32), SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct snd_pcm_channel_info32), SNDRV_PCM_IOCTL_REWIND32 = _IOW('A', 0x46, u32), @@ -627,10 +579,10 @@ enum { SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32), SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32), SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32), + SNDRV_PCM_IOCTL_STATUS_COMPAT64 = _IOR('A', 0x20, struct compat_snd_pcm_status64), + SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64 = _IOWR('A', 0x24, struct compat_snd_pcm_status64), #ifdef CONFIG_X86_X32 SNDRV_PCM_IOCTL_CHANNEL_INFO_X32 = _IOR('A', 0x32, struct snd_pcm_channel_info), - SNDRV_PCM_IOCTL_STATUS_X32 = _IOR('A', 0x20, struct snd_pcm_status_x32), - SNDRV_PCM_IOCTL_STATUS_EXT_X32 = _IOWR('A', 0x24, struct snd_pcm_status_x32), SNDRV_PCM_IOCTL_SYNC_PTR_X32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr_x32), #endif /* CONFIG_X86_X32 */ }; @@ -680,10 +632,10 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l return snd_pcm_ioctl_hw_params_compat(substream, 0, argp); case SNDRV_PCM_IOCTL_SW_PARAMS32: return snd_pcm_ioctl_sw_params_compat(substream, argp); - case SNDRV_PCM_IOCTL_STATUS32: - return snd_pcm_status_user_compat(substream, argp, false); - case SNDRV_PCM_IOCTL_STATUS_EXT32: - return snd_pcm_status_user_compat(substream, argp, true); + case SNDRV_PCM_IOCTL_STATUS_COMPAT32: + return snd_pcm_status_user32(substream, argp, false); + case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32: + return snd_pcm_status_user32(substream, argp, true); case SNDRV_PCM_IOCTL_SYNC_PTR32: return snd_pcm_ioctl_sync_ptr_compat(substream, argp); case SNDRV_PCM_IOCTL_CHANNEL_INFO32: @@ -702,11 +654,11 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l return snd_pcm_ioctl_rewind_compat(substream, argp); case SNDRV_PCM_IOCTL_FORWARD32: return snd_pcm_ioctl_forward_compat(substream, argp); + case SNDRV_PCM_IOCTL_STATUS_COMPAT64: + return snd_pcm_status_user_compat64(substream, argp, false); + case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64: + return snd_pcm_status_user_compat64(substream, argp, true); #ifdef CONFIG_X86_X32 - case SNDRV_PCM_IOCTL_STATUS_X32: - return snd_pcm_status_user_x32(substream, argp, false); - case SNDRV_PCM_IOCTL_STATUS_EXT_X32: - return snd_pcm_status_user_x32(substream, argp, true); case SNDRV_PCM_IOCTL_SYNC_PTR_X32: return snd_pcm_ioctl_sync_ptr_x32(substream, argp); case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32: diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 67fe14bad7cb..ad4cf1e3e3bd 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -891,8 +891,8 @@ snd_pcm_calc_delay(struct snd_pcm_substream *substream) return delay + substream->runtime->delay; } -int snd_pcm_status(struct snd_pcm_substream *substream, - struct snd_pcm_status *status) +int snd_pcm_status64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 *status) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -918,14 +918,22 @@ int snd_pcm_status(struct snd_pcm_substream *substream, status->suspended_state = runtime->status->suspended_state; if (status->state == SNDRV_PCM_STATE_OPEN) goto _end; - status->trigger_tstamp = timespec64_to_timespec(runtime->trigger_tstamp); + status->trigger_tstamp_sec = runtime->trigger_tstamp.tv_sec; + status->trigger_tstamp_nsec = runtime->trigger_tstamp.tv_nsec; if (snd_pcm_running(substream)) { snd_pcm_update_hw_ptr(substream); if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { - status->tstamp = runtime->status->tstamp; - status->driver_tstamp = timespec64_to_timespec(runtime->driver_tstamp); - status->audio_tstamp = - runtime->status->audio_tstamp; + status->tstamp_sec = runtime->status->tstamp.tv_sec; + status->tstamp_nsec = + runtime->status->tstamp.tv_nsec; + status->driver_tstamp_sec = + runtime->driver_tstamp.tv_sec; + status->driver_tstamp_nsec = + runtime->driver_tstamp.tv_nsec; + status->audio_tstamp_sec = + runtime->status->audio_tstamp.tv_sec; + status->audio_tstamp_nsec = + runtime->status->audio_tstamp.tv_nsec; if (runtime->audio_tstamp_report.valid == 1) /* backwards compatibility, no report provided in COMPAT mode */ snd_pcm_pack_audio_tstamp_report(&status->audio_tstamp_data, @@ -940,7 +948,8 @@ int snd_pcm_status(struct snd_pcm_substream *substream, struct timespec64 tstamp; snd_pcm_gettime(runtime, &tstamp); - status->tstamp = timespec64_to_timespec(tstamp); + status->tstamp_sec = tstamp.tv_sec; + status->tstamp_nsec = tstamp.tv_nsec; } } _tstamp_end: @@ -958,11 +967,11 @@ int snd_pcm_status(struct snd_pcm_substream *substream, return 0; } -static int snd_pcm_status_user(struct snd_pcm_substream *substream, - struct snd_pcm_status __user * _status, - bool ext) +static int snd_pcm_status_user64(struct snd_pcm_substream *substream, + struct snd_pcm_status64 __user * _status, + bool ext) { - struct snd_pcm_status status; + struct snd_pcm_status64 status; int res; memset(&status, 0, sizeof(status)); @@ -974,7 +983,7 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream, if (ext && get_user(status.audio_tstamp_data, (u32 __user *)(&_status->audio_tstamp_data))) return -EFAULT; - res = snd_pcm_status(substream, &status); + res = snd_pcm_status64(substream, &status); if (res < 0) return res; if (copy_to_user(_status, &status, sizeof(status))) @@ -982,6 +991,55 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream, return 0; } +static int snd_pcm_status_user32(struct snd_pcm_substream *substream, + struct snd_pcm_status32 __user * _status, + bool ext) +{ + struct snd_pcm_status64 status64; + struct snd_pcm_status32 status32; + int res; + + memset(&status64, 0, sizeof(status64)); + memset(&status32, 0, sizeof(status32)); + /* + * with extension, parameters are read/write, + * get audio_tstamp_data from user, + * ignore rest of status structure + */ + if (ext && get_user(status64.audio_tstamp_data, + (u32 __user *)(&_status->audio_tstamp_data))) + return -EFAULT; + res = snd_pcm_status64(substream, &status64); + if (res < 0) + return res; + + status32 = (struct snd_pcm_status32) { + .state = status64.state, + .trigger_tstamp_sec = status64.trigger_tstamp_sec, + .trigger_tstamp_nsec = status64.trigger_tstamp_nsec, + .tstamp_sec = status64.tstamp_sec, + .tstamp_nsec = status64.tstamp_nsec, + .appl_ptr = status64.appl_ptr, + .hw_ptr = status64.hw_ptr, + .delay = status64.delay, + .avail = status64.avail, + .avail_max = status64.avail_max, + .overrange = status64.overrange, + .suspended_state = status64.suspended_state, + .audio_tstamp_data = status64.audio_tstamp_data, + .audio_tstamp_sec = status64.audio_tstamp_sec, + .audio_tstamp_nsec = status64.audio_tstamp_nsec, + .driver_tstamp_sec = status64.audio_tstamp_sec, + .driver_tstamp_nsec = status64.audio_tstamp_nsec, + .audio_tstamp_accuracy = status64.audio_tstamp_accuracy, + }; + + if (copy_to_user(_status, &status32, sizeof(status32))) + return -EFAULT; + + return 0; +} + static int snd_pcm_channel_info(struct snd_pcm_substream *substream, struct snd_pcm_channel_info * info) { @@ -2959,10 +3017,14 @@ static int snd_pcm_common_ioctl(struct file *file, return snd_pcm_hw_free(substream); case SNDRV_PCM_IOCTL_SW_PARAMS: return snd_pcm_sw_params_user(substream, arg); - case SNDRV_PCM_IOCTL_STATUS: - return snd_pcm_status_user(substream, arg, false); - case SNDRV_PCM_IOCTL_STATUS_EXT: - return snd_pcm_status_user(substream, arg, true); + case SNDRV_PCM_IOCTL_STATUS32: + return snd_pcm_status_user32(substream, arg, false); + case SNDRV_PCM_IOCTL_STATUS_EXT32: + return snd_pcm_status_user32(substream, arg, true); + case SNDRV_PCM_IOCTL_STATUS64: + return snd_pcm_status_user64(substream, arg, false); + case SNDRV_PCM_IOCTL_STATUS_EXT64: + return snd_pcm_status_user64(substream, arg, true); case SNDRV_PCM_IOCTL_CHANNEL_INFO: return snd_pcm_channel_info_user(substream, arg); case SNDRV_PCM_IOCTL_PREPARE: -- cgit v1.2.3 From d9e5582c4bb219f3459e39f65410f0e5128fbe91 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:12 +0800 Subject: ALSA: Avoid using timespec for struct snd_rawmidi_status The struct snd_rawmidi_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Thus we introduced 'struct snd_rawmidi_status32' and 'struct snd_rawmidi_status64' to handle 32bit time_t and 64bit time_t in native mode, which replace timespec with s64 type. In compat mode, we renamed or introduced new structures to handle 32bit/64bit time_t in compatible mode. The 'struct snd_rawmidi_status32' and snd_rawmidi_ioctl_status32() are used to handle 32bit time_t in compat mode. 'struct compat_snd_rawmidi_status64' is used to handle 64bit time_t. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 3 + sound/core/rawmidi.c | 132 ++++++++++++++++++++++++++++++++++---------- sound/core/rawmidi_compat.c | 87 ++++++++--------------------- 3 files changed, 128 insertions(+), 94 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index d2c88c098b20..e0ada33afa1e 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -654,13 +654,16 @@ struct snd_rawmidi_params { unsigned char reserved[16]; /* reserved for future use */ }; +#ifndef __KERNEL__ struct snd_rawmidi_status { int stream; + __time_pad pad1; struct timespec tstamp; /* Timestamp */ size_t avail; /* available bytes */ size_t xruns; /* count of overruns since last status (in bytes) */ unsigned char reserved[16]; /* reserved for future use */ }; +#endif #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 8a12a7538d63..cd9bbb546846 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -50,6 +50,29 @@ static DEFINE_MUTEX(register_mutex); #define rmidi_dbg(rmidi, fmt, args...) \ dev_dbg(&(rmidi)->dev, fmt, ##args) +struct snd_rawmidi_status32 { + s32 stream; + s32 tstamp_sec; /* Timestamp */ + s32 tstamp_nsec; + u32 avail; /* available bytes */ + u32 xruns; /* count of overruns since last status (in bytes) */ + unsigned char reserved[16]; /* reserved for future use */ +}; + +#define SNDRV_RAWMIDI_IOCTL_STATUS32 _IOWR('W', 0x20, struct snd_rawmidi_status32) + +struct snd_rawmidi_status64 { + int stream; + u8 rsvd[4]; /* alignment */ + s64 tstamp_sec; /* Timestamp */ + s64 tstamp_nsec; + size_t avail; /* available bytes */ + size_t xruns; /* count of overruns since last status (in bytes) */ + unsigned char reserved[16]; /* reserved for future use */ +}; + +#define SNDRV_RAWMIDI_IOCTL_STATUS64 _IOWR('W', 0x20, struct snd_rawmidi_status64) + static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) { struct snd_rawmidi *rawmidi; @@ -677,7 +700,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, EXPORT_SYMBOL(snd_rawmidi_input_params); static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, - struct snd_rawmidi_status *status) + struct snd_rawmidi_status64 *status) { struct snd_rawmidi_runtime *runtime = substream->runtime; @@ -690,7 +713,7 @@ static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, } static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream, - struct snd_rawmidi_status *status) + struct snd_rawmidi_status64 *status) { struct snd_rawmidi_runtime *runtime = substream->runtime; @@ -704,6 +727,80 @@ static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream, return 0; } +static int snd_rawmidi_ioctl_status32(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_status32 __user *argp) +{ + int err = 0; + struct snd_rawmidi_status32 __user *status = argp; + struct snd_rawmidi_status32 status32; + struct snd_rawmidi_status64 status64; + + if (copy_from_user(&status32, argp, + sizeof(struct snd_rawmidi_status32))) + return -EFAULT; + + switch (status32.stream) { + case SNDRV_RAWMIDI_STREAM_OUTPUT: + if (rfile->output == NULL) + return -EINVAL; + err = snd_rawmidi_output_status(rfile->output, &status64); + break; + case SNDRV_RAWMIDI_STREAM_INPUT: + if (rfile->input == NULL) + return -EINVAL; + err = snd_rawmidi_input_status(rfile->input, &status64); + break; + default: + return -EINVAL; + } + if (err < 0) + return err; + + status32 = (struct snd_rawmidi_status32) { + .stream = status64.stream, + .tstamp_sec = status64.tstamp_sec, + .tstamp_nsec = status64.tstamp_nsec, + .avail = status64.avail, + .xruns = status64.xruns, + }; + + if (copy_to_user(status, &status32, sizeof(*status))) + return -EFAULT; + + return 0; +} + +static int snd_rawmidi_ioctl_status64(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_status64 __user *argp) +{ + int err = 0; + struct snd_rawmidi_status64 status; + + if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status64))) + return -EFAULT; + + switch (status.stream) { + case SNDRV_RAWMIDI_STREAM_OUTPUT: + if (rfile->output == NULL) + return -EINVAL; + err = snd_rawmidi_output_status(rfile->output, &status); + break; + case SNDRV_RAWMIDI_STREAM_INPUT: + if (rfile->input == NULL) + return -EINVAL; + err = snd_rawmidi_input_status(rfile->input, &status); + break; + default: + return -EINVAL; + } + if (err < 0) + return err; + if (copy_to_user(argp, &status, + sizeof(struct snd_rawmidi_status64))) + return -EFAULT; + return 0; +} + static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct snd_rawmidi_file *rfile; @@ -750,33 +847,10 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long return -EINVAL; } } - case SNDRV_RAWMIDI_IOCTL_STATUS: - { - int err = 0; - struct snd_rawmidi_status status; - - if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status))) - return -EFAULT; - switch (status.stream) { - case SNDRV_RAWMIDI_STREAM_OUTPUT: - if (rfile->output == NULL) - return -EINVAL; - err = snd_rawmidi_output_status(rfile->output, &status); - break; - case SNDRV_RAWMIDI_STREAM_INPUT: - if (rfile->input == NULL) - return -EINVAL; - err = snd_rawmidi_input_status(rfile->input, &status); - break; - default: - return -EINVAL; - } - if (err < 0) - return err; - if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status))) - return -EFAULT; - return 0; - } + case SNDRV_RAWMIDI_IOCTL_STATUS32: + return snd_rawmidi_ioctl_status32(rfile, argp); + case SNDRV_RAWMIDI_IOCTL_STATUS64: + return snd_rawmidi_ioctl_status64(rfile, argp); case SNDRV_RAWMIDI_IOCTL_DROP: { int val; diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c index 66eee61674b6..7397130976d0 100644 --- a/sound/core/rawmidi_compat.c +++ b/sound/core/rawmidi_compat.c @@ -41,19 +41,22 @@ static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile, return -EINVAL; } -struct snd_rawmidi_status32 { +struct compat_snd_rawmidi_status64 { s32 stream; - struct compat_timespec tstamp; + u8 rsvd[4]; /* alignment */ + s64 tstamp_sec; + s64 tstamp_nsec; u32 avail; u32 xruns; unsigned char reserved[16]; } __attribute__((packed)); -static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile, - struct snd_rawmidi_status32 __user *src) +static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile, + struct compat_snd_rawmidi_status64 __user *src) { int err; - struct snd_rawmidi_status status; + struct snd_rawmidi_status64 status; + struct compat_snd_rawmidi_status64 compat_status; if (get_user(status.stream, &src->stream)) return -EFAULT; @@ -75,68 +78,24 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile, if (err < 0) return err; - if (compat_put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.avail, &src->avail) || - put_user(status.xruns, &src->xruns)) - return -EFAULT; - - return 0; -} - -#ifdef CONFIG_X86_X32 -/* X32 ABI has 64bit timespec and 64bit alignment */ -struct snd_rawmidi_status_x32 { - s32 stream; - u32 rsvd; /* alignment */ - struct timespec tstamp; - u32 avail; - u32 xruns; - unsigned char reserved[16]; -} __attribute__((packed)); - -#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) - -static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile, - struct snd_rawmidi_status_x32 __user *src) -{ - int err; - struct snd_rawmidi_status status; - - if (get_user(status.stream, &src->stream)) - return -EFAULT; - - switch (status.stream) { - case SNDRV_RAWMIDI_STREAM_OUTPUT: - if (!rfile->output) - return -EINVAL; - err = snd_rawmidi_output_status(rfile->output, &status); - break; - case SNDRV_RAWMIDI_STREAM_INPUT: - if (!rfile->input) - return -EINVAL; - err = snd_rawmidi_input_status(rfile->input, &status); - break; - default: - return -EINVAL; - } - if (err < 0) - return err; + compat_status = (struct compat_snd_rawmidi_status64) { + .stream = status.stream, + .tstamp_sec = status.tstamp_sec, + .tstamp_nsec = status.tstamp_nsec, + .avail = status.avail, + .xruns = status.xruns, + }; - if (put_timespec(&status.tstamp, &src->tstamp) || - put_user(status.avail, &src->avail) || - put_user(status.xruns, &src->xruns)) + if (copy_to_user(src, &compat_status, sizeof(*src))) return -EFAULT; return 0; } -#endif /* CONFIG_X86_X32 */ enum { SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32), - SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32), -#ifdef CONFIG_X86_X32 - SNDRV_RAWMIDI_IOCTL_STATUS_X32 = _IOWR('W', 0x20, struct snd_rawmidi_status_x32), -#endif /* CONFIG_X86_X32 */ + SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32 = _IOWR('W', 0x20, struct snd_rawmidi_status32), + SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64 = _IOWR('W', 0x20, struct compat_snd_rawmidi_status64), }; static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) @@ -153,12 +112,10 @@ static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsign return snd_rawmidi_ioctl(file, cmd, (unsigned long)argp); case SNDRV_RAWMIDI_IOCTL_PARAMS32: return snd_rawmidi_ioctl_params_compat(rfile, argp); - case SNDRV_RAWMIDI_IOCTL_STATUS32: - return snd_rawmidi_ioctl_status_compat(rfile, argp); -#ifdef CONFIG_X86_X32 - case SNDRV_RAWMIDI_IOCTL_STATUS_X32: - return snd_rawmidi_ioctl_status_x32(rfile, argp); -#endif /* CONFIG_X86_X32 */ + case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT32: + return snd_rawmidi_ioctl_status32(rfile, argp); + case SNDRV_RAWMIDI_IOCTL_STATUS_COMPAT64: + return snd_rawmidi_ioctl_status_compat64(rfile, argp); } return -ENOIOCTLCMD; } -- cgit v1.2.3 From 528be501b7d4a64e04672a38ebfc9e19c555e770 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:44:57 -0600 Subject: soundwire: sdw_slave: add probe_complete structure and new fields When a Slave device becomes synchronized with the bus, it may report its presence in PING frames, as well as optionally asserting an in-band PREQ signal. The bus driver will detect a new Device0, start the enumeration process and assign it a non-zero device number. The SoundWire enumeration provides an arbitration to deal with multiple Slaves reporting ATTACHED at the same time. The bus driver will also invoke the driver .probe() callback associated with this device. The probe() depends on the Linux device core, which handles the match operations and may result in modules being loaded. Once the non-zero device number is programmed, the Slave will report its new status in PING frames and the Master hardware will typically report this status change with an interrupt. At this point, the .update_status() callback of the codec driver will be invoked (usually from an interrupt thread or workqueue scheduled from the interrupt thread). The first race condition which can happen is between the .probe(), which allocates the resources, and .update_status() where initializations are typically handled. The .probe() is only called once during the initial boot, while .update_status() will be called for every bus hardware reset and if the Slave device loses synchronization (an unlikely event but with non-zero probability). The time difference between the end of the enumeration process and a change of status reported by the hardware may be as small as one SoundWire PING frame. The scheduling of the interrupt thread, which invokes .update_status() is not deterministic, but can be small enough to create a race condition. With a 48 kHz frame rate and ideal scheduling cases, the .probe() may be pre-empted within double-digit microseconds. Since there is no guarantee that the .probe() completes by the time .update_status() is invoked as a result of an interrupt, it's not unusual for the .update_status() to rely on data structures that have not been allocated yet, leading to kernel oopses. This patch adds a probe_complete utility, which is used in the sdw_update_slave_status() routine. The codec driver does not need to do anything and can safely assume all resources are allocated in its update_status() callback. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 28745b9ba279..cb1db4a7475d 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -547,6 +547,10 @@ struct sdw_slave_ops { * @node: node for bus list * @port_ready: Port ready completion flag for each Slave port * @dev_num: Device Number assigned by Bus + * @probed: boolean tracking driver state + * @probe_complete: completion utility to control potential races + * on startup between driver probe/initialization and SoundWire + * Slave state changes/implementation-defined interrupts */ struct sdw_slave { struct sdw_slave_id id; @@ -561,6 +565,8 @@ struct sdw_slave { struct list_head node; struct completion *port_ready; u16 dev_num; + bool probed; + struct completion probe_complete; }; #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev) -- cgit v1.2.3 From fbbff36325079fd9d2fcd30063c84f4b38a0ad9b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:44:58 -0600 Subject: soundwire: sdw_slave: add enumeration_complete structure When the Master starts the bus (be it during the initial boot or system resume), it usually performs a HardReset to make sure electrical levels are correct, then enables the control channel. While the PM framework guarantees that the Slave devices will only become 'active' once the Master completes the bus initialization, there is still a risk of a race condition: the Slave enumeration is handled in a separate interrupt thread triggered by hardware status changes, so the Slave device may not be ready to accept commands when the Slave driver tries to access the registers and restore settings in its resume or pm_runtime_resume callbacks. In those cases, any read/write commands from/to the Slave device will result in a timeout. This patch adds an enumeration_complete structure. When the bus is goes through a HardReset sequence and restarted, the Slave will be marked as UNATTACHED, which will result in a call to init_completion(). When the Slave reports its presence during PING frames as a non-zero Device, the Master hardware will issue an interrupt and the bus driver will invoke complete(). The order between init_completion()/complete() is predictable since this is a Master-initiated transition. The Slave driver may use wait_for_completion() in its resume callback. When regmap is used, the Slave driver will typically set its regmap in cache-only mode on suspend, then on resume block on wait_for_completion(&enumeration_complete) to guarantee it is safe to start read/write transactions. It may then exit the cache-only mode and use a regmap_sync to restore settings. All these steps are optional, their use completely depends on the Slave device capabilities and how the Slave driver is implemented. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index cb1db4a7475d..3fa8d875b16b 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -551,6 +551,9 @@ struct sdw_slave_ops { * @probe_complete: completion utility to control potential races * on startup between driver probe/initialization and SoundWire * Slave state changes/implementation-defined interrupts + * @enumeration_complete: completion utility to control potential races + * on startup between device enumeration and read/write access to the + * Slave device */ struct sdw_slave { struct sdw_slave_id id; @@ -567,6 +570,7 @@ struct sdw_slave { u16 dev_num; bool probed; struct completion probe_complete; + struct completion enumeration_complete; }; #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev) -- cgit v1.2.3 From 7afc50e441af0afc8055920a64cff70b648e4b44 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:44:59 -0600 Subject: soundwire: sdw_slave: add initialization_complete definition Slave drivers may have different ways of handling their settings, with or without regmap. During the integration of codec drivers, done in partnership between Intel and Realtek, it became desirable to implement a predictable order between low-level initializations performed in .update_status() (invoked by an interrupt thread) and the settings restored in the resume steps (invoked by the PM core). This patch builds on the previous solution to wait for the Slave device to be fully enumerated. The complete() in this case is signaled not before the .update_status() is called, but after .update_status() returns. Without this patch, the settings were not properly restored, leading to timing-dependent 'no sound after resume' or 'no headset detected after resume' bug reports. Depending on how initialization is handled, a Slave device driver may wait for enumeration_complete, or for initialization_complete, both are valid synchronization points. They are initialized at the same time, they only differ on when complete() is invoked. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 3fa8d875b16b..ed42cd79eab7 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -554,6 +554,8 @@ struct sdw_slave_ops { * @enumeration_complete: completion utility to control potential races * on startup between device enumeration and read/write access to the * Slave device + * @initialization_complete: completion utility to control potential races + * on startup between device enumeration and settings being restored */ struct sdw_slave { struct sdw_slave_id id; @@ -571,6 +573,7 @@ struct sdw_slave { bool probed; struct completion probe_complete; struct completion enumeration_complete; + struct completion initialization_complete; }; #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev) -- cgit v1.2.3 From b2bd75f806c49929d7ab5a860c0a69b0a17c59d2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:45:00 -0600 Subject: soundwire: sdw_slave: track unattach_request to handle all init sequences The Slave device initialization can be split in 4 different cases: 1. Master-initiated hardware reset, system suspend-resume and pm_runtime based on clock-stop mode1. To avoid timeouts and a bad audio experience, the Slave device resume operations need to wait for the Slave device to be re-enumerated and its settings restored. 2. Exit from clock-stop mode0. In this case, the Slave device is required to remain enumerated and its context preserved while the clock is stopped, so no re-initialization or wait_for_completion() is necessary. 3. Slave-initiated pm_runtime D3 transition. With the parent child relationship, it is possible that a Slave device becomes 'suspended' while its parent is still 'active' with the bus clock still toggling. In this case, during the pm_runtime resume operation, there is no need to wait for any settings to be restored. 4. Slave reset (sync loss or implementation-defined). In that case the bus remains operational and the Slave device will be re-initialized when it becomes ATTACHED again. In previous patches, we suggested the use of wait_for_completion() to deal with the case #1, but case #2 and #3 do not need any wait. To account for those differences, this patch adds an unattach_request field. The field is explicitly set by the Master for the case #1, and if non-zero the Slave device shall wait on resume. In all other cases, the Slave resume operations can proceed without wait. The only request tracked so far is Master HardReset, but the request is declared as a bit mask for future extensions (if needed). The definition for this value is added in bus.h and does not need to be exposed in sdw.h Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index ed42cd79eab7..b7c9eca4332a 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -556,6 +556,11 @@ struct sdw_slave_ops { * Slave device * @initialization_complete: completion utility to control potential races * on startup between device enumeration and settings being restored + * @unattach_request: mask field to keep track why the Slave re-attached and + * was re-initialized. This is useful to deal with potential race conditions + * between the Master suspending and the codec resuming, and make sure that + * when the Master triggered a reset the Slave is properly enumerated and + * initialized */ struct sdw_slave { struct sdw_slave_id id; @@ -574,6 +579,7 @@ struct sdw_slave { struct completion probe_complete; struct completion enumeration_complete; struct completion initialization_complete; + u32 unattach_request; }; #define dev_to_sdw_dev(_dev) container_of(_dev, struct sdw_slave, dev) -- cgit v1.2.3 From f98f690fb03c2a8d21dfa31aa1042480cf6f7f9b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:45:01 -0600 Subject: soundwire: intel: update interfaces between ASoC and SoundWire The current interfaces between ASoC and SoundWire are limited by the platform_device infrastructure to an init() and exit() (mapped to the platform driver.probe and .remove) To help with the platform detection, machine driver selection and management of power dependencies between DSP and SoundWire IP, the ASoC side requires: a) an ACPI scan helper, to report if any devices are exposed in the DSDT tables, and if any links are disabled by the BIOS. b) a probe helper that allocates the resources without actually starting the bus. c) a startup helper which does start the bus when all power dependencies are settled. d) an exit helper to free all resources e) an interrupt_enable/disable helper, typically invoked after the startup helper but also used in suspend routines. This patch moves all required interfaces to sdw_intel.h, mainly to allow SoundWire and ASoC parts to be merged separately once the header files are shared between trees. To avoid compilation issues, the conflicts in intel_init.c are blindly removed. This would in theory prevent the code from working, but since there are no users of the Intel Soundwire driver this has no impact. Functionality will be restored when the removal of platform devices is complete. Support for SoundWire + SOF builds will only be provided once all the required pieces are upstream. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- drivers/soundwire/intel.h | 9 +++-- drivers/soundwire/intel_init.c | 31 ++++----------- include/linux/soundwire/sdw_intel.h | 77 ++++++++++++++++++++++++++++++++++--- 3 files changed, 85 insertions(+), 32 deletions(-) diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h index d923b6262330..e4cc1d3804ff 100644 --- a/drivers/soundwire/intel.h +++ b/drivers/soundwire/intel.h @@ -5,17 +5,20 @@ #define __SDW_INTEL_LOCAL_H /** - * struct sdw_intel_link_res - Soundwire link resources + * struct sdw_intel_link_res - Soundwire Intel link resource structure, + * typically populated by the controller driver. + * @pdev: platform_device + * @mmio_base: mmio base of SoundWire registers * @registers: Link IO registers base * @shim: Audio shim pointer * @alh: ALH (Audio Link Hub) pointer * @irq: Interrupt line * @ops: Shim callback ops * @arg: Shim callback ops argument - * - * This is set as pdata for each link instance. */ struct sdw_intel_link_res { + struct platform_device *pdev; + void __iomem *mmio_base; /* not strictly needed, useful for debug */ void __iomem *registers; void __iomem *shim; void __iomem *alh; diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c index 2a2b4d8df462..bc739a38916d 100644 --- a/drivers/soundwire/intel_init.c +++ b/drivers/soundwire/intel_init.c @@ -27,19 +27,9 @@ static int link_mask; module_param_named(sdw_link_mask, link_mask, int, 0444); MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)"); -struct sdw_link_data { - struct sdw_intel_link_res res; - struct platform_device *pdev; -}; - -struct sdw_intel_ctx { - int count; - struct sdw_link_data *links; -}; - static int sdw_intel_cleanup_pdev(struct sdw_intel_ctx *ctx) { - struct sdw_link_data *link = ctx->links; + struct sdw_intel_link_res *link = ctx->links; int i; if (!link) @@ -62,7 +52,7 @@ static struct sdw_intel_ctx { struct platform_device_info pdevinfo; struct platform_device *pdev; - struct sdw_link_data *link; + struct sdw_intel_link_res *link; struct sdw_intel_ctx *ctx; struct acpi_device *adev; int ret, i; @@ -123,14 +113,12 @@ static struct sdw_intel_ctx continue; } - link->res.irq = res->irq; - link->res.registers = res->mmio_base + SDW_LINK_BASE + link->registers = res->mmio_base + SDW_LINK_BASE + (SDW_LINK_SIZE * i); - link->res.shim = res->mmio_base + SDW_SHIM_BASE; - link->res.alh = res->mmio_base + SDW_ALH_BASE; + link->shim = res->mmio_base + SDW_SHIM_BASE; + link->alh = res->mmio_base + SDW_ALH_BASE; - link->res.ops = res->ops; - link->res.arg = res->arg; + link->ops = res->ops; memset(&pdevinfo, 0, sizeof(pdevinfo)); @@ -138,8 +126,6 @@ static struct sdw_intel_ctx pdevinfo.name = "int-sdw"; pdevinfo.id = i; pdevinfo.fwnode = acpi_fwnode_handle(adev); - pdevinfo.data = &link->res; - pdevinfo.size_data = sizeof(link->res); pdev = platform_device_register_full(&pdevinfo); if (IS_ERR(pdev)) { @@ -216,7 +202,6 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res) return sdw_intel_add_controller(res); } -EXPORT_SYMBOL(sdw_intel_init); /** * sdw_intel_exit() - SoundWire Intel exit @@ -224,10 +209,8 @@ EXPORT_SYMBOL(sdw_intel_init); * * Delete the controller instances created and cleanup */ -void sdw_intel_exit(void *arg) +void sdw_intel_exit(struct sdw_intel_ctx *ctx) { - struct sdw_intel_ctx *ctx = arg; - sdw_intel_cleanup_pdev(ctx); kfree(ctx); } diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index c9427cb6020b..034eca8df748 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -16,24 +16,91 @@ struct sdw_intel_ops { }; /** - * struct sdw_intel_res - Soundwire Intel resource structure + * struct sdw_intel_acpi_info - Soundwire Intel information found in ACPI tables + * @handle: ACPI controller handle + * @count: link count found with "sdw-master-count" property + * @link_mask: bit-wise mask listing links enabled by BIOS menu + * + * this structure could be expanded to e.g. provide all the _ADR + * information in case the link_mask is not sufficient to identify + * platform capabilities. + */ +struct sdw_intel_acpi_info { + acpi_handle handle; + int count; + u32 link_mask; +}; + +struct sdw_intel_link_res; + +/** + * struct sdw_intel_ctx - context allocated by the controller + * driver probe + * @count: link count + * @mmio_base: mmio base of SoundWire registers, only used to check + * hardware capabilities after all power dependencies are settled. + * @link_mask: bit-wise mask listing SoundWire links reported by the + * Controller + * @handle: ACPI parent handle + * @links: information for each link (controller-specific and kept + * opaque here) + */ +struct sdw_intel_ctx { + int count; + void __iomem *mmio_base; + u32 link_mask; + acpi_handle handle; + struct sdw_intel_link_res *links; +}; + +/** + * struct sdw_intel_res - Soundwire Intel global resource structure, + * typically populated by the DSP driver + * + * @count: link count * @mmio_base: mmio base of SoundWire registers * @irq: interrupt number * @handle: ACPI parent handle * @parent: parent device * @ops: callback ops - * @arg: callback arg + * @dev: device implementing hwparams and free callbacks + * @link_mask: bit-wise mask listing links selected by the DSP driver + * This mask may be a subset of the one reported by the controller since + * machine-specific quirks are handled in the DSP driver. */ struct sdw_intel_res { + int count; void __iomem *mmio_base; int irq; acpi_handle handle; struct device *parent; const struct sdw_intel_ops *ops; - void *arg; + struct device *dev; + u32 link_mask; }; -void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res); -void sdw_intel_exit(void *arg); +/* + * On Intel platforms, the SoundWire IP has dependencies on power + * rails shared with the DSP, and the initialization steps are split + * in three. First an ACPI scan to check what the firmware describes + * in DSDT tables, then an allocation step (with no hardware + * configuration but with all the relevant devices created) and last + * the actual hardware configuration. The final stage is a global + * interrupt enable which is controlled by the DSP driver. Splitting + * these phases helps simplify the boot flow and make early decisions + * on e.g. which machine driver to select (I2S mode, HDaudio or + * SoundWire). + */ +int sdw_intel_acpi_scan(acpi_handle *parent_handle, + struct sdw_intel_acpi_info *info); + +struct sdw_intel_ctx * +sdw_intel_probe(struct sdw_intel_res *res); + +int sdw_intel_startup(struct sdw_intel_ctx *ctx); + +void sdw_intel_exit(struct sdw_intel_ctx *ctx); + +void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable); #endif -- cgit v1.2.3 From 4b206d34b92224496c42226c4b6d92719056c8b6 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 11 Dec 2019 19:45:02 -0600 Subject: soundwire: intel: update stream callbacks for hwparams/free stream operations The SoundWire DAIs for Intel platform are created in drivers/soundwire/intel.c, while the communication with the Intel DSP is all controlled in soc/sof/intel When the DAI status changes, a callback is used to bridge the gap between the two subsystems. The naming of the existing 'config_stream' callback does not map well with any of ALSA/ASoC concepts. This patch renames it as 'params_stream' to be more self-explanatory. A new 'free_stream' callback is added in case any resources allocated in the 'params_stream' stage need to be released. In the SOF implementation, this is used in the hw_free case to release the DMA channels over IPC. These two callbacks now rely on structures which expose the link_id and alh_stream_id (required by the firmware IPC), instead of a list of parameters. The 'void *' definitions are changed to use explicit types, as suggested on alsa-devel during earlier reviews. Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- drivers/soundwire/intel.c | 20 ++++++++++++++------ drivers/soundwire/intel.h | 4 ++-- drivers/soundwire/intel_init.c | 1 + include/linux/soundwire/sdw_intel.h | 32 ++++++++++++++++++++++++++++---- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index 99dc61021211..0371d3d5501a 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -529,17 +529,24 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi) intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf); } -static int intel_config_stream(struct sdw_intel *sdw, +static int intel_params_stream(struct sdw_intel *sdw, struct snd_pcm_substream *substream, struct snd_soc_dai *dai, - struct snd_pcm_hw_params *hw_params, int link_id) + struct snd_pcm_hw_params *hw_params, + int link_id, int alh_stream_id) { struct sdw_intel_link_res *res = sdw->res; + struct sdw_intel_stream_params_data params_data; - if (res->ops && res->ops->config_stream && res->arg) - return res->ops->config_stream(res->arg, - substream, dai, hw_params, link_id); + params_data.substream = substream; + params_data.dai = dai; + params_data.hw_params = hw_params; + params_data.link_id = link_id; + params_data.alh_stream_id = alh_stream_id; + if (res->ops && res->ops->params_stream && res->dev) + return res->ops->params_stream(res->dev, + ¶ms_data); return -EIO; } @@ -654,7 +661,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream, /* Inform DSP about PDI stream number */ - ret = intel_config_stream(sdw, substream, dai, params, + ret = intel_params_stream(sdw, substream, dai, params, + sdw->instance, pdi->intel_alh_id); if (ret) goto error; diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h index e4cc1d3804ff..38b7c125fb10 100644 --- a/drivers/soundwire/intel.h +++ b/drivers/soundwire/intel.h @@ -14,7 +14,7 @@ * @alh: ALH (Audio Link Hub) pointer * @irq: Interrupt line * @ops: Shim callback ops - * @arg: Shim callback ops argument + * @dev: device implementing hw_params and free callbacks */ struct sdw_intel_link_res { struct platform_device *pdev; @@ -24,7 +24,7 @@ struct sdw_intel_link_res { void __iomem *alh; int irq; const struct sdw_intel_ops *ops; - void *arg; + struct device *dev; }; #endif /* __SDW_INTEL_LOCAL_H */ diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c index bc739a38916d..4b769409f6f8 100644 --- a/drivers/soundwire/intel_init.c +++ b/drivers/soundwire/intel_init.c @@ -119,6 +119,7 @@ static struct sdw_intel_ctx link->alh = res->mmio_base + SDW_ALH_BASE; link->ops = res->ops; + link->dev = res->dev; memset(&pdevinfo, 0, sizeof(pdevinfo)); diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 034eca8df748..3ccb38d48eef 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -4,15 +4,39 @@ #ifndef __SDW_INTEL_H #define __SDW_INTEL_H +/** + * struct sdw_intel_stream_params_data: configuration passed during + * the @params_stream callback, e.g. for interaction with DSP + * firmware. + */ +struct sdw_intel_stream_params_data { + struct snd_pcm_substream *substream; + struct snd_soc_dai *dai; + struct snd_pcm_hw_params *hw_params; + int link_id; + int alh_stream_id; +}; + +/** + * struct sdw_intel_stream_free_data: configuration passed during + * the @free_stream callback, e.g. for interaction with DSP + * firmware. + */ +struct sdw_intel_stream_free_data { + struct snd_pcm_substream *substream; + struct snd_soc_dai *dai; + int link_id; +}; + /** * struct sdw_intel_ops: Intel audio driver callback ops * - * @config_stream: configure the stream with the hw_params - * the first argument containing the context is mandatory */ struct sdw_intel_ops { - int (*config_stream)(void *arg, void *substream, - void *dai, void *hw_params, int stream_num); + int (*params_stream)(struct device *dev, + struct sdw_intel_stream_params_data *params_data); + int (*free_stream)(struct device *dev, + struct sdw_intel_stream_free_data *free_data); }; /** -- cgit v1.2.3 From 6cd1d670bee641d5d10b11d58c7c99ac1ddf8068 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 11 Dec 2019 19:45:03 -0600 Subject: soundwire: intel: update headers for interrupts The existing use of 6 handlers is problematic in MSI mode. Update headers so that all shared interrupts can be handled with a single handler. Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 3ccb38d48eef..2ce3e9ecc4b6 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -4,6 +4,8 @@ #ifndef __SDW_INTEL_H #define __SDW_INTEL_H +#include + /** * struct sdw_intel_stream_params_data: configuration passed during * the @params_stream callback, e.g. for interaction with DSP @@ -127,4 +129,6 @@ void sdw_intel_exit(struct sdw_intel_ctx *ctx); void sdw_intel_enable_irq(void __iomem *mmio_base, bool enable); +irqreturn_t sdw_intel_thread(int irq, void *dev_id); + #endif -- cgit v1.2.3 From eae0b60d64834c75a460d96b1d1e0e187381e341 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 11 Dec 2019 19:45:04 -0600 Subject: soundwire: intel: add link_list to handle interrupts with a single thread In MSI mode, the use of separate handlers and threads for the Intel IPC, stream and SoundWire shared interrupt leads to timeouts and lost interrupts. The solution is to merge all interrupt handling across all links with a single thread function. The use of a linked list enables this thread function to walk through all contexts and figure out which link needs attention. Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 2ce3e9ecc4b6..2a56180bc9dc 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -70,6 +70,7 @@ struct sdw_intel_link_res; * @handle: ACPI parent handle * @links: information for each link (controller-specific and kept * opaque here) + * @link_list: list to handle interrupts across all links */ struct sdw_intel_ctx { int count; @@ -77,6 +78,7 @@ struct sdw_intel_ctx { u32 link_mask; acpi_handle handle; struct sdw_intel_link_res *links; + struct list_head link_list; }; /** -- cgit v1.2.3 From 905b5a81afe15e8252e5892b8ca1ff1c1adfb79d Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 11 Dec 2019 19:45:05 -0600 Subject: soundwire: intel: add prototype for WAKEEN interrupt processing In ClockStop mode, the PCI device will be notified of a wake, which will be handled from an interrupt thread. Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-10-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 2a56180bc9dc..073121c49695 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -122,6 +122,8 @@ struct sdw_intel_res { int sdw_intel_acpi_scan(acpi_handle *parent_handle, struct sdw_intel_acpi_info *info); +void sdw_intel_process_wakeen_event(struct sdw_intel_ctx *ctx); + struct sdw_intel_ctx * sdw_intel_probe(struct sdw_intel_res *res); -- cgit v1.2.3 From 4da0680f24c9af2de8406ded68c4ef967f448de3 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:45:06 -0600 Subject: soundwire: intel: add mutex for shared SHIM register access Some of the Intel SoundWire SHIM registers contain fields for different links. Without protection, the master drivers for the different links will access these shared registers, leading to invalid configurations and timeouts (specifically when changing CPA/SPA power-related registers and polling for the changes to be applied). A mutex is added to make sure all rmw access to those registers are serialized. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-11-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 073121c49695..45fa6d93197f 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -71,6 +71,7 @@ struct sdw_intel_link_res; * @links: information for each link (controller-specific and kept * opaque here) * @link_list: list to handle interrupts across all links + * @shim_lock: mutex to handle concurrent rmw access to shared SHIM registers. */ struct sdw_intel_ctx { int count; @@ -79,6 +80,7 @@ struct sdw_intel_ctx { acpi_handle handle; struct sdw_intel_link_res *links; struct list_head link_list; + struct mutex shim_lock; /* lock for access to shared SHIM registers */ }; /** -- cgit v1.2.3 From 09f6a72d014386939d21899921dd379006471a4b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 11 Dec 2019 19:45:07 -0600 Subject: soundwire: intel: add clock stop quirks Due to power rail dependencies, the SoundWire Master driver cannot make decisions on its own when entering pm runtime suspend. Add quirk mask for each link, so that the SOF parent driver can inform the SoundWire master driver of the desired behavior: a) leave clock on b) power-off instead of clock stop c) power-off if all devices cannot generate wakes d) force bus reset on clock restart Note that for now the interface with the SOF driver relies on a single mask for all links. If needed, the interface might be modified at a later point to provide more freedom. The code at the lower level does not assume any commonality between links. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191212014507.28050-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul --- include/linux/soundwire/sdw_intel.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h index 45fa6d93197f..93b83bdf8035 100644 --- a/include/linux/soundwire/sdw_intel.h +++ b/include/linux/soundwire/sdw_intel.h @@ -59,6 +59,40 @@ struct sdw_intel_acpi_info { struct sdw_intel_link_res; +/* Intel clock-stop/pm_runtime quirk definitions */ + +/* + * Force the clock to remain on during pm_runtime suspend. This might + * be needed if Slave devices do not have an alternate clock source or + * if the latency requirements are very strict. + */ +#define SDW_INTEL_CLK_STOP_NOT_ALLOWED BIT(0) + +/* + * Stop the bus during pm_runtime suspend. If set, a complete bus + * reset and re-enumeration will be performed when the bus + * restarts. This mode shall not be used if Slave devices can generate + * in-band wakes. + */ +#define SDW_INTEL_CLK_STOP_TEARDOWN BIT(1) + +/* + * Stop the bus during pm_suspend if Slaves are not wake capable + * (e.g. speaker amplifiers). The clock-stop mode is typically + * slightly higher power than when the IP is completely powered-off. + */ +#define SDW_INTEL_CLK_STOP_WAKE_CAPABLE_ONLY BIT(2) + +/* + * Require a bus reset (and complete re-enumeration) when exiting + * clock stop modes. This may be needed if the controller power was + * turned off and all context lost. This quirk shall not be used if a + * Slave device needs to remain enumerated and keep its context, + * e.g. to provide the reasons for the wake, report acoustic events or + * pass a history buffer. + */ +#define SDW_INTEL_CLK_STOP_BUS_RESET BIT(3) + /** * struct sdw_intel_ctx - context allocated by the controller * driver probe @@ -97,6 +131,8 @@ struct sdw_intel_ctx { * @link_mask: bit-wise mask listing links selected by the DSP driver * This mask may be a subset of the one reported by the controller since * machine-specific quirks are handled in the DSP driver. + * @clock_stop_quirks: mask array of possible behaviors requested by the + * DSP driver. The quirks are common for all links for now. */ struct sdw_intel_res { int count; @@ -107,6 +143,7 @@ struct sdw_intel_res { const struct sdw_intel_ops *ops; struct device *dev; u32 link_mask; + u32 clock_stop_quirks; }; /* -- cgit v1.2.3 From 341a79ee8b080ed41dccc13250fcffc2c2028ccd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 12 Dec 2019 09:05:18 +0100 Subject: ALSA: hda: tegra: Fix unused variable compile warning Forgot to remove the variable declaration as well in the last commit. sound/pci/hda/hda_tegra.c: In function 'hda_tegra_runtime_suspend': sound/pci/hda/hda_tegra.c:169:19: warning: unused variable 'bus' [-Wunused-variable] Fixes: f36da9406e66 ("ALSA: hda: Support PCM sync_stop") Reported-by: Stephen Rothwell Link: https://lore.kernel.org/r/20191212080518.6522-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_tegra.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index fc2e0a294bc1..269f242fcbfd 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -166,7 +166,6 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev) struct snd_card *card = dev_get_drvdata(dev); struct azx *chip = card->private_data; struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); - struct hdac_bus *bus = azx_bus(chip); if (chip && chip->running) { azx_stop_chip(chip); -- cgit v1.2.3 From bf523463d8c38cd92424ed011b90769c29ef99ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 11 Dec 2019 18:20:18 +0100 Subject: ASoC: mediatek: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, as well as the superfluous snd_pcm_lib_preallocate_free_for_all() call. As of the result, hw_free and pcm_destruct ops became empty and got removed. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191211172019.23206-1-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 6 +----- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 12 ++---------- sound/soc/mediatek/common/mtk-afe-platform-driver.h | 2 -- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 1 - sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 1 - 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index e761cb66be5d..8f314e15ce73 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -129,10 +129,6 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, unsigned int rate = params_rate(params); snd_pcm_format_t format = params_format(params); - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) - return ret; - if (afe->request_dram_resource) afe->request_dram_resource(afe->dev); @@ -193,7 +189,7 @@ int mtk_afe_fe_hw_free(struct snd_pcm_substream *substream, if (afe->release_dram_resource) afe->release_dram_resource(afe->dev); - return snd_pcm_lib_free_pages(substream); + return 0; } EXPORT_SYMBOL_GPL(mtk_afe_fe_hw_free); diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index 86c09165fae1..44dfef713905 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -120,24 +120,16 @@ int mtk_afe_pcm_new(struct snd_soc_component *component, struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); size = afe->mtk_afe_hardware->buffer_bytes_max; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - afe->dev, size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + afe->dev, size, size); return 0; } EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); -void mtk_afe_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} -EXPORT_SYMBOL_GPL(mtk_afe_pcm_free); - const struct snd_soc_component_driver mtk_afe_pcm_platform = { .name = AFE_PCM_NAME, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, }; EXPORT_SYMBOL_GPL(mtk_afe_pcm_platform); diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h index e550d11568c3..fcc923b88f12 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h @@ -21,8 +21,6 @@ snd_pcm_uframes_t mtk_afe_pcm_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream); int mtk_afe_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd); -void mtk_afe_pcm_free(struct snd_soc_component *component, - struct snd_pcm *pcm); int mtk_afe_combine_sub_dai(struct mtk_base_afe *afe); int mtk_afe_add_sub_dai_control(struct snd_soc_component *component); diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c index cd7c5fabc605..378bfc16ef52 100644 --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c @@ -714,7 +714,6 @@ static const struct snd_soc_component_driver mt6797_afe_component = { .probe = mt6797_afe_component_probe, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, }; static int mt6797_dai_memif_register(struct mtk_base_afe *afe) diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c index f6a0fadeb3cc..6e2270bbb10e 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1052,7 +1052,6 @@ static const struct snd_soc_component_driver mt8183_afe_component = { .probe = mt8183_afe_component_probe, .pointer = mtk_afe_pcm_pointer, .pcm_construct = mtk_afe_pcm_new, - .pcm_destruct = mtk_afe_pcm_free, }; static int mt8183_dai_memif_register(struct mtk_base_afe *afe) -- cgit v1.2.3 From 57e960f0020ec46db277426762ba5ffe77e03e3c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 11 Dec 2019 18:20:19 +0100 Subject: ASoC: SOF: Use managed buffer allocation Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Pierre-Louis Bossart Cc: Ranjani Sridharan Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191211172019.23206-2-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/sof/pcm.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 67ba317942d3..86829e5bd62d 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -118,20 +118,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, memset(&pcm, 0, sizeof(pcm)); - /* allocate audio buffer pages */ - ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (ret < 0) { - dev_err(component->dev, "error: could not allocate %d bytes for PCM %d\n", - params_buffer_bytes(params), spcm->pcm.pcm_id); - return ret; - } - if (ret) { - /* - * ret == 1 means the buffer is changed - * create compressed page table for audio firmware - * ret == 0 means the buffer is not changed - * so no need to regenerate the page table - */ + /* create compressed page table for audio firmware */ + if (runtime->buffer_changed) { ret = create_page_table(component, substream, runtime->dma_area, runtime->dma_bytes); if (ret < 0) @@ -259,8 +247,6 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, err = ret; } - snd_pcm_lib_free_pages(substream); - cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work); ret = snd_sof_pcm_platform_hw_free(sdev, substream); @@ -596,10 +582,10 @@ static int sof_pcm_new(struct snd_soc_component *component, "spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n", caps->name, caps->buffer_size_min, caps->buffer_size_max); - snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream, - SNDRV_DMA_TYPE_DEV_SG, sdev->dev, - le32_to_cpu(caps->buffer_size_min), - le32_to_cpu(caps->buffer_size_max)); + snd_pcm_set_managed_buffer(pcm->streams[stream].substream, + SNDRV_DMA_TYPE_DEV_SG, sdev->dev, + le32_to_cpu(caps->buffer_size_min), + le32_to_cpu(caps->buffer_size_max)); capture: stream = SNDRV_PCM_STREAM_CAPTURE; @@ -614,10 +600,10 @@ capture: "spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n", caps->name, caps->buffer_size_min, caps->buffer_size_max); - snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream, - SNDRV_DMA_TYPE_DEV_SG, sdev->dev, - le32_to_cpu(caps->buffer_size_min), - le32_to_cpu(caps->buffer_size_max)); + snd_pcm_set_managed_buffer(pcm->streams[stream].substream, + SNDRV_DMA_TYPE_DEV_SG, sdev->dev, + le32_to_cpu(caps->buffer_size_min), + le32_to_cpu(caps->buffer_size_max)); return 0; } -- cgit v1.2.3 From 07094ae6f9527279de6fd0c59e88f6d0423585b1 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Tue, 24 Apr 2018 20:06:13 +0800 Subject: ALSA: Avoid using timespec for struct snd_timer_tread The struct snd_timer_tread will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Since the struct snd_timer_tread is passed through read() rather than ioctl(), and the read syscall has no command number that lets us pick between the 32-bit or 64-bit version of this structure. Thus we introduced one new command SNDRV_TIMER_IOCTL_TREAD64 and new struct snd_timer_tread64 replacing timespec with s64 type to handle 64bit time_t. That means we will set tu->tread = TREAD_FORMAT_64BIT when user space has a 64bit time_t, then we will copy to user with struct snd_timer_tread64. Otherwise we will use 32bit time_t variables when copying to user. Moreover this patch replaces timespec type with timespec64 type and related y2038 safe APIs. Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 15 ++++- sound/core/timer.c | 150 +++++++++++++++++++++++++++++++++----------- sound/core/timer_compat.c | 5 +- 3 files changed, 131 insertions(+), 39 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index e0ada33afa1e..ad86c5a7a1e2 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -783,7 +783,7 @@ struct snd_timer_status { #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) -#define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int) +#define SNDRV_TIMER_IOCTL_TREAD_OLD _IOW('T', 0x02, int) #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo) #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams) #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus) @@ -796,6 +796,15 @@ struct snd_timer_status { #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1) #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2) #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3) +#define SNDRV_TIMER_IOCTL_TREAD64 _IOW('T', 0xa4, int) + +#if __BITS_PER_LONG == 64 +#define SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_TREAD_OLD +#else +#define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \ + SNDRV_TIMER_IOCTL_TREAD_OLD : \ + SNDRV_TIMER_IOCTL_TREAD64) +#endif struct snd_timer_read { unsigned int resolution; @@ -821,11 +830,15 @@ enum { SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10, }; +#ifndef __KERNEL__ struct snd_timer_tread { int event; + __time_pad pad1; struct timespec tstamp; unsigned int val; + __time_pad pad2; }; +#endif /**************************************************************************** * * diff --git a/sound/core/timer.c b/sound/core/timer.c index d2f69039f941..4cfd8e691903 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -44,6 +44,28 @@ MODULE_PARM_DESC(timer_tstamp_monotonic, "Use posix monotonic clock source for t MODULE_ALIAS_CHARDEV(CONFIG_SND_MAJOR, SNDRV_MINOR_TIMER); MODULE_ALIAS("devname:snd/timer"); +enum timer_tread_format { + TREAD_FORMAT_NONE = 0, + TREAD_FORMAT_TIME64, + TREAD_FORMAT_TIME32, +}; + +struct snd_timer_tread32 { + int event; + s32 tstamp_sec; + s32 tstamp_nsec; + unsigned int val; +}; + +struct snd_timer_tread64 { + int event; + u8 pad1[4]; + s64 tstamp_sec; + s64 tstamp_nsec; + unsigned int val; + u8 pad2[4]; +}; + struct snd_timer_user { struct snd_timer_instance *timeri; int tread; /* enhanced read with timestamps and events */ @@ -55,7 +77,7 @@ struct snd_timer_user { int queue_size; bool disconnected; struct snd_timer_read *queue; - struct snd_timer_tread *tqueue; + struct snd_timer_tread64 *tqueue; spinlock_t qlock; unsigned long last_resolution; unsigned int filter; @@ -1329,7 +1351,7 @@ static void snd_timer_user_interrupt(struct snd_timer_instance *timeri, } static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, - struct snd_timer_tread *tread) + struct snd_timer_tread64 *tread) { if (tu->qused >= tu->queue_size) { tu->overrun++; @@ -1346,7 +1368,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, unsigned long resolution) { struct snd_timer_user *tu = timeri->callback_data; - struct snd_timer_tread r1; + struct snd_timer_tread64 r1; unsigned long flags; if (event >= SNDRV_TIMER_EVENT_START && @@ -1356,7 +1378,8 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, return; memset(&r1, 0, sizeof(r1)); r1.event = event; - r1.tstamp = timespec64_to_timespec(*tstamp); + r1.tstamp_sec = tstamp->tv_sec; + r1.tstamp_nsec = tstamp->tv_nsec; r1.val = resolution; spin_lock_irqsave(&tu->qlock, flags); snd_timer_user_append_to_tqueue(tu, &r1); @@ -1378,7 +1401,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, unsigned long ticks) { struct snd_timer_user *tu = timeri->callback_data; - struct snd_timer_tread *r, r1; + struct snd_timer_tread64 *r, r1; struct timespec64 tstamp; int prev, append = 0; @@ -1399,7 +1422,8 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && tu->last_resolution != resolution) { r1.event = SNDRV_TIMER_EVENT_RESOLUTION; - r1.tstamp = timespec64_to_timespec(tstamp); + r1.tstamp_sec = tstamp.tv_sec; + r1.tstamp_nsec = tstamp.tv_nsec; r1.val = resolution; snd_timer_user_append_to_tqueue(tu, &r1); tu->last_resolution = resolution; @@ -1413,14 +1437,16 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, prev = tu->qtail == 0 ? tu->queue_size - 1 : tu->qtail - 1; r = &tu->tqueue[prev]; if (r->event == SNDRV_TIMER_EVENT_TICK) { - r->tstamp = timespec64_to_timespec(tstamp); + r->tstamp_sec = tstamp.tv_sec; + r->tstamp_nsec = tstamp.tv_nsec; r->val += ticks; append++; goto __wake; } } r1.event = SNDRV_TIMER_EVENT_TICK; - r1.tstamp = timespec64_to_timespec(tstamp); + r1.tstamp_sec = tstamp.tv_sec; + r1.tstamp_nsec = tstamp.tv_nsec; r1.val = ticks; snd_timer_user_append_to_tqueue(tu, &r1); append++; @@ -1435,7 +1461,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, static int realloc_user_queue(struct snd_timer_user *tu, int size) { struct snd_timer_read *queue = NULL; - struct snd_timer_tread *tqueue = NULL; + struct snd_timer_tread64 *tqueue = NULL; if (tu->tread) { tqueue = kcalloc(size, sizeof(*tqueue), GFP_KERNEL); @@ -1874,11 +1900,11 @@ static int snd_timer_user_params(struct file *file, tu->qhead = tu->qtail = tu->qused = 0; if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { if (tu->tread) { - struct snd_timer_tread tread; + struct snd_timer_tread64 tread; memset(&tread, 0, sizeof(tread)); tread.event = SNDRV_TIMER_EVENT_EARLY; - tread.tstamp.tv_sec = 0; - tread.tstamp.tv_nsec = 0; + tread.tstamp_sec = 0; + tread.tstamp_nsec = 0; tread.val = 0; snd_timer_user_append_to_tqueue(tu, &tread); } else { @@ -2008,6 +2034,36 @@ static int snd_timer_user_pause(struct file *file) return 0; } +static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu, + unsigned int cmd, bool compat) +{ + int __user *p = argp; + int xarg, old_tread; + + if (tu->timeri) /* too late */ + return -EBUSY; + if (get_user(xarg, p)) + return -EFAULT; + + old_tread = tu->tread; + + if (!xarg) + tu->tread = TREAD_FORMAT_NONE; + else if (cmd == SNDRV_TIMER_IOCTL_TREAD64 || + (IS_ENABLED(CONFIG_64BIT) && !compat)) + tu->tread = TREAD_FORMAT_TIME64; + else + tu->tread = TREAD_FORMAT_TIME32; + + if (tu->tread != old_tread && + realloc_user_queue(tu, tu->queue_size) < 0) { + tu->tread = old_tread; + return -ENOMEM; + } + + return 0; +} + enum { SNDRV_TIMER_IOCTL_START_OLD = _IO('T', 0x20), SNDRV_TIMER_IOCTL_STOP_OLD = _IO('T', 0x21), @@ -2016,7 +2072,7 @@ enum { }; static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + unsigned long arg, bool compat) { struct snd_timer_user *tu; void __user *argp = (void __user *)arg; @@ -2028,23 +2084,9 @@ static long __snd_timer_user_ioctl(struct file *file, unsigned int cmd, return put_user(SNDRV_TIMER_VERSION, p) ? -EFAULT : 0; case SNDRV_TIMER_IOCTL_NEXT_DEVICE: return snd_timer_user_next_device(argp); - case SNDRV_TIMER_IOCTL_TREAD: - { - int xarg, old_tread; - - if (tu->timeri) /* too late */ - return -EBUSY; - if (get_user(xarg, p)) - return -EFAULT; - old_tread = tu->tread; - tu->tread = xarg ? 1 : 0; - if (tu->tread != old_tread && - realloc_user_queue(tu, tu->queue_size) < 0) { - tu->tread = old_tread; - return -ENOMEM; - } - return 0; - } + case SNDRV_TIMER_IOCTL_TREAD_OLD: + case SNDRV_TIMER_IOCTL_TREAD64: + return snd_timer_user_tread(argp, tu, cmd, compat); case SNDRV_TIMER_IOCTL_GINFO: return snd_timer_user_ginfo(file, argp); case SNDRV_TIMER_IOCTL_GPARAMS: @@ -2084,7 +2126,7 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, long ret; mutex_lock(&tu->ioctl_lock); - ret = __snd_timer_user_ioctl(file, cmd, arg); + ret = __snd_timer_user_ioctl(file, cmd, arg, false); mutex_unlock(&tu->ioctl_lock); return ret; } @@ -2100,13 +2142,29 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on) static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, size_t count, loff_t *offset) { + struct snd_timer_tread64 *tread; + struct snd_timer_tread32 tread32; struct snd_timer_user *tu; long result = 0, unit; int qhead; int err = 0; tu = file->private_data; - unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); + switch (tu->tread) { + case TREAD_FORMAT_TIME64: + unit = sizeof(struct snd_timer_tread64); + break; + case TREAD_FORMAT_TIME32: + unit = sizeof(struct snd_timer_tread32); + break; + case TREAD_FORMAT_NONE: + unit = sizeof(struct snd_timer_read); + break; + default: + WARN_ONCE(1, "Corrupt snd_timer_user\n"); + return -ENOTSUPP; + } + mutex_lock(&tu->ioctl_lock); spin_lock_irq(&tu->qlock); while ((long)count - result >= unit) { @@ -2145,14 +2203,34 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, tu->qused--; spin_unlock_irq(&tu->qlock); - if (tu->tread) { - if (copy_to_user(buffer, &tu->tqueue[qhead], - sizeof(struct snd_timer_tread))) + tread = &tu->tqueue[qhead]; + + switch (tu->tread) { + case TREAD_FORMAT_TIME64: + if (copy_to_user(buffer, tread, + sizeof(struct snd_timer_tread64))) err = -EFAULT; - } else { + break; + case TREAD_FORMAT_TIME32: + memset(&tread32, 0, sizeof(tread32)); + tread32 = (struct snd_timer_tread32) { + .event = tread->event, + .tstamp_sec = tread->tstamp_sec, + .tstamp_sec = tread->tstamp_nsec, + .val = tread->val, + }; + + if (copy_to_user(buffer, &tread32, sizeof(tread32))) + err = -EFAULT; + break; + case TREAD_FORMAT_NONE: if (copy_to_user(buffer, &tu->queue[qhead], sizeof(struct snd_timer_read))) err = -EFAULT; + break; + default: + err = -ENOTSUPP; + break; } spin_lock_irq(&tu->qlock); diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index 20eef5bc304b..0103d16f6f9f 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c @@ -83,7 +83,8 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, switch (cmd) { case SNDRV_TIMER_IOCTL_PVERSION: - case SNDRV_TIMER_IOCTL_TREAD: + case SNDRV_TIMER_IOCTL_TREAD_OLD: + case SNDRV_TIMER_IOCTL_TREAD64: case SNDRV_TIMER_IOCTL_GINFO: case SNDRV_TIMER_IOCTL_GSTATUS: case SNDRV_TIMER_IOCTL_SELECT: @@ -97,7 +98,7 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, case SNDRV_TIMER_IOCTL_PAUSE: case SNDRV_TIMER_IOCTL_PAUSE_OLD: case SNDRV_TIMER_IOCTL_NEXT_DEVICE: - return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp); + return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp, true); case SNDRV_TIMER_IOCTL_GPARAMS32: return snd_timer_user_gparams_compat(file, argp); case SNDRV_TIMER_IOCTL_INFO32: -- cgit v1.2.3 From 09d94175dbeac12d38b1599a02c7000a5e51b4cb Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 24 Apr 2018 20:06:14 +0800 Subject: ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.c This is a preparation patch, moving the compat handler for snd_pcm_ioctl_sync_ptr_compat from pcm_compat.c to pcm_native.c. No other changes are indented. Signed-off-by: Arnd Bergmann Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- sound/core/pcm_compat.c | 98 ----------------------------------------------- sound/core/pcm_native.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 2671658442ea..6a2e5ea145e6 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -83,19 +83,6 @@ struct snd_pcm_sw_params32 { unsigned char reserved[56]; }; -/* recalcuate the boundary within 32bit */ -static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) -{ - snd_pcm_uframes_t boundary; - - if (! runtime->buffer_size) - return 0; - boundary = runtime->buffer_size; - while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) - boundary *= 2; - return boundary; -} - static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream, struct snd_pcm_sw_params32 __user *src) { @@ -388,91 +375,6 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, return err; } - -struct snd_pcm_mmap_status32 { - s32 state; - s32 pad1; - u32 hw_ptr; - struct compat_timespec tstamp; - s32 suspended_state; - struct compat_timespec audio_tstamp; -} __attribute__((packed)); - -struct snd_pcm_mmap_control32 { - u32 appl_ptr; - u32 avail_min; -}; - -struct snd_pcm_sync_ptr32 { - u32 flags; - union { - struct snd_pcm_mmap_status32 status; - unsigned char reserved[64]; - } s; - union { - struct snd_pcm_mmap_control32 control; - unsigned char reserved[64]; - } c; -} __attribute__((packed)); - -static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, - struct snd_pcm_sync_ptr32 __user *src) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - volatile struct snd_pcm_mmap_status *status; - volatile struct snd_pcm_mmap_control *control; - u32 sflags; - struct snd_pcm_mmap_control scontrol; - struct snd_pcm_mmap_status sstatus; - snd_pcm_uframes_t boundary; - int err; - - if (snd_BUG_ON(!runtime)) - return -EINVAL; - - if (get_user(sflags, &src->flags) || - get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - get_user(scontrol.avail_min, &src->c.control.avail_min)) - return -EFAULT; - if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { - err = snd_pcm_hwsync(substream); - if (err < 0) - return err; - } - status = runtime->status; - control = runtime->control; - boundary = recalculate_boundary(runtime); - if (! boundary) - boundary = 0x7fffffff; - snd_pcm_stream_lock_irq(substream); - /* FIXME: we should consider the boundary for the sync from app */ - if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) - control->appl_ptr = scontrol.appl_ptr; - else - scontrol.appl_ptr = control->appl_ptr % boundary; - if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) - control->avail_min = scontrol.avail_min; - else - scontrol.avail_min = control->avail_min; - sstatus.state = status->state; - sstatus.hw_ptr = status->hw_ptr % boundary; - sstatus.tstamp = status->tstamp; - sstatus.suspended_state = status->suspended_state; - sstatus.audio_tstamp = status->audio_tstamp; - snd_pcm_stream_unlock_irq(substream); - if (put_user(sstatus.state, &src->s.status.state) || - put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || - compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || - put_user(sstatus.suspended_state, &src->s.status.suspended_state) || - compat_put_timespec(&sstatus.audio_tstamp, - &src->s.status.audio_tstamp) || - put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || - put_user(scontrol.avail_min, &src->c.control.avail_min)) - return -EFAULT; - - return 0; -} - #ifdef CONFIG_X86_X32 /* X32 ABI has 64bit timespec and 64bit alignment */ struct snd_pcm_mmap_status_x32 { diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ad4cf1e3e3bd..ba0636a2b437 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -4,6 +4,7 @@ * Copyright (c) by Jaroslav Kysela */ +#include #include #include #include @@ -2888,6 +2889,105 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, return 0; } +#ifdef CONFIG_COMPAT +struct snd_pcm_mmap_status32 { + s32 state; + s32 pad1; + u32 hw_ptr; + struct compat_timespec tstamp; + s32 suspended_state; + struct compat_timespec audio_tstamp; +} __attribute__((packed)); + +struct snd_pcm_mmap_control32 { + u32 appl_ptr; + u32 avail_min; +}; + +struct snd_pcm_sync_ptr32 { + u32 flags; + union { + struct snd_pcm_mmap_status32 status; + unsigned char reserved[64]; + } s; + union { + struct snd_pcm_mmap_control32 control; + unsigned char reserved[64]; + } c; +} __attribute__((packed)); + +/* recalcuate the boundary within 32bit */ +static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) +{ + snd_pcm_uframes_t boundary; + + if (! runtime->buffer_size) + return 0; + boundary = runtime->buffer_size; + while (boundary * 2 <= 0x7fffffffUL - runtime->buffer_size) + boundary *= 2; + return boundary; +} + +static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, + struct snd_pcm_sync_ptr32 __user *src) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; + u32 sflags; + struct snd_pcm_mmap_control scontrol; + struct snd_pcm_mmap_status sstatus; + snd_pcm_uframes_t boundary; + int err; + + if (snd_BUG_ON(!runtime)) + return -EINVAL; + + if (get_user(sflags, &src->flags) || + get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + get_user(scontrol.avail_min, &src->c.control.avail_min)) + return -EFAULT; + if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) { + err = snd_pcm_hwsync(substream); + if (err < 0) + return err; + } + status = runtime->status; + control = runtime->control; + boundary = recalculate_boundary(runtime); + if (! boundary) + boundary = 0x7fffffff; + snd_pcm_stream_lock_irq(substream); + /* FIXME: we should consider the boundary for the sync from app */ + if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL)) + control->appl_ptr = scontrol.appl_ptr; + else + scontrol.appl_ptr = control->appl_ptr % boundary; + if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) + control->avail_min = scontrol.avail_min; + else + scontrol.avail_min = control->avail_min; + sstatus.state = status->state; + sstatus.hw_ptr = status->hw_ptr % boundary; + sstatus.tstamp = status->tstamp; + sstatus.suspended_state = status->suspended_state; + sstatus.audio_tstamp = status->audio_tstamp; + snd_pcm_stream_unlock_irq(substream); + if (put_user(sstatus.state, &src->s.status.state) || + put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || + compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.suspended_state, &src->s.status.suspended_state) || + compat_put_timespec(&sstatus.audio_tstamp, + &src->s.status.audio_tstamp) || + put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || + put_user(scontrol.avail_min, &src->c.control.avail_min)) + return -EFAULT; + + return 0; +} +#endif + static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) { struct snd_pcm_runtime *runtime = substream->runtime; -- cgit v1.2.3 From 80fe7430c7085951d1246d83f638cc17e6c0be36 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 24 Apr 2018 20:06:15 +0800 Subject: ALSA: add new 32-bit layout for snd_pcm_mmap_status/control The snd_pcm_mmap_status and snd_pcm_mmap_control interfaces are one of the trickiest areas to get right when moving to 64-bit time_t in user space. The snd_pcm_mmap_status structure layout is incompatible with user space that uses a 64-bit time_t, so we need a new layout for it. Since the SNDRV_PCM_IOCTL_SYNC_PTR ioctl combines it with snd_pcm_mmap_control into snd_pcm_sync_ptr, we need to change those two as well. Both structures are also exported via an mmap() operation on certain architectures, and this suffers from incompatibility between 32-bit and 64-bit user space. As we have to change both structures anyway, this is a good opportunity to fix the mmap() problem as well, so let's standardize on the existing 64-bit layout of the structure where possible. The downside is that we lose mmap() support for existing 32-bit x86 and powerpc applications, adding that would introduce very noticeable runtime overhead and complexity. My assumption here is that not too many people will miss the removed feature, given that: - Almost all x86 and powerpc users these days are on 64-bit kernels, the majority of today's 32-bit users are on architectures that never supported mmap (ARM, MIPS, ...). - It never worked in compat mode (it was intentionally disabled there) - The application already needs to work with a fallback to SNDRV_PCM_IOCTL_SYNC_PTR, which will keep working with both the old and new structure layout. Both the ioctl() and mmap() based interfaces are changed at the same time, as they are based on the same structures. Unlike other interfaces, we change the uapi header to export both the traditional structure and a version that is portable between 32-bit and 64-bit user space code and that corresponds to the existing 64-bit layout. We further check the __USE_TIME_BITS64 macro that will be defined by future C library versions whenever we use the new time_t definition, so any existing user space source code will not see any changes until it gets rebuilt against a new C library. However, the new structures are all visible in addition to the old ones, allowing applications to explicitly request the new structures. In order to detect the difference between the old snd_pcm_mmap_status and the new __snd_pcm_mmap_status64 structure from the ioctl command number, we rely on one quirk in the structure definition: snd_pcm_mmap_status must be aligned to alignof(time_t), which leads the compiler to insert four bytes of padding in struct snd_pcm_sync_ptr after 'flags' and a corresponding change in the size of snd_pcm_sync_ptr itself. On x86-32 (and only there), the compiler doesn't use 64-bit alignment in structure, so I'm adding an explicit pad in the structure that has no effect on the existing 64-bit architectures but ensures that the layout matches for x86. The snd_pcm_uframes_t type compatibility requires another hack: we can't easily make that 64 bit wide, so I leave the type as 'unsigned long', but add padding before and after it, to ensure that the data is properly aligned to the respective 64-bit field in the in-kernel structure. For the SNDRV_PCM_MMAP_OFFSET_STATUS/CONTROL constants that are used as the virtual file offset in the mmap() function, we also have to introduce new constants that depend on hte __USE_TIME_BITS64 macro: The existing macros are renamed to SNDRV_PCM_MMAP_OFFSET_STATUS_OLD and SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, they continue to work fine on 64-bit architectures, but stop working on native 32-bit user space. The replacement _NEW constants are now used by default for user space built with __USE_TIME_BITS64, those now work on all new kernels for x86, ppc and alpha (32 and 64 bit, native and compat). It might be a good idea for a future alsa-lib to support both the _OLD and _NEW macros and use the corresponding structures directly. Unmodified alsa-lib source code will retain the current behavior, so it will no longer be able to use mmap() for the status/control structures on 32-bit systems, until either the C library gets updated to 64-bit time_t or alsa-lib gets updated to support both mmap() layouts. Co-developed-with: Baolin Wang Signed-off-by: Baolin Wang Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 110 ++++++++++++++++++++++++++++++++++++++++---- sound/core/pcm_compat.c | 30 ++++++------ sound/core/pcm_lib.c | 10 ++-- sound/core/pcm_native.c | 38 +++++++++------ 4 files changed, 147 insertions(+), 41 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index ad86c5a7a1e2..df9983e7ead5 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -35,6 +35,8 @@ #include #endif +#include + /* * protocol version */ @@ -301,7 +303,9 @@ typedef int __bitwise snd_pcm_subformat_t; #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ - +#if (__BITS_PER_LONG == 32 && defined(__USE_TIME_BITS64)) || defined __KERNEL__ +#define __SND_STRUCT_TIME64 +#endif typedef int __bitwise snd_pcm_state_t; #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */ @@ -317,8 +321,17 @@ typedef int __bitwise snd_pcm_state_t; enum { SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, - SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000, - SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, + SNDRV_PCM_MMAP_OFFSET_STATUS_OLD = 0x80000000, + SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD = 0x81000000, + SNDRV_PCM_MMAP_OFFSET_STATUS_NEW = 0x82000000, + SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW = 0x83000000, +#ifdef __SND_STRUCT_TIME64 + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_NEW, + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW, +#else + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_OLD, + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, +#endif }; union snd_pcm_sync_id { @@ -480,16 +493,46 @@ struct snd_pcm_status { }; #endif -struct snd_pcm_mmap_status { +/* + * For mmap operations, we need the 64-bit layout, both for compat mode, + * and for y2038 compatibility. For 64-bit applications, the two definitions + * are identical, so we keep the traditional version. + */ +#ifdef __SND_STRUCT_TIME64 +#define __snd_pcm_mmap_status64 snd_pcm_mmap_status +#define __snd_pcm_mmap_control64 snd_pcm_mmap_control +#define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr +#ifdef __KERNEL__ +#define __snd_timespec64 __kernel_timespec +#else +#define __snd_timespec64 timespec +#endif +struct __snd_timespec { + __s32 tv_sec; + __s32 tv_nsec; +}; +#else +#define __snd_pcm_mmap_status snd_pcm_mmap_status +#define __snd_pcm_mmap_control snd_pcm_mmap_control +#define __snd_pcm_sync_ptr snd_pcm_sync_ptr +#define __snd_timespec timespec +struct __snd_timespec64 { + __s64 tv_sec; + __s64 tv_nsec; +}; + +#endif + +struct __snd_pcm_mmap_status { snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ int pad1; /* Needed for 64 bit alignment */ snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ - struct timespec tstamp; /* Timestamp */ + struct __snd_timespec tstamp; /* Timestamp */ snd_pcm_state_t suspended_state; /* RO: suspended stream state */ - struct timespec audio_tstamp; /* from sample counter or wall clock */ + struct __snd_timespec audio_tstamp; /* from sample counter or wall clock */ }; -struct snd_pcm_mmap_control { +struct __snd_pcm_mmap_control { snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ }; @@ -498,14 +541,59 @@ struct snd_pcm_mmap_control { #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */ #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */ -struct snd_pcm_sync_ptr { +struct __snd_pcm_sync_ptr { unsigned int flags; union { - struct snd_pcm_mmap_status status; + struct __snd_pcm_mmap_status status; + unsigned char reserved[64]; + } s; + union { + struct __snd_pcm_mmap_control control; + unsigned char reserved[64]; + } c; +}; + +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) +typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +typedef char __pad_after_uframe[0]; +#endif + +#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) +typedef char __pad_before_uframe[0]; +typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; +#endif + +struct __snd_pcm_mmap_status64 { + __s32 state; /* RO: state - SNDRV_PCM_STATE_XXXX */ + __u32 pad1; /* Needed for 64 bit alignment */ + __pad_before_uframe __pad1; + snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ + __pad_after_uframe __pad2; + struct __snd_timespec64 tstamp; /* Timestamp */ + __s32 suspended_state; /* RO: suspended stream state */ + __u32 pad3; /* Needed for 64 bit alignment */ + struct __snd_timespec64 audio_tstamp; /* sample counter or wall clock */ +}; + +struct __snd_pcm_mmap_control64 { + __pad_before_uframe __pad1; + snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ + __pad_before_uframe __pad2; + + __pad_before_uframe __pad3; + snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ + __pad_after_uframe __pad4; +}; + +struct __snd_pcm_sync_ptr64 { + __u32 flags; + __u32 pad1; + union { + struct __snd_pcm_mmap_status64 status; unsigned char reserved[64]; } s; union { - struct snd_pcm_mmap_control control; + struct __snd_pcm_mmap_control64 control; unsigned char reserved[64]; } c; }; @@ -590,6 +678,8 @@ enum { #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status) #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) +#define __SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct __snd_pcm_sync_ptr) +#define __SNDRV_PCM_IOCTL_SYNC_PTR64 _IOWR('A', 0x23, struct __snd_pcm_sync_ptr64) #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status) #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 6a2e5ea145e6..967c689fb8da 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -178,8 +178,6 @@ struct compat_snd_pcm_status64 { unsigned char reserved[52-4*sizeof(s64)]; } __packed; -#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst)) - static int snd_pcm_status_user_compat64(struct snd_pcm_substream *substream, struct compat_snd_pcm_status64 __user *src, bool ext) @@ -382,10 +380,12 @@ struct snd_pcm_mmap_status_x32 { s32 pad1; u32 hw_ptr; u32 pad2; /* alignment */ - struct timespec tstamp; + s64 tstamp_sec; + s64 tstamp_nsec; s32 suspended_state; s32 pad3; - struct timespec audio_tstamp; + s64 audio_tstamp_sec; + s64 audio_tstamp_nsec; } __packed; struct snd_pcm_mmap_control_x32 { @@ -453,9 +453,11 @@ static int snd_pcm_ioctl_sync_ptr_x32(struct snd_pcm_substream *substream, snd_pcm_stream_unlock_irq(substream); if (put_user(sstatus.state, &src->s.status.state) || put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || - put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp_sec) || + put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp_nsec) || put_user(sstatus.suspended_state, &src->s.status.suspended_state) || - put_timespec(&sstatus.audio_tstamp, &src->s.status.audio_tstamp) || + put_user(sstatus.audio_tstamp.tv_sec, &src->s.status.audio_tstamp_sec) || + put_user(sstatus.audio_tstamp.tv_nsec, &src->s.status.audio_tstamp_nsec) || put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || put_user(scontrol.avail_min, &src->c.control.avail_min)) return -EFAULT; @@ -480,7 +482,6 @@ enum { SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct snd_xferi32), SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32), SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32), - SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32), SNDRV_PCM_IOCTL_STATUS_COMPAT64 = _IOR('A', 0x20, struct compat_snd_pcm_status64), SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64 = _IOWR('A', 0x24, struct compat_snd_pcm_status64), #ifdef CONFIG_X86_X32 @@ -504,8 +505,8 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l /* * When PCM is used on 32bit mode, we need to disable - * mmap of PCM status/control records because of the size - * incompatibility. + * mmap of the old PCM status/control records because + * of the size incompatibility. */ pcm_file->no_compat_mmap = 1; @@ -527,6 +528,13 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l case SNDRV_PCM_IOCTL_XRUN: case SNDRV_PCM_IOCTL_LINK: case SNDRV_PCM_IOCTL_UNLINK: + case __SNDRV_PCM_IOCTL_SYNC_PTR32: + return snd_pcm_common_ioctl(file, substream, cmd, argp); + case __SNDRV_PCM_IOCTL_SYNC_PTR64: +#ifdef CONFIG_X86_X32 + if (in_x32_syscall()) + return snd_pcm_ioctl_sync_ptr_x32(substream, argp); +#endif /* CONFIG_X86_X32 */ return snd_pcm_common_ioctl(file, substream, cmd, argp); case SNDRV_PCM_IOCTL_HW_REFINE32: return snd_pcm_ioctl_hw_params_compat(substream, 1, argp); @@ -538,8 +546,6 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l return snd_pcm_status_user32(substream, argp, false); case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT32: return snd_pcm_status_user32(substream, argp, true); - case SNDRV_PCM_IOCTL_SYNC_PTR32: - return snd_pcm_ioctl_sync_ptr_compat(substream, argp); case SNDRV_PCM_IOCTL_CHANNEL_INFO32: return snd_pcm_ioctl_channel_info_compat(substream, argp); case SNDRV_PCM_IOCTL_WRITEI_FRAMES32: @@ -561,8 +567,6 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l case SNDRV_PCM_IOCTL_STATUS_EXT_COMPAT64: return snd_pcm_status_user_compat64(substream, argp, true); #ifdef CONFIG_X86_X32 - case SNDRV_PCM_IOCTL_SYNC_PTR_X32: - return snd_pcm_ioctl_sync_ptr_x32(substream, argp); case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32: return snd_pcm_ioctl_channel_info_x32(substream, argp); #endif /* CONFIG_X86_X32 */ diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index ea5518d44e66..0271802bfba9 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -148,7 +148,8 @@ void __snd_pcm_xrun(struct snd_pcm_substream *substream) struct timespec64 tstamp; snd_pcm_gettime(runtime, &tstamp); - runtime->status->tstamp = timespec64_to_timespec(tstamp); + runtime->status->tstamp.tv_sec = tstamp.tv_sec; + runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; } snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { @@ -238,9 +239,10 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream, if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { - runtime->status->audio_tstamp = - timespec64_to_timespec(*audio_tstamp); - runtime->status->tstamp = timespec64_to_timespec(*curr_tstamp); + runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; + runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; + runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; + runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ba0636a2b437..5a1245509eac 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2889,14 +2889,15 @@ static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, return 0; } -#ifdef CONFIG_COMPAT struct snd_pcm_mmap_status32 { s32 state; s32 pad1; u32 hw_ptr; - struct compat_timespec tstamp; + s32 tstamp_sec; + s32 tstamp_nsec; s32 suspended_state; - struct compat_timespec audio_tstamp; + s32 audio_tstamp_sec; + s32 audio_tstamp_nsec; } __attribute__((packed)); struct snd_pcm_mmap_control32 { @@ -2976,17 +2977,18 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, snd_pcm_stream_unlock_irq(substream); if (put_user(sstatus.state, &src->s.status.state) || put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) || - compat_put_timespec(&sstatus.tstamp, &src->s.status.tstamp) || + put_user(sstatus.tstamp.tv_sec, &src->s.status.tstamp_sec) || + put_user(sstatus.tstamp.tv_nsec, &src->s.status.tstamp_nsec) || put_user(sstatus.suspended_state, &src->s.status.suspended_state) || - compat_put_timespec(&sstatus.audio_tstamp, - &src->s.status.audio_tstamp) || + put_user(sstatus.audio_tstamp.tv_sec, &src->s.status.audio_tstamp_sec) || + put_user(sstatus.audio_tstamp.tv_nsec, &src->s.status.audio_tstamp_nsec) || put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || put_user(scontrol.avail_min, &src->c.control.avail_min)) return -EFAULT; return 0; } -#endif +#define __SNDRV_PCM_IOCTL_SYNC_PTR32 _IOWR('A', 0x23, struct snd_pcm_sync_ptr32) static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) { @@ -3156,7 +3158,9 @@ static int snd_pcm_common_ioctl(struct file *file, return -EFAULT; return 0; } - case SNDRV_PCM_IOCTL_SYNC_PTR: + case __SNDRV_PCM_IOCTL_SYNC_PTR32: + return snd_pcm_ioctl_sync_ptr_compat(substream, arg); + case __SNDRV_PCM_IOCTL_SYNC_PTR64: return snd_pcm_sync_ptr(substream, arg); #ifdef CONFIG_SND_SUPPORT_OLD_API case SNDRV_PCM_IOCTL_HW_REFINE_OLD: @@ -3494,8 +3498,6 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file static bool pcm_status_mmap_allowed(struct snd_pcm_file *pcm_file) { - if (pcm_file->no_compat_mmap) - return false; /* See pcm_control_mmap_allowed() below. * Since older alsa-lib requires both status and control mmaps to be * coupled, we have to disable the status mmap for old alsa-lib, too. @@ -3720,11 +3722,19 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) offset = area->vm_pgoff << PAGE_SHIFT; switch (offset) { - case SNDRV_PCM_MMAP_OFFSET_STATUS: + case SNDRV_PCM_MMAP_OFFSET_STATUS_OLD: + if (pcm_file->no_compat_mmap || !IS_ENABLED(CONFIG_64BIT)) + return -ENXIO; + /* fallthrough */ + case SNDRV_PCM_MMAP_OFFSET_STATUS_NEW: if (!pcm_status_mmap_allowed(pcm_file)) return -ENXIO; return snd_pcm_mmap_status(substream, file, area); - case SNDRV_PCM_MMAP_OFFSET_CONTROL: + case SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD: + if (pcm_file->no_compat_mmap || !IS_ENABLED(CONFIG_64BIT)) + return -ENXIO; + /* fallthrough */ + case SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW: if (!pcm_control_mmap_allowed(pcm_file)) return -ENXIO; return snd_pcm_mmap_control(substream, file, area); @@ -3884,9 +3894,9 @@ static unsigned long snd_pcm_get_unmapped_area(struct file *file, unsigned long offset = pgoff << PAGE_SHIFT; switch (offset) { - case SNDRV_PCM_MMAP_OFFSET_STATUS: + case SNDRV_PCM_MMAP_OFFSET_STATUS_NEW: return (unsigned long)runtime->status; - case SNDRV_PCM_MMAP_OFFSET_CONTROL: + case SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW: return (unsigned long)runtime->control; default: return (unsigned long)runtime->dma_area + offset; -- cgit v1.2.3 From 1cfaef9617033f38eba9cc725809ed32bcdb3dc5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 13 Nov 2019 17:49:14 +0100 Subject: ALSA: bump uapi version numbers Change SNDRV_PCM_VERSION, SNDRV_RAWMIDI_VERSION and SNDRV_TIMER_VERSION to indicate the addition of the time64 version of the mmap interface and these ioctl commands: SNDRV_PCM_IOCTL_SYNC SNDRV_RAWMIDI_IOCTL_STATUS SNDRV_PCM_IOCTL_STATUS SNDRV_PCM_IOCTL_STATUS_EXT SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_STATUS 32-bit applications built with 64-bit time_t require both the headers and the running kernel to support at least the new API version. When built with earlier kernel headers, some of these may not work correctly, so applications are encouraged to fail compilation like #if SNDRV_PCM_VERSION < SNDRV_PROTOCOL_VERSION(2, 0, 15) extern int __fail_build_for_time_64[sizeof(long) - sizeof(time_t)]; #endif or provide their own updated copy of the header file. At runtime, the interface is unchanged for 32-bit time_t, but new kernels are required to work with user compiled with 64-bit time_t. A runtime check can be used to detect old kernel versions and warn about those. Signed-off-by: Arnd Bergmann --- include/uapi/sound/asound.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index df9983e7ead5..e6a958b8aff1 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -156,7 +156,7 @@ struct snd_hwdep_dsp_image { * * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 14) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15) typedef unsigned long snd_pcm_uframes_t; typedef signed long snd_pcm_sframes_t; @@ -710,7 +710,7 @@ enum { * Raw MIDI section - /dev/snd/midi?? */ -#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) +#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1) enum { SNDRV_RAWMIDI_STREAM_OUTPUT = 0, @@ -766,7 +766,7 @@ struct snd_rawmidi_status { * Timer section - /dev/snd/timer */ -#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) +#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) enum { SNDRV_TIMER_CLASS_NONE = -1, -- cgit v1.2.3 From 89698ed5cc76d8de6c2b51d132c06bf4cd930314 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 12 Dec 2019 20:11:00 +0100 Subject: ALSA: hda: Use waitqueue for RIRB in HDA-core helper, too This patch implements the same logic that was done for the legacy HD-audio controller driver by the commit 88452da92ba2 ("ALSA: hda: Use standard waitqueue for RIRB wakeup") to the HDA-core helper code, too. This makes snd_hdac_bus_get_response() waiting for the response with bus->rirb_wq instead of polling when bus->polling is false. It'll save both CPU time and response latency. Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20191212191101.19517-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/hda/hdac_controller.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index cd1c3b282657..61950b83b8c9 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -241,30 +241,42 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, { unsigned long timeout; unsigned long loopcounter; + wait_queue_entry_t wait; + init_wait_entry(&wait, 0); timeout = jiffies + msecs_to_jiffies(1000); for (loopcounter = 0;; loopcounter++) { spin_lock_irq(&bus->reg_lock); + if (!bus->polling_mode) + prepare_to_wait(&bus->rirb_wq, &wait, + TASK_UNINTERRUPTIBLE); if (bus->polling_mode) snd_hdac_bus_update_rirb(bus); if (!bus->rirb.cmds[addr]) { if (res) *res = bus->rirb.res[addr]; /* the last value */ + if (!bus->polling_mode) + finish_wait(&bus->rirb_wq, &wait); spin_unlock_irq(&bus->reg_lock); return 0; } spin_unlock_irq(&bus->reg_lock); if (time_after(jiffies, timeout)) break; - if (loopcounter > 3000) + if (!bus->polling_mode) { + schedule_timeout(msecs_to_jiffies(2)); + } else if (loopcounter > 3000) { msleep(2); /* temporary workaround */ - else { + } else { udelay(10); cond_resched(); } } + if (!bus->polling_mode) + finish_wait(&bus->rirb_wq, &wait); + return -EIO; } EXPORT_SYMBOL_GPL(snd_hdac_bus_get_response); -- cgit v1.2.3 From 5f2cb361d798fb39adb79fab4e5235e307c70e9a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 12 Dec 2019 20:11:01 +0100 Subject: ALSA: hda: Unify get_response handling Now most of the get_response handling became quite similar between HDA-core and legacy drivers, and the only differences are: - the handling of extra-long polling delay for some codecs - the debug message for the stalled communication and both are worth to share in the common code. This patch unifies the code into snd_hdac_bus_get_response(), and use this from the legacy get_response callback. It results in a good amount of code reduction in the end. Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20191212191101.19517-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/hda_codec.h | 1 - include/sound/hdaudio.h | 1 + sound/hda/hdac_controller.c | 11 +++++++++- sound/pci/hda/hda_controller.c | 49 ++++-------------------------------------- sound/pci/hda/hda_intel.c | 2 +- sound/pci/hda/hda_tegra.c | 2 +- sound/pci/hda/patch_ca0110.c | 2 +- sound/pci/hda/patch_sigmatel.c | 2 +- 8 files changed, 19 insertions(+), 51 deletions(-) diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h index ac18f428eda6..3ee8036f5436 100644 --- a/include/sound/hda_codec.h +++ b/include/sound/hda_codec.h @@ -51,7 +51,6 @@ struct hda_bus { DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES); /* misc op flags */ - unsigned int needs_damn_long_delay :1; unsigned int allow_bus_reset:1; /* allow bus reset at fatal error */ /* status for codec/controller */ unsigned int shutdown :1; /* being unloaded */ diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 81373a2efd96..bc2f77a6f17b 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -338,6 +338,7 @@ struct hdac_bus { bool reverse_assign:1; /* assign devices in reverse order */ bool corbrp_self_clear:1; /* CORBRP clears itself after reset */ bool polling_mode:1; + bool needs_damn_long_delay:1; int poll_count; diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index 61950b83b8c9..01787081552d 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -242,6 +242,7 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, unsigned long timeout; unsigned long loopcounter; wait_queue_entry_t wait; + bool warned = false; init_wait_entry(&wait, 0); timeout = jiffies + msecs_to_jiffies(1000); @@ -264,9 +265,17 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, spin_unlock_irq(&bus->reg_lock); if (time_after(jiffies, timeout)) break; +#define LOOP_COUNT_MAX 3000 if (!bus->polling_mode) { schedule_timeout(msecs_to_jiffies(2)); - } else if (loopcounter > 3000) { + } else if (bus->needs_damn_long_delay || + loopcounter > LOOP_COUNT_MAX) { + if (loopcounter > LOOP_COUNT_MAX && !warned) { + dev_dbg_ratelimited(bus->dev, + "too slow response, last cmd=%#08x\n", + bus->last_cmd[addr]); + warned = true; + } msleep(2); /* temporary workaround */ } else { udelay(10); diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 870102f00efd..d6a7bda28925 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -784,53 +784,12 @@ static int azx_rirb_get_response(struct hdac_bus *bus, unsigned int addr, { struct azx *chip = bus_to_azx(bus); struct hda_bus *hbus = &chip->bus; - unsigned long timeout; - unsigned long loopcounter; - wait_queue_entry_t wait; - bool warned = false; + int err; - init_wait_entry(&wait, 0); again: - timeout = jiffies + msecs_to_jiffies(1000); - - for (loopcounter = 0;; loopcounter++) { - spin_lock_irq(&bus->reg_lock); - if (!bus->polling_mode) - prepare_to_wait(&bus->rirb_wq, &wait, - TASK_UNINTERRUPTIBLE); - if (bus->polling_mode) - snd_hdac_bus_update_rirb(bus); - if (!bus->rirb.cmds[addr]) { - if (res) - *res = bus->rirb.res[addr]; /* the last value */ - if (!bus->polling_mode) - finish_wait(&bus->rirb_wq, &wait); - spin_unlock_irq(&bus->reg_lock); - return 0; - } - spin_unlock_irq(&bus->reg_lock); - if (time_after(jiffies, timeout)) - break; -#define LOOP_COUNT_MAX 3000 - if (!bus->polling_mode) { - schedule_timeout(msecs_to_jiffies(2)); - } else if (hbus->needs_damn_long_delay || - loopcounter > LOOP_COUNT_MAX) { - if (loopcounter > LOOP_COUNT_MAX && !warned) { - dev_dbg_ratelimited(chip->card->dev, - "too slow response, last cmd=%#08x\n", - bus->last_cmd[addr]); - warned = true; - } - msleep(2); /* temporary workaround */ - } else { - udelay(10); - cond_resched(); - } - } - - if (!bus->polling_mode) - finish_wait(&bus->rirb_wq, &wait); + err = snd_hdac_bus_get_response(bus, addr, res); + if (!err) + return 0; if (hbus->no_response_fallback) return -EIO; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index c86539cdbd4b..c7efb6f66bdc 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1809,7 +1809,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, if (chip->driver_type == AZX_DRIVER_NVIDIA) { dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); - chip->bus.needs_damn_long_delay = 1; + chip->bus.core.needs_damn_long_delay = 1; } err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 269f242fcbfd..9d0784aed9e4 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -394,7 +394,7 @@ static int hda_tegra_create(struct snd_card *card, if (err < 0) return err; - chip->bus.needs_damn_long_delay = 1; + chip->bus.core.needs_damn_long_delay = 1; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index e780922a1190..1818ce67f761 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c @@ -53,7 +53,7 @@ static int patch_ca0110(struct hda_codec *codec) codec->patch_ops = ca0110_patch_ops; spec->multi_cap_vol = 1; - codec->bus->needs_damn_long_delay = 1; + codec->bus->core.needs_damn_long_delay = 1; err = ca0110_parse_auto_config(codec); if (err < 0) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 894f3f509e76..8ecb53bce509 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -4908,7 +4908,7 @@ static int patch_stac927x(struct hda_codec *codec) * The below flag enables the longer delay (see get_response * in hda_intel.c). */ - codec->bus->needs_damn_long_delay = 1; + codec->bus->core.needs_damn_long_delay = 1; snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); -- cgit v1.2.3 From 1faa9d3a3ea7852761ff403f5a9d4a409c0bb199 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sat, 14 Dec 2019 22:13:51 +0900 Subject: ALSA: control: remove useless assignment in .info callback of PCM chmap element Control elements for PCM chmap return information to userspace abount the maximum number of available PCM channels as the number of values in the element. In current implementation the number is once initialized to zero, then assigned to. This is useless and this commit fixes it. Fixes: 2d3391ec0ecc ("ALSA: PCM: channel mapping API implementation") Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191214131351.28950-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 2236b5e0c1f2..6f0a00fd3ae5 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2308,7 +2308,6 @@ static int pcm_chmap_ctl_info(struct snd_kcontrol *kcontrol, struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 0; uinfo->count = info->max_channels; uinfo->value.integer.min = 0; uinfo->value.integer.max = SNDRV_CHMAP_LAST; -- cgit v1.2.3 From 651bbb9d5161ae7170bc19fec893b8bf05fc590f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 13 Dec 2019 17:30:05 +0100 Subject: ALSA: hda: Comment about snd_hdac_bus_update_rirb() and spinlock The call of snd_hdac_bus_update_rirb() needs the bus->reg_lock spinlock protection for concurrency. Comment about it more explicitly. Link: https://lore.kernel.org/r/20191213163005.19116-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/hda/hdac_controller.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index 01787081552d..b856184af37f 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -181,6 +181,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_send_cmd); * @bus: HD-audio core bus * * Usually called from interrupt handler. + * The caller needs bus->reg_lock spinlock before calling this. */ void snd_hdac_bus_update_rirb(struct hdac_bus *bus) { -- cgit v1.2.3 From c13493a2460b7ba8f6e75fe6e1a3b732cc294f8f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:54:36 +0900 Subject: ASoC: soc-core: support snd_soc_dai_link_component for codec_conf To find codec_conf component, it is using dev_name, of_node. But, we already has this kind of finding component method by snd_soc_dai_link_component, and snd_soc_is_matching_component(). We shouldn't have duplicate implementation to do same things. This patch adds snd_soc_dai_link_component support to find codec_conf component. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87lfrh59kj.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 82e65235c60d..a94e5d2fc2b2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -949,6 +949,7 @@ struct snd_soc_dai_link { #define COMP_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, } #define COMP_PLATFORM(_name) { .name = _name } #define COMP_AUX(_name) { .name = _name } +#define COMP_CODEC_CONF(_name) { .name = _name } #define COMP_DUMMY() { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", } extern struct snd_soc_dai_link_component null_dailink_component[0]; @@ -962,6 +963,8 @@ struct snd_soc_codec_conf { const char *dev_name; struct device_node *of_node; + struct snd_soc_dai_link_component dlc; + /* * optional map of kcontrol, widget and path name prefixes that are * associated per device diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ee77db253bcc..411b83ba2fc0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1185,12 +1185,16 @@ static void soc_set_name_prefix(struct snd_soc_card *card, for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; - if (map->of_node && of_node != map->of_node) - continue; - if (map->dev_name && strcmp(component->name, map->dev_name)) - continue; - component->name_prefix = map->name_prefix; - return; + /* fixme */ + if (map->dev_name) + map->dlc.name = map->dev_name; + if (map->of_node) + map->dlc.of_node = map->of_node; + + if (snd_soc_is_matching_component(&map->dlc, component)) { + component->name_prefix = map->name_prefix; + return; + } } /* @@ -2915,7 +2919,7 @@ void snd_soc_of_parse_node_prefix(struct device_node *np, return; } - codec_conf->of_node = of_node; + codec_conf->dlc.of_node = of_node; codec_conf->name_prefix = str; } EXPORT_SYMBOL_GPL(snd_soc_of_parse_node_prefix); -- cgit v1.2.3 From eea2395217374b5ad8a97e525dcdae663b49f2d9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:54:44 +0900 Subject: ASoC: fsl: imx-audmix: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87k17159kb.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/fsl/imx-audmix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c index 71590ca6394b..5ef6881395e0 100644 --- a/sound/soc/fsl/imx-audmix.c +++ b/sound/soc/fsl/imx-audmix.c @@ -289,7 +289,7 @@ static int imx_audmix_probe(struct platform_device *pdev) priv->dai[num_dai + i].ignore_pmdown_time = 1; priv->dai[num_dai + i].ops = &imx_audmix_be_ops; - priv->dai_conf[i].of_node = args.np; + priv->dai_conf[i].dlc.of_node = args.np; priv->dai_conf[i].name_prefix = dai_name; priv->dapm_routes[i].source = -- cgit v1.2.3 From 13568b0331c5f2839925c586f7e3e6cfe7f2ab71 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:54:53 +0900 Subject: ASoC: intel: kbl_da7219_max98927: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87imml59k2.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98927.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c index 829f95fc4179..34e734adac19 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -571,12 +571,12 @@ static struct snd_soc_ops skylake_refcap_ops = { static struct snd_soc_codec_conf max98927_codec_conf[] = { { - .dev_name = MAX98927_DEV0_NAME, + .dlc = COMP_CODEC_CONF(MAX98927_DEV0_NAME), .name_prefix = "Right", }, { - .dev_name = MAX98927_DEV1_NAME, + .dlc = COMP_CODEC_CONF(MAX98927_DEV1_NAME), .name_prefix = "Left", }, }; @@ -584,12 +584,12 @@ static struct snd_soc_codec_conf max98927_codec_conf[] = { static struct snd_soc_codec_conf max98373_codec_conf[] = { { - .dev_name = MAX98373_DEV0_NAME, + .dlc = COMP_CODEC_CONF(MAX98373_DEV0_NAME), .name_prefix = "Right", }, { - .dev_name = MAX98373_DEV1_NAME, + .dlc = COMP_CODEC_CONF(MAX98373_DEV1_NAME), .name_prefix = "Left", }, }; -- cgit v1.2.3 From 8a3bd454ee784360fc099eccc3e70be135aee836 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:54:59 +0900 Subject: ASoC: intel: kbl_rt5663_max98927: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87h82559jw.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 7cefda341fbf..cd748d6f4af3 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -229,11 +229,11 @@ static const struct snd_soc_dapm_route kabylake_5663_map[] = { static struct snd_soc_codec_conf max98927_codec_conf[] = { { - .dev_name = MAXIM_DEV0_NAME, + .dlc = COMP_CODEC_CONF(MAXIM_DEV0_NAME), .name_prefix = "Right", }, { - .dev_name = MAXIM_DEV1_NAME, + .dlc = COMP_CODEC_CONF(MAXIM_DEV1_NAME), .name_prefix = "Left", }, }; -- cgit v1.2.3 From 5a3493305ac0828ad33efe6f23db26a8dae6c3c3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:04 +0900 Subject: ASoC: intel: kbl_rt5663_rt5514_max98927: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87fthp59jr.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 3e5f6bead229..e2b0a027f5a1 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -193,11 +193,11 @@ static const struct snd_soc_dapm_route kabylake_map[] = { static struct snd_soc_codec_conf max98927_codec_conf[] = { { - .dev_name = MAXIM_DEV0_NAME, + .dlc = COMP_CODEC_CONF(MAXIM_DEV0_NAME), .name_prefix = "Right", }, { - .dev_name = MAXIM_DEV1_NAME, + .dlc = COMP_CODEC_CONF(MAXIM_DEV1_NAME), .name_prefix = "Left", }, }; -- cgit v1.2.3 From 03b70ef529aeabee42174bc356635ea1ab7a1729 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:09 +0900 Subject: ASoC: intel: skl_nau88l25_ssm4567: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87eex959jm.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 1a7ac8bdf543..b96b014e8c9e 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -147,11 +147,11 @@ static const struct snd_soc_dapm_route skylake_map[] = { static struct snd_soc_codec_conf ssm4567_codec_conf[] = { { - .dev_name = "i2c-INT343B:00", + .dlc = COMP_CODEC_CONF("i2c-INT343B:00"), .name_prefix = "Left", }, { - .dev_name = "i2c-INT343B:01", + .dlc = COMP_CODEC_CONF("i2c-INT343B:01"), .name_prefix = "Right", }, }; -- cgit v1.2.3 From e90c2a3bc151f7c855c67461be42dbf16625eb67 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:15 +0900 Subject: ASoC: mediatek: mt8173-rt5650-rt5514: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87d0ct59jg.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c index 8717e87bfe26..2e1e61d8f127 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c @@ -209,7 +209,7 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n"); return -EINVAL; } - mt8173_rt5650_rt5514_codec_conf[0].of_node = + mt8173_rt5650_rt5514_codec_conf[0].dlc.of_node = mt8173_rt5650_rt5514_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node; card->dev = &pdev->dev; -- cgit v1.2.3 From fe71bf9aaf459f2b3432593eb917edb4ffe1cb0d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:20 +0900 Subject: ASoC: mediatek: mt8173-rt5650-rt5676: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87blsd59jb.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c index 9d4dd9721154..ebcc0b86286b 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c @@ -265,7 +265,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) "Property 'audio-codec' missing or invalid\n"); return -EINVAL; } - mt8173_rt5650_rt5676_codec_conf[0].of_node = + mt8173_rt5650_rt5676_codec_conf[0].dlc.of_node = mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node; mt8173_rt5650_rt5676_dais[DAI_LINK_INTERCODEC].codecs->of_node = -- cgit v1.2.3 From 2d27a4cf19674ff5c05d84e1037d8793e1090065 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:25 +0900 Subject: ASoC: mediatek: mt8183-da7219-max98357: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87a77x59j6.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c index 43f99e59a078..c65493721e90 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -367,7 +367,7 @@ static struct snd_soc_aux_dev mt8183_da7219_max98357_headset_dev = { static struct snd_soc_codec_conf mt6358_codec_conf[] = { { - .dev_name = "mt6358-sound", + .dlc = COMP_CODEC_CONF("mt6358-sound"), .name_prefix = "Mt6358", }, }; -- cgit v1.2.3 From 3874b2154be7abd3e5eb1c19af7e556f6a22d2fa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:30 +0900 Subject: ASoC: samsung: bells: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/878snh59j1.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/samsung/bells.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c index 58d8a81aa0ea..5de633497f83 100644 --- a/sound/soc/samsung/bells.c +++ b/sound/soc/samsung/bells.c @@ -381,7 +381,7 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = { static struct snd_soc_codec_conf bells_codec_conf[] = { { - .dev_name = "wm9081.1-006c", + .dlc = COMP_CODEC_CONF("wm9081.1-006c"), .name_prefix = "Sub", }, }; -- cgit v1.2.3 From bfc5b22c7181b39cb106ae5c2fb1dfb6ad53a724 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:34 +0900 Subject: ASoC: samsung: lowland: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/877e3159ix.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/samsung/lowland.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c index 973f22bcc747..098eefc764db 100644 --- a/sound/soc/samsung/lowland.c +++ b/sound/soc/samsung/lowland.c @@ -126,7 +126,7 @@ static struct snd_soc_dai_link lowland_dai[] = { static struct snd_soc_codec_conf lowland_codec_conf[] = { { - .dev_name = "wm9081.1-006c", + .dlc = COMP_CODEC_CONF("wm9081.1-006c"), .name_prefix = "Sub", }, }; -- cgit v1.2.3 From 1762d3a5fd69ad3b38713f9e6144c3e32279d8bf Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:39 +0900 Subject: ASoC: samsung: neo1973_wm8753: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/875zil59is.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/samsung/neo1973_wm8753.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c index 38f536bafa09..1339e41e9860 100644 --- a/sound/soc/samsung/neo1973_wm8753.c +++ b/sound/soc/samsung/neo1973_wm8753.c @@ -303,7 +303,7 @@ static struct snd_soc_aux_dev neo1973_aux_devs[] = { static struct snd_soc_codec_conf neo1973_codec_conf[] = { { - .dev_name = "lm4857.0-007c", + .dlc = COMP_CODEC_CONF("lm4857.0-007c"), .name_prefix = "Amp", }, }; -- cgit v1.2.3 From b9fc10027cf37014d159deba69f0aad926496554 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:44 +0900 Subject: ASoC: samsung: speyside: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/874ky559in.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/samsung/speyside.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 5ccdfe0eb6fe..ea0d1ec67f01 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c @@ -247,7 +247,7 @@ static struct snd_soc_aux_dev speyside_aux_dev[] = { static struct snd_soc_codec_conf speyside_codec_conf[] = { { - .dev_name = "wm9081.1-006c", + .dlc = COMP_CODEC_CONF("wm9081.1-006c"), .name_prefix = "Sub", }, }; -- cgit v1.2.3 From e3c157c934fbb99054572a81ccc9da0a97227689 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:50 +0900 Subject: ASoC: ti: rx51: use snd_soc_dai_link_component for codec_conf We can use snd_soc_dai_link_component to specify codec_conf. Let's use it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/8736dp59ih.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/ti/rx51.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/ti/rx51.c b/sound/soc/ti/rx51.c index 588f680a9c24..fdb0dc85fe67 100644 --- a/sound/soc/ti/rx51.c +++ b/sound/soc/ti/rx51.c @@ -328,11 +328,11 @@ static struct snd_soc_aux_dev rx51_aux_dev[] = { static struct snd_soc_codec_conf rx51_codec_conf[] = { { - .dev_name = "tlv320aic3x-codec.2-0019", + .dlc = COMP_CODEC_CONF("tlv320aic3x-codec.2-0019"), .name_prefix = "b", }, { - .dev_name = "tpa6130a2.2-0060", + .dlc = COMP_CODEC_CONF("tpa6130a2.2-0060"), .name_prefix = "TPA6130A2", }, }; @@ -397,8 +397,8 @@ static int rx51_soc_probe(struct platform_device *pdev) } rx51_aux_dev[0].dlc.name = NULL; rx51_aux_dev[0].dlc.of_node = dai_node; - rx51_codec_conf[0].dev_name = NULL; - rx51_codec_conf[0].of_node = dai_node; + rx51_codec_conf[0].dlc.name = NULL; + rx51_codec_conf[0].dlc.of_node = dai_node; dai_node = of_parse_phandle(np, "nokia,headphone-amplifier", 0); if (!dai_node) { @@ -407,8 +407,8 @@ static int rx51_soc_probe(struct platform_device *pdev) } rx51_aux_dev[1].dlc.name = NULL; rx51_aux_dev[1].dlc.of_node = dai_node; - rx51_codec_conf[1].dev_name = NULL; - rx51_codec_conf[1].of_node = dai_node; + rx51_codec_conf[1].dlc.name = NULL; + rx51_codec_conf[1].dlc.of_node = dai_node; } pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); -- cgit v1.2.3 From ee8f537fd8b71c555d01a89e0834413bbf5373d4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 13 Dec 2019 09:55:55 +0900 Subject: ASoC: soc-core: remove legacy style of codec_conf Now all driver is using snd_soc_dai_link_component for codec_conf. Let's remove legacy style Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/871rt959ic.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Signed-off-by: Mark Brown --- include/sound/soc.h | 3 --- sound/soc/soc-core.c | 6 ------ 2 files changed, 9 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index a94e5d2fc2b2..9787c80e548b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -960,9 +960,6 @@ struct snd_soc_codec_conf { * specify device either by device name, or by * DT/OF node, but not both. */ - const char *dev_name; - struct device_node *of_node; - struct snd_soc_dai_link_component dlc; /* diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 411b83ba2fc0..0bd2cb2e7a67 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1185,12 +1185,6 @@ static void soc_set_name_prefix(struct snd_soc_card *card, for (i = 0; i < card->num_configs; i++) { struct snd_soc_codec_conf *map = &card->codec_conf[i]; - /* fixme */ - if (map->dev_name) - map->dlc.name = map->dev_name; - if (map->of_node) - map->dlc.of_node = map->of_node; - if (snd_soc_is_matching_component(&map->dlc, component)) { component->name_prefix = map->name_prefix; return; -- cgit v1.2.3 From d8cac6207ec1abd3c85cff2625dd3898d59c4df5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 17 Dec 2019 09:14:48 +0100 Subject: ALSA: cmipci: Allow disabling MPU port via module option Patrick May reported that his sound card with CMI8378 chip causes a crash / reboot when accessing the MIDI port that isn't actually present on the board. Moreover, despite of the documentation, passing mpu_port=0 doesn't disable the MIDI port on this board. It implies that the chip is a newer revision and the MPU401 port is integrated and mapped on the PCI register. For this chip model, the driver enables the MPU port unconditionally, so far. Although fixing the unexpected reboot would be the best solution, it's not so trivial to identify the cause. So, as a plan B, this patch extends the existing mpu_port option usage to allow disabling the port by specifying the value 0, just like we applied for fm_port option in commit 2f24d159d5ac ("[ALSA] cmipci - Allow to disable integrated FM port"). As default, the MPU port is still enabled, but user can pass mpu_port=0 to disable it. Reported-and-tested-by: Patrick May Link: https://lore.kernel.org/r/20191217081448.1144-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- Documentation/sound/alsa-configuration.rst | 3 ++- sound/pci/cmipci.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/sound/alsa-configuration.rst b/Documentation/sound/alsa-configuration.rst index 02aacd69ab96..392875a1b94e 100644 --- a/Documentation/sound/alsa-configuration.rst +++ b/Documentation/sound/alsa-configuration.rst @@ -495,7 +495,8 @@ Module for C-Media CMI8338/8738/8768/8770 PCI sound cards. mpu_port port address of MIDI interface (8338 only): 0x300,0x310,0x320,0x330 = legacy port, - 0 = disable (default) + 1 = integrated PCI port (default on 8738), + 0 = disable fm_port port address of OPL-3 FM synthesizer (8x38 only): 0x388 = legacy port, diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 4bfab21c53f4..266c4cf28b78 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8738}," static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ -static long mpu_port[SNDRV_CARDS]; +static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1}; static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; static bool soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1}; #ifdef SUPPORT_JOYSTICK @@ -3132,7 +3132,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, if (cm->chip_version >= 39) { val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1); if (val != 0x00 && val != 0xff) { - iomidi = cm->iobase + CM_REG_MPU_PCI; + if (mpu_port[dev]) + iomidi = cm->iobase + CM_REG_MPU_PCI; integrated_midi = 1; } } -- cgit v1.2.3 From ae91a189d2459644e800ceea615a9c1937ee5ae2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 12 Dec 2019 20:17:47 +0100 Subject: ASoC: intel: skylake: Remove superfluous bus ops The bus_core_ops values set in skl driver are same as the default values, so we can drop it and pass NULL to snd_hdac_ext_bus_init() instead. Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/r/20191212191747.19995-1-tiwai@suse.de Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 58ba3e9469ba..f755ca2484cf 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -773,11 +773,6 @@ static void skl_codec_create(struct hdac_bus *bus) } } -static const struct hdac_bus_ops bus_core_ops = { - .command = snd_hdac_bus_send_cmd, - .get_response = snd_hdac_bus_get_response, -}; - static int skl_i915_init(struct hdac_bus *bus) { int err; @@ -888,7 +883,7 @@ static int skl_create(struct pci_dev *pci, #if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) ext_ops = snd_soc_hdac_hda_get_ops(); #endif - snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, ext_ops); + snd_hdac_ext_bus_init(bus, &pci->dev, NULL, ext_ops); bus->use_posbuf = 1; skl->pci = pci; INIT_WORK(&skl->probe_work, skl_probe_work); -- cgit v1.2.3 From 4137f4b65df7608e52f307f4aa9792b984bad7de Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Tue, 17 Dec 2019 10:58:50 +0100 Subject: ASoC: compress: Add pm_runtime support For some devices, components need to be powered-up before stream startup sequence commences. Update soc_compr_open to provide such functionality. Based on soc_pcm_open. Adjust soc_compr_free accordingly to power down components once compress stream is closed. Signed-off-by: Cezary Rojewski Link: https://lore.kernel.org/r/20191217095851.19629-7-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/soc-compress.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 6615ef64c7f5..b2a5351b1a11 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -19,6 +19,7 @@ #include #include #include +#include static int soc_compr_components_open(struct snd_compr_stream *cstream, struct snd_soc_component **last) @@ -72,10 +73,20 @@ static int soc_compr_components_free(struct snd_compr_stream *cstream, static int soc_compr_open(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_component *component; + struct snd_soc_component *component, *save = NULL; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; int ret; + for_each_rtd_components(rtd, rtdcom, component) { + ret = pm_runtime_get_sync(component->dev); + if (ret < 0 && ret != -EACCES) { + pm_runtime_put_noidle(component->dev); + save = component; + goto pm_err; + } + } + mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); if (cpu_dai->driver->cops && cpu_dai->driver->cops->startup) { @@ -115,6 +126,14 @@ machine_err: cpu_dai->driver->cops->shutdown(cstream, cpu_dai); out: mutex_unlock(&rtd->card->pcm_mutex); +pm_err: + for_each_rtd_components(rtd, rtdcom, component) { + if (component == save) + break; + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + } + return ret; } @@ -239,6 +258,8 @@ static void close_delayed_work(struct snd_soc_pcm_runtime *rtd) static int soc_compr_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; int stream; @@ -287,6 +308,12 @@ static int soc_compr_free(struct snd_compr_stream *cstream) } mutex_unlock(&rtd->card->pcm_mutex); + + for_each_rtd_components(rtd, rtdcom, component) { + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + } + return 0; } -- cgit v1.2.3 From df4654bd6e42125d9b85ce3a26eaca2935290b98 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 17 Dec 2019 20:42:57 -0700 Subject: ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status Clang warns: ../sound/usb/usx2y/usX2Yhwdep.c:122:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation] info->version = USX2Y_DRIVER_VERSION; ^ ../sound/usb/usx2y/usX2Yhwdep.c:120:2: note: previous statement is here if (us428->chip_status & USX2Y_STAT_CHIP_INIT) ^ 1 warning generated. This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns. This was introduced before the beginning of git history so no fixes tag. Link: https://github.com/ClangBuiltLinux/linux/issues/831 Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20191218034257.54535-1-natechancellor@gmail.com Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usX2Yhwdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index d1caa8ed9e68..9985fc139487 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -119,7 +119,7 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code if (us428->chip_status & USX2Y_STAT_CHIP_INIT) info->chip_ready = 1; - info->version = USX2Y_DRIVER_VERSION; + info->version = USX2Y_DRIVER_VERSION; return 0; } -- cgit v1.2.3 From 5610b90e6bb21ca31caa635bf0c17c1ee6cf1c08 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 10:56:48 -0600 Subject: ASoC: Intel: cml_rt1011_rt5682: fix codec_conf by removing legacy style Now that the legacy style is removed, we have to use the new macros for the codec configuration. This change was missed in the initial series. Reported-by: Randy Dunlap Cc: Kuninori Morimoto Fixes: ee8f537fd8b71c ("ASoC: soc-core: remove legacy style of codec_conf") Signed-off-by: Pierre-Louis Bossart Acked-by: Randy Dunlap # build-tested Acked-by: Kuninori Morimoto Link: https://lore.kernel.org/r/20191217165649.12091-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/cml_rt1011_rt5682.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/cml_rt1011_rt5682.c b/sound/soc/intel/boards/cml_rt1011_rt5682.c index a22f97234201..ab1196108d23 100644 --- a/sound/soc/intel/boards/cml_rt1011_rt5682.c +++ b/sound/soc/intel/boards/cml_rt1011_rt5682.c @@ -406,19 +406,19 @@ static struct snd_soc_dai_link cml_rt1011_rt5682_dailink[] = { static struct snd_soc_codec_conf rt1011_conf[] = { { - .dev_name = "i2c-10EC1011:00", + .dlc = COMP_CODEC_CONF("i2c-10EC1011:00"), .name_prefix = "WL", }, { - .dev_name = "i2c-10EC1011:01", + .dlc = COMP_CODEC_CONF("i2c-10EC1011:01"), .name_prefix = "WR", }, { - .dev_name = "i2c-10EC1011:02", + .dlc = COMP_CODEC_CONF("i2c-10EC1011:02"), .name_prefix = "TL", }, { - .dev_name = "i2c-10EC1011:03", + .dlc = COMP_CODEC_CONF("i2c-10EC1011:03"), .name_prefix = "TR", }, }; -- cgit v1.2.3 From f4483a0fda1df3e5b4f25de647b8777d2481f08c Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:24 -0600 Subject: ASoC: SOF: Intel: add module namespace for legacy IPC The legacy IPC routines are only used by broadwell and baytrail modules, import them as needed and make sure other modules cannot load them. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/bdw.c | 1 + sound/soc/sof/intel/byt.c | 1 + sound/soc/sof/intel/intel-ipc.c | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index c09885c0eb7d..39d1c8c7cddf 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -642,3 +642,4 @@ const struct sof_intel_dsp_desc bdw_chip_info = { EXPORT_SYMBOL(bdw_chip_info); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index d43098a962c0..b214b12fdcda 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -877,3 +877,4 @@ EXPORT_SYMBOL(cht_chip_info); #endif /* CONFIG_SND_SOC_SOF_BAYTRAIL */ MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); diff --git a/sound/soc/sof/intel/intel-ipc.c b/sound/soc/sof/intel/intel-ipc.c index 4edd92151fd5..e935f70d611b 100644 --- a/sound/soc/sof/intel/intel-ipc.c +++ b/sound/soc/sof/intel/intel-ipc.c @@ -39,7 +39,7 @@ void intel_ipc_msg_data(struct snd_sof_dev *sdev, sof_mailbox_read(sdev, stream->posn_offset, p, sz); } } -EXPORT_SYMBOL(intel_ipc_msg_data); +EXPORT_SYMBOL_NS(intel_ipc_msg_data, SND_SOC_SOF_INTEL_HIFI_EP_IPC); int intel_ipc_pcm_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream, @@ -60,7 +60,7 @@ int intel_ipc_pcm_params(struct snd_sof_dev *sdev, return 0; } -EXPORT_SYMBOL(intel_ipc_pcm_params); +EXPORT_SYMBOL_NS(intel_ipc_pcm_params, SND_SOC_SOF_INTEL_HIFI_EP_IPC); int intel_pcm_open(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) @@ -75,7 +75,7 @@ int intel_pcm_open(struct snd_sof_dev *sdev, return 0; } -EXPORT_SYMBOL(intel_pcm_open); +EXPORT_SYMBOL_NS(intel_pcm_open, SND_SOC_SOF_INTEL_HIFI_EP_IPC); int intel_pcm_close(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) @@ -87,6 +87,6 @@ int intel_pcm_close(struct snd_sof_dev *sdev, return 0; } -EXPORT_SYMBOL(intel_pcm_close); +EXPORT_SYMBOL_NS(intel_pcm_close, SND_SOC_SOF_INTEL_HIFI_EP_IPC); MODULE_LICENSE("Dual BSD/GPL"); -- cgit v1.2.3 From e42b19450866fbd447e459d8935c208e3888705a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:25 -0600 Subject: ASoC: SOF: Intel: add namespaces for BAYTRAIL and MERRIFIELD Define separate namespaces and include them in ACPI and PCI top-level modules. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/byt.c | 12 ++++++------ sound/soc/sof/sof-acpi-dev.c | 1 + sound/soc/sof/sof-pci-dev.c | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index b214b12fdcda..07634873deb6 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -619,13 +619,13 @@ const struct snd_sof_dsp_ops sof_tng_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, }; -EXPORT_SYMBOL(sof_tng_ops); +EXPORT_SYMBOL_NS(sof_tng_ops, SND_SOC_SOF_MERRIFIELD); const struct sof_intel_dsp_desc tng_chip_info = { .cores_num = 1, .cores_mask = 1, }; -EXPORT_SYMBOL(tng_chip_info); +EXPORT_SYMBOL_NS(tng_chip_info, SND_SOC_SOF_MERRIFIELD); #endif /* CONFIG_SND_SOC_SOF_MERRIFIELD */ @@ -793,13 +793,13 @@ const struct snd_sof_dsp_ops sof_byt_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, }; -EXPORT_SYMBOL(sof_byt_ops); +EXPORT_SYMBOL_NS(sof_byt_ops, SND_SOC_SOF_BAYTRAIL); const struct sof_intel_dsp_desc byt_chip_info = { .cores_num = 1, .cores_mask = 1, }; -EXPORT_SYMBOL(byt_chip_info); +EXPORT_SYMBOL_NS(byt_chip_info, SND_SOC_SOF_BAYTRAIL); /* cherrytrail and braswell ops */ const struct snd_sof_dsp_ops sof_cht_ops = { @@ -866,13 +866,13 @@ const struct snd_sof_dsp_ops sof_cht_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, }; -EXPORT_SYMBOL(sof_cht_ops); +EXPORT_SYMBOL_NS(sof_cht_ops, SND_SOC_SOF_BAYTRAIL); const struct sof_intel_dsp_desc cht_chip_info = { .cores_num = 1, .cores_mask = 1, }; -EXPORT_SYMBOL(cht_chip_info); +EXPORT_SYMBOL_NS(cht_chip_info, SND_SOC_SOF_BAYTRAIL); #endif /* CONFIG_SND_SOC_SOF_BAYTRAIL */ diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 9c0a4eed5cc8..6d44d5802e29 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -240,3 +240,4 @@ static struct platform_driver snd_sof_acpi_driver = { module_platform_driver(snd_sof_acpi_driver); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_BAYTRAIL); diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 5f08a9ca6bf8..0c67e5d7dc33 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -415,3 +415,4 @@ static struct pci_driver snd_sof_pci_driver = { module_pci_driver(snd_sof_pci_driver); MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_MERRIFIELD); -- cgit v1.2.3 From 8caa99bb5d8007fdd206ed6ba2fe4f881b1552c7 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:26 -0600 Subject: ASoC: SOF: Intel: add namespace for BROADWELL Define namespace and include it in ACPI top-level module. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/bdw.c | 4 ++-- sound/soc/sof/sof-acpi-dev.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 39d1c8c7cddf..f017089c7b2d 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -633,13 +633,13 @@ const struct snd_sof_dsp_ops sof_bdw_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, }; -EXPORT_SYMBOL(sof_bdw_ops); +EXPORT_SYMBOL_NS(sof_bdw_ops, SND_SOC_SOF_BROADWELL); const struct sof_intel_dsp_desc bdw_chip_info = { .cores_num = 1, .cores_mask = 1, }; -EXPORT_SYMBOL(bdw_chip_info); +EXPORT_SYMBOL_NS(bdw_chip_info, SND_SOC_SOF_BROADWELL); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 6d44d5802e29..d8ed6bfa5ce7 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -241,3 +241,4 @@ module_platform_driver(snd_sof_acpi_driver); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_BAYTRAIL); +MODULE_IMPORT_NS(SND_SOC_SOF_BROADWELL); -- cgit v1.2.3 From 1fa44098b683312b426bd05f1bfc0b5b1fa7860a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:27 -0600 Subject: ASoC: SOF: remove references to Haswell There are no known commercial devices using Haswell, and there is no support for Haswell in SOF so remove remaining definitions and structures. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/Kconfig | 2 +- sound/soc/sof/intel/shim.h | 6 ++---- sound/soc/sof/sof-acpi-dev.c | 20 -------------------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig index 71a0fc075a63..827b0ec92522 100644 --- a/sound/soc/sof/Kconfig +++ b/sound/soc/sof/Kconfig @@ -28,7 +28,7 @@ config SND_SOC_SOF_ACPI select IOSF_MBI if X86 && PCI help This adds support for ACPI enumeration. This option is required - to enable Intel Haswell/Broadwell/Baytrail/Cherrytrail devices + to enable Intel Broadwell/Baytrail/Cherrytrail devices Say Y if you need this option If unsure select "N". diff --git a/sound/soc/sof/intel/shim.h b/sound/soc/sof/intel/shim.h index f7a3f62e45d4..daaf3364c177 100644 --- a/sound/soc/sof/intel/shim.h +++ b/sound/soc/sof/intel/shim.h @@ -12,7 +12,7 @@ #define __SOF_INTEL_SHIM_H /* - * SHIM registers for BYT, BSW, CHT, HSW, BDW + * SHIM registers for BYT, BSW, CHT, BDW */ #define SHIM_CSR (SHIM_OFFSET + 0x00) @@ -38,7 +38,7 @@ #define SHIM_PWMCTRL 0x1000 /* - * SST SHIM register bits for BYT, BSW, CHT HSW, BDW + * SST SHIM register bits for BYT, BSW, CHT, BDW * Register bit naming and functionaility can differ between devices. */ @@ -169,13 +169,11 @@ struct sof_intel_dsp_desc { extern const struct snd_sof_dsp_ops sof_tng_ops; extern const struct snd_sof_dsp_ops sof_byt_ops; extern const struct snd_sof_dsp_ops sof_cht_ops; -extern const struct snd_sof_dsp_ops sof_hsw_ops; extern const struct snd_sof_dsp_ops sof_bdw_ops; extern const struct sof_intel_dsp_desc byt_chip_info; extern const struct sof_intel_dsp_desc cht_chip_info; extern const struct sof_intel_dsp_desc bdw_chip_info; -extern const struct sof_intel_dsp_desc hsw_chip_info; extern const struct sof_intel_dsp_desc tng_chip_info; struct sof_intel_stream { diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index d8ed6bfa5ce7..9100d7c70bb2 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -35,23 +35,6 @@ MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI debug options (0x0 all off)"); #define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0) -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HASWELL) -static const struct sof_dev_desc sof_acpi_haswell_desc = { - .machines = snd_soc_acpi_intel_haswell_machines, - .resindex_lpe_base = 0, - .resindex_pcicfg_base = 1, - .resindex_imr_base = -1, - .irqindex_host_ipc = 0, - .chip_info = &hsw_chip_info, - .default_fw_path = "intel/sof", - .default_tplg_path = "intel/sof-tplg", - .default_fw_filename = "sof-hsw.ri", - .nocodec_tplg_filename = "sof-hsw-nocodec.tplg", - .ops = &sof_hsw_ops, - .arch_ops = &sof_xtensa_arch_ops -}; -#endif - #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) static const struct sof_dev_desc sof_acpi_broadwell_desc = { .machines = snd_soc_acpi_intel_broadwell_machines, @@ -213,9 +196,6 @@ static int sof_acpi_remove(struct platform_device *pdev) } static const struct acpi_device_id sof_acpi_match[] = { -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HASWELL) - { "INT33C8", (unsigned long)&sof_acpi_haswell_desc }, -#endif #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) { "INT3438", (unsigned long)&sof_acpi_broadwell_desc }, #endif -- cgit v1.2.3 From cf5629e4594c2164aa629d21a749c65ad594de95 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:28 -0600 Subject: ASoC: SOF: Intel: add namespace for HDA_COMMON Define namespace and include it in PCI top-level module. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/apl.c | 4 ++-- sound/soc/sof/intel/cnl.c | 12 ++++++------ sound/soc/sof/sof-pci-dev.c | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index aeed1422900b..97831d2c9df6 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -112,7 +112,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, }; -EXPORT_SYMBOL(sof_apl_ops); +EXPORT_SYMBOL_NS(sof_apl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc apl_chip_info = { /* Apollolake */ @@ -128,4 +128,4 @@ const struct sof_intel_dsp_desc apl_chip_info = { .ssp_count = APL_SSP_COUNT, .ssp_base_offset = APL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(apl_chip_info); +EXPORT_SYMBOL_NS(apl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index 6b44f6d02082..b27088e67c7b 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -298,7 +298,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, }; -EXPORT_SYMBOL(sof_cnl_ops); +EXPORT_SYMBOL_NS(sof_cnl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc cnl_chip_info = { /* Cannonlake */ @@ -317,7 +317,7 @@ const struct sof_intel_dsp_desc cnl_chip_info = { .ssp_count = CNL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(cnl_chip_info); +EXPORT_SYMBOL_NS(cnl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc icl_chip_info = { /* Icelake */ @@ -336,7 +336,7 @@ const struct sof_intel_dsp_desc icl_chip_info = { .ssp_count = ICL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(icl_chip_info); +EXPORT_SYMBOL_NS(icl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc tgl_chip_info = { /* Tigerlake */ @@ -352,7 +352,7 @@ const struct sof_intel_dsp_desc tgl_chip_info = { .ssp_count = ICL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(tgl_chip_info); +EXPORT_SYMBOL_NS(tgl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc ehl_chip_info = { /* Elkhartlake */ @@ -368,7 +368,7 @@ const struct sof_intel_dsp_desc ehl_chip_info = { .ssp_count = ICL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(ehl_chip_info); +EXPORT_SYMBOL_NS(ehl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); const struct sof_intel_dsp_desc jsl_chip_info = { /* Jasperlake */ @@ -385,4 +385,4 @@ const struct sof_intel_dsp_desc jsl_chip_info = { .ssp_count = ICL_SSP_COUNT, .ssp_base_offset = CNL_SSP_BASE_OFFSET, }; -EXPORT_SYMBOL(jsl_chip_info); +EXPORT_SYMBOL_NS(jsl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 0c67e5d7dc33..20638f666189 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -416,3 +416,4 @@ module_pci_driver(snd_sof_pci_driver); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_MERRIFIELD); +MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HDA_COMMON); -- cgit v1.2.3 From 6ca5cecbd1c1758666ab79446f19e0e61ed11444 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 17 Dec 2019 18:26:09 -0600 Subject: ASoC: SOF: Introduce state machine for FW boot Add a state machine for FW boot to track the different stages of FW boot and replace the boot_complete field with fw_state field in struct snd_sof_dev. This will be used to determine the actions to be performed during system suspend. One of the main motivations for adding this change is the fact that errors during the top-level SOF device probe cannot be propagated and therefore suspending the SOF device normally during system suspend could potentially run into errors. For example, with the current flow, if the FW boot failed for some reason and the system suspends, the SOF device suspend could fail because the CTX_SAVE IPC would be attempted even though the FW never really booted successfully causing it to time out. Another scenario that the state machine fixes is when the runtime suspend for the SOF device fails and the DSP is powered down nevertheless, the CTX_SAVE IPC during system suspend would timeout because the DSP is already powered down. Reviewed-by: Curtis Malainey Reviewed-by: Daniel Baluta Signed-off-by: Ranjani Sridharan Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/core.c | 50 +++++++++++++++++++++++++++++++++++++++- sound/soc/sof/intel/hda-loader.c | 1 - sound/soc/sof/intel/hda.c | 4 ++-- sound/soc/sof/ipc.c | 17 ++++---------- sound/soc/sof/loader.c | 19 ++++++++++----- sound/soc/sof/pm.c | 21 ++++++++++++++++- sound/soc/sof/sof-priv.h | 11 ++++++++- 7 files changed, 99 insertions(+), 24 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index e258f6a8e7a5..44f9c04d54aa 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -92,6 +92,46 @@ out: } EXPORT_SYMBOL(snd_sof_get_status); +/* + * FW Boot State Transition Diagram + * + * +-----------------------------------------------------------------------+ + * | | + * ------------------ ------------------ | + * | | | | | + * | BOOT_FAILED | | READY_FAILED |-------------------------+ | + * | | | | | | + * ------------------ ------------------ | | + * ^ ^ | | + * | | | | + * (FW Boot Timeout) (FW_READY FAIL) | | + * | | | | + * | | | | + * ------------------ | ------------------ | | + * | | | | | | | + * | IN_PROGRESS |---------------+------------->| COMPLETE | | | + * | | (FW Boot OK) (FW_READY OK) | | | | + * ------------------ ------------------ | | + * ^ | | | + * | | | | + * (FW Loading OK) (System Suspend/Runtime Suspend) + * | | | | + * | | | | + * ------------------ ------------------ | | | + * | | | |<-----+ | | + * | PREPARE | | NOT_STARTED |<---------------------+ | + * | | | |<---------------------------+ + * ------------------ ------------------ + * | ^ | ^ + * | | | | + * | +-----------------------+ | + * | (DSP Probe OK) | + * | | + * | | + * +------------------------------------+ + * (System Suspend/Runtime Suspend) + */ + static int sof_probe_continue(struct snd_sof_dev *sdev) { struct snd_sof_pdata *plat_data = sdev->pdata; @@ -104,6 +144,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) return ret; } + sdev->fw_state = SOF_FW_BOOT_PREPARE; + /* check machine info */ ret = sof_machine_check(sdev); if (ret < 0) { @@ -143,7 +185,12 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) goto fw_load_err; } - /* boot the firmware */ + sdev->fw_state = SOF_FW_BOOT_IN_PROGRESS; + + /* + * Boot the firmware. The FW boot status will be modified + * in snd_sof_run_firmware() depending on the outcome. + */ ret = snd_sof_run_firmware(sdev); if (ret < 0) { dev_err(sdev->dev, "error: failed to boot DSP firmware %d\n", @@ -254,6 +301,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) sdev->pdata = plat_data; sdev->first_boot = true; + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; dev_set_drvdata(dev, sdev); /* check all mandatory ops */ diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c index b1783360fe10..1782f5092639 100644 --- a/sound/soc/sof/intel/hda-loader.c +++ b/sound/soc/sof/intel/hda-loader.c @@ -295,7 +295,6 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) /* init for booting wait */ init_waitqueue_head(&sdev->boot_wait); - sdev->boot_complete = false; /* prepare DMA for code loader stream */ tag = cl_stream_prepare(sdev, 0x40, stripped_firmware.size, diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 8d27846d9048..3335e0076180 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -168,7 +168,7 @@ void hda_dsp_dump_skl(struct snd_sof_dev *sdev, u32 flags) panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_ADSP_ERROR_CODE_SKL + 0x4); - if (sdev->boot_complete) { + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, HDA_DSP_STACK_DUMP_SIZE); snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, @@ -195,7 +195,7 @@ void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags) HDA_DSP_SRAM_REG_FW_STATUS); panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_TRACEP); - if (sdev->boot_complete) { + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, HDA_DSP_STACK_DUMP_SIZE); snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 293c5ae8e882..6186c7ff0447 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -347,19 +347,12 @@ void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev) break; case SOF_IPC_FW_READY: /* check for FW boot completion */ - if (!sdev->boot_complete) { + if (sdev->fw_state == SOF_FW_BOOT_IN_PROGRESS) { err = sof_ops(sdev)->fw_ready(sdev, cmd); - if (err < 0) { - /* - * this indicates a mismatch in ABI - * between the driver and fw - */ - dev_err(sdev->dev, "error: ABI mismatch %d\n", - err); - } else { - /* firmware boot completed OK */ - sdev->boot_complete = true; - } + if (err < 0) + sdev->fw_state = SOF_FW_BOOT_READY_FAILED; + else + sdev->fw_state = SOF_FW_BOOT_COMPLETE; /* wake up firmware loader */ wake_up(&sdev->boot_wait); diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c index 432d12bd4937..31847aa3975d 100644 --- a/sound/soc/sof/loader.c +++ b/sound/soc/sof/loader.c @@ -512,7 +512,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) int init_core_mask; init_waitqueue_head(&sdev->boot_wait); - sdev->boot_complete = false; /* create read-only fw_version debugfs to store boot version info */ if (sdev->first_boot) { @@ -544,19 +543,27 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) init_core_mask = ret; - /* now wait for the DSP to boot */ - ret = wait_event_timeout(sdev->boot_wait, sdev->boot_complete, + /* + * now wait for the DSP to boot. There are 3 possible outcomes: + * 1. Boot wait times out indicating FW boot failure. + * 2. FW boots successfully and fw_ready op succeeds. + * 3. FW boots but fw_ready op fails. + */ + ret = wait_event_timeout(sdev->boot_wait, + sdev->fw_state > SOF_FW_BOOT_IN_PROGRESS, msecs_to_jiffies(sdev->boot_timeout)); if (ret == 0) { dev_err(sdev->dev, "error: firmware boot failure\n"); snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX | SOF_DBG_TEXT | SOF_DBG_PCI); - /* after this point FW_READY msg should be ignored */ - sdev->boot_complete = true; + sdev->fw_state = SOF_FW_BOOT_FAILED; return -EIO; } - dev_info(sdev->dev, "firmware boot complete\n"); + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) + dev_info(sdev->dev, "firmware boot complete\n"); + else + return -EIO; /* FW boots but fw_ready op failed */ /* perform post fw run operations */ ret = snd_sof_dsp_post_fw_run(sdev); diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index d1a7b98886d1..84290bbeebdd 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -70,6 +70,8 @@ static int sof_resume(struct device *dev, bool runtime_resume) return ret; } + sdev->fw_state = SOF_FW_BOOT_PREPARE; + /* load the firmware */ ret = snd_sof_load_firmware(sdev); if (ret < 0) { @@ -79,7 +81,12 @@ static int sof_resume(struct device *dev, bool runtime_resume) return ret; } - /* boot the firmware */ + sdev->fw_state = SOF_FW_BOOT_IN_PROGRESS; + + /* + * Boot the firmware. The FW boot status will be modified + * in snd_sof_run_firmware() depending on the outcome. + */ ret = snd_sof_run_firmware(sdev); if (ret < 0) { dev_err(sdev->dev, @@ -128,6 +135,9 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) if (!sof_ops(sdev)->suspend) return 0; + if (sdev->fw_state != SOF_FW_BOOT_COMPLETE) + goto power_down; + /* release trace */ snd_sof_release_trace(sdev); @@ -165,6 +175,12 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) ret); } +power_down: + + /* return if the DSP was not probed successfully */ + if (sdev->fw_state == SOF_FW_BOOT_NOT_STARTED) + return 0; + /* power down all DSP cores */ if (runtime_suspend) ret = snd_sof_dsp_runtime_suspend(sdev); @@ -175,6 +191,9 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) "error: failed to power down DSP during suspend %d\n", ret); + /* reset FW state */ + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; + return ret; } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 54dd6d4b4c12..220b35141c34 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -298,6 +298,15 @@ struct snd_sof_ipc_msg { bool ipc_complete; }; +enum snd_sof_fw_state { + SOF_FW_BOOT_NOT_STARTED = 0, + SOF_FW_BOOT_PREPARE, + SOF_FW_BOOT_IN_PROGRESS, + SOF_FW_BOOT_FAILED, + SOF_FW_BOOT_READY_FAILED, /* firmware booted but fw_ready op failed */ + SOF_FW_BOOT_COMPLETE, +}; + /* * SOF Device Level. */ @@ -319,7 +328,7 @@ struct snd_sof_dev { /* DSP firmware boot */ wait_queue_head_t boot_wait; - u32 boot_complete; + enum snd_sof_fw_state fw_state; u32 first_boot; /* work queue in case the probe is implemented in two steps */ -- cgit v1.2.3 From e8b7cab8cec3386598de29bbca70d8d31aacc709 Mon Sep 17 00:00:00 2001 From: Karol Trzcinski Date: Tue, 17 Dec 2019 18:26:10 -0600 Subject: ASoC: SOF: define struct with compiler name and version Add compiler information structure sof_ipc_cc_version. Add new enum value in sof_ipc_ext_data for new structure. This struct will be used to show more information about firmware in host system. It will be helpful during debugging. Signed-off-by: Karol Trzcinski Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof/info.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/sound/sof/info.h b/include/sound/sof/info.h index a9156b4a062c..1c560144996c 100644 --- a/include/sound/sof/info.h +++ b/include/sound/sof/info.h @@ -30,6 +30,7 @@ enum sof_ipc_ext_data { SOF_IPC_EXT_DMA_BUFFER = 0, SOF_IPC_EXT_WINDOW, + SOF_IPC_EXT_CC_INFO, }; /* FW version - SOF_IPC_GLB_VERSION */ @@ -115,4 +116,18 @@ struct sof_ipc_window { struct sof_ipc_window_elem window[]; } __packed; +struct sof_ipc_cc_version { + struct sof_ipc_ext_data_hdr ext_hdr; + uint32_t major; + uint32_t minor; + uint32_t micro; + + /* reserved for future use */ + uint32_t reserved[4]; + + char name[16]; /* null terminated compiler name */ + char optim[4]; /* null terminated compiler -O flag value */ + char desc[]; /* null terminated compiler description */ +} __packed; + #endif -- cgit v1.2.3 From 59283959e82bd272a5e15e4ed5274cdd059fb532 Mon Sep 17 00:00:00 2001 From: Karol Trzcinski Date: Tue, 17 Dec 2019 18:26:11 -0600 Subject: ASoC: SOF: log compiler name and version information Log information about used compilator and optimization level in sof firmware to host system. It will be helful to catch some compiler dependent bugs. Signed-off-by: Karol Trzcinski Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/loader.c | 39 +++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 1 + 2 files changed, 40 insertions(+) diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c index 31847aa3975d..235be4fc0862 100644 --- a/sound/soc/sof/loader.c +++ b/sound/soc/sof/loader.c @@ -32,6 +32,42 @@ static int get_ext_windows(struct snd_sof_dev *sdev, return 0; } +static int get_cc_info(struct snd_sof_dev *sdev, + struct sof_ipc_ext_data_hdr *ext_hdr) +{ + int ret; + + struct sof_ipc_cc_version *cc = + container_of(ext_hdr, struct sof_ipc_cc_version, ext_hdr); + + dev_dbg(sdev->dev, "Firmware info: used compiler %s %d:%d:%d%s used optimization flags %s\n", + cc->name, cc->major, cc->minor, cc->micro, cc->desc, + cc->optim); + + /* create read-only cc_version debugfs to store compiler version info */ + /* use local copy of the cc_version to prevent data corruption */ + if (sdev->first_boot) { + sdev->cc_version = devm_kmalloc(sdev->dev, cc->ext_hdr.hdr.size, + GFP_KERNEL); + + if (!sdev->cc_version) + return -ENOMEM; + + memcpy(sdev->cc_version, cc, cc->ext_hdr.hdr.size); + ret = snd_sof_debugfs_buf_item(sdev, sdev->cc_version, + cc->ext_hdr.hdr.size, + "cc_version", 0444); + + /* errors are only due to memory allocation, not debugfs */ + if (ret < 0) { + dev_err(sdev->dev, "error: snd_sof_debugfs_buf_item failed\n"); + return ret; + } + } + + return 0; +} + /* parse the extended FW boot data structures from FW boot message */ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset) { @@ -65,6 +101,9 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset) case SOF_IPC_EXT_WINDOW: ret = get_ext_windows(sdev, ext_hdr); break; + case SOF_IPC_EXT_CC_INFO: + ret = get_cc_info(sdev, ext_hdr); + break; default: dev_warn(sdev->dev, "warning: unknown ext header type %d size 0x%x\n", ext_hdr->type, ext_hdr->hdr.size); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 220b35141c34..3f1e1eb7c55f 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -361,6 +361,7 @@ struct snd_sof_dev { struct snd_dma_buffer dmab_bdl; struct sof_ipc_fw_ready fw_ready; struct sof_ipc_fw_version fw_version; + struct sof_ipc_cc_version *cc_version; /* topology */ struct snd_soc_tplg_ops *tplg_ops; -- cgit v1.2.3 From 35dc19ad86fdf6a2af30c10c281e5fe10d45c041 Mon Sep 17 00:00:00 2001 From: Yong Zhi Date: Tue, 17 Dec 2019 18:26:12 -0600 Subject: ASoC: Intel: Add machine driver for da7219_max98373 This patch adds sof_da7219_max98373 machine driver. Tested on JasperLake platform with SOF only. Signed-off-by: Yong Zhi Signed-off-by: Bard Liao Signed-off-by: Vani Ganji Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 18 ++ sound/soc/intel/boards/Makefile | 3 + sound/soc/intel/boards/sof_da7219_max98373.c | 371 ++++++++++++++++++++++ sound/soc/intel/common/soc-acpi-intel-jsl-match.c | 7 + 4 files changed, 399 insertions(+) create mode 100644 sound/soc/intel/boards/sof_da7219_max98373.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index a8d71b5ed41e..b922596cf1e8 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -474,4 +474,22 @@ config SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH endif ## SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK +if SND_SOC_SOF_JASPERLAKE + +config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH + tristate "SOF with DA7219 and MAX98373 in I2S Mode" + depends on I2C && ACPI + depends on MFD_INTEL_LPSS || COMPILE_TEST + select SND_SOC_DA7219 + select SND_SOC_MAX98373 + select SND_SOC_DMIC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC + help + This adds support for ASoC machine driver for SOF platforms + with DA7219 + MAX98373 I2S audio codec. + Say Y if you have such a device. + If unsure select "N". + +endif ## SND_SOC_SOF_JASPERLAKE + endif ## SND_SOC_INTEL_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index ba1aa89db09d..5369627fa4c8 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -28,6 +28,7 @@ snd-soc-skl_rt286-objs := skl_rt286.o snd-soc-skl_hda_dsp-objs := skl_hda_dsp_generic.o skl_hda_dsp_common.o hda_dsp_common.o snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o +snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o hda_dsp_common.o obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o @@ -58,3 +59,5 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ssm4567.o obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o +obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH) += snd-soc-sof_da7219_max98373.o + diff --git a/sound/soc/intel/boards/sof_da7219_max98373.c b/sound/soc/intel/boards/sof_da7219_max98373.c new file mode 100644 index 000000000000..8f44f13d2848 --- /dev/null +++ b/sound/soc/intel/boards/sof_da7219_max98373.c @@ -0,0 +1,371 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2019 Intel Corporation. + +/* + * Intel SOF Machine driver for DA7219 + MAX98373 codec + */ + +#include +#include +#include +#include +#include +#include +#include +#include "../../codecs/da7219.h" +#include "../../codecs/da7219-aad.h" +#include "hda_dsp_common.h" + +#define DIALOG_CODEC_DAI "da7219-hifi" +#define MAX98373_CODEC_DAI "max98373-aif1" +#define MAXIM_DEV0_NAME "i2c-MX98373:00" +#define MAXIM_DEV1_NAME "i2c-MX98373:01" + +struct hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct card_private { + struct snd_soc_jack headset; + struct list_head hdmi_pcm_list; + struct snd_soc_jack hdmi[3]; +}; + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + int ret = 0; + + codec_dai = snd_soc_card_get_codec_dai(card, DIALOG_CODEC_DAI); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); + return -EIO; + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_MCLK, + 0, 0); + if (ret) + dev_err(card->dev, "failed to stop PLL: %d\n", ret); + } else if (SND_SOC_DAPM_EVENT_ON(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, + 0, DA7219_PLL_FREQ_OUT_98304); + if (ret) + dev_err(card->dev, "failed to start PLL: %d\n", ret); + } + + return ret; +} + +static const struct snd_kcontrol_new controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Left Spk"), + SOC_DAPM_PIN_SWITCH("Right Spk"), +}; + +static const struct snd_soc_dapm_widget widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Left Spk", NULL), + SND_SOC_DAPM_SPK("Right Spk", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_PRE_PMU), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + { "Headphone Jack", NULL, "HPL" }, + { "Headphone Jack", NULL, "HPR" }, + + { "Left Spk", NULL, "Left BE_OUT" }, + { "Right Spk", NULL, "Right BE_OUT" }, + + { "MIC", NULL, "Headset Mic" }, + + { "Headphone Jack", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, +}; + +static struct snd_soc_jack headset; + +static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_jack *jack; + int ret; + + /* Configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24000000, + SND_SOC_CLOCK_IN); + if (ret) { + dev_err(rtd->dev, "can't set codec sysclk configuration\n"); + return ret; + } + + /* + * Headset buttons map to the google Reference headset. + * These can be configured by userspace. + */ + ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | + SND_JACK_BTN_1 | SND_JACK_BTN_2 | + SND_JACK_BTN_3 | SND_JACK_LINEOUT, + &headset, NULL, 0); + if (ret) { + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); + return ret; + } + + jack = &headset; + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); + da7219_aad_jack_det(component, jack); + + return ret; +} + +static int ssp1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *runtime = substream->private_data; + int ret, j; + + for (j = 0; j < runtime->num_codecs; j++) { + struct snd_soc_dai *codec_dai = runtime->codec_dais[j]; + + if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) { + /* vmon_slot_no = 0 imon_slot_no = 1 for TX slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 3, 4, 16); + if (ret < 0) { + dev_err(runtime->dev, "DEV0 TDM slot err:%d\n", ret); + return ret; + } + } + if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) { + /* vmon_slot_no = 2 imon_slot_no = 3 for TX slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC, 3, 4, 16); + if (ret < 0) { + dev_err(runtime->dev, "DEV1 TDM slot err:%d\n", ret); + return ret; + } + } + } + + return 0; +} + +static struct snd_soc_ops ssp1_ops = { + .hw_params = ssp1_hw_params, +}; + +static struct snd_soc_codec_conf max98373_codec_conf[] = { + { + .dlc = COMP_CODEC_CONF(MAXIM_DEV0_NAME), + .name_prefix = "Right", + }, + { + .dlc = COMP_CODEC_CONF(MAXIM_DEV1_NAME), + .name_prefix = "Left", + }, +}; + +static int hdmi_init(struct snd_soc_pcm_runtime *rtd) +{ + struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = dai->id; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int card_late_probe(struct snd_soc_card *card) +{ + struct card_private *ctx = snd_soc_card_get_drvdata(card); + struct snd_soc_acpi_mach *mach = (card->dev)->platform_data; + struct hdmi_pcm *pcm; + + if (mach->mach_params.common_hdmi_codec_drv) { + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct hdmi_pcm, + head); + return hda_dsp_hdmi_build_controls(card, + pcm->codec_dai->component); + } + + return -EINVAL; +} + +SND_SOC_DAILINK_DEF(ssp0_pin, + DAILINK_COMP_ARRAY(COMP_CPU("SSP0 Pin"))); +SND_SOC_DAILINK_DEF(ssp0_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00", DIALOG_CODEC_DAI))); + +SND_SOC_DAILINK_DEF(ssp1_pin, + DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); +SND_SOC_DAILINK_DEF(ssp1_amps, + DAILINK_COMP_ARRAY( + /* Left */ COMP_CODEC(MAXIM_DEV0_NAME, MAX98373_CODEC_DAI), + /* Right */ COMP_CODEC(MAXIM_DEV1_NAME, MAX98373_CODEC_DAI))); + +SND_SOC_DAILINK_DEF(dmic_pin, + DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); +SND_SOC_DAILINK_DEF(dmic_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi"))); + +SND_SOC_DAILINK_DEF(idisp1_pin, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); +SND_SOC_DAILINK_DEF(idisp1_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); + +SND_SOC_DAILINK_DEF(idisp2_pin, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); +SND_SOC_DAILINK_DEF(idisp2_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); + +SND_SOC_DAILINK_DEF(idisp3_pin, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); +SND_SOC_DAILINK_DEF(idisp3_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); + +SND_SOC_DAILINK_DEF(platform, /* subject to be overridden during probe */ + DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3"))); + +static struct snd_soc_dai_link dais[] = { + /* Back End DAI links */ + { + .name = "SSP1-Codec", + .id = 0, + .ignore_pmdown_time = 1, + .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, /* IV feedback */ + .ops = &ssp1_ops, + SND_SOC_DAILINK_REG(ssp1_pin, ssp1_amps, platform), + }, + { + .name = "SSP0-Codec", + .id = 1, + .no_pcm = 1, + .init = da7219_codec_init, + .ignore_pmdown_time = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform), + }, + { + .name = "dmic01", + .id = 2, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform), + }, + { + .name = "iDisp1", + .id = 3, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), + }, + { + .name = "iDisp2", + .id = 4, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), + }, + { + .name = "iDisp3", + .id = 5, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), + }, +}; + +static struct snd_soc_card card_da7219_m98373 = { + .name = "da7219max", + .owner = THIS_MODULE, + .dai_link = dais, + .num_links = ARRAY_SIZE(dais), + .controls = controls, + .num_controls = ARRAY_SIZE(controls), + .dapm_widgets = widgets, + .num_dapm_widgets = ARRAY_SIZE(widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), + .codec_conf = max98373_codec_conf, + .num_configs = ARRAY_SIZE(max98373_codec_conf), + .fully_routed = true, + .late_probe = card_late_probe, +}; + +static int audio_probe(struct platform_device *pdev) +{ + static struct snd_soc_card *card; + struct snd_soc_acpi_mach *mach; + struct card_private *ctx; + int ret; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); + if (!ctx) + return -ENOMEM; + + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + card = (struct snd_soc_card *)pdev->id_entry->driver_data; + card->dev = &pdev->dev; + + mach = (&pdev->dev)->platform_data; + ret = snd_soc_fixup_dai_links_platform_name(card, + mach->mach_params.platform); + if (ret) + return ret; + + snd_soc_card_set_drvdata(card, ctx); + + return devm_snd_soc_register_card(&pdev->dev, card); +} + +static const struct platform_device_id board_ids[] = { + { + .name = "sof_da7219_max98373", + .driver_data = (kernel_ulong_t)&card_da7219_m98373, + }, + { } +}; + +static struct platform_driver audio = { + .probe = audio_probe, + .driver = { + .name = "sof_da7219_max98373", + .pm = &snd_soc_pm_ops, + }, + .id_table = board_ids, +}; +module_platform_driver(audio) + +/* Module information */ +MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver"); +MODULE_AUTHOR("Yong Zhi "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:sof_da7219_max98373"); diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c index 1c68a04f0c6e..ed2b125f6a11 100644 --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c @@ -10,6 +10,13 @@ #include struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { + { + .id = "DLGS7219", + .drv_name = "sof_da7219_max98373", + .machine_quirk = snd_soc_acpi_codec_list, + .sof_fw_filename = "sof-jsl.ri", + .sof_tplg_filename = "sof-jsl-da7219.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_machines); -- cgit v1.2.3 From 91dce767cd0b08be9f1c87bb2de8e63391a72692 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 17 Dec 2019 18:26:13 -0600 Subject: ASoC: SOF: Intel: drop HDA codec upon probe failure In case a HDA codec probe fails, do not raise error immediately, but instead remove the codec from bus->codec_mask and continue probe for other codecs. This allows for more robust behaviour in cases where one codec in the system is faulty. SOF driver load can still proceed with the codecs that can be probed successfully. Probe may still fail if suitable machine driver is not found, but in many cases the generic HDA machine driver can operate with a subset of codecs. Reviewed-by: Ranjani Sridharan Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-codec.c | 12 +++++------- sound/soc/sof/intel/hda.h | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 65761e095184..d7855b1f8e2e 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -140,8 +140,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, } /* Codec initialization */ -int hda_codec_probe_bus(struct snd_sof_dev *sdev, - bool hda_codec_use_common_hdmi) +void hda_codec_probe_bus(struct snd_sof_dev *sdev, + bool hda_codec_use_common_hdmi) { struct hdac_bus *bus = sof_to_bus(sdev); int i, ret; @@ -154,13 +154,11 @@ int hda_codec_probe_bus(struct snd_sof_dev *sdev, ret = hda_codec_probe(sdev, i, hda_codec_use_common_hdmi); if (ret < 0) { - dev_err(bus->dev, "error: codec #%d probe error, ret: %d\n", - i, ret); - return ret; + dev_warn(bus->dev, "codec #%d probe error, ret: %d\n", + i, ret); + bus->codec_mask &= ~BIT(i); } } - - return 0; } EXPORT_SYMBOL(hda_codec_probe_bus); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 01529c7058f3..47408ec0de40 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -575,8 +575,8 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev); /* * HDA Codec operations. */ -int hda_codec_probe_bus(struct snd_sof_dev *sdev, - bool hda_codec_use_common_hdmi); +void hda_codec_probe_bus(struct snd_sof_dev *sdev, + bool hda_codec_use_common_hdmi); void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev); void hda_codec_jack_check(struct snd_sof_dev *sdev); -- cgit v1.2.3 From aa2b4a59871a0528bccb91ad94768c9dc2b7bb3d Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 17 Dec 2019 18:26:14 -0600 Subject: ASoC: Intel: boards: fix incorrect HDMI Kconfig dependency Fix typo in Kconfig dependencies. The correct dependency for HDMI is SND_SOC_SOF_HDA_AUDIO_CODEC. Reported-by: Yong Zhi Fixes: e3d8f8ae5b1e ("ASoC: Intel: boards: make common HDMI driver the default for SOF") Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index b922596cf1e8..11dbc59046f8 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -274,7 +274,7 @@ config SND_SOC_INTEL_DA7219_MAX98357A_GENERIC select SND_SOC_DA7219 select SND_SOC_MAX98357A select SND_SOC_DMIC - select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC select SND_SOC_HDAC_HDMI config SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON @@ -401,7 +401,7 @@ config SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH select SND_SOC_RT5682 select SND_SOC_MAX98357A select SND_SOC_DMIC - select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC select SND_SOC_HDAC_HDMI help This adds support for ASoC machine driver for Geminilake platforms @@ -415,7 +415,7 @@ if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC || SND_SOC_SOF_HDA_AUDIO_CODEC config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH tristate "SKL/KBL/BXT/APL with HDA Codecs" - select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC select SND_SOC_HDAC_HDMI select SND_SOC_DMIC # SND_SOC_HDAC_HDA is already selected @@ -435,7 +435,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH (SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST)) select SND_SOC_RT5682 select SND_SOC_DMIC - select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC select SND_SOC_HDAC_HDMI help This adds support for ASoC machine driver for SOF platforms @@ -465,7 +465,7 @@ config SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH select SND_SOC_RT5682 select SND_SOC_DMIC select SND_SOC_HDAC_HDMI - select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_CODEC + select SND_HDA_CODEC_HDMI if SND_SOC_SOF_HDA_AUDIO_CODEC help This adds support for ASoC machine driver for SOF platform with RT1011 + RT5682 I2S codec. -- cgit v1.2.3 From 9c1d4cf6ac26f890d82278326f6c7552c53ffb65 Mon Sep 17 00:00:00 2001 From: Guido Roncarolo Date: Tue, 17 Dec 2019 18:26:15 -0600 Subject: ASoC: SOF: imx: Describe SAI parameters to be sent to DSP Introduce sof_ipc_dai_sai_params to keep information that we get from topology and we send to DSP FW. For the moment it is identical to ESAI one but it will evolve shortly independently Signed-off-by: Guido Roncarolo Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof/dai-imx.h | 20 ++++++++++++++++++++ include/sound/sof/dai.h | 1 + include/uapi/sound/sof/tokens.h | 3 +-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/sound/sof/dai-imx.h b/include/sound/sof/dai-imx.h index e02fb0b0fae1..ff9088dcc6f2 100644 --- a/include/sound/sof/dai-imx.h +++ b/include/sound/sof/dai-imx.h @@ -31,4 +31,24 @@ struct sof_ipc_dai_esai_params { uint16_t reserved2; /* alignment */ } __packed; +/* SAI Configuration Request - SOF_IPC_DAI_SAI_CONFIG */ +struct sof_ipc_dai_sai_params { + struct sof_ipc_hdr hdr; + + /* MCLK */ + uint16_t reserved1; + uint16_t mclk_id; + uint32_t mclk_direction; + + uint32_t mclk_rate; /* MCLK frequency in Hz */ + uint32_t fsync_rate; /* FSYNC frequency in Hz */ + uint32_t bclk_rate; /* BCLK frequency in Hz */ + + /* TDM */ + uint32_t tdm_slots; + uint32_t rx_slots; + uint32_t tx_slots; + uint16_t tdm_slot_width; + uint16_t reserved2; /* alignment */ +} __packed; #endif diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index c229565767e5..2565edd336f1 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -75,6 +75,7 @@ struct sof_ipc_dai_config { struct sof_ipc_dai_hda_params hda; struct sof_ipc_dai_alh_params alh; struct sof_ipc_dai_esai_params esai; + struct sof_ipc_dai_sai_params sai; }; } __packed; diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h index a9a5c4d0a892..2a25cd8da503 100644 --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h @@ -113,8 +113,7 @@ #define SOF_TKN_EFFECT_TYPE SOF_TKN_PROCESS_TYPE /* SAI */ -#define SOF_TKN_IMX_SAI_FIRST_TOKEN 1000 -/* TODO: Add SAI tokens */ +#define SOF_TKN_IMX_SAI_MCLK_ID 1000 /* ESAI */ #define SOF_TKN_IMX_ESAI_MCLK_ID 1100 -- cgit v1.2.3 From d88cbd6feaf4b5de07d91f531112cf57ce821d78 Mon Sep 17 00:00:00 2001 From: Guido Roncarolo Date: Tue, 17 Dec 2019 18:26:16 -0600 Subject: ASoC: SOF: imx: Read SAI parameters and send them to DSP Follow example from Intel SSP. Signed-off-by: Guido Roncarolo Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218002616.7652-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/pcm.c | 8 ++++++ sound/soc/sof/topology.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 86829e5bd62d..9bb6388742e1 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -693,6 +693,14 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, channels->min = dai->dai_config->esai.tdm_slots; channels->max = dai->dai_config->esai.tdm_slots; + dev_dbg(component->dev, + "channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; + case SOF_DAI_IMX_SAI: + channels->min = dai->dai_config->sai.tdm_slots; + channels->max = dai->dai_config->sai.tdm_slots; + dev_dbg(component->dev, "channels_min: %d channels_max: %d\n", channels->min, channels->max); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index e06fa7c7e502..9f4f8868b386 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -695,6 +695,13 @@ static const struct sof_topology_token esai_tokens[] = { offsetof(struct sof_ipc_dai_esai_params, mclk_id), 0}, }; +/* SAI */ +static const struct sof_topology_token sai_tokens[] = { + {SOF_TKN_IMX_SAI_MCLK_ID, + SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16, + offsetof(struct sof_ipc_dai_sai_params, mclk_id), 0}, +}; + /* * DMIC PDM Tokens * SOF_TKN_INTEL_DMIC_PDM_CTRL_ID should be the first token @@ -2704,8 +2711,66 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index, struct snd_soc_tplg_hw_config *hw_config, struct sof_ipc_dai_config *config) { - /*TODO: Add implementation */ - return 0; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_soc_tplg_private *private = &cfg->priv; + struct sof_ipc_reply reply; + u32 size = sizeof(*config); + int ret; + + /* handle master/slave and inverted clocks */ + sof_dai_set_format(hw_config, config); + + /* init IPC */ + memset(&config->sai, 0, sizeof(struct sof_ipc_dai_sai_params)); + config->hdr.size = size; + + ret = sof_parse_tokens(scomp, &config->sai, sai_tokens, + ARRAY_SIZE(sai_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse sai tokens failed %d\n", + le32_to_cpu(private->size)); + return ret; + } + + config->sai.mclk_rate = le32_to_cpu(hw_config->mclk_rate); + config->sai.mclk_direction = hw_config->mclk_direction; + + config->sai.tdm_slots = le32_to_cpu(hw_config->tdm_slots); + config->sai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width); + config->sai.rx_slots = le32_to_cpu(hw_config->rx_slots); + config->sai.tx_slots = le32_to_cpu(hw_config->tx_slots); + + dev_info(scomp->dev, + "tplg: config SAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n", + config->dai_index, config->format, + config->sai.mclk_rate, config->sai.tdm_slot_width, + config->sai.tdm_slots, config->sai.mclk_id); + + if (config->sai.tdm_slots < 1 || config->sai.tdm_slots > 8) { + dev_err(scomp->dev, "error: invalid channel count for SAI%d\n", + config->dai_index); + return -EINVAL; + } + + /* send message to DSP */ + ret = sof_ipc_tx_message(sdev->ipc, + config->hdr.cmd, config, size, &reply, + sizeof(reply)); + + if (ret < 0) { + dev_err(scomp->dev, "error: failed to set DAI config for SAI%d\n", + config->dai_index); + return ret; + } + + /* set config for all DAI's with name matching the link name */ + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "error: failed to save DAI config for SAI%d\n", + config->dai_index); + + return ret; } static int sof_link_esai_load(struct snd_soc_component *scomp, int index, -- cgit v1.2.3 From fb522dbb4531c14193115a09905c6c31b37dbfc5 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 18 Dec 2019 18:24:18 +0100 Subject: ASoC: meson: axg-fifo: add fifo depth to the bindings documentation Add a new property with the depth of the fifo in bytes. This is useful since some instance of the fifo, even on the same SoC, may have different depth. The depth is useful is set some parameters of the fifo. Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20191218172420.1199117-3-jbrunet@baylibre.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt b/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt index 3080979350a0..fa4545ed81ca 100644 --- a/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt +++ b/Documentation/devicetree/bindings/sound/amlogic,axg-fifo.txt @@ -17,6 +17,9 @@ Required properties: * "arb" : memory ARB line (required) * "rst" : dedicated device reset line (optional) - #sound-dai-cells: must be 0. +- amlogic,fifo-depth: The size of the controller's fifo in bytes. This + is useful for determining certain configuration such + as the flush threshold of the fifo Example of FRDDR A on the A113 SoC: @@ -27,4 +30,5 @@ frddr_a: audio-controller@1c0 { interrupts = ; clocks = <&clkc_audio AUD_CLKID_FRDDR_A>; resets = <&arb AXG_ARB_FRDDR_A>; + fifo-depth = <512>; }; -- cgit v1.2.3 From 72b46612d06b83851e2e4f7b538a0bbeb69c10de Mon Sep 17 00:00:00 2001 From: Dragos Tarcatu Date: Tue, 17 Dec 2019 18:05:18 -0600 Subject: ASoC: topology: Prevent use-after-free in snd_soc_get_pcm_runtime() remove_link() is currently calling snd_soc_remove_pcm_runtime() after it has already freed the memory for the link name. But this is later read from snd_soc_get_pcm_runtime() causing a KASAN use-after-free warning. Reorder the cleanups to fix this issue. Reviewed-by: Ranjani Sridharan Signed-off-by: Dragos Tarcatu Signed-off-by: Pierre-Louis Bossart Acked-by: Kuninori Morimoto Link: https://lore.kernel.org/r/20191218000518.5830-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/soc-topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index f8bd406c6198..2b3c74a0b126 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -548,14 +548,14 @@ static void remove_link(struct snd_soc_component *comp, if (dobj->ops && dobj->ops->link_unload) dobj->ops->link_unload(comp, dobj); - kfree(link->name); - kfree(link->stream_name); - kfree(link->cpus->dai_name); - list_del(&dobj->list); snd_soc_remove_pcm_runtime(comp->card, snd_soc_get_pcm_runtime(comp->card, link)); + + kfree(link->name); + kfree(link->stream_name); + kfree(link->cpus->dai_name); kfree(link); } -- cgit v1.2.3 From 864cee90d4bd870e5d5e5a0b1a6f055f4f951350 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 18 Dec 2019 18:24:17 +0100 Subject: ASoC: meson: axg-fifo: fix fifo threshold setup On TODDR sm1, the fifo threshold register field is slightly different compared to the other SoCs. This leads to the fifo A being flushed to memory every 8kB. If the period is smaller than that, several periods are pushed to memory and notified at once. This is not ideal. Fix the register field update. With this, the fifos are flushed every 128B. We could still do better, like adapt the threshold depending on the period size, but at least it consistent across the different SoC/fifos Fixes: 5ac825c3d85e ("ASoC: meson: axg-toddr: add sm1 support") Reported-by: Alden DSouza Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20191218172420.1199117-2-jbrunet@baylibre.com Signed-off-by: Mark Brown --- sound/soc/meson/axg-fifo.c | 27 +++++++++++++++++++++++++-- sound/soc/meson/axg-fifo.h | 6 ++++-- sound/soc/meson/axg-frddr.c | 24 ++++++++++++------------ sound/soc/meson/axg-toddr.c | 21 +++++++++------------ 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index 772eda857019..4365086c9a31 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -113,8 +113,10 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component, { struct snd_pcm_runtime *runtime = ss->runtime; struct axg_fifo *fifo = axg_fifo_data(ss); + unsigned int burst_num, period, threshold; dma_addr_t end_ptr; - unsigned int burst_num; + + period = params_period_bytes(params); /* Setup dma memory pointers */ end_ptr = runtime->dma_addr + runtime->dma_bytes - AXG_FIFO_BURST; @@ -122,9 +124,25 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component, regmap_write(fifo->map, FIFO_FINISH_ADDR, end_ptr); /* Setup interrupt periodicity */ - burst_num = params_period_bytes(params) / AXG_FIFO_BURST; + burst_num = period / AXG_FIFO_BURST; regmap_write(fifo->map, FIFO_INT_ADDR, burst_num); + /* + * Start the fifo request on the smallest of the following: + * - Half the fifo size + * - Half the period size + */ + threshold = min(period / 2, + (unsigned int)AXG_FIFO_MIN_DEPTH / 2); + + /* + * With the threshold in bytes, register value is: + * V = (threshold / burst) - 1 + */ + threshold /= AXG_FIFO_BURST; + regmap_field_write(fifo->field_threshold, + threshold ? threshold - 1 : 0); + /* Enable block count irq */ regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), @@ -347,6 +365,11 @@ int axg_fifo_probe(struct platform_device *pdev) return fifo->irq; } + fifo->field_threshold = + devm_regmap_field_alloc(dev, fifo->map, data->field_threshold); + if (IS_ERR(fifo->field_threshold)) + return PTR_ERR(fifo->field_threshold); + return devm_snd_soc_register_component(dev, data->component_drv, data->dai_drv, 1); } diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h index cf928d43b558..c442195ba191 100644 --- a/sound/soc/meson/axg-fifo.h +++ b/sound/soc/meson/axg-fifo.h @@ -9,7 +9,9 @@ struct clk; struct platform_device; +struct reg_field; struct regmap; +struct regmap_field; struct reset_control; struct snd_soc_component_driver; @@ -50,8 +52,6 @@ struct snd_soc_pcm_runtime; #define CTRL1_STATUS2_SEL_MASK GENMASK(11, 8) #define CTRL1_STATUS2_SEL(x) ((x) << 8) #define STATUS2_SEL_DDR_READ 0 -#define CTRL1_THRESHOLD_MASK GENMASK(23, 16) -#define CTRL1_THRESHOLD(x) ((x) << 16) #define CTRL1_FRDDR_DEPTH_MASK GENMASK(31, 24) #define CTRL1_FRDDR_DEPTH(x) ((x) << 24) #define FIFO_START_ADDR 0x08 @@ -67,12 +67,14 @@ struct axg_fifo { struct regmap *map; struct clk *pclk; struct reset_control *arb; + struct regmap_field *field_threshold; int irq; }; struct axg_fifo_match_data { const struct snd_soc_component_driver *component_drv; struct snd_soc_dai_driver *dai_drv; + struct reg_field field_threshold; }; int axg_fifo_pcm_open(struct snd_soc_component *component, diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c index 0a7d41257a38..df104303351f 100644 --- a/sound/soc/meson/axg-frddr.c +++ b/sound/soc/meson/axg-frddr.c @@ -50,7 +50,7 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); - unsigned int fifo_depth, fifo_threshold; + unsigned int fifo_depth; int ret; /* Enable pclk to access registers and clock the fifo ip */ @@ -68,11 +68,8 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, * Depth and threshold are zero based. */ fifo_depth = AXG_FIFO_MIN_CNT - 1; - fifo_threshold = (AXG_FIFO_MIN_CNT / 2) - 1; - regmap_update_bits(fifo->map, FIFO_CTRL1, - CTRL1_FRDDR_DEPTH_MASK | CTRL1_THRESHOLD_MASK, - CTRL1_FRDDR_DEPTH(fifo_depth) | - CTRL1_THRESHOLD(fifo_threshold)); + regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH_MASK, + CTRL1_FRDDR_DEPTH(fifo_depth)); return 0; } @@ -158,8 +155,9 @@ static const struct snd_soc_component_driver axg_frddr_component_drv = { }; static const struct axg_fifo_match_data axg_frddr_match_data = { - .component_drv = &axg_frddr_component_drv, - .dai_drv = &axg_frddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), + .component_drv = &axg_frddr_component_drv, + .dai_drv = &axg_frddr_dai_drv }; static const struct snd_soc_dai_ops g12a_frddr_ops = { @@ -281,8 +279,9 @@ static const struct snd_soc_component_driver g12a_frddr_component_drv = { }; static const struct axg_fifo_match_data g12a_frddr_match_data = { - .component_drv = &g12a_frddr_component_drv, - .dai_drv = &g12a_frddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), + .component_drv = &g12a_frddr_component_drv, + .dai_drv = &g12a_frddr_dai_drv }; /* On SM1, the output selection in on CTRL2 */ @@ -350,8 +349,9 @@ static const struct snd_soc_component_driver sm1_frddr_component_drv = { }; static const struct axg_fifo_match_data sm1_frddr_match_data = { - .component_drv = &sm1_frddr_component_drv, - .dai_drv = &g12a_frddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), + .component_drv = &sm1_frddr_component_drv, + .dai_drv = &g12a_frddr_dai_drv }; static const struct of_device_id axg_frddr_of_match[] = { diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c index f6023397c8fe..e711abcf8c12 100644 --- a/sound/soc/meson/axg-toddr.c +++ b/sound/soc/meson/axg-toddr.c @@ -89,7 +89,6 @@ static int axg_toddr_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); - unsigned int fifo_threshold; int ret; /* Enable pclk to access registers and clock the fifo ip */ @@ -107,11 +106,6 @@ static int axg_toddr_dai_startup(struct snd_pcm_substream *substream, /* Apply single buffer mode to the interface */ regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_TODDR_PP_MODE, 0); - /* TODDR does not have a configurable fifo depth */ - fifo_threshold = AXG_FIFO_MIN_CNT - 1; - regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_THRESHOLD_MASK, - CTRL1_THRESHOLD(fifo_threshold)); - return 0; } @@ -190,8 +184,9 @@ static const struct snd_soc_component_driver axg_toddr_component_drv = { }; static const struct axg_fifo_match_data axg_toddr_match_data = { - .component_drv = &axg_toddr_component_drv, - .dai_drv = &axg_toddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), + .component_drv = &axg_toddr_component_drv, + .dai_drv = &axg_toddr_dai_drv }; static const struct snd_soc_dai_ops g12a_toddr_ops = { @@ -228,8 +223,9 @@ static const struct snd_soc_component_driver g12a_toddr_component_drv = { }; static const struct axg_fifo_match_data g12a_toddr_match_data = { - .component_drv = &g12a_toddr_component_drv, - .dai_drv = &g12a_toddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), + .component_drv = &g12a_toddr_component_drv, + .dai_drv = &g12a_toddr_dai_drv }; static const char * const sm1_toddr_sel_texts[] = { @@ -297,8 +293,9 @@ static const struct snd_soc_component_driver sm1_toddr_component_drv = { }; static const struct axg_fifo_match_data sm1_toddr_match_data = { - .component_drv = &sm1_toddr_component_drv, - .dai_drv = &g12a_toddr_dai_drv + .field_threshold = REG_FIELD(FIFO_CTRL1, 12, 23), + .component_drv = &sm1_toddr_component_drv, + .dai_drv = &g12a_toddr_dai_drv }; static const struct of_device_id axg_toddr_of_match[] = { -- cgit v1.2.3 From 23b89e1d62c75f2c1985449e968886e8a97860c0 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 18 Dec 2019 18:24:19 +0100 Subject: ASoC: meson: axg-fifo: improve depth handling Let the fifo driver parse the fifo depth from DT. Eventually all DT should have this property. Until it is actually the case, default to 256 bytes if the property is missing. 256 bytes is the size of the smallest fifo on the supported SoCs. On the supported SoC, fifo A is usually bigger than the other ones. With depth known, we can improve the usage of the fifo and adapt the setup of request threshold. Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20191218172420.1199117-4-jbrunet@baylibre.com Signed-off-by: Mark Brown --- sound/soc/meson/axg-fifo.c | 19 +++++++++++++++++-- sound/soc/meson/axg-fifo.h | 1 + sound/soc/meson/axg-frddr.c | 13 ++++--------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index 4365086c9a31..c2742a02d866 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -132,8 +132,7 @@ int axg_fifo_pcm_hw_params(struct snd_soc_component *component, * - Half the fifo size * - Half the period size */ - threshold = min(period / 2, - (unsigned int)AXG_FIFO_MIN_DEPTH / 2); + threshold = min(period / 2, fifo->depth / 2); /* * With the threshold in bytes, register value is: @@ -320,6 +319,7 @@ int axg_fifo_probe(struct platform_device *pdev) const struct axg_fifo_match_data *data; struct axg_fifo *fifo; void __iomem *regs; + int ret; data = of_device_get_match_data(dev); if (!data) { @@ -370,6 +370,21 @@ int axg_fifo_probe(struct platform_device *pdev) if (IS_ERR(fifo->field_threshold)) return PTR_ERR(fifo->field_threshold); + ret = of_property_read_u32(dev->of_node, "amlogic,fifo-depth", + &fifo->depth); + if (ret) { + /* Error out for anything but a missing property */ + if (ret != -EINVAL) + return ret; + /* + * If the property is missing, it might be because of an old + * DT. In such case, assume the smallest known fifo depth + */ + fifo->depth = 256; + dev_warn(dev, "fifo depth not found, assume %u bytes\n", + fifo->depth); + } + return devm_snd_soc_register_component(dev, data->component_drv, data->dai_drv, 1); } diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h index c442195ba191..521b54e98fd3 100644 --- a/sound/soc/meson/axg-fifo.h +++ b/sound/soc/meson/axg-fifo.h @@ -68,6 +68,7 @@ struct axg_fifo { struct clk *pclk; struct reset_control *arb; struct regmap_field *field_threshold; + unsigned int depth; int irq; }; diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c index df104303351f..c3ae8ac30745 100644 --- a/sound/soc/meson/axg-frddr.c +++ b/sound/soc/meson/axg-frddr.c @@ -50,7 +50,7 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); - unsigned int fifo_depth; + unsigned int val; int ret; /* Enable pclk to access registers and clock the fifo ip */ @@ -61,15 +61,10 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, /* Apply single buffer mode to the interface */ regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_FRDDR_PP_MODE, 0); - /* - * TODO: We could adapt the fifo depth and the fifo threshold - * depending on the expected memory throughput and lantencies - * For now, we'll just use the same values as the vendor kernel - * Depth and threshold are zero based. - */ - fifo_depth = AXG_FIFO_MIN_CNT - 1; + /* Use all fifo depth */ + val = (fifo->depth / AXG_FIFO_BURST) - 1; regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH_MASK, - CTRL1_FRDDR_DEPTH(fifo_depth)); + CTRL1_FRDDR_DEPTH(val)); return 0; } -- cgit v1.2.3 From 42b5ac832b0c3bf5b0bf98ea6d99efa5fb5d5075 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 18 Dec 2019 18:24:20 +0100 Subject: ASoC: meson: axg-fifo: relax period size constraints Now that the fifo depths and thresholds are properly in the axg-fifo driver, we can relax the constraints on period. As long as the period is a multiple of the fifo burst size (8 bytes) things should be OK. Signed-off-by: Jerome Brunet Link: https://lore.kernel.org/r/20191218172420.1199117-5-jbrunet@baylibre.com Signed-off-by: Mark Brown --- sound/soc/meson/axg-fifo.c | 8 ++++---- sound/soc/meson/axg-fifo.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c index c2742a02d866..c12b0d5e8ebf 100644 --- a/sound/soc/meson/axg-fifo.c +++ b/sound/soc/meson/axg-fifo.c @@ -34,7 +34,7 @@ static struct snd_pcm_hardware axg_fifo_hw = { .rate_max = 192000, .channels_min = 1, .channels_max = AXG_FIFO_CH_MAX, - .period_bytes_min = AXG_FIFO_MIN_DEPTH, + .period_bytes_min = AXG_FIFO_BURST, .period_bytes_max = UINT_MAX, .periods_min = 2, .periods_max = UINT_MAX, @@ -227,17 +227,17 @@ int axg_fifo_pcm_open(struct snd_soc_component *component, /* * Make sure the buffer and period size are multiple of the FIFO - * minimum depth size + * burst */ ret = snd_pcm_hw_constraint_step(ss->runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - AXG_FIFO_MIN_DEPTH); + AXG_FIFO_BURST); if (ret) return ret; ret = snd_pcm_hw_constraint_step(ss->runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, - AXG_FIFO_MIN_DEPTH); + AXG_FIFO_BURST); if (ret) return ret; diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h index 521b54e98fd3..b63acd723c87 100644 --- a/sound/soc/meson/axg-fifo.h +++ b/sound/soc/meson/axg-fifo.h @@ -31,8 +31,6 @@ struct snd_soc_pcm_runtime; SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) #define AXG_FIFO_BURST 8 -#define AXG_FIFO_MIN_CNT 64 -#define AXG_FIFO_MIN_DEPTH (AXG_FIFO_BURST * AXG_FIFO_MIN_CNT) #define FIFO_INT_ADDR_FINISH BIT(0) #define FIFO_INT_ADDR_INT BIT(1) -- cgit v1.2.3 From 5bd216c6a6b48d8ed0b3283bf7ba84fc3a566b25 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:29 -0600 Subject: ASoC: SOF: Intel: hda: add namespace for hda-codec functionality Define namespaces (one generic and one dedicated for i915) and include them in HDaudio top-level module. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-codec.c | 14 +++++++------- sound/soc/sof/intel/hda.c | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index d7855b1f8e2e..5514e6191ba4 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -76,8 +76,8 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev) void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev) {} void hda_codec_jack_check(struct snd_sof_dev *sdev) {} #endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ -EXPORT_SYMBOL(hda_codec_jack_wake_enable); -EXPORT_SYMBOL(hda_codec_jack_check); +EXPORT_SYMBOL_NS(hda_codec_jack_wake_enable, SND_SOC_SOF_HDA_AUDIO_CODEC); +EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC); /* probe individual codec */ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, @@ -160,7 +160,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev, } } } -EXPORT_SYMBOL(hda_codec_probe_bus); +EXPORT_SYMBOL_NS(hda_codec_probe_bus, SND_SOC_SOF_HDA_AUDIO_CODEC); #if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) || \ IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI) @@ -172,7 +172,7 @@ void hda_codec_i915_get(struct snd_sof_dev *sdev) dev_dbg(bus->dev, "Turning i915 HDAC power on\n"); snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, true); } -EXPORT_SYMBOL(hda_codec_i915_get); +EXPORT_SYMBOL_NS(hda_codec_i915_get, SND_SOC_SOF_HDA_AUDIO_CODEC_I915); void hda_codec_i915_put(struct snd_sof_dev *sdev) { @@ -181,7 +181,7 @@ void hda_codec_i915_put(struct snd_sof_dev *sdev) dev_dbg(bus->dev, "Turning i915 HDAC power off\n"); snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false); } -EXPORT_SYMBOL(hda_codec_i915_put); +EXPORT_SYMBOL_NS(hda_codec_i915_put, SND_SOC_SOF_HDA_AUDIO_CODEC_I915); int hda_codec_i915_init(struct snd_sof_dev *sdev) { @@ -197,7 +197,7 @@ int hda_codec_i915_init(struct snd_sof_dev *sdev) return 0; } -EXPORT_SYMBOL(hda_codec_i915_init); +EXPORT_SYMBOL_NS(hda_codec_i915_init, SND_SOC_SOF_HDA_AUDIO_CODEC_I915); int hda_codec_i915_exit(struct snd_sof_dev *sdev) { @@ -210,7 +210,7 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev) return ret; } -EXPORT_SYMBOL(hda_codec_i915_exit); +EXPORT_SYMBOL_NS(hda_codec_i915_exit, SND_SOC_SOF_HDA_AUDIO_CODEC_I915); #endif diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 3335e0076180..adb842ed6b26 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -795,3 +795,5 @@ void hda_machine_select(struct snd_sof_dev *sdev) } MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC); +MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC_I915); -- cgit v1.2.3 From 0f501c7cde4086d15c396a95c59631b05dbc0351 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:30 -0600 Subject: ASoC: SOF: move arch_ops under ops The current structures are not well designed. We include Xtensa information from the ACPI and PCI levels, but at the Kconfig/module level everything Xtensa related is included at the sof/intel level. Move the arch_ops under ops so that Xtensa is hidden in the DSP ops, with a structure that follows the Kconfig/module partition. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/sof.h | 1 - sound/soc/sof/intel/apl.c | 2 ++ sound/soc/sof/intel/bdw.c | 2 ++ sound/soc/sof/intel/byt.c | 6 ++++++ sound/soc/sof/intel/cnl.c | 2 ++ sound/soc/sof/sof-acpi-dev.c | 4 ---- sound/soc/sof/sof-pci-dev.c | 10 ---------- sound/soc/sof/sof-priv.h | 4 +++- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/sound/sof.h b/include/sound/sof.h index 6ea74f1a9ec2..a0cbca021230 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -93,7 +93,6 @@ struct sof_dev_desc { const char *default_fw_filename; const struct snd_sof_dsp_ops *ops; - const struct sof_arch_ops *arch_ops; }; int sof_nocodec_setup(struct device *dev, diff --git a/sound/soc/sof/intel/apl.c b/sound/soc/sof/intel/apl.c index 97831d2c9df6..2483b15699e7 100644 --- a/sound/soc/sof/intel/apl.c +++ b/sound/soc/sof/intel/apl.c @@ -111,6 +111,8 @@ const struct snd_sof_dsp_ops sof_apl_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_apl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index f017089c7b2d..4d45b54a0f8b 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -632,6 +632,8 @@ const struct snd_sof_dsp_ops sof_bdw_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_bdw_ops, SND_SOC_SOF_BROADWELL); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index 07634873deb6..08193882f91f 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -618,6 +618,8 @@ const struct snd_sof_dsp_ops sof_tng_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_tng_ops, SND_SOC_SOF_MERRIFIELD); @@ -792,6 +794,8 @@ const struct snd_sof_dsp_ops sof_byt_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_byt_ops, SND_SOC_SOF_BAYTRAIL); @@ -865,6 +869,8 @@ const struct snd_sof_dsp_ops sof_cht_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_BATCH, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_cht_ops, SND_SOC_SOF_BAYTRAIL); diff --git a/sound/soc/sof/intel/cnl.c b/sound/soc/sof/intel/cnl.c index b27088e67c7b..9e2d8afe0535 100644 --- a/sound/soc/sof/intel/cnl.c +++ b/sound/soc/sof/intel/cnl.c @@ -297,6 +297,8 @@ const struct snd_sof_dsp_ops sof_cnl_ops = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, + + .arch_ops = &sof_xtensa_arch_ops, }; EXPORT_SYMBOL_NS(sof_cnl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 9100d7c70bb2..1278aa95effa 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -48,7 +48,6 @@ static const struct sof_dev_desc sof_acpi_broadwell_desc = { .default_fw_filename = "sof-bdw.ri", .nocodec_tplg_filename = "sof-bdw-nocodec.tplg", .ops = &sof_bdw_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -67,7 +66,6 @@ static const struct sof_dev_desc sof_acpi_baytrailcr_desc = { .default_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, - .arch_ops = &sof_xtensa_arch_ops }; static const struct sof_dev_desc sof_acpi_baytrail_desc = { @@ -82,7 +80,6 @@ static const struct sof_dev_desc sof_acpi_baytrail_desc = { .default_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt-nocodec.tplg", .ops = &sof_byt_ops, - .arch_ops = &sof_xtensa_arch_ops }; static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { @@ -97,7 +94,6 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = { .default_fw_filename = "sof-cht.ri", .nocodec_tplg_filename = "sof-cht-nocodec.tplg", .ops = &sof_cht_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 20638f666189..da7b17e5177b 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -50,7 +50,6 @@ static const struct sof_dev_desc bxt_desc = { .default_fw_filename = "sof-apl.ri", .nocodec_tplg_filename = "sof-apl-nocodec.tplg", .ops = &sof_apl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -68,7 +67,6 @@ static const struct sof_dev_desc glk_desc = { .default_fw_filename = "sof-glk.ri", .nocodec_tplg_filename = "sof-glk-nocodec.tplg", .ops = &sof_apl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -96,7 +94,6 @@ static const struct sof_dev_desc tng_desc = { .default_fw_filename = "sof-byt.ri", .nocodec_tplg_filename = "sof-byt.tplg", .ops = &sof_tng_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -114,7 +111,6 @@ static const struct sof_dev_desc cnl_desc = { .default_fw_filename = "sof-cnl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -132,7 +128,6 @@ static const struct sof_dev_desc cfl_desc = { .default_fw_filename = "sof-cfl.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -152,7 +147,6 @@ static const struct sof_dev_desc cml_desc = { .default_fw_filename = "sof-cml.ri", .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -170,7 +164,6 @@ static const struct sof_dev_desc icl_desc = { .default_fw_filename = "sof-icl.ri", .nocodec_tplg_filename = "sof-icl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -188,7 +181,6 @@ static const struct sof_dev_desc tgl_desc = { .default_fw_filename = "sof-tgl.ri", .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -206,7 +198,6 @@ static const struct sof_dev_desc ehl_desc = { .default_fw_filename = "sof-ehl.ri", .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif @@ -223,7 +214,6 @@ static const struct sof_dev_desc jsl_desc = { .default_tplg_path = "intel/sof-tplg", .nocodec_tplg_filename = "sof-jsl-nocodec.tplg", .ops = &sof_cnl_ops, - .arch_ops = &sof_xtensa_arch_ops }; #endif diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 3f1e1eb7c55f..bc2337cf1142 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -217,6 +217,8 @@ struct snd_sof_dsp_ops { /* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */ u32 hw_info; + + const struct sof_arch_ops *arch_ops; }; /* DSP architecture specific callbacks for oops and stack dumps */ @@ -226,7 +228,7 @@ struct sof_arch_ops { u32 *stack, u32 stack_words); }; -#define sof_arch_ops(sdev) ((sdev)->pdata->desc->arch_ops) +#define sof_arch_ops(sdev) ((sdev)->pdata->desc->ops->arch_ops) /* DSP device HW descriptor mapping between bus ID and ops */ struct sof_ops_table { -- cgit v1.2.3 From 068ac0db8637d3c188010ab8b9cc136f98fcd3df Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Dec 2019 14:22:31 -0600 Subject: ASoC: SOF: Intel: add namespace for XTENSA Now that Xtensa stuff is only referenced in Intel stuff, define namespace and import it in Intel BYT/BDW/HDaudio modules Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191217202231.18259-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/bdw.c | 1 + sound/soc/sof/intel/byt.c | 1 + sound/soc/sof/intel/hda.c | 1 + sound/soc/sof/xtensa/core.c | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c index 4d45b54a0f8b..6c23c5769330 100644 --- a/sound/soc/sof/intel/bdw.c +++ b/sound/soc/sof/intel/bdw.c @@ -645,3 +645,4 @@ EXPORT_SYMBOL_NS(bdw_chip_info, SND_SOC_SOF_BROADWELL); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); +MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c index 08193882f91f..f84391294f12 100644 --- a/sound/soc/sof/intel/byt.c +++ b/sound/soc/sof/intel/byt.c @@ -884,3 +884,4 @@ EXPORT_SYMBOL_NS(cht_chip_info, SND_SOC_SOF_BAYTRAIL); MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HIFI_EP_IPC); +MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index adb842ed6b26..d08462f481de 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -797,3 +797,4 @@ void hda_machine_select(struct snd_sof_dev *sdev) MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC); MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC_I915); +MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); diff --git a/sound/soc/sof/xtensa/core.c b/sound/soc/sof/xtensa/core.c index 46a4905a9dce..ea08651f0bb3 100644 --- a/sound/soc/sof/xtensa/core.c +++ b/sound/soc/sof/xtensa/core.c @@ -132,7 +132,7 @@ const struct sof_arch_ops sof_xtensa_arch_ops = { .dsp_oops = xtensa_dsp_oops, .dsp_stack = xtensa_stack, }; -EXPORT_SYMBOL(sof_xtensa_arch_ops); +EXPORT_SYMBOL_NS(sof_xtensa_arch_ops, SND_SOC_SOF_XTENSA); MODULE_DESCRIPTION("SOF Xtensa DSP support"); MODULE_LICENSE("Dual BSD/GPL"); -- cgit v1.2.3 From 5b425814f13f373cf36d58cf1b418e075d45ad86 Mon Sep 17 00:00:00 2001 From: Ben Zhang Date: Wed, 18 Dec 2019 06:39:30 -0800 Subject: ASoC: intel: Add Broadwell rt5650 machine driver Add machine driver for Broadwell + rt5650. Signed-off-by: Bard Liao Signed-off-by: Ben Zhang Signed-off-by: Mac Chiang Signed-off-by: Jon Flatley Signed-off-by: Curtis Malainey Acked-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218143937.122665-1-cujomalainey@chromium.org Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 12 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/bdw-rt5650.c | 319 +++++++++++++++++++++ .../intel/common/soc-acpi-intel-hsw-bdw-match.c | 7 + 4 files changed, 340 insertions(+) create mode 100644 sound/soc/intel/boards/bdw-rt5650.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 11dbc59046f8..bddf04715f15 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -44,6 +44,18 @@ endif ## SND_SOC_INTEL_HASWELL if SND_SOC_INTEL_HASWELL || SND_SOC_SOF_BROADWELL +config SND_SOC_INTEL_BDW_RT5650_MACH + tristate "Broadwell with RT5650 codec" + depends on I2C + depends on I2C_DESIGNWARE_PLATFORM || COMPILE_TEST + depends on X86_INTEL_LPSS || COMPILE_TEST + select SND_SOC_RT5645 + help + This adds the ASoC machine driver for Intel Broadwell platforms with + the RT5650 codec. + Say Y if you have such a device. + If unsure select "N". + config SND_SOC_INTEL_BDW_RT5677_MACH tristate "Broadwell with RT5677 codec" depends on I2C diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 5369627fa4c8..b74ddd49bd39 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -2,6 +2,7 @@ snd-soc-sst-haswell-objs := haswell.o snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o +snd-soc-sst-bdw-rt5650-mach-objs := bdw-rt5650.o snd-soc-sst-bdw-rt5677-mach-objs := bdw-rt5677.o snd-soc-sst-broadwell-objs := broadwell.o snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o hda_dsp_common.o @@ -38,6 +39,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da721 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o obj-$(CONFIG_SND_SOC_INTEL_GLK_RT5682_MAX98357A_MACH) += snd-soc-sst-glk-rt5682_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o +obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5650_MACH) += snd-soc-sst-bdw-rt5650-mach.o obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o diff --git a/sound/soc/intel/boards/bdw-rt5650.c b/sound/soc/intel/boards/bdw-rt5650.c new file mode 100644 index 000000000000..ba3fc1ef900a --- /dev/null +++ b/sound/soc/intel/boards/bdw-rt5650.c @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ASoC machine driver for Intel Broadwell platforms with RT5650 codec + * + * Copyright 2019, The Chromium OS Authors. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../common/sst-dsp.h" +#include "../haswell/sst-haswell-ipc.h" + +#include "../../codecs/rt5645.h" + +struct bdw_rt5650_priv { + struct gpio_desc *gpio_hp_en; + struct snd_soc_component *component; +}; + +static const struct snd_soc_dapm_widget bdw_rt5650_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("DMIC Pair1", NULL), + SND_SOC_DAPM_MIC("DMIC Pair2", NULL), +}; + +static const struct snd_soc_dapm_route bdw_rt5650_map[] = { + /* Speakers */ + {"Speaker", NULL, "SPOL"}, + {"Speaker", NULL, "SPOR"}, + + /* Headset jack connectors */ + {"Headphone", NULL, "HPOL"}, + {"Headphone", NULL, "HPOR"}, + {"IN1P", NULL, "Headset Mic"}, + {"IN1N", NULL, "Headset Mic"}, + + /* Digital MICs + * DMIC Pair1 are the two DMICs connected on the DMICN1 connector. + * DMIC Pair2 are the two DMICs connected on the DMICN2 connector. + * Facing the camera, DMIC Pair1 are on the left side, DMIC Pair2 + * are on the right side. + */ + {"DMIC L1", NULL, "DMIC Pair1"}, + {"DMIC R1", NULL, "DMIC Pair1"}, + {"DMIC L2", NULL, "DMIC Pair2"}, + {"DMIC R2", NULL, "DMIC Pair2"}, + + /* CODEC BE connections */ + {"SSP0 CODEC IN", NULL, "AIF1 Capture"}, + {"AIF1 Playback", NULL, "SSP0 CODEC OUT"}, +}; + +static const struct snd_kcontrol_new bdw_rt5650_controls[] = { + SOC_DAPM_PIN_SWITCH("Speaker"), + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("DMIC Pair1"), + SOC_DAPM_PIN_SWITCH("DMIC Pair2"), +}; + + +static struct snd_soc_jack headphone_jack; +static struct snd_soc_jack mic_jack; + +static struct snd_soc_jack_pin headphone_jack_pin = { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, +}; + +static struct snd_soc_jack_pin mic_jack_pin = { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, +}; + +static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + /* The ADSP will covert the FE rate to 48k, max 4-channels */ + rate->min = rate->max = 48000; + channels->min = 2; + channels->max = 4; + + /* set SSP0 to 24 bit */ + snd_mask_set_format(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), + SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int bdw_rt5650_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + /* Workaround: set codec PLL to 19.2MHz that PLL source is + * from MCLK(24MHz) to conform 2.4MHz DMIC clock. + */ + ret = snd_soc_dai_set_pll(codec_dai, 0, RT5645_PLL1_S_MCLK, + 24000000, 19200000); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + return ret; + } + + /* The actual MCLK freq is 24MHz. The codec is told that MCLK is + * 24.576MHz to satisfy the requirement of rl6231_get_clk_info. + * ASRC is enabled on AD and DA filters to ensure good audio quality. + */ + ret = snd_soc_dai_set_sysclk(codec_dai, RT5645_SCLK_S_PLL1, 24576000, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec sysclk configuration\n"); + return ret; + } + + return ret; +} + +static struct snd_soc_ops bdw_rt5650_ops = { + .hw_params = bdw_rt5650_hw_params, +}; + +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) +static int bdw_rt5650_rtd_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct sst_hsw *broadwell = pdata->dsp; + int ret; + + /* Set ADSP SSP port settings + * clock_divider = 4 means BCLK = MCLK/5 = 24MHz/5 = 4.8MHz + */ + ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0, + SST_HSW_DEVICE_MCLK_FREQ_24_MHZ, + SST_HSW_DEVICE_TDM_CLOCK_MASTER, 4); + if (ret < 0) { + dev_err(rtd->dev, "error: failed to set device config\n"); + return ret; + } + + return 0; +} +#endif + +static int bdw_rt5650_init(struct snd_soc_pcm_runtime *rtd) +{ + struct bdw_rt5650_priv *bdw_rt5650 = + snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + /* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1. + * The ASRC clock source is clk_i2s1_asrc. + */ + rt5645_sel_asrc_clk_src(component, + RT5645_DA_STEREO_FILTER | + RT5645_DA_MONO_L_FILTER | + RT5645_DA_MONO_R_FILTER | + RT5645_AD_STEREO_FILTER | + RT5645_AD_MONO_L_FILTER | + RT5645_AD_MONO_R_FILTER, + RT5645_CLK_SEL_I2S1_ASRC); + + /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0xF, 4, 24); + + if (ret < 0) { + dev_err(rtd->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + /* Create and initialize headphone jack */ + if (snd_soc_card_jack_new(rtd->card, "Headphone Jack", + SND_JACK_HEADPHONE, &headphone_jack, + &headphone_jack_pin, 1)) { + dev_err(component->dev, "Can't create headphone jack\n"); + } + + /* Create and initialize mic jack */ + if (snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, + &mic_jack, &mic_jack_pin, 1)) { + dev_err(component->dev, "Can't create mic jack\n"); + } + + rt5645_set_jack_detect(component, &headphone_jack, &mic_jack, NULL); + + bdw_rt5650->component = component; + + return 0; +} + +/* broadwell digital audio interface glue - connects codec <--> CPU */ +SND_SOC_DAILINK_DEF(dummy, + DAILINK_COMP_ARRAY(COMP_DUMMY())); + +SND_SOC_DAILINK_DEF(fe, + DAILINK_COMP_ARRAY(COMP_CPU("System Pin"))); + +SND_SOC_DAILINK_DEF(platform, + DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio"))); + +SND_SOC_DAILINK_DEF(be, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5650:00", "rt5645-aif1"))); + +static struct snd_soc_dai_link bdw_rt5650_dais[] = { + /* Front End DAI links */ + { + .name = "System PCM", + .stream_name = "System Playback", + .dynamic = 1, +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) + .init = bdw_rt5650_rtd_init, +#endif + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, + SND_SOC_DPCM_TRIGGER_POST + }, + .dpcm_playback = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(fe, dummy, platform), + }, + + /* Back End DAI links */ + { + /* SSP0 - Codec */ + .name = "Codec", + .id = 0, + .no_pcm = 1, + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_suspend = 1, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = broadwell_ssp0_fixup, + .ops = &bdw_rt5650_ops, + .dpcm_playback = 1, + .dpcm_capture = 1, + .init = bdw_rt5650_init, + SND_SOC_DAILINK_REG(dummy, be, dummy), + }, +}; + +/* ASoC machine driver for Broadwell DSP + RT5650 */ +static struct snd_soc_card bdw_rt5650_card = { + .name = "bdw-rt5650", + .owner = THIS_MODULE, + .dai_link = bdw_rt5650_dais, + .num_links = ARRAY_SIZE(bdw_rt5650_dais), + .dapm_widgets = bdw_rt5650_widgets, + .num_dapm_widgets = ARRAY_SIZE(bdw_rt5650_widgets), + .dapm_routes = bdw_rt5650_map, + .num_dapm_routes = ARRAY_SIZE(bdw_rt5650_map), + .controls = bdw_rt5650_controls, + .num_controls = ARRAY_SIZE(bdw_rt5650_controls), + .fully_routed = true, +}; + +static int bdw_rt5650_probe(struct platform_device *pdev) +{ + struct bdw_rt5650_priv *bdw_rt5650; + struct snd_soc_acpi_mach *mach; + int ret; + + bdw_rt5650_card.dev = &pdev->dev; + + /* Allocate driver private struct */ + bdw_rt5650 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5650_priv), + GFP_KERNEL); + if (!bdw_rt5650) + return -ENOMEM; + + /* override plaform name, if required */ + mach = (&pdev->dev)->platform_data; + ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5650_card, + mach->mach_params.platform); + + if (ret) + return ret; + + snd_soc_card_set_drvdata(&bdw_rt5650_card, bdw_rt5650); + + return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5650_card); +} + +static struct platform_driver bdw_rt5650_audio = { + .probe = bdw_rt5650_probe, + .driver = { + .name = "bdw-rt5650", + .pm = &snd_soc_pm_ops, + }, +}; + +module_platform_driver(bdw_rt5650_audio) + +/* Module information */ +MODULE_AUTHOR("Ben Zhang "); +MODULE_DESCRIPTION("Intel Broadwell RT5650 machine driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:bdw-rt5650"); diff --git a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c index 34eb0baaa951..35958553652e 100644 --- a/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-hsw-bdw-match.c @@ -29,6 +29,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_broadwell_machines[] = { .sof_fw_filename = "sof-bdw.ri", .sof_tplg_filename = "sof-bdw-rt286.tplg", }, + { + .id = "10EC5650", + .drv_name = "bdw-rt5650", + .fw_filename = "intel/IntcSST2.bin", + .sof_fw_filename = "sof-bdw.ri", + .sof_tplg_filename = "sof-bdw-rt5650.tplg", + }, { .id = "RT5677CE", .drv_name = "bdw-rt5677", -- cgit v1.2.3 From d24a70636b8b2b41bf983e89bbaaaf301bb80de4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 19 Dec 2019 12:51:40 +0000 Subject: ASoC: max98090: Remove empty suspend function The suspend function is empty so can be removed. Signed-off-by: Mark Brown Reviewed-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20191219125140.47689-1-broonie@kernel.org Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index da23810f958e..4c7b16d557e2 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2838,17 +2838,12 @@ static int max98090_resume(struct device *dev) return 0; } - -static int max98090_suspend(struct device *dev) -{ - return 0; -} #endif static const struct dev_pm_ops max98090_pm = { SET_RUNTIME_PM_OPS(max98090_runtime_suspend, max98090_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(max98090_suspend, max98090_resume) + SET_SYSTEM_SLEEP_PM_OPS(NULL, max98090_resume) }; static const struct i2c_device_id max98090_i2c_id[] = { -- cgit v1.2.3 From 2e4688676392767e16c1adeca4cc2c083e2db13f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 16:34:11 +0100 Subject: ALSA: emu10k1: Make uapi/emu10k1.h compilable again Recently we updated the content in alsa-lib uapi header files by just copying from the latest Linus kernel uapi/*.h, and noticed that it broke the build of some alsa-tools programs. The reason is that we used to have a modified version in the past, so that the program can be built without referring to the unexported stuff like snd_ctl_elem_id or __user prefix. This patch attempts to restore that, i.e. dropping the stuff that can't be referred in the user-space. For adapting the changes in uapi/emu10k1.h, the emu10k1 driver code is also slightly modified. Most of changes are pointer cast. Link: https://lore.kernel.org/r/20191220153415.2740-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/emu10k1.h | 38 ++++++++++++++++++++++++++------------ sound/pci/emu10k1/emufx.c | 26 ++++++++++++++------------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/include/uapi/sound/emu10k1.h b/include/uapi/sound/emu10k1.h index 042c5a6f16ee..c1150e4d0231 100644 --- a/include/uapi/sound/emu10k1.h +++ b/include/uapi/sound/emu10k1.h @@ -23,9 +23,6 @@ #ifndef _UAPI__SOUND_EMU10K1_H #define _UAPI__SOUND_EMU10K1_H -#include -#include - /* * ---- FX8010 ---- */ @@ -282,8 +279,22 @@ struct snd_emu10k1_fx8010_info { #define EMU10K1_GPR_TRANSLATION_TREBLE 3 #define EMU10K1_GPR_TRANSLATION_ONOFF 4 +enum emu10k1_ctl_elem_iface { + EMU10K1_CTL_ELEM_IFACE_MIXER = 2, /* virtual mixer device */ + EMU10K1_CTL_ELEM_IFACE_PCM = 3, /* PCM device */ +}; + +struct emu10k1_ctl_elem_id { + unsigned int pad; /* don't use */ + int iface; /* interface identifier */ + unsigned int device; /* device/client number */ + unsigned int subdevice; /* subdevice (substream) number */ + unsigned char name[44]; /* ASCII name of item */ + unsigned int index; /* index of item */ +}; + struct snd_emu10k1_fx8010_control_gpr { - struct snd_ctl_elem_id id; /* full control ID definition */ + struct emu10k1_ctl_elem_id id; /* full control ID definition */ unsigned int vcount; /* visible count */ unsigned int count; /* count of GPR (1..16) */ unsigned short gpr[32]; /* GPR number(s) */ @@ -296,7 +307,7 @@ struct snd_emu10k1_fx8010_control_gpr { /* old ABI without TLV support */ struct snd_emu10k1_fx8010_control_old_gpr { - struct snd_ctl_elem_id id; + struct emu10k1_ctl_elem_id id; unsigned int vcount; unsigned int count; unsigned short gpr[32]; @@ -310,24 +321,24 @@ struct snd_emu10k1_fx8010_code { char name[128]; __EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */ - __u32 __user *gpr_map; /* initializers */ + __u32 *gpr_map; /* initializers */ unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */ - struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */ + struct snd_emu10k1_fx8010_control_gpr *gpr_add_controls; /* GPR controls to add/replace */ unsigned int gpr_del_control_count; /* count of GPR controls to remove */ - struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */ + struct emu10k1_ctl_elem_id *gpr_del_controls; /* IDs of GPR controls to remove */ unsigned int gpr_list_control_count; /* count of GPR controls to list */ unsigned int gpr_list_control_total; /* total count of GPR controls */ - struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */ + struct snd_emu10k1_fx8010_control_gpr *gpr_list_controls; /* listed GPR controls */ __EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */ - __u32 __user *tram_data_map; /* data initializers */ - __u32 __user *tram_addr_map; /* map initializers */ + __u32 *tram_data_map; /* data initializers */ + __u32 *tram_addr_map; /* map initializers */ __EMU10K1_DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */ - __u32 __user *code; /* one instruction - 64 bits */ + __u32 *code; /* one instruction - 64 bits */ }; struct snd_emu10k1_fx8010_tram { @@ -371,11 +382,14 @@ struct snd_emu10k1_fx8010_pcm_rec { #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) +#ifndef __KERNEL__ /* typedefs for compatibility to user-space */ typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t; +typedef struct emu10k1_ctl_elem_id emu10k1_ctl_elem_id_t; +#endif #endif /* _UAPI__SOUND_EMU10K1_H */ diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index a31adecfe608..e0e076a9c321 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -628,7 +628,7 @@ static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, } static struct snd_emu10k1_fx8010_ctl * -snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) +snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct emu10k1_ctl_elem_id *id) { struct snd_emu10k1_fx8010_ctl *ctl; struct snd_kcontrol *kcontrol; @@ -714,15 +714,15 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, bool in_kernel) { unsigned int i; - struct snd_ctl_elem_id __user *_id; - struct snd_ctl_elem_id id; + struct emu10k1_ctl_elem_id __user *_id; + struct emu10k1_ctl_elem_id id; struct snd_emu10k1_fx8010_control_gpr *gctl; int err; - for (i = 0, _id = icode->gpr_del_controls; - i < icode->gpr_del_control_count; i++, _id++) { + _id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; + for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { if (in_kernel) - id = *(__force struct snd_ctl_elem_id *)_id; + id = *(__force struct emu10k1_ctl_elem_id *)_id; else if (copy_from_user(&id, _id, sizeof(id))) return -EFAULT; if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) @@ -741,7 +741,8 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) continue; down_read(&emu->card->controls_rwsem); - if (snd_ctl_find_id(emu->card, &gctl->id) != NULL) { + if (snd_ctl_find_id(emu->card, + (struct snd_ctl_elem_id *)&gctl->id)) { up_read(&emu->card->controls_rwsem); err = -EEXIST; goto __error; @@ -876,15 +877,16 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, bool in_kernel) { unsigned int i; - struct snd_ctl_elem_id id; - struct snd_ctl_elem_id __user *_id; + struct emu10k1_ctl_elem_id id; + struct emu10k1_ctl_elem_id __user *_id; struct snd_emu10k1_fx8010_ctl *ctl; struct snd_card *card = emu->card; - for (i = 0, _id = icode->gpr_del_controls; - i < icode->gpr_del_control_count; i++, _id++) { + _id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; + + for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { if (in_kernel) - id = *(__force struct snd_ctl_elem_id *)_id; + id = *(__force struct emu10k1_ctl_elem_id *)_id; else if (copy_from_user(&id, _id, sizeof(id))) return -EFAULT; down_write(&card->controls_rwsem); -- cgit v1.2.3 From d63e63d4210713ddc7eb1b2d2afc4a8d42ccf91e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 16:34:12 +0100 Subject: ALSA: hdsp: Make uapi/hdsp.h compilable again Recently alsa-lib updated its content of sound/hdsp.h just by copying the latest Linus kernel uapi/*.h, and this broke the build of alsa-tools programs. We used to modify the headers so that they can be built without asoundlib.h and linux kernel headers, and the verbatim copy doesn't work as is. This patch removes again the linux/types.h inclusion and drop __user prefix that broke the build and adjusts the corresponding code. Link: https://lore.kernel.org/r/20191220153415.2740-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/hdsp.h | 4 +--- sound/pci/rme9652/hdsp.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/uapi/sound/hdsp.h b/include/uapi/sound/hdsp.h index 5dc0c3db0a4c..88c92a3fb477 100644 --- a/include/uapi/sound/hdsp.h +++ b/include/uapi/sound/hdsp.h @@ -20,8 +20,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - #define HDSP_MATRIX_MIXER_SIZE 2048 enum HDSP_IO_Type { @@ -74,7 +72,7 @@ struct hdsp_config_info { #define SNDRV_HDSP_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, struct hdsp_config_info) struct hdsp_firmware { - void __user *firmware_data; /* 24413 x 4 bytes */ + void *firmware_data; /* 24413 x 4 bytes */ }; #define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, struct hdsp_firmware) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 87e60dd13066..b4c42c4fa201 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -4817,7 +4817,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne "initializing firmware upload\n"); firmware = (struct hdsp_firmware __user *)argp; - if (get_user(firmware_data, &firmware->firmware_data)) + if (get_user(firmware_data, (__force void __user **)&firmware->firmware_data)) return -EFAULT; if (hdsp_check_for_iobox (hdsp)) -- cgit v1.2.3 From 4fa406caf950fd46ae06bccf9a4c72171401d203 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 16:34:13 +0100 Subject: ALSA: hdspm: Drop linux/types.h inclusion in uapi header The hdspm.h uapi header has been used also from non-Linux or platforms that don't have linux/*.h. It was OK in the past because alsa-lib contained the modified version of this header file, but now it tries to the verbatim copy, so it broke the build. This fixes it again. Link: https://lore.kernel.org/r/20191220153415.2740-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/hdspm.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/uapi/sound/hdspm.h b/include/uapi/sound/hdspm.h index a38f3f79beb7..2d91f90eb5e1 100644 --- a/include/uapi/sound/hdspm.h +++ b/include/uapi/sound/hdspm.h @@ -21,8 +21,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - /* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */ #define HDSPM_MAX_CHANNELS 64 -- cgit v1.2.3 From 7fd7d6c5045113350fcf78e865ced8a80dbde9fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 16:34:14 +0100 Subject: ALSA: uapi: Fix typos and header inclusion in asound.h The recent changes in uapi/asoundlib.h caused some build errors in alsa-lib side because of a typo and the new included files. Basically asound.h is supposed to be usable also on non-Linux systems, so we've tried to avoid the Linux-specific include files. This patch is an attempt to recover from those changes. Fixes: 3ddee7f88aaf ("ALSA: Avoid using timespec for struct snd_pcm_status") Fixes: 80fe7430c708 ("ALSA: add new 32-bit layout for snd_pcm_mmap_status/control") Link: https://lore.kernel.org/r/20191220153415.2740-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/asound.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index e6a958b8aff1..e7943302359e 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -26,7 +26,9 @@ #if defined(__KERNEL__) || defined(__linux__) #include +#include #else +#include #include #endif @@ -35,8 +37,6 @@ #include #endif -#include - /* * protocol version */ @@ -471,7 +471,7 @@ enum { #ifndef __KERNEL__ /* explicit padding avoids incompatibility between i386 and x86-64 */ -typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)] __time_pad; +typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)]; } __time_pad; struct snd_pcm_status { snd_pcm_state_t state; /* stream state */ -- cgit v1.2.3 From 645c08f17f477915f6d900b767e789852f150054 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 16:34:15 +0100 Subject: ALSA: uapi: Drop asound.h inclusion from asoc.h The asound.h isn't always available while asoc.h itself is distributed in alsa-lib package. So we need to avoid the unnecessary inclusion of asound.h from there. Link: https://lore.kernel.org/r/20191220153415.2740-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/asoc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h index a74ca232f1fc..6048553c119d 100644 --- a/include/uapi/sound/asoc.h +++ b/include/uapi/sound/asoc.h @@ -17,7 +17,6 @@ #define __LINUX_UAPI_SND_ASOC_H #include -#include /* * Maximum number of channels topology kcontrol can represent. -- cgit v1.2.3 From bfea224d9250e56ed5475bf72190783a7e1d8e43 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 20 Dec 2019 17:15:55 +0100 Subject: ALSA: uapi: Drop unneeded typedefs We kept some typedefs in uapi/sound/*.h so that the programs in alsa-tools can be built. Now that alsa-lib takes these and applies the workarounds in its own, we don't need these typedefs any longer in the kernel uapi side. Let's drop them. Link: https://lore.kernel.org/r/20191220161555.20232-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/emu10k1.h | 10 ---------- include/uapi/sound/hdsp.h | 9 --------- include/uapi/sound/hdspm.h | 8 -------- 3 files changed, 27 deletions(-) diff --git a/include/uapi/sound/emu10k1.h b/include/uapi/sound/emu10k1.h index c1150e4d0231..6bcd76f64c1c 100644 --- a/include/uapi/sound/emu10k1.h +++ b/include/uapi/sound/emu10k1.h @@ -382,14 +382,4 @@ struct snd_emu10k1_fx8010_pcm_rec { #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) -#ifndef __KERNEL__ -/* typedefs for compatibility to user-space */ -typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; -typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; -typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; -typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; -typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t; -typedef struct emu10k1_ctl_elem_id emu10k1_ctl_elem_id_t; -#endif - #endif /* _UAPI__SOUND_EMU10K1_H */ diff --git a/include/uapi/sound/hdsp.h b/include/uapi/sound/hdsp.h index 88c92a3fb477..7ac2d3f2a9b3 100644 --- a/include/uapi/sound/hdsp.h +++ b/include/uapi/sound/hdsp.h @@ -97,13 +97,4 @@ struct hdsp_9632_aeb { #define SNDRV_HDSP_IOCTL_GET_9632_AEB _IOR('H', 0x45, struct hdsp_9632_aeb) -/* typedefs for compatibility to user-space */ -typedef enum HDSP_IO_Type HDSP_IO_Type; -typedef struct hdsp_peak_rms hdsp_peak_rms_t; -typedef struct hdsp_config_info hdsp_config_info_t; -typedef struct hdsp_firmware hdsp_firmware_t; -typedef struct hdsp_version hdsp_version_t; -typedef struct hdsp_mixer hdsp_mixer_t; -typedef struct hdsp_9632_aeb hdsp_9632_aeb_t; - #endif /* __SOUND_HDSP_H */ diff --git a/include/uapi/sound/hdspm.h b/include/uapi/sound/hdspm.h index 2d91f90eb5e1..3fbfd9dc5f51 100644 --- a/include/uapi/sound/hdspm.h +++ b/include/uapi/sound/hdspm.h @@ -219,12 +219,4 @@ struct hdspm_mixer_ioctl { /* use indirect access due to the limit of ioctl bit size */ #define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdspm_mixer_ioctl) -/* typedefs for compatibility to user-space */ -typedef struct hdspm_peak_rms hdspm_peak_rms_t; -typedef struct hdspm_config_info hdspm_config_info_t; -typedef struct hdspm_version hdspm_version_t; -typedef struct hdspm_channelfader snd_hdspm_channelfader_t; -typedef struct hdspm_mixer hdspm_mixer_t; - - #endif -- cgit v1.2.3 From 54228356667920658cd33a63e12b7bff3e13c880 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 23 Dec 2019 11:39:18 +0900 Subject: ALSA: ctl: remove unused macro for timestamping of elem_value In a former commit, 'tstamp' member was removed from 'struct snd_ctl_elem_value' in a middle way toward solution of Y2038 issue. In a protocol of ALSA control interface, this member is designed to deliver timestamp information in the value structure when the target element supports SNDRV_CTL_ELEM_ACCESS_TIMESTAMP flag. Actually, the feature is neither used by kernel space nor user space, especiall alsa-lib has no API for the feature. Therefore it's reasonable to remove both of them. Practically, the timestamp information corresponds to no information about type of clock ID. It can bring confusions to applications. Reference: a4e7dd35b9da ("ALSA: Avoid using timespec for struct snd_ctl_elem_value") Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191223023921.8151-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- include/uapi/sound/asound.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index e7943302359e..efd9e1398e07 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -974,7 +974,7 @@ typedef int __bitwise snd_ctl_elem_iface_t; #define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1) #define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE) #define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */ -#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) /* when was control changed */ +// (1 << 3) is unused. #define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) /* TLV read is possible */ #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) /* TLV write is possible */ #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) -- cgit v1.2.3 From e67c3f0fd44c9bbd7a484b7cf6e9bcb4c0a0a858 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 23 Dec 2019 11:39:19 +0900 Subject: ALSA: pci: echoaudio: remove usage of dimen menber of elem_value structure In a couple of years ago, 'echomixer' userspace application was revised not to use 'dimen' member of 'struct snd_ctl_elem_info'. This commit removes usage of 'dimen' member from echoaudio PCI driver so that no implementation uses the member. Reference: 275353bb684e ("ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members") Reference: 51db452df07b ("Revert "ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members") Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191223023921.8151-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index a9ac9fc635aa..abad652a4006 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1237,8 +1237,6 @@ static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol, uinfo->count = 1; uinfo->value.integer.min = ECHOGAIN_MINOUT; uinfo->value.integer.max = ECHOGAIN_MAXOUT; - uinfo->dimen.d[0] = num_busses_out(chip); - uinfo->dimen.d[1] = num_busses_in(chip); return 0; } @@ -1309,8 +1307,6 @@ static int snd_echo_vmixer_info(struct snd_kcontrol *kcontrol, uinfo->count = 1; uinfo->value.integer.min = ECHOGAIN_MINOUT; uinfo->value.integer.max = ECHOGAIN_MAXOUT; - uinfo->dimen.d[0] = num_busses_out(chip); - uinfo->dimen.d[1] = num_pipes_out(chip); return 0; } @@ -1693,13 +1689,6 @@ static int snd_echo_vumeters_info(struct snd_kcontrol *kcontrol, uinfo->count = 96; uinfo->value.integer.min = ECHOGAIN_MINOUT; uinfo->value.integer.max = 0; -#ifdef ECHOCARD_HAS_VMIXER - uinfo->dimen.d[0] = 3; /* Out, In, Virt */ -#else - uinfo->dimen.d[0] = 2; /* Out, In */ -#endif - uinfo->dimen.d[1] = 16; /* 16 channels */ - uinfo->dimen.d[2] = 2; /* 0=level, 1=peak */ return 0; } -- cgit v1.2.3 From ff16351e3f302a2913bd17da6ed8f195ab2139fd Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 23 Dec 2019 11:39:20 +0900 Subject: ALSA: ctl: remove dimen member from elem_info structure The 'dimen' member of 'struct snd_ctl_elem_info' is designed to deliver information to use an array of value as multi-dimensional values. This feature is used just by echoaudio PCI driver, and fortunately it's not used by the other applications than 'echomixer' in alsa-tools. In a previous commit, usage of 'dimen' member is removed from echoaudio PCI driver. Nowadays no driver/application use the feature. This commit removes the member from structure. Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191223023921.8151-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- include/uapi/sound/asound.h | 6 +----- sound/core/control.c | 32 -------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index efd9e1398e07..06033fc78ee4 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -1040,11 +1040,7 @@ struct snd_ctl_elem_info { } enumerated; unsigned char reserved[128]; } value; - union { - unsigned short d[4]; /* dimensions */ - unsigned short *d_ptr; /* indirect - obsoleted */ - } dimen; - unsigned char reserved[64-4*sizeof(unsigned short)]; + unsigned char reserved[64]; }; struct snd_ctl_elem_value { diff --git a/sound/core/control.c b/sound/core/control.c index 7a4d8690ce41..3fa1171dc1c2 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -758,36 +758,6 @@ static int snd_ctl_elem_list(struct snd_card *card, return err; } -static bool validate_element_member_dimension(struct snd_ctl_elem_info *info) -{ - unsigned int members; - unsigned int i; - - if (info->dimen.d[0] == 0) - return true; - - members = 1; - for (i = 0; i < ARRAY_SIZE(info->dimen.d); ++i) { - if (info->dimen.d[i] == 0) - break; - members *= info->dimen.d[i]; - - /* - * info->count should be validated in advance, to guarantee - * calculation soundness. - */ - if (members > info->count) - return false; - } - - for (++i; i < ARRAY_SIZE(info->dimen.d); ++i) { - if (info->dimen.d[i] > 0) - return false; - } - - return members == info->count; -} - static int snd_ctl_elem_info(struct snd_ctl_file *ctl, struct snd_ctl_elem_info *info) { @@ -1280,8 +1250,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, if (info->count < 1 || info->count > max_value_counts[info->type]) return -EINVAL; - if (!validate_element_member_dimension(info)) - return -EINVAL; private_size = value_sizes[info->type] * info->count; /* -- cgit v1.2.3 From bd3eb4e87eb399a9fe15ef1b59db78faf9c20359 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 23 Dec 2019 11:39:21 +0900 Subject: ALSA: ctl: bump protocol version up to v2.1.0 In a development period for v5.6 kernel, some changes are introduced to structures in ALSA control interface: - 'tstamp' member is removed from 'struct snd_ctl_elem_value - 'TSTAMP' flag is removed from a set of access flags for 'struct snd_ctl_elem_info' - 'dimen' member is removed from 'struct snd_ctl_elem_info Although these changes were introduced with enough consideration for backward compatibility, they include slightly lose of it. This commit bumps protocol version of ALSA control interface up to v2.1.0. Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20191223023921.8151-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- include/uapi/sound/asound.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 06033fc78ee4..e36dadaf84ba 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -936,7 +936,7 @@ struct snd_timer_tread { * * ****************************************************************************/ -#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) +#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 1, 0) struct snd_ctl_card_info { int card; /* card number */ -- cgit v1.2.3 From d61fe22c2ae42d9fd76c34ef4224064cca4b04b0 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 23 Dec 2019 18:33:47 +0900 Subject: ALSA: ctl: allow TLV read operation for callback type of element in locked case A design of ALSA control core allows applications to execute three operations for TLV feature; read, write and command. Furthermore, it allows driver developers to process the operations by two ways; allocated array or callback function. In the former, read operation is just allowed, thus developers uses the latter when device driver supports variety of models or the target model is expected to dynamically change information stored in TLV container. The core also allows applications to lock any element so that the other applications can't perform write operation to the element for element value and TLV information. When the element is locked, write and command operation for TLV information are prohibited as well as element value. Any read operation should be allowed in the case. At present, when an element has callback function for TLV information, TLV read operation returns EPERM if the element is locked. On the other hand, the read operation is success when an element has allocated array for TLV information. In both cases, read operation is success for element value expectedly. This commit fixes the bug. This change can be backported to v4.14 kernel or later. Signed-off-by: Takashi Sakamoto Reviewed-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20191223093347.15279-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/core/control.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 3fa1171dc1c2..4728f6828890 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1398,8 +1398,9 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag, if (kctl->tlv.c == NULL) return -ENXIO; - /* When locked, this is unavailable. */ - if (vd->owner != NULL && vd->owner != file) + /* Write and command operations are not allowed for locked element. */ + if (op_flag != SNDRV_CTL_TLV_OP_READ && + vd->owner != NULL && vd->owner != file) return -EPERM; return kctl->tlv.c(kctl, op_flag, size, buf); -- cgit v1.2.3 From e68d6696575e1af3f92125e842f2853708f34589 Mon Sep 17 00:00:00 2001 From: Sathyanarayana Nujella Date: Fri, 20 Dec 2019 11:10:36 -0600 Subject: ASoC: SOF: Intel: hda: Add iDisp4 DAI TGL supports more than three iDisp DAI's. Add support for iDisp4 CPU DAI. Without this patch, we saw the below error on our TGL DUT: sof_rt5682 tgl_max98357a_rt5682: ASoC: CPU DAI iDisp4 Pin not registered Signed-off-by: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191220171037.10689-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-dai.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 2d9ac0035bd2..638812a41328 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -440,6 +440,10 @@ struct snd_soc_dai_driver skl_dai[] = { .name = "iDisp3 Pin", .ops = &hda_link_dai_ops, }, +{ + .name = "iDisp4 Pin", + .ops = &hda_link_dai_ops, +}, { .name = "Analog CPU DAI", .ops = &hda_link_dai_ops, -- cgit v1.2.3 From 4bb16cd82773ee2e73d6201e6e7271f75312144c Mon Sep 17 00:00:00 2001 From: Sathyanarayana Nujella Date: Fri, 20 Dec 2019 11:10:37 -0600 Subject: ASoC: hdac_hda: Update hdac hda dai table to include intel-hdmi-hifi4 TGL supports more than three HDMI Dai's. So, update hdac_hda_dais table to include 4th DAI. Without this patch, we saw the below error in TGL DUT: sof_rt5682 tgl_max98357a_rt5682: ASoC: CODEC DAI intel-hdmi-hifi4 not Signed-off-by: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191220171037.10689-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hda.c | 16 ++++++++++++++++ sound/soc/codecs/hdac_hda.h | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 6803d39e09a5..4e0f4afe6ddc 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -164,6 +164,19 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = { .sig_bits = 24, }, }, +{ + .id = HDAC_HDMI_3_DAI_ID, + .name = "intel-hdmi-hifi4", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi4", + .channels_min = 1, + .channels_max = 32, + .rates = STUB_HDMI_RATES, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, }; @@ -346,6 +359,9 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt, case HDAC_HDMI_2_DAI_ID: pcm_name = "HDMI 2"; break; + case HDAC_HDMI_3_DAI_ID: + pcm_name = "HDMI 3"; + break; default: dev_err(&hcodec->core.dev, "invalid dai id %d\n", dai->id); return NULL; diff --git a/sound/soc/codecs/hdac_hda.h b/sound/soc/codecs/hdac_hda.h index e145cec085b8..598b07d9b6fe 100644 --- a/sound/soc/codecs/hdac_hda.h +++ b/sound/soc/codecs/hdac_hda.h @@ -13,7 +13,8 @@ enum { HDAC_HDMI_0_DAI_ID, HDAC_HDMI_1_DAI_ID, HDAC_HDMI_2_DAI_ID, - HDAC_LAST_DAI_ID = HDAC_HDMI_2_DAI_ID, + HDAC_HDMI_3_DAI_ID, + HDAC_LAST_DAI_ID = HDAC_HDMI_3_DAI_ID, }; struct hdac_hda_pcm { -- cgit v1.2.3 From c5614fb8e3d13be7bba79f71b798468a3a6224f7 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 24 Dec 2019 22:02:37 +0800 Subject: ASoC: Intel: kbl_da7219_max98357a: remove unused variable 'constraints_16000' and 'ch_mono' sound/soc/intel/boards/kbl_da7219_max98357a.c:343:48: warning: constraints_16000 defined but not used [-Wunused-const-variable=] sound/soc/intel/boards/kbl_da7219_max98357a.c:348:27: warning: ch_mono defined but not used [-Wunused-const-variable=] They are never used, so can be removed. Reported-by: Hulk Robot Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191224140237.36732-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98357a.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c index 537a88932bb6..0d55319a0773 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -336,19 +336,6 @@ static struct snd_soc_ops kabylake_dmic_ops = { .startup = kabylake_dmic_startup, }; -static const unsigned int rates_16000[] = { - 16000, -}; - -static const struct snd_pcm_hw_constraint_list constraints_16000 = { - .count = ARRAY_SIZE(rates_16000), - .list = rates_16000, -}; - -static const unsigned int ch_mono[] = { - 1, -}; - SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY())); -- cgit v1.2.3 From 057a317a8d94136b76a3cc6f7be53ee2b85dc115 Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Mon, 23 Dec 2019 07:47:11 -0800 Subject: ASoC: gtm601: add Broadmobi bm818 sound profile The Broadmobi bm818 uses stereo sound at 48Khz sample rate Signed-off-by: Angus Ainslie (Purism) Link: https://lore.kernel.org/r/20191223154712.18581-2-angus@akkea.ca Signed-off-by: Mark Brown --- sound/soc/codecs/gtm601.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/gtm601.c b/sound/soc/codecs/gtm601.c index d454294c8d06..7f05ebcb88d1 100644 --- a/sound/soc/codecs/gtm601.c +++ b/sound/soc/codecs/gtm601.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,6 +47,24 @@ static struct snd_soc_dai_driver gtm601_dai = { }, }; +static struct snd_soc_dai_driver bm818_dai = { + .name = "bm818", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}; + static const struct snd_soc_component_driver soc_component_dev_gtm601 = { .dapm_widgets = gtm601_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets), @@ -60,13 +78,19 @@ static const struct snd_soc_component_driver soc_component_dev_gtm601 = { static int gtm601_platform_probe(struct platform_device *pdev) { + const struct snd_soc_dai_driver *dai_driver; + + dai_driver = of_device_get_match_data(&pdev->dev); + return devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_gtm601, >m601_dai, 1); + &soc_component_dev_gtm601, + (struct snd_soc_dai_driver *)dai_driver, 1); } #if defined(CONFIG_OF) static const struct of_device_id gtm601_codec_of_match[] = { - { .compatible = "option,gtm601", }, + { .compatible = "option,gtm601", .data = (void *)>m601_dai }, + { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai }, {}, }; MODULE_DEVICE_TABLE(of, gtm601_codec_of_match); -- cgit v1.2.3 From bb9ee1eacb2dfcdf419f14c739b866c3eba4dc1f Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Mon, 23 Dec 2019 07:47:12 -0800 Subject: dt-bindings: sound: gtm601: add the broadmobi interface The Broadmobi BM818 uses a different sample rate and channels from the option modem. Signed-off-by: Angus Ainslie (Purism) Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20191223154712.18581-3-angus@akkea.ca Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/gtm601.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/gtm601.txt b/Documentation/devicetree/bindings/sound/gtm601.txt index 5efc8c068de0..efa32a486c4a 100644 --- a/Documentation/devicetree/bindings/sound/gtm601.txt +++ b/Documentation/devicetree/bindings/sound/gtm601.txt @@ -1,10 +1,16 @@ GTM601 UMTS modem audio interface CODEC -This device has no configuration interface. Sample rate is fixed - 8kHz. +This device has no configuration interface. The sample rate and channels are +based on the compatible string + "option,gtm601" = 8kHz mono + "broadmobi,bm818" = 48KHz stereo Required properties: - - compatible : "option,gtm601" + - compatible : one of + "option,gtm601" + "broadmobi,bm818" + Example: -- cgit v1.2.3 From a6b748713205242d1483a78662bf147b1aa7d90b Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:43 +0000 Subject: ASoC: dt-bindings: add dt bindings for WCD9340/WCD9341 audio codec This patch adds bindings for wcd9340/wcd9341 audio codec which can support both SLIMbus and I2S/I2C interface. Signed-off-by: Srinivas Kandagatla Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20191219103153.14875-2-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/qcom,wcd934x.yaml | 175 +++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,wcd934x.yaml diff --git a/Documentation/devicetree/bindings/sound/qcom,wcd934x.yaml b/Documentation/devicetree/bindings/sound/qcom,wcd934x.yaml new file mode 100644 index 000000000000..38eaf0c028f9 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,wcd934x.yaml @@ -0,0 +1,175 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/qcom,wcd934x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bindings for Qualcomm WCD9340/WCD9341 Audio Codec + +maintainers: + - Srinivas Kandagatla + +description: | + Qualcomm WCD9340/WCD9341 Codec is a standalone Hi-Fi audio codec IC. + It has in-built Soundwire controller, pin controller, interrupt mux and + supports both I2S/I2C and SLIMbus audio interfaces. + +properties: + compatible: + const: slim217,250 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + description: GPIO spec for reset line to use + maxItems: 1 + + slim-ifc-dev: true + + clocks: + maxItems: 1 + + clock-names: + const: extclk + + vdd-buck-supply: + description: A reference to the 1.8V buck supply + + vdd-buck-sido-supply: + description: A reference to the 1.8V SIDO buck supply + + vdd-rx-supply: + description: A reference to the 1.8V rx supply + + vdd-tx-supply: + description: A reference to the 1.8V tx supply + + vdd-vbat-supply: + description: A reference to the vbat supply + + vdd-io-supply: + description: A reference to the 1.8V I/O supply + + vdd-micbias-supply: + description: A reference to the micbias supply + + qcom,micbias1-microvolt: + description: micbias1 voltage + minimum: 1800000 + maximum: 2850000 + + qcom,micbias2-microvolt: + description: micbias2 voltage + minimum: 1800000 + maximum: 2850000 + + qcom,micbias3-microvolt: + description: micbias3 voltage + minimum: 1800000 + maximum: 2850000 + + qcom,micbias4-microvolt: + description: micbias4 voltage + minimum: 1800000 + maximum: 2850000 + + clock-output-names: + const: mclk + + clock-frequency: + description: Clock frequency of output clk in Hz + + interrupt-controller: true + + '#interrupt-cells': + const: 1 + + '#clock-cells': + const: 0 + + '#sound-dai-cells': + const: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + + gpio@42: + type: object + allOf: + - $ref: ../gpio/qcom,wcd934x-gpio.yaml# + +patternProperties: + "^.*@[0-9a-f]+$": + type: object + description: | + WCD934x subnode for each slave devices. Bindings of each subnodes + depends on the specific driver providing the functionality and + documented in their respective bindings. + + properties: + reg: + maxItems: 1 + + required: + - reg + +required: + - compatible + - reg + - reset-gpios + - slim-ifc-dev + - interrupts + - interrupt-controller + - clock-frequency + - clock-output-names + - qcom,micbias1-microvolt + - qcom,micbias2-microvolt + - qcom,micbias3-microvolt + - qcom,micbias4-microvolt + - "#interrupt-cells" + - "#clock-cells" + - "#sound-dai-cells" + - "#address-cells" + - "#size-cells" + +examples: + - | + codec@1,0{ + compatible = "slim217,250"; + reg = <1 0>; + reset-gpios = <&tlmm 64 0>; + slim-ifc-dev = <&wcd9340_ifd>; + #sound-dai-cells = <1>; + interrupt-parent = <&tlmm>; + interrupts = <54 4>; + interrupt-controller; + #interrupt-cells = <1>; + #clock-cells = <0>; + clock-frequency = <9600000>; + clock-output-names = "mclk"; + qcom,micbias1-microvolt = <1800000>; + qcom,micbias2-microvolt = <1800000>; + qcom,micbias3-microvolt = <1800000>; + qcom,micbias4-microvolt = <1800000>; + clock-names = "extclk"; + clocks = <&rpmhcc 2>; + + #address-cells = <1>; + #size-cells = <1>; + + gpio@42 { + compatible = "qcom,wcd9340-gpio"; + reg = <0x42 0x2>; + gpio-controller; + #gpio-cells = <2>; + }; + }; + +... -- cgit v1.2.3 From a61f3b4f476eceb25274161e5a53a8d18e42610b Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:45 +0000 Subject: ASoC: wcd934x: add support to wcd9340/wcd9341 codec Qualcomm WCD9340/WCD9341 Codec is a standalone Hi-Fi audio codec IC, It supports both I2S/I2C and SLIMbus audio interfaces. On slimbus interface it supports two data lanes; 16 Tx ports and 8 Rx ports. It has Five DACs and seven dedicated interpolators, Seven (six audio ADCs, and one VBAT ADC), Multibutton headset control (MBHC), Active noise cancellation, Sidetone paths, MAD (mic activity detection) and codec processing engine. It supports Class-H differential earpiece out and stereo single ended headphones out. This codec also has integrated SoundWire controller. This patchset adds very basic support for playback and capture via the interpolators and ADC respectively. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-4-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 8 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wcd934x.c | 1591 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1601 insertions(+) create mode 100644 sound/soc/codecs/wcd934x.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 4abf37b5083f..146682049007 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -207,6 +207,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_UDA134X select SND_SOC_UDA1380 if I2C select SND_SOC_WCD9335 if SLIMBUS + select SND_SOC_WCD934X if MFD_WCD934X select SND_SOC_WL1273 if MFD_WL1273_CORE select SND_SOC_WM0010 if SPI_MASTER select SND_SOC_WM1250_EV1 if I2C @@ -1275,6 +1276,13 @@ config SND_SOC_WCD9335 Qualcomm Technologies, Inc. (QTI) multimedia solutions, including the MSM8996, MSM8976, and MSM8956 chipsets. +config SND_SOC_WCD934X + tristate "WCD9340/WCD9341 Codec" + depends on MFD_WCD934X + help + The WCD9340/9341 is a audio codec IC Integrated in + Qualcomm SoCs like SDM845. + config SND_SOC_WL1273 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index ddfd07071925..0290fb389835 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -220,6 +220,7 @@ snd-soc-uda1334-objs := uda1334.o snd-soc-uda134x-objs := uda134x.o snd-soc-uda1380-objs := uda1380.o snd-soc-wcd9335-objs := wcd-clsh-v2.o wcd9335.o +snd-soc-wcd934x-objs := wcd-clsh-v2.o wcd934x.o snd-soc-wl1273-objs := wl1273.o snd-soc-wm-adsp-objs := wm_adsp.o snd-soc-wm0010-objs := wm0010.o @@ -509,6 +510,7 @@ obj-$(CONFIG_SND_SOC_UDA1334) += snd-soc-uda1334.o obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o obj-$(CONFIG_SND_SOC_WCD9335) += snd-soc-wcd9335.o +obj-$(CONFIG_SND_SOC_WCD934X) += snd-soc-wcd934x.o obj-$(CONFIG_SND_SOC_WL1273) += snd-soc-wl1273.o obj-$(CONFIG_SND_SOC_WM0010) += snd-soc-wm0010.o obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c new file mode 100644 index 000000000000..825cf057e8b7 --- /dev/null +++ b/sound/soc/codecs/wcd934x.c @@ -0,0 +1,1591 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2019, Linaro Limited + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "wcd-clsh-v2.h" + +#define WCD934X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000) +/* Fractional Rates */ +#define WCD934X_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\ + SNDRV_PCM_RATE_176400) +#define WCD934X_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE) + +/* slave port water mark level + * (0: 6bytes, 1: 9bytes, 2: 12 bytes, 3: 15 bytes) + */ +#define SLAVE_PORT_WATER_MARK_6BYTES 0 +#define SLAVE_PORT_WATER_MARK_9BYTES 1 +#define SLAVE_PORT_WATER_MARK_12BYTES 2 +#define SLAVE_PORT_WATER_MARK_15BYTES 3 +#define SLAVE_PORT_WATER_MARK_SHIFT 1 +#define SLAVE_PORT_ENABLE 1 +#define SLAVE_PORT_DISABLE 0 +#define WCD934X_SLIM_WATER_MARK_VAL \ + ((SLAVE_PORT_WATER_MARK_12BYTES << SLAVE_PORT_WATER_MARK_SHIFT) | \ + (SLAVE_PORT_ENABLE)) + +#define WCD934X_SLIM_NUM_PORT_REG 3 +#define WCD934X_SLIM_PGD_PORT_INT_TX_EN0 (WCD934X_SLIM_PGD_PORT_INT_EN0 + 2) +#define WCD934X_SLIM_IRQ_OVERFLOW BIT(0) +#define WCD934X_SLIM_IRQ_UNDERFLOW BIT(1) +#define WCD934X_SLIM_IRQ_PORT_CLOSED BIT(2) + +#define WCD934X_MCLK_CLK_12P288MHZ 12288000 +#define WCD934X_MCLK_CLK_9P6MHZ 9600000 + +/* Only valid for 9.6 MHz mclk */ +#define WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ 2400000 +#define WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ 4800000 + +/* Only valid for 12.288 MHz mclk */ +#define WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ 4096000 + +#define WCD934X_DMIC_CLK_DIV_2 0x0 +#define WCD934X_DMIC_CLK_DIV_3 0x1 +#define WCD934X_DMIC_CLK_DIV_4 0x2 +#define WCD934X_DMIC_CLK_DIV_6 0x3 +#define WCD934X_DMIC_CLK_DIV_8 0x4 +#define WCD934X_DMIC_CLK_DIV_16 0x5 +#define WCD934X_DMIC_CLK_DRIVE_DEFAULT 0x02 + +#define TX_HPF_CUT_OFF_FREQ_MASK 0x60 +#define CF_MIN_3DB_4HZ 0x0 +#define CF_MIN_3DB_75HZ 0x1 +#define CF_MIN_3DB_150HZ 0x2 + +#define WCD934X_RX_START 16 +#define WCD934X_NUM_INTERPOLATORS 9 +#define WCD934X_RX_PATH_CTL_OFFSET 20 +#define WCD934X_MAX_VALID_ADC_MUX 13 +#define WCD934X_INVALID_ADC_MUX 9 + +#define WCD934X_SLIM_RX_CH(p) \ + {.port = p + WCD934X_RX_START, .shift = p,} + +#define WCD934X_SLIM_TX_CH(p) \ + {.port = p, .shift = p,} + +/* Feature masks to distinguish codec version */ +#define DSD_DISABLED_MASK 0 +#define SLNQ_DISABLED_MASK 1 + +#define DSD_DISABLED BIT(DSD_DISABLED_MASK) +#define SLNQ_DISABLED BIT(SLNQ_DISABLED_MASK) + +/* As fine version info cannot be retrieved before wcd probe. + * Define three coarse versions for possible future use before wcd probe. + */ +#define WCD_VERSION_WCD9340_1_0 0x400 +#define WCD_VERSION_WCD9341_1_0 0x410 +#define WCD_VERSION_WCD9340_1_1 0x401 +#define WCD_VERSION_WCD9341_1_1 0x411 +#define WCD934X_AMIC_PWR_LEVEL_LP 0 +#define WCD934X_AMIC_PWR_LEVEL_DEFAULT 1 +#define WCD934X_AMIC_PWR_LEVEL_HP 2 +#define WCD934X_AMIC_PWR_LEVEL_HYBRID 3 +#define WCD934X_AMIC_PWR_LVL_MASK 0x60 +#define WCD934X_AMIC_PWR_LVL_SHIFT 0x5 + +#define WCD934X_DEC_PWR_LVL_MASK 0x06 +#define WCD934X_DEC_PWR_LVL_LP 0x02 +#define WCD934X_DEC_PWR_LVL_HP 0x04 +#define WCD934X_DEC_PWR_LVL_DF 0x00 +#define WCD934X_DEC_PWR_LVL_HYBRID WCD934X_DEC_PWR_LVL_DF + +#define WCD934X_DEF_MICBIAS_MV 1800 +#define WCD934X_MAX_MICBIAS_MV 2850 + +enum { + SIDO_SOURCE_INTERNAL, + SIDO_SOURCE_RCO_BG, +}; + +enum { + INTERP_EAR = 0, + INTERP_HPHL, + INTERP_HPHR, + INTERP_LO1, + INTERP_LO2, + INTERP_LO3_NA, /* LO3 not avalible in Tavil */ + INTERP_LO4_NA, + INTERP_SPKR1, /*INT7 WSA Speakers via soundwire */ + INTERP_SPKR2, /*INT8 WSA Speakers via soundwire */ + INTERP_MAX, +}; + +enum { + WCD934X_RX0 = 0, + WCD934X_RX1, + WCD934X_RX2, + WCD934X_RX3, + WCD934X_RX4, + WCD934X_RX5, + WCD934X_RX6, + WCD934X_RX7, + WCD934X_RX8, + WCD934X_RX9, + WCD934X_RX10, + WCD934X_RX11, + WCD934X_RX12, + WCD934X_RX_MAX, +}; + +enum { + WCD934X_TX0 = 0, + WCD934X_TX1, + WCD934X_TX2, + WCD934X_TX3, + WCD934X_TX4, + WCD934X_TX5, + WCD934X_TX6, + WCD934X_TX7, + WCD934X_TX8, + WCD934X_TX9, + WCD934X_TX10, + WCD934X_TX11, + WCD934X_TX12, + WCD934X_TX13, + WCD934X_TX14, + WCD934X_TX15, + WCD934X_TX_MAX, +}; + +struct wcd934x_slim_ch { + u32 ch_num; + u16 port; + u16 shift; + struct list_head list; +}; + +static const struct wcd934x_slim_ch wcd934x_tx_chs[WCD934X_TX_MAX] = { + WCD934X_SLIM_TX_CH(0), + WCD934X_SLIM_TX_CH(1), + WCD934X_SLIM_TX_CH(2), + WCD934X_SLIM_TX_CH(3), + WCD934X_SLIM_TX_CH(4), + WCD934X_SLIM_TX_CH(5), + WCD934X_SLIM_TX_CH(6), + WCD934X_SLIM_TX_CH(7), + WCD934X_SLIM_TX_CH(8), + WCD934X_SLIM_TX_CH(9), + WCD934X_SLIM_TX_CH(10), + WCD934X_SLIM_TX_CH(11), + WCD934X_SLIM_TX_CH(12), + WCD934X_SLIM_TX_CH(13), + WCD934X_SLIM_TX_CH(14), + WCD934X_SLIM_TX_CH(15), +}; + +static const struct wcd934x_slim_ch wcd934x_rx_chs[WCD934X_RX_MAX] = { + WCD934X_SLIM_RX_CH(0), /* 16 */ + WCD934X_SLIM_RX_CH(1), /* 17 */ + WCD934X_SLIM_RX_CH(2), + WCD934X_SLIM_RX_CH(3), + WCD934X_SLIM_RX_CH(4), + WCD934X_SLIM_RX_CH(5), + WCD934X_SLIM_RX_CH(6), + WCD934X_SLIM_RX_CH(7), + WCD934X_SLIM_RX_CH(8), + WCD934X_SLIM_RX_CH(9), + WCD934X_SLIM_RX_CH(10), + WCD934X_SLIM_RX_CH(11), + WCD934X_SLIM_RX_CH(12), +}; + +enum { + AIF1_PB = 0, + AIF1_CAP, + AIF2_PB, + AIF2_CAP, + AIF3_PB, + AIF3_CAP, + AIF4_PB, + AIF4_VIFEED, + AIF4_MAD_TX, + NUM_CODEC_DAIS, +}; + +enum { + INTn_1_INP_SEL_ZERO = 0, + INTn_1_INP_SEL_DEC0, + INTn_1_INP_SEL_DEC1, + INTn_1_INP_SEL_IIR0, + INTn_1_INP_SEL_IIR1, + INTn_1_INP_SEL_RX0, + INTn_1_INP_SEL_RX1, + INTn_1_INP_SEL_RX2, + INTn_1_INP_SEL_RX3, + INTn_1_INP_SEL_RX4, + INTn_1_INP_SEL_RX5, + INTn_1_INP_SEL_RX6, + INTn_1_INP_SEL_RX7, +}; + +enum { + INTn_2_INP_SEL_ZERO = 0, + INTn_2_INP_SEL_RX0, + INTn_2_INP_SEL_RX1, + INTn_2_INP_SEL_RX2, + INTn_2_INP_SEL_RX3, + INTn_2_INP_SEL_RX4, + INTn_2_INP_SEL_RX5, + INTn_2_INP_SEL_RX6, + INTn_2_INP_SEL_RX7, + INTn_2_INP_SEL_PROXIMITY, +}; + +enum { + INTERP_MAIN_PATH, + INTERP_MIX_PATH, +}; + +struct interp_sample_rate { + int sample_rate; + int rate_val; +}; + +static struct interp_sample_rate sr_val_tbl[] = { + {8000, 0x0}, + {16000, 0x1}, + {32000, 0x3}, + {48000, 0x4}, + {96000, 0x5}, + {192000, 0x6}, + {384000, 0x7}, + {44100, 0x9}, + {88200, 0xA}, + {176400, 0xB}, + {352800, 0xC}, +}; + +struct wcd_slim_codec_dai_data { + struct list_head slim_ch_list; + struct slim_stream_config sconfig; + struct slim_stream_runtime *sruntime; +}; + +static const struct regmap_range_cfg wcd934x_ifc_ranges[] = { + { + .name = "WCD9335-IFC-DEV", + .range_min = 0x0, + .range_max = 0xffff, + .selector_reg = 0x800, + .selector_mask = 0xfff, + .selector_shift = 0, + .window_start = 0x800, + .window_len = 0x400, + }, +}; + +static struct regmap_config wcd934x_ifc_regmap_config = { + .reg_bits = 16, + .val_bits = 8, + .max_register = 0xffff, + .ranges = wcd934x_ifc_ranges, + .num_ranges = ARRAY_SIZE(wcd934x_ifc_ranges), +}; + +struct wcd934x_codec { + struct device *dev; + struct clk_hw hw; + struct clk *extclk; + struct regmap *regmap; + struct regmap *if_regmap; + struct slim_device *sdev; + struct slim_device *sidev; + struct wcd_clsh_ctrl *clsh_ctrl; + struct snd_soc_component *component; + struct wcd934x_slim_ch rx_chs[WCD934X_RX_MAX]; + struct wcd934x_slim_ch tx_chs[WCD934X_TX_MAX]; + struct wcd_slim_codec_dai_data dai[NUM_CODEC_DAIS]; + int rate; + u32 version; + u32 hph_mode; + int num_rx_port; + int num_tx_port; + u32 tx_port_value[WCD934X_TX_MAX]; + u32 rx_port_value[WCD934X_RX_MAX]; + int sido_input_src; + int dmic_0_1_clk_cnt; + int dmic_2_3_clk_cnt; + int dmic_4_5_clk_cnt; + int dmic_sample_rate; + int sysclk_users; + struct mutex sysclk_mutex; +}; + +#define to_wcd934x_codec(_hw) container_of(_hw, struct wcd934x_codec, hw) + +static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, + int sido_src) +{ + if (sido_src == wcd->sido_input_src) + return 0; + + if (sido_src == SIDO_SOURCE_INTERNAL) { + regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL, + WCD934X_ANA_BUCK_HI_ACCU_EN_MASK, 0); + usleep_range(100, 110); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL, + WCD934X_ANA_BUCK_HI_ACCU_PRE_ENX_MASK, 0x0); + usleep_range(100, 110); + regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO, + WCD934X_ANA_RCO_BG_EN_MASK, 0); + usleep_range(100, 110); + } else if (sido_src == SIDO_SOURCE_RCO_BG) { + regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO, + WCD934X_ANA_RCO_BG_EN_MASK, + WCD934X_ANA_RCO_BG_ENABLE); + usleep_range(100, 110); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL, + WCD934X_ANA_BUCK_PRE_EN1_MASK, + WCD934X_ANA_BUCK_PRE_EN1_ENABLE); + usleep_range(100, 110); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL, + WCD934X_ANA_BUCK_PRE_EN2_MASK, + WCD934X_ANA_BUCK_PRE_EN2_ENABLE); + usleep_range(100, 110); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BUCK_CTL, + WCD934X_ANA_BUCK_HI_ACCU_EN_MASK, + WCD934X_ANA_BUCK_HI_ACCU_ENABLE); + usleep_range(100, 110); + } + wcd->sido_input_src = sido_src; + + return 0; +} + +static int wcd934x_enable_ana_bias_and_sysclk(struct wcd934x_codec *wcd) +{ + mutex_lock(&wcd->sysclk_mutex); + + if (++wcd->sysclk_users != 1) { + mutex_unlock(&wcd->sysclk_mutex); + return 0; + } + mutex_unlock(&wcd->sysclk_mutex); + + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_BIAS_EN_MASK, + WCD934X_ANA_BIAS_EN); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_PRECHRG_EN_MASK, + WCD934X_ANA_PRECHRG_EN); + /* + * 1ms delay is required after pre-charge is enabled + * as per HW requirement + */ + usleep_range(1000, 1100); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_PRECHRG_EN_MASK, 0); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_PRECHRG_MODE_MASK, 0); + + /* + * In data clock contrl register is changed + * to CLK_SYS_MCLK_PRG + */ + + regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, + WCD934X_EXT_CLK_BUF_EN_MASK, + WCD934X_EXT_CLK_BUF_EN); + regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, + WCD934X_EXT_CLK_DIV_RATIO_MASK, + WCD934X_EXT_CLK_DIV_BY_2); + regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, + WCD934X_MCLK_SRC_MASK, + WCD934X_MCLK_SRC_EXT_CLK); + regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, + WCD934X_MCLK_EN_MASK, WCD934X_MCLK_EN); + regmap_update_bits(wcd->regmap, + WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, + WCD934X_CDC_FS_MCLK_CNT_EN_MASK, + WCD934X_CDC_FS_MCLK_CNT_ENABLE); + regmap_update_bits(wcd->regmap, + WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL, + WCD934X_MCLK_EN_MASK, + WCD934X_MCLK_EN); + regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_GATE, + WCD934X_CODEC_RPM_CLK_GATE_MASK, 0x0); + /* + * 10us sleep is required after clock is enabled + * as per HW requirement + */ + usleep_range(10, 15); + + wcd934x_set_sido_input_src(wcd, SIDO_SOURCE_RCO_BG); + + return 0; +} + +static int wcd934x_disable_ana_bias_and_syclk(struct wcd934x_codec *wcd) +{ + mutex_lock(&wcd->sysclk_mutex); + if (--wcd->sysclk_users != 0) { + mutex_unlock(&wcd->sysclk_mutex); + return 0; + } + mutex_unlock(&wcd->sysclk_mutex); + + regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, + WCD934X_EXT_CLK_BUF_EN_MASK | + WCD934X_MCLK_EN_MASK, 0x0); + wcd934x_set_sido_input_src(wcd, SIDO_SOURCE_INTERNAL); + + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_BIAS_EN_MASK, 0); + regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, + WCD934X_ANA_PRECHRG_EN_MASK, 0); + + return 0; +} + +static int __wcd934x_cdc_mclk_enable(struct wcd934x_codec *wcd, bool enable) +{ + int ret = 0; + + if (enable) { + ret = clk_prepare_enable(wcd->extclk); + + if (ret) { + dev_err(wcd->dev, "%s: ext clk enable failed\n", + __func__); + return ret; + } + ret = wcd934x_enable_ana_bias_and_sysclk(wcd); + } else { + int val; + + regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, + &val); + + /* Don't disable clock if soundwire using it.*/ + if (val & WCD934X_CDC_SWR_CLK_EN_MASK) + return 0; + + wcd934x_disable_ana_bias_and_syclk(wcd); + clk_disable_unprepare(wcd->extclk); + } + + return ret; +} + +static int wcd934x_get_version(struct wcd934x_codec *wcd) +{ + int val1, val2, ver, ret; + struct regmap *regmap; + u16 id_minor; + u32 version_mask = 0; + + regmap = wcd->regmap; + ver = 0; + + ret = regmap_bulk_read(regmap, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0, + (u8 *)&id_minor, sizeof(u16)); + + if (ret) + return ret; + + regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14, &val1); + regmap_read(regmap, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT15, &val2); + + version_mask |= (!!((u8)val1 & 0x80)) << DSD_DISABLED_MASK; + version_mask |= (!!((u8)val2 & 0x01)) << SLNQ_DISABLED_MASK; + + switch (version_mask) { + case DSD_DISABLED | SLNQ_DISABLED: + if (id_minor == 0) + ver = WCD_VERSION_WCD9340_1_0; + else if (id_minor == 0x01) + ver = WCD_VERSION_WCD9340_1_1; + break; + case SLNQ_DISABLED: + if (id_minor == 0) + ver = WCD_VERSION_WCD9341_1_0; + else if (id_minor == 0x01) + ver = WCD_VERSION_WCD9341_1_1; + break; + } + + wcd->version = ver; + dev_info(wcd->dev, "WCD934X Minor:0x%x Version:0x%x\n", id_minor, ver); + + return 0; +} + +static void wcd934x_enable_efuse_sensing(struct wcd934x_codec *wcd) +{ + int rc, val; + + __wcd934x_cdc_mclk_enable(wcd, true); + + regmap_update_bits(wcd->regmap, + WCD934X_CHIP_TIER_CTRL_EFUSE_CTL, + WCD934X_EFUSE_SENSE_STATE_MASK, + WCD934X_EFUSE_SENSE_STATE_DEF); + regmap_update_bits(wcd->regmap, + WCD934X_CHIP_TIER_CTRL_EFUSE_CTL, + WCD934X_EFUSE_SENSE_EN_MASK, + WCD934X_EFUSE_SENSE_ENABLE); + /* + * 5ms sleep required after enabling efuse control + * before checking the status. + */ + usleep_range(5000, 5500); + wcd934x_set_sido_input_src(wcd, SIDO_SOURCE_RCO_BG); + + rc = regmap_read(wcd->regmap, + WCD934X_CHIP_TIER_CTRL_EFUSE_STATUS, &val); + if (rc || (!(val & 0x01))) + WARN(1, "%s: Efuse sense is not complete val=%x, ret=%d\n", + __func__, val, rc); + + __wcd934x_cdc_mclk_enable(wcd, false); +} + +static int wcd934x_swrm_clock(struct wcd934x_codec *wcd, bool enable) +{ + if (enable) { + __wcd934x_cdc_mclk_enable(wcd, true); + regmap_update_bits(wcd->regmap, + WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, + WCD934X_CDC_SWR_CLK_EN_MASK, + WCD934X_CDC_SWR_CLK_ENABLE); + } else { + regmap_update_bits(wcd->regmap, + WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, + WCD934X_CDC_SWR_CLK_EN_MASK, 0); + __wcd934x_cdc_mclk_enable(wcd, false); + } + + return 0; +} + +static int wcd934x_set_prim_interpolator_rate(struct snd_soc_dai *dai, + u8 rate_val, u32 rate) +{ + struct snd_soc_component *comp = dai->component; + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + struct wcd934x_slim_ch *ch; + u8 cfg0, cfg1, inp0_sel, inp1_sel, inp2_sel; + int inp, j; + + list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { + inp = ch->shift + INTn_1_INP_SEL_RX0; + /* + * Loop through all interpolator MUX inputs and find out + * to which interpolator input, the slim rx port + * is connected + */ + for (j = 0; j < WCD934X_NUM_INTERPOLATORS; j++) { + /* Interpolators 5 and 6 are not aviliable in Tavil */ + if (j == INTERP_LO3_NA || j == INTERP_LO4_NA) + continue; + + cfg0 = snd_soc_component_read32(comp, + WCD934X_CDC_RX_INP_MUX_RX_INT_CFG0(j)); + cfg1 = snd_soc_component_read32(comp, + WCD934X_CDC_RX_INP_MUX_RX_INT_CFG1(j)); + + inp0_sel = cfg0 & + WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK; + inp1_sel = (cfg0 >> 4) & + WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK; + inp2_sel = (cfg1 >> 4) & + WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK; + + if ((inp0_sel == inp) || (inp1_sel == inp) || + (inp2_sel == inp)) { + /* rate is in Hz */ + /* + * Ear and speaker primary path does not support + * native sample rates + */ + if ((j == INTERP_EAR || j == INTERP_SPKR1 || + j == INTERP_SPKR2) && rate == 44100) + dev_err(wcd->dev, + "Cannot set 44.1KHz on INT%d\n", + j); + else + snd_soc_component_update_bits(comp, + WCD934X_CDC_RX_PATH_CTL(j), + WCD934X_CDC_MIX_PCM_RATE_MASK, + rate_val); + } + } + } + + return 0; +} + +static int wcd934x_set_mix_interpolator_rate(struct snd_soc_dai *dai, + int rate_val, u32 rate) +{ + struct snd_soc_component *component = dai->component; + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + struct wcd934x_slim_ch *ch; + int val, j; + + list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { + for (j = 0; j < WCD934X_NUM_INTERPOLATORS; j++) { + /* Interpolators 5 and 6 are not aviliable in Tavil */ + if (j == INTERP_LO3_NA || j == INTERP_LO4_NA) + continue; + val = snd_soc_component_read32(component, + WCD934X_CDC_RX_INP_MUX_RX_INT_CFG1(j)) & + WCD934X_CDC_RX_INP_MUX_RX_INT_SEL_MASK; + + if (val == (ch->shift + INTn_2_INP_SEL_RX0)) { + /* + * Ear mix path supports only 48, 96, 192, + * 384KHz only + */ + if ((j == INTERP_EAR) && + (rate_val < 0x4 || + rate_val > 0x7)) { + dev_err(component->dev, + "Invalid rate for AIF_PB DAI(%d)\n", + dai->id); + return -EINVAL; + } + + snd_soc_component_update_bits(component, + WCD934X_CDC_RX_PATH_MIX_CTL(j), + WCD934X_CDC_MIX_PCM_RATE_MASK, + rate_val); + } + } + } + + return 0; +} + +static int wcd934x_set_interpolator_rate(struct snd_soc_dai *dai, + u32 sample_rate) +{ + int rate_val = 0; + int i, ret; + + for (i = 0; i < ARRAY_SIZE(sr_val_tbl); i++) { + if (sample_rate == sr_val_tbl[i].sample_rate) { + rate_val = sr_val_tbl[i].rate_val; + break; + } + } + if ((i == ARRAY_SIZE(sr_val_tbl)) || (rate_val < 0)) { + dev_err(dai->dev, "Unsupported sample rate: %d\n", sample_rate); + return -EINVAL; + } + + ret = wcd934x_set_prim_interpolator_rate(dai, (u8)rate_val, + sample_rate); + if (ret) + return ret; + ret = wcd934x_set_mix_interpolator_rate(dai, (u8)rate_val, + sample_rate); + if (ret) + return ret; + + return ret; +} + +static int wcd934x_set_decimator_rate(struct snd_soc_dai *dai, + u8 rate_val, u32 rate) +{ + struct snd_soc_component *comp = dai->component; + struct wcd934x_codec *wcd = snd_soc_component_get_drvdata(comp); + u8 shift = 0, shift_val = 0, tx_mux_sel; + struct wcd934x_slim_ch *ch; + int tx_port, tx_port_reg; + int decimator = -1; + + list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { + tx_port = ch->port; + /* Find the SB TX MUX input - which decimator is connected */ + switch (tx_port) { + case 0 ... 3: + tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0; + shift = (tx_port << 1); + shift_val = 0x03; + break; + case 4 ... 7: + tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1; + shift = ((tx_port - 4) << 1); + shift_val = 0x03; + break; + case 8 ... 10: + tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2; + shift = ((tx_port - 8) << 1); + shift_val = 0x03; + break; + case 11: + tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3; + shift = 0; + shift_val = 0x0F; + break; + case 13: + tx_port_reg = WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3; + shift = 4; + shift_val = 0x03; + break; + default: + dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", + tx_port, dai->id); + return -EINVAL; + } + + tx_mux_sel = snd_soc_component_read32(comp, tx_port_reg) & + (shift_val << shift); + + tx_mux_sel = tx_mux_sel >> shift; + switch (tx_port) { + case 0 ... 8: + if ((tx_mux_sel == 0x2) || (tx_mux_sel == 0x3)) + decimator = tx_port; + break; + case 9 ... 10: + if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2)) + decimator = ((tx_port == 9) ? 7 : 6); + break; + case 11: + if ((tx_mux_sel >= 1) && (tx_mux_sel < 7)) + decimator = tx_mux_sel - 1; + break; + case 13: + if ((tx_mux_sel == 0x1) || (tx_mux_sel == 0x2)) + decimator = 5; + break; + default: + dev_err(wcd->dev, "ERROR: Invalid tx_port: %d\n", + tx_port); + return -EINVAL; + } + + snd_soc_component_update_bits(comp, + WCD934X_CDC_TX_PATH_CTL(decimator), + WCD934X_CDC_TX_PATH_CTL_PCM_RATE_MASK, + rate_val); + } + + return 0; +} + +static int wcd934x_slim_set_hw_params(struct wcd934x_codec *wcd, + struct wcd_slim_codec_dai_data *dai_data, + int direction) +{ + struct list_head *slim_ch_list = &dai_data->slim_ch_list; + struct slim_stream_config *cfg = &dai_data->sconfig; + struct wcd934x_slim_ch *ch; + u16 payload = 0; + int ret, i; + + cfg->ch_count = 0; + cfg->direction = direction; + cfg->port_mask = 0; + + /* Configure slave interface device */ + list_for_each_entry(ch, slim_ch_list, list) { + cfg->ch_count++; + payload |= 1 << ch->shift; + cfg->port_mask |= BIT(ch->port); + } + + cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); + if (!cfg->chs) + return -ENOMEM; + + i = 0; + list_for_each_entry(ch, slim_ch_list, list) { + cfg->chs[i++] = ch->ch_num; + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + /* write to interface device */ + ret = regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), + payload); + + if (ret < 0) + goto err; + + /* configure the slave port for water mark and enable*/ + ret = regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_RX_PORT_CFG(ch->port), + WCD934X_SLIM_WATER_MARK_VAL); + if (ret < 0) + goto err; + } else { + ret = regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), + payload & 0x00FF); + if (ret < 0) + goto err; + + /* ports 8,9 */ + ret = regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), + (payload & 0xFF00) >> 8); + if (ret < 0) + goto err; + + /* configure the slave port for water mark and enable*/ + ret = regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_TX_PORT_CFG(ch->port), + WCD934X_SLIM_WATER_MARK_VAL); + + if (ret < 0) + goto err; + } + } + + dai_data->sruntime = slim_stream_allocate(wcd->sdev, "WCD934x-SLIM"); + + return 0; + +err: + dev_err(wcd->dev, "Error Setting slim hw params\n"); + kfree(cfg->chs); + cfg->chs = NULL; + + return ret; +} + +static int wcd934x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct wcd934x_codec *wcd; + int ret, tx_fs_rate = 0; + + wcd = snd_soc_component_get_drvdata(dai->component); + + switch (substream->stream) { + case SNDRV_PCM_STREAM_PLAYBACK: + ret = wcd934x_set_interpolator_rate(dai, params_rate(params)); + if (ret) { + dev_err(wcd->dev, "cannot set sample rate: %u\n", + params_rate(params)); + return ret; + } + switch (params_width(params)) { + case 16 ... 24: + wcd->dai[dai->id].sconfig.bps = params_width(params); + break; + default: + dev_err(wcd->dev, "Invalid format 0x%x\n", + params_width(params)); + return -EINVAL; + } + break; + + case SNDRV_PCM_STREAM_CAPTURE: + switch (params_rate(params)) { + case 8000: + tx_fs_rate = 0; + break; + case 16000: + tx_fs_rate = 1; + break; + case 32000: + tx_fs_rate = 3; + break; + case 48000: + tx_fs_rate = 4; + break; + case 96000: + tx_fs_rate = 5; + break; + case 192000: + tx_fs_rate = 6; + break; + case 384000: + tx_fs_rate = 7; + break; + default: + dev_err(wcd->dev, "Invalid TX sample rate: %d\n", + params_rate(params)); + return -EINVAL; + + }; + + ret = wcd934x_set_decimator_rate(dai, tx_fs_rate, + params_rate(params)); + if (ret < 0) { + dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); + return ret; + } + switch (params_width(params)) { + case 16 ... 32: + wcd->dai[dai->id].sconfig.bps = params_width(params); + break; + default: + dev_err(wcd->dev, "Invalid format 0x%x\n", + params_width(params)); + return -EINVAL; + }; + break; + default: + dev_err(wcd->dev, "Invalid stream type %d\n", + substream->stream); + return -EINVAL; + }; + + wcd->dai[dai->id].sconfig.rate = params_rate(params); + wcd934x_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); + + return 0; +} + +static int wcd934x_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wcd_slim_codec_dai_data *dai_data; + struct wcd934x_codec *wcd; + + wcd = snd_soc_component_get_drvdata(dai->component); + + dai_data = &wcd->dai[dai->id]; + + kfree(dai_data->sconfig.chs); + + return 0; +} + +static int wcd934x_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct wcd_slim_codec_dai_data *dai_data; + struct wcd934x_codec *wcd; + struct slim_stream_config *cfg; + + wcd = snd_soc_component_get_drvdata(dai->component); + + dai_data = &wcd->dai[dai->id]; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + cfg = &dai_data->sconfig; + slim_stream_prepare(dai_data->sruntime, cfg); + slim_stream_enable(dai_data->sruntime); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + slim_stream_unprepare(dai_data->sruntime); + slim_stream_disable(dai_data->sruntime); + break; + default: + break; + } + + return 0; +} + +static int wcd934x_set_channel_map(struct snd_soc_dai *dai, + unsigned int tx_num, unsigned int *tx_slot, + unsigned int rx_num, unsigned int *rx_slot) +{ + struct wcd934x_codec *wcd; + int i; + + wcd = snd_soc_component_get_drvdata(dai->component); + + if (!tx_slot || !rx_slot) { + dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", + tx_slot, rx_slot); + return -EINVAL; + } + + if (wcd->rx_chs) { + wcd->num_rx_port = rx_num; + for (i = 0; i < rx_num; i++) { + wcd->rx_chs[i].ch_num = rx_slot[i]; + INIT_LIST_HEAD(&wcd->rx_chs[i].list); + } + } + + if (wcd->tx_chs) { + wcd->num_tx_port = tx_num; + for (i = 0; i < tx_num; i++) { + wcd->tx_chs[i].ch_num = tx_slot[i]; + INIT_LIST_HEAD(&wcd->tx_chs[i].list); + } + } + + return 0; +} + +static int wcd934x_get_channel_map(struct snd_soc_dai *dai, + unsigned int *tx_num, unsigned int *tx_slot, + unsigned int *rx_num, unsigned int *rx_slot) +{ + struct wcd934x_slim_ch *ch; + struct wcd934x_codec *wcd; + int i = 0; + + wcd = snd_soc_component_get_drvdata(dai->component); + + switch (dai->id) { + case AIF1_PB: + case AIF2_PB: + case AIF3_PB: + case AIF4_PB: + if (!rx_slot || !rx_num) { + dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", + rx_slot, rx_num); + return -EINVAL; + } + + list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) + rx_slot[i++] = ch->ch_num; + + *rx_num = i; + break; + case AIF1_CAP: + case AIF2_CAP: + case AIF3_CAP: + if (!tx_slot || !tx_num) { + dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", + tx_slot, tx_num); + return -EINVAL; + } + + list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) + tx_slot[i++] = ch->ch_num; + + *tx_num = i; + break; + default: + dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); + break; + } + + return 0; +} + +static struct snd_soc_dai_ops wcd934x_dai_ops = { + .hw_params = wcd934x_hw_params, + .hw_free = wcd934x_hw_free, + .trigger = wcd934x_trigger, + .set_channel_map = wcd934x_set_channel_map, + .get_channel_map = wcd934x_get_channel_map, +}; + +static struct snd_soc_dai_driver wcd934x_slim_dais[] = { + [0] = { + .name = "wcd934x_rx1", + .id = AIF1_PB, + .playback = { + .stream_name = "AIF1 Playback", + .rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK, + .formats = WCD934X_FORMATS_S16_S24_LE, + .rate_max = 192000, + .rate_min = 8000, + .channels_min = 1, + .channels_max = 2, + }, + .ops = &wcd934x_dai_ops, + }, + [1] = { + .name = "wcd934x_tx1", + .id = AIF1_CAP, + .capture = { + .stream_name = "AIF1 Capture", + .rates = WCD934X_RATES_MASK, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 4, + }, + .ops = &wcd934x_dai_ops, + }, + [2] = { + .name = "wcd934x_rx2", + .id = AIF2_PB, + .playback = { + .stream_name = "AIF2 Playback", + .rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK, + .formats = WCD934X_FORMATS_S16_S24_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 2, + }, + .ops = &wcd934x_dai_ops, + }, + [3] = { + .name = "wcd934x_tx2", + .id = AIF2_CAP, + .capture = { + .stream_name = "AIF2 Capture", + .rates = WCD934X_RATES_MASK, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 4, + }, + .ops = &wcd934x_dai_ops, + }, + [4] = { + .name = "wcd934x_rx3", + .id = AIF3_PB, + .playback = { + .stream_name = "AIF3 Playback", + .rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK, + .formats = WCD934X_FORMATS_S16_S24_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 2, + }, + .ops = &wcd934x_dai_ops, + }, + [5] = { + .name = "wcd934x_tx3", + .id = AIF3_CAP, + .capture = { + .stream_name = "AIF3 Capture", + .rates = WCD934X_RATES_MASK, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 4, + }, + .ops = &wcd934x_dai_ops, + }, + [6] = { + .name = "wcd934x_rx4", + .id = AIF4_PB, + .playback = { + .stream_name = "AIF4 Playback", + .rates = WCD934X_RATES_MASK | WCD934X_FRAC_RATES_MASK, + .formats = WCD934X_FORMATS_S16_S24_LE, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 2, + }, + .ops = &wcd934x_dai_ops, + }, +}; + +static int swclk_gate_enable(struct clk_hw *hw) +{ + return wcd934x_swrm_clock(to_wcd934x_codec(hw), true); +} + +static void swclk_gate_disable(struct clk_hw *hw) +{ + wcd934x_swrm_clock(to_wcd934x_codec(hw), false); +} + +static int swclk_gate_is_enabled(struct clk_hw *hw) +{ + struct wcd934x_codec *wcd = to_wcd934x_codec(hw); + int ret, val; + + regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, &val); + ret = val & WCD934X_CDC_SWR_CLK_EN_MASK; + + return ret; +} + +static unsigned long swclk_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + return parent_rate / 2; +} + +static const struct clk_ops swclk_gate_ops = { + .prepare = swclk_gate_enable, + .unprepare = swclk_gate_disable, + .is_enabled = swclk_gate_is_enabled, + .recalc_rate = swclk_recalc_rate, + +}; + +static struct clk *wcd934x_register_mclk_output(struct wcd934x_codec *wcd) +{ + struct clk *parent = wcd->extclk; + struct device *dev = wcd->dev; + struct device_node *np = dev->parent->of_node; + const char *parent_clk_name = NULL; + const char *clk_name = "mclk"; + struct clk_hw *hw; + struct clk_init_data init; + int ret; + + if (of_property_read_u32(np, "clock-frequency", &wcd->rate)) + return NULL; + + parent_clk_name = __clk_get_name(parent); + + of_property_read_string(np, "clock-output-names", &clk_name); + + init.name = clk_name; + init.ops = &swclk_gate_ops; + init.flags = 0; + init.parent_names = &parent_clk_name; + init.num_parents = 1; + wcd->hw.init = &init; + + hw = &wcd->hw; + ret = clk_hw_register(wcd->dev->parent, hw); + if (ret) + return ERR_PTR(ret); + + of_clk_add_provider(np, of_clk_src_simple_get, hw->clk); + + return NULL; +} + +static int wcd934x_get_micbias_val(struct device *dev, const char *micbias) +{ + int mv; + + if (of_property_read_u32(dev->parent->of_node, micbias, &mv)) { + dev_err(dev, "%s value not found, using default\n", micbias); + mv = WCD934X_DEF_MICBIAS_MV; + } else { + /* convert it to milli volts */ + mv = mv/1000; + } + + if (mv < 1000 || mv > 2850) { + dev_err(dev, "%s value not in valid range, using default\n", + micbias); + mv = WCD934X_DEF_MICBIAS_MV; + } + + return (mv - 1000) / 50; +} + +static int wcd934x_init_dmic(struct snd_soc_component *comp) +{ + int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4; + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + u32 def_dmic_rate, dmic_clk_drv; + + vout_ctl_1 = wcd934x_get_micbias_val(comp->dev, + "qcom,micbias1-microvolt"); + vout_ctl_2 = wcd934x_get_micbias_val(comp->dev, + "qcom,micbias2-microvolt"); + vout_ctl_3 = wcd934x_get_micbias_val(comp->dev, + "qcom,micbias3-microvolt"); + vout_ctl_4 = wcd934x_get_micbias_val(comp->dev, + "qcom,micbias4-microvolt"); + + snd_soc_component_update_bits(comp, WCD934X_ANA_MICB1, + WCD934X_MICB_VAL_MASK, vout_ctl_1); + snd_soc_component_update_bits(comp, WCD934X_ANA_MICB2, + WCD934X_MICB_VAL_MASK, vout_ctl_2); + snd_soc_component_update_bits(comp, WCD934X_ANA_MICB3, + WCD934X_MICB_VAL_MASK, vout_ctl_3); + snd_soc_component_update_bits(comp, WCD934X_ANA_MICB4, + WCD934X_MICB_VAL_MASK, vout_ctl_4); + + if (wcd->rate == WCD934X_MCLK_CLK_9P6MHZ) + def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ; + else + def_dmic_rate = WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ; + + wcd->dmic_sample_rate = def_dmic_rate; + + dmic_clk_drv = 0; + snd_soc_component_update_bits(comp, WCD934X_TEST_DEBUG_PAD_DRVCTL_0, + 0x0C, dmic_clk_drv << 2); + + return 0; +} + +static void wcd934x_hw_init(struct wcd934x_codec *wcd) +{ + struct regmap *rm = wcd->regmap; + + /* set SPKR rate to FS_2P4_3P072 */ + regmap_update_bits(rm, WCD934X_CDC_RX7_RX_PATH_CFG1, 0x08, 0x08); + regmap_update_bits(rm, WCD934X_CDC_RX8_RX_PATH_CFG1, 0x08, 0x08); + + /* Take DMICs out of reset */ + regmap_update_bits(rm, WCD934X_CPE_SS_DMIC_CFG, 0x80, 0x00); +} + +static int wcd934x_comp_init(struct snd_soc_component *component) +{ + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + + wcd934x_hw_init(wcd); + wcd934x_enable_efuse_sensing(wcd); + wcd934x_get_version(wcd); + + return 0; +} + +static irqreturn_t wcd934x_slim_irq_handler(int irq, void *data) +{ + struct wcd934x_codec *wcd = data; + unsigned long status = 0; + int i, j, port_id; + unsigned int val, int_val = 0; + irqreturn_t ret = IRQ_NONE; + bool tx; + unsigned short reg = 0; + + for (i = WCD934X_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0; + i <= WCD934X_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) { + regmap_read(wcd->if_regmap, i, &val); + status |= ((u32)val << (8 * j)); + } + + for_each_set_bit(j, &status, 32) { + tx = false; + port_id = j; + + if (j >= 16) { + tx = true; + port_id = j - 16; + } + + regmap_read(wcd->if_regmap, + WCD934X_SLIM_PGD_PORT_INT_RX_SOURCE0 + j, &val); + if (val) { + if (!tx) + reg = WCD934X_SLIM_PGD_PORT_INT_EN0 + + (port_id / 8); + else + reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 + + (port_id / 8); + regmap_read(wcd->if_regmap, reg, &int_val); + } + + if (val & WCD934X_SLIM_IRQ_OVERFLOW) + dev_err_ratelimited(wcd->dev, + "overflow error on %s port %d, value %x\n", + (tx ? "TX" : "RX"), port_id, val); + + if (val & WCD934X_SLIM_IRQ_UNDERFLOW) + dev_err_ratelimited(wcd->dev, + "underflow error on %s port %d, value %x\n", + (tx ? "TX" : "RX"), port_id, val); + + if ((val & WCD934X_SLIM_IRQ_OVERFLOW) || + (val & WCD934X_SLIM_IRQ_UNDERFLOW)) { + if (!tx) + reg = WCD934X_SLIM_PGD_PORT_INT_EN0 + + (port_id / 8); + else + reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 + + (port_id / 8); + regmap_read( + wcd->if_regmap, reg, &int_val); + if (int_val & (1 << (port_id % 8))) { + int_val = int_val ^ (1 << (port_id % 8)); + regmap_write(wcd->if_regmap, + reg, int_val); + } + } + + if (val & WCD934X_SLIM_IRQ_PORT_CLOSED) + dev_err_ratelimited(wcd->dev, + "Port Closed %s port %d, value %x\n", + (tx ? "TX" : "RX"), port_id, val); + + regmap_write(wcd->if_regmap, + WCD934X_SLIM_PGD_PORT_INT_CLR_RX_0 + (j / 8), + BIT(j % 8)); + ret = IRQ_HANDLED; + } + + return ret; +} + +static int wcd934x_comp_probe(struct snd_soc_component *component) +{ + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + int i; + + snd_soc_component_init_regmap(component, wcd->regmap); + wcd->component = component; + + /* Class-H Init*/ + wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, wcd->version); + if (IS_ERR(wcd->clsh_ctrl)) + return PTR_ERR(wcd->clsh_ctrl); + + /* Default HPH Mode to Class-H Low HiFi */ + wcd->hph_mode = CLS_H_LOHIFI; + + wcd934x_comp_init(component); + + for (i = 0; i < NUM_CODEC_DAIS; i++) + INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); + + wcd934x_init_dmic(component); + return 0; +} + +static void wcd934x_comp_remove(struct snd_soc_component *comp) +{ + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + + wcd_clsh_ctrl_free(wcd->clsh_ctrl); +} + +static int wcd934x_comp_set_sysclk(struct snd_soc_component *comp, + int clk_id, int source, + unsigned int freq, int dir) +{ + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + int val = WCD934X_CODEC_RPM_CLK_MCLK_CFG_9P6MHZ; + + wcd->rate = freq; + + if (wcd->rate == WCD934X_MCLK_CLK_12P288MHZ) + val = WCD934X_CODEC_RPM_CLK_MCLK_CFG_12P288MHZ; + + snd_soc_component_update_bits(comp, WCD934X_CODEC_RPM_CLK_MCLK_CFG, + WCD934X_CODEC_RPM_CLK_MCLK_CFG_MCLK_MASK, + val); + + return clk_set_rate(wcd->extclk, freq); +} + +static const struct snd_soc_component_driver wcd934x_component_drv = { + .probe = wcd934x_comp_probe, + .remove = wcd934x_comp_remove, + .set_sysclk = wcd934x_comp_set_sysclk, +}; + +static int wcd934x_codec_parse_data(struct wcd934x_codec *wcd) +{ + struct device *dev = &wcd->sdev->dev; + struct device_node *ifc_dev_np; + + ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); + if (!ifc_dev_np) { + dev_err(dev, "No Interface device found\n"); + return -EINVAL; + } + + wcd->sidev = of_slim_get_device(wcd->sdev->ctrl, ifc_dev_np); + if (!wcd->sidev) { + dev_err(dev, "Unable to get SLIM Interface device\n"); + return -EINVAL; + } + + slim_get_logical_addr(wcd->sidev); + wcd->if_regmap = regmap_init_slimbus(wcd->sidev, + &wcd934x_ifc_regmap_config); + if (IS_ERR(wcd->if_regmap)) { + dev_err(dev, "Failed to allocate ifc register map\n"); + return PTR_ERR(wcd->if_regmap); + } + + of_property_read_u32(dev->parent->of_node, "qcom,dmic-sample-rate", + &wcd->dmic_sample_rate); + + return 0; +} + +static int wcd934x_codec_probe(struct platform_device *pdev) +{ + struct wcd934x_ddata *data = dev_get_drvdata(pdev->dev.parent); + struct wcd934x_codec *wcd; + struct device *dev = &pdev->dev; + int ret, irq; + + wcd = devm_kzalloc(&pdev->dev, sizeof(*wcd), GFP_KERNEL); + if (!wcd) + return -ENOMEM; + + wcd->dev = dev; + wcd->regmap = data->regmap; + wcd->extclk = data->extclk; + wcd->sdev = to_slim_device(data->dev); + mutex_init(&wcd->sysclk_mutex); + + ret = wcd934x_codec_parse_data(wcd); + if (ret) { + dev_err(wcd->dev, "Failed to get SLIM IRQ\n"); + return ret; + } + + /* set default rate 9P6MHz */ + regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_MCLK_CFG, + WCD934X_CODEC_RPM_CLK_MCLK_CFG_MCLK_MASK, + WCD934X_CODEC_RPM_CLK_MCLK_CFG_9P6MHZ); + memcpy(wcd->rx_chs, wcd934x_rx_chs, sizeof(wcd934x_rx_chs)); + memcpy(wcd->tx_chs, wcd934x_tx_chs, sizeof(wcd934x_tx_chs)); + + irq = regmap_irq_get_virq(data->irq_data, WCD934X_IRQ_SLIMBUS); + if (irq < 0) { + dev_err(wcd->dev, "Failed to get SLIM IRQ\n"); + return irq; + } + + ret = devm_request_threaded_irq(dev, irq, NULL, + wcd934x_slim_irq_handler, + IRQF_TRIGGER_RISING, + "slim", wcd); + if (ret) { + dev_err(dev, "Failed to request slimbus irq\n"); + return ret; + } + + wcd934x_register_mclk_output(wcd); + platform_set_drvdata(pdev, wcd); + + return devm_snd_soc_register_component(dev, &wcd934x_component_drv, + wcd934x_slim_dais, + ARRAY_SIZE(wcd934x_slim_dais)); +} + +static const struct platform_device_id wcd934x_driver_id[] = { + { + .name = "wcd934x-codec", + }, + {}, +}; +MODULE_DEVICE_TABLE(platform, wcd934x_driver_id); + +static struct platform_driver wcd934x_codec_driver = { + .probe = &wcd934x_codec_probe, + .id_table = wcd934x_driver_id, + .driver = { + .name = "wcd934x-codec", + } +}; + +MODULE_ALIAS("platform:wcd934x-codec"); +module_platform_driver(wcd934x_codec_driver); +MODULE_DESCRIPTION("WCD934x codec driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 1cde8b82233275a72db34a8c1efa4cf6cc8c894f Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:46 +0000 Subject: ASoC: wcd934x: add basic controls This patch adds basic controls found in wcd934x codec. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-5-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/wcd934x.c | 506 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 506 insertions(+) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 825cf057e8b7..27a864f2ff77 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -120,6 +120,21 @@ #define WCD934X_DEF_MICBIAS_MV 1800 #define WCD934X_MAX_MICBIAS_MV 2850 +#define WCD_IIR_FILTER_SIZE (sizeof(u32) * BAND_MAX) + +#define WCD_IIR_FILTER_CTL(xname, iidx, bidx) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = wcd934x_iir_filter_info, \ + .get = wcd934x_get_iir_band_audio_mixer, \ + .put = wcd934x_put_iir_band_audio_mixer, \ + .private_value = (unsigned long)&(struct wcd_iir_filter_ctl) { \ + .iir_idx = iidx, \ + .band_idx = bidx, \ + .bytes_ext = {.max = WCD_IIR_FILTER_SIZE, }, \ + } \ +} + enum { SIDO_SOURCE_INTERNAL, SIDO_SOURCE_RCO_BG, @@ -217,6 +232,35 @@ static const struct wcd934x_slim_ch wcd934x_rx_chs[WCD934X_RX_MAX] = { WCD934X_SLIM_RX_CH(12), }; +/* Codec supports 2 IIR filters */ +enum { + IIR0 = 0, + IIR1, + IIR_MAX, +}; + +/* Each IIR has 5 Filter Stages */ +enum { + BAND1 = 0, + BAND2, + BAND3, + BAND4, + BAND5, + BAND_MAX, +}; + +enum { + COMPANDER_1, /* HPH_L */ + COMPANDER_2, /* HPH_R */ + COMPANDER_3, /* LO1_DIFF */ + COMPANDER_4, /* LO2_DIFF */ + COMPANDER_5, /* LO3_SE - not used in Tavil */ + COMPANDER_6, /* LO4_SE - not used in Tavil */ + COMPANDER_7, /* SWR SPK CH1 */ + COMPANDER_8, /* SWR SPK CH2 */ + COMPANDER_MAX, +}; + enum { AIF1_PB = 0, AIF1_CAP, @@ -335,12 +379,112 @@ struct wcd934x_codec { int dmic_2_3_clk_cnt; int dmic_4_5_clk_cnt; int dmic_sample_rate; + int comp_enabled[COMPANDER_MAX]; int sysclk_users; struct mutex sysclk_mutex; }; #define to_wcd934x_codec(_hw) container_of(_hw, struct wcd934x_codec, hw) +struct wcd_iir_filter_ctl { + unsigned int iir_idx; + unsigned int band_idx; + struct soc_bytes_ext bytes_ext; +}; + +static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); +static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1); +static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); +static const DECLARE_TLV_DB_SCALE(ear_pa_gain, 0, 150, 0); + +/* Cutoff frequency for high pass filter */ +static const char * const cf_text[] = { + "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ" +}; + +static const char * const rx_cf_text[] = { + "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ", + "CF_NEG_3DB_0P48HZ" +}; + +static const char * const rx_hph_mode_mux_text[] = { + "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB", + "Class-H Hi-Fi Low Power" +}; + +static const struct soc_enum cf_dec0_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX1_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec2_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX2_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec3_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX3_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec4_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX4_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec5_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX5_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec6_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX6_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec7_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX7_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_dec8_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX8_TX_PATH_CFG0, 5, 3, cf_text); + +static const struct soc_enum cf_int0_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX0_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int0_2_enum, WCD934X_CDC_RX0_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int1_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX1_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int1_2_enum, WCD934X_CDC_RX1_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int2_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX2_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int2_2_enum, WCD934X_CDC_RX2_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int3_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX3_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int3_2_enum, WCD934X_CDC_RX3_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int4_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX4_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int4_2_enum, WCD934X_CDC_RX4_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int7_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX7_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int7_2_enum, WCD934X_CDC_RX7_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum cf_int8_1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX8_RX_PATH_CFG2, 0, 4, rx_cf_text); + +static SOC_ENUM_SINGLE_DECL(cf_int8_2_enum, WCD934X_CDC_RX8_RX_PATH_MIX_CFG, 2, + rx_cf_text); + +static const struct soc_enum rx_hph_mode_mux_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text), + rx_hph_mode_mux_text); + static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src) { @@ -1479,10 +1623,372 @@ static int wcd934x_comp_set_sysclk(struct snd_soc_component *comp, return clk_set_rate(wcd->extclk, freq); } +static uint32_t get_iir_band_coeff(struct snd_soc_component *component, + int iir_idx, int band_idx, int coeff_idx) +{ + u32 value = 0; + int reg, b2_reg; + + /* Address does not automatically update if reading */ + reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; + b2_reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + + snd_soc_component_write(component, reg, + ((band_idx * BAND_MAX + coeff_idx) * + sizeof(uint32_t)) & 0x7F); + + value |= snd_soc_component_read32(component, b2_reg); + snd_soc_component_write(component, reg, + ((band_idx * BAND_MAX + coeff_idx) + * sizeof(uint32_t) + 1) & 0x7F); + + value |= (snd_soc_component_read32(component, b2_reg) << 8); + snd_soc_component_write(component, reg, + ((band_idx * BAND_MAX + coeff_idx) + * sizeof(uint32_t) + 2) & 0x7F); + + value |= (snd_soc_component_read32(component, b2_reg) << 16); + snd_soc_component_write(component, reg, + ((band_idx * BAND_MAX + coeff_idx) + * sizeof(uint32_t) + 3) & 0x7F); + + /* Mask bits top 2 bits since they are reserved */ + value |= (snd_soc_component_read32(component, b2_reg) << 24); + return value; +} + +static void set_iir_band_coeff(struct snd_soc_component *component, + int iir_idx, int band_idx, uint32_t value) +{ + int reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; + + snd_soc_component_write(component, reg, (value & 0xFF)); + snd_soc_component_write(component, reg, (value >> 8) & 0xFF); + snd_soc_component_write(component, reg, (value >> 16) & 0xFF); + /* Mask top 2 bits, 7-8 are reserved */ + snd_soc_component_write(component, reg, (value >> 24) & 0x3F); +} + +static int wcd934x_put_iir_band_audio_mixer( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + int iir_idx = ctl->iir_idx; + int band_idx = ctl->band_idx; + u32 coeff[BAND_MAX]; + int reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; + + memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); + + /* Mask top bit it is reserved */ + /* Updates addr automatically for each B2 write */ + snd_soc_component_write(component, reg, (band_idx * BAND_MAX * + sizeof(uint32_t)) & 0x7F); + + set_iir_band_coeff(component, iir_idx, band_idx, coeff[0]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[1]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[2]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[3]); + set_iir_band_coeff(component, iir_idx, band_idx, coeff[4]); + + return 0; +} + +static int wcd934x_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + int iir_idx = ctl->iir_idx; + int band_idx = ctl->band_idx; + u32 coeff[BAND_MAX]; + + coeff[0] = get_iir_band_coeff(component, iir_idx, band_idx, 0); + coeff[1] = get_iir_band_coeff(component, iir_idx, band_idx, 1); + coeff[2] = get_iir_band_coeff(component, iir_idx, band_idx, 2); + coeff[3] = get_iir_band_coeff(component, iir_idx, band_idx, 3); + coeff[4] = get_iir_band_coeff(component, iir_idx, band_idx, 4); + + memcpy(ucontrol->value.bytes.data, &coeff[0], params->max); + + return 0; +} + +static int wcd934x_iir_filter_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *ucontrol) +{ + struct wcd_iir_filter_ctl *ctl = + (struct wcd_iir_filter_ctl *)kcontrol->private_value; + struct soc_bytes_ext *params = &ctl->bytes_ext; + + ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES; + ucontrol->count = params->max; + + return 0; +} + +static int wcd934x_compander_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + int comp = ((struct soc_mixer_control *)kc->private_value)->shift; + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + + ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; + + return 0; +} + +static int wcd934x_compander_set(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + int comp = ((struct soc_mixer_control *)kc->private_value)->shift; + int value = ucontrol->value.integer.value[0]; + int sel; + + wcd->comp_enabled[comp] = value; + sel = value ? WCD934X_HPH_GAIN_SRC_SEL_COMPANDER : + WCD934X_HPH_GAIN_SRC_SEL_REGISTER; + + /* Any specific register configuration for compander */ + switch (comp) { + case COMPANDER_1: + /* Set Gain Source Select based on compander enable/disable */ + snd_soc_component_update_bits(component, WCD934X_HPH_L_EN, + WCD934X_HPH_GAIN_SRC_SEL_MASK, + sel); + break; + case COMPANDER_2: + snd_soc_component_update_bits(component, WCD934X_HPH_R_EN, + WCD934X_HPH_GAIN_SRC_SEL_MASK, + sel); + break; + case COMPANDER_3: + case COMPANDER_4: + case COMPANDER_7: + case COMPANDER_8: + break; + default: + break; + }; + + return 0; +} + +static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + + ucontrol->value.enumerated.item[0] = wcd->hph_mode; + + return 0; +} + +static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_soc_kcontrol_component(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + u32 mode_val; + + mode_val = ucontrol->value.enumerated.item[0]; + + if (mode_val == 0) { + dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); + mode_val = CLS_H_LOHIFI; + } + wcd->hph_mode = mode_val; + + return 0; +} + +static const struct snd_kcontrol_new wcd934x_snd_controls[] = { + /* Gain Controls */ + SOC_SINGLE_TLV("EAR PA Volume", WCD934X_ANA_EAR, 4, 4, 1, ear_pa_gain), + SOC_SINGLE_TLV("HPHL Volume", WCD934X_HPH_L_EN, 0, 24, 1, line_gain), + SOC_SINGLE_TLV("HPHR Volume", WCD934X_HPH_R_EN, 0, 24, 1, line_gain), + SOC_SINGLE_TLV("LINEOUT1 Volume", WCD934X_DIFF_LO_LO1_COMPANDER, + 3, 16, 1, line_gain), + SOC_SINGLE_TLV("LINEOUT2 Volume", WCD934X_DIFF_LO_LO2_COMPANDER, + 3, 16, 1, line_gain), + + SOC_SINGLE_TLV("ADC1 Volume", WCD934X_ANA_AMIC1, 0, 20, 0, analog_gain), + SOC_SINGLE_TLV("ADC2 Volume", WCD934X_ANA_AMIC2, 0, 20, 0, analog_gain), + SOC_SINGLE_TLV("ADC3 Volume", WCD934X_ANA_AMIC3, 0, 20, 0, analog_gain), + SOC_SINGLE_TLV("ADC4 Volume", WCD934X_ANA_AMIC4, 0, 20, 0, analog_gain), + + SOC_SINGLE_S8_TLV("RX0 Digital Volume", WCD934X_CDC_RX0_RX_VOL_CTL, + -84, 40, digital_gain), /* -84dB min - 40dB max */ + SOC_SINGLE_S8_TLV("RX1 Digital Volume", WCD934X_CDC_RX1_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX2 Digital Volume", WCD934X_CDC_RX2_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX3 Digital Volume", WCD934X_CDC_RX3_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX4 Digital Volume", WCD934X_CDC_RX4_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX7 Digital Volume", WCD934X_CDC_RX7_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX8 Digital Volume", WCD934X_CDC_RX8_RX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX0 Mix Digital Volume", + WCD934X_CDC_RX0_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX1 Mix Digital Volume", + WCD934X_CDC_RX1_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX2 Mix Digital Volume", + WCD934X_CDC_RX2_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX3 Mix Digital Volume", + WCD934X_CDC_RX3_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX4 Mix Digital Volume", + WCD934X_CDC_RX4_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX7 Mix Digital Volume", + WCD934X_CDC_RX7_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("RX8 Mix Digital Volume", + WCD934X_CDC_RX8_RX_VOL_MIX_CTL, + -84, 40, digital_gain), + + SOC_SINGLE_S8_TLV("DEC0 Volume", WCD934X_CDC_TX0_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC1 Volume", WCD934X_CDC_TX1_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC2 Volume", WCD934X_CDC_TX2_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC3 Volume", WCD934X_CDC_TX3_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC4 Volume", WCD934X_CDC_TX4_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC5 Volume", WCD934X_CDC_TX5_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC6 Volume", WCD934X_CDC_TX6_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC7 Volume", WCD934X_CDC_TX7_TX_VOL_CTL, + -84, 40, digital_gain), + SOC_SINGLE_S8_TLV("DEC8 Volume", WCD934X_CDC_TX8_TX_VOL_CTL, + -84, 40, digital_gain), + + SOC_SINGLE_S8_TLV("IIR0 INP0 Volume", + WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR0 INP1 Volume", + WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR0 INP2 Volume", + WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR0 INP3 Volume", + WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR1 INP0 Volume", + WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", + WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", + WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40, + digital_gain), + SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", + WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40, + digital_gain), + + SOC_ENUM("TX0 HPF cut off", cf_dec0_enum), + SOC_ENUM("TX1 HPF cut off", cf_dec1_enum), + SOC_ENUM("TX2 HPF cut off", cf_dec2_enum), + SOC_ENUM("TX3 HPF cut off", cf_dec3_enum), + SOC_ENUM("TX4 HPF cut off", cf_dec4_enum), + SOC_ENUM("TX5 HPF cut off", cf_dec5_enum), + SOC_ENUM("TX6 HPF cut off", cf_dec6_enum), + SOC_ENUM("TX7 HPF cut off", cf_dec7_enum), + SOC_ENUM("TX8 HPF cut off", cf_dec8_enum), + + SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum), + SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum), + SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum), + SOC_ENUM("RX INT1_2 HPF cut off", cf_int1_2_enum), + SOC_ENUM("RX INT2_1 HPF cut off", cf_int2_1_enum), + SOC_ENUM("RX INT2_2 HPF cut off", cf_int2_2_enum), + SOC_ENUM("RX INT3_1 HPF cut off", cf_int3_1_enum), + SOC_ENUM("RX INT3_2 HPF cut off", cf_int3_2_enum), + SOC_ENUM("RX INT4_1 HPF cut off", cf_int4_1_enum), + SOC_ENUM("RX INT4_2 HPF cut off", cf_int4_2_enum), + SOC_ENUM("RX INT7_1 HPF cut off", cf_int7_1_enum), + SOC_ENUM("RX INT7_2 HPF cut off", cf_int7_2_enum), + SOC_ENUM("RX INT8_1 HPF cut off", cf_int8_1_enum), + SOC_ENUM("RX INT8_2 HPF cut off", cf_int8_2_enum), + + SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum, + wcd934x_rx_hph_mode_get, wcd934x_rx_hph_mode_put), + + SOC_SINGLE("IIR1 Band1 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL, + 0, 1, 0), + SOC_SINGLE("IIR1 Band2 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL, + 1, 1, 0), + SOC_SINGLE("IIR1 Band3 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL, + 2, 1, 0), + SOC_SINGLE("IIR1 Band4 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL, + 3, 1, 0), + SOC_SINGLE("IIR1 Band5 Switch", WCD934X_CDC_SIDETONE_IIR0_IIR_CTL, + 4, 1, 0), + SOC_SINGLE("IIR2 Band1 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL, + 0, 1, 0), + SOC_SINGLE("IIR2 Band2 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL, + 1, 1, 0), + SOC_SINGLE("IIR2 Band3 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL, + 2, 1, 0), + SOC_SINGLE("IIR2 Band4 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL, + 3, 1, 0), + SOC_SINGLE("IIR2 Band5 Switch", WCD934X_CDC_SIDETONE_IIR1_IIR_CTL, + 4, 1, 0), + WCD_IIR_FILTER_CTL("IIR0 Band1", IIR0, BAND1), + WCD_IIR_FILTER_CTL("IIR0 Band2", IIR0, BAND2), + WCD_IIR_FILTER_CTL("IIR0 Band3", IIR0, BAND3), + WCD_IIR_FILTER_CTL("IIR0 Band4", IIR0, BAND4), + WCD_IIR_FILTER_CTL("IIR0 Band5", IIR0, BAND5), + + WCD_IIR_FILTER_CTL("IIR1 Band1", IIR1, BAND1), + WCD_IIR_FILTER_CTL("IIR1 Band2", IIR1, BAND2), + WCD_IIR_FILTER_CTL("IIR1 Band3", IIR1, BAND3), + WCD_IIR_FILTER_CTL("IIR1 Band4", IIR1, BAND4), + WCD_IIR_FILTER_CTL("IIR1 Band5", IIR1, BAND5), + + SOC_SINGLE_EXT("COMP1 Switch", SND_SOC_NOPM, COMPANDER_1, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), + SOC_SINGLE_EXT("COMP2 Switch", SND_SOC_NOPM, COMPANDER_2, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), + SOC_SINGLE_EXT("COMP3 Switch", SND_SOC_NOPM, COMPANDER_3, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), + SOC_SINGLE_EXT("COMP4 Switch", SND_SOC_NOPM, COMPANDER_4, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), + SOC_SINGLE_EXT("COMP7 Switch", SND_SOC_NOPM, COMPANDER_7, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), + SOC_SINGLE_EXT("COMP8 Switch", SND_SOC_NOPM, COMPANDER_8, 1, 0, + wcd934x_compander_get, wcd934x_compander_set), +}; + static const struct snd_soc_component_driver wcd934x_component_drv = { .probe = wcd934x_comp_probe, .remove = wcd934x_comp_remove, .set_sysclk = wcd934x_comp_set_sysclk, + .controls = wcd934x_snd_controls, + .num_controls = ARRAY_SIZE(wcd934x_snd_controls), }; static int wcd934x_codec_parse_data(struct wcd934x_codec *wcd) -- cgit v1.2.3 From dd9eb19b567303e4b92747dcfb5deedb182af111 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:47 +0000 Subject: ASoC: wcd934x: add playback dapm widgets This patch adds required dapm widgets for playback. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-6-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/wcd934x.c | 1550 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1550 insertions(+) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 27a864f2ff77..556c051f7f99 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -412,6 +412,94 @@ static const char * const rx_hph_mode_mux_text[] = { "Class-H Hi-Fi Low Power" }; +static const char *const slim_rx_mux_text[] = { + "ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB", +}; + +static const char * const rx_int0_7_mix_mux_text[] = { + "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", + "RX6", "RX7", "PROXIMITY" +}; + +static const char * const rx_int_mix_mux_text[] = { + "ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", + "RX6", "RX7" +}; + +static const char * const rx_prim_mix_text[] = { + "ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2", + "RX3", "RX4", "RX5", "RX6", "RX7" +}; + +static const char * const rx_sidetone_mix_text[] = { + "ZERO", "SRC0", "SRC1", "SRC_SUM" +}; + +static const char * const iir_inp_mux_text[] = { + "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", "DEC5", "DEC6", + "DEC7", "DEC8", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7" +}; + +static const char * const rx_int_dem_inp_mux_text[] = { + "NORMAL_DSM_OUT", "CLSH_DSM_OUT", +}; + +static const char * const rx_int0_1_interp_mux_text[] = { + "ZERO", "RX INT0_1 MIX1", +}; + +static const char * const rx_int1_1_interp_mux_text[] = { + "ZERO", "RX INT1_1 MIX1", +}; + +static const char * const rx_int2_1_interp_mux_text[] = { + "ZERO", "RX INT2_1 MIX1", +}; + +static const char * const rx_int3_1_interp_mux_text[] = { + "ZERO", "RX INT3_1 MIX1", +}; + +static const char * const rx_int4_1_interp_mux_text[] = { + "ZERO", "RX INT4_1 MIX1", +}; + +static const char * const rx_int7_1_interp_mux_text[] = { + "ZERO", "RX INT7_1 MIX1", +}; + +static const char * const rx_int8_1_interp_mux_text[] = { + "ZERO", "RX INT8_1 MIX1", +}; + +static const char * const rx_int0_2_interp_mux_text[] = { + "ZERO", "RX INT0_2 MUX", +}; + +static const char * const rx_int1_2_interp_mux_text[] = { + "ZERO", "RX INT1_2 MUX", +}; + +static const char * const rx_int2_2_interp_mux_text[] = { + "ZERO", "RX INT2_2 MUX", +}; + +static const char * const rx_int3_2_interp_mux_text[] = { + "ZERO", "RX INT3_2 MUX", +}; + +static const char * const rx_int4_2_interp_mux_text[] = { + "ZERO", "RX INT4_2 MUX", +}; + +static const char * const rx_int7_2_interp_mux_text[] = { + "ZERO", "RX INT7_2 MUX", +}; + +static const char * const rx_int8_2_interp_mux_text[] = { + "ZERO", "RX INT8_2 MUX", +}; + static const struct soc_enum cf_dec0_enum = SOC_ENUM_SINGLE(WCD934X_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text); @@ -485,6 +573,236 @@ static const struct soc_enum rx_hph_mode_mux_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text), rx_hph_mode_mux_text); +static const struct soc_enum slim_rx_mux_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim_rx_mux_text), slim_rx_mux_text); + +static const struct soc_enum rx_int0_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1, 0, 10, + rx_int0_7_mix_mux_text); + +static const struct soc_enum rx_int1_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1, 0, 9, + rx_int_mix_mux_text); + +static const struct soc_enum rx_int2_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, 9, + rx_int_mix_mux_text); + +static const struct soc_enum rx_int3_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1, 0, 9, + rx_int_mix_mux_text); + +static const struct soc_enum rx_int4_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1, 0, 9, + rx_int_mix_mux_text); + +static const struct soc_enum rx_int7_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1, 0, 10, + rx_int0_7_mix_mux_text); + +static const struct soc_enum rx_int8_2_mux_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1, 0, 9, + rx_int_mix_mux_text); + +static const struct soc_enum rx_int0_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int0_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int0_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT0_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int1_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int1_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int1_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int2_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int2_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int2_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT2_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int3_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int3_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int3_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT3_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int4_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int4_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int4_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT4_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int7_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int7_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int7_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int8_1_mix_inp0_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0, 0, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int8_1_mix_inp1_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG0, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int8_1_mix_inp2_chain_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1, 4, 13, + rx_prim_mix_text); + +static const struct soc_enum rx_int0_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0, 4, + rx_sidetone_mix_text); + +static const struct soc_enum rx_int1_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2, 4, + rx_sidetone_mix_text); + +static const struct soc_enum rx_int2_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4, 4, + rx_sidetone_mix_text); + +static const struct soc_enum rx_int3_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6, 4, + rx_sidetone_mix_text); + +static const struct soc_enum rx_int4_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 0, 4, + rx_sidetone_mix_text); + +static const struct soc_enum rx_int7_mix2_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX_INP_MUX_SIDETONE_SRC_CFG1, 2, 4, + rx_sidetone_mix_text); + +static const struct soc_enum iir0_inp0_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG0, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir0_inp1_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG1, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir0_inp2_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG2, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir0_inp3_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR0_MIX_CFG3, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir1_inp0_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG0, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir1_inp1_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG1, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir1_inp2_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG2, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum iir1_inp3_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_SIDETONE_IIR_INP_MUX_IIR1_MIX_CFG3, + 0, 18, iir_inp_mux_text); + +static const struct soc_enum rx_int0_dem_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX0_RX_PATH_SEC0, 0, + ARRAY_SIZE(rx_int_dem_inp_mux_text), + rx_int_dem_inp_mux_text); + +static const struct soc_enum rx_int1_dem_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX1_RX_PATH_SEC0, 0, + ARRAY_SIZE(rx_int_dem_inp_mux_text), + rx_int_dem_inp_mux_text); + +static const struct soc_enum rx_int2_dem_inp_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_RX2_RX_PATH_SEC0, 0, + ARRAY_SIZE(rx_int_dem_inp_mux_text), + rx_int_dem_inp_mux_text); +static const struct soc_enum rx_int0_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, + rx_int0_1_interp_mux_text); + +static const struct soc_enum rx_int1_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, + rx_int1_1_interp_mux_text); + +static const struct soc_enum rx_int2_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, + rx_int2_1_interp_mux_text); + +static const struct soc_enum rx_int3_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int3_1_interp_mux_text); + +static const struct soc_enum rx_int4_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int4_1_interp_mux_text); + +static const struct soc_enum rx_int7_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int7_1_interp_mux_text); + +static const struct soc_enum rx_int8_1_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int8_1_interp_mux_text); + +static const struct soc_enum rx_int0_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int0_2_interp_mux_text); + +static const struct soc_enum rx_int1_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int1_2_interp_mux_text); + +static const struct soc_enum rx_int2_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int2_2_interp_mux_text); + +static const struct soc_enum rx_int3_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int3_2_interp_mux_text); + +static const struct soc_enum rx_int4_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int4_2_interp_mux_text); + +static const struct soc_enum rx_int7_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int7_2_interp_mux_text); + +static const struct soc_enum rx_int8_2_interp_mux_enum = + SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int8_2_interp_mux_text); + static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src) { @@ -639,6 +957,22 @@ static int __wcd934x_cdc_mclk_enable(struct wcd934x_codec *wcd, bool enable) return ret; } +static int wcd934x_codec_enable_mclk(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + return __wcd934x_cdc_mclk_enable(wcd, true); + case SND_SOC_DAPM_POST_PMD: + return __wcd934x_cdc_mclk_enable(wcd, false); + } + + return 0; +} + static int wcd934x_get_version(struct wcd934x_codec *wcd) { int val1, val2, ver, ret; @@ -1814,6 +2148,311 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, return 0; } +static int slim_rx_mux_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); + + ucontrol->value.enumerated.item[0] = wcd->rx_port_value[w->shift]; + + return 0; +} + +static int slim_rx_mux_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev); + struct soc_enum *e = (struct soc_enum *)kc->private_value; + struct snd_soc_dapm_update *update = NULL; + u32 port_id = w->shift; + + if (wcd->rx_port_value[port_id] == ucontrol->value.enumerated.item[0]) + return 0; + + wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; + + switch (wcd->rx_port_value[port_id]) { + case 0: + list_del_init(&wcd->rx_chs[port_id].list); + break; + case 1: + list_add_tail(&wcd->rx_chs[port_id].list, + &wcd->dai[AIF1_PB].slim_ch_list); + break; + case 2: + list_add_tail(&wcd->rx_chs[port_id].list, + &wcd->dai[AIF2_PB].slim_ch_list); + break; + case 3: + list_add_tail(&wcd->rx_chs[port_id].list, + &wcd->dai[AIF3_PB].slim_ch_list); + break; + case 4: + list_add_tail(&wcd->rx_chs[port_id].list, + &wcd->dai[AIF4_PB].slim_ch_list); + break; + default: + dev_err(wcd->dev, "Unknown AIF %d\n", + wcd->rx_port_value[port_id]); + goto err; + } + + snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], + e, update); + + return 0; +err: + return -EINVAL; +} + +static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct soc_enum *e = (struct soc_enum *)kc->private_value; + struct snd_soc_component *component; + int reg, val, ret; + + component = snd_soc_dapm_kcontrol_component(kc); + val = ucontrol->value.enumerated.item[0]; + if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0) + reg = WCD934X_CDC_RX0_RX_PATH_CFG0; + else if (e->reg == WCD934X_CDC_RX1_RX_PATH_SEC0) + reg = WCD934X_CDC_RX1_RX_PATH_CFG0; + else if (e->reg == WCD934X_CDC_RX2_RX_PATH_SEC0) + reg = WCD934X_CDC_RX2_RX_PATH_CFG0; + else + return -EINVAL; + + /* Set Look Ahead Delay */ + if (val) + snd_soc_component_update_bits(component, reg, + WCD934X_RX_DLY_ZN_EN_MASK, + WCD934X_RX_DLY_ZN_ENABLE); + else + snd_soc_component_update_bits(component, reg, + WCD934X_RX_DLY_ZN_EN_MASK, + WCD934X_RX_DLY_ZN_DISABLE); + + ret = snd_soc_dapm_put_enum_double(kc, ucontrol); + + return ret; +} + +static const struct snd_kcontrol_new rx_int0_2_mux = + SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int1_2_mux = + SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int2_2_mux = + SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int3_2_mux = + SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int4_2_mux = + SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int7_2_mux = + SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int8_2_mux = + SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum); + +static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int3_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int3_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int3_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int4_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int4_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int4_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int7_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int7_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int7_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int8_1_mix_inp0_mux = + SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum); + +static const struct snd_kcontrol_new rx_int8_1_mix_inp1_mux = + SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum); + +static const struct snd_kcontrol_new rx_int8_1_mix_inp2_mux = + SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum); + +static const struct snd_kcontrol_new rx_int0_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new rx_int1_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new rx_int2_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new rx_int3_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new rx_int4_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new rx_int7_mix2_inp_mux = + SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_mix2_inp_mux_enum); + +static const struct snd_kcontrol_new iir0_inp0_mux = + SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum); +static const struct snd_kcontrol_new iir0_inp1_mux = + SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum); +static const struct snd_kcontrol_new iir0_inp2_mux = + SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum); +static const struct snd_kcontrol_new iir0_inp3_mux = + SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum); + +static const struct snd_kcontrol_new iir1_inp0_mux = + SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum); +static const struct snd_kcontrol_new iir1_inp1_mux = + SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum); +static const struct snd_kcontrol_new iir1_inp2_mux = + SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum); +static const struct snd_kcontrol_new iir1_inp3_mux = + SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum); + +static const struct snd_kcontrol_new slim_rx_mux[WCD934X_RX_MAX] = { + SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), + SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum, + slim_rx_mux_get, slim_rx_mux_put), +}; + +static const struct snd_kcontrol_new rx_int1_asrc_switch[] = { + SOC_DAPM_SINGLE("HPHL Switch", SND_SOC_NOPM, 0, 1, 0), +}; + +static const struct snd_kcontrol_new rx_int2_asrc_switch[] = { + SOC_DAPM_SINGLE("HPHR Switch", SND_SOC_NOPM, 0, 1, 0), +}; + +static const struct snd_kcontrol_new rx_int3_asrc_switch[] = { + SOC_DAPM_SINGLE("LO1 Switch", SND_SOC_NOPM, 0, 1, 0), +}; + +static const struct snd_kcontrol_new rx_int4_asrc_switch[] = { + SOC_DAPM_SINGLE("LO2 Switch", SND_SOC_NOPM, 0, 1, 0), +}; + +static const struct snd_kcontrol_new rx_int0_dem_inp_mux = + SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum, + snd_soc_dapm_get_enum_double, + wcd934x_int_dem_inp_mux_put); + +static const struct snd_kcontrol_new rx_int1_dem_inp_mux = + SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum, + snd_soc_dapm_get_enum_double, + wcd934x_int_dem_inp_mux_put); + +static const struct snd_kcontrol_new rx_int2_dem_inp_mux = + SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum, + snd_soc_dapm_get_enum_double, + wcd934x_int_dem_inp_mux_put); + +static const struct snd_kcontrol_new rx_int0_1_interp_mux = + SOC_DAPM_ENUM("RX INT0_1 INTERP Mux", rx_int0_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int1_1_interp_mux = + SOC_DAPM_ENUM("RX INT1_1 INTERP Mux", rx_int1_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int2_1_interp_mux = + SOC_DAPM_ENUM("RX INT2_1 INTERP Mux", rx_int2_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int3_1_interp_mux = + SOC_DAPM_ENUM("RX INT3_1 INTERP Mux", rx_int3_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int4_1_interp_mux = + SOC_DAPM_ENUM("RX INT4_1 INTERP Mux", rx_int4_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int7_1_interp_mux = + SOC_DAPM_ENUM("RX INT7_1 INTERP Mux", rx_int7_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int8_1_interp_mux = + SOC_DAPM_ENUM("RX INT8_1 INTERP Mux", rx_int8_1_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int0_2_interp_mux = + SOC_DAPM_ENUM("RX INT0_2 INTERP Mux", rx_int0_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int1_2_interp_mux = + SOC_DAPM_ENUM("RX INT1_2 INTERP Mux", rx_int1_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int2_2_interp_mux = + SOC_DAPM_ENUM("RX INT2_2 INTERP Mux", rx_int2_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int3_2_interp_mux = + SOC_DAPM_ENUM("RX INT3_2 INTERP Mux", rx_int3_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int4_2_interp_mux = + SOC_DAPM_ENUM("RX INT4_2 INTERP Mux", rx_int4_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int7_2_interp_mux = + SOC_DAPM_ENUM("RX INT7_2 INTERP Mux", rx_int7_2_interp_mux_enum); + +static const struct snd_kcontrol_new rx_int8_2_interp_mux = + SOC_DAPM_ENUM("RX INT8_2 INTERP Mux", rx_int8_2_interp_mux_enum); + static const struct snd_kcontrol_new wcd934x_snd_controls[] = { /* Gain Controls */ SOC_SINGLE_TLV("EAR PA Volume", WCD934X_ANA_EAR, 4, 4, 1, ear_pa_gain), @@ -1983,12 +2622,923 @@ static const struct snd_kcontrol_new wcd934x_snd_controls[] = { wcd934x_compander_get, wcd934x_compander_set), }; +static void wcd934x_codec_enable_int_port(struct wcd_slim_codec_dai_data *dai, + struct snd_soc_component *component) +{ + int port_num = 0; + unsigned short reg = 0; + unsigned int val = 0; + struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); + struct wcd934x_slim_ch *ch; + + list_for_each_entry(ch, &dai->slim_ch_list, list) { + if (ch->port >= WCD934X_RX_START) { + port_num = ch->port - WCD934X_RX_START; + reg = WCD934X_SLIM_PGD_PORT_INT_EN0 + (port_num / 8); + } else { + port_num = ch->port; + reg = WCD934X_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8); + } + + regmap_read(wcd->if_regmap, reg, &val); + if (!(val & BIT(port_num % 8))) + regmap_write(wcd->if_regmap, reg, + val | BIT(port_num % 8)); + } +} + +static int wcd934x_codec_enable_slim(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = snd_soc_component_get_drvdata(comp); + struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + wcd934x_codec_enable_int_port(dai, comp); + break; + } + + return 0; +} + +static void wcd934x_codec_hd2_control(struct snd_soc_component *component, + u16 interp_idx, int event) +{ + u16 hd2_scale_reg; + u16 hd2_enable_reg = 0; + + switch (interp_idx) { + case INTERP_HPHL: + hd2_scale_reg = WCD934X_CDC_RX1_RX_PATH_SEC3; + hd2_enable_reg = WCD934X_CDC_RX1_RX_PATH_CFG0; + break; + case INTERP_HPHR: + hd2_scale_reg = WCD934X_CDC_RX2_RX_PATH_SEC3; + hd2_enable_reg = WCD934X_CDC_RX2_RX_PATH_CFG0; + break; + default: + return; + } + + if (SND_SOC_DAPM_EVENT_ON(event)) { + snd_soc_component_update_bits(component, hd2_scale_reg, + WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_MASK, + WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_0P3125); + snd_soc_component_update_bits(component, hd2_enable_reg, + WCD934X_CDC_RX_PATH_CFG_HD2_EN_MASK, + WCD934X_CDC_RX_PATH_CFG_HD2_ENABLE); + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + snd_soc_component_update_bits(component, hd2_enable_reg, + WCD934X_CDC_RX_PATH_CFG_HD2_EN_MASK, + WCD934X_CDC_RX_PATH_CFG_HD2_DISABLE); + snd_soc_component_update_bits(component, hd2_scale_reg, + WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_MASK, + WCD934X_CDC_RX_PATH_SEC_HD2_ALPHA_0P0000); + } +} + +static void wcd934x_codec_hphdelay_lutbypass(struct snd_soc_component *comp, + u16 interp_idx, int event) +{ + u8 hph_dly_mask; + u16 hph_lut_bypass_reg = 0; + u16 hph_comp_ctrl7 = 0; + + switch (interp_idx) { + case INTERP_HPHL: + hph_dly_mask = 1; + hph_lut_bypass_reg = WCD934X_CDC_TOP_HPHL_COMP_LUT; + hph_comp_ctrl7 = WCD934X_CDC_COMPANDER1_CTL7; + break; + case INTERP_HPHR: + hph_dly_mask = 2; + hph_lut_bypass_reg = WCD934X_CDC_TOP_HPHR_COMP_LUT; + hph_comp_ctrl7 = WCD934X_CDC_COMPANDER2_CTL7; + break; + default: + return; + } + + if (SND_SOC_DAPM_EVENT_ON(event)) { + snd_soc_component_update_bits(comp, WCD934X_CDC_CLSH_TEST0, + hph_dly_mask, 0x0); + snd_soc_component_update_bits(comp, hph_lut_bypass_reg, + WCD934X_HPH_LUT_BYPASS_MASK, + WCD934X_HPH_LUT_BYPASS_ENABLE); + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + snd_soc_component_update_bits(comp, WCD934X_CDC_CLSH_TEST0, + hph_dly_mask, hph_dly_mask); + snd_soc_component_update_bits(comp, hph_lut_bypass_reg, + WCD934X_HPH_LUT_BYPASS_MASK, + WCD934X_HPH_LUT_BYPASS_DISABLE); + } +} + +static int wcd934x_config_compander(struct snd_soc_component *comp, + int interp_n, int event) +{ + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + int compander; + u16 comp_ctl0_reg, rx_path_cfg0_reg; + + /* EAR does not have compander */ + if (!interp_n) + return 0; + + compander = interp_n - 1; + if (!wcd->comp_enabled[compander]) + return 0; + + comp_ctl0_reg = WCD934X_CDC_COMPANDER1_CTL0 + (compander * 8); + rx_path_cfg0_reg = WCD934X_CDC_RX1_RX_PATH_CFG0 + (compander * 20); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* Enable Compander Clock */ + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_CLK_EN_MASK, + WCD934X_COMP_CLK_ENABLE); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_SOFT_RST_MASK, + WCD934X_COMP_SOFT_RST_ENABLE); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_SOFT_RST_MASK, + WCD934X_COMP_SOFT_RST_DISABLE); + snd_soc_component_update_bits(comp, rx_path_cfg0_reg, + WCD934X_HPH_CMP_EN_MASK, + WCD934X_HPH_CMP_ENABLE); + break; + case SND_SOC_DAPM_POST_PMD: + snd_soc_component_update_bits(comp, rx_path_cfg0_reg, + WCD934X_HPH_CMP_EN_MASK, + WCD934X_HPH_CMP_DISABLE); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_HALT_MASK, + WCD934X_COMP_HALT); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_SOFT_RST_MASK, + WCD934X_COMP_SOFT_RST_ENABLE); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_SOFT_RST_MASK, + WCD934X_COMP_SOFT_RST_DISABLE); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_CLK_EN_MASK, 0x0); + snd_soc_component_update_bits(comp, comp_ctl0_reg, + WCD934X_COMP_SOFT_RST_MASK, 0x0); + break; + } + + return 0; +} + +static int wcd934x_codec_enable_interp_clk(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + int interp_idx = w->shift; + u16 main_reg = WCD934X_CDC_RX0_RX_PATH_CTL + (interp_idx * 20); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* Clk enable */ + snd_soc_component_update_bits(comp, main_reg, + WCD934X_RX_CLK_EN_MASK, + WCD934X_RX_CLK_ENABLE); + wcd934x_codec_hd2_control(comp, interp_idx, event); + wcd934x_codec_hphdelay_lutbypass(comp, interp_idx, event); + wcd934x_config_compander(comp, interp_idx, event); + break; + case SND_SOC_DAPM_POST_PMD: + wcd934x_config_compander(comp, interp_idx, event); + wcd934x_codec_hphdelay_lutbypass(comp, interp_idx, event); + wcd934x_codec_hd2_control(comp, interp_idx, event); + /* Clk Disable */ + snd_soc_component_update_bits(comp, main_reg, + WCD934X_RX_CLK_EN_MASK, 0); + /* Reset enable and disable */ + snd_soc_component_update_bits(comp, main_reg, + WCD934X_RX_RESET_MASK, + WCD934X_RX_RESET_ENABLE); + snd_soc_component_update_bits(comp, main_reg, + WCD934X_RX_RESET_MASK, + WCD934X_RX_RESET_DISABLE); + /* Reset rate to 48K*/ + snd_soc_component_update_bits(comp, main_reg, + WCD934X_RX_PCM_RATE_MASK, + WCD934X_RX_PCM_RATE_F_48K); + break; + } + + return 0; +} + +static int wcd934x_codec_enable_mix_path(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + int offset_val = 0; + u16 gain_reg, mix_reg; + int val = 0; + + gain_reg = WCD934X_CDC_RX0_RX_VOL_MIX_CTL + + (w->shift * WCD934X_RX_PATH_CTL_OFFSET); + mix_reg = WCD934X_CDC_RX0_RX_PATH_MIX_CTL + + (w->shift * WCD934X_RX_PATH_CTL_OFFSET); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* Clk enable */ + snd_soc_component_update_bits(comp, mix_reg, + WCD934X_CDC_RX_MIX_CLK_EN_MASK, + WCD934X_CDC_RX_MIX_CLK_ENABLE); + break; + + case SND_SOC_DAPM_POST_PMU: + val = snd_soc_component_read32(comp, gain_reg); + val += offset_val; + snd_soc_component_write(comp, gain_reg, val); + break; + }; + + return 0; +} + +static int wcd934x_codec_set_iir_gain(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + int reg = w->reg; + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + /* B1 GAIN */ + snd_soc_component_write(comp, reg, + snd_soc_component_read32(comp, reg)); + /* B2 GAIN */ + reg++; + snd_soc_component_write(comp, reg, + snd_soc_component_read32(comp, reg)); + /* B3 GAIN */ + reg++; + snd_soc_component_write(comp, reg, + snd_soc_component_read32(comp, reg)); + /* B4 GAIN */ + reg++; + snd_soc_component_write(comp, reg, + snd_soc_component_read32(comp, reg)); + /* B5 GAIN */ + reg++; + snd_soc_component_write(comp, reg, + snd_soc_component_read32(comp, reg)); + break; + default: + break; + } + return 0; +} + +static int wcd934x_codec_enable_main_path(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + u16 gain_reg; + + gain_reg = WCD934X_CDC_RX0_RX_VOL_CTL + (w->shift * + WCD934X_RX_PATH_CTL_OFFSET); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + snd_soc_component_write(comp, gain_reg, + snd_soc_component_read32(comp, gain_reg)); + break; + }; + + return 0; +} + +static int wcd934x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* Disable AutoChop timer during power up */ + snd_soc_component_update_bits(comp, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK, 0x0); + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, + WCD_CLSH_STATE_EAR, CLS_H_NORMAL); + + break; + case SND_SOC_DAPM_POST_PMD: + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, + WCD_CLSH_STATE_EAR, CLS_H_NORMAL); + break; + }; + + return 0; +} + +static int wcd934x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + int hph_mode = wcd->hph_mode; + u8 dem_inp; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* Read DEM INP Select */ + dem_inp = snd_soc_component_read32(comp, + WCD934X_CDC_RX1_RX_PATH_SEC0) & 0x03; + + if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || + (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { + return -EINVAL; + } + if (hph_mode != CLS_H_LP) + /* Ripple freq control enable */ + snd_soc_component_update_bits(comp, + WCD934X_SIDO_NEW_VOUT_D_FREQ2, + WCD934X_SIDO_RIPPLE_FREQ_EN_MASK, + WCD934X_SIDO_RIPPLE_FREQ_ENABLE); + /* Disable AutoChop timer during power up */ + snd_soc_component_update_bits(comp, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK, 0x0); + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, + WCD_CLSH_STATE_HPHL, hph_mode); + + break; + case SND_SOC_DAPM_POST_PMD: + /* 1000us required as per HW requirement */ + usleep_range(1000, 1100); + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, + WCD_CLSH_STATE_HPHL, hph_mode); + if (hph_mode != CLS_H_LP) + /* Ripple freq control disable */ + snd_soc_component_update_bits(comp, + WCD934X_SIDO_NEW_VOUT_D_FREQ2, + WCD934X_SIDO_RIPPLE_FREQ_EN_MASK, 0x0); + + break; + default: + break; + }; + + return 0; +} + +static int wcd934x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + int hph_mode = wcd->hph_mode; + u8 dem_inp; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dem_inp = snd_soc_component_read32(comp, + WCD934X_CDC_RX2_RX_PATH_SEC0) & 0x03; + if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || + (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { + return -EINVAL; + } + if (hph_mode != CLS_H_LP) + /* Ripple freq control enable */ + snd_soc_component_update_bits(comp, + WCD934X_SIDO_NEW_VOUT_D_FREQ2, + WCD934X_SIDO_RIPPLE_FREQ_EN_MASK, + WCD934X_SIDO_RIPPLE_FREQ_ENABLE); + /* Disable AutoChop timer during power up */ + snd_soc_component_update_bits(comp, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK, 0x0); + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, + WCD_CLSH_STATE_HPHR, + hph_mode); + break; + case SND_SOC_DAPM_POST_PMD: + /* 1000us required as per HW requirement */ + usleep_range(1000, 1100); + + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, + WCD_CLSH_STATE_HPHR, hph_mode); + if (hph_mode != CLS_H_LP) + /* Ripple freq control disable */ + snd_soc_component_update_bits(comp, + WCD934X_SIDO_NEW_VOUT_D_FREQ2, + WCD934X_SIDO_RIPPLE_FREQ_EN_MASK, 0x0); + break; + default: + break; + }; + + return 0; +} + +static int wcd934x_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kc, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, + WCD_CLSH_STATE_LO, CLS_AB); + break; + case SND_SOC_DAPM_POST_PMD: + wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, + WCD_CLSH_STATE_LO, CLS_AB); + break; + } + + return 0; +} + +static int wcd934x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + /* + * 7ms sleep is required after PA is enabled as per + * HW requirement. If compander is disabled, then + * 20ms delay is needed. + */ + usleep_range(20000, 20100); + + snd_soc_component_update_bits(comp, WCD934X_HPH_L_TEST, + WCD934X_HPH_OCP_DET_MASK, + WCD934X_HPH_OCP_DET_ENABLE); + /* Remove Mute on primary path */ + snd_soc_component_update_bits(comp, WCD934X_CDC_RX1_RX_PATH_CTL, + WCD934X_RX_PATH_PGA_MUTE_EN_MASK, + 0); + /* Enable GM3 boost */ + snd_soc_component_update_bits(comp, WCD934X_HPH_CNP_WG_CTL, + WCD934X_HPH_GM3_BOOST_EN_MASK, + WCD934X_HPH_GM3_BOOST_ENABLE); + /* Enable AutoChop timer at the end of power up */ + snd_soc_component_update_bits(comp, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK, + WCD934X_HPH_AUTOCHOP_TIMER_ENABLE); + /* Remove mix path mute */ + snd_soc_component_update_bits(comp, + WCD934X_CDC_RX1_RX_PATH_MIX_CTL, + WCD934X_CDC_RX_PGA_MUTE_EN_MASK, 0x00); + break; + case SND_SOC_DAPM_PRE_PMD: + /* Enable DSD Mute before PA disable */ + snd_soc_component_update_bits(comp, WCD934X_HPH_L_TEST, + WCD934X_HPH_OCP_DET_MASK, + WCD934X_HPH_OCP_DET_DISABLE); + snd_soc_component_update_bits(comp, WCD934X_CDC_RX1_RX_PATH_CTL, + WCD934X_RX_PATH_PGA_MUTE_EN_MASK, + WCD934X_RX_PATH_PGA_MUTE_ENABLE); + snd_soc_component_update_bits(comp, + WCD934X_CDC_RX1_RX_PATH_MIX_CTL, + WCD934X_RX_PATH_PGA_MUTE_EN_MASK, + WCD934X_RX_PATH_PGA_MUTE_ENABLE); + break; + case SND_SOC_DAPM_POST_PMD: + /* + * 5ms sleep is required after PA disable. If compander is + * disabled, then 20ms delay is needed after PA disable. + */ + usleep_range(20000, 20100); + break; + }; + + return 0; +} + +static int wcd934x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + /* + * 7ms sleep is required after PA is enabled as per + * HW requirement. If compander is disabled, then + * 20ms delay is needed. + */ + usleep_range(20000, 20100); + snd_soc_component_update_bits(comp, WCD934X_HPH_R_TEST, + WCD934X_HPH_OCP_DET_MASK, + WCD934X_HPH_OCP_DET_ENABLE); + /* Remove mute */ + snd_soc_component_update_bits(comp, WCD934X_CDC_RX2_RX_PATH_CTL, + WCD934X_RX_PATH_PGA_MUTE_EN_MASK, + 0); + /* Enable GM3 boost */ + snd_soc_component_update_bits(comp, WCD934X_HPH_CNP_WG_CTL, + WCD934X_HPH_GM3_BOOST_EN_MASK, + WCD934X_HPH_GM3_BOOST_ENABLE); + /* Enable AutoChop timer at the end of power up */ + snd_soc_component_update_bits(comp, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + WCD934X_HPH_AUTOCHOP_TIMER_EN_MASK, + WCD934X_HPH_AUTOCHOP_TIMER_ENABLE); + /* Remove mix path mute if it is enabled */ + if ((snd_soc_component_read32(comp, + WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(comp, + WCD934X_CDC_RX2_RX_PATH_MIX_CTL, + WCD934X_CDC_RX_PGA_MUTE_EN_MASK, + WCD934X_CDC_RX_PGA_MUTE_DISABLE); + break; + case SND_SOC_DAPM_PRE_PMD: + snd_soc_component_update_bits(comp, WCD934X_HPH_R_TEST, + WCD934X_HPH_OCP_DET_MASK, + WCD934X_HPH_OCP_DET_DISABLE); + snd_soc_component_update_bits(comp, WCD934X_CDC_RX2_RX_PATH_CTL, + WCD934X_RX_PATH_PGA_MUTE_EN_MASK, + WCD934X_RX_PATH_PGA_MUTE_ENABLE); + snd_soc_component_update_bits(comp, + WCD934X_CDC_RX2_RX_PATH_MIX_CTL, + WCD934X_CDC_RX_PGA_MUTE_EN_MASK, + WCD934X_CDC_RX_PGA_MUTE_ENABLE); + break; + case SND_SOC_DAPM_POST_PMD: + /* + * 5ms sleep is required after PA disable. If compander is + * disabled, then 20ms delay is needed after PA disable. + */ + usleep_range(20000, 20100); + break; + }; + + return 0; +} + +static const struct snd_soc_dapm_widget wcd934x_dapm_widgets[] = { + /* Analog Outputs */ + SND_SOC_DAPM_OUTPUT("EAR"), + SND_SOC_DAPM_OUTPUT("HPHL"), + SND_SOC_DAPM_OUTPUT("HPHR"), + SND_SOC_DAPM_OUTPUT("LINEOUT1"), + SND_SOC_DAPM_OUTPUT("LINEOUT2"), + SND_SOC_DAPM_OUTPUT("SPK1 OUT"), + SND_SOC_DAPM_OUTPUT("SPK2 OUT"), + SND_SOC_DAPM_OUTPUT("ANC EAR"), + SND_SOC_DAPM_OUTPUT("ANC HPHL"), + SND_SOC_DAPM_OUTPUT("ANC HPHR"), + SND_SOC_DAPM_OUTPUT("WDMA3_OUT"), + SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT1"), + SND_SOC_DAPM_OUTPUT("MAD_CPE_OUT2"), + SND_SOC_DAPM_AIF_IN_E("AIF1 PB", "AIF1 Playback", 0, SND_SOC_NOPM, + AIF1_PB, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_AIF_IN_E("AIF2 PB", "AIF2 Playback", 0, SND_SOC_NOPM, + AIF2_PB, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_AIF_IN_E("AIF3 PB", "AIF3 Playback", 0, SND_SOC_NOPM, + AIF3_PB, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_AIF_IN_E("AIF4 PB", "AIF4 Playback", 0, SND_SOC_NOPM, + AIF4_PB, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, WCD934X_RX0, 0, + &slim_rx_mux[WCD934X_RX0]), + SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, WCD934X_RX1, 0, + &slim_rx_mux[WCD934X_RX1]), + SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, WCD934X_RX2, 0, + &slim_rx_mux[WCD934X_RX2]), + SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, WCD934X_RX3, 0, + &slim_rx_mux[WCD934X_RX3]), + SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, WCD934X_RX4, 0, + &slim_rx_mux[WCD934X_RX4]), + SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, WCD934X_RX5, 0, + &slim_rx_mux[WCD934X_RX5]), + SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, WCD934X_RX6, 0, + &slim_rx_mux[WCD934X_RX6]), + SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, WCD934X_RX7, 0, + &slim_rx_mux[WCD934X_RX7]), + + SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0), + + SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM, INTERP_EAR, 0, + &rx_int0_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM, INTERP_HPHL, 0, + &rx_int1_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM, INTERP_HPHR, 0, + &rx_int2_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", SND_SOC_NOPM, INTERP_LO1, 0, + &rx_int3_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", SND_SOC_NOPM, INTERP_LO2, 0, + &rx_int4_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", SND_SOC_NOPM, INTERP_SPKR1, 0, + &rx_int7_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", SND_SOC_NOPM, INTERP_SPKR2, 0, + &rx_int8_2_mux, wcd934x_codec_enable_mix_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int0_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int0_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int0_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int1_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int1_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int1_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int2_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int2_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int2_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int3_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int3_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT3_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int3_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int4_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int4_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT4_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int4_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int7_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int7_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT7_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int7_1_mix_inp2_mux), + SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, + &rx_int8_1_mix_inp0_mux), + SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, + &rx_int8_1_mix_inp1_mux), + SND_SOC_DAPM_MUX("RX INT8_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, + &rx_int8_1_mix_inp2_mux), + SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, + rx_int1_asrc_switch, + ARRAY_SIZE(rx_int1_asrc_switch)), + SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, + rx_int2_asrc_switch, + ARRAY_SIZE(rx_int2_asrc_switch)), + SND_SOC_DAPM_MIXER("RX INT3_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT3 SEC MIX", SND_SOC_NOPM, 0, 0, + rx_int3_asrc_switch, + ARRAY_SIZE(rx_int3_asrc_switch)), + SND_SOC_DAPM_MIXER("RX INT4_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT4 SEC MIX", SND_SOC_NOPM, 0, 0, + rx_int4_asrc_switch, + ARRAY_SIZE(rx_int4_asrc_switch)), + SND_SOC_DAPM_MIXER("RX INT7_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT7 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT8_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT8 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT1 MIX3", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT2 MIX3", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT3 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT3 MIX3", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT4 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("RX INT4 MIX3", SND_SOC_NOPM, 0, 0, NULL, 0), + + SND_SOC_DAPM_MIXER("RX INT7 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER_E("RX INT7 CHAIN", SND_SOC_NOPM, 0, 0, + NULL, 0, NULL, 0), + SND_SOC_DAPM_MIXER_E("RX INT8 CHAIN", SND_SOC_NOPM, 0, 0, + NULL, 0, NULL, 0), + SND_SOC_DAPM_MUX_E("RX INT0 MIX2 INP", WCD934X_CDC_RX0_RX_PATH_CFG0, 4, + 0, &rx_int0_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT1 MIX2 INP", WCD934X_CDC_RX1_RX_PATH_CFG0, 4, + 0, &rx_int1_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT2 MIX2 INP", WCD934X_CDC_RX2_RX_PATH_CFG0, 4, + 0, &rx_int2_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT3 MIX2 INP", WCD934X_CDC_RX3_RX_PATH_CFG0, 4, + 0, &rx_int3_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT4 MIX2 INP", WCD934X_CDC_RX4_RX_PATH_CFG0, 4, + 0, &rx_int4_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT7 MIX2 INP", WCD934X_CDC_RX7_RX_PATH_CFG0, 4, + 0, &rx_int7_mix2_inp_mux, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux), + SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux), + SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux), + SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux), + SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux), + SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux), + SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux), + SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux), + + SND_SOC_DAPM_PGA_E("IIR0", WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, + 0, 0, NULL, 0, wcd934x_codec_set_iir_gain, + SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PGA_E("IIR1", WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, + 1, 0, NULL, 0, wcd934x_codec_set_iir_gain, + SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_MIXER("SRC0", WCD934X_CDC_SIDETONE_SRC0_ST_SRC_PATH_CTL, + 4, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SRC1", WCD934X_CDC_SIDETONE_SRC1_ST_SRC_PATH_CTL, + 4, 0, NULL, 0), + SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0, + &rx_int0_dem_inp_mux), + SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0, + &rx_int1_dem_inp_mux), + SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0, + &rx_int2_dem_inp_mux), + + SND_SOC_DAPM_MUX_E("RX INT0_1 INTERP", SND_SOC_NOPM, INTERP_EAR, 0, + &rx_int0_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT1_1 INTERP", SND_SOC_NOPM, INTERP_HPHL, 0, + &rx_int1_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT2_1 INTERP", SND_SOC_NOPM, INTERP_HPHR, 0, + &rx_int2_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT3_1 INTERP", SND_SOC_NOPM, INTERP_LO1, 0, + &rx_int3_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT4_1 INTERP", SND_SOC_NOPM, INTERP_LO2, 0, + &rx_int4_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT7_1 INTERP", SND_SOC_NOPM, INTERP_SPKR1, 0, + &rx_int7_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("RX INT8_1 INTERP", SND_SOC_NOPM, INTERP_SPKR2, 0, + &rx_int8_1_interp_mux, + wcd934x_codec_enable_main_path, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("RX INT0_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int0_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT1_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int1_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT2_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int2_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT3_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int3_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT4_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int4_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT7_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int7_2_interp_mux), + SND_SOC_DAPM_MUX("RX INT8_2 INTERP", SND_SOC_NOPM, 0, 0, + &rx_int8_2_interp_mux), + SND_SOC_DAPM_DAC_E("RX INT0 DAC", NULL, SND_SOC_NOPM, + 0, 0, wcd934x_codec_ear_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_DAC_E("RX INT1 DAC", NULL, WCD934X_ANA_HPH, + 5, 0, wcd934x_codec_hphl_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_DAC_E("RX INT2 DAC", NULL, WCD934X_ANA_HPH, + 4, 0, wcd934x_codec_hphr_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_DAC_E("RX INT3 DAC", NULL, SND_SOC_NOPM, + 0, 0, wcd934x_codec_lineout_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_DAC_E("RX INT4 DAC", NULL, SND_SOC_NOPM, + 0, 0, wcd934x_codec_lineout_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("EAR PA", WCD934X_ANA_EAR, 7, 0, NULL, 0, NULL, 0), + SND_SOC_DAPM_PGA_E("HPHL PA", WCD934X_ANA_HPH, 7, 0, NULL, 0, + wcd934x_codec_enable_hphl_pa, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("HPHR PA", WCD934X_ANA_HPH, 6, 0, NULL, 0, + wcd934x_codec_enable_hphr_pa, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("LINEOUT1 PA", WCD934X_ANA_LO_1_2, 7, 0, NULL, 0, + NULL, 0), + SND_SOC_DAPM_PGA_E("LINEOUT2 PA", WCD934X_ANA_LO_1_2, 6, 0, NULL, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("RX_BIAS", WCD934X_ANA_RX_SUPPLIES, 0, 0, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("SBOOST0", WCD934X_CDC_RX7_RX_PATH_CFG1, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("SBOOST0_CLK", WCD934X_CDC_BOOST0_BOOST_PATH_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("SBOOST1", WCD934X_CDC_RX8_RX_PATH_CFG1, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("SBOOST1_CLK", WCD934X_CDC_BOOST1_BOOST_PATH_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("INT0_CLK", SND_SOC_NOPM, INTERP_EAR, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT1_CLK", SND_SOC_NOPM, INTERP_HPHL, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT2_CLK", SND_SOC_NOPM, INTERP_HPHR, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT3_CLK", SND_SOC_NOPM, INTERP_LO1, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT4_CLK", SND_SOC_NOPM, INTERP_LO2, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT7_CLK", SND_SOC_NOPM, INTERP_SPKR1, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("INT8_CLK", SND_SOC_NOPM, INTERP_SPKR2, 0, + wcd934x_codec_enable_interp_clk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("DSMDEM0_CLK", WCD934X_CDC_RX0_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM1_CLK", WCD934X_CDC_RX1_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM2_CLK", WCD934X_CDC_RX2_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM3_CLK", WCD934X_CDC_RX3_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM4_CLK", WCD934X_CDC_RX4_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM7_CLK", WCD934X_CDC_RX7_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DSMDEM8_CLK", WCD934X_CDC_RX8_RX_PATH_DSMDEM_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_mclk, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), +}; + static const struct snd_soc_component_driver wcd934x_component_drv = { .probe = wcd934x_comp_probe, .remove = wcd934x_comp_remove, .set_sysclk = wcd934x_comp_set_sysclk, .controls = wcd934x_snd_controls, .num_controls = ARRAY_SIZE(wcd934x_snd_controls), + .dapm_widgets = wcd934x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wcd934x_dapm_widgets), }; static int wcd934x_codec_parse_data(struct wcd934x_codec *wcd) -- cgit v1.2.3 From a70d9245759a48e57bb1dc9f63213dcf3017db32 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:48 +0000 Subject: ASoC: wcd934x: add capture dapm widgets This patch adds required dapm widgets for capture path. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-7-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/wcd934x.c | 1151 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1149 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 556c051f7f99..24f78a0b7f5a 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -135,6 +135,13 @@ } \ } +enum { + MIC_BIAS_1 = 1, + MIC_BIAS_2, + MIC_BIAS_3, + MIC_BIAS_4 +}; + enum { SIDO_SOURCE_INTERNAL, SIDO_SOURCE_RCO_BG, @@ -500,6 +507,83 @@ static const char * const rx_int8_2_interp_mux_text[] = { "ZERO", "RX INT8_2 MUX", }; +static const char * const dmic_mux_text[] = { + "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3", "DMIC4", "DMIC5" +}; + +static const char * const amic_mux_text[] = { + "ZERO", "ADC1", "ADC2", "ADC3", "ADC4" +}; + +static const char * const amic4_5_sel_text[] = { + "AMIC4", "AMIC5" +}; + +static const char * const adc_mux_text[] = { + "DMIC", "AMIC", "ANC_FB_TUNE1", "ANC_FB_TUNE2" +}; + +static const char * const cdc_if_tx0_mux_text[] = { + "ZERO", "RX_MIX_TX0", "DEC0", "DEC0_192" +}; + +static const char * const cdc_if_tx1_mux_text[] = { + "ZERO", "RX_MIX_TX1", "DEC1", "DEC1_192" +}; + +static const char * const cdc_if_tx2_mux_text[] = { + "ZERO", "RX_MIX_TX2", "DEC2", "DEC2_192" +}; + +static const char * const cdc_if_tx3_mux_text[] = { + "ZERO", "RX_MIX_TX3", "DEC3", "DEC3_192" +}; + +static const char * const cdc_if_tx4_mux_text[] = { + "ZERO", "RX_MIX_TX4", "DEC4", "DEC4_192" +}; + +static const char * const cdc_if_tx5_mux_text[] = { + "ZERO", "RX_MIX_TX5", "DEC5", "DEC5_192" +}; + +static const char * const cdc_if_tx6_mux_text[] = { + "ZERO", "RX_MIX_TX6", "DEC6", "DEC6_192" +}; + +static const char * const cdc_if_tx7_mux_text[] = { + "ZERO", "RX_MIX_TX7", "DEC7", "DEC7_192" +}; + +static const char * const cdc_if_tx8_mux_text[] = { + "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192" +}; + +static const char * const cdc_if_tx9_mux_text[] = { + "ZERO", "DEC7", "DEC7_192" +}; + +static const char * const cdc_if_tx10_mux_text[] = { + "ZERO", "DEC6", "DEC6_192" +}; + +static const char * const cdc_if_tx11_mux_text[] = { + "DEC_0_5", "DEC_9_12", "MAD_AUDIO", "MAD_BRDCST" +}; + +static const char * const cdc_if_tx11_inp1_mux_text[] = { + "ZERO", "DEC0", "DEC1", "DEC2", "DEC3", "DEC4", + "DEC5", "RX_MIX_TX5", "DEC9_10", "DEC11_12" +}; + +static const char * const cdc_if_tx13_mux_text[] = { + "CDC_DEC_5", "MAD_BRDCST" +}; + +static const char * const cdc_if_tx13_inp1_mux_text[] = { + "ZERO", "DEC5", "DEC5_192" +}; + static const struct soc_enum cf_dec0_enum = SOC_ENUM_SINGLE(WCD934X_CDC_TX0_TX_PATH_CFG0, 5, 3, cf_text); @@ -758,6 +842,35 @@ static const struct soc_enum rx_int2_dem_inp_mux_enum = SOC_ENUM_SINGLE(WCD934X_CDC_RX2_RX_PATH_SEC0, 0, ARRAY_SIZE(rx_int_dem_inp_mux_text), rx_int_dem_inp_mux_text); + +static const struct soc_enum tx_adc_mux0_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 0, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux2_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux3_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 0, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux4_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1, 2, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux5_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 2, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux6_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 2, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux7_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1, 2, + ARRAY_SIZE(adc_mux_text), adc_mux_text); +static const struct soc_enum tx_adc_mux8_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 4, + ARRAY_SIZE(adc_mux_text), adc_mux_text); + static const struct soc_enum rx_int0_1_interp_mux_enum = SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int0_1_interp_mux_text); @@ -803,8 +916,122 @@ static const struct soc_enum rx_int7_2_interp_mux_enum = static const struct soc_enum rx_int8_2_interp_mux_enum = SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, 2, rx_int8_2_interp_mux_text); -static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, - int sido_src) +static const struct soc_enum tx_dmic_mux0_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux2_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux3_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux4_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux5_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux6_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux7_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_dmic_mux8_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 3, 7, + dmic_mux_text); + +static const struct soc_enum tx_amic_mux0_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux1_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux2_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux3_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux4_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux5_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX5_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux6_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX6_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux7_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX7_CFG0, 0, 5, + amic_mux_text); +static const struct soc_enum tx_amic_mux8_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_TX_INP_MUX_ADC_MUX8_CFG0, 0, 5, + amic_mux_text); + +static const struct soc_enum tx_amic4_5_enum = + SOC_ENUM_SINGLE(WCD934X_TX_NEW_AMIC_4_5_SEL, 7, 2, amic4_5_sel_text); + +static const struct soc_enum cdc_if_tx0_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 0, + ARRAY_SIZE(cdc_if_tx0_mux_text), cdc_if_tx0_mux_text); +static const struct soc_enum cdc_if_tx1_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 2, + ARRAY_SIZE(cdc_if_tx1_mux_text), cdc_if_tx1_mux_text); +static const struct soc_enum cdc_if_tx2_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 4, + ARRAY_SIZE(cdc_if_tx2_mux_text), cdc_if_tx2_mux_text); +static const struct soc_enum cdc_if_tx3_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG0, 6, + ARRAY_SIZE(cdc_if_tx3_mux_text), cdc_if_tx3_mux_text); +static const struct soc_enum cdc_if_tx4_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 0, + ARRAY_SIZE(cdc_if_tx4_mux_text), cdc_if_tx4_mux_text); +static const struct soc_enum cdc_if_tx5_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 2, + ARRAY_SIZE(cdc_if_tx5_mux_text), cdc_if_tx5_mux_text); +static const struct soc_enum cdc_if_tx6_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 4, + ARRAY_SIZE(cdc_if_tx6_mux_text), cdc_if_tx6_mux_text); +static const struct soc_enum cdc_if_tx7_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG1, 6, + ARRAY_SIZE(cdc_if_tx7_mux_text), cdc_if_tx7_mux_text); +static const struct soc_enum cdc_if_tx8_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 0, + ARRAY_SIZE(cdc_if_tx8_mux_text), cdc_if_tx8_mux_text); +static const struct soc_enum cdc_if_tx9_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 2, + ARRAY_SIZE(cdc_if_tx9_mux_text), cdc_if_tx9_mux_text); +static const struct soc_enum cdc_if_tx10_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG2, 4, + ARRAY_SIZE(cdc_if_tx10_mux_text), cdc_if_tx10_mux_text); +static const struct soc_enum cdc_if_tx11_inp1_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3, 0, + ARRAY_SIZE(cdc_if_tx11_inp1_mux_text), + cdc_if_tx11_inp1_mux_text); +static const struct soc_enum cdc_if_tx11_mux_enum = + SOC_ENUM_SINGLE(WCD934X_DATA_HUB_SB_TX11_INP_CFG, 0, + ARRAY_SIZE(cdc_if_tx11_mux_text), cdc_if_tx11_mux_text); +static const struct soc_enum cdc_if_tx13_inp1_mux_enum = + SOC_ENUM_SINGLE(WCD934X_CDC_IF_ROUTER_TX_MUX_CFG3, 4, + ARRAY_SIZE(cdc_if_tx13_inp1_mux_text), + cdc_if_tx13_inp1_mux_text); +static const struct soc_enum cdc_if_tx13_mux_enum = + SOC_ENUM_SINGLE(WCD934X_DATA_HUB_SB_TX13_INP_CFG, 0, + ARRAY_SIZE(cdc_if_tx13_mux_text), cdc_if_tx13_mux_text); + +static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src) { if (sido_src == wcd->sido_input_src) return 0; @@ -2241,6 +2468,63 @@ static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, return ret; } +static int wcd934x_dec_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp; + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int val; + u16 mic_sel_reg = 0; + u8 mic_sel; + + comp = snd_soc_dapm_kcontrol_component(kcontrol); + + val = ucontrol->value.enumerated.item[0]; + if (val > e->items - 1) + return -EINVAL; + + switch (e->reg) { + case WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1: + if (e->shift_l == 0) + mic_sel_reg = WCD934X_CDC_TX0_TX_PATH_CFG0; + else if (e->shift_l == 2) + mic_sel_reg = WCD934X_CDC_TX4_TX_PATH_CFG0; + else if (e->shift_l == 4) + mic_sel_reg = WCD934X_CDC_TX8_TX_PATH_CFG0; + break; + case WCD934X_CDC_TX_INP_MUX_ADC_MUX1_CFG1: + if (e->shift_l == 0) + mic_sel_reg = WCD934X_CDC_TX1_TX_PATH_CFG0; + else if (e->shift_l == 2) + mic_sel_reg = WCD934X_CDC_TX5_TX_PATH_CFG0; + break; + case WCD934X_CDC_TX_INP_MUX_ADC_MUX2_CFG1: + if (e->shift_l == 0) + mic_sel_reg = WCD934X_CDC_TX2_TX_PATH_CFG0; + else if (e->shift_l == 2) + mic_sel_reg = WCD934X_CDC_TX6_TX_PATH_CFG0; + break; + case WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1: + if (e->shift_l == 0) + mic_sel_reg = WCD934X_CDC_TX3_TX_PATH_CFG0; + else if (e->shift_l == 2) + mic_sel_reg = WCD934X_CDC_TX7_TX_PATH_CFG0; + break; + default: + dev_err(comp->dev, "%s: e->reg: 0x%x not expected\n", + __func__, e->reg); + return -EINVAL; + } + + /* ADC: 0, DMIC: 1 */ + mic_sel = val ? 0x0 : 0x1; + if (mic_sel_reg) + snd_soc_component_update_bits(comp, mic_sel_reg, BIT(7), + mic_sel << 7); + + return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); +} + static const struct snd_kcontrol_new rx_int0_2_mux = SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum); @@ -2453,6 +2737,252 @@ static const struct snd_kcontrol_new rx_int7_2_interp_mux = static const struct snd_kcontrol_new rx_int8_2_interp_mux = SOC_DAPM_ENUM("RX INT8_2 INTERP Mux", rx_int8_2_interp_mux_enum); +static const struct snd_kcontrol_new tx_dmic_mux0 = + SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum); + +static const struct snd_kcontrol_new tx_dmic_mux1 = + SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum); + +static const struct snd_kcontrol_new tx_dmic_mux2 = + SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum); + +static const struct snd_kcontrol_new tx_dmic_mux3 = + SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum); + +static const struct snd_kcontrol_new tx_dmic_mux4 = + SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum); + +static const struct snd_kcontrol_new tx_dmic_mux5 = + SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum); + +static const struct snd_kcontrol_new tx_dmic_mux6 = + SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum); + +static const struct snd_kcontrol_new tx_dmic_mux7 = + SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum); + +static const struct snd_kcontrol_new tx_dmic_mux8 = + SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum); + +static const struct snd_kcontrol_new tx_amic_mux0 = + SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum); + +static const struct snd_kcontrol_new tx_amic_mux1 = + SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum); + +static const struct snd_kcontrol_new tx_amic_mux2 = + SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum); + +static const struct snd_kcontrol_new tx_amic_mux3 = + SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum); + +static const struct snd_kcontrol_new tx_amic_mux4 = + SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum); + +static const struct snd_kcontrol_new tx_amic_mux5 = + SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum); + +static const struct snd_kcontrol_new tx_amic_mux6 = + SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum); + +static const struct snd_kcontrol_new tx_amic_mux7 = + SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum); + +static const struct snd_kcontrol_new tx_amic_mux8 = + SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum); + +static const struct snd_kcontrol_new tx_amic4_5 = + SOC_DAPM_ENUM("AMIC4_5 SEL Mux", tx_amic4_5_enum); + +static const struct snd_kcontrol_new tx_adc_mux0_mux = + SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux1_mux = + SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux2_mux = + SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux3_mux = + SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux4_mux = + SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux5_mux = + SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux6_mux = + SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux7_mux = + SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); +static const struct snd_kcontrol_new tx_adc_mux8_mux = + SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_enum, + snd_soc_dapm_get_enum_double, wcd934x_dec_enum_put); + +static const struct snd_kcontrol_new cdc_if_tx0_mux = + SOC_DAPM_ENUM("CDC_IF TX0 MUX Mux", cdc_if_tx0_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx1_mux = + SOC_DAPM_ENUM("CDC_IF TX1 MUX Mux", cdc_if_tx1_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx2_mux = + SOC_DAPM_ENUM("CDC_IF TX2 MUX Mux", cdc_if_tx2_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx3_mux = + SOC_DAPM_ENUM("CDC_IF TX3 MUX Mux", cdc_if_tx3_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx4_mux = + SOC_DAPM_ENUM("CDC_IF TX4 MUX Mux", cdc_if_tx4_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx5_mux = + SOC_DAPM_ENUM("CDC_IF TX5 MUX Mux", cdc_if_tx5_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx6_mux = + SOC_DAPM_ENUM("CDC_IF TX6 MUX Mux", cdc_if_tx6_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx7_mux = + SOC_DAPM_ENUM("CDC_IF TX7 MUX Mux", cdc_if_tx7_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx8_mux = + SOC_DAPM_ENUM("CDC_IF TX8 MUX Mux", cdc_if_tx8_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx9_mux = + SOC_DAPM_ENUM("CDC_IF TX9 MUX Mux", cdc_if_tx9_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx10_mux = + SOC_DAPM_ENUM("CDC_IF TX10 MUX Mux", cdc_if_tx10_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx11_mux = + SOC_DAPM_ENUM("CDC_IF TX11 MUX Mux", cdc_if_tx11_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx11_inp1_mux = + SOC_DAPM_ENUM("CDC_IF TX11 INP1 MUX Mux", cdc_if_tx11_inp1_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx13_mux = + SOC_DAPM_ENUM("CDC_IF TX13 MUX Mux", cdc_if_tx13_mux_enum); +static const struct snd_kcontrol_new cdc_if_tx13_inp1_mux = + SOC_DAPM_ENUM("CDC_IF TX13 INP1 MUX Mux", cdc_if_tx13_inp1_mux_enum); + +static int slim_tx_mixer_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kc->private_value; + int port_id = mixer->shift; + + ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id]; + + return 0; +} + +static int slim_tx_mixer_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kc); + struct wcd934x_codec *wcd = dev_get_drvdata(widget->dapm->dev); + struct snd_soc_dapm_update *update = NULL; + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kc->private_value; + int enable = ucontrol->value.integer.value[0]; + int dai_id = widget->shift; + int port_id = mixer->shift; + + /* only add to the list if value not set */ + if (enable == wcd->tx_port_value[port_id]) + return 0; + + wcd->tx_port_value[port_id] = enable; + + if (enable) + list_add_tail(&wcd->tx_chs[port_id].list, + &wcd->dai[dai_id].slim_ch_list); + else + list_del_init(&wcd->tx_chs[port_id].list); + + snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); + + return 0; +} + +static const struct snd_kcontrol_new aif1_slim_cap_mixer[] = { + SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), +}; + +static const struct snd_kcontrol_new aif2_slim_cap_mixer[] = { + SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), +}; + +static const struct snd_kcontrol_new aif3_slim_cap_mixer[] = { + SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD934X_TX0, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD934X_TX1, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD934X_TX2, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD934X_TX3, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD934X_TX4, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD934X_TX5, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD934X_TX6, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD934X_TX7, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD934X_TX8, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD934X_TX9, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD934X_TX10, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD934X_TX11, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), + SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD934X_TX13, 1, 0, + slim_tx_mixer_get, slim_tx_mixer_put), +}; + static const struct snd_kcontrol_new wcd934x_snd_controls[] = { /* Gain Controls */ SOC_SINGLE_TLV("EAR PA Volume", WCD934X_ANA_EAR, 4, 4, 1, ear_pa_gain), @@ -3193,6 +3723,455 @@ static int wcd934x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, return 0; } +static u32 wcd934x_get_dmic_sample_rate(struct snd_soc_component *comp, + unsigned int dmic, + struct wcd934x_codec *wcd) +{ + u8 tx_stream_fs; + u8 adc_mux_index = 0, adc_mux_sel = 0; + bool dec_found = false; + u16 adc_mux_ctl_reg, tx_fs_reg; + u32 dmic_fs; + + while (dec_found == 0 && adc_mux_index < WCD934X_MAX_VALID_ADC_MUX) { + if (adc_mux_index < 4) { + adc_mux_ctl_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + + (adc_mux_index * 2); + } else if (adc_mux_index < WCD934X_INVALID_ADC_MUX) { + adc_mux_ctl_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_index - 4; + } else if (adc_mux_index == WCD934X_INVALID_ADC_MUX) { + ++adc_mux_index; + continue; + } + adc_mux_sel = ((snd_soc_component_read32(comp, adc_mux_ctl_reg) + & 0xF8) >> 3) - 1; + + if (adc_mux_sel == dmic) { + dec_found = true; + break; + } + + ++adc_mux_index; + } + + if (dec_found && adc_mux_index <= 8) { + tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index); + tx_stream_fs = snd_soc_component_read32(comp, tx_fs_reg) & 0x0F; + if (tx_stream_fs <= 4) { + if (wcd->dmic_sample_rate <= + WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ) + dmic_fs = wcd->dmic_sample_rate; + else + dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ; + } else + dmic_fs = WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ; + } else { + dmic_fs = wcd->dmic_sample_rate; + } + + return dmic_fs; +} + +static u8 wcd934x_get_dmic_clk_val(struct snd_soc_component *comp, + u32 mclk_rate, u32 dmic_clk_rate) +{ + u32 div_factor; + u8 dmic_ctl_val; + + /* Default value to return in case of error */ + if (mclk_rate == WCD934X_MCLK_CLK_9P6MHZ) + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_2; + else + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_3; + + if (dmic_clk_rate == 0) { + dev_err(comp->dev, + "%s: dmic_sample_rate cannot be 0\n", + __func__); + goto done; + } + + div_factor = mclk_rate / dmic_clk_rate; + switch (div_factor) { + case 2: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_2; + break; + case 3: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_3; + break; + case 4: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_4; + break; + case 6: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_6; + break; + case 8: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_8; + break; + case 16: + dmic_ctl_val = WCD934X_DMIC_CLK_DIV_16; + break; + default: + dev_err(comp->dev, + "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n", + __func__, div_factor, mclk_rate, dmic_clk_rate); + break; + } + +done: + return dmic_ctl_val; +} + +static int wcd934x_codec_enable_dmic(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); + u8 dmic_clk_en = 0x01; + u16 dmic_clk_reg; + s32 *dmic_clk_cnt; + u8 dmic_rate_val, dmic_rate_shift = 1; + unsigned int dmic; + u32 dmic_sample_rate; + int ret; + char *wname; + + wname = strpbrk(w->name, "012345"); + if (!wname) { + dev_err(comp->dev, "%s: widget not found\n", __func__); + return -EINVAL; + } + + ret = kstrtouint(wname, 10, &dmic); + if (ret < 0) { + dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", + __func__); + return -EINVAL; + } + + switch (dmic) { + case 0: + case 1: + dmic_clk_cnt = &wcd->dmic_0_1_clk_cnt; + dmic_clk_reg = WCD934X_CPE_SS_DMIC0_CTL; + break; + case 2: + case 3: + dmic_clk_cnt = &wcd->dmic_2_3_clk_cnt; + dmic_clk_reg = WCD934X_CPE_SS_DMIC1_CTL; + break; + case 4: + case 5: + dmic_clk_cnt = &wcd->dmic_4_5_clk_cnt; + dmic_clk_reg = WCD934X_CPE_SS_DMIC2_CTL; + break; + default: + dev_err(comp->dev, "%s: Invalid DMIC Selection\n", + __func__); + return -EINVAL; + }; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dmic_sample_rate = wcd934x_get_dmic_sample_rate(comp, dmic, + wcd); + dmic_rate_val = wcd934x_get_dmic_clk_val(comp, wcd->rate, + dmic_sample_rate); + (*dmic_clk_cnt)++; + if (*dmic_clk_cnt == 1) { + dmic_rate_val = dmic_rate_val << dmic_rate_shift; + snd_soc_component_update_bits(comp, dmic_clk_reg, + WCD934X_DMIC_RATE_MASK, + dmic_rate_val); + snd_soc_component_update_bits(comp, dmic_clk_reg, + dmic_clk_en, dmic_clk_en); + } + + break; + case SND_SOC_DAPM_POST_PMD: + (*dmic_clk_cnt)--; + if (*dmic_clk_cnt == 0) + snd_soc_component_update_bits(comp, dmic_clk_reg, + dmic_clk_en, 0); + break; + }; + + return 0; +} + +static int wcd934x_codec_find_amic_input(struct snd_soc_component *comp, + int adc_mux_n) +{ + u16 mask, shift, adc_mux_in_reg; + u16 amic_mux_sel_reg; + bool is_amic; + + if (adc_mux_n < 0 || adc_mux_n > WCD934X_MAX_VALID_ADC_MUX || + adc_mux_n == WCD934X_INVALID_ADC_MUX) + return 0; + + if (adc_mux_n < 3) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 + + adc_mux_n; + mask = 0x03; + shift = 0; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + + 2 * adc_mux_n; + } else if (adc_mux_n < 4) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1; + mask = 0x03; + shift = 0; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + + 2 * adc_mux_n; + } else if (adc_mux_n < 7) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 + + (adc_mux_n - 4); + mask = 0x0C; + shift = 2; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_n - 4; + } else if (adc_mux_n < 8) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1; + mask = 0x0C; + shift = 2; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_n - 4; + } else if (adc_mux_n < 12) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1 + + ((adc_mux_n == 8) ? (adc_mux_n - 8) : + (adc_mux_n - 9)); + mask = 0x30; + shift = 4; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_n - 4; + } else if (adc_mux_n < 13) { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX3_CFG1; + mask = 0x30; + shift = 4; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_n - 4; + } else { + adc_mux_in_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX0_CFG1; + mask = 0xC0; + shift = 6; + amic_mux_sel_reg = WCD934X_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + + adc_mux_n - 4; + } + + is_amic = (((snd_soc_component_read32(comp, adc_mux_in_reg) + & mask) >> shift) == 1); + if (!is_amic) + return 0; + + return snd_soc_component_read32(comp, amic_mux_sel_reg) & 0x07; +} + +static u16 wcd934x_codec_get_amic_pwlvl_reg(struct snd_soc_component *comp, + int amic) +{ + u16 pwr_level_reg = 0; + + switch (amic) { + case 1: + case 2: + pwr_level_reg = WCD934X_ANA_AMIC1; + break; + + case 3: + case 4: + pwr_level_reg = WCD934X_ANA_AMIC3; + break; + default: + break; + } + + return pwr_level_reg; +} + +static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + unsigned int decimator; + char *dec_adc_mux_name = NULL; + char *widget_name = NULL; + char *wname; + int ret = 0, amic_n; + u16 tx_vol_ctl_reg, pwr_level_reg = 0, dec_cfg_reg, hpf_gate_reg; + u16 tx_gain_ctl_reg; + char *dec; + u8 hpf_coff_freq; + + widget_name = kstrndup(w->name, 15, GFP_KERNEL); + if (!widget_name) + return -ENOMEM; + + wname = widget_name; + dec_adc_mux_name = strsep(&widget_name, " "); + if (!dec_adc_mux_name) { + dev_err(comp->dev, "%s: Invalid decimator = %s\n", + __func__, w->name); + ret = -EINVAL; + goto out; + } + dec_adc_mux_name = widget_name; + + dec = strpbrk(dec_adc_mux_name, "012345678"); + if (!dec) { + dev_err(comp->dev, "%s: decimator index not found\n", + __func__); + ret = -EINVAL; + goto out; + } + + ret = kstrtouint(dec, 10, &decimator); + if (ret < 0) { + dev_err(comp->dev, "%s: Invalid decimator = %s\n", + __func__, wname); + ret = -EINVAL; + goto out; + } + + tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; + hpf_gate_reg = WCD934X_CDC_TX0_TX_PATH_SEC2 + 16 * decimator; + dec_cfg_reg = WCD934X_CDC_TX0_TX_PATH_CFG0 + 16 * decimator; + tx_gain_ctl_reg = WCD934X_CDC_TX0_TX_VOL_CTL + 16 * decimator; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + amic_n = wcd934x_codec_find_amic_input(comp, decimator); + if (amic_n) + pwr_level_reg = wcd934x_codec_get_amic_pwlvl_reg(comp, + amic_n); + + if (!pwr_level_reg) + break; + + switch ((snd_soc_component_read32(comp, pwr_level_reg) & + WCD934X_AMIC_PWR_LVL_MASK) >> + WCD934X_AMIC_PWR_LVL_SHIFT) { + case WCD934X_AMIC_PWR_LEVEL_LP: + snd_soc_component_update_bits(comp, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_LP); + break; + case WCD934X_AMIC_PWR_LEVEL_HP: + snd_soc_component_update_bits(comp, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_HP); + break; + case WCD934X_AMIC_PWR_LEVEL_DEFAULT: + case WCD934X_AMIC_PWR_LEVEL_HYBRID: + default: + snd_soc_component_update_bits(comp, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_DF); + break; + } + break; + case SND_SOC_DAPM_POST_PMU: + hpf_coff_freq = (snd_soc_component_read32(comp, dec_cfg_reg) & + TX_HPF_CUT_OFF_FREQ_MASK) >> 5; + if (hpf_coff_freq != CF_MIN_3DB_150HZ) { + snd_soc_component_update_bits(comp, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + CF_MIN_3DB_150HZ << 5); + snd_soc_component_update_bits(comp, hpf_gate_reg, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ); + /* + * Minimum 1 clk cycle delay is required as per + * HW spec. + */ + usleep_range(1000, 1010); + snd_soc_component_update_bits(comp, hpf_gate_reg, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK, + 0); + } + /* apply gain after decimator is enabled */ + snd_soc_component_write(comp, tx_gain_ctl_reg, + snd_soc_component_read32(comp, + tx_gain_ctl_reg)); + break; + case SND_SOC_DAPM_PRE_PMD: + hpf_coff_freq = (snd_soc_component_read32(comp, dec_cfg_reg) & + TX_HPF_CUT_OFF_FREQ_MASK) >> 5; + + if (hpf_coff_freq != CF_MIN_3DB_150HZ) { + snd_soc_component_update_bits(comp, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_coff_freq << 5); + snd_soc_component_update_bits(comp, hpf_gate_reg, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ); + /* + * Minimum 1 clk cycle delay is required as per + * HW spec. + */ + usleep_range(1000, 1010); + snd_soc_component_update_bits(comp, hpf_gate_reg, + WCD934X_HPH_CUTOFF_FREQ_CHANGE_REQ_MASK, + 0); + } + break; + case SND_SOC_DAPM_POST_PMD: + snd_soc_component_update_bits(comp, tx_vol_ctl_reg, + 0x10, 0x00); + snd_soc_component_update_bits(comp, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_DF); + break; + }; +out: + kfree(wname); + return ret; +} + +static void wcd934x_codec_set_tx_hold(struct snd_soc_component *comp, + u16 amic_reg, bool set) +{ + u8 mask = 0x20; + u8 val; + + if (amic_reg == WCD934X_ANA_AMIC1 || + amic_reg == WCD934X_ANA_AMIC3) + mask = 0x40; + + val = set ? mask : 0x00; + + switch (amic_reg) { + case WCD934X_ANA_AMIC1: + case WCD934X_ANA_AMIC2: + snd_soc_component_update_bits(comp, WCD934X_ANA_AMIC2, + mask, val); + break; + case WCD934X_ANA_AMIC3: + case WCD934X_ANA_AMIC4: + snd_soc_component_update_bits(comp, WCD934X_ANA_AMIC4, + mask, val); + break; + default: + break; + } +} + +static int wcd934x_codec_enable_adc(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + wcd934x_codec_set_tx_hold(comp, w->reg, true); + break; + default: + break; + } + + return 0; +} + static const struct snd_soc_dapm_widget wcd934x_dapm_widgets[] = { /* Analog Outputs */ SND_SOC_DAPM_OUTPUT("EAR"), @@ -3529,6 +4508,174 @@ static const struct snd_soc_dapm_widget wcd934x_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, wcd934x_codec_enable_mclk, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + + /* TX */ + SND_SOC_DAPM_INPUT("AMIC1"), + SND_SOC_DAPM_INPUT("AMIC2"), + SND_SOC_DAPM_INPUT("AMIC3"), + SND_SOC_DAPM_INPUT("AMIC4"), + SND_SOC_DAPM_INPUT("AMIC5"), + SND_SOC_DAPM_INPUT("DMIC0 Pin"), + SND_SOC_DAPM_INPUT("DMIC1 Pin"), + SND_SOC_DAPM_INPUT("DMIC2 Pin"), + SND_SOC_DAPM_INPUT("DMIC3 Pin"), + SND_SOC_DAPM_INPUT("DMIC4 Pin"), + SND_SOC_DAPM_INPUT("DMIC5 Pin"), + + SND_SOC_DAPM_AIF_OUT_E("AIF1 CAP", "AIF1 Capture", 0, SND_SOC_NOPM, + AIF1_CAP, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_AIF_OUT_E("AIF2 CAP", "AIF2 Capture", 0, SND_SOC_NOPM, + AIF2_CAP, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_AIF_OUT_E("AIF3 CAP", "AIF3 Capture", 0, SND_SOC_NOPM, + AIF3_CAP, 0, wcd934x_codec_enable_slim, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MIXER("SLIM TX0", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX2", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX3", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX4", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX5", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX6", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX7", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX8", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX9", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX10", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX11", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("SLIM TX13", SND_SOC_NOPM, 0, 0, NULL, 0), + + /* Digital Mic Inputs */ + SND_SOC_DAPM_ADC_E("DMIC0", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 0, 0, + wcd934x_codec_enable_dmic, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX("DMIC MUX0", SND_SOC_NOPM, 0, 0, &tx_dmic_mux0), + SND_SOC_DAPM_MUX("DMIC MUX1", SND_SOC_NOPM, 0, 0, &tx_dmic_mux1), + SND_SOC_DAPM_MUX("DMIC MUX2", SND_SOC_NOPM, 0, 0, &tx_dmic_mux2), + SND_SOC_DAPM_MUX("DMIC MUX3", SND_SOC_NOPM, 0, 0, &tx_dmic_mux3), + SND_SOC_DAPM_MUX("DMIC MUX4", SND_SOC_NOPM, 0, 0, &tx_dmic_mux4), + SND_SOC_DAPM_MUX("DMIC MUX5", SND_SOC_NOPM, 0, 0, &tx_dmic_mux5), + SND_SOC_DAPM_MUX("DMIC MUX6", SND_SOC_NOPM, 0, 0, &tx_dmic_mux6), + SND_SOC_DAPM_MUX("DMIC MUX7", SND_SOC_NOPM, 0, 0, &tx_dmic_mux7), + SND_SOC_DAPM_MUX("DMIC MUX8", SND_SOC_NOPM, 0, 0, &tx_dmic_mux8), + SND_SOC_DAPM_MUX("AMIC MUX0", SND_SOC_NOPM, 0, 0, &tx_amic_mux0), + SND_SOC_DAPM_MUX("AMIC MUX1", SND_SOC_NOPM, 0, 0, &tx_amic_mux1), + SND_SOC_DAPM_MUX("AMIC MUX2", SND_SOC_NOPM, 0, 0, &tx_amic_mux2), + SND_SOC_DAPM_MUX("AMIC MUX3", SND_SOC_NOPM, 0, 0, &tx_amic_mux3), + SND_SOC_DAPM_MUX("AMIC MUX4", SND_SOC_NOPM, 0, 0, &tx_amic_mux4), + SND_SOC_DAPM_MUX("AMIC MUX5", SND_SOC_NOPM, 0, 0, &tx_amic_mux5), + SND_SOC_DAPM_MUX("AMIC MUX6", SND_SOC_NOPM, 0, 0, &tx_amic_mux6), + SND_SOC_DAPM_MUX("AMIC MUX7", SND_SOC_NOPM, 0, 0, &tx_amic_mux7), + SND_SOC_DAPM_MUX("AMIC MUX8", SND_SOC_NOPM, 0, 0, &tx_amic_mux8), + SND_SOC_DAPM_MUX_E("ADC MUX0", WCD934X_CDC_TX0_TX_PATH_CTL, 5, 0, + &tx_adc_mux0_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX1", WCD934X_CDC_TX1_TX_PATH_CTL, 5, 0, + &tx_adc_mux1_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX2", WCD934X_CDC_TX2_TX_PATH_CTL, 5, 0, + &tx_adc_mux2_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX3", WCD934X_CDC_TX3_TX_PATH_CTL, 5, 0, + &tx_adc_mux3_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX4", WCD934X_CDC_TX4_TX_PATH_CTL, 5, 0, + &tx_adc_mux4_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX5", WCD934X_CDC_TX5_TX_PATH_CTL, 5, 0, + &tx_adc_mux5_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX6", WCD934X_CDC_TX6_TX_PATH_CTL, 5, 0, + &tx_adc_mux6_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX7", WCD934X_CDC_TX7_TX_PATH_CTL, 5, 0, + &tx_adc_mux7_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MUX_E("ADC MUX8", WCD934X_CDC_TX8_TX_PATH_CTL, 5, 0, + &tx_adc_mux8_mux, wcd934x_codec_enable_dec, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_ADC_E("ADC1", NULL, WCD934X_ANA_AMIC1, 7, 0, + wcd934x_codec_enable_adc, SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_ADC_E("ADC2", NULL, WCD934X_ANA_AMIC2, 7, 0, + wcd934x_codec_enable_adc, SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_ADC_E("ADC3", NULL, WCD934X_ANA_AMIC3, 7, 0, + wcd934x_codec_enable_adc, SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_ADC_E("ADC4", NULL, WCD934X_ANA_AMIC4, 7, 0, + wcd934x_codec_enable_adc, SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_SUPPLY("MIC BIAS1", WCD934X_ANA_MICB1, 6, 0, NULL, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("MIC BIAS2", WCD934X_ANA_MICB2, 6, 0, NULL, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("MIC BIAS3", WCD934X_ANA_MICB3, 6, 0, NULL, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("MIC BIAS4", WCD934X_ANA_MICB4, 6, 0, NULL, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_MUX("AMIC4_5 SEL", SND_SOC_NOPM, 0, 0, &tx_amic4_5), + SND_SOC_DAPM_MUX("CDC_IF TX0 MUX", SND_SOC_NOPM, WCD934X_TX0, 0, + &cdc_if_tx0_mux), + SND_SOC_DAPM_MUX("CDC_IF TX1 MUX", SND_SOC_NOPM, WCD934X_TX1, 0, + &cdc_if_tx1_mux), + SND_SOC_DAPM_MUX("CDC_IF TX2 MUX", SND_SOC_NOPM, WCD934X_TX2, 0, + &cdc_if_tx2_mux), + SND_SOC_DAPM_MUX("CDC_IF TX3 MUX", SND_SOC_NOPM, WCD934X_TX3, 0, + &cdc_if_tx3_mux), + SND_SOC_DAPM_MUX("CDC_IF TX4 MUX", SND_SOC_NOPM, WCD934X_TX4, 0, + &cdc_if_tx4_mux), + SND_SOC_DAPM_MUX("CDC_IF TX5 MUX", SND_SOC_NOPM, WCD934X_TX5, 0, + &cdc_if_tx5_mux), + SND_SOC_DAPM_MUX("CDC_IF TX6 MUX", SND_SOC_NOPM, WCD934X_TX6, 0, + &cdc_if_tx6_mux), + SND_SOC_DAPM_MUX("CDC_IF TX7 MUX", SND_SOC_NOPM, WCD934X_TX7, 0, + &cdc_if_tx7_mux), + SND_SOC_DAPM_MUX("CDC_IF TX8 MUX", SND_SOC_NOPM, WCD934X_TX8, 0, + &cdc_if_tx8_mux), + SND_SOC_DAPM_MUX("CDC_IF TX9 MUX", SND_SOC_NOPM, WCD934X_TX9, 0, + &cdc_if_tx9_mux), + SND_SOC_DAPM_MUX("CDC_IF TX10 MUX", SND_SOC_NOPM, WCD934X_TX10, 0, + &cdc_if_tx10_mux), + SND_SOC_DAPM_MUX("CDC_IF TX11 MUX", SND_SOC_NOPM, WCD934X_TX11, 0, + &cdc_if_tx11_mux), + SND_SOC_DAPM_MUX("CDC_IF TX11 INP1 MUX", SND_SOC_NOPM, WCD934X_TX11, 0, + &cdc_if_tx11_inp1_mux), + SND_SOC_DAPM_MUX("CDC_IF TX13 MUX", SND_SOC_NOPM, WCD934X_TX13, 0, + &cdc_if_tx13_mux), + SND_SOC_DAPM_MUX("CDC_IF TX13 INP1 MUX", SND_SOC_NOPM, WCD934X_TX13, 0, + &cdc_if_tx13_inp1_mux), + SND_SOC_DAPM_MIXER("AIF1_CAP Mixer", SND_SOC_NOPM, AIF1_CAP, 0, + aif1_slim_cap_mixer, + ARRAY_SIZE(aif1_slim_cap_mixer)), + SND_SOC_DAPM_MIXER("AIF2_CAP Mixer", SND_SOC_NOPM, AIF2_CAP, 0, + aif2_slim_cap_mixer, + ARRAY_SIZE(aif2_slim_cap_mixer)), + SND_SOC_DAPM_MIXER("AIF3_CAP Mixer", SND_SOC_NOPM, AIF3_CAP, 0, + aif3_slim_cap_mixer, + ARRAY_SIZE(aif3_slim_cap_mixer)), }; static const struct snd_soc_component_driver wcd934x_component_drv = { -- cgit v1.2.3 From da3e83f8bb866a91945ef5c47bdb25de189a381e Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:49 +0000 Subject: ASoC: wcd934x: add audio routings This patch adds audio routing for both playback and capture. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-8-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/wcd934x.c | 290 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 24f78a0b7f5a..158e878abd6c 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -135,6 +135,162 @@ } \ } +#define WCD934X_INTERPOLATOR_PATH(id) \ + {"RX INT" #id "_1 MIX1 INP0", "RX0", "SLIM RX0"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX1", "SLIM RX1"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX2", "SLIM RX2"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX3", "SLIM RX3"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX4", "SLIM RX4"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX5", "SLIM RX5"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX6", "SLIM RX6"}, \ + {"RX INT" #id "_1 MIX1 INP0", "RX7", "SLIM RX7"}, \ + {"RX INT" #id "_1 MIX1 INP0", "IIR0", "IIR0"}, \ + {"RX INT" #id "_1 MIX1 INP0", "IIR1", "IIR1"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX0", "SLIM RX0"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX1", "SLIM RX1"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX2", "SLIM RX2"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX3", "SLIM RX3"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX4", "SLIM RX4"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX5", "SLIM RX5"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX6", "SLIM RX6"}, \ + {"RX INT" #id "_1 MIX1 INP1", "RX7", "SLIM RX7"}, \ + {"RX INT" #id "_1 MIX1 INP1", "IIR0", "IIR0"}, \ + {"RX INT" #id "_1 MIX1 INP1", "IIR1", "IIR1"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX0", "SLIM RX0"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX1", "SLIM RX1"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX2", "SLIM RX2"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX3", "SLIM RX3"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX4", "SLIM RX4"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX5", "SLIM RX5"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX6", "SLIM RX6"}, \ + {"RX INT" #id "_1 MIX1 INP2", "RX7", "SLIM RX7"}, \ + {"RX INT" #id "_1 MIX1 INP2", "IIR0", "IIR0"}, \ + {"RX INT" #id "_1 MIX1 INP2", "IIR1", "IIR1"}, \ + {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP0"}, \ + {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP1"}, \ + {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP2"}, \ + {"RX INT" #id "_2 MUX", "RX0", "SLIM RX0"}, \ + {"RX INT" #id "_2 MUX", "RX1", "SLIM RX1"}, \ + {"RX INT" #id "_2 MUX", "RX2", "SLIM RX2"}, \ + {"RX INT" #id "_2 MUX", "RX3", "SLIM RX3"}, \ + {"RX INT" #id "_2 MUX", "RX4", "SLIM RX4"}, \ + {"RX INT" #id "_2 MUX", "RX5", "SLIM RX5"}, \ + {"RX INT" #id "_2 MUX", "RX6", "SLIM RX6"}, \ + {"RX INT" #id "_2 MUX", "RX7", "SLIM RX7"}, \ + {"RX INT" #id "_2 MUX", NULL, "INT" #id "_CLK"}, \ + {"RX INT" #id "_2 MUX", NULL, "DSMDEM" #id "_CLK"}, \ + {"RX INT" #id "_2 INTERP", NULL, "RX INT" #id "_2 MUX"}, \ + {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_2 INTERP"}, \ + {"RX INT" #id "_1 INTERP", NULL, "RX INT" #id "_1 MIX1"}, \ + {"RX INT" #id "_1 INTERP", NULL, "INT" #id "_CLK"}, \ + {"RX INT" #id "_1 INTERP", NULL, "DSMDEM" #id "_CLK"}, \ + {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_1 INTERP"} + +#define WCD934X_INTERPOLATOR_MIX2(id) \ + {"RX INT" #id " MIX2", NULL, "RX INT" #id " SEC MIX"}, \ + {"RX INT" #id " MIX2", NULL, "RX INT" #id " MIX2 INP"} + +#define WCD934X_SLIM_RX_AIF_PATH(id) \ + {"SLIM RX"#id" MUX", "AIF1_PB", "AIF1 PB"}, \ + {"SLIM RX"#id" MUX", "AIF2_PB", "AIF2 PB"}, \ + {"SLIM RX"#id" MUX", "AIF3_PB", "AIF3 PB"}, \ + {"SLIM RX"#id" MUX", "AIF4_PB", "AIF4 PB"}, \ + {"SLIM RX"#id, NULL, "SLIM RX"#id" MUX"} + +#define WCD934X_ADC_MUX(id) \ + {"ADC MUX" #id, "DMIC", "DMIC MUX" #id }, \ + {"ADC MUX" #id, "AMIC", "AMIC MUX" #id }, \ + {"DMIC MUX" #id, "DMIC0", "DMIC0"}, \ + {"DMIC MUX" #id, "DMIC1", "DMIC1"}, \ + {"DMIC MUX" #id, "DMIC2", "DMIC2"}, \ + {"DMIC MUX" #id, "DMIC3", "DMIC3"}, \ + {"DMIC MUX" #id, "DMIC4", "DMIC4"}, \ + {"DMIC MUX" #id, "DMIC5", "DMIC5"}, \ + {"AMIC MUX" #id, "ADC1", "ADC1"}, \ + {"AMIC MUX" #id, "ADC2", "ADC2"}, \ + {"AMIC MUX" #id, "ADC3", "ADC3"}, \ + {"AMIC MUX" #id, "ADC4", "ADC4"} + +#define WCD934X_IIR_INP_MUX(id) \ + {"IIR" #id, NULL, "IIR" #id " INP0 MUX"}, \ + {"IIR" #id " INP0 MUX", "DEC0", "ADC MUX0"}, \ + {"IIR" #id " INP0 MUX", "DEC1", "ADC MUX1"}, \ + {"IIR" #id " INP0 MUX", "DEC2", "ADC MUX2"}, \ + {"IIR" #id " INP0 MUX", "DEC3", "ADC MUX3"}, \ + {"IIR" #id " INP0 MUX", "DEC4", "ADC MUX4"}, \ + {"IIR" #id " INP0 MUX", "DEC5", "ADC MUX5"}, \ + {"IIR" #id " INP0 MUX", "DEC6", "ADC MUX6"}, \ + {"IIR" #id " INP0 MUX", "DEC7", "ADC MUX7"}, \ + {"IIR" #id " INP0 MUX", "DEC8", "ADC MUX8"}, \ + {"IIR" #id " INP0 MUX", "RX0", "SLIM RX0"}, \ + {"IIR" #id " INP0 MUX", "RX1", "SLIM RX1"}, \ + {"IIR" #id " INP0 MUX", "RX2", "SLIM RX2"}, \ + {"IIR" #id " INP0 MUX", "RX3", "SLIM RX3"}, \ + {"IIR" #id " INP0 MUX", "RX4", "SLIM RX4"}, \ + {"IIR" #id " INP0 MUX", "RX5", "SLIM RX5"}, \ + {"IIR" #id " INP0 MUX", "RX6", "SLIM RX6"}, \ + {"IIR" #id " INP0 MUX", "RX7", "SLIM RX7"}, \ + {"IIR" #id, NULL, "IIR" #id " INP1 MUX"}, \ + {"IIR" #id " INP1 MUX", "DEC0", "ADC MUX0"}, \ + {"IIR" #id " INP1 MUX", "DEC1", "ADC MUX1"}, \ + {"IIR" #id " INP1 MUX", "DEC2", "ADC MUX2"}, \ + {"IIR" #id " INP1 MUX", "DEC3", "ADC MUX3"}, \ + {"IIR" #id " INP1 MUX", "DEC4", "ADC MUX4"}, \ + {"IIR" #id " INP1 MUX", "DEC5", "ADC MUX5"}, \ + {"IIR" #id " INP1 MUX", "DEC6", "ADC MUX6"}, \ + {"IIR" #id " INP1 MUX", "DEC7", "ADC MUX7"}, \ + {"IIR" #id " INP1 MUX", "DEC8", "ADC MUX8"}, \ + {"IIR" #id " INP1 MUX", "RX0", "SLIM RX0"}, \ + {"IIR" #id " INP1 MUX", "RX1", "SLIM RX1"}, \ + {"IIR" #id " INP1 MUX", "RX2", "SLIM RX2"}, \ + {"IIR" #id " INP1 MUX", "RX3", "SLIM RX3"}, \ + {"IIR" #id " INP1 MUX", "RX4", "SLIM RX4"}, \ + {"IIR" #id " INP1 MUX", "RX5", "SLIM RX5"}, \ + {"IIR" #id " INP1 MUX", "RX6", "SLIM RX6"}, \ + {"IIR" #id " INP1 MUX", "RX7", "SLIM RX7"}, \ + {"IIR" #id, NULL, "IIR" #id " INP2 MUX"}, \ + {"IIR" #id " INP2 MUX", "DEC0", "ADC MUX0"}, \ + {"IIR" #id " INP2 MUX", "DEC1", "ADC MUX1"}, \ + {"IIR" #id " INP2 MUX", "DEC2", "ADC MUX2"}, \ + {"IIR" #id " INP2 MUX", "DEC3", "ADC MUX3"}, \ + {"IIR" #id " INP2 MUX", "DEC4", "ADC MUX4"}, \ + {"IIR" #id " INP2 MUX", "DEC5", "ADC MUX5"}, \ + {"IIR" #id " INP2 MUX", "DEC6", "ADC MUX6"}, \ + {"IIR" #id " INP2 MUX", "DEC7", "ADC MUX7"}, \ + {"IIR" #id " INP2 MUX", "DEC8", "ADC MUX8"}, \ + {"IIR" #id " INP2 MUX", "RX0", "SLIM RX0"}, \ + {"IIR" #id " INP2 MUX", "RX1", "SLIM RX1"}, \ + {"IIR" #id " INP2 MUX", "RX2", "SLIM RX2"}, \ + {"IIR" #id " INP2 MUX", "RX3", "SLIM RX3"}, \ + {"IIR" #id " INP2 MUX", "RX4", "SLIM RX4"}, \ + {"IIR" #id " INP2 MUX", "RX5", "SLIM RX5"}, \ + {"IIR" #id " INP2 MUX", "RX6", "SLIM RX6"}, \ + {"IIR" #id " INP2 MUX", "RX7", "SLIM RX7"}, \ + {"IIR" #id, NULL, "IIR" #id " INP3 MUX"}, \ + {"IIR" #id " INP3 MUX", "DEC0", "ADC MUX0"}, \ + {"IIR" #id " INP3 MUX", "DEC1", "ADC MUX1"}, \ + {"IIR" #id " INP3 MUX", "DEC2", "ADC MUX2"}, \ + {"IIR" #id " INP3 MUX", "DEC3", "ADC MUX3"}, \ + {"IIR" #id " INP3 MUX", "DEC4", "ADC MUX4"}, \ + {"IIR" #id " INP3 MUX", "DEC5", "ADC MUX5"}, \ + {"IIR" #id " INP3 MUX", "DEC6", "ADC MUX6"}, \ + {"IIR" #id " INP3 MUX", "DEC7", "ADC MUX7"}, \ + {"IIR" #id " INP3 MUX", "DEC8", "ADC MUX8"}, \ + {"IIR" #id " INP3 MUX", "RX0", "SLIM RX0"}, \ + {"IIR" #id " INP3 MUX", "RX1", "SLIM RX1"}, \ + {"IIR" #id " INP3 MUX", "RX2", "SLIM RX2"}, \ + {"IIR" #id " INP3 MUX", "RX3", "SLIM RX3"}, \ + {"IIR" #id " INP3 MUX", "RX4", "SLIM RX4"}, \ + {"IIR" #id " INP3 MUX", "RX5", "SLIM RX5"}, \ + {"IIR" #id " INP3 MUX", "RX6", "SLIM RX6"}, \ + {"IIR" #id " INP3 MUX", "RX7", "SLIM RX7"} + +#define WCD934X_SLIM_TX_AIF_PATH(id) \ + {"AIF1_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \ + {"AIF2_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \ + {"AIF3_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id }, \ + {"SLIM TX" #id, NULL, "CDC_IF TX" #id " MUX"} + enum { MIC_BIAS_1 = 1, MIC_BIAS_2, @@ -4678,6 +4834,138 @@ static const struct snd_soc_dapm_widget wcd934x_dapm_widgets[] = { ARRAY_SIZE(aif3_slim_cap_mixer)), }; +static const struct snd_soc_dapm_route wcd934x_audio_map[] = { + /* RX0-RX7 */ + WCD934X_SLIM_RX_AIF_PATH(0), + WCD934X_SLIM_RX_AIF_PATH(1), + WCD934X_SLIM_RX_AIF_PATH(2), + WCD934X_SLIM_RX_AIF_PATH(3), + WCD934X_SLIM_RX_AIF_PATH(4), + WCD934X_SLIM_RX_AIF_PATH(5), + WCD934X_SLIM_RX_AIF_PATH(6), + WCD934X_SLIM_RX_AIF_PATH(7), + + /* RX0 Ear out */ + WCD934X_INTERPOLATOR_PATH(0), + WCD934X_INTERPOLATOR_MIX2(0), + {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"}, + {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"}, + {"RX INT0 DAC", NULL, "RX_BIAS"}, + {"EAR PA", NULL, "RX INT0 DAC"}, + {"EAR", NULL, "EAR PA"}, + + /* RX1 Headphone left */ + WCD934X_INTERPOLATOR_PATH(1), + WCD934X_INTERPOLATOR_MIX2(1), + {"RX INT1 MIX3", NULL, "RX INT1 MIX2"}, + {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX3"}, + {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"}, + {"RX INT1 DAC", NULL, "RX_BIAS"}, + {"HPHL PA", NULL, "RX INT1 DAC"}, + {"HPHL", NULL, "HPHL PA"}, + + /* RX2 Headphone right */ + WCD934X_INTERPOLATOR_PATH(2), + WCD934X_INTERPOLATOR_MIX2(2), + {"RX INT2 MIX3", NULL, "RX INT2 MIX2"}, + {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 MIX3"}, + {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"}, + {"RX INT2 DAC", NULL, "RX_BIAS"}, + {"HPHR PA", NULL, "RX INT2 DAC"}, + {"HPHR", NULL, "HPHR PA"}, + + /* RX3 HIFi LineOut1 */ + WCD934X_INTERPOLATOR_PATH(3), + WCD934X_INTERPOLATOR_MIX2(3), + {"RX INT3 MIX3", NULL, "RX INT3 MIX2"}, + {"RX INT3 DAC", NULL, "RX INT3 MIX3"}, + {"RX INT3 DAC", NULL, "RX_BIAS"}, + {"LINEOUT1 PA", NULL, "RX INT3 DAC"}, + {"LINEOUT1", NULL, "LINEOUT1 PA"}, + + /* RX4 HIFi LineOut2 */ + WCD934X_INTERPOLATOR_PATH(4), + WCD934X_INTERPOLATOR_MIX2(4), + {"RX INT4 MIX3", NULL, "RX INT4 MIX2"}, + {"RX INT4 DAC", NULL, "RX INT4 MIX3"}, + {"RX INT4 DAC", NULL, "RX_BIAS"}, + {"LINEOUT2 PA", NULL, "RX INT4 DAC"}, + {"LINEOUT2", NULL, "LINEOUT2 PA"}, + + /* RX7 Speaker Left Out PA */ + WCD934X_INTERPOLATOR_PATH(7), + WCD934X_INTERPOLATOR_MIX2(7), + {"RX INT7 CHAIN", NULL, "RX INT7 MIX2"}, + {"RX INT7 CHAIN", NULL, "RX_BIAS"}, + {"RX INT7 CHAIN", NULL, "SBOOST0"}, + {"RX INT7 CHAIN", NULL, "SBOOST0_CLK"}, + {"SPK1 OUT", NULL, "RX INT7 CHAIN"}, + + /* RX8 Speaker Right Out PA */ + WCD934X_INTERPOLATOR_PATH(8), + {"RX INT8 CHAIN", NULL, "RX INT8 SEC MIX"}, + {"RX INT8 CHAIN", NULL, "RX_BIAS"}, + {"RX INT8 CHAIN", NULL, "SBOOST1"}, + {"RX INT8 CHAIN", NULL, "SBOOST1_CLK"}, + {"SPK2 OUT", NULL, "RX INT8 CHAIN"}, + + /* Tx */ + {"AIF1 CAP", NULL, "AIF1_CAP Mixer"}, + {"AIF2 CAP", NULL, "AIF2_CAP Mixer"}, + {"AIF3 CAP", NULL, "AIF3_CAP Mixer"}, + + WCD934X_SLIM_TX_AIF_PATH(0), + WCD934X_SLIM_TX_AIF_PATH(1), + WCD934X_SLIM_TX_AIF_PATH(2), + WCD934X_SLIM_TX_AIF_PATH(3), + WCD934X_SLIM_TX_AIF_PATH(4), + WCD934X_SLIM_TX_AIF_PATH(5), + WCD934X_SLIM_TX_AIF_PATH(6), + WCD934X_SLIM_TX_AIF_PATH(7), + WCD934X_SLIM_TX_AIF_PATH(8), + + WCD934X_ADC_MUX(0), + WCD934X_ADC_MUX(1), + WCD934X_ADC_MUX(2), + WCD934X_ADC_MUX(3), + WCD934X_ADC_MUX(4), + WCD934X_ADC_MUX(5), + WCD934X_ADC_MUX(6), + WCD934X_ADC_MUX(7), + WCD934X_ADC_MUX(8), + + {"CDC_IF TX0 MUX", "DEC0", "ADC MUX0"}, + {"CDC_IF TX1 MUX", "DEC1", "ADC MUX1"}, + {"CDC_IF TX2 MUX", "DEC2", "ADC MUX2"}, + {"CDC_IF TX3 MUX", "DEC3", "ADC MUX3"}, + {"CDC_IF TX4 MUX", "DEC4", "ADC MUX4"}, + {"CDC_IF TX5 MUX", "DEC5", "ADC MUX5"}, + {"CDC_IF TX6 MUX", "DEC6", "ADC MUX6"}, + {"CDC_IF TX7 MUX", "DEC7", "ADC MUX7"}, + {"CDC_IF TX8 MUX", "DEC8", "ADC MUX8"}, + + {"AMIC4_5 SEL", "AMIC4", "AMIC4"}, + {"AMIC4_5 SEL", "AMIC5", "AMIC5"}, + + { "DMIC0", NULL, "DMIC0 Pin" }, + { "DMIC1", NULL, "DMIC1 Pin" }, + { "DMIC2", NULL, "DMIC2 Pin" }, + { "DMIC3", NULL, "DMIC3 Pin" }, + { "DMIC4", NULL, "DMIC4 Pin" }, + { "DMIC5", NULL, "DMIC5 Pin" }, + + {"ADC1", NULL, "AMIC1"}, + {"ADC2", NULL, "AMIC2"}, + {"ADC3", NULL, "AMIC3"}, + {"ADC4", NULL, "AMIC4_5 SEL"}, + + WCD934X_IIR_INP_MUX(0), + WCD934X_IIR_INP_MUX(1), + + {"SRC0", NULL, "IIR0"}, + {"SRC1", NULL, "IIR1"}, +}; + static const struct snd_soc_component_driver wcd934x_component_drv = { .probe = wcd934x_comp_probe, .remove = wcd934x_comp_remove, @@ -4686,6 +4974,8 @@ static const struct snd_soc_component_driver wcd934x_component_drv = { .num_controls = ARRAY_SIZE(wcd934x_snd_controls), .dapm_widgets = wcd934x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(wcd934x_dapm_widgets), + .dapm_routes = wcd934x_audio_map, + .num_dapm_routes = ARRAY_SIZE(wcd934x_audio_map), }; static int wcd934x_codec_parse_data(struct wcd934x_codec *wcd) -- cgit v1.2.3 From 834d899794f4ec3bbf9836c85e8f76b7de6e8a59 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:52 +0000 Subject: ASoC: qcom: dt-bindings: Add compatible for DB845c and Lenovo Yoga This patch adds compatible strings for DB845c and Lenovo Yoga C630 soundcard. Based on this compatible strings common machine driver will be in better position to setup board specific configuration. Signed-off-by: Srinivas Kandagatla Acked-by: Rob Herring Link: https://lore.kernel.org/r/20191219103153.14875-11-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/qcom,sdm845.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,sdm845.txt b/Documentation/devicetree/bindings/sound/qcom,sdm845.txt index 408c4837e6d5..ca8c89e88bfa 100644 --- a/Documentation/devicetree/bindings/sound/qcom,sdm845.txt +++ b/Documentation/devicetree/bindings/sound/qcom,sdm845.txt @@ -5,7 +5,10 @@ This binding describes the SDM845 sound card, which uses qdsp for audio. - compatible: Usage: required Value type: - Definition: must be "qcom,sdm845-sndcard" + Definition: must be one of this + "qcom,sdm845-sndcard" + "qcom,db845c-sndcard" + "lenovo,yoga-c630-sndcard" - audio-routing: Usage: Optional -- cgit v1.2.3 From 5caf64c633a3564f70e734868254281b25932fc0 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 19 Dec 2019 10:31:53 +0000 Subject: ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga This patch adds support to Lenovo Yoga c630 compatible strings and related setup to the sound machine driver. Signed-off-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20191219103153.14875-12-srinivas.kandagatla@linaro.org Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/qcom/sdm845.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 28f3cef696e6..3b5547a27aad 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -24,6 +24,9 @@ #define RIGHT_SPK_TDM_TX_MASK 0xC0 #define SPK_TDM_RX_MASK 0x03 #define NUM_TDM_SLOTS 8 +#define SLIM_MAX_TX_PORTS 16 +#define SLIM_MAX_RX_PORTS 16 +#define WCD934X_DEFAULT_MCLK_RATE 9600000 struct sdm845_snd_data { struct snd_soc_jack jack; @@ -36,6 +39,39 @@ struct sdm845_snd_data { static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; +static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; + u32 rx_ch_cnt = 0, tx_ch_cnt = 0; + int ret = 0, i; + + for (i = 0 ; i < dai_link->num_codecs; i++) { + ret = snd_soc_dai_get_channel_map(rtd->codec_dais[i], + &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); + + if (ret != 0 && ret != -ENOTSUPP) { + pr_err("failed to get codec chan map, err:%d\n", ret); + return ret; + } else if (ret == -ENOTSUPP) { + /* Ignore unsupported */ + continue; + } + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, + rx_ch_cnt, rx_ch); + else + ret = snd_soc_dai_set_channel_map(cpu_dai, tx_ch_cnt, + tx_ch, 0, NULL); + } + + return 0; +} + static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -151,6 +187,11 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, case QUATERNARY_TDM_TX_0: ret = sdm845_tdm_snd_hw_params(substream, params); break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + ret = sdm845_slim_snd_hw_params(substream, params); + break; + case QUATERNARY_MI2S_RX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); break; @@ -173,7 +214,20 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); struct snd_jack *jack; - int rval; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + /* + * Codec SLIMBUS configuration + * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13 + * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13 + * TX14, TX15, TX16 + */ + unsigned int rx_ch[SLIM_MAX_RX_PORTS] = {144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156}; + unsigned int tx_ch[SLIM_MAX_TX_PORTS] = {128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143}; + int rval, i; + if (!pdata->jack_setup) { rval = snd_soc_card_jack_new(card, "Headset Jack", @@ -211,6 +265,21 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) return rval; } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + for (i = 0 ; i < dai_link->num_codecs; i++) { + rval = snd_soc_dai_set_channel_map(rtd->codec_dais[i], + ARRAY_SIZE(tx_ch), + tx_ch, + ARRAY_SIZE(rx_ch), + rx_ch); + if (rval != 0 && rval != -ENOTSUPP) + return rval; + + snd_soc_dai_set_sysclk(rtd->codec_dais[i], 0, + WCD934X_DEFAULT_MCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); + } + break; default: break; } @@ -256,6 +325,14 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) } snd_soc_dai_set_fmt(cpu_dai, fmt); snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); + break; + case QUATERNARY_MI2S_RX: + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT, + MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); + + break; case QUATERNARY_TDM_RX_0: @@ -294,6 +371,8 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) } } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); @@ -338,6 +417,9 @@ static void sdm845_snd_shutdown(struct snd_pcm_substream *substream) 0, SNDRV_PCM_STREAM_PLAYBACK); } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + case QUATERNARY_MI2S_RX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); @@ -451,6 +533,8 @@ static int sdm845_snd_platform_remove(struct platform_device *pdev) static const struct of_device_id sdm845_snd_device_id[] = { { .compatible = "qcom,sdm845-sndcard" }, + { .compatible = "qcom,db845c-sndcard" }, + { .compatible = "lenovo,yoga-c630-sndcard" }, {}, }; MODULE_DEVICE_TABLE(of, sdm845_snd_device_id); -- cgit v1.2.3 From a103a3989993859091a26936b9337a8e09330fc3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 26 Dec 2019 11:03:53 +0100 Subject: ALSA: control: Fix incompatible protocol error The recent change to bump the ALSA control API protocol version from 2.0.7 to 2.1.0 caused a regression on user-space; while the user-space expects both the major and the minor versions to be identical with the supported numbers, we changed the minor number from 0 to 1. For recovering from the incompatibility, this patch changes the protocol version again to 2.0.8, which is compatible, but yet higher than the original number 2.0.7, indicating that the protocol change. Fixes: bd3eb4e87eb3 ("ALSA: ctl: bump protocol version up to v2.1.0") Reported-by: Paul Menzel Tested-by: Paul Menzel Link: https://lore.kernel.org/r/s5h1rsr769i.wl-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/asound.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index e36dadaf84ba..30ebb2a42983 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -936,7 +936,7 @@ struct snd_timer_tread { * * ****************************************************************************/ -#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 1, 0) +#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) struct snd_ctl_card_info { int card; /* card number */ -- cgit v1.2.3 From 5def0136c609062091b03a91ac1d987f4afc5363 Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Thu, 5 Dec 2019 19:07:26 +0530 Subject: ASoC: amd: Create multiple I2S platform device endpoint Creates Platform Device endpoints for multiple I2S instances: SP and BT endpoints device. Pass PCI resources like MMIO, irq to the platform devices. Signed-off-by: Ravulapati Vishnu vardhan rao Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/1575553053-18344-2-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x.h | 5 +++ sound/soc/amd/raven/pci-acp3x.c | 95 +++++++++++++++++++++++++++-------------- 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index 4f2cadd90a87..2f15fe10ead5 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -7,10 +7,15 @@ #include "chip_offset_byte.h" +#define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 #define ACP3x_I2S_MODE 0 #define ACP3x_REG_START 0x1240000 #define ACP3x_REG_END 0x1250200 +#define ACP3x_I2STDM_REG_START 0x1242400 +#define ACP3x_I2STDM_REG_END 0x1242410 +#define ACP3x_BT_TDM_REG_START 0x1242800 +#define ACP3x_BT_TDM_REG_END 0x1242810 #define I2S_MODE 0x04 #define BT_TX_THRESHOLD 26 #define BT_RX_THRESHOLD 25 diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index facec2472b34..94f5f21d9a53 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -16,17 +16,17 @@ struct acp3x_dev_data { void __iomem *acp3x_base; bool acp3x_audio_mode; struct resource *res; - struct platform_device *pdev; + struct platform_device *pdev[ACP3x_DEVS]; }; static int snd_acp3x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - int ret; - u32 addr, val; struct acp3x_dev_data *adata; - struct platform_device_info pdevinfo; + struct platform_device_info pdevinfo[ACP3x_DEVS]; unsigned int irqflags; + int ret, i; + u32 addr, val; if (pci_enable_device(pci)) { dev_err(&pci->dev, "pci_enable_device failed\n"); @@ -56,10 +56,11 @@ static int snd_acp3x_probe(struct pci_dev *pci, irqflags = 0; addr = pci_resource_start(pci, 0); - adata->acp3x_base = ioremap(addr, pci_resource_len(pci, 0)); + adata->acp3x_base = devm_ioremap(&pci->dev, addr, + pci_resource_len(pci, 0)); if (!adata->acp3x_base) { ret = -ENOMEM; - goto release_regions; + goto disable_msi; } pci_set_master(pci); pci_set_drvdata(pci, adata); @@ -68,11 +69,11 @@ static int snd_acp3x_probe(struct pci_dev *pci, switch (val) { case I2S_MODE: adata->res = devm_kzalloc(&pci->dev, - sizeof(struct resource) * 2, + sizeof(struct resource) * 4, GFP_KERNEL); if (!adata->res) { ret = -ENOMEM; - goto unmap_mmio; + goto disable_msi; } adata->res[0].name = "acp3x_i2s_iomem"; @@ -80,40 +81,67 @@ static int snd_acp3x_probe(struct pci_dev *pci, adata->res[0].start = addr; adata->res[0].end = addr + (ACP3x_REG_END - ACP3x_REG_START); - adata->res[1].name = "acp3x_i2s_irq"; - adata->res[1].flags = IORESOURCE_IRQ; - adata->res[1].start = pci->irq; - adata->res[1].end = pci->irq; + adata->res[1].name = "acp3x_i2s_sp"; + adata->res[1].flags = IORESOURCE_MEM; + adata->res[1].start = addr + ACP3x_I2STDM_REG_START; + adata->res[1].end = addr + ACP3x_I2STDM_REG_END; + + adata->res[2].name = "acp3x_i2s_bt"; + adata->res[2].flags = IORESOURCE_MEM; + adata->res[2].start = addr + ACP3x_BT_TDM_REG_START; + adata->res[2].end = addr + ACP3x_BT_TDM_REG_END; + + adata->res[3].name = "acp3x_i2s_irq"; + adata->res[3].flags = IORESOURCE_IRQ; + adata->res[3].start = pci->irq; + adata->res[3].end = adata->res[3].start; adata->acp3x_audio_mode = ACP3x_I2S_MODE; memset(&pdevinfo, 0, sizeof(pdevinfo)); - pdevinfo.name = "acp3x_rv_i2s"; - pdevinfo.id = 0; - pdevinfo.parent = &pci->dev; - pdevinfo.num_res = 2; - pdevinfo.res = adata->res; - pdevinfo.data = &irqflags; - pdevinfo.size_data = sizeof(irqflags); - - adata->pdev = platform_device_register_full(&pdevinfo); - if (IS_ERR(adata->pdev)) { - dev_err(&pci->dev, "cannot register %s device\n", - pdevinfo.name); - ret = PTR_ERR(adata->pdev); - goto unmap_mmio; + pdevinfo[0].name = "acp3x_rv_i2s_dma"; + pdevinfo[0].id = 0; + pdevinfo[0].parent = &pci->dev; + pdevinfo[0].num_res = 4; + pdevinfo[0].res = &adata->res[0]; + pdevinfo[0].data = &irqflags; + pdevinfo[0].size_data = sizeof(irqflags); + + pdevinfo[1].name = "acp3x_i2s_playcap"; + pdevinfo[1].id = 0; + pdevinfo[1].parent = &pci->dev; + pdevinfo[1].num_res = 1; + pdevinfo[1].res = &adata->res[1]; + + pdevinfo[2].name = "acp3x_i2s_playcap"; + pdevinfo[2].id = 1; + pdevinfo[2].parent = &pci->dev; + pdevinfo[2].num_res = 1; + pdevinfo[2].res = &adata->res[2]; + for (i = 0; i < ACP3x_DEVS ; i++) { + adata->pdev[i] = + platform_device_register_full(&pdevinfo[i]); + if (IS_ERR(adata->pdev[i])) { + dev_err(&pci->dev, "cannot register %s device\n", + pdevinfo[i].name); + ret = PTR_ERR(adata->pdev[i]); + goto unregister_devs; + } } break; default: dev_err(&pci->dev, "Invalid ACP audio mode : %d\n", val); ret = -ENODEV; - goto unmap_mmio; + goto disable_msi; } return 0; -unmap_mmio: +unregister_devs: + if (val == I2S_MODE) + for (i = 0 ; i < ACP3x_DEVS ; i++) + platform_device_unregister(adata->pdev[i]); +disable_msi: pci_disable_msi(pci); - iounmap(adata->acp3x_base); release_regions: pci_release_regions(pci); disable_pci: @@ -125,10 +153,12 @@ disable_pci: static void snd_acp3x_remove(struct pci_dev *pci) { struct acp3x_dev_data *adata = pci_get_drvdata(pci); + int i; - platform_device_unregister(adata->pdev); - iounmap(adata->acp3x_base); - + if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) { + for (i = 0 ; i < ACP3x_DEVS ; i++) + platform_device_unregister(adata->pdev[i]); + } pci_disable_msi(pci); pci_release_regions(pci); pci_disable_device(pci); @@ -151,6 +181,7 @@ static struct pci_driver acp3x_driver = { module_pci_driver(acp3x_driver); +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com"); MODULE_DESCRIPTION("AMD ACP3x PCI driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 7d8d3c377cc9731c3924f807c7769177ca3f0865 Mon Sep 17 00:00:00 2001 From: Chris Boyle Date: Fri, 27 Dec 2019 10:40:53 +0100 Subject: ALSA: usb-audio: fix Corsair Virtuoso mixer label collision The Corsair Virtuoso RGB Wireless is a USB headset with a mic and a sidetone feature. Label its mixer appropriately instead of all "Headset", so that applications such as Pulseaudio don't just move the sidetone control when they intend the main Headset control. Signed-off-by: Chris Boyle Link: https://lore.kernel.org/r/20191227094053.GA12167@nova.chris.boyle.name Signed-off-by: Takashi Iwai --- sound/usb/mixer_maps.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index 73baf398c84a..d094934ae6c5 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -349,6 +349,16 @@ static const struct usbmix_name_map dell_alc4020_map[] = { { 0 } }; +/* + * Corsair Virtuoso calls everything "Headset" without this, leading to + * applications moving the sidetone control instead of the main one. + */ +static const struct usbmix_name_map corsair_virtuoso_map[] = { + { 3, "Mic Capture" }, + { 6, "Sidetone Playback" }, + { 0 } +}; + /* * Control map entries */ @@ -468,6 +478,16 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { .id = USB_ID(0x05a7, 0x1020), .map = bose_companion5_map, }, + { + /* Corsair Virtuoso (wired mode) */ + .id = USB_ID(0x1b1c, 0x0a41), + .map = corsair_virtuoso_map, + }, + { + /* Corsair Virtuoso (wireless mode) */ + .id = USB_ID(0x1b1c, 0x0a42), + .map = corsair_virtuoso_map, + }, { 0 } /* terminator */ }; -- cgit v1.2.3 From d06ed0c20960f124642ce77cd80056a35ffebe55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Dec 2019 22:27:42 +0100 Subject: ALSA: uapi: Add linux/types.h include back (but carefully) A few uapi/sound/*.h headers have been corrected for recovering from the compile errors with the existing user-space code (alsa-lib) by the recent commits. OTOH, these introduced another regression, as now linux/types.h inclusion became mandatory for the uapi header checks. As a compromise, this patch re-adds linux/types.h inclusions again, but conditionally not to break other non-standard user-space stuff again. Fixes: 2e4688676392 ("ALSA: emu10k1: Make uapi/emu10k1.h compilable again") Fixes: d63e63d42107 ("ALSA: hdsp: Make uapi/hdsp.h compilable again") Fixes: 4fa406caf950 ("ALSA: hdspm: Drop linux/types.h inclusion in uapi header") Reported-by: kbuild test robot Link: https://lore.kernel.org/r/20191230212742.28925-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/uapi/sound/emu10k1.h | 4 ++++ include/uapi/sound/hdsp.h | 4 ++++ include/uapi/sound/hdspm.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/include/uapi/sound/emu10k1.h b/include/uapi/sound/emu10k1.h index 6bcd76f64c1c..88609cc0524c 100644 --- a/include/uapi/sound/emu10k1.h +++ b/include/uapi/sound/emu10k1.h @@ -23,6 +23,10 @@ #ifndef _UAPI__SOUND_EMU10K1_H #define _UAPI__SOUND_EMU10K1_H +#ifdef __linux__ +#include +#endif + /* * ---- FX8010 ---- */ diff --git a/include/uapi/sound/hdsp.h b/include/uapi/sound/hdsp.h index 7ac2d3f2a9b3..b8df62b60f4d 100644 --- a/include/uapi/sound/hdsp.h +++ b/include/uapi/sound/hdsp.h @@ -20,6 +20,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef __linux__ +#include +#endif + #define HDSP_MATRIX_MIXER_SIZE 2048 enum HDSP_IO_Type { diff --git a/include/uapi/sound/hdspm.h b/include/uapi/sound/hdspm.h index 3fbfd9dc5f51..14af3d00ea3f 100644 --- a/include/uapi/sound/hdspm.h +++ b/include/uapi/sound/hdspm.h @@ -21,6 +21,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef __linux__ +#include +#endif + /* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */ #define HDSPM_MAX_CHANNELS 64 -- cgit v1.2.3 From 9ea7a991cc27e9af1099b7a628c0ab210dc70a69 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Thu, 26 Dec 2019 17:29:07 +0100 Subject: ASoC: cs47l92: Simplify error handling code in 'cs47l92_probe()' If 'madera_init_bus_error_irq()' fails, 'wm_adsp2_remove(&cs47l92->core.adsp[0])' will be called twice. Once in the 'if' block, and once in the error handling path. This is harmless, but one of this call can be axed. Signed-off-by: Christophe JAILLET Acked-by: Charles Keepax Link: https://lore.kernel.org/r/20191226162907.9490-1-christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l92.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs47l92.c b/sound/soc/codecs/cs47l92.c index d50f75f3b3e4..536b7d35d6b2 100644 --- a/sound/soc/codecs/cs47l92.c +++ b/sound/soc/codecs/cs47l92.c @@ -1959,10 +1959,8 @@ static int cs47l92_probe(struct platform_device *pdev) goto error_dsp_irq; ret = madera_init_bus_error_irq(&cs47l92->core, 0, wm_adsp2_bus_error); - if (ret != 0) { - wm_adsp2_remove(&cs47l92->core.adsp[0]); + if (ret != 0) goto error_adsp; - } madera_init_fll(madera, 1, MADERA_FLL1_CONTROL_1 - 1, &cs47l92->fll[0]); -- cgit v1.2.3 From 1094af1199007976370b8f04b4d6668ad9707954 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 30 Dec 2019 14:35:16 +0000 Subject: ASoC: madera: Enable clocks for input pins when used as a direct clock When one of the MCLK pins is used to supply an internal clock directly enable the source clock for that pin. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20191230143517.21005-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l15.c | 8 ++++--- sound/soc/codecs/cs47l35.c | 6 +++-- sound/soc/codecs/cs47l85.c | 11 +++++---- sound/soc/codecs/cs47l90.c | 11 +++++---- sound/soc/codecs/cs47l92.c | 58 ++++++++++++++++++++++++++++++++++++++++++---- sound/soc/codecs/madera.c | 53 ++++++++++++++++++++++++++++++++++++++++-- sound/soc/codecs/madera.h | 2 ++ 7 files changed, 129 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/cs47l15.c b/sound/soc/codecs/cs47l15.c index ece1276f38eb..513e2875e4c6 100644 --- a/sound/soc/codecs/cs47l15.c +++ b/sound/soc/codecs/cs47l15.c @@ -438,11 +438,13 @@ static const struct snd_kcontrol_new cs47l15_aec_loopback_mux[] = { static const struct snd_soc_dapm_widget cs47l15_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 0, madera_sysclk_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), -SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, - MADERA_DSP_CLK_ENA_SHIFT, 0, NULL, 0), +SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, + 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS), diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c index d396a8545d51..ba7aa6b31205 100644 --- a/sound/soc/codecs/cs47l35.c +++ b/sound/soc/codecs/cs47l35.c @@ -521,11 +521,13 @@ static const struct snd_kcontrol_new cs47l35_aec_loopback_mux[] = { static const struct snd_soc_dapm_widget cs47l35_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 0, madera_sysclk_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, - 0, NULL, 0), + 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0), diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c index 32fe7ffb7526..f85581a97bdc 100644 --- a/sound/soc/codecs/cs47l85.c +++ b/sound/soc/codecs/cs47l85.c @@ -790,15 +790,18 @@ static const struct snd_kcontrol_new cs47l85_output_anc_src[] = { static const struct snd_soc_dapm_widget cs47l85_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 0, madera_sysclk_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("ASYNCCLK", MADERA_ASYNC_CLOCK_1, - MADERA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), + MADERA_ASYNC_CLK_ENA_SHIFT, 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", MADERA_OUTPUT_ASYNC_CLOCK, MADERA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), -SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, - MADERA_DSP_CLK_ENA_SHIFT, 0, NULL, 0), +SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, + 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0), diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c index 67cac60a859d..c3b6f4d41005 100644 --- a/sound/soc/codecs/cs47l90.c +++ b/sound/soc/codecs/cs47l90.c @@ -744,15 +744,18 @@ static const struct snd_kcontrol_new cs47l90_output_anc_src[] = { static const struct snd_soc_dapm_widget cs47l90_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 0, madera_sysclk_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("ASYNCCLK", MADERA_ASYNC_CLOCK_1, - MADERA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), + MADERA_ASYNC_CLK_ENA_SHIFT, 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", MADERA_OUTPUT_ASYNC_CLOCK, MADERA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), -SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, - MADERA_DSP_CLK_ENA_SHIFT, 0, NULL, 0), +SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, + 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0), diff --git a/sound/soc/codecs/cs47l92.c b/sound/soc/codecs/cs47l92.c index 536b7d35d6b2..cbffcd84766d 100644 --- a/sound/soc/codecs/cs47l92.c +++ b/sound/soc/codecs/cs47l92.c @@ -163,6 +163,51 @@ static int cs47l92_adsp_power_ev(struct snd_soc_dapm_widget *w, return wm_adsp_early_event(w, kcontrol, event); } +static int cs47l92_outclk_ev(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct cs47l92 *cs47l92 = snd_soc_component_get_drvdata(component); + struct madera_priv *priv = &cs47l92->core; + struct madera *madera = priv->madera; + unsigned int val; + int ret; + + ret = regmap_read(madera->regmap, MADERA_OUTPUT_RATE_1, &val); + if (ret) { + dev_err(madera->dev, "Failed to read OUTCLK source: %d\n", ret); + return ret; + } + + val &= MADERA_OUT_CLK_SRC_MASK; + + switch (val) { + case MADERA_OUTCLK_MCLK1: + case MADERA_OUTCLK_MCLK2: + case MADERA_OUTCLK_MCLK3: + val -= (MADERA_OUTCLK_MCLK1 - MADERA_MCLK1); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + ret = clk_prepare_enable(madera->mclk[val].clk); + if (ret) + return ret; + break; + case SND_SOC_DAPM_POST_PMD: + clk_disable_unprepare(madera->mclk[val].clk); + break; + default: + break; + } + default: + break; + } + + return madera_domain_clk_ev(w, kcontrol, event); +} + #define CS47L92_NG_SRC(name, base) \ SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \ SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \ @@ -615,15 +660,18 @@ static const struct snd_kcontrol_new cs47l92_aec_loopback_mux = static const struct snd_soc_dapm_widget cs47l92_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT, 0, madera_sysclk_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("ASYNCCLK", MADERA_ASYNC_CLOCK_1, - MADERA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), + MADERA_ASYNC_CLK_ENA_SHIFT, 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK, MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", MADERA_OUTPUT_ASYNC_CLOCK, MADERA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0), -SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, - MADERA_DSP_CLK_ENA_SHIFT, 0, NULL, 0), +SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT, + 0, madera_clk_ev, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0), SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD2", 20, 0), @@ -666,7 +714,7 @@ SND_SOC_DAPM_SUPPLY("ISRC2CLK", SND_SOC_NOPM, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("OUTCLK", SND_SOC_NOPM, MADERA_DOM_GRP_OUT, 0, - madera_domain_clk_ev, + cs47l92_outclk_ev, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_SUPPLY("SPDCLK", SND_SOC_NOPM, MADERA_DOM_GRP_SPD, 0, diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 52639811cc52..9b4b4c52b9e4 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -163,6 +163,48 @@ static const int madera_dsp_bus_error_irqs[MADERA_MAX_ADSP] = { MADERA_IRQ_DSP7_BUS_ERR, }; +int madera_clk_ev(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct madera_priv *priv = snd_soc_component_get_drvdata(component); + struct madera *madera = priv->madera; + unsigned int val; + int clk_idx; + int ret; + + ret = regmap_read(madera->regmap, w->reg, &val); + if (ret) { + dev_err(madera->dev, "Failed to check clock source: %d\n", ret); + return ret; + } + + switch ((val & MADERA_SYSCLK_SRC_MASK) >> MADERA_SYSCLK_SRC_SHIFT) { + case MADERA_CLK_SRC_MCLK1: + clk_idx = MADERA_MCLK1; + break; + case MADERA_CLK_SRC_MCLK2: + clk_idx = MADERA_MCLK2; + break; + case MADERA_CLK_SRC_MCLK3: + clk_idx = MADERA_MCLK3; + break; + default: + return 0; + } + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + return clk_prepare_enable(madera->mclk[clk_idx].clk); + case SND_SOC_DAPM_POST_PMD: + clk_disable_unprepare(madera->mclk[clk_idx].clk); + return 0; + default: + return 0; + } +} +EXPORT_SYMBOL_GPL(madera_clk_ev); + static void madera_spin_sysclk(struct madera_priv *priv) { struct madera *madera = priv->madera; @@ -193,9 +235,16 @@ int madera_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct madera_priv *priv = snd_soc_component_get_drvdata(component); - madera_spin_sysclk(priv); + switch (event) { + case SND_SOC_DAPM_POST_PMU: + case SND_SOC_DAPM_PRE_PMD: + madera_spin_sysclk(priv); + break; + default: + break; + } - return 0; + return madera_clk_ev(w, kcontrol, event); } EXPORT_SYMBOL_GPL(madera_sysclk_ev); diff --git a/sound/soc/codecs/madera.h b/sound/soc/codecs/madera.h index 6d8938a3fb64..49a8f68ec43d 100644 --- a/sound/soc/codecs/madera.h +++ b/sound/soc/codecs/madera.h @@ -383,6 +383,8 @@ int madera_eq_coeff_put(struct snd_kcontrol *kcontrol, int madera_lhpf_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int madera_clk_ev(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event); int madera_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); int madera_spk_ev(struct snd_soc_dapm_widget *w, -- cgit v1.2.3 From 3863857dd5ca3e60685c6b49a7873fda727ff233 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 30 Dec 2019 14:35:17 +0000 Subject: ASoC: madera: Enable clocks for input pins when used for the FLL When one of the MCLK pins is used to supply the FLL enable that clock source. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20191230143517.21005-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/madera.c | 109 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 9b4b4c52b9e4..12dc468ae6bf 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -3858,11 +3858,75 @@ static bool madera_set_fll_phase_integrator(struct madera_fll *fll, return reg_change; } +static int madera_set_fll_clks_reg(struct madera_fll *fll, bool ena, + unsigned int reg, unsigned int mask, + unsigned int shift) +{ + struct madera *madera = fll->madera; + unsigned int src; + struct clk *clk; + int ret; + + ret = regmap_read(madera->regmap, reg, &src); + if (ret != 0) { + madera_fll_err(fll, "Failed to read current source: %d\n", + ret); + return ret; + } + + src = (src & mask) >> shift; + + switch (src) { + case MADERA_FLL_SRC_MCLK1: + clk = madera->mclk[MADERA_MCLK1].clk; + break; + case MADERA_FLL_SRC_MCLK2: + clk = madera->mclk[MADERA_MCLK2].clk; + break; + case MADERA_FLL_SRC_MCLK3: + clk = madera->mclk[MADERA_MCLK3].clk; + break; + default: + return 0; + } + + if (ena) { + return clk_prepare_enable(clk); + } else { + clk_disable_unprepare(clk); + return 0; + } +} + +static inline int madera_set_fll_clks(struct madera_fll *fll, int base, bool ena) +{ + return madera_set_fll_clks_reg(fll, ena, + base + MADERA_FLL_CONTROL_6_OFFS, + MADERA_FLL1_REFCLK_SRC_MASK, + MADERA_FLL1_REFCLK_DIV_SHIFT); +} + +static inline int madera_set_fllao_clks(struct madera_fll *fll, int base, bool ena) +{ + return madera_set_fll_clks_reg(fll, ena, + base + MADERA_FLLAO_CONTROL_6_OFFS, + MADERA_FLL_AO_REFCLK_SRC_MASK, + MADERA_FLL_AO_REFCLK_SRC_SHIFT); +} + +static inline int madera_set_fllhj_clks(struct madera_fll *fll, int base, bool ena) +{ + return madera_set_fll_clks_reg(fll, ena, + base + MADERA_FLL_CONTROL_1_OFFS, + CS47L92_FLL1_REFCLK_SRC_MASK, + CS47L92_FLL1_REFCLK_SRC_SHIFT); +} + static void madera_disable_fll(struct madera_fll *fll) { struct madera *madera = fll->madera; unsigned int sync_base; - bool change; + bool ref_change, sync_change; switch (madera->type) { case CS47L35: @@ -3880,18 +3944,23 @@ static void madera_disable_fll(struct madera_fll *fll) MADERA_FLL1_FREERUN, MADERA_FLL1_FREERUN); regmap_update_bits_check(madera->regmap, fll->base + MADERA_FLL_CONTROL_1_OFFS, - MADERA_FLL1_ENA, 0, &change); - regmap_update_bits(madera->regmap, - sync_base + MADERA_FLL_SYNCHRONISER_1_OFFS, - MADERA_FLL1_SYNC_ENA, 0); + MADERA_FLL1_ENA, 0, &ref_change); + regmap_update_bits_check(madera->regmap, + sync_base + MADERA_FLL_SYNCHRONISER_1_OFFS, + MADERA_FLL1_SYNC_ENA, 0, &sync_change); regmap_update_bits(madera->regmap, fll->base + MADERA_FLL_CONTROL_1_OFFS, MADERA_FLL1_FREERUN, 0); madera_wait_for_fll(fll, false); - if (change) + if (sync_change) + madera_set_fll_clks(fll, sync_base, false); + + if (ref_change) { + madera_set_fll_clks(fll, fll->base, false); pm_runtime_put_autosuspend(madera->dev); + } } static int madera_enable_fll(struct madera_fll *fll) @@ -3947,6 +4016,10 @@ static int madera_enable_fll(struct madera_fll *fll) regmap_update_bits(fll->madera->regmap, fll->base + MADERA_FLL_CONTROL_7_OFFS, MADERA_FLL1_GAIN_MASK, 0); + + if (sync_enabled > 0) + madera_set_fll_clks(fll, sync_base, false); + madera_set_fll_clks(fll, fll->base, false); } /* Apply SYNCCLK setting */ @@ -4025,11 +4098,15 @@ static int madera_enable_fll(struct madera_fll *fll) if (!already_enabled) pm_runtime_get_sync(madera->dev); - if (have_sync) + if (have_sync) { + madera_set_fll_clks(fll, sync_base, true); regmap_update_bits(madera->regmap, sync_base + MADERA_FLL_SYNCHRONISER_1_OFFS, MADERA_FLL1_SYNC_ENA, MADERA_FLL1_SYNC_ENA); + } + + madera_set_fll_clks(fll, fll->base, true); regmap_update_bits(madera->regmap, fll->base + MADERA_FLL_CONTROL_1_OFFS, MADERA_FLL1_ENA, MADERA_FLL1_ENA); @@ -4201,6 +4278,9 @@ static int madera_enable_fll_ao(struct madera_fll *fll, fll->base + MADERA_FLLAO_CONTROL_1_OFFS, MADERA_FLL_AO_HOLD, MADERA_FLL_AO_HOLD); + if (already_enabled) + madera_set_fllao_clks(fll, fll->base, false); + for (i = 0; i < patch_size; i++) { val = patch[i].def; @@ -4214,6 +4294,8 @@ static int madera_enable_fll_ao(struct madera_fll *fll, regmap_write(madera->regmap, patch[i].reg, val); } + madera_set_fllao_clks(fll, fll->base, true); + regmap_update_bits(madera->regmap, fll->base + MADERA_FLLAO_CONTROL_1_OFFS, MADERA_FLL_AO_ENA, MADERA_FLL_AO_ENA); @@ -4257,8 +4339,10 @@ static int madera_disable_fll_ao(struct madera_fll *fll) fll->base + MADERA_FLLAO_CONTROL_2_OFFS, MADERA_FLL_AO_CTRL_UPD_MASK, 0); - if (change) + if (change) { + madera_set_fllao_clks(fll, fll->base, false); pm_runtime_put_autosuspend(madera->dev); + } return 0; } @@ -4344,8 +4428,10 @@ static int madera_fllhj_disable(struct madera_fll *fll) fll->base + MADERA_FLL_CONTROL_2_OFFS, MADERA_FLL1_CTRL_UPD_MASK, 0); - if (change) + if (change) { + madera_set_fllhj_clks(fll, fll->base, false); pm_runtime_put_autosuspend(madera->dev); + } return 0; } @@ -4517,6 +4603,9 @@ static int madera_fllhj_enable(struct madera_fll *fll) MADERA_FLL1_HOLD_MASK, MADERA_FLL1_HOLD_MASK); + if (already_enabled) + madera_set_fllhj_clks(fll, fll->base, false); + /* Apply refclk */ ret = madera_fllhj_apply(fll, fll->ref_freq); if (ret) { @@ -4528,6 +4617,8 @@ static int madera_fllhj_enable(struct madera_fll *fll) CS47L92_FLL1_REFCLK_SRC_MASK, fll->ref_src << CS47L92_FLL1_REFCLK_SRC_SHIFT); + madera_set_fllhj_clks(fll, fll->base, true); + regmap_update_bits(madera->regmap, fll->base + MADERA_FLL_CONTROL_1_OFFS, MADERA_FLL1_ENA_MASK, -- cgit v1.2.3 From c9fe7db6e884d0ab8c55d4ed4660fb19400acf2e Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:10:55 +0530 Subject: ASoC: amd: Refactoring of DAI from DMA driver ASoC: PCM DMA driver should only have dma ops. So Removed all DAI related functionality.Refactoring the PCM DMA diver code.Added new file containing only DAI ops Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-2-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/Makefile | 2 + sound/soc/amd/raven/acp3x-i2s.c | 261 ++++++++++++++++++++++++++++++++ sound/soc/amd/raven/acp3x-pcm-dma.c | 292 ++++++------------------------------ sound/soc/amd/raven/acp3x.h | 44 ++++++ 4 files changed, 356 insertions(+), 243 deletions(-) create mode 100644 sound/soc/amd/raven/acp3x-i2s.c diff --git a/sound/soc/amd/raven/Makefile b/sound/soc/amd/raven/Makefile index 108d1acf189b..62c22b6ed95a 100644 --- a/sound/soc/amd/raven/Makefile +++ b/sound/soc/amd/raven/Makefile @@ -2,5 +2,7 @@ # Raven Ridge platform Support snd-pci-acp3x-objs := pci-acp3x.o snd-acp3x-pcm-dma-objs := acp3x-pcm-dma.o +snd-acp3x-i2s-objs := acp3x-i2s.o obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-pci-acp3x.o obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-acp3x-pcm-dma.o +obj-$(CONFIG_SND_SOC_AMD_ACP3x) += snd-acp3x-i2s.o diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c new file mode 100644 index 000000000000..d9bc0fc63185 --- /dev/null +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -0,0 +1,261 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// AMD ALSA SoC PCM Driver +// +//Copyright 2016 Advanced Micro Devices, Inc. + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "acp3x.h" + +#define DRV_NAME "acp3x-i2s" + +static int acp3x_i2s_set_fmt(struct snd_soc_dai *cpu_dai, + unsigned int fmt) +{ + struct i2s_dev_data *adata; + int mode; + + adata = snd_soc_dai_get_drvdata(cpu_dai); + mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK; + switch (mode) { + case SND_SOC_DAIFMT_I2S: + adata->tdm_mode = false; + break; + case SND_SOC_DAIFMT_DSP_A: + adata->tdm_mode = true; + break; + default: + return -EINVAL; + } + return 0; +} + +static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, + u32 tx_mask, u32 rx_mask, int slots, int slot_width) +{ + struct i2s_dev_data *adata; + u32 val, reg_val, frmt_val, frm_len; + u16 slot_len; + + adata = snd_soc_dai_get_drvdata(cpu_dai); + + /* These values are as per Hardware Spec */ + switch (slot_width) { + case SLOT_WIDTH_8: + slot_len = 8; + break; + case SLOT_WIDTH_16: + slot_len = 16; + break; + case SLOT_WIDTH_24: + slot_len = 24; + break; + case SLOT_WIDTH_32: + slot_len = 0; + break; + default: + return -EINVAL; + } + + /* Enable I2S/BT channels TDM, respective TX/RX frame lengths.*/ + + frm_len = FRM_LEN | (slots << 15) | (slot_len << 18); + if (adata->substream_type == SNDRV_PCM_STREAM_PLAYBACK) { + reg_val = mmACP_BTTDM_ITER; + frmt_val = mmACP_BTTDM_TXFRMT; + } else { + reg_val = mmACP_BTTDM_IRER; + frmt_val = mmACP_BTTDM_RXFRMT; + } + val = rv_readl(adata->acp3x_base + reg_val); + rv_writel(val | 0x2, adata->acp3x_base + reg_val); + rv_writel(frm_len, adata->acp3x_base + frmt_val); + adata->tdm_fmt = frm_len; + return 0; +} + +static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct i2s_stream_instance *rtd; + u32 val; + u32 reg_val; + + rtd = substream->runtime->private_data; + + /* These values are as per Hardware Spec */ + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_U8: + case SNDRV_PCM_FORMAT_S8: + rtd->xfer_resolution = 0x0; + break; + case SNDRV_PCM_FORMAT_S16_LE: + rtd->xfer_resolution = 0x02; + break; + case SNDRV_PCM_FORMAT_S24_LE: + rtd->xfer_resolution = 0x04; + break; + case SNDRV_PCM_FORMAT_S32_LE: + rtd->xfer_resolution = 0x05; + break; + default: + return -EINVAL; + } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + reg_val = mmACP_BTTDM_ITER; + else + reg_val = mmACP_BTTDM_IRER; + + val = rv_readl(rtd->acp3x_base + reg_val); + val = val | (rtd->xfer_resolution << 3); + rv_writel(val, rtd->acp3x_base + reg_val); + return 0; +} + +static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct i2s_stream_instance *rtd; + u32 val, period_bytes; + int ret, reg_val; + + rtd = substream->runtime->private_data; + period_bytes = frames_to_bytes(substream->runtime, + substream->runtime->period_size); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + rtd->bytescount = acp_get_byte_count(rtd, + substream->stream); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + reg_val = mmACP_BTTDM_ITER; + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_BT_TX_INTR_WATERMARK_SIZE); + } else { + reg_val = mmACP_BTTDM_IRER; + rv_writel(period_bytes, rtd->acp3x_base + + mmACP_BT_RX_INTR_WATERMARK_SIZE); + } + val = rv_readl(rtd->acp3x_base + reg_val); + val = val | BIT(0); + rv_writel(val, rtd->acp3x_base + reg_val); + rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + reg_val = mmACP_BTTDM_ITER; + else + reg_val = mmACP_BTTDM_IRER; + + val = rv_readl(rtd->acp3x_base + reg_val); + val = val & ~BIT(0); + rv_writel(val, rtd->acp3x_base + reg_val); + rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static struct snd_soc_dai_ops acp3x_i2s_dai_ops = { + .hw_params = acp3x_i2s_hwparams, + .trigger = acp3x_i2s_trigger, + .set_fmt = acp3x_i2s_set_fmt, + .set_tdm_slot = acp3x_i2s_set_tdm_slot, +}; + +static const struct snd_soc_component_driver acp3x_dai_component = { + .name = "acp3x-i2s", +}; + +static struct snd_soc_dai_driver acp3x_i2s_dai = { + .playback = { + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 8, + .rate_min = 8000, + .rate_max = 96000, + }, + .capture = { + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | + SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &acp3x_i2s_dai_ops, +}; + +static int acp3x_dai_probe(struct platform_device *pdev) +{ + struct resource *res; + struct i2s_dev_data *adata; + int ret; + + adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data), + GFP_KERNEL); + if (!adata) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); + return -ENOMEM; + } + adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); + if (IS_ERR(adata->acp3x_base)) + return PTR_ERR(adata->acp3x_base); + + adata->i2s_irq = res->start; + dev_set_drvdata(&pdev->dev, adata); + ret = devm_snd_soc_register_component(&pdev->dev, + &acp3x_dai_component, &acp3x_i2s_dai, 1); + if (ret) { + dev_err(&pdev->dev, "Fail to register acp i2s dai\n"); + return -ENODEV; + } + return 0; +} + +static int acp3x_dai_remove(struct platform_device *pdev) +{ + /* As we use devm_ memory alloc there is nothing TBD here */ + + return 0; +} + +static struct platform_driver acp3x_dai_driver = { + .probe = acp3x_dai_probe, + .remove = acp3x_dai_remove, + .driver = { + .name = "acp3x_i2s_playcap", + }, +}; + +module_platform_driver(acp3x_dai_driver); + +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); +MODULE_DESCRIPTION("AMD ACP 3.x PCM Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" DRV_NAME); diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 97921046afff..9f6ea3ef2441 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -18,24 +17,6 @@ #define DRV_NAME "acp3x-i2s-audio" -struct i2s_dev_data { - bool tdm_mode; - unsigned int i2s_irq; - u32 tdm_fmt; - void __iomem *acp3x_base; - struct snd_pcm_substream *play_stream; - struct snd_pcm_substream *capture_stream; -}; - -struct i2s_stream_instance { - u16 num_pages; - u16 channels; - u32 xfer_resolution; - u64 bytescount; - dma_addr_t dma_addr; - void __iomem *acp3x_base; -}; - static const struct snd_pcm_hardware acp3x_pcm_hardware_playback = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -178,10 +159,11 @@ static int acp3x_deinit(void __iomem *acp3x_base) static irqreturn_t i2s_irq_handler(int irq, void *dev_id) { + struct i2s_dev_data *rv_i2s_data; u16 play_flag, cap_flag; u32 val; - struct i2s_dev_data *rv_i2s_data = dev_id; + rv_i2s_data = dev_id; if (!rv_i2s_data) return IRQ_NONE; @@ -278,11 +260,17 @@ static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction) static int acp3x_dma_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - int ret = 0; - struct snd_pcm_runtime *runtime = substream->runtime; - struct i2s_dev_data *adata = dev_get_drvdata(component->dev); - struct i2s_stream_instance *i2s_data = kzalloc(sizeof(struct i2s_stream_instance), - GFP_KERNEL); + struct snd_pcm_runtime *runtime; + struct snd_soc_pcm_runtime *prtd; + struct i2s_dev_data *adata; + struct i2s_stream_instance *i2s_data; + int ret; + + runtime = substream->runtime; + prtd = substream->private_data; + component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + adata = dev_get_drvdata(component->dev); + i2s_data = kzalloc(sizeof(*i2s_data), GFP_KERNEL); if (!i2s_data) return -EINVAL; @@ -312,23 +300,6 @@ static int acp3x_dma_open(struct snd_soc_component *component, return 0; } -static u64 acp_get_byte_count(struct i2s_stream_instance *rtd, int direction) -{ - u64 byte_count; - - if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); - } else { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); - } - return byte_count; -} static int acp3x_dma_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, @@ -351,12 +322,12 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - u32 pos = 0; - u32 buffersize = 0; - u64 bytescount = 0; - struct i2s_stream_instance *rtd = - substream->runtime->private_data; + struct i2s_stream_instance *rtd; + u32 pos; + u32 buffersize; + u64 bytescount; + rtd = substream->runtime->private_data; buffersize = frames_to_bytes(substream->runtime, substream->runtime->buffer_size); bytescount = acp_get_byte_count(rtd, substream->stream); @@ -385,8 +356,12 @@ static int acp3x_dma_mmap(struct snd_soc_component *component, static int acp3x_dma_close(struct snd_soc_component *component, struct snd_pcm_substream *substream) { - struct i2s_stream_instance *rtd = substream->runtime->private_data; - struct i2s_dev_data *adata = dev_get_drvdata(component->dev); + struct snd_soc_pcm_runtime *prtd; + struct i2s_dev_data *adata; + + prtd = substream->private_data; + component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + adata = dev_get_drvdata(component->dev); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) adata->play_stream = NULL; @@ -398,186 +373,9 @@ static int acp3x_dma_close(struct snd_soc_component *component, */ if (!adata->play_stream && !adata->capture_stream) rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); - kfree(rtd); return 0; } -static int acp3x_dai_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) -{ - - struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); - - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - adata->tdm_mode = false; - break; - case SND_SOC_DAIFMT_DSP_A: - adata->tdm_mode = true; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int acp3x_dai_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, - u32 rx_mask, int slots, int slot_width) -{ - u32 val = 0; - u16 slot_len; - - struct i2s_dev_data *adata = snd_soc_dai_get_drvdata(cpu_dai); - - switch (slot_width) { - case SLOT_WIDTH_8: - slot_len = 8; - break; - case SLOT_WIDTH_16: - slot_len = 16; - break; - case SLOT_WIDTH_24: - slot_len = 24; - break; - case SLOT_WIDTH_32: - slot_len = 0; - break; - default: - return -EINVAL; - } - - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_ITER); - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); - rv_writel((val | 0x2), adata->acp3x_base + mmACP_BTTDM_IRER); - - val = (FRM_LEN | (slots << 15) | (slot_len << 18)); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_TXFRMT); - rv_writel(val, adata->acp3x_base + mmACP_BTTDM_RXFRMT); - - adata->tdm_fmt = val; - return 0; -} - -static int acp3x_dai_i2s_hwparams(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - u32 val = 0; - struct i2s_stream_instance *rtd = substream->runtime->private_data; - - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_U8: - case SNDRV_PCM_FORMAT_S8: - rtd->xfer_resolution = 0x0; - break; - case SNDRV_PCM_FORMAT_S16_LE: - rtd->xfer_resolution = 0x02; - break; - case SNDRV_PCM_FORMAT_S24_LE: - rtd->xfer_resolution = 0x04; - break; - case SNDRV_PCM_FORMAT_S32_LE: - rtd->xfer_resolution = 0x05; - break; - default: - return -EINVAL; - } - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | (rtd->xfer_resolution << 3); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - else - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - - return 0; -} - -static int acp3x_dai_i2s_trigger(struct snd_pcm_substream *substream, - int cmd, struct snd_soc_dai *dai) -{ - int ret = 0; - struct i2s_stream_instance *rtd = substream->runtime->private_data; - u32 val, period_bytes; - - period_bytes = frames_to_bytes(substream->runtime, - substream->runtime->period_size); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - rtd->bytescount = acp_get_byte_count(rtd, substream->stream); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_TX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - } else { - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_RX_INTR_WATERMARK_SIZE); - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val | BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - } - rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_ITER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_ITER); - } else { - val = rv_readl(rtd->acp3x_base + mmACP_BTTDM_IRER); - val = val & ~BIT(0); - rv_writel(val, rtd->acp3x_base + mmACP_BTTDM_IRER); - } - rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static struct snd_soc_dai_ops acp3x_dai_i2s_ops = { - .hw_params = acp3x_dai_i2s_hwparams, - .trigger = acp3x_dai_i2s_trigger, - .set_fmt = acp3x_dai_i2s_set_fmt, - .set_tdm_slot = acp3x_dai_set_tdm_slot, -}; - -static struct snd_soc_dai_driver acp3x_i2s_dai_driver = { - .playback = { - .rates = SNDRV_PCM_RATE_8000_96000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_U8 | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .channels_min = 2, - .channels_max = 8, - - .rate_min = 8000, - .rate_max = 96000, - }, - .capture = { - .rates = SNDRV_PCM_RATE_8000_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | - SNDRV_PCM_FMTBIT_U8 | - SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .channels_min = 2, - .channels_max = 2, - .rate_min = 8000, - .rate_max = 48000, - }, - .ops = &acp3x_dai_i2s_ops, -}; - static const struct snd_soc_component_driver acp3x_i2s_component = { .name = DRV_NAME, .open = acp3x_dma_open, @@ -590,10 +388,10 @@ static const struct snd_soc_component_driver acp3x_i2s_component = { static int acp3x_audio_probe(struct platform_device *pdev) { - int status; struct resource *res; struct i2s_dev_data *adata; unsigned int irqflags; + int status, ret; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "platform_data not retrieved\n"); @@ -603,7 +401,7 @@ static int acp3x_audio_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n"); + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n"); return -ENODEV; } @@ -613,6 +411,8 @@ static int acp3x_audio_probe(struct platform_device *pdev) adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!adata->acp3x_base) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { @@ -621,52 +421,54 @@ static int acp3x_audio_probe(struct platform_device *pdev) } adata->i2s_irq = res->start; - adata->play_stream = NULL; - adata->capture_stream = NULL; dev_set_drvdata(&pdev->dev, adata); /* Initialize ACP */ status = acp3x_init(adata->acp3x_base); if (status) return -ENODEV; + status = devm_snd_soc_register_component(&pdev->dev, &acp3x_i2s_component, - &acp3x_i2s_dai_driver, 1); + NULL, 0); if (status) { - dev_err(&pdev->dev, "Fail to register acp i2s dai\n"); + dev_err(&pdev->dev, "Fail to register acp i2s component\n"); + ret = -ENODEV; goto dev_err; } status = devm_request_irq(&pdev->dev, adata->i2s_irq, i2s_irq_handler, irqflags, "ACP3x_I2S_IRQ", adata); if (status) { dev_err(&pdev->dev, "ACP3x I2S IRQ request failed\n"); + ret = -ENODEV; goto dev_err; } - pm_runtime_set_autosuspend_delay(&pdev->dev, 10000); + pm_runtime_set_autosuspend_delay(&pdev->dev, 5000); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; + dev_err: status = acp3x_deinit(adata->acp3x_base); if (status) dev_err(&pdev->dev, "ACP de-init failed\n"); else - dev_info(&pdev->dev, "ACP de-initialized\n"); - /*ignore device status and return driver probe error*/ - return -ENODEV; + dev_dbg(&pdev->dev, "ACP de-initialized\n"); + return ret; } static int acp3x_audio_remove(struct platform_device *pdev) { + struct i2s_dev_data *adata; int ret; - struct i2s_dev_data *adata = dev_get_drvdata(&pdev->dev); + adata = dev_get_drvdata(&pdev->dev); ret = acp3x_deinit(adata->acp3x_base); if (ret) dev_err(&pdev->dev, "ACP de-init failed\n"); else - dev_info(&pdev->dev, "ACP de-initialized\n"); + dev_dbg(&pdev->dev, "ACP de-initialized\n"); pm_runtime_disable(&pdev->dev); return 0; @@ -674,10 +476,11 @@ static int acp3x_audio_remove(struct platform_device *pdev) static int acp3x_resume(struct device *dev) { + struct i2s_dev_data *adata; int status; u32 val; - struct i2s_dev_data *adata = dev_get_drvdata(dev); + adata = dev_get_drvdata(dev); status = acp3x_init(adata->acp3x_base); if (status) return -ENODEV; @@ -719,14 +522,15 @@ static int acp3x_resume(struct device *dev) static int acp3x_pcm_runtime_suspend(struct device *dev) { + struct i2s_dev_data *adata; int status; - struct i2s_dev_data *adata = dev_get_drvdata(dev); + adata = dev_get_drvdata(dev); status = acp3x_deinit(adata->acp3x_base); if (status) dev_err(dev, "ACP de-init failed\n"); else - dev_info(dev, "ACP de-initialized\n"); + dev_dbg(dev, "ACP de-initialized\n"); rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); @@ -735,8 +539,9 @@ static int acp3x_pcm_runtime_suspend(struct device *dev) static int acp3x_pcm_runtime_resume(struct device *dev) { + struct i2s_dev_data *adata; int status; - struct i2s_dev_data *adata = dev_get_drvdata(dev); + adata = dev_get_drvdata(dev); status = acp3x_init(adata->acp3x_base); if (status) @@ -755,13 +560,14 @@ static struct platform_driver acp3x_dma_driver = { .probe = acp3x_audio_probe, .remove = acp3x_audio_remove, .driver = { - .name = "acp3x_rv_i2s", + .name = "acp3x_rv_i2s_dma", .pm = &acp3x_pm_ops, }, }; module_platform_driver(acp3x_dma_driver); +MODULE_AUTHOR("Vishnuvardhanrao.Ravulapati@amd.com"); MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com"); MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); MODULE_DESCRIPTION("AMD ACP 3.x PCM Driver"); diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index 2f15fe10ead5..a1f03fce68fa 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -6,6 +6,7 @@ */ #include "chip_offset_byte.h" +#include #define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 @@ -51,6 +52,30 @@ #define SLOT_WIDTH_24 0x18 #define SLOT_WIDTH_32 0x20 +struct acp3x_platform_info { + u16 play_i2s_instance; + u16 cap_i2s_instance; + u16 capture_channel; +}; + +struct i2s_dev_data { + bool tdm_mode; + unsigned int i2s_irq; + u32 tdm_fmt; + u32 substream_type; + void __iomem *acp3x_base; + struct snd_pcm_substream *play_stream; + struct snd_pcm_substream *capture_stream; +}; + +struct i2s_stream_instance { + u16 num_pages; + u16 channels; + u32 xfer_resolution; + u64 bytescount; + dma_addr_t dma_addr; + void __iomem *acp3x_base; +}; static inline u32 rv_readl(void __iomem *base_addr) { @@ -61,3 +86,22 @@ static inline void rv_writel(u32 val, void __iomem *base_addr) { writel(val, base_addr - ACP3x_PHY_BASE_ADDRESS); } + +static inline u64 acp_get_byte_count(struct i2s_stream_instance *rtd, + int direction) +{ + u64 byte_count; + + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); + } else { + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); + } + return byte_count; +} -- cgit v1.2.3 From 703a6e22888be41531461ad99ff6c25cd54a5ddf Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:10:56 +0530 Subject: ASoC: amd: Enabling I2S instance in DMA and DAI This patch adds I2S SP support in ACP PCM DMA and DAI. Added I2S support in DMA and DAI probe,its hw_params handling its open and close functionalities. This enables to open and close on the SP instance for playback and capture. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-3-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-i2s.c | 123 ++++++++++++++++---- sound/soc/amd/raven/acp3x-pcm-dma.c | 217 +++++++++++++++++++++++++----------- sound/soc/amd/raven/acp3x.h | 76 ++++++++++--- 3 files changed, 312 insertions(+), 104 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c index d9bc0fc63185..368e4c855268 100644 --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -27,10 +27,10 @@ static int acp3x_i2s_set_fmt(struct snd_soc_dai *cpu_dai, mode = fmt & SND_SOC_DAIFMT_FORMAT_MASK; switch (mode) { case SND_SOC_DAIFMT_I2S: - adata->tdm_mode = false; + adata->tdm_mode = TDM_DISABLE; break; case SND_SOC_DAIFMT_DSP_A: - adata->tdm_mode = true; + adata->tdm_mode = TDM_ENABLE; break; default: return -EINVAL; @@ -86,10 +86,22 @@ static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct i2s_stream_instance *rtd; + struct snd_soc_pcm_runtime *prtd; + struct snd_soc_card *card; + struct acp3x_platform_info *pinfo; u32 val; u32 reg_val; + prtd = substream->private_data; rtd = substream->runtime->private_data; + card = prtd->card; + pinfo = snd_soc_card_get_drvdata(card); + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } /* These values are as per Hardware Spec */ switch (params_format(params)) { @@ -109,11 +121,25 @@ static int acp3x_i2s_hwparams(struct snd_pcm_substream *substream, default: return -EINVAL; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - reg_val = mmACP_BTTDM_ITER; - else - reg_val = mmACP_BTTDM_IRER; - + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_ITER; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_ITER; + } + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_IRER; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_IRER; + } + } val = rv_readl(rtd->acp3x_base + reg_val); val = val | (rtd->xfer_resolution << 3); rv_writel(val, rtd->acp3x_base + reg_val); @@ -124,10 +150,21 @@ static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct i2s_stream_instance *rtd; - u32 val, period_bytes; - int ret, reg_val; + struct snd_soc_pcm_runtime *prtd; + struct snd_soc_card *card; + struct acp3x_platform_info *pinfo; + u32 ret, val, period_bytes, reg_val, ier_val, water_val; + prtd = substream->private_data; rtd = substream->runtime->private_data; + card = prtd->card; + pinfo = snd_soc_card_get_drvdata(card); + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } period_bytes = frames_to_bytes(substream->runtime, substream->runtime->period_size); switch (cmd) { @@ -137,31 +174,75 @@ static int acp3x_i2s_trigger(struct snd_pcm_substream *substream, rtd->bytescount = acp_get_byte_count(rtd, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - reg_val = mmACP_BTTDM_ITER; - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_TX_INTR_WATERMARK_SIZE); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + water_val = + mmACP_BT_TX_INTR_WATERMARK_SIZE; + reg_val = mmACP_BTTDM_ITER; + ier_val = mmACP_BTTDM_IER; + break; + case I2S_SP_INSTANCE: + default: + water_val = + mmACP_I2S_TX_INTR_WATERMARK_SIZE; + reg_val = mmACP_I2STDM_ITER; + ier_val = mmACP_I2STDM_IER; + } } else { - reg_val = mmACP_BTTDM_IRER; - rv_writel(period_bytes, rtd->acp3x_base + - mmACP_BT_RX_INTR_WATERMARK_SIZE); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + water_val = + mmACP_BT_RX_INTR_WATERMARK_SIZE; + reg_val = mmACP_BTTDM_IRER; + ier_val = mmACP_BTTDM_IER; + break; + case I2S_SP_INSTANCE: + default: + water_val = + mmACP_I2S_RX_INTR_WATERMARK_SIZE; + reg_val = mmACP_I2STDM_IRER; + ier_val = mmACP_I2STDM_IER; + } } + rv_writel(period_bytes, rtd->acp3x_base + water_val); val = rv_readl(rtd->acp3x_base + reg_val); val = val | BIT(0); rv_writel(val, rtd->acp3x_base + reg_val); - rv_writel(1, rtd->acp3x_base + mmACP_BTTDM_IER); + rv_writel(1, rtd->acp3x_base + ier_val); + ret = 0; break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - reg_val = mmACP_BTTDM_ITER; - else - reg_val = mmACP_BTTDM_IRER; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_ITER; + ier_val = mmACP_BTTDM_IER; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_ITER; + ier_val = mmACP_I2STDM_IER; + } + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_IRER; + ier_val = mmACP_BTTDM_IER; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_IRER; + ier_val = mmACP_I2STDM_IER; + } + } val = rv_readl(rtd->acp3x_base + reg_val); val = val & ~BIT(0); rv_writel(val, rtd->acp3x_base + reg_val); - rv_writel(0, rtd->acp3x_base + mmACP_BTTDM_IER); + rv_writel(0, rtd->acp3x_base + ier_val); + ret = 0; break; default: ret = -EINVAL; diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 9f6ea3ef2441..040a8be593f0 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -193,15 +193,31 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction) { u16 page_idx; - u32 low, high, val, acp_fifo_addr; - dma_addr_t addr = rtd->dma_addr; + u32 low, high, val, acp_fifo_addr, reg_fifo_addr; + u32 reg_ringbuf_size, reg_dma_size, reg_fifo_size; + dma_addr_t addr; - /* 8 scratch registers used to map one 64 bit address */ - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - val = 0; - else - val = rtd->num_pages * 8; + addr = rtd->dma_addr; + if (direction == SNDRV_PCM_STREAM_PLAYBACK) { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = ACP_SRAM_BT_PB_PTE_OFFSET; + break; + case I2S_SP_INSTANCE: + default: + val = ACP_SRAM_SP_PB_PTE_OFFSET; + } + } else { + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + val = ACP_SRAM_BT_CP_PTE_OFFSET; + break; + case I2S_SP_INSTANCE: + default: + val = ACP_SRAM_SP_CP_PTE_OFFSET; + } + } /* Group Enable */ rv_writel(ACP_SRAM_PTE_OFFSET | BIT(31), rtd->acp3x_base + mmACPAXI2AXI_ATU_BASE_ADDR_GRP_1); @@ -223,38 +239,61 @@ static void config_acp3x_dma(struct i2s_stream_instance *rtd, int direction) } if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - /* Config ringbuffer */ - rv_writel(MEM_WINDOW_START, rtd->acp3x_base + - mmACP_BT_TX_RINGBUFADDR); - rv_writel(MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_TX_RINGBUFSIZE); - rv_writel(DMA_SIZE, rtd->acp3x_base + mmACP_BT_TX_DMA_SIZE); - - /* Config audio fifo */ - acp_fifo_addr = ACP_SRAM_PTE_OFFSET + (rtd->num_pages * 8) - + PLAYBACK_FIFO_ADDR_OFFSET; - rv_writel(acp_fifo_addr, rtd->acp3x_base + - mmACP_BT_TX_FIFOADDR); - rv_writel(FIFO_SIZE, rtd->acp3x_base + mmACP_BT_TX_FIFOSIZE); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_ringbuf_size = mmACP_BT_TX_RINGBUFSIZE; + reg_dma_size = mmACP_BT_TX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_PB_FIFO_ADDR_OFFSET; + reg_fifo_addr = mmACP_BT_TX_FIFOADDR; + reg_fifo_size = mmACP_BT_TX_FIFOSIZE; + rv_writel(I2S_BT_TX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_BT_TX_RINGBUFADDR); + break; + + case I2S_SP_INSTANCE: + default: + reg_ringbuf_size = mmACP_I2S_TX_RINGBUFSIZE; + reg_dma_size = mmACP_I2S_TX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_PB_FIFO_ADDR_OFFSET; + reg_fifo_addr = mmACP_I2S_TX_FIFOADDR; + reg_fifo_size = mmACP_I2S_TX_FIFOSIZE; + rv_writel(I2S_SP_TX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_I2S_TX_RINGBUFADDR); + } } else { - /* Config ringbuffer */ - rv_writel(MEM_WINDOW_START + MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_RX_RINGBUFADDR); - rv_writel(MAX_BUFFER, rtd->acp3x_base + - mmACP_BT_RX_RINGBUFSIZE); - rv_writel(DMA_SIZE, rtd->acp3x_base + mmACP_BT_RX_DMA_SIZE); - - /* Config audio fifo */ - acp_fifo_addr = ACP_SRAM_PTE_OFFSET + - (rtd->num_pages * 8) + CAPTURE_FIFO_ADDR_OFFSET; - rv_writel(acp_fifo_addr, rtd->acp3x_base + - mmACP_BT_RX_FIFOADDR); - rv_writel(FIFO_SIZE, rtd->acp3x_base + mmACP_BT_RX_FIFOSIZE); - } + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_ringbuf_size = mmACP_BT_RX_RINGBUFSIZE; + reg_dma_size = mmACP_BT_RX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + BT_CAPT_FIFO_ADDR_OFFSET; + reg_fifo_addr = mmACP_BT_RX_FIFOADDR; + reg_fifo_size = mmACP_BT_RX_FIFOSIZE; + rv_writel(I2S_BT_RX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_BT_RX_RINGBUFADDR); + break; - /* Enable watermark/period interrupt to host */ - rv_writel(BIT(BT_TX_THRESHOLD) | BIT(BT_RX_THRESHOLD), - rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); + case I2S_SP_INSTANCE: + default: + reg_ringbuf_size = mmACP_I2S_RX_RINGBUFSIZE; + reg_dma_size = mmACP_I2S_RX_DMA_SIZE; + acp_fifo_addr = ACP_SRAM_PTE_OFFSET + + SP_CAPT_FIFO_ADDR_OFFSET; + reg_fifo_addr = mmACP_I2S_RX_FIFOADDR; + reg_fifo_size = mmACP_I2S_RX_FIFOSIZE; + rv_writel(I2S_SP_RX_MEM_WINDOW_START, + rtd->acp3x_base + mmACP_I2S_RX_RINGBUFADDR); + } + } + rv_writel(MAX_BUFFER, rtd->acp3x_base + reg_ringbuf_size); + rv_writel(DMA_SIZE, rtd->acp3x_base + reg_dma_size); + rv_writel(acp_fifo_addr, rtd->acp3x_base + reg_fifo_addr); + rv_writel(FIFO_SIZE, rtd->acp3x_base + reg_fifo_size); + rv_writel(BIT(I2S_RX_THRESHOLD) | BIT(BT_RX_THRESHOLD) + | BIT(I2S_TX_THRESHOLD) | BIT(BT_TX_THRESHOLD), + rtd->acp3x_base + mmACP_EXTERNAL_INTR_CNTL); } static int acp3x_dma_open(struct snd_soc_component *component, @@ -287,17 +326,21 @@ static int acp3x_dma_open(struct snd_soc_component *component, return ret; } - if (!adata->play_stream && !adata->capture_stream) + if (!adata->play_stream && !adata->capture_stream && + adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { adata->play_stream = substream; - else + adata->i2ssp_play_stream = substream; + } else { adata->capture_stream = substream; + adata->i2ssp_capture_stream = substream; + } i2s_data->acp3x_base = adata->acp3x_base; runtime->private_data = i2s_data; - return 0; + return ret; } @@ -305,13 +348,27 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { + struct i2s_stream_instance *rtd; + struct snd_soc_pcm_runtime *prtd; + struct snd_soc_card *card; + struct acp3x_platform_info *pinfo; u64 size; - struct snd_pcm_runtime *runtime = substream->runtime; - struct i2s_stream_instance *rtd = runtime->private_data; + prtd = substream->private_data; + card = prtd->card; + pinfo = snd_soc_card_get_drvdata(card); + rtd = substream->runtime->private_data; if (!rtd) return -EINVAL; + if (pinfo) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + else + pr_err("pinfo failed\n"); + size = params_buffer_bytes(params); rtd->dma_addr = substream->dma_buffer.addr; rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT); @@ -322,12 +379,25 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component, static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_soc_component *component, struct snd_pcm_substream *substream) { + struct snd_soc_pcm_runtime *prtd; + struct snd_soc_card *card; + struct acp3x_platform_info *pinfo; struct i2s_stream_instance *rtd; u32 pos; u32 buffersize; u64 bytescount; + prtd = substream->private_data; + card = prtd->card; rtd = substream->runtime->private_data; + pinfo = snd_soc_card_get_drvdata(card); + if (pinfo) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + rtd->i2s_instance = pinfo->play_i2s_instance; + else + rtd->i2s_instance = pinfo->cap_i2s_instance; + } + buffersize = frames_to_bytes(substream->runtime, substream->runtime->buffer_size); bytescount = acp_get_byte_count(rtd, substream->stream); @@ -363,15 +433,19 @@ static int acp3x_dma_close(struct snd_soc_component *component, component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); adata = dev_get_drvdata(component->dev); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { adata->play_stream = NULL; - else + adata->i2ssp_play_stream = NULL; + } else { adata->capture_stream = NULL; + adata->i2ssp_capture_stream = NULL; + } /* Disable ACP irq, when the current stream is being closed and * another stream is also not active. */ - if (!adata->play_stream && !adata->capture_stream) + if (!adata->play_stream && !adata->capture_stream && + !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); return 0; } @@ -478,8 +552,10 @@ static int acp3x_resume(struct device *dev) { struct i2s_dev_data *adata; int status; - u32 val; + u32 val, reg_val, frmt_val; + reg_val = 0; + frmt_val = 0; adata = dev_get_drvdata(dev); status = acp3x_init(adata->acp3x_base); if (status) @@ -489,32 +565,39 @@ static int acp3x_resume(struct device *dev) struct i2s_stream_instance *rtd = adata->play_stream->runtime->private_data; config_acp3x_dma(rtd, SNDRV_PCM_STREAM_PLAYBACK); - rv_writel((rtd->xfer_resolution << 3), - rtd->acp3x_base + mmACP_BTTDM_ITER); - if (adata->tdm_mode == true) { - rv_writel(adata->tdm_fmt, adata->acp3x_base + - mmACP_BTTDM_TXFRMT); - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_ITER); - rv_writel((val | 0x2), adata->acp3x_base + - mmACP_BTTDM_ITER); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_ITER; + frmt_val = mmACP_BTTDM_TXFRMT; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_ITER; + frmt_val = mmACP_I2STDM_TXFRMT; } + rv_writel((rtd->xfer_resolution << 3), rtd->acp3x_base + reg_val); } - if (adata->capture_stream && adata->capture_stream->runtime) { struct i2s_stream_instance *rtd = adata->capture_stream->runtime->private_data; config_acp3x_dma(rtd, SNDRV_PCM_STREAM_CAPTURE); - rv_writel((rtd->xfer_resolution << 3), - rtd->acp3x_base + mmACP_BTTDM_IRER); - if (adata->tdm_mode == true) { - rv_writel(adata->tdm_fmt, adata->acp3x_base + - mmACP_BTTDM_RXFRMT); - val = rv_readl(adata->acp3x_base + mmACP_BTTDM_IRER); - rv_writel((val | 0x2), adata->acp3x_base + - mmACP_BTTDM_IRER); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_IRER; + frmt_val = mmACP_BTTDM_RXFRMT; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_IRER; + frmt_val = mmACP_I2STDM_RXFRMT; } + rv_writel((rtd->xfer_resolution << 3), rtd->acp3x_base + reg_val); + } + if (adata->tdm_mode == TDM_ENABLE) { + rv_writel(adata->tdm_fmt, adata->acp3x_base + frmt_val); + val = rv_readl(adata->acp3x_base + reg_val); + rv_writel(val | 0x2, adata->acp3x_base + reg_val); } - rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); return 0; } @@ -524,8 +607,8 @@ static int acp3x_pcm_runtime_suspend(struct device *dev) { struct i2s_dev_data *adata; int status; - adata = dev_get_drvdata(dev); + adata = dev_get_drvdata(dev); status = acp3x_deinit(adata->acp3x_base); if (status) dev_err(dev, "ACP de-init failed\n"); @@ -541,8 +624,8 @@ static int acp3x_pcm_runtime_resume(struct device *dev) { struct i2s_dev_data *adata; int status; - adata = dev_get_drvdata(dev); + adata = dev_get_drvdata(dev); status = acp3x_init(adata->acp3x_base); if (status) return -ENODEV; diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index a1f03fce68fa..a1cdc4e768e2 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -7,6 +7,11 @@ #include "chip_offset_byte.h" #include +#define I2S_SP_INSTANCE 0x01 +#define I2S_BT_INSTANCE 0x02 + +#define TDM_ENABLE 1 +#define TDM_DISABLE 0 #define ACP3x_DEVS 3 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 @@ -18,8 +23,11 @@ #define ACP3x_BT_TDM_REG_START 0x1242800 #define ACP3x_BT_TDM_REG_END 0x1242810 #define I2S_MODE 0x04 +#define I2S_RX_THRESHOLD 27 +#define I2S_TX_THRESHOLD 28 #define BT_TX_THRESHOLD 26 #define BT_RX_THRESHOLD 25 +#define ACP_ERR_INTR_MASK 29 #define ACP3x_POWER_ON 0x00 #define ACP3x_POWER_ON_IN_PROGRESS 0x01 #define ACP3x_POWER_OFF 0x02 @@ -27,19 +35,28 @@ #define ACP3x_SOFT_RESET__SoftResetAudDone_MASK 0x00010001 #define ACP_SRAM_PTE_OFFSET 0x02050000 +#define ACP_SRAM_SP_PB_PTE_OFFSET 0x0 +#define ACP_SRAM_SP_CP_PTE_OFFSET 0x100 +#define ACP_SRAM_BT_PB_PTE_OFFSET 0x200 +#define ACP_SRAM_BT_CP_PTE_OFFSET 0x300 #define PAGE_SIZE_4K_ENABLE 0x2 -#define MEM_WINDOW_START 0x4000000 -#define PLAYBACK_FIFO_ADDR_OFFSET 0x400 -#define CAPTURE_FIFO_ADDR_OFFSET 0x500 +#define I2S_SP_TX_MEM_WINDOW_START 0x4000000 +#define I2S_SP_RX_MEM_WINDOW_START 0x4020000 +#define I2S_BT_TX_MEM_WINDOW_START 0x4040000 +#define I2S_BT_RX_MEM_WINDOW_START 0x4060000 +#define SP_PB_FIFO_ADDR_OFFSET 0x500 +#define SP_CAPT_FIFO_ADDR_OFFSET 0x700 +#define BT_PB_FIFO_ADDR_OFFSET 0x900 +#define BT_CAPT_FIFO_ADDR_OFFSET 0xB00 #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 8 -#define PLAYBACK_MAX_PERIOD_SIZE 16384 -#define PLAYBACK_MIN_PERIOD_SIZE 4096 +#define PLAYBACK_MAX_PERIOD_SIZE 8192 +#define PLAYBACK_MIN_PERIOD_SIZE 1024 #define CAPTURE_MIN_NUM_PERIODS 2 #define CAPTURE_MAX_NUM_PERIODS 8 -#define CAPTURE_MAX_PERIOD_SIZE 16384 -#define CAPTURE_MIN_PERIOD_SIZE 4096 +#define CAPTURE_MAX_PERIOD_SIZE 8192 +#define CAPTURE_MIN_PERIOD_SIZE 1024 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS) #define MIN_BUFFER MAX_BUFFER @@ -66,14 +83,20 @@ struct i2s_dev_data { void __iomem *acp3x_base; struct snd_pcm_substream *play_stream; struct snd_pcm_substream *capture_stream; + struct snd_pcm_substream *i2ssp_play_stream; + struct snd_pcm_substream *i2ssp_capture_stream; }; struct i2s_stream_instance { u16 num_pages; + u16 i2s_instance; + u16 capture_channel; + u16 direction; u16 channels; u32 xfer_resolution; - u64 bytescount; + u32 val; dma_addr_t dma_addr; + u64 bytescount; void __iomem *acp3x_base; }; @@ -93,15 +116,36 @@ static inline u64 acp_get_byte_count(struct i2s_stream_instance *rtd, u64 byte_count; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_TX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + default: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_I2S_TX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_I2S_TX_LINEARPOSITIONCNTR_LOW); + } + } else { - byte_count = rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); - byte_count |= rv_readl(rtd->acp3x_base + - mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); + switch (rtd->i2s_instance) { + case I2S_BT_INSTANCE: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_BT_RX_LINEARPOSITIONCNTR_LOW); + break; + case I2S_SP_INSTANCE: + default: + byte_count = rv_readl(rtd->acp3x_base + + mmACP_I2S_RX_LINEARPOSITIONCNTR_HIGH); + byte_count |= rv_readl(rtd->acp3x_base + + mmACP_I2S_RX_LINEARPOSITIONCNTR_LOW); + } } return byte_count; } -- cgit v1.2.3 From a43ea44ddda94bc6c4dbe257fcbdeecde8cb06f1 Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:10:57 +0530 Subject: ASoC: amd: add ACP3x TDM mode support ACP3x I2S (CPU DAI) can act in normal I2S and TDM modes. Added support for TDM mode. Desired mode can be selected from ASoC machine driver. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-4-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-i2s.c | 28 ++++++++++++++++++++++------ sound/soc/amd/raven/acp3x.h | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c index 368e4c855268..d9b287b8396c 100644 --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -42,7 +42,7 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, u32 rx_mask, int slots, int slot_width) { struct i2s_dev_data *adata; - u32 val, reg_val, frmt_val, frm_len; + u32 val, reg_val, frmt_reg, frm_len; u16 slot_len; adata = snd_soc_dai_get_drvdata(cpu_dai); @@ -69,15 +69,31 @@ static int acp3x_i2s_set_tdm_slot(struct snd_soc_dai *cpu_dai, frm_len = FRM_LEN | (slots << 15) | (slot_len << 18); if (adata->substream_type == SNDRV_PCM_STREAM_PLAYBACK) { - reg_val = mmACP_BTTDM_ITER; - frmt_val = mmACP_BTTDM_TXFRMT; + switch (adata->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_ITER; + frmt_reg = mmACP_BTTDM_TXFRMT; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_ITER; + frmt_reg = mmACP_I2STDM_TXFRMT; + } } else { - reg_val = mmACP_BTTDM_IRER; - frmt_val = mmACP_BTTDM_RXFRMT; + switch (adata->i2s_instance) { + case I2S_BT_INSTANCE: + reg_val = mmACP_BTTDM_IRER; + frmt_reg = mmACP_BTTDM_RXFRMT; + break; + case I2S_SP_INSTANCE: + default: + reg_val = mmACP_I2STDM_IRER; + frmt_reg = mmACP_I2STDM_RXFRMT; + } } val = rv_readl(adata->acp3x_base + reg_val); rv_writel(val | 0x2, adata->acp3x_base + reg_val); - rv_writel(frm_len, adata->acp3x_base + frmt_val); + rv_writel(frm_len, adata->acp3x_base + frmt_reg); adata->tdm_fmt = frm_len; return 0; } diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index a1cdc4e768e2..43213aec7f59 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -78,6 +78,7 @@ struct acp3x_platform_info { struct i2s_dev_data { bool tdm_mode; unsigned int i2s_irq; + u16 i2s_instance; u32 tdm_fmt; u32 substream_type; void __iomem *acp3x_base; -- cgit v1.2.3 From cea5f40d4e7ae711622ba7ee3caa60c315f101c0 Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:10:58 +0530 Subject: ASoC: amd: Handle ACP3x I2S-SP Interrupts. Enabled support for I2S-SP interrupt handling. Previous to this implementation, driver supports only interrupts on BT instance. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-5-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-pcm-dma.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 040a8be593f0..c5d7f3558867 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -176,6 +176,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(rv_i2s_data->play_stream); play_flag = 1; } + if ((val & BIT(I2S_TX_THRESHOLD)) && + rv_i2s_data->i2ssp_play_stream) { + rv_writel(BIT(I2S_TX_THRESHOLD), + rv_i2s_data->acp3x_base + mmACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(rv_i2s_data->i2ssp_play_stream); + play_flag = 1; + } if ((val & BIT(BT_RX_THRESHOLD)) && rv_i2s_data->capture_stream) { rv_writel(BIT(BT_RX_THRESHOLD), rv_i2s_data->acp3x_base + @@ -183,6 +190,13 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) snd_pcm_period_elapsed(rv_i2s_data->capture_stream); cap_flag = 1; } + if ((val & BIT(I2S_RX_THRESHOLD)) && + rv_i2s_data->i2ssp_capture_stream) { + rv_writel(BIT(I2S_RX_THRESHOLD), + rv_i2s_data->acp3x_base + mmACP_EXTERNAL_INTR_STAT); + snd_pcm_period_elapsed(rv_i2s_data->i2ssp_capture_stream); + cap_flag = 1; + } if (play_flag | cap_flag) return IRQ_HANDLED; -- cgit v1.2.3 From 535fd141ef346a3851f6aabc3eacb0d46518eca3 Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:10:59 +0530 Subject: ASoC: amd: Added ACP3x system resume and runtime pm When system wide suspend happens, ACP will be powered off and when system resumes,for audio usecase to continue,all the runtime configuration data needs to be programmed again. Added resume pm call back to ACP pm ops and also added runtime PM operations for ACP3x PCM platform device. Device will enter into D3 state when there is no activity on audio I2S lines. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-6-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-pcm-dma.c | 149 ++----------------------------- sound/soc/amd/raven/acp3x.h | 7 ++ sound/soc/amd/raven/pci-acp3x.c | 173 ++++++++++++++++++++++++++++++++++-- 3 files changed, 180 insertions(+), 149 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index c5d7f3558867..151daa996343 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -57,106 +57,6 @@ static const struct snd_pcm_hardware acp3x_pcm_hardware_capture = { .periods_max = CAPTURE_MAX_NUM_PERIODS, }; -static int acp3x_power_on(void __iomem *acp3x_base, bool on) -{ - u16 val, mask; - u32 timeout; - - if (on == true) { - val = 1; - mask = ACP3x_POWER_ON; - } else { - val = 0; - mask = ACP3x_POWER_OFF; - } - - rv_writel(val, acp3x_base + mmACP_PGFSM_CONTROL); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); - if ((val & ACP3x_POWER_OFF_IN_PROGRESS) == mask) - break; - if (timeout > 100) { - pr_err("ACP3x power state change failure\n"); - return -ENODEV; - } - timeout++; - cpu_relax(); - } - return 0; -} - -static int acp3x_reset(void __iomem *acp3x_base) -{ - u32 val, timeout; - - rv_writel(1, acp3x_base + mmACP_SOFT_RESET); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_SOFT_RESET); - if ((val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) || - timeout > 100) { - if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) - break; - return -ENODEV; - } - timeout++; - cpu_relax(); - } - - rv_writel(0, acp3x_base + mmACP_SOFT_RESET); - timeout = 0; - while (true) { - val = rv_readl(acp3x_base + mmACP_SOFT_RESET); - if (!val || timeout > 100) { - if (!val) - break; - return -ENODEV; - } - timeout++; - cpu_relax(); - } - return 0; -} - -static int acp3x_init(void __iomem *acp3x_base) -{ - int ret; - - /* power on */ - ret = acp3x_power_on(acp3x_base, true); - if (ret) { - pr_err("ACP3x power on failed\n"); - return ret; - } - /* Reset */ - ret = acp3x_reset(acp3x_base); - if (ret) { - pr_err("ACP3x reset failed\n"); - return ret; - } - return 0; -} - -static int acp3x_deinit(void __iomem *acp3x_base) -{ - int ret; - - /* Reset */ - ret = acp3x_reset(acp3x_base); - if (ret) { - pr_err("ACP3x reset failed\n"); - return ret; - } - /* power off */ - ret = acp3x_power_on(acp3x_base, false); - if (ret) { - pr_err("ACP3x power off failed\n"); - return ret; - } - return 0; -} - static irqreturn_t i2s_irq_handler(int irq, void *dev_id) { struct i2s_dev_data *rv_i2s_data; @@ -479,7 +379,7 @@ static int acp3x_audio_probe(struct platform_device *pdev) struct resource *res; struct i2s_dev_data *adata; unsigned int irqflags; - int status, ret; + int status; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "platform_data not retrieved\n"); @@ -511,53 +411,29 @@ static int acp3x_audio_probe(struct platform_device *pdev) adata->i2s_irq = res->start; dev_set_drvdata(&pdev->dev, adata); - /* Initialize ACP */ - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; - status = devm_snd_soc_register_component(&pdev->dev, &acp3x_i2s_component, NULL, 0); if (status) { dev_err(&pdev->dev, "Fail to register acp i2s component\n"); - ret = -ENODEV; - goto dev_err; + return -ENODEV; } status = devm_request_irq(&pdev->dev, adata->i2s_irq, i2s_irq_handler, irqflags, "ACP3x_I2S_IRQ", adata); if (status) { dev_err(&pdev->dev, "ACP3x I2S IRQ request failed\n"); - ret = -ENODEV; - goto dev_err; + return -ENODEV; } - pm_runtime_set_autosuspend_delay(&pdev->dev, 5000); + pm_runtime_set_autosuspend_delay(&pdev->dev, 2000); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); + pm_runtime_allow(&pdev->dev); return 0; - -dev_err: - status = acp3x_deinit(adata->acp3x_base); - if (status) - dev_err(&pdev->dev, "ACP de-init failed\n"); - else - dev_dbg(&pdev->dev, "ACP de-initialized\n"); - return ret; } static int acp3x_audio_remove(struct platform_device *pdev) { - struct i2s_dev_data *adata; - int ret; - - adata = dev_get_drvdata(&pdev->dev); - ret = acp3x_deinit(adata->acp3x_base); - if (ret) - dev_err(&pdev->dev, "ACP de-init failed\n"); - else - dev_dbg(&pdev->dev, "ACP de-initialized\n"); - pm_runtime_disable(&pdev->dev); return 0; } @@ -565,15 +441,11 @@ static int acp3x_audio_remove(struct platform_device *pdev) static int acp3x_resume(struct device *dev) { struct i2s_dev_data *adata; - int status; u32 val, reg_val, frmt_val; reg_val = 0; frmt_val = 0; adata = dev_get_drvdata(dev); - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; if (adata->play_stream && adata->play_stream->runtime) { struct i2s_stream_instance *rtd = @@ -620,14 +492,8 @@ static int acp3x_resume(struct device *dev) static int acp3x_pcm_runtime_suspend(struct device *dev) { struct i2s_dev_data *adata; - int status; adata = dev_get_drvdata(dev); - status = acp3x_deinit(adata->acp3x_base); - if (status) - dev_err(dev, "ACP de-init failed\n"); - else - dev_dbg(dev, "ACP de-initialized\n"); rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); @@ -637,12 +503,9 @@ static int acp3x_pcm_runtime_suspend(struct device *dev) static int acp3x_pcm_runtime_resume(struct device *dev) { struct i2s_dev_data *adata; - int status; adata = dev_get_drvdata(dev); - status = acp3x_init(adata->acp3x_base); - if (status) - return -ENODEV; + rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); return 0; } diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index 43213aec7f59..b6a80dc0b641 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -68,6 +68,13 @@ #define SLOT_WIDTH_16 0x10 #define SLOT_WIDTH_24 0x18 #define SLOT_WIDTH_32 0x20 +#define ACP_PGFSM_CNTL_POWER_ON_MASK 0x01 +#define ACP_PGFSM_CNTL_POWER_OFF_MASK 0x00 +#define ACP_PGFSM_STATUS_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_POWER_ON_IN_PROGRESS 0x01 +#define ACP_POWERED_OFF 0x02 +#define ACP_POWER_OFF_IN_PROGRESS 0x03 struct acp3x_platform_info { u16 play_i2s_instance; diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index 94f5f21d9a53..2f9f52905853 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "acp3x.h" @@ -19,6 +21,109 @@ struct acp3x_dev_data { struct platform_device *pdev[ACP3x_DEVS]; }; +static int acp3x_power_on(void __iomem *acp3x_base) +{ + u32 val; + int timeout; + + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + + if (val == 0) + return val; + + if (!((val & ACP_PGFSM_STATUS_MASK) == + ACP_POWER_ON_IN_PROGRESS)) + rv_writel(ACP_PGFSM_CNTL_POWER_ON_MASK, + acp3x_base + mmACP_PGFSM_CONTROL); + timeout = 0; + while (++timeout < 500) { + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + if (!val) + return 0; + udelay(1); + } + return -ETIMEDOUT; +} + +static int acp3x_power_off(void __iomem *acp3x_base) +{ + u32 val; + int timeout; + + rv_writel(ACP_PGFSM_CNTL_POWER_OFF_MASK, + acp3x_base + mmACP_PGFSM_CONTROL); + timeout = 0; + while (++timeout < 500) { + val = rv_readl(acp3x_base + mmACP_PGFSM_STATUS); + if ((val & ACP_PGFSM_STATUS_MASK) == ACP_POWERED_OFF) + return 0; + udelay(1); + } + return -ETIMEDOUT; +} + +static int acp3x_reset(void __iomem *acp3x_base) +{ + u32 val; + int timeout; + + rv_writel(1, acp3x_base + mmACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = rv_readl(acp3x_base + mmACP_SOFT_RESET); + if (val & ACP3x_SOFT_RESET__SoftResetAudDone_MASK) + break; + cpu_relax(); + } + rv_writel(0, acp3x_base + mmACP_SOFT_RESET); + timeout = 0; + while (++timeout < 500) { + val = rv_readl(acp3x_base + mmACP_SOFT_RESET); + if (!val) + return 0; + cpu_relax(); + } + return -ETIMEDOUT; +} + +static int acp3x_init(void __iomem *acp3x_base) +{ + int ret; + + /* power on */ + ret = acp3x_power_on(acp3x_base); + if (ret) { + pr_err("ACP3x power on failed\n"); + return ret; + } + /* Reset */ + ret = acp3x_reset(acp3x_base); + if (ret) { + pr_err("ACP3x reset failed\n"); + return ret; + } + return 0; +} + +static int acp3x_deinit(void __iomem *acp3x_base) +{ + int ret; + + /* Reset */ + ret = acp3x_reset(acp3x_base); + if (ret) { + pr_err("ACP3x reset failed\n"); + return ret; + } + /* power off */ + ret = acp3x_power_off(acp3x_base); + if (ret) { + pr_err("ACP3x power off failed\n"); + return ret; + } + return 0; +} + static int snd_acp3x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -64,6 +169,9 @@ static int snd_acp3x_probe(struct pci_dev *pci, } pci_set_master(pci); pci_set_drvdata(pci, adata); + ret = acp3x_init(adata->acp3x_base); + if (ret) + goto disable_msi; val = rv_readl(adata->acp3x_base + mmACP_I2S_PIN_CONFIG); switch (val) { @@ -73,7 +181,7 @@ static int snd_acp3x_probe(struct pci_dev *pci, GFP_KERNEL); if (!adata->res) { ret = -ENOMEM; - goto disable_msi; + goto de_init; } adata->res[0].name = "acp3x_i2s_iomem"; @@ -118,7 +226,7 @@ static int snd_acp3x_probe(struct pci_dev *pci, pdevinfo[2].parent = &pci->dev; pdevinfo[2].num_res = 1; pdevinfo[2].res = &adata->res[2]; - for (i = 0; i < ACP3x_DEVS ; i++) { + for (i = 0; i < ACP3x_DEVS; i++) { adata->pdev[i] = platform_device_register_full(&pdevinfo[i]); if (IS_ERR(adata->pdev[i])) { @@ -134,12 +242,21 @@ static int snd_acp3x_probe(struct pci_dev *pci, ret = -ENODEV; goto disable_msi; } + pm_runtime_set_autosuspend_delay(&pci->dev, 2000); + pm_runtime_use_autosuspend(&pci->dev); + pm_runtime_set_active(&pci->dev); + pm_runtime_put_noidle(&pci->dev); + pm_runtime_enable(&pci->dev); + pm_runtime_allow(&pci->dev); return 0; unregister_devs: if (val == I2S_MODE) - for (i = 0 ; i < ACP3x_DEVS ; i++) + for (i = 0; i < ACP3x_DEVS; i++) platform_device_unregister(adata->pdev[i]); +de_init: + if (acp3x_deinit(adata->acp3x_base)) + dev_err(&pci->dev, "ACP de-init failed\n"); disable_msi: pci_disable_msi(pci); release_regions: @@ -150,15 +267,56 @@ disable_pci: return ret; } +static int snd_acp3x_suspend(struct device *dev) +{ + int ret; + struct acp3x_dev_data *adata; + + adata = dev_get_drvdata(dev); + ret = acp3x_deinit(adata->acp3x_base); + if (ret) + dev_err(dev, "ACP de-init failed\n"); + else + dev_dbg(dev, "ACP de-initialized\n"); + + return 0; +} + +static int snd_acp3x_resume(struct device *dev) +{ + int ret; + struct acp3x_dev_data *adata; + + adata = dev_get_drvdata(dev); + ret = acp3x_init(adata->acp3x_base); + if (ret) { + dev_err(dev, "ACP init failed\n"); + return ret; + } + return 0; +} + +static const struct dev_pm_ops acp3x_pm = { + .runtime_suspend = snd_acp3x_suspend, + .runtime_resume = snd_acp3x_resume, + .resume = snd_acp3x_resume, +}; + static void snd_acp3x_remove(struct pci_dev *pci) { - struct acp3x_dev_data *adata = pci_get_drvdata(pci); - int i; + struct acp3x_dev_data *adata; + int i, ret; + adata = pci_get_drvdata(pci); if (adata->acp3x_audio_mode == ACP3x_I2S_MODE) { - for (i = 0 ; i < ACP3x_DEVS ; i++) + for (i = 0; i < ACP3x_DEVS; i++) platform_device_unregister(adata->pdev[i]); } + ret = acp3x_deinit(adata->acp3x_base); + if (ret) + dev_err(&pci->dev, "ACP de-init failed\n"); + pm_runtime_disable(&pci->dev); + pm_runtime_get_noresume(&pci->dev); pci_disable_msi(pci); pci_release_regions(pci); pci_disable_device(pci); @@ -177,6 +335,9 @@ static struct pci_driver acp3x_driver = { .id_table = snd_acp3x_ids, .probe = snd_acp3x_probe, .remove = snd_acp3x_remove, + .driver = { + .pm = &acp3x_pm, + } }; module_pci_driver(acp3x_driver); -- cgit v1.2.3 From 3d8cbeda38f1cc51733715f0a02b338b4f75fad0 Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Sat, 28 Dec 2019 19:11:00 +0530 Subject: ASoC: amd MMAP_INTERLEAVED Support ACP-I2S device support MMAP_INTERLEAVED. Added support for the same. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1577540460-21438-7-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-pcm-dma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c index 151daa996343..5c3ec3c58e3b 100644 --- a/sound/soc/amd/raven/acp3x-pcm-dma.c +++ b/sound/soc/amd/raven/acp3x-pcm-dma.c @@ -21,6 +21,7 @@ static const struct snd_pcm_hardware acp3x_pcm_hardware_playback = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_BATCH | + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | @@ -41,7 +42,8 @@ static const struct snd_pcm_hardware acp3x_pcm_hardware_capture = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_BATCH | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, + SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, -- cgit v1.2.3 From cb5b83580c6101ce3c7de4640ecc7f1ca6e006bf Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 1 Jan 2020 08:43:19 +0100 Subject: ALSA: ad1816a: constify copied structure The snd_ad1816a_timer_table structure is only copied into another structure, so make it const. The opportunity for this change was found using Coccinelle. Signed-off-by: Julia Lawall Link: https://lore.kernel.org/r/1577864614-5543-2-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index e1aa5372c483..da6f68b8c248 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -409,7 +409,7 @@ static int snd_ad1816a_timer_stop(struct snd_timer *timer) return 0; } -static struct snd_timer_hardware snd_ad1816a_timer_table = { +static const struct snd_timer_hardware snd_ad1816a_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 10000, .ticks = 65535, -- cgit v1.2.3 From c56fc8c9ad7a8693a9c07a39fd3081576f908fea Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 1 Jan 2020 08:43:20 +0100 Subject: ALSA: hda: constify copied structure The azx_pcm_hw structure is only copied into another structure, so make it const. The opportunity for this change was found using Coccinelle. Signed-off-by: Julia Lawall Link: https://lore.kernel.org/r/1577864614-5543-3-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index a74c85867eb3..9757667cdd58 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -548,7 +548,7 @@ static int azx_get_time_info(struct snd_pcm_substream *substream, return 0; } -static struct snd_pcm_hardware azx_pcm_hw = { +static const struct snd_pcm_hardware azx_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.2.3 From 0da390ba86d841b1f9770c0a67bdebb4d8dc8be5 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 1 Jan 2020 08:43:28 +0100 Subject: ASoC: qdsp6: q6asm-dai: constify copied structure The q6asm_dai_hardware_capture structure is only copied into another structure, so make it const. The opportunity for this change was found using Coccinelle. Signed-off-by: Julia Lawall Link: https://lore.kernel.org/r/1577864614-5543-11-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Mark Brown --- sound/soc/qcom/qdsp6/q6asm-dai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index 5e2327708772..c0d422d0ab94 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -72,7 +72,7 @@ struct q6asm_dai_data { long long int sid; }; -static struct snd_pcm_hardware q6asm_dai_hardware_capture = { +static const struct snd_pcm_hardware q6asm_dai_hardware_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.2.3 From 49f261e273078a5dc0272296a833dc72571efd92 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 1 Jan 2020 18:49:46 +0100 Subject: ASoC: SOF: imx8: use resource_size Use resource_size rather than a verbose computation on the end and start fields. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) @@ struct resource ptr; @@ - (ptr.end - ptr.start + 1) + resource_size(&ptr) Signed-off-by: Julia Lawall Link: https://lore.kernel.org/r/1577900990-8588-7-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Mark Brown --- sound/soc/sof/imx/imx8.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index aef6ca167b9c..b2556f5e2871 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -294,8 +294,7 @@ static int imx8_probe(struct snd_sof_dev *sdev) } sdev->bar[SOF_FW_BLK_TYPE_SRAM] = devm_ioremap_wc(sdev->dev, res.start, - res.end - res.start + - 1); + resource_size(&res)); if (!sdev->bar[SOF_FW_BLK_TYPE_SRAM]) { dev_err(sdev->dev, "failed to ioremap mem 0x%x size 0x%x\n", base, size); -- cgit v1.2.3 From 22a0d31a595c7cd0d37b97e1bc09c79ae1408311 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 2 Jan 2020 13:59:51 -0600 Subject: ASoC: Intel: boards: hda_dsp_common: use NULL pointer assignment, not 0 Fix Sparse warning: hda_dsp_common.c:66:37: warning: Using plain integer as NULL pointer Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200102195952.9465-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/hda_dsp_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/hda_dsp_common.c b/sound/soc/intel/boards/hda_dsp_common.c index ed36b68d6705..9179f07f9ee4 100644 --- a/sound/soc/intel/boards/hda_dsp_common.c +++ b/sound/soc/intel/boards/hda_dsp_common.c @@ -63,7 +63,7 @@ int hda_dsp_hdmi_build_controls(struct snd_soc_card *card, "%s: mapping HDMI converter %d to PCM %d (%p)\n", __func__, i, hpcm->device, spcm); } else { - hpcm->pcm = 0; + hpcm->pcm = NULL; hpcm->device = SNDRV_PCM_INVALID_DEVICE; dev_warn(card->dev, "%s: no PCM in topology for HDMI converter %d\n\n", -- cgit v1.2.3 From 72bbeda0222bcd382ee33b3aff71346074410c21 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 2 Jan 2020 13:59:52 -0600 Subject: ASoC: soc-topology: fix endianness issues Sparse complains about a series of easy warnings, fix. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200102195952.9465-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/soc-topology.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 69d6a52d0066..107ba3ed5440 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -605,9 +605,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, ext_ops = tplg->bytes_ext_ops; num_ops = tplg->bytes_ext_ops_count; for (i = 0; i < num_ops; i++) { - if (!sbe->put && ext_ops[i].id == be->ext_ops.put) + if (!sbe->put && + ext_ops[i].id == le32_to_cpu(be->ext_ops.put)) sbe->put = ext_ops[i].put; - if (!sbe->get && ext_ops[i].id == be->ext_ops.get) + if (!sbe->get && + ext_ops[i].id == le32_to_cpu(be->ext_ops.get)) sbe->get = ext_ops[i].get; } @@ -622,11 +624,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, num_ops = tplg->io_ops_count; for (i = 0; i < num_ops; i++) { - if (k->put == NULL && ops[i].id == hdr->ops.put) + if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put)) k->put = ops[i].put; - if (k->get == NULL && ops[i].id == hdr->ops.get) + if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get)) k->get = ops[i].get; - if (k->info == NULL && ops[i].id == hdr->ops.info) + if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info)) k->info = ops[i].info; } @@ -639,11 +641,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, num_ops = ARRAY_SIZE(io_ops); for (i = 0; i < num_ops; i++) { - if (k->put == NULL && ops[i].id == hdr->ops.put) + if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put)) k->put = ops[i].put; - if (k->get == NULL && ops[i].id == hdr->ops.get) + if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get)) k->get = ops[i].get; - if (k->info == NULL && ops[i].id == hdr->ops.info) + if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info)) k->info = ops[i].info; } @@ -932,7 +934,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se, if (se->dobj.control.dtexts == NULL) return -ENOMEM; - for (i = 0; i < ec->items; i++) { + for (i = 0; i < le32_to_cpu(ec->items); i++) { if (strnlen(ec->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == SNDRV_CTL_ELEM_ID_NAME_MAXLEN) { @@ -1326,7 +1328,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( if (kc[i].name == NULL) goto err_sm; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc[i].access = mc->hdr.access; + kc[i].access = le32_to_cpu(mc->hdr.access); /* we only support FL/FR channel mapping atm */ sm->reg = tplc_chan_get_reg(tplg, mc->channel, @@ -1338,10 +1340,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( sm->rshift = tplc_chan_get_shift(tplg, mc->channel, SNDRV_CHMAP_FR); - sm->max = mc->max; - sm->min = mc->min; - sm->invert = mc->invert; - sm->platform_max = mc->platform_max; + sm->max = le32_to_cpu(mc->max); + sm->min = le32_to_cpu(mc->min); + sm->invert = le32_to_cpu(mc->invert); + sm->platform_max = le32_to_cpu(mc->platform_max); sm->dobj.index = tplg->index; INIT_LIST_HEAD(&sm->dobj.list); @@ -1402,7 +1404,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create( goto err_se; tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) + - ec->priv.size); + le32_to_cpu(ec->priv.size)); dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n", ec->hdr.name); @@ -1412,7 +1414,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create( if (kc[i].name == NULL) goto err_se; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc[i].access = ec->hdr.access; + kc[i].access = le32_to_cpu(ec->hdr.access); /* we only support FL/FR channel mapping atm */ se->reg = tplc_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL); @@ -1421,8 +1423,8 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create( se->shift_r = tplc_chan_get_shift(tplg, ec->channel, SNDRV_CHMAP_FR); - se->items = ec->items; - se->mask = ec->mask; + se->items = le32_to_cpu(ec->items); + se->mask = le32_to_cpu(ec->mask); se->dobj.index = tplg->index; switch (le32_to_cpu(ec->hdr.ops.info)) { @@ -1524,9 +1526,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create( if (kc[i].name == NULL) goto err_sbe; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; - kc[i].access = be->hdr.access; + kc[i].access = le32_to_cpu(be->hdr.access); - sbe->max = be->max; + sbe->max = le32_to_cpu(be->max); INIT_LIST_HEAD(&sbe->dobj.list); /* map standard io handlers and check for external handlers */ -- cgit v1.2.3 From c1c3981fa16688e02f629a4805c9188679b132e9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:17 +0100 Subject: ALSA: pci: Constify snd_pcm_hardware definitions Most of snd_pcm_hardware definitions are just copied to another object as-is, hence we can define them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 8 ++++---- sound/pci/echoaudio/darla20.c | 2 +- sound/pci/echoaudio/darla24.c | 2 +- sound/pci/echoaudio/echo3g.c | 2 +- sound/pci/echoaudio/gina20.c | 2 +- sound/pci/echoaudio/gina24.c | 2 +- sound/pci/echoaudio/indigo.c | 2 +- sound/pci/echoaudio/indigodj.c | 2 +- sound/pci/echoaudio/indigodjx.c | 2 +- sound/pci/echoaudio/indigoio.c | 2 +- sound/pci/echoaudio/indigoiox.c | 2 +- sound/pci/echoaudio/layla20.c | 2 +- sound/pci/echoaudio/layla24.c | 2 +- sound/pci/echoaudio/mia.c | 2 +- sound/pci/echoaudio/mona.c | 2 +- sound/pci/nm256/nm256.c | 6 +++--- sound/pci/rme9652/hdspm.c | 4 ++-- 17 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 9f78cf9e0b47..434077527b95 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1400,7 +1400,7 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream) return cso; } -static struct snd_pcm_hardware snd_ali_playback = +static const struct snd_pcm_hardware snd_ali_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1426,7 +1426,7 @@ static struct snd_pcm_hardware snd_ali_playback = * Capture support device description */ -static struct snd_pcm_hardware snd_ali_capture = +static const struct snd_pcm_hardware snd_ali_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1457,7 +1457,7 @@ static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime) } static int snd_ali_open(struct snd_pcm_substream *substream, int rec, - int channel, struct snd_pcm_hardware *phw) + int channel, const struct snd_pcm_hardware *phw) { struct snd_ali *codec = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; @@ -1537,7 +1537,7 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_pcm_hardware snd_ali_modem = +static const struct snd_pcm_hardware snd_ali_modem = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c index 0f1c65d701f9..e295c71c7a39 100644 --- a/sound/pci/echoaudio/darla20.c +++ b/sound/pci/echoaudio/darla20.c @@ -56,7 +56,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c index 6dd7bfd643da..ae816e78f599 100644 --- a/sound/pci/echoaudio/darla24.c +++ b/sound/pci/echoaudio/darla24.c @@ -61,7 +61,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c index 8a03c4bb9f4c..3d37bb4030ec 100644 --- a/sound/pci/echoaudio/echo3g.c +++ b/sound/pci/echoaudio/echo3g.c @@ -74,7 +74,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c index fa1208f4031f..4f864ddc9530 100644 --- a/sound/pci/echoaudio/gina20.c +++ b/sound/pci/echoaudio/gina20.c @@ -60,7 +60,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c index 3089c3221a25..eff69e83ca0a 100644 --- a/sound/pci/echoaudio/gina24.c +++ b/sound/pci/echoaudio/gina24.c @@ -81,7 +81,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c index 0e85070b305e..a9f2efc58f6e 100644 --- a/sound/pci/echoaudio/indigo.c +++ b/sound/pci/echoaudio/indigo.c @@ -61,7 +61,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c index 0ad022137e53..14e9769ceba1 100644 --- a/sound/pci/echoaudio/indigodj.c +++ b/sound/pci/echoaudio/indigodj.c @@ -61,7 +61,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/indigodjx.c b/sound/pci/echoaudio/indigodjx.c index 38f17d39e53a..a14a7dc8c87d 100644 --- a/sound/pci/echoaudio/indigodjx.c +++ b/sound/pci/echoaudio/indigodjx.c @@ -61,7 +61,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c index 29e0137feb02..97e024450d19 100644 --- a/sound/pci/echoaudio/indigoio.c +++ b/sound/pci/echoaudio/indigoio.c @@ -62,7 +62,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/indigoiox.c b/sound/pci/echoaudio/indigoiox.c index f5c9ef6148ad..a017c966b4dc 100644 --- a/sound/pci/echoaudio/indigoiox.c +++ b/sound/pci/echoaudio/indigoiox.c @@ -62,7 +62,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c index 74906c35c662..7e38bc9c025d 100644 --- a/sound/pci/echoaudio/layla20.c +++ b/sound/pci/echoaudio/layla20.c @@ -70,7 +70,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c index 69742326f188..95c52210fb65 100644 --- a/sound/pci/echoaudio/layla24.c +++ b/sound/pci/echoaudio/layla24.c @@ -80,7 +80,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c index ee9722db62f5..a2d4b0003b57 100644 --- a/sound/pci/echoaudio/mia.c +++ b/sound/pci/echoaudio/mia.c @@ -71,7 +71,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c index 3e5747ea4860..1b45a2b5066f 100644 --- a/sound/pci/echoaudio/mona.c +++ b/sound/pci/echoaudio/mona.c @@ -90,7 +90,7 @@ static const struct pci_device_id snd_echo_ids[] = { {0,} }; -static struct snd_pcm_hardware pcm_hardware_skel = { +static const struct snd_pcm_hardware pcm_hardware_skel = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index ac194485aa78..5da28b0adbd9 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -785,7 +785,7 @@ snd_nm256_capture_update(struct nm256 *chip) /* * hardware info */ -static struct snd_pcm_hardware snd_nm256_playback = +static const struct snd_pcm_hardware snd_nm256_playback = { .info = SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -804,7 +804,7 @@ static struct snd_pcm_hardware snd_nm256_playback = .period_bytes_max = 128 * 1024, }; -static struct snd_pcm_hardware snd_nm256_capture = +static const struct snd_pcm_hardware snd_nm256_capture = { .info = SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -838,7 +838,7 @@ static int snd_nm256_pcm_hw_params(struct snd_pcm_substream *substream, */ static void snd_nm256_setup_stream(struct nm256 *chip, struct nm256_stream *s, struct snd_pcm_substream *substream, - struct snd_pcm_hardware *hw_ptr) + const struct snd_pcm_hardware *hw_ptr) { struct snd_pcm_runtime *runtime = substream->runtime; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 56ae14c90a2c..9e3263395f98 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -5820,7 +5820,7 @@ static int snd_hdspm_prepare(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { +static const struct snd_pcm_hardware snd_hdspm_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_NONINTERLEAVED | @@ -5845,7 +5845,7 @@ static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { .fifo_size = 0 }; -static struct snd_pcm_hardware snd_hdspm_capture_subinfo = { +static const struct snd_pcm_hardware snd_hdspm_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_NONINTERLEAVED | -- cgit v1.2.3 From 2ead9d087fe2eafecf801dd2ab83bdb66dc08ced Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:18 +0100 Subject: ALSA: usb: Constify snd_pcm_hardware definitions Most of snd_pcm_hardware definitions are just copied to another object as-is, hence we can define them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/caiaq/audio.c | 2 +- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 72212153cb1f..41993a5c0537 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -30,7 +30,7 @@ #define MAKE_CHECKBYTE(cdev,stream,i) \ (stream << 1) | (~(i / (cdev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) -static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { +static const struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER), .formats = SNDRV_PCM_FMTBIT_S24_3BE, diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 8ac4ce0e8965..c7dbc0f94efb 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -838,7 +838,7 @@ static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream) return err; } -static struct snd_pcm_hardware snd_usX2Y_2c = +static const struct snd_pcm_hardware snd_usX2Y_2c = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index d8d91f2fb799..8253669c6a7d 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -528,7 +528,7 @@ static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream) return err; } -static struct snd_pcm_hardware snd_usX2Y_4c = +static const struct snd_pcm_hardware snd_usX2Y_4c = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.2.3 From 8b575824304dd18a90616cbcf0f81ca1ed1fb5d2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:19 +0100 Subject: ALSA: core: Treat snd_device_ops as const This is a preliminary patch to allow const for snd_device_ops definitions in each driver's code. The ops reference is read-only, hence it can be declared as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/core.h | 4 ++-- sound/core/device.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index af3dce956c17..0e14b7a3e67b 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -69,7 +69,7 @@ struct snd_device { enum snd_device_state state; /* state of the device */ enum snd_device_type type; /* device type */ void *device_data; /* device structure */ - struct snd_device_ops *ops; /* operations */ + const struct snd_device_ops *ops; /* operations */ }; #define snd_device(n) list_entry(n, struct snd_device, list) @@ -256,7 +256,7 @@ static inline void snd_card_unref(struct snd_card *card) /* device.c */ int snd_device_new(struct snd_card *card, enum snd_device_type type, - void *device_data, struct snd_device_ops *ops); + void *device_data, const struct snd_device_ops *ops); int snd_device_register(struct snd_card *card, void *device_data); int snd_device_register_all(struct snd_card *card); void snd_device_disconnect(struct snd_card *card, void *device_data); diff --git a/sound/core/device.c b/sound/core/device.c index 708b91944de3..cdc5af526739 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -27,7 +27,7 @@ * Return: Zero if successful, or a negative error code on failure. */ int snd_device_new(struct snd_card *card, enum snd_device_type type, - void *device_data, struct snd_device_ops *ops) + void *device_data, const struct snd_device_ops *ops) { struct snd_device *dev; struct list_head *p; -- cgit v1.2.3 From f15ee210cdb87f82147df237d2fcfc4527523d62 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:20 +0100 Subject: ALSA: core: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/compress_offload.c | 2 +- sound/core/control.c | 2 +- sound/core/hwdep.c | 2 +- sound/core/jack.c | 2 +- sound/core/pcm.c | 4 ++-- sound/core/rawmidi.c | 2 +- sound/core/seq_device.c | 2 +- sound/core/timer.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index f34ce564d92c..9de1c9a0173e 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -1099,7 +1099,7 @@ static int snd_compress_dev_free(struct snd_device *device) int snd_compress_new(struct snd_card *card, int device, int dirn, const char *id, struct snd_compr *compr) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_compress_dev_free, .dev_register = snd_compress_dev_register, .dev_disconnect = snd_compress_dev_disconnect, diff --git a/sound/core/control.c b/sound/core/control.c index 4728f6828890..63bb2fcf13be 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1823,7 +1823,7 @@ static int snd_ctl_dev_free(struct snd_device *device) */ int snd_ctl_create(struct snd_card *card) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ctl_dev_free, .dev_register = snd_ctl_dev_register, .dev_disconnect = snd_ctl_dev_disconnect, diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 00cb5aed10a9..b412d3b3d5ff 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -353,7 +353,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, { struct snd_hwdep *hwdep; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_hwdep_dev_free, .dev_register = snd_hwdep_dev_register, .dev_disconnect = snd_hwdep_dev_disconnect, diff --git a/sound/core/jack.c b/sound/core/jack.c index fb26196571a7..6590b1b8d62a 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -201,7 +201,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, struct snd_jack *jack; struct snd_jack_kctl *jack_kctl = NULL; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_jack_dev_free, #ifdef CONFIG_SND_JACK_INPUT_DEV .dev_register = snd_jack_dev_register, diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 85db55ea49fd..a0f704b72a78 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -706,12 +706,12 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device, { struct snd_pcm *pcm; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_pcm_dev_free, .dev_register = snd_pcm_dev_register, .dev_disconnect = snd_pcm_dev_disconnect, }; - static struct snd_device_ops internal_ops = { + static const struct snd_device_ops internal_ops = { .dev_free = snd_pcm_dev_free, }; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index cd9bbb546846..7bc95c24f724 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1621,7 +1621,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, { struct snd_rawmidi *rmidi; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_rawmidi_dev_free, .dev_register = snd_rawmidi_dev_register, .dev_disconnect = snd_rawmidi_dev_disconnect, diff --git a/sound/core/seq_device.c b/sound/core/seq_device.c index e9dbad93f9d0..7ed13cb32ef8 100644 --- a/sound/core/seq_device.c +++ b/sound/core/seq_device.c @@ -193,7 +193,7 @@ int snd_seq_device_new(struct snd_card *card, int device, const char *id, { struct snd_seq_device *dev; int err; - static struct snd_device_ops dops = { + static const struct snd_device_ops dops = { .dev_free = snd_seq_device_dev_free, .dev_register = snd_seq_device_dev_register, .dev_disconnect = snd_seq_device_dev_disconnect, diff --git a/sound/core/timer.c b/sound/core/timer.c index 4cfd8e691903..d53bc1f3a48a 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -936,7 +936,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, { struct snd_timer *timer; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_timer_dev_free, .dev_register = snd_timer_dev_register, .dev_disconnect = snd_timer_dev_disconnect, -- cgit v1.2.3 From 34273b234c0712c963f02845919125686f503d3e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:21 +0100 Subject: ALSA: drivers: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/ml403-ac97cr.c | 2 +- sound/drivers/opl3/opl3_lib.c | 2 +- sound/drivers/opl4/opl4_lib.c | 2 +- sound/drivers/pcsp/pcsp.c | 2 +- sound/drivers/serial-u16550.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index d1e01d89c722..2cec7c5bf8fd 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -1076,7 +1076,7 @@ snd_ml403_ac97cr_create(struct snd_card *card, struct platform_device *pfdev, { struct snd_ml403_ac97cr *ml403_ac97cr; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ml403_ac97cr_dev_free, }; struct resource *resource; diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index cbdec28e89af..6134e5ffea0b 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -332,7 +332,7 @@ int snd_opl3_new(struct snd_card *card, unsigned short hardware, struct snd_opl3 **ropl3) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_opl3_dev_free, }; struct snd_opl3 *opl3; diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c index 901d339703a9..035645eb5e8d 100644 --- a/sound/drivers/opl4/opl4_lib.c +++ b/sound/drivers/opl4/opl4_lib.c @@ -184,7 +184,7 @@ int snd_opl4_create(struct snd_card *card, struct snd_opl4 *opl4; struct snd_opl3 *opl3; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_opl4_dev_free }; diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 14aacd8267d1..fd79e57c85ca 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -43,7 +43,7 @@ struct snd_pcsp pcsp_chip; static int snd_pcsp_create(struct snd_card *card) { - static struct snd_device_ops ops = { }; + static const struct snd_device_ops ops = { }; unsigned int resolution = hrtimer_resolution; int err, div, min_div, order; diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 4775f1b7b444..893c2b57331f 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -777,7 +777,7 @@ static int snd_uart16550_create(struct snd_card *card, int droponfull, struct snd_uart16550 **ruart) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_uart16550_dev_free, }; struct snd_uart16550 *uart; -- cgit v1.2.3 From d23015c12144736bbea6dbd0fdd8dcae3d1e47c5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:22 +0100 Subject: ALSA: i2c: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-7-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/i2c/i2c.c | 2 +- sound/i2c/other/ak4113.c | 2 +- sound/i2c/other/ak4114.c | 2 +- sound/i2c/other/ak4117.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c index 37b3c6940cac..a684faa771ef 100644 --- a/sound/i2c/i2c.c +++ b/sound/i2c/i2c.c @@ -67,7 +67,7 @@ int snd_i2c_bus_create(struct snd_card *card, const char *name, { struct snd_i2c_bus *bus; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_i2c_bus_dev_free, }; diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index 775f9a354a86..2700a8470388 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -60,7 +60,7 @@ int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read, struct ak4113 *chip; int err; unsigned char reg; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ak4113_dev_free, }; diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 6611c7debf23..e7325af8af5b 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -71,7 +71,7 @@ int snd_ak4114_create(struct snd_card *card, struct ak4114 *chip; int err = 0; unsigned char reg; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ak4114_dev_free, }; diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 381949c8f15f..0d9e8252cc27 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -64,7 +64,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t struct ak4117 *chip; int err = 0; unsigned char reg; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ak4117_dev_free, }; -- cgit v1.2.3 From 99f664df4fead60e31d96cc2b5044c9b2fee0767 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:23 +0100 Subject: ALSA: isa: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-8-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 2 +- sound/isa/es1688/es1688_lib.c | 2 +- sound/isa/es18xx.c | 2 +- sound/isa/gus/gus_main.c | 2 +- sound/isa/msnd/msnd_pinnacle.c | 2 +- sound/isa/sb/emu8000.c | 2 +- sound/isa/sb/sb_common.c | 2 +- sound/isa/wss/wss_lib.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index da6f68b8c248..560885fbc983 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -577,7 +577,7 @@ int snd_ad1816a_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, struct snd_ad1816a *chip) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ad1816a_dev_free, }; int error; diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 632e867c5766..99a833f29544 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -612,7 +612,7 @@ int snd_es1688_create(struct snd_card *card, int dma8, unsigned short hardware) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_es1688_dev_free, }; diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index a581083b876b..f9cd05d2b3bd 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1753,7 +1753,7 @@ static int snd_es18xx_new_device(struct snd_card *card, int irq, int dma1, int dma2) { struct snd_es18xx *chip = card->private_data; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_es18xx_dev_free, }; int err; diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 9f94b5f3b029..e9fc333c0fcb 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -134,7 +134,7 @@ int snd_gus_create(struct snd_card *card, { struct snd_gus_card *gus; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_gus_dev_free, }; diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 9e7f03eec7e6..7fca418a64f8 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -528,7 +528,7 @@ static int snd_msnd_attach(struct snd_card *card) { struct snd_msnd *chip = card->private_data; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_msnd_dev_free, }; diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 433e32e254f9..bc47e8e51523 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -1075,7 +1075,7 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, struct snd_seq_device *awe; struct snd_emu8000 *hw; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_emu8000_dev_free, }; diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 4aaf9ab82afe..61ea4078aa95 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -204,7 +204,7 @@ int snd_sbdsp_create(struct snd_card *card, { struct snd_sb *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_sbdsp_dev_free, }; diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 100e8b547d27..b51b50154e8a 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1772,7 +1772,7 @@ int snd_wss_create(struct snd_card *card, unsigned short hwshare, struct snd_wss **rchip) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_wss_dev_free, }; struct snd_wss *chip; -- cgit v1.2.3 From 41f394a8d80766a0d8d2cc8879c3a295be951f6c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:24 +0100 Subject: ALSA: hda: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-9-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_beep.c | 2 +- sound/pci/hda/hda_codec.c | 2 +- sound/pci/hda/hda_intel.c | 2 +- sound/pci/hda/hda_tegra.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index b7d9160ed868..f5fd62ed4df5 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c @@ -192,7 +192,7 @@ static int beep_dev_free(struct snd_device *device) */ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_register = beep_dev_register, .dev_disconnect = beep_dev_disconnect, .dev_free = beep_dev_free, diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a2fb19129219..8f166bbc438b 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -915,7 +915,7 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, char component[31]; hda_nid_t fg; int err; - static struct snd_device_ops dev_ops = { + static const struct snd_device_ops dev_ops = { .dev_register = snd_hda_codec_dev_register, .dev_free = snd_hda_codec_dev_free, }; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index c7efb6f66bdc..4733268ec74e 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1743,7 +1743,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, int dev, unsigned int driver_caps, struct azx **rchip) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_disconnect = azx_dev_disconnect, .dev_free = azx_dev_free, }; diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 9d0784aed9e4..567c9ebddb2e 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -366,7 +366,7 @@ static int hda_tegra_create(struct snd_card *card, unsigned int driver_caps, struct hda_tegra *hda) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_disconnect = hda_tegra_dev_disconnect, .dev_free = hda_tegra_dev_free, }; -- cgit v1.2.3 From efb0ad25d370344e61bb4fca8c3b9c3c6047922e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:25 +0100 Subject: ALSA: pci: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-10-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 4 ++-- sound/pci/ad1889.c | 2 +- sound/pci/ak4531_codec.c | 2 +- sound/pci/ali5451/ali5451.c | 2 +- sound/pci/als300.c | 2 +- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/au88x0/au88x0.c | 2 +- sound/pci/aw2/aw2-alsa.c | 2 +- sound/pci/azt3328.c | 2 +- sound/pci/bt87x.c | 2 +- sound/pci/ca0106/ca0106_main.c | 2 +- sound/pci/cmipci.c | 2 +- sound/pci/cs4281.c | 2 +- sound/pci/cs46xx/cs46xx_lib.c | 2 +- sound/pci/cs5530.c | 2 +- sound/pci/cs5535audio/cs5535audio.c | 2 +- sound/pci/ctxfi/ctatc.c | 2 +- sound/pci/echoaudio/echoaudio.c | 2 +- sound/pci/emu10k1/emu10k1_main.c | 2 +- sound/pci/emu10k1/emu10k1x.c | 2 +- sound/pci/ens1370.c | 2 +- sound/pci/es1938.c | 2 +- sound/pci/es1968.c | 2 +- sound/pci/fm801.c | 2 +- sound/pci/ice1712/ice1712.c | 2 +- sound/pci/ice1712/ice1724.c | 2 +- sound/pci/intel8x0.c | 2 +- sound/pci/intel8x0m.c | 2 +- sound/pci/korg1212/korg1212.c | 2 +- sound/pci/lola/lola.c | 2 +- sound/pci/lx6464es/lx6464es.c | 2 +- sound/pci/maestro3.c | 2 +- sound/pci/mixart/mixart.c | 2 +- sound/pci/nm256/nm256.c | 2 +- sound/pci/pcxhr/pcxhr.c | 2 +- sound/pci/riptide/riptide.c | 2 +- sound/pci/sis7019.c | 2 +- sound/pci/sonicvibes.c | 2 +- sound/pci/trident/trident_main.c | 2 +- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- sound/pci/vx222/vx222.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 2 +- 44 files changed, 45 insertions(+), 45 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 66f6c3bf08e3..41bdec4249e1 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1899,7 +1899,7 @@ int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, { int err; struct snd_ac97_bus *bus; - static struct snd_device_ops dev_ops = { + static const struct snd_device_ops dev_ops = { .dev_free = snd_ac97_bus_dev_free, }; @@ -1999,7 +1999,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, unsigned long end_time; unsigned int reg; const struct ac97_codec_id *pid; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ac97_dev_free, .dev_register = snd_ac97_dev_register, .dev_disconnect = snd_ac97_dev_disconnect, diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 7770157a3a8c..3daa978263f6 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -847,7 +847,7 @@ snd_ad1889_create(struct snd_card *card, int err; struct snd_ad1889 *chip; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ad1889_dev_free, }; diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c index 7fa8106b5010..fbf9a93a8053 100644 --- a/sound/pci/ak4531_codec.c +++ b/sound/pci/ak4531_codec.c @@ -371,7 +371,7 @@ int snd_ak4531_mixer(struct snd_card *card, unsigned int idx; int err; struct snd_ak4531 *ak4531; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ak4531_dev_free, }; diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 434077527b95..39c33a944e5d 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -2046,7 +2046,7 @@ static int snd_ali_create(struct snd_card *card, struct snd_ali *codec; int i, err; unsigned short cmdw; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ali_dev_free, }; diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 6573a2259cb6..64d978307755 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -617,7 +617,7 @@ static int snd_als300_create(struct snd_card *card, void *irq_handler; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_als300_dev_free, }; *rchip = NULL; diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 684b4f18e52c..61ae4fe8d646 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1557,7 +1557,7 @@ static int snd_atiixp_create(struct snd_card *card, struct pci_dev *pci, struct atiixp **r_chip) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_atiixp_dev_free, }; struct atiixp *chip; diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 40cda5c3bfeb..b62cde3a00b2 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1187,7 +1187,7 @@ static int snd_atiixp_create(struct snd_card *card, struct pci_dev *pci, struct atiixp_modem **r_chip) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_atiixp_dev_free, }; struct atiixp_modem *chip; diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index c9e0159af2b1..be276fb3f5af 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -142,7 +142,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) { vortex_t *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_vortex_dev_free, }; diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 819b148573a6..b3be98e33845 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -223,7 +223,7 @@ static int snd_aw2_create(struct snd_card *card, { struct aw2 *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_aw2_dev_free, }; diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index b36e7a64e268..810d5772f097 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -2355,7 +2355,7 @@ snd_azf3328_create(struct snd_card *card, { struct snd_azf3328 *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_azf3328_dev_free, }; u8 dma_init; diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 2e16604c31ce..ece3f8971145 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -705,7 +705,7 @@ static int snd_bt87x_create(struct snd_card *card, { struct snd_bt87x *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_bt87x_dev_free }; diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index a14e9b1e50b0..e65154cecad5 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1595,7 +1595,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card, struct snd_ca0106 *chip; struct snd_ca0106_details *c; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ca0106_dev_free, }; diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 266c4cf28b78..ff5525722d58 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2976,7 +2976,7 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, { struct cmipci *cm; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_cmipci_dev_free, }; unsigned int val; diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index e7294b9d2cb6..75450e329cee 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1304,7 +1304,7 @@ static int snd_cs4281_create(struct snd_card *card, struct cs4281 *chip; unsigned int tmp; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_cs4281_dev_free, }; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index adfc750bc61c..6251fa8da939 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3864,7 +3864,7 @@ int snd_cs46xx_create(struct snd_card *card, struct snd_cs46xx_region *region; struct cs_card_type *cp; u16 ss_card, ss_vendor; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_cs46xx_dev_free, }; diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index 3ab7ec565071..20b4faea50a6 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c @@ -104,7 +104,7 @@ static int snd_cs5530_create(struct snd_card *card, void __iomem *mem; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_cs5530_dev_free, }; *rchip = NULL; diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 15126aff63fc..930c2ac405e5 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -261,7 +261,7 @@ static int snd_cs5535audio_create(struct snd_card *card, struct cs5535audio *cs5535au; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_cs5535audio_dev_free, }; diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 055a71b0a643..8d92154ac262 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -1669,7 +1669,7 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci, struct ct_atc **ratc) { struct ct_atc *atc; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = atc_dev_free, }; int err; diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index abad652a4006..dae3a853a6e1 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1856,7 +1856,7 @@ static int snd_echo_create(struct snd_card *card, struct echoaudio *chip; int err; size_t sz; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_echo_dev_free, }; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 65e9ec94b807..6a8fce8ac218 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1791,7 +1791,7 @@ int snd_emu10k1_create(struct snd_card *card, size_t page_table_size; unsigned int silent_page; const struct snd_emu_chip_details *c; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_emu10k1_dev_free, }; diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 6467142ec460..90ae1c72d663 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -886,7 +886,7 @@ static int snd_emu10k1x_create(struct snd_card *card, struct emu10k1x *chip; int err; int ch; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_emu10k1x_dev_free, }; diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 378141aa7c7d..7611e44e2af5 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -2041,7 +2041,7 @@ static int snd_ensoniq_create(struct snd_card *card, { struct ensoniq *ensoniq; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ensoniq_dev_free, }; diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index d9fba07d36d0..9d5568509387 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1548,7 +1548,7 @@ static int snd_es1938_create(struct snd_card *card, { struct es1938 *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_es1938_dev_free, }; diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 3610aa1da94c..43cfdf02048b 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2656,7 +2656,7 @@ static int snd_es1968_create(struct snd_card *card, int radio_nr, struct es1968 **chip_ret) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_es1968_dev_free, }; struct es1968 *chip; diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 152fbc352123..bb5cffee5dac 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1183,7 +1183,7 @@ static int snd_fm801_create(struct snd_card *card, { struct fm801 *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_fm801_dev_free, }; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index ffacf5e6ac9a..15cb90dceeb8 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2474,7 +2474,7 @@ static int snd_ice1712_create(struct snd_card *card, { struct snd_ice1712 *ice; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ice1712_dev_free, }; diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 14e4da08adfd..628b0581a4ff 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2502,7 +2502,7 @@ static int snd_vt1724_create(struct snd_card *card, { struct snd_ice1712 *ice; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_vt1724_dev_free, }; diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index f88008465c44..563f3a3e820e 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2897,7 +2897,7 @@ static int snd_intel8x0_create(struct snd_card *card, unsigned int i; unsigned int int_sta_masks; struct ichdev *ichdev; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_intel8x0_dev_free, }; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 2f73b45c845c..c6dc36167a01 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1079,7 +1079,7 @@ static int snd_intel8x0m_create(struct snd_card *card, unsigned int i; unsigned int int_sta_masks; struct ichdev *ichdev; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_intel8x0m_dev_free, }; static struct ich_reg_info intel_regs[2] = { diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 5d48ff0b32a7..f605926a0709 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2153,7 +2153,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, struct snd_korg1212 * korg1212; const struct firmware *dsp_code; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_korg1212_dev_free, }; diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index e7c620caa935..cdd8db79bcfa 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c @@ -559,7 +559,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci, struct lola *chip; int err; unsigned int dever; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = lola_dev_free, }; diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 7f6b1c6c2afe..b92ea074ff2a 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -938,7 +938,7 @@ static int snd_lx6464es_create(struct snd_card *card, struct lx6464es *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_lx6464es_dev_free, }; diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 9f75cc0c01dd..b94e3ec5f158 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2522,7 +2522,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, struct snd_m3 *chip; int i, err; const struct snd_pci_quirk *quirk; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_m3_dev_free, }; diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 18124bd97d80..44009c555322 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1030,7 +1030,7 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int { int err; struct snd_mixart *chip; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_mixart_chip_dev_free, }; diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 5da28b0adbd9..003a09788572 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1471,7 +1471,7 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci, { struct nm256 *chip; int err, pval; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_nm256_dev_free, }; u32 addr; diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index f4330832e520..9e59d591217b 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1179,7 +1179,7 @@ static int pcxhr_create(struct pcxhr_mgr *mgr, { int err; struct snd_pcxhr *chip; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = pcxhr_chip_dev_free, }; diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index af6956e26c29..6617bc347bfb 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1824,7 +1824,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, struct snd_riptide *chip; struct riptideport *hwport; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_riptide_dev_free, }; diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 515598e3cacf..2e351bf1d792 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1280,7 +1280,7 @@ static int sis_chip_create(struct snd_card *card, { struct sis7019 *sis = card->private_data; struct voice *voice; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = sis_dev_free, }; int rc; diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index a2bff9431512..dcdf5a534c4e 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1221,7 +1221,7 @@ static int snd_sonicvibes_create(struct snd_card *card, struct sonicvibes *sonic; unsigned int dmaa, dmac; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_sonicvibes_dev_free, }; diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 0d039eacbf0a..ba4a9fcd5eba 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3487,7 +3487,7 @@ int snd_trident_create(struct snd_card *card, int i, err; struct snd_trident_voice *voice; struct snd_trident_pcm_mixer *tmix; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_trident_dev_free, }; diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index e72050a9ffdb..090b0c47fbdd 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2332,7 +2332,7 @@ static int snd_via82xx_create(struct snd_card *card, { struct via82xx *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_via82xx_dev_free, }; diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 4e0858f8e372..7f138fa4e141 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1074,7 +1074,7 @@ static int snd_via82xx_create(struct snd_card *card, { struct via82xx_modem *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_via82xx_dev_free, }; diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index bc451224df16..b278c72797d5 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -128,7 +128,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, struct vx_core *chip; struct snd_vx222 *vx; int i, err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_vx222_dev_free, }; struct snd_vx_ops *vx_ops; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 3bc92d236508..2e20cd9d8cfc 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2327,7 +2327,7 @@ int snd_ymfpci_create(struct snd_card *card, { struct snd_ymfpci *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_ymfpci_dev_free, }; -- cgit v1.2.3 From c0a142e21bbaeddc9e0ed00045e0ac6c841f1769 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:26 +0100 Subject: ALSA: usb: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-11-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 6cd4ff09c5ee..f60e0869c096 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -3407,7 +3407,7 @@ static int create_keep_iface_ctl(struct usb_mixer_interface *mixer) int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, int ignore_error) { - static struct snd_device_ops dev_ops = { + static const struct snd_device_ops dev_ops = { .dev_free = snd_usb_mixer_dev_free }; struct usb_mixer_interface *mixer; -- cgit v1.2.3 From e6f2a617ac53bc0753b885ffb94379ff48b2e2df Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:27 +0100 Subject: ALSA: aoa: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-12-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/aoa/aoa.h | 2 +- sound/aoa/codecs/onyx.c | 2 +- sound/aoa/codecs/tas.c | 2 +- sound/aoa/codecs/toonie.c | 2 +- sound/aoa/core/alsa.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/aoa/aoa.h b/sound/aoa/aoa.h index 60ce9dedc737..3d2d03ff6337 100644 --- a/sound/aoa/aoa.h +++ b/sound/aoa/aoa.h @@ -116,7 +116,7 @@ struct aoa_card { }; extern int aoa_snd_device_new(enum snd_device_type type, - void * device_data, struct snd_device_ops * ops); + void *device_data, const struct snd_device_ops *ops); extern struct snd_card *aoa_get_card(void); extern int aoa_snd_ctl_add(struct snd_kcontrol* control); diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c index 9827bee109c1..83ab3e58a0d3 100644 --- a/sound/aoa/codecs/onyx.c +++ b/sound/aoa/codecs/onyx.c @@ -97,7 +97,7 @@ static int onyx_dev_register(struct snd_device *dev) return 0; } -static struct snd_device_ops ops = { +static const struct snd_device_ops ops = { .dev_register = onyx_dev_register, }; diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c index 7af6129d1cd7..c60b78367fc9 100644 --- a/sound/aoa/codecs/tas.c +++ b/sound/aoa/codecs/tas.c @@ -217,7 +217,7 @@ static int tas_dev_register(struct snd_device *dev) return 0; } -static struct snd_device_ops ops = { +static const struct snd_device_ops ops = { .dev_register = tas_dev_register, }; diff --git a/sound/aoa/codecs/toonie.c b/sound/aoa/codecs/toonie.c index b43469f43d2d..c2d014486c33 100644 --- a/sound/aoa/codecs/toonie.c +++ b/sound/aoa/codecs/toonie.c @@ -30,7 +30,7 @@ static int toonie_dev_register(struct snd_device *dev) return 0; } -static struct snd_device_ops ops = { +static const struct snd_device_ops ops = { .dev_register = toonie_dev_register, }; diff --git a/sound/aoa/core/alsa.c b/sound/aoa/core/alsa.c index fcf30f0c3adb..b61081342266 100644 --- a/sound/aoa/core/alsa.c +++ b/sound/aoa/core/alsa.c @@ -59,7 +59,7 @@ void aoa_alsa_cleanup(void) } int aoa_snd_device_new(enum snd_device_type type, - void * device_data, struct snd_device_ops * ops) + void *device_data, const struct snd_device_ops *ops) { struct snd_card *card = aoa_get_card(); int err; -- cgit v1.2.3 From 35a76585c6386115c065ebdda906f9a65a1b75ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:28 +0100 Subject: ALSA: mips: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-13-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/mips/hal2.c | 2 +- sound/mips/sgio2audio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index db44d9d691db..ec84bc4c3a6e 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -732,7 +732,7 @@ static int hal2_dev_free(struct snd_device *device) return 0; } -static struct snd_device_ops hal2_ops = { +static const struct snd_device_ops hal2_ops = { .dev_free = hal2_dev_free, }; diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index f10a08a8777f..9f60a5037f8b 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -787,7 +787,7 @@ static int snd_sgio2audio_dev_free(struct snd_device *device) return snd_sgio2audio_free(chip); } -static struct snd_device_ops ops = { +static const struct snd_device_ops ops = { .dev_free = snd_sgio2audio_dev_free, }; -- cgit v1.2.3 From 65341589599a17465c25ae760e9b317b3596eb8c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:29 +0100 Subject: ALSA: parisc: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-14-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index ea3630217d39..d330f22a3e8f 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -881,7 +881,7 @@ snd_harmony_create(struct snd_card *card, { int err; struct snd_harmony *h; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_harmony_dev_free, }; -- cgit v1.2.3 From 0326564d725f441617139ea5e862bf82a527dd08 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:30 +0100 Subject: ALSA: pcmcia: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-15-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 2 +- sound/pcmcia/vx/vxpocket.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index eed2d60178e4..6c33ea91cc05 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -82,7 +82,7 @@ static int snd_pdacf_probe(struct pcmcia_device *link) int i, err; struct snd_pdacf *pdacf; struct snd_card *card; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_pdacf_dev_free, }; diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index f924d8819f9d..cad603ca0d93 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -126,7 +126,7 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl, { struct vx_core *chip; struct snd_vxpocket *vxp; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; int err; -- cgit v1.2.3 From 46dd47c106f11587cf5887710765868e5bb53ce6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:31 +0100 Subject: ALSA: ppc: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-16-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 026410c7dd71..6ee97008c8f0 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -1143,7 +1143,7 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) int i, err; unsigned int irq; unsigned long ctrl_addr, txdma_addr, rxdma_addr; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_pmac_dev_free, }; -- cgit v1.2.3 From b75851d43d73c68f302d7c11dc3ae23598c57990 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:32 +0100 Subject: ALSA: sparc: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-17-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 2 +- sound/sparc/cs4231.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index df1b16c97d16..916bed46be06 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -912,7 +912,7 @@ static int snd_amd7930_dev_free(struct snd_device *device) return snd_amd7930_free(amd); } -static struct snd_device_ops snd_amd7930_dev_ops = { +static const struct snd_device_ops snd_amd7930_dev_ops = { .dev_free = snd_amd7930_dev_free, }; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 1676d44769ad..476ffaa413d9 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1771,7 +1771,7 @@ static int snd_cs4231_sbus_dev_free(struct snd_device *device) return snd_cs4231_sbus_free(cp); } -static struct snd_device_ops snd_cs4231_sbus_dev_ops = { +static const struct snd_device_ops snd_cs4231_sbus_dev_ops = { .dev_free = snd_cs4231_sbus_dev_free, }; @@ -1937,7 +1937,7 @@ static int snd_cs4231_ebus_dev_free(struct snd_device *device) return snd_cs4231_ebus_free(cp); } -static struct snd_device_ops snd_cs4231_ebus_dev_ops = { +static const struct snd_device_ops snd_cs4231_ebus_dev_ops = { .dev_free = snd_cs4231_ebus_dev_free, }; -- cgit v1.2.3 From 52b136d24842b3e7dfd6ed10d349841a90c754ac Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:33 +0100 Subject: ALSA: sh: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-18-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/sh_dac_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index b1e171dfe361..4affdc128119 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -325,7 +325,7 @@ static int snd_sh_dac_create(struct snd_card *card, struct snd_sh_dac *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_sh_dac_dev_free, }; -- cgit v1.2.3 From c3b53df3d00848936b286c41fae09cf9a5192ce0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:34 +0100 Subject: ALSA: spi: Constify snd_device_ops definitions Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-19-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 77563baf7a8f..d6f2b19cfa39 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -874,7 +874,7 @@ static int snd_at73c213_dev_free(struct snd_device *device) static int snd_at73c213_dev_init(struct snd_card *card, struct spi_device *spi) { - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_at73c213_dev_free, }; struct snd_at73c213 *chip = get_chip(card); -- cgit v1.2.3 From e382d7fcfc3ff21c8ba97a29bd451a289f57b757 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:35 +0100 Subject: ALSA: docs: Constify snd_device_ops definitions Update the documentation for adding the const prefix to snd_device_ops definitions as well. Link: https://lore.kernel.org/r/20200103081714.9560-20-tiwai@suse.de Signed-off-by: Takashi Iwai --- Documentation/sound/kernel-api/writing-an-alsa-driver.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst index f169d58ca019..7b1ba1e447b9 100644 --- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst +++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst @@ -259,7 +259,7 @@ to details explained in the following section. { struct mychip *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_mychip_dev_free, }; @@ -675,7 +675,7 @@ low-level device with a specified ``ops``, :: - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_mychip_dev_free, }; .... @@ -761,7 +761,7 @@ destructor and PCI entries. Example code is shown first, below. { struct mychip *chip; int err; - static struct snd_device_ops ops = { + static const struct snd_device_ops ops = { .dev_free = snd_mychip_dev_free, }; -- cgit v1.2.3 From df76996a2c5369769b23a017b6303f7ecacb277b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:36 +0100 Subject: ALSA: timer: Constify snd_timer_hardware definitions Most of snd_timer_hardware definitions do simply copying to another struct as-is. Mark them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-21-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/pcm_timer.c | 2 +- sound/core/timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c index 7928bda235c1..c43484b22b34 100644 --- a/sound/core/pcm_timer.c +++ b/sound/core/pcm_timer.c @@ -75,7 +75,7 @@ static int snd_pcm_timer_stop(struct snd_timer * timer) return 0; } -static struct snd_timer_hardware snd_pcm_timer = +static const struct snd_timer_hardware snd_pcm_timer = { .flags = SNDRV_TIMER_HW_AUTO | SNDRV_TIMER_HW_SLAVE, .resolution = 0, diff --git a/sound/core/timer.c b/sound/core/timer.c index d53bc1f3a48a..8835ff91a893 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1199,7 +1199,7 @@ static int snd_timer_s_close(struct snd_timer *timer) return 0; } -static struct snd_timer_hardware snd_timer_system = +static const struct snd_timer_hardware snd_timer_system = { .flags = SNDRV_TIMER_HW_FIRST | SNDRV_TIMER_HW_TASKLET, .resolution = 1000000000L / HZ, -- cgit v1.2.3 From 5ff16a3d48ef58be8fd93035ae9272d4cc990c49 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:37 +0100 Subject: ALSA: Constify snd_timer_hardware definitions Most of snd_timer_hardware definitions do simply copying to another struct as-is. Mark them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-22-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_lib.c | 4 ++-- sound/isa/gus/gus_timer.c | 4 ++-- sound/isa/wss/wss_lib.c | 2 +- sound/pci/emu10k1/timer.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 2 +- sound/sparc/cs4231.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index 6134e5ffea0b..9259522483c8 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -214,7 +214,7 @@ static int snd_opl3_timer2_stop(struct snd_timer * timer) */ -static struct snd_timer_hardware snd_opl3_timer1 = +static const struct snd_timer_hardware snd_opl3_timer1 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 80000, @@ -223,7 +223,7 @@ static struct snd_timer_hardware snd_opl3_timer1 = .stop = snd_opl3_timer1_stop, }; -static struct snd_timer_hardware snd_opl3_timer2 = +static const struct snd_timer_hardware snd_opl3_timer2 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 320000, diff --git a/sound/isa/gus/gus_timer.c b/sound/isa/gus/gus_timer.c index 4e9664e434fe..047ddbc6192f 100644 --- a/sound/isa/gus/gus_timer.c +++ b/sound/isa/gus/gus_timer.c @@ -108,7 +108,7 @@ static void snd_gf1_interrupt_timer2(struct snd_gus_card * gus) */ -static struct snd_timer_hardware snd_gf1_timer1 = +static const struct snd_timer_hardware snd_gf1_timer1 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 80000, @@ -117,7 +117,7 @@ static struct snd_timer_hardware snd_gf1_timer1 = .stop = snd_gf1_timer1_stop, }; -static struct snd_timer_hardware snd_gf1_timer2 = +static const struct snd_timer_hardware snd_gf1_timer2 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 320000, diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index b51b50154e8a..0d019b238399 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -961,7 +961,7 @@ static int snd_wss_timer_close(struct snd_timer *timer) return 0; } -static struct snd_timer_hardware snd_wss_timer_table = +static const struct snd_timer_hardware snd_wss_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, diff --git a/sound/pci/emu10k1/timer.c b/sound/pci/emu10k1/timer.c index 9ef3b999dcd6..c2803000aace 100644 --- a/sound/pci/emu10k1/timer.c +++ b/sound/pci/emu10k1/timer.c @@ -52,7 +52,7 @@ static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer, return 0; } -static struct snd_timer_hardware snd_emu10k1_timer_hw = { +static const struct snd_timer_hardware snd_emu10k1_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */ .ticks = 1024, diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 2e20cd9d8cfc..1d9295bb00a9 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1908,7 +1908,7 @@ static int snd_ymfpci_timer_precise_resolution(struct snd_timer *timer, return 0; } -static struct snd_timer_hardware snd_ymfpci_timer_hw = { +static const struct snd_timer_hardware snd_ymfpci_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 10417, /* 1 / 96 kHz = 10.41666...us */ .ticks = 0x10000, diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 476ffaa413d9..b0e5b4a83a26 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -869,7 +869,7 @@ static int snd_cs4231_timer_close(struct snd_timer *timer) return 0; } -static struct snd_timer_hardware snd_cs4231_timer_table = { +static const struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, .ticks = 65535, -- cgit v1.2.3 From 19260818a9747768b09c1c1f10b4125b4d00595e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:38 +0100 Subject: ALSA: ac97: Treat snd_ac97_bus_ops as const This is a preliminary patch to allow const for snd_ac97_bus_ops definitions in each driver's code. The ops reference is read-only, hence it can be declared as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-23-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/ac97_codec.h | 5 +++-- sound/ac97_bus.c | 2 +- sound/pci/ac97/ac97_codec.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index cc383991c0fe..49200ec26dc4 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -197,7 +197,7 @@ struct snd_ac97_bus_ops { struct snd_ac97_bus { /* -- lowlevel (hardware) driver specific -- */ - struct snd_ac97_bus_ops *ops; + const struct snd_ac97_bus_ops *ops; void *private_data; void (*private_free) (struct snd_ac97_bus *bus); /* --- */ @@ -310,7 +310,8 @@ static inline int ac97_can_spdif(struct snd_ac97 * ac97) /* functions */ /* create new AC97 bus */ -int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, +int snd_ac97_bus(struct snd_card *card, int num, + const struct snd_ac97_bus_ops *ops, void *private_data, struct snd_ac97_bus **rbus); /* create mixer controls */ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, diff --git a/sound/ac97_bus.c b/sound/ac97_bus.c index 3732a63a2a81..b4685c53ff11 100644 --- a/sound/ac97_bus.c +++ b/sound/ac97_bus.c @@ -55,7 +55,7 @@ static bool snd_ac97_check_id(struct snd_ac97 *ac97, unsigned int id, int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id, unsigned int id_mask) { - struct snd_ac97_bus_ops *ops = ac97->bus->ops; + const struct snd_ac97_bus_ops *ops = ac97->bus->ops; if (try_warm && ops->warm_reset) { ops->warm_reset(ac97); diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 41bdec4249e1..fcfa8499e453 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1894,7 +1894,8 @@ static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem) * * Return: Zero if successful, or a negative error code on failure. */ -int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, +int snd_ac97_bus(struct snd_card *card, int num, + const struct snd_ac97_bus_ops *ops, void *private_data, struct snd_ac97_bus **rbus) { int err; -- cgit v1.2.3 From 33c83aaf29f54f948467240dd9a2a7242126e146 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:39 +0100 Subject: ALSA: ac97: Constify snd_ac97_bus_ops definitions Now snd_ac97_bus() takes the const ops pointer, so we can define the snd_ac97_bus_ops locally as const as well for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-24-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ac97/snd_ac97_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/ac97/snd_ac97_compat.c b/sound/ac97/snd_ac97_compat.c index 715daf141713..d2479bba75bf 100644 --- a/sound/ac97/snd_ac97_compat.c +++ b/sound/ac97/snd_ac97_compat.c @@ -53,7 +53,7 @@ static unsigned short compat_ac97_read(struct snd_ac97 *ac97, return actrl->ops->read(actrl, ac97->num, reg); } -static struct snd_ac97_bus_ops compat_snd_ac97_bus_ops = { +static const struct snd_ac97_bus_ops compat_snd_ac97_bus_ops = { .reset = compat_ac97_reset, .warm_reset = compat_ac97_warm_reset, .write = compat_ac97_write, -- cgit v1.2.3 From 74d2bae3434aef8e63d395559b25988275f81885 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:40 +0100 Subject: ALSA: arm: Constify snd_ac97_bus_ops definitions Now snd_ac97_bus() takes the const ops pointer, so we can define the snd_ac97_bus_ops locally as const as well for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-25-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 +- sound/arm/pxa2xx-ac97.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index d1b5dbcd9e87..d663bd7adae6 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -811,7 +811,7 @@ static const struct ac97_pcm ac97_defs[] = { } }; -static struct snd_ac97_bus_ops aaci_bus_ops = { +static const struct snd_ac97_bus_ops aaci_bus_ops = { .write = aaci_ac97_write, .read = aaci_ac97_read, }; diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index 08ae55166890..ea8e233150c8 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -52,7 +52,7 @@ static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97, ret = pxa2xx_ac97_write(ac97->num, reg, val); } -static struct snd_ac97_bus_ops pxa2xx_ac97_ops = { +static const struct snd_ac97_bus_ops pxa2xx_ac97_ops = { .read = pxa2xx_ac97_legacy_read, .write = pxa2xx_ac97_legacy_write, .reset = pxa2xx_ac97_legacy_reset, -- cgit v1.2.3 From 3a3fac8b3b99614d2e4df6b244a313eb5b2716a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:41 +0100 Subject: ALSA: atmel: Constify snd_ac97_bus_ops definitions Now snd_ac97_bus() takes the const ops pointer, so we can define the snd_ac97_bus_ops locally as const as well for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-26-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 658b4d385249..a1dce9725b98 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -702,7 +702,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev) struct atmel_ac97c *chip; struct resource *regs; struct clk *pclk; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = atmel_ac97c_write, .read = atmel_ac97c_read, }; -- cgit v1.2.3 From 6e6598db079d443c76b808faae542dd4edd52b02 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:42 +0100 Subject: ALSA: drivers: Constify snd_ac97_bus_ops definitions Now snd_ac97_bus() takes the const ops pointer, so we can define the snd_ac97_bus_ops locally as const as well for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-27-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/ml403-ac97cr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index 2cec7c5bf8fd..0a039bf4650f 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -1172,7 +1172,7 @@ snd_ml403_ac97cr_mixer(struct snd_ml403_ac97cr *ml403_ac97cr) struct snd_ac97_bus *bus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_ml403_ac97cr_codec_write, .read = snd_ml403_ac97cr_codec_read, }; -- cgit v1.2.3 From 51055da51d1e92bb089c9b9e0ecb1be69396f808 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:43 +0100 Subject: ALSA: pci: Constify snd_ac97_bus_ops definitions Now snd_ac97_bus() takes the const ops pointer, so we can define the snd_ac97_bus_ops locally as const as well for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-28-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 2 +- sound/pci/ali5451/ali5451.c | 2 +- sound/pci/als300.c | 2 +- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/au88x0/au88x0_mixer.c | 2 +- sound/pci/azt3328.c | 2 +- sound/pci/ca0106/ca0106_main.c | 2 +- sound/pci/cs4281.c | 2 +- sound/pci/cs46xx/cs46xx_lib.c | 2 +- sound/pci/cs5535audio/cs5535audio.c | 2 +- sound/pci/emu10k1/emu10k1x.c | 2 +- sound/pci/emu10k1/emumixer.c | 2 +- sound/pci/ens1370.c | 2 +- sound/pci/es1968.c | 2 +- sound/pci/fm801.c | 2 +- sound/pci/ice1712/ice1712.c | 4 ++-- sound/pci/ice1712/ice1724.c | 2 +- sound/pci/intel8x0.c | 6 +++--- sound/pci/intel8x0m.c | 2 +- sound/pci/maestro3.c | 2 +- sound/pci/nm256/nm256.c | 2 +- sound/pci/riptide/riptide.c | 2 +- sound/pci/sis7019.c | 2 +- sound/pci/trident/trident_main.c | 2 +- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- sound/pci/ymfpci/ymfpci_main.c | 2 +- 28 files changed, 31 insertions(+), 31 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 3daa978263f6..5d42c42491bf 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -760,7 +760,7 @@ snd_ad1889_ac97_init(struct snd_ad1889 *chip, const char *quirk_override) { int err; struct snd_ac97_template ac97; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_ad1889_ac97_write, .read = snd_ad1889_ac97_read, }; diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 39c33a944e5d..b2374266c52c 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1791,7 +1791,7 @@ static int snd_ali_mixer(struct snd_ali *codec) struct snd_ac97_template ac97; unsigned int idx; int i, err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_ali_codec_write, .read = snd_ali_codec_read, }; diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 64d978307755..8d2471ea090b 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -294,7 +294,7 @@ static int snd_als300_ac97(struct snd_als300 *chip) struct snd_ac97_bus *bus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_als300_ac97_write, .read = snd_als300_ac97_read, }; diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 61ae4fe8d646..c3281fab365d 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1403,7 +1403,7 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, struct snd_ac97_template ac97; int i, err; int codec_count; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index b62cde3a00b2..3ec34e78ffef 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1046,7 +1046,7 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) struct snd_ac97_template ac97; int i, err; int codec_count; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; diff --git a/sound/pci/au88x0/au88x0_mixer.c b/sound/pci/au88x0/au88x0_mixer.c index 60dd8a091bc3..5b647682b683 100644 --- a/sound/pci/au88x0/au88x0_mixer.c +++ b/sound/pci/au88x0/au88x0_mixer.c @@ -25,7 +25,7 @@ static int snd_vortex_mixer(vortex_t *vortex) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = vortex_codec_write, .read = vortex_codec_read, }; diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 810d5772f097..898ba55fc0dd 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -757,7 +757,7 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip) { struct snd_ac97_bus *bus; struct snd_ac97_template ac97; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_azf3328_mixer_ac97_write, .read = snd_azf3328_mixer_ac97_read, }; diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index e65154cecad5..d3bd27ddb049 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1161,7 +1161,7 @@ static int snd_ca0106_ac97(struct snd_ca0106 *chip) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_ca0106_ac97_write, .read = snd_ca0106_ac97_read, }; diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 75450e329cee..8fd64dab372d 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1064,7 +1064,7 @@ static int snd_cs4281_mixer(struct cs4281 *chip) struct snd_card *card = chip->card; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_cs4281_ac97_write, .read = snd_cs4281_ac97_read, }; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 6251fa8da939..3f2fe26efee3 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2465,7 +2465,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) struct snd_ctl_elem_id id; int err; unsigned int idx; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { #ifdef CONFIG_SND_CS46XX_NEW_DSP .reset = snd_cs46xx_codec_reset, #endif diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 930c2ac405e5..11ce3c4589fa 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -138,7 +138,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_cs5535audio_ac97_codec_write, .read = snd_cs5535audio_ac97_codec_read, }; diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 90ae1c72d663..ddb7c2ce3f7c 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -718,7 +718,7 @@ static int snd_emu10k1x_ac97(struct emu10k1x *chip) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_emu10k1x_ac97_write, .read = snd_emu10k1x_ac97_read, }; diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 7c0417253cb5..0b3dfc71fa69 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -1898,7 +1898,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, if (emu->card_capabilities->ac97_chip) { struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_emu10k1_ac97_write, .read = snd_emu10k1_ac97_read, }; diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 7611e44e2af5..15e6d2377ecf 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1596,7 +1596,7 @@ static int snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_es1371_codec_write, .read = snd_es1371_codec_read, .wait = snd_es1371_codec_wait, diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 43cfdf02048b..f23a935267c3 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2007,7 +2007,7 @@ snd_es1968_mixer(struct es1968 *chip) struct snd_ctl_elem_id elem_id; #endif int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_es1968_ac97_write, .read = snd_es1968_ac97_read, }; diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index bb5cffee5dac..ae2b413ff489 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1020,7 +1020,7 @@ static int snd_fm801_mixer(struct fm801 *chip) struct snd_ac97_template ac97; unsigned int i; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_fm801_codec_write, .read = snd_fm801_codec_read, }; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 15cb90dceeb8..9794bbedffc3 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -1464,11 +1464,11 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice) int err, bus_num = 0; struct snd_ac97_template ac97; struct snd_ac97_bus *pbus; - static struct snd_ac97_bus_ops con_ops = { + static const struct snd_ac97_bus_ops con_ops = { .write = snd_ice1712_ac97_write, .read = snd_ice1712_ac97_read, }; - static struct snd_ac97_bus_ops pro_ops = { + static const struct snd_ac97_bus_ops pro_ops = { .write = snd_ice1712_pro_ac97_write, .read = snd_ice1712_pro_ac97_read, }; diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 628b0581a4ff..4630a8c42aa9 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -1463,7 +1463,7 @@ static int snd_vt1724_ac97_mixer(struct snd_ice1712 *ice) if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) { struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_vt1724_ac97_write, .read = snd_vt1724_ac97_read, }; diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 563f3a3e820e..de875ea8ecbe 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2138,12 +2138,12 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock, int err; unsigned int i, codecs; unsigned int glob_sta = 0; - struct snd_ac97_bus_ops *ops; - static struct snd_ac97_bus_ops standard_bus_ops = { + const struct snd_ac97_bus_ops *ops; + static const struct snd_ac97_bus_ops standard_bus_ops = { .write = snd_intel8x0_codec_write, .read = snd_intel8x0_codec_read, }; - static struct snd_ac97_bus_ops ali_bus_ops = { + static const struct snd_ac97_bus_ops ali_bus_ops = { .write = snd_intel8x0_ali_codec_write, .read = snd_intel8x0_ali_codec_read, }; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index c6dc36167a01..74d45b9a1571 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -801,7 +801,7 @@ static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock) struct snd_ac97 *x97; int err; unsigned int glob_sta = 0; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_intel8x0m_codec_write, .read = snd_intel8x0m_codec_read, }; diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index b94e3ec5f158..89018d44d777 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2036,7 +2036,7 @@ static int snd_m3_mixer(struct snd_m3 *chip) struct snd_ctl_elem_id elem_id; #endif int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_m3_ac97_write, .read = snd_m3_ac97_read, }; diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 003a09788572..99228b93b3c6 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1309,7 +1309,7 @@ snd_nm256_mixer(struct nm256 *chip) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .reset = snd_nm256_ac97_reset, .write = snd_nm256_ac97_write, .read = snd_nm256_ac97_read, diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 6617bc347bfb..625c85428955 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1963,7 +1963,7 @@ static int snd_riptide_mixer(struct snd_riptide *chip) struct snd_ac97_bus *pbus; struct snd_ac97_template ac97; int err = 0; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_riptide_codec_write, .read = snd_riptide_codec_read, }; diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 2e351bf1d792..4977ab0b8b3d 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -983,7 +983,7 @@ static int sis_mixer_create(struct sis7019 *sis) { struct snd_ac97_bus *bus; struct snd_ac97_template ac97; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = sis_ac97_write, .read = sis_ac97_read, }; diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index ba4a9fcd5eba..6e50376163a2 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2912,7 +2912,7 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) struct snd_kcontrol *kctl; struct snd_ctl_elem_value *uctl; int idx, err, retries = 2; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_trident_codec_write, .read = snd_trident_codec_read, }; diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 090b0c47fbdd..c8fb51885b6d 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1868,7 +1868,7 @@ static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_overrid { struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_via82xx_codec_write, .read = snd_via82xx_codec_read, .wait = snd_via82xx_codec_wait, diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 7f138fa4e141..84e589803e2e 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -871,7 +871,7 @@ static int snd_via82xx_mixer_new(struct via82xx_modem *chip) { struct snd_ac97_template ac97; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_via82xx_codec_write, .read = snd_via82xx_codec_read, .wait = snd_via82xx_codec_wait, diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 1d9295bb00a9..a531f4d2605d 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1780,7 +1780,7 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) struct snd_pcm_substream *substream; unsigned int idx; int err; - static struct snd_ac97_bus_ops ops = { + static const struct snd_ac97_bus_ops ops = { .write = snd_ymfpci_codec_write, .read = snd_ymfpci_codec_read, }; -- cgit v1.2.3 From d25ff26840bd0af3283d8e478669abc104bb873a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:44 +0100 Subject: ALSA: info: Make snd_info_entry_ops as const The reference to snd_info_entry_ops is rather read-only, so declare it as a const pointer. This allows a bit more optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-29-tiwai@suse.de Signed-off-by: Takashi Iwai --- Documentation/sound/kernel-api/writing-an-alsa-driver.rst | 2 +- include/sound/info.h | 2 +- sound/drivers/opl4/opl4_proc.c | 2 +- sound/isa/gus/gus_mem_proc.c | 2 +- sound/pci/cs4281.c | 4 ++-- sound/pci/cs46xx/cs46xx_lib.c | 2 +- sound/pci/emu10k1/emuproc.c | 2 +- sound/pci/mixart/mixart.c | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst index 7b1ba1e447b9..8204e3b6fea6 100644 --- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst +++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst @@ -3912,7 +3912,7 @@ For a raw-data proc-file, set the attributes as follows: :: - static struct snd_info_entry_ops my_file_io_ops = { + static const struct snd_info_entry_ops my_file_io_ops = { .read = my_file_io_read, }; diff --git a/include/sound/info.h b/include/sound/info.h index b01a22913400..7c13bf52cc81 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -64,7 +64,7 @@ struct snd_info_entry { unsigned short content; union { struct snd_info_entry_text text; - struct snd_info_entry_ops *ops; + const struct snd_info_entry_ops *ops; } c; struct snd_info_entry *parent; struct module *module; diff --git a/sound/drivers/opl4/opl4_proc.c b/sound/drivers/opl4/opl4_proc.c index e0516e532969..f2149091e10a 100644 --- a/sound/drivers/opl4/opl4_proc.c +++ b/sound/drivers/opl4/opl4_proc.c @@ -76,7 +76,7 @@ static ssize_t snd_opl4_mem_proc_write(struct snd_info_entry *entry, return count; } -static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { +static const struct snd_info_entry_ops snd_opl4_mem_proc_ops = { .open = snd_opl4_mem_proc_open, .release = snd_opl4_mem_proc_release, .read = snd_opl4_mem_proc_read, diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c index 54510e2d78c2..b5e1d1649500 100644 --- a/sound/isa/gus/gus_mem_proc.c +++ b/sound/isa/gus/gus_mem_proc.c @@ -37,7 +37,7 @@ static void snd_gf1_mem_proc_free(struct snd_info_entry *entry) kfree(priv); } -static struct snd_info_entry_ops snd_gf1_mem_proc_ops = { +static const struct snd_info_entry_ops snd_gf1_mem_proc_ops = { .read = snd_gf1_mem_proc_dump, }; diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 8fd64dab372d..dc89ef906c9b 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1129,11 +1129,11 @@ static ssize_t snd_cs4281_BA1_read(struct snd_info_entry *entry, return count; } -static struct snd_info_entry_ops snd_cs4281_proc_ops_BA0 = { +static const struct snd_info_entry_ops snd_cs4281_proc_ops_BA0 = { .read = snd_cs4281_BA0_read, }; -static struct snd_info_entry_ops snd_cs4281_proc_ops_BA1 = { +static const struct snd_info_entry_ops snd_cs4281_proc_ops_BA1 = { .read = snd_cs4281_BA1_read, }; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 3f2fe26efee3..5bb84303f577 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2815,7 +2815,7 @@ static ssize_t snd_cs46xx_io_read(struct snd_info_entry *entry, return count; } -static struct snd_info_entry_ops snd_cs46xx_proc_io_ops = { +static const struct snd_info_entry_ops snd_cs46xx_proc_io_ops = { .read = snd_cs46xx_io_read, }; diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index d32f256af809..637446f19598 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -545,7 +545,7 @@ static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry, } #endif -static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { +static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { .read = snd_emu10k1_fx8010_read, }; diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 44009c555322..7ba487443c7f 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1153,11 +1153,11 @@ static ssize_t snd_mixart_BA1_read(struct snd_info_entry *entry, return count; } -static struct snd_info_entry_ops snd_mixart_proc_ops_BA0 = { +static const struct snd_info_entry_ops snd_mixart_proc_ops_BA0 = { .read = snd_mixart_BA0_read, }; -static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { +static const struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { .read = snd_mixart_BA1_read, }; -- cgit v1.2.3 From aad7ebb544072bcb9335fa4eb0fbd1b85a6c495b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:45 +0100 Subject: ALSA: seq: Constify struct snd_midi_op Change the argument of snd_midi_process_event() to receive a const snd_midi_op pointer and its callers respectively. This allows further optimizations. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-30-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/seq_midi_emul.h | 3 ++- sound/core/seq/seq_midi_emul.c | 37 ++++++++++++++++++++++--------------- sound/drivers/opl3/opl3_seq.c | 2 +- sound/drivers/opl3/opl3_voice.h | 2 +- sound/drivers/opl4/opl4_seq.c | 2 +- sound/synth/emux/emux_seq.c | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/sound/seq_midi_emul.h b/include/sound/seq_midi_emul.h index d6b74059b4b1..88799d1e1f53 100644 --- a/include/sound/seq_midi_emul.h +++ b/include/sound/seq_midi_emul.h @@ -174,7 +174,8 @@ enum { }; /* Prototypes for midi_process.c */ -void snd_midi_process_event(struct snd_midi_op *ops, struct snd_seq_event *ev, +void snd_midi_process_event(const struct snd_midi_op *ops, + struct snd_seq_event *ev, struct snd_midi_channel_set *chanset); void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset); struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n); diff --git a/sound/core/seq/seq_midi_emul.c b/sound/core/seq/seq_midi_emul.c index 770d3f4eee7c..536ccf48ee72 100644 --- a/sound/core/seq/seq_midi_emul.c +++ b/sound/core/seq/seq_midi_emul.c @@ -30,22 +30,25 @@ MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI emulation." MODULE_LICENSE("GPL"); /* Prototypes for static functions */ -static void note_off(struct snd_midi_op *ops, void *drv, +static void note_off(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, int note, int vel); -static void do_control(struct snd_midi_op *ops, void *private, +static void do_control(const struct snd_midi_op *ops, void *private, struct snd_midi_channel_set *chset, struct snd_midi_channel *chan, int control, int value); -static void rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, +static void rpn(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan, struct snd_midi_channel_set *chset); -static void nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, +static void nrpn(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan, struct snd_midi_channel_set *chset); -static void sysex(struct snd_midi_op *ops, void *private, unsigned char *sysex, +static void sysex(const struct snd_midi_op *ops, void *private, + unsigned char *sysex, int len, struct snd_midi_channel_set *chset); -static void all_sounds_off(struct snd_midi_op *ops, void *private, +static void all_sounds_off(const struct snd_midi_op *ops, void *private, struct snd_midi_channel *chan); -static void all_notes_off(struct snd_midi_op *ops, void *private, +static void all_notes_off(const struct snd_midi_op *ops, void *private, struct snd_midi_channel *chan); static void snd_midi_reset_controllers(struct snd_midi_channel *chan); static void reset_all_channels(struct snd_midi_channel_set *chset); @@ -66,7 +69,7 @@ static void reset_all_channels(struct snd_midi_channel_set *chset); * be interpreted. */ void -snd_midi_process_event(struct snd_midi_op *ops, +snd_midi_process_event(const struct snd_midi_op *ops, struct snd_seq_event *ev, struct snd_midi_channel_set *chanset) { @@ -229,7 +232,8 @@ EXPORT_SYMBOL(snd_midi_process_event); * release note */ static void -note_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, +note_off(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan, int note, int vel) { if (chan->gm_hold) { @@ -251,7 +255,8 @@ note_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, * events that need to take place immediately to the driver. */ static void -do_control(struct snd_midi_op *ops, void *drv, struct snd_midi_channel_set *chset, +do_control(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel_set *chset, struct snd_midi_channel *chan, int control, int value) { int i; @@ -402,7 +407,7 @@ EXPORT_SYMBOL(snd_midi_channel_set_clear); * Process a rpn message. */ static void -rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, +rpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, struct snd_midi_channel_set *chset) { int type; @@ -442,7 +447,7 @@ rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, * Process an nrpn message. */ static void -nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, +nrpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, struct snd_midi_channel_set *chset) { /* parse XG NRPNs here if possible */ @@ -470,7 +475,7 @@ get_channel(unsigned char cmd) * Process a sysex message. */ static void -sysex(struct snd_midi_op *ops, void *private, unsigned char *buf, int len, +sysex(const struct snd_midi_op *ops, void *private, unsigned char *buf, int len, struct snd_midi_channel_set *chset) { /* GM on */ @@ -584,7 +589,8 @@ sysex(struct snd_midi_op *ops, void *private, unsigned char *buf, int len, * all sound off */ static void -all_sounds_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan) +all_sounds_off(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan) { int n; @@ -602,7 +608,8 @@ all_sounds_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan * all notes off */ static void -all_notes_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan) +all_notes_off(const struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan) { int n; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 20f2f5125394..cd2a01b5e2e1 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -128,7 +128,7 @@ static int snd_opl3_synth_unuse(void *private_data, struct snd_seq_port_subscrib /* * MIDI emulation operators */ -struct snd_midi_op opl3_ops = { +const struct snd_midi_op opl3_ops = { .note_on = snd_opl3_note_on, .note_off = snd_opl3_note_off, .key_press = snd_opl3_key_press, diff --git a/sound/drivers/opl3/opl3_voice.h b/sound/drivers/opl3/opl3_voice.h index dc0626a2dd61..be9ccca2d952 100644 --- a/sound/drivers/opl3/opl3_voice.h +++ b/sound/drivers/opl3/opl3_voice.h @@ -41,6 +41,6 @@ void snd_opl3_free_seq_oss(struct snd_opl3 *opl3); extern char snd_opl3_regmap[MAX_OPL2_VOICES][4]; extern bool use_internal_drums; -extern struct snd_midi_op opl3_ops; +extern const struct snd_midi_op opl3_ops; #endif diff --git a/sound/drivers/opl4/opl4_seq.c b/sound/drivers/opl4/opl4_seq.c index 03d6202f4829..f59ca660c616 100644 --- a/sound/drivers/opl4/opl4_seq.c +++ b/sound/drivers/opl4/opl4_seq.c @@ -100,7 +100,7 @@ static int snd_opl4_seq_unuse(void *private_data, struct snd_seq_port_subscribe return 0; } -static struct snd_midi_op opl4_ops = { +static const struct snd_midi_op opl4_ops = { .note_on = snd_opl4_note_on, .note_off = snd_opl4_note_off, .note_terminate = snd_opl4_terminate_note, diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 9d8a69f1a644..b227c7e0bc2a 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -19,7 +19,7 @@ static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *inf /* * MIDI emulation operators */ -static struct snd_midi_op emux_ops = { +static const struct snd_midi_op emux_ops = { .note_on = snd_emux_note_on, .note_off = snd_emux_note_off, .key_press = snd_emux_key_press, -- cgit v1.2.3 From f8ae2d2919481817d2e942617c203fc792687c66 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:46 +0100 Subject: ALSA: vx: Constify snd_vx_hardware and snd_vx_ops definitions Both snd_vx_hardware and snd_vx_ops are only referred without modification, hence they can be constified gracefully for further optimizations. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-31-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/vx_core.h | 9 +++++---- sound/drivers/vx/vx_core.c | 5 +++-- sound/pci/vx222/vx222.c | 12 ++++++------ sound/pci/vx222/vx222.h | 4 ++-- sound/pci/vx222/vx222_ops.c | 4 ++-- sound/pcmcia/vx/vxp_ops.c | 2 +- sound/pcmcia/vx/vxpocket.c | 4 ++-- sound/pcmcia/vx/vxpocket.h | 2 +- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h index 84569ddf85e1..1ddd3036bdfc 100644 --- a/include/sound/vx_core.h +++ b/include/sound/vx_core.h @@ -147,8 +147,8 @@ struct vx_core { /* ports are defined externally */ /* low-level functions */ - struct snd_vx_hardware *hw; - struct snd_vx_ops *ops; + const struct snd_vx_hardware *hw; + const struct snd_vx_ops *ops; struct mutex lock; @@ -193,8 +193,9 @@ struct vx_core { /* * constructor */ -struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, - struct snd_vx_ops *ops, int extra_size); +struct vx_core *snd_vx_create(struct snd_card *card, + const struct snd_vx_hardware *hw, + const struct snd_vx_ops *ops, int extra_size); int snd_vx_setup_firmware(struct vx_core *chip); int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *dsp); int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *dsp); diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index 6bbc2a4f85c1..dd35de3f2434 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -765,8 +765,9 @@ EXPORT_SYMBOL(snd_vx_resume); * * return the instance pointer if successful, NULL in error. */ -struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, - struct snd_vx_ops *ops, +struct vx_core *snd_vx_create(struct snd_card *card, + const struct snd_vx_hardware *hw, + const struct snd_vx_ops *ops, int extra_size) { struct vx_core *chip; diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index b278c72797d5..f7800ed1b67e 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -62,7 +62,7 @@ MODULE_DEVICE_TABLE(pci, snd_vx222_ids); static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0); static const DECLARE_TLV_DB_SCALE(db_scale_akm, -7350, 50, 0); -static struct snd_vx_hardware vx222_old_hw = { +static const struct snd_vx_hardware vx222_old_hw = { .name = "VX222/Old", .type = VX_TYPE_BOARD, @@ -74,7 +74,7 @@ static struct snd_vx_hardware vx222_old_hw = { .output_level_db_scale = db_scale_old_vol, }; -static struct snd_vx_hardware vx222_v2_hw = { +static const struct snd_vx_hardware vx222_v2_hw = { .name = "VX222/v2", .type = VX_TYPE_V2, @@ -86,7 +86,7 @@ static struct snd_vx_hardware vx222_v2_hw = { .output_level_db_scale = db_scale_akm, }; -static struct snd_vx_hardware vx222_mic_hw = { +static const struct snd_vx_hardware vx222_mic_hw = { .name = "VX222/Mic", .type = VX_TYPE_MIC, @@ -122,7 +122,7 @@ static int snd_vx222_dev_free(struct snd_device *device) static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, - struct snd_vx_hardware *hw, + const struct snd_vx_hardware *hw, struct snd_vx222 **rchip) { struct vx_core *chip; @@ -131,7 +131,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, static const struct snd_device_ops ops = { .dev_free = snd_vx222_dev_free, }; - struct snd_vx_ops *vx_ops; + const struct snd_vx_ops *vx_ops; /* enable PCI device */ if ((err = pci_enable_device(pci)) < 0) @@ -180,7 +180,7 @@ static int snd_vx222_probe(struct pci_dev *pci, { static int dev; struct snd_card *card; - struct snd_vx_hardware *hw; + const struct snd_vx_hardware *hw; struct snd_vx222 *vx; int err; diff --git a/sound/pci/vx222/vx222.h b/sound/pci/vx222/vx222.h index d27af637125c..46ddc6858a61 100644 --- a/sound/pci/vx222/vx222.h +++ b/sound/pci/vx222/vx222.h @@ -31,8 +31,8 @@ struct snd_vx222 { /* we use a lookup table with 148 values, see vx_mixer.c */ #define VX2_AKM_LEVEL_MAX 0x93 -extern struct snd_vx_ops vx222_ops; -extern struct snd_vx_ops vx222_old_ops; +extern const struct snd_vx_ops vx222_ops; +extern const struct snd_vx_ops vx222_old_ops; /* Offset of registers with base equal to portDSP. */ #define VX_RESET_DMA_REGISTER_OFFSET 0x00000008 diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index c145951e2fc6..6245240d8768 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -984,7 +984,7 @@ static int vx2_add_mic_controls(struct vx_core *_chip) /* * callbacks */ -struct snd_vx_ops vx222_ops = { +const struct snd_vx_ops vx222_ops = { .in8 = vx2_inb, .in32 = vx2_inl, .out8 = vx2_outb, @@ -1004,7 +1004,7 @@ struct snd_vx_ops vx222_ops = { }; /* for old VX222 board */ -struct snd_vx_ops vx222_old_ops = { +const struct snd_vx_ops vx222_old_ops = { .in8 = vx2_inb, .in32 = vx2_inl, .out8 = vx2_outb, diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index 447c6342eec8..f7cf707d315f 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c @@ -581,7 +581,7 @@ static void vxp_reset_board(struct vx_core *_chip, int cold_reset) * callbacks */ /* exported */ -struct snd_vx_ops snd_vxpocket_ops = { +const struct snd_vx_ops snd_vxpocket_ops = { .in8 = vxp_inb, .out8 = vxp_outb, .test_and_ack = vxp_test_and_ack, diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index cad603ca0d93..afd30a90c807 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -82,7 +82,7 @@ static int snd_vxpocket_dev_free(struct snd_device *device) static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0); -static struct snd_vx_hardware vxpocket_hw = { +static const struct snd_vx_hardware vxpocket_hw = { .name = "VXPocket", .type = VX_TYPE_VXPOCKET, @@ -104,7 +104,7 @@ static struct snd_vx_hardware vxpocket_hw = { * UER, but only for the first two inputs and outputs. */ -static struct snd_vx_hardware vxp440_hw = { +static const struct snd_vx_hardware vxp440_hw = { .name = "VXPocket440", .type = VX_TYPE_VXP440, diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h index 6dbd9f6bd2ff..bce616cc3aca 100644 --- a/sound/pcmcia/vx/vxpocket.h +++ b/sound/pcmcia/vx/vxpocket.h @@ -32,7 +32,7 @@ struct snd_vxpocket { #define to_vxpocket(x) container_of(x, struct snd_vxpocket, core) -extern struct snd_vx_ops snd_vxpocket_ops; +extern const struct snd_vx_ops snd_vxpocket_ops; void vx_set_mic_boost(struct vx_core *chip, int boost); void vx_set_mic_level(struct vx_core *chip, int level); -- cgit v1.2.3 From 454f5ec1d2b774b89f3ea759a9a791f320e6f389 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:47 +0100 Subject: ALSA: mixer: oss: Constify snd_mixer_oss_assign_table definition The snd_mixer_oss_assign_table is read-only, and can it be declared as const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-32-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/oss/mixer_oss.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 7eb54df5556d..26502294f7d8 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -486,7 +486,7 @@ struct slot { unsigned int channels; unsigned int numid[SNDRV_MIXER_OSS_ITEM_COUNT]; unsigned int capture_item; - struct snd_mixer_oss_assign_table *assigned; + const struct snd_mixer_oss_assign_table *assigned; unsigned int allocated: 1; }; @@ -934,8 +934,8 @@ static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn) struct slot *p = chn->private_data; if (p) { if (p->allocated && p->assigned) { - kfree(p->assigned->name); - kfree(p->assigned); + kfree_const(p->assigned->name); + kfree_const(p->assigned); } kfree(p); } @@ -953,7 +953,7 @@ static void mixer_slot_clear(struct snd_mixer_oss_slot *rslot) /* In a separate function to keep gcc 3.2 happy - do NOT merge this in snd_mixer_oss_build_input! */ static int snd_mixer_oss_build_test_all(struct snd_mixer_oss *mixer, - struct snd_mixer_oss_assign_table *ptr, + const struct snd_mixer_oss_assign_table *ptr, struct slot *slot) { char str[64]; @@ -1017,7 +1017,9 @@ static int snd_mixer_oss_build_test_all(struct snd_mixer_oss *mixer, * ptr_allocated means the entry is dynamically allocated (change via proc file). * when replace_old = 1, the old entry is replaced with the new one. */ -static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mixer_oss_assign_table *ptr, int ptr_allocated, int replace_old) +static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, + const struct snd_mixer_oss_assign_table *ptr, + int ptr_allocated, int replace_old) { struct slot slot; struct slot *pslot; @@ -1255,7 +1257,7 @@ static void snd_mixer_oss_proc_done(struct snd_mixer_oss *mixer) static void snd_mixer_oss_build(struct snd_mixer_oss *mixer) { - static struct snd_mixer_oss_assign_table table[] = { + static const struct snd_mixer_oss_assign_table table[] = { { SOUND_MIXER_VOLUME, "Master", 0 }, { SOUND_MIXER_VOLUME, "Front", 0 }, /* fallback */ { SOUND_MIXER_BASS, "Tone Control - Bass", 0 }, -- cgit v1.2.3 From dde5199c988b16426cf9a4e0df4b7ae06790471e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:48 +0100 Subject: ALSA: aoa: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-33-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/aoa/codecs/onyx.c | 2 +- sound/aoa/codecs/tas.c | 2 +- sound/aoa/fabrics/layout.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c index 83ab3e58a0d3..f85bc8a1e2a6 100644 --- a/sound/aoa/codecs/onyx.c +++ b/sound/aoa/codecs/onyx.c @@ -413,7 +413,7 @@ static int onyx_snd_single_bit_put(struct snd_kcontrol *kcontrol, } #define SINGLE_BIT(n, type, description, address, mask, flags) \ -static struct snd_kcontrol_new n##_control = { \ +static const struct snd_kcontrol_new n##_control = { \ .iface = SNDRV_CTL_ELEM_IFACE_##type, \ .name = description, \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c index c60b78367fc9..d3e37577b529 100644 --- a/sound/aoa/codecs/tas.c +++ b/sound/aoa/codecs/tas.c @@ -369,7 +369,7 @@ static int tas_snd_mixer_put(struct snd_kcontrol *kcontrol, } #define MIXER_CONTROL(n,descr,idx) \ -static struct snd_kcontrol_new n##_control = { \ +static const struct snd_kcontrol_new n##_control = { \ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ .name = descr " Playback Volume", \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index 801b2f7699c2..d2e85b83f7ed 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c @@ -655,7 +655,7 @@ static int n##_control_put(struct snd_kcontrol *kcontrol, \ !!ucontrol->value.integer.value[0]); \ return 1; \ } \ -static struct snd_kcontrol_new n##_ctl = { \ +static const struct snd_kcontrol_new n##_ctl = { \ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ .name = description, \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ -- cgit v1.2.3 From 2eccd408037449ac6c1ceba1d74bd10c67dc13d7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:49 +0100 Subject: ALSA: drivers: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. Constify snd_kcontrol_new items There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-34-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 2 +- sound/drivers/dummy.c | 2 +- sound/drivers/mts64.c | 14 +++++++------- sound/drivers/opl4/opl4_mixer.c | 2 +- sound/drivers/pcsp/pcsp_mixer.c | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 13abb3d0893f..d78a27271d6d 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1496,7 +1496,7 @@ static int loopback_channels_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new loopback_controls[] = { +static const struct snd_kcontrol_new loopback_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "PCM Rate Shift 100000", diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index cef5b391cc44..cec682a7b88d 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -849,7 +849,7 @@ static int snd_dummy_iobox_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new snd_dummy_controls[] = { +static const struct snd_kcontrol_new snd_dummy_controls[] = { DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER), DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER), DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH), diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index 44776e1463cb..eeef3c0215e4 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -467,7 +467,7 @@ __out: return changed; } -static struct snd_kcontrol_new mts64_ctl_smpte_switch = { +static const struct snd_kcontrol_new mts64_ctl_smpte_switch = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Playback Switch", .index = 0, @@ -540,7 +540,7 @@ static int snd_mts64_ctl_smpte_time_put(struct snd_kcontrol *kctl, return changed; } -static struct snd_kcontrol_new mts64_ctl_smpte_time_hours = { +static const struct snd_kcontrol_new mts64_ctl_smpte_time_hours = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Time Hours", .index = 0, @@ -551,7 +551,7 @@ static struct snd_kcontrol_new mts64_ctl_smpte_time_hours = { .put = snd_mts64_ctl_smpte_time_put }; -static struct snd_kcontrol_new mts64_ctl_smpte_time_minutes = { +static const struct snd_kcontrol_new mts64_ctl_smpte_time_minutes = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Time Minutes", .index = 0, @@ -562,7 +562,7 @@ static struct snd_kcontrol_new mts64_ctl_smpte_time_minutes = { .put = snd_mts64_ctl_smpte_time_put }; -static struct snd_kcontrol_new mts64_ctl_smpte_time_seconds = { +static const struct snd_kcontrol_new mts64_ctl_smpte_time_seconds = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Time Seconds", .index = 0, @@ -573,7 +573,7 @@ static struct snd_kcontrol_new mts64_ctl_smpte_time_seconds = { .put = snd_mts64_ctl_smpte_time_put }; -static struct snd_kcontrol_new mts64_ctl_smpte_time_frames = { +static const struct snd_kcontrol_new mts64_ctl_smpte_time_frames = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Time Frames", .index = 0, @@ -625,7 +625,7 @@ static int snd_mts64_ctl_smpte_fps_put(struct snd_kcontrol *kctl, return changed; } -static struct snd_kcontrol_new mts64_ctl_smpte_fps = { +static const struct snd_kcontrol_new mts64_ctl_smpte_fps = { .iface = SNDRV_CTL_ELEM_IFACE_RAWMIDI, .name = "SMPTE Fps", .index = 0, @@ -641,7 +641,7 @@ static int snd_mts64_ctl_create(struct snd_card *card, struct mts64 *mts) { int err, i; - static struct snd_kcontrol_new *control[] = { + static const struct snd_kcontrol_new *control[] = { &mts64_ctl_smpte_switch, &mts64_ctl_smpte_time_hours, &mts64_ctl_smpte_time_minutes, diff --git a/sound/drivers/opl4/opl4_mixer.c b/sound/drivers/opl4/opl4_mixer.c index 7d4b3cc0fb6c..fa1e6eff43ab 100644 --- a/sound/drivers/opl4/opl4_mixer.c +++ b/sound/drivers/opl4/opl4_mixer.c @@ -47,7 +47,7 @@ static int snd_opl4_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v return value != old_value; } -static struct snd_kcontrol_new snd_opl4_controls[] = { +static const struct snd_kcontrol_new snd_opl4_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Playback Volume", diff --git a/sound/drivers/pcsp/pcsp_mixer.c b/sound/drivers/pcsp/pcsp_mixer.c index be2990451bcd..da33e5b620a7 100644 --- a/sound/drivers/pcsp/pcsp_mixer.c +++ b/sound/drivers/pcsp/pcsp_mixer.c @@ -120,17 +120,17 @@ static int pcsp_pcspkr_put(struct snd_kcontrol *kcontrol, .put = pcsp_##ctl_type##_put, \ } -static struct snd_kcontrol_new snd_pcsp_controls_pcm[] = { +static const struct snd_kcontrol_new snd_pcsp_controls_pcm[] = { PCSP_MIXER_CONTROL(enable, "Master Playback Switch"), PCSP_MIXER_CONTROL(treble, "BaseFRQ Playback Volume"), }; -static struct snd_kcontrol_new snd_pcsp_controls_spkr[] = { +static const struct snd_kcontrol_new snd_pcsp_controls_spkr[] = { PCSP_MIXER_CONTROL(pcspkr, "Beep Playback Switch"), }; static int snd_pcsp_ctls_add(struct snd_pcsp *chip, - struct snd_kcontrol_new *ctls, int num) + const struct snd_kcontrol_new *ctls, int num) { int i, err; struct snd_card *card = chip->card; -- cgit v1.2.3 From 0da2c47a951c27f1be34cb9221d77b0ed2db6cee Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:50 +0100 Subject: ALSA: i2c: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-35-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/i2c/cs8427.c | 2 +- sound/i2c/other/ak4113.c | 2 +- sound/i2c/other/ak4114.c | 2 +- sound/i2c/other/ak4117.c | 2 +- sound/i2c/tea6330t.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index bac4f0036cd6..8634d4f466b3 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c @@ -459,7 +459,7 @@ static int snd_cs8427_spdif_mask_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new snd_cs8427_iec958_controls[] = { +static const struct snd_kcontrol_new snd_cs8427_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .info = snd_cs8427_in_status_info, diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c index 2700a8470388..e7213092eb4f 100644 --- a/sound/i2c/other/ak4113.c +++ b/sound/i2c/other/ak4113.c @@ -349,7 +349,7 @@ static int snd_ak4113_spdif_qget(struct snd_kcontrol *kcontrol, } /* Don't forget to change AK4113_CONTROLS define!!! */ -static struct snd_kcontrol_new snd_ak4113_iec958_controls[] = { +static const struct snd_kcontrol_new snd_ak4113_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "IEC958 Parity Errors", diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index e7325af8af5b..2ce0a97957ab 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -318,7 +318,7 @@ static int snd_ak4114_spdif_qget(struct snd_kcontrol *kcontrol, } /* Don't forget to change AK4114_CONTROLS define!!! */ -static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = { +static const struct snd_kcontrol_new snd_ak4114_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "IEC958 Parity Errors", diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 0d9e8252cc27..905be2d0780b 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -305,7 +305,7 @@ static int snd_ak4117_spdif_qget(struct snd_kcontrol *kcontrol, } /* Don't forget to change AK4117_CONTROLS define!!! */ -static struct snd_kcontrol_new snd_ak4117_iec958_controls[] = { +static const struct snd_kcontrol_new snd_ak4117_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "IEC958 Parity Errors", diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 93ca8bb71f54..08eb6a873768 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -260,7 +260,7 @@ static int snd_tea6330t_put_treble(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_tea6330t_controls[] = { +static const struct snd_kcontrol_new snd_tea6330t_controls[] = { TEA6330T_MASTER_SWITCH("Master Playback Switch", 0), TEA6330T_MASTER_VOLUME("Master Playback Volume", 0), TEA6330T_BASS("Tone Control - Bass", 0), @@ -278,7 +278,7 @@ int snd_tea6330t_update_mixer(struct snd_card *card, { struct snd_i2c_device *device; struct tea6330t *tea; - struct snd_kcontrol_new *knew; + const struct snd_kcontrol_new *knew; unsigned int idx; int err = -ENOMEM; u8 default_treble, default_bass; -- cgit v1.2.3 From fdd1f6fd328ff2e3723fe2a5c94378ef6f217edc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:51 +0100 Subject: ALSA: isa: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-36-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 2 +- sound/isa/cmi8330.c | 2 +- sound/isa/cs423x/cs4236_lib.c | 14 +++++++------- sound/isa/es1688/es1688_lib.c | 2 +- sound/isa/es18xx.c | 26 +++++++++++++------------- sound/isa/gus/gus_mixer.c | 4 ++-- sound/isa/msnd/msnd_pinnacle_mixer.c | 2 +- sound/isa/opl3sa2.c | 4 ++-- sound/isa/opti9xx/miro.c | 14 +++++++------- sound/isa/opti9xx/opti92x-ad1848.c | 2 +- sound/isa/sb/emu8000.c | 14 +++++++------- sound/isa/sb/sb_mixer.c | 2 +- sound/isa/wss/wss_lib.c | 2 +- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 560885fbc983..01381fe7c0c9 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -884,7 +884,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); -static struct snd_kcontrol_new snd_ad1816a_controls[] = { +static const struct snd_kcontrol_new snd_ad1816a_controls[] = { AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1), AD1816A_DOUBLE_TLV("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1, db_scale_5bit), diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index f8ec59a5bb8f..61d6944a69c7 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -179,7 +179,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_cmi8330_pnpids); #endif -static struct snd_kcontrol_new snd_cmi8330_controls[] = { +static const struct snd_kcontrol_new snd_cmi8330_controls[] = { WSS_DOUBLE("Master Playback Volume", 0, CMI8330_MASTVOL, CMI8330_MASTVOL, 4, 0, 15, 0), WSS_SINGLE("Loud Playback Switch", 0, diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index be48c60355d0..ca6646f9b58d 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -758,7 +758,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); static const DECLARE_TLV_DB_SCALE(db_scale_2bit, -1800, 600, 0); static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); -static struct snd_kcontrol_new snd_cs4236_controls[] = { +static const struct snd_kcontrol_new snd_cs4236_controls[] = { CS4236_DOUBLE("Master Digital Playback Switch", 0, CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), @@ -853,7 +853,7 @@ CS4236_DOUBLE1_TLV("Loopback Digital Playback Volume", 0, static const DECLARE_TLV_DB_SCALE(db_scale_5bit_6db_max, -5600, 200, 0); static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0); -static struct snd_kcontrol_new snd_cs4235_controls[] = { +static const struct snd_kcontrol_new snd_cs4235_controls[] = { WSS_DOUBLE("Master Playback Switch", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), @@ -986,7 +986,7 @@ static int snd_cs4236_put_iec958_switch(struct snd_kcontrol *kcontrol, struct sn return change; } -static struct snd_kcontrol_new snd_cs4236_iec958_controls[] = { +static const struct snd_kcontrol_new snd_cs4236_iec958_controls[] = { CS4236_IEC958_ENABLE("IEC958 Output Enable", 0), CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0), CS4236_SINGLEC("IEC958 Output User", 0, 4, 5, 1, 0), @@ -995,12 +995,12 @@ CS4236_SINGLEC("IEC958 Output Channel Status Low", 0, 5, 1, 127, 0), CS4236_SINGLEC("IEC958 Output Channel Status High", 0, 6, 0, 255, 0) }; -static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = { +static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1) }; -static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = { +static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Center", 0, 2, 0, 15, 1), @@ -1008,7 +1008,7 @@ CS4236_SINGLEC("3D Control - Mono", 0, 3, 6, 1, 0), CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) }; -static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = { +static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Volume", 0, 2, 0, 15, 1), @@ -1020,7 +1020,7 @@ int snd_cs4236_mixer(struct snd_wss *chip) struct snd_card *card; unsigned int idx, count; int err; - struct snd_kcontrol_new *kcontrol; + const struct snd_kcontrol_new *kcontrol; if (snd_BUG_ON(!chip || !chip->card)) return -EINVAL; diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 99a833f29544..1568d0bfd1a8 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -924,7 +924,7 @@ static int snd_es1688_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e return change; } -static struct snd_kcontrol_new snd_es1688_controls[] = { +static const struct snd_kcontrol_new snd_es1688_controls[] = { ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0), ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0), ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0), diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index f9cd05d2b3bd..6ce5b5c76980 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1246,7 +1246,7 @@ static int snd_es18xx_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e * The controls that are universal to all chipsets are fully initialized * here. */ -static struct snd_kcontrol_new snd_es18xx_base_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_base_controls[] = { ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), @@ -1265,7 +1265,7 @@ ES18XX_DOUBLE("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0), } }; -static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), @@ -1277,35 +1277,35 @@ ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) /* * The chipset specific mixer controls */ -static struct snd_kcontrol_new snd_es18xx_opt_speaker = +static const struct snd_kcontrol_new snd_es18xx_opt_speaker = ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0); -static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { +static const struct snd_kcontrol_new snd_es18xx_opt_1869[] = { ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, ES18XX_FL_INVERT), ES18XX_SINGLE("Video Playback Switch", 0, 0x7f, 0, 1, 0), ES18XX_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), ES18XX_DOUBLE("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0) }; -static struct snd_kcontrol_new snd_es18xx_opt_1878 = +static const struct snd_kcontrol_new snd_es18xx_opt_1878 = ES18XX_DOUBLE("Video Playback Volume", 0, 0x68, 0x68, 4, 0, 15, 0); -static struct snd_kcontrol_new snd_es18xx_opt_1879[] = { +static const struct snd_kcontrol_new snd_es18xx_opt_1879[] = { ES18XX_SINGLE("Video Playback Switch", 0, 0x71, 6, 1, 0), ES18XX_DOUBLE("Video Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), ES18XX_DOUBLE("Video Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0) }; -static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0), }; -static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0) }; -static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -1316,13 +1316,13 @@ ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), } }; -static struct snd_kcontrol_new snd_es18xx_micpre1_control = +static const struct snd_kcontrol_new snd_es18xx_micpre1_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0); -static struct snd_kcontrol_new snd_es18xx_micpre2_control = +static const struct snd_kcontrol_new snd_es18xx_micpre2_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0); -static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { +static const struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Hardware Master Playback Volume", @@ -1340,7 +1340,7 @@ static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), }; -static struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = { +static const struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = { ES18XX_SINGLE("GPO0 Switch", 0, ES18XX_PM, 0, 1, ES18XX_FL_PMPORT), ES18XX_SINGLE("GPO1 Switch", 0, ES18XX_PM, 1, 1, ES18XX_FL_PMPORT), }; diff --git a/sound/isa/gus/gus_mixer.c b/sound/isa/gus/gus_mixer.c index 94e0c75ee417..201d0c40d0d9 100644 --- a/sound/isa/gus/gus_mixer.c +++ b/sound/isa/gus/gus_mixer.c @@ -120,13 +120,13 @@ static int snd_ics_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem return change; } -static struct snd_kcontrol_new snd_gf1_controls[] = { +static const struct snd_kcontrol_new snd_gf1_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), GF1_SINGLE("Line Switch", 0, 0, 1), GF1_SINGLE("Mic Switch", 0, 2, 0) }; -static struct snd_kcontrol_new snd_ics_controls[] = { +static const struct snd_kcontrol_new snd_ics_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV), ICS_DOUBLE("Synth Playback Volume", 0, SNDRV_ICS_GF1_DEV), diff --git a/sound/isa/msnd/msnd_pinnacle_mixer.c b/sound/isa/msnd/msnd_pinnacle_mixer.c index d0770e2aedca..02c566fca9e5 100644 --- a/sound/isa/msnd/msnd_pinnacle_mixer.c +++ b/sound/isa/msnd/msnd_pinnacle_mixer.c @@ -275,7 +275,7 @@ static int snd_msndmix_volume_put(struct snd_kcontrol *kcontrol, .private_value = addr } -static struct snd_kcontrol_new snd_msnd_controls[] = { +static const struct snd_kcontrol_new snd_msnd_controls[] = { DUMMY_VOLUME("Master Volume", 0, MSND_MIXER_VOLUME), DUMMY_VOLUME("PCM Volume", 0, MSND_MIXER_PCM), DUMMY_VOLUME("Aux Volume", 0, MSND_MIXER_AUX), diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 6d19ab458291..85a181acd388 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -457,7 +457,7 @@ static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_ static const DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0); static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); -static struct snd_kcontrol_new snd_opl3sa2_controls[] = { +static const struct snd_kcontrol_new snd_opl3sa2_controls[] = { OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1), OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1, db_scale_master), @@ -467,7 +467,7 @@ OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1, OPL3SA2_SINGLE("ZV Port Switch", 0, 0x02, 0, 1, 0), }; -static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { +static const struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0) diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 0458934de1c7..a9c773b9f471 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -577,7 +577,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_miro_controls[] = { +static const struct snd_kcontrol_new snd_miro_controls[] = { MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER), MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC), MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE), @@ -589,7 +589,7 @@ MIRO_DOUBLE("Aux Playback Volume", 2, ACI_GET_LINE2, ACI_SET_LINE2), /* Equalizer with seven bands (only PCM20) from -12dB up to +12dB on each band */ -static struct snd_kcontrol_new snd_miro_eq_controls[] = { +static const struct snd_kcontrol_new snd_miro_eq_controls[] = { MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1), MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2), MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3), @@ -599,15 +599,15 @@ MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, ACI_GET_EQ6, ACI_SET_EQ6), MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7), }; -static struct snd_kcontrol_new snd_miro_radio_control[] = { +static const struct snd_kcontrol_new snd_miro_radio_control[] = { MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1), }; -static struct snd_kcontrol_new snd_miro_line_control[] = { +static const struct snd_kcontrol_new snd_miro_line_control[] = { MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1), }; -static struct snd_kcontrol_new snd_miro_preamp_control[] = { +static const struct snd_kcontrol_new snd_miro_preamp_control[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost", @@ -617,7 +617,7 @@ static struct snd_kcontrol_new snd_miro_preamp_control[] = { .put = snd_miro_put_preamp, }}; -static struct snd_kcontrol_new snd_miro_amp_control[] = { +static const struct snd_kcontrol_new snd_miro_amp_control[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line Boost", @@ -627,7 +627,7 @@ static struct snd_kcontrol_new snd_miro_amp_control[] = { .put = snd_miro_put_amp, }}; -static struct snd_kcontrol_new snd_miro_capture_control[] = { +static const struct snd_kcontrol_new snd_miro_capture_control[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Capture Switch", diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index b40ab806c349..697576459f71 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -550,7 +550,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0); static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0); -static struct snd_kcontrol_new snd_opti93x_controls[] = { +static const struct snd_kcontrol_new snd_opti93x_controls[] = { WSS_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), WSS_DOUBLE_TLV("Master Playback Volume", 0, diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index bc47e8e51523..455dd5fa3ccb 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -855,7 +855,7 @@ static int mixer_bass_treble_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e return change; } -static struct snd_kcontrol_new mixer_bass_control = +static const struct snd_kcontrol_new mixer_bass_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Bass", @@ -865,7 +865,7 @@ static struct snd_kcontrol_new mixer_bass_control = .private_value = 0, }; -static struct snd_kcontrol_new mixer_treble_control = +static const struct snd_kcontrol_new mixer_treble_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Treble", @@ -922,7 +922,7 @@ static int mixer_chorus_reverb_put(struct snd_kcontrol *kcontrol, struct snd_ctl return change; } -static struct snd_kcontrol_new mixer_chorus_mode_control = +static const struct snd_kcontrol_new mixer_chorus_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Chorus Mode", @@ -932,7 +932,7 @@ static struct snd_kcontrol_new mixer_chorus_mode_control = .private_value = 1, }; -static struct snd_kcontrol_new mixer_reverb_mode_control = +static const struct snd_kcontrol_new mixer_reverb_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Reverb Mode", @@ -984,7 +984,7 @@ static int mixer_fm_depth_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem return change; } -static struct snd_kcontrol_new mixer_fm_chorus_depth_control = +static const struct snd_kcontrol_new mixer_fm_chorus_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Chorus Depth", @@ -994,7 +994,7 @@ static struct snd_kcontrol_new mixer_fm_chorus_depth_control = .private_value = 1, }; -static struct snd_kcontrol_new mixer_fm_reverb_depth_control = +static const struct snd_kcontrol_new mixer_fm_reverb_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Reverb Depth", @@ -1005,7 +1005,7 @@ static struct snd_kcontrol_new mixer_fm_reverb_depth_control = }; -static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = { +static const struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = { &mixer_bass_control, &mixer_treble_control, &mixer_chorus_mode_control, diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index bd65ef0412a6..789dcf279a26 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -438,7 +438,7 @@ static int snd_sb16mixer_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ */ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value) { - static struct snd_kcontrol_new newctls[] = { + static const struct snd_kcontrol_new newctls[] = { [SB_MIX_SINGLE] = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_sbmixer_info_single, diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 0d019b238399..d37f4642162a 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -2157,7 +2157,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); -static struct snd_kcontrol_new snd_wss_controls[] = { +static const struct snd_kcontrol_new snd_wss_controls[] = { WSS_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), WSS_DOUBLE_TLV("PCM Playback Volume", 0, -- cgit v1.2.3 From 35ace5e8410e41df8719ee9fee49312655efa26a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:52 +0100 Subject: ALSA: hda: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-37-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 8 ++++---- sound/pci/hda/patch_sigmatel.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 8f166bbc438b..d039eeec080f 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2387,7 +2387,7 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new dig_mixes[] = { +static const struct snd_kcontrol_new dig_mixes[] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -2437,7 +2437,7 @@ int snd_hda_create_dig_out_ctls(struct hda_codec *codec, { int err; struct snd_kcontrol *kctl; - struct snd_kcontrol_new *dig_mix; + const struct snd_kcontrol_new *dig_mix; int idx = 0; int val = 0; const int spdif_index = 16; @@ -2655,7 +2655,7 @@ static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new dig_in_ctls[] = { +static const struct snd_kcontrol_new dig_in_ctls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH), @@ -2687,7 +2687,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) { int err; struct snd_kcontrol *kctl; - struct snd_kcontrol_new *dig_mix; + const struct snd_kcontrol_new *dig_mix; int idx; idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0); diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 8ecb53bce509..9b816b377547 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -825,11 +825,11 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec, struct sigmatel_spec *spec = codec->spec; u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); struct snd_kcontrol_new *knew; - static struct snd_kcontrol_new abeep_mute_ctl = + static const struct snd_kcontrol_new abeep_mute_ctl = HDA_CODEC_MUTE(NULL, 0, 0, 0); - static struct snd_kcontrol_new dbeep_mute_ctl = + static const struct snd_kcontrol_new dbeep_mute_ctl = HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0); - static struct snd_kcontrol_new beep_vol_ctl = + static const struct snd_kcontrol_new beep_vol_ctl = HDA_CODEC_VOLUME(NULL, 0, 0, 0); /* check for mute support for the the amp */ -- cgit v1.2.3 From b4e5e70775546480035e156b40040e5d0d4264d1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:53 +0100 Subject: ALSA: pci: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-38-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ak4531_codec.c | 2 +- sound/pci/ali5451/ali5451.c | 2 +- sound/pci/au88x0/au88x0_pcm.c | 2 +- sound/pci/azt3328.c | 2 +- sound/pci/ca0106/ca0106_mixer.c | 4 ++-- sound/pci/cmipci.c | 16 ++++++++-------- sound/pci/cs46xx/cs46xx_lib.c | 4 ++-- sound/pci/cs5535audio/cs5535audio_olpc.c | 2 +- sound/pci/emu10k1/emumixer.c | 14 +++++++------- sound/pci/emu10k1/p16v.c | 2 +- sound/pci/ens1370.c | 4 ++-- sound/pci/es1938.c | 2 +- sound/pci/fm801.c | 4 ++-- sound/pci/ice1712/aureon.c | 10 +++++----- sound/pci/ice1712/delta.c | 10 +++++----- sound/pci/ice1712/ews.c | 6 +++--- sound/pci/ice1712/ice1712.c | 2 +- sound/pci/ice1712/juli.c | 2 +- sound/pci/ice1712/maya44.c | 2 +- sound/pci/ice1712/phase.c | 4 ++-- sound/pci/ice1712/pontis.c | 2 +- sound/pci/ice1712/prodigy192.c | 4 ++-- sound/pci/ice1712/prodigy_hifi.c | 4 ++-- sound/pci/ice1712/quartet.c | 2 +- sound/pci/ice1712/wtm.c | 2 +- sound/pci/korg1212/korg1212.c | 2 +- sound/pci/rme32.c | 2 +- sound/pci/rme96.c | 2 +- sound/pci/rme9652/hdsp.c | 8 ++++---- sound/pci/rme9652/hdspm.c | 14 +++++++------- sound/pci/rme9652/rme9652.c | 6 +++--- sound/pci/sonicvibes.c | 6 +++--- sound/pci/ymfpci/ymfpci_main.c | 2 +- 33 files changed, 76 insertions(+), 76 deletions(-) diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c index fbf9a93a8053..c00c65726a34 100644 --- a/sound/pci/ak4531_codec.c +++ b/sound/pci/ak4531_codec.c @@ -255,7 +255,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_master, -6200, 200, 0); static const DECLARE_TLV_DB_SCALE(db_scale_mono, -2800, 400, 0); static const DECLARE_TLV_DB_SCALE(db_scale_input, -5000, 200, 0); -static struct snd_kcontrol_new snd_ak4531_controls[] = { +static const struct snd_kcontrol_new snd_ak4531_controls[] = { AK4531_DOUBLE_TLV("Master Playback Switch", 0, AK4531_LMASTER, AK4531_RMASTER, 7, 7, 1, 1, diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index b2374266c52c..4f524a9dbbca 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1776,7 +1776,7 @@ static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = { +static const struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = { /* spdif aplayback switch */ /* FIXME: "IEC958 Playback Switch" may conflict with one on ac97_codec */ ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 0, 0), diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 787c79aba441..2cdb7845f651 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -497,7 +497,7 @@ static int snd_vortex_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el } /* spdif controls */ -static struct snd_kcontrol_new snd_vortex_mixer_spdif[] = { +static const struct snd_kcontrol_new snd_vortex_mixer_spdif[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 898ba55fc0dd..73745352c55d 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1094,7 +1094,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol, return (nreg != oreg); } -static struct snd_kcontrol_new snd_azf3328_mixer_controls[] = { +static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] = { AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1), AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1), AZF3328_MIXER_SWITCH("PCM Playback Switch", IDX_MIXER_WAVEOUT, 15, 1), diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 38f7f0a8c810..729d757c900a 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -550,7 +550,7 @@ static int spi_mute_put(struct snd_kcontrol *kcontrol, .private_value = ((chid) << 8) | (reg) \ } -static struct snd_kcontrol_new snd_ca0106_volume_ctls[] = { +static const struct snd_kcontrol_new snd_ca0106_volume_ctls[] = { CA_VOLUME("Analog Front Playback Volume", CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), CA_VOLUME("Analog Rear Playback Volume", @@ -631,7 +631,7 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] = { .private_value = chid \ } -static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] = { +static const struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] = { I2C_VOLUME("Phone Capture Volume", 0), I2C_VOLUME("Mic Capture Volume", 1), I2C_VOLUME("Line in Capture Volume", 2), diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index ff5525722d58..7f91742ed6f0 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2256,7 +2256,7 @@ static int snd_cmipci_put_native_mixer_sensitive(struct snd_kcontrol *kcontrol, } -static struct snd_kcontrol_new snd_cmipci_mixers[] = { +static const struct snd_kcontrol_new snd_cmipci_mixers[] = { CMIPCI_SB_VOL_STEREO("Master Playback Volume", SB_DSP4_MASTER_DEV, 3, 31), CMIPCI_MIXER_SW_MONO("3D Control - Switch", CM_REG_MIXER1, CM_X3DEN_SHIFT, 0), CMIPCI_SB_VOL_STEREO("PCM Playback Volume", SB_DSP4_PCM_DEV, 3, 31), @@ -2567,7 +2567,7 @@ static int snd_cmipci_mic_in_mode_put(struct snd_kcontrol *kcontrol, } /* both for CM8338/8738 */ -static struct snd_kcontrol_new snd_cmipci_mixer_switches[] = { +static const struct snd_kcontrol_new snd_cmipci_mixer_switches[] = { DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), { .name = "Line-In Mode", @@ -2579,11 +2579,11 @@ static struct snd_kcontrol_new snd_cmipci_mixer_switches[] = { }; /* for non-multichannel chips */ -static struct snd_kcontrol_new snd_cmipci_nomulti_switch = +static const struct snd_kcontrol_new snd_cmipci_nomulti_switch = DEFINE_MIXER_SWITCH("Exchange DAC", exchange_dac); /* only for CM8738 */ -static struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] = { +static const struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] = { #if 0 /* controlled in pcm device */ DEFINE_MIXER_SWITCH("IEC958 In Record", spdif_in), DEFINE_MIXER_SWITCH("IEC958 Out", spdif_out), @@ -2605,14 +2605,14 @@ static struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] = { }; /* only for model 033/037 */ -static struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] = { +static const struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] = { DEFINE_MIXER_SWITCH("IEC958 Mix Analog", spdif_dac_out), DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase), DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel1), }; /* only for model 039 or later */ -static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] = { +static const struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] = { DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), { @@ -2625,14 +2625,14 @@ static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] = { }; /* card control switches */ -static struct snd_kcontrol_new snd_cmipci_modem_switch = +static const struct snd_kcontrol_new snd_cmipci_modem_switch = DEFINE_CARD_SWITCH("Modem", modem); static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) { struct snd_card *card; - struct snd_kcontrol_new *sw; + const struct snd_kcontrol_new *sw; struct snd_kcontrol *kctl; unsigned int idx; int err; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 5bb84303f577..cbac9f1edc51 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2238,7 +2238,7 @@ static int snd_cs46xx_spdif_stream_put(struct snd_kcontrol *kcontrol, #endif /* CONFIG_SND_CS46XX_NEW_DSP */ -static struct snd_kcontrol_new snd_cs46xx_controls[] = { +static const struct snd_kcontrol_new snd_cs46xx_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DAC Volume", @@ -2364,7 +2364,7 @@ static const struct snd_kcontrol_new snd_cs46xx_front_dup_ctl = { #ifdef CONFIG_SND_CS46XX_NEW_DSP /* Only available on the Hercules Game Theater XP soundcard */ -static struct snd_kcontrol_new snd_hercules_controls[] = { +static const struct snd_kcontrol_new snd_hercules_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Optical/Coaxial SPDIF Input Switch", diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c index bd246b10636e..4e295303b041 100644 --- a/sound/pci/cs5535audio/cs5535audio_olpc.c +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c @@ -111,7 +111,7 @@ static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) return 1; } -static struct snd_kcontrol_new olpc_cs5535audio_ctls[] = { +static const struct snd_kcontrol_new olpc_cs5535audio_ctls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DC Mode Enable", diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 0b3dfc71fa69..46c79dfe9844 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -484,7 +484,7 @@ static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol, .private_value = chid \ } -static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] = { +static const struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] = { EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0), EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1), EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Enum", 2), @@ -513,7 +513,7 @@ static struct snd_kcontrol_new snd_emu1010_output_enum_ctls[] = { /* 1616(m) cardbus */ -static struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] = { +static const struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] = { EMU1010_SOURCE_OUTPUT("Dock DAC1 Left Playback Enum", 0), EMU1010_SOURCE_OUTPUT("Dock DAC1 Right Playback Enum", 1), EMU1010_SOURCE_OUTPUT("Dock DAC2 Left Playback Enum", 2), @@ -545,7 +545,7 @@ static struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] = { .private_value = chid \ } -static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] = { +static const struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] = { EMU1010_SOURCE_INPUT("DSP 0 Capture Enum", 0), EMU1010_SOURCE_INPUT("DSP 1 Capture Enum", 1), EMU1010_SOURCE_INPUT("DSP 2 Capture Enum", 2), @@ -613,7 +613,7 @@ static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ct .private_value = chid \ } -static struct snd_kcontrol_new snd_emu1010_adc_pads[] = { +static const struct snd_kcontrol_new snd_emu1010_adc_pads[] = { EMU1010_ADC_PADS("ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1), EMU1010_ADC_PADS("ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2), EMU1010_ADC_PADS("ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3), @@ -661,7 +661,7 @@ static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ct .private_value = chid \ } -static struct snd_kcontrol_new snd_emu1010_dac_pads[] = { +static const struct snd_kcontrol_new snd_emu1010_dac_pads[] = { EMU1010_DAC_PADS("DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1), EMU1010_DAC_PADS("DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2), EMU1010_DAC_PADS("DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3), @@ -1051,7 +1051,7 @@ static int snd_audigy_i2c_volume_put(struct snd_kcontrol *kcontrol, } -static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] = { +static const struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] = { I2C_VOLUME("Mic Capture Volume", 0), I2C_VOLUME("Line Capture Volume", 0) }; @@ -1125,7 +1125,7 @@ static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_audigy_spdif_output_rate = +static const struct snd_kcontrol_new snd_audigy_spdif_output_rate = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 1cdbad494e13..1099f102b365 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -776,7 +776,7 @@ static const DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1); .private_value = ((xreg) | ((xhl) << 8)) \ } -static struct snd_kcontrol_new p16v_mixer_controls[] = { +static const struct snd_kcontrol_new p16v_mixer_controls[] = { P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1), diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 15e6d2377ecf..4f8202980b61 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1433,7 +1433,7 @@ static int snd_es1371_spdif_put(struct snd_kcontrol *kcontrol, /* spdif controls */ -static struct snd_kcontrol_new snd_es1371_mixer_spdif[] = { +static const struct snd_kcontrol_new snd_es1371_mixer_spdif[] = { ES1371_SPDIF(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH)), { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1698,7 +1698,7 @@ static int snd_ensoniq_control_put(struct snd_kcontrol *kcontrol, * ENS1370 mixer */ -static struct snd_kcontrol_new snd_es1370_controls[2] = { +static const struct snd_kcontrol_new snd_es1370_controls[2] = { ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0), ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1) }; diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 9d5568509387..8336b20fbafc 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1307,7 +1307,7 @@ static const DECLARE_TLV_DB_RANGE(db_scale_line, static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0); -static struct snd_kcontrol_new snd_es1938_controls[] = { +static const struct snd_kcontrol_new snd_es1938_controls[] = { ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0, db_scale_master), ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index ae2b413ff489..4117a053eb18 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -969,7 +969,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_dsp, -3450, 150, 0); #define FM801_CONTROLS ARRAY_SIZE(snd_fm801_controls) -static struct snd_kcontrol_new snd_fm801_controls[] = { +static const struct snd_kcontrol_new snd_fm801_controls[] = { FM801_DOUBLE_TLV("Wave Playback Volume", FM801_PCM_VOL, 0, 8, 31, 1, db_scale_dsp), FM801_SINGLE("Wave Playback Switch", FM801_PCM_VOL, 15, 1, 1), @@ -990,7 +990,7 @@ FM801_SINGLE("FM Playback Switch", FM801_FM_VOL, 15, 1, 1), #define FM801_CONTROLS_MULTI ARRAY_SIZE(snd_fm801_controls_multi) -static struct snd_kcontrol_new snd_fm801_controls_multi[] = { +static const struct snd_kcontrol_new snd_fm801_controls_multi[] = { FM801_SINGLE("AC97 2ch->4ch Copy Switch", FM801_CODEC_CTRL, 7, 1, 0), FM801_SINGLE("AC97 18-bit Switch", FM801_CODEC_CTRL, 10, 1, 0), FM801_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), FM801_I2S_MODE, 8, 1, 0), diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 4556ba76b791..025fe7820620 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -1389,7 +1389,7 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl * mixers */ -static struct snd_kcontrol_new aureon_dac_controls[] = { +static const struct snd_kcontrol_new aureon_dac_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -1504,7 +1504,7 @@ static struct snd_kcontrol_new aureon_dac_controls[] = { } }; -static struct snd_kcontrol_new wm_controls[] = { +static const struct snd_kcontrol_new wm_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Switch", @@ -1570,7 +1570,7 @@ static struct snd_kcontrol_new wm_controls[] = { } }; -static struct snd_kcontrol_new ac97_controls[] = { +static const struct snd_kcontrol_new ac97_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 Playback Switch", @@ -1675,7 +1675,7 @@ static struct snd_kcontrol_new ac97_controls[] = { } }; -static struct snd_kcontrol_new universe_ac97_controls[] = { +static const struct snd_kcontrol_new universe_ac97_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 Playback Switch", @@ -1807,7 +1807,7 @@ static struct snd_kcontrol_new universe_ac97_controls[] = { }; -static struct snd_kcontrol_new cs8415_controls[] = { +static const struct snd_kcontrol_new cs8415_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH), diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index 519c9fbcff1e..81929063b2fa 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -753,15 +753,15 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice) * additional controls for M-Audio cards */ -static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select = +static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0); -static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select = +static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0); -static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status = +static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); -static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select = +static const struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0); -static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status = +static const struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index fe08dd9f1564..3794308313bf 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -597,7 +597,7 @@ static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct sn return val != nval; } -static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] = { +static const struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Sensitivity Switch", @@ -792,7 +792,7 @@ static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct .private_value = xshift | (xinvert << 8),\ } -static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] = { +static const struct snd_kcontrol_new snd_ice1712_ews88d_controls[] = { EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */ EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0), EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0), @@ -928,7 +928,7 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, str .private_value = xshift | (xinvert << 8),\ } -static struct snd_kcontrol_new snd_ice1712_6fire_controls[] = { +static const struct snd_kcontrol_new snd_ice1712_6fire_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog Input Select", diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 9794bbedffc3..5202e4c06fc4 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -1335,7 +1335,7 @@ static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struc static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0); -static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] = { +static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Playback Switch", diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 0da7e940f264..079e58ec8b09 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -343,7 +343,7 @@ static int juli_mute_put(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new juli_mute_controls[] = { +static const struct snd_kcontrol_new juli_mute_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", diff --git a/sound/pci/ice1712/maya44.c b/sound/pci/ice1712/maya44.c index 3af5abed1e3c..c2761e009c67 100644 --- a/sound/pci/ice1712/maya44.c +++ b/sound/pci/ice1712/maya44.c @@ -424,7 +424,7 @@ static int maya_pb_route_put(struct snd_kcontrol *kcontrol, * controls to be added */ -static struct snd_kcontrol_new maya_controls[] = { +static const struct snd_kcontrol_new maya_controls[] = { { .name = "Crossmix Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index 699051154bf9..ced4a2bfd08e 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -745,7 +745,7 @@ static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); -static struct snd_kcontrol_new phase28_dac_controls[] = { +static const struct snd_kcontrol_new phase28_dac_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -860,7 +860,7 @@ static struct snd_kcontrol_new phase28_dac_controls[] = { } }; -static struct snd_kcontrol_new wm_controls[] = { +static const struct snd_kcontrol_new wm_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Switch", diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c index 56cbc966d7a9..8ddb6c35a5e6 100644 --- a/sound/pci/ice1712/pontis.c +++ b/sound/pci/ice1712/pontis.c @@ -529,7 +529,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1); * mixers */ -static struct snd_kcontrol_new pontis_controls[] = { +static const struct snd_kcontrol_new pontis_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c index 98f8ac658796..105716961e39 100644 --- a/sound/pci/ice1712/prodigy192.c +++ b/sound/pci/ice1712/prodigy192.c @@ -346,7 +346,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); * mixers */ -static struct snd_kcontrol_new stac_controls[] = { +static const struct snd_kcontrol_new stac_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -578,7 +578,7 @@ static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol, } -static struct snd_kcontrol_new ak4114_controls[] = { +static const struct snd_kcontrol_new ak4114_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "MIODIO IEC958 Capture Input", diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 9d71e9d5c9a0..ba37f7eab166 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c @@ -284,7 +284,7 @@ static int ak4396_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); -static struct snd_kcontrol_new prodigy_hd2_controls[] = { +static const struct snd_kcontrol_new prodigy_hd2_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | @@ -741,7 +741,7 @@ static int wm_chswap_put(struct snd_kcontrol *kcontrol, * mixers */ -static struct snd_kcontrol_new prodigy_hifi_controls[] = { +static const struct snd_kcontrol_new prodigy_hifi_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index 9e2149fd42f8..bfd811a08d90 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -720,7 +720,7 @@ static int qtet_sw_put(struct snd_kcontrol *kcontrol, .put = qtet_sw_put,\ .private_value = xpriv } -static struct snd_kcontrol_new qtet_controls[] = { +static const struct snd_kcontrol_new qtet_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 4ca96ec6d687..4a7315ad51e8 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -477,7 +477,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); /* * Control tabs */ -static struct snd_kcontrol_new stac9640_controls[] = { +static const struct snd_kcontrol_new stac9640_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index f605926a0709..685a60551c71 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -2019,7 +2019,7 @@ static int snd_korg1212_control_sync_put(struct snd_kcontrol *kcontrol, .private_value = ord, \ } -static struct snd_kcontrol_new snd_korg1212_controls[] = { +static const struct snd_kcontrol_new snd_korg1212_controls[] = { MON_MIXER(8, "Analog"), MON_MIXER(10, "SPDIF"), MON_MIXER(0, "ADAT-1"), MON_MIXER(1, "ADAT-2"), MON_MIXER(2, "ADAT-3"), MON_MIXER(3, "ADAT-4"), diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 15029b2be233..16d726da74bf 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -1796,7 +1796,7 @@ static int snd_rme32_control_spdif_mask_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new snd_rme32_controls[] = { +static const struct snd_kcontrol_new snd_rme32_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 537381632be7..db576b7e5d5b 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2253,7 +2253,7 @@ snd_rme96_dac_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu return change; } -static struct snd_kcontrol_new snd_rme96_controls[] = { +static const struct snd_kcontrol_new snd_rme96_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index b4c42c4fa201..632f7878ff3e 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -2879,7 +2879,7 @@ static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl return change; } -static struct snd_kcontrol_new snd_hdsp_9632_controls[] = { +static const struct snd_kcontrol_new snd_hdsp_9632_controls[] = { HDSP_DA_GAIN("DA Gain", 0), HDSP_AD_GAIN("AD Gain", 0), HDSP_PHONE_GAIN("Phones Gain", 0), @@ -2887,7 +2887,7 @@ HDSP_TOGGLE_SETTING("XLR Breakout Cable", HDSP_XLRBreakoutCable), HDSP_DDS_OFFSET("DDS Sample Rate Offset", 0) }; -static struct snd_kcontrol_new snd_hdsp_controls[] = { +static const struct snd_kcontrol_new snd_hdsp_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -3216,7 +3216,7 @@ static int snd_hdsp_info_rpm_disconnect(struct snd_kcontrol *kcontrol, struct sn return snd_ctl_enum_info(uinfo, 1, 2, texts); } -static struct snd_kcontrol_new snd_hdsp_rpm_controls[] = { +static const struct snd_kcontrol_new snd_hdsp_rpm_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "RPM Bypass", @@ -3249,7 +3249,7 @@ static struct snd_kcontrol_new snd_hdsp_rpm_controls[] = { HDSP_MIXER("Mixer", 0) }; -static struct snd_kcontrol_new snd_hdsp_96xx_aeb = +static const struct snd_kcontrol_new snd_hdsp_96xx_aeb = HDSP_TOGGLE_SETTING("Analog Extension Board", HDSP_AnalogExtensionBoard); static struct snd_kcontrol_new snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK; diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 9e3263395f98..f926899e4755 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -4478,7 +4478,7 @@ static int snd_hdspm_put_tco_word_term(struct snd_kcontrol *kcontrol, -static struct snd_kcontrol_new snd_hdspm_controls_madi[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_madi[] = { HDSPM_MIXER("Mixer", 0), HDSPM_INTERNAL_CLOCK("Internal Clock", 0), HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), @@ -4500,7 +4500,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_madi[] = { }; -static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_madiface[] = { HDSPM_MIXER("Mixer", 0), HDSPM_INTERNAL_CLOCK("Internal Clock", 0), HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), @@ -4513,7 +4513,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_madiface[] = { HDSPM_MADI_SPEEDMODE("MADI Speed Mode", 0) }; -static struct snd_kcontrol_new snd_hdspm_controls_aio[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_aio[] = { HDSPM_MIXER("Mixer", 0), HDSPM_INTERNAL_CLOCK("Internal Clock", 0), HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), @@ -4554,7 +4554,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_aio[] = { */ }; -static struct snd_kcontrol_new snd_hdspm_controls_raydat[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_raydat[] = { HDSPM_MIXER("Mixer", 0), HDSPM_INTERNAL_CLOCK("Internal Clock", 0), HDSPM_SYSTEM_CLOCK_MODE("Clock Mode", 0), @@ -4582,7 +4582,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_raydat[] = { HDSPM_TOGGLE_SETTING("Single Speed WordClock Out", HDSPM_c0_Wck48) }; -static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_aes32[] = { HDSPM_MIXER("Mixer", 0), HDSPM_INTERNAL_CLOCK("Internal Clock", 0), HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0), @@ -4624,7 +4624,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_aes32[] = { /* Control elements for the optional TCO module */ -static struct snd_kcontrol_new snd_hdspm_controls_tco[] = { +static const struct snd_kcontrol_new snd_hdspm_controls_tco[] = { HDSPM_TCO_SAMPLE_RATE("TCO Sample Rate", 0), HDSPM_TCO_PULL("TCO Pull", 0), HDSPM_TCO_WCK_CONVERSION("TCO WCK Conversion", 0), @@ -4671,7 +4671,7 @@ static int snd_hdspm_create_controls(struct snd_card *card, unsigned int idx, limit; int err; struct snd_kcontrol *kctl; - struct snd_kcontrol_new *list = NULL; + const struct snd_kcontrol_new *list = NULL; switch (hdspm->io_type) { case MADI: diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 6fda027d28a4..2cb5b03f84d3 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -1454,7 +1454,7 @@ static int snd_rme9652_get_tc_value(void *private_data, #endif /* ALSA_HAS_STANDARD_WAY_OF_RETURNING_TIMECODE */ -static struct snd_kcontrol_new snd_rme9652_controls[] = { +static const struct snd_kcontrol_new snd_rme9652_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1509,10 +1509,10 @@ RME9652_TC_VALID("Timecode Valid", 0), RME9652_PASSTHRU("Passthru", 0) }; -static struct snd_kcontrol_new snd_rme9652_adat3_check = +static const struct snd_kcontrol_new snd_rme9652_adat3_check = RME9652_ADAT_SYNC("ADAT3 Sync Check", 0, 2); -static struct snd_kcontrol_new snd_rme9652_adat1_input = +static const struct snd_kcontrol_new snd_rme9652_adat1_input = RME9652_ADAT1_IN("ADAT1 Input Source", 0); static int snd_rme9652_create_controls(struct snd_card *card, struct snd_rme9652 *rme9652) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index dcdf5a534c4e..ecdd54d7a4e1 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1050,7 +1050,7 @@ static int snd_sonicvibes_put_double(struct snd_kcontrol *kcontrol, struct snd_c return change; } -static struct snd_kcontrol_new snd_sonicvibes_controls[] = { +static const struct snd_kcontrol_new snd_sonicvibes_controls[] = { SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0), SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1), SONICVIBES_DOUBLE("Aux Playback Volume", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 0, 0, 31, 1), @@ -1149,7 +1149,7 @@ static void snd_sonicvibes_proc_init(struct sonicvibes *sonic) */ #ifdef SUPPORT_JOYSTICK -static struct snd_kcontrol_new snd_sonicvibes_game_control = +static const struct snd_kcontrol_new snd_sonicvibes_game_control = SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) @@ -1375,7 +1375,7 @@ static int snd_sonicvibes_create(struct snd_card *card, * MIDI section */ -static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] = { +static const struct snd_kcontrol_new snd_sonicvibes_midi_controls[] = { SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0), SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0), SONICVIBES_SINGLE("SonicVibes Onboard Synth", 0, SV_IREG_MPU401, 0, 1, 0), diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index a531f4d2605d..1cffd988b616 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1588,7 +1588,7 @@ static const struct snd_kcontrol_new snd_ymfpci_dup4ch = { .put = snd_ymfpci_put_dup4ch, }; -static struct snd_kcontrol_new snd_ymfpci_controls[] = { +static const struct snd_kcontrol_new snd_ymfpci_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Wave Playback Volume", -- cgit v1.2.3 From c031b0cc77a1bef980eb360e317a6bbd54211326 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:54 +0100 Subject: ALSA: ppc: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-39-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/awacs.c | 50 +++++++++++++++++++++++++------------------------- sound/ppc/burgundy.c | 20 ++++++++++---------- sound/ppc/daca.c | 2 +- sound/ppc/pmac.c | 2 +- sound/ppc/snd_ps3.c | 2 +- sound/ppc/tumbler.c | 4 ++-- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 359d22a81ae3..73c0fd7277e6 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c @@ -464,7 +464,7 @@ static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, #define AMP_CH_SPK 0 #define AMP_CH_HD 1 -static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Speaker Playback Volume", .info = snd_pmac_awacs_info_volume_amp, @@ -582,46 +582,46 @@ static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol, /* * lists of mixer elements */ -static struct snd_kcontrol_new snd_pmac_awacs_mixers[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers[] = { AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), AWACS_VOLUME("Master Capture Volume", 0, 4, 0), /* AWACS_SWITCH("Unknown Playback Switch", 6, SHIFT_PAROUT0, 0), */ }; -static struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mixers_beige[] = { AWACS_VOLUME("Master Playback Volume", 2, 6, 1), AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_LINE, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mixers_lo[] = { AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), }; -static struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mixers_imac[] = { AWACS_VOLUME("Play-through Playback Volume", 5, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mixers_g4agp[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mixers_g4agp[] = { AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), AWACS_VOLUME("Master Playback Volume", 5, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), }; -static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac7500[] = { AWACS_VOLUME("Line out Playback Volume", 2, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), }; -static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac5500[] = { AWACS_VOLUME("Headphone Playback Volume", 2, 6, 1), }; -static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] = { AWACS_VOLUME("Master Playback Volume", 2, 6, 1), AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; @@ -629,34 +629,34 @@ static struct snd_kcontrol_new snd_pmac_awacs_mixers_pmac[] = { /* FIXME: is this correct order? * screamer (powerbook G3 pismo) seems to have different bits... */ -static struct snd_kcontrol_new snd_pmac_awacs_mixers2[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers2[] = { AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_LINE, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_MIC, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mixers2[] = { AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), }; -static struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mixers2_pmac5500[] = { AWACS_SWITCH("CD Capture Switch", 0, SHIFT_MUX_CD, 0), }; -static struct snd_kcontrol_new snd_pmac_awacs_master_sw = +static const struct snd_kcontrol_new snd_pmac_awacs_master_sw = AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); -static struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac = +static const struct snd_kcontrol_new snd_pmac_awacs_master_sw_imac = AWACS_SWITCH("Line out Playback Switch", 1, SHIFT_HDMUTE, 1); -static struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 = +static const struct snd_kcontrol_new snd_pmac_awacs_master_sw_pmac5500 = AWACS_SWITCH("Headphone Playback Switch", 1, SHIFT_HDMUTE, 1); -static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] = { AWACS_SWITCH("Mic Boost Capture Switch", 0, SHIFT_GAINLINE, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] = { +static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost Capture Volume", .info = snd_pmac_screamer_mic_boost_info, @@ -665,34 +665,34 @@ static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] = { }, }; -static struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] = +static const struct snd_kcontrol_new snd_pmac_awacs_mic_boost_pmac7500[] = { AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] = +static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost_beige[] = { AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), AWACS_SWITCH("CD Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), }; -static struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] = +static const struct snd_kcontrol_new snd_pmac_screamer_mic_boost_imac[] = { AWACS_SWITCH("Line Boost Capture Switch", 0, SHIFT_GAINLINE, 0), AWACS_SWITCH("Mic Boost Capture Switch", 6, SHIFT_MIC_BOOST, 0), }; -static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] = { +static const struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] = { AWACS_VOLUME("Speaker Playback Volume", 4, 6, 1), }; -static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw = +static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw = AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); -static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 = +static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac1 = AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 1); -static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 = +static const struct snd_kcontrol_new snd_pmac_awacs_speaker_sw_imac2 = AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); @@ -700,7 +700,7 @@ AWACS_SWITCH("Speaker Playback Switch", 1, SHIFT_PAROUT1, 0); * add new mixer elements to the card */ static int build_mixers(struct snd_pmac *chip, int nums, - struct snd_kcontrol_new *mixers) + const struct snd_kcontrol_new *mixers) { int i, err; diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index a2a41e5245ef..4fb990ab2ceb 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c @@ -454,7 +454,7 @@ static int snd_pmac_burgundy_put_switch_b(struct snd_kcontrol *kcontrol, /* * Burgundy mixers */ -static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] = { +static const struct snd_kcontrol_new snd_pmac_burgundy_mixers[] = { BURGUNDY_VOLUME_W("Master Playback Volume", 0, MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), BURGUNDY_VOLUME_W("CD Capture Volume", 0, @@ -482,7 +482,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] = { */ BURGUNDY_SWITCH_B("PCM Capture Switch", 0, MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0) }; -static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] = { +static const struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] = { BURGUNDY_VOLUME_W("Line in Capture Volume", 0, MASK_ADDR_BURGUNDY_VOLLINE, 16), BURGUNDY_VOLUME_W("Mic Capture Volume", 0, @@ -508,7 +508,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] = { BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0, MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) }; -static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] = { +static const struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] = { BURGUNDY_VOLUME_W("Line in Capture Volume", 0, MASK_ADDR_BURGUNDY_VOLMIC, 16), BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0, @@ -524,33 +524,33 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] = { /* BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0, * MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */ }; -static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac = +static const struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac = BURGUNDY_SWITCH_B("Master Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT, BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1); -static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac = +static const struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac = BURGUNDY_SWITCH_B("Master Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_OUTPUT_INTERN | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); -static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac = +static const struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac = BURGUNDY_SWITCH_B("Speaker Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); -static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac = +static const struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac = BURGUNDY_SWITCH_B("Speaker Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_OUTPUT_INTERN, 0, 0); -static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac = +static const struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac = BURGUNDY_SWITCH_B("Line out Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1); -static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac = +static const struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac = BURGUNDY_SWITCH_B("Line out Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); -static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac = +static const struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac = BURGUNDY_SWITCH_B("Headphone Playback Switch", 0, MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES, BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1); diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index f2b4478139a4..1eb698dafd93 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c @@ -186,7 +186,7 @@ static int daca_put_amp(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new daca_mixers[] = { +static const struct snd_kcontrol_new daca_mixers[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Deemphasis Switch", .info = daca_info_deemphasis, diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 6ee97008c8f0..87738ddc8bfd 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -1104,7 +1104,7 @@ static int pmac_hp_detect_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new auto_mute_controls[] = { +static const struct snd_kcontrol_new auto_mute_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Auto Mute Switch", .info = snd_pmac_boolean_mono_info, diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index 2b4c0268a86b..6d2a33b8faa0 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -715,7 +715,7 @@ static int snd_ps3_spdif_default_put(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new spdif_ctls[] = { +static const struct snd_kcontrol_new spdif_ctls[] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 31bab6af645f..a5843035d718 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -826,7 +826,7 @@ static int snapper_put_capture_source(struct snd_kcontrol *kcontrol, /* */ -static struct snd_kcontrol_new tumbler_mixers[] = { +static const struct snd_kcontrol_new tumbler_mixers[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .info = tumbler_info_master_volume, @@ -850,7 +850,7 @@ static struct snd_kcontrol_new tumbler_mixers[] = { }, }; -static struct snd_kcontrol_new snapper_mixers[] = { +static const struct snd_kcontrol_new snapper_mixers[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .info = tumbler_info_master_volume, -- cgit v1.2.3 From f8a32d94f31fc9e28732b73602adc072e620e466 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:55 +0100 Subject: ALSA: sparc: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-40-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 2 +- sound/sparc/cs4231.c | 2 +- sound/sparc/dbri.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 916bed46be06..9d0da5fa1c70 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -837,7 +837,7 @@ static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem return change; } -static struct snd_kcontrol_new amd7930_controls[] = { +static const struct snd_kcontrol_new amd7930_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitor Volume", diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index b0e5b4a83a26..59f812b5ce59 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1479,7 +1479,7 @@ static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, .private_value = (left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | \ ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22) } -static struct snd_kcontrol_new snd_cs4231_controls[] = { +static const struct snd_kcontrol_new snd_cs4231_controls[] = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 1390a52d6cfd..aaa1493b9ef9 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2410,7 +2410,7 @@ static int snd_cs4215_put_single(struct snd_kcontrol *kcontrol, .private_value = (entry) | ((shift) << 8) | ((mask) << 16) | \ ((invert) << 24) }, -static struct snd_kcontrol_new dbri_controls[] = { +static const struct snd_kcontrol_new dbri_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Playback Volume", -- cgit v1.2.3 From 1aeb1c7f281ea7b372d5801fda119df73b1be98c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:56 +0100 Subject: ALSA: spi: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-41-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index d6f2b19cfa39..e51bbf7836a2 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -657,7 +657,7 @@ static int snd_at73c213_aux_capture_volume_info( | (mask << 24) | (invert << 22)) \ } -static struct snd_kcontrol_new snd_at73c213_controls[] = { +static const struct snd_kcontrol_new snd_at73c213_controls[] = { AT73C213_STEREO("Master Playback Volume", 0, DAC_LMPG, DAC_RMPG, 0, 0, 0x1f, 1), AT73C213_STEREO("Master Playback Switch", 0, DAC_LMPG, DAC_RMPG, 5, 5, 1, 1), AT73C213_STEREO("PCM Playback Volume", 0, DAC_LLOG, DAC_RLOG, 0, 0, 0x1f, 1), -- cgit v1.2.3 From 195727e8b6a896d898b048e44fdf7ea52d36bd7e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:57 +0100 Subject: ALSA: usb: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-42-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/6fire/control.c | 8 ++++---- sound/usb/mixer.c | 6 +++--- sound/usb/mixer.h | 2 +- sound/usb/mixer_quirks.c | 16 ++++++++-------- sound/usb/mixer_us16x08.c | 38 +++++++++++++++++++------------------- sound/usb/mixer_us16x08.h | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sound/usb/6fire/control.c b/sound/usb/6fire/control.c index de1f030eaf72..20f34d2ace5f 100644 --- a/sound/usb/6fire/control.c +++ b/sound/usb/6fire/control.c @@ -397,7 +397,7 @@ static int usb6fire_control_digital_thru_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new vol_elements[] = { +static const struct snd_kcontrol_new vol_elements[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog Playback Volume", @@ -437,7 +437,7 @@ static struct snd_kcontrol_new vol_elements[] = { {} }; -static struct snd_kcontrol_new mute_elements[] = { +static const struct snd_kcontrol_new mute_elements[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog Playback Switch", @@ -471,7 +471,7 @@ static struct snd_kcontrol_new mute_elements[] = { {} }; -static struct snd_kcontrol_new elements[] = { +static const struct snd_kcontrol_new elements[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line/Phono Capture Route", @@ -517,7 +517,7 @@ static int usb6fire_control_add_virtual( struct control_runtime *rt, struct snd_card *card, char *name, - struct snd_kcontrol_new *elems) + const struct snd_kcontrol_new *elems) { int ret; int i; diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index f60e0869c096..6d9080b47d0f 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1445,7 +1445,7 @@ error: return 0; } -static struct snd_kcontrol_new usb_feature_unit_ctl = { +static const struct snd_kcontrol_new usb_feature_unit_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "", /* will be filled later manually */ .info = mixer_ctl_feature_info, @@ -1466,7 +1466,7 @@ static const struct snd_kcontrol_new usb_feature_unit_ctl_ro = { * A control which shows the boolean value from reading a UAC control on * the master channel. */ -static struct snd_kcontrol_new usb_bool_master_control_ctl_ro = { +static const struct snd_kcontrol_new usb_bool_master_control_ctl_ro = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "", /* will be filled later manually */ .access = SNDRV_CTL_ELEM_ACCESS_READ, @@ -1488,7 +1488,7 @@ static const struct snd_kcontrol_new usb_connector_ctl_ro = { * This symbol is exported in order to allow the mixer quirks to * hook up to the standard feature unit control mechanism */ -struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl; +const struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl; /* * build a feature control diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 37e1b234c802..65d6d08c96f5 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -116,6 +116,6 @@ int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval, extern void snd_usb_mixer_elem_free(struct snd_kcontrol *kctl); -extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl; +extern const struct snd_kcontrol_new *snd_usb_feature_unit_ctl; #endif /* __USBMIXER_H */ diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 39e27ae6c597..4cb8331d87a4 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -507,7 +507,7 @@ static int snd_emu0204_ch_switch_resume(struct usb_mixer_elem_list *list) list->kctl->private_value); } -static struct snd_kcontrol_new snd_emu0204_control = { +static const struct snd_kcontrol_new snd_emu0204_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Front Jack Channels", .info = snd_emu0204_ch_switch_info, @@ -575,7 +575,7 @@ static int snd_xonar_u1_switch_resume(struct usb_mixer_elem_list *list) list->kctl->private_value); } -static struct snd_kcontrol_new snd_xonar_u1_output_switch = { +static const struct snd_kcontrol_new snd_xonar_u1_output_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Digital Playback Switch", .info = snd_ctl_boolean_mono_info, @@ -702,7 +702,7 @@ static int snd_mbox1_switch_resume(struct usb_mixer_elem_list *list) return snd_mbox1_switch_update(list->mixer, list->kctl->private_value); } -static struct snd_kcontrol_new snd_mbox1_switch = { +static const struct snd_kcontrol_new snd_mbox1_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Clock Source", .index = 0, @@ -787,7 +787,7 @@ static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol, return err < 0 ? err : 1; } -static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = { +static const struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = { { .name = "Direct Thru Channel A", .private_value = _MAKE_NI_CONTROL(0x01, 0x03), @@ -806,7 +806,7 @@ static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = { }, }; -static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = { +static const struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = { { .name = "Direct Thru Channel A", .private_value = _MAKE_NI_CONTROL(0x01, 0x03), @@ -1662,7 +1662,7 @@ static int snd_microii_spdif_switch_put(struct snd_kcontrol *kcontrol, return err < 0 ? err : 1; } -static struct snd_kcontrol_new snd_microii_mixer_spdif[] = { +static const struct snd_kcontrol_new snd_microii_mixer_spdif[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), @@ -1769,7 +1769,7 @@ static int snd_soundblaster_e1_switch_info(struct snd_kcontrol *kcontrol, return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); } -static struct snd_kcontrol_new snd_soundblaster_e1_input_switch = { +static const struct snd_kcontrol_new snd_soundblaster_e1_input_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Source", .info = snd_soundblaster_e1_switch_info, @@ -2093,7 +2093,7 @@ static int snd_rme_sync_source_info(struct snd_kcontrol *kcontrol, ARRAY_SIZE(sync_sources), sync_sources); } -static struct snd_kcontrol_new snd_rme_controls[] = { +static const struct snd_kcontrol_new snd_rme_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AES Rate", diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c index f0e8e1539450..986145fd2ce0 100644 --- a/sound/usb/mixer_us16x08.c +++ b/sound/usb/mixer_us16x08.c @@ -760,7 +760,7 @@ static int snd_us16x08_meter_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new snd_us16x08_ch_boolean_ctl = { +static const struct snd_kcontrol_new snd_us16x08_ch_boolean_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -770,7 +770,7 @@ static struct snd_kcontrol_new snd_us16x08_ch_boolean_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 1) }; -static struct snd_kcontrol_new snd_us16x08_ch_int_ctl = { +static const struct snd_kcontrol_new snd_us16x08_ch_int_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -780,7 +780,7 @@ static struct snd_kcontrol_new snd_us16x08_ch_int_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_FADER_BIAS, 1, 0, 133) }; -static struct snd_kcontrol_new snd_us16x08_pan_int_ctl = { +static const struct snd_kcontrol_new snd_us16x08_pan_int_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -790,7 +790,7 @@ static struct snd_kcontrol_new snd_us16x08_pan_int_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_FADER_BIAS, 1, 0, 255) }; -static struct snd_kcontrol_new snd_us16x08_master_ctl = { +static const struct snd_kcontrol_new snd_us16x08_master_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 1, @@ -800,7 +800,7 @@ static struct snd_kcontrol_new snd_us16x08_master_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_FADER_BIAS, 1, 0, 133) }; -static struct snd_kcontrol_new snd_us16x08_route_ctl = { +static const struct snd_kcontrol_new snd_us16x08_route_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 8, @@ -810,7 +810,7 @@ static struct snd_kcontrol_new snd_us16x08_route_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 9) }; -static struct snd_kcontrol_new snd_us16x08_bus_ctl = { +static const struct snd_kcontrol_new snd_us16x08_bus_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 1, @@ -820,7 +820,7 @@ static struct snd_kcontrol_new snd_us16x08_bus_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 1) }; -static struct snd_kcontrol_new snd_us16x08_compswitch_ctl = { +static const struct snd_kcontrol_new snd_us16x08_compswitch_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -830,7 +830,7 @@ static struct snd_kcontrol_new snd_us16x08_compswitch_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 1) }; -static struct snd_kcontrol_new snd_us16x08_comp_threshold_ctl = { +static const struct snd_kcontrol_new snd_us16x08_comp_threshold_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -841,7 +841,7 @@ static struct snd_kcontrol_new snd_us16x08_comp_threshold_ctl = { 0, 0x20) }; -static struct snd_kcontrol_new snd_us16x08_comp_ratio_ctl = { +static const struct snd_kcontrol_new snd_us16x08_comp_ratio_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -852,7 +852,7 @@ static struct snd_kcontrol_new snd_us16x08_comp_ratio_ctl = { sizeof(ratio_map) - 1), /*max*/ }; -static struct snd_kcontrol_new snd_us16x08_comp_gain_ctl = { +static const struct snd_kcontrol_new snd_us16x08_comp_gain_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -862,7 +862,7 @@ static struct snd_kcontrol_new snd_us16x08_comp_gain_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 0x14) }; -static struct snd_kcontrol_new snd_us16x08_comp_attack_ctl = { +static const struct snd_kcontrol_new snd_us16x08_comp_attack_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -873,7 +873,7 @@ static struct snd_kcontrol_new snd_us16x08_comp_attack_ctl = { SND_US16X08_KCSET(SND_US16X08_COMP_ATTACK_BIAS, 1, 0, 0xc6), }; -static struct snd_kcontrol_new snd_us16x08_comp_release_ctl = { +static const struct snd_kcontrol_new snd_us16x08_comp_release_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -884,7 +884,7 @@ static struct snd_kcontrol_new snd_us16x08_comp_release_ctl = { SND_US16X08_KCSET(SND_US16X08_COMP_RELEASE_BIAS, 1, 0, 0x63), }; -static struct snd_kcontrol_new snd_us16x08_eq_gain_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_gain_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -894,7 +894,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_gain_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 24), }; -static struct snd_kcontrol_new snd_us16x08_eq_low_freq_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_low_freq_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -904,7 +904,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_low_freq_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 0x1F), }; -static struct snd_kcontrol_new snd_us16x08_eq_mid_freq_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_mid_freq_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -914,7 +914,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_mid_freq_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 0x3F) }; -static struct snd_kcontrol_new snd_us16x08_eq_mid_width_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_mid_width_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -924,7 +924,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_mid_width_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 0x06) }; -static struct snd_kcontrol_new snd_us16x08_eq_high_freq_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_high_freq_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -935,7 +935,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_high_freq_ctl = { SND_US16X08_KCSET(SND_US16X08_EQ_HIGHFREQ_BIAS, 1, 0, 0x1F) }; -static struct snd_kcontrol_new snd_us16x08_eq_switch_ctl = { +static const struct snd_kcontrol_new snd_us16x08_eq_switch_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 16, @@ -945,7 +945,7 @@ static struct snd_kcontrol_new snd_us16x08_eq_switch_ctl = { .private_value = SND_US16X08_KCSET(SND_US16X08_NO_BIAS, 1, 0, 1) }; -static struct snd_kcontrol_new snd_us16x08_meter_ctl = { +static const struct snd_kcontrol_new snd_us16x08_meter_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .count = 1, diff --git a/sound/usb/mixer_us16x08.h b/sound/usb/mixer_us16x08.h index 56ff16c0698f..7b8583dd3b07 100644 --- a/sound/usb/mixer_us16x08.h +++ b/sound/usb/mixer_us16x08.h @@ -108,7 +108,7 @@ struct snd_us16x08_meter_store { }; struct snd_us16x08_control_params { - struct snd_kcontrol_new *kcontrol_new; + const struct snd_kcontrol_new *kcontrol_new; int control_id; int type; int num_channels; -- cgit v1.2.3 From 46708e626d0d768587cf676e55b21e0beb966be6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:58 +0100 Subject: ALSA: parisc: Constify snd_kcontrol_new items Most of snd_kcontrol_new definitions are read-only and passed as-is. Let's declare them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-43-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index d330f22a3e8f..97241d984c6c 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -797,7 +797,7 @@ snd_harmony_captureroute_put(struct snd_kcontrol *kc, .private_value = ((left_shift) | ((right_shift) << 8) | \ ((mask) << 16) | ((invert) << 24)) } -static struct snd_kcontrol_new snd_harmony_controls[] = { +static const struct snd_kcontrol_new snd_harmony_controls[] = { HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT, HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, -- cgit v1.2.3 From 1da7f0c570d7356f232aee6528ccf8b2dcd96dcf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:16:59 +0100 Subject: ALSA: dummy: Constify snd_pcm_ops definitions The snd_pcm_ops items defined in snd-dummy driver can be gracefully declared as const. Let's mark them for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-44-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/dummy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index cec682a7b88d..46fa60e7f722 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -644,7 +644,7 @@ static struct page *dummy_pcm_page(struct snd_pcm_substream *substream, return virt_to_page(dummy_page[substream->stream]); /* the same page */ } -static struct snd_pcm_ops dummy_pcm_ops = { +static const struct snd_pcm_ops dummy_pcm_ops = { .open = dummy_pcm_open, .close = dummy_pcm_close, .hw_params = dummy_pcm_hw_params, @@ -653,7 +653,7 @@ static struct snd_pcm_ops dummy_pcm_ops = { .pointer = dummy_pcm_pointer, }; -static struct snd_pcm_ops dummy_pcm_ops_no_buf = { +static const struct snd_pcm_ops dummy_pcm_ops_no_buf = { .open = dummy_pcm_open, .close = dummy_pcm_close, .hw_params = dummy_pcm_hw_params, @@ -670,7 +670,7 @@ static int snd_card_dummy_pcm(struct snd_dummy *dummy, int device, int substreams) { struct snd_pcm *pcm; - struct snd_pcm_ops *ops; + const struct snd_pcm_ops *ops; int err; err = snd_pcm_new(dummy->card, "Dummy PCM", device, -- cgit v1.2.3 From fe27463ad867864da1786e209f5d23e10ef17d3b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:00 +0100 Subject: ALSA: opl3: Constify snd_opl3_drum_voice definitions The snd_opl3_drum_voice items are all read-only, hence they can be declared as const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-45-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_drums.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sound/drivers/opl3/opl3_drums.c b/sound/drivers/opl3/opl3_drums.c index cc7fb35e521b..318cd8a2ee3a 100644 --- a/sound/drivers/opl3/opl3_drums.c +++ b/sound/drivers/opl3/opl3_drums.c @@ -47,25 +47,25 @@ struct snd_opl3_drum_note { unsigned char feedback_connection; }; -static struct snd_opl3_drum_voice bass_op0 = {6, 0, 0x00, 0x32, 0xf8, 0x66, 0x30, 0x00}; -static struct snd_opl3_drum_voice bass_op1 = {6, 1, 0x00, 0x03, 0xf6, 0x57, 0x30, 0x00}; -static struct snd_opl3_drum_note bass_note = {6, 0x90, 0x09}; +static const struct snd_opl3_drum_voice bass_op0 = {6, 0, 0x00, 0x32, 0xf8, 0x66, 0x30, 0x00}; +static const struct snd_opl3_drum_voice bass_op1 = {6, 1, 0x00, 0x03, 0xf6, 0x57, 0x30, 0x00}; +static const struct snd_opl3_drum_note bass_note = {6, 0x90, 0x09}; -static struct snd_opl3_drum_voice hihat = {7, 0, 0x00, 0x03, 0xf0, 0x06, 0x20, 0x00}; +static const struct snd_opl3_drum_voice hihat = {7, 0, 0x00, 0x03, 0xf0, 0x06, 0x20, 0x00}; -static struct snd_opl3_drum_voice snare = {7, 1, 0x00, 0x03, 0xf0, 0x07, 0x20, 0x02}; -static struct snd_opl3_drum_note snare_note = {7, 0xf4, 0x0d}; +static const struct snd_opl3_drum_voice snare = {7, 1, 0x00, 0x03, 0xf0, 0x07, 0x20, 0x02}; +static const struct snd_opl3_drum_note snare_note = {7, 0xf4, 0x0d}; -static struct snd_opl3_drum_voice tomtom = {8, 0, 0x02, 0x03, 0xf0, 0x06, 0x10, 0x00}; -static struct snd_opl3_drum_note tomtom_note = {8, 0xf4, 0x09}; +static const struct snd_opl3_drum_voice tomtom = {8, 0, 0x02, 0x03, 0xf0, 0x06, 0x10, 0x00}; +static const struct snd_opl3_drum_note tomtom_note = {8, 0xf4, 0x09}; -static struct snd_opl3_drum_voice cymbal = {8, 1, 0x04, 0x03, 0xf0, 0x06, 0x10, 0x00}; +static const struct snd_opl3_drum_voice cymbal = {8, 1, 0x04, 0x03, 0xf0, 0x06, 0x10, 0x00}; /* * set drum voice characteristics */ static void snd_opl3_drum_voice_set(struct snd_opl3 *opl3, - struct snd_opl3_drum_voice *data) + const struct snd_opl3_drum_voice *data) { unsigned char op_offset = snd_opl3_regmap[data->voice][data->op]; unsigned char voice_offset = data->voice; @@ -100,7 +100,7 @@ static void snd_opl3_drum_voice_set(struct snd_opl3 *opl3, * Set drum voice pitch */ static void snd_opl3_drum_note_set(struct snd_opl3 *opl3, - struct snd_opl3_drum_note *data) + const struct snd_opl3_drum_note *data) { unsigned char voice_offset = data->voice; unsigned short opl3_reg; @@ -118,7 +118,7 @@ static void snd_opl3_drum_note_set(struct snd_opl3 *opl3, * Set drum voice volume and position */ static void snd_opl3_drum_vol_set(struct snd_opl3 *opl3, - struct snd_opl3_drum_voice *data, + const struct snd_opl3_drum_voice *data, int vel, struct snd_midi_channel *chan) { unsigned char op_offset = snd_opl3_regmap[data->voice][data->op]; @@ -170,7 +170,7 @@ void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int vel, int on_off, struct snd_midi_channel *chan) { unsigned char drum_mask; - struct snd_opl3_drum_voice *drum_voice; + const struct snd_opl3_drum_voice *drum_voice; if (!(opl3->drum_reg & OPL3_PERCUSSION_ENABLE)) return; -- cgit v1.2.3 From c0476b980d6cb23d845e4c39f415507915344f22 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:01 +0100 Subject: ALSA: ac97: Constify snd_ac97_res_table definition One snd_ac97_res_table definition remains forgotten without const. Let's add it for a bit of optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-46-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 719a1e4956dd..524f9d2dcb3c 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -3871,7 +3871,7 @@ static int mpatch_si3036(struct snd_ac97 * ac97) * check_volume_resolution(). */ -static struct snd_ac97_res_table lm4550_restbl[] = { +static const struct snd_ac97_res_table lm4550_restbl[] = { { AC97_MASTER, 0x1f1f }, { AC97_HEADPHONE, 0x1f1f }, { AC97_MASTER_MONO, 0x001f }, -- cgit v1.2.3 From 311840d96fd6f41ce1614bc57068f35169d6a52c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:02 +0100 Subject: ALSA: ca0106: Constify snd_ca0106_category_str items snd_ca0106_con_category array is read-only and can be marked as const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-47-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index 15272c9ca4d5..c99603e137e5 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c @@ -66,7 +66,7 @@ struct snd_ca0106_category_str { const char *name; }; -static struct snd_ca0106_category_str snd_ca0106_con_category[] = { +static const struct snd_ca0106_category_str snd_ca0106_con_category[] = { { IEC958_AES1_CON_DAT, "DAT" }, { IEC958_AES1_CON_VCR, "VCR" }, { IEC958_AES1_CON_MICROPHONE, "microphone" }, -- cgit v1.2.3 From dc6ffaf82899d459cc486dff88e57133e03d9e28 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:03 +0100 Subject: ALSA: ca0106: Constify snd_ca0106_details The snd_ca0106_details table entries are referred only as read-only. Let's make them const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-48-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106.h | 2 +- sound/pci/ca0106/ca0106_main.c | 6 +++--- sound/pci/ca0106/ca0106_mixer.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index 986905cfcc4c..62a22ca3b9de 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h @@ -663,7 +663,7 @@ struct snd_ca0106_details { // definition of the chip-specific record struct snd_ca0106 { struct snd_card *card; - struct snd_ca0106_details *details; + const struct snd_ca0106_details *details; struct pci_dev *pci; unsigned long port; diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index d3bd27ddb049..487b1aaafa1e 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -156,7 +156,7 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model."); #include "ca0106.h" -static struct snd_ca0106_details ca0106_chip_details[] = { +static const struct snd_ca0106_details ca0106_chip_details[] = { /* Sound Blaster X-Fi Extreme Audio. This does not have an AC97. 53SB079000000 */ /* It is really just a normal SB Live 24bit. */ /* Tested: @@ -503,7 +503,7 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) } static int snd_ca0106_channel_dac(struct snd_ca0106 *chip, - struct snd_ca0106_details *details, + const struct snd_ca0106_details *details, int channel_id) { switch (channel_id) { @@ -1593,7 +1593,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card, struct snd_ca0106 **rchip) { struct snd_ca0106 *chip; - struct snd_ca0106_details *c; + const struct snd_ca0106_details *c; int err; static const struct snd_device_ops ops = { .dev_free = snd_ca0106_dev_free, diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 729d757c900a..c771995b12b9 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -654,7 +654,7 @@ static const int spi_dmute_bit[] = { }; static struct snd_kcontrol_new -snd_ca0106_volume_spi_dac_ctl(struct snd_ca0106_details *details, +snd_ca0106_volume_spi_dac_ctl(const struct snd_ca0106_details *details, int channel_id) { struct snd_kcontrol_new spi_switch = {0}; -- cgit v1.2.3 From aeb0215c76990efcc0c3d6b11e130d176c040ff9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:04 +0100 Subject: ALSA: ice17xx: Constify snd_ice1712_card_info The snd_ice1712_card_info objects are referred only as read-only. Let's make them const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-49-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ice1712.c | 6 +++--- sound/pci/ice1712/ice1712.h | 2 +- sound/pci/ice1712/ice1724.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 5202e4c06fc4..884d0cdec08c 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -2218,7 +2218,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak = { /* * list of available boards */ -static struct snd_ice1712_card_info *card_tables[] = { +static const struct snd_ice1712_card_info *card_tables[] = { snd_ice1712_hoontech_cards, snd_ice1712_delta_cards, snd_ice1712_ews_cards, @@ -2242,7 +2242,7 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice, { int dev = ICE_I2C_EEPROM_ADDR; /* I2C EEPROM device address */ unsigned int i, size; - struct snd_ice1712_card_info * const *tbl, *c; + const struct snd_ice1712_card_info * const *tbl, *c; if (!modelname || !*modelname) { ice->eeprom.subvendor = 0; @@ -2587,7 +2587,7 @@ static int snd_ice1712_probe(struct pci_dev *pci, struct snd_card *card; struct snd_ice1712 *ice; int pcm_dev = 0, err; - struct snd_ice1712_card_info * const *tbl, *c; + const struct snd_ice1712_card_info * const *tbl, *c; if (dev >= SNDRV_CARDS) return -ENODEV; diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index 88145708a8a7..cd02710d8271 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h @@ -316,7 +316,7 @@ struct snd_ice1712 { struct snd_info_entry *proc_entry; struct snd_ice1712_eeprom eeprom; - struct snd_ice1712_card_info *card_info; + const struct snd_ice1712_card_info *card_info; unsigned int pro_volumes[20]; unsigned int omni:1; /* Delta Omni I/O */ diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 4630a8c42aa9..f4d69b8197ed 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -2170,13 +2170,13 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak = { * */ -static struct snd_ice1712_card_info no_matched; +static const struct snd_ice1712_card_info no_matched; /* ooAoo cards with no controls */ -static unsigned char ooaoo_sq210_eeprom[] = { +static const unsigned char ooaoo_sq210_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC, 1xDACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ @@ -2196,7 +2196,7 @@ static unsigned char ooaoo_sq210_eeprom[] = { }; -static struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = { +static const struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = { { .name = "ooAoo SQ210a", .model = "sq210a", @@ -2206,7 +2206,7 @@ static struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = { { } /* terminator */ }; -static struct snd_ice1712_card_info *card_tables[] = { +static const struct snd_ice1712_card_info *card_tables[] = { snd_vt1724_revo_cards, snd_vt1724_amp_cards, snd_vt1724_aureon_cards, @@ -2276,7 +2276,7 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice, { const int dev = 0xa0; /* EEPROM device address */ unsigned int i, size; - struct snd_ice1712_card_info * const *tbl, *c; + const struct snd_ice1712_card_info * const *tbl, *c; if (!modelname || !*modelname) { ice->eeprom.subvendor = 0; @@ -2590,7 +2590,7 @@ static int snd_vt1724_probe(struct pci_dev *pci, struct snd_card *card; struct snd_ice1712 *ice; int pcm_dev = 0, err; - struct snd_ice1712_card_info * const *tbl, *c; + const struct snd_ice1712_card_info * const *tbl, *c; if (dev >= SNDRV_CARDS) return -ENODEV; -- cgit v1.2.3 From 4f8ce9821ecd3aca758a52f7dbb6146b8bdcb71c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:05 +0100 Subject: ALSA: ice1712: Constify wm-specific tables The tables defined in wm8766.c and wm8776.c are referred as read-only, hence they can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-50-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/wm8766.c | 2 +- sound/pci/ice1712/wm8776.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c index 0943f9ef73cf..fe3e243b3854 100644 --- a/sound/pci/ice1712/wm8766.c +++ b/sound/pci/ice1712/wm8766.c @@ -26,7 +26,7 @@ static void snd_wm8766_write(struct snd_wm8766 *wm, u16 addr, u16 data) static const DECLARE_TLV_DB_SCALE(wm8766_tlv, -12750, 50, 1); -static struct snd_wm8766_ctl snd_wm8766_default_ctl[WM8766_CTL_COUNT] = { +static const struct snd_wm8766_ctl snd_wm8766_default_ctl[WM8766_CTL_COUNT] = { [WM8766_CTL_CH1_VOL] = { .name = "Channel 1 Playback Volume", .type = SNDRV_CTL_ELEM_TYPE_INTEGER, diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c index d696a7c29f7e..d96008df880d 100644 --- a/sound/pci/ice1712/wm8776.c +++ b/sound/pci/ice1712/wm8776.c @@ -129,7 +129,7 @@ static const DECLARE_TLV_DB_SCALE(wm8776_ngth_tlv, -7800, 600, 0); static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_lim_tlv, -1200, 100, 0); static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_alc_tlv, -2100, 400, 0); -static struct snd_wm8776_ctl snd_wm8776_default_ctl[WM8776_CTL_COUNT] = { +static const struct snd_wm8776_ctl snd_wm8776_default_ctl[WM8776_CTL_COUNT] = { [WM8776_CTL_DAC_VOL] = { .name = "Master Playback Volume", .type = SNDRV_CTL_ELEM_TYPE_INTEGER, -- cgit v1.2.3 From 37cc306b723f94d2be73578069ed1e88e1a30cdb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:06 +0100 Subject: ALSA: line6: Constify snd_ratden definitions The snd_ratden definitions used in line6 drivers are all read-only, so they can be marked as const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-51-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/line6/pod.c | 2 +- sound/usb/line6/podhd.c | 2 +- sound/usb/line6/toneport.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c index ee4c9d220fdf..cd44cb5f1310 100644 --- a/sound/usb/line6/pod.c +++ b/sound/usb/line6/pod.c @@ -110,7 +110,7 @@ enum { POD_BUSY_MIDISEND }; -static struct snd_ratden pod_ratden = { +static const struct snd_ratden pod_ratden = { .num_min = 78125, .num_max = 78125, .num_step = 1, diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 27bf61c177c0..d37db32ecd3b 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -42,7 +42,7 @@ struct usb_line6_podhd { #define line6_to_podhd(x) container_of(x, struct usb_line6_podhd, line6) -static struct snd_ratden podhd_ratden = { +static const struct snd_ratden podhd_ratden = { .num_min = 48000, .num_max = 48000, .num_step = 1, diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c index d0a555dbe324..94dd5e7ab2e6 100644 --- a/sound/usb/line6/toneport.c +++ b/sound/usb/line6/toneport.c @@ -63,7 +63,7 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2); #define TONEPORT_PCM_DELAY 1 -static struct snd_ratden toneport_ratden = { +static const struct snd_ratden toneport_ratden = { .num_min = 44100, .num_max = 44100, .num_step = 1, -- cgit v1.2.3 From 49624472a90b0f50f20389e0896e2eb53ea71b5e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:07 +0100 Subject: ALSA: usx2y: Constify struct snd_usb_audio_quirk entries The quirk entries used in us122l and usx2y drivers can be declared as const as they are read-only. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-52-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/usx2y/us122l.c | 8 ++++---- sound/usb/usx2y/usX2Yhwdep.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index e82c5236482d..f86f7a61fb36 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -40,13 +40,13 @@ static int snd_us122l_card_used[SNDRV_CARDS]; static int us122l_create_usbmidi(struct snd_card *card) { - static struct snd_usb_midi_endpoint_info quirk_data = { + static const struct snd_usb_midi_endpoint_info quirk_data = { .out_ep = 4, .in_ep = 3, .out_cables = 0x001, .in_cables = 0x001 }; - static struct snd_usb_audio_quirk quirk = { + static const struct snd_usb_audio_quirk quirk = { .vendor_name = "US122L", .product_name = NAME_ALLCAPS, .ifnum = 1, @@ -62,13 +62,13 @@ static int us122l_create_usbmidi(struct snd_card *card) static int us144_create_usbmidi(struct snd_card *card) { - static struct snd_usb_midi_endpoint_info quirk_data = { + static const struct snd_usb_midi_endpoint_info quirk_data = { .out_ep = 4, .in_ep = 3, .out_cables = 0x001, .in_cables = 0x001 }; - static struct snd_usb_audio_quirk quirk = { + static const struct snd_usb_audio_quirk quirk = { .vendor_name = "US144", .product_name = NAME_ALLCAPS, .ifnum = 0, diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 9985fc139487..0e6d82b5778e 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -126,26 +126,26 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, static int usX2Y_create_usbmidi(struct snd_card *card) { - static struct snd_usb_midi_endpoint_info quirk_data_1 = { + static const struct snd_usb_midi_endpoint_info quirk_data_1 = { .out_ep = 0x06, .in_ep = 0x06, .out_cables = 0x001, .in_cables = 0x001 }; - static struct snd_usb_audio_quirk quirk_1 = { + static const struct snd_usb_audio_quirk quirk_1 = { .vendor_name = "TASCAM", .product_name = NAME_ALLCAPS, .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &quirk_data_1 }; - static struct snd_usb_midi_endpoint_info quirk_data_2 = { + static const struct snd_usb_midi_endpoint_info quirk_data_2 = { .out_ep = 0x06, .in_ep = 0x06, .out_cables = 0x003, .in_cables = 0x003 }; - static struct snd_usb_audio_quirk quirk_2 = { + static const struct snd_usb_audio_quirk quirk_2 = { .vendor_name = "TASCAM", .product_name = "US428", .ifnum = 0, @@ -154,7 +154,7 @@ static int usX2Y_create_usbmidi(struct snd_card *card) }; struct usb_device *dev = usX2Y(card)->dev; struct usb_interface *iface = usb_ifnum_to_if(dev, 0); - struct snd_usb_audio_quirk *quirk = + const struct snd_usb_audio_quirk *quirk = le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? &quirk_2 : &quirk_1; -- cgit v1.2.3 From 87065d3d946bf116a639f3bd88ebbd3f3938cffb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:08 +0100 Subject: ALSA: seq: oss: Constify snd_seq_oss_callback definitions The snd_seq_oss_callback items are just copied to another struct as-is, hence they can be declared as const. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-53-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_oss.c | 2 +- sound/synth/emux/emux_oss.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c index d0cf2fb02cce..7bf0d5f3fedd 100644 --- a/sound/drivers/opl3/opl3_oss.c +++ b/sound/drivers/opl3/opl3_oss.c @@ -16,7 +16,7 @@ static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg); /* operators */ -static struct snd_seq_oss_callback oss_callback = { +static const struct snd_seq_oss_callback oss_callback = { .owner = THIS_MODULE, .open = snd_opl3_open_seq_oss, .close = snd_opl3_close_seq_oss, diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c index a14fc6562664..d8d32671f703 100644 --- a/sound/synth/emux/emux_oss.c +++ b/sound/synth/emux/emux_oss.c @@ -34,7 +34,7 @@ static void fake_event(struct snd_emux *emu, struct snd_emux_port *port, int ch, int param, int val, int atomic, int hop); /* operators */ -static struct snd_seq_oss_callback oss_callback = { +static const struct snd_seq_oss_callback oss_callback = { .owner = THIS_MODULE, .open = snd_emux_open_seq_oss, .close = snd_emux_close_seq_oss, -- cgit v1.2.3 From baa9df207a8f9e0377ef26a262e29b9342e45738 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:09 +0100 Subject: ALSA: bt87x: Constify snd_bt87x_boards The snd_bt87x_boards array is referred as read-only, hence it can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-54-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/bt87x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index ece3f8971145..8c48864c844a 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -150,7 +150,7 @@ struct snd_bt87x_board { unsigned no_digital:1; /* No digital input */ }; -static struct snd_bt87x_board snd_bt87x_boards[] = { +static const struct snd_bt87x_board snd_bt87x_boards[] = { [SND_BT87X_BOARD_UNKNOWN] = { .dig_rate = 32000, /* just a guess */ }, -- cgit v1.2.3 From c274d967cee5859c91c200905f038cac84ebd464 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:10 +0100 Subject: ALSA: emu10k1: Constify snd_emu_chip_details The snd_emu_chip_details definitions are referred as read-only, hence they can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-55-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 6a8fce8ac218..51af766f57d2 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1283,7 +1283,7 @@ static int snd_emu10k1_dev_free(struct snd_device *device) return snd_emu10k1_free(emu); } -static struct snd_emu_chip_details emu_chip_details[] = { +static const struct snd_emu_chip_details emu_chip_details[] = { /* Audigy 5/Rx SB1550 */ /* Tested by michael@gernoth.net 28 Mar 2015 */ /* DSP: CA10300-IAT LF -- cgit v1.2.3 From cd6e03122be08fd6d2af0445d5f2527563d6bf49 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:11 +0100 Subject: ALSA: es1968: Constify snd_es1968_tea575x_gpios The snd_es1968_tea575x_gpios table is referred as read-only, hence it can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-56-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index f23a935267c3..affd3e8d7a67 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2529,7 +2529,7 @@ struct snd_es1968_tea575x_gpio { char *name; }; -static struct snd_es1968_tea575x_gpio snd_es1968_tea575x_gpios[] = { +static const struct snd_es1968_tea575x_gpio snd_es1968_tea575x_gpios[] = { { .data = 6, .clk = 7, .wren = 8, .most = 9, .name = "SF64-PCE2" }, { .data = 7, .clk = 8, .wren = 6, .most = 10, .name = "M56VAP" }, }; -- cgit v1.2.3 From fb537cd0089db62190405e5ec43ce4740e65f330 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:12 +0100 Subject: ALSA: fm801: Constify snd_fm801_tea575x_gpios The snd_fm801_tea575x_gpios table is referred as read-only, hence it can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-57-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 4117a053eb18..40dfad74f8e1 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -724,7 +724,7 @@ struct snd_fm801_tea575x_gpio { char *name; }; -static struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = { +static const struct snd_fm801_tea575x_gpio snd_fm801_tea575x_gpios[] = { { .data = 1, .clk = 3, .wren = 2, .most = 0, .name = "SF256-PCS" }, { .data = 1, .clk = 0, .wren = 2, .most = 3, .name = "SF256-PCP" }, { .data = 2, .clk = 0, .wren = 1, .most = 3, .name = "SF64-PCR" }, -- cgit v1.2.3 From a5dc05e466b054722817e09e9e2867b2c373f570 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:13 +0100 Subject: ALSA: hda: Constify snd_pci_quirk tables The snd_pci_quirk tables are referred as read-only, hence they can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-58-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 4733268ec74e..bebc31024737 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1490,7 +1490,7 @@ static bool check_hdmi_disabled(struct pci_dev *pci) /* * white/black-listing for position_fix */ -static struct snd_pci_quirk position_fix_list[] = { +static const struct snd_pci_quirk position_fix_list[] = { SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), @@ -1583,7 +1583,7 @@ static void assign_position_fix(struct azx *chip, int fix) /* * black-lists for probe_mask */ -static struct snd_pci_quirk probe_mask_list[] = { +static const struct snd_pci_quirk probe_mask_list[] = { /* Thinkpad often breaks the controller communication when accessing * to the non-working (or non-existing) modem codec slot. */ @@ -1631,7 +1631,7 @@ static void check_probe_mask(struct azx *chip, int dev) /* * white/black-list for enable_msi */ -static struct snd_pci_quirk msi_black_list[] = { +static const struct snd_pci_quirk msi_black_list[] = { SND_PCI_QUIRK(0x103c, 0x2191, "HP", 0), /* AMD Hudson */ SND_PCI_QUIRK(0x103c, 0x2192, "HP", 0), /* AMD Hudson */ SND_PCI_QUIRK(0x103c, 0x21f7, "HP", 0), /* AMD Hudson */ @@ -2164,7 +2164,7 @@ out_free: * So we keep a list of devices where we disable powersaving as its known * to causes problems on these devices. */ -static struct snd_pci_quirk power_save_blacklist[] = { +static const struct snd_pci_quirk power_save_blacklist[] = { /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ SND_PCI_QUIRK(0x1849, 0xc892, "Asrock B85M-ITX", 0), /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ -- cgit v1.2.3 From 88e540a8764ec0f5fb4a1185fbeb7827fefd3601 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Jan 2020 09:17:14 +0100 Subject: ALSA: pci: Constify snd_pci_quirk tables The snd_pci_quirk tables are referred as read-only, hence they can be declared as const gracefully. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-59-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 2 +- sound/pci/ctxfi/ctatc.c | 4 ++-- sound/pci/ens1370.c | 8 ++++---- sound/pci/intel8x0.c | 6 +++--- sound/pci/maestro3.c | 8 ++++---- sound/pci/nm256/nm256.c | 2 +- sound/pci/via82xx.c | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index c3281fab365d..4a840734e7a7 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -282,7 +282,7 @@ static const struct pci_device_id snd_atiixp_ids[] = { MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); -static struct snd_pci_quirk atiixp_quirks[] = { +static const struct snd_pci_quirk atiixp_quirks[] = { SND_PCI_QUIRK(0x105b, 0x0c81, "Foxconn RC4107MA-RS2", 0), SND_PCI_QUIRK(0x15bd, 0x3100, "DFI RS482", 0), { } /* terminator */ diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 8d92154ac262..e56a230f6a9c 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c @@ -35,7 +35,7 @@ | (0x10 << 16) \ | ((IEC958_AES3_CON_FS_48000) << 24)) -static struct snd_pci_quirk subsys_20k1_list[] = { +static const struct snd_pci_quirk subsys_20k1_list[] = { SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0022, "SB055x", CTSB055X), SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x002f, "SB055x", CTSB055X), SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0029, "SB073x", CTSB073X), @@ -45,7 +45,7 @@ static struct snd_pci_quirk subsys_20k1_list[] = { { } /* terminator */ }; -static struct snd_pci_quirk subsys_20k2_list[] = { +static const struct snd_pci_quirk subsys_20k2_list[] = { SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB0760, "SB0760", CTSB0760), SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB1270, diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 4f8202980b61..7ef9b7a1b2e6 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1562,7 +1562,7 @@ struct es1371_quirk { }; static int es1371_quirk_lookup(struct ensoniq *ensoniq, - struct es1371_quirk *list) + const struct es1371_quirk *list) { while (list->vid != (unsigned short)PCI_ANY_ID) { if (ensoniq->pci->vendor == list->vid && @@ -1583,7 +1583,7 @@ static struct es1371_quirk es1371_spdif_present[] = { { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } }; -static struct snd_pci_quirk ens1373_line_quirk[] = { +static const struct snd_pci_quirk ens1373_line_quirk[] = { SND_PCI_QUIRK_ID(0x1274, 0x2000), /* GA-7DXR */ SND_PCI_QUIRK_ID(0x1458, 0xa000), /* GA-8IEXP */ { } /* end */ @@ -1909,7 +1909,7 @@ static int snd_ensoniq_dev_free(struct snd_device *device) } #ifdef CHIP1371 -static struct snd_pci_quirk es1371_amplifier_hack[] = { +static const struct snd_pci_quirk es1371_amplifier_hack[] = { SND_PCI_QUIRK_ID(0x107b, 0x2150), /* Gateway Solo 2150 */ SND_PCI_QUIRK_ID(0x13bd, 0x100c), /* EV1938 on Mebius PC-MJ100V */ SND_PCI_QUIRK_ID(0x1102, 0x5938), /* Targa Xtender300 */ @@ -1917,7 +1917,7 @@ static struct snd_pci_quirk es1371_amplifier_hack[] = { { } /* end */ }; -static struct es1371_quirk es1371_ac97_reset_hack[] = { +static const struct es1371_quirk es1371_ac97_reset_hack[] = { { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index de875ea8ecbe..5bdd25815fc7 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2328,7 +2328,7 @@ static void do_ali_reset(struct intel8x0 *chip) } #ifdef CONFIG_SND_AC97_POWER_SAVE -static struct snd_pci_quirk ich_chip_reset_mode[] = { +static const struct snd_pci_quirk ich_chip_reset_mode[] = { SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1), { } /* end */ }; @@ -2774,7 +2774,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip) snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); } -static struct snd_pci_quirk intel8x0_clock_list[] = { +static const struct snd_pci_quirk intel8x0_clock_list[] = { SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000), SND_PCI_QUIRK(0x1014, 0x0581, "AD1981B", 48000), SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100), @@ -3133,7 +3133,7 @@ static struct shortname_table { { 0, NULL }, }; -static struct snd_pci_quirk spdif_aclink_defaults[] = { +static const struct snd_pci_quirk spdif_aclink_defaults[] = { SND_PCI_QUIRK(0x147b, 0x1c1a, "ASUS KN8", 1), { } /* end */ }; diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 89018d44d777..40232a278b1a 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -807,7 +807,7 @@ static const struct pci_device_id snd_m3_ids[] = { MODULE_DEVICE_TABLE(pci, snd_m3_ids); -static struct snd_pci_quirk m3_amp_quirk_list[] = { +static const struct snd_pci_quirk m3_amp_quirk_list[] = { SND_PCI_QUIRK(0x0E11, 0x0094, "Compaq Evo N600c", 0x0c), SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d), SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d), @@ -816,7 +816,7 @@ static struct snd_pci_quirk m3_amp_quirk_list[] = { { } /* END */ }; -static struct snd_pci_quirk m3_irda_quirk_list[] = { +static const struct snd_pci_quirk m3_irda_quirk_list[] = { SND_PCI_QUIRK(0x1028, 0x00b0, "Dell Inspiron 4000", 1), SND_PCI_QUIRK(0x1028, 0x00a4, "Dell Inspiron 8000", 1), SND_PCI_QUIRK(0x1028, 0x00e6, "Dell Inspiron 8100", 1), @@ -824,7 +824,7 @@ static struct snd_pci_quirk m3_irda_quirk_list[] = { }; /* hardware volume quirks */ -static struct snd_pci_quirk m3_hv_quirk_list[] = { +static const struct snd_pci_quirk m3_hv_quirk_list[] = { /* Allegro chips */ SND_PCI_QUIRK(0x0E11, 0x002E, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), SND_PCI_QUIRK(0x0E11, 0x0094, NULL, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD), @@ -902,7 +902,7 @@ static struct snd_pci_quirk m3_hv_quirk_list[] = { }; /* HP Omnibook quirks */ -static struct snd_pci_quirk m3_omnibook_quirk_list[] = { +static const struct snd_pci_quirk m3_omnibook_quirk_list[] = { SND_PCI_QUIRK_ID(0x103c, 0x0010), /* HP OmniBook 6000 */ SND_PCI_QUIRK_ID(0x103c, 0x0011), /* HP OmniBook 500 */ { } /* END */ diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 99228b93b3c6..25275a98e950 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1634,7 +1634,7 @@ __error: enum { NM_BLACKLISTED, NM_RESET_WORKAROUND, NM_RESET_WORKAROUND_2 }; -static struct snd_pci_quirk nm256_quirks[] = { +static const struct snd_pci_quirk nm256_quirks[] = { /* HP omnibook 4150 has cs4232 codec internally */ SND_PCI_QUIRK(0x103c, 0x0007, "HP omnibook 4150", NM_BLACKLISTED), /* Reset workarounds to avoid lock-ups */ diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index c8fb51885b6d..6c83ad3275f9 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2417,7 +2417,7 @@ static struct via823x_info via823x_cards[] = { * auto detection of DXS channel supports. */ -static struct snd_pci_quirk dxs_whitelist[] = { +static const struct snd_pci_quirk dxs_whitelist[] = { SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE), SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), -- cgit v1.2.3 From caf3c0437aaf2e63624c4aaf94c0dd38d1f897e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Fri, 3 Jan 2020 10:23:48 +0100 Subject: ALSA: hda - constify and cleanup static NodeID tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make hda_nid_t tables static const, as they are not intended to be modified by callees. Signed-off-by: Michał Mirosław Link: https://lore.kernel.org/r/5150c94101c9534f4c8e987324f6912c16d459f6.1578043216.git.mirq-linux@rere.qmqm.pl Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_generic.c | 4 +-- sound/pci/hda/patch_analog.c | 6 ++-- sound/pci/hda/patch_ca0132.c | 12 ++++---- sound/pci/hda/patch_conexant.c | 6 ++-- sound/pci/hda/patch_realtek.c | 62 +++++++++++++++++++++--------------------- sound/pci/hda/patch_sigmatel.c | 4 +-- sound/pci/hda/patch_via.c | 4 +-- 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 10d502328b76..fc001c64ef20 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -4401,7 +4401,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_fix_pin_power); */ /* check each pin in the given array; returns true if any of them is plugged */ -static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) +static bool detect_jacks(struct hda_codec *codec, int num_pins, const hda_nid_t *pins) { int i; bool present = false; @@ -4420,7 +4420,7 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) } /* standard HP/line-out auto-mute helper */ -static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, +static void do_automute(struct hda_codec *codec, int num_pins, const hda_nid_t *pins, int *paths, bool mute) { struct hda_gen_spec *spec = codec->spec; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index bc9dd8e6fd86..c64895f99299 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -389,7 +389,7 @@ static int patch_ad1986a(struct hda_codec *codec) { int err; struct ad198x_spec *spec; - static hda_nid_t preferred_pairs[] = { + static const hda_nid_t preferred_pairs[] = { 0x1a, 0x03, 0x1b, 0x03, 0x1c, 0x04, @@ -519,9 +519,9 @@ static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec) static int patch_ad1983(struct hda_codec *codec) { + static const hda_nid_t conn_0c[] = { 0x08 }; + static const hda_nid_t conn_0d[] = { 0x09 }; struct ad198x_spec *spec; - static hda_nid_t conn_0c[] = { 0x08 }; - static hda_nid_t conn_0d[] = { 0x09 }; int err; err = alloc_ad_spec(codec); diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 32ed46464af7..250534f90ce0 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -7802,23 +7802,23 @@ static void sbz_region2_exit(struct hda_codec *codec) static void sbz_set_pin_ctl_default(struct hda_codec *codec) { - hda_nid_t pins[5] = {0x0B, 0x0C, 0x0E, 0x12, 0x13}; + static const hda_nid_t pins[] = {0x0B, 0x0C, 0x0E, 0x12, 0x13}; unsigned int i; snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40); - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_SIZE(pins); i++) snd_hda_codec_write(codec, pins[i], 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00); } static void ca0132_clear_unsolicited(struct hda_codec *codec) { - hda_nid_t pins[7] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}; + static const hda_nid_t pins[] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13}; unsigned int i; - for (i = 0; i < 7; i++) { + for (i = 0; i < ARRAY_SIZE(pins); i++) { snd_hda_codec_write(codec, pins[i], 0, AC_VERB_SET_UNSOLICITED_ENABLE, 0x00); } @@ -7842,10 +7842,10 @@ static void sbz_gpio_shutdown_commands(struct hda_codec *codec, int dir, static void zxr_dbpro_power_state_shutdown(struct hda_codec *codec) { - hda_nid_t pins[7] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01}; + static const hda_nid_t pins[] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01}; unsigned int i; - for (i = 0; i < 7; i++) + for (i = 0; i < ARRAY_SIZE(pins); i++) snd_hda_codec_write(codec, pins[i], 0, AC_VERB_SET_POWER_STATE, 0x03); } diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 90aa0f400a57..9853e00a0816 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -116,7 +116,7 @@ static void cx_auto_parse_eapd(struct hda_codec *codec) } static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins, - hda_nid_t *pins, bool on) + const hda_nid_t *pins, bool on) { int i; for (i = 0; i < num_pins; i++) { @@ -959,10 +959,10 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = { static void add_cx5051_fake_mutes(struct hda_codec *codec) { struct conexant_spec *spec = codec->spec; - static hda_nid_t out_nids[] = { + static const hda_nid_t out_nids[] = { 0x10, 0x11, 0 }; - hda_nid_t *p; + const hda_nid_t *p; for (p = out_nids; *p; p++) snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT, diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index dbfafee97931..5bb1959dae0f 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -464,10 +464,10 @@ static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) { /* We currently only handle front, HP */ - static hda_nid_t pins[] = { + static const hda_nid_t pins[] = { 0x0f, 0x10, 0x14, 0x15, 0x17, 0 }; - hda_nid_t *p; + const hda_nid_t *p; for (p = pins; *p; p++) set_eapd(codec, *p, on); } @@ -1935,19 +1935,19 @@ static void alc889_fixup_dac_route(struct hda_codec *codec, { if (action == HDA_FIXUP_ACT_PRE_PROBE) { /* fake the connections during parsing the tree */ - hda_nid_t conn1[2] = { 0x0c, 0x0d }; - hda_nid_t conn2[2] = { 0x0e, 0x0f }; - snd_hda_override_conn_list(codec, 0x14, 2, conn1); - snd_hda_override_conn_list(codec, 0x15, 2, conn1); - snd_hda_override_conn_list(codec, 0x18, 2, conn2); - snd_hda_override_conn_list(codec, 0x1a, 2, conn2); + static const hda_nid_t conn1[] = { 0x0c, 0x0d }; + static const hda_nid_t conn2[] = { 0x0e, 0x0f }; + snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); + snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1); + snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2); + snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2); } else if (action == HDA_FIXUP_ACT_PROBE) { /* restore the connections */ - hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; - snd_hda_override_conn_list(codec, 0x14, 5, conn); - snd_hda_override_conn_list(codec, 0x15, 5, conn); - snd_hda_override_conn_list(codec, 0x18, 5, conn); - snd_hda_override_conn_list(codec, 0x1a, 5, conn); + static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; + snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn); + snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn); + snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn); + snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn); } } @@ -1955,8 +1955,8 @@ static void alc889_fixup_dac_route(struct hda_codec *codec, static void alc889_fixup_mbp_vref(struct hda_codec *codec, const struct hda_fixup *fix, int action) { + static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 }; struct alc_spec *spec = codec->spec; - static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 }; int i; if (action != HDA_FIXUP_ACT_INIT) @@ -1992,7 +1992,7 @@ static void alc889_fixup_mac_pins(struct hda_codec *codec, static void alc889_fixup_imac91_vref(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - static hda_nid_t nids[2] = { 0x18, 0x1a }; + static const hda_nid_t nids[] = { 0x18, 0x1a }; if (action == HDA_FIXUP_ACT_INIT) alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); @@ -2002,7 +2002,7 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec, static void alc889_fixup_mba11_vref(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - static hda_nid_t nids[1] = { 0x18 }; + static const hda_nid_t nids[] = { 0x18 }; if (action == HDA_FIXUP_ACT_INIT) alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); @@ -2012,7 +2012,7 @@ static void alc889_fixup_mba11_vref(struct hda_codec *codec, static void alc889_fixup_mba21_vref(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - static hda_nid_t nids[2] = { 0x18, 0x19 }; + static const hda_nid_t nids[] = { 0x18, 0x19 }; if (action == HDA_FIXUP_ACT_INIT) alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); @@ -2094,7 +2094,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec, const struct hda_fixup *fix, int action) { - hda_nid_t conn1[1] = { 0x0c }; + static const hda_nid_t conn1[] = { 0x0c }; if (action != HDA_FIXUP_ACT_PRE_PROBE) return; @@ -2103,8 +2103,8 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec, /* We therefore want to make sure 0x14 (front headphone) and * 0x1b (speakers) use the stereo DAC 0x02 */ - snd_hda_override_conn_list(codec, 0x14, 1, conn1); - snd_hda_override_conn_list(codec, 0x1b, 1, conn1); + snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); + snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1); } static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, @@ -5243,7 +5243,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec, * the speaker output becomes too low by some reason on Thinkpads with * ALC298 codec */ - static hda_nid_t preferred_pairs[] = { + static const hda_nid_t preferred_pairs[] = { 0x14, 0x03, 0x17, 0x02, 0x21, 0x02, 0 }; @@ -5515,9 +5515,9 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec, /* DAC node 0x03 is giving mono output. We therefore want to make sure 0x14 (front speaker) and 0x15 (headphones) use the stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */ - hda_nid_t conn1[2] = { 0x0c }; - snd_hda_override_conn_list(codec, 0x14, 1, conn1); - snd_hda_override_conn_list(codec, 0x15, 1, conn1); + static const hda_nid_t conn1[] = { 0x0c }; + snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1); + snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1); } } @@ -5532,8 +5532,8 @@ static void alc298_fixup_speaker_volume(struct hda_codec *codec, Pin Complex), since Node 0x02 has Amp-out caps, we can adjust speaker's volume now. */ - hda_nid_t conn1[1] = { 0x0c }; - snd_hda_override_conn_list(codec, 0x17, 1, conn1); + static const hda_nid_t conn1[] = { 0x0c }; + snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1); } } @@ -5542,8 +5542,8 @@ static void alc295_fixup_disable_dac3(struct hda_codec *codec, const struct hda_fixup *fix, int action) { if (action == HDA_FIXUP_ACT_PRE_PROBE) { - hda_nid_t conn[2] = { 0x02, 0x03 }; - snd_hda_override_conn_list(codec, 0x17, 2, conn); + static const hda_nid_t conn[] = { 0x02, 0x03 }; + snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); } } @@ -5552,8 +5552,8 @@ static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec, const struct hda_fixup *fix, int action) { if (action == HDA_FIXUP_ACT_PRE_PROBE) { - hda_nid_t conn[1] = { 0x02 }; - snd_hda_override_conn_list(codec, 0x17, 1, conn); + static const hda_nid_t conn[] = { 0x02 }; + snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn); } } @@ -5631,7 +5631,7 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec, const struct hda_fixup *fix, int action) { struct alc_spec *spec = codec->spec; - static hda_nid_t preferred_pairs[] = { + static const hda_nid_t preferred_pairs[] = { 0x21, 0x03, 0x1b, 0x03, 0x16, 0x02, 0 }; diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 9b816b377547..a608d0486ae4 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -795,7 +795,7 @@ static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity) static bool has_builtin_speaker(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; - hda_nid_t *nid_pin; + const hda_nid_t *nid_pin; int nids, i; if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) { @@ -2182,7 +2182,7 @@ static void hp_envy_ts_fixup_dac_bind(struct hda_codec *codec, int action) { struct sigmatel_spec *spec = codec->spec; - static hda_nid_t preferred_pairs[] = { + static const hda_nid_t preferred_pairs[] = { 0xd, 0x13, 0 }; diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 29dcdb8b36db..b40d01e01832 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1038,8 +1038,8 @@ static const struct snd_pci_quirk vt2002p_fixups[] = { */ static void fix_vt1802_connections(struct hda_codec *codec) { - static hda_nid_t conn_24[] = { 0x14, 0x1c }; - static hda_nid_t conn_33[] = { 0x1c }; + static const hda_nid_t conn_24[] = { 0x14, 0x1c }; + static const hda_nid_t conn_33[] = { 0x1c }; snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24); snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33); -- cgit v1.2.3 From fbd3eb7f66c5b4f37a959bc2deaeb1d7b5ddf0d4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sat, 4 Jan 2020 09:35:56 +0100 Subject: ALSA: control: Add verification for kctl accesses The current implementation of ALSA control API fully relies on the callbacks of each driver, and there is no verification of the values passed via API. This patch is an attempt to improve the situation slightly by adding the validation code for the values stored via info and get callbacks. The patch adds a new kconfig, CONFIG_SND_CTL_VALIDATION. It depends on CONFIG_SND_DEBUG and off as default since the validation would require a slight overhead including the additional call of info callback at each get callback invocation. When this config is enabled, the values stored by each info callback invocation are verified, namely: - Whether the info type is valid - Whether the number of enum items is non-zero - Whether the given info count is within the allowed boundary Similarly, the values stored at each get callback are verified as well: - Whether the values are within the given range - Whether the values are aligned with the given step - Whether any further changes are seen in the data array over the given info count The last point helps identifying a possibly invalid data type access, typically a case where the info callback declares the type being SNDRV_CTL_ELEM_TYPE_ENUMERATED while the get/put callbacks store the values in value.integer.value[] array. When a validation fails, the ALSA core logs an error message including the device and the control ID, and the API call also returns an error. So, with the new validation turned on, the driver behavior difference may be visible on user-space, too -- it's intentional, though, so that we can catch an error more clearly. The patch also introduces a new ctl access type, SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK. A driver may pass this flag with other access bits to indicate that the ctl element won't be verified. It's useful when a driver code is specially written to access the data greater than info->count size by some reason. For example, this flag is actually set now in HD-audio HDMI codec driver which needs to clear the data array in the case of the disconnected monitor. Also, the PCM channel-map helper code is slightly modified to avoid the false-positive hit by this validation code, too. Link: https://lore.kernel.org/r/20200104083556.27789-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/control.h | 10 ++ sound/core/Kconfig | 9 ++ sound/core/control.c | 283 +++++++++++++++++++++++++++++++++++++++------ sound/core/pcm_lib.c | 2 +- sound/pci/hda/patch_hdmi.c | 3 +- 5 files changed, 268 insertions(+), 39 deletions(-) diff --git a/include/sound/control.h b/include/sound/control.h index 5d7c99475684..11feeee31e35 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -22,6 +22,16 @@ typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol, unsigned int size, unsigned int __user *tlv); +/* internal flag for skipping validations */ +#ifdef CONFIG_SND_CTL_VALIDATION +#define SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK (1 << 27) +#define snd_ctl_skip_validation(info) \ + ((info)->access & SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK) +#else +#define SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK 0 +#define snd_ctl_skip_validation(info) true +#endif + enum { SNDRV_CTL_TLV_OP_READ = 0, SNDRV_CTL_TLV_OP_WRITE = 1, diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 4044c42d8595..d4554f376160 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -178,6 +178,15 @@ config SND_PCM_XRUN_DEBUG sound clicking when system is loaded, it may help to determine the process or driver which causes the scheduling gaps. +config SND_CTL_VALIDATION + bool "Perform sanity-checks for each control element access" + depends on SND_DEBUG + help + Say Y to enable the additional validation of each control element + access, including sanity-checks like whether the values returned + from the driver are in the proper ranges or the check of the invalid + access at out-of-array areas. + config SND_VMASTER bool diff --git a/sound/core/control.c b/sound/core/control.c index 63bb2fcf13be..d06033d418a8 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -248,7 +249,8 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, SNDRV_CTL_ELEM_ACCESS_INACTIVE | SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND | - SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK); + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK | + SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK); err = snd_ctl_new(&kctl, count, access, NULL); if (err < 0) @@ -758,21 +760,199 @@ static int snd_ctl_elem_list(struct snd_card *card, return err; } -static int snd_ctl_elem_info(struct snd_ctl_file *ctl, - struct snd_ctl_elem_info *info) +/* Check whether the given kctl info is valid */ +static int snd_ctl_check_elem_info(struct snd_card *card, + const struct snd_ctl_elem_info *info) +{ + static const unsigned int max_value_counts[] = { + [SNDRV_CTL_ELEM_TYPE_BOOLEAN] = 128, + [SNDRV_CTL_ELEM_TYPE_INTEGER] = 128, + [SNDRV_CTL_ELEM_TYPE_ENUMERATED] = 128, + [SNDRV_CTL_ELEM_TYPE_BYTES] = 512, + [SNDRV_CTL_ELEM_TYPE_IEC958] = 1, + [SNDRV_CTL_ELEM_TYPE_INTEGER64] = 64, + }; + + if (info->type < SNDRV_CTL_ELEM_TYPE_BOOLEAN || + info->type > SNDRV_CTL_ELEM_TYPE_INTEGER64) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: invalid type %d\n", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index, info->type); + return -EINVAL; + } + if (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED && + info->value.enumerated.items == 0) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: zero enum items\n", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index); + return -EINVAL; + } + if (info->count > max_value_counts[info->type]) { + if (card) + dev_err(card->dev, + "control %i:%i:%i:%s:%i: invalid count %d\n", + info->id.iface, info->id.device, + info->id.subdevice, info->id.name, + info->id.index, info->count); + return -EINVAL; + } + + return 0; +} + +/* The capacity of struct snd_ctl_elem_value.value.*/ +static const unsigned int value_sizes[] = { + [SNDRV_CTL_ELEM_TYPE_BOOLEAN] = sizeof(long), + [SNDRV_CTL_ELEM_TYPE_INTEGER] = sizeof(long), + [SNDRV_CTL_ELEM_TYPE_ENUMERATED] = sizeof(unsigned int), + [SNDRV_CTL_ELEM_TYPE_BYTES] = sizeof(unsigned char), + [SNDRV_CTL_ELEM_TYPE_IEC958] = sizeof(struct snd_aes_iec958), + [SNDRV_CTL_ELEM_TYPE_INTEGER64] = sizeof(long long), +}; + +#ifdef CONFIG_SND_CTL_VALIDATION +/* fill the remaining snd_ctl_elem_value data with the given pattern */ +static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ + size_t offset = value_sizes[info->type] * info->count; + + offset = (offset + sizeof(u32) - 1) / sizeof(u32); + memset32((u32 *)control->value.bytes.data + offset, pattern, + sizeof(control->value) / sizeof(u32) - offset); +} + +/* check whether the given integer ctl value is valid */ +static int sanity_check_int_value(struct snd_card *card, + const struct snd_ctl_elem_value *control, + const struct snd_ctl_elem_info *info, + int i) +{ + long long lval, lmin, lmax, lstep; + u64 rem; + + switch (info->type) { + default: + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: + lval = control->value.integer.value[i]; + lmin = 0; + lmax = 1; + lstep = 0; + break; + case SNDRV_CTL_ELEM_TYPE_INTEGER: + lval = control->value.integer.value[i]; + lmin = info->value.integer.min; + lmax = info->value.integer.max; + lstep = info->value.integer.step; + break; + case SNDRV_CTL_ELEM_TYPE_INTEGER64: + lval = control->value.integer64.value[i]; + lmin = info->value.integer64.min; + lmax = info->value.integer64.max; + lstep = info->value.integer64.step; + break; + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: + lval = control->value.enumerated.item[i]; + lmin = 0; + lmax = info->value.enumerated.items - 1; + lstep = 0; + break; + } + + if (lval < lmin || lval > lmax) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: value out of range %lld (%lld/%lld) at count %i\n", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index, lval, lmin, lmax, i); + return -EINVAL; + } + if (lstep) { + div64_u64_rem(lval, lstep, &rem); + if (rem) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: unaligned value %lld (step %lld) at count %i\n", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index, lval, lstep, i); + return -EINVAL; + } + } + + return 0; +} + +/* perform sanity checks to the given snd_ctl_elem_value object */ +static int sanity_check_elem_value(struct snd_card *card, + const struct snd_ctl_elem_value *control, + const struct snd_ctl_elem_info *info, + u32 pattern) +{ + size_t offset; + int i, ret; + u32 *p; + + switch (info->type) { + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: + case SNDRV_CTL_ELEM_TYPE_INTEGER: + case SNDRV_CTL_ELEM_TYPE_INTEGER64: + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: + for (i = 0; i < info->count; i++) { + ret = sanity_check_int_value(card, control, info, i); + if (ret < 0) + return ret; + } + break; + default: + break; + } + + /* check whether the remaining area kept untouched */ + offset = value_sizes[info->type] * info->count; + offset = (offset + sizeof(u32) - 1) / sizeof(u32); + p = (u32 *)control->value.bytes.data + offset; + for (; offset < sizeof(control->value) / sizeof(u32); offset++, p++) { + if (*p != pattern) { + ret = -EINVAL; + break; + } + *p = 0; /* clear the checked area */ + } + + return ret; +} +#else +static inline void fill_remaining_elem_value(struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ +} + +static inline int sanity_check_elem_value(struct snd_card *card, + struct snd_ctl_elem_value *control, + struct snd_ctl_elem_info *info, + u32 pattern) +{ + return 0; +} +#endif + +static int __snd_ctl_elem_info(struct snd_card *card, + struct snd_kcontrol *kctl, + struct snd_ctl_elem_info *info, + struct snd_ctl_file *ctl) { - struct snd_card *card = ctl->card; - struct snd_kcontrol *kctl; struct snd_kcontrol_volatile *vd; unsigned int index_offset; int result; - down_read(&card->controls_rwsem); - kctl = snd_ctl_find_id(card, &info->id); - if (kctl == NULL) { - up_read(&card->controls_rwsem); - return -ENOENT; - } #ifdef CONFIG_SND_DEBUG info->access = 0; #endif @@ -791,7 +971,26 @@ static int snd_ctl_elem_info(struct snd_ctl_file *ctl, } else { info->owner = -1; } + if (!snd_ctl_skip_validation(info) && + snd_ctl_check_elem_info(card, info) < 0) + result = -EINVAL; } + return result; +} + +static int snd_ctl_elem_info(struct snd_ctl_file *ctl, + struct snd_ctl_elem_info *info) +{ + struct snd_card *card = ctl->card; + struct snd_kcontrol *kctl; + int result; + + down_read(&card->controls_rwsem); + kctl = snd_ctl_find_id(card, &info->id); + if (kctl == NULL) + result = -ENOENT; + else + result = __snd_ctl_elem_info(card, kctl, info, ctl); up_read(&card->controls_rwsem); return result; } @@ -810,6 +1009,8 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl, result = snd_ctl_elem_info(ctl, &info); if (result < 0) return result; + /* drop internal access flags */ + info.access &= ~SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK; if (copy_to_user(_info, &info, sizeof(info))) return -EFAULT; return result; @@ -821,6 +1022,9 @@ static int snd_ctl_elem_read(struct snd_card *card, struct snd_kcontrol *kctl; struct snd_kcontrol_volatile *vd; unsigned int index_offset; + struct snd_ctl_elem_info info; + const u32 pattern = 0xdeadbeef; + int ret; kctl = snd_ctl_find_id(card, &control->id); if (kctl == NULL) @@ -832,7 +1036,31 @@ static int snd_ctl_elem_read(struct snd_card *card, return -EPERM; snd_ctl_build_ioff(&control->id, kctl, index_offset); - return kctl->get(kctl, control); + +#ifdef CONFIG_SND_CTL_VALIDATION + /* info is needed only for validation */ + memset(&info, 0, sizeof(info)); + info.id = control->id; + ret = __snd_ctl_elem_info(card, kctl, &info, NULL); + if (ret < 0) + return ret; +#endif + + if (!snd_ctl_skip_validation(&info)) + fill_remaining_elem_value(control, &info, pattern); + ret = kctl->get(kctl, control); + if (ret < 0) + return ret; + if (!snd_ctl_skip_validation(&info) && + sanity_check_elem_value(card, control, &info, pattern) < 0) { + dev_err(card->dev, + "control %i:%i:%i:%s:%i: access overflow\n", + control->id.iface, control->id.device, + control->id.subdevice, control->id.name, + control->id.index); + return -EINVAL; + } + return ret; } static int snd_ctl_elem_read_user(struct snd_card *card, @@ -1173,23 +1401,6 @@ static void snd_ctl_elem_user_free(struct snd_kcontrol *kcontrol) static int snd_ctl_elem_add(struct snd_ctl_file *file, struct snd_ctl_elem_info *info, int replace) { - /* The capacity of struct snd_ctl_elem_value.value.*/ - static const unsigned int value_sizes[] = { - [SNDRV_CTL_ELEM_TYPE_BOOLEAN] = sizeof(long), - [SNDRV_CTL_ELEM_TYPE_INTEGER] = sizeof(long), - [SNDRV_CTL_ELEM_TYPE_ENUMERATED] = sizeof(unsigned int), - [SNDRV_CTL_ELEM_TYPE_BYTES] = sizeof(unsigned char), - [SNDRV_CTL_ELEM_TYPE_IEC958] = sizeof(struct snd_aes_iec958), - [SNDRV_CTL_ELEM_TYPE_INTEGER64] = sizeof(long long), - }; - static const unsigned int max_value_counts[] = { - [SNDRV_CTL_ELEM_TYPE_BOOLEAN] = 128, - [SNDRV_CTL_ELEM_TYPE_INTEGER] = 128, - [SNDRV_CTL_ELEM_TYPE_ENUMERATED] = 128, - [SNDRV_CTL_ELEM_TYPE_BYTES] = 512, - [SNDRV_CTL_ELEM_TYPE_IEC958] = 1, - [SNDRV_CTL_ELEM_TYPE_INTEGER64] = 64, - }; struct snd_card *card = file->card; struct snd_kcontrol *kctl; unsigned int count; @@ -1241,14 +1452,12 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, * Check information and calculate the size of data specific to * this userspace control. */ - if (info->type < SNDRV_CTL_ELEM_TYPE_BOOLEAN || - info->type > SNDRV_CTL_ELEM_TYPE_INTEGER64) - return -EINVAL; - if (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED && - info->value.enumerated.items == 0) - return -EINVAL; - if (info->count < 1 || - info->count > max_value_counts[info->type]) + /* pass NULL to card for suppressing error messages */ + err = snd_ctl_check_elem_info(NULL, info); + if (err < 0) + return err; + /* user-space control doesn't allow zero-size data */ + if (info->count < 1) return -EINVAL; private_size = value_sizes[info->type] * info->count; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index ce3a36cb58da..18f498ab7af1 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2341,7 +2341,7 @@ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, if (!substream) return -ENODEV; memset(ucontrol->value.integer.value, 0, - sizeof(ucontrol->value.integer.value)); + sizeof(long) * info->max_channels); if (!substream->runtime) return 0; /* no channels set */ for (map = info->chmap; map->channels; map++) { diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 630b1f5c276d..3beb842817ff 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -372,7 +372,8 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, } static const struct snd_kcontrol_new eld_bytes_ctl = { - .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, + .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE | + SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK, .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "ELD", .info = hdmi_eld_ctl_info, -- cgit v1.2.3 From 5da116f164ce265e397b8f59af5c39e4a61d61a5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sat, 4 Jan 2020 12:00:57 +0100 Subject: ALSA: sh: Fix unused variable warnings Remove unused variables that are left over after the conversion of new PCM ops: sound/sh/sh_dac_audio.c:166:26: warning: unused variable 'runtime' sound/sh/sh_dac_audio.c:186:26: warning: unused variable 'runtime' sound/sh/sh_dac_audio.c:205:26: warning: unused variable 'runtime' Fixes: 1cc2f8ba0b3e ("ALSA: sh: Convert to the new PCM ops") Link: https://lore.kernel.org/r/20200104110057.13875-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/sh_dac_audio.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index 4affdc128119..feb28502940f 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -163,7 +163,6 @@ static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - struct snd_pcm_runtime *runtime = substream->runtime; if (copy_from_user_toio(chip->data_buffer + pos, src, count)) return -EFAULT; @@ -183,7 +182,6 @@ static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream, { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - struct snd_pcm_runtime *runtime = substream->runtime; memcpy_toio(chip->data_buffer + pos, src, count); chip->buffer_end = chip->data_buffer + pos + count; @@ -202,7 +200,6 @@ static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream, { /* channel is not used (interleaved data) */ struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - struct snd_pcm_runtime *runtime = substream->runtime; memset_io(chip->data_buffer + pos, 0, count); chip->buffer_end = chip->data_buffer + pos + count; -- cgit v1.2.3 From 5fab5829674c279839a7408ab30c71c6dfe726b9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 09:11:19 +0100 Subject: ALSA: hda/realtek - Apply mic mute LED quirk for Dell E7xx laptops, too Dell E7xx laptops have also mic mute LED that is driven by the dell-laptop platform driver. Bind it with the capture control as already done for other models. A caveat is that the fixup hook for the mic mute LED has to be applied at last, otherwise it results in the invalid override of the callback. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205529 Link: https://lore.kernel.org/r/20200105081119.21396-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 5bb1959dae0f..7fb3d6868f7c 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5844,6 +5844,7 @@ enum { ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, ALC288_FIXUP_DELL_XPS_13, ALC288_FIXUP_DISABLE_AAMIX, + ALC292_FIXUP_DELL_E7X_AAMIX, ALC292_FIXUP_DELL_E7X, ALC292_FIXUP_DISABLE_AAMIX, ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, @@ -6536,12 +6537,19 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE }, - [ALC292_FIXUP_DELL_E7X] = { + [ALC292_FIXUP_DELL_E7X_AAMIX] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_dell_xps13, .chained = true, .chain_id = ALC292_FIXUP_DISABLE_AAMIX }, + [ALC292_FIXUP_DELL_E7X] = { + .type = HDA_FIXUP_FUNC, + .v.func = snd_hda_gen_fixup_micmute_led, + /* micmute fixup must be applied at last */ + .chained_before = true, + .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX, + }, [ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) { -- cgit v1.2.3 From 8be03a7177c36bfc05bbe9f4949cdeba57f1c2ab Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 09:19:00 +0100 Subject: ALSA: usb-audio: Use lower hex numbers for IDs For consistency reason, make all hex numbers with lower alphabets for USB ID entries. It improves grep-ability and reduces careless mistakes. Link: https://lore.kernel.org/r/20200105081900.21870-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/format.c | 8 ++++---- sound/usb/midi.c | 4 ++-- sound/usb/quirks.c | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sound/usb/format.c b/sound/usb/format.c index d79db71305f6..5e7c4c7beff2 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -292,10 +292,10 @@ static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip, struct audioformat *fp) { switch (chip->usb_id) { - case USB_ID(0x0E41, 0x4241): /* Line6 Helix */ - case USB_ID(0x0E41, 0x4242): /* Line6 Helix Rack */ - case USB_ID(0x0E41, 0x4244): /* Line6 Helix LT */ - case USB_ID(0x0E41, 0x4246): /* Line6 HX-Stomp */ + case USB_ID(0x0e41, 0x4241): /* Line6 Helix */ + case USB_ID(0x0e41, 0x4242): /* Line6 Helix Rack */ + case USB_ID(0x0e41, 0x4244): /* Line6 Helix LT */ + case USB_ID(0x0e41, 0x4246): /* Line6 HX-Stomp */ /* supported rates: 48Khz */ kfree(fp->rate_table); fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); diff --git a/sound/usb/midi.c b/sound/usb/midi.c index b737f0ec77d0..392e5fda680c 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -1408,8 +1408,8 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi, /* * Some devices only work with 9 bytes packet size: */ - case USB_ID(0x0644, 0x800E): /* Tascam US-122L */ - case USB_ID(0x0644, 0x800F): /* Tascam US-144 */ + case USB_ID(0x0644, 0x800e): /* Tascam US-122L */ + case USB_ID(0x0644, 0x800f): /* Tascam US-144 */ ep->max_transfer = 9; break; } diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 82184036437b..11159fcfdcdf 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1393,22 +1393,22 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) { /* devices which do not support reading the sample rate. */ switch (chip->usb_id) { - case USB_ID(0x041E, 0x4080): /* Creative Live Cam VF0610 */ - case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ + case USB_ID(0x041e, 0x4080): /* Creative Live Cam VF0610 */ + case USB_ID(0x04d8, 0xfeea): /* Benchmark DAC1 Pre */ case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ - case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ + case USB_ID(0x05a3, 0x9420): /* ELP HD USB Camera */ case USB_ID(0x05a7, 0x1020): /* Bose Companion 5 */ - case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ + case USB_ID(0x074d, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ - case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ + case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ return true; } /* devices of these vendors don't support reading rate, either */ switch (USB_ID_VENDOR(chip->usb_id)) { - case 0x045E: /* MS Lifecam */ - case 0x047F: /* Plantronics */ + case 0x045e: /* MS Lifecam */ + case 0x047f: /* Plantronics */ case 0x1de7: /* Phoenix Audio */ return true; } -- cgit v1.2.3 From f5f87abfb745aa6eb5c5f9bdf8b5a64600692506 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:16 +0100 Subject: ALSA: Allow const arrays for legacy resource management helpers Declare the arrays passed to the helper functions for legacy resources (mostly for ISA drivers) as const, so that each caller can make its static data as const for minor optimizations, too. Link: https://lore.kernel.org/r/20200105144823.29547-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/initval.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sound/initval.h b/include/sound/initval.h index 3ddae2b4177e..a1ff3b4865b4 100644 --- a/include/sound/initval.h +++ b/include/sound/initval.h @@ -37,7 +37,7 @@ #define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR #ifdef SNDRV_LEGACY_FIND_FREE_IOPORT -static long snd_legacy_find_free_ioport(long *port_table, long size) +static long snd_legacy_find_free_ioport(const long *port_table, long size) { while (*port_table != -1) { if (request_region(*port_table, size, "ALSA test")) { @@ -58,7 +58,7 @@ static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static int snd_legacy_find_free_irq(int *irq_table) +static int snd_legacy_find_free_irq(const int *irq_table) { while (*irq_table != -1) { if (!request_irq(*irq_table, snd_legacy_empty_irq_handler, @@ -74,7 +74,7 @@ static int snd_legacy_find_free_irq(int *irq_table) #endif #ifdef SNDRV_LEGACY_FIND_FREE_DMA -static int snd_legacy_find_free_dma(int *dma_table) +static int snd_legacy_find_free_dma(const int *dma_table) { while (*dma_table != -1) { if (!request_dma(*dma_table, "ALSA Test DMA")) { -- cgit v1.2.3 From fa35aa46077794de446ddd4bcaf809c2fd041ce2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:17 +0100 Subject: ALSA: aoa: More constifications Apply const prefix at every place where appropriate: the static register tables, the volume tables and the callback tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-3-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/aoa/codecs/onyx.c | 4 ++-- sound/aoa/codecs/tas-basstreble.h | 4 ++-- sound/aoa/codecs/tas-gain-table.h | 2 +- sound/aoa/soundbus/i2sbus/core.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c index f85bc8a1e2a6..12028b3e2eee 100644 --- a/sound/aoa/codecs/onyx.c +++ b/sound/aoa/codecs/onyx.c @@ -543,7 +543,7 @@ static const struct snd_kcontrol_new onyx_spdif_ctrl = { /* our registers */ -static u8 register_map[] = { +static const u8 register_map[] = { ONYX_REG_DAC_ATTEN_LEFT, ONYX_REG_DAC_ATTEN_RIGHT, ONYX_REG_CONTROL, @@ -559,7 +559,7 @@ static u8 register_map[] = { ONYX_REG_DIG_INFO4 }; -static u8 initial_values[ARRAY_SIZE(register_map)] = { +static const u8 initial_values[ARRAY_SIZE(register_map)] = { 0x80, 0x80, /* muted */ ONYX_MRST | ONYX_SRST, /* but handled specially! */ ONYX_MUTE_LEFT | ONYX_MUTE_RIGHT, diff --git a/sound/aoa/codecs/tas-basstreble.h b/sound/aoa/codecs/tas-basstreble.h index 770935af66af..14dc4e9eea73 100644 --- a/sound/aoa/codecs/tas-basstreble.h +++ b/sound/aoa/codecs/tas-basstreble.h @@ -13,7 +13,7 @@ #define TAS3004_TREBLE_ZERO 36 #define TAS3004_BASS_ZERO 36 -static u8 tas3004_treble_table[] = { +static const u8 tas3004_treble_table[] = { 150, /* -18 dB */ 149, 148, @@ -99,7 +99,7 @@ static inline u8 tas3004_treble(int idx) * I have also ignored completely differences of * +/- 1 */ -static s8 tas3004_bass_diff_to_treble[] = { +static const s8 tas3004_bass_diff_to_treble[] = { 2, /* 7 dB, offset 50 */ 2, 2, diff --git a/sound/aoa/codecs/tas-gain-table.h b/sound/aoa/codecs/tas-gain-table.h index 77b8e7dc55fd..c9ea01488181 100644 --- a/sound/aoa/codecs/tas-gain-table.h +++ b/sound/aoa/codecs/tas-gain-table.h @@ -27,7 +27,7 @@ int main() { * as easy as calculating * hwvalue = 1048576.0*exp(0.057564628*dB*2) * :) */ -static int tas_gaintable[] = { +static const int tas_gaintable[] = { 0x000000, /* -infinity dB */ 0x00014b, /* -70.0 dB */ 0x00015f, /* -69.5 dB */ diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 17df288fbe98..faf6b03131ee 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c @@ -160,7 +160,7 @@ static int i2sbus_add_dev(struct macio_dev *macio, static const char *rnames[] = { "i2sbus: %pOFn (control)", "i2sbus: %pOFn (tx)", "i2sbus: %pOFn (rx)" }; - static irq_handler_t ints[] = { + static const irq_handler_t ints[] = { i2sbus_bus_intr, i2sbus_tx_intr, i2sbus_rx_intr -- cgit v1.2.3 From 6b0f95c49d890440c01a759c767dfe40e2acdbf2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:18 +0100 Subject: ALSA: hda/realtek - More constifications Apply const prefix to each coef table array. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-4-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 118 +++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 76b603544f2a..73407b25a777 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -948,7 +948,7 @@ struct alc_codec_rename_pci_table { const char *name; }; -static struct alc_codec_rename_table rename_tbl[] = { +static const struct alc_codec_rename_table rename_tbl[] = { { 0x10ec0221, 0xf00f, 0x1003, "ALC231" }, { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, @@ -969,7 +969,7 @@ static struct alc_codec_rename_table rename_tbl[] = { { } /* terminator */ }; -static struct alc_codec_rename_pci_table rename_pci_tbl[] = { +static const struct alc_codec_rename_pci_table rename_pci_tbl[] = { { 0x10ec0280, 0x1028, 0, "ALC3220" }, { 0x10ec0282, 0x1028, 0, "ALC3221" }, { 0x10ec0283, 0x1028, 0, "ALC3223" }, @@ -2995,7 +2995,7 @@ static void alc269_shutup(struct hda_codec *codec) alc_shutup_pins(codec); } -static struct coef_fw alc282_coefs[] = { +static const struct coef_fw alc282_coefs[] = { WRITE_COEF(0x03, 0x0002), /* Power Down Control */ UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */ WRITE_COEF(0x07, 0x0200), /* DMIC control */ @@ -3107,7 +3107,7 @@ static void alc282_shutup(struct hda_codec *codec) alc_write_coef_idx(codec, 0x78, coef78); } -static struct coef_fw alc283_coefs[] = { +static const struct coef_fw alc283_coefs[] = { WRITE_COEF(0x03, 0x0002), /* Power Down Control */ UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */ WRITE_COEF(0x07, 0x0200), /* DMIC control */ @@ -4183,7 +4183,7 @@ static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, } } -static struct coef_fw alc225_pre_hsmode[] = { +static const struct coef_fw alc225_pre_hsmode[] = { UPDATE_COEF(0x4a, 1<<8, 0), UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), UPDATE_COEF(0x63, 3<<14, 3<<14), @@ -4196,7 +4196,7 @@ static struct coef_fw alc225_pre_hsmode[] = { static void alc_headset_mode_unplugged(struct hda_codec *codec) { - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */ WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */ UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/ @@ -4204,7 +4204,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */ {} }; - static struct coef_fw coef0256[] = { + static const struct coef_fw coef0256[] = { WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */ WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */ WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */ @@ -4212,7 +4212,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/ {} }; - static struct coef_fw coef0233[] = { + static const struct coef_fw coef0233[] = { WRITE_COEF(0x1b, 0x0c0b), WRITE_COEF(0x45, 0xc429), UPDATE_COEF(0x35, 0x4000, 0), @@ -4222,7 +4222,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) WRITE_COEF(0x32, 0x42a3), {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x4f, 0xfcc0, 0xc400), UPDATE_COEF(0x50, 0x2000, 0x2000), UPDATE_COEF(0x56, 0x0006, 0x0006), @@ -4230,18 +4230,18 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) UPDATE_COEF(0x67, 0x2000, 0), {} }; - static struct coef_fw coef0298[] = { + static const struct coef_fw coef0298[] = { UPDATE_COEF(0x19, 0x1300, 0x0300), {} }; - static struct coef_fw coef0292[] = { + static const struct coef_fw coef0292[] = { WRITE_COEF(0x76, 0x000e), WRITE_COEF(0x6c, 0x2400), WRITE_COEF(0x18, 0x7308), WRITE_COEF(0x6b, 0xc429), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */ UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */ UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */ @@ -4250,16 +4250,16 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */ {} }; - static struct coef_fw coef0668[] = { + static const struct coef_fw coef0668[] = { WRITE_COEF(0x15, 0x0d40), WRITE_COEF(0xb7, 0x802b), {} }; - static struct coef_fw coef0225[] = { + static const struct coef_fw coef0225[] = { UPDATE_COEF(0x63, 3<<14, 0), {} }; - static struct coef_fw coef0274[] = { + static const struct coef_fw coef0274[] = { UPDATE_COEF(0x4a, 0x0100, 0), UPDATE_COEFEX(0x57, 0x05, 0x4000, 0), UPDATE_COEF(0x6b, 0xf000, 0x5000), @@ -4324,25 +4324,25 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec) static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, hda_nid_t mic_pin) { - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEFEX(0x57, 0x03, 0x8aa6), WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */ {} }; - static struct coef_fw coef0256[] = { + static const struct coef_fw coef0256[] = { UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/ WRITE_COEFEX(0x57, 0x03, 0x09a3), WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */ {} }; - static struct coef_fw coef0233[] = { + static const struct coef_fw coef0233[] = { UPDATE_COEF(0x35, 0, 1<<14), WRITE_COEF(0x06, 0x2100), WRITE_COEF(0x1a, 0x0021), WRITE_COEF(0x26, 0x008c), {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x4f, 0x00c0, 0), UPDATE_COEF(0x50, 0x2000, 0), UPDATE_COEF(0x56, 0x0006, 0), @@ -4351,30 +4351,30 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, UPDATE_COEF(0x67, 0x2000, 0x2000), {} }; - static struct coef_fw coef0292[] = { + static const struct coef_fw coef0292[] = { WRITE_COEF(0x19, 0xa208), WRITE_COEF(0x2e, 0xacf0), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */ UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */ UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */ {} }; - static struct coef_fw coef0688[] = { + static const struct coef_fw coef0688[] = { WRITE_COEF(0xb7, 0x802b), WRITE_COEF(0xb5, 0x1040), UPDATE_COEF(0xc3, 0, 1<<12), {} }; - static struct coef_fw coef0225[] = { + static const struct coef_fw coef0225[] = { UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), UPDATE_COEF(0x4a, 3<<4, 2<<4), UPDATE_COEF(0x63, 3<<14, 0), {} }; - static struct coef_fw coef0274[] = { + static const struct coef_fw coef0274[] = { UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000), UPDATE_COEF(0x4a, 0x0010, 0), UPDATE_COEF(0x6b, 0xf000, 0), @@ -4460,7 +4460,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, static void alc_headset_mode_default(struct hda_codec *codec) { - static struct coef_fw coef0225[] = { + static const struct coef_fw coef0225[] = { UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10), UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10), UPDATE_COEF(0x49, 3<<8, 0<<8), @@ -4469,14 +4469,14 @@ static void alc_headset_mode_default(struct hda_codec *codec) UPDATE_COEF(0x67, 0xf000, 0x3000), {} }; - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEF(0x45, 0xc089), WRITE_COEF(0x45, 0xc489), WRITE_COEFEX(0x57, 0x03, 0x8ea6), WRITE_COEF(0x49, 0x0049), {} }; - static struct coef_fw coef0256[] = { + static const struct coef_fw coef0256[] = { WRITE_COEF(0x45, 0xc489), WRITE_COEFEX(0x57, 0x03, 0x0da3), WRITE_COEF(0x49, 0x0049), @@ -4484,12 +4484,12 @@ static void alc_headset_mode_default(struct hda_codec *codec) WRITE_COEF(0x06, 0x6100), {} }; - static struct coef_fw coef0233[] = { + static const struct coef_fw coef0233[] = { WRITE_COEF(0x06, 0x2100), WRITE_COEF(0x32, 0x4ea3), {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */ UPDATE_COEF(0x50, 0x2000, 0x2000), UPDATE_COEF(0x56, 0x0006, 0x0006), @@ -4497,26 +4497,26 @@ static void alc_headset_mode_default(struct hda_codec *codec) UPDATE_COEF(0x67, 0x2000, 0), {} }; - static struct coef_fw coef0292[] = { + static const struct coef_fw coef0292[] = { WRITE_COEF(0x76, 0x000e), WRITE_COEF(0x6c, 0x2400), WRITE_COEF(0x6b, 0xc429), WRITE_COEF(0x18, 0x7308), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */ WRITE_COEF(0x45, 0xC429), /* Set to TRS type */ UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */ {} }; - static struct coef_fw coef0688[] = { + static const struct coef_fw coef0688[] = { WRITE_COEF(0x11, 0x0041), WRITE_COEF(0x15, 0x0d40), WRITE_COEF(0xb7, 0x802b), {} }; - static struct coef_fw coef0274[] = { + static const struct coef_fw coef0274[] = { WRITE_COEF(0x45, 0x4289), UPDATE_COEF(0x4a, 0x0010, 0x0010), UPDATE_COEF(0x6b, 0x0f00, 0), @@ -4579,53 +4579,53 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) { int val; - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */ WRITE_COEF(0x1b, 0x0c2b), WRITE_COEFEX(0x57, 0x03, 0x8ea6), {} }; - static struct coef_fw coef0256[] = { + static const struct coef_fw coef0256[] = { WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */ WRITE_COEF(0x1b, 0x0e6b), {} }; - static struct coef_fw coef0233[] = { + static const struct coef_fw coef0233[] = { WRITE_COEF(0x45, 0xd429), WRITE_COEF(0x1b, 0x0c2b), WRITE_COEF(0x32, 0x4ea3), {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x50, 0x2000, 0x2000), UPDATE_COEF(0x56, 0x0006, 0x0006), UPDATE_COEF(0x66, 0x0008, 0), UPDATE_COEF(0x67, 0x2000, 0), {} }; - static struct coef_fw coef0292[] = { + static const struct coef_fw coef0292[] = { WRITE_COEF(0x6b, 0xd429), WRITE_COEF(0x76, 0x0008), WRITE_COEF(0x18, 0x7388), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { WRITE_COEF(0x45, 0xd429), /* Set to ctia type */ UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */ {} }; - static struct coef_fw coef0688[] = { + static const struct coef_fw coef0688[] = { WRITE_COEF(0x11, 0x0001), WRITE_COEF(0x15, 0x0d60), WRITE_COEF(0xc3, 0x0000), {} }; - static struct coef_fw coef0225_1[] = { + static const struct coef_fw coef0225_1[] = { UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10), UPDATE_COEF(0x63, 3<<14, 2<<14), {} }; - static struct coef_fw coef0225_2[] = { + static const struct coef_fw coef0225_2[] = { UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10), UPDATE_COEF(0x63, 3<<14, 1<<14), {} @@ -4697,48 +4697,48 @@ static void alc_headset_mode_ctia(struct hda_codec *codec) /* Nokia type */ static void alc_headset_mode_omtp(struct hda_codec *codec) { - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */ WRITE_COEF(0x1b, 0x0c2b), WRITE_COEFEX(0x57, 0x03, 0x8ea6), {} }; - static struct coef_fw coef0256[] = { + static const struct coef_fw coef0256[] = { WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */ WRITE_COEF(0x1b, 0x0e6b), {} }; - static struct coef_fw coef0233[] = { + static const struct coef_fw coef0233[] = { WRITE_COEF(0x45, 0xe429), WRITE_COEF(0x1b, 0x0c2b), WRITE_COEF(0x32, 0x4ea3), {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x50, 0x2000, 0x2000), UPDATE_COEF(0x56, 0x0006, 0x0006), UPDATE_COEF(0x66, 0x0008, 0), UPDATE_COEF(0x67, 0x2000, 0), {} }; - static struct coef_fw coef0292[] = { + static const struct coef_fw coef0292[] = { WRITE_COEF(0x6b, 0xe429), WRITE_COEF(0x76, 0x0008), WRITE_COEF(0x18, 0x7388), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { WRITE_COEF(0x45, 0xe429), /* Set to omtp type */ UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */ {} }; - static struct coef_fw coef0688[] = { + static const struct coef_fw coef0688[] = { WRITE_COEF(0x11, 0x0001), WRITE_COEF(0x15, 0x0d50), WRITE_COEF(0xc3, 0x0000), {} }; - static struct coef_fw coef0225[] = { + static const struct coef_fw coef0225[] = { UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10), UPDATE_COEF(0x63, 3<<14, 2<<14), {} @@ -4798,17 +4798,17 @@ static void alc_determine_headset_type(struct hda_codec *codec) int val; bool is_ctia = false; struct alc_spec *spec = codec->spec; - static struct coef_fw coef0255[] = { + static const struct coef_fw coef0255[] = { WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/ WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref conteol) */ {} }; - static struct coef_fw coef0288[] = { + static const struct coef_fw coef0288[] = { UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */ {} }; - static struct coef_fw coef0298[] = { + static const struct coef_fw coef0298[] = { UPDATE_COEF(0x50, 0x2000, 0x2000), UPDATE_COEF(0x56, 0x0006, 0x0006), UPDATE_COEF(0x66, 0x0008, 0), @@ -4816,19 +4816,19 @@ static void alc_determine_headset_type(struct hda_codec *codec) UPDATE_COEF(0x19, 0x1300, 0x1300), {} }; - static struct coef_fw coef0293[] = { + static const struct coef_fw coef0293[] = { UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */ WRITE_COEF(0x45, 0xD429), /* Set to ctia type */ {} }; - static struct coef_fw coef0688[] = { + static const struct coef_fw coef0688[] = { WRITE_COEF(0x11, 0x0001), WRITE_COEF(0xb7, 0x802b), WRITE_COEF(0x15, 0x0d60), WRITE_COEF(0xc3, 0x0c00), {} }; - static struct coef_fw coef0274[] = { + static const struct coef_fw coef0274[] = { UPDATE_COEF(0x4a, 0x0010, 0), UPDATE_COEF(0x4a, 0x8000, 0), WRITE_COEF(0x45, 0xd289), @@ -5115,7 +5115,7 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, static void alc255_set_default_jack_type(struct hda_codec *codec) { /* Set to iphone type */ - static struct coef_fw alc255fw[] = { + static const struct coef_fw alc255fw[] = { WRITE_COEF(0x1b, 0x880b), WRITE_COEF(0x45, 0xd089), WRITE_COEF(0x1b, 0x080b), @@ -5123,7 +5123,7 @@ static void alc255_set_default_jack_type(struct hda_codec *codec) WRITE_COEF(0x1b, 0x0c0b), {} }; - static struct coef_fw alc256fw[] = { + static const struct coef_fw alc256fw[] = { WRITE_COEF(0x1b, 0x884b), WRITE_COEF(0x45, 0xd089), WRITE_COEF(0x1b, 0x084b), @@ -8482,7 +8482,7 @@ static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec, } } -static struct coef_fw alc668_coefs[] = { +static const struct coef_fw alc668_coefs[] = { WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0), WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80), WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0), -- cgit v1.2.3 From d64e7f7c9e70c587ce9fcc2eacd0cd7c29bcf91c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:19 +0100 Subject: ALSA: dummy: More constifications Apply const prefix to every possible place: mostly for declaring the dummy hardware models. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-5-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/dummy.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 46fa60e7f722..da0bd8960b3c 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -117,7 +117,7 @@ struct dummy_model { struct snd_dummy { struct snd_card *card; - struct dummy_model *model; + const struct dummy_model *model; struct snd_pcm *pcm; struct snd_pcm_hardware pcm_hw; spinlock_t mixer_lock; @@ -144,13 +144,13 @@ static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) return 0; } -static struct dummy_model model_emu10k1 = { +static const struct dummy_model model_emu10k1 = { .name = "emu10k1", .playback_constraints = emu10k1_playback_constraints, .buffer_bytes_max = 128 * 1024, }; -static struct dummy_model model_rme9652 = { +static const struct dummy_model model_rme9652 = { .name = "rme9652", .buffer_bytes_max = 26 * 64 * 1024, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -160,7 +160,7 @@ static struct dummy_model model_rme9652 = { .periods_max = 2, }; -static struct dummy_model model_ice1712 = { +static const struct dummy_model model_ice1712 = { .name = "ice1712", .buffer_bytes_max = 256 * 1024, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -170,7 +170,7 @@ static struct dummy_model model_ice1712 = { .periods_max = 1024, }; -static struct dummy_model model_uda1341 = { +static const struct dummy_model model_uda1341 = { .name = "uda1341", .buffer_bytes_max = 16380, .formats = SNDRV_PCM_FMTBIT_S16_LE, @@ -180,7 +180,7 @@ static struct dummy_model model_uda1341 = { .periods_max = 255, }; -static struct dummy_model model_ac97 = { +static const struct dummy_model model_ac97 = { .name = "ac97", .formats = SNDRV_PCM_FMTBIT_S16_LE, .channels_min = 2, @@ -190,7 +190,7 @@ static struct dummy_model model_ac97 = { .rate_max = 48000, }; -static struct dummy_model model_ca0106 = { +static const struct dummy_model model_ca0106 = { .name = "ca0106", .formats = SNDRV_PCM_FMTBIT_S16_LE, .buffer_bytes_max = ((65536-64)*8), @@ -204,7 +204,7 @@ static struct dummy_model model_ca0106 = { .rate_max = 192000, }; -static struct dummy_model *dummy_models[] = { +static const struct dummy_model *dummy_models[] = { &model_emu10k1, &model_rme9652, &model_ice1712, @@ -535,7 +535,7 @@ static int dummy_pcm_hw_params(struct snd_pcm_substream *substream, static int dummy_pcm_open(struct snd_pcm_substream *substream) { struct snd_dummy *dummy = snd_pcm_substream_chip(substream); - struct dummy_model *model = dummy->model; + const struct dummy_model *model = dummy->model; struct snd_pcm_runtime *runtime = substream->runtime; const struct dummy_timer_ops *ops; int err; @@ -912,7 +912,7 @@ static void print_formats(struct snd_dummy *dummy, static void print_rates(struct snd_dummy *dummy, struct snd_info_buffer *buffer) { - static int rates[] = { + static const int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000, }; @@ -944,7 +944,7 @@ struct dummy_hw_field { .offset = offsetof(struct snd_pcm_hardware, item), \ .size = sizeof(dummy_pcm_hardware.item) } -static struct dummy_hw_field fields[] = { +static const struct dummy_hw_field fields[] = { FIELD_ENTRY(formats, "%#llx"), FIELD_ENTRY(rates, "%#x"), FIELD_ENTRY(rate_min, "%d"), @@ -1022,7 +1022,7 @@ static int snd_dummy_probe(struct platform_device *devptr) { struct snd_card *card; struct snd_dummy *dummy; - struct dummy_model *m = NULL, **mdl; + const struct dummy_model *m = NULL, **mdl; int idx, err; int dev = devptr->id; -- cgit v1.2.3 From d03af9b8ea7e8655869834f2eed1f1d583cc5672 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:20 +0100 Subject: ALSA: pcm: More constifications Apply const prefix to more possible places: the string tables for PCM format and co, the table for the PCM type helpers, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-6-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/pcm.c | 12 ++++++------ sound/core/pcm_lib.c | 2 +- sound/core/pcm_misc.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sound/core/pcm.c b/sound/core/pcm.c index a0f704b72a78..a141a301369f 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -163,7 +163,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v -static char *snd_pcm_format_names[] = { +static const char * const snd_pcm_format_names[] = { FORMAT(S8), FORMAT(U8), FORMAT(S16_LE), @@ -237,12 +237,12 @@ EXPORT_SYMBOL_GPL(snd_pcm_format_name); #define START(v) [SNDRV_PCM_START_##v] = #v #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v -static char *snd_pcm_stream_names[] = { +static const char * const snd_pcm_stream_names[] = { STREAM(PLAYBACK), STREAM(CAPTURE), }; -static char *snd_pcm_state_names[] = { +static const char * const snd_pcm_state_names[] = { STATE(OPEN), STATE(SETUP), STATE(PREPARED), @@ -253,7 +253,7 @@ static char *snd_pcm_state_names[] = { STATE(SUSPENDED), }; -static char *snd_pcm_access_names[] = { +static const char * const snd_pcm_access_names[] = { ACCESS(MMAP_INTERLEAVED), ACCESS(MMAP_NONINTERLEAVED), ACCESS(MMAP_COMPLEX), @@ -261,11 +261,11 @@ static char *snd_pcm_access_names[] = { ACCESS(RW_NONINTERLEAVED), }; -static char *snd_pcm_subformat_names[] = { +static const char * const snd_pcm_subformat_names[] = { SUBFORMAT(STD), }; -static char *snd_pcm_tstamp_mode_names[] = { +static const char * const snd_pcm_tstamp_mode_names[] = { TSTAMP(NONE), TSTAMP(ENABLE), }; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 18f498ab7af1..872a852de75c 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1452,7 +1452,7 @@ EXPORT_SYMBOL(snd_pcm_hw_constraint_step); static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - static unsigned int pow2_sizes[] = { + static const unsigned int pow2_sizes[] = { 1<<0, 1<<1, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6, 1<<7, 1<<8, 1<<9, 1<<10, 1<<11, 1<<12, 1<<13, 1<<14, 1<<15, 1<<16, 1<<17, 1<<18, 1<<19, 1<<20, 1<<21, 1<<22, 1<<23, diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index c4eb561d2008..a6a541511534 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -42,7 +42,7 @@ struct pcm_format_data { /* we do lots of calculations on snd_pcm_format_t; shut up sparse */ #define INT __force int -static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { +static const struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { [SNDRV_PCM_FORMAT_S8] = { .width = 8, .phys = 8, .le = -1, .signd = 1, .silence = {}, @@ -415,7 +415,8 @@ EXPORT_SYMBOL(snd_pcm_format_silence_64); int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) { int width; - unsigned char *dst, *pat; + unsigned char *dst; + const unsigned char *pat; if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST) return -EINVAL; -- cgit v1.2.3 From 731922a5939e653ce501b7d72bfe8fbe79717abf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:21 +0100 Subject: ALSA: seq: More constifications Apply const prefix to the remaining sequencer code: the static tables for MIDI macros, RPN/NRPN, and some strings. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-7-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/seq/oss/seq_oss_init.c | 4 ++-- sound/core/seq/seq_midi_emul.c | 6 +++--- sound/core/seq/seq_midi_event.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index 6dc94efc19c9..4534a154b8c8 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -460,10 +460,10 @@ enabled_str(int bool) return bool ? "enabled" : "disabled"; } -static char * +static const char * filemode_str(int val) { - static char *str[] = { + static const char * const str[] = { "none", "read", "write", "read/write", }; return str[val & SNDRV_SEQ_OSS_FILE_ACMODE]; diff --git a/sound/core/seq/seq_midi_emul.c b/sound/core/seq/seq_midi_emul.c index 536ccf48ee72..198f285594e3 100644 --- a/sound/core/seq/seq_midi_emul.c +++ b/sound/core/seq/seq_midi_emul.c @@ -479,11 +479,11 @@ sysex(const struct snd_midi_op *ops, void *private, unsigned char *buf, int len, struct snd_midi_channel_set *chset) { /* GM on */ - static unsigned char gm_on_macro[] = { + static const unsigned char gm_on_macro[] = { 0x7e,0x7f,0x09,0x01, }; /* XG on */ - static unsigned char xg_on_macro[] = { + static const unsigned char xg_on_macro[] = { 0x43,0x10,0x4c,0x00,0x00,0x7e,0x00, }; /* GS prefix @@ -492,7 +492,7 @@ sysex(const struct snd_midi_op *ops, void *private, unsigned char *buf, int len, * chorus mode: XX=0x01, YY=0x38, ZZ=0-7 * master vol: XX=0x00, YY=0x04, ZZ=0-127 */ - static unsigned char gs_pfx_macro[] = { + static const unsigned char gs_pfx_macro[] = { 0x41,0x10,0x42,0x12,0x40,/*XX,YY,ZZ*/ }; diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c index ae0308d4ace3..7511462fe071 100644 --- a/sound/core/seq/seq_midi_event.c +++ b/sound/core/seq/seq_midi_event.c @@ -422,12 +422,12 @@ static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf, int count, struct snd_seq_event *ev) { unsigned char cmd; - char *cbytes; - static char cbytes_nrpn[4] = { MIDI_CTL_NONREG_PARM_NUM_MSB, + const char *cbytes; + static const char cbytes_nrpn[4] = { MIDI_CTL_NONREG_PARM_NUM_MSB, MIDI_CTL_NONREG_PARM_NUM_LSB, MIDI_CTL_MSB_DATA_ENTRY, MIDI_CTL_LSB_DATA_ENTRY }; - static char cbytes_rpn[4] = { MIDI_CTL_REGIST_PARM_NUM_MSB, + static const char cbytes_rpn[4] = { MIDI_CTL_REGIST_PARM_NUM_MSB, MIDI_CTL_REGIST_PARM_NUM_LSB, MIDI_CTL_MSB_DATA_ENTRY, MIDI_CTL_LSB_DATA_ENTRY }; -- cgit v1.2.3 From c09482455ca586539802282380f59f54a1febf16 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:22 +0100 Subject: ALSA: vx: More constifications Apply const prefix to every possible place: the static tables for DSP commands, the string tables, and register/offset tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-8-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/vx/vx_cmd.c | 2 +- sound/drivers/vx/vx_core.c | 12 ++++++------ sound/drivers/vx/vx_hwdep.c | 2 +- sound/drivers/vx/vx_mixer.c | 2 +- sound/pci/vx222/vx222_ops.c | 4 ++-- sound/pcmcia/vx/vxp_ops.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/drivers/vx/vx_cmd.c b/sound/drivers/vx/vx_cmd.c index 77ae59aef4e0..b0970a04883e 100644 --- a/sound/drivers/vx/vx_cmd.c +++ b/sound/drivers/vx/vx_cmd.c @@ -15,7 +15,7 @@ /* * Array of DSP commands */ -static struct vx_cmd_info vx_dsp_cmds[] = { +static const struct vx_cmd_info vx_dsp_cmds[] = { [CMD_VERSION] = { 0x010000, 2, RMH_SSIZE_FIXED, 1 }, [CMD_SUPPORTED] = { 0x020000, 1, RMH_SSIZE_FIXED, 2 }, [CMD_TEST_IT] = { 0x040000, 1, RMH_SSIZE_FIXED, 1 }, diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index dd35de3f2434..ffab0400d7fb 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -39,7 +39,7 @@ MODULE_LICENSE("GPL"); int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time) { unsigned long end_time = jiffies + (time * HZ + 999) / 1000; - static char *reg_names[VX_REG_MAX] = { + static const char * const reg_names[VX_REG_MAX] = { "ICR", "CVR", "ISR", "IVR", "RXH", "RXM", "RXL", "DMA", "CDSP", "RFREQ", "RUER/V2", "DATA", "MEMIRQ", "ACQ", "BIT0", "BIT1", "MIC0", "MIC1", "MIC2", @@ -588,11 +588,11 @@ static void vx_reset_board(struct vx_core *chip, int cold_reset) static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct vx_core *chip = entry->private_data; - static char *audio_src_vxp[] = { "Line", "Mic", "Digital" }; - static char *audio_src_vx2[] = { "Analog", "Analog", "Digital" }; - static char *clock_mode[] = { "Auto", "Internal", "External" }; - static char *clock_src[] = { "Internal", "External" }; - static char *uer_type[] = { "Consumer", "Professional", "Not Present" }; + static const char * const audio_src_vxp[] = { "Line", "Mic", "Digital" }; + static const char * const audio_src_vx2[] = { "Analog", "Analog", "Digital" }; + static const char * const clock_mode[] = { "Auto", "Internal", "External" }; + static const char * const clock_src[] = { "Internal", "External" }; + static const char * const uer_type[] = { "Consumer", "Professional", "Not Present" }; snd_iprintf(buffer, "%s\n", chip->card->longname); snd_iprintf(buffer, "Xilinx Firmware: %s\n", diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c index f0d31b0a178e..01baa6d872e9 100644 --- a/sound/drivers/vx/vx_hwdep.c +++ b/sound/drivers/vx/vx_hwdep.c @@ -32,7 +32,7 @@ MODULE_FIRMWARE("vx/l_1_vp4.d56"); int snd_vx_setup_firmware(struct vx_core *chip) { - static char *fw_files[VX_TYPE_NUMS][4] = { + static const char * const fw_files[VX_TYPE_NUMS][4] = { [VX_TYPE_BOARD] = { NULL, "x1_1_vx2.xlx", "bd56002.boot", "l_1_vx2.d56", }, diff --git a/sound/drivers/vx/vx_mixer.c b/sound/drivers/vx/vx_mixer.c index b17c67b14d59..13099f8c84d6 100644 --- a/sound/drivers/vx/vx_mixer.c +++ b/sound/drivers/vx/vx_mixer.c @@ -961,7 +961,7 @@ int snd_vx_mixer_new(struct vx_core *chip) return err; /* VU, peak, saturation meters */ for (c = 0; c < 2; c++) { - static char *dir[2] = { "Output", "Input" }; + static const char * const dir[2] = { "Output", "Input" }; for (i = 0; i < chip->hw->num_ins; i++) { int val = (i * 2) | (c << 8); if (c == 1) { diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 6245240d8768..23d4338dc553 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -19,7 +19,7 @@ #include "vx222.h" -static int vx2_reg_offset[VX_REG_MAX] = { +static const int vx2_reg_offset[VX_REG_MAX] = { [VX_ICR] = 0x00, [VX_CVR] = 0x04, [VX_ISR] = 0x08, @@ -45,7 +45,7 @@ static int vx2_reg_offset[VX_REG_MAX] = { [VX_GPIOC] = 0x54, // VX_GPIOC (new with PLX9030) }; -static int vx2_reg_index[VX_REG_MAX] = { +static const int vx2_reg_index[VX_REG_MAX] = { [VX_ICR] = 1, [VX_CVR] = 1, [VX_ISR] = 1, diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index f7cf707d315f..45eeb0f57d59 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c @@ -15,7 +15,7 @@ #include "vxpocket.h" -static int vxp_reg_offset[VX_REG_MAX] = { +static const int vxp_reg_offset[VX_REG_MAX] = { [VX_ICR] = 0x00, // ICR [VX_CVR] = 0x01, // CVR [VX_ISR] = 0x02, // ISR -- cgit v1.2.3 From f729f88a04089d2a0f2783182027347e0446b900 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:23 +0100 Subject: ALSA: intel8x0: More constifications Apply const prefix to more places: the static tables for PCM definitions, the register tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-9-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 28 ++++++++++++++-------------- sound/pci/intel8x0m.c | 12 ++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 5bdd25815fc7..1781a1c081c3 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -393,7 +393,7 @@ struct intel8x0 { struct snd_ac97 *ac97[3]; unsigned int ac97_sdin[3]; unsigned int max_codecs, ncodecs; - unsigned int *codec_bit; + const unsigned int *codec_bit; unsigned int codec_isr_bits; unsigned int codec_ready_bits; @@ -843,7 +843,7 @@ static int snd_intel8x0_ali_trigger(struct snd_pcm_substream *substream, int cmd struct intel8x0 *chip = snd_pcm_substream_chip(substream); struct ichdev *ichdev = get_ichdev(substream); unsigned long port = ichdev->reg_offset; - static int fiforeg[] = { + static const int fiforeg[] = { ICHREG(ALI_FIFOCR1), ICHREG(ALI_FIFOCR2), ICHREG(ALI_FIFOCR3) }; unsigned int val, fifo; @@ -1443,7 +1443,7 @@ struct ich_pcm_table { ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_UC : SNDRV_DMA_TYPE_DEV) static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, - struct ich_pcm_table *rec) + const struct ich_pcm_table *rec) { struct snd_pcm *pcm; int err; @@ -1498,7 +1498,7 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, return 0; } -static struct ich_pcm_table intel_pcms[] = { +static const struct ich_pcm_table intel_pcms[] = { { .playback_ops = &snd_intel8x0_playback_ops, .capture_ops = &snd_intel8x0_capture_ops, @@ -1535,7 +1535,7 @@ static struct ich_pcm_table intel_pcms[] = { }, }; -static struct ich_pcm_table nforce_pcms[] = { +static const struct ich_pcm_table nforce_pcms[] = { { .playback_ops = &snd_intel8x0_playback_ops, .capture_ops = &snd_intel8x0_capture_ops, @@ -1558,7 +1558,7 @@ static struct ich_pcm_table nforce_pcms[] = { }, }; -static struct ich_pcm_table ali_pcms[] = { +static const struct ich_pcm_table ali_pcms[] = { { .playback_ops = &snd_intel8x0_ali_playback_ops, .capture_ops = &snd_intel8x0_ali_capture_ops, @@ -1593,7 +1593,7 @@ static struct ich_pcm_table ali_pcms[] = { static int snd_intel8x0_pcm(struct intel8x0 *chip) { int i, tblsize, device, err; - struct ich_pcm_table *tbl, *rec; + const struct ich_pcm_table *tbl, *rec; switch (chip->device_type) { case DEVICE_INTEL_ICH4: @@ -2849,10 +2849,10 @@ struct ich_reg_info { unsigned int offset; }; -static unsigned int ich_codec_bits[3] = { +static const unsigned int ich_codec_bits[3] = { ICH_PCR, ICH_SCR, ICH_TCR }; -static unsigned int sis_codec_bits[3] = { +static const unsigned int sis_codec_bits[3] = { ICH_PCR, ICH_SCR, ICH_SIS_TCR }; @@ -2901,14 +2901,14 @@ static int snd_intel8x0_create(struct snd_card *card, .dev_free = snd_intel8x0_dev_free, }; - static unsigned int bdbars[] = { + static const unsigned int bdbars[] = { 3, /* DEVICE_INTEL */ 6, /* DEVICE_INTEL_ICH4 */ 3, /* DEVICE_SIS */ 6, /* DEVICE_ALI */ 4, /* DEVICE_NFORCE */ }; - static struct ich_reg_info intel_regs[6] = { + static const struct ich_reg_info intel_regs[6] = { { ICH_PIINT, 0 }, { ICH_POINT, 0x10 }, { ICH_MCINT, 0x20 }, @@ -2916,13 +2916,13 @@ static int snd_intel8x0_create(struct snd_card *card, { ICH_P2INT, 0x50 }, { ICH_SPINT, 0x60 }, }; - static struct ich_reg_info nforce_regs[4] = { + static const struct ich_reg_info nforce_regs[4] = { { ICH_PIINT, 0 }, { ICH_POINT, 0x10 }, { ICH_MCINT, 0x20 }, { ICH_NVSPINT, 0x70 }, }; - static struct ich_reg_info ali_regs[6] = { + static const struct ich_reg_info ali_regs[6] = { { ALI_INT_PCMIN, 0x40 }, { ALI_INT_PCMOUT, 0x50 }, { ALI_INT_MICIN, 0x60 }, @@ -2930,7 +2930,7 @@ static int snd_intel8x0_create(struct snd_card *card, { ALI_INT_SPDIFIN, 0xa0 }, { ALI_INT_SPDIFOUT, 0xb0 }, }; - struct ich_reg_info *tbl; + const struct ich_reg_info *tbl; *r_intel8x0 = NULL; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 74d45b9a1571..1b7df0c4e57c 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -288,7 +288,7 @@ static inline void iaputword(struct intel8x0m *chip, u32 offset, u16 val) /* return the GLOB_STA bit for the corresponding codec */ static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec) { - static unsigned int codec_bit[3] = { + static const unsigned int codec_bit[3] = { ICH_PCR, ICH_SCR, ICH_TCR }; if (snd_BUG_ON(codec >= 3)) @@ -686,7 +686,7 @@ struct ich_pcm_table { }; static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, - struct ich_pcm_table *rec) + const struct ich_pcm_table *rec) { struct snd_pcm *pcm; int err; @@ -724,7 +724,7 @@ static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, return 0; } -static struct ich_pcm_table intel_pcms[] = { +static const struct ich_pcm_table intel_pcms[] = { { .suffix = "Modem", .playback_ops = &snd_intel8x0m_playback_ops, @@ -737,7 +737,7 @@ static struct ich_pcm_table intel_pcms[] = { static int snd_intel8x0m_pcm(struct intel8x0m *chip) { int i, tblsize, device, err; - struct ich_pcm_table *tbl, *rec; + const struct ich_pcm_table *tbl, *rec; #if 1 tbl = intel_pcms; @@ -1082,11 +1082,11 @@ static int snd_intel8x0m_create(struct snd_card *card, static const struct snd_device_ops ops = { .dev_free = snd_intel8x0m_dev_free, }; - static struct ich_reg_info intel_regs[2] = { + static const struct ich_reg_info intel_regs[2] = { { ICH_MIINT, 0 }, { ICH_MOINT, 0x10 }, }; - struct ich_reg_info *tbl; + const struct ich_reg_info *tbl; *r_intel8x0m = NULL; -- cgit v1.2.3 From bf82326fce53321c3f9088874dc12dcbd6d0ca06 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:24 +0100 Subject: ALSA: hda: More constifications Apply const prefix to the remaining possible places: the string tables, the rate tables, the verb tables, the index tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-10-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/hda/hdac_device.c | 4 ++-- sound/hda/hdmi_chmap.c | 2 +- sound/hda/intel-nhlt.c | 2 +- sound/pci/hda/hda_codec.c | 6 +++--- sound/pci/hda/hda_eld.c | 6 +++--- sound/pci/hda/hda_intel.c | 8 ++++---- sound/pci/hda/hda_proc.c | 2 +- sound/pci/hda/hda_sysfs.c | 2 +- sound/pci/hda/patch_analog.c | 2 +- sound/pci/hda/patch_ca0132.c | 18 +++++++++--------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 9f3e37511408..b4f8725f5ddf 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -637,7 +637,7 @@ struct hda_vendor_id { const char *name; }; -static struct hda_vendor_id hda_vendor_ids[] = { +static const struct hda_vendor_id hda_vendor_ids[] = { { 0x1002, "ATI" }, { 0x1013, "Cirrus Logic" }, { 0x1057, "Motorola" }, @@ -692,7 +692,7 @@ struct hda_rate_tbl { (AC_FMT_BASE_##base##K | (((mult) - 1) << AC_FMT_MULT_SHIFT) | \ (((div) - 1) << AC_FMT_DIV_SHIFT)) -static struct hda_rate_tbl rate_bits[] = { +static const struct hda_rate_tbl rate_bits[] = { /* rate in Hz, ALSA rate bitmask, HDA format value */ /* autodetected value used in snd_hda_query_supported_pcm */ diff --git a/sound/hda/hdmi_chmap.c b/sound/hda/hdmi_chmap.c index 886cb7811bd6..5fd6d575e123 100644 --- a/sound/hda/hdmi_chmap.c +++ b/sound/hda/hdmi_chmap.c @@ -59,7 +59,7 @@ static const char * const cea_speaker_allocation_names[] = { /* * ELD SA bits in the CEA Speaker Allocation data block */ -static int eld_speaker_allocation_bits[] = { +static const int eld_speaker_allocation_bits[] = { [0] = FL | FR, [1] = LFE, [2] = FC, diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c index 097ff6c10099..99a23fe7fab9 100644 --- a/sound/hda/intel-nhlt.c +++ b/sound/hda/intel-nhlt.c @@ -7,7 +7,7 @@ #define NHLT_ACPI_HEADER_SIG "NHLT" /* Unique identification for getting NHLT blobs */ -static guid_t osc_guid = +static const guid_t osc_guid = GUID_INIT(0xA69F886E, 0x6CEB, 0x4594, 0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53); diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index d039eeec080f..4377b2aba835 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3201,7 +3201,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type) /* assigned to static slots up to dev#10; if more needed, assign * the later slot dynamically (when CONFIG_SND_DYNAMIC_MINORS=y) */ - static int audio_idx[HDA_PCM_NTYPES][5] = { + static const int audio_idx[HDA_PCM_NTYPES][5] = { [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 }, [HDA_PCM_TYPE_SPDIF] = { 1, -1 }, [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 }, @@ -3869,7 +3869,7 @@ EXPORT_SYMBOL_GPL(snd_hda_get_default_vref); unsigned int snd_hda_correct_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val) { - static unsigned int cap_lists[][2] = { + static const unsigned int cap_lists[][2] = { { AC_PINCTL_VREF_100, AC_PINCAP_VREF_100 }, { AC_PINCTL_VREF_80, AC_PINCAP_VREF_80 }, { AC_PINCTL_VREF_50, AC_PINCAP_VREF_50 }, @@ -4014,7 +4014,7 @@ void snd_hda_bus_reset_codecs(struct hda_bus *bus) */ void snd_print_pcm_bits(int pcm, char *buf, int buflen) { - static unsigned int bits[] = { 8, 16, 20, 24, 32 }; + static const unsigned int bits[] = { 8, 16, 20, 24, 32 }; int i, j; for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++) diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index d081fb2880a0..bb46c89b7f63 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -98,7 +98,7 @@ static const char * const cea_audio_coding_type_names[] = { /* * SS1:SS0 index => sample size */ -static int cea_sample_sizes[4] = { +static const int cea_sample_sizes[4] = { 0, /* 0: Refer to Stream Header */ AC_SUPPCM_BITS_16, /* 1: 16 bits */ AC_SUPPCM_BITS_20, /* 2: 20 bits */ @@ -108,7 +108,7 @@ static int cea_sample_sizes[4] = { /* * SF2:SF1:SF0 index => sampling frequency */ -static int cea_sampling_frequencies[8] = { +static const int cea_sampling_frequencies[8] = { 0, /* 0: Refer to Stream Header */ SNDRV_PCM_RATE_32000, /* 1: 32000Hz */ SNDRV_PCM_RATE_44100, /* 2: 44100Hz */ @@ -352,7 +352,7 @@ error: */ static void hdmi_print_pcm_rates(int pcm, char *buf, int buflen) { - static unsigned int alsa_rates[] = { + static const unsigned int alsa_rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000, 384000 }; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 49f1638969e3..617143a44a10 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -372,7 +372,7 @@ enum { #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) -static char *driver_short_names[] = { +static const char * const driver_short_names[] = { [AZX_DRIVER_ICH] = "HDA Intel", [AZX_DRIVER_PCH] = "HDA Intel PCH", [AZX_DRIVER_SCH] = "HDA Intel MID", @@ -499,7 +499,7 @@ static void bxt_reduce_dma_latency(struct azx *chip) static int intel_get_lctl_scf(struct azx *chip) { struct hdac_bus *bus = azx_bus(chip); - static int preferred_bits[] = { 2, 3, 1, 4, 5 }; + static const int preferred_bits[] = { 2, 3, 1, 4, 5 }; u32 val, t; int i; @@ -1564,7 +1564,7 @@ static int check_position_fix(struct azx *chip, int fix) static void assign_position_fix(struct azx *chip, int fix) { - static azx_get_pos_callback_t callbacks[] = { + static const azx_get_pos_callback_t callbacks[] = { [POS_FIX_AUTO] = NULL, [POS_FIX_LPIB] = azx_get_pos_lpib, [POS_FIX_POSBUF] = azx_get_pos_posbuf, @@ -2231,7 +2231,7 @@ static void set_default_power_save(struct azx *chip) } /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ -static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = { +static const unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = { [AZX_DRIVER_NVIDIA] = 8, [AZX_DRIVER_TERA] = 1, }; diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 468836c65445..0631f31ef87f 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -160,7 +160,7 @@ static void print_amp_vals(struct snd_info_buffer *buffer, static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) { - static unsigned int rates[] = { + static const unsigned int rates[] = { 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 384000 }; diff --git a/sound/pci/hda/hda_sysfs.c b/sound/pci/hda/hda_sysfs.c index fcc34417cbce..0607ed5d1959 100644 --- a/sound/pci/hda/hda_sysfs.c +++ b/sound/pci/hda/hda_sysfs.c @@ -611,7 +611,7 @@ struct hda_patch_item { void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc); }; -static struct hda_patch_item patch_items[NUM_LINE_MODES] = { +static const struct hda_patch_item patch_items[NUM_LINE_MODES] = { [LINE_MODE_CODEC] = { .tag = "[codec]", .parser = parse_codec_mode, diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index c64895f99299..88c46b051d14 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -812,7 +812,7 @@ static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec) /* we create four static faked paths, since AD codecs have odd * widget connections regarding the SPDIF out source */ - static struct nid_path fake_paths[4] = { + static const struct nid_path fake_paths[4] = { { .depth = 3, .path = { 0x02, 0x1d, 0x1b }, diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 250534f90ce0..46e105244ad3 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -3768,7 +3768,7 @@ static const unsigned int float_xbass_xover_lookup[] = { /* The following are for tuning of products */ #ifdef ENABLE_TUNING_CONTROLS -static unsigned int voice_focus_vals_lookup[] = { +static const unsigned int voice_focus_vals_lookup[] = { 0x41A00000, 0x41A80000, 0x41B00000, 0x41B80000, 0x41C00000, 0x41C80000, 0x41D00000, 0x41D80000, 0x41E00000, 0x41E80000, 0x41F00000, 0x41F80000, 0x42000000, 0x42040000, 0x42080000, 0x420C0000, 0x42100000, 0x42140000, @@ -3798,7 +3798,7 @@ static unsigned int voice_focus_vals_lookup[] = { 0x43300000, 0x43310000, 0x43320000, 0x43330000, 0x43340000 }; -static unsigned int mic_svm_vals_lookup[] = { +static const unsigned int mic_svm_vals_lookup[] = { 0x00000000, 0x3C23D70A, 0x3CA3D70A, 0x3CF5C28F, 0x3D23D70A, 0x3D4CCCCD, 0x3D75C28F, 0x3D8F5C29, 0x3DA3D70A, 0x3DB851EC, 0x3DCCCCCD, 0x3DE147AE, 0x3DF5C28F, 0x3E051EB8, 0x3E0F5C29, 0x3E19999A, 0x3E23D70A, 0x3E2E147B, @@ -3818,7 +3818,7 @@ static unsigned int mic_svm_vals_lookup[] = { 0x3F75C28F, 0x3F7851EC, 0x3F7AE148, 0x3F7D70A4, 0x3F800000 }; -static unsigned int equalizer_vals_lookup[] = { +static const unsigned int equalizer_vals_lookup[] = { 0xC1C00000, 0xC1B80000, 0xC1B00000, 0xC1A80000, 0xC1A00000, 0xC1980000, 0xC1900000, 0xC1880000, 0xC1800000, 0xC1700000, 0xC1600000, 0xC1500000, 0xC1400000, 0xC1300000, 0xC1200000, 0xC1100000, 0xC1000000, 0xC0E00000, @@ -3831,7 +3831,7 @@ static unsigned int equalizer_vals_lookup[] = { }; static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid, - unsigned int *lookup, int idx) + const unsigned int *lookup, int idx) { int i = 0; @@ -7642,14 +7642,14 @@ static void ca0132_init_unsol(struct hda_codec *codec) */ /* Sends before DSP download. */ -static struct hda_verb ca0132_base_init_verbs[] = { +static const struct hda_verb ca0132_base_init_verbs[] = { /*enable ct extension*/ {0x15, VENDOR_CHIPIO_CT_EXTENSIONS_ENABLE, 0x1}, {} }; /* Send at exit. */ -static struct hda_verb ca0132_base_exit_verbs[] = { +static const struct hda_verb ca0132_base_exit_verbs[] = { /*set afg to D3*/ {0x01, AC_VERB_SET_POWER_STATE, 0x03}, /*disable ct extension*/ @@ -7659,7 +7659,7 @@ static struct hda_verb ca0132_base_exit_verbs[] = { /* Other verbs tables. Sends after DSP download. */ -static struct hda_verb ca0132_init_verbs0[] = { +static const struct hda_verb ca0132_init_verbs0[] = { /* chip init verbs */ {0x15, 0x70D, 0xF0}, {0x15, 0x70E, 0xFE}, @@ -7692,7 +7692,7 @@ static struct hda_verb ca0132_init_verbs0[] = { }; /* Extra init verbs for desktop cards. */ -static struct hda_verb ca0132_init_verbs1[] = { +static const struct hda_verb ca0132_init_verbs1[] = { {0x15, 0x70D, 0x20}, {0x15, 0x70E, 0x19}, {0x15, 0x707, 0x00}, @@ -8869,7 +8869,7 @@ static int patch_ca0132(struct hda_codec *codec) /* * patch entries */ -static struct hda_device_id snd_hda_id_ca0132[] = { +static const struct hda_device_id snd_hda_id_ca0132[] = { HDA_CODEC_ENTRY(0x11020011, "CA0132", patch_ca0132), {} /* terminator */ }; -- cgit v1.2.3 From 1675bfc0fb040e421d15d1944dc578b76543c19f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:25 +0100 Subject: ALSA: ac97: More constifications Apply const prefix to each possible place: the static tables for registers and bits, the quirk tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-11-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 10 +++++----- sound/pci/ac97/ac97_patch.c | 26 +++++++++++++------------- sound/pci/ac97/ac97_pcm.c | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index fcfa8499e453..6758c072000e 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1753,10 +1753,10 @@ static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97) { unsigned int result = 0; int i; - static unsigned short ctl_bits[] = { + static const unsigned short ctl_bits[] = { AC97_SC_SPSR_44K, AC97_SC_SPSR_32K, AC97_SC_SPSR_48K }; - static unsigned int rate_bits[] = { + static const unsigned int rate_bits[] = { SNDRV_PCM_RATE_44100, SNDRV_PCM_RATE_32000, SNDRV_PCM_RATE_48000 }; @@ -2346,7 +2346,7 @@ struct ac97_power_reg { enum { PWIDX_ADC, PWIDX_FRONT, PWIDX_CLFE, PWIDX_SURR, PWIDX_MIC, PWIDX_SIZE }; -static struct ac97_power_reg power_regs[PWIDX_SIZE] = { +static const struct ac97_power_reg power_regs[PWIDX_SIZE] = { [PWIDX_ADC] = { AC97_PCM_LR_ADC_RATE, AC97_POWERDOWN, AC97_PD_PR0}, [PWIDX_FRONT] = { AC97_PCM_FRONT_DAC_RATE, AC97_POWERDOWN, AC97_PD_PR1}, [PWIDX_CLFE] = { AC97_PCM_LFE_DAC_RATE, AC97_EXTENDED_STATUS, @@ -2829,7 +2829,7 @@ struct quirk_table { int (*func)(struct snd_ac97 *); }; -static struct quirk_table applicable_quirks[] = { +static const struct quirk_table applicable_quirks[] = { { "none", NULL }, { "hp_only", tune_hp_only }, { "swap_hp", tune_swap_hp }, @@ -2857,7 +2857,7 @@ static int apply_quirk(struct snd_ac97 *ac97, int type) static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr) { int i; - struct quirk_table *q; + const struct quirk_table *q; for (i = 0; i < ARRAY_SIZE(applicable_quirks); i++) { q = &applicable_quirks[i]; diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 524f9d2dcb3c..ebf926728c5f 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -1211,25 +1211,25 @@ static const struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = { static int patch_sigmatel_stac9758(struct snd_ac97 * ac97) { - static unsigned short regs[4] = { + static const unsigned short regs[4] = { AC97_SIGMATEL_OUTSEL, AC97_SIGMATEL_IOMISC, AC97_SIGMATEL_INSEL, AC97_SIGMATEL_VARIOUS }; - static unsigned short def_regs[4] = { + static const unsigned short def_regs[4] = { /* OUTSEL */ 0xd794, /* CL:CL, SR:SR, LO:MX, LI:DS, MI:DS */ /* IOMISC */ 0x2001, /* INSEL */ 0x0201, /* LI:LI, MI:M1 */ /* VARIOUS */ 0x0040 }; - static unsigned short m675_regs[4] = { + static const unsigned short m675_regs[4] = { /* OUTSEL */ 0xfc70, /* CL:MX, SR:MX, LO:DS, LI:MX, MI:DS */ /* IOMISC */ 0x2102, /* HP amp on */ /* INSEL */ 0x0203, /* LI:LI, MI:FR */ /* VARIOUS */ 0x0041 /* stereo mic */ }; - unsigned short *pregs = def_regs; + const unsigned short *pregs = def_regs; int i; /* Gateway M675 notebook */ @@ -1361,7 +1361,7 @@ static int patch_cx20551(struct snd_ac97 *ac97) #ifdef CONFIG_PM static void ad18xx_resume(struct snd_ac97 *ac97) { - static unsigned short setup_regs[] = { + static const unsigned short setup_regs[] = { AC97_AD_MISC, AC97_AD_SERIAL_CFG, AC97_AD_JACK_SPDIF, }; int i, codec; @@ -1470,7 +1470,7 @@ static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, un static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits) { - static int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 }; + static const int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 }; unsigned short val; snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]); @@ -1794,7 +1794,7 @@ static const struct snd_kcontrol_new snd_ac97_ad1981x_jack_sense[] = { /* black list to avoid HP/Line jack-sense controls * (SS vendor << 16 | device) */ -static unsigned int ad1981_jacks_blacklist[] = { +static const unsigned int ad1981_jacks_blacklist[] = { 0x10140523, /* Thinkpad R40 */ 0x10140534, /* Thinkpad X31 */ 0x10140537, /* Thinkpad T41p */ @@ -1838,7 +1838,7 @@ static const struct snd_ac97_build_ops patch_ad1981a_build_ops = { /* white list to enable HP jack-sense bits * (SS vendor << 16 | device) */ -static unsigned int ad1981_jacks_whitelist[] = { +static const unsigned int ad1981_jacks_whitelist[] = { 0x0e11005a, /* HP nc4000/4010 */ 0x103c0890, /* HP nc6000 */ 0x103c0938, /* HP nc4220 */ @@ -3116,22 +3116,22 @@ static void cm9761_update_jacks(struct snd_ac97 *ac97) /* FIXME: check the bits for each model * model 83 is confirmed to work */ - static unsigned short surr_on[3][2] = { + static const unsigned short surr_on[3][2] = { { 0x0008, 0x0000 }, /* 9761-78 & 82 */ { 0x0000, 0x0008 }, /* 9761-82 rev.B */ { 0x0000, 0x0008 }, /* 9761-83 */ }; - static unsigned short clfe_on[3][2] = { + static const unsigned short clfe_on[3][2] = { { 0x0000, 0x1000 }, /* 9761-78 & 82 */ { 0x1000, 0x0000 }, /* 9761-82 rev.B */ { 0x0000, 0x1000 }, /* 9761-83 */ }; - static unsigned short surr_shared[3][2] = { + static const unsigned short surr_shared[3][2] = { { 0x0000, 0x0400 }, /* 9761-78 & 82 */ { 0x0000, 0x0400 }, /* 9761-82 rev.B */ { 0x0000, 0x0400 }, /* 9761-83 */ }; - static unsigned short clfe_shared[3][2] = { + static const unsigned short clfe_shared[3][2] = { { 0x2000, 0x0880 }, /* 9761-78 & 82 */ { 0x0000, 0x2880 }, /* 9761-82 rev.B */ { 0x2000, 0x0800 }, /* 9761-83 */ @@ -3635,7 +3635,7 @@ struct vt1618_uaj_item { /* This list reflects the vt1618 docs for Vendor Defined Register 0x60. */ -static struct vt1618_uaj_item vt1618_uaj[3] = { +static const struct vt1618_uaj_item vt1618_uaj[3] = { { /* speaker jack */ .mask = 0x03, diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c index 1c23a0f90559..491de1a623cb 100644 --- a/sound/pci/ac97/ac97_pcm.c +++ b/sound/pci/ac97/ac97_pcm.c @@ -26,7 +26,7 @@ * PCM support */ -static unsigned char rate_reg_tables[2][4][9] = { +static const unsigned char rate_reg_tables[2][4][9] = { { /* standard rates */ { @@ -129,7 +129,7 @@ static unsigned char rate_reg_tables[2][4][9] = { }}; /* FIXME: more various mappings for ADC? */ -static unsigned char rate_cregs[9] = { +static const unsigned char rate_cregs[9] = { AC97_PCM_LR_ADC_RATE, /* 3 */ AC97_PCM_LR_ADC_RATE, /* 4 */ 0xff, /* 5 */ -- cgit v1.2.3 From a01df925d1bbc97d6f7fe07b157aadb565315337 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:26 +0100 Subject: ALSA: usb-audio: More constifications Apply const prefix to the remaining places: the static table for the unit information, the mixer maps, the validator tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-12-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 60 +++++++++++++++++++++++----------------------- sound/usb/mixer_maps.c | 56 +++++++++++++++++++++---------------------- sound/usb/mixer_quirks.c | 6 ++--- sound/usb/mixer_scarlett.c | 14 +++++------ sound/usb/proc.c | 2 +- sound/usb/stream.c | 4 ++-- sound/usb/validate.c | 4 ++-- 7 files changed, 73 insertions(+), 73 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 6d9080b47d0f..d659fdb475e2 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1020,7 +1020,7 @@ struct usb_feature_control_info { int type_uac2; /* data type for uac2 if different from uac1, else -1 */ }; -static struct usb_feature_control_info audio_feature_info[] = { +static const struct usb_feature_control_info audio_feature_info[] = { { UAC_FU_MUTE, "Mute", USB_MIXER_INV_BOOLEAN, -1 }, { UAC_FU_VOLUME, "Volume", USB_MIXER_S16, -1 }, { UAC_FU_BASS, "Tone Control - Bass", USB_MIXER_S8, -1 }, @@ -1526,7 +1526,7 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, strlcpy(kctl->id.name, "Headphone", sizeof(kctl->id.name)); } -static struct usb_feature_control_info *get_feature_control_info(int control) +static const struct usb_feature_control_info *get_feature_control_info(int control) { int i; @@ -1544,7 +1544,7 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer, struct usb_audio_term *oterm, int unitid, int nameid, int readonly_mask) { - struct usb_feature_control_info *ctl_info; + const struct usb_feature_control_info *ctl_info; unsigned int len = 0; int mapped_name = 0; struct snd_kcontrol *kctl; @@ -2198,7 +2198,7 @@ static const struct snd_kcontrol_new mixer_procunit_ctl = { */ struct procunit_value_info { int control; - char *suffix; + const char *suffix; int val_type; int min_value; }; @@ -2206,44 +2206,44 @@ struct procunit_value_info { struct procunit_info { int type; char *name; - struct procunit_value_info *values; + const struct procunit_value_info *values; }; -static struct procunit_value_info undefined_proc_info[] = { +static const struct procunit_value_info undefined_proc_info[] = { { 0x00, "Control Undefined", 0 }, { 0 } }; -static struct procunit_value_info updown_proc_info[] = { +static const struct procunit_value_info updown_proc_info[] = { { UAC_UD_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 }, { 0 } }; -static struct procunit_value_info prologic_proc_info[] = { +static const struct procunit_value_info prologic_proc_info[] = { { UAC_DP_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_DP_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 }, { 0 } }; -static struct procunit_value_info threed_enh_proc_info[] = { +static const struct procunit_value_info threed_enh_proc_info[] = { { UAC_3D_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_3D_SPACE, "Spaciousness", USB_MIXER_U8 }, { 0 } }; -static struct procunit_value_info reverb_proc_info[] = { +static const struct procunit_value_info reverb_proc_info[] = { { UAC_REVERB_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_REVERB_LEVEL, "Level", USB_MIXER_U8 }, { UAC_REVERB_TIME, "Time", USB_MIXER_U16 }, { UAC_REVERB_FEEDBACK, "Feedback", USB_MIXER_U8 }, { 0 } }; -static struct procunit_value_info chorus_proc_info[] = { +static const struct procunit_value_info chorus_proc_info[] = { { UAC_CHORUS_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_CHORUS_LEVEL, "Level", USB_MIXER_U8 }, { UAC_CHORUS_RATE, "Rate", USB_MIXER_U16 }, { UAC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 }, { 0 } }; -static struct procunit_value_info dcr_proc_info[] = { +static const struct procunit_value_info dcr_proc_info[] = { { UAC_DCR_ENABLE, "Switch", USB_MIXER_BOOLEAN }, { UAC_DCR_RATE, "Ratio", USB_MIXER_U16 }, { UAC_DCR_MAXAMPL, "Max Amp", USB_MIXER_S16 }, @@ -2253,7 +2253,7 @@ static struct procunit_value_info dcr_proc_info[] = { { 0 } }; -static struct procunit_info procunits[] = { +static const struct procunit_info procunits[] = { { UAC_PROCESS_UP_DOWNMIX, "Up Down", updown_proc_info }, { UAC_PROCESS_DOLBY_PROLOGIC, "Dolby Prologic", prologic_proc_info }, { UAC_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", threed_enh_proc_info }, @@ -2263,16 +2263,16 @@ static struct procunit_info procunits[] = { { 0 }, }; -static struct procunit_value_info uac3_updown_proc_info[] = { +static const struct procunit_value_info uac3_updown_proc_info[] = { { UAC3_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 }, { 0 } }; -static struct procunit_value_info uac3_stereo_ext_proc_info[] = { +static const struct procunit_value_info uac3_stereo_ext_proc_info[] = { { UAC3_EXT_WIDTH_CONTROL, "Width Control", USB_MIXER_U8 }, { 0 } }; -static struct procunit_info uac3_procunits[] = { +static const struct procunit_info uac3_procunits[] = { { UAC3_PROCESS_UP_DOWNMIX, "Up Down", uac3_updown_proc_info }, { UAC3_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", uac3_stereo_ext_proc_info }, { UAC3_PROCESS_MULTI_FUNCTION, "Multi-Function", undefined_proc_info }, @@ -2282,23 +2282,23 @@ static struct procunit_info uac3_procunits[] = { /* * predefined data for extension units */ -static struct procunit_value_info clock_rate_xu_info[] = { +static const struct procunit_value_info clock_rate_xu_info[] = { { USB_XU_CLOCK_RATE_SELECTOR, "Selector", USB_MIXER_U8, 0 }, { 0 } }; -static struct procunit_value_info clock_source_xu_info[] = { +static const struct procunit_value_info clock_source_xu_info[] = { { USB_XU_CLOCK_SOURCE_SELECTOR, "External", USB_MIXER_BOOLEAN }, { 0 } }; -static struct procunit_value_info spdif_format_xu_info[] = { +static const struct procunit_value_info spdif_format_xu_info[] = { { USB_XU_DIGITAL_FORMAT_SELECTOR, "SPDIF/AC3", USB_MIXER_BOOLEAN }, { 0 } }; -static struct procunit_value_info soft_limit_xu_info[] = { +static const struct procunit_value_info soft_limit_xu_info[] = { { USB_XU_SOFT_LIMIT_SELECTOR, " ", USB_MIXER_BOOLEAN }, { 0 } }; -static struct procunit_info extunits[] = { +static const struct procunit_info extunits[] = { { USB_XU_CLOCK_RATE, "Clock rate", clock_rate_xu_info }, { USB_XU_CLOCK_SOURCE, "DigitalIn CLK source", clock_source_xu_info }, { USB_XU_DIGITAL_IO_STATUS, "DigitalOut format:", spdif_format_xu_info }, @@ -2310,7 +2310,7 @@ static struct procunit_info extunits[] = { * build a processing/extension unit */ static int build_audio_procunit(struct mixer_build *state, int unitid, - void *raw_desc, struct procunit_info *list, + void *raw_desc, const struct procunit_info *list, bool extension_unit) { struct uac_processing_unit_descriptor *desc = raw_desc; @@ -2318,14 +2318,14 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, struct usb_mixer_elem_info *cval; struct snd_kcontrol *kctl; int i, err, nameid, type, len; - struct procunit_info *info; - struct procunit_value_info *valinfo; + const struct procunit_info *info; + const struct procunit_value_info *valinfo; const struct usbmix_name_map *map; - static struct procunit_value_info default_value_info[] = { + static const struct procunit_value_info default_value_info[] = { { 0x01, "Switch", USB_MIXER_BOOLEAN }, { 0 } }; - static struct procunit_info default_info = { + static const struct procunit_info default_info = { 0, NULL, default_value_info }; const char *name = extension_unit ? @@ -2803,7 +2803,7 @@ struct uac3_badd_profile { int st_chmask; /* side tone mixing channel mask */ }; -static struct uac3_badd_profile uac3_badd_profiles[] = { +static const struct uac3_badd_profile uac3_badd_profiles[] = { { /* * BAIF, BAOF or combination of both @@ -2864,7 +2864,7 @@ static struct uac3_badd_profile uac3_badd_profiles[] = { }; static bool uac3_badd_func_has_valid_channels(struct usb_mixer_interface *mixer, - struct uac3_badd_profile *f, + const struct uac3_badd_profile *f, int c_chmask, int p_chmask) { /* @@ -2908,7 +2908,7 @@ static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer, struct usb_device *dev = mixer->chip->dev; struct usb_interface_assoc_descriptor *assoc; int badd_profile = mixer->chip->badd_profile; - struct uac3_badd_profile *f; + const struct uac3_badd_profile *f; const struct usbmix_ctl_map *map; int p_chmask = 0, c_chmask = 0, st_chmask = 0; int i; @@ -3174,7 +3174,7 @@ static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer, struct usb_mixer_elem_list *list) { struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list); - static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN", + static const char * const val_types[] = {"BOOLEAN", "INV_BOOLEAN", "S8", "U8", "S16", "U16"}; snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, " "channels=%i, type=\"%s\"\n", cval->head.id, diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index d094934ae6c5..5ebca8013840 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -14,7 +14,7 @@ struct usbmix_name_map { int id; const char *name; int control; - struct usbmix_dB_map *dB; + const struct usbmix_dB_map *dB; }; struct usbmix_selector_map { @@ -52,7 +52,7 @@ Mic-IN[9] --+->FU[10]----------------------------+ | ++--+->SU[11]-->FU[12] --------------------------------------------------------------------------------------> USB_OUT[13] */ -static struct usbmix_name_map extigy_map[] = { +static const struct usbmix_name_map extigy_map[] = { /* 1: IT pcm */ { 2, "PCM Playback" }, /* FU */ /* 3: IT pcm */ @@ -93,12 +93,12 @@ static struct usbmix_name_map extigy_map[] = { * e.g. no Master and fake PCM volume * Pavel Mihaylov */ -static struct usbmix_dB_map mp3plus_dB_1 = {.min = -4781, .max = 0}; +static const struct usbmix_dB_map mp3plus_dB_1 = {.min = -4781, .max = 0}; /* just guess */ -static struct usbmix_dB_map mp3plus_dB_2 = {.min = -1781, .max = 618}; +static const struct usbmix_dB_map mp3plus_dB_2 = {.min = -1781, .max = 618}; /* just guess */ -static struct usbmix_name_map mp3plus_map[] = { +static const struct usbmix_name_map mp3plus_map[] = { /* 1: IT pcm */ /* 2: IT mic */ /* 3: IT line */ @@ -139,7 +139,7 @@ Lin_IN[7]-+--->FU[8]---+ +->EU[23]->FU[28]------------->Spk_OUT[19] | ^ +->FU[13]--------------------------------------+ */ -static struct usbmix_name_map audigy2nx_map[] = { +static const struct usbmix_name_map audigy2nx_map[] = { /* 1: IT pcm playback */ /* 4: IT digital in */ { 6, "Digital In Playback" }, /* FU */ @@ -167,12 +167,12 @@ static struct usbmix_name_map audigy2nx_map[] = { { 0 } /* terminator */ }; -static struct usbmix_name_map mbox1_map[] = { +static const struct usbmix_name_map mbox1_map[] = { { 1, "Clock" }, { 0 } /* terminator */ }; -static struct usbmix_selector_map c400_selectors[] = { +static const struct usbmix_selector_map c400_selectors[] = { { .id = 0x80, .count = 2, @@ -181,7 +181,7 @@ static struct usbmix_selector_map c400_selectors[] = { { 0 } /* terminator */ }; -static struct usbmix_selector_map audigy2nx_selectors[] = { +static const struct usbmix_selector_map audigy2nx_selectors[] = { { .id = 14, /* Capture Source */ .count = 3, @@ -201,21 +201,21 @@ static struct usbmix_selector_map audigy2nx_selectors[] = { }; /* Creative SoundBlaster Live! 24-bit External */ -static struct usbmix_name_map live24ext_map[] = { +static const struct usbmix_name_map live24ext_map[] = { /* 2: PCM Playback Volume */ { 5, "Mic Capture" }, /* FU, default PCM Capture Volume */ { 0 } /* terminator */ }; /* LineX FM Transmitter entry - needed to bypass controls bug */ -static struct usbmix_name_map linex_map[] = { +static const struct usbmix_name_map linex_map[] = { /* 1: IT pcm */ /* 2: OT Speaker */ { 3, "Master" }, /* FU: master volume - left / right / mute */ { 0 } /* terminator */ }; -static struct usbmix_name_map maya44_map[] = { +static const struct usbmix_name_map maya44_map[] = { /* 1: IT line */ { 2, "Line Playback" }, /* FU */ /* 3: IT line */ @@ -238,7 +238,7 @@ static struct usbmix_name_map maya44_map[] = { * so this map removes all unwanted sliders from alsamixer */ -static struct usbmix_name_map justlink_map[] = { +static const struct usbmix_name_map justlink_map[] = { /* 1: IT pcm playback */ /* 2: Not present */ { 3, NULL}, /* IT mic (No mic input on device) */ @@ -255,7 +255,7 @@ static struct usbmix_name_map justlink_map[] = { }; /* TerraTec Aureon 5.1 MkII USB */ -static struct usbmix_name_map aureon_51_2_map[] = { +static const struct usbmix_name_map aureon_51_2_map[] = { /* 1: IT USB */ /* 2: IT Mic */ /* 3: IT Line */ @@ -274,7 +274,7 @@ static struct usbmix_name_map aureon_51_2_map[] = { {} /* terminator */ }; -static struct usbmix_name_map scratch_live_map[] = { +static const struct usbmix_name_map scratch_live_map[] = { /* 1: IT Line 1 (USB streaming) */ /* 2: OT Line 1 (Speaker) */ /* 3: IT Line 1 (Line connector) */ @@ -290,7 +290,7 @@ static struct usbmix_name_map scratch_live_map[] = { { 0 } /* terminator */ }; -static struct usbmix_name_map ebox44_map[] = { +static const struct usbmix_name_map ebox44_map[] = { { 4, NULL }, /* FU */ { 6, NULL }, /* MU */ { 7, NULL }, /* FU */ @@ -305,7 +305,7 @@ static struct usbmix_name_map ebox44_map[] = { * FIXME: or mp3plus_map should use "Capture Source" too, * so this maps can be merget */ -static struct usbmix_name_map hercules_usb51_map[] = { +static const struct usbmix_name_map hercules_usb51_map[] = { { 8, "Capture Source" }, /* SU, default "PCM Capture Source" */ { 9, "Master Playback" }, /* FU, default "Speaker Playback" */ { 10, "Mic Boost", 7 }, /* FU, default "Auto Gain Input" */ @@ -316,7 +316,7 @@ static struct usbmix_name_map hercules_usb51_map[] = { }; /* Plantronics Gamecom 780 has a broken volume control, better to disable it */ -static struct usbmix_name_map gamecom780_map[] = { +static const struct usbmix_name_map gamecom780_map[] = { { 9, NULL }, /* FU, speaker out */ {} }; @@ -330,8 +330,8 @@ static const struct usbmix_name_map scms_usb3318_map[] = { }; /* Bose companion 5, the dB conversion factor is 16 instead of 256 */ -static struct usbmix_dB_map bose_companion5_dB = {-5006, -6}; -static struct usbmix_name_map bose_companion5_map[] = { +static const struct usbmix_dB_map bose_companion5_dB = {-5006, -6}; +static const struct usbmix_name_map bose_companion5_map[] = { { 3, NULL, .dB = &bose_companion5_dB }, { 0 } /* terminator */ }; @@ -363,7 +363,7 @@ static const struct usbmix_name_map corsair_virtuoso_map[] = { * Control map entries */ -static struct usbmix_ctl_map usbmix_ctl_maps[] = { +static const struct usbmix_ctl_map usbmix_ctl_maps[] = { { .id = USB_ID(0x041e, 0x3000), .map = extigy_map, @@ -495,37 +495,37 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { * Control map entries for UAC3 BADD profiles */ -static struct usbmix_name_map uac3_badd_generic_io_map[] = { +static const struct usbmix_name_map uac3_badd_generic_io_map[] = { { UAC3_BADD_FU_ID2, "Generic Out Playback" }, { UAC3_BADD_FU_ID5, "Generic In Capture" }, { 0 } /* terminator */ }; -static struct usbmix_name_map uac3_badd_headphone_map[] = { +static const struct usbmix_name_map uac3_badd_headphone_map[] = { { UAC3_BADD_FU_ID2, "Headphone Playback" }, { 0 } /* terminator */ }; -static struct usbmix_name_map uac3_badd_speaker_map[] = { +static const struct usbmix_name_map uac3_badd_speaker_map[] = { { UAC3_BADD_FU_ID2, "Speaker Playback" }, { 0 } /* terminator */ }; -static struct usbmix_name_map uac3_badd_microphone_map[] = { +static const struct usbmix_name_map uac3_badd_microphone_map[] = { { UAC3_BADD_FU_ID5, "Mic Capture" }, { 0 } /* terminator */ }; /* Covers also 'headset adapter' profile */ -static struct usbmix_name_map uac3_badd_headset_map[] = { +static const struct usbmix_name_map uac3_badd_headset_map[] = { { UAC3_BADD_FU_ID2, "Headset Playback" }, { UAC3_BADD_FU_ID5, "Headset Capture" }, { UAC3_BADD_FU_ID7, "Sidetone Mixing" }, { 0 } /* terminator */ }; -static struct usbmix_name_map uac3_badd_speakerphone_map[] = { +static const struct usbmix_name_map uac3_badd_speakerphone_map[] = { { UAC3_BADD_FU_ID2, "Speaker Playback" }, { UAC3_BADD_FU_ID5, "Mic Capture" }, { 0 } /* terminator */ }; -static struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = { +static const struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = { { .id = UAC3_FUNCTION_SUBCLASS_GENERIC_IO, .map = uac3_badd_generic_io_map, diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 4cb8331d87a4..b9f5a9c18040 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -119,7 +119,7 @@ static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer, * Create a set of standard UAC controls from a table */ static int snd_create_std_mono_table(struct usb_mixer_interface *mixer, - struct std_mono_table *t) + const struct std_mono_table *t) { int err; @@ -1386,7 +1386,7 @@ static int snd_c400_create_mixer(struct usb_mixer_interface *mixer) * are valid they presents mono controls as L and R channels of * stereo. So we provide a good mixer here. */ -static struct std_mono_table ebox44_table[] = { +static const struct std_mono_table ebox44_table[] = { { .unitid = 4, .control = 1, @@ -1691,7 +1691,7 @@ static const struct snd_kcontrol_new snd_microii_mixer_spdif[] = { static int snd_microii_controls_create(struct usb_mixer_interface *mixer) { int err, i; - static usb_mixer_elem_resume_func_t resume_funcs[] = { + const static usb_mixer_elem_resume_func_t resume_funcs[] = { snd_microii_spdif_default_update, NULL, snd_microii_spdif_switch_update diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c index 9d10cbf1b5ed..49fcd2505443 100644 --- a/sound/usb/mixer_scarlett.c +++ b/sound/usb/mixer_scarlett.c @@ -633,7 +633,7 @@ static int add_output_ctls(struct usb_mixer_interface *mixer, /********************** device-specific config *************************/ /* untested... */ -static struct scarlett_device_info s6i6_info = { +static const struct scarlett_device_info s6i6_info = { .matrix_in = 18, .matrix_out = 8, .input_len = 6, @@ -675,7 +675,7 @@ static struct scarlett_device_info s6i6_info = { }; /* untested... */ -static struct scarlett_device_info s8i6_info = { +static const struct scarlett_device_info s8i6_info = { .matrix_in = 18, .matrix_out = 6, .input_len = 8, @@ -714,7 +714,7 @@ static struct scarlett_device_info s8i6_info = { } }; -static struct scarlett_device_info s18i6_info = { +static const struct scarlett_device_info s18i6_info = { .matrix_in = 18, .matrix_out = 6, .input_len = 18, @@ -751,7 +751,7 @@ static struct scarlett_device_info s18i6_info = { } }; -static struct scarlett_device_info s18i8_info = { +static const struct scarlett_device_info s18i8_info = { .matrix_in = 18, .matrix_out = 8, .input_len = 18, @@ -793,7 +793,7 @@ static struct scarlett_device_info s18i8_info = { } }; -static struct scarlett_device_info s18i20_info = { +static const struct scarlett_device_info s18i20_info = { .matrix_in = 18, .matrix_out = 8, .input_len = 18, @@ -843,7 +843,7 @@ static struct scarlett_device_info s18i20_info = { static int scarlett_controls_create_generic(struct usb_mixer_interface *mixer, - struct scarlett_device_info *info) + const struct scarlett_device_info *info) { int i, err; char mx[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; @@ -915,7 +915,7 @@ int snd_scarlett_controls_create(struct usb_mixer_interface *mixer) { int err, i, o; char mx[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; - struct scarlett_device_info *info; + const struct scarlett_device_info *info; struct usb_mixer_elem_info *elem; static char sample_rate_buffer[4] = { '\x80', '\xbb', '\x00', '\x00' }; diff --git a/sound/usb/proc.c b/sound/usb/proc.c index 49e3f176aaf5..ffbf4bd9208c 100644 --- a/sound/usb/proc.c +++ b/sound/usb/proc.c @@ -60,7 +60,7 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip) static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) { struct audioformat *fp; - static char *sync_types[4] = { + static const char * const sync_types[4] = { "NONE", "ASYNC", "ADAPTIVE", "SYNC" }; diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 11785f9652ad..afd5aa574611 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -239,7 +239,7 @@ static int add_chmap(struct snd_pcm *pcm, int stream, static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, int protocol) { - static unsigned int uac1_maps[] = { + static const unsigned int uac1_maps[] = { SNDRV_CHMAP_FL, /* left front */ SNDRV_CHMAP_FR, /* right front */ SNDRV_CHMAP_FC, /* center front */ @@ -254,7 +254,7 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, SNDRV_CHMAP_TC, /* top */ 0 /* terminator */ }; - static unsigned int uac2_maps[] = { + static const unsigned int uac2_maps[] = { SNDRV_CHMAP_FL, /* front left */ SNDRV_CHMAP_FR, /* front right */ SNDRV_CHMAP_FC, /* front center */ diff --git a/sound/usb/validate.c b/sound/usb/validate.c index 36ae78c3da3d..4034c2072415 100644 --- a/sound/usb/validate.c +++ b/sound/usb/validate.c @@ -233,7 +233,7 @@ static bool validate_midi_out_jack(const void *p, #define FIXED(p, t, s) { .protocol = (p), .type = (t), .size = sizeof(s) } #define FUNC(p, t, f) { .protocol = (p), .type = (t), .func = (f) } -static struct usb_desc_validator audio_validators[] = { +static const struct usb_desc_validator audio_validators[] = { /* UAC1 */ FUNC(UAC_VERSION_1, UAC_HEADER, validate_uac1_header), FIXED(UAC_VERSION_1, UAC_INPUT_TERMINAL, @@ -288,7 +288,7 @@ static struct usb_desc_validator audio_validators[] = { { } /* terminator */ }; -static struct usb_desc_validator midi_validators[] = { +static const struct usb_desc_validator midi_validators[] = { FIXED(UAC_VERSION_ALL, USB_MS_HEADER, struct usb_ms_header_descriptor), FIXED(UAC_VERSION_ALL, USB_MS_MIDI_IN_JACK, -- cgit v1.2.3 From 56d7058e124d5dfaf6579833a2e630ef90b149ca Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:27 +0100 Subject: ALSA: caiaq: More constifications Apply const prefix to each possible place: the rate table, the controller tables, and the key tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-13-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/caiaq/audio.c | 2 +- sound/usb/caiaq/control.c | 20 ++++++++++---------- sound/usb/caiaq/input.c | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 41993a5c0537..e9243d53a107 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -179,7 +179,7 @@ static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) #error "Change this table" #endif -static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, +static const unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 }; static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c index 532e354f6124..af459c49baf4 100644 --- a/sound/usb/caiaq/control.c +++ b/sound/usb/caiaq/control.c @@ -163,14 +163,14 @@ struct caiaq_controller { int index; }; -static struct caiaq_controller ak1_controller[] = { +static const struct caiaq_controller ak1_controller[] = { { "LED left", 2 }, { "LED middle", 1 }, { "LED right", 0 }, { "LED ring", 3 } }; -static struct caiaq_controller rk2_controller[] = { +static const struct caiaq_controller rk2_controller[] = { { "LED 1", 5 }, { "LED 2", 4 }, { "LED 3", 3 }, @@ -196,7 +196,7 @@ static struct caiaq_controller rk2_controller[] = { { "LED 7seg_3g", 23 } }; -static struct caiaq_controller rk3_controller[] = { +static const struct caiaq_controller rk3_controller[] = { { "LED 7seg_1a", 0 + 0 }, { "LED 7seg_1b", 0 + 1 }, { "LED 7seg_1c", 0 + 2 }, @@ -244,7 +244,7 @@ static struct caiaq_controller rk3_controller[] = { { "LED pedal", 32 + 8 } }; -static struct caiaq_controller kore_controller[] = { +static const struct caiaq_controller kore_controller[] = { { "LED F1", 8 | CNT_INTVAL }, { "LED F2", 12 | CNT_INTVAL }, { "LED F3", 0 | CNT_INTVAL }, @@ -278,7 +278,7 @@ static struct caiaq_controller kore_controller[] = { { "LED control", 26 | CNT_INTVAL } }; -static struct caiaq_controller a8dj_controller[] = { +static const struct caiaq_controller a8dj_controller[] = { { "Current input mode", 0 | CNT_INTVAL }, { "GND lift for TC Vinyl mode", 24 + 0 }, { "GND lift for TC CD/Line mode", 24 + 1 }, @@ -286,11 +286,11 @@ static struct caiaq_controller a8dj_controller[] = { { "Software lock", 40 } }; -static struct caiaq_controller a4dj_controller[] = { +static const struct caiaq_controller a4dj_controller[] = { { "Current input mode", 0 | CNT_INTVAL } }; -static struct caiaq_controller kontrolx1_controller[] = { +static const struct caiaq_controller kontrolx1_controller[] = { { "LED FX A: ON", 7 | CNT_INTVAL }, { "LED FX A: 1", 6 | CNT_INTVAL }, { "LED FX A: 2", 5 | CNT_INTVAL }, @@ -327,7 +327,7 @@ static struct caiaq_controller kontrolx1_controller[] = { { "LED Deck B: SYNC", 8 | CNT_INTVAL }, }; -static struct caiaq_controller kontrols4_controller[] = { +static const struct caiaq_controller kontrols4_controller[] = { { "LED: Master: Quant", 10 | CNT_INTVAL }, { "LED: Master: Headphone", 11 | CNT_INTVAL }, { "LED: Master: Master", 12 | CNT_INTVAL }, @@ -500,7 +500,7 @@ static struct caiaq_controller kontrols4_controller[] = { { "LED: FX2: Mode", 133 | CNT_INTVAL }, }; -static struct caiaq_controller maschine_controller[] = { +static const struct caiaq_controller maschine_controller[] = { { "LED: Pad 1", 3 | CNT_INTVAL }, { "LED: Pad 2", 2 | CNT_INTVAL }, { "LED: Pad 3", 1 | CNT_INTVAL }, @@ -568,7 +568,7 @@ static struct caiaq_controller maschine_controller[] = { { "Backlight Display", 59 | CNT_INTVAL } }; -static int add_controls(struct caiaq_controller *c, int num, +static int add_controls(const struct caiaq_controller *c, int num, struct snd_usb_caiaqdev *cdev) { int i, ret; diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c index 533eb69fe4e6..1e2cf2f08eec 100644 --- a/sound/usb/caiaq/input.c +++ b/sound/usb/caiaq/input.c @@ -14,13 +14,13 @@ #include "device.h" #include "input.h" -static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; -static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, +static const unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; +static const unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7 }; -static unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4, +static const unsigned short keycode_rk3[] = { KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9 }; -static unsigned short keycode_kore[] = { +static const unsigned short keycode_kore[] = { KEY_FN_F1, /* "menu" */ KEY_FN_F7, /* "lcd backlight */ KEY_FN_F2, /* "control" */ @@ -60,7 +60,7 @@ static unsigned short keycode_kore[] = { #define MASCHINE_PADS (16) #define MASCHINE_PAD(X) ((X) + ABS_PRESSURE) -static unsigned short keycode_maschine[] = { +static const unsigned short keycode_maschine[] = { MASCHINE_BUTTON(40), /* mute */ MASCHINE_BUTTON(39), /* solo */ MASCHINE_BUTTON(38), /* select */ -- cgit v1.2.3 From eafcdbdb4f4019cfd0ad1d0ff59225f73c95d185 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:28 +0100 Subject: ALSA: au88x0: More constifications Apply const prefix to each possible place: the static register tables, the coef tables, the string arrays, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-14-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_core.c | 2 +- sound/pci/au88x0/au88x0_eq.c | 22 +++++++++++----------- sound/pci/au88x0/au88x0_eqdata.c | 18 +++++++++--------- sound/pci/au88x0/au88x0_pcm.c | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index ce0564c5392a..f5512b72b3e0 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -1989,7 +1989,7 @@ vortex_connect_codecrec(vortex_t * vortex, int en, unsigned char mixin0, // Higher level ADB audio path (de)allocator. /* Resource manager */ -static int resnum[VORTEX_RESOURCE_LAST] = +static const int resnum[VORTEX_RESOURCE_LAST] = { NR_ADB, NR_SRC, NR_MIXIN, NR_MIXOUT, NR_A3D }; /* Checkout/Checkin resource of given type. diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c index abaf9f912784..58e92f2a72c0 100644 --- a/sound/pci/au88x0/au88x0_eq.c +++ b/sound/pci/au88x0/au88x0_eq.c @@ -51,7 +51,7 @@ static inline u16 sign_invert(u16 a) return -a; } -static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) +static void vortex_EqHw_SetLeftCoefs(vortex_t *vortex, const u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, n /*esp2c */; @@ -73,7 +73,7 @@ static void vortex_EqHw_SetLeftCoefs(vortex_t * vortex, u16 coefs[]) } } -static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[]) +static void vortex_EqHw_SetRightCoefs(vortex_t *vortex, const u16 coefs[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, n /*esp2c */; @@ -96,7 +96,7 @@ static void vortex_EqHw_SetRightCoefs(vortex_t * vortex, u16 coefs[]) } -static void vortex_EqHw_SetLeftStates(vortex_t * vortex, u16 a[], u16 b[]) +static void vortex_EqHw_SetLeftStates(vortex_t *vortex, const u16 a[], const u16 b[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx; @@ -113,7 +113,7 @@ static void vortex_EqHw_SetLeftStates(vortex_t * vortex, u16 a[], u16 b[]) } } -static void vortex_EqHw_SetRightStates(vortex_t * vortex, u16 a[], u16 b[]) +static void vortex_EqHw_SetRightStates(vortex_t *vortex, const u16 a[], const u16 b[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i = 0, ebx; @@ -206,7 +206,7 @@ vortex_EqHw_SetRightGainsSingleTarget(vortex_t * vortex, u16 index, u16 b) hwwrite(vortex->mmio, 0x2b20c + (index * 0x30), b); } -static void vortex_EqHw_SetLeftGainsTarget(vortex_t * vortex, u16 a[]) +static void vortex_EqHw_SetLeftGainsTarget(vortex_t *vortex, const u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; @@ -216,7 +216,7 @@ static void vortex_EqHw_SetLeftGainsTarget(vortex_t * vortex, u16 a[]) } } -static void vortex_EqHw_SetRightGainsTarget(vortex_t * vortex, u16 a[]) +static void vortex_EqHw_SetRightGainsTarget(vortex_t *vortex, const u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; @@ -226,7 +226,7 @@ static void vortex_EqHw_SetRightGainsTarget(vortex_t * vortex, u16 a[]) } } -static void vortex_EqHw_SetLeftGainsCurrent(vortex_t * vortex, u16 a[]) +static void vortex_EqHw_SetLeftGainsCurrent(vortex_t *vortex, const u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; @@ -236,7 +236,7 @@ static void vortex_EqHw_SetLeftGainsCurrent(vortex_t * vortex, u16 a[]) } } -static void vortex_EqHw_SetRightGainsCurrent(vortex_t * vortex, u16 a[]) +static void vortex_EqHw_SetRightGainsCurrent(vortex_t *vortex, const u16 a[]) { eqhw_t *eqhw = &(vortex->eq.this04); int ebx; @@ -309,7 +309,7 @@ static void vortex_EqHw_GetRightGainsCurrent(vortex_t * vortex, u16 a[]) #endif /* EQ band levels settings */ -static void vortex_EqHw_SetLevels(vortex_t * vortex, u16 peaks[]) +static void vortex_EqHw_SetLevels(vortex_t *vortex, const u16 peaks[]) { eqhw_t *eqhw = &(vortex->eq.this04); int i; @@ -574,7 +574,7 @@ static int vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex_t * vortex) } static int -vortex_Eqlzr_SetAllBands(vortex_t * vortex, u16 gains[], s32 count) +vortex_Eqlzr_SetAllBands(vortex_t *vortex, const u16 gains[], s32 count) { eqlzr_t *eq = &(vortex->eq); int i; @@ -852,7 +852,7 @@ static const struct snd_kcontrol_new vortex_levels_kcontrol = { }; /* EQ band gain labels. */ -static char *EqBandLabels[10] = { +static const char * const EqBandLabels[10] = { "EQ0 31Hz\0", "EQ1 63Hz\0", "EQ2 125Hz\0", diff --git a/sound/pci/au88x0/au88x0_eqdata.c b/sound/pci/au88x0/au88x0_eqdata.c index 49a52d298b1a..a74f266f0bd0 100644 --- a/sound/pci/au88x0/au88x0_eqdata.c +++ b/sound/pci/au88x0/au88x0_eqdata.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Data structs */ -static u16 asEqCoefsZeros[50] = { +static const u16 asEqCoefsZeros[50] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -14,7 +14,7 @@ static u16 asEqCoefsZeros[50] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; -static u16 asEqCoefsPipes[64] = { +static const u16 asEqCoefsPipes[64] = { 0x0000, 0x0000, 0x0000, 0x0666, 0x0000, 0x0000, 0x0666, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -33,7 +33,7 @@ static u16 asEqCoefsPipes[64] = { }; /* More coef sets can be found in the win2k "inf" file. */ -static auxxEqCoeffSet_t asEqCoefsNormal = { +static const auxxEqCoeffSet_t asEqCoefsNormal = { .LeftCoefs = { 0x7e60, 0xc19e, 0x0001, 0x0002, 0x0001, 0x7fa0, 0xc05f, 0x004f, 0x0000, 0xffb1, @@ -66,7 +66,7 @@ static auxxEqCoeffSet_t asEqCoefsNormal = { 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96} }; -static u16 eq_gains_normal[20] = { +static const u16 eq_gains_normal[20] = { 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96, @@ -74,22 +74,22 @@ static u16 eq_gains_normal[20] = { }; /* _rodatab60 */ -static u16 eq_gains_zero[10] = { +static const u16 eq_gains_zero[10] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; /* _rodatab7c: ProgramPipe */ -static u16 eq_gains_current[12] = { +static const u16 eq_gains_current[12] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff }; /* _rodatab78 */ -static u16 eq_states_zero[2] = { 0x0000, 0x0000 }; +static const u16 eq_states_zero[2] = { 0x0000, 0x0000 }; -static u16 asEqOutStateZeros[48] = { +static const u16 asEqOutStateZeros[48] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -105,7 +105,7 @@ static u16 asEqOutStateZeros[48] = { }; /*_rodataba0:*/ -static u16 eq_levels[64] = { +static const u16 eq_levels[64] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 2cdb7845f651..d019aa566de3 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -433,14 +433,14 @@ static const struct snd_pcm_ops snd_vortex_playback_ops = { * definitions of capture are omitted here... */ -static char *vortex_pcm_prettyname[VORTEX_PCM_LAST] = { +static const char * const vortex_pcm_prettyname[VORTEX_PCM_LAST] = { CARD_NAME " ADB", CARD_NAME " SPDIF", CARD_NAME " A3D", CARD_NAME " WT", CARD_NAME " I2S", }; -static char *vortex_pcm_name[VORTEX_PCM_LAST] = { +static const char * const vortex_pcm_name[VORTEX_PCM_LAST] = { "adb", "spdif", "a3d", -- cgit v1.2.3 From 6fddce26f84c8229db1f6689b6046aa3dff5c887 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:29 +0100 Subject: ALSA: emu10k1: More constifications Apply const prefix to the remaining possible places: the static tables for init verbs and registers, the string arrays, the conversion tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-15-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1_main.c | 12 ++++++------ sound/pci/emu10k1/emufx.c | 14 +++++++------- sound/pci/emu10k1/emumixer.c | 28 ++++++++++++++-------------- sound/pci/emu10k1/emuproc.c | 16 ++++++++-------- sound/pci/emu10k1/io.c | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 51af766f57d2..a89a7e603ca8 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -100,7 +100,7 @@ void snd_emu10k1_voice_init(struct snd_emu10k1 *emu, int ch) } } -static unsigned int spi_dac_init[] = { +static const unsigned int spi_dac_init[] = { 0x00ff, 0x02ff, 0x0400, @@ -124,7 +124,7 @@ static unsigned int spi_dac_init[] = { 0x1400, }; -static unsigned int i2c_adc_init[][2] = { +static const unsigned int i2c_adc_init[][2] = { { 0x17, 0x00 }, /* Reset */ { 0x07, 0x00 }, /* Timeout */ { 0x0b, 0x22 }, /* Interface control */ @@ -2050,7 +2050,7 @@ int snd_emu10k1_create(struct snd_card *card, } #ifdef CONFIG_PM_SLEEP -static unsigned char saved_regs[] = { +static const unsigned char saved_regs[] = { CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, ATKHLDM, DCYSUSM, LFOVAL2, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2, @@ -2059,7 +2059,7 @@ static unsigned char saved_regs[] = { SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX, 0xff /* end */ }; -static unsigned char saved_regs_audigy[] = { +static const unsigned char saved_regs_audigy[] = { A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, A_FXRT2, A_SENDAMOUNTS, A_FXRT1, 0xff /* end */ @@ -2094,7 +2094,7 @@ static void free_pm_buffer(struct snd_emu10k1 *emu) void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu) { int i; - unsigned char *reg; + const unsigned char *reg; unsigned int *val; val = emu->saved_ptr; @@ -2127,7 +2127,7 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu) { int i; - unsigned char *reg; + const unsigned char *reg; unsigned int *val; snd_emu10k1_audio_enable(emu); diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index e0e076a9c321..6b7ff4a94800 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -46,7 +46,7 @@ MODULE_PARM_DESC(high_res_gpr_volume, "GPR mixer controls use 31-bit range."); * Tables */ -static char *fxbuses[16] = { +static const char * const fxbuses[16] = { /* 0x00 */ "PCM Left", /* 0x01 */ "PCM Right", /* 0x02 */ "PCM Surround Left", @@ -65,7 +65,7 @@ static char *fxbuses[16] = { /* 0x0f */ NULL }; -static char *creative_ins[16] = { +static const char * const creative_ins[16] = { /* 0x00 */ "AC97 Left", /* 0x01 */ "AC97 Right", /* 0x02 */ "TTL IEC958 Left", @@ -84,7 +84,7 @@ static char *creative_ins[16] = { /* 0x0f */ NULL }; -static char *audigy_ins[16] = { +static const char * const audigy_ins[16] = { /* 0x00 */ "AC97 Left", /* 0x01 */ "AC97 Right", /* 0x02 */ "Audigy CD Left", @@ -103,7 +103,7 @@ static char *audigy_ins[16] = { /* 0x0f */ NULL }; -static char *creative_outs[32] = { +static const char * const creative_outs[32] = { /* 0x00 */ "AC97 Left", /* 0x01 */ "AC97 Right", /* 0x02 */ "Optical IEC958 Left", @@ -138,7 +138,7 @@ static char *creative_outs[32] = { /* 0x1f */ NULL, }; -static char *audigy_outs[32] = { +static const char * const audigy_outs[32] = { /* 0x00 */ "Digital Front Left", /* 0x01 */ "Digital Front Right", /* 0x02 */ "Digital Center", @@ -2485,7 +2485,7 @@ static int snd_emu10k1_fx8010_open(struct snd_hwdep * hw, struct file *file) return 0; } -static void copy_string(char *dst, char *src, char *null, int idx) +static void copy_string(char *dst, const char *src, const char *null, int idx) { if (src == NULL) sprintf(dst, "%s %02X", null, idx); @@ -2496,7 +2496,7 @@ static void copy_string(char *dst, char *src, char *null, int idx) static void snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, struct snd_emu10k1_fx8010_info *info) { - char **fxbus, **extin, **extout; + const char * const *fxbus, * const *extin, * const *extout; unsigned short fxbus_mask, extin_mask, extout_mask; int res; diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 46c79dfe9844..8a6cbe67e29d 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -183,7 +183,7 @@ static const char * const emu1616_src_texts[] = { /* * List of data sources available for each destination */ -static unsigned int emu1010_src_regs[] = { +static const unsigned int emu1010_src_regs[] = { EMU_SRC_SILENCE,/* 0 */ EMU_SRC_DOCK_MIC_A1, /* 1 */ EMU_SRC_DOCK_MIC_B1, /* 2 */ @@ -240,7 +240,7 @@ static unsigned int emu1010_src_regs[] = { }; /* 1616(m) cardbus */ -static unsigned int emu1616_src_regs[] = { +static const unsigned int emu1616_src_regs[] = { EMU_SRC_SILENCE, EMU_SRC_DOCK_MIC_A1, EMU_SRC_DOCK_MIC_B1, @@ -296,7 +296,7 @@ static unsigned int emu1616_src_regs[] = { * Data destinations - physical EMU outputs. * Each destination has an enum mixer control to choose a data source */ -static unsigned int emu1010_output_dst[] = { +static const unsigned int emu1010_output_dst[] = { EMU_DST_DOCK_DAC1_LEFT1, /* 0 */ EMU_DST_DOCK_DAC1_RIGHT1, /* 1 */ EMU_DST_DOCK_DAC2_LEFT1, /* 2 */ @@ -324,7 +324,7 @@ static unsigned int emu1010_output_dst[] = { }; /* 1616(m) cardbus */ -static unsigned int emu1616_output_dst[] = { +static const unsigned int emu1616_output_dst[] = { EMU_DST_DOCK_DAC1_LEFT1, EMU_DST_DOCK_DAC1_RIGHT1, EMU_DST_DOCK_DAC2_LEFT1, @@ -350,7 +350,7 @@ static unsigned int emu1616_output_dst[] = { * capture (EMU32 + I2S links) * Each destination has an enum mixer control to choose a data source */ -static unsigned int emu1010_input_dst[] = { +static const unsigned int emu1010_input_dst[] = { EMU_DST_ALICE2_EMU32_0, EMU_DST_ALICE2_EMU32_1, EMU_DST_ALICE2_EMU32_2, @@ -1778,8 +1778,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, int err, pcm; struct snd_kcontrol *kctl; struct snd_card *card = emu->card; - char **c; - static char *emu10k1_remove_ctls[] = { + const char * const *c; + static const char * const emu10k1_remove_ctls[] = { /* no AC97 mono, surround, center/lfe */ "Master Mono Playback Switch", "Master Mono Playback Volume", @@ -1793,13 +1793,13 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "LFE Playback Volume", NULL }; - static char *emu10k1_rename_ctls[] = { + static const char * const emu10k1_rename_ctls[] = { "Surround Digital Playback Volume", "Surround Playback Volume", "Center Digital Playback Volume", "Center Playback Volume", "LFE Digital Playback Volume", "LFE Playback Volume", NULL }; - static char *audigy_remove_ctls[] = { + static const char * const audigy_remove_ctls[] = { /* Master/PCM controls on ac97 of Audigy has no effect */ /* On the Audigy2 the AC97 playback is piped into * the Philips ADC for 24bit capture */ @@ -1826,7 +1826,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "External Amplifier", NULL }; - static char *audigy_rename_ctls[] = { + static const char * const audigy_rename_ctls[] = { /* use conventional names */ "Wave Playback Volume", "PCM Playback Volume", /* "Wave Capture Volume", "PCM Capture Volume", */ @@ -1836,7 +1836,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "Master Mono Playback Volume", "Phone Output Playback Volume", NULL }; - static char *audigy_rename_ctls_i2c_adc[] = { + static const char * const audigy_rename_ctls_i2c_adc[] = { //"Analog Mix Capture Volume","OLD Analog Mix Capture Volume", "Line Capture Volume", "Analog Mix Capture Volume", "Wave Playback Volume", "OLD PCM Playback Volume", @@ -1845,7 +1845,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "CD Capture Volume", "IEC958 Optical Capture Volume", NULL }; - static char *audigy_remove_ctls_i2c_adc[] = { + static const char * const audigy_remove_ctls_i2c_adc[] = { /* On the Audigy2 ZS Notebook * Capture via WM8775 */ "Mic Capture Volume", @@ -1854,7 +1854,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "IEC958 Optical Capture Volume", NULL }; - static char *audigy_remove_ctls_1361t_adc[] = { + static const char * const audigy_remove_ctls_1361t_adc[] = { /* On the Audigy2 the AC97 playback is piped into * the Philips ADC for 24bit capture */ "PCM Playback Switch", @@ -1872,7 +1872,7 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, "Line2 Capture Volume", NULL }; - static char *audigy_rename_ctls_1361t_adc[] = { + static const char * const audigy_rename_ctls_1361t_adc[] = { "Master Playback Switch", "Master Capture Switch", "Master Playback Volume", "Master Capture Volume", "Wave Master Playback Volume", "Master Playback Volume", diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index 637446f19598..6e20cca9c98f 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -26,10 +26,10 @@ static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, int status_reg, int rate_reg) { - static char *clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" }; - static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - static char *channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; - static char *emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" }; + static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" }; + static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; + static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" }; unsigned int status, rate = 0; status = snd_emu10k1_ptr_read(emu, status_reg, 0); @@ -67,7 +67,7 @@ static void snd_emu10k1_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { /* FIXME - output names are in emufx.c too */ - static char *creative_outs[32] = { + static const char * const creative_outs[32] = { /* 00 */ "AC97 Left", /* 01 */ "AC97 Right", /* 02 */ "Optical IEC958 Left", @@ -102,7 +102,7 @@ static void snd_emu10k1_proc_read(struct snd_info_entry *entry, /* 31 */ "???" }; - static char *audigy_outs[64] = { + static const char * const audigy_outs[64] = { /* 00 */ "Digital Front Left", /* 01 */ "Digital Front Right", /* 02 */ "Digital Center", @@ -172,7 +172,7 @@ static void snd_emu10k1_proc_read(struct snd_info_entry *entry, struct snd_emu10k1 *emu = entry->private_data; unsigned int val, val1; int nefx = emu->audigy ? 64 : 32; - char **outputs = emu->audigy ? audigy_outs : creative_outs; + const char * const *outputs = emu->audigy ? audigy_outs : creative_outs; int idx; snd_iprintf(buffer, "EMU10K1\n\n"); @@ -262,7 +262,7 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; + static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; struct snd_emu10k1 *emu = entry->private_data; unsigned int val, tmp, n; val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index a3f1de7e5fee..e15092ce9848 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -510,7 +510,7 @@ void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate) { - static u32 logMagTable[128] = { + static const u32 logMagTable[128] = { 0x00000, 0x02dfc, 0x05b9e, 0x088e6, 0x0b5d6, 0x0e26f, 0x10eb3, 0x13aa2, 0x1663f, 0x1918a, 0x1bc84, 0x1e72e, 0x2118b, 0x23b9a, 0x2655d, 0x28ed5, 0x2b803, 0x2e0e8, 0x30985, 0x331db, 0x359eb, 0x381b6, 0x3a93d, 0x3d081, @@ -528,7 +528,7 @@ unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate) 0xe829f, 0xe9b31, 0xeb3a9, 0xecc08, 0xee44c, 0xefc78, 0xf148a, 0xf2c83, 0xf4463, 0xf5c2a, 0xf73da, 0xf8b71, 0xfa2f0, 0xfba57, 0xfd1a7, 0xfe8df }; - static char logSlopeTable[128] = { + static const char logSlopeTable[128] = { 0x5c, 0x5c, 0x5b, 0x5a, 0x5a, 0x59, 0x58, 0x58, 0x57, 0x56, 0x56, 0x55, 0x55, 0x54, 0x53, 0x53, 0x52, 0x52, 0x51, 0x51, 0x50, 0x50, 0x4f, 0x4f, -- cgit v1.2.3 From bf6f3d74c9594c3a684620d3d7418a73ee659288 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:30 +0100 Subject: ALSA: riptide: More constifications Apply const prefix to each lbus path table definition and its callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-16-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 60 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 625c85428955..b4f300281822 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -361,9 +361,9 @@ enum RT_CHANNEL_IDS { enum { SB_CMD = 0, MODEM_CMD, I2S_CMD0, I2S_CMD1, FM_CMD, MAX_CMD }; struct lbuspath { - unsigned char *noconv; - unsigned char *stereo; - unsigned char *mono; + const unsigned char *noconv; + const unsigned char *stereo; + const unsigned char *mono; }; struct cmdport { @@ -464,7 +464,7 @@ struct sgd { /* scatter gather desriptor */ struct pcmhw { /* pcm descriptor */ struct lbuspath paths; - unsigned char *lbuspath; + const unsigned char *lbuspath; unsigned char source; unsigned char intdec[2]; unsigned char mixer; @@ -517,7 +517,7 @@ MODULE_DEVICE_TABLE(pci, snd_riptide_ids); /* */ -static unsigned char lbusin2out[E2SINK_MAX + 1][2] = { +static const unsigned char lbusin2out[E2SINK_MAX + 1][2] = { {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT, @@ -557,63 +557,63 @@ static unsigned char lbusin2out[E2SINK_MAX + 1][2] = { LS_NONE2}, }; -static unsigned char lbus_play_opl3[] = { +static const unsigned char lbus_play_opl3[] = { DIGITAL_MIXER_IN0 + FM_MIXER, 0xff }; -static unsigned char lbus_play_modem[] = { +static const unsigned char lbus_play_modem[] = { DIGITAL_MIXER_IN0 + MODEM_MIXER, 0xff }; -static unsigned char lbus_play_i2s[] = { +static const unsigned char lbus_play_i2s[] = { INTER0_IN + I2S_INTDEC, DIGITAL_MIXER_IN0 + I2S_MIXER, 0xff }; -static unsigned char lbus_play_out[] = { +static const unsigned char lbus_play_out[] = { PDAC2ACLNK, 0xff }; -static unsigned char lbus_play_outhp[] = { +static const unsigned char lbus_play_outhp[] = { HNDSPK2ACLNK, 0xff }; -static unsigned char lbus_play_noconv1[] = { +static const unsigned char lbus_play_noconv1[] = { DIGITAL_MIXER_IN0, 0xff }; -static unsigned char lbus_play_stereo1[] = { +static const unsigned char lbus_play_stereo1[] = { INTER0_IN, DIGITAL_MIXER_IN0, 0xff }; -static unsigned char lbus_play_mono1[] = { +static const unsigned char lbus_play_mono1[] = { INTERM0_IN, DIGITAL_MIXER_IN0, 0xff }; -static unsigned char lbus_play_noconv2[] = { +static const unsigned char lbus_play_noconv2[] = { DIGITAL_MIXER_IN1, 0xff }; -static unsigned char lbus_play_stereo2[] = { +static const unsigned char lbus_play_stereo2[] = { INTER1_IN, DIGITAL_MIXER_IN1, 0xff }; -static unsigned char lbus_play_mono2[] = { +static const unsigned char lbus_play_mono2[] = { INTERM1_IN, DIGITAL_MIXER_IN1, 0xff }; -static unsigned char lbus_play_noconv3[] = { +static const unsigned char lbus_play_noconv3[] = { DIGITAL_MIXER_IN2, 0xff }; -static unsigned char lbus_play_stereo3[] = { +static const unsigned char lbus_play_stereo3[] = { INTER2_IN, DIGITAL_MIXER_IN2, 0xff }; -static unsigned char lbus_play_mono3[] = { +static const unsigned char lbus_play_mono3[] = { INTERM2_IN, DIGITAL_MIXER_IN2, 0xff }; -static unsigned char lbus_rec_noconv1[] = { +static const unsigned char lbus_rec_noconv1[] = { LBUS2ARM_FIFO5, 0xff }; -static unsigned char lbus_rec_stereo1[] = { +static const unsigned char lbus_rec_stereo1[] = { DECIM0_IN, LBUS2ARM_FIFO5, 0xff }; -static unsigned char lbus_rec_mono1[] = { +static const unsigned char lbus_rec_mono1[] = { DECIMM3_IN, LBUS2ARM_FIFO5, 0xff }; -static unsigned char play_ids[] = { 4, 1, 2, }; -static unsigned char play_sources[] = { +static const unsigned char play_ids[] = { 4, 1, 2, }; +static const unsigned char play_sources[] = { ARM2LBUS_FIFO4, ARM2LBUS_FIFO1, ARM2LBUS_FIFO2, }; -static struct lbuspath lbus_play_paths[] = { +static const struct lbuspath lbus_play_paths[] = { { .noconv = lbus_play_noconv1, .stereo = lbus_play_stereo1, @@ -737,7 +737,7 @@ static int loadfirmware(struct cmdif *cif, const unsigned char *img, static void alloclbuspath(struct cmdif *cif, unsigned char source, - unsigned char *path, unsigned char *mixer, unsigned char *s) + const unsigned char *path, unsigned char *mixer, unsigned char *s) { while (*path != 0xff) { unsigned char sink, type; @@ -765,7 +765,7 @@ alloclbuspath(struct cmdif *cif, unsigned char source, } } if (*path++ & SPLIT_PATH) { - unsigned char *npath = path; + const unsigned char *npath = path; while (*npath != 0xff) npath++; @@ -775,7 +775,7 @@ alloclbuspath(struct cmdif *cif, unsigned char source, } static void -freelbuspath(struct cmdif *cif, unsigned char source, unsigned char *path) +freelbuspath(struct cmdif *cif, unsigned char source, const unsigned char *path) { while (*path != 0xff) { unsigned char sink; @@ -787,7 +787,7 @@ freelbuspath(struct cmdif *cif, unsigned char source, unsigned char *path) source = lbusin2out[sink][0]; } if (*path++ & SPLIT_PATH) { - unsigned char *npath = path; + const unsigned char *npath = path; while (*npath != 0xff) npath++; @@ -1441,7 +1441,7 @@ static int snd_riptide_prepare(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct pcmhw *data = get_pcmhwdev(substream); struct cmdif *cif = chip->cif; - unsigned char *lbuspath = NULL; + const unsigned char *lbuspath = NULL; unsigned int rate, channels; int err = 0; snd_pcm_format_t format; -- cgit v1.2.3 From f16a4e960ab3475d71df6f0d968c5393f3eca2aa Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:31 +0100 Subject: ALSA: ice1712: More constifications Apply const prefix to each possible place: the EEPROM tables, the static string arrays, the init verb tables, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-17-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ice1712/aureon.c | 8 ++++---- sound/pci/ice1712/juli.c | 6 +++--- sound/pci/ice1712/maya44.c | 10 +++++----- sound/pci/ice1712/phase.c | 4 ++-- sound/pci/ice1712/pontis.c | 2 +- sound/pci/ice1712/prodigy192.c | 2 +- sound/pci/ice1712/prodigy_hifi.c | 16 ++++++++-------- sound/pci/ice1712/psc724.c | 2 +- sound/pci/ice1712/quartet.c | 8 ++++---- sound/pci/ice1712/se.c | 8 ++++---- sound/pci/ice1712/vt1720_mobo.c | 4 ++-- sound/pci/ice1712/wtm.c | 6 +++--- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 025fe7820620..9a30f6d35d13 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -2133,7 +2133,7 @@ static int aureon_init(struct snd_ice1712 *ice) * hence the driver needs to sets up it properly. */ -static unsigned char aureon51_eeprom[] = { +static const unsigned char aureon51_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ @@ -2149,7 +2149,7 @@ static unsigned char aureon51_eeprom[] = { [ICE_EEP2_GPIO_STATE2] = 0x00, }; -static unsigned char aureon71_eeprom[] = { +static const unsigned char aureon71_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ @@ -2166,7 +2166,7 @@ static unsigned char aureon71_eeprom[] = { }; #define prodigy71_eeprom aureon71_eeprom -static unsigned char aureon71_universe_eeprom[] = { +static const unsigned char aureon71_universe_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC, * 4DACs */ @@ -2184,7 +2184,7 @@ static unsigned char aureon71_universe_eeprom[] = { [ICE_EEP2_GPIO_STATE2] = 0x00, }; -static unsigned char prodigy71lt_eeprom[] = { +static const unsigned char prodigy71lt_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 079e58ec8b09..7be4eb42f05e 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -397,7 +397,7 @@ static const struct snd_kcontrol_new juli_mute_controls[] = { }, }; -static char *slave_vols[] = { +static const char * const slave_vols[] = { PCM_VOLUME, MONITOR_AN_IN_VOLUME, MONITOR_DIG_IN_VOLUME, @@ -420,7 +420,7 @@ static struct snd_kcontrol *ctl_find(struct snd_card *card, static void add_slaves(struct snd_card *card, struct snd_kcontrol *master, - char * const *list) + const char * const *list) { for (; *list; list++) { struct snd_kcontrol *slave = ctl_find(card, *list); @@ -651,7 +651,7 @@ static int juli_init(struct snd_ice1712 *ice) * hence the driver needs to sets up it properly. */ -static unsigned char juli_eeprom[] = { +static const unsigned char juli_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, 1xADC, 1xDACs, SPDIF in */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ diff --git a/sound/pci/ice1712/maya44.c b/sound/pci/ice1712/maya44.c index c2761e009c67..b46df1821251 100644 --- a/sound/pci/ice1712/maya44.c +++ b/sound/pci/ice1712/maya44.c @@ -116,7 +116,7 @@ struct maya_vol_info { unsigned char mux_bits[2]; /* extra bits for ADC mute */ }; -static struct maya_vol_info vol_info[WM_NUM_VOLS] = { +static const struct maya_vol_info vol_info[WM_NUM_VOLS] = { [WM_VOL_HP] = { .maxval = 80, .regs = { WM8776_REG_HEADPHONE_L, WM8776_REG_HEADPHONE_R }, @@ -158,7 +158,7 @@ static int maya_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { unsigned int idx = kcontrol->private_value; - struct maya_vol_info *vol = &vol_info[idx]; + const struct maya_vol_info *vol = &vol_info[idx]; uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -189,7 +189,7 @@ static int maya_vol_put(struct snd_kcontrol *kcontrol, struct snd_wm8776 *wm = &chip->wm[snd_ctl_get_ioff(kcontrol, &ucontrol->id)]; unsigned int idx = kcontrol->private_value; - struct maya_vol_info *vol = &vol_info[idx]; + const struct maya_vol_info *vol = &vol_info[idx]; unsigned int val, data; int ch, changed = 0; @@ -662,7 +662,7 @@ static const struct snd_pcm_hw_constraint_list dac_rates = { /* * chip addresses on I2C bus */ -static unsigned char wm8776_addr[2] = { +static const unsigned char wm8776_addr[2] = { 0x34, 0x36, /* codec 0 & 1 */ }; @@ -712,7 +712,7 @@ static int maya44_init(struct snd_ice1712 *ice) * hence the driver needs to sets up it properly. */ -static unsigned char maya44_eeprom[] = { +static const unsigned char maya44_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x45, /* clock xin1=49.152MHz, mpu401, 2 stereo ADCs+DACs */ [ICE_EEP2_ACLINK] = 0x80, diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index ced4a2bfd08e..1e47e46ab8ac 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -157,7 +157,7 @@ static int phase22_add_controls(struct snd_ice1712 *ice) return 0; } -static unsigned char phase22_eeprom[] = { +static const unsigned char phase22_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x28, /* clock 512, mpu 401, spdif-in/1xADC, 1xDACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ @@ -174,7 +174,7 @@ static unsigned char phase22_eeprom[] = { [ICE_EEP2_GPIO_STATE2] = 0x00, }; -static unsigned char phase28_eeprom[] = { +static const unsigned char phase28_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/1xADC, 4xDACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c index 8ddb6c35a5e6..683909ca147c 100644 --- a/sound/pci/ice1712/pontis.c +++ b/sound/pci/ice1712/pontis.c @@ -778,7 +778,7 @@ static int pontis_init(struct snd_ice1712 *ice) * hence the driver needs to sets up it properly. */ -static unsigned char pontis_eeprom[] = { +static const unsigned char pontis_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c index 105716961e39..8df14f63b10d 100644 --- a/sound/pci/ice1712/prodigy192.c +++ b/sound/pci/ice1712/prodigy192.c @@ -753,7 +753,7 @@ static int prodigy192_init(struct snd_ice1712 *ice) * hence the driver needs to sets up it properly. */ -static unsigned char prodigy71_eeprom[] = { +static const unsigned char prodigy71_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x6a, /* 49MHz crystal, mpu401, * spdif-in+ 1 stereo ADC, * 3 stereo DACs diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index ba37f7eab166..91f83cef0e56 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c @@ -930,7 +930,7 @@ static int prodigy_hd2_add_controls(struct snd_ice1712 *ice) static void wm8766_init(struct snd_ice1712 *ice) { - static unsigned short wm8766_inits[] = { + static const unsigned short wm8766_inits[] = { WM8766_RESET, 0x0000, WM8766_DAC_CTRL, 0x0120, WM8766_INT_CTRL, 0x0022, /* I2S Normal Mode, 24 bit */ @@ -953,7 +953,7 @@ static void wm8766_init(struct snd_ice1712 *ice) static void wm8776_init(struct snd_ice1712 *ice) { - static unsigned short wm8776_inits[] = { + static const unsigned short wm8776_inits[] = { /* These come first to reduce init pop noise */ WM_ADC_MUX, 0x0003, /* ADC mute */ /* 0x00c0 replaced by 0x0003 */ @@ -973,7 +973,7 @@ static void wm8776_init(struct snd_ice1712 *ice) #ifdef CONFIG_PM_SLEEP static int prodigy_hifi_resume(struct snd_ice1712 *ice) { - static unsigned short wm8776_reinit_registers[] = { + static const unsigned short wm8776_reinit_registers[] = { WM_MASTER_CTRL, WM_DAC_INT, WM_ADC_INT, @@ -1033,7 +1033,7 @@ static int prodigy_hifi_resume(struct snd_ice1712 *ice) */ static int prodigy_hifi_init(struct snd_ice1712 *ice) { - static unsigned short wm8776_defaults[] = { + static const unsigned short wm8776_defaults[] = { WM_MASTER_CTRL, 0x0022, /* 256fs, slave mode */ WM_DAC_INT, 0x0022, /* I2S, normal polarity, 24bit */ WM_ADC_INT, 0x0022, /* I2S, normal polarity, 24bit */ @@ -1108,7 +1108,7 @@ static int prodigy_hifi_init(struct snd_ice1712 *ice) */ static void ak4396_init(struct snd_ice1712 *ice) { - static unsigned short ak4396_inits[] = { + static const unsigned short ak4396_inits[] = { AK4396_CTRL1, 0x87, /* I2S Normal Mode, 24 bit */ AK4396_CTRL2, 0x02, AK4396_CTRL3, 0x00, @@ -1180,7 +1180,7 @@ static int prodigy_hd2_init(struct snd_ice1712 *ice) } -static unsigned char prodigy71hifi_eeprom[] = { +static const unsigned char prodigy71hifi_eeprom[] = { 0x4b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */ 0x80, /* ACLINK: I2S */ 0xfc, /* I2S: vol, 96k, 24bit, 192k */ @@ -1196,7 +1196,7 @@ static unsigned char prodigy71hifi_eeprom[] = { 0x00, /* GPIO_STATE2 */ }; -static unsigned char prodigyhd2_eeprom[] = { +static const unsigned char prodigyhd2_eeprom[] = { 0x4b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */ 0x80, /* ACLINK: I2S */ 0xfc, /* I2S: vol, 96k, 24bit, 192k */ @@ -1212,7 +1212,7 @@ static unsigned char prodigyhd2_eeprom[] = { 0x00, /* GPIO_STATE2 */ }; -static unsigned char fortissimo4_eeprom[] = { +static const unsigned char fortissimo4_eeprom[] = { 0x43, /* SYSCONF: clock 512, ADC, 4DACs */ 0x80, /* ACLINK: I2S */ 0xfc, /* I2S: vol, 96k, 24bit, 192k */ diff --git a/sound/pci/ice1712/psc724.c b/sound/pci/ice1712/psc724.c index 7287ebed2b5a..7aa3f92040d0 100644 --- a/sound/pci/ice1712/psc724.c +++ b/sound/pci/ice1712/psc724.c @@ -420,7 +420,7 @@ static void psc724_exit(struct snd_ice1712 *ice) } /* PSC724 has buggy EEPROM (no 96&192kHz, all FFh GPIOs), so override it here */ -static unsigned char psc724_eeprom[] = { +static const unsigned char psc724_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x42, /* 49.152MHz, 1 ADC, 3 DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0xf0, /* I2S volume, 96kHz, 24bit */ diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index bfd811a08d90..866596205710 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -657,7 +657,7 @@ static int qtet_php_put(struct snd_kcontrol *kcontrol, .get_register = get_##xreg,\ .texts = {xtext1, xtext2} } -static struct qtet_kcontrol_private qtet_privates[] = { +static const struct qtet_kcontrol_private qtet_privates[] = { PRIV_ENUM2(IN12_SEL, CPLD_IN12_SEL, cpld, "An In 1/2", "An In 3/4"), PRIV_ENUM2(IN34_SEL, CPLD_IN34_SEL, cpld, "An In 3/4", "IEC958 In"), PRIV_ENUM2(AIN34_SEL, SCR_AIN34_SEL, scr, "Line In 3/4", "Hi-Z"), @@ -757,7 +757,7 @@ static const struct snd_kcontrol_new qtet_controls[] = { QTET_CONTROL("Output 3/4 to Monitor 1/2", sw, OUT34_MON12), }; -static char *slave_vols[] = { +static const char * const slave_vols[] = { PCM_12_PLAYBACK_VOLUME, PCM_34_PLAYBACK_VOLUME, NULL @@ -777,7 +777,7 @@ static struct snd_kcontrol *ctl_find(struct snd_card *card, } static void add_slaves(struct snd_card *card, - struct snd_kcontrol *master, char * const *list) + struct snd_kcontrol *master, const char * const *list) { for (; *list; list++) { struct snd_kcontrol *slave = ctl_find(card, *list); @@ -1053,7 +1053,7 @@ static int qtet_init(struct snd_ice1712 *ice) return 0; } -static unsigned char qtet_eeprom[] = { +static const unsigned char qtet_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x28, /* clock 256(24MHz), mpu401, 1xADC, 1xDACs, SPDIF in */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ diff --git a/sound/pci/ice1712/se.c b/sound/pci/ice1712/se.c index fdc502783e07..ffa9d8860a5a 100644 --- a/sound/pci/ice1712/se.c +++ b/sound/pci/ice1712/se.c @@ -245,7 +245,7 @@ static const char * const se200pci_sel[] = { static void se200pci_WM8776_set_input_selector(struct snd_ice1712 *ice, unsigned int sel) { - static unsigned char vals[] = { + static const unsigned char vals[] = { /* LINE, CD, MIC, ALL, GND */ 0x10, 0x04, 0x08, 0x1c, 0x03 }; @@ -288,7 +288,7 @@ static void se200pci_WM8776_set_agc(struct snd_ice1712 *ice, unsigned int agc) static void se200pci_WM8776_init(struct snd_ice1712 *ice) { int i; - static unsigned short default_values[] = { + static const unsigned short default_values[] = { 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x000, 0x090, 0x000, 0x000, @@ -701,7 +701,7 @@ static int se_add_controls(struct snd_ice1712 *ice) /* entry point */ /****************************************************************************/ -static unsigned char se200pci_eeprom[] = { +static const unsigned char se200pci_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */ @@ -720,7 +720,7 @@ static unsigned char se200pci_eeprom[] = { [ICE_EEP2_GPIO_STATE2] = 0x07, /* WM8766 ML/MC/MD */ }; -static unsigned char se90pci_eeprom[] = { +static const unsigned char se90pci_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */ [ICE_EEP2_ACLINK] = 0x80, /* I2S */ [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */ diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c index 3d240125a644..47470b07197c 100644 --- a/sound/pci/ice1712/vt1720_mobo.c +++ b/sound/pci/ice1712/vt1720_mobo.c @@ -39,7 +39,7 @@ static int k8x800_add_controls(struct snd_ice1712 *ice) /* EEPROM image */ -static unsigned char k8x800_eeprom[] = { +static const unsigned char k8x800_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ [ICE_EEP2_I2S] = 0x00, /* - */ @@ -55,7 +55,7 @@ static unsigned char k8x800_eeprom[] = { [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */ }; -static unsigned char sn25p_eeprom[] = { +static const unsigned char sn25p_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ [ICE_EEP2_I2S] = 0x00, /* - */ diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c index 4a7315ad51e8..f613f0067d8c 100644 --- a/sound/pci/ice1712/wtm.c +++ b/sound/pci/ice1712/wtm.c @@ -567,12 +567,12 @@ static int wtm_add_controls(struct snd_ice1712 *ice) static int wtm_init(struct snd_ice1712 *ice) { - static unsigned short stac_inits_wtm[] = { + static const unsigned short stac_inits_wtm[] = { STAC946X_RESET, 0, STAC946X_MASTER_CLOCKING, 0x11, (unsigned short)-1 }; - unsigned short *p; + const unsigned short *p; struct wtm_spec *spec; /*WTM 192M*/ @@ -599,7 +599,7 @@ static int wtm_init(struct snd_ice1712 *ice) } -static unsigned char wtm_eeprom[] = { +static const unsigned char wtm_eeprom[] = { [ICE_EEP2_SYSCONF] = 0x67, /*SYSCONF: clock 192KHz, mpu401, 4ADC, 8DAC */ [ICE_EEP2_ACLINK] = 0x80, /* ACLINK : I2S */ -- cgit v1.2.3 From 6e9ef32fab28835110b5981295e6895bcac3614b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:32 +0100 Subject: ALSA: ppc: More constifications Apply const prefix to each possible place: the static tables for rate, volume, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-18-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/ppc/beep.c | 2 +- sound/ppc/pmac.c | 8 ++++---- sound/ppc/pmac.h | 2 +- sound/ppc/tumbler.c | 20 ++++++++++---------- sound/ppc/tumbler_volume.h | 12 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index e2806b8aee53..6bc586a5db0f 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c @@ -44,7 +44,7 @@ void snd_pmac_beep_stop(struct snd_pmac *chip) * so we can multiply by an amplitude in the range 0..100 to get a * signed short value to put in the output buffer. */ -static short beep_wform[256] = { +static const short beep_wform[256] = { 0, 40, 79, 117, 153, 187, 218, 245, 269, 288, 304, 316, 323, 327, 327, 324, 318, 310, 299, 288, 275, 262, 249, 236, diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 87738ddc8bfd..592532c09a82 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -24,11 +24,11 @@ /* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */ -static int awacs_freqs[8] = { +static const int awacs_freqs[8] = { 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350 }; /* fixed frequency table for tumbler */ -static int tumbler_freqs[1] = { +static const int tumbler_freqs[1] = { 44100 }; @@ -1174,7 +1174,7 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) np = chip->node; chip->requested = 0; if (chip->is_k2) { - static char *rnames[] = { + static const char * const rnames[] = { "Sound Control", "Sound DMA" }; for (i = 0; i < 2; i ++) { if (of_address_to_resource(np->parent, i, @@ -1199,7 +1199,7 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) txdma_addr = chip->rsrc[1].start; rxdma_addr = txdma_addr + 0x100; } else { - static char *rnames[] = { + static const char * const rnames[] = { "Sound Control", "Sound Tx DMA", "Sound Rx DMA" }; for (i = 0; i < 3; i ++) { if (of_address_to_resource(np, i, diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h index 529f5a9f9039..a758caf689d2 100644 --- a/sound/ppc/pmac.h +++ b/sound/ppc/pmac.h @@ -104,7 +104,7 @@ struct snd_pmac { struct resource rsrc[3]; int num_freqs; - int *freq_table; + const int *freq_table; unsigned int freqs_ok; /* bit flags */ unsigned int formats_ok; /* pcm hwinfo */ int active; diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index a5843035d718..6e5bdaa262b0 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -106,7 +106,7 @@ struct pmac_tumbler { /* */ -static int send_init_client(struct pmac_keywest *i2c, unsigned int *regs) +static int send_init_client(struct pmac_keywest *i2c, const unsigned int *regs) { while (*regs > 0) { int err, count = 10; @@ -128,7 +128,7 @@ static int send_init_client(struct pmac_keywest *i2c, unsigned int *regs) static int tumbler_init_client(struct pmac_keywest *i2c) { - static unsigned int regs[] = { + static const unsigned int regs[] = { /* normal operation, SCLK=64fps, i2s output, i2s input, 16bit width */ TAS_REG_MCS, (1<<6)|(2<<4)|(2<<2)|0, 0, /* terminator */ @@ -139,7 +139,7 @@ static int tumbler_init_client(struct pmac_keywest *i2c) static int snapper_init_client(struct pmac_keywest *i2c) { - static unsigned int regs[] = { + static const unsigned int regs[] = { /* normal operation, SCLK=64fps, i2s output, 16bit width */ TAS_REG_MCS, (1<<6)|(2<<4)|0, /* normal operation, all-pass mode */ @@ -478,11 +478,11 @@ struct tumbler_mono_vol { int reg; int bytes; unsigned int max; - unsigned int *table; + const unsigned int *table; }; static int tumbler_set_mono_volume(struct pmac_tumbler *mix, - struct tumbler_mono_vol *info) + const struct tumbler_mono_vol *info) { unsigned char block[4]; unsigned int vol; @@ -553,7 +553,7 @@ static int tumbler_put_mono(struct snd_kcontrol *kcontrol, } /* TAS3001c mono volumes */ -static struct tumbler_mono_vol tumbler_pcm_vol_info = { +static const struct tumbler_mono_vol tumbler_pcm_vol_info = { .index = VOL_IDX_PCM_MONO, .reg = TAS_REG_PCM, .bytes = 3, @@ -561,7 +561,7 @@ static struct tumbler_mono_vol tumbler_pcm_vol_info = { .table = mixer_volume_table, }; -static struct tumbler_mono_vol tumbler_bass_vol_info = { +static const struct tumbler_mono_vol tumbler_bass_vol_info = { .index = VOL_IDX_BASS, .reg = TAS_REG_BASS, .bytes = 1, @@ -569,7 +569,7 @@ static struct tumbler_mono_vol tumbler_bass_vol_info = { .table = bass_volume_table, }; -static struct tumbler_mono_vol tumbler_treble_vol_info = { +static const struct tumbler_mono_vol tumbler_treble_vol_info = { .index = VOL_IDX_TREBLE, .reg = TAS_REG_TREBLE, .bytes = 1, @@ -578,7 +578,7 @@ static struct tumbler_mono_vol tumbler_treble_vol_info = { }; /* TAS3004 mono volumes */ -static struct tumbler_mono_vol snapper_bass_vol_info = { +static const struct tumbler_mono_vol snapper_bass_vol_info = { .index = VOL_IDX_BASS, .reg = TAS_REG_BASS, .bytes = 1, @@ -586,7 +586,7 @@ static struct tumbler_mono_vol snapper_bass_vol_info = { .table = snapper_bass_volume_table, }; -static struct tumbler_mono_vol snapper_treble_vol_info = { +static const struct tumbler_mono_vol snapper_treble_vol_info = { .index = VOL_IDX_TREBLE, .reg = TAS_REG_TREBLE, .bytes = 1, diff --git a/sound/ppc/tumbler_volume.h b/sound/ppc/tumbler_volume.h index 549ec6a31a98..16d548019ee9 100644 --- a/sound/ppc/tumbler_volume.h +++ b/sound/ppc/tumbler_volume.h @@ -2,7 +2,7 @@ /* volume tables, taken from TAS3001c data manual */ /* volume gain values */ /* 0 = -70 dB, 175 = 18.0 dB in 0.5 dB step */ -static unsigned int master_volume_table[] = { +static const unsigned int master_volume_table[] = { 0x00000015, 0x00000016, 0x00000017, 0x00000019, 0x0000001a, 0x0000001c, 0x0000001d, 0x0000001f, 0x00000021, @@ -66,7 +66,7 @@ static unsigned int master_volume_table[] = { /* treble table for TAS3001c */ /* 0 = -18 dB, 72 = 18 dB in 0.5 dB step */ -static unsigned int treble_volume_table[] = { +static const unsigned int treble_volume_table[] = { 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, @@ -96,7 +96,7 @@ static unsigned int treble_volume_table[] = { /* bass table for TAS3001c */ /* 0 = -18 dB, 72 = 18 dB in 0.5 dB step */ -static unsigned int bass_volume_table[] = { +static const unsigned int bass_volume_table[] = { 0x86, 0x82, 0x7f, 0x7d, 0x7a, 0x78, 0x76, 0x74, 0x72, @@ -126,7 +126,7 @@ static unsigned int bass_volume_table[] = { /* mixer (pcm) volume table */ /* 0 = -70 dB, 175 = 18.0 dB in 0.5 dB step */ -static unsigned int mixer_volume_table[] = { +static const unsigned int mixer_volume_table[] = { 0x00014b, 0x00015f, 0x000174, 0x00018a, 0x0001a1, 0x0001ba, 0x0001d4, 0x0001f0, 0x00020d, @@ -191,7 +191,7 @@ static unsigned int mixer_volume_table[] = { /* treble table for TAS3004 */ /* 0 = -18 dB, 72 = 18 dB in 0.5 dB step */ -static unsigned int snapper_treble_volume_table[] = { +static const unsigned int snapper_treble_volume_table[] = { 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, @@ -221,7 +221,7 @@ static unsigned int snapper_treble_volume_table[] = { /* bass table for TAS3004 */ /* 0 = -18 dB, 72 = 18 dB in 0.5 dB step */ -static unsigned int snapper_bass_volume_table[] = { +static const unsigned int snapper_bass_volume_table[] = { 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e, -- cgit v1.2.3 From d92596402d517cfc281d1c1189fb1cbca3412f62 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:33 +0100 Subject: ALSA: hdsp: More constifications Apply const prefix to each channel map table and its callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-19-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 632f7878ff3e..ba2a47dd384c 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -479,7 +479,7 @@ struct hdsp { pid_t playback_pid; int running; int system_sample_rate; - char *channel_map; + const char *channel_map; int dev; int irq; unsigned long port; @@ -501,12 +501,12 @@ struct hdsp { where the data for that channel can be read/written from/to. */ -static char channel_map_df_ss[HDSP_MAX_CHANNELS] = { +static const char channel_map_df_ss[HDSP_MAX_CHANNELS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }; -static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ +static const char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ /* Analog */ 0, 1, 2, 3, 4, 5, 6, 7, /* ADAT 2 */ @@ -516,7 +516,7 @@ static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_ds[HDSP_MAX_CHANNELS] = { +static const char channel_map_ds[HDSP_MAX_CHANNELS] = { /* ADAT channels are remapped */ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, /* channels 12 and 13 are S/PDIF */ @@ -525,7 +525,7 @@ static char channel_map_ds[HDSP_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = { +static const char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = { /* ADAT channels */ 0, 1, 2, 3, 4, 5, 6, 7, /* SPDIF */ @@ -539,7 +539,7 @@ static char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = { -1, -1 }; -static char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = { +static const char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = { /* ADAT */ 1, 3, 5, 7, /* SPDIF */ @@ -553,7 +553,7 @@ static char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1 }; -static char channel_map_H9632_qs[HDSP_MAX_CHANNELS] = { +static const char channel_map_H9632_qs[HDSP_MAX_CHANNELS] = { /* ADAT is disabled in this mode */ /* SPDIF */ 8, 9, -- cgit v1.2.3 From e315cc3f93c93e4969d28145b9e30761ad4e58a6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:34 +0100 Subject: ALSA: hdspm: More constifications Apply const prefix to each possible place: the string arrays, the channel map tables and callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-20-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 66 +++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index f926899e4755..2212d5799151 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -637,7 +637,7 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}"); #define HDSPM_SPEED_QUAD 2 /* names for speed modes */ -static char *hdspm_speed_names[] = { "single", "double", "quad" }; +static const char * const hdspm_speed_names[] = { "single", "double", "quad" }; static const char *const texts_autosync_aes_tco[] = { "Word Clock", "AES1", "AES2", "AES3", "AES4", @@ -684,7 +684,7 @@ static const char *const texts_freq[] = { "192 kHz" }; -static char *texts_ports_madi[] = { +static const char * const texts_ports_madi[] = { "MADI.1", "MADI.2", "MADI.3", "MADI.4", "MADI.5", "MADI.6", "MADI.7", "MADI.8", "MADI.9", "MADI.10", "MADI.11", "MADI.12", "MADI.13", "MADI.14", "MADI.15", "MADI.16", "MADI.17", "MADI.18", @@ -699,7 +699,7 @@ static char *texts_ports_madi[] = { }; -static char *texts_ports_raydat_ss[] = { +static const char * const texts_ports_raydat_ss[] = { "ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4", "ADAT1.5", "ADAT1.6", "ADAT1.7", "ADAT1.8", "ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4", "ADAT2.5", "ADAT2.6", "ADAT2.7", "ADAT2.8", "ADAT3.1", "ADAT3.2", @@ -710,7 +710,7 @@ static char *texts_ports_raydat_ss[] = { "SPDIF.L", "SPDIF.R" }; -static char *texts_ports_raydat_ds[] = { +static const char * const texts_ports_raydat_ds[] = { "ADAT1.1", "ADAT1.2", "ADAT1.3", "ADAT1.4", "ADAT2.1", "ADAT2.2", "ADAT2.3", "ADAT2.4", "ADAT3.1", "ADAT3.2", "ADAT3.3", "ADAT3.4", @@ -719,7 +719,7 @@ static char *texts_ports_raydat_ds[] = { "SPDIF.L", "SPDIF.R" }; -static char *texts_ports_raydat_qs[] = { +static const char * const texts_ports_raydat_qs[] = { "ADAT1.1", "ADAT1.2", "ADAT2.1", "ADAT2.2", "ADAT3.1", "ADAT3.2", @@ -729,7 +729,7 @@ static char *texts_ports_raydat_qs[] = { }; -static char *texts_ports_aio_in_ss[] = { +static const char * const texts_ports_aio_in_ss[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -738,7 +738,7 @@ static char *texts_ports_aio_in_ss[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aio_out_ss[] = { +static const char * const texts_ports_aio_out_ss[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -748,7 +748,7 @@ static char *texts_ports_aio_out_ss[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aio_in_ds[] = { +static const char * const texts_ports_aio_in_ds[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -756,7 +756,7 @@ static char *texts_ports_aio_in_ds[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aio_out_ds[] = { +static const char * const texts_ports_aio_out_ds[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -765,7 +765,7 @@ static char *texts_ports_aio_out_ds[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aio_in_qs[] = { +static const char * const texts_ports_aio_in_qs[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -773,7 +773,7 @@ static char *texts_ports_aio_in_qs[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aio_out_qs[] = { +static const char * const texts_ports_aio_out_qs[] = { "Analogue.L", "Analogue.R", "AES.L", "AES.R", "SPDIF.L", "SPDIF.R", @@ -782,7 +782,7 @@ static char *texts_ports_aio_out_qs[] = { "AEB.1", "AEB.2", "AEB.3", "AEB.4" }; -static char *texts_ports_aes32[] = { +static const char * const texts_ports_aes32[] = { "AES.1", "AES.2", "AES.3", "AES.4", "AES.5", "AES.6", "AES.7", "AES.8", "AES.9.", "AES.10", "AES.11", "AES.12", "AES.13", "AES.14", "AES.15", "AES.16" @@ -796,7 +796,7 @@ static char *texts_ports_aes32[] = { where the data for that channel can be read/written from/to. */ -static char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = { +static const char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -807,7 +807,7 @@ static char channel_map_unity_ss[HDSPM_MAX_CHANNELS] = { 56, 57, 58, 59, 60, 61, 62, 63 }; -static char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = { +static const char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = { 4, 5, 6, 7, 8, 9, 10, 11, /* ADAT 1 */ 12, 13, 14, 15, 16, 17, 18, 19, /* ADAT 2 */ 20, 21, 22, 23, 24, 25, 26, 27, /* ADAT 3 */ @@ -820,7 +820,7 @@ static char channel_map_raydat_ss[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, }; -static char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = { +static const char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = { 4, 5, 6, 7, /* ADAT 1 */ 8, 9, 10, 11, /* ADAT 2 */ 12, 13, 14, 15, /* ADAT 3 */ @@ -835,7 +835,7 @@ static char channel_map_raydat_ds[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, }; -static char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = { +static const char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = { 4, 5, /* ADAT 1 */ 6, 7, /* ADAT 2 */ 8, 9, /* ADAT 3 */ @@ -851,7 +851,7 @@ static char channel_map_raydat_qs[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, }; -static char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = { 0, 1, /* line in */ 8, 9, /* aes in, */ 10, 11, /* spdif in */ @@ -865,7 +865,7 @@ static char channel_map_aio_in_ss[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, }; -static char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = { 0, 1, /* line out */ 8, 9, /* aes out */ 10, 11, /* spdif out */ @@ -880,7 +880,7 @@ static char channel_map_aio_out_ss[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1, }; -static char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = { 0, 1, /* line in */ 8, 9, /* aes in */ 10, 11, /* spdif in */ @@ -895,7 +895,7 @@ static char channel_map_aio_in_ds[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = { 0, 1, /* line out */ 8, 9, /* aes out */ 10, 11, /* spdif out */ @@ -910,7 +910,7 @@ static char channel_map_aio_out_ds[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = { 0, 1, /* line in */ 8, 9, /* aes in */ 10, 11, /* spdif in */ @@ -925,7 +925,7 @@ static char channel_map_aio_in_qs[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = { 0, 1, /* line out */ 8, 9, /* aes out */ 10, 11, /* spdif out */ @@ -941,7 +941,7 @@ static char channel_map_aio_out_qs[HDSPM_MAX_CHANNELS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_aes32[HDSPM_MAX_CHANNELS] = { +static const char channel_map_aes32[HDSPM_MAX_CHANNELS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, @@ -1010,17 +1010,21 @@ struct hdspm { unsigned char max_channels_in; unsigned char max_channels_out; - signed char *channel_map_in; - signed char *channel_map_out; + const signed char *channel_map_in; + const signed char *channel_map_out; - signed char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs; - signed char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs; + const signed char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs; + const signed char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs; - char **port_names_in; - char **port_names_out; + const char * const *port_names_in; + const char * const *port_names_out; - char **port_names_in_ss, **port_names_in_ds, **port_names_in_qs; - char **port_names_out_ss, **port_names_out_ds, **port_names_out_qs; + const char * const *port_names_in_ss; + const char * const *port_names_in_ds; + const char * const *port_names_in_qs; + const char * const *port_names_out_ss; + const char * const *port_names_out_ds; + const char * const *port_names_out_qs; unsigned char *playback_buffer; /* suitably aligned address */ unsigned char *capture_buffer; /* suitably aligned address */ -- cgit v1.2.3 From 1e393ef4e3dbcea814ccadc08f10026e40267669 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:35 +0100 Subject: ALSA: rme9652: More constifications Apply const prefix to the channel map tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-21-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/rme9652/rme9652.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 2cb5b03f84d3..c20e590eb570 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -229,7 +229,7 @@ struct snd_rme9652 { int last_spdif_sample_rate; /* so that we can catch externally ... */ int last_adat_sample_rate; /* ... induced rate changes */ - char *channel_map; + const char *channel_map; struct snd_card *card; struct snd_pcm *pcm; @@ -246,12 +246,12 @@ struct snd_rme9652 { where the data for that channel can be read/written from/to. */ -static char channel_map_9652_ss[26] = { +static const char channel_map_9652_ss[26] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }; -static char channel_map_9636_ss[26] = { +static const char channel_map_9636_ss[26] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* channels 16 and 17 are S/PDIF */ 24, 25, @@ -259,7 +259,7 @@ static char channel_map_9636_ss[26] = { -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_9652_ds[26] = { +static const char channel_map_9652_ds[26] = { /* ADAT channels are remapped */ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, /* channels 12 and 13 are S/PDIF */ @@ -268,7 +268,7 @@ static char channel_map_9652_ds[26] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; -static char channel_map_9636_ds[26] = { +static const char channel_map_9636_ds[26] = { /* ADAT channels are remapped */ 1, 3, 5, 7, 9, 11, 13, 15, /* channels 8 and 9 are S/PDIF */ -- cgit v1.2.3 From 55a6921bf1ea0cfd01aa798c084b6932842fe10e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:36 +0100 Subject: ALSA: emux: More constifications Apply const prefix to each possible place: the MIDI data definitions, the static tables for volume parameters, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-22-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/synth/emux/emux_nrpn.c | 4 ++-- sound/synth/emux/emux_synth.c | 10 +++++----- sound/synth/emux/soundfont.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/synth/emux/emux_nrpn.c b/sound/synth/emux/emux_nrpn.c index 1ac22676d464..7eed5791972c 100644 --- a/sound/synth/emux/emux_nrpn.c +++ b/sound/synth/emux/emux_nrpn.c @@ -63,7 +63,7 @@ static int send_converted_effect(const struct nrpn_conv_table *table, /* effect sensitivities for GS NRPN: * adjusted for chaos 8MB soundfonts */ -static int gs_sense[] = +static const int gs_sense[] = { DEF_FX_CUTOFF, DEF_FX_RESONANCE, DEF_FX_ATTACK, DEF_FX_RELEASE, DEF_FX_VIBRATE, DEF_FX_VIBDEPTH, DEF_FX_VIBDELAY @@ -72,7 +72,7 @@ static int gs_sense[] = /* effect sensitivies for XG controls: * adjusted for chaos 8MB soundfonts */ -static int xg_sense[] = +static const int xg_sense[] = { DEF_FX_CUTOFF, DEF_FX_RESONANCE, DEF_FX_ATTACK, DEF_FX_RELEASE, DEF_FX_VIBRATE, DEF_FX_VIBDEPTH, DEF_FX_VIBDELAY diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index 7c9eecd4d14e..a5385efcedb6 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c @@ -529,7 +529,7 @@ update_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int update) #if 0 // not used /* table for volume target calculation */ -static unsigned short voltarget[16] = { +static const unsigned short voltarget[16] = { 0xEAC0, 0xE0C8, 0xD740, 0xCE20, 0xC560, 0xBD08, 0xB500, 0xAD58, 0xA5F8, 0x9EF0, 0x9830, 0x91C0, 0x8B90, 0x85A8, 0x8000, 0x7A90 }; @@ -616,7 +616,7 @@ setup_voice(struct snd_emux_voice *vp) /* * calculate pitch parameter */ -static unsigned char pan_volumes[256] = { +static const unsigned char pan_volumes[256] = { 0x00,0x03,0x06,0x09,0x0c,0x0f,0x12,0x14,0x17,0x1a,0x1d,0x20,0x22,0x25,0x28,0x2a, 0x2d,0x30,0x32,0x35,0x37,0x3a,0x3c,0x3f,0x41,0x44,0x46,0x49,0x4b,0x4d,0x50,0x52, 0x54,0x57,0x59,0x5b,0x5d,0x60,0x62,0x64,0x66,0x68,0x6a,0x6c,0x6f,0x71,0x73,0x75, @@ -684,7 +684,7 @@ calc_pan(struct snd_emux_voice *vp) */ /* tables for volume->attenuation calculation */ -static unsigned char voltab1[128] = { +static const unsigned char voltab1[128] = { 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x2b, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x1e, 0x1d, 0x1c, 0x1b, 0x1b, 0x1a, @@ -700,7 +700,7 @@ static unsigned char voltab1[128] = { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static unsigned char voltab2[128] = { +static const unsigned char voltab2[128] = { 0x32, 0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1f, 0x1e, 0x1e, 0x1d, 0x1c, 0x1c, 0x1b, 0x1a, @@ -716,7 +716,7 @@ static unsigned char voltab2[128] = { 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; -static unsigned char expressiontab[128] = { +static const unsigned char expressiontab[128] = { 0x7f, 0x6c, 0x62, 0x5a, 0x54, 0x50, 0x4b, 0x48, 0x45, 0x42, 0x40, 0x3d, 0x3b, 0x39, 0x38, 0x36, 0x34, 0x33, 0x31, 0x30, 0x2f, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x28, 0x27, 0x26, 0x25, diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index dcc6a925a03e..9ebc711afa6b 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -751,7 +751,7 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) /* log2_tbl[i] = log2(i+128) * 0x10000 */ -static int log_tbl[129] = { +static const int log_tbl[129] = { 0x70000, 0x702df, 0x705b9, 0x7088e, 0x70b5d, 0x70e26, 0x710eb, 0x713aa, 0x71663, 0x71918, 0x71bc8, 0x71e72, 0x72118, 0x723b9, 0x72655, 0x728ed, 0x72b80, 0x72e0e, 0x73098, 0x7331d, 0x7359e, 0x7381b, 0x73a93, 0x73d08, @@ -857,7 +857,7 @@ calc_gus_envelope_time(int rate, int start, int end) /* convert envelope time parameter to soundfont parameters */ /* attack & decay/release time table (msec) */ -static short attack_time_tbl[128] = { +static const short attack_time_tbl[128] = { 32767, 32767, 5989, 4235, 2994, 2518, 2117, 1780, 1497, 1373, 1259, 1154, 1058, 970, 890, 816, 707, 691, 662, 634, 607, 581, 557, 533, 510, 489, 468, 448, 429, 411, 393, 377, 361, 345, 331, 317, 303, 290, 278, 266, 255, 244, 234, 224, 214, 205, 196, 188, @@ -868,7 +868,7 @@ static short attack_time_tbl[128] = { 11, 11, 10, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 0, }; -static short decay_time_tbl[128] = { +static const short decay_time_tbl[128] = { 32767, 32767, 22614, 15990, 11307, 9508, 7995, 6723, 5653, 5184, 4754, 4359, 3997, 3665, 3361, 3082, 2828, 2765, 2648, 2535, 2428, 2325, 2226, 2132, 2042, 1955, 1872, 1793, 1717, 1644, 1574, 1507, 1443, 1382, 1324, 1267, 1214, 1162, 1113, 1066, 978, 936, 897, 859, 822, 787, 754, 722, @@ -891,7 +891,7 @@ snd_sf_calc_parm_hold(int msec) /* search an index for specified time from given time table */ static int -calc_parm_search(int msec, short *table) +calc_parm_search(int msec, const short *table) { int left = 1, right = 127, mid; while (left < right) { -- cgit v1.2.3 From 7ec03ff7c761371b363e184f6b0722225f548102 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:37 +0100 Subject: ALSA: usx2y: More constifications Apply const prefix to each possible place: the string array and the parameter tables and callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-23-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usX2Yhwdep.c | 2 +- sound/usb/usx2y/usbusx2yaudio.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 0e6d82b5778e..22412cd69e98 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -94,7 +94,7 @@ static __poll_t snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, struct snd_hwdep_dsp_status *info) { - static char *type_ids[USX2Y_TYPE_NUMS] = { + static const char * const type_ids[USX2Y_TYPE_NUMS] = { [USX2Y_TYPE_122] = "us122", [USX2Y_TYPE_224] = "us224", [USX2Y_TYPE_428] = "us428", diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index c7dbc0f94efb..772f6f3ccbb1 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -549,7 +549,7 @@ static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd) * if sg buffer is supported on the later version of alsa, we'll follow * that. */ -static struct s_c2 +static const struct s_c2 { char c1, c2; } @@ -589,7 +589,7 @@ static struct s_c2 { 0x18, 0x7C}, { 0x18, 0x7E} }; -static struct s_c2 SetRate48000[] = +static const struct s_c2 SetRate48000[] = { { 0x14, 0x09}, // this line sets 48000, well actually a little less { 0x18, 0x40}, // only tascam / frontier design knows the further lines ....... @@ -642,7 +642,7 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) int err = 0, i; struct snd_usX2Y_urbSeq *us = NULL; int *usbdata = NULL; - struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; + const struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; if (usX2Y->rate != rate) { us = kzalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); -- cgit v1.2.3 From 98fd539841319a46ba3773d908bfde13416d57eb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:38 +0100 Subject: ALSA: pcxhr: More constifications Apply const prefix to each possible place: the board parameters and DSP command table, and the string arrays. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-24-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 2 +- sound/pci/pcxhr/pcxhr_core.c | 6 +++--- sound/pci/pcxhr/pcxhr_hwdep.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 9e59d591217b..c2e4831c3a13 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -136,7 +136,7 @@ struct board_parameters { short fw_file_set; short firmware_num; }; -static struct board_parameters pcxhr_board_params[] = { +static const struct board_parameters pcxhr_board_params[] = { [PCI_ID_VX882HR] = { "VX882HR", 4, 4, 0, 41 }, [PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 0, 41 }, [PCI_ID_VX881HR] = { "VX881HR", 4, 4, 0, 41 }, diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c index 495be27e3ba2..87d24224c042 100644 --- a/sound/pci/pcxhr/pcxhr_core.c +++ b/sound/pci/pcxhr/pcxhr_core.c @@ -466,7 +466,7 @@ enum { /* * Array of DSP commands */ -static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = { +static const struct pcxhr_cmd_info pcxhr_dsp_cmds[] = { [CMD_VERSION] = { 0x010000, 1, RMH_SSIZE_FIXED }, [CMD_SUPPORTED] = { 0x020000, 4, RMH_SSIZE_FIXED }, [CMD_TEST_IT] = { 0x040000, 1, RMH_SSIZE_FIXED }, @@ -497,7 +497,7 @@ static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = { }; #ifdef CONFIG_SND_DEBUG_VERBOSE -static char* cmd_names[] = { +static const char * const cmd_names[] = { [CMD_VERSION] = "CMD_VERSION", [CMD_SUPPORTED] = "CMD_SUPPORTED", [CMD_TEST_IT] = "CMD_TEST_IT", @@ -1006,7 +1006,7 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err, enum pcxhr_async_err_src err_src, int pipe, int is_capture) { - static char* err_src_name[] = { + static const char * const err_src_name[] = { [PCXHR_ERR_PIPE] = "Pipe", [PCXHR_ERR_STREAM] = "Stream", [PCXHR_ERR_AUDIO] = "Audio" diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index 12a6bdb920b2..2258bd698844 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -348,7 +348,7 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, */ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) { - static char *fw_files[][5] = { + static const char * const fw_files[][5] = { [0] = { "xlxint.dat", "xlxc882hr.dat", "dspe882.e56", "dspb882hr.b56", "dspd882.d56" }, [1] = { "xlxint.dat", "xlxc882e.dat", -- cgit v1.2.3 From 3cfe54b96ca1a8483b376fd24a6fb1b63a2f02c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:39 +0100 Subject: ALSA: mixart: More constifications Apply const prefix to each possible place: the string arrays and the static tables for volumes. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-25-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart_hwdep.c | 2 +- sound/pci/mixart/mixart_mixer.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c index 92b051c6572d..13dcb2fd0a85 100644 --- a/sound/pci/mixart/mixart_hwdep.c +++ b/sound/pci/mixart/mixart_hwdep.c @@ -548,7 +548,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw int snd_mixart_setup_firmware(struct mixart_mgr *mgr) { - static char *fw_files[3] = { + static const char * const fw_files[3] = { "miXart8.xlx", "miXart8.elf", "miXart8AES.xlx" }; char path[32]; diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c index 1378f9ee70a9..d2e7c3381267 100644 --- a/sound/pci/mixart/mixart_mixer.c +++ b/sound/pci/mixart/mixart_mixer.c @@ -20,7 +20,7 @@ #include #include "mixart_mixer.h" -static u32 mixart_analog_level[256] = { +static const u32 mixart_analog_level[256] = { 0xc2c00000, /* [000] -96.0 dB */ 0xc2bf0000, /* [001] -95.5 dB */ 0xc2be0000, /* [002] -95.0 dB */ @@ -443,7 +443,7 @@ static const struct snd_kcontrol_new mixart_control_output_switch = { .put = mixart_audio_sw_put }; -static u32 mixart_digital_level[256] = { +static const u32 mixart_digital_level[256] = { 0x00000000, /* [000] = 0.00e+000 = mute if <= -109.5dB */ 0x366e1c7a, /* [001] = 3.55e-006 = pow(10.0, 0.05 * -109.0dB) */ 0x367c3860, /* [002] = 3.76e-006 = pow(10.0, 0.05 * -108.5dB) */ -- cgit v1.2.3 From 10aab1a24d52176f591412ce9827832aa04d3267 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:40 +0100 Subject: ALSA: ymfpci: More constifications Apply const prefix to each possible place: the static tables for sample rates, parameters and registers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-26-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 1cffd988b616..e07d70307d20 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -122,14 +122,14 @@ static u32 snd_ymfpci_calc_delta(u32 rate) } } -static u32 def_rate[8] = { +static const u32 def_rate[8] = { 100, 2000, 8000, 11025, 16000, 22050, 32000, 48000 }; static u32 snd_ymfpci_calc_lpfK(u32 rate) { u32 i; - static u32 val[8] = { + static const u32 val[8] = { 0x00570000, 0x06AA0000, 0x18B20000, 0x20930000, 0x2B9A0000, 0x35A10000, 0x3EAA0000, 0x40000000 }; @@ -145,7 +145,7 @@ static u32 snd_ymfpci_calc_lpfK(u32 rate) static u32 snd_ymfpci_calc_lpfQ(u32 rate) { u32 i; - static u32 val[8] = { + static const u32 val[8] = { 0x35280000, 0x34A70000, 0x32020000, 0x31770000, 0x31390000, 0x31C90000, 0x33D00000, 0x40000000 }; @@ -2234,7 +2234,7 @@ static int snd_ymfpci_dev_free(struct snd_device *device) } #ifdef CONFIG_PM_SLEEP -static int saved_regs_index[] = { +static const int saved_regs_index[] = { /* spdif */ YDSXGR_SPDIFOUTCTRL, YDSXGR_SPDIFOUTSTATUS, -- cgit v1.2.3 From 71075c421060cd3cc00f77770cc01254f8ff2c27 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:41 +0100 Subject: ALSA: bcd2000: More constifications Apply const prefix to the static tables for command and verbs. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-27-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/usb/bcd2000/bcd2000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/bcd2000/bcd2000.c b/sound/usb/bcd2000/bcd2000.c index 6e3175826faf..010976d9ceb2 100644 --- a/sound/usb/bcd2000/bcd2000.c +++ b/sound/usb/bcd2000/bcd2000.c @@ -25,9 +25,9 @@ static const struct usb_device_id id_table[] = { { }, }; -static unsigned char device_cmd_prefix[] = {0x03, 0x00}; +static const unsigned char device_cmd_prefix[] = {0x03, 0x00}; -static unsigned char bcd2000_init_sequence[] = { +static const unsigned char bcd2000_init_sequence[] = { 0x07, 0x00, 0x00, 0x00, 0x78, 0x48, 0x1c, 0x81, 0xc4, 0x00, 0x00, 0x00, 0x5e, 0x53, 0x4a, 0xf7, 0x18, 0xfa, 0x11, 0xff, 0x6c, 0xf3, 0x90, 0xff, -- cgit v1.2.3 From ccfacf2b2ee49962452b8d7bd104047d681f0555 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:42 +0100 Subject: ALSA: nm256: More constifications Apply const prefix to the static tables coefs and init registers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-28-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 4 ++-- sound/pci/nm256/nm256_coef.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 25275a98e950..1726f2959ae8 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -299,7 +299,7 @@ snd_nm256_writel(struct nm256 *chip, int offset, u32 val) } static inline void -snd_nm256_write_buffer(struct nm256 *chip, void *src, int offset, int size) +snd_nm256_write_buffer(struct nm256 *chip, const void *src, int offset, int size) { offset -= chip->buffer_start; #ifdef CONFIG_SND_DEBUG @@ -1179,7 +1179,7 @@ struct initialValues { unsigned short value; }; -static struct initialValues nm256_ac97_init_val[] = +static const struct initialValues nm256_ac97_init_val[] = { { AC97_MASTER, 0x8000 }, { AC97_HEADPHONE, 0x8000 }, diff --git a/sound/pci/nm256/nm256_coef.c b/sound/pci/nm256/nm256_coef.c index c757252119b1..f0599dbe8492 100644 --- a/sound/pci/nm256/nm256_coef.c +++ b/sound/pci/nm256/nm256_coef.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #define NM_TOTAL_COEFF_COUNT 0x3158 -static char coefficients[NM_TOTAL_COEFF_COUNT * 4] = { +static const char coefficients[NM_TOTAL_COEFF_COUNT * 4] = { 0xFF, 0xFF, 0x2F, 0x00, 0x4B, 0xFF, 0xA5, 0x01, 0xEF, 0xFC, 0x21, 0x05, 0x87, 0xF7, 0x62, 0x11, 0xE9, 0x45, 0x5E, 0xF9, 0xB5, 0x01, 0xDE, 0xFF, 0xA4, 0xFF, 0x60, 0x00, 0xCA, 0xFF, 0x0D, 0x00, 0xFD, @@ -4598,7 +4598,7 @@ static char coefficients[NM_TOTAL_COEFF_COUNT * 4] = { 0x01, 0x8D, 0xFF, 0x0F, 0x00 }; -static u16 +static const u16 coefficient_sizes[8 * 2] = { /* Playback */ 0x00C0, 0x5000, 0x0060, 0x2800, 0x0040, 0x0060, 0x1400, 0x0000, -- cgit v1.2.3 From a7f7edcfa47c720b31e503e8817687229757f8dc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:43 +0100 Subject: ALSA: korg1212: More constifications Apply const prefix to each possible place: the string array, the static tables for clock selectors, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-29-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/korg1212/korg1212.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 685a60551c71..21ab9cc50c71 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -415,7 +415,7 @@ static const struct pci_device_id snd_korg1212_ids[] = { MODULE_DEVICE_TABLE(pci, snd_korg1212_ids); -static char *stateName[] = { +static const char * const stateName[] = { "Non-existent", "Uninitialized", "DSP download in process", @@ -455,7 +455,7 @@ static const char * const channelName[] = { "SPDIF-R", }; -static u16 ClockSourceSelector[] = { +static const u16 ClockSourceSelector[] = { 0x8000, // selects source as ADAT at 44.1 kHz 0x0000, // selects source as ADAT at 48 kHz 0x8001, // selects source as S/PDIF at 44.1 kHz @@ -813,12 +813,12 @@ static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212) static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate) { - static enum ClockSourceIndex s44[] = { + static const enum ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K, K1212_CLKIDX_WordAt44_1K, K1212_CLKIDX_LocalAt44_1K }; - static enum ClockSourceIndex s48[] = { + static const enum ClockSourceIndex s48[] = { K1212_CLKIDX_AdatAt48K, K1212_CLKIDX_WordAt48K, K1212_CLKIDX_LocalAt48K -- cgit v1.2.3 From ba09f5d84e3e39ffb6768e5473073cfb96ba32e3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:44 +0100 Subject: ALSA: cs46xx: More constifications Apply const prefix to each possible place: the static tables for registers and op codes, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-30-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/cs46xx_lib.c | 2 +- sound/pci/cs46xx/dsp_spos.c | 4 ++-- sound/pci/cs46xx/dsp_spos_scb_lib.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index cbac9f1edc51..e46efae1e192 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3745,7 +3745,7 @@ static struct cs_card_type cards[] = { * APM support */ #ifdef CONFIG_PM_SLEEP -static unsigned int saved_regs[] = { +static const unsigned int saved_regs[] = { BA0_ACOSV, /*BA0_ASER_FADDR,*/ BA0_ASER_MASTER, diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 887790ac33c6..05f3f6dc918d 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -27,7 +27,7 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip, struct dsp_scb_descriptor * fg_entry); -static enum wide_opcode wide_opcodes[] = { +static const enum wide_opcode wide_opcodes[] = { WIDE_FOR_BEGIN_LOOP, WIDE_FOR_BEGIN_LOOP2, WIDE_COND_GOTO_ADDR, @@ -1038,7 +1038,7 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip) int fifo_addr, fifo_span, valid_slots; - static struct dsp_spos_control_block sposcb = { + static const struct dsp_spos_control_block sposcb = { /* 0 */ HFG_TREE_SCB,HFG_STACK, /* 1 */ SPOSCB_ADDR,BG_TREE_SCB_ADDR, /* 2 */ DSP_SPOS_DC,0, diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 715ead59613d..2c5c9d4c1d94 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -1145,7 +1145,7 @@ find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from) return scb; } -static u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { +static const u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { 0x0600, /* 1 */ 0x1500, /* 2 */ 0x1580, /* 3 */ @@ -1180,7 +1180,7 @@ static u32 pcm_reader_buffer_addr[DSP_MAX_PCM_CHANNELS] = { 0x2400, /* 32 */ }; -static u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { +static const u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { 0x2B80, 0x2BA0, 0x2BC0, @@ -1197,7 +1197,7 @@ static u32 src_output_buffer_addr[DSP_MAX_SRC_NR] = { 0x2E20 }; -static u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = { +static const u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = { 0x2480, 0x2500, 0x2580, -- cgit v1.2.3 From 97974309721eb996a5092cb13901af126886450e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:45 +0100 Subject: ALSA: ca0106: More constifications Apply const prefix to each possible place: the static tables for registers and verbs, and the string arrays. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-31-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 4 ++-- sound/pci/ca0106/ca0106_mixer.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 487b1aaafa1e..70d775ff967e 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1360,7 +1360,7 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device) } #define SPI_REG(reg, value) (((reg) << SPI_REG_SHIFT) | (value)) -static unsigned int spi_dac_init[] = { +static const unsigned int spi_dac_init[] = { SPI_REG(SPI_LDA1_REG, SPI_DA_BIT_0dB), /* 0dB dig. attenuation */ SPI_REG(SPI_RDA1_REG, SPI_DA_BIT_0dB), SPI_REG(SPI_PL_REG, SPI_PL_BIT_L_L | SPI_PL_BIT_R_R | SPI_IZD_BIT), @@ -1378,7 +1378,7 @@ static unsigned int spi_dac_init[] = { SPI_REG(SPI_DACD4_REG, SPI_DACD4_BIT), }; -static unsigned int i2c_adc_init[][2] = { +static const unsigned int i2c_adc_init[][2] = { { 0x17, 0x00 }, /* Reset */ { 0x07, 0x00 }, /* Timeout */ { 0x0b, 0x22 }, /* Interface control */ diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index c771995b12b9..3b8ec673dc0a 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -739,7 +739,7 @@ static int rename_ctl(struct snd_card *card, const char *src, const char *dst) static DECLARE_TLV_DB_SCALE(snd_ca0106_master_db_scale, -6375, 25, 1); -static char *slave_vols[] = { +static const char * const slave_vols[] = { "Analog Front Playback Volume", "Analog Rear Playback Volume", "Analog Center/LFE Playback Volume", @@ -752,7 +752,7 @@ static char *slave_vols[] = { NULL }; -static char *slave_sws[] = { +static const char * const slave_sws[] = { "Analog Front Playback Switch", "Analog Rear Playback Switch", "Analog Center/LFE Playback Switch", @@ -762,7 +762,7 @@ static char *slave_sws[] = { }; static void add_slaves(struct snd_card *card, - struct snd_kcontrol *master, char **list) + struct snd_kcontrol *master, const char * const *list) { for (; *list; list++) { struct snd_kcontrol *slave = ctl_find(card, *list); @@ -775,9 +775,9 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) { int err; struct snd_card *card = emu->card; - char **c; + const char * const *c; struct snd_kcontrol *vmaster; - static char *ca0106_remove_ctls[] = { + static const char * const ca0106_remove_ctls[] = { "Master Mono Playback Switch", "Master Mono Playback Volume", "3D Control - Switch", @@ -801,7 +801,7 @@ int snd_ca0106_mixer(struct snd_ca0106 *emu) "Surround Phase Inversion Playback Switch", NULL }; - static char *ca0106_rename_ctls[] = { + static const char * const ca0106_rename_ctls[] = { "Master Playback Switch", "Capture Switch", "Master Playback Volume", "Capture Volume", "Line Playback Switch", "AC97 Line Capture Switch", @@ -875,7 +875,7 @@ struct ca0106_vol_tbl { unsigned int reg; }; -static struct ca0106_vol_tbl saved_volumes[NUM_SAVED_VOLUMES] = { +static const struct ca0106_vol_tbl saved_volumes[NUM_SAVED_VOLUMES] = { { CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2 }, { CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2 }, { CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2 }, -- cgit v1.2.3 From 6e0e75d94e7a84fe65ce75dee93857292426a44d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:46 +0100 Subject: ALSA: ctxfi: More constifications Apply const prefix to each possible place: the DAIO tables and the register offset table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-32-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctdaio.c | 4 ++-- sound/pci/ctxfi/ctresource.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 27441d498968..4cb47b5a792c 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -29,7 +29,7 @@ struct daio_rsc_idx { unsigned short right; }; -static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { +static const struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { [LINEO1] = {.left = 0x00, .right = 0x01}, [LINEO2] = {.left = 0x18, .right = 0x19}, [LINEO3] = {.left = 0x08, .right = 0x09}, @@ -40,7 +40,7 @@ static struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { [SPDIFI1] = {.left = 0x95, .right = 0x9d}, }; -static struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { +static const struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { [LINEO1] = {.left = 0x40, .right = 0x41}, [LINEO2] = {.left = 0x60, .right = 0x61}, [LINEO3] = {.left = 0x50, .right = 0x51}, diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c index 0bb5696e44b3..61e51e35ba16 100644 --- a/sound/pci/ctxfi/ctresource.c +++ b/sound/pci/ctxfi/ctresource.c @@ -92,7 +92,7 @@ int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx) return 0; } -static unsigned char offset_in_audio_slot_block[NUM_RSCTYP] = { +static const unsigned char offset_in_audio_slot_block[NUM_RSCTYP] = { /* SRC channel is at Audio Ring slot 1 every 16 slots. */ [SRC] = 0x1, [AMIXER] = 0x4, -- cgit v1.2.3 From 9ca7a0c97923a88d9bbb645ea6e3e1ffe2bd5661 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:47 +0100 Subject: ALSA: asihpi: More constifications Apply const prefix to each possible place: the static tables for formats, parameters, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-33-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 4 ++-- sound/pci/asihpi/hpimsgx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 1fdb9f9f0ae0..a9540c2c4a1a 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -300,7 +300,7 @@ static void print_hwparams(struct snd_pcm_substream *substream, #define INVALID_FORMAT (__force snd_pcm_format_t)(-1) -static snd_pcm_format_t hpi_to_alsa_formats[] = { +static const snd_pcm_format_t hpi_to_alsa_formats[] = { INVALID_FORMAT, /* INVALID */ SNDRV_PCM_FORMAT_U8, /* HPI_FORMAT_PCM8_UNSIGNED 1 */ SNDRV_PCM_FORMAT_S16, /* HPI_FORMAT_PCM16_SIGNED 2 */ @@ -2073,7 +2073,7 @@ static int snd_asihpi_meter_info(struct snd_kcontrol *kcontrol, } /* linear values for 10dB steps */ -static int log2lin[] = { +static const int log2lin[] = { 0x7FFFFFFF, /* 0dB */ 679093956, 214748365, diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c index 5fb0b98bec30..f7427f8eb630 100644 --- a/sound/pci/asihpi/hpimsgx.c +++ b/sound/pci/asihpi/hpimsgx.c @@ -17,7 +17,7 @@ Extended Message Function With Response Caching #include "hpimsgx.h" #include "hpidebug.h" -static struct pci_device_id asihpi_pci_tbl[] = { +static const struct pci_device_id asihpi_pci_tbl[] = { #include "hpipcida.h" }; -- cgit v1.2.3 From 066c044b054a4445ee9e0219c77cda6d2f964570 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:48 +0100 Subject: ALSA: atiixp: More constifications Apply const prefix to the static register tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-34-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 4a840734e7a7..85d3b4e95489 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1407,7 +1407,7 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; - static unsigned int codec_skip[NUM_ATI_CODECS] = { + static const unsigned int codec_skip[NUM_ATI_CODECS] = { ATI_REG_ISR_CODEC0_NOT_READY, ATI_REG_ISR_CODEC1_NOT_READY, ATI_REG_ISR_CODEC2_NOT_READY, diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 3ec34e78ffef..ae88217d685a 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1050,7 +1050,7 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; - static unsigned int codec_skip[NUM_ATI_CODECS] = { + static const unsigned int codec_skip[NUM_ATI_CODECS] = { ATI_REG_ISR_CODEC0_NOT_READY, ATI_REG_ISR_CODEC1_NOT_READY, ATI_REG_ISR_CODEC2_NOT_READY, -- cgit v1.2.3 From 96d5ebf25e131b4e824754ec622b89260341302c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:49 +0100 Subject: ALSA: es1938: More constifications Apply const prefix to the static register table and its callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-35-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 8336b20fbafc..b4a0adf7451c 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1420,7 +1420,7 @@ static void snd_es1938_chip_init(struct es1938 *chip) * PM support */ -static unsigned char saved_regs[SAVED_REG_SIZE+1] = { +static const unsigned char saved_regs[SAVED_REG_SIZE+1] = { 0x14, 0x1a, 0x1c, 0x3a, 0x3c, 0x3e, 0x36, 0x38, 0x50, 0x52, 0x60, 0x61, 0x62, 0x63, 0x64, 0x68, 0x69, 0x6a, 0x6b, 0x6d, 0x6e, 0x6f, 0x7c, 0x7d, @@ -1432,7 +1432,8 @@ static int es1938_suspend(struct device *dev) { struct snd_card *card = dev_get_drvdata(dev); struct es1938 *chip = card->private_data; - unsigned char *s, *d; + const unsigned char *s; + unsigned char *d; snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); @@ -1454,7 +1455,8 @@ static int es1938_resume(struct device *dev) struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct es1938 *chip = card->private_data; - unsigned char *s, *d; + const unsigned char *s; + unsigned char *d; if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { -- cgit v1.2.3 From 096da809f6e87c2ec96e6d2eab6f8f2fbf3c2b65 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:50 +0100 Subject: ALSA: es1968: More constifications Apply const prefix to the quirk white/black lists. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-36-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index affd3e8d7a67..d26004b35a81 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2631,7 +2631,7 @@ struct ess_device_list { unsigned short vendor; /* subsystem vendor id */ }; -static struct ess_device_list pm_whitelist[] = { +static const struct ess_device_list pm_whitelist[] = { { TYPE_MAESTRO2E, 0x0e11 }, /* Compaq Armada */ { TYPE_MAESTRO2E, 0x1028 }, { TYPE_MAESTRO2E, 0x103c }, @@ -2642,7 +2642,7 @@ static struct ess_device_list pm_whitelist[] = { { TYPE_MAESTRO2, 0x125d }, /* a PCI card, e.g. SF64-PCE2 */ }; -static struct ess_device_list mpu_blacklist[] = { +static const struct ess_device_list mpu_blacklist[] = { { TYPE_MAESTRO2, 0x125d }, }; -- cgit v1.2.3 From 5f3aca1065e1b5a7f26ba2c991d4ebac6a69c9e8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:51 +0100 Subject: ALSA: cmipci: More constifications Apply const prefix to the static tables for rates, ports and registers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-37-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 7f91742ed6f0..7363d61eaec2 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -586,7 +586,7 @@ static int snd_cmipci_clear_bit_b(struct cmipci *cm, unsigned int cmd, unsigned * calculate frequency */ -static unsigned int rates[] = { 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 }; +static const unsigned int rates[] = { 5512, 11025, 22050, 44100, 8000, 16000, 32000, 48000 }; static unsigned int snd_cmipci_rate_freq(unsigned int rate) { @@ -2826,7 +2826,7 @@ static void query_chip(struct cmipci *cm) #ifdef SUPPORT_JOYSTICK static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) { - static int ports[] = { 0x201, 0x200, 0 }; /* FIXME: majority is 0x201? */ + static const int ports[] = { 0x201, 0x200, 0 }; /* FIXME: majority is 0x201? */ struct gameport *gp; struct resource *r = NULL; int i, io_port = 0; @@ -3289,7 +3289,7 @@ static void snd_cmipci_remove(struct pci_dev *pci) /* * power management */ -static unsigned char saved_regs[] = { +static const unsigned char saved_regs[] = { CM_REG_FUNCTRL1, CM_REG_CHFORMAT, CM_REG_LEGACY_CTRL, CM_REG_MISC_CTRL, CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_MIXER3, CM_REG_PLL, CM_REG_CH0_FRAME1, CM_REG_CH0_FRAME2, @@ -3297,7 +3297,7 @@ static unsigned char saved_regs[] = { CM_REG_INT_STATUS, CM_REG_INT_HLDCLR, CM_REG_FUNCTRL0, }; -static unsigned char saved_mixers[] = { +static const unsigned char saved_mixers[] = { SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, -- cgit v1.2.3 From 121f46be2c6cd8b90c9c7a28b7ae2dc084425478 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:52 +0100 Subject: ALSA: sparc: More constifications Apply const prefix to the static tables for rates, bits and strings. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-38-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sparc/cs4231.c | 4 ++-- sound/sparc/dbri.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 59f812b5ce59..0eed5f79a2bf 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -184,7 +184,7 @@ struct snd_cs4231 { * Some variables */ -static unsigned char freq_bits[14] = { +static const unsigned char freq_bits[14] = { /* 5510 */ 0x00 | CS4231_XTAL2, /* 6620 */ 0x0E | CS4231_XTAL2, /* 8000 */ 0x00 | CS4231_XTAL1, @@ -218,7 +218,7 @@ static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime) &hw_constraints_rates); } -static unsigned char snd_cs4231_original_image[32] = +static const unsigned char snd_cs4231_original_image[32] = { 0x00, /* 00/00 - lic */ 0x00, /* 01/01 - ric */ diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index aaa1493b9ef9..cf7049999261 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -104,7 +104,7 @@ module_param(dbri_debug, int, 0644); MODULE_PARM_DESC(dbri_debug, "Debug value for Sun DBRI soundcard."); #ifdef DBRI_DEBUG -static char *cmds[] = { +static const char * const cmds[] = { "WAIT", "PAUSE", "JUMP", "IIQ", "REX", "SDP", "CDP", "DTS", "SSP", "CHI", "NT", "TE", "CDEC", "TEST", "CDM", "RESRV" }; -- cgit v1.2.3 From 51d7847a2d81ac6779b62fabd722b49b3b664de9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:53 +0100 Subject: ALSA: info: More constifications Apply const prefix to the string array and its callers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-39-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/info.c b/sound/core/info.c index e051a029ccfb..6801d8160866 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -20,7 +20,7 @@ int snd_info_check_reserved_words(const char *str) { - static char *reserved[] = + static const char * const reserved[] = { "version", "meminfo", @@ -35,7 +35,7 @@ int snd_info_check_reserved_words(const char *str) "seq", NULL }; - char **xstr = reserved; + const char * const *xstr = reserved; while (*xstr) { if (!strcmp(*xstr, str)) -- cgit v1.2.3 From f98903fce976f261b5cfc28a1c86163a7c5b01b9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:54 +0100 Subject: ALSA: jack: More constification Apply const prefix to the static jack switch table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-40-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/jack.c b/sound/core/jack.c index 6590b1b8d62a..503c8af79d55 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -19,7 +19,7 @@ struct snd_jack_kctl { }; #ifdef CONFIG_SND_JACK_INPUT_DEV -static int jack_switch_types[SND_JACK_SWITCH_TYPES] = { +static const int jack_switch_types[SND_JACK_SWITCH_TYPES] = { SW_HEADPHONE_INSERT, SW_MICROPHONE_INSERT, SW_LINEOUT_INSERT, -- cgit v1.2.3 From b40fe4bbc76bf6be655f9ba975dc91c6a72fe79e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:55 +0100 Subject: ALSA: oss: More constifications Apply const prefix to the static tables for strings and formats. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-41-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/oss/mixer_oss.c | 2 +- sound/core/oss/pcm_plugin.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 26502294f7d8..f702c96a7478 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -1109,7 +1109,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, /* */ #define MIXER_VOL(name) [SOUND_MIXER_##name] = #name -static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = { +static const char * const oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = { MIXER_VOL(VOLUME), MIXER_VOL(BASS), MIXER_VOL(TREBLE), diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 31cb2acf8afc..240e4702c098 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -288,7 +288,7 @@ static int snd_pcm_plug_formats(const struct snd_mask *mask, return snd_mask_test(&formats, (__force int)format); } -static snd_pcm_format_t preferred_formats[] = { +static const snd_pcm_format_t preferred_formats[] = { SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_FORMAT_S16_BE, SNDRV_PCM_FORMAT_U16_LE, -- cgit v1.2.3 From edb87ed5f9f180fecca64f803eb1f595291d519d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:56 +0100 Subject: ALSA: rawmidi: More constification Apply const prefix to the static flag info table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-42-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7bc95c24f724..20dd08e1f675 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -249,7 +249,7 @@ static int assign_substream(struct snd_rawmidi *rmidi, int subdevice, { struct snd_rawmidi_substream *substream; struct snd_rawmidi_str *s = &rmidi->streams[stream]; - static unsigned int info_flags[2] = { + static const unsigned int info_flags[2] = { [SNDRV_RAWMIDI_STREAM_OUTPUT] = SNDRV_RAWMIDI_INFO_OUTPUT, [SNDRV_RAWMIDI_STREAM_INPUT] = SNDRV_RAWMIDI_INFO_INPUT, }; -- cgit v1.2.3 From e3de2a406ef525302e8a0805a753af13db26c844 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:57 +0100 Subject: ALSA: opl3: More constifications Apply const prefix to the static tables for drum, volume and notes. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-43-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_drums.c | 2 +- sound/drivers/opl3/opl3_midi.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/drivers/opl3/opl3_drums.c b/sound/drivers/opl3/opl3_drums.c index 318cd8a2ee3a..ccc49f39404d 100644 --- a/sound/drivers/opl3/opl3_drums.c +++ b/sound/drivers/opl3/opl3_drums.c @@ -7,7 +7,7 @@ #include "opl3_voice.h" -static char snd_opl3_drum_table[47] = +static const char snd_opl3_drum_table[47] = { OPL3_BASSDRUM_ON, OPL3_BASSDRUM_ON, OPL3_HIHAT_ON, /* 35 - 37 */ OPL3_SNAREDRUM_ON, OPL3_HIHAT_ON, OPL3_SNAREDRUM_ON, /* 38 - 40 */ diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 280cc79870cf..2f6e8023e05c 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -23,7 +23,7 @@ static void snd_opl3_note_off_unsafe(void *p, int note, int vel, * it saves a lot of log() calculations. (Rob Hooft ) */ -static char opl3_volume_table[128] = +static const char opl3_volume_table[128] = { -63, -48, -40, -35, -32, -29, -27, -26, -24, -23, -21, -20, -19, -18, -18, -17, @@ -69,7 +69,7 @@ void snd_opl3_calc_volume(unsigned char *volbyte, int vel, /* * Converts the note frequency to block and fnum values for the FM chip */ -static short opl3_note_table[16] = +static const short opl3_note_table[16] = { 305, 323, /* for pitch bending, -2 semitones */ 343, 363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647, @@ -266,7 +266,7 @@ static void snd_opl3_start_timer(struct snd_opl3 *opl3) /* ------------------------------ */ -static int snd_opl3_oss_map[MAX_OPL3_VOICES] = { +static const int snd_opl3_oss_map[MAX_OPL3_VOICES] = { 0, 1, 2, 9, 10, 11, 6, 7, 8, 15, 16, 17, 3, 4 ,5, 12, 13, 14 }; -- cgit v1.2.3 From f3c0916946706f6aa8e9041f41378d9c26ba57d6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:58 +0100 Subject: ALSA: cmi8328: More constifications Apply const prefix to the static resource tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-44-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/cmi8328.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/isa/cmi8328.c b/sound/isa/cmi8328.c index 250db35109a2..faca5dd95bfe 100644 --- a/sound/isa/cmi8328.c +++ b/sound/isa/cmi8328.c @@ -32,7 +32,7 @@ MODULE_LICENSE("GPL"); #endif /* I/O port is configured by jumpers on the card to one of these */ -static int cmi8328_ports[] = { 0x530, 0xe80, 0xf40, 0x604 }; +static const int cmi8328_ports[] = { 0x530, 0xe80, 0xf40, 0x604 }; #define CMI8328_MAX ARRAY_SIZE(cmi8328_ports) static int index[CMI8328_MAX] = {[0 ... (CMI8328_MAX-1)] = -1}; @@ -193,7 +193,7 @@ static int snd_cmi8328_mixer(struct snd_wss *chip) } /* find index of an item in "-1"-ended array */ -static int array_find(int array[], int item) +static int array_find(const int array[], int item) { int i; @@ -204,7 +204,7 @@ static int array_find(int array[], int item) return -1; } /* the same for long */ -static int array_find_l(long array[], long item) +static int array_find_l(const long array[], long item) { int i; @@ -224,16 +224,16 @@ static int snd_cmi8328_probe(struct device *pdev, unsigned int ndev) struct resource *res; #endif int err, pos; - static long mpu_ports[] = { 0x330, 0x300, 0x310, 0x320, 0x332, 0x334, + static const long mpu_ports[] = { 0x330, 0x300, 0x310, 0x320, 0x332, 0x334, 0x336, -1 }; - static u8 mpu_port_bits[] = { 3, 0, 1, 2, 4, 5, 6 }; - static int mpu_irqs[] = { 9, 7, 5, 3, -1 }; - static u8 mpu_irq_bits[] = { 3, 2, 1, 0 }; - static int irqs[] = { 9, 10, 11, 7, -1 }; - static u8 irq_bits[] = { 2, 3, 4, 1 }; - static int dma1s[] = { 3, 1, 0, -1 }; - static u8 dma_bits[] = { 3, 2, 1 }; - static int dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, {0, -1} }; + static const u8 mpu_port_bits[] = { 3, 0, 1, 2, 4, 5, 6 }; + static const int mpu_irqs[] = { 9, 7, 5, 3, -1 }; + static const u8 mpu_irq_bits[] = { 3, 2, 1, 0 }; + static const int irqs[] = { 9, 10, 11, 7, -1 }; + static const u8 irq_bits[] = { 2, 3, 4, 1 }; + static const int dma1s[] = { 3, 1, 0, -1 }; + static const u8 dma_bits[] = { 3, 2, 1 }; + static const int dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, {0, -1} }; u16 port = cmi8328_ports[ndev]; u8 val; -- cgit v1.2.3 From 58b5b363702de28e95541efeeb04626a0f2b43c4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:47:59 +0100 Subject: ALSA: cs423x: More constification Apply const prefix to the static mapping table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-45-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4236_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index ca6646f9b58d..4a028f42bb74 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -80,7 +80,7 @@ * */ -static unsigned char snd_cs4236_ext_map[18] = { +static const unsigned char snd_cs4236_ext_map[18] = { /* CS4236_LEFT_LINE */ 0xff, /* CS4236_RIGHT_LINE */ 0xff, /* CS4236_LEFT_MIC */ 0xdf, -- cgit v1.2.3 From 2a076d0af49875d2806ff300b632ebc6a43720ee Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:00 +0100 Subject: ALSA: sb: More constifications Apply const prefix to each possible place: the static tables for the resources, controls, registers, values and parameters. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-46-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000.c | 16 ++++++++-------- sound/isa/sb/jazz16.c | 10 +++++----- sound/isa/sb/sb16.c | 8 ++++---- sound/isa/sb/sb8.c | 2 +- sound/isa/sb/sb_mixer.c | 38 +++++++++++++++++++------------------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 455dd5fa3ccb..0aa545ac6e60 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -222,7 +222,7 @@ init_dma(struct snd_emu8000 *emu) /* * initialization arrays; from ADIP */ -static unsigned short init1[128] = { +static const unsigned short init1[128] = { 0x03ff, 0x0030, 0x07ff, 0x0130, 0x0bff, 0x0230, 0x0fff, 0x0330, 0x13ff, 0x0430, 0x17ff, 0x0530, 0x1bff, 0x0630, 0x1fff, 0x0730, 0x23ff, 0x0830, 0x27ff, 0x0930, 0x2bff, 0x0a30, 0x2fff, 0x0b30, @@ -244,7 +244,7 @@ static unsigned short init1[128] = { 0xf3ff, 0x0c30, 0xf7ff, 0x0d30, 0xfbff, 0x0e30, 0xffff, 0x0f30, }; -static unsigned short init2[128] = { +static const unsigned short init2[128] = { 0x03ff, 0x8030, 0x07ff, 0x8130, 0x0bff, 0x8230, 0x0fff, 0x8330, 0x13ff, 0x8430, 0x17ff, 0x8530, 0x1bff, 0x8630, 0x1fff, 0x8730, 0x23ff, 0x8830, 0x27ff, 0x8930, 0x2bff, 0x8a30, 0x2fff, 0x8b30, @@ -266,7 +266,7 @@ static unsigned short init2[128] = { 0xf3ff, 0x8c30, 0xf7ff, 0x8d30, 0xfbff, 0x8e30, 0xffff, 0x8f30, }; -static unsigned short init3[128] = { +static const unsigned short init3[128] = { 0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5, 0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x8F7C, 0x167E, 0xF254, 0x0000, 0x842A, 0x0001, 0x852A, 0x18E6, 0x8BAA, 0x1B6D, 0xF234, @@ -288,7 +288,7 @@ static unsigned short init3[128] = { 0x1342, 0xD36E, 0x3EC7, 0xB3FF, 0x0000, 0x8365, 0x1420, 0x9570, }; -static unsigned short init4[128] = { +static const unsigned short init4[128] = { 0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5, 0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x0F7C, 0x167E, 0x7254, 0x0000, 0x842A, 0x0001, 0x852A, 0x18E6, 0x0BAA, 0x1B6D, 0x7234, @@ -315,10 +315,10 @@ static unsigned short init4[128] = { * is meant to work */ static void -send_array(struct snd_emu8000 *emu, unsigned short *data, int size) +send_array(struct snd_emu8000 *emu, const unsigned short *data, int size) { int i; - unsigned short *p; + const unsigned short *p; p = data; for (i = 0; i < size; i++, p++) @@ -548,7 +548,7 @@ snd_emu8000_init_hw(struct snd_emu8000 *emu) * Bass/Treble Equalizer *----------------------------------------------------------------*/ -static unsigned short bass_parm[12][3] = { +static const unsigned short bass_parm[12][3] = { {0xD26A, 0xD36A, 0x0000}, /* -12 dB */ {0xD25B, 0xD35B, 0x0000}, /* -8 */ {0xD24C, 0xD34C, 0x0000}, /* -6 */ @@ -563,7 +563,7 @@ static unsigned short bass_parm[12][3] = { {0xC26A, 0xC36A, 0x0002}, /* +12 dB */ }; -static unsigned short treble_parm[12][9] = { +static const unsigned short treble_parm[12][9] = { {0x821E, 0xC26A, 0x031E, 0xC36A, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001}, /* -12 dB */ {0x821E, 0xC25B, 0x031E, 0xC35B, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001}, {0x821E, 0xC24C, 0x031E, 0xC34C, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001}, diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c index 7a313ff589c7..ee379bbf70a4 100644 --- a/sound/isa/sb/jazz16.c +++ b/sound/isa/sb/jazz16.c @@ -158,9 +158,9 @@ err_unmap: static int jazz16_configure_board(struct snd_sb *chip, int mpu_irq) { - static unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, + static const unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, 0, 2, 5, 0, 0, 0, 0, 6 }; - static unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; + static const unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; if (jazz_dma_bits[chip->dma8] == 0 || jazz_dma_bits[chip->dma16] == 0 || @@ -224,9 +224,9 @@ static int snd_jazz16_probe(struct device *devptr, unsigned int dev) struct snd_card_jazz16 *jazz16; struct snd_sb *chip; struct snd_opl3 *opl3; - static int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; - static int possible_dmas8[] = {1, 3, -1}; - static int possible_dmas16[] = {5, 7, -1}; + static const int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; + static const int possible_dmas8[] = {1, 3, -1}; + static const int possible_dmas16[] = {5, 7, -1}; int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq; err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE, diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index b528238675fe..479197c13803 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -509,9 +509,9 @@ static int snd_sb16_isa_match(struct device *pdev, unsigned int dev) static int snd_sb16_isa_probe(struct device *pdev, unsigned int dev) { int err; - static int possible_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dmas8[] = {1, 3, 0, -1}; - static int possible_dmas16[] = {5, 6, 7, -1}; + static const int possible_irqs[] = {5, 9, 10, 7, -1}; + static const int possible_dmas8[] = {1, 3, 0, -1}; + static const int possible_dmas16[] = {5, 6, 7, -1}; if (irq[dev] == SNDRV_AUTO_IRQ) { if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { @@ -535,7 +535,7 @@ static int snd_sb16_isa_probe(struct device *pdev, unsigned int dev) if (port[dev] != SNDRV_AUTO_PORT) return snd_sb16_isa_probe1(dev, pdev); else { - static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; + static const int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index d67eae3988bd..438109f167d6 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -111,7 +111,7 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) goto _err; } else { /* auto-probe legacy ports */ - static unsigned long possible_ports[] = { + static const unsigned long possible_ports[] = { 0x220, 0x240, 0x260, }; int i; diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 789dcf279a26..3f703b4a304d 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -494,14 +494,14 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty * SB 2.0 specific mixer elements */ -static struct sbmix_elem snd_sb20_controls[] = { +static const struct sbmix_elem snd_sb20_controls[] = { SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) }; -static unsigned char snd_sb20_init_values[][2] = { +static const unsigned char snd_sb20_init_values[][2] = { { SB_DSP20_MASTER_DEV, 0 }, { SB_DSP20_FM_DEV, 0 }, }; @@ -509,7 +509,7 @@ static unsigned char snd_sb20_init_values[][2] = { /* * SB Pro specific mixer elements */ -static struct sbmix_elem snd_sbpro_controls[] = { +static const struct sbmix_elem snd_sbpro_controls[] = { SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), SB_DOUBLE("PCM Playback Volume", @@ -529,7 +529,7 @@ static struct sbmix_elem snd_sbpro_controls[] = { SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1) }; -static unsigned char snd_sbpro_init_values[][2] = { +static const unsigned char snd_sbpro_init_values[][2] = { { SB_DSP_MASTER_DEV, 0 }, { SB_DSP_PCM_DEV, 0 }, { SB_DSP_FM_DEV, 0 }, @@ -538,7 +538,7 @@ static unsigned char snd_sbpro_init_values[][2] = { /* * SB16 specific mixer elements */ -static struct sbmix_elem snd_sb16_controls[] = { +static const struct sbmix_elem snd_sb16_controls[] = { SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), SB_DOUBLE("PCM Playback Volume", @@ -576,7 +576,7 @@ static struct sbmix_elem snd_sb16_controls[] = { SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) }; -static unsigned char snd_sb16_init_values[][2] = { +static const unsigned char snd_sb16_init_values[][2] = { { SB_DSP4_MASTER_DEV + 0, 0 }, { SB_DSP4_MASTER_DEV + 1, 0 }, { SB_DSP4_PCM_DEV + 0, 0 }, @@ -592,7 +592,7 @@ static unsigned char snd_sb16_init_values[][2] = { /* * DT019x specific mixer elements */ -static struct sbmix_elem snd_dt019x_controls[] = { +static const struct sbmix_elem snd_dt019x_controls[] = { /* ALS4000 below has some parts which we might be lacking, * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ SB_DOUBLE("Master Playback Volume", @@ -622,7 +622,7 @@ static struct sbmix_elem snd_dt019x_controls[] = { } }; -static unsigned char snd_dt019x_init_values[][2] = { +static const unsigned char snd_dt019x_init_values[][2] = { { SB_DT019X_MASTER_DEV, 0 }, { SB_DT019X_PCM_DEV, 0 }, { SB_DT019X_SYNTH_DEV, 0 }, @@ -637,7 +637,7 @@ static unsigned char snd_dt019x_init_values[][2] = { /* * ALS4000 specific mixer elements */ -static struct sbmix_elem snd_als4000_controls[] = { +static const struct sbmix_elem snd_als4000_controls[] = { SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), SB_DOUBLE("Synth Playback Switch", @@ -671,7 +671,7 @@ static struct sbmix_elem snd_als4000_controls[] = { #endif }; -static unsigned char snd_als4000_init_values[][2] = { +static const unsigned char snd_als4000_init_values[][2] = { { SB_DSP4_MASTER_DEV + 0, 0 }, { SB_DSP4_MASTER_DEV + 1, 0 }, { SB_DSP4_PCM_DEV + 0, 0 }, @@ -689,9 +689,9 @@ static unsigned char snd_als4000_init_values[][2] = { /* */ static int snd_sbmixer_init(struct snd_sb *chip, - struct sbmix_elem *controls, + const struct sbmix_elem *controls, int controls_count, - unsigned char map[][2], + const unsigned char map[][2], int map_count, char *name) { @@ -800,14 +800,14 @@ int snd_sbmixer_new(struct snd_sb *chip) } #ifdef CONFIG_PM -static unsigned char sb20_saved_regs[] = { +static const unsigned char sb20_saved_regs[] = { SB_DSP20_MASTER_DEV, SB_DSP20_PCM_DEV, SB_DSP20_FM_DEV, SB_DSP20_CD_DEV, }; -static unsigned char sbpro_saved_regs[] = { +static const unsigned char sbpro_saved_regs[] = { SB_DSP_MASTER_DEV, SB_DSP_PCM_DEV, SB_DSP_PLAYBACK_FILT, @@ -819,7 +819,7 @@ static unsigned char sbpro_saved_regs[] = { SB_DSP_CAPTURE_FILT, }; -static unsigned char sb16_saved_regs[] = { +static const unsigned char sb16_saved_regs[] = { SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, SB_DSP4_3DSE, SB_DSP4_BASS_DEV, SB_DSP4_BASS_DEV + 1, @@ -837,7 +837,7 @@ static unsigned char sb16_saved_regs[] = { SB_DSP4_MIC_AGC }; -static unsigned char dt019x_saved_regs[] = { +static const unsigned char dt019x_saved_regs[] = { SB_DT019X_MASTER_DEV, SB_DT019X_PCM_DEV, SB_DT019X_SYNTH_DEV, @@ -850,7 +850,7 @@ static unsigned char dt019x_saved_regs[] = { SB_DT019X_CAPTURE_SW, }; -static unsigned char als4000_saved_regs[] = { +static const unsigned char als4000_saved_regs[] = { /* please verify in dsheet whether regs to be added are actually real H/W or just dummy */ SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, @@ -872,7 +872,7 @@ static unsigned char als4000_saved_regs[] = { SB_ALS4000_CR3_CONFIGURATION, }; -static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +static void save_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs) { unsigned char *val = chip->saved_regs; if (snd_BUG_ON(num_regs > ARRAY_SIZE(chip->saved_regs))) @@ -881,7 +881,7 @@ static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) *val++ = snd_sbmixer_read(chip, *regs++); } -static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +static void restore_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs) { unsigned char *val = chip->saved_regs; if (snd_BUG_ON(num_regs > ARRAY_SIZE(chip->saved_regs))) -- cgit v1.2.3 From 350f613f37e63ca0162e6ea42df4c1f9c5cc49db Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:01 +0100 Subject: ALSA: cmi8330: More constifications Apply const prefix to the static tables for the register, controls and callbacks. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-47-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/cmi8330.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 61d6944a69c7..4669eb0cc8ce 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -120,7 +120,7 @@ static int pnp_registered; #define CMI8330_LINGAIN 25 #define CMI8330_CDINGAIN 26 -static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] = +static const unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] = { 0x40, /* 16 - recording mux (SB-mixer-enabled) */ #ifdef ENABLE_SB_MIXER @@ -235,7 +235,7 @@ WSS_SINGLE(SNDRV_CTL_NAME_IEC958("Input ", PLAYBACK, SWITCH), 0, }; #ifdef ENABLE_SB_MIXER -static struct sbmix_elem cmi8330_sb_mixers[] = { +static const struct sbmix_elem cmi8330_sb_mixers[] = { SB_DOUBLE("SB Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15), SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15), @@ -253,7 +253,7 @@ SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6 SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), }; -static unsigned char cmi8330_sb_init_values[][2] = { +static const unsigned char cmi8330_sb_init_values[][2] = { { SB_DSP4_MASTER_DEV + 0, 0 }, { SB_DSP4_MASTER_DEV + 1, 0 }, { SB_DSP4_PCM_DEV + 0, 0 }, @@ -428,7 +428,7 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) struct snd_pcm *pcm; const struct snd_pcm_ops *ops; int err; - static snd_pcm_open_callback_t cmi_open_callbacks[2] = { + static const snd_pcm_open_callback_t cmi_open_callbacks[2] = { snd_cmi8330_playback_open, snd_cmi8330_capture_open }; -- cgit v1.2.3 From 748f51812182788703c3bf664282a41e70ae3386 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:02 +0100 Subject: ALSA: es1688: More constifications Apply const prefix to the static resource tables and init tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-48-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688.c | 6 +++--- sound/isa/es1688/es1688_lib.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 9be89377171b..ff3a05ad99c0 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -84,9 +84,9 @@ static int snd_es1688_legacy_create(struct snd_card *card, struct device *dev, unsigned int n) { struct snd_es1688 *chip = card->private_data; - static long possible_ports[] = {0x220, 0x240, 0x260}; - static int possible_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dmas[] = {1, 3, 0, -1}; + static const long possible_ports[] = {0x220, 0x240, 0x260}; + static const int possible_irqs[] = {5, 9, 10, 7, -1}; + static const int possible_dmas[] = {1, 3, 0, -1}; int i, error; diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 1568d0bfd1a8..1816e55c6edf 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -180,7 +180,7 @@ static int snd_es1688_probe(struct snd_es1688 *chip) static int snd_es1688_init(struct snd_es1688 * chip, int enable) { - static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; + static const int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; unsigned long flags; int cfg, irq_bits, dma, dma_bits, tmp, tmp1; @@ -946,7 +946,7 @@ ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), #define ES1688_INIT_TABLE_SIZE (sizeof(snd_es1688_init_table)/2) -static unsigned char snd_es1688_init_table[][2] = { +static const unsigned char snd_es1688_init_table[][2] = { { ES1688_MASTER_DEV, 0 }, { ES1688_PCM_DEV, 0 }, { ES1688_LINE_DEV, 0 }, -- cgit v1.2.3 From fce6709730255f3b81e98ea3b78859b079521077 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:03 +0100 Subject: ALSA: es18xx: More constifications Apply const prefix to the static map tables and the static resource tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-49-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 6ce5b5c76980..d1135f6ae104 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -965,7 +965,7 @@ static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_ele static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - static unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3}; + static const unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3}; struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int muxSource = snd_es18xx_mixer_read(chip, 0x1c) & 0x07; if (!(chip->version == 0x1869 || chip->version == 0x1879)) { @@ -982,7 +982,7 @@ static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - static unsigned char map4Source[4] = {0, 2, 6, 7}; + static const unsigned char map4Source[4] = {0, 2, 6, 7}; struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char val = ucontrol->value.enumerated.item[0]; unsigned char retVal = 0; @@ -2173,8 +2173,8 @@ static int snd_es18xx_isa_probe1(int dev, struct device *devptr) static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev) { int err; - static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; - static int possible_dmas[] = {1, 0, 3, 5, -1}; + static const int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; + static const int possible_dmas[] = {1, 0, 3, 5, -1}; if (irq[dev] == SNDRV_AUTO_IRQ) { if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { @@ -2198,7 +2198,7 @@ static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev) if (port[dev] != SNDRV_AUTO_PORT) { return snd_es18xx_isa_probe1(dev, pdev); } else { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; + static const unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; -- cgit v1.2.3 From 15a1af95d65729d35071445b9459c1e22f776347 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:04 +0100 Subject: ALSA: gus: More constifications Apply const prefix to each possible place: the static resource tables, the volume table, etc. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-50-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_io.c | 2 +- sound/isa/gus/gus_main.c | 4 ++-- sound/isa/gus/gus_volume.c | 9 +++++---- sound/isa/gus/gusclassic.c | 6 +++--- sound/isa/gus/gusextreme.c | 10 +++++----- sound/isa/gus/gusmax.c | 6 +++--- sound/isa/gus/interwave.c | 10 +++++----- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c index 0ab550bc80f2..fb7b5e2636b8 100644 --- a/sound/isa/gus/gus_io.c +++ b/sound/isa/gus/gus_io.c @@ -403,7 +403,7 @@ void snd_gf1_select_active_voices(struct snd_gus_card * gus) { unsigned short voices; - static unsigned short voices_tbl[32 - 14 + 1] = + static const unsigned short voices_tbl[32 - 14 + 1] = { 44100, 41160, 38587, 36317, 34300, 32494, 30870, 29400, 28063, 26843, 25725, 24696, 23746, 22866, 22050, 21289, 20580, 19916, 19293 diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index e9fc333c0fcb..afc088f0377c 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -267,9 +267,9 @@ static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches) struct snd_card *card; unsigned long flags; int irq, dma1, dma2; - static unsigned char irqs[16] = + static const unsigned char irqs[16] = {0, 0, 1, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7}; - static unsigned char dmas[8] = + static const unsigned char dmas[8] = {6, 1, 0, 2, 0, 3, 4, 5}; if (snd_BUG_ON(!gus)) diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c index 39a2e5bd6c0a..ed72196a361b 100644 --- a/sound/isa/gus/gus_volume.c +++ b/sound/isa/gus/gus_volume.c @@ -62,7 +62,7 @@ unsigned int snd_gf1_calc_ramp_rate(struct snd_gus_card * gus, unsigned short end, unsigned int us) { - static unsigned char vol_rates[19] = + static const unsigned char vol_rates[19] = { 23, 24, 26, 28, 29, 31, 32, 34, 36, 37, 39, 40, 42, 44, 45, 47, @@ -113,7 +113,7 @@ unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int fr short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) { - static short vibrato_table[] = + static const short vibrato_table[] = { 0, 0, 32, 592, 61, 1175, 93, 1808, 124, 2433, 152, 3007, 182, 3632, 213, 4290, @@ -121,7 +121,8 @@ short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) }; long depth; - short *vi1, *vi2, pcents, v1; + const short *vi1, *vi2; + short pcents, v1; pcents = cents < 0 ? -cents : cents; for (vi1 = vibrato_table, vi2 = vi1 + 2; pcents > *vi2; vi1 = vi2, vi2 += 2); @@ -145,7 +146,7 @@ short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) unsigned short snd_gf1_compute_pitchbend(unsigned short pitchbend, unsigned short sens) { - static long log_table[] = {1024, 1085, 1149, 1218, 1290, 1367, 1448, 1534, 1625, 1722, 1825, 1933}; + static const long log_table[] = {1024, 1085, 1149, 1218, 1290, 1367, 1448, 1534, 1625, 1722, 1825, 1933}; int wheel, sensitivity; unsigned int mantissa, f1, f2; unsigned short semitones, f1_index, f2_index, f1_power, f2_power; diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index f7e869771d16..7419b1939754 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -67,9 +67,9 @@ static int snd_gusclassic_create(struct snd_card *card, struct device *dev, unsigned int n, struct snd_gus_card **rgus) { - static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260}; - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; - static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; + static const long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260}; + static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; + static const int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int i, error; diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 8cf366bbdd8d..ed2f9d64efae 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -83,9 +83,9 @@ static int snd_gusextreme_es1688_create(struct snd_card *card, struct snd_es1688 *chip, struct device *dev, unsigned int n) { - static long possible_ports[] = {0x220, 0x240, 0x260}; - static int possible_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dmas[] = {1, 3, 0, -1}; + static const long possible_ports[] = {0x220, 0x240, 0x260}; + static const int possible_irqs[] = {5, 9, 10, 7, -1}; + static const int possible_dmas[] = {1, 3, 0, -1}; int i, error; @@ -122,8 +122,8 @@ static int snd_gusextreme_gus_card_create(struct snd_card *card, struct device *dev, unsigned int n, struct snd_gus_card **rgus) { - static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1}; - static int possible_dmas[] = {5, 6, 7, 3, 1, -1}; + static const int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1}; + static const int possible_dmas[] = {5, 6, 7, 3, 1, -1}; if (gf1_irq[n] == SNDRV_AUTO_IRQ) { gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs); diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index efe576625f48..05cd9be4dd8a 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -191,8 +191,8 @@ static int snd_gusmax_match(struct device *pdev, unsigned int dev) static int snd_gusmax_probe(struct device *pdev, unsigned int dev) { - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; + static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; + static const int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; struct snd_card *card; struct snd_gus_card *gus = NULL; @@ -241,7 +241,7 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) pcm_channels[dev], 0, &gus); } else { - static unsigned long possible_ports[] = { + static const unsigned long possible_ports[] = { 0x220, 0x230, 0x240, 0x250, 0x260 }; int i; diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 5cd4aa477ba7..3e9ad930deae 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -364,7 +364,7 @@ struct rom_hdr { static void snd_interwave_detect_memory(struct snd_gus_card *gus) { - static unsigned int lmc[13] = + static const unsigned int lmc[13] = { 0x00000001, 0x00000101, 0x01010101, 0x00000401, 0x04040401, 0x00040101, 0x04040101, 0x00000004, @@ -475,7 +475,7 @@ static void snd_interwave_init(int dev, struct snd_gus_card *gus) } -static struct snd_kcontrol_new snd_interwave_controls[] = { +static const struct snd_kcontrol_new snd_interwave_controls[] = { WSS_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1), WSS_DOUBLE("Master Playback Volume", 0, @@ -788,8 +788,8 @@ static int snd_interwave_isa_probe(struct device *pdev, unsigned int dev) { int err; - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; + static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; + static const int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; if (irq[dev] == SNDRV_AUTO_IRQ) { if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { @@ -813,7 +813,7 @@ static int snd_interwave_isa_probe(struct device *pdev, if (port[dev] != SNDRV_AUTO_PORT) return snd_interwave_isa_probe1(dev, pdev); else { - static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; + static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; int i; for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { port[dev] = possible_ports[i]; -- cgit v1.2.3 From 80e0a7c095462e24f48908e6effd7a44099249f9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:05 +0100 Subject: ALSA: opti9xx: More constifications Apply const prefix to the static resource tables, the mc size tables and the string arrays. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-51-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/miro.c | 18 +++++++++--------- sound/isa/opti9xx/opti92x-ad1848.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index a9c773b9f471..e764816a8f7a 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -119,7 +119,7 @@ struct snd_miro { static struct snd_miro_aci aci_device; -static char * snd_opti9xx_names[] = { +static const char * const snd_opti9xx_names[] = { "unknown", "82C928", "82C929", "82C924", "82C925", @@ -637,7 +637,7 @@ static const struct snd_kcontrol_new snd_miro_capture_control[] = { .put = snd_miro_put_capture, }}; -static unsigned char aci_init_values[][2] = { +static const unsigned char aci_init_values[][2] = { { ACI_SET_MUTE, 0x00 }, { ACI_SET_POWERAMP, 0x00 }, { ACI_SET_PREAMP, 0x00 }, @@ -764,7 +764,7 @@ static int snd_miro_mixer(struct snd_card *card, static int snd_miro_init(struct snd_miro *chip, unsigned short hardware) { - static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; + static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; chip->hardware = hardware; strcpy(chip->name, snd_opti9xx_names[hardware]); @@ -1387,12 +1387,12 @@ static int snd_miro_isa_match(struct device *devptr, unsigned int n) static int snd_miro_isa_probe(struct device *devptr, unsigned int n) { - static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; - static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; - static int possible_irqs[] = {11, 9, 10, 7, -1}; - static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; - static int possible_dma1s[] = {3, 1, 0, -1}; - static int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, + static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; + static const long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; + static const int possible_irqs[] = {11, 9, 10, 7, -1}; + static const int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; + static const int possible_dma1s[] = {3, 1, 0, -1}; + static const int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, {0, -1} }; int error; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 697576459f71..d06b29693c85 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -163,7 +163,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); #define DEV_NAME KBUILD_MODNAME -static char * snd_opti9xx_names[] = { +static const char * const snd_opti9xx_names[] = { "unknown", "82C928", "82C929", "82C924", "82C925", @@ -173,7 +173,7 @@ static char * snd_opti9xx_names[] = { static int snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) { - static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; + static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; chip->hardware = hardware; strcpy(chip->name, snd_opti9xx_names[hardware]); @@ -808,7 +808,7 @@ static void snd_card_opti9xx_free(struct snd_card *card) static int snd_opti9xx_probe(struct snd_card *card) { - static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; + static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; int error; int xdma2; struct snd_opti9xx *chip = card->private_data; @@ -958,16 +958,16 @@ static int snd_opti9xx_isa_probe(struct device *devptr, { struct snd_card *card; int error; - static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; + static const long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; #ifdef OPTi93X - static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; + static const int possible_irqs[] = {5, 9, 10, 11, 7, -1}; #else - static int possible_irqs[] = {9, 10, 11, 7, -1}; + static const int possible_irqs[] = {9, 10, 11, 7, -1}; #endif /* OPTi93X */ - static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dma1s[] = {3, 1, 0, -1}; + static const int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; + static const int possible_dma1s[] = {3, 1, 0, -1}; #if defined(CS4231) || defined(OPTi93X) - static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; + static const int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; #endif /* CS4231 || OPTi93X */ if (mpu_port == SNDRV_AUTO_PORT) { -- cgit v1.2.3 From 429bca4d76b406302de4d06d6f4e20e2a36afb08 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:06 +0100 Subject: ALSA: wss: More constifications Apply const prefix to the static tables for parameters. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-52-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index d37f4642162a..ea5d3cdfe4e4 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -38,7 +38,7 @@ MODULE_LICENSE("GPL"); * Some variables */ -static unsigned char freq_bits[14] = { +static const unsigned char freq_bits[14] = { /* 5510 */ 0x00 | CS4231_XTAL2, /* 6620 */ 0x0E | CS4231_XTAL2, /* 8000 */ 0x00 | CS4231_XTAL1, @@ -72,7 +72,7 @@ static int snd_wss_xrate(struct snd_pcm_runtime *runtime) &hw_constraints_rates); } -static unsigned char snd_wss_original_image[32] = +static const unsigned char snd_wss_original_image[32] = { 0x00, /* 00/00 - lic */ 0x00, /* 01/01 - ric */ @@ -108,7 +108,7 @@ static unsigned char snd_wss_original_image[32] = 0x00, /* 1f/31 - cbrl */ }; -static unsigned char snd_opti93x_original_image[32] = +static const unsigned char snd_opti93x_original_image[32] = { 0x00, /* 00/00 - l_mixout_outctrl */ 0x00, /* 01/01 - r_mixout_outctrl */ -- cgit v1.2.3 From 8fc179162df5b307d8d1f8f4b6b7bb507742cd55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:07 +0100 Subject: ALSA: sc6000: More constification Apply const prefix to the static resource tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-53-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/isa/sc6000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c index 395ee3b1794d..3d0bea44f454 100644 --- a/sound/isa/sc6000.c +++ b/sound/isa/sc6000.c @@ -534,8 +534,8 @@ static int snd_sc6000_match(struct device *devptr, unsigned int dev) static int snd_sc6000_probe(struct device *devptr, unsigned int dev) { - static int possible_irqs[] = { 5, 7, 9, 10, 11, -1 }; - static int possible_dmas[] = { 1, 3, 0, -1 }; + static const int possible_irqs[] = { 5, 7, 9, 10, 11, -1 }; + static const int possible_dmas[] = { 1, 3, 0, -1 }; int err; int xirq = irq[dev]; int xdma = dma[dev]; -- cgit v1.2.3 From 616986985d4c609f90acee5d3417dbb2cb67109d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:08 +0100 Subject: ALSA: mts64: More constifications Apply const prefix to the static mapping tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-54-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/mts64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index eeef3c0215e4..9c708b693cb3 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -261,7 +261,7 @@ static int mts64_device_close(struct mts64 *mts) */ static u8 mts64_map_midi_input(u8 c) { - static u8 map[] = { 0, 1, 4, 2, 3 }; + static const u8 map[] = { 0, 1, 4, 2, 3 }; return map[c]; } @@ -353,7 +353,7 @@ static void mts64_smpte_start(struct parport *p, u8 seconds, u8 frames, u8 idx) { - static u8 fps[5] = { MTS64_CMD_SMPTE_FPS_24, + static const u8 fps[5] = { MTS64_CMD_SMPTE_FPS_24, MTS64_CMD_SMPTE_FPS_25, MTS64_CMD_SMPTE_FPS_2997, MTS64_CMD_SMPTE_FPS_30D, -- cgit v1.2.3 From 26170691ffbb05f161d1ba21465497b4ba2502cd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:09 +0100 Subject: ALSA: aw2: More constifications Apply const prefix to the static parameter tables. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-55-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/aw2/aw2-tsl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/aw2/aw2-tsl.c b/sound/pci/aw2/aw2-tsl.c index 41fed546ea14..2f35b08809a3 100644 --- a/sound/pci/aw2/aw2-tsl.c +++ b/sound/pci/aw2/aw2-tsl.c @@ -59,7 +59,7 @@ /* SD3: >-------<_4-L___>-------<_4-R___> */ /* WS4: -------\_______________/--------- */ -static int tsl1[8] = { +static const int tsl1[8] = { 1 * TSL_SDW_A1 | 3 * TSL_BSEL_A1 | 0 * TSL_DIS_A1 | 0 * TSL_DOD_A1 | TSL_LF_A1, @@ -85,7 +85,7 @@ static int tsl1[8] = { 0 * TSL_DOD_A1 | TSL_WS1 | TSL_WS0 | TSL_SF_A1 | TSL_EOS, }; -static int tsl2[8] = { +static const int tsl2[8] = { 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2 | TSL_LF_A2, 0 * TSL_SDW_A2 | 2 * TSL_BSEL_A2 | 2 * TSL_DOD_A2, 0 * TSL_SDW_A2 | 3 * TSL_BSEL_A2 | 2 * TSL_DOD_A2, -- cgit v1.2.3 From 2f200ce2919b231038f80dde4e7e7147c611242b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:10 +0100 Subject: ALSA: lx6464es: More constifications Apply const prefix to the static tables for the DSP command and the peak map. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-56-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index dd3a873777eb..f884f5a6a61c 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -161,7 +161,7 @@ struct dsp_cmd_info { the number of status words (in addition to the return value) */ -static struct dsp_cmd_info dsp_commands[] = +static const struct dsp_cmd_info dsp_commands[] = { { (CMD_00_INFO_DEBUG << OPCODE_OFFSET) , 1 /*custom*/ , 1 , 0 /**/ , CMD_NAME("INFO_DEBUG") }, @@ -858,7 +858,7 @@ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute) return err; } -static u32 peak_map[] = { +static const u32 peak_map[] = { 0x00000109, /* -90.308dB */ 0x0000083B, /* -72.247dB */ 0x000020C4, /* -60.205dB */ -- cgit v1.2.3 From 7840d8a103389ae37b4f11fb3574ea69b2863ba3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:11 +0100 Subject: ALSA: arm: More constification Apply const prefix to the static channel list table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-57-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index d663bd7adae6..a0996c47e58f 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -380,7 +380,7 @@ static const struct snd_pcm_hardware aaci_hw_info = { static int aaci_rule_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) { - static unsigned int channel_list[] = { 2, 4, 6 }; + static const unsigned int channel_list[] = { 2, 4, 6 }; struct aaci *aaci = rule->private; unsigned int mask = 1 << 0, slots; -- cgit v1.2.3 From 1d99500a1d782f506f215b757d681e0e071981a5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:12 +0100 Subject: ALSA: opl4: More constification Apply const prefix to the static volume table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-58-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/opl4/opl4_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/opl4/opl4_synth.c b/sound/drivers/opl4/opl4_synth.c index 7bc1e58c95aa..34e2bd52bba1 100644 --- a/sound/drivers/opl4/opl4_synth.c +++ b/sound/drivers/opl4/opl4_synth.c @@ -248,7 +248,7 @@ static const s16 snd_opl4_pitch_map[0x600] = { * Attenuation according to GM recommendations, in -0.375 dB units. * table[v] = 40 * log(v / 127) / -0.375 */ -static unsigned char snd_opl4_volume_table[128] = { +static const unsigned char snd_opl4_volume_table[128] = { 255,224,192,173,160,150,141,134, 128,122,117,113,109,105,102, 99, 96, 93, 90, 88, 85, 83, 81, 79, -- cgit v1.2.3 From 6c8454888fe68bf2e3690c489d8764bac47c24c5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:13 +0100 Subject: ALSA: serial-u16550: More constification Apply const prefix to the string array. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-59-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/drivers/serial-u16550.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 893c2b57331f..3947f084dd6b 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{{ALSA, MIDI serial u16550}}"); #define SNDRV_SERIAL_MS124W_MB 3 /* Midiator MS-124W in M/B mode */ #define SNDRV_SERIAL_GENERIC 4 /* Generic Interface */ #define SNDRV_SERIAL_MAX_ADAPTOR SNDRV_SERIAL_GENERIC -static char *adaptor_names[] = { +static const char * const adaptor_names[] = { "Soundcanvas", "MS-124T", "MS-124W S/A", -- cgit v1.2.3 From 24ce8056a935cc1a42e73f7bba1d25893a3f9851 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:14 +0100 Subject: ALSA: ak4531: More constification Apply const prefix to the initial register map. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-60-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ak4531_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c index c00c65726a34..e0a81f99f79a 100644 --- a/sound/pci/ak4531_codec.c +++ b/sound/pci/ak4531_codec.c @@ -335,7 +335,7 @@ static int snd_ak4531_dev_free(struct snd_device *device) return snd_ak4531_free(ak4531); } -static u8 snd_ak4531_initial_map[0x19 + 1] = { +static const u8 snd_ak4531_initial_map[0x19 + 1] = { 0x9f, /* 00: Master Volume Lch */ 0x9f, /* 01: Master Volume Rch */ 0x9f, /* 02: Voice Volume Lch */ -- cgit v1.2.3 From 83fdb6fbccfcf771bce8d3d69a737f23843f2507 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:15 +0100 Subject: ALSA: azt3328: More constification Apply const prefix to the static initial register table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-61-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/azt3328.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 73745352c55d..58167d8469e1 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1152,7 +1152,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] = { #endif }; -static u16 snd_azf3328_init_values[][2] = { +static const u16 snd_azf3328_init_values[][2] = { { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f }, { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f }, { IDX_MIXER_BASSTREBLE, 0x0000 }, -- cgit v1.2.3 From e157f0cd056af9f2715dd91d55688a7c0fea4608 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:16 +0100 Subject: ALSA: cs4281: More constification Apply const prefix to the static register table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-62-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index dc89ef906c9b..94d2a6a466a8 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1939,7 +1939,7 @@ static void snd_cs4281_remove(struct pci_dev *pci) */ #ifdef CONFIG_PM_SLEEP -static int saved_regs[SUSPEND_REGISTERS] = { +static const int saved_regs[SUSPEND_REGISTERS] = { BA0_JSCTL, BA0_GPIOR, BA0_SSCR, -- cgit v1.2.3 From 9bca09079352db5c5cd68a37a3d441d45fac9b54 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:17 +0100 Subject: ALSA: echoaudio: More constification Apply const prefix to the static channel list table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-63-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index dae3a853a6e1..994ed51f813f 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -23,7 +23,7 @@ MODULE_PARM_DESC(id, "ID string for " ECHOCARD_NAME " soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard."); -static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; +static const unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1); -- cgit v1.2.3 From 7103e4a70cb9413b3b6a485c03d463bb0232c15a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:18 +0100 Subject: ALSA: ens137x: More constification Apply const prefix to the quirk entry, forgotten in the previous fix. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-64-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 7ef9b7a1b2e6..d9acef0826a9 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1574,7 +1574,7 @@ static int es1371_quirk_lookup(struct ensoniq *ensoniq, return 0; } -static struct es1371_quirk es1371_spdif_present[] = { +static const struct es1371_quirk es1371_spdif_present[] = { { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_C }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_D }, { .vid = PCI_VENDOR_ID_ENSONIQ, .did = PCI_DEVICE_ID_ENSONIQ_CT5880, .rev = CT5880REV_CT5880_E }, -- cgit v1.2.3 From 8045d0fc95753b00c6f0cb0f3a50a919a0b95038 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:19 +0100 Subject: ALSA: fm801: More constification Apply const prefix to the static register table. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-65-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 40dfad74f8e1..181ebafa550a 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -1360,7 +1360,7 @@ static void snd_card_fm801_remove(struct pci_dev *pci) } #ifdef CONFIG_PM_SLEEP -static unsigned char saved_regs[] = { +static const unsigned char saved_regs[] = { FM801_PCM_VOL, FM801_I2S_VOL, FM801_FM_VOL, FM801_REC_SRC, FM801_PLY_CTRL, FM801_PLY_COUNT, FM801_PLY_BUF1, FM801_PLY_BUF2, FM801_CAP_CTRL, FM801_CAP_COUNT, FM801_CAP_BUF1, FM801_CAP_BUF2, -- cgit v1.2.3 From a05c0737d3c7a0eab47711e29185655eb357d718 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:20 +0100 Subject: ALSA: via82xx: More constification Apply const prefix to the static table for the chip models. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-66-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 6c83ad3275f9..799789c8eea9 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2403,7 +2403,7 @@ struct via823x_info { char *name; int type; }; -static struct via823x_info via823x_cards[] = { +static const struct via823x_info via823x_cards[] = { { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, -- cgit v1.2.3 From 6ab9eabe19c07a8b6fca7c588b5a03a3e6e9cd49 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:21 +0100 Subject: ALSA: pdaudiocf: More constification Apply const prefix to the static table for verbs. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-67-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c index db3cd459b954..5537c0882aa5 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c @@ -179,7 +179,7 @@ int snd_pdacf_ak4117_create(struct snd_pdacf *chip) /* from AK4117 then INT1 pin from AK4117 will be high all time, because PCMCIA interrupts are */ /* egde based and FPGA does logical OR for all interrupt sources, we cannot use these */ /* high-rate sources */ - static unsigned char pgm[5] = { + static const unsigned char pgm[5] = { AK4117_XTL_24_576M | AK4117_EXCT, /* AK4117_REG_PWRDN */ AK4117_CM_PLL_XTAL | AK4117_PKCS_128fs | AK4117_XCKS_128fs, /* AK4117_REQ_CLOCK */ AK4117_EFH_1024LRCLK | AK4117_DIF_24R | AK4117_IPS, /* AK4117_REG_IO */ -- cgit v1.2.3 From cabc04680778adf57e1c0d64af2c46971a895d99 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:22 +0100 Subject: ALSA: spi: More constification Apply const prefix to the static table for registers. Just for minor optimization and no functional changes. Link: https://lore.kernel.org/r/20200105144823.29547-68-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index e51bbf7836a2..76c0e37a838c 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -36,7 +36,7 @@ #define BITRATE_MAX 50000 /* Hardware limit. */ /* Initial (hardware reset) AT73C213 register values. */ -static u8 snd_at73c213_original_image[18] = +static const u8 snd_at73c213_original_image[18] = { 0x00, /* 00 - CTRL */ 0x05, /* 01 - LLIG */ -- cgit v1.2.3 From f1dd4795b1523fbca7ab4344dd5a8bb439cc770d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 5 Jan 2020 15:48:23 +0100 Subject: ALSA: sh: Fix compile warning wrt const A long-standing compile warning was seen during build test: sound/sh/aica.c: In function 'load_aica_firmware': sound/sh/aica.c:521:25: warning: passing argument 2 of 'spu_memload' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] Fixes: 198de43d758c ("[ALSA] Add ALSA support for the SEGA Dreamcast PCM device") Link: https://lore.kernel.org/r/20200105144823.29547-69-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/sh/aica.c b/sound/sh/aica.c index f3cd12ff09c3..8fa68432d3c1 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -101,10 +101,10 @@ static void spu_memset(u32 toi, u32 what, int length) } /* spu_memload - write to SPU address space */ -static void spu_memload(u32 toi, void *from, int length) +static void spu_memload(u32 toi, const void *from, int length) { unsigned long flags; - u32 *froml = from; + const u32 *froml = from; u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi); int i; u32 val; -- cgit v1.2.3 From d4b74e218a8d0d6cf58e546627ab9d4d4f2645ab Mon Sep 17 00:00:00 2001 From: Sam McNally Date: Fri, 3 Jan 2020 12:50:19 +1100 Subject: ASoC: Intel: sof_rt5682: Ignore the speaker amp when there isn't one. Some members of the Google_Hatch family include a rt5682 jack codec, but no speaker amplifier. This uses the same driver (sof_rt5682) as a combination of rt5682 jack codec and max98357a speaker amplifier. Within the sof_rt5682 driver, these cases are not currently distinguishable, relying on a DMI quirk to decide the configuration. This causes an incorrect configuration when only the rt5682 is present on a Google_Hatch device. For CML, the jack codec is used as the primary key when matching, with a possible speaker amplifier described in quirk_data. The two cases of interest are the second and third 10EC5682 entries in snd_soc_acpi_intel_cml_machines[]. The second entry matches the combination of rt5682 and max98357a, resulting in the quirk_data field in the snd_soc_acpi_mach being non-null, pointing at max98357a_spk_codecs, the snd_soc_acpi_codecs for the matched speaker amplifier. The third entry matches just the rt5682, resulting in a null quirk_data. The sof_rt5682 driver's DMI data matching identifies that a speaker amplifier is present for all Google_Hatch family devices. Detect cases where there is no speaker amplifier by checking for a null quirk_data in the snd_soc_acpi_mach and remove the speaker amplifier bit in that case. Signed-off-by: Sam McNally Acked-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200103124921.v3.1.Ib87c4a7fbb3fc818ea12198e291b87dc2d5bc8c2@changeid Signed-off-by: Mark Brown --- sound/soc/intel/boards/sof_rt5682.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index ad8a2b4bc709..8a13231dee15 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -603,6 +603,14 @@ static int sof_audio_probe(struct platform_device *pdev) dmi_check_system(sof_rt5682_quirk_table); + mach = (&pdev->dev)->platform_data; + + /* A speaker amp might not be present when the quirk claims one is. + * Detect this via whether the machine driver match includes quirk_data. + */ + if ((sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) + sof_rt5682_quirk &= ~SOF_SPEAKER_AMP_PRESENT; + if (soc_intel_is_byt() || soc_intel_is_cht()) { is_legacy_cpu = 1; dmic_be_num = 0; @@ -663,7 +671,6 @@ static int sof_audio_probe(struct platform_device *pdev) INIT_LIST_HEAD(&ctx->hdmi_pcm_list); sof_audio_card_rt5682.dev = &pdev->dev; - mach = (&pdev->dev)->platform_data; /* set platform name for each dailink */ ret = snd_soc_fixup_dai_links_platform_name(&sof_audio_card_rt5682, -- cgit v1.2.3 From 46207ca24545540231ac8b4cf856baf1ca19e2fa Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 Jan 2020 10:08:39 -0600 Subject: ASoC: SOF: pci: change the default firmware path when the community key is used Since ApolloLake, Intel platforms require signed firmware. On all Windows platforms the default is to require the Intel production key be used. But some platforms allow for a community key to be used, which allows developers to compile/build their own firmware. In the linux-firmware tree, the default intel/sof path is used for firmwares signed for the production key, and files signed with the community key are located in intel/sof/community. Since we don't have an API to query which key is used on what platforms, we have to rely on DMI-based quirks. Developers can bypass this mechanism by setting a kernel 'fw_path' module parameter. Additional dynamic debug traces are provided to help debug cases where the wrong file might be used. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200107160840.1524-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/sof-pci-dev.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index da7b17e5177b..9993be36d105 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -9,6 +9,7 @@ // #include +#include #include #include #include @@ -36,6 +37,23 @@ MODULE_PARM_DESC(sof_pci_debug, "SOF PCI debug options (0x0 all off)"); #define SOF_PCI_DISABLE_PM_RUNTIME BIT(0) +static const struct dmi_system_id community_key_platforms[] = { + { + .ident = "Up Squared", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), + DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"), + } + }, + { + .ident = "Google Chromebooks", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Google"), + } + }, + {}, +}; + #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) static const struct sof_dev_desc bxt_desc = { .machines = snd_soc_acpi_intel_bxt_machines, @@ -290,12 +308,34 @@ static int sof_pci_probe(struct pci_dev *pci, sof_pdata->dev = dev; sof_pdata->fw_filename = desc->default_fw_filename; + /* + * for platforms using the SOF community key, change the + * default path automatically to pick the right files from the + * linux-firmware tree. This can be overridden with the + * fw_path kernel parameter, e.g. for developers. + */ + /* alternate fw and tplg filenames ? */ - if (fw_path) + if (fw_path) { sof_pdata->fw_filename_prefix = fw_path; - else + + dev_dbg(dev, + "Module parameter used, changed fw path to %s\n", + sof_pdata->fw_filename_prefix); + + } else if (dmi_check_system(community_key_platforms)) { + sof_pdata->fw_filename_prefix = + devm_kasprintf(dev, GFP_KERNEL, "%s/%s", + sof_pdata->desc->default_fw_path, + "community"); + + dev_dbg(dev, + "Platform uses community key, changed fw path to %s\n", + sof_pdata->fw_filename_prefix); + } else { sof_pdata->fw_filename_prefix = sof_pdata->desc->default_fw_path; + } if (tplg_path) sof_pdata->tplg_filename_prefix = tplg_path; -- cgit v1.2.3 From 490a625b01775857a9d00c623164e8aa0be762a2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 Jan 2020 10:08:40 -0600 Subject: ASoC: SOF: loader: add dynamic debug trace We currently have no trace referring to the firmware path, add a trace to help debug cases where the wrong file might be used. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200107160840.1524-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/loader.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c index 235be4fc0862..fc4ab51bacf4 100644 --- a/sound/soc/sof/loader.c +++ b/sound/soc/sof/loader.c @@ -487,6 +487,9 @@ int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev) if (ret < 0) { dev_err(sdev->dev, "error: request firmware %s failed err: %d\n", fw_filename, ret); + } else { + dev_dbg(sdev->dev, "request_firmware %s successful\n", + fw_filename); } kfree(fw_filename); -- cgit v1.2.3 From 599b10193c77e4b8a68192b3b277a01e8b467043 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 7 Jan 2020 22:48:35 +0100 Subject: ASoC: gtm601: fix build warning The driver produces warnings without CONFIG_OF, and makes no sense without it either: sound/soc/codecs/gtm601.c:50:34: error: 'bm818_dai' defined but not used [-Werror=unused-variable] static struct snd_soc_dai_driver bm818_dai = { ^~~~~~~~~ sound/soc/codecs/gtm601.c:32:34: error: 'gtm601_dai' defined but not used [-Werror=unused-variable] static struct snd_soc_dai_driver gtm601_dai = { ^~~~~~~~~~ Remove the #ifdef check to avoid the warning. Fixes: 057a317a8d94 ("ASoC: gtm601: add Broadmobi bm818 sound profile") Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20200107214846.1284981-1-arnd@arndb.de Signed-off-by: Mark Brown --- sound/soc/codecs/gtm601.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/codecs/gtm601.c b/sound/soc/codecs/gtm601.c index 7f05ebcb88d1..ae9e1c70ca57 100644 --- a/sound/soc/codecs/gtm601.c +++ b/sound/soc/codecs/gtm601.c @@ -87,14 +87,12 @@ static int gtm601_platform_probe(struct platform_device *pdev) (struct snd_soc_dai_driver *)dai_driver, 1); } -#if defined(CONFIG_OF) static const struct of_device_id gtm601_codec_of_match[] = { { .compatible = "option,gtm601", .data = (void *)>m601_dai }, { .compatible = "broadmobi,bm818", .data = (void *)&bm818_dai }, {}, }; MODULE_DEVICE_TABLE(of, gtm601_codec_of_match); -#endif static struct platform_driver gtm601_codec_driver = { .driver = { -- cgit v1.2.3 From 3b2549a3740efb8af0150415737067d87e466c5b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 8 Jan 2020 08:37:06 +0300 Subject: ALSA: control: potential uninitialized return value Smatch complains that "ret" might be uninitialized. Fixes: fbd3eb7f66c5 ("ALSA: control: Add verification for kctl accesses") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20200108053706.h3hcnvmnf62wkjac@kili.mountain Signed-off-by: Takashi Iwai --- sound/core/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/control.c b/sound/core/control.c index d06033d418a8..aa0c0cf182af 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -896,7 +896,7 @@ static int sanity_check_elem_value(struct snd_card *card, u32 pattern) { size_t offset; - int i, ret; + int i, ret = 0; u32 *p; switch (info->type) { -- cgit v1.2.3 From 55c203a308ac74256bc240f7ce14ff45dc221a15 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 8 Jan 2020 20:58:03 +0800 Subject: ALSA: pci: echoaudio: remove set but not used variable 'chip' sound/pci/echoaudio/echoaudio.c: In function snd_echo_mixer_info: sound/pci/echoaudio/echoaudio.c:1233:20: warning: variable chip set but not used [-Wunused-but-set-variable] sound/pci/echoaudio/echoaudio.c: In function 'snd_echo_vmixer_info': sound/pci/echoaudio/echoaudio.c:1300:20: warning: variable 'chip' set but not used [-Wunused-but-set-variable] commit e67c3f0fd44c ("ALSA: pci: echoaudio: remove usage of dimen menber of elem_value structure") left behind this unused variable. Reported-by: Hulk Robot Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20200108125803.45584-1-yuehaibing@huawei.com Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 994ed51f813f..565c5a3f3a91 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -1230,9 +1230,6 @@ static const struct snd_kcontrol_new snd_echo_intput_nominal_level = { static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct echoaudio *chip; - - chip = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = ECHOGAIN_MINOUT; @@ -1300,9 +1297,6 @@ static struct snd_kcontrol_new snd_echo_monitor_mixer = { static int snd_echo_vmixer_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct echoaudio *chip; - - chip = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = ECHOGAIN_MINOUT; -- cgit v1.2.3 From 1a0986c1bc14a6a05da9d9cdeb61833560bacb1e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Jan 2020 16:34:30 +0100 Subject: ALSA: hda: Fix a typo in comments Link: https://lore.kernel.org/r/20200108153430.31456-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/hda/hdac_regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c index 906b1e20bae0..d771d2cfdef7 100644 --- a/sound/hda/hdac_regmap.c +++ b/sound/hda/hdac_regmap.c @@ -509,7 +509,7 @@ int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, * snd_hdac_regmap_update_raw - update a pseudo register with power mgmt * @codec: the codec object * @reg: pseudo register - * @mask: bit mask to udpate + * @mask: bit mask to update * @val: value to update * * Returns zero if successful or a negative error code. -- cgit v1.2.3 From f0df2e650e3eee5ff79c06dedb98c318ff177a95 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Wed, 8 Jan 2020 03:59:54 +0000 Subject: ASoC: amd: acp3x: Fix return value check in acp3x_dai_probe() In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Fixes: c9fe7db6e884 ("ASoC: amd: Refactoring of DAI from DMA driver") Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200108035954.51317-1-weiyongjun1@huawei.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x-i2s.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/raven/acp3x-i2s.c b/sound/soc/amd/raven/acp3x-i2s.c index d9b287b8396c..bf51cadf8682 100644 --- a/sound/soc/amd/raven/acp3x-i2s.c +++ b/sound/soc/amd/raven/acp3x-i2s.c @@ -321,8 +321,8 @@ static int acp3x_dai_probe(struct platform_device *pdev) } adata->acp3x_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (IS_ERR(adata->acp3x_base)) - return PTR_ERR(adata->acp3x_base); + if (!adata->acp3x_base) + return -ENOMEM; adata->i2s_irq = res->start; dev_set_drvdata(&pdev->dev, adata); -- cgit v1.2.3 From 1d7b051891722a36ee0b228bc940dd245f161ab1 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Wed, 8 Jan 2020 12:50:06 +0100 Subject: ASoC: max98090: fix incorrect helper in max98090_dapm_put_enum_double() Commit 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") extended the code for handling "LTENL Mux", "LTENR Mux", "LBENL Mux" and "LBENR Mux" controls by adding a custom max98090_dapm_put_enum_double() function to them. However that function used incorrect helper to get its component object. Fix this by using the proper snd_soc_dapm_* helper. This fixes the following NULL pointer exception observed on Exynos4412-based Odroid U3 board: 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 000000b0 pgd = (ptrval) [000000b0] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1104 Comm: alsactl Not tainted 5.5.0-rc5-next-20200107 #166 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) PC is at __mutex_lock+0x54/0xb18 LR is at ___might_sleep+0x3c/0x2e0 ... Process alsactl (pid: 1104, stack limit = 0x(ptrval)) ... [] (__mutex_lock) from [] (mutex_lock_nested+0x1c/0x24) [] (mutex_lock_nested) from [] (max98090_shdn_save+0x1c/0x28) [] (max98090_shdn_save) from [] (max98090_dapm_put_enum_double+0x20/0x40) [] (max98090_dapm_put_enum_double) from [] (snd_ctl_ioctl+0x190/0xbb8) [] (snd_ctl_ioctl) from [] (ksys_ioctl+0x470/0xaf8) [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28) ... ---[ end trace 0e93f0580f4b9241 ]--- Fixes: 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") Signed-off-by: Marek Szyprowski Reviewed-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200108115007.31095-1-m.szyprowski@samsung.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 4c7b16d557e2..c01ce4a3f86d 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -82,7 +82,7 @@ static int max98090_dapm_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + snd_soc_dapm_kcontrol_component(kcontrol); struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); int ret; -- cgit v1.2.3 From 4e93c1294f4b051d574d6bc59755d2863286990e Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Wed, 8 Jan 2020 12:50:06 +0100 Subject: ASoC: max98090: fix incorrect helper in max98090_dapm_put_enum_double() Commit 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") extended the code for handling "LTENL Mux", "LTENR Mux", "LBENL Mux" and "LBENR Mux" controls by adding a custom max98090_dapm_put_enum_double() function to them. However that function used incorrect helper to get its component object. Fix this by using the proper snd_soc_dapm_* helper. This fixes the following NULL pointer exception observed on Exynos4412-based Odroid U3 board: 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 000000b0 pgd = (ptrval) [000000b0] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1104 Comm: alsactl Not tainted 5.5.0-rc5-next-20200107 #166 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) PC is at __mutex_lock+0x54/0xb18 LR is at ___might_sleep+0x3c/0x2e0 ... Process alsactl (pid: 1104, stack limit = 0x(ptrval)) ... [] (__mutex_lock) from [] (mutex_lock_nested+0x1c/0x24) [] (mutex_lock_nested) from [] (max98090_shdn_save+0x1c/0x28) [] (max98090_shdn_save) from [] (max98090_dapm_put_enum_double+0x20/0x40) [] (max98090_dapm_put_enum_double) from [] (snd_ctl_ioctl+0x190/0xbb8) [] (snd_ctl_ioctl) from [] (ksys_ioctl+0x470/0xaf8) [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28) ... ---[ end trace 0e93f0580f4b9241 ]--- Fixes: 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") Signed-off-by: Marek Szyprowski Reviewed-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200108115007.31095-1-m.szyprowski@samsung.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c01ce4a3f86d..ede03663cbed 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -98,7 +98,7 @@ static int max98090_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); + snd_soc_dapm_kcontrol_component(kcontrol); struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); int ret; -- cgit v1.2.3 From 2dc98af62c32ff6c8b9a32365346c5c407e291a8 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Wed, 8 Jan 2020 12:50:07 +0100 Subject: ASoC: max98090: fix lockdep warning Commit 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") extended the code for handling many controls by adding a custom put function to them. That new custom put function properly handles relations between codec's hardware registers. However they used card->dapm_mutex to properly serialize those operations. This in turn triggers a lockdep warning about possible circular dependency. Fix this by introducing a separate mutex only for serializing the SHDN hardware register related operations. This fixes the following lockdep warning observed on Exynos4412-based Odroid U3 board: ====================================================== WARNING: possible circular locking dependency detected 5.5.0-rc5-next-20200107 #166 Not tainted ------------------------------------------------------ alsactl/1104 is trying to acquire lock: ed0d50f4 (&card->dapm_mutex){+.+.}, at: max98090_shdn_save+0x1c/0x28 but task is already holding lock: edb4b49c (&card->controls_rwsem){++++}, at: snd_ctl_ioctl+0xcc/0xbb8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&card->controls_rwsem){++++}: snd_ctl_add_replace+0x3c/0x84 dapm_create_or_share_kcontrol+0x24c/0x2e0 snd_soc_dapm_new_widgets+0x308/0x594 snd_soc_bind_card+0x80c/0xad4 devm_snd_soc_register_card+0x34/0x6c odroid_audio_probe+0x288/0x34c platform_drv_probe+0x6c/0xa4 really_probe+0x200/0x490 driver_probe_device+0x78/0x1f8 bus_for_each_drv+0x74/0xb8 __device_attach+0xd4/0x16c bus_probe_device+0x88/0x90 deferred_probe_work_func+0x3c/0xd0 process_one_work+0x22c/0x7c4 worker_thread+0x44/0x524 kthread+0x130/0x164 ret_from_fork+0x14/0x20 0x0 -> #0 (&card->dapm_mutex){+.+.}: lock_acquire+0xe8/0x270 __mutex_lock+0x9c/0xb18 mutex_lock_nested+0x1c/0x24 max98090_shdn_save+0x1c/0x28 max98090_put_enum_double+0x20/0x40 snd_ctl_ioctl+0x190/0xbb8 ksys_ioctl+0x470/0xaf8 ret_fast_syscall+0x0/0x28 0xbefaa564 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&card->controls_rwsem); lock(&card->dapm_mutex); lock(&card->controls_rwsem); lock(&card->dapm_mutex); *** DEADLOCK *** 1 lock held by alsactl/1104: #0: edb4b49c (&card->controls_rwsem){++++}, at: snd_ctl_ioctl+0xcc/0xbb8 stack backtrace: CPU: 0 PID: 1104 Comm: alsactl Not tainted 5.5.0-rc5-next-20200107 #166 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) (unwind_backtrace) from [] (show_stack+0x10/0x14) (show_stack) from [] (dump_stack+0xb4/0xe0) (dump_stack) from [] (check_noncircular+0x1ec/0x208) (check_noncircular) from [] (__lock_acquire+0x1210/0x25ec) (__lock_acquire) from [] (lock_acquire+0xe8/0x270) (lock_acquire) from [] (__mutex_lock+0x9c/0xb18) (__mutex_lock) from [] (mutex_lock_nested+0x1c/0x24) (mutex_lock_nested) from [] (max98090_shdn_save+0x1c/0x28) (max98090_shdn_save) from [] (max98090_put_enum_double+0x20/0x40) (max98090_put_enum_double) from [] (snd_ctl_ioctl+0x190/0xbb8) (snd_ctl_ioctl) from [] (ksys_ioctl+0x470/0xaf8) (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28) ... Fixes: 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers") Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20200108115007.31095-2-m.szyprowski@samsung.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 10 ++++++---- sound/soc/codecs/max98090.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index ede03663cbed..ba0e3ba162f8 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -52,14 +52,14 @@ static void max98090_shdn_restore_locked(struct max98090_priv *max98090) static void max98090_shdn_save(struct max98090_priv *max98090) { - mutex_lock(&max98090->component->card->dapm_mutex); + mutex_lock(&max98090->shdn_lock); max98090_shdn_save_locked(max98090); } static void max98090_shdn_restore(struct max98090_priv *max98090) { max98090_shdn_restore_locked(max98090); - mutex_unlock(&max98090->component->card->dapm_mutex); + mutex_unlock(&max98090->shdn_lock); } static int max98090_put_volsw(struct snd_kcontrol *kcontrol, @@ -2313,12 +2313,12 @@ static void max98090_pll_work(struct max98090_priv *max98090) */ /* Toggle shutdown OFF then ON */ - mutex_lock(&component->card->dapm_mutex); + mutex_lock(&max98090->shdn_lock); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, 0); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, M98090_SHDNN_MASK); - mutex_unlock(&component->card->dapm_mutex); + mutex_unlock(&max98090->shdn_lock); for (i = 0; i < 10; ++i) { /* Give PLL time to lock */ @@ -2731,6 +2731,8 @@ static int max98090_i2c_probe(struct i2c_client *i2c, if (max98090 == NULL) return -ENOMEM; + mutex_init(&max98090->shdn_lock); + if (ACPI_HANDLE(&i2c->dev)) { acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, &i2c->dev); diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index 0a31708b7df7..dabd8be34a01 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h @@ -1539,6 +1539,7 @@ struct max98090_priv { unsigned int pa2en; unsigned int sidetone; bool master; + struct mutex shdn_lock; int saved_count; int saved_shdn; }; -- cgit v1.2.3 From fbcdf32f6b54266132c6697a80f49c0c494b8877 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Tue, 7 Jan 2020 13:59:28 +0000 Subject: dt-bindings: ASoC: Add WSA881x bindings This patch adds bindings for WSA8810/WSA8815 Class-D Smart Speaker Amplifier. This Amplifier also has a simple thermal sensor for over temperature and speaker protection. Signed-off-by: Srinivas Kandagatla Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20200107135929.3267-2-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/qcom,wsa881x.yaml | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml new file mode 100644 index 000000000000..ea44d03e58ca --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,wsa881x.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/qcom,wsa881x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bindings for Qualcomm WSA8810/WSA8815 Class-D Smart Speaker Amplifier + +maintainers: + - Srinivas Kandagatla + +description: | + WSA8810 is a class-D smart speaker amplifier and WSA8815 + is a high-output power class-D smart speaker amplifier. + Their primary operating mode uses a SoundWire digital audio + interface. This binding is for SoundWire interface. + +properties: + compatible: + const: sdw10217201000 + + reg: + maxItems: 1 + + powerdown-gpios: + description: GPIO spec for Powerdown/Shutdown line to use + maxItems: 1 + + '#thermal-sensor-cells': + const: 0 + + '#sound-dai-cells': + const: 0 + +required: + - compatible + - reg + - powerdown-gpios + - "#thermal-sensor-cells" + - "#sound-dai-cells" + +additionalProperties: false + +examples: + - | + soundwire@c2d0000 { + #address-cells = <2>; + #size-cells = <0>; + reg = <0x0c2d0000 0x2000>; + + speaker@0,1 { + compatible = "sdw10217201000"; + reg = <0 1>; + powerdown-gpios = <&wcdpinctrl 2 0>; + #thermal-sensor-cells = <0>; + #sound-dai-cells = <0>; + }; + + speaker@0,2 { + compatible = "sdw10217201000"; + reg = <0 2>; + powerdown-gpios = <&wcdpinctrl 2 0>; + #thermal-sensor-cells = <0>; + #sound-dai-cells = <0>; + }; + }; + +... -- cgit v1.2.3 From a0aab9e1404ac9f8a300b4546cac3c38e04d07bf Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Tue, 7 Jan 2020 13:59:29 +0000 Subject: ASoC: codecs: add wsa881x amplifier support This patch adds support to WSA8810/WSA8815 Class-D Smart Speaker Amplifier. This Amplifier is primarily interfaced with SoundWire. One WSA is used for mono speaker configuration and second one would give stereo setup. This patch is tested on SDM845 based DragonBoard DB845c and Lenovo YOGA C630 Laptop based on SDM850 with WSA8815 speaker amplifiers. Signed-off-by: Srinivas Kandagatla Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200107135929.3267-3-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 10 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wsa881x.c | 1185 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1197 insertions(+) create mode 100644 sound/soc/codecs/wsa881x.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 146682049007..986a31c68992 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -262,6 +262,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_WM9705 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW) + select SND_SOC_WSA881X if SOUNDWIRE help Normally ASoC codec drivers are only built if a machine driver which uses them is also built since they are only usable with a machine @@ -1481,6 +1482,15 @@ config SND_SOC_WM9713 select REGMAP_AC97 select AC97_BUS_COMPAT if AC97_BUS_NEW +config SND_SOC_WSA881X + tristate "WSA881X Codec" + depends on SOUNDWIRE + select REGMAP_SOUNDWIRE + tristate + help + This enables support for Qualcomm WSA8810/WSA8815 Class-D + Smart Speaker Amplifier. + config SND_SOC_ZX_AUD96P22 tristate "ZTE ZX AUD96P22 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 0290fb389835..495f7e2f63eb 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -278,6 +278,7 @@ snd-soc-wm9705-objs := wm9705.o snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o snd-soc-wm-hubs-objs := wm_hubs.o +snd-soc-wsa881x-objs := wsa881x.o snd-soc-zx-aud96p22-objs := zx_aud96p22.o # Amp snd-soc-max9877-objs := max9877.o @@ -568,6 +569,7 @@ obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o +obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o obj-$(CONFIG_SND_SOC_ZX_AUD96P22) += snd-soc-zx-aud96p22.o # Amp diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c new file mode 100644 index 000000000000..b59f1d0e7f84 --- /dev/null +++ b/sound/soc/codecs/wsa881x.c @@ -0,0 +1,1185 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2015-2017, The Linux Foundation. +// Copyright (c) 2019, Linaro Limited + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WSA881X_DIGITAL_BASE 0x3000 +#define WSA881X_ANALOG_BASE 0x3100 + +/* Digital register address space */ +#define WSA881X_CHIP_ID0 (WSA881X_DIGITAL_BASE + 0x0000) +#define WSA881X_CHIP_ID1 (WSA881X_DIGITAL_BASE + 0x0001) +#define WSA881X_CHIP_ID2 (WSA881X_DIGITAL_BASE + 0x0002) +#define WSA881X_CHIP_ID3 (WSA881X_DIGITAL_BASE + 0x0003) +#define WSA881X_BUS_ID (WSA881X_DIGITAL_BASE + 0x0004) +#define WSA881X_CDC_RST_CTL (WSA881X_DIGITAL_BASE + 0x0005) +#define WSA881X_CDC_TOP_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0006) +#define WSA881X_CDC_ANA_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0007) +#define WSA881X_CDC_DIG_CLK_CTL (WSA881X_DIGITAL_BASE + 0x0008) +#define WSA881X_CLOCK_CONFIG (WSA881X_DIGITAL_BASE + 0x0009) +#define WSA881X_ANA_CTL (WSA881X_DIGITAL_BASE + 0x000A) +#define WSA881X_SWR_RESET_EN (WSA881X_DIGITAL_BASE + 0x000B) +#define WSA881X_RESET_CTL (WSA881X_DIGITAL_BASE + 0x000C) +#define WSA881X_TADC_VALUE_CTL (WSA881X_DIGITAL_BASE + 0x000F) +#define WSA881X_TEMP_DETECT_CTL (WSA881X_DIGITAL_BASE + 0x0010) +#define WSA881X_TEMP_MSB (WSA881X_DIGITAL_BASE + 0x0011) +#define WSA881X_TEMP_LSB (WSA881X_DIGITAL_BASE + 0x0012) +#define WSA881X_TEMP_CONFIG0 (WSA881X_DIGITAL_BASE + 0x0013) +#define WSA881X_TEMP_CONFIG1 (WSA881X_DIGITAL_BASE + 0x0014) +#define WSA881X_CDC_CLIP_CTL (WSA881X_DIGITAL_BASE + 0x0015) +#define WSA881X_SDM_PDM9_LSB (WSA881X_DIGITAL_BASE + 0x0016) +#define WSA881X_SDM_PDM9_MSB (WSA881X_DIGITAL_BASE + 0x0017) +#define WSA881X_CDC_RX_CTL (WSA881X_DIGITAL_BASE + 0x0018) +#define WSA881X_DEM_BYPASS_DATA0 (WSA881X_DIGITAL_BASE + 0x0019) +#define WSA881X_DEM_BYPASS_DATA1 (WSA881X_DIGITAL_BASE + 0x001A) +#define WSA881X_DEM_BYPASS_DATA2 (WSA881X_DIGITAL_BASE + 0x001B) +#define WSA881X_DEM_BYPASS_DATA3 (WSA881X_DIGITAL_BASE + 0x001C) +#define WSA881X_OTP_CTRL0 (WSA881X_DIGITAL_BASE + 0x001D) +#define WSA881X_OTP_CTRL1 (WSA881X_DIGITAL_BASE + 0x001E) +#define WSA881X_HDRIVE_CTL_GROUP1 (WSA881X_DIGITAL_BASE + 0x001F) +#define WSA881X_INTR_MODE (WSA881X_DIGITAL_BASE + 0x0020) +#define WSA881X_INTR_MASK (WSA881X_DIGITAL_BASE + 0x0021) +#define WSA881X_INTR_STATUS (WSA881X_DIGITAL_BASE + 0x0022) +#define WSA881X_INTR_CLEAR (WSA881X_DIGITAL_BASE + 0x0023) +#define WSA881X_INTR_LEVEL (WSA881X_DIGITAL_BASE + 0x0024) +#define WSA881X_INTR_SET (WSA881X_DIGITAL_BASE + 0x0025) +#define WSA881X_INTR_TEST (WSA881X_DIGITAL_BASE + 0x0026) +#define WSA881X_PDM_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0030) +#define WSA881X_ATE_TEST_MODE (WSA881X_DIGITAL_BASE + 0x0031) +#define WSA881X_PIN_CTL_MODE (WSA881X_DIGITAL_BASE + 0x0032) +#define WSA881X_PIN_CTL_OE (WSA881X_DIGITAL_BASE + 0x0033) +#define WSA881X_PIN_WDATA_IOPAD (WSA881X_DIGITAL_BASE + 0x0034) +#define WSA881X_PIN_STATUS (WSA881X_DIGITAL_BASE + 0x0035) +#define WSA881X_DIG_DEBUG_MODE (WSA881X_DIGITAL_BASE + 0x0037) +#define WSA881X_DIG_DEBUG_SEL (WSA881X_DIGITAL_BASE + 0x0038) +#define WSA881X_DIG_DEBUG_EN (WSA881X_DIGITAL_BASE + 0x0039) +#define WSA881X_SWR_HM_TEST1 (WSA881X_DIGITAL_BASE + 0x003B) +#define WSA881X_SWR_HM_TEST2 (WSA881X_DIGITAL_BASE + 0x003C) +#define WSA881X_TEMP_DETECT_DBG_CTL (WSA881X_DIGITAL_BASE + 0x003D) +#define WSA881X_TEMP_DEBUG_MSB (WSA881X_DIGITAL_BASE + 0x003E) +#define WSA881X_TEMP_DEBUG_LSB (WSA881X_DIGITAL_BASE + 0x003F) +#define WSA881X_SAMPLE_EDGE_SEL (WSA881X_DIGITAL_BASE + 0x0044) +#define WSA881X_IOPAD_CTL (WSA881X_DIGITAL_BASE + 0x0045) +#define WSA881X_SPARE_0 (WSA881X_DIGITAL_BASE + 0x0050) +#define WSA881X_SPARE_1 (WSA881X_DIGITAL_BASE + 0x0051) +#define WSA881X_SPARE_2 (WSA881X_DIGITAL_BASE + 0x0052) +#define WSA881X_OTP_REG_0 (WSA881X_DIGITAL_BASE + 0x0080) +#define WSA881X_OTP_REG_1 (WSA881X_DIGITAL_BASE + 0x0081) +#define WSA881X_OTP_REG_2 (WSA881X_DIGITAL_BASE + 0x0082) +#define WSA881X_OTP_REG_3 (WSA881X_DIGITAL_BASE + 0x0083) +#define WSA881X_OTP_REG_4 (WSA881X_DIGITAL_BASE + 0x0084) +#define WSA881X_OTP_REG_5 (WSA881X_DIGITAL_BASE + 0x0085) +#define WSA881X_OTP_REG_6 (WSA881X_DIGITAL_BASE + 0x0086) +#define WSA881X_OTP_REG_7 (WSA881X_DIGITAL_BASE + 0x0087) +#define WSA881X_OTP_REG_8 (WSA881X_DIGITAL_BASE + 0x0088) +#define WSA881X_OTP_REG_9 (WSA881X_DIGITAL_BASE + 0x0089) +#define WSA881X_OTP_REG_10 (WSA881X_DIGITAL_BASE + 0x008A) +#define WSA881X_OTP_REG_11 (WSA881X_DIGITAL_BASE + 0x008B) +#define WSA881X_OTP_REG_12 (WSA881X_DIGITAL_BASE + 0x008C) +#define WSA881X_OTP_REG_13 (WSA881X_DIGITAL_BASE + 0x008D) +#define WSA881X_OTP_REG_14 (WSA881X_DIGITAL_BASE + 0x008E) +#define WSA881X_OTP_REG_15 (WSA881X_DIGITAL_BASE + 0x008F) +#define WSA881X_OTP_REG_16 (WSA881X_DIGITAL_BASE + 0x0090) +#define WSA881X_OTP_REG_17 (WSA881X_DIGITAL_BASE + 0x0091) +#define WSA881X_OTP_REG_18 (WSA881X_DIGITAL_BASE + 0x0092) +#define WSA881X_OTP_REG_19 (WSA881X_DIGITAL_BASE + 0x0093) +#define WSA881X_OTP_REG_20 (WSA881X_DIGITAL_BASE + 0x0094) +#define WSA881X_OTP_REG_21 (WSA881X_DIGITAL_BASE + 0x0095) +#define WSA881X_OTP_REG_22 (WSA881X_DIGITAL_BASE + 0x0096) +#define WSA881X_OTP_REG_23 (WSA881X_DIGITAL_BASE + 0x0097) +#define WSA881X_OTP_REG_24 (WSA881X_DIGITAL_BASE + 0x0098) +#define WSA881X_OTP_REG_25 (WSA881X_DIGITAL_BASE + 0x0099) +#define WSA881X_OTP_REG_26 (WSA881X_DIGITAL_BASE + 0x009A) +#define WSA881X_OTP_REG_27 (WSA881X_DIGITAL_BASE + 0x009B) +#define WSA881X_OTP_REG_28 (WSA881X_DIGITAL_BASE + 0x009C) +#define WSA881X_OTP_REG_29 (WSA881X_DIGITAL_BASE + 0x009D) +#define WSA881X_OTP_REG_30 (WSA881X_DIGITAL_BASE + 0x009E) +#define WSA881X_OTP_REG_31 (WSA881X_DIGITAL_BASE + 0x009F) +#define WSA881X_OTP_REG_63 (WSA881X_DIGITAL_BASE + 0x00BF) + +/* Analog Register address space */ +#define WSA881X_BIAS_REF_CTRL (WSA881X_ANALOG_BASE + 0x0000) +#define WSA881X_BIAS_TEST (WSA881X_ANALOG_BASE + 0x0001) +#define WSA881X_BIAS_BIAS (WSA881X_ANALOG_BASE + 0x0002) +#define WSA881X_TEMP_OP (WSA881X_ANALOG_BASE + 0x0003) +#define WSA881X_TEMP_IREF_CTRL (WSA881X_ANALOG_BASE + 0x0004) +#define WSA881X_TEMP_ISENS_CTRL (WSA881X_ANALOG_BASE + 0x0005) +#define WSA881X_TEMP_CLK_CTRL (WSA881X_ANALOG_BASE + 0x0006) +#define WSA881X_TEMP_TEST (WSA881X_ANALOG_BASE + 0x0007) +#define WSA881X_TEMP_BIAS (WSA881X_ANALOG_BASE + 0x0008) +#define WSA881X_TEMP_ADC_CTRL (WSA881X_ANALOG_BASE + 0x0009) +#define WSA881X_TEMP_DOUT_MSB (WSA881X_ANALOG_BASE + 0x000A) +#define WSA881X_TEMP_DOUT_LSB (WSA881X_ANALOG_BASE + 0x000B) +#define WSA881X_ADC_EN_MODU_V (WSA881X_ANALOG_BASE + 0x0010) +#define WSA881X_ADC_EN_MODU_I (WSA881X_ANALOG_BASE + 0x0011) +#define WSA881X_ADC_EN_DET_TEST_V (WSA881X_ANALOG_BASE + 0x0012) +#define WSA881X_ADC_EN_DET_TEST_I (WSA881X_ANALOG_BASE + 0x0013) +#define WSA881X_ADC_SEL_IBIAS (WSA881X_ANALOG_BASE + 0x0014) +#define WSA881X_ADC_EN_SEL_IBAIS (WSA881X_ANALOG_BASE + 0x0015) +#define WSA881X_SPKR_DRV_EN (WSA881X_ANALOG_BASE + 0x001A) +#define WSA881X_SPKR_DRV_GAIN (WSA881X_ANALOG_BASE + 0x001B) +#define WSA881X_PA_GAIN_SEL_MASK BIT(3) +#define WSA881X_PA_GAIN_SEL_REG BIT(3) +#define WSA881X_PA_GAIN_SEL_DRE 0 +#define WSA881X_SPKR_PAG_GAIN_MASK GENMASK(7, 4) +#define WSA881X_SPKR_DAC_CTL (WSA881X_ANALOG_BASE + 0x001C) +#define WSA881X_SPKR_DRV_DBG (WSA881X_ANALOG_BASE + 0x001D) +#define WSA881X_SPKR_PWRSTG_DBG (WSA881X_ANALOG_BASE + 0x001E) +#define WSA881X_SPKR_OCP_CTL (WSA881X_ANALOG_BASE + 0x001F) +#define WSA881X_SPKR_OCP_MASK GENMASK(7, 6) +#define WSA881X_SPKR_OCP_EN BIT(7) +#define WSA881X_SPKR_OCP_HOLD BIT(6) +#define WSA881X_SPKR_CLIP_CTL (WSA881X_ANALOG_BASE + 0x0020) +#define WSA881X_SPKR_BBM_CTL (WSA881X_ANALOG_BASE + 0x0021) +#define WSA881X_SPKR_MISC_CTL1 (WSA881X_ANALOG_BASE + 0x0022) +#define WSA881X_SPKR_MISC_CTL2 (WSA881X_ANALOG_BASE + 0x0023) +#define WSA881X_SPKR_BIAS_INT (WSA881X_ANALOG_BASE + 0x0024) +#define WSA881X_SPKR_PA_INT (WSA881X_ANALOG_BASE + 0x0025) +#define WSA881X_SPKR_BIAS_CAL (WSA881X_ANALOG_BASE + 0x0026) +#define WSA881X_SPKR_BIAS_PSRR (WSA881X_ANALOG_BASE + 0x0027) +#define WSA881X_SPKR_STATUS1 (WSA881X_ANALOG_BASE + 0x0028) +#define WSA881X_SPKR_STATUS2 (WSA881X_ANALOG_BASE + 0x0029) +#define WSA881X_BOOST_EN_CTL (WSA881X_ANALOG_BASE + 0x002A) +#define WSA881X_BOOST_EN_MASK BIT(7) +#define WSA881X_BOOST_EN BIT(7) +#define WSA881X_BOOST_CURRENT_LIMIT (WSA881X_ANALOG_BASE + 0x002B) +#define WSA881X_BOOST_PS_CTL (WSA881X_ANALOG_BASE + 0x002C) +#define WSA881X_BOOST_PRESET_OUT1 (WSA881X_ANALOG_BASE + 0x002D) +#define WSA881X_BOOST_PRESET_OUT2 (WSA881X_ANALOG_BASE + 0x002E) +#define WSA881X_BOOST_FORCE_OUT (WSA881X_ANALOG_BASE + 0x002F) +#define WSA881X_BOOST_LDO_PROG (WSA881X_ANALOG_BASE + 0x0030) +#define WSA881X_BOOST_SLOPE_COMP_ISENSE_FB (WSA881X_ANALOG_BASE + 0x0031) +#define WSA881X_BOOST_RON_CTL (WSA881X_ANALOG_BASE + 0x0032) +#define WSA881X_BOOST_LOOP_STABILITY (WSA881X_ANALOG_BASE + 0x0033) +#define WSA881X_BOOST_ZX_CTL (WSA881X_ANALOG_BASE + 0x0034) +#define WSA881X_BOOST_START_CTL (WSA881X_ANALOG_BASE + 0x0035) +#define WSA881X_BOOST_MISC1_CTL (WSA881X_ANALOG_BASE + 0x0036) +#define WSA881X_BOOST_MISC2_CTL (WSA881X_ANALOG_BASE + 0x0037) +#define WSA881X_BOOST_MISC3_CTL (WSA881X_ANALOG_BASE + 0x0038) +#define WSA881X_BOOST_ATEST_CTL (WSA881X_ANALOG_BASE + 0x0039) +#define WSA881X_SPKR_PROT_FE_GAIN (WSA881X_ANALOG_BASE + 0x003A) +#define WSA881X_SPKR_PROT_FE_CM_LDO_SET (WSA881X_ANALOG_BASE + 0x003B) +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x003C) +#define WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2 (WSA881X_ANALOG_BASE + 0x003D) +#define WSA881X_SPKR_PROT_ATEST1 (WSA881X_ANALOG_BASE + 0x003E) +#define WSA881X_SPKR_PROT_ATEST2 (WSA881X_ANALOG_BASE + 0x003F) +#define WSA881X_SPKR_PROT_FE_VSENSE_VCM (WSA881X_ANALOG_BASE + 0x0040) +#define WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1 (WSA881X_ANALOG_BASE + 0x0041) +#define WSA881X_BONGO_RESRV_REG1 (WSA881X_ANALOG_BASE + 0x0042) +#define WSA881X_BONGO_RESRV_REG2 (WSA881X_ANALOG_BASE + 0x0043) +#define WSA881X_SPKR_PROT_SAR (WSA881X_ANALOG_BASE + 0x0044) +#define WSA881X_SPKR_STATUS3 (WSA881X_ANALOG_BASE + 0x0045) + +#define SWRS_SCP_FRAME_CTRL_BANK(m) (0x60 + 0x10 * (m)) +#define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m)) +#define SWR_SLV_MAX_REG_ADDR 0x390 +#define SWR_SLV_START_REG_ADDR 0x40 +#define SWR_SLV_MAX_BUF_LEN 20 +#define BYTES_PER_LINE 12 +#define SWR_SLV_RD_BUF_LEN 8 +#define SWR_SLV_WR_BUF_LEN 32 +#define SWR_SLV_MAX_DEVICES 2 +#define WSA881X_MAX_SWR_PORTS 4 +#define WSA881X_VERSION_ENTRY_SIZE 27 +#define WSA881X_OCP_CTL_TIMER_SEC 2 +#define WSA881X_OCP_CTL_TEMP_CELSIUS 25 +#define WSA881X_OCP_CTL_POLL_TIMER_SEC 60 + +#define WSA881X_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ + SNDRV_CTL_ELEM_ACCESS_READWRITE,\ + .tlv.p = (tlv_array), \ + .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ + .put = wsa881x_put_pa_gain, \ + .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } + +static struct reg_default wsa881x_defaults[] = { + { WSA881X_CHIP_ID0, 0x00 }, + { WSA881X_CHIP_ID1, 0x00 }, + { WSA881X_CHIP_ID2, 0x00 }, + { WSA881X_CHIP_ID3, 0x02 }, + { WSA881X_BUS_ID, 0x00 }, + { WSA881X_CDC_RST_CTL, 0x00 }, + { WSA881X_CDC_TOP_CLK_CTL, 0x03 }, + { WSA881X_CDC_ANA_CLK_CTL, 0x00 }, + { WSA881X_CDC_DIG_CLK_CTL, 0x00 }, + { WSA881X_CLOCK_CONFIG, 0x00 }, + { WSA881X_ANA_CTL, 0x08 }, + { WSA881X_SWR_RESET_EN, 0x00 }, + { WSA881X_TEMP_DETECT_CTL, 0x01 }, + { WSA881X_TEMP_MSB, 0x00 }, + { WSA881X_TEMP_LSB, 0x00 }, + { WSA881X_TEMP_CONFIG0, 0x00 }, + { WSA881X_TEMP_CONFIG1, 0x00 }, + { WSA881X_CDC_CLIP_CTL, 0x03 }, + { WSA881X_SDM_PDM9_LSB, 0x00 }, + { WSA881X_SDM_PDM9_MSB, 0x00 }, + { WSA881X_CDC_RX_CTL, 0x7E }, + { WSA881X_DEM_BYPASS_DATA0, 0x00 }, + { WSA881X_DEM_BYPASS_DATA1, 0x00 }, + { WSA881X_DEM_BYPASS_DATA2, 0x00 }, + { WSA881X_DEM_BYPASS_DATA3, 0x00 }, + { WSA881X_OTP_CTRL0, 0x00 }, + { WSA881X_OTP_CTRL1, 0x00 }, + { WSA881X_HDRIVE_CTL_GROUP1, 0x00 }, + { WSA881X_INTR_MODE, 0x00 }, + { WSA881X_INTR_STATUS, 0x00 }, + { WSA881X_INTR_CLEAR, 0x00 }, + { WSA881X_INTR_LEVEL, 0x00 }, + { WSA881X_INTR_SET, 0x00 }, + { WSA881X_INTR_TEST, 0x00 }, + { WSA881X_PDM_TEST_MODE, 0x00 }, + { WSA881X_ATE_TEST_MODE, 0x00 }, + { WSA881X_PIN_CTL_MODE, 0x00 }, + { WSA881X_PIN_CTL_OE, 0x00 }, + { WSA881X_PIN_WDATA_IOPAD, 0x00 }, + { WSA881X_PIN_STATUS, 0x00 }, + { WSA881X_DIG_DEBUG_MODE, 0x00 }, + { WSA881X_DIG_DEBUG_SEL, 0x00 }, + { WSA881X_DIG_DEBUG_EN, 0x00 }, + { WSA881X_SWR_HM_TEST1, 0x08 }, + { WSA881X_SWR_HM_TEST2, 0x00 }, + { WSA881X_TEMP_DETECT_DBG_CTL, 0x00 }, + { WSA881X_TEMP_DEBUG_MSB, 0x00 }, + { WSA881X_TEMP_DEBUG_LSB, 0x00 }, + { WSA881X_SAMPLE_EDGE_SEL, 0x0C }, + { WSA881X_SPARE_0, 0x00 }, + { WSA881X_SPARE_1, 0x00 }, + { WSA881X_SPARE_2, 0x00 }, + { WSA881X_OTP_REG_0, 0x01 }, + { WSA881X_OTP_REG_1, 0xFF }, + { WSA881X_OTP_REG_2, 0xC0 }, + { WSA881X_OTP_REG_3, 0xFF }, + { WSA881X_OTP_REG_4, 0xC0 }, + { WSA881X_OTP_REG_5, 0xFF }, + { WSA881X_OTP_REG_6, 0xFF }, + { WSA881X_OTP_REG_7, 0xFF }, + { WSA881X_OTP_REG_8, 0xFF }, + { WSA881X_OTP_REG_9, 0xFF }, + { WSA881X_OTP_REG_10, 0xFF }, + { WSA881X_OTP_REG_11, 0xFF }, + { WSA881X_OTP_REG_12, 0xFF }, + { WSA881X_OTP_REG_13, 0xFF }, + { WSA881X_OTP_REG_14, 0xFF }, + { WSA881X_OTP_REG_15, 0xFF }, + { WSA881X_OTP_REG_16, 0xFF }, + { WSA881X_OTP_REG_17, 0xFF }, + { WSA881X_OTP_REG_18, 0xFF }, + { WSA881X_OTP_REG_19, 0xFF }, + { WSA881X_OTP_REG_20, 0xFF }, + { WSA881X_OTP_REG_21, 0xFF }, + { WSA881X_OTP_REG_22, 0xFF }, + { WSA881X_OTP_REG_23, 0xFF }, + { WSA881X_OTP_REG_24, 0x03 }, + { WSA881X_OTP_REG_25, 0x01 }, + { WSA881X_OTP_REG_26, 0x03 }, + { WSA881X_OTP_REG_27, 0x11 }, + { WSA881X_OTP_REG_63, 0x40 }, + /* WSA881x Analog registers */ + { WSA881X_BIAS_REF_CTRL, 0x6C }, + { WSA881X_BIAS_TEST, 0x16 }, + { WSA881X_BIAS_BIAS, 0xF0 }, + { WSA881X_TEMP_OP, 0x00 }, + { WSA881X_TEMP_IREF_CTRL, 0x56 }, + { WSA881X_TEMP_ISENS_CTRL, 0x47 }, + { WSA881X_TEMP_CLK_CTRL, 0x87 }, + { WSA881X_TEMP_TEST, 0x00 }, + { WSA881X_TEMP_BIAS, 0x51 }, + { WSA881X_TEMP_DOUT_MSB, 0x00 }, + { WSA881X_TEMP_DOUT_LSB, 0x00 }, + { WSA881X_ADC_EN_MODU_V, 0x00 }, + { WSA881X_ADC_EN_MODU_I, 0x00 }, + { WSA881X_ADC_EN_DET_TEST_V, 0x00 }, + { WSA881X_ADC_EN_DET_TEST_I, 0x00 }, + { WSA881X_ADC_EN_SEL_IBAIS, 0x10 }, + { WSA881X_SPKR_DRV_EN, 0x74 }, + { WSA881X_SPKR_DRV_DBG, 0x15 }, + { WSA881X_SPKR_PWRSTG_DBG, 0x00 }, + { WSA881X_SPKR_OCP_CTL, 0xD4 }, + { WSA881X_SPKR_CLIP_CTL, 0x90 }, + { WSA881X_SPKR_PA_INT, 0x54 }, + { WSA881X_SPKR_BIAS_CAL, 0xAC }, + { WSA881X_SPKR_STATUS1, 0x00 }, + { WSA881X_SPKR_STATUS2, 0x00 }, + { WSA881X_BOOST_EN_CTL, 0x18 }, + { WSA881X_BOOST_CURRENT_LIMIT, 0x7A }, + { WSA881X_BOOST_PRESET_OUT2, 0x70 }, + { WSA881X_BOOST_FORCE_OUT, 0x0E }, + { WSA881X_BOOST_LDO_PROG, 0x16 }, + { WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x71 }, + { WSA881X_BOOST_RON_CTL, 0x0F }, + { WSA881X_BOOST_ZX_CTL, 0x34 }, + { WSA881X_BOOST_START_CTL, 0x23 }, + { WSA881X_BOOST_MISC1_CTL, 0x80 }, + { WSA881X_BOOST_MISC2_CTL, 0x00 }, + { WSA881X_BOOST_MISC3_CTL, 0x00 }, + { WSA881X_BOOST_ATEST_CTL, 0x00 }, + { WSA881X_SPKR_PROT_FE_GAIN, 0x46 }, + { WSA881X_SPKR_PROT_FE_CM_LDO_SET, 0x3B }, + { WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1, 0x8D }, + { WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2, 0x8D }, + { WSA881X_SPKR_PROT_ATEST1, 0x01 }, + { WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x8D }, + { WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1, 0x4D }, + { WSA881X_SPKR_PROT_SAR, 0x00 }, + { WSA881X_SPKR_STATUS3, 0x00 }, +}; + +static const struct reg_sequence wsa881x_pre_pmu_pa_2_0[] = { + { WSA881X_SPKR_DRV_GAIN, 0x41, 0 }, + { WSA881X_SPKR_MISC_CTL1, 0x87, 0 }, +}; + +static const struct reg_sequence wsa881x_vi_txfe_en_2_0[] = { + { WSA881X_SPKR_PROT_FE_VSENSE_VCM, 0x85, 0 }, + { WSA881X_SPKR_PROT_ATEST2, 0x0A, 0 }, + { WSA881X_SPKR_PROT_FE_GAIN, 0x47, 0 }, +}; + +/* Default register reset values for WSA881x rev 2.0 */ +static struct reg_sequence wsa881x_rev_2_0[] = { + { WSA881X_RESET_CTL, 0x00, 0x00 }, + { WSA881X_TADC_VALUE_CTL, 0x01, 0x00 }, + { WSA881X_INTR_MASK, 0x1B, 0x00 }, + { WSA881X_IOPAD_CTL, 0x00, 0x00 }, + { WSA881X_OTP_REG_28, 0x3F, 0x00 }, + { WSA881X_OTP_REG_29, 0x3F, 0x00 }, + { WSA881X_OTP_REG_30, 0x01, 0x00 }, + { WSA881X_OTP_REG_31, 0x01, 0x00 }, + { WSA881X_TEMP_ADC_CTRL, 0x03, 0x00 }, + { WSA881X_ADC_SEL_IBIAS, 0x45, 0x00 }, + { WSA881X_SPKR_DRV_GAIN, 0xC1, 0x00 }, + { WSA881X_SPKR_DAC_CTL, 0x42, 0x00 }, + { WSA881X_SPKR_BBM_CTL, 0x02, 0x00 }, + { WSA881X_SPKR_MISC_CTL1, 0x40, 0x00 }, + { WSA881X_SPKR_MISC_CTL2, 0x07, 0x00 }, + { WSA881X_SPKR_BIAS_INT, 0x5F, 0x00 }, + { WSA881X_SPKR_BIAS_PSRR, 0x44, 0x00 }, + { WSA881X_BOOST_PS_CTL, 0xA0, 0x00 }, + { WSA881X_BOOST_PRESET_OUT1, 0xB7, 0x00 }, + { WSA881X_BOOST_LOOP_STABILITY, 0x8D, 0x00 }, + { WSA881X_SPKR_PROT_ATEST2, 0x02, 0x00 }, + { WSA881X_BONGO_RESRV_REG1, 0x5E, 0x00 }, + { WSA881X_BONGO_RESRV_REG2, 0x07, 0x00 }, +}; + +enum wsa_port_ids { + WSA881X_PORT_DAC, + WSA881X_PORT_COMP, + WSA881X_PORT_BOOST, + WSA881X_PORT_VISENSE, +}; + +/* 4 ports */ +static struct sdw_dpn_prop wsa_sink_dpn_prop[WSA881X_MAX_SWR_PORTS] = { + { + /* DAC */ + .num = 1, + .type = SDW_DPN_SIMPLE, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* COMP */ + .num = 2, + .type = SDW_DPN_SIMPLE, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* BOOST */ + .num = 3, + .type = SDW_DPN_SIMPLE, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + }, { + /* VISENSE */ + .num = 4, + .type = SDW_DPN_SIMPLE, + .min_ch = 1, + .max_ch = 1, + .simple_ch_prep_sm = true, + } +}; + +static struct sdw_port_config wsa881x_pconfig[WSA881X_MAX_SWR_PORTS] = { + { + .num = 1, + .ch_mask = 0x1, + }, { + .num = 2, + .ch_mask = 0xf, + }, { + .num = 3, + .ch_mask = 0x3, + }, { /* IV feedback */ + .num = 4, + .ch_mask = 0x3, + }, +}; + +static bool wsa881x_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case WSA881X_CHIP_ID0: + case WSA881X_CHIP_ID1: + case WSA881X_CHIP_ID2: + case WSA881X_CHIP_ID3: + case WSA881X_BUS_ID: + case WSA881X_CDC_RST_CTL: + case WSA881X_CDC_TOP_CLK_CTL: + case WSA881X_CDC_ANA_CLK_CTL: + case WSA881X_CDC_DIG_CLK_CTL: + case WSA881X_CLOCK_CONFIG: + case WSA881X_ANA_CTL: + case WSA881X_SWR_RESET_EN: + case WSA881X_RESET_CTL: + case WSA881X_TADC_VALUE_CTL: + case WSA881X_TEMP_DETECT_CTL: + case WSA881X_TEMP_MSB: + case WSA881X_TEMP_LSB: + case WSA881X_TEMP_CONFIG0: + case WSA881X_TEMP_CONFIG1: + case WSA881X_CDC_CLIP_CTL: + case WSA881X_SDM_PDM9_LSB: + case WSA881X_SDM_PDM9_MSB: + case WSA881X_CDC_RX_CTL: + case WSA881X_DEM_BYPASS_DATA0: + case WSA881X_DEM_BYPASS_DATA1: + case WSA881X_DEM_BYPASS_DATA2: + case WSA881X_DEM_BYPASS_DATA3: + case WSA881X_OTP_CTRL0: + case WSA881X_OTP_CTRL1: + case WSA881X_HDRIVE_CTL_GROUP1: + case WSA881X_INTR_MODE: + case WSA881X_INTR_MASK: + case WSA881X_INTR_STATUS: + case WSA881X_INTR_CLEAR: + case WSA881X_INTR_LEVEL: + case WSA881X_INTR_SET: + case WSA881X_INTR_TEST: + case WSA881X_PDM_TEST_MODE: + case WSA881X_ATE_TEST_MODE: + case WSA881X_PIN_CTL_MODE: + case WSA881X_PIN_CTL_OE: + case WSA881X_PIN_WDATA_IOPAD: + case WSA881X_PIN_STATUS: + case WSA881X_DIG_DEBUG_MODE: + case WSA881X_DIG_DEBUG_SEL: + case WSA881X_DIG_DEBUG_EN: + case WSA881X_SWR_HM_TEST1: + case WSA881X_SWR_HM_TEST2: + case WSA881X_TEMP_DETECT_DBG_CTL: + case WSA881X_TEMP_DEBUG_MSB: + case WSA881X_TEMP_DEBUG_LSB: + case WSA881X_SAMPLE_EDGE_SEL: + case WSA881X_IOPAD_CTL: + case WSA881X_SPARE_0: + case WSA881X_SPARE_1: + case WSA881X_SPARE_2: + case WSA881X_OTP_REG_0: + case WSA881X_OTP_REG_1: + case WSA881X_OTP_REG_2: + case WSA881X_OTP_REG_3: + case WSA881X_OTP_REG_4: + case WSA881X_OTP_REG_5: + case WSA881X_OTP_REG_6: + case WSA881X_OTP_REG_7: + case WSA881X_OTP_REG_8: + case WSA881X_OTP_REG_9: + case WSA881X_OTP_REG_10: + case WSA881X_OTP_REG_11: + case WSA881X_OTP_REG_12: + case WSA881X_OTP_REG_13: + case WSA881X_OTP_REG_14: + case WSA881X_OTP_REG_15: + case WSA881X_OTP_REG_16: + case WSA881X_OTP_REG_17: + case WSA881X_OTP_REG_18: + case WSA881X_OTP_REG_19: + case WSA881X_OTP_REG_20: + case WSA881X_OTP_REG_21: + case WSA881X_OTP_REG_22: + case WSA881X_OTP_REG_23: + case WSA881X_OTP_REG_24: + case WSA881X_OTP_REG_25: + case WSA881X_OTP_REG_26: + case WSA881X_OTP_REG_27: + case WSA881X_OTP_REG_28: + case WSA881X_OTP_REG_29: + case WSA881X_OTP_REG_30: + case WSA881X_OTP_REG_31: + case WSA881X_OTP_REG_63: + case WSA881X_BIAS_REF_CTRL: + case WSA881X_BIAS_TEST: + case WSA881X_BIAS_BIAS: + case WSA881X_TEMP_OP: + case WSA881X_TEMP_IREF_CTRL: + case WSA881X_TEMP_ISENS_CTRL: + case WSA881X_TEMP_CLK_CTRL: + case WSA881X_TEMP_TEST: + case WSA881X_TEMP_BIAS: + case WSA881X_TEMP_ADC_CTRL: + case WSA881X_TEMP_DOUT_MSB: + case WSA881X_TEMP_DOUT_LSB: + case WSA881X_ADC_EN_MODU_V: + case WSA881X_ADC_EN_MODU_I: + case WSA881X_ADC_EN_DET_TEST_V: + case WSA881X_ADC_EN_DET_TEST_I: + case WSA881X_ADC_SEL_IBIAS: + case WSA881X_ADC_EN_SEL_IBAIS: + case WSA881X_SPKR_DRV_EN: + case WSA881X_SPKR_DRV_GAIN: + case WSA881X_SPKR_DAC_CTL: + case WSA881X_SPKR_DRV_DBG: + case WSA881X_SPKR_PWRSTG_DBG: + case WSA881X_SPKR_OCP_CTL: + case WSA881X_SPKR_CLIP_CTL: + case WSA881X_SPKR_BBM_CTL: + case WSA881X_SPKR_MISC_CTL1: + case WSA881X_SPKR_MISC_CTL2: + case WSA881X_SPKR_BIAS_INT: + case WSA881X_SPKR_PA_INT: + case WSA881X_SPKR_BIAS_CAL: + case WSA881X_SPKR_BIAS_PSRR: + case WSA881X_SPKR_STATUS1: + case WSA881X_SPKR_STATUS2: + case WSA881X_BOOST_EN_CTL: + case WSA881X_BOOST_CURRENT_LIMIT: + case WSA881X_BOOST_PS_CTL: + case WSA881X_BOOST_PRESET_OUT1: + case WSA881X_BOOST_PRESET_OUT2: + case WSA881X_BOOST_FORCE_OUT: + case WSA881X_BOOST_LDO_PROG: + case WSA881X_BOOST_SLOPE_COMP_ISENSE_FB: + case WSA881X_BOOST_RON_CTL: + case WSA881X_BOOST_LOOP_STABILITY: + case WSA881X_BOOST_ZX_CTL: + case WSA881X_BOOST_START_CTL: + case WSA881X_BOOST_MISC1_CTL: + case WSA881X_BOOST_MISC2_CTL: + case WSA881X_BOOST_MISC3_CTL: + case WSA881X_BOOST_ATEST_CTL: + case WSA881X_SPKR_PROT_FE_GAIN: + case WSA881X_SPKR_PROT_FE_CM_LDO_SET: + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET1: + case WSA881X_SPKR_PROT_FE_ISENSE_BIAS_SET2: + case WSA881X_SPKR_PROT_ATEST1: + case WSA881X_SPKR_PROT_ATEST2: + case WSA881X_SPKR_PROT_FE_VSENSE_VCM: + case WSA881X_SPKR_PROT_FE_VSENSE_BIAS_SET1: + case WSA881X_BONGO_RESRV_REG1: + case WSA881X_BONGO_RESRV_REG2: + case WSA881X_SPKR_PROT_SAR: + case WSA881X_SPKR_STATUS3: + return true; + default: + return false; + } +} + +static bool wsa881x_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case WSA881X_CHIP_ID0: + case WSA881X_CHIP_ID1: + case WSA881X_CHIP_ID2: + case WSA881X_CHIP_ID3: + case WSA881X_BUS_ID: + case WSA881X_TEMP_MSB: + case WSA881X_TEMP_LSB: + case WSA881X_SDM_PDM9_LSB: + case WSA881X_SDM_PDM9_MSB: + case WSA881X_OTP_CTRL1: + case WSA881X_INTR_STATUS: + case WSA881X_ATE_TEST_MODE: + case WSA881X_PIN_STATUS: + case WSA881X_SWR_HM_TEST2: + case WSA881X_SPKR_STATUS1: + case WSA881X_SPKR_STATUS2: + case WSA881X_SPKR_STATUS3: + case WSA881X_OTP_REG_0: + case WSA881X_OTP_REG_1: + case WSA881X_OTP_REG_2: + case WSA881X_OTP_REG_3: + case WSA881X_OTP_REG_4: + case WSA881X_OTP_REG_5: + case WSA881X_OTP_REG_31: + case WSA881X_TEMP_DOUT_MSB: + case WSA881X_TEMP_DOUT_LSB: + case WSA881X_TEMP_OP: + case WSA881X_SPKR_PROT_SAR: + return true; + default: + return false; + } +} + +static struct regmap_config wsa881x_regmap_config = { + .reg_bits = 32, + .val_bits = 8, + .cache_type = REGCACHE_RBTREE, + .reg_defaults = wsa881x_defaults, + .num_reg_defaults = ARRAY_SIZE(wsa881x_defaults), + .volatile_reg = wsa881x_volatile_register, + .readable_reg = wsa881x_readable_register, + .reg_format_endian = REGMAP_ENDIAN_NATIVE, + .val_format_endian = REGMAP_ENDIAN_NATIVE, + .can_multi_write = true, +}; + +enum { + G_18DB = 0, + G_16P5DB, + G_15DB, + G_13P5DB, + G_12DB, + G_10P5DB, + G_9DB, + G_7P5DB, + G_6DB, + G_4P5DB, + G_3DB, + G_1P5DB, + G_0DB, +}; + +/* + * Private data Structure for wsa881x. All parameters related to + * WSA881X codec needs to be defined here. + */ +struct wsa881x_priv { + struct regmap *regmap; + struct device *dev; + struct sdw_slave *slave; + struct sdw_stream_config sconfig; + struct sdw_stream_runtime *sruntime; + struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS]; + struct gpio_desc *sd_n; + int version; + int active_ports; + bool port_prepared[WSA881X_MAX_SWR_PORTS]; + bool port_enable[WSA881X_MAX_SWR_PORTS]; + bool stream_prepared; +}; + +static void wsa881x_init(struct wsa881x_priv *wsa881x) +{ + struct regmap *rm = wsa881x->regmap; + unsigned int val = 0; + + regmap_read(rm, WSA881X_CHIP_ID1, &wsa881x->version); + regmap_register_patch(wsa881x->regmap, wsa881x_rev_2_0, + ARRAY_SIZE(wsa881x_rev_2_0)); + + /* Enable software reset output from soundwire slave */ + regmap_update_bits(rm, WSA881X_SWR_RESET_EN, 0x07, 0x07); + + /* Bring out of analog reset */ + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x02, 0x02); + + /* Bring out of digital reset */ + regmap_update_bits(rm, WSA881X_CDC_RST_CTL, 0x01, 0x01); + regmap_update_bits(rm, WSA881X_CLOCK_CONFIG, 0x10, 0x10); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x02, 0x02); + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80); + regmap_update_bits(rm, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06); + regmap_update_bits(rm, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00); + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0xF0, 0x40); + regmap_update_bits(rm, WSA881X_SPKR_PA_INT, 0x0E, 0x0E); + regmap_update_bits(rm, WSA881X_BOOST_LOOP_STABILITY, 0x03, 0x03); + regmap_update_bits(rm, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14); + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x80, 0x80); + regmap_update_bits(rm, WSA881X_BOOST_START_CTL, 0x03, 0x00); + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x0C, 0x04); + regmap_update_bits(rm, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, 0x03, 0x00); + + regmap_read(rm, WSA881X_OTP_REG_0, &val); + if (val) + regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT1, 0xF0, 0x70); + + regmap_update_bits(rm, WSA881X_BOOST_PRESET_OUT2, 0xF0, 0x30); + regmap_update_bits(rm, WSA881X_SPKR_DRV_EN, 0x08, 0x08); + regmap_update_bits(rm, WSA881X_BOOST_CURRENT_LIMIT, 0x0F, 0x08); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x30, 0x30); + regmap_update_bits(rm, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); + regmap_update_bits(rm, WSA881X_OTP_REG_28, 0x3F, 0x3A); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG1, 0xFF, 0xB2); + regmap_update_bits(rm, WSA881X_BONGO_RESRV_REG2, 0xFF, 0x05); +} + +static int wsa881x_component_probe(struct snd_soc_component *comp) +{ + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + snd_soc_component_init_regmap(comp, wsa881x->regmap); + + return 0; +} + +static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kc); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kc->private_value; + int max = mc->max; + unsigned int mask = (1 << fls(max)) - 1; + int val, ret, min_gain, max_gain; + + max_gain = (max - ucontrol->value.integer.value[0]) & mask; + /* + * Gain has to set incrementally in 4 steps + * as per HW sequence + */ + if (max_gain > G_4P5DB) + min_gain = G_0DB; + else + min_gain = max_gain + 3; + /* + * 1ms delay is needed before change in gain + * as per HW requirement. + */ + usleep_range(1000, 1010); + + for (val = min_gain; max_gain <= val; val--) { + ret = snd_soc_component_update_bits(comp, + WSA881X_SPKR_DRV_GAIN, + WSA881X_SPKR_PAG_GAIN_MASK, + val << 4); + if (ret < 0) + dev_err(comp->dev, "Failed to change PA gain"); + + usleep_range(1000, 1010); + } + return 0; +} + +static int wsa881x_get_port(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kcontrol->private_value; + int portidx = mixer->reg; + + ucontrol->value.integer.value[0] = data->port_enable[portidx]; + + + return 0; +} + +static int wsa881x_boost_ctrl(struct snd_soc_component *comp, bool enable) +{ + if (enable) + snd_soc_component_update_bits(comp, WSA881X_BOOST_EN_CTL, + WSA881X_BOOST_EN_MASK, + WSA881X_BOOST_EN); + else + snd_soc_component_update_bits(comp, WSA881X_BOOST_EN_CTL, + WSA881X_BOOST_EN_MASK, 0); + /* + * 1.5ms sleep is needed after boost enable/disable as per + * HW requirement + */ + usleep_range(1500, 1510); + return 0; +} + +static int wsa881x_set_port(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *data = snd_soc_component_get_drvdata(comp); + struct soc_mixer_control *mixer = + (struct soc_mixer_control *)kcontrol->private_value; + int portidx = mixer->reg; + + if (ucontrol->value.integer.value[0]) + data->port_enable[portidx] = true; + else + data->port_enable[portidx] = false; + + if (portidx == WSA881X_PORT_BOOST) /* Boost Switch */ + wsa881x_boost_ctrl(comp, data->port_enable[portidx]); + + return 0; +} + +static const char * const smart_boost_lvl_text[] = { + "6.625 V", "6.750 V", "6.875 V", "7.000 V", + "7.125 V", "7.250 V", "7.375 V", "7.500 V", + "7.625 V", "7.750 V", "7.875 V", "8.000 V", + "8.125 V", "8.250 V", "8.375 V", "8.500 V" +}; + +static const struct soc_enum smart_boost_lvl_enum = + SOC_ENUM_SINGLE(WSA881X_BOOST_PRESET_OUT1, 0, + ARRAY_SIZE(smart_boost_lvl_text), + smart_boost_lvl_text); + +static const DECLARE_TLV_DB_SCALE(pa_gain, 0, 150, 0); + +static const struct snd_kcontrol_new wsa881x_snd_controls[] = { + SOC_ENUM("Smart Boost Level", smart_boost_lvl_enum), + WSA881X_PA_GAIN_TLV("PA Volume", WSA881X_SPKR_DRV_GAIN, + 4, 0xC, 1, pa_gain), + SOC_SINGLE_EXT("DAC Switch", WSA881X_PORT_DAC, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + SOC_SINGLE_EXT("COMP Switch", WSA881X_PORT_COMP, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + SOC_SINGLE_EXT("BOOST Switch", WSA881X_PORT_BOOST, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), + SOC_SINGLE_EXT("VISENSE Switch", WSA881X_PORT_VISENSE, 0, 1, 0, + wsa881x_get_port, wsa881x_set_port), +}; + +static const struct snd_soc_dapm_route wsa881x_audio_map[] = { + { "RDAC", NULL, "IN" }, + { "RDAC", NULL, "DCLK" }, + { "RDAC", NULL, "ACLK" }, + { "RDAC", NULL, "Bandgap" }, + { "SPKR PGA", NULL, "RDAC" }, + { "SPKR", NULL, "SPKR PGA" }, +}; + +static int wsa881x_visense_txfe_ctrl(struct snd_soc_component *comp, + bool enable) +{ + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + if (enable) { + regmap_multi_reg_write(wsa881x->regmap, wsa881x_vi_txfe_en_2_0, + ARRAY_SIZE(wsa881x_vi_txfe_en_2_0)); + } else { + snd_soc_component_update_bits(comp, + WSA881X_SPKR_PROT_FE_VSENSE_VCM, + 0x08, 0x08); + /* + * 200us sleep is needed after visense txfe disable as per + * HW requirement. + */ + usleep_range(200, 210); + snd_soc_component_update_bits(comp, WSA881X_SPKR_PROT_FE_GAIN, + 0x01, 0x00); + } + return 0; +} + +static int wsa881x_visense_adc_ctrl(struct snd_soc_component *comp, + bool enable) +{ + snd_soc_component_update_bits(comp, WSA881X_ADC_EN_MODU_V, BIT(7), + (enable << 7)); + snd_soc_component_update_bits(comp, WSA881X_ADC_EN_MODU_I, BIT(7), + (enable << 7)); + return 0; +} + +static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + snd_soc_component_update_bits(comp, WSA881X_SPKR_OCP_CTL, + WSA881X_SPKR_OCP_MASK, + WSA881X_SPKR_OCP_EN); + regmap_multi_reg_write(wsa881x->regmap, wsa881x_pre_pmu_pa_2_0, + ARRAY_SIZE(wsa881x_pre_pmu_pa_2_0)); + + snd_soc_component_update_bits(comp, WSA881X_SPKR_DRV_GAIN, + WSA881X_PA_GAIN_SEL_MASK, + WSA881X_PA_GAIN_SEL_REG); + break; + case SND_SOC_DAPM_POST_PMU: + if (wsa881x->port_prepared[WSA881X_PORT_VISENSE]) { + wsa881x_visense_txfe_ctrl(comp, true); + snd_soc_component_update_bits(comp, + WSA881X_ADC_EN_SEL_IBAIS, + 0x07, 0x01); + wsa881x_visense_adc_ctrl(comp, true); + } + + break; + case SND_SOC_DAPM_POST_PMD: + if (wsa881x->port_prepared[WSA881X_PORT_VISENSE]) { + wsa881x_visense_adc_ctrl(comp, false); + wsa881x_visense_txfe_ctrl(comp, false); + } + + snd_soc_component_update_bits(comp, WSA881X_SPKR_OCP_CTL, + WSA881X_SPKR_OCP_MASK, + WSA881X_SPKR_OCP_EN | + WSA881X_SPKR_OCP_HOLD); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("IN"), + SND_SOC_DAPM_DAC_E("RDAC", NULL, WSA881X_SPKR_DAC_CTL, 7, 0, + NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("SPKR PGA", SND_SOC_NOPM, 0, 0, NULL, 0, + wsa881x_spkr_pa_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("DCLK", WSA881X_CDC_DIG_CLK_CTL, 0, 0, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("ACLK", WSA881X_CDC_ANA_CLK_CTL, 0, 0, NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("Bandgap", WSA881X_TEMP_OP, 3, 0, + NULL, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_OUTPUT("SPKR"), +}; + +static int wsa881x_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + int ret; + + if (wsa881x->stream_prepared) { + sdw_disable_stream(wsa881x->sruntime); + sdw_deprepare_stream(wsa881x->sruntime); + wsa881x->stream_prepared = false; + } + + + ret = sdw_prepare_stream(wsa881x->sruntime); + if (ret) + return ret; + + /** + * NOTE: there is a strict hw requirement about the ordering of port + * enables and actual PA enable. PA enable should only happen after + * soundwire ports are enabled if not DC on the line is accumulated + * resulting in Click/Pop Noise + * PA enable/mute are handled as part of DAPM and digital mute. + */ + + ret = sdw_enable_stream(wsa881x->sruntime); + if (ret) { + sdw_deprepare_stream(wsa881x->sruntime); + return ret; + } + wsa881x->stream_prepared = true; + + return ret; +} + +static int wsa881x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + int i; + + wsa881x->active_ports = 0; + for (i = 0; i < WSA881X_MAX_SWR_PORTS; i++) { + if (!wsa881x->port_enable[i]) + continue; + + wsa881x->port_config[wsa881x->active_ports] = + wsa881x_pconfig[i]; + wsa881x->active_ports++; + } + + return sdw_stream_add_slave(wsa881x->slave, &wsa881x->sconfig, + wsa881x->port_config, wsa881x->active_ports, + wsa881x->sruntime); +} + +static int wsa881x_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + if (wsa881x->stream_prepared) { + sdw_disable_stream(wsa881x->sruntime); + sdw_deprepare_stream(wsa881x->sruntime); + sdw_stream_remove_slave(wsa881x->slave, wsa881x->sruntime); + wsa881x->stream_prepared = false; + } + + return 0; +} + +static int wsa881x_set_sdw_stream(struct snd_soc_dai *dai, + void *stream, int direction) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + wsa881x->sruntime = stream; + + return 0; +} + +static int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev); + + if (mute) + regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, + 0x00); + else + regmap_update_bits(wsa881x->regmap, WSA881X_SPKR_DRV_EN, 0x80, + 0x80); + + return 0; +} + +static struct snd_soc_dai_ops wsa881x_dai_ops = { + .hw_params = wsa881x_hw_params, + .prepare = wsa881x_prepare, + .hw_free = wsa881x_hw_free, + .mute_stream = wsa881x_digital_mute, + .set_sdw_stream = wsa881x_set_sdw_stream, +}; + +static struct snd_soc_dai_driver wsa881x_dais[] = { + { + .name = "SPKR", + .id = 0, + .playback = { + .stream_name = "SPKR Playback", + .rate_max = 48000, + .rate_min = 48000, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &wsa881x_dai_ops, + }, +}; + +static const struct snd_soc_component_driver wsa881x_component_drv = { + .name = "WSA881x", + .probe = wsa881x_component_probe, + .controls = wsa881x_snd_controls, + .num_controls = ARRAY_SIZE(wsa881x_snd_controls), + .dapm_widgets = wsa881x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets), + .dapm_routes = wsa881x_audio_map, + .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), +}; + +static int wsa881x_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(&slave->dev); + + if (status == SDW_SLAVE_ATTACHED && slave->dev_num > 0) + wsa881x_init(wsa881x); + + return 0; +} + +static int wsa881x_port_prep(struct sdw_slave *slave, + struct sdw_prepare_ch *prepare_ch, + enum sdw_port_prep_ops state) +{ + struct wsa881x_priv *wsa881x = dev_get_drvdata(&slave->dev); + + if (state == SDW_OPS_PORT_POST_PREP) + wsa881x->port_prepared[prepare_ch->num - 1] = true; + else + wsa881x->port_prepared[prepare_ch->num - 1] = false; + + return 0; +} + +static int wsa881x_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), + 0x01); + + return 0; +} + +static struct sdw_slave_ops wsa881x_slave_ops = { + .update_status = wsa881x_update_status, + .bus_config = wsa881x_bus_config, + .port_prep = wsa881x_port_prep, +}; + +static int wsa881x_probe(struct sdw_slave *pdev, + const struct sdw_device_id *id) +{ + struct wsa881x_priv *wsa881x; + + wsa881x = devm_kzalloc(&pdev->dev, sizeof(*wsa881x), GFP_KERNEL); + if (!wsa881x) + return -ENOMEM; + + wsa881x->sd_n = devm_gpiod_get_optional(&pdev->dev, "powerdown", + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(wsa881x->sd_n)) { + dev_err(&pdev->dev, "Shutdown Control GPIO not found\n"); + return PTR_ERR(wsa881x->sd_n); + } + + dev_set_drvdata(&pdev->dev, wsa881x); + wsa881x->slave = pdev; + wsa881x->dev = &pdev->dev; + wsa881x->sconfig.ch_count = 1; + wsa881x->sconfig.bps = 1; + wsa881x->sconfig.frame_rate = 48000; + wsa881x->sconfig.direction = SDW_DATA_DIR_RX; + wsa881x->sconfig.type = SDW_STREAM_PDM; + pdev->prop.sink_ports = GENMASK(WSA881X_MAX_SWR_PORTS, 0); + pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; + gpiod_set_value(wsa881x->sd_n, 1); + + wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config); + if (IS_ERR(wsa881x->regmap)) { + dev_err(&pdev->dev, "regmap_init failed\n"); + return PTR_ERR(wsa881x->regmap); + } + + return devm_snd_soc_register_component(&pdev->dev, + &wsa881x_component_drv, + wsa881x_dais, + ARRAY_SIZE(wsa881x_dais)); +} + +static const struct sdw_device_id wsa881x_slave_id[] = { + SDW_SLAVE_ENTRY(0x0217, 0x2010, 0), + SDW_SLAVE_ENTRY(0x0217, 0x2110, 0), + {}, +}; +MODULE_DEVICE_TABLE(sdw, wsa881x_slave_id); + +static struct sdw_driver wsa881x_codec_driver = { + .probe = wsa881x_probe, + .ops = &wsa881x_slave_ops, + .id_table = wsa881x_slave_id, + .driver = { + .name = "wsa881x-codec", + } +}; +module_sdw_driver(wsa881x_codec_driver); + +MODULE_DESCRIPTION("WSA881x codec driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 320b8b0d13b81f3697acff5b6ddb47f88a09c118 Mon Sep 17 00:00:00 2001 From: Shuming Fan Date: Fri, 27 Dec 2019 13:44:45 +0800 Subject: ASoC: rt711: add rt711 codec driver This is the initial codec driver for rt711. Signed-off-by: Shuming Fan Tested-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191227054445.27223-1-shumingf@realtek.com Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 10 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt711-sdw.c | 552 ++++++++++++++++++ sound/soc/codecs/rt711-sdw.h | 281 +++++++++ sound/soc/codecs/rt711.c | 1293 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt711.h | 227 ++++++++ 6 files changed, 2365 insertions(+) create mode 100644 sound/soc/codecs/rt711-sdw.c create mode 100644 sound/soc/codecs/rt711-sdw.h create mode 100644 sound/soc/codecs/rt711.c create mode 100644 sound/soc/codecs/rt711.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 986a31c68992..65b81888ca3d 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -165,6 +165,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT5670 if I2C select SND_SOC_RT5677 if I2C && SPI_MASTER select SND_SOC_RT5682 if I2C + select SND_SOC_RT711_SDW if SOUNDWIRE select SND_SOC_SGTL5000 if I2C select SND_SOC_SI476X if MFD_SI476X_CORE select SND_SOC_SIMPLE_AMPLIFIER @@ -1059,6 +1060,15 @@ config SND_SOC_RT5677_SPI config SND_SOC_RT5682 tristate +config SND_SOC_RT711 + tristate + +config SND_SOC_RT711_SDW + tristate "Realtek RT711 Codec - SDW" + depends on SOUNDWIRE + select SND_SOC_RT711 + select REGMAP_SOUNDWIRE + #Freescale sgtl5000 codec config SND_SOC_SGTL5000 tristate "Freescale SGTL5000 CODEC" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 495f7e2f63eb..f4dfe033d120 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -173,6 +173,7 @@ snd-soc-rt5670-objs := rt5670.o snd-soc-rt5677-objs := rt5677.o snd-soc-rt5677-spi-objs := rt5677-spi.o snd-soc-rt5682-objs := rt5682.o +snd-soc-rt711-objs := rt711.o rt711-sdw.o snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-alc5623-objs := alc5623.o snd-soc-alc5632-objs := alc5632.o @@ -465,6 +466,7 @@ obj-$(CONFIG_SND_SOC_RT5670) += snd-soc-rt5670.o obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o obj-$(CONFIG_SND_SOC_RT5677_SPI) += snd-soc-rt5677-spi.o obj-$(CONFIG_SND_SOC_RT5682) += snd-soc-rt5682.o +obj-$(CONFIG_SND_SOC_RT711) += snd-soc-rt711.o obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o diff --git a/sound/soc/codecs/rt711-sdw.c b/sound/soc/codecs/rt711-sdw.c new file mode 100644 index 000000000000..e28dc84ede5b --- /dev/null +++ b/sound/soc/codecs/rt711-sdw.c @@ -0,0 +1,552 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt711-sdw.c -- rt711 ALSA SoC audio driver +// +// Copyright(c) 2019 Realtek Semiconductor Corp. +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rt711.h" +#include "rt711-sdw.h" + +static bool rt711_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2012 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2201 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2239: + case 0x2f01 ... 0x2f0f: + case 0x3000 ... 0x3fff: + case 0x7000 ... 0x7fff: + case 0x8300 ... 0x83ff: + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0x752009: + case 0x752011: + case 0x75201a: + case 0x752045: + case 0x752046: + case 0x752048: + case 0x75204a: + case 0x75206b: + case 0x75206f: + case 0x752080: + case 0x752081: + case 0x752091: + case 0x755800: + return true; + default: + return false; + } +} + +static bool rt711_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2021: + case 0x2023: + case 0x2230: + case 0x2012 ... 0x2015: /* HD-A read */ + case 0x202d ... 0x202f: /* BRA */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded HD-A */ + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0xff01: + case 0x75201a: + case 0x752046: + case 0x752080: + case 0x752081: + case 0x755800: + return true; + default: + return false; + } +} + +static int rt711_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt711->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT711_PRIV_DATA_R_H | nid; + ret = regmap_write(rt711->sdw_regmap, + reg3, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt711->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt711->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt711->sdw_regmap, + reg2, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt711->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt711->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt711->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt711->sdw_regmap, + RT711_READ_HDA_3, &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + RT711_READ_HDA_2, &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + RT711_READ_HDA_1, &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt711->sdw_regmap, + RT711_READ_HDA_0, &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x\n", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x\n", + __func__, reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x\n", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt711_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt711->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT711_PRIV_DATA_W_H | nid; + ret = regmap_write(rt711->sdw_regmap, + reg3, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == RT711_FUNC_RESET) { + ret = regmap_write(rt711->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt711->sdw_regmap, + reg, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt711->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt711->sdw_regmap, + reg2, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt711->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x\n", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x\n", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x\n", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt711_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt711_readable_register, + .volatile_reg = rt711_volatile_register, + .max_register = 0x755800, + .reg_defaults = rt711_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(rt711_reg_defaults), + .cache_type = REGCACHE_RBTREE, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt711_sdw_read, + .reg_write = rt711_sdw_write, +}; + +static const struct regmap_config rt711_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt711_readable_register, + .max_register = 0xff01, + .cache_type = REGCACHE_NONE, + .use_single_read = true, + .use_single_write = true, +}; + +static int rt711_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + /* Update the status */ + rt711->status = status; + + if (status == SDW_SLAVE_UNATTACHED) + rt711->hw_init = false; + + /* + * Perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt711->hw_init || rt711->status != SDW_SLAVE_ATTACHED) + return 0; + + /* perform I/O transfers required for Slave initialization */ + return rt711_io_init(&slave->dev, slave); +} + +static int rt711_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x14; /* BITMAP: 00010100 */ + prop->sink_ports = 0x8; /* BITMAP: 00001000 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + GFP_KERNEL); + if (!prop->src_dpn_prop) + return -ENOMEM; + + i = 0; + dpn = prop->src_dpn_prop; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = SDW_DPN_FULL; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + GFP_KERNEL); + if (!prop->sink_dpn_prop) + return -ENOMEM; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = SDW_DPN_FULL; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* Allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + GFP_KERNEL); + if (!slave->port_ready) + return -ENOMEM; + + /* Initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt711_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt711->params, params, sizeof(*params)); + + ret = rt711_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "Invalid clk config"); + + return ret; +} + +static int rt711_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + if (status->control_port & 0x4) { + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_detect_work, msecs_to_jiffies(250)); + } + + return 0; +} + +static struct sdw_slave_ops rt711_slave_ops = { + .read_prop = rt711_read_prop, + .interrupt_callback = rt711_interrupt_callback, + .update_status = rt711_update_status, + .bus_config = rt711_bus_config, +}; + +static int rt711_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* Assign ops */ + slave->ops = &rt711_slave_ops; + + /* Regmap Initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt711_sdw_regmap); + if (!sdw_regmap) + return -EINVAL; + + regmap = devm_regmap_init(&slave->dev, NULL, + &slave->dev, &rt711_regmap); + if (!regmap) + return -EINVAL; + + rt711_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static int rt711_sdw_remove(struct sdw_slave *slave) +{ + struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev); + + if (rt711 && rt711->hw_init) { + cancel_delayed_work(&rt711->jack_detect_work); + cancel_delayed_work(&rt711->jack_btn_check_work); + cancel_work_sync(&rt711->calibration_work); + } + + return 0; +} + +static const struct sdw_device_id rt711_id[] = { + SDW_SLAVE_ENTRY(0x025d, 0x711, 0), + {}, +}; +MODULE_DEVICE_TABLE(sdw, rt711_id); + +static int rt711_dev_suspend(struct device *dev) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + + if (!rt711->hw_init) + return 0; + + regcache_cache_only(rt711->regmap, true); + + return 0; +} + +#define RT711_PROBE_TIMEOUT 2000 + +static int rt711_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt711->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(RT711_PROBE_TIMEOUT)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete, timed out\n"); + return -ETIMEDOUT; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt711->regmap, false); + regcache_sync_region(rt711->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt711->regmap, 0x752009, 0x752091); + + return 0; +} + +static const struct dev_pm_ops rt711_pm = { + SET_SYSTEM_SLEEP_PM_OPS(rt711_dev_suspend, rt711_dev_resume) + SET_RUNTIME_PM_OPS(rt711_dev_suspend, rt711_dev_resume, NULL) +}; + +static struct sdw_driver rt711_sdw_driver = { + .driver = { + .name = "rt711", + .owner = THIS_MODULE, + .pm = &rt711_pm, + }, + .probe = rt711_sdw_probe, + .remove = rt711_sdw_remove, + .ops = &rt711_slave_ops, + .id_table = rt711_id, +}; +module_sdw_driver(rt711_sdw_driver); + +MODULE_DESCRIPTION("ASoC RT711 SDW driver"); +MODULE_AUTHOR("Shuming Fan "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/rt711-sdw.h b/sound/soc/codecs/rt711-sdw.h new file mode 100644 index 000000000000..43b2b984b29c --- /dev/null +++ b/sound/soc/codecs/rt711-sdw.h @@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt711-sdw.h -- RT711 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT711_SDW_H__ +#define __RT711_SDW_H__ + +static const struct reg_default rt711_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x01 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5d }, + { 0x0053, 0x07 }, + { 0x0054, 0x11 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x0080, 0xc0 }, + { 0x0088, 0x00 }, + { 0x00e0, 0x00 }, + { 0x00e1, 0x00 }, + { 0x00e2, 0x00 }, + { 0x00e3, 0x00 }, + { 0x00e5, 0x00 }, + { 0x00ee, 0x00 }, + { 0x00ef, 0x00 }, + { 0x00f0, 0x00 }, + { 0x00f1, 0x00 }, + { 0x00f2, 0x00 }, + { 0x00f3, 0x00 }, + { 0x00f4, 0x00 }, + { 0x00f5, 0x00 }, + { 0x00fe, 0x00 }, + { 0x00ff, 0x00 }, + { 0x0100, 0x00 }, + { 0x0101, 0x00 }, + { 0x0102, 0x00 }, + { 0x0103, 0x00 }, + { 0x0104, 0x00 }, + { 0x0105, 0x00 }, + { 0x0120, 0x00 }, + { 0x0122, 0x00 }, + { 0x0123, 0x00 }, + { 0x0124, 0x00 }, + { 0x0125, 0x00 }, + { 0x0126, 0x00 }, + { 0x0127, 0x00 }, + { 0x0130, 0x00 }, + { 0x0132, 0x00 }, + { 0x0133, 0x00 }, + { 0x0134, 0x00 }, + { 0x0135, 0x00 }, + { 0x0136, 0x00 }, + { 0x0137, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x00 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x0300, 0x00 }, + { 0x0301, 0x00 }, + { 0x0302, 0x20 }, + { 0x0303, 0x00 }, + { 0x0304, 0x00 }, + { 0x0305, 0x03 }, + { 0x0320, 0x00 }, + { 0x0322, 0x00 }, + { 0x0323, 0x00 }, + { 0x0324, 0x00 }, + { 0x0325, 0x00 }, + { 0x0326, 0x00 }, + { 0x0327, 0x00 }, + { 0x0330, 0x00 }, + { 0x0332, 0x00 }, + { 0x0333, 0x00 }, + { 0x0334, 0x00 }, + { 0x0335, 0x00 }, + { 0x0336, 0x00 }, + { 0x0337, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x00 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x03 }, + { 0x0420, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x20 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0x03 }, + { 0x0f06, 0x00 }, + { 0x0f07, 0x00 }, + { 0x0f08, 0x00 }, + { 0x0f09, 0x00 }, + { 0x0f10, 0x00 }, + { 0x0f11, 0x00 }, + { 0x0f12, 0x00 }, + { 0x0f13, 0x00 }, + { 0x0f14, 0x00 }, + { 0x0f15, 0x00 }, + { 0x0f16, 0x00 }, + { 0x0f17, 0x00 }, + { 0x0f18, 0x00 }, + { 0x0f19, 0x00 }, + { 0x0f1a, 0x00 }, + { 0x0f1b, 0x00 }, + { 0x0f1c, 0x00 }, + { 0x0f1d, 0x00 }, + { 0x0f1e, 0x00 }, + { 0x0f1f, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2012, 0x00 }, + { 0x2013, 0x00 }, + { 0x2014, 0x00 }, + { 0x2015, 0x00 }, + { 0x2016, 0x00 }, + { 0x201a, 0x00 }, + { 0x201b, 0x00 }, + { 0x201c, 0x0c }, + { 0x201d, 0x00 }, + { 0x201e, 0x00 }, + { 0x201f, 0x00 }, + { 0x2020, 0x00 }, + { 0x2021, 0x00 }, + { 0x2022, 0x00 }, + { 0x2023, 0x00 }, + { 0x2024, 0x00 }, + { 0x2025, 0x01 }, + { 0x2026, 0x00 }, + { 0x2027, 0x00 }, + { 0x2029, 0x00 }, + { 0x202a, 0x00 }, + { 0x202d, 0x00 }, + { 0x202e, 0x00 }, + { 0x202f, 0x00 }, + { 0x2030, 0x00 }, + { 0x2031, 0x00 }, + { 0x2032, 0x00 }, + { 0x2033, 0x00 }, + { 0x2034, 0x00 }, + { 0x2201, 0xc7 }, + { 0x2202, 0x0c }, + { 0x2203, 0x22 }, + { 0x2204, 0x04 }, + { 0x2206, 0x00 }, + { 0x2207, 0x00 }, + { 0x2208, 0x00 }, + { 0x2209, 0x00 }, + { 0x220a, 0x00 }, + { 0x220b, 0x00 }, + { 0x220c, 0x00 }, + { 0x220d, 0x04 }, + { 0x220e, 0x00 }, + { 0x220f, 0x00 }, + { 0x2211, 0x01 }, + { 0x2212, 0x00 }, + { 0x2220, 0x00 }, + { 0x2221, 0x00 }, + { 0x2222, 0x00 }, + { 0x2223, 0x00 }, + { 0x2230, 0x00 }, + { 0x2231, 0x2f }, + { 0x2232, 0x80 }, + { 0x2233, 0x00 }, + { 0x2234, 0x00 }, + { 0x2235, 0x00 }, + { 0x2236, 0x00 }, + { 0x2237, 0x00 }, + { 0x2238, 0x00 }, + { 0x2239, 0x00 }, + { 0x2f01, 0x00 }, + { 0x2f02, 0x09 }, + { 0x2f03, 0x00 }, + { 0x2f04, 0x00 }, + { 0x2f05, 0x0b }, + { 0x2f06, 0x01 }, + { 0x2f07, 0xcf }, + { 0x2f08, 0x00 }, + { 0x2f09, 0x00 }, + { 0x2f0a, 0x00 }, + { 0x2f0b, 0x00 }, + { 0x2f0c, 0x00 }, + { 0x2f0d, 0x00 }, + { 0x2f0e, 0x00 }, + { 0x2f0f, 0x00 }, + { 0x3122, 0x00 }, + { 0x3123, 0x00 }, + { 0x7303, 0x57 }, + { 0x8383, 0x57 }, + { 0x7308, 0x97 }, + { 0x8388, 0x97 }, + { 0x7309, 0x97 }, + { 0x8389, 0x97 }, + { 0x7312, 0x00 }, + { 0x8392, 0x00 }, + { 0x7313, 0x00 }, + { 0x8393, 0x00 }, + { 0x7319, 0x00 }, + { 0x8399, 0x00 }, + { 0x752009, 0x1029 }, + { 0x752011, 0x007a }, + { 0x75201a, 0x8003 }, + { 0x752045, 0x5289 }, + { 0x752048, 0xd049 }, + { 0x75204a, 0xa83b }, + { 0x75206b, 0x5064 }, + { 0x75206f, 0x058b }, + { 0x752091, 0x0000 }, +}; + +#endif /* __RT711_SDW_H__ */ diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c new file mode 100644 index 000000000000..3bebba7a63be --- /dev/null +++ b/sound/soc/codecs/rt711.c @@ -0,0 +1,1293 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt711.c -- rt711 ALSA SoC audio driver +// +// Copyright(c) 2019 Realtek Semiconductor Corp. +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rt711.h" + +static int rt711_index_write(struct regmap *regmap, + unsigned int nid, unsigned int reg, unsigned int value) +{ + int ret; + unsigned int addr = ((RT711_PRIV_INDEX_W_H | nid) << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) + pr_err("Failed to set private value: %06x <= %04x ret=%d\n", + addr, value, ret); + + return ret; +} + +static int rt711_index_read(struct regmap *regmap, + unsigned int nid, unsigned int reg, unsigned int *value) +{ + int ret; + unsigned int addr = ((RT711_PRIV_INDEX_W_H | nid) << 8) | reg; + + *value = 0; + ret = regmap_read(regmap, addr, value); + if (ret < 0) + pr_err("Failed to get private value: %06x => %04x ret=%d\n", + addr, *value, ret); + + return ret; +} + +static int rt711_index_update_bits(struct regmap *regmap, unsigned int nid, + unsigned int reg, unsigned int mask, unsigned int val) +{ + unsigned int tmp, orig; + int ret; + + ret = rt711_index_read(regmap, nid, reg, &orig); + if (ret < 0) + return ret; + + tmp = orig & ~mask; + tmp |= val & mask; + + return rt711_index_write(regmap, nid, reg, tmp); +} + +static void rt711_reset(struct regmap *regmap) +{ + regmap_write(regmap, RT711_FUNC_RESET, 0); + rt711_index_update_bits(regmap, RT711_VENDOR_REG, + RT711_PARA_VERB_CTL, RT711_HIDDEN_REG_SW_RESET, + RT711_HIDDEN_REG_SW_RESET); +} + +static int rt711_calibration(struct rt711_priv *rt711) +{ + unsigned int val, loop = 0; + struct device *dev; + struct regmap *regmap = rt711->regmap; + int ret = 0; + + mutex_lock(&rt711->calibrate_mutex); + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + dev = regmap_get_device(regmap); + + /* Calibration manual mode */ + rt711_index_update_bits(regmap, RT711_VENDOR_REG, RT711_FSM_CTL, + 0xf, 0x0); + + /* trigger */ + rt711_index_update_bits(regmap, RT711_VENDOR_CALI, + RT711_DAC_DC_CALI_CTL1, RT711_DAC_DC_CALI_TRIGGER, + RT711_DAC_DC_CALI_TRIGGER); + + /* wait for calibration process */ + rt711_index_read(regmap, RT711_VENDOR_CALI, + RT711_DAC_DC_CALI_CTL1, &val); + + while (val & RT711_DAC_DC_CALI_TRIGGER) { + if (loop >= 500) { + pr_err("%s, calibration time-out!\n", + __func__); + ret = -ETIMEDOUT; + break; + } + loop++; + + usleep_range(10000, 11000); + rt711_index_read(regmap, RT711_VENDOR_CALI, + RT711_DAC_DC_CALI_CTL1, &val); + } + + /* depop mode */ + rt711_index_update_bits(regmap, RT711_VENDOR_REG, + RT711_FSM_CTL, 0xf, RT711_DEPOP_CTL); + + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + mutex_unlock(&rt711->calibrate_mutex); + + dev_dbg(dev, "%s calibration complete, ret=%d\n", __func__, ret); + return ret; +} + +static unsigned int rt711_button_detect(struct rt711_priv *rt711) +{ + unsigned int btn_type = 0, val80, val81; + int ret; + + ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, + RT711_IRQ_FLAG_TABLE1, &val80); + if (ret < 0) + goto read_error; + ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, + RT711_IRQ_FLAG_TABLE2, &val81); + if (ret < 0) + goto read_error; + + val80 &= 0x0381; + val81 &= 0xff00; + + switch (val80) { + case 0x0200: + case 0x0100: + case 0x0080: + btn_type |= SND_JACK_BTN_0; + break; + case 0x0001: + btn_type |= SND_JACK_BTN_3; + break; + } + switch (val81) { + case 0x8000: + case 0x4000: + case 0x2000: + btn_type |= SND_JACK_BTN_1; + break; + case 0x1000: + case 0x0800: + case 0x0400: + btn_type |= SND_JACK_BTN_2; + break; + case 0x0200: + case 0x0100: + btn_type |= SND_JACK_BTN_3; + break; + } +read_error: + return btn_type; +} + +static int rt711_headset_detect(struct rt711_priv *rt711) +{ + unsigned int buf, loop = 0; + int ret; + unsigned int jack_status = 0, reg; + + ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, + RT711_COMBO_JACK_AUTO_CTL2, &buf); + if (ret < 0) + goto io_error; + + while (loop < 500 && + (buf & RT711_COMBOJACK_AUTO_DET_STATUS) == 0) { + loop++; + + usleep_range(9000, 10000); + ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, + RT711_COMBO_JACK_AUTO_CTL2, &buf); + if (ret < 0) + goto io_error; + + reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + if ((jack_status & (1 << 31)) == 0) + goto remove_error; + } + + if (loop >= 500) + goto to_error; + + if (buf & RT711_COMBOJACK_AUTO_DET_TRS) + rt711->jack_type = SND_JACK_HEADPHONE; + else if ((buf & RT711_COMBOJACK_AUTO_DET_CTIA) || + (buf & RT711_COMBOJACK_AUTO_DET_OMTP)) + rt711->jack_type = SND_JACK_HEADSET; + + return 0; + +to_error: + ret = -ETIMEDOUT; + pr_err_ratelimited("Time-out error in %s\n", __func__); + return ret; +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); + return ret; +remove_error: + pr_err_ratelimited("Jack removal in %s\n", __func__); + return -ENODEV; +} + +static void rt711_jack_detect_handler(struct work_struct *work) +{ + struct rt711_priv *rt711 = + container_of(work, struct rt711_priv, jack_detect_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + if (!rt711->hs_jack) + return; + + if (!rt711->component->card->instantiated) + return; + + reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + /* jack in */ + if (rt711->jack_type == 0) { + ret = rt711_headset_detect(rt711); + if (ret < 0) + return; + if (rt711->jack_type == SND_JACK_HEADSET) + btn_type = rt711_button_detect(rt711); + } else if (rt711->jack_type == SND_JACK_HEADSET) { + /* jack is already in, report button event */ + btn_type = rt711_button_detect(rt711); + } + } else { + /* jack out */ + rt711->jack_type = 0; + } + + dev_dbg(&rt711->slave->dev, + "in %s, jack_type=0x%x\n", __func__, rt711->jack_type); + dev_dbg(&rt711->slave->dev, + "in %s, btn_type=0x%x\n", __func__, btn_type); + + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); +} + +static void rt711_btn_check_handler(struct work_struct *work) +{ + struct rt711_priv *rt711 = container_of(work, struct rt711_priv, + jack_btn_check_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + reg = RT711_VERB_GET_PIN_SENSE | RT711_HP_OUT; + ret = regmap_read(rt711->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + if (rt711->jack_type == SND_JACK_HEADSET) { + /* jack is already in, report button event */ + btn_type = rt711_button_detect(rt711); + } + } else { + rt711->jack_type = 0; + } + + /* cbj comparator */ + ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, + RT711_COMBO_JACK_AUTO_CTL2, ®); + if (ret < 0) + goto io_error; + + if ((reg & 0xf0) == 0xf0) + btn_type = 0; + + dev_dbg(&rt711->slave->dev, + "%s, btn_type=0x%x\n", __func__, btn_type); + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); +} + +static void rt711_jack_init(struct rt711_priv *rt711) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(rt711->component); + + mutex_lock(&rt711->calibrate_mutex); + /* power on */ + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + if (rt711->hs_jack) { + /* unsolicited response & IRQ control */ + regmap_write(rt711->regmap, + RT711_SET_MIC2_UNSOLICITED_ENABLE, 0x82); + regmap_write(rt711->regmap, + RT711_SET_HP_UNSOLICITED_ENABLE, 0x81); + regmap_write(rt711->regmap, + RT711_SET_INLINE_UNSOLICITED_ENABLE, 0x83); + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + 0x10, 0x2420); + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + 0x19, 0x2e11); + + switch (rt711->jd_src) { + case RT711_JD1: + /* default settings was already for JD1 */ + break; + case RT711_JD2: + rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, + RT711_JD_CTL2, RT711_JD2_2PORT_200K_DECODE_HP | + RT711_HP_JD_SEL_JD2, + RT711_JD2_2PORT_200K_DECODE_HP | + RT711_HP_JD_SEL_JD2); + rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, + RT711_CC_DET1, + RT711_HP_JD_FINAL_RESULT_CTL_JD12, + RT711_HP_JD_FINAL_RESULT_CTL_JD12); + break; + default: + dev_warn(rt711->component->dev, "Wrong JD source\n"); + break; + } + + dev_dbg(&rt711->slave->dev, "in %s enable\n", __func__); + + mod_delayed_work(system_power_efficient_wq, + &rt711->jack_detect_work, msecs_to_jiffies(250)); + } else { + regmap_write(rt711->regmap, + RT711_SET_MIC2_UNSOLICITED_ENABLE, 0x00); + regmap_write(rt711->regmap, + RT711_SET_HP_UNSOLICITED_ENABLE, 0x00); + regmap_write(rt711->regmap, + RT711_SET_INLINE_UNSOLICITED_ENABLE, 0x00); + + dev_dbg(&rt711->slave->dev, "in %s disable\n", __func__); + } + + /* power off */ + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + mutex_unlock(&rt711->calibrate_mutex); +} + +static int rt711_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hs_jack, void *data) +{ + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + rt711->hs_jack = hs_jack; + + if (!rt711->hw_init) { + dev_dbg(&rt711->slave->dev, + "%s hw_init not ready yet\n", __func__); + return 0; + } + + rt711_jack_init(rt711); + + return 0; +} + +static void rt711_get_gain(struct rt711_priv *rt711, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + /* R Channel */ + *r_val = (val_h << 8); + regmap_read(rt711->regmap, addr_l, r_val); + + /* L Channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + regmap_read(rt711->regmap, addr_h, l_val); +} + +/* For Verb-Set Amplifier Gain (Verb ID = 3h) */ +static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* Can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT711_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* L Channel */ + if (mc->invert) { + /* for mute/unmute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) + << RT711_MUTE_SFT; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & (1 << RT711_MUTE_SFT); + val_ll |= read_ll; + } + + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + /* R Channel */ + if (mc->invert) { + /* for mute/unmute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) + << RT711_MUTE_SFT; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & (1 << RT711_MUTE_SFT); + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + + if (val_ll == val_lr) { + /* Set both L/R channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt711->regmap, + addr_h, (val_h << 8 | val_ll)); + regmap_write(rt711->regmap, + addr_l, (val_h << 8 | val_ll)); + } else { + /* Lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt711->regmap, + addr_h, (val_h << 8 | val_ll)); + + /* Rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt711->regmap, + addr_l, (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == RT711_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + return 0; +} + +static int rt711_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + /* switch to get command */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT711_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* mute/unmute for switch controls */ + read_ll = !((read_ll & 0x80) >> RT711_MUTE_SFT); + read_rl = !((read_rl & 0x80) >> RT711_MUTE_SFT); + } else { + /* for gain volume controls */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); +static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); +static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); + +static const struct snd_kcontrol_new rt711_snd_controls[] = { + SOC_DOUBLE_R_EXT_TLV("DAC Surr Playback Volume", + RT711_SET_GAIN_DAC2_H, RT711_SET_GAIN_DAC2_L, + RT711_DIR_OUT_SFT, 0x57, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, out_vol_tlv), + SOC_DOUBLE_R_EXT("ADC 08 Capture Switch", + RT711_SET_GAIN_ADC2_H, RT711_SET_GAIN_ADC2_L, + RT711_DIR_IN_SFT, 1, 1, + rt711_set_amp_gain_get, rt711_set_amp_gain_put), + SOC_DOUBLE_R_EXT("ADC 09 Capture Switch", + RT711_SET_GAIN_ADC1_H, RT711_SET_GAIN_ADC1_L, + RT711_DIR_IN_SFT, 1, 1, + rt711_set_amp_gain_get, rt711_set_amp_gain_put), + SOC_DOUBLE_R_EXT_TLV("ADC 08 Capture Volume", + RT711_SET_GAIN_ADC2_H, RT711_SET_GAIN_ADC2_L, + RT711_DIR_IN_SFT, 0x3f, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("ADC 09 Capture Volume", + RT711_SET_GAIN_ADC1_H, RT711_SET_GAIN_ADC1_L, + RT711_DIR_IN_SFT, 0x3f, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("AMIC Volume", + RT711_SET_GAIN_AMIC_H, RT711_SET_GAIN_AMIC_L, + RT711_DIR_IN_SFT, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("DMIC1 Volume", + RT711_SET_GAIN_DMIC1_H, RT711_SET_GAIN_DMIC1_L, + RT711_DIR_IN_SFT, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("DMIC2 Volume", + RT711_SET_GAIN_DMIC2_H, RT711_SET_GAIN_DMIC2_L, + RT711_DIR_IN_SFT, 3, 0, + rt711_set_amp_gain_get, rt711_set_amp_gain_put, mic_vol_tlv), +}; + +static int rt711_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int reg, val = 0, nid; + int ret; + + if (strstr(ucontrol->id.name, "ADC 22 Mux")) + nid = RT711_MIXER_IN1; + else if (strstr(ucontrol->id.name, "ADC 23 Mux")) + nid = RT711_MIXER_IN2; + else + return -EINVAL; + + /* vid = 0xf01 */ + reg = RT711_VERB_SET_CONNECT_SEL | nid; + ret = regmap_read(rt711->regmap, reg, &val); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d\n", + __func__, ret); + return ret; + } + + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt711_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg, nid; + int ret; + + if (item[0] >= e->items) + return -EINVAL; + + if (strstr(ucontrol->id.name, "ADC 22 Mux")) + nid = RT711_MIXER_IN1; + else if (strstr(ucontrol->id.name, "ADC 23 Mux")) + nid = RT711_MIXER_IN2; + else + return -EINVAL; + + /* Verb ID = 0x701h */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = RT711_VERB_SET_CONNECT_SEL | nid; + ret = regmap_read(rt711->regmap, reg, &val2); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d\n", + __func__, ret); + return ret; + } + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = RT711_VERB_SET_CONNECT_SEL | nid; + regmap_write(rt711->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, NULL); + + return change; +} + +static const char * const adc_mux_text[] = { + "MIC2", + "LINE1", + "LINE2", + "DMIC", +}; + +static SOC_ENUM_SINGLE_DECL( + rt711_adc22_enum, SND_SOC_NOPM, 0, adc_mux_text); + +static SOC_ENUM_SINGLE_DECL( + rt711_adc23_enum, SND_SOC_NOPM, 0, adc_mux_text); + +static const struct snd_kcontrol_new rt711_adc22_mux = + SOC_DAPM_ENUM_EXT("ADC 22 Mux", rt711_adc22_enum, + rt711_mux_get, rt711_mux_put); + +static const struct snd_kcontrol_new rt711_adc23_mux = + SOC_DAPM_ENUM_EXT("ADC 23 Mux", rt711_adc23_enum, + rt711_mux_get, rt711_mux_put); + +static int rt711_dac_surround_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << RT711_DIR_OUT_SFT) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt711->regmap, + RT711_SET_STREAMID_DAC2, 0x10); + + val_l = 0x00; + regmap_write(rt711->regmap, + RT711_SET_GAIN_HP_H, (val_h << 8 | val_l)); + break; + case SND_SOC_DAPM_PRE_PMD: + val_l = (1 << RT711_MUTE_SFT); + regmap_write(rt711->regmap, + RT711_SET_GAIN_HP_H, (val_h << 8 | val_l)); + usleep_range(50000, 55000); + + regmap_write(rt711->regmap, + RT711_SET_STREAMID_DAC2, 0x00); + break; + } + return 0; +} + +static int rt711_adc_09_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt711->regmap, + RT711_SET_STREAMID_ADC1, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt711->regmap, + RT711_SET_STREAMID_ADC1, 0x00); + break; + } + return 0; +} + +static int rt711_adc_08_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt711->regmap, + RT711_SET_STREAMID_ADC2, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt711->regmap, + RT711_SET_STREAMID_ADC2, 0x00); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt711_dapm_widgets[] = { + SND_SOC_DAPM_OUTPUT("HP"), + SND_SOC_DAPM_INPUT("MIC2"), + SND_SOC_DAPM_INPUT("DMIC1"), + SND_SOC_DAPM_INPUT("DMIC2"), + SND_SOC_DAPM_INPUT("LINE1"), + SND_SOC_DAPM_INPUT("LINE2"), + + SND_SOC_DAPM_DAC_E("DAC Surround", NULL, SND_SOC_NOPM, 0, 0, + rt711_dac_surround_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_ADC_E("ADC 09", NULL, SND_SOC_NOPM, 0, 0, + rt711_adc_09_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_ADC_E("ADC 08", NULL, SND_SOC_NOPM, 0, 0, + rt711_adc_08_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_MUX("ADC 22 Mux", SND_SOC_NOPM, 0, 0, + &rt711_adc22_mux), + SND_SOC_DAPM_MUX("ADC 23 Mux", SND_SOC_NOPM, 0, 0, + &rt711_adc23_mux), + + SND_SOC_DAPM_AIF_IN("DP3RX", "DP3 Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("DP2TX", "DP2 Capture", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("DP4TX", "DP4 Capture", 0, SND_SOC_NOPM, 0, 0), +}; + +static const struct snd_soc_dapm_route rt711_audio_map[] = { + {"DAC Surround", NULL, "DP3RX"}, + {"DP2TX", NULL, "ADC 09"}, + {"DP4TX", NULL, "ADC 08"}, + + {"ADC 09", NULL, "ADC 22 Mux"}, + {"ADC 08", NULL, "ADC 23 Mux"}, + {"ADC 22 Mux", "DMIC", "DMIC1"}, + {"ADC 22 Mux", "LINE1", "LINE1"}, + {"ADC 22 Mux", "LINE2", "LINE2"}, + {"ADC 22 Mux", "MIC2", "MIC2"}, + {"ADC 23 Mux", "DMIC", "DMIC2"}, + {"ADC 23 Mux", "LINE1", "LINE1"}, + {"ADC 23 Mux", "LINE2", "LINE2"}, + {"ADC 23 Mux", "MIC2", "MIC2"}, + + {"HP", NULL, "DAC Surround"}, +}; + +static int rt711_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + switch (level) { + case SND_SOC_BIAS_PREPARE: + if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, + AC_PWRST_D0); + } + break; + + case SND_SOC_BIAS_STANDBY: + regmap_write(rt711->regmap, + RT711_SET_AUDIO_POWER_STATE, + AC_PWRST_D3); + break; + + default: + break; + } + + return 0; +} + +static int rt711_parse_dt(struct rt711_priv *rt711, struct device *dev) +{ + device_property_read_u32(dev, "realtek,jd-src", + &rt711->jd_src); + + return 0; +} + +static int rt711_probe(struct snd_soc_component *component) +{ + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + + rt711_parse_dt(rt711, &rt711->slave->dev); + rt711->component = component; + + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt711 = { + .probe = rt711_probe, + .set_bias_level = rt711_set_bias_level, + .controls = rt711_snd_controls, + .num_controls = ARRAY_SIZE(rt711_snd_controls), + .dapm_widgets = rt711_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt711_dapm_widgets), + .dapm_routes = rt711_audio_map, + .num_dapm_routes = ARRAY_SIZE(rt711_audio_map), + .set_jack = rt711_set_jack_detect, +}; + +static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* Use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt711_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(stream); +} + +static int rt711_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -EINVAL; + + if (!rt711->slave) + return -EINVAL; + + /* SoundWire specific configuration */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + direction = SDW_DATA_DIR_RX; + port = 3; + } else { + direction = SDW_DATA_DIR_TX; + if (dai->id == RT711_AIF1) + port = 4; + else if (dai->id == RT711_AIF2) + port = 2; + else + return -EINVAL; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt711->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "Unable to configure port\n"); + return retval; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 Number of Channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "Unsupported channels %d\n", + params_channels(params)); + return -EINVAL; + } + + switch (params_width(params)) { + /* bit 6:4 Bits per Sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -EINVAL; + } + + /* 48Khz */ + regmap_write(rt711->regmap, RT711_DAC_FORMAT_H, val); + regmap_write(rt711->regmap, RT711_ADC1_FORMAT_H, val); + regmap_write(rt711->regmap, RT711_ADC2_FORMAT_H, val); + + return retval; +} + +static int rt711_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt711->slave) + return -EINVAL; + + sdw_stream_remove_slave(rt711->slave, stream->sdw_stream); + return 0; +} + +#define RT711_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +#define RT711_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) + +static struct snd_soc_dai_ops rt711_ops = { + .hw_params = rt711_pcm_hw_params, + .hw_free = rt711_pcm_hw_free, + .set_sdw_stream = rt711_set_sdw_stream, + .shutdown = rt711_shutdown, +}; + +static struct snd_soc_dai_driver rt711_dai[] = { + { + .name = "rt711-aif1", + .id = RT711_AIF1, + .playback = { + .stream_name = "DP3 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = RT711_STEREO_RATES, + .formats = RT711_FORMATS, + }, + .capture = { + .stream_name = "DP4 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT711_STEREO_RATES, + .formats = RT711_FORMATS, + }, + .ops = &rt711_ops, + }, + { + .name = "rt711-aif2", + .id = RT711_AIF2, + .capture = { + .stream_name = "DP2 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT711_STEREO_RATES, + .formats = RT711_FORMATS, + }, + .ops = &rt711_ops, + } +}; + +/* Bus clock frequency */ +#define RT711_CLK_FREQ_9600000HZ 9600000 +#define RT711_CLK_FREQ_12000000HZ 12000000 +#define RT711_CLK_FREQ_6000000HZ 6000000 +#define RT711_CLK_FREQ_4800000HZ 4800000 +#define RT711_CLK_FREQ_2400000HZ 2400000 +#define RT711_CLK_FREQ_12288000HZ 12288000 + +int rt711_clock_config(struct device *dev) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt711->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case RT711_CLK_FREQ_12000000HZ: + value = 0x0; + break; + case RT711_CLK_FREQ_6000000HZ: + value = 0x1; + break; + case RT711_CLK_FREQ_9600000HZ: + value = 0x2; + break; + case RT711_CLK_FREQ_4800000HZ: + value = 0x3; + break; + case RT711_CLK_FREQ_2400000HZ: + value = 0x4; + break; + case RT711_CLK_FREQ_12288000HZ: + value = 0x5; + break; + default: + return -EINVAL; + } + + regmap_write(rt711->regmap, 0xe0, value); + regmap_write(rt711->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d\n", __func__, clk_freq); + + return 0; +} + +static void rt711_calibration_work(struct work_struct *work) +{ + struct rt711_priv *rt711 = + container_of(work, struct rt711_priv, calibration_work); + + rt711_calibration(rt711); +} + +int rt711_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) +{ + struct rt711_priv *rt711; + int ret; + + rt711 = devm_kzalloc(dev, sizeof(*rt711), GFP_KERNEL); + if (!rt711) + return -ENOMEM; + + dev_set_drvdata(dev, rt711); + rt711->slave = slave; + rt711->sdw_regmap = sdw_regmap; + rt711->regmap = regmap; + + /* + * Mark hw_init to false + * HW init will be performed when device reports present + */ + rt711->hw_init = false; + rt711->first_hw_init = false; + + /* JD source uses JD2 in default */ + rt711->jd_src = RT711_JD2; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt711, + rt711_dai, + ARRAY_SIZE(rt711_dai)); + + dev_dbg(&slave->dev, "%s\n", __func__); + + return ret; +} + +int rt711_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt711_priv *rt711 = dev_get_drvdata(dev); + + if (rt711->hw_init) + return 0; + + if (rt711->first_hw_init) { + regcache_cache_only(rt711->regmap, false); + regcache_cache_bypass(rt711->regmap, true); + } + + /* + * PM runtime is only enabled when a Slave reports as Attached + */ + if (!rt711->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + rt711_reset(rt711->regmap); + + /* power on */ + regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + /* Set Pin Widget */ + regmap_write(rt711->regmap, RT711_SET_PIN_MIC2, 0x25); + regmap_write(rt711->regmap, RT711_SET_PIN_HP, 0xc0); + regmap_write(rt711->regmap, RT711_SET_PIN_DMIC1, 0x20); + regmap_write(rt711->regmap, RT711_SET_PIN_DMIC2, 0x20); + regmap_write(rt711->regmap, RT711_SET_PIN_LINE1, 0x20); + regmap_write(rt711->regmap, RT711_SET_PIN_LINE2, 0x20); + + /* Mute HP/ADC1/ADC2 */ + regmap_write(rt711->regmap, RT711_SET_GAIN_HP_H, 0xa080); + regmap_write(rt711->regmap, RT711_SET_GAIN_HP_H, 0x9080); + regmap_write(rt711->regmap, RT711_SET_GAIN_ADC2_H, 0x6080); + regmap_write(rt711->regmap, RT711_SET_GAIN_ADC2_H, 0x5080); + regmap_write(rt711->regmap, RT711_SET_GAIN_ADC1_H, 0x6080); + regmap_write(rt711->regmap, RT711_SET_GAIN_ADC1_H, 0x5080); + + /* Set Configuration Default */ + regmap_write(rt711->regmap, 0x4f12, 0x91); + regmap_write(rt711->regmap, 0x4e12, 0xd6); + regmap_write(rt711->regmap, 0x4d12, 0x11); + regmap_write(rt711->regmap, 0x4c12, 0x20); + regmap_write(rt711->regmap, 0x4f13, 0x91); + regmap_write(rt711->regmap, 0x4e13, 0xd6); + regmap_write(rt711->regmap, 0x4d13, 0x11); + regmap_write(rt711->regmap, 0x4c13, 0x21); + regmap_write(rt711->regmap, 0x4c21, 0xf0); + regmap_write(rt711->regmap, 0x4d21, 0x11); + regmap_write(rt711->regmap, 0x4e21, 0x11); + regmap_write(rt711->regmap, 0x4f21, 0x01); + + /* Data port arrangement */ + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + RT711_TX_RX_MUX_CTL, 0x0154); + + /* Set index */ + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + RT711_DIGITAL_MISC_CTRL4, 0x201b); + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + RT711_COMBO_JACK_AUTO_CTL1, 0x5089); + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + RT711_VREFOUT_CTL, 0x5064); + rt711_index_write(rt711->regmap, RT711_VENDOR_REG, + RT711_INLINE_CMD_CTL, 0xd249); + + /* Finish Initial Settings, set power to D3 */ + regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + + if (rt711->first_hw_init) + rt711_calibration(rt711); + else { + INIT_DELAYED_WORK(&rt711->jack_detect_work, + rt711_jack_detect_handler); + INIT_DELAYED_WORK(&rt711->jack_btn_check_work, + rt711_btn_check_handler); + mutex_init(&rt711->calibrate_mutex); + INIT_WORK(&rt711->calibration_work, rt711_calibration_work); + schedule_work(&rt711->calibration_work); + } + + /* + * if set_jack callback occurred early than io_init, + * we set up the jack detection function now + */ + if (rt711->hs_jack) + rt711_jack_init(rt711); + + if (rt711->first_hw_init) { + regcache_cache_bypass(rt711->regmap, false); + regcache_mark_dirty(rt711->regmap); + } else + rt711->first_hw_init = true; + + /* Mark Slave initialization complete */ + rt711->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); + return 0; +} + +MODULE_DESCRIPTION("ASoC RT711 SDW driver"); +MODULE_AUTHOR("Shuming Fan "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/rt711.h b/sound/soc/codecs/rt711.h new file mode 100644 index 000000000000..ca0f581feec7 --- /dev/null +++ b/sound/soc/codecs/rt711.h @@ -0,0 +1,227 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt711.h -- RT711 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT711_H__ +#define __RT711_H__ + +extern const struct dev_pm_ops rt711_runtime_pm; + +struct rt711_priv { + struct regmap *regmap; + struct regmap *sdw_regmap; + struct snd_soc_component *component; + struct sdw_slave *slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; + struct snd_soc_jack *hs_jack; + struct delayed_work jack_detect_work; + struct delayed_work jack_btn_check_work; + struct work_struct calibration_work; + struct mutex calibrate_mutex; /* for headset calibration */ + int jack_type, jd_src; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* NID */ +#define RT711_AUDIO_FUNCTION_GROUP 0x01 +#define RT711_DAC_OUT2 0x03 +#define RT711_ADC_IN1 0x09 +#define RT711_ADC_IN2 0x08 +#define RT711_DMIC1 0x12 +#define RT711_DMIC2 0x13 +#define RT711_MIC2 0x19 +#define RT711_LINE1 0x1a +#define RT711_LINE2 0x1b +#define RT711_BEEP 0x1d +#define RT711_VENDOR_REG 0x20 +#define RT711_HP_OUT 0x21 +#define RT711_MIXER_IN1 0x22 +#define RT711_MIXER_IN2 0x23 +#define RT711_INLINE_CMD 0x55 +#define RT711_VENDOR_CALI 0x58 +#define RT711_VENDOR_IMS_DRE 0x5b + +/* Index (NID:20h) */ +#define RT711_DAC_DC_CALI_CTL1 0x00 +#define RT711_JD_CTL2 0x09 +#define RT711_CC_DET1 0x11 +#define RT711_PARA_VERB_CTL 0x1a +#define RT711_COMBO_JACK_AUTO_CTL1 0x45 +#define RT711_COMBO_JACK_AUTO_CTL2 0x46 +#define RT711_INLINE_CMD_CTL 0x48 +#define RT711_DIGITAL_MISC_CTRL4 0x4a +#define RT711_VREFOUT_CTL 0x6b +#define RT711_FSM_CTL 0x6f +#define RT711_IRQ_FLAG_TABLE1 0x80 +#define RT711_IRQ_FLAG_TABLE2 0x81 +#define RT711_IRQ_FLAG_TABLE3 0x82 +#define RT711_TX_RX_MUX_CTL 0x91 + +/* Index (NID:5bh) */ +#define RT711_IMS_DIGITAL_CTL1 0x00 +#define RT711_HP_IMS_RESULT_L 0x20 +#define RT711_HP_IMS_RESULT_R 0x21 + +/* Verb */ +#define RT711_VERB_SET_CONNECT_SEL 0x3100 +#define RT711_VERB_SET_EAPD_BTLENABLE 0x3c00 +#define RT711_VERB_GET_CONNECT_SEL 0xb100 +#define RT711_VERB_SET_POWER_STATE 0x3500 +#define RT711_VERB_SET_CHANNEL_STREAMID 0x3600 +#define RT711_VERB_SET_PIN_WIDGET_CONTROL 0x3700 +#define RT711_VERB_SET_UNSOLICITED_ENABLE 0x3800 +#define RT711_SET_AMP_GAIN_MUTE_H 0x7300 +#define RT711_SET_AMP_GAIN_MUTE_L 0x8380 +#define RT711_VERB_GET_POWER_STATE 0xb500 +#define RT711_VERB_GET_CHANNEL_STREAMID 0xb600 +#define RT711_VERB_GET_PIN_SENSE 0xb900 +#define RT711_FUNC_RESET 0xff01 + +#define RT711_READ_HDA_3 0x2012 +#define RT711_READ_HDA_2 0x2013 +#define RT711_READ_HDA_1 0x2014 +#define RT711_READ_HDA_0 0x2015 +#define RT711_PRIV_INDEX_W_H 0x7500 +#define RT711_PRIV_INDEX_W_L 0x8580 +#define RT711_PRIV_DATA_W_H 0x7400 +#define RT711_PRIV_DATA_W_L 0x8480 +#define RT711_PRIV_INDEX_R_H 0x9d00 +#define RT711_PRIV_INDEX_R_L 0xad80 +#define RT711_PRIV_DATA_R_H 0x9c00 +#define RT711_PRIV_DATA_R_L 0xac80 +#define RT711_DAC_FORMAT_H 0x7203 +#define RT711_DAC_FORMAT_L 0x8283 +#define RT711_ADC1_FORMAT_H 0x7209 +#define RT711_ADC1_FORMAT_L 0x8289 +#define RT711_ADC2_FORMAT_H 0x7208 +#define RT711_ADC2_FORMAT_L 0x8288 + +#define RT711_SET_AUDIO_POWER_STATE\ + (RT711_VERB_SET_POWER_STATE | RT711_AUDIO_FUNCTION_GROUP) +#define RT711_GET_AUDIO_POWER_STATE\ + (RT711_VERB_GET_POWER_STATE | RT711_AUDIO_FUNCTION_GROUP) +#define RT711_SET_PIN_DMIC1\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_DMIC1) +#define RT711_SET_PIN_DMIC2\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_DMIC2) +#define RT711_SET_PIN_HP\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_HP_OUT) +#define RT711_SET_PIN_MIC2\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_MIC2) +#define RT711_SET_PIN_LINE1\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_LINE1) +#define RT711_SET_PIN_LINE2\ + (RT711_VERB_SET_PIN_WIDGET_CONTROL | RT711_LINE2) +#define RT711_SET_MIC2_UNSOLICITED_ENABLE\ + (RT711_VERB_SET_UNSOLICITED_ENABLE | RT711_MIC2) +#define RT711_SET_HP_UNSOLICITED_ENABLE\ + (RT711_VERB_SET_UNSOLICITED_ENABLE | RT711_HP_OUT) +#define RT711_SET_INLINE_UNSOLICITED_ENABLE\ + (RT711_VERB_SET_UNSOLICITED_ENABLE | RT711_INLINE_CMD) +#define RT711_SET_STREAMID_DAC2\ + (RT711_VERB_SET_CHANNEL_STREAMID | RT711_DAC_OUT2) +#define RT711_SET_STREAMID_ADC1\ + (RT711_VERB_SET_CHANNEL_STREAMID | RT711_ADC_IN1) +#define RT711_SET_STREAMID_ADC2\ + (RT711_VERB_SET_CHANNEL_STREAMID | RT711_ADC_IN2) +#define RT711_GET_STREAMID_DAC2\ + (RT711_VERB_GET_CHANNEL_STREAMID | RT711_DAC_OUT2) +#define RT711_GET_STREAMID_ADC1\ + (RT711_VERB_GET_CHANNEL_STREAMID | RT711_ADC_IN1) +#define RT711_GET_STREAMID_ADC2\ + (RT711_VERB_GET_CHANNEL_STREAMID | RT711_ADC_IN2) +#define RT711_SET_GAIN_DAC2_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_DAC_OUT2) +#define RT711_SET_GAIN_DAC2_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_DAC_OUT2) +#define RT711_SET_GAIN_ADC1_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_ADC_IN1) +#define RT711_SET_GAIN_ADC1_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_ADC_IN1) +#define RT711_SET_GAIN_ADC2_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_ADC_IN2) +#define RT711_SET_GAIN_ADC2_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_ADC_IN2) +#define RT711_SET_GAIN_AMIC_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_MIC2) +#define RT711_SET_GAIN_AMIC_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_MIC2) +#define RT711_SET_GAIN_DMIC1_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_DMIC1) +#define RT711_SET_GAIN_DMIC1_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_DMIC1) +#define RT711_SET_GAIN_DMIC2_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_DMIC2) +#define RT711_SET_GAIN_DMIC2_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_DMIC2) +#define RT711_SET_GAIN_HP_L\ + (RT711_SET_AMP_GAIN_MUTE_L | RT711_HP_OUT) +#define RT711_SET_GAIN_HP_H\ + (RT711_SET_AMP_GAIN_MUTE_H | RT711_HP_OUT) + +/* DAC DC offset calibration control-1 (0x00)(NID:20h) */ +#define RT711_DAC_DC_CALI_TRIGGER (0x1 << 15) + +/* jack detect control 2 (0x09)(NID:20h) */ +#define RT711_JD2_2PORT_200K_DECODE_HP (0x1 << 13) +#define RT711_HP_JD_SEL_JD1 (0x0 << 1) +#define RT711_HP_JD_SEL_JD2 (0x1 << 1) + +/* CC DET1 (0x11)(NID:20h) */ +#define RT711_HP_JD_FINAL_RESULT_CTL_JD12 (0x1 << 10) +#define RT711_HP_JD_FINAL_RESULT_CTL_CCDET (0x0 << 10) + +/* Parameter & Verb control (0x1a)(NID:20h) */ +#define RT711_HIDDEN_REG_SW_RESET (0x1 << 14) + +/* combo jack auto switch control 2 (0x46)(NID:20h) */ +#define RT711_COMBOJACK_AUTO_DET_STATUS (0x1 << 11) +#define RT711_COMBOJACK_AUTO_DET_TRS (0x1 << 10) +#define RT711_COMBOJACK_AUTO_DET_CTIA (0x1 << 9) +#define RT711_COMBOJACK_AUTO_DET_OMTP (0x1 << 8) + +/* FSM control (0x6f)(NID:20h) */ +#define RT711_CALI_CTL (0x0 << 0) +#define RT711_COMBOJACK_CTL (0x1 << 0) +#define RT711_IMS_CTL (0x2 << 0) +#define RT711_DEPOP_CTL (0x3 << 0) + +/* Impedance Sense Digital Control 1 (0x00)(NID:5bh) */ +#define RT711_TRIGGER_IMS (0x1 << 15) +#define RT711_IMS_EN (0x1 << 6) + +#define RT711_EAPD_HIGH 0x2 +#define RT711_EAPD_LOW 0x0 +#define RT711_MUTE_SFT 7 +/* set input/output mapping to payload[14][15] separately */ +#define RT711_DIR_IN_SFT 6 +#define RT711_DIR_OUT_SFT 7 + +enum { + RT711_AIF1, + RT711_AIF2, + RT711_AIFS, +}; + +enum rt711_jd_src { + RT711_JD_NULL, + RT711_JD1, + RT711_JD2 +}; + +int rt711_io_init(struct device *dev, struct sdw_slave *slave); +int rt711_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int rt711_jack_detect(struct rt711_priv *rt711, bool *hp, bool *mic); +int rt711_clock_config(struct device *dev); +#endif /* __RT711_H__ */ -- cgit v1.2.3 From a84188eced6109983af54f9435a26d21eac3f8cc Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 10 Jan 2020 13:24:02 +0000 Subject: ASoC: max98090: Drop incorrectly applied duplicate commit This reverts commit 4e93c1294f4b051 (ASoC: max98090: fix incorrect helper in max98090_dapm_put_enum_double()) which was misapplied. Reported-by: Marek Szyprowski Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index ba0e3ba162f8..454cb8e5b0a1 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -98,7 +98,7 @@ static int max98090_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_component *component = - snd_soc_dapm_kcontrol_component(kcontrol); + snd_soc_kcontrol_component(kcontrol); struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); int ret; -- cgit v1.2.3 From 613fb50059cf19aa6acbc503a00265d9151c0b09 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:35:21 +0900 Subject: ASoC: soc-core: remove snd_soc_rtdcom_list Current ALSA SoC is using struct snd_soc_rtdcom_list to connecting component to rtd by using list_head. struct snd_soc_rtdcom_list { struct snd_soc_component *component; struct list_head list; /* rtd::component_list */ }; struct snd_soc_pcm_runtime { ... struct list_head component_list; /* list of connected components */ ... }; The CPU/Codec/Platform component which will be connected to rtd (a) is indicated via dai_link at snd_soc_add_pcm_runtime() int snd_soc_add_pcm_runtime(...) { ... /* Find CPU from registered CPUs */ rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus); ... (a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); ... /* Find CODEC from registered CODECs */ (b) for_each_link_codecs(dai_link, i, codec) { rtd->codec_dais[i] = snd_soc_find_dai(codec); ... (a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); } ... /* Find PLATFORM from registered PLATFORMs */ (b) for_each_link_platforms(dai_link, i, platform) { for_each_component(component) { ... (a) snd_soc_rtdcom_add(rtd, component); } } } It shows, it is possible to know how many components will be connected to rtd by using dai_link->num_cpus dai_link->num_codecs dai_link->num_platforms If so, we can use component pointer array instead of list_head, in such case, code can be more simple. This patch removes struct snd_soc_rtdcom_list that is only of temporary value, and convert to pointer array. Signed-off-by: Kuninori Morimoto Reviewed-By: Ranjani Sridharan Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 18 +++++------- sound/soc/soc-component.c | 33 ++++++++++----------- sound/soc/soc-compress.c | 75 ++++++++++++++++++++--------------------------- sound/soc/soc-core.c | 56 +++++++++++++---------------------- sound/soc/soc-pcm.c | 43 ++++++++++----------------- 5 files changed, 91 insertions(+), 134 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 9787c80e548b..0513f30a0209 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -736,19 +736,9 @@ struct snd_soc_compr_ops { int (*trigger)(struct snd_compr_stream *); }; -struct snd_soc_rtdcom_list { - struct snd_soc_component *component; - struct list_head list; /* rtd::component_list */ -}; struct snd_soc_component* snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, const char *driver_name); -#define for_each_rtd_components(rtd, rtdcom, _component) \ - for (rtdcom = list_first_entry(&(rtd)->component_list, \ - typeof(*rtdcom), list); \ - (&rtdcom->list != &(rtd)->component_list) && \ - (_component = rtdcom->component); \ - rtdcom = list_next_entry(rtdcom, list)) struct snd_soc_dai_link_component { const char *name; @@ -1150,12 +1140,18 @@ struct snd_soc_pcm_runtime { unsigned int num; /* 0-based and monotonic increasing */ struct list_head list; /* rtd list of the soc card */ - struct list_head component_list; /* list of connected components */ /* bit field */ unsigned int pop_wait:1; unsigned int fe_compr:1; /* for Dynamic PCM */ + + int num_components; + struct snd_soc_component *components[0]; /* CPU/Codec/Platform */ }; +#define for_each_rtd_components(rtd, i, component) \ + for ((i) = 0; \ + ((i) < rtd->num_components) && ((component) = rtd->components[i]);\ + (i)++) #define for_each_rtd_codec_dai(rtd, i, dai)\ for ((i) = 0; \ ((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index b94680fb26fa..14e175cdeeb8 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -418,10 +418,10 @@ int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; + int i; /* FIXME: use 1st pointer */ - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) if (component->driver->pointer) return component->driver->pointer(component, substream); @@ -433,10 +433,10 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; + int i; /* FIXME: use 1st ioctl */ - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) if (component->driver->ioctl) return component->driver->ioctl(component, substream, cmd, arg); @@ -448,10 +448,9 @@ int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret; + int i, ret; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component->driver->ioctl) { ret = component->driver->sync_stop(component, substream); @@ -468,11 +467,11 @@ int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream, void __user *buf, unsigned long bytes) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; + int i; /* FIXME. it returns 1st copy now */ - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) if (component->driver->copy_user) return component->driver->copy_user( component, substream, channel, pos, buf, bytes); @@ -484,12 +483,12 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream, unsigned long offset) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; struct page *page; + int i; /* FIXME. it returns 1st page now */ - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component->driver->page) { page = component->driver->page(component, substream, offset); @@ -505,11 +504,11 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; + int i; /* FIXME. it returns 1st mmap now */ - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) if (component->driver->mmap) return component->driver->mmap(component, substream, vma); @@ -519,11 +518,11 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream, int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; int ret; + int i; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component->driver->pcm_construct) { ret = component->driver->pcm_construct(component, rtd); if (ret < 0) @@ -536,13 +535,13 @@ int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd) void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; + int i; if (!rtd->pcm) return; - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) if (component->driver->pcm_destruct) component->driver->pcm_destruct(component, rtd->pcm); } diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index b2a5351b1a11..16fe08690cf5 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -26,10 +26,9 @@ static int soc_compr_components_open(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret; + int i, ret; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->open) continue; @@ -54,9 +53,9 @@ static int soc_compr_components_free(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; + int i; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component == last) break; @@ -74,11 +73,10 @@ static int soc_compr_open(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component, *save = NULL; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; + int ret, i; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { ret = pm_runtime_get_sync(component->dev); if (ret < 0 && ret != -EACCES) { pm_runtime_put_noidle(component->dev); @@ -127,7 +125,7 @@ machine_err: out: mutex_unlock(&rtd->card->pcm_mutex); pm_err: - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component == save) break; pm_runtime_mark_last_busy(component->dev); @@ -259,10 +257,9 @@ static int soc_compr_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; - int stream; + int stream, i; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -309,7 +306,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream) mutex_unlock(&rtd->card->pcm_mutex); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { pm_runtime_mark_last_busy(component->dev); pm_runtime_put_autosuspend(component->dev); } @@ -371,10 +368,9 @@ static int soc_compr_components_trigger(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret; + int i, ret; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->trigger) continue; @@ -474,10 +470,9 @@ static int soc_compr_components_set_params(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret; + int i, ret; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->set_params) continue; @@ -606,9 +601,8 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -618,7 +612,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, goto err; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->get_params) continue; @@ -637,12 +631,11 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret = 0; + int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->get_caps) continue; @@ -660,12 +653,11 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret = 0; + int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->get_codec_caps) continue; @@ -683,9 +675,8 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret = 0; + int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -695,7 +686,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) goto err; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->ack) continue; @@ -715,8 +706,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret = 0; + int i, ret = 0; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -724,7 +714,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->pointer) continue; @@ -742,12 +732,11 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; - int ret = 0; + int i, ret = 0; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->copy) continue; @@ -765,9 +754,8 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; + int i, ret; if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) { ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai); @@ -775,7 +763,7 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, return ret; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->set_metadata) continue; @@ -794,9 +782,8 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - int ret; + int i, ret; if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) { ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai); @@ -804,7 +791,7 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, return ret; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->get_metadata) continue; @@ -857,7 +844,6 @@ static struct snd_compr_ops soc_compr_dyn_ops = { int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) { struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_compr *compr; @@ -865,6 +851,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) char new_name[64]; int ret = 0, direction = 0; int playback = 0, capture = 0; + int i; if (rtd->num_codecs > 1) { dev_err(rtd->card->dev, @@ -933,7 +920,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->compr_ops || !component->driver->compr_ops->copy) continue; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 55b98e82a978..c9daa63a339b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -261,34 +261,18 @@ static inline void snd_soc_debugfs_exit(void) static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, struct snd_soc_component *component) { - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *comp; + int i; - for_each_rtd_components(rtd, rtdcom, comp) { + for_each_rtd_components(rtd, i, comp) { /* already connected */ if (comp == component) return 0; } - /* - * created rtdcom here will be freed when rtd->dev was freed. - * see - * soc_free_pcm_runtime() :: device_unregister(rtd->dev) - */ - rtdcom = devm_kzalloc(rtd->dev, sizeof(*rtdcom), GFP_KERNEL); - if (!rtdcom) - return -ENOMEM; - - rtdcom->component = component; - INIT_LIST_HEAD(&rtdcom->list); - - /* - * When rtd was freed, created rtdcom here will be - * also freed. - * And we don't need to call list_del(&rtdcom->list) - * when freed, because rtd is also freed. - */ - list_add_tail(&rtdcom->list, &rtd->component_list); + /* see for_each_rtd_components */ + rtd->components[rtd->num_components] = component; + rtd->num_components++; return 0; } @@ -296,8 +280,8 @@ static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, const char *driver_name) { - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; + int i; if (!driver_name) return NULL; @@ -310,7 +294,7 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, * But, if many components which have same driver name are connected * to 1 rtd, this function will return 1st found component. */ - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { const char *component_name = component->driver->name; if (!component_name) @@ -318,7 +302,7 @@ struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, if ((component_name == driver_name) || strcmp(component_name, driver_name) == 0) - return rtdcom->component; + return component; } return NULL; @@ -418,6 +402,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; + struct snd_soc_component *component; struct device *dev; int ret; @@ -443,13 +428,17 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( /* * for rtd */ - rtd = devm_kzalloc(dev, sizeof(*rtd), GFP_KERNEL); + rtd = devm_kzalloc(dev, + sizeof(*rtd) + + sizeof(*component) * (dai_link->num_cpus + + dai_link->num_codecs + + dai_link->num_platforms), + GFP_KERNEL); if (!rtd) goto free_rtd; rtd->dev = dev; INIT_LIST_HEAD(&rtd->list); - INIT_LIST_HEAD(&rtd->component_list); INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].be_clients); INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].be_clients); INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK].fe_clients); @@ -1108,9 +1097,8 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, { struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - int ret, num; + int ret, num, i; /* set default power off timeout */ rtd->pmdown_time = pmdown_time; @@ -1141,7 +1129,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, * topology based drivers can use the DAI link id field to set PCM * device number and then use rtd + a base offset of the BEs. */ - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (!component->driver->use_dai_pcm_id) continue; @@ -1406,12 +1394,11 @@ static void soc_remove_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; struct snd_soc_pcm_runtime *rtd; - struct snd_soc_rtdcom_list *rtdcom; - int order; + int i, order; for_each_comp_order(order) { for_each_card_rtds(card, rtd) { - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component->driver->remove_order != order) continue; @@ -1425,12 +1412,11 @@ static int soc_probe_link_components(struct snd_soc_card *card) { struct snd_soc_component *component; struct snd_soc_pcm_runtime *rtd; - struct snd_soc_rtdcom_list *rtdcom; - int ret, order; + int i, ret, order; for_each_comp_order(order) { for_each_card_rtds(card, rtd) { - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component->driver->probe_order != order) continue; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 01e7bc03d92f..9c6c7533a508 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -111,14 +111,14 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) */ bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; bool ignore = true; + int i; if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) return true; - for_each_rtd_components(rtd, rtdcom, component) + for_each_rtd_components(rtd, i, component) ignore &= !component->driver->use_pmdown_time; return ignore; @@ -428,11 +428,10 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream, struct snd_soc_component **last) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - int ret = 0; + int i, ret = 0; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { *last = component; ret = snd_soc_component_module_get_when_open(component); @@ -459,11 +458,10 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream, struct snd_soc_component *last) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - int ret = 0; + int i, ret = 0; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component == last) break; @@ -484,7 +482,6 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; const char *codec_dai_name = "multicodec"; @@ -494,9 +491,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) for_each_rtd_codec_dai(rtd, i, codec_dai) pinctrl_pm_select_default_state(codec_dai->dev); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) pm_runtime_get_sync(component->dev); - } mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); @@ -617,7 +613,7 @@ component_err: out: mutex_unlock(&rtd->card->pcm_mutex); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { pm_runtime_mark_last_busy(component->dev); pm_runtime_put_autosuspend(component->dev); } @@ -677,7 +673,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i; @@ -728,7 +723,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) mutex_unlock(&rtd->card->pcm_mutex); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { pm_runtime_mark_last_busy(component->dev); pm_runtime_put_autosuspend(component->dev); } @@ -752,7 +747,6 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret = 0; @@ -768,7 +762,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_prepare(component, substream); if (ret < 0) { dev_err(component->dev, @@ -829,11 +823,10 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream, struct snd_soc_component *last) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; - int ret = 0; + int i, ret = 0; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { if (component == last) break; @@ -853,7 +846,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret = 0; @@ -932,7 +924,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, snd_soc_dapm_update_dai(substream, params, cpu_dai); - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_hw_params(component, substream, params); if (ret < 0) { dev_err(component->dev, @@ -1033,7 +1025,6 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret; @@ -1044,7 +1035,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) return ret; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_trigger(component, substream, cmd); if (ret < 0) return ret; @@ -1067,7 +1058,6 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_component *component; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i, ret; @@ -1082,7 +1072,7 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) if (ret < 0) return ret; - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_trigger(component, substream, cmd); if (ret < 0) return ret; @@ -2897,7 +2887,6 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) { struct snd_soc_dai *codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_component *component; struct snd_pcm *pcm; char new_name[64]; @@ -3007,7 +2996,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) rtd->ops.pointer = soc_pcm_pointer; } - for_each_rtd_components(rtd, rtdcom, component) { + for_each_rtd_components(rtd, i, component) { const struct snd_soc_component_driver *drv = component->driver; if (drv->ioctl) -- cgit v1.2.3 From 7d2a5f9ae41e3d3b50cd32b9fb307fab88064daf Mon Sep 17 00:00:00 2001 From: Shuming Fan Date: Fri, 10 Jan 2020 09:45:52 +0800 Subject: ASoC: rt700: add rt700 codec driver This is the initial codec driver for rt700. Signed-off-by: Shuming Fan Tested-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110014552.17252-1-shumingf@realtek.com Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 10 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt700-sdw.c | 551 +++++++++++++++++++ sound/soc/codecs/rt700-sdw.h | 335 ++++++++++++ sound/soc/codecs/rt700.c | 1238 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt700.h | 174 ++++++ 6 files changed, 2310 insertions(+) create mode 100644 sound/soc/codecs/rt700-sdw.c create mode 100644 sound/soc/codecs/rt700-sdw.h create mode 100644 sound/soc/codecs/rt700.c create mode 100644 sound/soc/codecs/rt700.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 65b81888ca3d..7761aeec4d07 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -165,6 +165,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT5670 if I2C select SND_SOC_RT5677 if I2C && SPI_MASTER select SND_SOC_RT5682 if I2C + select SND_SOC_RT700_SDW if SOUNDWIRE select SND_SOC_RT711_SDW if SOUNDWIRE select SND_SOC_SGTL5000 if I2C select SND_SOC_SI476X if MFD_SI476X_CORE @@ -1060,6 +1061,15 @@ config SND_SOC_RT5677_SPI config SND_SOC_RT5682 tristate +config SND_SOC_RT700 + tristate + +config SND_SOC_RT700_SDW + tristate "Realtek RT700 Codec - SDW" + depends on SOUNDWIRE + select SND_SOC_RT700 + select REGMAP_SOUNDWIRE + config SND_SOC_RT711 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index f4dfe033d120..288b7af354a0 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -173,6 +173,7 @@ snd-soc-rt5670-objs := rt5670.o snd-soc-rt5677-objs := rt5677.o snd-soc-rt5677-spi-objs := rt5677-spi.o snd-soc-rt5682-objs := rt5682.o +snd-soc-rt700-objs := rt700.o rt700-sdw.o snd-soc-rt711-objs := rt711.o rt711-sdw.o snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-alc5623-objs := alc5623.o @@ -466,6 +467,7 @@ obj-$(CONFIG_SND_SOC_RT5670) += snd-soc-rt5670.o obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o obj-$(CONFIG_SND_SOC_RT5677_SPI) += snd-soc-rt5677-spi.o obj-$(CONFIG_SND_SOC_RT5682) += snd-soc-rt5682.o +obj-$(CONFIG_SND_SOC_RT700) += snd-soc-rt700.o obj-$(CONFIG_SND_SOC_RT711) += snd-soc-rt711.o obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c new file mode 100644 index 000000000000..314103601af3 --- /dev/null +++ b/sound/soc/codecs/rt700-sdw.c @@ -0,0 +1,551 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt700-sdw.c -- rt700 ALSA SoC audio driver +// +// Copyright(c) 2019 Realtek Semiconductor Corp. +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include "rt700.h" +#include "rt700-sdw.h" + +static bool rt700_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2000 ... 0x200e: + case 0x2012 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2200 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2231: + case 0x3000 ... 0x3fff: + case 0x7000 ... 0x7fff: + case 0x8300 ... 0x83ff: + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0x75201a: + case 0x752045: + case 0x752046: + case 0x752048: + case 0x75204a: + case 0x75206b: + case 0x752080: + case 0x752081: + return true; + default: + return false; + } +} + +static bool rt700_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2009: + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2021: + case 0x2023: + case 0x2230: + case 0x200b ... 0x200e: /* i2c read */ + case 0x2012 ... 0x2015: /* HD-A read */ + case 0x202d ... 0x202f: /* BRA */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded HD-A */ + case 0x9c00 ... 0x9cff: + case 0xb900 ... 0xb9ff: + case 0xff01: + case 0x75201a: + case 0x752046: + case 0x752080: + case 0x752081: + return true; + default: + return false; + } +} + +static int rt700_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt700->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT700_PRIV_DATA_R_H | nid; + ret = regmap_write(rt700->sdw_regmap, + reg3, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt700->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt700->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt700->sdw_regmap, + reg2, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt700->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt700->sdw_regmap, + reg, ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt700->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt700->sdw_regmap, + RT700_READ_HDA_3, &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + RT700_READ_HDA_2, &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + RT700_READ_HDA_1, &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt700->sdw_regmap, + RT700_READ_HDA_0, &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x\n", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x\n", + __func__, reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x\n", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt700_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt700->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT700_PRIV_DATA_W_H | nid; + ret = regmap_write(rt700->sdw_regmap, + reg3, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == 0xff01) { + ret = regmap_write(rt700->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt700->sdw_regmap, + reg, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt700->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt700->sdw_regmap, + reg2, ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt700->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x\n", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x\n", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x\n", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt700_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt700_readable_register, + .volatile_reg = rt700_volatile_register, + .max_register = 0x755800, + .reg_defaults = rt700_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(rt700_reg_defaults), + .cache_type = REGCACHE_RBTREE, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt700_sdw_read, + .reg_write = rt700_sdw_write, +}; + +static const struct regmap_config rt700_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt700_readable_register, + .max_register = 0xff01, + .cache_type = REGCACHE_NONE, + .use_single_read = true, + .use_single_write = true, +}; + +static int rt700_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + /* Update the status */ + rt700->status = status; + + if (status == SDW_SLAVE_UNATTACHED) + rt700->hw_init = false; + + /* + * Perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt700->hw_init || rt700->status != SDW_SLAVE_ATTACHED) + return 0; + + /* perform I/O transfers required for Slave initialization */ + return rt700_io_init(&slave->dev, slave); +} + +static int rt700_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x14; /* BITMAP: 00010100 */ + prop->sink_ports = 0xA; /* BITMAP: 00001010 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + GFP_KERNEL); + if (!prop->src_dpn_prop) + return -ENOMEM; + + i = 0; + dpn = prop->src_dpn_prop; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = SDW_DPN_FULL; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + GFP_KERNEL); + if (!prop->sink_dpn_prop) + return -ENOMEM; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = SDW_DPN_FULL; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* Allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + GFP_KERNEL); + if (!slave->port_ready) + return -ENOMEM; + + /* Initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt700_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt700->params, params, sizeof(*params)); + + ret = rt700_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "Invalid clk config"); + + return ret; +} + +static int rt700_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + if (status->control_port & 0x4) { + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_detect_work, msecs_to_jiffies(250)); + } + + return 0; +} + +/* + * slave_ops: callbacks for get_clock_stop_mode, clock_stop and + * port_prep are not defined for now + */ +static struct sdw_slave_ops rt700_slave_ops = { + .read_prop = rt700_read_prop, + .interrupt_callback = rt700_interrupt_callback, + .update_status = rt700_update_status, + .bus_config = rt700_bus_config, +}; + +static int rt700_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* Assign ops */ + slave->ops = &rt700_slave_ops; + + /* Regmap Initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt700_sdw_regmap); + if (!sdw_regmap) + return -EINVAL; + + regmap = devm_regmap_init(&slave->dev, NULL, + &slave->dev, &rt700_regmap); + if (!regmap) + return -EINVAL; + + rt700_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static int rt700_sdw_remove(struct sdw_slave *slave) +{ + struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev); + + if (rt700 && rt700->hw_init) { + cancel_delayed_work(&rt700->jack_detect_work); + cancel_delayed_work(&rt700->jack_btn_check_work); + } + + return 0; +} + +static const struct sdw_device_id rt700_id[] = { + SDW_SLAVE_ENTRY(0x025d, 0x700, 0), + {}, +}; +MODULE_DEVICE_TABLE(sdw, rt700_id); + +static int rt700_dev_suspend(struct device *dev) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + + if (!rt700->hw_init) + return 0; + + regcache_cache_only(rt700->regmap, true); + + return 0; +} + +#define RT700_PROBE_TIMEOUT 2000 + +static int rt700_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt700->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(RT700_PROBE_TIMEOUT)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete, timed out\n"); + return -ETIMEDOUT; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt700->regmap, false); + regcache_sync_region(rt700->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt700->regmap, 0x752010, 0x75206b); + + return 0; +} + +static const struct dev_pm_ops rt700_pm = { + SET_SYSTEM_SLEEP_PM_OPS(rt700_dev_suspend, rt700_dev_resume) + SET_RUNTIME_PM_OPS(rt700_dev_suspend, rt700_dev_resume, NULL) +}; + +static struct sdw_driver rt700_sdw_driver = { + .driver = { + .name = "rt700", + .owner = THIS_MODULE, + .pm = &rt700_pm, + }, + .probe = rt700_sdw_probe, + .remove = rt700_sdw_remove, + .ops = &rt700_slave_ops, + .id_table = rt700_id, +}; +module_sdw_driver(rt700_sdw_driver); + +MODULE_DESCRIPTION("ASoC RT700 driver SDW"); +MODULE_AUTHOR("Shuming Fan "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt700-sdw.h b/sound/soc/codecs/rt700-sdw.h new file mode 100644 index 000000000000..4ad0dcfd16fd --- /dev/null +++ b/sound/soc/codecs/rt700-sdw.h @@ -0,0 +1,335 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt700-sdw.h -- RT700 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT700_SDW_H__ +#define __RT700_SDW_H__ + +static const struct reg_default rt700_reg_defaults[] = { + { 0x0000, 0x0000 }, + { 0x0001, 0x0000 }, + { 0x0002, 0x0000 }, + { 0x0003, 0x0000 }, + { 0x0004, 0x0000 }, + { 0x0005, 0x0001 }, + { 0x0020, 0x0000 }, + { 0x0022, 0x0000 }, + { 0x0023, 0x0000 }, + { 0x0024, 0x0000 }, + { 0x0025, 0x0000 }, + { 0x0026, 0x0000 }, + { 0x0030, 0x0000 }, + { 0x0032, 0x0000 }, + { 0x0033, 0x0000 }, + { 0x0034, 0x0000 }, + { 0x0035, 0x0000 }, + { 0x0036, 0x0000 }, + { 0x0040, 0x0000 }, + { 0x0041, 0x0000 }, + { 0x0042, 0x0000 }, + { 0x0043, 0x0000 }, + { 0x0044, 0x0020 }, + { 0x0045, 0x0001 }, + { 0x0046, 0x0000 }, + { 0x0050, 0x0000 }, + { 0x0051, 0x0000 }, + { 0x0052, 0x0000 }, + { 0x0053, 0x0000 }, + { 0x0054, 0x0000 }, + { 0x0055, 0x0000 }, + { 0x0060, 0x0000 }, + { 0x0070, 0x0000 }, + { 0x00e0, 0x0000 }, + { 0x00f0, 0x0000 }, + { 0x0100, 0x0000 }, + { 0x0101, 0x0000 }, + { 0x0102, 0x0000 }, + { 0x0103, 0x0000 }, + { 0x0104, 0x0000 }, + { 0x0105, 0x0000 }, + { 0x0120, 0x0000 }, + { 0x0121, 0x0000 }, + { 0x0122, 0x0000 }, + { 0x0123, 0x0000 }, + { 0x0124, 0x0000 }, + { 0x0125, 0x0000 }, + { 0x0126, 0x0000 }, + { 0x0127, 0x0000 }, + { 0x0130, 0x0000 }, + { 0x0131, 0x0000 }, + { 0x0132, 0x0000 }, + { 0x0133, 0x0000 }, + { 0x0134, 0x0000 }, + { 0x0135, 0x0000 }, + { 0x0136, 0x0000 }, + { 0x0137, 0x0000 }, + { 0x0200, 0x0000 }, + { 0x0201, 0x0000 }, + { 0x0202, 0x0000 }, + { 0x0203, 0x0000 }, + { 0x0204, 0x0000 }, + { 0x0205, 0x0000 }, + { 0x0220, 0x0000 }, + { 0x0221, 0x0000 }, + { 0x0222, 0x0000 }, + { 0x0223, 0x0000 }, + { 0x0224, 0x0000 }, + { 0x0225, 0x0000 }, + { 0x0226, 0x0000 }, + { 0x0227, 0x0000 }, + { 0x0230, 0x0000 }, + { 0x0231, 0x0000 }, + { 0x0232, 0x0000 }, + { 0x0233, 0x0000 }, + { 0x0234, 0x0000 }, + { 0x0235, 0x0000 }, + { 0x0236, 0x0000 }, + { 0x0237, 0x0000 }, + { 0x0300, 0x0000 }, + { 0x0301, 0x0000 }, + { 0x0302, 0x0000 }, + { 0x0303, 0x0000 }, + { 0x0304, 0x0000 }, + { 0x0305, 0x0000 }, + { 0x0320, 0x0000 }, + { 0x0321, 0x0000 }, + { 0x0322, 0x0000 }, + { 0x0323, 0x0000 }, + { 0x0324, 0x0000 }, + { 0x0325, 0x0000 }, + { 0x0326, 0x0000 }, + { 0x0327, 0x0000 }, + { 0x0330, 0x0000 }, + { 0x0331, 0x0000 }, + { 0x0332, 0x0000 }, + { 0x0333, 0x0000 }, + { 0x0334, 0x0000 }, + { 0x0335, 0x0000 }, + { 0x0336, 0x0000 }, + { 0x0337, 0x0000 }, + { 0x0400, 0x0000 }, + { 0x0401, 0x0000 }, + { 0x0402, 0x0000 }, + { 0x0403, 0x0000 }, + { 0x0404, 0x0000 }, + { 0x0405, 0x0000 }, + { 0x0420, 0x0000 }, + { 0x0421, 0x0000 }, + { 0x0422, 0x0000 }, + { 0x0423, 0x0000 }, + { 0x0424, 0x0000 }, + { 0x0425, 0x0000 }, + { 0x0426, 0x0000 }, + { 0x0427, 0x0000 }, + { 0x0430, 0x0000 }, + { 0x0431, 0x0000 }, + { 0x0432, 0x0000 }, + { 0x0433, 0x0000 }, + { 0x0434, 0x0000 }, + { 0x0435, 0x0000 }, + { 0x0436, 0x0000 }, + { 0x0437, 0x0000 }, + { 0x0500, 0x0000 }, + { 0x0501, 0x0000 }, + { 0x0502, 0x0000 }, + { 0x0503, 0x0000 }, + { 0x0504, 0x0000 }, + { 0x0505, 0x0000 }, + { 0x0520, 0x0000 }, + { 0x0521, 0x0000 }, + { 0x0522, 0x0000 }, + { 0x0523, 0x0000 }, + { 0x0524, 0x0000 }, + { 0x0525, 0x0000 }, + { 0x0526, 0x0000 }, + { 0x0527, 0x0000 }, + { 0x0530, 0x0000 }, + { 0x0531, 0x0000 }, + { 0x0532, 0x0000 }, + { 0x0533, 0x0000 }, + { 0x0534, 0x0000 }, + { 0x0535, 0x0000 }, + { 0x0536, 0x0000 }, + { 0x0537, 0x0000 }, + { 0x0600, 0x0000 }, + { 0x0601, 0x0000 }, + { 0x0602, 0x0000 }, + { 0x0603, 0x0000 }, + { 0x0604, 0x0000 }, + { 0x0605, 0x0000 }, + { 0x0620, 0x0000 }, + { 0x0621, 0x0000 }, + { 0x0622, 0x0000 }, + { 0x0623, 0x0000 }, + { 0x0624, 0x0000 }, + { 0x0625, 0x0000 }, + { 0x0626, 0x0000 }, + { 0x0627, 0x0000 }, + { 0x0630, 0x0000 }, + { 0x0631, 0x0000 }, + { 0x0632, 0x0000 }, + { 0x0633, 0x0000 }, + { 0x0634, 0x0000 }, + { 0x0635, 0x0000 }, + { 0x0636, 0x0000 }, + { 0x0637, 0x0000 }, + { 0x0700, 0x0000 }, + { 0x0701, 0x0000 }, + { 0x0702, 0x0000 }, + { 0x0703, 0x0000 }, + { 0x0704, 0x0000 }, + { 0x0705, 0x0000 }, + { 0x0720, 0x0000 }, + { 0x0721, 0x0000 }, + { 0x0722, 0x0000 }, + { 0x0723, 0x0000 }, + { 0x0724, 0x0000 }, + { 0x0725, 0x0000 }, + { 0x0726, 0x0000 }, + { 0x0727, 0x0000 }, + { 0x0730, 0x0000 }, + { 0x0731, 0x0000 }, + { 0x0732, 0x0000 }, + { 0x0733, 0x0000 }, + { 0x0734, 0x0000 }, + { 0x0735, 0x0000 }, + { 0x0736, 0x0000 }, + { 0x0737, 0x0000 }, + { 0x0800, 0x0000 }, + { 0x0801, 0x0000 }, + { 0x0802, 0x0000 }, + { 0x0803, 0x0000 }, + { 0x0804, 0x0000 }, + { 0x0805, 0x0000 }, + { 0x0820, 0x0000 }, + { 0x0821, 0x0000 }, + { 0x0822, 0x0000 }, + { 0x0823, 0x0000 }, + { 0x0824, 0x0000 }, + { 0x0825, 0x0000 }, + { 0x0826, 0x0000 }, + { 0x0827, 0x0000 }, + { 0x0830, 0x0000 }, + { 0x0831, 0x0000 }, + { 0x0832, 0x0000 }, + { 0x0833, 0x0000 }, + { 0x0834, 0x0000 }, + { 0x0835, 0x0000 }, + { 0x0836, 0x0000 }, + { 0x0837, 0x0000 }, + { 0x0f00, 0x0000 }, + { 0x0f01, 0x0000 }, + { 0x0f02, 0x0000 }, + { 0x0f03, 0x0000 }, + { 0x0f04, 0x0000 }, + { 0x0f05, 0x0000 }, + { 0x0f20, 0x0000 }, + { 0x0f21, 0x0000 }, + { 0x0f22, 0x0000 }, + { 0x0f23, 0x0000 }, + { 0x0f24, 0x0000 }, + { 0x0f25, 0x0000 }, + { 0x0f26, 0x0000 }, + { 0x0f27, 0x0000 }, + { 0x0f30, 0x0000 }, + { 0x0f31, 0x0000 }, + { 0x0f32, 0x0000 }, + { 0x0f33, 0x0000 }, + { 0x0f34, 0x0000 }, + { 0x0f35, 0x0000 }, + { 0x0f36, 0x0000 }, + { 0x0f37, 0x0000 }, + { 0x2000, 0x0000 }, + { 0x2001, 0x0000 }, + { 0x2002, 0x0000 }, + { 0x2003, 0x0000 }, + { 0x2004, 0x0000 }, + { 0x2005, 0x0000 }, + { 0x2006, 0x0000 }, + { 0x2007, 0x0000 }, + { 0x2008, 0x0000 }, + { 0x2009, 0x0003 }, + { 0x200a, 0x0003 }, + { 0x200b, 0x0000 }, + { 0x200c, 0x0000 }, + { 0x200d, 0x0000 }, + { 0x200e, 0x0000 }, + { 0x2012, 0x0000 }, + { 0x2013, 0x0000 }, + { 0x2014, 0x0000 }, + { 0x2015, 0x0000 }, + { 0x2016, 0x0000 }, + { 0x201a, 0x0000 }, + { 0x201b, 0x0000 }, + { 0x201c, 0x0000 }, + { 0x201d, 0x0000 }, + { 0x201e, 0x0000 }, + { 0x201f, 0x0000 }, + { 0x2020, 0x0000 }, + { 0x2021, 0x0000 }, + { 0x2022, 0x0000 }, + { 0x2023, 0x0000 }, + { 0x2024, 0x0000 }, + { 0x2025, 0x0002 }, + { 0x2026, 0x0000 }, + { 0x2027, 0x0000 }, + { 0x2029, 0x0000 }, + { 0x202a, 0x0000 }, + { 0x202d, 0x0000 }, + { 0x202e, 0x0000 }, + { 0x202f, 0x0000 }, + { 0x2030, 0x0000 }, + { 0x2031, 0x0000 }, + { 0x2032, 0x0000 }, + { 0x2033, 0x0000 }, + { 0x2034, 0x0000 }, + { 0x2200, 0x0000 }, + { 0x2201, 0x0000 }, + { 0x2202, 0x0000 }, + { 0x2203, 0x0000 }, + { 0x2204, 0x0000 }, + { 0x2206, 0x0000 }, + { 0x2207, 0x0000 }, + { 0x2208, 0x0000 }, + { 0x2209, 0x0000 }, + { 0x220a, 0x0000 }, + { 0x220b, 0x0000 }, + { 0x220c, 0x0000 }, + { 0x220d, 0x0000 }, + { 0x220e, 0x0000 }, + { 0x220f, 0x0000 }, + { 0x2211, 0x0000 }, + { 0x2212, 0x0000 }, + { 0x2220, 0x0000 }, + { 0x2221, 0x0000 }, + { 0x2222, 0x0000 }, + { 0x2223, 0x0000 }, + { 0x2230, 0x0000 }, + { 0x2231, 0x0000 }, + { 0x3121, 0x0001 }, + { 0x3122, 0x0000 }, + { 0x3123, 0x0000 }, + { 0x7303, 0x0057 }, + { 0x7303, 0x0057 }, + { 0x8383, 0x0057 }, + { 0x7308, 0x0097 }, + { 0x8388, 0x0097 }, + { 0x7309, 0x0097 }, + { 0x8389, 0x0097 }, + { 0x7312, 0x0000 }, + { 0x8392, 0x0000 }, + { 0x7313, 0x0000 }, + { 0x8393, 0x0000 }, + { 0x7319, 0x0000 }, + { 0x8399, 0x0000 }, + { 0x75201a, 0x8003 }, + { 0x752045, 0x5289 }, + { 0x752048, 0xd049 }, + { 0x75204a, 0xa83b }, + { 0x75206b, 0x5064 }, +}; + +#endif /* __RT700_H__ */ diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c new file mode 100644 index 000000000000..b1830c1ebf8a --- /dev/null +++ b/sound/soc/codecs/rt700.c @@ -0,0 +1,1238 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt700.c -- rt700 ALSA SoC audio driver +// +// Copyright(c) 2019 Realtek Semiconductor Corp. +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rt700.h" + +static int rt700_index_write(struct regmap *regmap, + unsigned int reg, unsigned int value) +{ + int ret; + unsigned int addr = (RT700_PRIV_INDEX_W_H << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) + pr_err("Failed to set private value: %06x <= %04x ret=%d\n", + addr, value, ret); + + return ret; +} + +static int rt700_index_read(struct regmap *regmap, + unsigned int reg, unsigned int *value) +{ + int ret; + unsigned int addr = (RT700_PRIV_INDEX_W_H << 8) | reg; + + *value = 0; + ret = regmap_read(regmap, addr, value); + if (ret < 0) + pr_err("Failed to get private value: %06x => %04x ret=%d\n", + addr, *value, ret); + + return ret; +} + +static unsigned int rt700_button_detect(struct rt700_priv *rt700) +{ + unsigned int btn_type = 0, val80, val81; + int ret; + + ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE1, &val80); + if (ret < 0) + goto read_error; + ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE2, &val81); + if (ret < 0) + goto read_error; + + val80 &= 0x0381; + val81 &= 0xff00; + + switch (val80) { + case 0x0200: + case 0x0100: + case 0x0080: + btn_type |= SND_JACK_BTN_0; + break; + case 0x0001: + btn_type |= SND_JACK_BTN_3; + break; + } + switch (val81) { + case 0x8000: + case 0x4000: + case 0x2000: + btn_type |= SND_JACK_BTN_1; + break; + case 0x1000: + case 0x0800: + case 0x0400: + btn_type |= SND_JACK_BTN_2; + break; + case 0x0200: + case 0x0100: + btn_type |= SND_JACK_BTN_3; + break; + } +read_error: + return btn_type; +} + +static int rt700_headset_detect(struct rt700_priv *rt700) +{ + unsigned int buf, loop = 0; + int ret; + unsigned int jack_status = 0, reg; + + ret = rt700_index_read(rt700->regmap, + RT700_COMBO_JACK_AUTO_CTL2, &buf); + if (ret < 0) + goto io_error; + + while (loop < 500 && + (buf & RT700_COMBOJACK_AUTO_DET_STATUS) == 0) { + loop++; + + usleep_range(9000, 10000); + ret = rt700_index_read(rt700->regmap, + RT700_COMBO_JACK_AUTO_CTL2, &buf); + if (ret < 0) + goto io_error; + + reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if ((jack_status & (1 << 31)) == 0) + goto remove_error; + } + + if (loop >= 500) + goto to_error; + + if (buf & RT700_COMBOJACK_AUTO_DET_TRS) + rt700->jack_type = SND_JACK_HEADPHONE; + else if ((buf & RT700_COMBOJACK_AUTO_DET_CTIA) || + (buf & RT700_COMBOJACK_AUTO_DET_OMTP)) + rt700->jack_type = SND_JACK_HEADSET; + + return 0; + +to_error: + ret = -ETIMEDOUT; + pr_err_ratelimited("Time-out error in %s\n", __func__); + return ret; +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); + return ret; +remove_error: + pr_err_ratelimited("Jack removal in %s\n", __func__); + return -ENODEV; +} + +static void rt700_jack_detect_handler(struct work_struct *work) +{ + struct rt700_priv *rt700 = + container_of(work, struct rt700_priv, jack_detect_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + if (!rt700->hs_jack) + return; + + if (!rt700->component->card->instantiated) + return; + + reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + /* jack in */ + if (rt700->jack_type == 0) { + ret = rt700_headset_detect(rt700); + if (ret < 0) + return; + if (rt700->jack_type == SND_JACK_HEADSET) + btn_type = rt700_button_detect(rt700); + } else if (rt700->jack_type == SND_JACK_HEADSET) { + /* jack is already in, report button event */ + btn_type = rt700_button_detect(rt700); + } + } else { + /* jack out */ + rt700->jack_type = 0; + } + + dev_dbg(&rt700->slave->dev, + "in %s, jack_type=0x%x\n", __func__, rt700->jack_type); + dev_dbg(&rt700->slave->dev, + "in %s, btn_type=0x%x\n", __func__, btn_type); + + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); +} + +static void rt700_btn_check_handler(struct work_struct *work) +{ + struct rt700_priv *rt700 = container_of(work, struct rt700_priv, + jack_btn_check_work.work); + int btn_type = 0, ret; + unsigned int jack_status = 0, reg; + + reg = RT700_VERB_GET_PIN_SENSE | RT700_HP_OUT; + ret = regmap_read(rt700->regmap, reg, &jack_status); + if (ret < 0) + goto io_error; + + /* pin attached */ + if (jack_status & (1 << 31)) { + if (rt700->jack_type == SND_JACK_HEADSET) { + /* jack is already in, report button event */ + btn_type = rt700_button_detect(rt700); + } + } else { + rt700->jack_type = 0; + } + + /* cbj comparator */ + ret = rt700_index_read(rt700->regmap, RT700_COMBO_JACK_AUTO_CTL2, ®); + if (ret < 0) + goto io_error; + + if ((reg & 0xf0) == 0xf0) + btn_type = 0; + + dev_dbg(&rt700->slave->dev, + "%s, btn_type=0x%x\n", __func__, btn_type); + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + if (btn_type) { + /* button released */ + snd_soc_jack_report(rt700->hs_jack, rt700->jack_type, + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_btn_check_work, msecs_to_jiffies(200)); + } + + return; + +io_error: + pr_err_ratelimited("IO error in %s, ret %d\n", __func__, ret); +} + +static void rt700_jack_init(struct rt700_priv *rt700) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(rt700->component); + + /* power on */ + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + if (rt700->hs_jack) { + /* Enable Jack Detection */ + regmap_write(rt700->regmap, + RT700_SET_MIC2_UNSOLICITED_ENABLE, 0x82); + regmap_write(rt700->regmap, + RT700_SET_HP_UNSOLICITED_ENABLE, 0x81); + regmap_write(rt700->regmap, + RT700_SET_INLINE_UNSOLICITED_ENABLE, 0x83); + rt700_index_write(rt700->regmap, 0x10, 0x2420); + rt700_index_write(rt700->regmap, 0x19, 0x2e11); + + dev_dbg(&rt700->slave->dev, "in %s enable\n", __func__); + + mod_delayed_work(system_power_efficient_wq, + &rt700->jack_detect_work, msecs_to_jiffies(250)); + } else { + regmap_write(rt700->regmap, + RT700_SET_MIC2_UNSOLICITED_ENABLE, 0x00); + regmap_write(rt700->regmap, + RT700_SET_HP_UNSOLICITED_ENABLE, 0x00); + regmap_write(rt700->regmap, + RT700_SET_INLINE_UNSOLICITED_ENABLE, 0x00); + + dev_dbg(&rt700->slave->dev, "in %s disable\n", __func__); + } + + /* power off */ + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); +} + +static int rt700_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hs_jack, void *data) +{ + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + rt700->hs_jack = hs_jack; + + if (!rt700->hw_init) { + dev_dbg(&rt700->slave->dev, + "%s hw_init not ready yet\n", __func__); + return 0; + } + + rt700_jack_init(rt700); + + return 0; +} + +static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + /* R Channel */ + *r_val = (val_h << 8); + regmap_read(rt700->regmap, addr_l, r_val); + + /* L Channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + regmap_read(rt700->regmap, addr_h, l_val); +} + +/* For Verb-Set Amplifier Gain (Verb ID = 3h) */ +static int rt700_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* Can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT700_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* L Channel */ + if (mc->invert) { + /* for mute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) << 7; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & 0x80; + val_ll |= read_ll; + } + + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + + /* R Channel */ + if (mc->invert) { + /* for mute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) << 7; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & 0x80; + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + if (val_ll == val_lr) { + /* Set both L/R channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt700->regmap, + addr_h, (val_h << 8 | val_ll)); + regmap_write(rt700->regmap, + addr_l, (val_h << 8 | val_ll)); + } else { + /* Lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt700->regmap, + addr_h, (val_h << 8 | val_ll)); + + /* Rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt700->regmap, + addr_l, (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == RT700_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + return 0; +} + +static int rt700_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT700_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* for mute status */ + read_ll = !((read_ll & 0x80) >> RT700_MUTE_SFT); + read_rl = !((read_rl & 0x80) >> RT700_MUTE_SFT); + } else { + /* for gain */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); +static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); +static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); + +static const struct snd_kcontrol_new rt700_snd_controls[] = { + SOC_DOUBLE_R_EXT_TLV("DAC Front Playback Volume", + RT700_SET_GAIN_DAC1_H, RT700_SET_GAIN_DAC1_L, + RT700_DIR_OUT_SFT, 0x57, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, out_vol_tlv), + SOC_DOUBLE_R_EXT("ADC 08 Capture Switch", + RT700_SET_GAIN_ADC2_H, RT700_SET_GAIN_ADC2_L, + RT700_DIR_IN_SFT, 1, 1, + rt700_set_amp_gain_get, rt700_set_amp_gain_put), + SOC_DOUBLE_R_EXT("ADC 09 Capture Switch", + RT700_SET_GAIN_ADC1_H, RT700_SET_GAIN_ADC1_L, + RT700_DIR_IN_SFT, 1, 1, + rt700_set_amp_gain_get, rt700_set_amp_gain_put), + SOC_DOUBLE_R_EXT_TLV("ADC 08 Capture Volume", + RT700_SET_GAIN_ADC2_H, RT700_SET_GAIN_ADC2_L, + RT700_DIR_IN_SFT, 0x3f, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("ADC 09 Capture Volume", + RT700_SET_GAIN_ADC1_H, RT700_SET_GAIN_ADC1_L, + RT700_DIR_IN_SFT, 0x3f, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("AMIC Volume", + RT700_SET_GAIN_AMIC_H, RT700_SET_GAIN_AMIC_L, + RT700_DIR_IN_SFT, 3, 0, + rt700_set_amp_gain_get, rt700_set_amp_gain_put, mic_vol_tlv), +}; + +static int rt700_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int reg, val = 0, nid; + int ret; + + if (strstr(ucontrol->id.name, "HPO Mux")) + nid = RT700_HP_OUT; + else if (strstr(ucontrol->id.name, "ADC 22 Mux")) + nid = RT700_MIXER_IN1; + else if (strstr(ucontrol->id.name, "ADC 23 Mux")) + nid = RT700_MIXER_IN2; + else + return -EINVAL; + + /* vid = 0xf01 */ + reg = RT700_VERB_SET_CONNECT_SEL | nid; + ret = regmap_read(rt700->regmap, reg, &val); + if (ret < 0) + return ret; + + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt700_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg, nid; + int ret; + + if (item[0] >= e->items) + return -EINVAL; + + if (strstr(ucontrol->id.name, "HPO Mux")) + nid = RT700_HP_OUT; + else if (strstr(ucontrol->id.name, "ADC 22 Mux")) + nid = RT700_MIXER_IN1; + else if (strstr(ucontrol->id.name, "ADC 23 Mux")) + nid = RT700_MIXER_IN2; + else + return -EINVAL; + + /* Verb ID = 0x701h */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = RT700_VERB_SET_CONNECT_SEL | nid; + ret = regmap_read(rt700->regmap, reg, &val2); + if (ret < 0) + return ret; + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = RT700_VERB_SET_CONNECT_SEL | nid; + regmap_write(rt700->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, NULL); + + return change; +} + +static const char * const adc_mux_text[] = { + "MIC2", + "LINE1", + "LINE2", + "DMIC", +}; + +static SOC_ENUM_SINGLE_DECL( + rt700_adc22_enum, SND_SOC_NOPM, 0, adc_mux_text); + +static SOC_ENUM_SINGLE_DECL( + rt700_adc23_enum, SND_SOC_NOPM, 0, adc_mux_text); + +static const struct snd_kcontrol_new rt700_adc22_mux = + SOC_DAPM_ENUM_EXT("ADC 22 Mux", rt700_adc22_enum, + rt700_mux_get, rt700_mux_put); + +static const struct snd_kcontrol_new rt700_adc23_mux = + SOC_DAPM_ENUM_EXT("ADC 23 Mux", rt700_adc23_enum, + rt700_mux_get, rt700_mux_put); + +static const char * const out_mux_text[] = { + "Front", + "Surround", +}; + +static SOC_ENUM_SINGLE_DECL( + rt700_hp_enum, SND_SOC_NOPM, 0, out_mux_text); + +static const struct snd_kcontrol_new rt700_hp_mux = + SOC_DAPM_ENUM_EXT("HP Mux", rt700_hp_enum, + rt700_mux_get, rt700_mux_put); + +static int rt700_dac_front_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_DAC1, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_DAC1, 0x00); + break; + } + return 0; +} + +static int rt700_dac_surround_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_DAC2, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_DAC2, 0x00); + break; + } + return 0; +} + +static int rt700_adc_09_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_ADC1, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_ADC1, 0x00); + break; + } + return 0; +} + +static int rt700_adc_08_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_ADC2, 0x10); + break; + case SND_SOC_DAPM_PRE_PMD: + regmap_write(rt700->regmap, + RT700_SET_STREAMID_ADC2, 0x00); + break; + } + return 0; +} + +static int rt700_hpo_mux_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << RT700_DIR_OUT_SFT) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + val_l = 0x00; + regmap_write(rt700->regmap, + RT700_SET_GAIN_HP_H, (val_h << 8 | val_l)); + break; + case SND_SOC_DAPM_PRE_PMD: + val_l = (1 << RT700_MUTE_SFT); + regmap_write(rt700->regmap, + RT700_SET_GAIN_HP_H, (val_h << 8 | val_l)); + usleep_range(50000, 55000); + break; + } + return 0; +} + +static int rt700_spk_pga_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + unsigned int val_h = (1 << RT700_DIR_OUT_SFT) | (0x3 << 4); + unsigned int val_l; + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + val_l = 0x00; + regmap_write(rt700->regmap, + RT700_SET_GAIN_SPK_H, (val_h << 8 | val_l)); + break; + case SND_SOC_DAPM_PRE_PMD: + val_l = (1 << RT700_MUTE_SFT); + regmap_write(rt700->regmap, + RT700_SET_GAIN_SPK_H, (val_h << 8 | val_l)); + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt700_dapm_widgets[] = { + SND_SOC_DAPM_OUTPUT("HP"), + SND_SOC_DAPM_OUTPUT("SPK"), + SND_SOC_DAPM_INPUT("DMIC1"), + SND_SOC_DAPM_INPUT("DMIC2"), + SND_SOC_DAPM_INPUT("MIC2"), + SND_SOC_DAPM_INPUT("LINE1"), + SND_SOC_DAPM_INPUT("LINE2"), + SND_SOC_DAPM_DAC_E("DAC Front", NULL, SND_SOC_NOPM, 0, 0, + rt700_dac_front_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_DAC_E("DAC Surround", NULL, SND_SOC_NOPM, 0, 0, + rt700_dac_surround_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_MUX_E("HPO Mux", SND_SOC_NOPM, 0, 0, &rt700_hp_mux, + rt700_hpo_mux_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_PGA_E("SPK PGA", SND_SOC_NOPM, 0, 0, NULL, 0, + rt700_spk_pga_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_ADC_E("ADC 09", NULL, SND_SOC_NOPM, 0, 0, + rt700_adc_09_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_ADC_E("ADC 08", NULL, SND_SOC_NOPM, 0, 0, + rt700_adc_08_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_MUX("ADC 22 Mux", SND_SOC_NOPM, 0, 0, + &rt700_adc22_mux), + SND_SOC_DAPM_MUX("ADC 23 Mux", SND_SOC_NOPM, 0, 0, + &rt700_adc23_mux), + SND_SOC_DAPM_AIF_IN("DP1RX", "DP1 Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("DP3RX", "DP3 Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("DP2TX", "DP2 Capture", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("DP4TX", "DP4 Capture", 0, SND_SOC_NOPM, 0, 0), +}; + +static const struct snd_soc_dapm_route rt700_audio_map[] = { + {"DAC Front", NULL, "DP1RX"}, + {"DAC Surround", NULL, "DP3RX"}, + {"DP2TX", NULL, "ADC 09"}, + {"DP4TX", NULL, "ADC 08"}, + {"ADC 09", NULL, "ADC 22 Mux"}, + {"ADC 08", NULL, "ADC 23 Mux"}, + {"ADC 22 Mux", "DMIC", "DMIC1"}, + {"ADC 22 Mux", "LINE1", "LINE1"}, + {"ADC 22 Mux", "LINE2", "LINE2"}, + {"ADC 22 Mux", "MIC2", "MIC2"}, + {"ADC 23 Mux", "DMIC", "DMIC2"}, + {"ADC 23 Mux", "LINE1", "LINE1"}, + {"ADC 23 Mux", "LINE2", "LINE2"}, + {"ADC 23 Mux", "MIC2", "MIC2"}, + {"HPO Mux", "Front", "DAC Front"}, + {"HPO Mux", "Surround", "DAC Surround"}, + {"HP", NULL, "HPO Mux"}, + {"SPK PGA", NULL, "DAC Front"}, + {"SPK", NULL, "SPK PGA"}, +}; + +static int rt700_probe(struct snd_soc_component *component) +{ + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + rt700->component = component; + + return 0; +} + +static int rt700_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + + switch (level) { + case SND_SOC_BIAS_PREPARE: + if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, + AC_PWRST_D0); + } + break; + + case SND_SOC_BIAS_STANDBY: + regmap_write(rt700->regmap, + RT700_SET_AUDIO_POWER_STATE, + AC_PWRST_D3); + break; + + default: + break; + } + dapm->bias_level = level; + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt700 = { + .probe = rt700_probe, + .set_bias_level = rt700_set_bias_level, + .controls = rt700_snd_controls, + .num_controls = ARRAY_SIZE(rt700_snd_controls), + .dapm_widgets = rt700_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt700_dapm_widgets), + .dapm_routes = rt700_audio_map, + .num_dapm_routes = ARRAY_SIZE(rt700_audio_map), + .set_jack = rt700_set_jack_detect, +}; + +static int rt700_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* Use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt700_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(stream); +} + +static int rt700_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -EINVAL; + + if (!rt700->slave) + return -EINVAL; + + /* SoundWire specific configuration */ + /* This code assumes port 1 for playback and port 2 for capture */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + direction = SDW_DATA_DIR_RX; + port = 1; + } else { + direction = SDW_DATA_DIR_TX; + port = 2; + } + + switch (dai->id) { + case RT700_AIF1: + break; + case RT700_AIF2: + port += 2; + break; + default: + dev_err(component->dev, "Invalid DAI id %d\n", dai->id); + return -EINVAL; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt700->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "Unable to configure port\n"); + return retval; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 Number of Channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "Unsupported channels %d\n", + params_channels(params)); + return -EINVAL; + } + + switch (params_width(params)) { + /* bit 6:4 Bits per Sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -EINVAL; + } + + /* 48Khz */ + regmap_write(rt700->regmap, RT700_DAC_FORMAT_H, val); + regmap_write(rt700->regmap, RT700_ADC_FORMAT_H, val); + + return retval; +} + +static int rt700_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt700->slave) + return -EINVAL; + + sdw_stream_remove_slave(rt700->slave, stream->sdw_stream); + return 0; +} + +#define RT700_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +#define RT700_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) + +static struct snd_soc_dai_ops rt700_ops = { + .hw_params = rt700_pcm_hw_params, + .hw_free = rt700_pcm_hw_free, + .set_sdw_stream = rt700_set_sdw_stream, + .shutdown = rt700_shutdown, +}; + +static struct snd_soc_dai_driver rt700_dai[] = { + { + .name = "rt700-aif1", + .id = RT700_AIF1, + .playback = { + .stream_name = "DP1 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = RT700_STEREO_RATES, + .formats = RT700_FORMATS, + }, + .capture = { + .stream_name = "DP2 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT700_STEREO_RATES, + .formats = RT700_FORMATS, + }, + .ops = &rt700_ops, + }, + { + .name = "rt700-aif2", + .id = RT700_AIF2, + .playback = { + .stream_name = "DP3 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = RT700_STEREO_RATES, + .formats = RT700_FORMATS, + }, + .capture = { + .stream_name = "DP4 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT700_STEREO_RATES, + .formats = RT700_FORMATS, + }, + .ops = &rt700_ops, + }, +}; + +/* Bus clock frequency */ +#define RT700_CLK_FREQ_9600000HZ 9600000 +#define RT700_CLK_FREQ_12000000HZ 12000000 +#define RT700_CLK_FREQ_6000000HZ 6000000 +#define RT700_CLK_FREQ_4800000HZ 4800000 +#define RT700_CLK_FREQ_2400000HZ 2400000 +#define RT700_CLK_FREQ_12288000HZ 12288000 + +int rt700_clock_config(struct device *dev) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt700->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case RT700_CLK_FREQ_12000000HZ: + value = 0x0; + break; + case RT700_CLK_FREQ_6000000HZ: + value = 0x1; + break; + case RT700_CLK_FREQ_9600000HZ: + value = 0x2; + break; + case RT700_CLK_FREQ_4800000HZ: + value = 0x3; + break; + case RT700_CLK_FREQ_2400000HZ: + value = 0x4; + break; + case RT700_CLK_FREQ_12288000HZ: + value = 0x5; + break; + default: + return -EINVAL; + } + + regmap_write(rt700->regmap, 0xe0, value); + regmap_write(rt700->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d\n", __func__, clk_freq); + + return 0; +} + +int rt700_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) + +{ + struct rt700_priv *rt700; + int ret; + + rt700 = devm_kzalloc(dev, sizeof(*rt700), GFP_KERNEL); + if (!rt700) + return -ENOMEM; + + dev_set_drvdata(dev, rt700); + rt700->slave = slave; + rt700->sdw_regmap = sdw_regmap; + rt700->regmap = regmap; + + /* + * Mark hw_init to false + * HW init will be performed when device reports present + */ + rt700->hw_init = false; + rt700->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt700, + rt700_dai, + ARRAY_SIZE(rt700_dai)); + + dev_dbg(&slave->dev, "%s\n", __func__); + + return ret; +} + +int rt700_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt700_priv *rt700 = dev_get_drvdata(dev); + + if (rt700->hw_init) + return 0; + + if (rt700->first_hw_init) { + regcache_cache_only(rt700->regmap, false); + regcache_cache_bypass(rt700->regmap, true); + } + + /* + * PM runtime is only enabled when a Slave reports as Attached + */ + if (!rt700->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* reset */ + regmap_write(rt700->regmap, 0xff01, 0x0000); + regmap_write(rt700->regmap, 0x7520, 0x001a); + regmap_write(rt700->regmap, 0x7420, 0xc003); + + /* power on */ + regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + /* Set Pin Widget */ + regmap_write(rt700->regmap, RT700_SET_PIN_HP, 0x40); + regmap_write(rt700->regmap, RT700_SET_PIN_SPK, 0x40); + regmap_write(rt700->regmap, RT700_SET_EAPD_SPK, RT700_EAPD_HIGH); + regmap_write(rt700->regmap, RT700_SET_PIN_DMIC1, 0x20); + regmap_write(rt700->regmap, RT700_SET_PIN_DMIC2, 0x20); + regmap_write(rt700->regmap, RT700_SET_PIN_MIC2, 0x20); + + /* Set Configuration Default */ + regmap_write(rt700->regmap, 0x4f12, 0x91); + regmap_write(rt700->regmap, 0x4e12, 0xd6); + regmap_write(rt700->regmap, 0x4d12, 0x11); + regmap_write(rt700->regmap, 0x4c12, 0x20); + regmap_write(rt700->regmap, 0x4f13, 0x91); + regmap_write(rt700->regmap, 0x4e13, 0xd6); + regmap_write(rt700->regmap, 0x4d13, 0x11); + regmap_write(rt700->regmap, 0x4c13, 0x21); + + regmap_write(rt700->regmap, 0x4f19, 0x02); + regmap_write(rt700->regmap, 0x4e19, 0xa1); + regmap_write(rt700->regmap, 0x4d19, 0x90); + regmap_write(rt700->regmap, 0x4c19, 0x80); + + /* Enable Line2 */ + regmap_write(rt700->regmap, 0x371b, 0x40); + regmap_write(rt700->regmap, 0x731b, 0xb0); + regmap_write(rt700->regmap, 0x839b, 0x00); + + /* Set index */ + rt700_index_write(rt700->regmap, 0x4a, 0x201b); + rt700_index_write(rt700->regmap, 0x45, 0x5089); + rt700_index_write(rt700->regmap, 0x6b, 0x5064); + rt700_index_write(rt700->regmap, 0x48, 0xd249); + + /* Finish Initial Settings, set power to D3 */ + regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + + if (!rt700->first_hw_init) { + INIT_DELAYED_WORK(&rt700->jack_detect_work, + rt700_jack_detect_handler); + INIT_DELAYED_WORK(&rt700->jack_btn_check_work, + rt700_btn_check_handler); + } + + /* + * if set_jack callback occurred early than io_init, + * we set up the jack detection function now + */ + if (rt700->hs_jack) + rt700_jack_init(rt700); + + if (rt700->first_hw_init) { + regcache_cache_bypass(rt700->regmap, false); + regcache_mark_dirty(rt700->regmap); + } else + rt700->first_hw_init = true; + + /* Mark Slave initialization complete */ + rt700->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); + + return 0; +} + +MODULE_DESCRIPTION("ASoC RT700 driver SDW"); +MODULE_AUTHOR("Shuming Fan "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt700.h b/sound/soc/codecs/rt700.h new file mode 100644 index 000000000000..794ee2e29051 --- /dev/null +++ b/sound/soc/codecs/rt700.h @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt700.h -- RT700 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT700_H__ +#define __RT700_H__ + +extern const struct dev_pm_ops rt700_runtime_pm; + +struct rt700_priv { + struct snd_soc_component *component; + struct regmap *regmap; + struct regmap *sdw_regmap; + struct sdw_slave *slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; + struct snd_soc_jack *hs_jack; + struct delayed_work jack_detect_work; + struct delayed_work jack_btn_check_work; + int jack_type; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* NID */ +#define RT700_AUDIO_FUNCTION_GROUP 0x01 +#define RT700_DAC_OUT1 0x02 +#define RT700_DAC_OUT2 0x03 +#define RT700_ADC_IN1 0x09 +#define RT700_ADC_IN2 0x08 +#define RT700_DMIC1 0x12 +#define RT700_DMIC2 0x13 +#define RT700_SPK_OUT 0x14 +#define RT700_MIC2 0x19 +#define RT700_LINE1 0x1a +#define RT700_LINE2 0x1b +#define RT700_BEEP 0x1d +#define RT700_SPDIF 0x1e +#define RT700_VENDOR_REGISTERS 0x20 +#define RT700_HP_OUT 0x21 +#define RT700_MIXER_IN1 0x22 +#define RT700_MIXER_IN2 0x23 +#define RT700_INLINE_CMD 0x55 + +/* Index (NID:20h) */ +#define RT700_DAC_DC_CALI_CTL1 0x00 +#define RT700_PARA_VERB_CTL 0x1a +#define RT700_COMBO_JACK_AUTO_CTL1 0x45 +#define RT700_COMBO_JACK_AUTO_CTL2 0x46 +#define RT700_INLINE_CMD_CTL 0x48 +#define RT700_DIGITAL_MISC_CTRL4 0x4a +#define RT700_VREFOUT_CTL 0x6b +#define RT700_FSM_CTL 0x6f +#define RT700_IRQ_FLAG_TABLE1 0x80 +#define RT700_IRQ_FLAG_TABLE2 0x81 +#define RT700_IRQ_FLAG_TABLE3 0x82 + +/* Verb */ +#define RT700_VERB_SET_CONNECT_SEL 0x3100 +#define RT700_VERB_SET_EAPD_BTLENABLE 0x3c00 +#define RT700_VERB_GET_CONNECT_SEL 0xb100 +#define RT700_VERB_SET_POWER_STATE 0x3500 +#define RT700_VERB_SET_CHANNEL_STREAMID 0x3600 +#define RT700_VERB_SET_PIN_WIDGET_CONTROL 0x3700 +#define RT700_VERB_SET_UNSOLICITED_ENABLE 0x3800 +#define RT700_SET_AMP_GAIN_MUTE_H 0x7300 +#define RT700_SET_AMP_GAIN_MUTE_L 0x8380 +#define RT700_VERB_GET_PIN_SENSE 0xb900 + +#define RT700_READ_HDA_3 0x2012 +#define RT700_READ_HDA_2 0x2013 +#define RT700_READ_HDA_1 0x2014 +#define RT700_READ_HDA_0 0x2015 +#define RT700_PRIV_INDEX_W_H 0x7520 +#define RT700_PRIV_INDEX_W_L 0x85a0 +#define RT700_PRIV_DATA_W_H 0x7420 +#define RT700_PRIV_DATA_W_L 0x84a0 +#define RT700_PRIV_INDEX_R_H 0x9d20 +#define RT700_PRIV_INDEX_R_L 0xada0 +#define RT700_PRIV_DATA_R_H 0x9c20 +#define RT700_PRIV_DATA_R_L 0xaca0 +#define RT700_DAC_FORMAT_H 0x7203 +#define RT700_DAC_FORMAT_L 0x8283 +#define RT700_ADC_FORMAT_H 0x7209 +#define RT700_ADC_FORMAT_L 0x8289 +#define RT700_SET_AUDIO_POWER_STATE\ + (RT700_VERB_SET_POWER_STATE | RT700_AUDIO_FUNCTION_GROUP) +#define RT700_SET_PIN_DMIC1\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC1) +#define RT700_SET_PIN_DMIC2\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC2) +#define RT700_SET_PIN_SPK\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_SPK_OUT) +#define RT700_SET_PIN_HP\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_HP_OUT) +#define RT700_SET_PIN_MIC2\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_MIC2) +#define RT700_SET_PIN_LINE1\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE1) +#define RT700_SET_PIN_LINE2\ + (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE2) +#define RT700_SET_MIC2_UNSOLICITED_ENABLE\ + (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_MIC2) +#define RT700_SET_HP_UNSOLICITED_ENABLE\ + (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_HP_OUT) +#define RT700_SET_INLINE_UNSOLICITED_ENABLE\ + (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_INLINE_CMD) +#define RT700_SET_STREAMID_DAC1\ + (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT1) +#define RT700_SET_STREAMID_DAC2\ + (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT2) +#define RT700_SET_STREAMID_ADC1\ + (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN1) +#define RT700_SET_STREAMID_ADC2\ + (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN2) +#define RT700_SET_GAIN_DAC1_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_DAC_OUT1) +#define RT700_SET_GAIN_DAC1_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_DAC_OUT1) +#define RT700_SET_GAIN_ADC1_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN1) +#define RT700_SET_GAIN_ADC1_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN1) +#define RT700_SET_GAIN_ADC2_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN2) +#define RT700_SET_GAIN_ADC2_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN2) +#define RT700_SET_GAIN_AMIC_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_MIC2) +#define RT700_SET_GAIN_AMIC_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_MIC2) +#define RT700_SET_GAIN_HP_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_HP_OUT) +#define RT700_SET_GAIN_HP_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_HP_OUT) +#define RT700_SET_GAIN_SPK_L\ + (RT700_SET_AMP_GAIN_MUTE_L | RT700_SPK_OUT) +#define RT700_SET_GAIN_SPK_H\ + (RT700_SET_AMP_GAIN_MUTE_H | RT700_SPK_OUT) +#define RT700_SET_EAPD_SPK\ + (RT700_VERB_SET_EAPD_BTLENABLE | RT700_SPK_OUT) + +/* combo jack auto switch control 2 (0x46)(NID:20h) */ +#define RT700_COMBOJACK_AUTO_DET_STATUS (0x1 << 11) +#define RT700_COMBOJACK_AUTO_DET_TRS (0x1 << 10) +#define RT700_COMBOJACK_AUTO_DET_CTIA (0x1 << 9) +#define RT700_COMBOJACK_AUTO_DET_OMTP (0x1 << 8) + +#define RT700_EAPD_HIGH 0x2 +#define RT700_EAPD_LOW 0x0 +#define RT700_MUTE_SFT 7 +#define RT700_DIR_IN_SFT 6 +#define RT700_DIR_OUT_SFT 7 + +enum { + RT700_AIF1, + RT700_AIF2, + RT700_AIFS, +}; + +int rt700_io_init(struct device *dev, struct sdw_slave *slave); +int rt700_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int rt700_jack_detect(struct rt700_priv *rt700, bool *hp, bool *mic); +int rt700_clock_config(struct device *dev); +#endif /* __RT700_H__ */ -- cgit v1.2.3 From 12b052327dc2d9d4ca5146608aad1c42741df4fb Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:35:54 +0900 Subject: ASoC: soc-core: rename snd_soc_rtdcom_add() to snd_soc_rtd_add_component() We don't have snd_soc_rtdcom_list anymore. Let's rename snd_soc_rtdcom_add() to more understandable snd_soc_rtd_add_component() Reported-by: Sridharan, Ranjani Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/878smgt4vp.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c9daa63a339b..9a6d905cda43 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -258,8 +258,8 @@ static inline void snd_soc_debugfs_exit(void) #endif -static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, - struct snd_soc_component *component) +static int snd_soc_rtd_add_component(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_component *component) { struct snd_soc_component *comp; int i; @@ -1035,7 +1035,7 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, dai_link->cpus->dai_name); goto _err_defer; } - snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); + snd_soc_rtd_add_component(rtd, rtd->cpu_dai->component); /* Find CODEC from registered CODECs */ rtd->num_codecs = dai_link->num_codecs; @@ -1047,7 +1047,7 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, goto _err_defer; } - snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); + snd_soc_rtd_add_component(rtd, rtd->codec_dais[i]->component); } /* Single codec links expect codec and codec_dai in runtime data */ @@ -1059,7 +1059,7 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card, if (!snd_soc_is_matching_component(platform, component)) continue; - snd_soc_rtdcom_add(rtd, component); + snd_soc_rtd_add_component(rtd, component); } } -- cgit v1.2.3 From 1272063a7ee4e60ace4cf7cae621fb6f8cafaaba Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:02 +0900 Subject: ASoC: soc-core: care .ignore_suspend for Component suspend Card dai_link has .ignore_suspend, and ALSA SoC cares it when suspend. For example, like this for_each_card_rtds(card, rtd) { if (rtd->dai_link->ignore_suspend) continue; ... } But in snd_soc_suspend(), it doesn't care about it when suspending Component. This patch cares it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/877e20t4vh.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9a6d905cda43..8a1b4ffa6ca6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -562,15 +562,25 @@ int snd_soc_suspend(struct device *dev) snd_soc_dapm_sync(&card->dapm); /* suspend all COMPONENTs */ - for_each_card_components(card, component) { - struct snd_soc_dapm_context *dapm = + for_each_card_rtds(card, rtd) { + + if (rtd->dai_link->ignore_suspend) + continue; + + for_each_rtd_components(rtd, i, component) { + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - /* - * If there are paths active then the COMPONENT will be held - * with bias _ON and should not be suspended. - */ - if (!snd_soc_component_is_suspended(component)) { + /* + * ignore if component was already suspended + */ + if (snd_soc_component_is_suspended(component)) + continue; + + /* + * If there are paths active then the COMPONENT will be + * held with bias _ON and should not be suspended. + */ switch (snd_soc_dapm_get_bias_level(dapm)) { case SND_SOC_BIAS_STANDBY: /* -- cgit v1.2.3 From d7a8cb4931652256a01383bb3ea10fab316e72a1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:07 +0900 Subject: ASoC: soc-core: remove duplicate pinctrl operation when suspend snd_soc_suspend() are doing below for pinctrl_pm_select_sleep_state() int snd_soc_suspend(struct device *dev) { ... for_each_card_components(card, component) { ... (1) pinctrl_pm_select_sleep_state(component->dev); } for_each_card_rtds(card, rtd) { ... (2) pinctrl_pm_select_sleep_state(cpu_dai->dev); } } (1) is called for all component (CPU/Codec/Platform), and (2) is called for CPU DAIs. Here, component->dev is same as dai->dev. This means, it is called in duplicate on CPU case. This patch removes (2). Signed-off-by: Kuninori Morimoto Reviewed-By: Ranjani Sridharan Link: https://lore.kernel.org/r/875zhkt4vc.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8a1b4ffa6ca6..191b68732e56 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -619,9 +619,6 @@ int snd_soc_suspend(struct device *dev) if (cpu_dai->driver->bus_control) snd_soc_dai_suspend(cpu_dai); - - /* deactivate pins to sleep state */ - pinctrl_pm_select_sleep_state(cpu_dai->dev); } if (card->suspend_post) -- cgit v1.2.3 From 76c39e867cba338d8982f6372b2c4e3189f6439b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:13 +0900 Subject: ASoC: soc-core: do pinctrl_pm_select_xxx() as component ALSA SoC need to care pinctrl_pm_select_xxx(). It is called at soc-core and soc-pcm. soc-pcm is controlling it for activate DAI. soc-core is controlling it for whole system (= suspend/resume/probe/poweroff). If we focus to soc-core side, it need to care about BIAS level. Then, snd_soc_suspend() only is controlling it by Component base (a). Other functions are DAI base (b). (a) pinctrl_pm_select_xxx(component->dev, xxx); (b) pinctrl_pm_select_xxx(dai->dev, xxx); Because of these unbalance, the code is confusable. Here, dai->dev and component->dev are same pointer. Thus, we can replace it component base. One note here is that it cared DAI (= CPU/Codec) pin before this patch, after this patch, it cares Component (= CPU/Codec/Platform) pin. Signed-off-by: Kuninori Morimoto Reviewed-By: Ranjani Sridharan Link: https://lore.kernel.org/r/874kx4t4v6.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 46 +++++++++++----------------------------------- sound/soc/soc-pcm.c | 23 ++++++++--------------- 2 files changed, 19 insertions(+), 50 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 191b68732e56..3c729eaf0bbf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -727,25 +727,16 @@ int snd_soc_resume(struct device *dev) struct snd_soc_card *card = dev_get_drvdata(dev); bool bus_control = false; struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai *codec_dai; - int i; + struct snd_soc_component *component; /* If the card is not initialized yet there is nothing to do */ if (!card->instantiated) return 0; /* activate pins from sleep state */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (cpu_dai->active) - pinctrl_pm_select_default_state(cpu_dai->dev); - - for_each_rtd_codec_dai(rtd, i, codec_dai) { - if (codec_dai->active) - pinctrl_pm_select_default_state(codec_dai->dev); - } - } + for_each_card_components(card, component) + if (component->active) + pinctrl_pm_select_default_state(component->dev); /* * DAIs that also act as the control bus master might have other drivers @@ -1885,6 +1876,7 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) static int snd_soc_bind_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; + struct snd_soc_component *component; struct snd_soc_dai_link *dai_link; int ret, i, card_probed = 0; @@ -2036,17 +2028,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card) snd_soc_dapm_sync(&card->dapm); /* deactivate pins to sleep state */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *dai; - - for_each_rtd_codec_dai(rtd, i, dai) { - if (!dai->active) - pinctrl_pm_select_sleep_state(dai->dev); - } - - if (!rtd->cpu_dai->active) - pinctrl_pm_select_sleep_state(rtd->cpu_dai->dev); - } + for_each_card_components(card, component) + if (!component->active) + pinctrl_pm_select_sleep_state(component->dev); probe_end: if (ret < 0) @@ -2092,7 +2076,7 @@ static int soc_remove(struct platform_device *pdev) int snd_soc_poweroff(struct device *dev) { struct snd_soc_card *card = dev_get_drvdata(dev); - struct snd_soc_pcm_runtime *rtd; + struct snd_soc_component *component; if (!card->instantiated) return 0; @@ -2106,16 +2090,8 @@ int snd_soc_poweroff(struct device *dev) snd_soc_dapm_shutdown(card); /* deactivate pins to sleep state */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai; - int i; - - pinctrl_pm_select_sleep_state(cpu_dai->dev); - for_each_rtd_codec_dai(rtd, i, codec_dai) { - pinctrl_pm_select_sleep_state(codec_dai->dev); - } - } + for_each_card_components(card, component) + pinctrl_pm_select_sleep_state(component->dev); return 0; } diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 9c6c7533a508..68f72051f8e3 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -487,9 +487,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) const char *codec_dai_name = "multicodec"; int i, ret = 0; - pinctrl_pm_select_default_state(cpu_dai->dev); - for_each_rtd_codec_dai(rtd, i, codec_dai) - pinctrl_pm_select_default_state(codec_dai->dev); + for_each_rtd_components(rtd, i, component) + pinctrl_pm_select_default_state(component->dev); for_each_rtd_components(rtd, i, component) pm_runtime_get_sync(component->dev); @@ -618,12 +617,9 @@ out: pm_runtime_put_autosuspend(component->dev); } - for_each_rtd_codec_dai(rtd, i, codec_dai) { - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - } - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); + for_each_rtd_components(rtd, i, component) + if (!component->active) + pinctrl_pm_select_sleep_state(component->dev); return ret; } @@ -728,12 +724,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) pm_runtime_put_autosuspend(component->dev); } - for_each_rtd_codec_dai(rtd, i, codec_dai) { - if (!codec_dai->active) - pinctrl_pm_select_sleep_state(codec_dai->dev); - } - if (!cpu_dai->active) - pinctrl_pm_select_sleep_state(cpu_dai->dev); + for_each_rtd_components(rtd, i, component) + if (!component->active) + pinctrl_pm_select_sleep_state(component->dev); return 0; } -- cgit v1.2.3 From 83f94a2e293d617a98e077680ea00b2830a9ca22 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:17 +0900 Subject: ASoC: soc-core: add snd_soc_close_delayed_work() We need to setup rtd->close_delayed_work_func. It will be set at snd_soc_dai_compress_new() or soc_new_pcm(). But these setups close_delayed_work() which is same name / same implemantaion, but different local code. To reduce duplicate code, this patch moves it as snd_soc_close_delayed_work() and share same code. Signed-off-by: Kuninori Morimoto Reviewed-By: Ranjani Sridharan Link: https://lore.kernel.org/r/8736cot4v2.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + sound/soc/soc-compress.c | 29 +---------------------------- sound/soc/soc-core.c | 28 ++++++++++++++++++++++++++++ sound/soc/soc-pcm.c | 28 +--------------------------- 4 files changed, 31 insertions(+), 55 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0513f30a0209..f0e4f36f83bf 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1159,6 +1159,7 @@ struct snd_soc_pcm_runtime { #define for_each_rtd_codec_dai_rollback(rtd, i, dai) \ for (; ((--i) >= 0) && ((dai) = rtd->codec_dais[i]);) +void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); /* mixer control */ struct soc_mixer_control { diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 16fe08690cf5..72494717dde3 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -226,33 +226,6 @@ be_err: return ret; } -/* - * Power down the audio subsystem pmdown_time msecs after close is called. - * This is to ensure there are no pops or clicks in between any music tracks - * due to DAPM power cycling. - */ -static void close_delayed_work(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *codec_dai = rtd->codec_dai; - - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - - dev_dbg(rtd->dev, - "Compress ASoC: pop wq checking: %s status: %s waiting: %s\n", - codec_dai->driver->playback.stream_name, - codec_dai->playback_active ? "active" : "inactive", - rtd->pop_wait ? "yes" : "no"); - - /* are we waiting on this codec DAI stream */ - if (rtd->pop_wait == 1) { - rtd->pop_wait = 0; - snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, - SND_SOC_DAPM_STREAM_STOP); - } - - mutex_unlock(&rtd->card->pcm_mutex); -} - static int soc_compr_free(struct snd_compr_stream *cstream) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; @@ -941,7 +914,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) } /* DAPM dai link stream work */ - rtd->close_delayed_work_func = close_delayed_work; + rtd->close_delayed_work_func = snd_soc_close_delayed_work; rtd->compr = compr; compr->private_data = rtd; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3c729eaf0bbf..acf6f141fd2d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -359,6 +359,34 @@ struct snd_soc_pcm_runtime } EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); +/* + * Power down the audio subsystem pmdown_time msecs after close is called. + * This is to ensure there are no pops or clicks in between any music tracks + * due to DAPM power cycling. + */ +void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = rtd->codec_dai; + + mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + + dev_dbg(rtd->dev, + "ASoC: pop wq checking: %s status: %s waiting: %s\n", + codec_dai->driver->playback.stream_name, + codec_dai->playback_active ? "active" : "inactive", + rtd->pop_wait ? "yes" : "no"); + + /* are we waiting on this codec DAI stream */ + if (rtd->pop_wait == 1) { + rtd->pop_wait = 0; + snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, + SND_SOC_DAPM_STREAM_STOP); + } + + mutex_unlock(&rtd->card->pcm_mutex); +} +EXPORT_SYMBOL_GPL(snd_soc_close_delayed_work); + static void soc_release_rtd_dev(struct device *dev) { /* "dev" means "rtd->dev" */ diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 68f72051f8e3..ad908e008b2f 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -624,32 +624,6 @@ out: return ret; } -/* - * Power down the audio subsystem pmdown_time msecs after close is called. - * This is to ensure there are no pops or clicks in between any music tracks - * due to DAPM power cycling. - */ -static void close_delayed_work(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *codec_dai = rtd->codec_dais[0]; - - mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - - dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n", - codec_dai->driver->playback.stream_name, - codec_dai->playback_active ? "active" : "inactive", - rtd->pop_wait ? "yes" : "no"); - - /* are we waiting on this codec DAI stream */ - if (rtd->pop_wait == 1) { - rtd->pop_wait = 0; - snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, - SND_SOC_DAPM_STREAM_STOP); - } - - mutex_unlock(&rtd->card->pcm_mutex); -} - static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd) { /* @@ -2956,7 +2930,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) if (rtd->dai_link->params) rtd->close_delayed_work_func = codec2codec_close_delayed_work; else - rtd->close_delayed_work_func = close_delayed_work; + rtd->close_delayed_work_func = snd_soc_close_delayed_work; pcm->nonatomic = rtd->dai_link->nonatomic; rtd->pcm = pcm; -- cgit v1.2.3 From 3f4cf797939cb3ccdb6f989da53f1899d30432dc Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:23 +0900 Subject: ASoC: soc-dapm: add snd_soc_dapm_stream_stop() When we stop stream, if it was Playback, we might need to care about power down time. In such case, we need to use delayed work. We have same implementation for it at soc-pcm.c and soc-compress.c, but we don't want to have duplicate code. This patch adds snd_soc_dapm_stream_stop(), and share same code. Signed-off-by: Kuninori Morimoto Reviewed-By: Ranjani Sridharan Link: https://lore.kernel.org/r/871rs8t4uw.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 1 + sound/soc/soc-compress.c | 18 +----------------- sound/soc/soc-dapm.c | 23 +++++++++++++++++++++++ sound/soc/soc-pcm.c | 19 +------------------ 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 6e8a31225383..1b6afbc1a4ed 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -434,6 +434,7 @@ void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm); /* dapm events */ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event); +void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream); void snd_soc_dapm_shutdown(struct snd_soc_card *card); /* external DAPM widget events */ diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 72494717dde3..392a1c5b15d3 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -259,23 +259,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream) if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) cpu_dai->driver->cops->shutdown(cstream, cpu_dai); - if (cstream->direction == SND_COMPRESS_PLAYBACK) { - if (snd_soc_runtime_ignore_pmdown_time(rtd)) { - snd_soc_dapm_stream_event(rtd, - SNDRV_PCM_STREAM_PLAYBACK, - SND_SOC_DAPM_STREAM_STOP); - } else { - rtd->pop_wait = 1; - queue_delayed_work(system_power_efficient_wq, - &rtd->delayed_work, - msecs_to_jiffies(rtd->pmdown_time)); - } - } else { - /* capture streams can be powered down now */ - snd_soc_dapm_stream_event(rtd, - SNDRV_PCM_STREAM_CAPTURE, - SND_SOC_DAPM_STREAM_STOP); - } + snd_soc_dapm_stream_stop(rtd, stream); mutex_unlock(&rtd->card->pcm_mutex); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index b6378f025836..442846f12cd4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4447,6 +4447,29 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, mutex_unlock(&card->dapm_mutex); } +void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream) +{ + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { + if (snd_soc_runtime_ignore_pmdown_time(rtd)) { + /* powered down playback stream now */ + snd_soc_dapm_stream_event(rtd, + SNDRV_PCM_STREAM_PLAYBACK, + SND_SOC_DAPM_STREAM_STOP); + } else { + /* start delayed pop wq here for playback streams */ + rtd->pop_wait = 1; + queue_delayed_work(system_power_efficient_wq, + &rtd->delayed_work, + msecs_to_jiffies(rtd->pmdown_time)); + } + } else { + /* capture streams can be powered down now */ + snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE, + SND_SOC_DAPM_STREAM_STOP); + } +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_stop); + /** * snd_soc_dapm_enable_pin_unlocked - enable pin. * @dapm: DAPM context diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index ad908e008b2f..dfff2ddb469a 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -672,24 +672,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) soc_pcm_components_close(substream, NULL); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (snd_soc_runtime_ignore_pmdown_time(rtd)) { - /* powered down playback stream now */ - snd_soc_dapm_stream_event(rtd, - SNDRV_PCM_STREAM_PLAYBACK, - SND_SOC_DAPM_STREAM_STOP); - } else { - /* start delayed pop wq here for playback streams */ - rtd->pop_wait = 1; - queue_delayed_work(system_power_efficient_wq, - &rtd->delayed_work, - msecs_to_jiffies(rtd->pmdown_time)); - } - } else { - /* capture streams can be powered down now */ - snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE, - SND_SOC_DAPM_STREAM_STOP); - } + snd_soc_dapm_stream_stop(rtd, substream->stream); mutex_unlock(&rtd->card->pcm_mutex); -- cgit v1.2.3 From b0edff42360ab4f772cc581a60a14089ef2e1718 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Jan 2020 11:36:56 +0900 Subject: ASoC: soc-pcm/soc-compress: use snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP dpcm_fe_dai_shutdown() / soc_compr_free_fe() didn't care pmdown_time. We already have snd_soc_dapm_stream_stop() for it. Let's use common method. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87zhewrq9j.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-compress.c | 2 +- sound/soc/soc-pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 392a1c5b15d3..223cd045719e 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -299,7 +299,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) for_each_dpcm_be(fe, stream, dpcm) dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; - dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); + snd_soc_dapm_stream_stop(fe, stream); fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index dfff2ddb469a..74d340d1c9f7 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1966,7 +1966,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream) soc_pcm_close(substream); /* run the stream event for each BE */ - dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); + snd_soc_dapm_stream_stop(fe, stream); fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO); -- cgit v1.2.3 From f9993480214f1345497875ed363a52b7ef7e33db Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Sat, 11 Jan 2020 14:33:25 -0600 Subject: ALSA: timer: fix nsec/sec initialization confusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC reports a warning with W=1: sound/core/timer.c: In function ‘snd_timer_user_read’: sound/core/timer.c:2219:19: warning: initialized field overwritten [-Woverride-init] 2219 | .tstamp_sec = tread->tstamp_nsec, | ^~~~~ sound/core/timer.c:2219:19: note: (near initialization for ‘(anonymous).tstamp_sec’) Assigning nsec values to sec fields is problematic in general, even more so when the initial goal was to survive the 2030 timer armageddon. Fix by using the proper field in the initialization Cc: Baolin Wang Cc: Arnd Bergmann Fixes: 07094ae6f9527 ("ALSA: Avoid using timespec for struct snd_timer_tread") Signed-off-by: Pierre-Louis Bossart Acked-by: Arnd Bergmann Link: https://lore.kernel.org/r/20200111203325.20498-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/core/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/timer.c b/sound/core/timer.c index 8835ff91a893..d9f85f2d66a3 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -2216,7 +2216,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, tread32 = (struct snd_timer_tread32) { .event = tread->event, .tstamp_sec = tread->tstamp_sec, - .tstamp_sec = tread->tstamp_nsec, + .tstamp_nsec = tread->tstamp_nsec, .val = tread->val, }; -- cgit v1.2.3 From 8a71821f12a010d7100f9cc1f7b218aff0313c4a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Sat, 11 Jan 2020 15:47:35 -0600 Subject: ALSA: hda: patch_realtek: fix empty macro usage in if block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC reports the following warning with W=1 sound/pci/hda/patch_realtek.c: In function ‘alc269_suspend’: sound/pci/hda/patch_realtek.c:3616:29: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] 3616 | alc5505_dsp_suspend(codec); | ^ sound/pci/hda/patch_realtek.c: In function ‘alc269_resume’: sound/pci/hda/patch_realtek.c:3651:28: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] 3651 | alc5505_dsp_resume(codec); | ^ This is a classic macro problem and can indeed lead to bad program flows. Fix by using the usual "do { } while (0)" pattern Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200111214736.3002-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 181e15072692..ed7982f5460d 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -3601,8 +3601,8 @@ static void alc5505_dsp_init(struct hda_codec *codec) } #ifdef HALT_REALTEK_ALC5505 -#define alc5505_dsp_suspend(codec) /* NOP */ -#define alc5505_dsp_resume(codec) /* NOP */ +#define alc5505_dsp_suspend(codec) do { } while (0) /* NOP */ +#define alc5505_dsp_resume(codec) do { } while (0) /* NOP */ #else #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec) #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec) -- cgit v1.2.3 From ff40e0d41af19e36b43693fcb9241b4a6795bb44 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Sat, 11 Jan 2020 15:47:36 -0600 Subject: ALSA: usb: update old-style static const declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC reports the following warning with W=1 sound/usb/mixer_quirks.c: In function ‘snd_microii_controls_create’: sound/usb/mixer_quirks.c:1694:2: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] 1694 | const static usb_mixer_elem_resume_func_t resume_funcs[] = { | ^~~~~ Move static to the beginning of declaration Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200111214736.3002-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/usb/mixer_quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index b9f5a9c18040..c237e24f08d9 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -1691,7 +1691,7 @@ static const struct snd_kcontrol_new snd_microii_mixer_spdif[] = { static int snd_microii_controls_create(struct usb_mixer_interface *mixer) { int err, i; - const static usb_mixer_elem_resume_func_t resume_funcs[] = { + static const usb_mixer_elem_resume_func_t resume_funcs[] = { snd_microii_spdif_default_update, NULL, snd_microii_spdif_switch_update -- cgit v1.2.3 From 03be63b2953c1b33ac77b7c21345495acc47e84b Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 13 Jan 2020 16:34:16 +0900 Subject: ALSA: oxfw: use ENXIO for not-supported cases When AV/C command returns 'NOT IMPLEMENTED' status in its response, ALSA oxfw driver uses ENOSYS as error code. However, it's expected just to be used for missing system call number. This commit replaces it with ENXIO. Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200113073418.24622-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/oxfw/oxfw-command.c | 6 +++--- sound/firewire/oxfw/oxfw-stream.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-command.c b/sound/firewire/oxfw/oxfw-command.c index 16dc337c7093..d2e57c76070d 100644 --- a/sound/firewire/oxfw/oxfw-command.c +++ b/sound/firewire/oxfw/oxfw-command.c @@ -38,7 +38,7 @@ int avc_stream_set_format(struct fw_unit *unit, enum avc_general_plug_dir dir, else if (err < len + 10) err = -EIO; else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ - err = -ENOSYS; + err = -ENXIO; else if (buf[0] == 0x0a) /* REJECTED */ err = -EINVAL; else @@ -83,7 +83,7 @@ int avc_stream_get_format(struct fw_unit *unit, else if (err < 12) err = -EIO; else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ - err = -ENOSYS; + err = -ENXIO; else if (buf[0] == 0x0a) /* REJECTED */ err = -EINVAL; else if (buf[0] == 0x0b) /* IN TRANSITION */ @@ -147,7 +147,7 @@ int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate, else if (err < 8) err = -EIO; else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ - err = -ENOSYS; + err = -ENXIO; if (err < 0) goto end; diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 501a80094bf7..692324670c78 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -513,7 +513,7 @@ int snd_oxfw_stream_parse_format(u8 *format, * Level 1: AM824 Compound (0x40) */ if ((format[0] != 0x90) || (format[1] != 0x40)) - return -ENOSYS; + return -ENXIO; /* check the sampling rate */ for (i = 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) { @@ -521,7 +521,7 @@ int snd_oxfw_stream_parse_format(u8 *format, break; } if (i == ARRAY_SIZE(avc_stream_rate_table)) - return -ENOSYS; + return -ENXIO; formation->rate = oxfw_rate_table[i]; @@ -565,13 +565,13 @@ int snd_oxfw_stream_parse_format(u8 *format, /* Don't care */ case 0xff: default: - return -ENOSYS; /* not supported */ + return -ENXIO; /* not supported */ } } if (formation->pcm > AM824_MAX_CHANNELS_FOR_PCM || formation->midi > AM824_MAX_CHANNELS_FOR_MIDI) - return -ENOSYS; + return -ENXIO; return 0; } @@ -656,7 +656,7 @@ static int fill_stream_formats(struct snd_oxfw *oxfw, /* get first entry */ len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; err = avc_stream_get_format_list(oxfw->unit, dir, 0, buf, &len, 0); - if (err == -ENOSYS) { + if (err == -ENXIO) { /* LIST subfunction is not implemented */ len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; err = assume_stream_formats(oxfw, dir, pid, buf, &len, @@ -728,7 +728,7 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) err); goto end; } else if ((plugs[0] == 0) && (plugs[1] == 0)) { - err = -ENOSYS; + err = -ENXIO; goto end; } -- cgit v1.2.3 From 06a42a74a0e704458754bdc5f29cf62cc1ce4b53 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 13 Jan 2020 16:34:17 +0900 Subject: ALSA: oxfw: don't add MIDI/PCM interface when packet streaming is unavailable Stanton SCS.1d doesn't support packet streaming even if it has plugs for isochronous communication. This commit is a preparation for this case. The 'has_input' member is added to specific structure, and MIDI/PCM interfaces are not added when the member is false. Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200113073418.24622-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/oxfw/oxfw-stream.c | 2 ++ sound/firewire/oxfw/oxfw.c | 39 ++++++++++++++++++++++----------------- sound/firewire/oxfw/oxfw.h | 1 + 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 692324670c78..36c3dd84d189 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -772,6 +772,8 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) if (formation.midi > 0) oxfw->midi_output_ports = 1; } + + oxfw->has_input = true; } end: return err; diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c index fb6df3fc018e..1f1e3236efb8 100644 --- a/sound/firewire/oxfw/oxfw.c +++ b/sound/firewire/oxfw/oxfw.c @@ -118,7 +118,8 @@ static void oxfw_card_free(struct snd_card *card) { struct snd_oxfw *oxfw = card->private_data; - snd_oxfw_stream_destroy_duplex(oxfw); + if (oxfw->has_output || oxfw->has_input) + snd_oxfw_stream_destroy_duplex(oxfw); } static int detect_quirks(struct snd_oxfw *oxfw) @@ -206,23 +207,25 @@ static void do_registration(struct work_struct *work) if (err < 0) goto error; - err = snd_oxfw_stream_init_duplex(oxfw); - if (err < 0) - goto error; + if (oxfw->has_output || oxfw->has_input) { + err = snd_oxfw_stream_init_duplex(oxfw); + if (err < 0) + goto error; - err = snd_oxfw_create_pcm(oxfw); - if (err < 0) - goto error; + err = snd_oxfw_create_pcm(oxfw); + if (err < 0) + goto error; - snd_oxfw_proc_init(oxfw); + snd_oxfw_proc_init(oxfw); - err = snd_oxfw_create_midi(oxfw); - if (err < 0) - goto error; + err = snd_oxfw_create_midi(oxfw); + if (err < 0) + goto error; - err = snd_oxfw_create_hwdep(oxfw); - if (err < 0) - goto error; + err = snd_oxfw_create_hwdep(oxfw); + if (err < 0) + goto error; + } err = snd_card_register(oxfw->card); if (err < 0) @@ -274,9 +277,11 @@ static void oxfw_bus_reset(struct fw_unit *unit) fcp_bus_reset(oxfw->unit); if (oxfw->registered) { - mutex_lock(&oxfw->mutex); - snd_oxfw_stream_update_duplex(oxfw); - mutex_unlock(&oxfw->mutex); + if (oxfw->has_output || oxfw->has_input) { + mutex_lock(&oxfw->mutex); + snd_oxfw_stream_update_duplex(oxfw); + mutex_unlock(&oxfw->mutex); + } if (oxfw->entry->vendor_id == OUI_STANTON) snd_oxfw_scs1x_update(oxfw); diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index c30e537087b0..fa2d7f9e2dc3 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h @@ -45,6 +45,7 @@ struct snd_oxfw { bool wrong_dbs; bool has_output; + bool has_input; u8 *tx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES]; u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES]; bool assumed; -- cgit v1.2.3 From 41dbc792794acf520892afe40b7df4cc58a8f5f5 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 13 Jan 2020 16:34:18 +0900 Subject: ALSA: oxfw: fix for Stanton SCS.1d Stanton SCS.1d uses Oxford Semiconductor FW 971 ASIC (FW971) for communication. Although the unit is bound to ALSA oxfw driver, the instance of sound card can not be added due to its quirk of plug information. This bug was added when snd-scs1x is merged into snd-oxfw at commit 9e2004f9cedf ("ALSA: oxfw: obsolete scs1x module"). This commit fixes the driver for the quirk. In cases that the unit returns NOT IMPLEMENTED for some AV/C commands, the sound card is added without any PCM/MIDI interfaces for packet streaming. For SCS.1d, model dependent operation adds MIDI interface and applications can use it to operate according to HSS1394 protocol from reverse-engineering work by Sean M. Pappalardo. Plug Control Register (PCR) has information that the unit has a pair of plugs for isochronous communication: (oMPR) $ ./firewire-request /dev/fw1 read 0xfffff0000900 result: 80ff0001 (iMPR) $ ./firewire-request /dev/fw1 read 0xfffff0000980 result: 80ff0001 AV/C PLUG INFO also returns information that the unit has a pair of plugs for isochronous communication. (AV/C PLUG INFO command) $ ./firewire-request /dev/fw1 fcp 0x01ff0200ffffffff response: 000: 0c ff 02 00 01 01 02 02 However, AV/C PLUG SIGNAL INFO command is rejected for both plugs. (AV/C OUTPUT PLUG SIGNAL INFO command) $ ./firewire-request /dev/fw1 fcp 0x01ff1800ffffffff response: 000: 0a ff 18 00 ff ff ff ff (AV/C INPUT PLUG SIGNAL INFO command) $ ./firewire-request /dev/fw1 fcp 0x01ff1900ffffffff response: 000: 0a ff 19 00 ff ff ff ff Furthermore, AV/C EXTENDED STREAM FORMAT INFO is not implemented. (AV/C EXTENDED STREAM FORMAT INFO list subfunction for input plug) $ ./firewire-request /dev/fw1 fcp 0x01ffbfc000000000ffff00ff response: 000: 08 ff bf c0 00 00 00 00 ff ff 00 ff (AV/C EXTENDED STREAM FORMAT INFO list subfunction for output plug) $ ./firewire-request /dev/fw1 fcp 0x01ffbfc001000000ffff00ff response: 000: 08 ff bf c0 01 00 00 00 ff ff 00 ff (AV/C EXTENDED STREAM FORMAT INFO single subfunction for input plug) $ ./firewire-request /dev/fw1 fcp 0x01ffbfc100000000ffffffff response: 000: 08 ff bf c1 00 00 00 00 ff ff ff ff (AV/C EXTENDED STREAM FORMAT INFO single subfunction for output plug) $ ./firewire-request /dev/fw1 fcp 0x01ffbfc101000000ffffffff response: 000: 08 ff bf c1 01 00 00 00 ff ff ff ff Reference: https://mailman.alsa-project.org/pipermail/alsa-devel/2012-May/052264.html Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200113073418.24622-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/oxfw/oxfw-stream.c | 72 +++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 36c3dd84d189..80c9dc13f1b5 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c @@ -735,45 +735,57 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw) /* use oPCR[0] if exists */ if (plugs[1] > 0) { err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_OUT, 0); - if (err < 0) - goto end; + if (err < 0) { + if (err != -ENXIO) + return err; - for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { - format = oxfw->tx_stream_formats[i]; - if (format == NULL) - continue; - err = snd_oxfw_stream_parse_format(format, &formation); - if (err < 0) - continue; - - /* Add one MIDI port. */ - if (formation.midi > 0) - oxfw->midi_input_ports = 1; - } + // The oPCR is not available for isoc communication. + err = 0; + } else { + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { + format = oxfw->tx_stream_formats[i]; + if (format == NULL) + continue; + err = snd_oxfw_stream_parse_format(format, + &formation); + if (err < 0) + continue; + + /* Add one MIDI port. */ + if (formation.midi > 0) + oxfw->midi_input_ports = 1; + } - oxfw->has_output = true; + oxfw->has_output = true; + } } /* use iPCR[0] if exists */ if (plugs[0] > 0) { err = fill_stream_formats(oxfw, AVC_GENERAL_PLUG_DIR_IN, 0); - if (err < 0) - goto end; + if (err < 0) { + if (err != -ENXIO) + return err; - for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { - format = oxfw->rx_stream_formats[i]; - if (format == NULL) - continue; - err = snd_oxfw_stream_parse_format(format, &formation); - if (err < 0) - continue; - - /* Add one MIDI port. */ - if (formation.midi > 0) - oxfw->midi_output_ports = 1; - } + // The iPCR is not available for isoc communication. + err = 0; + } else { + for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { + format = oxfw->rx_stream_formats[i]; + if (format == NULL) + continue; + err = snd_oxfw_stream_parse_format(format, + &formation); + if (err < 0) + continue; + + /* Add one MIDI port. */ + if (formation.midi > 0) + oxfw->midi_output_ports = 1; + } - oxfw->has_input = true; + oxfw->has_input = true; + } } end: return err; -- cgit v1.2.3 From a9f47fcb5e25c088b91ed768061b2ab3602f7868 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 13 Jan 2020 17:46:29 +0900 Subject: ALSA: dice: loosen stream format check for MIDI conformant data channel ALSA dice driver expects devices to multiplex MIDI messages into first port of isochronous communication. Actually devices perform for it. However, check of stream format is invalid for second port of isochronous communication. As a result, when the device supports two ports for isochronous communication and the stream format is hard-coded, ALSA dice driver fails to start packet streaming. This commit loosens stream format check for MIDI conformant data channel. Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200113084630.14305-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/dice/dice-stream.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index 6a3d60913e10..8e0c0380b4c4 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -224,7 +224,6 @@ static int keep_dual_resources(struct snd_dice *dice, unsigned int rate, struct amdtp_stream *stream; struct fw_iso_resources *resources; unsigned int pcm_cache; - unsigned int midi_cache; unsigned int pcm_chs; unsigned int midi_ports; @@ -233,7 +232,6 @@ static int keep_dual_resources(struct snd_dice *dice, unsigned int rate, resources = &dice->tx_resources[i]; pcm_cache = dice->tx_pcm_chs[i][mode]; - midi_cache = dice->tx_midi_ports[i]; err = snd_dice_transaction_read_tx(dice, params->size * i + TX_NUMBER_AUDIO, reg, sizeof(reg)); @@ -242,7 +240,6 @@ static int keep_dual_resources(struct snd_dice *dice, unsigned int rate, resources = &dice->rx_resources[i]; pcm_cache = dice->rx_pcm_chs[i][mode]; - midi_cache = dice->rx_midi_ports[i]; err = snd_dice_transaction_read_rx(dice, params->size * i + RX_NUMBER_AUDIO, reg, sizeof(reg)); @@ -253,10 +250,10 @@ static int keep_dual_resources(struct snd_dice *dice, unsigned int rate, midi_ports = be32_to_cpu(reg[1]); // These are important for developer of this driver. - if (pcm_chs != pcm_cache || midi_ports != midi_cache) { + if (pcm_chs != pcm_cache) { dev_info(&dice->unit->device, - "cache mismatch: pcm: %u:%u, midi: %u:%u\n", - pcm_chs, pcm_cache, midi_ports, midi_cache); + "cache mismatch: pcm: %u:%u, midi: %u\n", + pcm_chs, pcm_cache, midi_ports); return -EPROTO; } -- cgit v1.2.3 From 791a485f2da392df00341ed4c0c14780fd320d92 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Mon, 13 Jan 2020 17:46:30 +0900 Subject: ALSA: dice: add support for Alesis MasterControl Alesis MasterControl was shipped 2009 and already discontinued. This model consists of: * TSB41AB2 for physical layer of IEEE 1394 * WaveFront Dice II STD for link layer and protocol implementation * FreeScale DSPB56374AE Although the firmware of this model can respond against read transaction to address space for TCAT extension protocol, the content is not valid for protocol extension. This results in sound card without any PCM/MIDI interfaces. $ ./firewire-request /dev/fw1 read 0xffffe0200000 0x48 result: 000: 00 00 00 20 00 00 04 94 00 00 04 b4 00 00 00 b4 result: 010: 00 00 05 68 00 00 00 24 00 00 05 8c 00 00 00 48 result: 020: 00 00 00 20 00 00 00 08 00 00 00 20 00 00 00 20 result: 030: 00 00 00 10 00 00 00 08 00 00 00 08 00 00 00 04 result: 040: 00 00 00 00 00 00 00 00 This commit adds support the model by adding hard-coded stream formats. $ python3 ~/git/linux-firewire-utils/src/crpp < /sys/bus/firewire/devices/fw1/config_rom ROM header and bus information block ----------------------------------------------------------------- 400 04041ad7 bus_info_length 4, crc_length 4, crc 6871 404 31333934 bus_name "1394" 408 e0ff8112 irmc 1, cmc 1, isc 1, bmc 0, pmc 0, cyc_clk_acc 255, max_rec 8 (512), max_rom 1, gen 1, spd 2 (S400) 40c 00059504 company_id 000595 | Alesis Corporation 410 008003f5 device_id 04008003f5 | EUI-64 00059504008003f5 root directory ----------------------------------------------------------------- 414 0006a620 directory_length 6, crc 42528 418 03000595 vendor: Alesis Corporation 41c 8100000a --> descriptor leaf at 444 420 17000002 model 424 8100000d --> descriptor leaf at 458 428 0c0087c0 node capabilities per IEEE 1394 42c d1000001 --> unit directory at 430 unit directory at 430 ----------------------------------------------------------------- 430 00041b9f directory_length 4, crc 7071 434 12000595 specifier id: Alesis Corporation 438 13000001 version: audio 43c 17000002 model 440 8100000d --> descriptor leaf at 474 descriptor leaf at 444 ----------------------------------------------------------------- 444 000494c2 leaf_length 4, crc 38082 448 00000000 textual descriptor 44c 00000000 minimal ASCII 450 416c6573 "Ales" 454 69730000 "is" descriptor leaf at 458 ----------------------------------------------------------------- 458 0006c2ec leaf_length 6, crc 49900 45c 00000000 textual descriptor 460 00000000 minimal ASCII 464 4d617374 "Mast" 468 6572436f "erCo" 46c 6e74726f "ntro" 470 6c000000 "l" descriptor leaf at 474 ----------------------------------------------------------------- 474 0006c2ec leaf_length 6, crc 49900 478 00000000 textual descriptor 47c 00000000 minimal ASCII 480 4d617374 "Mast" 484 6572436f "erCo" 488 6e74726f "ntro" 48c 6c000000 "l" Signed-off-by: Takashi Sakamoto Link: https://lore.kernel.org/r/20200113084630.14305-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai --- sound/firewire/dice/dice-alesis.c | 24 ++++++++++++++++++++++++ sound/firewire/dice/dice.c | 8 ++++++++ sound/firewire/dice/dice.h | 1 + 3 files changed, 33 insertions(+) diff --git a/sound/firewire/dice/dice-alesis.c b/sound/firewire/dice/dice-alesis.c index f5b325263b67..0916864511d5 100644 --- a/sound/firewire/dice/dice-alesis.c +++ b/sound/firewire/dice/dice-alesis.c @@ -50,3 +50,27 @@ int snd_dice_detect_alesis_formats(struct snd_dice *dice) return 0; } + +int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice) +{ + int i; + + dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_LOW] = 16; + dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_LOW] = 12; + dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_MIDDLE] = 12; + dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_MIDDLE] = 4; + dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_HIGH] = 8; + dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_HIGH] = 0; + + for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i) { + dice->rx_pcm_chs[0][i] = 6; + dice->rx_pcm_chs[1][i] = 0; + } + + for (i = 0; i < MAX_STREAMS; ++i) { + dice->tx_midi_ports[i] = 2; + dice->rx_midi_ports[i] = 2; + } + + return 0; +} diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c index 13eeb3f52bb6..06c94f009dfb 100644 --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c @@ -355,6 +355,14 @@ static const struct ieee1394_device_id dice_id_table[] = { .model_id = MODEL_ALESIS_IO_BOTH, .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_formats, }, + // Alesis MasterControl. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_MODEL_ID, + .vendor_id = OUI_ALESIS, + .model_id = 0x000002, + .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_mastercontrol_formats, + }, /* Mytek Stereo 192 DSD-DAC. */ { .match_flags = IEEE1394_MATCH_VENDOR_ID | diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h index 16366773e22e..7fbffcab94c2 100644 --- a/sound/firewire/dice/dice.h +++ b/sound/firewire/dice/dice.h @@ -229,6 +229,7 @@ int snd_dice_create_midi(struct snd_dice *dice); int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice); int snd_dice_detect_alesis_formats(struct snd_dice *dice); +int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice); int snd_dice_detect_extension_formats(struct snd_dice *dice); int snd_dice_detect_mytek_formats(struct snd_dice *dice); int snd_dice_detect_presonus_formats(struct snd_dice *dice); -- cgit v1.2.3 From 73ac9f5e5b43a5dbadb61f27dae7a971f7ec0d22 Mon Sep 17 00:00:00 2001 From: Alexander Tsoy Date: Sun, 12 Jan 2020 13:23:58 +0300 Subject: ALSA: usb-audio: Add boot quirk for MOTU M Series Add delay to make sure that audio urbs are not sent too early. Otherwise the device hangs. Windows driver makes ~2s delay, so use about the same time delay value. snd_usb_apply_boot_quirk() is called 3 times for my MOTU M4, which is an overkill. Thus a quirk that is called only once is implemented. Also send two vendor-specific control messages before and after the delay. This behaviour is blindly copied from the Windows driver. Signed-off-by: Alexander Tsoy Link: https://lore.kernel.org/r/20200112102358.18085-1-alexander@tsoy.me Signed-off-by: Takashi Iwai --- sound/usb/card.c | 4 ++++ sound/usb/quirks.c | 38 ++++++++++++++++++++++++++++++++++++++ sound/usb/quirks.h | 5 +++++ 3 files changed, 47 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index 9f743ebae615..2f582ac7cf78 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -600,6 +600,10 @@ static int usb_audio_probe(struct usb_interface *intf, } } if (! chip) { + err = snd_usb_apply_boot_quirk_once(dev, intf, quirk, id); + if (err < 0) + return err; + /* it's a fresh one. * now look for an empty slot and create a new card instance */ diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 11159fcfdcdf..3a5242e383b2 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1113,6 +1113,31 @@ free_buf: return err; } +static int snd_usb_motu_m_series_boot_quirk(struct usb_device *dev) +{ + int ret; + + if (snd_usb_pipe_sanity_check(dev, usb_sndctrlpipe(dev, 0))) + return -EINVAL; + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0x0, 0, NULL, 0, 1000); + + if (ret < 0) + return ret; + + msleep(2000); + + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), + 1, USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0x20, 0, NULL, 0, 1000); + + if (ret < 0) + return ret; + + return 0; +} + /* * Setup quirks */ @@ -1297,6 +1322,19 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, return 0; } +int snd_usb_apply_boot_quirk_once(struct usb_device *dev, + struct usb_interface *intf, + const struct snd_usb_audio_quirk *quirk, + unsigned int id) +{ + switch (id) { + case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ + return snd_usb_motu_m_series_boot_quirk(dev); + } + + return 0; +} + /* * check if the device uses big-endian samples */ diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index a80e0ddd0736..df0355843a4c 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h @@ -20,6 +20,11 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, const struct snd_usb_audio_quirk *quirk, unsigned int usb_id); +int snd_usb_apply_boot_quirk_once(struct usb_device *dev, + struct usb_interface *intf, + const struct snd_usb_audio_quirk *quirk, + unsigned int usb_id); + void snd_usb_set_format_quirk(struct snd_usb_substream *subs, struct audioformat *fmt); -- cgit v1.2.3 From 1a462be52f4505a2719631fb5aa7bfdbd37bfd8d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Jan 2020 10:01:04 +0100 Subject: ALSA: hda: Manage concurrent reg access more properly In the commit 8e85def5723e ("ALSA: hda: enable regmap internal locking"), we re-enabled the regmap lock due to the reported regression that showed the possible concurrent accesses. It was a temporary workaround, and there are still a few opened races even after the revert. In this patch, we cover those still opened windows with a proper mutex lock and disable the regmap internal lock again. First off, the patch introduces a new snd_hdac_device.regmap_lock mutex that is applied for each snd_hdac_regmap_*() call, including read, write and update helpers. The mutex is applied carefully so that it won't block the self-power-up procedure in the helper function. Also, this assures the protection for the accesses without regmap, too. The snd_hdac_regmap_update_raw() is refactored to use the standard regmap_update_bits_check() function instead of the open-code. The non-regmap case is still open-coded but it's an easy part. The all read and write operations are in the single mutex protection, so it's now race-free. In addition, a couple of new helper functions are added: snd_hdac_regmap_update_raw_once() and snd_hdac_regmap_sync(). Both are called from HD-audio legacy driver. The former is to initialize the given verb bits but only once when it's not initialized yet. Due to this condition, the function invokes regcache_cache_only(), and it's now performed inside the regmap_lock (formerly it was racy) too. The latter function is for simply invoking regcache_sync() inside the regmap_lock, which is called from the codec resume call path. Along with that, the HD-audio codec driver code is slightly modified / simplified to adapt those new functions. And finally, snd_hdac_regmap_read_raw(), *_write_raw(), etc are rewritten with the helper macro. It's just for simplification because the code logic is identical among all those functions. Tested-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200109090104.26073-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/hda_regmap.h | 3 + include/sound/hdaudio.h | 1 + sound/hda/hdac_device.c | 1 + sound/hda/hdac_regmap.c | 142 +++++++++++++++++++++++++++++++----------- sound/pci/hda/hda_codec.c | 30 ++++----- sound/pci/hda/hda_generic.c | 2 +- sound/pci/hda/hda_local.h | 2 + sound/pci/hda/patch_hdmi.c | 2 +- sound/pci/hda/patch_realtek.c | 4 +- sound/pci/hda/patch_via.c | 2 +- 10 files changed, 135 insertions(+), 54 deletions(-) diff --git a/include/sound/hda_regmap.h b/include/sound/hda_regmap.h index 5141f8ffbb12..4c1b9bebbd60 100644 --- a/include/sound/hda_regmap.h +++ b/include/sound/hda_regmap.h @@ -24,6 +24,9 @@ int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg, unsigned int val); int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg, unsigned int mask, unsigned int val); +int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val); +void snd_hdac_regmap_sync(struct hdac_device *codec); /** * snd_hdac_regmap_encode_verb - encode the verb to a pseudo register diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index bc2f77a6f17b..541ca99b154b 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -86,6 +86,7 @@ struct hdac_device { /* regmap */ struct regmap *regmap; + struct mutex regmap_lock; struct snd_array vendor_verbs; bool lazy_cache:1; /* don't wake up for writes */ bool caps_overwriting:1; /* caps overwrite being in process */ diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index b4f8725f5ddf..7bcdb0e454f2 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -57,6 +57,7 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, codec->addr = addr; codec->type = HDA_DEV_CORE; mutex_init(&codec->widget_lock); + mutex_init(&codec->regmap_lock); pm_runtime_set_active(&codec->dev); pm_runtime_get_noresume(&codec->dev); atomic_set(&codec->in_pm, 0); diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c index 0c8188a48a00..d75f31eb9d78 100644 --- a/sound/hda/hdac_regmap.c +++ b/sound/hda/hdac_regmap.c @@ -363,6 +363,7 @@ static const struct regmap_config hda_regmap_cfg = { .reg_write = hda_reg_write, .use_single_read = true, .use_single_write = true, + .disable_locking = true, }; /** @@ -425,12 +426,29 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_add_vendor_verb); static int reg_raw_write(struct hdac_device *codec, unsigned int reg, unsigned int val) { + int err; + + mutex_lock(&codec->regmap_lock); if (!codec->regmap) - return hda_reg_write(codec, reg, val); + err = hda_reg_write(codec, reg, val); else - return regmap_write(codec->regmap, reg, val); + err = regmap_write(codec->regmap, reg, val); + mutex_unlock(&codec->regmap_lock); + return err; } +/* a helper macro to call @func_call; retry with power-up if failed */ +#define CALL_RAW_FUNC(codec, func_call) \ + ({ \ + int _err = func_call; \ + if (_err == -EAGAIN) { \ + _err = snd_hdac_power_up_pm(codec); \ + if (_err >= 0) \ + _err = func_call; \ + snd_hdac_power_down_pm(codec); \ + } \ + _err;}) + /** * snd_hdac_regmap_write_raw - write a pseudo register with power mgmt * @codec: the codec object @@ -442,42 +460,29 @@ static int reg_raw_write(struct hdac_device *codec, unsigned int reg, int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg, unsigned int val) { - int err; - - err = reg_raw_write(codec, reg, val); - if (err == -EAGAIN) { - err = snd_hdac_power_up_pm(codec); - if (err >= 0) - err = reg_raw_write(codec, reg, val); - snd_hdac_power_down_pm(codec); - } - return err; + return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val)); } EXPORT_SYMBOL_GPL(snd_hdac_regmap_write_raw); static int reg_raw_read(struct hdac_device *codec, unsigned int reg, unsigned int *val, bool uncached) { + int err; + + mutex_lock(&codec->regmap_lock); if (uncached || !codec->regmap) - return hda_reg_read(codec, reg, val); + err = hda_reg_read(codec, reg, val); else - return regmap_read(codec->regmap, reg, val); + err = regmap_read(codec->regmap, reg, val); + mutex_unlock(&codec->regmap_lock); + return err; } static int __snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg, unsigned int *val, bool uncached) { - int err; - - err = reg_raw_read(codec, reg, val, uncached); - if (err == -EAGAIN) { - err = snd_hdac_power_up_pm(codec); - if (err >= 0) - err = reg_raw_read(codec, reg, val, uncached); - snd_hdac_power_down_pm(codec); - } - return err; + return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached)); } /** @@ -504,6 +509,35 @@ int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, return __snd_hdac_regmap_read_raw(codec, reg, val, true); } +static int reg_raw_update(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val) +{ + unsigned int orig; + bool change; + int err; + + mutex_lock(&codec->regmap_lock); + if (codec->regmap) { + err = regmap_update_bits_check(codec->regmap, reg, mask, val, + &change); + if (!err) + err = change ? 1 : 0; + } else { + err = hda_reg_read(codec, reg, &orig); + if (!err) { + val &= mask; + val |= orig & ~mask; + if (val != orig) { + err = hda_reg_write(codec, reg, val); + if (!err) + err = 1; + } + } + } + mutex_unlock(&codec->regmap_lock); + return err; +} + /** * snd_hdac_regmap_update_raw - update a pseudo register with power mgmt * @codec: the codec object @@ -515,20 +549,58 @@ int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, */ int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg, unsigned int mask, unsigned int val) +{ + return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val)); +} +EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); + +static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val) { unsigned int orig; int err; - val &= mask; - err = snd_hdac_regmap_read_raw(codec, reg, &orig); - if (err < 0) - return err; - val |= orig & ~mask; - if (val == orig) - return 0; - err = snd_hdac_regmap_write_raw(codec, reg, val); + if (!codec->regmap) + return reg_raw_update(codec, reg, mask, val); + + mutex_lock(&codec->regmap_lock); + regcache_cache_only(codec->regmap, true); + err = regmap_read(codec->regmap, reg, &orig); + regcache_cache_only(codec->regmap, false); if (err < 0) - return err; - return 1; + err = regmap_update_bits(codec->regmap, reg, mask, val); + mutex_unlock(&codec->regmap_lock); + return err; } -EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); + +/** + * snd_hdac_regmap_update_raw_once - initialize the register value only once + * @codec: the codec object + * @reg: pseudo register + * @mask: bit mask to update + * @val: value to update + * + * Performs the update of the register bits only once when the register + * hasn't been initialized yet. Used in HD-audio legacy driver. + * Returns zero if successful or a negative error code + */ +int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg, + unsigned int mask, unsigned int val) +{ + return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val)); +} +EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once); + +/** + * snd_hdac_regmap_sync - sync out the cached values for PM resume + * @codec: the codec object + */ +void snd_hdac_regmap_sync(struct hdac_device *codec) +{ + if (codec->regmap) { + mutex_lock(&codec->regmap_lock); + regcache_sync(codec->regmap); + mutex_unlock(&codec->regmap_lock); + } +} +EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync); diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 4377b2aba835..83aa4c1015d2 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1267,6 +1267,18 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, } EXPORT_SYMBOL_GPL(snd_hda_override_amp_caps); +static unsigned int encode_amp(struct hda_codec *codec, hda_nid_t nid, + int ch, int dir, int idx) +{ + unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx); + + /* enable fake mute if no h/w mute but min=mute */ + if ((query_amp_caps(codec, nid, dir) & + (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) == AC_AMPCAP_MIN_MUTE) + cmd |= AC_AMP_FAKE_MUTE; + return cmd; +} + /** * snd_hda_codec_amp_update - update the AMP mono value * @codec: HD-audio codec @@ -1282,12 +1294,8 @@ EXPORT_SYMBOL_GPL(snd_hda_override_amp_caps); int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int dir, int idx, int mask, int val) { - unsigned int cmd = snd_hdac_regmap_encode_amp(nid, ch, dir, idx); + unsigned int cmd = encode_amp(codec, nid, ch, dir, idx); - /* enable fake mute if no h/w mute but min=mute */ - if ((query_amp_caps(codec, nid, dir) & - (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) == AC_AMPCAP_MIN_MUTE) - cmd |= AC_AMP_FAKE_MUTE; return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val); } EXPORT_SYMBOL_GPL(snd_hda_codec_amp_update); @@ -1335,16 +1343,11 @@ EXPORT_SYMBOL_GPL(snd_hda_codec_amp_stereo); int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch, int dir, int idx, int mask, int val) { - int orig; + unsigned int cmd = encode_amp(codec, nid, ch, dir, idx); if (!codec->core.regmap) return -EINVAL; - regcache_cache_only(codec->core.regmap, true); - orig = snd_hda_codec_amp_read(codec, nid, ch, dir, idx); - regcache_cache_only(codec->core.regmap, false); - if (orig >= 0) - return 0; - return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, mask, val); + return snd_hdac_regmap_update_raw_once(&codec->core, cmd, mask, val); } EXPORT_SYMBOL_GPL(snd_hda_codec_amp_init); @@ -2905,8 +2908,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) else { if (codec->patch_ops.init) codec->patch_ops.init(codec); - if (codec->core.regmap) - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); } if (codec->jackpoll_interval) diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index fc001c64ef20..6815f9dc8545 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -6027,7 +6027,7 @@ int snd_hda_gen_init(struct hda_codec *codec) /* call init functions of standard auto-mute helpers */ update_automute_all(codec); - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); if (spec->vmaster_mute.sw_kctl && spec->vmaster_mute.hook) snd_hda_sync_vmaster_hook(&spec->vmaster_mute); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 3942e1b528d8..3dca65d79b02 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -138,6 +138,8 @@ int snd_hda_codec_reset(struct hda_codec *codec); void snd_hda_codec_register(struct hda_codec *codec); void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec); +#define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core) + enum { HDA_VMUTE_OFF, HDA_VMUTE_ON, diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 3beb842817ff..3a18fa4f8c21 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2404,7 +2404,7 @@ static int generic_hdmi_resume(struct hda_codec *codec) int pin_idx; codec->patch_ops.init(codec); - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ed7982f5460d..27b522b9dfda 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -907,7 +907,7 @@ static int alc_resume(struct hda_codec *codec) if (!spec->no_depop_delay) msleep(150); /* to avoid pop noise */ codec->patch_ops.init(codec); - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); hda_call_check_power_status(codec, 0x01); return 0; } @@ -3638,7 +3638,7 @@ static int alc269_resume(struct hda_codec *codec) msleep(200); } - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); hda_call_check_power_status(codec, 0x01); /* on some machine, the BIOS will clear the codec gpio data when enter diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index b40d01e01832..7ef8f3105cdb 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -396,7 +396,7 @@ static int via_resume(struct hda_codec *codec) /* some delay here to make jack detection working (bko#98921) */ msleep(10); codec->patch_ops.init(codec); - regcache_sync(codec->core.regmap); + snd_hda_regmap_sync(codec); return 0; } #endif -- cgit v1.2.3 From ec0f6a4c4a987aa20b2e77e0db2ae555276e45e6 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Thu, 9 Jan 2020 11:14:22 -0800 Subject: ASoC: txx9: Remove unused rtd variable Commit a857e073ffc6 ("ASoC: txx9: txx9aclc: remove snd_pcm_ops") removed the last use of the rtd variable but didn't remove its definition, leading to the following warning/error for MIPS rbtx49xx_defconfig builds: sound/soc/txx9/txx9aclc.c: In function 'txx9aclc_pcm_hw_params': sound/soc/txx9/txx9aclc.c:54:30: error: unused variable 'rtd' [-Werror=unused-variable] struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); ^~~ Resolve this by removing the unused variable. Signed-off-by: Paul Burton Fixes: a857e073ffc6 ("ASoC: txx9: txx9aclc: remove snd_pcm_ops") Cc: Kuninori Morimoto Cc: Mark Brown Cc: Liam Girdwood Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Link: https://lore.kernel.org/r/20200109191422.334516-1-paulburton@kernel.org Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index dba13543911c..985487cc3a55 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -51,7 +51,6 @@ static int txx9aclc_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct txx9aclc_dmadata *dmadata = runtime->private_data; -- cgit v1.2.3 From d1ede0641b05e43542a6af330f6ca41014a02a5f Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Fri, 10 Jan 2020 10:18:21 +0800 Subject: ASoC: rt715: add RT715 codec driver Signed-off-by: Jack Yu Link: https://lore.kernel.org/r/20200110021821.17843-1-jack.yu@realtek.com Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 10 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt715-sdw.c | 613 ++++++++++++++++++++++++++++++ sound/soc/codecs/rt715-sdw.h | 337 +++++++++++++++++ sound/soc/codecs/rt715.c | 873 +++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt715.h | 221 +++++++++++ 6 files changed, 2056 insertions(+) create mode 100644 sound/soc/codecs/rt715-sdw.c create mode 100644 sound/soc/codecs/rt715-sdw.h create mode 100644 sound/soc/codecs/rt715.c create mode 100644 sound/soc/codecs/rt715.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 7761aeec4d07..cdfd912d5f8f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -167,6 +167,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT5682 if I2C select SND_SOC_RT700_SDW if SOUNDWIRE select SND_SOC_RT711_SDW if SOUNDWIRE + select SND_SOC_RT715_SDW if SOUNDWIRE select SND_SOC_SGTL5000 if I2C select SND_SOC_SI476X if MFD_SI476X_CORE select SND_SOC_SIMPLE_AMPLIFIER @@ -1079,6 +1080,15 @@ config SND_SOC_RT711_SDW select SND_SOC_RT711 select REGMAP_SOUNDWIRE +config SND_SOC_RT715 + tristate + +config SND_SOC_RT715_SDW + tristate "Realtek RT715 Codec - SDW" + depends on SOUNDWIRE + select SND_SOC_RT715 + select REGMAP_SOUNDWIRE + #Freescale sgtl5000 codec config SND_SOC_SGTL5000 tristate "Freescale SGTL5000 CODEC" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 288b7af354a0..ce285b33a806 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -175,6 +175,7 @@ snd-soc-rt5677-spi-objs := rt5677-spi.o snd-soc-rt5682-objs := rt5682.o snd-soc-rt700-objs := rt700.o rt700-sdw.o snd-soc-rt711-objs := rt711.o rt711-sdw.o +snd-soc-rt715-objs := rt715.o rt715-sdw.o snd-soc-sgtl5000-objs := sgtl5000.o snd-soc-alc5623-objs := alc5623.o snd-soc-alc5632-objs := alc5632.o @@ -469,6 +470,7 @@ obj-$(CONFIG_SND_SOC_RT5677_SPI) += snd-soc-rt5677-spi.o obj-$(CONFIG_SND_SOC_RT5682) += snd-soc-rt5682.o obj-$(CONFIG_SND_SOC_RT700) += snd-soc-rt700.o obj-$(CONFIG_SND_SOC_RT711) += snd-soc-rt711.o +obj-$(CONFIG_SND_SOC_RT715) += snd-soc-rt715.o obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o diff --git a/sound/soc/codecs/rt715-sdw.c b/sound/soc/codecs/rt715-sdw.c new file mode 100644 index 000000000000..c35591fd281b --- /dev/null +++ b/sound/soc/codecs/rt715-sdw.c @@ -0,0 +1,613 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * rt715-sdw.c -- rt715 ALSA SoC audio driver + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + * + * ALC715 ASoC Codec Driver based Intel Dummy SdW codec driver + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rt715.h" +#include "rt715-sdw.h" + +static bool rt715_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0 ... 0x00e5: + case 0x00ee ... 0x00ef: + case 0x00f0 ... 0x00f5: + case 0x00fe ... 0x00ff: + case 0x02e0: + case 0x02f0: + case 0x04e0: + case 0x04f0: + case 0x06e0: + case 0x06f0: + case 0x2000 ... 0x2016: + case 0x201a ... 0x2027: + case 0x2029 ... 0x202a: + case 0x202d ... 0x2034: + case 0x2200 ... 0x2204: + case 0x2206 ... 0x2212: + case 0x2220 ... 0x2223: + case 0x2230 ... 0x2239: + case 0x22f0 ... 0x22f3: + case 0x3122: + case 0x3123: + case 0x3124: + case 0x3125: + case 0x3607: + case 0x3608: + case 0x3609: + case 0x3610: + case 0x3611: + case 0x3627: + case 0x3712: + case 0x3713: + case 0x3718: + case 0x3719: + case 0x371a: + case 0x371b: + case 0x371d: + case 0x3729: + case 0x385e: + case 0x3859: + case 0x4c12: + case 0x4c13: + case 0x4c1d: + case 0x4c29: + case 0x4d12: + case 0x4d13: + case 0x4d1d: + case 0x4d29: + case 0x4e12: + case 0x4e13: + case 0x4e1d: + case 0x4e29: + case 0x4f12: + case 0x4f13: + case 0x4f1d: + case 0x4f29: + case 0x7207: + case 0x7208: + case 0x7209: + case 0x7227: + case 0x7307: + case 0x7308: + case 0x7309: + case 0x7312: + case 0x7313: + case 0x7318: + case 0x7319: + case 0x731a: + case 0x731b: + case 0x731d: + case 0x7327: + case 0x7329: + case 0x8287: + case 0x8288: + case 0x8289: + case 0x82a7: + case 0x8387: + case 0x8388: + case 0x8389: + case 0x8392: + case 0x8393: + case 0x8398: + case 0x8399: + case 0x839a: + case 0x839b: + case 0x839d: + case 0x83a7: + case 0x83a9: + case 0x752039: + return true; + default: + return false; + } +} + +static bool rt715_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e5: + case 0x00f0: + case 0x00f3: + case 0x00f5: + case 0x2009: + case 0x2016: + case 0x201b: + case 0x201c: + case 0x201d: + case 0x201f: + case 0x2023: + case 0x2230: + case 0x200b ... 0x200e: /* i2c read */ + case 0x2012 ... 0x2015: /* HD-A read */ + case 0x202d ... 0x202f: /* BRA */ + case 0x2201 ... 0x2212: /* i2c debug */ + case 0x2220 ... 0x2223: /* decoded HD-A */ + return true; + default: + return false; + } +} + +static int rt715_sdw_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int sdw_data_3, sdw_data_2, sdw_data_1, sdw_data_0; + unsigned int reg2 = 0, reg3 = 0, reg4 = 0, mask, nid, val2; + unsigned int is_hda_reg = 1, is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt715->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT715_PRIV_DATA_R_H | nid; + ret = regmap_write(rt715->sdw_regmap, reg3, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg4, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x3000) { + reg += 0x8000; + ret = regmap_write(rt715->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + reg += 0x2000; + reg |= 0x800; + ret = regmap_write(rt715->sdw_regmap, reg, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt715->sdw_regmap, reg, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0x9000) { + ret = regmap_write(rt715->sdw_regmap, reg, + ((*val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (*val & 0xff)); + if (ret < 0) + return ret; + } else if (mask == 0xb000) { + ret = regmap_write(rt715->sdw_regmap, reg, *val); + if (ret < 0) + return ret; + } else { + ret = regmap_read(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + is_hda_reg = 0; + } + + if (is_hda_reg || is_index_reg) { + sdw_data_3 = 0; + sdw_data_2 = 0; + sdw_data_1 = 0; + sdw_data_0 = 0; + ret = regmap_read(rt715->sdw_regmap, RT715_READ_HDA_3, + &sdw_data_3); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, RT715_READ_HDA_2, + &sdw_data_2); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, RT715_READ_HDA_1, + &sdw_data_1); + if (ret < 0) + return ret; + ret = regmap_read(rt715->sdw_regmap, RT715_READ_HDA_0, + &sdw_data_0); + if (ret < 0) + return ret; + *val = ((sdw_data_3 & 0xff) << 24) | + ((sdw_data_2 & 0xff) << 16) | + ((sdw_data_1 & 0xff) << 8) | (sdw_data_0 & 0xff); + } + + if (is_hda_reg == 0) + dev_dbg(dev, "[%s] %04x => %08x\n", __func__, reg, *val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x => %08x\n", __func__, + reg, reg2, reg3, reg4, *val); + else + dev_dbg(dev, "[%s] %04x %04x => %08x\n", + __func__, reg, reg2, *val); + + return 0; +} + +static int rt715_sdw_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int reg2 = 0, reg3, reg4, nid, mask, val2; + unsigned int is_index_reg = 0; + int ret; + + if (reg > 0xffff) + is_index_reg = 1; + + mask = reg & 0xf000; + + if (is_index_reg) { /* index registers */ + val2 = reg & 0xff; + reg = reg >> 8; + nid = reg & 0xff; + ret = regmap_write(rt715->sdw_regmap, reg, 0); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, val2); + if (ret < 0) + return ret; + + reg3 = RT715_PRIV_DATA_W_H | nid; + ret = regmap_write(rt715->sdw_regmap, reg3, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg4 = reg3 + 0x1000; + reg4 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg4, (val & 0xff)); + if (ret < 0) + return ret; + is_index_reg = 1; + } else if (reg < 0x4fff) { + ret = regmap_write(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (reg == RT715_FUNC_RESET) { + ret = regmap_write(rt715->sdw_regmap, reg, val); + if (ret < 0) + return ret; + } else if (mask == 0x7000) { + ret = regmap_write(rt715->sdw_regmap, reg, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + reg2 = reg + 0x1000; + reg2 |= 0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, (val & 0xff)); + if (ret < 0) + return ret; + } else if ((reg & 0xff00) == 0x8300) { /* for R channel */ + reg2 = reg - 0x1000; + reg2 &= ~0x80; + ret = regmap_write(rt715->sdw_regmap, reg2, + ((val >> 8) & 0xff)); + if (ret < 0) + return ret; + ret = regmap_write(rt715->sdw_regmap, reg, (val & 0xff)); + if (ret < 0) + return ret; + } + + if (reg2 == 0) + dev_dbg(dev, "[%s] %04x <= %04x\n", __func__, reg, val); + else if (is_index_reg) + dev_dbg(dev, "[%s] %04x %04x %04x %04x <= %04x %04x\n", + __func__, reg, reg2, reg3, reg4, val2, val); + else + dev_dbg(dev, "[%s] %04x %04x <= %04x\n", + __func__, reg, reg2, val); + + return 0; +} + +static const struct regmap_config rt715_regmap = { + .reg_bits = 24, + .val_bits = 32, + .readable_reg = rt715_readable_register, /* Readable registers */ + .volatile_reg = rt715_volatile_register, /* volatile register */ + .max_register = 0x752039, /* Maximum number of register */ + .reg_defaults = rt715_reg_defaults, /* Defaults */ + .num_reg_defaults = ARRAY_SIZE(rt715_reg_defaults), + .cache_type = REGCACHE_RBTREE, + .use_single_read = true, + .use_single_write = true, + .reg_read = rt715_sdw_read, + .reg_write = rt715_sdw_write, +}; + +static const struct regmap_config rt715_sdw_regmap = { + .name = "sdw", + .reg_bits = 32, /* Total register space for SDW */ + .val_bits = 8, /* Total number of bits in register */ + .max_register = 0xff01, /* Maximum number of register */ + .cache_type = REGCACHE_NONE, + .use_single_read = true, + .use_single_write = true, +}; + +int hda_to_sdw(unsigned int nid, unsigned int verb, unsigned int payload, + unsigned int *sdw_addr_h, unsigned int *sdw_data_h, + unsigned int *sdw_addr_l, unsigned int *sdw_data_l) +{ + unsigned int offset_h, offset_l, e_verb; + + if (((verb & 0xff) != 0) || verb == 0xf00) { /* 12 bits command */ + if (verb == 0x7ff) /* special case */ + offset_h = 0; + else + offset_h = 0x3000; + + if (verb & 0x800) /* get command */ + e_verb = (verb - 0xf00) | 0x80; + else /* set command */ + e_verb = (verb - 0x700); + + *sdw_data_h = payload; /* 7 bits payload */ + *sdw_addr_l = *sdw_data_l = 0; + } else { /* 4 bits command */ + if ((verb & 0x800) == 0x800) { /* read */ + offset_h = 0x9000; + offset_l = 0xa000; + } else { /* write */ + offset_h = 0x7000; + offset_l = 0x8000; + } + e_verb = verb >> 8; + *sdw_data_h = (payload >> 8); /* 16 bits payload [15:8] */ + *sdw_addr_l = (e_verb << 8) | nid | 0x80; /* 0x80: valid bit */ + *sdw_addr_l += offset_l; + *sdw_data_l = payload & 0xff; + } + + *sdw_addr_h = (e_verb << 8) | nid; + *sdw_addr_h += offset_h; + + return 0; +} +EXPORT_SYMBOL(hda_to_sdw); + +static int rt715_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt715_priv *rt715 = dev_get_drvdata(&slave->dev); + + /* Update the status */ + rt715->status = status; + /* + * Perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt715->hw_init || rt715->status != SDW_SLAVE_ATTACHED) + return 0; + + /* perform I/O transfers required for Slave initialization */ + return rt715_io_init(&slave->dev, slave); +} + +static int rt715_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = false; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x50;/* BITMAP: 01010000 */ + prop->sink_ports = 0x0; /* BITMAP: 00000000 */ + + nval = hweight32(prop->source_ports); + num_of_ports += nval; + prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->src_dpn_prop), + GFP_KERNEL); + if (!prop->src_dpn_prop) + return -ENOMEM; + + dpn = prop->src_dpn_prop; + i = 0; + addr = prop->source_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* do this again for sink now */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + GFP_KERNEL); + if (!prop->sink_dpn_prop) + return -ENOMEM; + + dpn = prop->sink_dpn_prop; + i = 0; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* Allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + GFP_KERNEL); + if (!slave->port_ready) + return -ENOMEM; + + /* Initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + /* wake-up event */ + prop->wake_capable = 1; + + return 0; +} + +static int rt715_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt715_priv *rt715 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt715->params, params, sizeof(*params)); + + ret = rt715_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "Invalid clk config"); + + return 0; +} + +static struct sdw_slave_ops rt715_slave_ops = { + .read_prop = rt715_read_prop, + .update_status = rt715_update_status, + .bus_config = rt715_bus_config, +}; + +static int rt715_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *sdw_regmap, *regmap; + + /* Assign ops */ + slave->ops = &rt715_slave_ops; + + /* Regmap Initialization */ + sdw_regmap = devm_regmap_init_sdw(slave, &rt715_sdw_regmap); + if (!sdw_regmap) + return -EINVAL; + + regmap = devm_regmap_init(&slave->dev, NULL, &slave->dev, + &rt715_regmap); + if (!regmap) + return -EINVAL; + + rt715_init(&slave->dev, sdw_regmap, regmap, slave); + + return 0; +} + +static const struct sdw_device_id rt715_id[] = { + SDW_SLAVE_ENTRY(0x025d, 0x715, 0), + {}, +}; +MODULE_DEVICE_TABLE(sdw, rt715_id); + +static int rt715_dev_suspend(struct device *dev) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + + if (!rt715->hw_init) + return 0; + + regcache_cache_only(rt715->regmap, true); + + return 0; +} + +#define RT715_PROBE_TIMEOUT 2000 + +static int rt715_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = to_sdw_slave_device(dev); + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt715->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(RT715_PROBE_TIMEOUT)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete, timed out\n"); + return -ETIMEDOUT; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt715->regmap, false); + regcache_sync_region(rt715->regmap, 0x3000, 0x8fff); + regcache_sync_region(rt715->regmap, 0x752039, 0x752039); + + return 0; +} + +static const struct dev_pm_ops rt715_pm = { + SET_SYSTEM_SLEEP_PM_OPS(rt715_dev_suspend, rt715_dev_resume) + SET_RUNTIME_PM_OPS(rt715_dev_suspend, rt715_dev_resume, NULL) +}; + +static struct sdw_driver rt715_sdw_driver = { + .driver = { + .name = "rt715", + .owner = THIS_MODULE, + .pm = &rt715_pm, + }, + .probe = rt715_sdw_probe, + .ops = &rt715_slave_ops, + .id_table = rt715_id, +}; +module_sdw_driver(rt715_sdw_driver); + +MODULE_DESCRIPTION("ASoC RT715 driver SDW"); +MODULE_AUTHOR("Jack Yu "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt715-sdw.h b/sound/soc/codecs/rt715-sdw.h new file mode 100644 index 000000000000..5d7661e335ae --- /dev/null +++ b/sound/soc/codecs/rt715-sdw.h @@ -0,0 +1,337 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt715-sdw.h -- RT715 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT715_SDW_H__ +#define __RT715_SDW_H__ + +static const struct reg_default rt715_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x00 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5d }, + { 0x0053, 0x07 }, + { 0x0054, 0x15 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x0080, 0x00 }, + { 0x0088, 0x10 }, + { 0x00e0, 0x00 }, + { 0x00e1, 0x00 }, + { 0x00e2, 0x00 }, + { 0x00e3, 0x00 }, + { 0x00e4, 0x00 }, + { 0x00e5, 0x00 }, + { 0x00ee, 0x00 }, + { 0x00ef, 0x00 }, + { 0x00f0, 0x00 }, + { 0x00f1, 0x00 }, + { 0x00f2, 0x00 }, + { 0x00f3, 0x00 }, + { 0x00f4, 0x00 }, + { 0x00f5, 0x00 }, + { 0x00fe, 0x00 }, + { 0x00ff, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x20 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0221, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0231, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x02e0, 0x00 }, + { 0x02f0, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x20 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x0f }, + { 0x0420, 0x00 }, + { 0x0421, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0431, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x04e0, 0x00 }, + { 0x04f0, 0x00 }, + { 0x0600, 0x00 }, + { 0x0601, 0x00 }, + { 0x0602, 0x20 }, + { 0x0603, 0x00 }, + { 0x0604, 0x00 }, + { 0x0605, 0xff }, + { 0x0620, 0x00 }, + { 0x0621, 0x00 }, + { 0x0622, 0x00 }, + { 0x0623, 0x00 }, + { 0x0624, 0x00 }, + { 0x0625, 0x00 }, + { 0x0626, 0x00 }, + { 0x0627, 0x00 }, + { 0x0630, 0x00 }, + { 0x0631, 0x00 }, + { 0x0632, 0x00 }, + { 0x0633, 0x00 }, + { 0x0634, 0x00 }, + { 0x0635, 0x00 }, + { 0x0636, 0x00 }, + { 0x0637, 0x00 }, + { 0x06e0, 0x00 }, + { 0x06f0, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x00 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0xff }, + { 0x0f06, 0x00 }, + { 0x0f07, 0x00 }, + { 0x0f08, 0x00 }, + { 0x0f09, 0x00 }, + { 0x0f0a, 0x00 }, + { 0x0f0b, 0x00 }, + { 0x0f0c, 0x00 }, + { 0x0f0d, 0x00 }, + { 0x0f0e, 0x00 }, + { 0x0f0f, 0x00 }, + { 0x0f10, 0x00 }, + { 0x0f11, 0x00 }, + { 0x0f12, 0x00 }, + { 0x0f13, 0x00 }, + { 0x0f14, 0x00 }, + { 0x0f15, 0x00 }, + { 0x0f16, 0x00 }, + { 0x0f17, 0x00 }, + { 0x0f18, 0x00 }, + { 0x0f19, 0x00 }, + { 0x0f1a, 0x00 }, + { 0x0f1b, 0x00 }, + { 0x0f1c, 0x00 }, + { 0x0f1d, 0x00 }, + { 0x0f1e, 0x00 }, + { 0x0f1f, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f21, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f31, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2000, 0x00 }, + { 0x2001, 0x00 }, + { 0x2002, 0x00 }, + { 0x2003, 0x00 }, + { 0x2004, 0x00 }, + { 0x2005, 0x00 }, + { 0x2006, 0x00 }, + { 0x2007, 0x00 }, + { 0x2008, 0x00 }, + { 0x2009, 0x03 }, + { 0x200a, 0x00 }, + { 0x200b, 0x00 }, + { 0x200c, 0x00 }, + { 0x200d, 0x00 }, + { 0x200e, 0x00 }, + { 0x200f, 0x10 }, + { 0x2010, 0x00 }, + { 0x2011, 0x00 }, + { 0x2012, 0x00 }, + { 0x2013, 0x00 }, + { 0x2014, 0x00 }, + { 0x2015, 0x00 }, + { 0x2016, 0x00 }, + { 0x201a, 0x00 }, + { 0x201b, 0x00 }, + { 0x201c, 0x00 }, + { 0x201d, 0x00 }, + { 0x201e, 0x00 }, + { 0x201f, 0x00 }, + { 0x2020, 0x00 }, + { 0x2021, 0x00 }, + { 0x2022, 0x00 }, + { 0x2023, 0x00 }, + { 0x2024, 0x00 }, + { 0x2025, 0x01 }, + { 0x2026, 0x00 }, + { 0x2027, 0x00 }, + { 0x2029, 0x00 }, + { 0x202a, 0x00 }, + { 0x202d, 0x00 }, + { 0x202e, 0x00 }, + { 0x202f, 0x00 }, + { 0x2030, 0x00 }, + { 0x2031, 0x00 }, + { 0x2032, 0x00 }, + { 0x2033, 0x00 }, + { 0x2034, 0x00 }, + { 0x2200, 0x00 }, + { 0x2201, 0x00 }, + { 0x2202, 0x00 }, + { 0x2203, 0x00 }, + { 0x2204, 0x00 }, + { 0x2206, 0x00 }, + { 0x2207, 0x00 }, + { 0x2208, 0x00 }, + { 0x2209, 0x00 }, + { 0x220a, 0x00 }, + { 0x220b, 0x00 }, + { 0x220c, 0x00 }, + { 0x220d, 0x00 }, + { 0x220e, 0x00 }, + { 0x220f, 0x00 }, + { 0x2210, 0x00 }, + { 0x2211, 0x00 }, + { 0x2212, 0x00 }, + { 0x2220, 0x00 }, + { 0x2221, 0x00 }, + { 0x2222, 0x00 }, + { 0x2223, 0x00 }, + { 0x2230, 0x00 }, + { 0x2231, 0x0f }, + { 0x2232, 0x00 }, + { 0x2233, 0x00 }, + { 0x2234, 0x00 }, + { 0x2235, 0x00 }, + { 0x2236, 0x00 }, + { 0x2237, 0x00 }, + { 0x2238, 0x00 }, + { 0x2239, 0x00 }, + { 0x22f0, 0x00 }, + { 0x22f1, 0x00 }, + { 0x22f2, 0x00 }, + { 0x22f3, 0x00 }, + { 0x3122, 0x02 }, + { 0x3123, 0x03 }, + { 0x3124, 0x00 }, + { 0x3125, 0x01 }, + { 0x3607, 0x00 }, + { 0x3608, 0x00 }, + { 0x3609, 0x00 }, + { 0x3610, 0x00 }, + { 0x3611, 0x00 }, + { 0x3627, 0x00 }, + { 0x3712, 0x00 }, + { 0x3713, 0x00 }, + { 0x3718, 0x00 }, + { 0x3719, 0x00 }, + { 0x371a, 0x00 }, + { 0x371b, 0x00 }, + { 0x371d, 0x00 }, + { 0x3729, 0x00 }, + { 0x385e, 0x00 }, + { 0x3859, 0x00 }, + { 0x4c12, 0x411111f0 }, + { 0x4c13, 0x411111f0 }, + { 0x4c1d, 0x411111f0 }, + { 0x4c29, 0x411111f0 }, + { 0x4d12, 0x411111f0 }, + { 0x4d13, 0x411111f0 }, + { 0x4d1d, 0x411111f0 }, + { 0x4d29, 0x411111f0 }, + { 0x4e12, 0x411111f0 }, + { 0x4e13, 0x411111f0 }, + { 0x4e1d, 0x411111f0 }, + { 0x4e29, 0x411111f0 }, + { 0x4f12, 0x411111f0 }, + { 0x4f13, 0x411111f0 }, + { 0x4f1d, 0x411111f0 }, + { 0x4f29, 0x411111f0 }, + { 0x7207, 0x00 }, + { 0x8287, 0x00 }, + { 0x7208, 0x00 }, + { 0x8288, 0x00 }, + { 0x7209, 0x00 }, + { 0x8289, 0x00 }, + { 0x7227, 0x00 }, + { 0x82a7, 0x00 }, + { 0x7307, 0x97 }, + { 0x8387, 0x97 }, + { 0x7308, 0x97 }, + { 0x8388, 0x97 }, + { 0x7309, 0x97 }, + { 0x8389, 0x97 }, + { 0x7312, 0x00 }, + { 0x8392, 0x00 }, + { 0x7313, 0x00 }, + { 0x8393, 0x00 }, + { 0x7318, 0x00 }, + { 0x8398, 0x00 }, + { 0x7319, 0x00 }, + { 0x8399, 0x00 }, + { 0x731a, 0x00 }, + { 0x839a, 0x00 }, + { 0x731b, 0x00 }, + { 0x839b, 0x00 }, + { 0x731d, 0x00 }, + { 0x839d, 0x00 }, + { 0x7327, 0x97 }, + { 0x83a7, 0x97 }, + { 0x7329, 0x00 }, + { 0x83a9, 0x00 }, + { 0x752039, 0xa500 }, +}; + +#endif /* __RT715_H__ */ diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c new file mode 100644 index 000000000000..5c6f05b8d8ab --- /dev/null +++ b/sound/soc/codecs/rt715.c @@ -0,0 +1,873 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * rt715.c -- rt715 ALSA SoC audio driver + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + * + * ALC715 ASoC Codec Driver based Intel Dummy SdW codec driver + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rt715.h" + +static int rt715_index_write(struct regmap *regmap, unsigned int reg, + unsigned int value) +{ + int ret; + unsigned int addr = ((RT715_PRIV_INDEX_W_H) << 8) | reg; + + ret = regmap_write(regmap, addr, value); + if (ret < 0) { + pr_err("Failed to set private value: %08x <= %04x %d\n", ret, + addr, value); + } + + return ret; +} + +static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h, + unsigned int addr_l, unsigned int val_h, + unsigned int *r_val, unsigned int *l_val) +{ + int ret; + /* R Channel */ + *r_val = (val_h << 8); + ret = regmap_read(rt715->regmap, addr_l, r_val); + if (ret < 0) + pr_err("Failed to get R channel gain.\n"); + + /* L Channel */ + val_h |= 0x20; + *l_val = (val_h << 8); + ret = regmap_read(rt715->regmap, addr_h, l_val); + if (ret < 0) + pr_err("Failed to get L channel gain.\n"); +} + +/* For Verb-Set Amplifier Gain (Verb ID = 3h) */ +static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + unsigned int addr_h, addr_l, val_h, val_ll, val_lr; + unsigned int read_ll, read_rl; + int i; + + /* Can't use update bit function, so read the original value first */ + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT715_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); + + /* L Channel */ + if (mc->invert) { + /* for mute */ + val_ll = (mc->max - ucontrol->value.integer.value[0]) << 7; + /* keep gain */ + read_ll = read_ll & 0x7f; + val_ll |= read_ll; + } else { + /* for gain */ + val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); + if (val_ll > mc->max) + val_ll = mc->max; + /* keep mute status */ + read_ll = read_ll & 0x80; + val_ll |= read_ll; + } + + /* R Channel */ + if (mc->invert) { + regmap_write(rt715->regmap, + RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D0); + /* for mute */ + val_lr = (mc->max - ucontrol->value.integer.value[1]) << 7; + /* keep gain */ + read_rl = read_rl & 0x7f; + val_lr |= read_rl; + } else { + /* for gain */ + val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); + if (val_lr > mc->max) + val_lr = mc->max; + /* keep mute status */ + read_rl = read_rl & 0x80; + val_lr |= read_rl; + } + + for (i = 0; i < 3; i++) { /* retry 3 times at most */ + + if (val_ll == val_lr) { + /* Set both L/R channels at the same time */ + val_h = (1 << mc->shift) | (3 << 4); + regmap_write(rt715->regmap, addr_h, + (val_h << 8 | val_ll)); + regmap_write(rt715->regmap, addr_l, + (val_h << 8 | val_ll)); + } else { + /* Lch*/ + val_h = (1 << mc->shift) | (1 << 5); + regmap_write(rt715->regmap, addr_h, + (val_h << 8 | val_ll)); + /* Rch */ + val_h = (1 << mc->shift) | (1 << 4); + regmap_write(rt715->regmap, addr_l, + (val_h << 8 | val_lr)); + } + /* check result */ + if (mc->shift == RT715_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, + &read_rl, &read_ll); + if (read_rl == val_lr && read_ll == val_ll) + break; + } + /* D0:power on state, D3: power saving mode */ + if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) + regmap_write(rt715->regmap, + RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + return 0; +} + +static int rt715_set_amp_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + unsigned int addr_h, addr_l, val_h; + unsigned int read_ll, read_rl; + + addr_h = mc->reg; + addr_l = mc->rreg; + if (mc->shift == RT715_DIR_OUT_SFT) /* output */ + val_h = 0x80; + else /* input */ + val_h = 0x0; + + rt715_get_gain(rt715, addr_h, addr_l, val_h, &read_rl, &read_ll); + + if (mc->invert) { + /* for mute status */ + read_ll = !((read_ll & 0x80) >> RT715_MUTE_SFT); + read_rl = !((read_rl & 0x80) >> RT715_MUTE_SFT); + } else { + /* for gain */ + read_ll = read_ll & 0x7f; + read_rl = read_rl & 0x7f; + } + ucontrol->value.integer.value[0] = read_ll; + ucontrol->value.integer.value[1] = read_rl; + + return 0; +} + +static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); +static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); +static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); + +#define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\ + xhandler_get, xhandler_put) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ + .info = snd_soc_info_volsw, \ + .get = xhandler_get, .put = xhandler_put, \ + .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ + xmax, xinvert) } + +static const struct snd_kcontrol_new rt715_snd_controls[] = { + /* Capture switch */ + SOC_DOUBLE_R_EXT("ADC 07 Capture Switch", RT715_SET_GAIN_MIC_ADC_H, + RT715_SET_GAIN_MIC_ADC_L, RT715_DIR_IN_SFT, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + SOC_DOUBLE_R_EXT("ADC 08 Capture Switch", RT715_SET_GAIN_LINE_ADC_H, + RT715_SET_GAIN_LINE_ADC_L, RT715_DIR_IN_SFT, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + SOC_DOUBLE_R_EXT("ADC 09 Capture Switch", RT715_SET_GAIN_MIX_ADC_H, + RT715_SET_GAIN_MIX_ADC_L, RT715_DIR_IN_SFT, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + SOC_DOUBLE_R_EXT("ADC 27 Capture Switch", RT715_SET_GAIN_MIX_ADC2_H, + RT715_SET_GAIN_MIX_ADC2_L, RT715_DIR_IN_SFT, 1, 1, + rt715_set_amp_gain_get, rt715_set_amp_gain_put), + /* Volume Control */ + SOC_DOUBLE_R_EXT_TLV("ADC 07 Capture Volume", RT715_SET_GAIN_MIC_ADC_H, + RT715_SET_GAIN_MIC_ADC_L, RT715_DIR_IN_SFT, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("ADC 08 Capture Volume", RT715_SET_GAIN_LINE_ADC_H, + RT715_SET_GAIN_LINE_ADC_L, RT715_DIR_IN_SFT, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("ADC 09 Capture Volume", RT715_SET_GAIN_MIX_ADC_H, + RT715_SET_GAIN_MIX_ADC_L, RT715_DIR_IN_SFT, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("ADC 27 Capture Volume", RT715_SET_GAIN_MIX_ADC2_H, + RT715_SET_GAIN_MIX_ADC2_L, RT715_DIR_IN_SFT, 0x3f, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + in_vol_tlv), + /* MIC Boost Control */ + SOC_DOUBLE_R_EXT_TLV("DMIC1 Boost", RT715_SET_GAIN_DMIC1_H, + RT715_SET_GAIN_DMIC1_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("DMIC2 Boost", RT715_SET_GAIN_DMIC2_H, + RT715_SET_GAIN_DMIC2_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("DMIC3 Boost", RT715_SET_GAIN_DMIC3_H, + RT715_SET_GAIN_DMIC3_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("DMIC4 Boost", RT715_SET_GAIN_DMIC4_H, + RT715_SET_GAIN_DMIC4_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("MIC1 Boost", RT715_SET_GAIN_MIC1_H, + RT715_SET_GAIN_MIC1_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("MIC2 Boost", RT715_SET_GAIN_MIC2_H, + RT715_SET_GAIN_MIC2_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("LINE1 Boost", RT715_SET_GAIN_LINE1_H, + RT715_SET_GAIN_LINE1_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), + SOC_DOUBLE_R_EXT_TLV("LINE2 Boost", RT715_SET_GAIN_LINE2_H, + RT715_SET_GAIN_LINE2_L, RT715_DIR_IN_SFT, 3, 0, + rt715_set_amp_gain_get, rt715_set_amp_gain_put, + mic_vol_tlv), +}; + +static int rt715_mux_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int reg, val; + int ret; + + /* nid = e->reg, vid = 0xf01 */ + reg = RT715_VERB_SET_CONNECT_SEL | e->reg; + ret = regmap_read(rt715->regmap, reg, &val); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d\n", + __func__, ret); + return ret; + } + + /* + * The first two indices of ADC Mux 24/25 are routed to the same + * hardware source. ie, ADC Mux 24 0/1 will both connect to MIC2. + * To have a unique set of inputs, we skip the index1 of the muxes. + */ + if ((e->reg == RT715_MUX_IN3 || e->reg == RT715_MUX_IN4) && (val > 0)) + val -= 1; + ucontrol->value.enumerated.item[0] = val; + + return 0; +} + +static int rt715_mux_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + unsigned int val, val2 = 0, change, reg; + int ret; + + if (item[0] >= e->items) + return -EINVAL; + + /* Verb ID = 0x701h, nid = e->reg */ + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + reg = RT715_VERB_SET_CONNECT_SEL | e->reg; + ret = regmap_read(rt715->regmap, reg, &val2); + if (ret < 0) { + dev_err(component->dev, "%s: sdw read failed: %d\n", + __func__, ret); + return ret; + } + + if (val == val2) + change = 0; + else + change = 1; + + if (change) { + reg = RT715_VERB_SET_CONNECT_SEL | e->reg; + regmap_write(rt715->regmap, reg, val); + } + + snd_soc_dapm_mux_update_power(dapm, kcontrol, + item[0], e, NULL); + + return change; +} + +static const char * const adc_22_23_mux_text[] = { + "MIC1", + "MIC2", + "LINE1", + "LINE2", + "DMIC1", + "DMIC2", + "DMIC3", + "DMIC4", +}; + +/** + * Due to mux design for nid 24 (MUX_IN3)/25 (MUX_IN4), connection index 0 and + * 1 will be connected to the same dmic source, therefore we skip index 1 to + * avoid misunderstanding on usage of dapm routing. + */ +static const unsigned int rt715_adc_24_25_values[] = { + 0, + 2, + 3, + 4, + 5, +}; + +static const char * const adc_24_mux_text[] = { + "MIC2", + "DMIC1", + "DMIC2", + "DMIC3", + "DMIC4", +}; + +static const char * const adc_25_mux_text[] = { + "MIC1", + "DMIC1", + "DMIC2", + "DMIC3", + "DMIC4", +}; + +static SOC_ENUM_SINGLE_DECL( + rt715_adc22_enum, RT715_MUX_IN1, 0, adc_22_23_mux_text); + +static SOC_ENUM_SINGLE_DECL( + rt715_adc23_enum, RT715_MUX_IN2, 0, adc_22_23_mux_text); + +static SOC_VALUE_ENUM_SINGLE_DECL(rt715_adc24_enum, + RT715_MUX_IN3, 0, 0xf, + adc_24_mux_text, rt715_adc_24_25_values); +static SOC_VALUE_ENUM_SINGLE_DECL(rt715_adc25_enum, + RT715_MUX_IN4, 0, 0xf, + adc_25_mux_text, rt715_adc_24_25_values); + +static const struct snd_kcontrol_new rt715_adc22_mux = + SOC_DAPM_ENUM_EXT("ADC 22 Mux", rt715_adc22_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc23_mux = + SOC_DAPM_ENUM_EXT("ADC 23 Mux", rt715_adc23_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc24_mux = + SOC_DAPM_ENUM_EXT("ADC 24 Mux", rt715_adc24_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_kcontrol_new rt715_adc25_mux = + SOC_DAPM_ENUM_EXT("ADC 25 Mux", rt715_adc25_enum, + rt715_mux_get, rt715_mux_put); + +static const struct snd_soc_dapm_widget rt715_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("DMIC1"), + SND_SOC_DAPM_INPUT("DMIC2"), + SND_SOC_DAPM_INPUT("DMIC3"), + SND_SOC_DAPM_INPUT("DMIC4"), + SND_SOC_DAPM_INPUT("MIC1"), + SND_SOC_DAPM_INPUT("MIC2"), + SND_SOC_DAPM_INPUT("LINE1"), + SND_SOC_DAPM_INPUT("LINE2"), + SND_SOC_DAPM_ADC("ADC 07", NULL, RT715_SET_STREAMID_MIC_ADC, 4, 0), + SND_SOC_DAPM_ADC("ADC 08", NULL, RT715_SET_STREAMID_LINE_ADC, 4, 0), + SND_SOC_DAPM_ADC("ADC 09", NULL, RT715_SET_STREAMID_MIX_ADC, 4, 0), + SND_SOC_DAPM_ADC("ADC 27", NULL, RT715_SET_STREAMID_MIX_ADC2, 4, 0), + SND_SOC_DAPM_MUX("ADC 22 Mux", SND_SOC_NOPM, 0, 0, + &rt715_adc22_mux), + SND_SOC_DAPM_MUX("ADC 23 Mux", SND_SOC_NOPM, 0, 0, + &rt715_adc23_mux), + SND_SOC_DAPM_MUX("ADC 24 Mux", SND_SOC_NOPM, 0, 0, + &rt715_adc24_mux), + SND_SOC_DAPM_MUX("ADC 25 Mux", SND_SOC_NOPM, 0, 0, + &rt715_adc25_mux), + SND_SOC_DAPM_AIF_OUT("DP4TX", "DP4 Capture", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("DP6TX", "DP6 Capture", 0, SND_SOC_NOPM, 0, 0), +}; + +static const struct snd_soc_dapm_route rt715_audio_map[] = { + {"DP6TX", NULL, "ADC 09"}, + {"DP6TX", NULL, "ADC 08"}, + {"DP4TX", NULL, "ADC 07"}, + {"DP4TX", NULL, "ADC 27"}, + {"ADC 09", NULL, "ADC 22 Mux"}, + {"ADC 08", NULL, "ADC 23 Mux"}, + {"ADC 07", NULL, "ADC 24 Mux"}, + {"ADC 27", NULL, "ADC 25 Mux"}, + {"ADC 22 Mux", "MIC1", "MIC1"}, + {"ADC 22 Mux", "MIC2", "MIC2"}, + {"ADC 22 Mux", "LINE1", "LINE1"}, + {"ADC 22 Mux", "LINE2", "LINE2"}, + {"ADC 22 Mux", "DMIC1", "DMIC1"}, + {"ADC 22 Mux", "DMIC2", "DMIC2"}, + {"ADC 22 Mux", "DMIC3", "DMIC3"}, + {"ADC 22 Mux", "DMIC4", "DMIC4"}, + {"ADC 23 Mux", "MIC1", "MIC1"}, + {"ADC 23 Mux", "MIC2", "MIC2"}, + {"ADC 23 Mux", "LINE1", "LINE1"}, + {"ADC 23 Mux", "LINE2", "LINE2"}, + {"ADC 23 Mux", "DMIC1", "DMIC1"}, + {"ADC 23 Mux", "DMIC2", "DMIC2"}, + {"ADC 23 Mux", "DMIC3", "DMIC3"}, + {"ADC 23 Mux", "DMIC4", "DMIC4"}, + {"ADC 24 Mux", "MIC2", "MIC2"}, + {"ADC 24 Mux", "DMIC1", "DMIC1"}, + {"ADC 24 Mux", "DMIC2", "DMIC2"}, + {"ADC 24 Mux", "DMIC3", "DMIC3"}, + {"ADC 24 Mux", "DMIC4", "DMIC4"}, + {"ADC 25 Mux", "MIC1", "MIC1"}, + {"ADC 25 Mux", "DMIC1", "DMIC1"}, + {"ADC 25 Mux", "DMIC2", "DMIC2"}, + {"ADC 25 Mux", "DMIC3", "DMIC3"}, + {"ADC 25 Mux", "DMIC4", "DMIC4"}, +}; + +static int rt715_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) +{ + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + + switch (level) { + case SND_SOC_BIAS_PREPARE: + if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { + regmap_write(rt715->regmap, + RT715_SET_AUDIO_POWER_STATE, + AC_PWRST_D0); + } + break; + + case SND_SOC_BIAS_STANDBY: + regmap_write(rt715->regmap, + RT715_SET_AUDIO_POWER_STATE, + AC_PWRST_D3); + break; + + default: + break; + } + dapm->bias_level = level; + return 0; +} + +static const struct snd_soc_component_driver soc_codec_dev_rt715 = { + .set_bias_level = rt715_set_bias_level, + .controls = rt715_snd_controls, + .num_controls = ARRAY_SIZE(rt715_snd_controls), + .dapm_widgets = rt715_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt715_dapm_widgets), + .dapm_routes = rt715_audio_map, + .num_dapm_routes = ARRAY_SIZE(rt715_audio_map), +}; + +static int rt715_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* Use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt715_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) + +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(stream); +} + +static int rt715_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + unsigned int val = 0; + + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -EINVAL; + + if (!rt715->slave) + return -EINVAL; + + switch (dai->id) { + case RT715_AIF1: + direction = SDW_DATA_DIR_TX; + port = 6; + rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa500); + break; + case RT715_AIF2: + direction = SDW_DATA_DIR_TX; + port = 4; + rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa000); + break; + default: + dev_err(component->dev, "Invalid DAI id %d\n", dai->id); + return -EINVAL; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt715->slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "Unable to configure port\n"); + return retval; + } + + switch (params_rate(params)) { + /* bit 14 0:48K 1:44.1K */ + /* bit 15 Stream Type 0:PCM 1:Non-PCM, should always be PCM */ + case 44100: + val |= 0x40 << 8; + break; + case 48000: + val |= 0x0 << 8; + break; + default: + dev_err(component->dev, "Unsupported sample rate %d\n", + params_rate(params)); + return -EINVAL; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 Number of Channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(component->dev, "Unsupported channels %d\n", + params_channels(params)); + return -EINVAL; + } + + switch (params_width(params)) { + /* bit 6:4 Bits per Sample */ + case 8: + break; + case 16: + val |= (0x1 << 4); + break; + case 20: + val |= (0x2 << 4); + break; + case 24: + val |= (0x3 << 4); + break; + case 32: + val |= (0x4 << 4); + break; + default: + return -EINVAL; + } + + regmap_write(rt715->regmap, RT715_MIC_ADC_FORMAT_H, val); + regmap_write(rt715->regmap, RT715_MIC_LINE_FORMAT_H, val); + regmap_write(rt715->regmap, RT715_MIX_ADC_FORMAT_H, val); + regmap_write(rt715->regmap, RT715_MIX_ADC2_FORMAT_H, val); + + return retval; +} + +static int rt715_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt715->slave) + return -EINVAL; + + sdw_stream_remove_slave(rt715->slave, stream->sdw_stream); + return 0; +} + +#define RT715_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +#define RT715_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) + +static struct snd_soc_dai_ops rt715_ops = { + .hw_params = rt715_pcm_hw_params, + .hw_free = rt715_pcm_hw_free, + .set_sdw_stream = rt715_set_sdw_stream, + .shutdown = rt715_shutdown, +}; + +static struct snd_soc_dai_driver rt715_dai[] = { + { + .name = "rt715-aif1", + .id = RT715_AIF1, + .capture = { + .stream_name = "DP6 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT715_STEREO_RATES, + .formats = RT715_FORMATS, + }, + .ops = &rt715_ops, + }, + { + .name = "rt715-aif2", + .id = RT715_AIF2, + .capture = { + .stream_name = "DP4 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT715_STEREO_RATES, + .formats = RT715_FORMATS, + }, + .ops = &rt715_ops, + }, +}; + +/* Bus clock frequency */ +#define RT715_CLK_FREQ_9600000HZ 9600000 +#define RT715_CLK_FREQ_12000000HZ 12000000 +#define RT715_CLK_FREQ_6000000HZ 6000000 +#define RT715_CLK_FREQ_4800000HZ 4800000 +#define RT715_CLK_FREQ_2400000HZ 2400000 +#define RT715_CLK_FREQ_12288000HZ 12288000 + +int rt715_clock_config(struct device *dev) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt715->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case RT715_CLK_FREQ_12000000HZ: + value = 0x0; + break; + case RT715_CLK_FREQ_6000000HZ: + value = 0x1; + break; + case RT715_CLK_FREQ_9600000HZ: + value = 0x2; + break; + case RT715_CLK_FREQ_4800000HZ: + value = 0x3; + break; + case RT715_CLK_FREQ_2400000HZ: + value = 0x4; + break; + case RT715_CLK_FREQ_12288000HZ: + value = 0x5; + break; + default: + return -EINVAL; + } + + regmap_write(rt715->regmap, 0xe0, value); + regmap_write(rt715->regmap, 0xf0, value); + + return 0; +} + +int rt715_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave) +{ + struct rt715_priv *rt715; + int ret; + + rt715 = devm_kzalloc(dev, sizeof(*rt715), GFP_KERNEL); + if (!rt715) + return -ENOMEM; + + dev_set_drvdata(dev, rt715); + rt715->slave = slave; + rt715->regmap = regmap; + rt715->sdw_regmap = sdw_regmap; + + /* + * Mark hw_init to false + * HW init will be performed when device reports present + */ + rt715->hw_init = false; + rt715->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_codec_dev_rt715, + rt715_dai, + ARRAY_SIZE(rt715_dai)); + + return ret; +} + +int rt715_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt715_priv *rt715 = dev_get_drvdata(dev); + + if (rt715->hw_init) + return 0; + + /* + * PM runtime is only enabled when a Slave reports as Attached + */ + if (!rt715->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* Mute nid=08h/09h */ + regmap_write(rt715->regmap, RT715_SET_GAIN_LINE_ADC_H, 0xb080); + regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC_H, 0xb080); + /* Mute nid=07h/27h */ + regmap_write(rt715->regmap, RT715_SET_GAIN_MIC_ADC_H, 0xb080); + regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC2_H, 0xb080); + + /* Set Pin Widget */ + regmap_write(rt715->regmap, RT715_SET_PIN_DMIC1, 0x20); + regmap_write(rt715->regmap, RT715_SET_PIN_DMIC2, 0x20); + regmap_write(rt715->regmap, RT715_SET_PIN_DMIC3, 0x20); + regmap_write(rt715->regmap, RT715_SET_PIN_DMIC4, 0x20); + /* Set Converter Stream */ + regmap_write(rt715->regmap, RT715_SET_STREAMID_LINE_ADC, 0x10); + regmap_write(rt715->regmap, RT715_SET_STREAMID_MIX_ADC, 0x10); + regmap_write(rt715->regmap, RT715_SET_STREAMID_MIC_ADC, 0x10); + regmap_write(rt715->regmap, RT715_SET_STREAMID_MIX_ADC2, 0x10); + /* Set Configuration Default */ + regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT1, 0xd0); + regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT2, 0x11); + regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT3, 0xa1); + regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT4, 0x81); + regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT1, 0xd1); + regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT2, 0x11); + regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT3, 0xa1); + regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT4, 0x81); + regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT1, 0xd0); + regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT2, 0x11); + regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT3, 0xa1); + regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT4, 0x81); + regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT1, 0xd1); + regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT2, 0x11); + regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT3, 0xa1); + regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT4, 0x81); + + /* Finish Initial Settings, set power to D3 */ + regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); + + if (rt715->first_hw_init) + regcache_mark_dirty(rt715->regmap); + else + rt715->first_hw_init = true; + + /* Mark Slave initialization complete */ + rt715->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + return 0; +} + +MODULE_DESCRIPTION("ASoC rt715 driver"); +MODULE_DESCRIPTION("ASoC rt715 driver SDW"); +MODULE_AUTHOR("Jack Yu "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt715.h b/sound/soc/codecs/rt715.h new file mode 100644 index 000000000000..df0f24f9bc0c --- /dev/null +++ b/sound/soc/codecs/rt715.h @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt715.h -- RT715 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT715_H__ +#define __RT715_H__ + +#include + +struct rt715_priv { + struct regmap *regmap; + struct regmap *sdw_regmap; + struct snd_soc_codec *codec; + struct sdw_slave *slave; + int dbg_nid; + int dbg_vid; + int dbg_payload; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +/* NID */ +#define RT715_AUDIO_FUNCTION_GROUP 0x01 +#define RT715_MIC_ADC 0x07 +#define RT715_LINE_ADC 0x08 +#define RT715_MIX_ADC 0x09 +#define RT715_DMIC1 0x12 +#define RT715_DMIC2 0x13 +#define RT715_MIC1 0x18 +#define RT715_MIC2 0x19 +#define RT715_LINE1 0x1a +#define RT715_LINE2 0x1b +#define RT715_DMIC3 0x1d +#define RT715_DMIC4 0x29 +#define RT715_VENDOR_REGISTERS 0x20 +#define RT715_MUX_IN1 0x22 +#define RT715_MUX_IN2 0x23 +#define RT715_MUX_IN3 0x24 +#define RT715_MUX_IN4 0x25 +#define RT715_MIX_ADC2 0x27 +#define RT715_INLINE_CMD 0x55 + +/* Index (NID:20h) */ +#define RT715_SDW_INPUT_SEL 0x39 +#define RT715_EXT_DMIC_CLK_CTRL2 0x54 + +/* Verb */ +#define RT715_VERB_SET_CONNECT_SEL 0x3100 +#define RT715_VERB_GET_CONNECT_SEL 0xb100 +#define RT715_VERB_SET_EAPD_BTLENABLE 0x3c00 +#define RT715_VERB_SET_POWER_STATE 0x3500 +#define RT715_VERB_SET_CHANNEL_STREAMID 0x3600 +#define RT715_VERB_SET_PIN_WIDGET_CONTROL 0x3700 +#define RT715_VERB_SET_CONFIG_DEFAULT1 0x4c00 +#define RT715_VERB_SET_CONFIG_DEFAULT2 0x4d00 +#define RT715_VERB_SET_CONFIG_DEFAULT3 0x4e00 +#define RT715_VERB_SET_CONFIG_DEFAULT4 0x4f00 +#define RT715_VERB_SET_UNSOLICITED_ENABLE 0x3800 +#define RT715_SET_AMP_GAIN_MUTE_H 0x7300 +#define RT715_SET_AMP_GAIN_MUTE_L 0x8380 +#define RT715_READ_HDA_3 0x2012 +#define RT715_READ_HDA_2 0x2013 +#define RT715_READ_HDA_1 0x2014 +#define RT715_READ_HDA_0 0x2015 +#define RT715_PRIV_INDEX_W_H 0x7520 +#define RT715_PRIV_INDEX_W_L 0x85a0 +#define RT715_PRIV_DATA_W_H 0x7420 +#define RT715_PRIV_DATA_W_L 0x84a0 +#define RT715_PRIV_INDEX_R_H 0x9d20 +#define RT715_PRIV_INDEX_R_L 0xada0 +#define RT715_PRIV_DATA_R_H 0x9c20 +#define RT715_PRIV_DATA_R_L 0xaca0 +#define RT715_MIC_ADC_FORMAT_H 0x7207 +#define RT715_MIC_ADC_FORMAT_L 0x8287 +#define RT715_MIC_LINE_FORMAT_H 0x7208 +#define RT715_MIC_LINE_FORMAT_L 0x8288 +#define RT715_MIX_ADC_FORMAT_H 0x7209 +#define RT715_MIX_ADC_FORMAT_L 0x8289 +#define RT715_MIX_ADC2_FORMAT_H 0x7227 +#define RT715_MIX_ADC2_FORMAT_L 0x82a7 +#define RT715_FUNC_RESET 0xff01 + +#define RT715_SET_AUDIO_POWER_STATE\ + (RT715_VERB_SET_POWER_STATE | RT715_AUDIO_FUNCTION_GROUP) +#define RT715_SET_PIN_DMIC1\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC1) +#define RT715_SET_PIN_DMIC2\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC2) +#define RT715_SET_PIN_DMIC3\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC3) +#define RT715_SET_PIN_DMIC4\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_DMIC4) +#define RT715_SET_PIN_MIC1\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_MIC1) +#define RT715_SET_PIN_MIC2\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_MIC2) +#define RT715_SET_PIN_LINE1\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_LINE1) +#define RT715_SET_PIN_LINE2\ + (RT715_VERB_SET_PIN_WIDGET_CONTROL | RT715_LINE2) +#define RT715_SET_MIC1_UNSOLICITED_ENABLE\ + (RT715_VERB_SET_UNSOLICITED_ENABLE | RT715_MIC1) +#define RT715_SET_MIC2_UNSOLICITED_ENABLE\ + (RT715_VERB_SET_UNSOLICITED_ENABLE | RT715_MIC2) +#define RT715_SET_STREAMID_MIC_ADC\ + (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIC_ADC) +#define RT715_SET_STREAMID_LINE_ADC\ + (RT715_VERB_SET_CHANNEL_STREAMID | RT715_LINE_ADC) +#define RT715_SET_STREAMID_MIX_ADC\ + (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIX_ADC) +#define RT715_SET_STREAMID_MIX_ADC2\ + (RT715_VERB_SET_CHANNEL_STREAMID | RT715_MIX_ADC2) +#define RT715_SET_GAIN_MIC_ADC_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC_ADC) +#define RT715_SET_GAIN_MIC_ADC_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC_ADC) +#define RT715_SET_GAIN_LINE_ADC_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE_ADC) +#define RT715_SET_GAIN_LINE_ADC_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE_ADC) +#define RT715_SET_GAIN_MIX_ADC_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIX_ADC) +#define RT715_SET_GAIN_MIX_ADC_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIX_ADC) +#define RT715_SET_GAIN_MIX_ADC2_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIX_ADC2) +#define RT715_SET_GAIN_MIX_ADC2_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIX_ADC2) +#define RT715_SET_GAIN_DMIC1_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC1) +#define RT715_SET_GAIN_DMIC1_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC1) +#define RT715_SET_GAIN_DMIC2_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC2) +#define RT715_SET_GAIN_DMIC2_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC2) +#define RT715_SET_GAIN_DMIC3_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC3) +#define RT715_SET_GAIN_DMIC3_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC3) +#define RT715_SET_GAIN_DMIC4_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_DMIC4) +#define RT715_SET_GAIN_DMIC4_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_DMIC4) +#define RT715_SET_GAIN_MIC1_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC1) +#define RT715_SET_GAIN_MIC1_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC1) +#define RT715_SET_GAIN_MIC2_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_MIC2) +#define RT715_SET_GAIN_MIC2_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_MIC2) +#define RT715_SET_GAIN_LINE1_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE1) +#define RT715_SET_GAIN_LINE1_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE1) +#define RT715_SET_GAIN_LINE2_L\ + (RT715_SET_AMP_GAIN_MUTE_L | RT715_LINE2) +#define RT715_SET_GAIN_LINE2_H\ + (RT715_SET_AMP_GAIN_MUTE_H | RT715_LINE2) +#define RT715_SET_DMIC1_CONFIG_DEFAULT1\ + (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC1) +#define RT715_SET_DMIC2_CONFIG_DEFAULT1\ + (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC2) +#define RT715_SET_DMIC1_CONFIG_DEFAULT2\ + (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC1) +#define RT715_SET_DMIC2_CONFIG_DEFAULT2\ + (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC2) +#define RT715_SET_DMIC1_CONFIG_DEFAULT3\ + (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC1) +#define RT715_SET_DMIC2_CONFIG_DEFAULT3\ + (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC2) +#define RT715_SET_DMIC1_CONFIG_DEFAULT4\ + (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC1) +#define RT715_SET_DMIC2_CONFIG_DEFAULT4\ + (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC2) +#define RT715_SET_DMIC3_CONFIG_DEFAULT1\ + (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC3) +#define RT715_SET_DMIC4_CONFIG_DEFAULT1\ + (RT715_VERB_SET_CONFIG_DEFAULT1 | RT715_DMIC4) +#define RT715_SET_DMIC3_CONFIG_DEFAULT2\ + (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC3) +#define RT715_SET_DMIC4_CONFIG_DEFAULT2\ + (RT715_VERB_SET_CONFIG_DEFAULT2 | RT715_DMIC4) +#define RT715_SET_DMIC3_CONFIG_DEFAULT3\ + (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC3) +#define RT715_SET_DMIC4_CONFIG_DEFAULT3\ + (RT715_VERB_SET_CONFIG_DEFAULT3 | RT715_DMIC4) +#define RT715_SET_DMIC3_CONFIG_DEFAULT4\ + (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC3) +#define RT715_SET_DMIC4_CONFIG_DEFAULT4\ + (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC4) + +#define RT715_MUTE_SFT 7 +#define RT715_DIR_IN_SFT 6 +#define RT715_DIR_OUT_SFT 7 + +enum { + RT715_AIF1, + RT715_AIF2, + RT715_AIFS, +}; + +int rt715_io_init(struct device *dev, struct sdw_slave *slave); +int rt715_init(struct device *dev, struct regmap *sdw_regmap, + struct regmap *regmap, struct sdw_slave *slave); + +int hda_to_sdw(unsigned int nid, unsigned int verb, unsigned int payload, + unsigned int *sdw_addr_h, unsigned int *sdw_data_h, + unsigned int *sdw_addr_l, unsigned int *sdw_data_l); +int rt715_clock_config(struct device *dev); +#endif /* __RT715_H__ */ -- cgit v1.2.3 From 62d28dcb65fd5ca12994207f17187545923d4f3d Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Mon, 13 Jan 2020 01:31:23 +0000 Subject: ASoC: rt711: remove unused including Remove including that don't need it. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20200113013123.47561-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt711.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index 3bebba7a63be..2daed7692a3b 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 630db1549356f64424b8f532c028e7894df8e40b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 17:57:44 -0600 Subject: ASoC: Intel: bdw-rt5677: fix Kconfig dependencies The existing machine driver depends on SPI Master capabilities, but the Kconfig does not model this dependency and the SPI controller needs to be selected as well. Without this patch the machine driver probe would fail with the spi-RT5677AA:00 component never registered by the ACPI/LPSS subsystem. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index bddf04715f15..9ca2567d0059 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -62,6 +62,9 @@ config SND_SOC_INTEL_BDW_RT5677_MACH depends on I2C_DESIGNWARE_PLATFORM || COMPILE_TEST depends on GPIOLIB || COMPILE_TEST depends on X86_INTEL_LPSS || COMPILE_TEST + depends on SPI_MASTER + select SPI_PXA2XX + select SND_SOC_RT5677_SPI select SND_SOC_RT5677 help This adds support for Intel Broadwell platform based boards with -- cgit v1.2.3 From 4865bde187b29e42b3f572d9610dfca9a57c30b9 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 17:57:45 -0600 Subject: ASoC: Intel: bdw-rt5677: change cpu_dai and platform components for SOF The legacy driver uses dummy cpu_dai and platform, SOF requires actual values to bind. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bdw-rt5677.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 2af8e5a62da8..bb643c99069d 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -295,6 +295,14 @@ SND_SOC_DAILINK_DEF(platform, SND_SOC_DAILINK_DEF(be, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RT5677CE:00", "rt5677-aif1"))); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); +#else +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_DUMMY())); +#endif + /* Wake on voice interface */ SND_SOC_DAILINK_DEFS(dsp, DAILINK_COMP_ARRAY(COMP_CPU("spi-RT5677AA:00")), @@ -342,7 +350,7 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = { .dpcm_playback = 1, .dpcm_capture = 1, .init = bdw_rt5677_init, - SND_SOC_DAILINK_REG(dummy, be, dummy), + SND_SOC_DAILINK_REG(ssp0_port, be, platform), }, }; -- cgit v1.2.3 From 64df6afa0dab5eda95cc4cc2269e3d4e83b6b6ce Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Fri, 10 Jan 2020 17:57:46 -0600 Subject: ASoC: Intel: broadwell: change cpu_dai and platform components for SOF The legacy driver uses dummy cpu_dai and platform, SOF requires actual values to bind. Signed-off-by: Pan Xiuli Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/broadwell.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index db7e1e87156d..b9c12e24c70b 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -164,6 +164,14 @@ SND_SOC_DAILINK_DEF(platform, SND_SOC_DAILINK_DEF(codec, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00", "rt286-aif1"))); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); +#else +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_DUMMY())); +#endif + /* broadwell digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link broadwell_rt286_dais[] = { /* Front End DAI links */ @@ -218,7 +226,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { .ops = &broadwell_rt286_ops, .dpcm_playback = 1, .dpcm_capture = 1, - SND_SOC_DAILINK_REG(dummy, codec, dummy), + SND_SOC_DAILINK_REG(ssp0_port, codec, platform), }, }; -- cgit v1.2.3 From a40acc6bfcebb59fdf6a71c4740c46880ed5c0b4 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 17:57:47 -0600 Subject: ASoC: Intel: bdw-rt5650: change cpu_dai and platform components for SOF The legacy driver uses dummy cpu_dai and platform, SOF requires actual values to bind. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bdw-rt5650.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bdw-rt5650.c b/sound/soc/intel/boards/bdw-rt5650.c index ba3fc1ef900a..1a302436d450 100644 --- a/sound/soc/intel/boards/bdw-rt5650.c +++ b/sound/soc/intel/boards/bdw-rt5650.c @@ -223,6 +223,14 @@ SND_SOC_DAILINK_DEF(platform, SND_SOC_DAILINK_DEF(be, DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5650:00", "rt5645-aif1"))); +#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL) +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); +#else +SND_SOC_DAILINK_DEF(ssp0_port, + DAILINK_COMP_ARRAY(COMP_DUMMY())); +#endif + static struct snd_soc_dai_link bdw_rt5650_dais[] = { /* Front End DAI links */ { @@ -256,7 +264,7 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = { .dpcm_playback = 1, .dpcm_capture = 1, .init = bdw_rt5650_init, - SND_SOC_DAILINK_REG(dummy, be, dummy), + SND_SOC_DAILINK_REG(ssp0_port, be, platform), }, }; -- cgit v1.2.3 From cfe8191b1bbf2b41581b63eb97e56cd6bc3c34a1 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 10 Jan 2020 17:57:49 -0600 Subject: ASoC: SOF: fix PCM playback through ALSA OSS emulation Any app using ALSA OSS emulation on top of SOF will fail to error from OSS SNDCTL_DSP_SETFMT ioctl. Reported initially as an issue with xournalpp (application using PortAudio with an OSS backend), but applies more generally to other apps using OSS as well. Problem is caused by SOF PCM not supporting repeated calls to hw_params(), without matching calls to pcm_free(). This is however exactly what the ALSA OSS PCM code is doing when it is handling the OSS ioctls. The problem will lead to leaking of DSP resources and eventual failure of DSP PCM_PARAMS IPC. BugLink: https://github.com/thesofproject/linux/issues/1510 Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110235751.3404-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/pcm.c | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 9bb6388742e1..314f3095c12f 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -92,7 +92,27 @@ void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream) } EXPORT_SYMBOL(snd_sof_pcm_period_elapsed); -/* this may get called several times by oss emulation */ +static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, + struct snd_sof_dev *sdev, + struct snd_sof_pcm *spcm) +{ + struct sof_ipc_stream stream; + struct sof_ipc_reply reply; + int ret; + + stream.hdr.size = sizeof(stream); + stream.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_FREE; + stream.comp_id = spcm->stream[substream->stream].comp_id; + + /* send IPC to the DSP */ + ret = sof_ipc_tx_message(sdev->ipc, stream.hdr.cmd, &stream, + sizeof(stream), &reply, sizeof(reply)); + if (!ret) + spcm->prepared[substream->stream] = false; + + return ret; +} + static int sof_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -113,6 +133,16 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, if (!spcm) return -EINVAL; + /* + * Handle repeated calls to hw_params() without free_pcm() in + * between. At least ALSA OSS emulation depends on this. + */ + if (spcm->prepared[substream->stream]) { + ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm); + if (ret < 0) + return ret; + } + dev_dbg(component->dev, "pcm: hw params stream %d dir %d\n", spcm->pcm.pcm_id, substream->stream); @@ -201,27 +231,6 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, return ret; } -static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, - struct snd_sof_dev *sdev, - struct snd_sof_pcm *spcm) -{ - struct sof_ipc_stream stream; - struct sof_ipc_reply reply; - int ret; - - stream.hdr.size = sizeof(stream); - stream.hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_FREE; - stream.comp_id = spcm->stream[substream->stream].comp_id; - - /* send IPC to the DSP */ - ret = sof_ipc_tx_message(sdev->ipc, stream.hdr.cmd, &stream, - sizeof(stream), &reply, sizeof(reply)); - if (!ret) - spcm->prepared[substream->stream] = false; - - return ret; -} - static int sof_pcm_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { -- cgit v1.2.3 From efb6f3159e874f09992b7318cea12e8e27e8389b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 16:25:25 -0600 Subject: ASoC: soc-acpi: add _ADR-based link descriptors For SoundWire support, we added a 'link_mask' to describe the PCB hardware layout. This helped form a signature that can be used as a first-order way of detecting the hardware and selecting the machine driver. The concept of link_mask is however not enough. Some BIOS enable all links, even when there are no devices physically connected. We can also see variations with multiple devices attached on one link, or different types of devices connected on the same link. To accurately represent the hardware, we need to build static tables where each link exposes a list of expected devices represented by the 64-bit _ADR field (which uniquely identifies each device). The new 'links' field is optional when the link_mask is sufficient to represent a platform in a unique way. The existing mechanism to support I2C devices is left as is, it'd be too invasive to change the existing support for _HID and the notion of link is not relevant either. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Bard liao Link: https://lore.kernel.org/r/20200110222530.30303-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/soc-acpi.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h index c4c997bd0379..a217a87cae86 100644 --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h @@ -61,6 +61,8 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) * @platform: string used for HDaudio codec support * @codec_mask: used for HDAudio support * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver + * @link_mask: links enabled on the board + * @links: array of link _ADR descriptors, null terminated */ struct snd_soc_acpi_mach_params { u32 acpi_ipc_irq_index; @@ -68,6 +70,23 @@ struct snd_soc_acpi_mach_params { u32 codec_mask; u32 dmic_num; bool common_hdmi_codec_drv; + u32 link_mask; + const struct snd_soc_acpi_link_adr *links; +}; + +/** + * snd_soc_acpi_link_adr: ACPI-based list of _ADR, with a variable + * number of devices per link + * + * @mask: one bit set indicates the link this list applies to + * @num_adr: ARRAY_SIZE of adr + * @adr: array of _ADR (represented as u64). + */ + +struct snd_soc_acpi_link_adr { + const u32 mask; + const u32 num_adr; + const u64 *adr; }; /** @@ -78,6 +97,7 @@ struct snd_soc_acpi_mach_params { * * @id: ACPI ID (usually the codec's) used to find a matching machine driver. * @link_mask: describes required board layout, e.g. for SoundWire. + * @links: array of link _ADR descriptors, null terminated. * @drv_name: machine driver name * @fw_filename: firmware file name. Used when SOF is not enabled. * @board: board name @@ -94,6 +114,7 @@ struct snd_soc_acpi_mach_params { struct snd_soc_acpi_mach { const u8 id[ACPI_ID_LEN]; const u32 link_mask; + const struct snd_soc_acpi_link_adr *links; const char *drv_name; const char *fw_filename; const char *board; -- cgit v1.2.3 From cf61a42066eae88b4bb0e5528ec9f5f8e50c5343 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 16:25:26 -0600 Subject: ASoC: Intel: common: soc-acpi: declare new tables for SoundWire We cannot really lump SoundWire-based configurations into the same tables since the mechanisms to identify boards is based on link configurations and _ADR instead of _HID for I2S, so define new tables Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110222530.30303-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- include/sound/soc-acpi-intel-match.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/sound/soc-acpi-intel-match.h b/include/sound/soc-acpi-intel-match.h index 20c0bee3b959..ab6f75a86611 100644 --- a/include/sound/soc-acpi-intel-match.h +++ b/include/sound/soc-acpi-intel-match.h @@ -31,6 +31,12 @@ extern struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[]; extern struct snd_soc_acpi_mach snd_soc_acpi_intel_ehl_machines[]; extern struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cfl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_sdw_machines[]; +extern struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[]; + /* * generic table used for HDA codec-based platforms, possibly with * additional ACPI-enumerated codecs -- cgit v1.2.3 From 4313dd3efe5751238f85dd7069bee3a8bbcdbe2f Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 10 Jan 2020 16:25:27 -0600 Subject: ASoC: Intel: common: add match tables for ICL w/ SoundWire The two configurations are with the Realtek 3-in-1 board requiring all 4 links to be enabled, or basic configuration with the on-board RT700 using link0. Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110222530.30303-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/common/soc-acpi-intel-icl-match.c | 98 +++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/sound/soc/intel/common/soc-acpi-intel-icl-match.c b/sound/soc/intel/common/soc-acpi-intel-icl-match.c index 38977669b576..67e9da4635f2 100644 --- a/sound/soc/intel/common/soc-acpi-intel-icl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-icl-match.c @@ -33,5 +33,103 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_machines[] = { }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_icl_machines); +static const u64 rt700_0_adr[] = { + 0x000010025D070000 +}; + +static const struct snd_soc_acpi_link_adr icl_rvp[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt700_0_adr), + .adr = rt700_0_adr, + }, + {} +}; + +static const u64 rt711_0_adr[] = { + 0x000010025D071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000110025D130800 +}; + +static const u64 rt1308_2_adr[] = { + 0x000210025D130800 +}; + +static const u64 rt715_3_adr[] = { + 0x000310025D715000 +}; + +static const struct snd_soc_acpi_link_adr icl_3_in_1_default[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = BIT(1), + .num_adr = ARRAY_SIZE(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = BIT(2), + .num_adr = ARRAY_SIZE(rt1308_2_adr), + .adr = rt1308_2_adr, + }, + { + .mask = BIT(3), + .num_adr = ARRAY_SIZE(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr icl_3_in_1_mono_amp[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = BIT(1), + .num_adr = ARRAY_SIZE(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = BIT(3), + .num_adr = ARRAY_SIZE(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +struct snd_soc_acpi_mach snd_soc_acpi_intel_icl_sdw_machines[] = { + { + .link_mask = 0xF, /* 4 active links required */ + .links = icl_3_in_1_default, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt711-rt1308-rt715.tplg", + }, + { + .link_mask = 0xB, /* 3 active links required */ + .links = icl_3_in_1_mono_amp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt711-rt1308-rt715-mono.tplg", + }, + { + .link_mask = 0x1, /* rt700 connected on link0 */ + .links = icl_rvp, + .drv_name = "sdw_rt700", + .sof_fw_filename = "sof-icl.ri", + .sof_tplg_filename = "sof-icl-rt700.tplg", + }, + {}, +}; +EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_icl_sdw_machines); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel Common ACPI Match module"); -- cgit v1.2.3 From db0b9efb989f01aa7145d30bcdbfb6b07e238875 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Fri, 10 Jan 2020 16:25:28 -0600 Subject: ASoC: Intel: common: add match tables for CNL/CFL/CML w/ SoundWire The two configurations are with the Realtek 3-in-1 board requiring all 4 links to be enabled, or basic configuration with the on-board RT700 using link1. For now we only have definitions for CML. CNL and CFL are just placeholders. Signed-off-by: Rander Wang Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110222530.30303-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/common/soc-acpi-intel-cfl-match.c | 5 ++ sound/soc/intel/common/soc-acpi-intel-cml-match.c | 89 +++++++++++++++++++++++ sound/soc/intel/common/soc-acpi-intel-cnl-match.c | 5 ++ 3 files changed, 99 insertions(+) diff --git a/sound/soc/intel/common/soc-acpi-intel-cfl-match.c b/sound/soc/intel/common/soc-acpi-intel-cfl-match.c index d6fd2026d0b8..ff9d6938b9f6 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cfl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cfl-match.c @@ -14,5 +14,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cfl_machines[] = { }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cfl_machines); +struct snd_soc_acpi_mach snd_soc_acpi_intel_cfl_sdw_machines[] = { + {} +}; +EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cfl_sdw_machines); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel Common ACPI Match module"); diff --git a/sound/soc/intel/common/soc-acpi-intel-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c index fb9ba8819706..f55634c4c2e8 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c @@ -59,5 +59,94 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_machines); +static const u64 rt711_0_adr[] = { + 0x000010025D071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000110025D130800 +}; + +static const u64 rt1308_2_adr[] = { + 0x000210025D130800 +}; + +static const u64 rt715_3_adr[] = { + 0x000310025D071500 +}; + +static const struct snd_soc_acpi_link_adr cml_3_in_1_default[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = BIT(1), + .num_adr = ARRAY_SIZE(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = BIT(2), + .num_adr = ARRAY_SIZE(rt1308_2_adr), + .adr = rt1308_2_adr, + }, + { + .mask = BIT(3), + .num_adr = ARRAY_SIZE(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr cml_3_in_1_mono_amp[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = BIT(1), + .num_adr = ARRAY_SIZE(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + { + .mask = BIT(3), + .num_adr = ARRAY_SIZE(rt715_3_adr), + .adr = rt715_3_adr, + }, + {} +}; + +struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_sdw_machines[] = { + { + .link_mask = 0xF, /* 4 active links required */ + .links = cml_3_in_1_default, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt711-rt1308-rt715.tplg", + }, + { + /* + * link_mask should be 0xB, but all links are enabled by BIOS. + * This entry will be selected if there is no rt1308 exposed + * on link2 since it will fail to match the above entry. + */ + .link_mask = 0xF, + .links = cml_3_in_1_mono_amp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt711-rt1308-mono-rt715.tplg", + }, + { + .link_mask = 0x2, /* RT700 connected on Link1 */ + .drv_name = "sdw_rt700", + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-rt700.tplg", + }, + {} +}; +EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_sdw_machines); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel Common ACPI Match module"); diff --git a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c index 27588841c8b0..828980d5630d 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c @@ -27,5 +27,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_machines[] = { }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cnl_machines); +struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_sdw_machines[] = { + {}, +}; +EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cnl_sdw_machines); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel Common ACPI Match module"); -- cgit v1.2.3 From d985d208bf8f079979f284864a6d08900597ee04 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 16:25:29 -0600 Subject: ASoC: Intel: common: add match tables for TGL w/ SoundWire RT711 is in SoundWire mode on link0. RT1308 is either on SSP2 or on SoundWire link1 (depending on hardware reworks). Signed-off-by: Rander Wang Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110222530.30303-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/common/soc-acpi-intel-tgl-match.c | 51 ++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c index b4687a5d1962..5984dd151f3e 100644 --- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c @@ -14,12 +14,46 @@ static struct snd_soc_acpi_codecs tgl_codecs = { .codecs = {"MX98357A"} }; +static const u64 rt711_0_adr[] = { + 0x000010025D071100 +}; + +static const u64 rt1308_1_adr[] = { + 0x000120025D130800, + 0x000122025D130800 +}; + +static const struct snd_soc_acpi_link_adr tgl_i2s_rt1308[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr tgl_rvp[] = { + { + .mask = BIT(0), + .num_adr = ARRAY_SIZE(rt711_0_adr), + .adr = rt711_0_adr, + }, + { + .mask = BIT(1), + .num_adr = ARRAY_SIZE(rt1308_1_adr), + .adr = rt1308_1_adr, + }, + {} +}; + struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { { .id = "10EC1308", - .drv_name = "tgl_rt1308", + .drv_name = "rt711_rt1308", + .link_mask = 0x1, /* RT711 on SoundWire link0 */ + .links = tgl_i2s_rt1308, .sof_fw_filename = "sof-tgl.ri", - .sof_tplg_filename = "sof-tgl-rt1308.tplg", + .sof_tplg_filename = "sof-tgl-rt711-rt1308.tplg", }, { .id = "10EC5682", @@ -33,5 +67,18 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines); +/* this table is used when there is no I2S codec present */ +struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = { + { + .link_mask = 0x3, /* rt711 on link 0 and 2 rt1308s on link 1 */ + .links = tgl_rvp, + .drv_name = "sdw_rt711_rt1308_rt715", + .sof_fw_filename = "sof-tgl.ri", + .sof_tplg_filename = "sof-tgl-rt711-rt1308.tplg", + }, + {}, +}; +EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_sdw_machines); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel Common ACPI Match module"); -- cgit v1.2.3 From 5732c0fc53eb45565c485a886d027c0b1f86d4c5 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 10 Jan 2020 16:25:30 -0600 Subject: ASoC: SOF: Intel: reference SoundWire machine lists Use static tables to automatically select the relevant configurations. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200110222530.30303-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/sof-pci-dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 9993be36d105..d855bc2b76ad 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -118,6 +118,7 @@ static const struct sof_dev_desc tng_desc = { #if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE) static const struct sof_dev_desc cnl_desc = { .machines = snd_soc_acpi_intel_cnl_machines, + .alt_machines = snd_soc_acpi_intel_cnl_sdw_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -135,6 +136,7 @@ static const struct sof_dev_desc cnl_desc = { #if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE) static const struct sof_dev_desc cfl_desc = { .machines = snd_soc_acpi_intel_cfl_machines, + .alt_machines = snd_soc_acpi_intel_cfl_sdw_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -154,6 +156,7 @@ static const struct sof_dev_desc cfl_desc = { static const struct sof_dev_desc cml_desc = { .machines = snd_soc_acpi_intel_cml_machines, + .alt_machines = snd_soc_acpi_intel_cml_sdw_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -171,6 +174,7 @@ static const struct sof_dev_desc cml_desc = { #if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE) static const struct sof_dev_desc icl_desc = { .machines = snd_soc_acpi_intel_icl_machines, + .alt_machines = snd_soc_acpi_intel_icl_sdw_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, @@ -188,6 +192,7 @@ static const struct sof_dev_desc icl_desc = { #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE) static const struct sof_dev_desc tgl_desc = { .machines = snd_soc_acpi_intel_tgl_machines, + .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines, .resindex_lpe_base = 0, .resindex_pcicfg_base = -1, .resindex_imr_base = -1, -- cgit v1.2.3 From 8fea78029f5e6ed734ae1957bef23cfda1af4354 Mon Sep 17 00:00:00 2001 From: Chen Zhou Date: Mon, 13 Jan 2020 21:32:42 +0800 Subject: ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m If CONFIG_SND_ATMEL_SOC_DMA=m, build error: sound/soc/atmel/atmel_ssc_dai.o: In function `atmel_ssc_set_audio': (.text+0x7cd): undefined reference to `atmel_pcm_dma_platform_register' Function atmel_pcm_dma_platform_register is defined under CONFIG SND_ATMEL_SOC_DMA, so select SND_ATMEL_SOC_DMA in CONFIG SND_ATMEL_SOC_SSC, same to CONFIG_SND_ATMEL_SOC_PDC. Reported-by: Hulk Robot Signed-off-by: Chen Zhou Link: https://lore.kernel.org/r/20200113133242.144550-1-chenzhou10@huawei.com Signed-off-by: Mark Brown --- sound/soc/atmel/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig index f118c229ed82..d1dc8e6366dc 100644 --- a/sound/soc/atmel/Kconfig +++ b/sound/soc/atmel/Kconfig @@ -19,6 +19,8 @@ config SND_ATMEL_SOC_DMA config SND_ATMEL_SOC_SSC tristate + select SND_ATMEL_SOC_DMA + select SND_ATMEL_SOC_PDC config SND_ATMEL_SOC_SSC_PDC tristate "SoC PCM DAI support for AT91 SSC controller using PDC" -- cgit v1.2.3 From a87a6653a28c0d511b3fdf3d62302bed5f325e03 Mon Sep 17 00:00:00 2001 From: Shuming Fan Date: Fri, 10 Jan 2020 09:46:06 +0800 Subject: ASoC: rt1308-sdw: add rt1308 SdW amplifier driver This is the initial amplifier driver for rt1308-sdw. Signed-off-by: Shuming Fan Link: https://lore.kernel.org/r/20200110014606.17333-1-shumingf@realtek.com Tested-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt1308-sdw.c | 736 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt1308-sdw.h | 169 ++++++++++ 4 files changed, 913 insertions(+) create mode 100644 sound/soc/codecs/rt1308-sdw.c create mode 100644 sound/soc/codecs/rt1308-sdw.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index cdfd912d5f8f..2f52e4cac96a 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -168,6 +168,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT700_SDW if SOUNDWIRE select SND_SOC_RT711_SDW if SOUNDWIRE select SND_SOC_RT715_SDW if SOUNDWIRE + select SND_SOC_RT1308_SDW if SOUNDWIRE select SND_SOC_SGTL5000 if I2C select SND_SOC_SI476X if MFD_SI476X_CORE select SND_SOC_SIMPLE_AMPLIFIER @@ -1005,6 +1006,11 @@ config SND_SOC_RT1305 config SND_SOC_RT1308 tristate +config SND_SOC_RT1308_SDW + tristate "Realtek RT1308 Codec - SDW" + depends on SOUNDWIRE + select REGMAP_SOUNDWIRE + config SND_SOC_RT5514 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index ce285b33a806..66aa452f5aa2 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -154,6 +154,7 @@ snd-soc-rl6347a-objs := rl6347a.o snd-soc-rt1011-objs := rt1011.o snd-soc-rt1305-objs := rt1305.o snd-soc-rt1308-objs := rt1308.o +snd-soc-rt1308-sdw-objs := rt1308-sdw.o snd-soc-rt274-objs := rt274.o snd-soc-rt286-objs := rt286.o snd-soc-rt298-objs := rt298.o @@ -448,6 +449,7 @@ obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o obj-$(CONFIG_SND_SOC_RT1011) += snd-soc-rt1011.o obj-$(CONFIG_SND_SOC_RT1305) += snd-soc-rt1305.o obj-$(CONFIG_SND_SOC_RT1308) += snd-soc-rt1308.o +obj-$(CONFIG_SND_SOC_RT1308_SDW) += snd-soc-rt1308-sdw.o obj-$(CONFIG_SND_SOC_RT274) += snd-soc-rt274.o obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o obj-$(CONFIG_SND_SOC_RT298) += snd-soc-rt298.o diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c new file mode 100644 index 000000000000..8a03dbfe7906 --- /dev/null +++ b/sound/soc/codecs/rt1308-sdw.c @@ -0,0 +1,736 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt1308-sdw.c -- rt1308 ALSA SoC audio driver +// +// Copyright(c) 2019 Realtek Semiconductor Corp. +// +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rt1308.h" +#include "rt1308-sdw.h" + +static bool rt1308_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x00e0: + case 0x00f0: + case 0x2f01 ... 0x2f07: + case 0x3000 ... 0x3001: + case 0x3004 ... 0x3005: + case 0x3008: + case 0x300a: + case 0xc000 ... 0xcff3: + return true; + default: + return false; + } +} + +static bool rt1308_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0x2f01 ... 0x2f07: + case 0x3000 ... 0x3001: + case 0x3004 ... 0x3005: + case 0x3008: + case 0x300a: + case 0xc000: + return true; + default: + return false; + } +} + +static const struct regmap_config rt1308_sdw_regmap = { + .reg_bits = 32, + .val_bits = 8, + .readable_reg = rt1308_readable_register, + .volatile_reg = rt1308_volatile_register, + .max_register = 0xcfff, + .reg_defaults = rt1308_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(rt1308_reg_defaults), + .cache_type = REGCACHE_RBTREE, + .use_single_read = true, + .use_single_write = true, +}; + +/* Bus clock frequency */ +#define RT1308_CLK_FREQ_9600000HZ 9600000 +#define RT1308_CLK_FREQ_12000000HZ 12000000 +#define RT1308_CLK_FREQ_6000000HZ 6000000 +#define RT1308_CLK_FREQ_4800000HZ 4800000 +#define RT1308_CLK_FREQ_2400000HZ 2400000 +#define RT1308_CLK_FREQ_12288000HZ 12288000 + +static int rt1308_clock_config(struct device *dev) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + unsigned int clk_freq, value; + + clk_freq = (rt1308->params.curr_dr_freq >> 1); + + switch (clk_freq) { + case RT1308_CLK_FREQ_12000000HZ: + value = 0x0; + break; + case RT1308_CLK_FREQ_6000000HZ: + value = 0x1; + break; + case RT1308_CLK_FREQ_9600000HZ: + value = 0x2; + break; + case RT1308_CLK_FREQ_4800000HZ: + value = 0x3; + break; + case RT1308_CLK_FREQ_2400000HZ: + value = 0x4; + break; + case RT1308_CLK_FREQ_12288000HZ: + value = 0x5; + break; + default: + return -EINVAL; + } + + regmap_write(rt1308->regmap, 0xe0, value); + regmap_write(rt1308->regmap, 0xf0, value); + + dev_dbg(dev, "%s complete, clk_freq=%d\n", __func__, clk_freq); + + return 0; +} + +static int rt1308_read_prop(struct sdw_slave *slave) +{ + struct sdw_slave_prop *prop = &slave->prop; + int nval, i, num_of_ports = 1; + u32 bit; + unsigned long addr; + struct sdw_dpn_prop *dpn; + + prop->paging_support = true; + + /* first we need to allocate memory for set bits in port lists */ + prop->source_ports = 0x00; /* BITMAP: 00010100 (not enable yet) */ + prop->sink_ports = 0x2; /* BITMAP: 00000010 */ + + /* for sink */ + nval = hweight32(prop->sink_ports); + num_of_ports += nval; + prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, + sizeof(*prop->sink_dpn_prop), + GFP_KERNEL); + if (!prop->sink_dpn_prop) + return -ENOMEM; + + i = 0; + dpn = prop->sink_dpn_prop; + addr = prop->sink_ports; + for_each_set_bit(bit, &addr, 32) { + dpn[i].num = bit; + dpn[i].type = SDW_DPN_FULL; + dpn[i].simple_ch_prep_sm = true; + dpn[i].ch_prep_timeout = 10; + i++; + } + + /* Allocate port_ready based on num_of_ports */ + slave->port_ready = devm_kcalloc(&slave->dev, num_of_ports, + sizeof(*slave->port_ready), + GFP_KERNEL); + if (!slave->port_ready) + return -ENOMEM; + + /* Initialize completion */ + for (i = 0; i < num_of_ports; i++) + init_completion(&slave->port_ready[i]); + + /* set the timeout values */ + prop->clk_stop_timeout = 20; + + dev_dbg(&slave->dev, "%s\n", __func__); + + return 0; +} + +static int rt1308_io_init(struct device *dev, struct sdw_slave *slave) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + int ret = 0; + unsigned int efuse_m_btl_l, efuse_m_btl_r, tmp; + unsigned int efuse_c_btl_l, efuse_c_btl_r; + + if (rt1308->hw_init) + return 0; + + ret = rt1308_read_prop(slave); + if (ret < 0) + goto _io_init_err_; + + if (rt1308->first_hw_init) { + regcache_cache_only(rt1308->regmap, false); + regcache_cache_bypass(rt1308->regmap, true); + } + + /* + * PM runtime is only enabled when a Slave reports as Attached + */ + if (!rt1308->first_hw_init) { + /* set autosuspend parameters */ + pm_runtime_set_autosuspend_delay(&slave->dev, 3000); + pm_runtime_use_autosuspend(&slave->dev); + + /* update count of parent 'active' children */ + pm_runtime_set_active(&slave->dev); + + /* make sure the device does not suspend immediately */ + pm_runtime_mark_last_busy(&slave->dev); + + pm_runtime_enable(&slave->dev); + } + + pm_runtime_get_noresume(&slave->dev); + + /* sw reset */ + regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0); + + /* read efuse */ + regmap_write(rt1308->regmap, 0xc360, 0x01); + regmap_write(rt1308->regmap, 0xc361, 0x80); + regmap_write(rt1308->regmap, 0xc7f0, 0x04); + regmap_write(rt1308->regmap, 0xc7f1, 0xfe); + msleep(100); + regmap_write(rt1308->regmap, 0xc7f0, 0x44); + msleep(20); + regmap_write(rt1308->regmap, 0xc240, 0x10); + + regmap_read(rt1308->regmap, 0xc861, &tmp); + efuse_m_btl_l = tmp; + regmap_read(rt1308->regmap, 0xc860, &tmp); + efuse_m_btl_l = efuse_m_btl_l | (tmp << 8); + regmap_read(rt1308->regmap, 0xc863, &tmp); + efuse_c_btl_l = tmp; + regmap_read(rt1308->regmap, 0xc862, &tmp); + efuse_c_btl_l = efuse_c_btl_l | (tmp << 8); + regmap_read(rt1308->regmap, 0xc871, &tmp); + efuse_m_btl_r = tmp; + regmap_read(rt1308->regmap, 0xc870, &tmp); + efuse_m_btl_r = efuse_m_btl_r | (tmp << 8); + regmap_read(rt1308->regmap, 0xc873, &tmp); + efuse_c_btl_r = tmp; + regmap_read(rt1308->regmap, 0xc872, &tmp); + efuse_c_btl_r = efuse_c_btl_r | (tmp << 8); + dev_info(&slave->dev, "%s m_btl_l=0x%x, m_btl_r=0x%x\n", __func__, + efuse_m_btl_l, efuse_m_btl_r); + dev_info(&slave->dev, "%s c_btl_l=0x%x, c_btl_r=0x%x\n", __func__, + efuse_c_btl_l, efuse_c_btl_r); + + /* initial settings */ + regmap_write(rt1308->regmap, 0xc103, 0xc0); + regmap_write(rt1308->regmap, 0xc030, 0x17); + regmap_write(rt1308->regmap, 0xc031, 0x81); + regmap_write(rt1308->regmap, 0xc032, 0x26); + regmap_write(rt1308->regmap, 0xc040, 0x80); + regmap_write(rt1308->regmap, 0xc041, 0x80); + regmap_write(rt1308->regmap, 0xc042, 0x06); + regmap_write(rt1308->regmap, 0xc052, 0x0a); + regmap_write(rt1308->regmap, 0xc080, 0x0a); + regmap_write(rt1308->regmap, 0xc060, 0x02); + regmap_write(rt1308->regmap, 0xc061, 0x75); + regmap_write(rt1308->regmap, 0xc062, 0x05); + regmap_write(rt1308->regmap, 0xc171, 0x07); + regmap_write(rt1308->regmap, 0xc173, 0x0d); + regmap_write(rt1308->regmap, 0xc311, 0x7f); + regmap_write(rt1308->regmap, 0xc900, 0x90); + regmap_write(rt1308->regmap, 0xc1a0, 0x84); + regmap_write(rt1308->regmap, 0xc1a1, 0x01); + regmap_write(rt1308->regmap, 0xc360, 0x78); + regmap_write(rt1308->regmap, 0xc361, 0x87); + regmap_write(rt1308->regmap, 0xc0a1, 0x71); + regmap_write(rt1308->regmap, 0xc210, 0x00); + regmap_write(rt1308->regmap, 0xc070, 0x00); + regmap_write(rt1308->regmap, 0xc100, 0xd7); + regmap_write(rt1308->regmap, 0xc101, 0xd7); + regmap_write(rt1308->regmap, 0xc300, 0x09); + + if (rt1308->first_hw_init) { + regcache_cache_bypass(rt1308->regmap, false); + regcache_mark_dirty(rt1308->regmap); + } else + rt1308->first_hw_init = true; + + /* Mark Slave initialization complete */ + rt1308->hw_init = true; + + pm_runtime_mark_last_busy(&slave->dev); + pm_runtime_put_autosuspend(&slave->dev); + + dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); + +_io_init_err_: + return ret; +} + +static int rt1308_update_status(struct sdw_slave *slave, + enum sdw_slave_status status) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev); + + /* Update the status */ + rt1308->status = status; + + if (status == SDW_SLAVE_UNATTACHED) + rt1308->hw_init = false; + + /* + * Perform initialization only if slave status is present and + * hw_init flag is false + */ + if (rt1308->hw_init || rt1308->status != SDW_SLAVE_ATTACHED) + return 0; + + /* perform I/O transfers required for Slave initialization */ + return rt1308_io_init(&slave->dev, slave); +} + +static int rt1308_bus_config(struct sdw_slave *slave, + struct sdw_bus_params *params) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev); + int ret; + + memcpy(&rt1308->params, params, sizeof(*params)); + + ret = rt1308_clock_config(&slave->dev); + if (ret < 0) + dev_err(&slave->dev, "Invalid clk config"); + + return ret; +} + +static int rt1308_interrupt_callback(struct sdw_slave *slave, + struct sdw_slave_intr_status *status) +{ + dev_dbg(&slave->dev, + "%s control_port_stat=%x", __func__, status->control_port); + + return 0; +} + +static int rt1308_classd_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + msleep(30); + snd_soc_component_update_bits(component, + RT1308_SDW_OFFSET | (RT1308_POWER_STATUS << 4), + 0x3, 0x3); + msleep(40); + break; + case SND_SOC_DAPM_PRE_PMD: + snd_soc_component_update_bits(component, + RT1308_SDW_OFFSET | (RT1308_POWER_STATUS << 4), + 0x3, 0); + usleep_range(150000, 200000); + break; + + default: + break; + } + + return 0; +} + +static const char * const rt1308_rx_data_ch_select[] = { + "LR", + "LL", + "RL", + "RR", +}; + +static SOC_ENUM_SINGLE_DECL(rt1308_rx_data_ch_enum, + RT1308_SDW_OFFSET | (RT1308_DATA_PATH << 4), 0, + rt1308_rx_data_ch_select); + +static const struct snd_kcontrol_new rt1308_snd_controls[] = { + + /* I2S Data Channel Selection */ + SOC_ENUM("RX Channel Select", rt1308_rx_data_ch_enum), +}; + +static const struct snd_kcontrol_new rt1308_sto_dac_l = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", + RT1308_SDW_OFFSET_BYTE3 | (RT1308_DAC_SET << 4), + RT1308_DVOL_MUTE_L_EN_SFT, 1, 1); + +static const struct snd_kcontrol_new rt1308_sto_dac_r = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", + RT1308_SDW_OFFSET_BYTE3 | (RT1308_DAC_SET << 4), + RT1308_DVOL_MUTE_R_EN_SFT, 1, 1); + +static const struct snd_soc_dapm_widget rt1308_dapm_widgets[] = { + /* Audio Interface */ + SND_SOC_DAPM_AIF_IN("AIF1RX", "DP1 Playback", 0, SND_SOC_NOPM, 0, 0), + + /* Supply Widgets */ + SND_SOC_DAPM_SUPPLY("MBIAS20U", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 7, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("ALDO", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 6, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DBG", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 5, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DACL", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 4, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("CLK25M", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 2, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("ADC_R", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("ADC_L", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DAC Power", + RT1308_SDW_OFFSET | (RT1308_POWER << 4), 3, 0, NULL, 0), + + SND_SOC_DAPM_SUPPLY("DLDO", + RT1308_SDW_OFFSET_BYTE1 | (RT1308_POWER << 4), 5, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("VREF", + RT1308_SDW_OFFSET_BYTE1 | (RT1308_POWER << 4), 4, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MIXER_R", + RT1308_SDW_OFFSET_BYTE1 | (RT1308_POWER << 4), 2, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MIXER_L", + RT1308_SDW_OFFSET_BYTE1 | (RT1308_POWER << 4), 1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MBIAS4U", + RT1308_SDW_OFFSET_BYTE1 | (RT1308_POWER << 4), 0, 0, NULL, 0), + + SND_SOC_DAPM_SUPPLY("PLL2_LDO", + RT1308_SDW_OFFSET_BYTE2 | (RT1308_POWER << 4), 4, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("PLL2B", + RT1308_SDW_OFFSET_BYTE2 | (RT1308_POWER << 4), 3, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("PLL2F", + RT1308_SDW_OFFSET_BYTE2 | (RT1308_POWER << 4), 2, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("PLL2F2", + RT1308_SDW_OFFSET_BYTE2 | (RT1308_POWER << 4), 1, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("PLL2B2", + RT1308_SDW_OFFSET_BYTE2 | (RT1308_POWER << 4), 0, 0, NULL, 0), + + /* Digital Interface */ + SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_SWITCH("DAC L", SND_SOC_NOPM, 0, 0, &rt1308_sto_dac_l), + SND_SOC_DAPM_SWITCH("DAC R", SND_SOC_NOPM, 0, 0, &rt1308_sto_dac_r), + + /* Output Lines */ + SND_SOC_DAPM_PGA_E("CLASS D", SND_SOC_NOPM, 0, 0, NULL, 0, + rt1308_classd_event, + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_OUTPUT("SPOL"), + SND_SOC_DAPM_OUTPUT("SPOR"), +}; + +static const struct snd_soc_dapm_route rt1308_dapm_routes[] = { + + { "DAC", NULL, "AIF1RX" }, + + { "DAC", NULL, "MBIAS20U" }, + { "DAC", NULL, "ALDO" }, + { "DAC", NULL, "DBG" }, + { "DAC", NULL, "DACL" }, + { "DAC", NULL, "CLK25M" }, + { "DAC", NULL, "ADC_R" }, + { "DAC", NULL, "ADC_L" }, + { "DAC", NULL, "DLDO" }, + { "DAC", NULL, "VREF" }, + { "DAC", NULL, "MIXER_R" }, + { "DAC", NULL, "MIXER_L" }, + { "DAC", NULL, "MBIAS4U" }, + { "DAC", NULL, "PLL2_LDO" }, + { "DAC", NULL, "PLL2B" }, + { "DAC", NULL, "PLL2F" }, + { "DAC", NULL, "PLL2F2" }, + { "DAC", NULL, "PLL2B2" }, + + { "DAC L", "Switch", "DAC" }, + { "DAC R", "Switch", "DAC" }, + { "DAC L", NULL, "DAC Power" }, + { "DAC R", NULL, "DAC Power" }, + + { "CLASS D", NULL, "DAC L" }, + { "CLASS D", NULL, "DAC R" }, + { "SPOL", NULL, "CLASS D" }, + { "SPOR", NULL, "CLASS D" }, +}; + +static int rt1308_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream, + int direction) +{ + struct sdw_stream_data *stream; + + stream = kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + stream->sdw_stream = (struct sdw_stream_runtime *)sdw_stream; + + /* Use tx_mask or rx_mask to configure stream tag and set dma_data */ + if (direction == SNDRV_PCM_STREAM_PLAYBACK) + dai->playback_dma_data = stream; + else + dai->capture_dma_data = stream; + + return 0; +} + +static void rt1308_sdw_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct sdw_stream_data *stream; + + stream = snd_soc_dai_get_dma_data(dai, substream); + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(stream); +} + +static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1308_sdw_priv *rt1308 = + snd_soc_component_get_drvdata(component); + struct sdw_stream_config stream_config; + struct sdw_port_config port_config; + enum sdw_data_direction direction; + struct sdw_stream_data *stream; + int retval, port, num_channels; + + dev_dbg(dai->dev, "%s %s", __func__, dai->name); + stream = snd_soc_dai_get_dma_data(dai, substream); + + if (!stream) + return -EINVAL; + + if (!rt1308->sdw_slave) + return -EINVAL; + + /* SoundWire specific configuration */ + /* port 1 for playback */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + direction = SDW_DATA_DIR_RX; + port = 1; + } else { + return -EINVAL; + } + + stream_config.frame_rate = params_rate(params); + stream_config.ch_count = params_channels(params); + stream_config.bps = snd_pcm_format_width(params_format(params)); + stream_config.direction = direction; + + num_channels = params_channels(params); + port_config.ch_mask = (1 << (num_channels)) - 1; + port_config.num = port; + + retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config, + &port_config, 1, stream->sdw_stream); + if (retval) { + dev_err(dai->dev, "Unable to configure port\n"); + return retval; + } + + return retval; +} + +static int rt1308_sdw_pcm_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1308_sdw_priv *rt1308 = + snd_soc_component_get_drvdata(component); + struct sdw_stream_data *stream = + snd_soc_dai_get_dma_data(dai, substream); + + if (!rt1308->sdw_slave) + return -EINVAL; + + sdw_stream_remove_slave(rt1308->sdw_slave, stream->sdw_stream); + return 0; +} + +/* + * slave_ops: callbacks for get_clock_stop_mode, clock_stop and + * port_prep are not defined for now + */ +static struct sdw_slave_ops rt1308_slave_ops = { + .read_prop = rt1308_read_prop, + .interrupt_callback = rt1308_interrupt_callback, + .update_status = rt1308_update_status, + .bus_config = rt1308_bus_config, +}; + +static const struct snd_soc_component_driver soc_component_sdw_rt1308 = { + .controls = rt1308_snd_controls, + .num_controls = ARRAY_SIZE(rt1308_snd_controls), + .dapm_widgets = rt1308_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt1308_dapm_widgets), + .dapm_routes = rt1308_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt1308_dapm_routes), +}; + +static const struct snd_soc_dai_ops rt1308_aif_dai_ops = { + .hw_params = rt1308_sdw_hw_params, + .hw_free = rt1308_sdw_pcm_hw_free, + .set_sdw_stream = rt1308_set_sdw_stream, + .shutdown = rt1308_sdw_shutdown, +}; + +#define RT1308_STEREO_RATES SNDRV_PCM_RATE_48000 +#define RT1308_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ + SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE) + +static struct snd_soc_dai_driver rt1308_sdw_dai[] = { + { + .name = "rt1308-aif", + .playback = { + .stream_name = "DP1 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = RT1308_STEREO_RATES, + .formats = RT1308_FORMATS, + }, + .ops = &rt1308_aif_dai_ops, + }, +}; + +static int rt1308_sdw_init(struct device *dev, struct regmap *regmap, + struct sdw_slave *slave) +{ + struct rt1308_sdw_priv *rt1308; + int ret; + + rt1308 = devm_kzalloc(dev, sizeof(*rt1308), GFP_KERNEL); + if (!rt1308) + return -ENOMEM; + + dev_set_drvdata(dev, rt1308); + rt1308->sdw_slave = slave; + rt1308->regmap = regmap; + + /* + * Mark hw_init to false + * HW init will be performed when device reports present + */ + rt1308->hw_init = false; + rt1308->first_hw_init = false; + + ret = devm_snd_soc_register_component(dev, + &soc_component_sdw_rt1308, + rt1308_sdw_dai, + ARRAY_SIZE(rt1308_sdw_dai)); + + dev_dbg(&slave->dev, "%s\n", __func__); + + return ret; +} + +static int rt1308_sdw_probe(struct sdw_slave *slave, + const struct sdw_device_id *id) +{ + struct regmap *regmap; + + /* Assign ops */ + slave->ops = &rt1308_slave_ops; + + /* Regmap Initialization */ + regmap = devm_regmap_init_sdw(slave, &rt1308_sdw_regmap); + if (!regmap) + return -EINVAL; + + rt1308_sdw_init(&slave->dev, regmap, slave); + + return 0; +} + +static const struct sdw_device_id rt1308_id[] = { + SDW_SLAVE_ENTRY(0x025d, 0x1308, 0), + {}, +}; +MODULE_DEVICE_TABLE(sdw, rt1308_id); + +static int rt1308_dev_suspend(struct device *dev) +{ + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + + if (!rt1308->hw_init) + return 0; + + regcache_cache_only(rt1308->regmap, true); + + return 0; +} + +#define RT1308_PROBE_TIMEOUT 2000 + +static int rt1308_dev_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev); + unsigned long time; + + if (!rt1308->hw_init) + return 0; + + if (!slave->unattach_request) + goto regmap_sync; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(RT1308_PROBE_TIMEOUT)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete, timed out\n"); + return -ETIMEDOUT; + } + +regmap_sync: + slave->unattach_request = 0; + regcache_cache_only(rt1308->regmap, false); + regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff); + + return 0; +} + +static const struct dev_pm_ops rt1308_pm = { + SET_SYSTEM_SLEEP_PM_OPS(rt1308_dev_suspend, rt1308_dev_resume) + SET_RUNTIME_PM_OPS(rt1308_dev_suspend, rt1308_dev_resume, NULL) +}; + +static struct sdw_driver rt1308_sdw_driver = { + .driver = { + .name = "rt1308", + .owner = THIS_MODULE, + .pm = &rt1308_pm, + }, + .probe = rt1308_sdw_probe, + .ops = &rt1308_slave_ops, + .id_table = rt1308_id, +}; +module_sdw_driver(rt1308_sdw_driver); + +MODULE_DESCRIPTION("ASoC RT1308 driver SDW"); +MODULE_AUTHOR("Shuming Fan "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt1308-sdw.h b/sound/soc/codecs/rt1308-sdw.h new file mode 100644 index 000000000000..c9341e70d6cf --- /dev/null +++ b/sound/soc/codecs/rt1308-sdw.h @@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * rt1308-sdw.h -- RT1308 ALSA SoC audio driver header + * + * Copyright(c) 2019 Realtek Semiconductor Corp. + */ + +#ifndef __RT1308_SDW_H__ +#define __RT1308_SDW_H__ + +static const struct reg_default rt1308_reg_defaults[] = { + { 0x0000, 0x00 }, + { 0x0001, 0x00 }, + { 0x0002, 0x00 }, + { 0x0003, 0x00 }, + { 0x0004, 0x00 }, + { 0x0005, 0x01 }, + { 0x0020, 0x00 }, + { 0x0022, 0x00 }, + { 0x0023, 0x00 }, + { 0x0024, 0x00 }, + { 0x0025, 0x00 }, + { 0x0026, 0x00 }, + { 0x0030, 0x00 }, + { 0x0032, 0x00 }, + { 0x0033, 0x00 }, + { 0x0034, 0x00 }, + { 0x0035, 0x00 }, + { 0x0036, 0x00 }, + { 0x0040, 0x00 }, + { 0x0041, 0x00 }, + { 0x0042, 0x00 }, + { 0x0043, 0x00 }, + { 0x0044, 0x20 }, + { 0x0045, 0x01 }, + { 0x0046, 0x01 }, + { 0x0048, 0x00 }, + { 0x0049, 0x00 }, + { 0x0050, 0x20 }, + { 0x0051, 0x02 }, + { 0x0052, 0x5D }, + { 0x0053, 0x13 }, + { 0x0054, 0x08 }, + { 0x0055, 0x00 }, + { 0x0060, 0x00 }, + { 0x0070, 0x00 }, + { 0x00E0, 0x00 }, + { 0x00F0, 0x00 }, + { 0x0100, 0x00 }, + { 0x0101, 0x00 }, + { 0x0102, 0x20 }, + { 0x0103, 0x00 }, + { 0x0104, 0x00 }, + { 0x0105, 0x03 }, + { 0x0120, 0x00 }, + { 0x0122, 0x00 }, + { 0x0123, 0x00 }, + { 0x0124, 0x00 }, + { 0x0125, 0x00 }, + { 0x0126, 0x00 }, + { 0x0127, 0x00 }, + { 0x0130, 0x00 }, + { 0x0132, 0x00 }, + { 0x0133, 0x00 }, + { 0x0134, 0x00 }, + { 0x0135, 0x00 }, + { 0x0136, 0x00 }, + { 0x0137, 0x00 }, + { 0x0200, 0x00 }, + { 0x0201, 0x00 }, + { 0x0202, 0x00 }, + { 0x0203, 0x00 }, + { 0x0204, 0x00 }, + { 0x0205, 0x03 }, + { 0x0220, 0x00 }, + { 0x0222, 0x00 }, + { 0x0223, 0x00 }, + { 0x0224, 0x00 }, + { 0x0225, 0x00 }, + { 0x0226, 0x00 }, + { 0x0227, 0x00 }, + { 0x0230, 0x00 }, + { 0x0232, 0x00 }, + { 0x0233, 0x00 }, + { 0x0234, 0x00 }, + { 0x0235, 0x00 }, + { 0x0236, 0x00 }, + { 0x0237, 0x00 }, + { 0x0400, 0x00 }, + { 0x0401, 0x00 }, + { 0x0402, 0x00 }, + { 0x0403, 0x00 }, + { 0x0404, 0x00 }, + { 0x0405, 0x03 }, + { 0x0420, 0x00 }, + { 0x0422, 0x00 }, + { 0x0423, 0x00 }, + { 0x0424, 0x00 }, + { 0x0425, 0x00 }, + { 0x0426, 0x00 }, + { 0x0427, 0x00 }, + { 0x0430, 0x00 }, + { 0x0432, 0x00 }, + { 0x0433, 0x00 }, + { 0x0434, 0x00 }, + { 0x0435, 0x00 }, + { 0x0436, 0x00 }, + { 0x0437, 0x00 }, + { 0x0f00, 0x00 }, + { 0x0f01, 0x00 }, + { 0x0f02, 0x00 }, + { 0x0f03, 0x00 }, + { 0x0f04, 0x00 }, + { 0x0f05, 0x00 }, + { 0x0f20, 0x00 }, + { 0x0f22, 0x00 }, + { 0x0f23, 0x00 }, + { 0x0f24, 0x00 }, + { 0x0f25, 0x00 }, + { 0x0f26, 0x00 }, + { 0x0f27, 0x00 }, + { 0x0f30, 0x00 }, + { 0x0f32, 0x00 }, + { 0x0f33, 0x00 }, + { 0x0f34, 0x00 }, + { 0x0f35, 0x00 }, + { 0x0f36, 0x00 }, + { 0x0f37, 0x00 }, + { 0x2f01, 0x01 }, + { 0x2f02, 0x09 }, + { 0x2f03, 0x00 }, + { 0x2f04, 0x0f }, + { 0x2f05, 0x0b }, + { 0x2f06, 0x01 }, + { 0x2f07, 0x8e }, + { 0x3000, 0x00 }, + { 0x3001, 0x00 }, + { 0x3004, 0x01 }, + { 0x3005, 0x23 }, + { 0x3008, 0x02 }, + { 0x300a, 0x00 }, + { 0xc003 | (RT1308_DAC_SET << 4), 0x00 }, + { 0xc001 | (RT1308_POWER << 4), 0x00 }, + { 0xc002 | (RT1308_POWER << 4), 0x00 }, +}; + +#define RT1308_SDW_OFFSET 0xc000 +#define RT1308_SDW_OFFSET_BYTE0 0xc000 +#define RT1308_SDW_OFFSET_BYTE1 0xc001 +#define RT1308_SDW_OFFSET_BYTE2 0xc002 +#define RT1308_SDW_OFFSET_BYTE3 0xc003 + +#define RT1308_SDW_RESET (RT1308_SDW_OFFSET | (RT1308_RESET << 4)) + +struct rt1308_sdw_priv { + struct snd_soc_component *component; + struct regmap *regmap; + struct sdw_slave *sdw_slave; + enum sdw_slave_status status; + struct sdw_bus_params params; + bool hw_init; + bool first_hw_init; +}; + +struct sdw_stream_data { + struct sdw_stream_runtime *sdw_stream; +}; + +#endif /* __RT1308_SDW_H__ */ -- cgit v1.2.3 From 6e57188f20ecf33185b671cff1af305d8f3bb2fe Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 13 Jan 2020 14:56:38 -0600 Subject: ALSA: hda: Update kernel-doc function parameter descriptions Make W=1 throws a lot of warnings, with multiple misalignments between function params and their descriptions. Signed-off-by: Keyon Jie Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113205638.27338-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/hda/ext/hdac_ext_bus.c | 11 ++++++----- sound/hda/ext/hdac_ext_controller.c | 14 +++++++------- sound/hda/ext/hdac_ext_stream.c | 1 - sound/hda/hdac_bus.c | 3 +++ sound/hda/hdac_component.c | 1 + sound/hda/hdac_controller.c | 2 +- sound/hda/hdac_device.c | 12 ++++++++---- sound/hda/hdac_stream.c | 2 ++ 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index 242306d820ec..73bfa71845f6 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c @@ -19,10 +19,10 @@ MODULE_LICENSE("GPL v2"); /** * snd_hdac_ext_bus_init - initialize a HD-audio extended bus - * @ebus: the pointer to extended bus object + * @bus: the pointer to HDAC bus object * @dev: device pointer * @ops: bus verb operators - * default ops + * @ext_ops: operators used for ASoC HDA codec drivers * * Returns 0 if successful, or a negative error code. */ @@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_init); /** * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus - * @ebus: the pointer to extended bus object + * @bus: the pointer to HDAC bus object */ void snd_hdac_ext_bus_exit(struct hdac_bus *bus) { @@ -67,8 +67,9 @@ static void default_release(struct device *dev) /** * snd_hdac_ext_bus_device_init - initialize the HDA extended codec base device - * @ebus: hdac extended bus to attach to + * @bus: hdac bus to attach to * @addr: codec address + * @hdev: hdac device to init * * Returns zero for success or a negative error code. */ @@ -114,7 +115,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit); /** * snd_hdac_ext_bus_device_remove - remove HD-audio extended codec base devices * - * @ebus: HD-audio extended bus + * @bus: the pointer to HDAC bus object */ void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus) { diff --git a/sound/hda/ext/hdac_ext_controller.c b/sound/hda/ext/hdac_ext_controller.c index cfab60d88c92..a684f0520b4b 100644 --- a/sound/hda/ext/hdac_ext_controller.c +++ b/sound/hda/ext/hdac_ext_controller.c @@ -28,7 +28,7 @@ /** * snd_hdac_ext_bus_ppcap_enable - enable/disable processing pipe capability - * @ebus: HD-audio extended core bus + * @bus: the pointer to HDAC bus object * @enable: flag to turn on/off the capability */ void snd_hdac_ext_bus_ppcap_enable(struct hdac_bus *bus, bool enable) @@ -50,7 +50,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_ppcap_enable); /** * snd_hdac_ext_bus_ppcap_int_enable - ppcap interrupt enable/disable - * @ebus: HD-audio extended core bus + * @bus: the pointer to HDAC bus object * @enable: flag to enable/disable interrupt */ void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_bus *bus, bool enable) @@ -77,7 +77,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_ppcap_int_enable); /** * snd_hdac_ext_bus_get_ml_capabilities - get multilink capability - * @ebus: HD-audio extended core bus + * @bus: the pointer to HDAC bus object * * This will parse all links and read the mlink capabilities and add them * in hlink_list of extended hdac bus @@ -117,7 +117,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_get_ml_capabilities); /** * snd_hdac_link_free_all- free hdac extended link objects * - * @ebus: HD-audio ext core bus + * @bus: the pointer to HDAC bus object */ void snd_hdac_link_free_all(struct hdac_bus *bus) @@ -134,7 +134,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_link_free_all); /** * snd_hdac_ext_bus_get_link_index - get link based on codec name - * @ebus: HD-audio extended core bus + * @bus: the pointer to HDAC bus object * @codec_name: codec name */ struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus, @@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_down); /** * snd_hdac_ext_bus_link_power_up_all -power up all hda link - * @ebus: HD-audio extended bus + * @bus: the pointer to HDAC bus object */ int snd_hdac_ext_bus_link_power_up_all(struct hdac_bus *bus) { @@ -232,7 +232,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_link_power_up_all); /** * snd_hdac_ext_bus_link_power_down_all -power down all hda link - * @ebus: HD-audio extended bus + * @bus: the pointer to HDAC bus object */ int snd_hdac_ext_bus_link_power_down_all(struct hdac_bus *bus) { diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c index 6b1b4b834bae..c4d54a838773 100644 --- a/sound/hda/ext/hdac_ext_stream.c +++ b/sound/hda/ext/hdac_ext_stream.c @@ -530,7 +530,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_stream_set_dpibr); /** * snd_hdac_ext_stream_set_lpib - sets the lpib value of a stream - * @bus: HD-audio core bus * @stream: hdac_ext_stream * @value: lpib value to set */ diff --git a/sound/hda/hdac_bus.c b/sound/hda/hdac_bus.c index 48b227fff204..3fe62be1cbcc 100644 --- a/sound/hda/hdac_bus.c +++ b/sound/hda/hdac_bus.c @@ -22,6 +22,7 @@ static const struct hdac_bus_ops default_ops = { /** * snd_hdac_bus_init - initialize a HD-audio bas bus * @bus: the pointer to bus object + * @dev: device pointer * @ops: bus verb operators * * Returns 0 if successful, or a negative error code. @@ -64,6 +65,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_exit); /** * snd_hdac_bus_exec_verb - execute a HD-audio verb on the given bus * @bus: bus object + * @addr: the HDAC device address * @cmd: HD-audio encoded verb * @res: pointer to store the response, NULL if performing asynchronously * @@ -84,6 +86,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_exec_verb); /** * snd_hdac_bus_exec_verb_unlocked - unlocked version * @bus: bus object + * @addr: the HDAC device address * @cmd: HD-audio encoded verb * @res: pointer to store the response, NULL if performing asynchronously * diff --git a/sound/hda/hdac_component.c b/sound/hda/hdac_component.c index dfe7e755f594..89126c6fd216 100644 --- a/sound/hda/hdac_component.c +++ b/sound/hda/hdac_component.c @@ -262,6 +262,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_acomp_register_notifier); /** * snd_hdac_acomp_init - Initialize audio component * @bus: HDA core bus + * @aops: audio component ops * @match_master: match function for finding components * @extra_size: Extra bytes to allocate * diff --git a/sound/hda/hdac_controller.c b/sound/hda/hdac_controller.c index b856184af37f..bc4a8b606020 100644 --- a/sound/hda/hdac_controller.c +++ b/sound/hda/hdac_controller.c @@ -561,7 +561,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip); * snd_hdac_bus_handle_stream_irq - interrupt handler for streams * @bus: HD-audio core bus * @status: INTSTS register value - * @ask: callback to be called for woken streams + * @ack: callback to be called for woken streams * * Returns the bits of handled streams, or zero if no stream is handled. */ diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 7bcdb0e454f2..9a526aeef8da 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -135,7 +135,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_exit); /** * snd_hdac_device_register - register the hd-audio codec base device - * codec: the device to register + * @codec: the device to register */ int snd_hdac_device_register(struct hdac_device *codec) { @@ -158,7 +158,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_register); /** * snd_hdac_device_unregister - unregister the hd-audio codec base device - * codec: the device to unregister + * @codec: the device to unregister */ void snd_hdac_device_unregister(struct hdac_device *codec) { @@ -281,6 +281,10 @@ EXPORT_SYMBOL_GPL(snd_hdac_read); /** * _snd_hdac_read_parm - read a parmeter + * @codec: the codec object + * @nid: NID to read a parameter + * @parm: parameter to read + * @res: pointer to store the read value * * This function returns zero or an error unlike snd_hdac_read_parm(). */ @@ -1062,9 +1066,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_check_power_state); * snd_hdac_sync_power_state - wait until actual power state matches * with the target state * - * @hdac: the HDAC device + * @codec: the HDAC device * @nid: NID to send the command - * @target_state: target state to check for + * @power_state: target power state to wait for * * Return power state or PS_ERROR if codec rejects GET verb. */ diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c index 682ed39f79b0..d01e69139164 100644 --- a/sound/hda/hdac_stream.c +++ b/sound/hda/hdac_stream.c @@ -590,7 +590,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_stream_timecounter_init); /** * snd_hdac_stream_sync_trigger - turn on/off stream sync register * @azx_dev: HD-audio core stream (master stream) + * @set: true = set, false = clear * @streams: bit flags of streams to sync + * @reg: the stream sync register address */ void snd_hdac_stream_sync_trigger(struct hdac_stream *azx_dev, bool set, unsigned int streams, unsigned int reg) -- cgit v1.2.3 From 4f5c26534d395bf68de38c3d4b6170ab28d49a05 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:14:04 -0600 Subject: ALSA: hda: correct kernel-doc parameter descriptions make W=1 throws warnings, provide missing documentation Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113211405.28070-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 1 + sound/pci/hda/hda_generic.c | 5 +++++ sound/pci/hda/hda_jack.c | 2 ++ sound/pci/hda/patch_ca0132.c | 1 + 4 files changed, 9 insertions(+) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 83aa4c1015d2..5dc42f932739 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -891,6 +891,7 @@ static int snd_hda_codec_device_init(struct hda_bus *bus, struct snd_card *card, /** * snd_hda_codec_new - create a HDA codec * @bus: the bus to assign + * @card: card for this codec * @codec_addr: the codec address * @codecp: the pointer to store the generated codec * diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 6815f9dc8545..f4e9d9445e18 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -4042,6 +4042,11 @@ static void call_ledtrig_micmute(struct hda_codec *codec) * * Note that this fixup has to be called after other fixup that sets * cap_sync_hook. Otherwise the chaining wouldn't work. + * + * @codec: the HDA codec + * @fix: fixup pointer + * @action: only supports HDA_FIXUP_ACT_PROBE value + * */ void snd_hda_gen_fixup_micmute_led(struct hda_codec *codec, const struct hda_fixup *fix, int action) diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index bf0255cb0515..02cc682caa55 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -122,6 +122,7 @@ any_jack_tbl_get_from_nid(struct hda_codec *codec, hda_nid_t nid) * snd_hda_jack_tbl_new - create a jack-table entry for the given NID * @codec: the HDA codec * @nid: pin NID to assign + * @dev_id: pin device entry id */ static struct hda_jack_tbl * snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid, int dev_id) @@ -233,6 +234,7 @@ EXPORT_SYMBOL_GPL(snd_hda_jack_set_dirty_all); * snd_hda_jack_pin_sense - execute pin sense measurement * @codec: the CODEC to sense * @nid: the pin NID to sense + * @dev_id: pin device entry id * * Execute necessary pin sense measurement and return its Presence Detect, * Impedance, ELD Valid etc. status bits. diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 46e105244ad3..ded8bc07d755 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -1923,6 +1923,7 @@ static int dspio_send_scp_message(struct hda_codec *codec, * Prepare and send the SCP message to DSP * @codec: the HDA codec * @mod_id: ID of the DSP module to send the command + * @src_id: ID of the source * @req: ID of request to send to the DSP module * @dir: SET or GET * @data: pointer to the data to send with the request, request specific -- cgit v1.2.3 From 75663c093d0bbbf51e3a3149f91f3148a7be3c5c Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:14:05 -0600 Subject: ALSA: hda: patch_hdmi: remove warnings with empty body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make W=1 reports the following warnings, fix as suggested sound/pci/hda/patch_hdmi.c: In function ‘hdmi_non_intrinsic_event’: sound/pci/hda/patch_hdmi.c:824:3: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] 824 | ; | ^ sound/pci/hda/patch_hdmi.c:826:3: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] 826 | ; | ^ Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113211405.28070-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 3a18fa4f8c21..ce3c212ee467 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -820,10 +820,12 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) cp_ready); /* TODO */ - if (cp_state) + if (cp_state) { ; - if (cp_ready) + } + if (cp_ready) { ; + } } -- cgit v1.2.3 From 5615b7a2784331d115e5774e80c1fb0c1ce80644 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 14 Jan 2020 01:13:19 +0000 Subject: ASoC: rt700: remove unused including Remove including that don't need it. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20200114011319.173401-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt700.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c index b1830c1ebf8a..ff68f0e4f629 100644 --- a/sound/soc/codecs/rt700.c +++ b/sound/soc/codecs/rt700.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 2c72943dc359c9592747c3fd82cda30e7c89714c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 14 Jan 2020 10:14:42 +0900 Subject: ASoC: rt715: use dev_to_sdw_dev() instead of to_sdw_slave_device() This patch fixup this error CC sound/soc/codecs/rt715-sdw.o linux/sound/soc/codecs/rt715-sdw.c: In function 'rt715_dev_resume': linux/sound/soc/codecs/rt715-sdw.c:568:28: error: implicit declaration\ of function 'to_sdw_slave_device'; did you mean 'sdw_slave_modalias'?\ [-Werror=implicit-function-declaration] struct sdw_slave *slave = to_sdw_slave_device(dev); ^~~~~~~~~~~~~~~~~~~ sdw_slave_modalias linux/sound/soc/codecs/rt715-sdw.c:568:28: warning: initialization of\ 'struct sdw_slave *' from 'int' makes pointer from integer without a\ cast [-Wint-conversion] cc1: some warnings being treated as errors Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87h80yhm9p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt715-sdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt715-sdw.c b/sound/soc/codecs/rt715-sdw.c index c35591fd281b..18868e4ae6e8 100644 --- a/sound/soc/codecs/rt715-sdw.c +++ b/sound/soc/codecs/rt715-sdw.c @@ -565,7 +565,7 @@ static int rt715_dev_suspend(struct device *dev) static int rt715_dev_resume(struct device *dev) { - struct sdw_slave *slave = to_sdw_slave_device(dev); + struct sdw_slave *slave = dev_to_sdw_dev(dev); struct rt715_priv *rt715 = dev_get_drvdata(dev); unsigned long time; -- cgit v1.2.3 From fed4383c4586a895dc8cd62e3a71814f16ba0e2d Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 16:36:25 -0600 Subject: ASoC: rt715: remove warnings make W=1 reports defined-but-not-used and kernel-doc formatting issues. No functionality change. Fixes: d1ede0641b05e4 ("ASoC: rt715: add RT715 codec driver") Cc: Jack Yu Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113223625.15995-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt715.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c index 5c6f05b8d8ab..4c746938a062 100644 --- a/sound/soc/codecs/rt715.c +++ b/sound/soc/codecs/rt715.c @@ -203,7 +203,6 @@ static int rt715_set_amp_gain_get(struct snd_kcontrol *kcontrol, return 0; } -static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0); static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0); static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); @@ -366,7 +365,7 @@ static const char * const adc_22_23_mux_text[] = { "DMIC4", }; -/** +/* * Due to mux design for nid 24 (MUX_IN3)/25 (MUX_IN4), connection index 0 and * 1 will be connected to the same dmic source, therefore we skip index 1 to * avoid misunderstanding on usage of dapm routing. @@ -404,6 +403,7 @@ static SOC_ENUM_SINGLE_DECL( static SOC_VALUE_ENUM_SINGLE_DECL(rt715_adc24_enum, RT715_MUX_IN3, 0, 0xf, adc_24_mux_text, rt715_adc_24_25_values); + static SOC_VALUE_ENUM_SINGLE_DECL(rt715_adc25_enum, RT715_MUX_IN4, 0, 0xf, adc_25_mux_text, rt715_adc_24_25_values); -- cgit v1.2.3 From d873997192ddcacb5333575502be2f91ea4b47b8 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 14:56:20 -0600 Subject: ASoC: SOF: Intel: hda-dai: fix compilation warning in pcm_prepare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix GCC warning with W=1, previous cleanup did not remove unnecessary variable. sound/soc/sof/intel/hda-dai.c: In function ‘hda_link_pcm_prepare’: sound/soc/sof/intel/hda-dai.c:265:31: warning: variable ‘hda_stream’ set but not used [-Wunused-but-set-variable] 265 | struct sof_intel_hda_stream *hda_stream; | ^~~~~~~~~~ Fixes: a3ebccb52efdf ("ASoC: SOF: Intel: hda: reset link DMA state in prepare") Cc: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113205620.27285-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda-dai.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 313611dcb5e4..9c6e3f990ee3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -262,14 +262,11 @@ static int hda_link_pcm_prepare(struct snd_pcm_substream *substream, { struct hdac_ext_stream *link_dev = snd_soc_dai_get_dma_data(dai, substream); - struct sof_intel_hda_stream *hda_stream; struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(dai->component); struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); int stream = substream->stream; - hda_stream = hstream_to_sof_hda_stream(link_dev); - if (link_dev->link_prepared) return 0; -- cgit v1.2.3 From 01bfee0d1d945a24061b12b8a9268365fceef518 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:11 -0600 Subject: ASoC: Intel: bxt_da7219_max98357a: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/bxt_da7219_max98357a.c:265] -> [sound/soc/intel/boards/bxt_da7219_max98357a.c:164]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/bxt_da7219_max98357a.c:265] -> [sound/soc/intel/boards/bxt_da7219_max98357a.c:316]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_da7219_max98357a.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index 5873abb46441..33b13f3ca152 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c @@ -161,13 +161,13 @@ static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = DUAL_CHANNEL; + chan->min = chan->max = DUAL_CHANNEL; /* set SSP to 24 bit */ snd_mask_none(fmt); @@ -313,12 +313,12 @@ static const struct snd_soc_ops broxton_da7219_fe_ops = { static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (params_channels(params) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From c1b765362bf8c2dc8bde93613f25d97a772709fa Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:12 -0600 Subject: ASoC: Intel: bxt_rt298: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/bxt_rt298.c:291] -> [sound/soc/intel/boards/bxt_rt298.c:209]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/bxt_rt298.c:291] -> [sound/soc/intel/boards/bxt_rt298.c:258]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index eabf9d8468ae..067a97e7e6a8 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -206,13 +206,13 @@ static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; /* set SSP5 to 24 bit */ snd_mask_none(fmt); @@ -255,9 +255,9 @@ static const struct snd_pcm_hw_constraint_list constraints_rates = { static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 83fa677581daddd301b4f0337a0643fef7746689 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:13 -0600 Subject: ASoC: Intel: glk_rt5682_max98357a: rename shadowed variable [sound/soc/intel/boards/glk_rt5682_max98357a.c:252] -> [sound/soc/intel/boards/glk_rt5682_max98357a.c:121]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/glk_rt5682_max98357a.c:252] -> [sound/soc/intel/boards/glk_rt5682_max98357a.c:275]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/glk_rt5682_max98357a.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c index b36264d1d1cd..2bfc4365d957 100644 --- a/sound/soc/intel/boards/glk_rt5682_max98357a.c +++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c @@ -118,13 +118,13 @@ static int geminilake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = DUAL_CHANNEL; + chan->min = chan->max = DUAL_CHANNEL; /* set SSP to 24 bit */ snd_mask_none(fmt); @@ -272,13 +272,13 @@ static struct snd_pcm_hw_constraint_list constraints_channels_quad = { static int geminilake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* * set BE channel constraint as user FE channels */ - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 988b414775fe34278b1ca898f0b3a607eb49986b Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:14 -0600 Subject: ASoC: Intel: glk_rt5682_max98357a: removed unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix GCC warning with W=1 sound/soc/intel/boards/glk_rt5682_max98357a.c:256:48: warning: ‘constraints_channels’ defined but not used [-Wunused-const-variable=] Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/glk_rt5682_max98357a.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sound/soc/intel/boards/glk_rt5682_max98357a.c b/sound/soc/intel/boards/glk_rt5682_max98357a.c index 2bfc4365d957..4a6d117ea7af 100644 --- a/sound/soc/intel/boards/glk_rt5682_max98357a.c +++ b/sound/soc/intel/boards/glk_rt5682_max98357a.c @@ -249,16 +249,6 @@ static const struct snd_pcm_hw_constraint_list constraints_rates = { .mask = 0, }; -static const unsigned int channels[] = { - DUAL_CHANNEL, -}; - -static const struct snd_pcm_hw_constraint_list constraints_channels = { - .count = ARRAY_SIZE(channels), - .list = channels, - .mask = 0, -}; - static unsigned int channels_quad[] = { QUAD_CHANNEL, }; -- cgit v1.2.3 From 2e539cf72a349bb593718f7f500c96dcfc23d911 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:15 -0600 Subject: ASoC: Intel: kbl_da7219_max98357a: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/kbl_da7219_max98357a.c:257] -> [sound/soc/intel/boards/kbl_da7219_max98357a.c:144]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/kbl_da7219_max98357a.c:257] -> [sound/soc/intel/boards/kbl_da7219_max98357a.c:308]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-6-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98357a.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c index 0d55319a0773..bc7f9a9ce9af 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -141,13 +141,13 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = DUAL_CHANNEL; + chan->min = chan->max = DUAL_CHANNEL; /* set SSP to 24 bit */ snd_mask_none(fmt); @@ -305,7 +305,7 @@ static const struct snd_soc_ops kabylake_da7219_fe_ops = { static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* @@ -313,9 +313,9 @@ static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, */ if (params_channels(params) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 2b66c70fbe64c8fd47abd62e601f2405c7810f04 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:16 -0600 Subject: ASoC: Intel: kbl_da7219_max98927: test return value on route add Fix cppcheck warning: [sound/soc/intel/boards/kbl_da7219_max98927.c:340] -> [sound/soc/intel/boards/kbl_da7219_max98927.c:348]: (style) Variable 'ret' is reassigned a value before the old one has been used. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98927.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c index 34e734adac19..e8b2ec60fb03 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -341,6 +341,9 @@ static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) kabylake_ssp1_map, ARRAY_SIZE(kabylake_ssp1_map)); + if (ret) + return ret; + /* * Headset buttons map to the google Reference headset. * These can be configured by userspace. -- cgit v1.2.3 From 1a29c760663624b0160c0143819c70db99343904 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:17 -0600 Subject: ASoC: Intel: kbl_da7219_max98927: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/kbl_da7219_max98927.c:432] -> [sound/soc/intel/boards/kbl_da7219_max98927.c:282]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/kbl_da7219_max98927.c:432] -> [sound/soc/intel/boards/kbl_da7219_max98927.c:494]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-8-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98927.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c index e8b2ec60fb03..f8cf5de5ba09 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -279,7 +279,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); struct snd_soc_dpcm *dpcm = container_of( @@ -298,7 +298,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, !strcmp(rtd->card->name, "kblmax98373")) { /* The ADSP will convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = DUAL_CHANNEL; + chan->min = chan->max = DUAL_CHANNEL; /* set SSP to 24 bit */ snd_mask_none(fmt); @@ -313,7 +313,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") || !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; snd_mask_none(fmt); snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); } @@ -494,7 +494,7 @@ static const struct snd_soc_ops kabylake_da7219_fe_ops = { static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); /* @@ -502,9 +502,9 @@ static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, */ if (params_channels(params) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 379336e30ff728c1c06e818ff4427dfe053f2102 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:18 -0600 Subject: ASoC: Intel: kbl_da7219_max98927: remove unnecessary initialization Fix cppcheck warning [sound/soc/intel/boards/kbl_da7219_max98927.c:179]: (style) Variable 'ret' is assigned a value that is never used. [sound/soc/intel/boards/kbl_da7219_max98927.c:1098]: (style) Variable 'i' is assigned a value that is never used. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-9-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98927.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98927.c b/sound/soc/intel/boards/kbl_da7219_max98927.c index f8cf5de5ba09..7a13e9b35187 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98927.c +++ b/sound/soc/intel/boards/kbl_da7219_max98927.c @@ -176,7 +176,7 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *runtime = substream->private_data; - int ret = 0, j; + int ret, j; for (j = 0; j < runtime->num_codecs; j++) { struct snd_soc_dai *codec_dai = runtime->codec_dais[j]; @@ -1095,7 +1095,7 @@ static int kabylake_audio_probe(struct platform_device *pdev) struct kbl_codec_private *ctx; struct snd_soc_dai_link *kbl_dai_link; struct snd_soc_dai_link_component **codecs; - int i = 0; + int i; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) -- cgit v1.2.3 From 74e7c6b0030c36a9e9e3c8da4d3b08160b5dda4d Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:19 -0600 Subject: ASoC: Intel: kbl_rt5660: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/kbl_rt5660.c:282] -> [sound/soc/intel/boards/kbl_rt5660.c:141]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-10-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5660.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5660.c b/sound/soc/intel/boards/kbl_rt5660.c index 74fe1f3a5479..e23dea9ab79a 100644 --- a/sound/soc/intel/boards/kbl_rt5660.c +++ b/sound/soc/intel/boards/kbl_rt5660.c @@ -138,13 +138,13 @@ static int kabylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will convert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = DUAL_CHANNEL; + chan->min = chan->max = DUAL_CHANNEL; /* set SSP0 to 24 bit */ snd_mask_none(fmt); -- cgit v1.2.3 From 13a5d5edcf0607ec1584b2c05b1bf3e6600f6533 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:20 -0600 Subject: ASoC: Intel: kbl_rt5663_max98927: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/kbl_rt5663_max98927.c:358] -> [sound/soc/intel/boards/kbl_rt5663_max98927.c:401]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/kbl_rt5663_max98927.c:358] -> [sound/soc/intel/boards/kbl_rt5663_max98927.c:457]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-11-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index cd748d6f4af3..d8f2ff7139a9 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -398,7 +398,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); struct snd_soc_dpcm *dpcm = container_of( @@ -413,7 +413,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") || !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; snd_mask_none(fmt); snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); } @@ -454,13 +454,13 @@ static struct snd_soc_ops kabylake_rt5663_ops = { static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 1157613863e0ec8ef9b5f8840b88e78ae13db5d7 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:21 -0600 Subject: ASoC: Intel: kbl_rt5663_rt5514_max98927: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c:293] -> [sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c:336]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index e2b0a027f5a1..952616ffbc16 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -333,7 +333,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); struct snd_soc_dpcm *dpcm = container_of( @@ -348,15 +348,15 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") || !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; snd_mask_none(fmt); snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE); } else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) { if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; } /* * The speaker on the SSP0 supports S16_LE and not S24_LE. -- cgit v1.2.3 From 38e58021a950a108215107e22148dfe04a30728a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:22 -0600 Subject: ASOC: Intel: kbl_rt5663_rt5514_max98927: remove useless initialization Fix cppcheck warning: [sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c:764]: (style) Variable 'ret' is assigned a value that is never used. Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-13-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 952616ffbc16..96c814f36458 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -761,7 +761,7 @@ static int kabylake_audio_probe(struct platform_device *pdev) { struct kbl_codec_private *ctx; struct snd_soc_acpi_mach *mach; - int ret = 0; + int ret; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) -- cgit v1.2.3 From 119cc7841403d1f1889ce17358ed98de023bf387 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:23 -0600 Subject: ASoC: Intel: skl_nau88l25_max98357a: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/skl_nau88l25_max98357a.c:257] -> [sound/soc/intel/boards/skl_nau88l25_max98357a.c:142]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/skl_nau88l25_max98357a.c:257] -> [sound/soc/intel/boards/skl_nau88l25_max98357a.c:318]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-14-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_nau88l25_max98357a.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c index 3ce8efbeed12..e6de3b28d840 100644 --- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c +++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c @@ -139,13 +139,13 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; /* set SSP0 to 24 bit */ snd_mask_none(fmt); @@ -315,13 +315,13 @@ static const struct snd_soc_ops skylake_nau8825_ops = { static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From ddce36afd59f7adb92dbbd3aa0eaab4bdcc6b530 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:24 -0600 Subject: ASoC: Intel: skl_nau88l25_ssm4567: rename shadowed variable Fix cppcheck warning [sound/soc/intel/boards/skl_nau88l25_ssm4567.c:277] -> [sound/soc/intel/boards/skl_nau88l25_ssm4567.c:320]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/skl_nau88l25_ssm4567.c:277] -> [sound/soc/intel/boards/skl_nau88l25_ssm4567.c:337]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-15-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index b96b014e8c9e..c99c8b23e509 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -317,13 +317,13 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The ADSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; /* set SSP0 to 24 bit */ snd_mask_none(fmt); @@ -334,12 +334,12 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (params_channels(params) == 2 || DMIC_CH(dmic_constraints) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 0c7288f49135c27211c3a39e16788db41b22bf93 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:25 -0600 Subject: ASoC: Intel: skl_rt286: rename shadowed variable Fix cppcheck warning: [sound/soc/intel/boards/skl_rt286.c:171] -> [sound/soc/intel/boards/skl_rt286.c:214]: (style) Local variable 'channels' shadows outer variable [sound/soc/intel/boards/skl_rt286.c:171] -> [sound/soc/intel/boards/skl_rt286.c:250]: (style) Local variable 'channels' shadows outer variable Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-16-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_rt286.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c index 231349a47cc9..a9aec66a2351 100644 --- a/sound/soc/intel/boards/skl_rt286.c +++ b/sound/soc/intel/boards/skl_rt286.c @@ -211,13 +211,13 @@ static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, { struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* The output is 48KHz, stereo, 16bits */ rate->min = rate->max = 48000; - channels->min = channels->max = 2; + chan->min = chan->max = 2; /* set SSP0 to 24 bit */ snd_mask_none(fmt); @@ -247,12 +247,12 @@ static const struct snd_soc_ops skylake_rt286_ops = { static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { - struct snd_interval *channels = hw_param_interval(params, + struct snd_interval *chan = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (params_channels(params) == 2) - channels->min = channels->max = 2; + chan->min = chan->max = 2; else - channels->min = channels->max = 4; + chan->min = chan->max = 4; return 0; } -- cgit v1.2.3 From 1b2c868083195f9ae374707bab83739f09a5b261 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:26 -0600 Subject: ASoC: Intel: bytcht_es8316: removed unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix GCC warning with W=1 sound/soc/intel//boards/bytcht_es8316.c:237:40: warning: ‘byt_cht_es8316_dai_params’ defined but not used [-Wunused-const-variable=] Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-17-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcht_es8316.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c index ce760c361eb2..0adc5a5e134a 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -234,14 +234,6 @@ static int byt_cht_es8316_init(struct snd_soc_pcm_runtime *runtime) return 0; } -static const struct snd_soc_pcm_stream byt_cht_es8316_dai_params = { - .formats = SNDRV_PCM_FMTBIT_S24_LE, - .rate_min = 48000, - .rate_max = 48000, - .channels_min = 2, - .channels_max = 2, -}; - static int byt_cht_es8316_codec_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { -- cgit v1.2.3 From 38c059399519f88a93d8873fc500ccb3e73348ac Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:27 -0600 Subject: ASoC: Intel: bytcr_rt5640: remove unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix GCC warning with W=1 sound/soc/intel//boards/bytcr_rt5640.c:936:40: warning: ‘byt_rt5640_dai_params’ defined but not used [-Wunused-const-variable=] Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-18-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5640.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index ab586a486839..dd6310fe8914 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -933,14 +933,6 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return 0; } -static const struct snd_soc_pcm_stream byt_rt5640_dai_params = { - .formats = SNDRV_PCM_FMTBIT_S24_LE, - .rate_min = 48000, - .rate_max = 48000, - .channels_min = 2, - .channels_max = 2, -}; - static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { -- cgit v1.2.3 From c1b34230a37d6c167bee0fc2c7204871cf5e875f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 13 Jan 2020 15:04:28 -0600 Subject: ASoC: Intel: bytcr_rt5651: remove unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix GCC warning with W=1 sound/soc/intel//boards/bytcr_rt5651.c:659:40: warning: ‘byt_rt5651_dai_params’ defined but not used [-Wunused-const-variable=] Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113210428.27457-19-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index c0d322a859f7..3bb2732a9f7e 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -656,14 +656,6 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) return 0; } -static const struct snd_soc_pcm_stream byt_rt5651_dai_params = { - .formats = SNDRV_PCM_FMTBIT_S24_LE, - .rate_min = 48000, - .rate_max = 48000, - .channels_min = 2, - .channels_max = 2, -}; - static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { -- cgit v1.2.3 From e26c4e900b1a75b1e0c9e19e1f807666a8ad2fa1 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Thu, 2 Jan 2020 17:17:54 -0800 Subject: ASoC: Intel: bytcr_rt5651: switch to using devm_fwnode_gpiod_get() devm_fwnode_get_index_gpiod_from_child() is going away as the name is too unwieldy, let's switch to using the new devm_fwnode_gpiod_get(). Signed-off-by: Dmitry Torokhov Link: https://lore.kernel.org/r/20200103011754.GA260926@dtor-ws Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 3bb2732a9f7e..6d71352ea864 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -990,10 +990,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) if (byt_rt5651_gpios) { devm_acpi_dev_add_driver_gpios(codec_dev, byt_rt5651_gpios); - priv->ext_amp_gpio = devm_fwnode_get_index_gpiod_from_child( - &pdev->dev, "ext-amp-enable", 0, - codec_dev->fwnode, - GPIOD_OUT_LOW, "speaker-amp"); + priv->ext_amp_gpio = devm_fwnode_gpiod_get(&pdev->dev, + codec_dev->fwnode, + "ext-amp-enable", + GPIOD_OUT_LOW, + "speaker-amp"); if (IS_ERR(priv->ext_amp_gpio)) { ret_val = PTR_ERR(priv->ext_amp_gpio); switch (ret_val) { @@ -1009,10 +1010,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) return ret_val; } } - priv->hp_detect = devm_fwnode_get_index_gpiod_from_child( - &pdev->dev, "hp-detect", 0, - codec_dev->fwnode, - GPIOD_IN, "hp-detect"); + priv->hp_detect = devm_fwnode_gpiod_get(&pdev->dev, + codec_dev->fwnode, + "hp-detect", + GPIOD_IN, + "hp-detect"); if (IS_ERR(priv->hp_detect)) { ret_val = PTR_ERR(priv->hp_detect); switch (ret_val) { -- cgit v1.2.3 From 30bcb1f264bfdd49561cc7a974b67c4d712b3668 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Tue, 24 Dec 2019 01:27:07 +0100 Subject: dt-bindings: sound: Convert jz47*-codec doc to YAML Convert ingenic,jz4740-codec.txt and ingenic,jz4725b-codec.txt to one single ingenic,codec.yaml file, since they share the same binding. Add the ingenic,jz4770-codec compatible string in the process. Signed-off-by: Paul Cercueil Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20191224002708.1207884-1-paul@crapouillou.net Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/ingenic,codec.yaml | 55 ++++++++++++++++++++++ .../bindings/sound/ingenic,jz4725b-codec.txt | 20 -------- .../bindings/sound/ingenic,jz4740-codec.txt | 20 -------- 3 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/ingenic,codec.yaml delete mode 100644 Documentation/devicetree/bindings/sound/ingenic,jz4725b-codec.txt delete mode 100644 Documentation/devicetree/bindings/sound/ingenic,jz4740-codec.txt diff --git a/Documentation/devicetree/bindings/sound/ingenic,codec.yaml b/Documentation/devicetree/bindings/sound/ingenic,codec.yaml new file mode 100644 index 000000000000..eb4be86464bb --- /dev/null +++ b/Documentation/devicetree/bindings/sound/ingenic,codec.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/ingenic,codec.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ingenic JZ47xx internal codec DT bindings + +maintainers: + - Paul Cercueil + +properties: + $nodename: + pattern: '^audio-codec@.*' + + compatible: + oneOf: + - const: ingenic,jz4770-codec + - const: ingenic,jz4725b-codec + - const: ingenic,jz4740-codec + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: aic + + '#sound-dai-cells': + const: 0 + +additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - '#sound-dai-cells' + +examples: + - | + #include + codec: audio-codec@10020080 { + compatible = "ingenic,jz4740-codec"; + reg = <0x10020080 0x8>; + #sound-dai-cells = <0>; + clocks = <&cgu JZ4740_CLK_AIC>; + clock-names = "aic"; + }; + +... diff --git a/Documentation/devicetree/bindings/sound/ingenic,jz4725b-codec.txt b/Documentation/devicetree/bindings/sound/ingenic,jz4725b-codec.txt deleted file mode 100644 index 05adc0d47b13..000000000000 --- a/Documentation/devicetree/bindings/sound/ingenic,jz4725b-codec.txt +++ /dev/null @@ -1,20 +0,0 @@ -Ingenic JZ4725B codec controller - -Required properties: -- compatible : "ingenic,jz4725b-codec" -- reg : codec registers location and length -- clocks : phandle to the AIC clock. -- clock-names: must be set to "aic". -- #sound-dai-cells: Must be set to 0. - -Example: - -codec: audio-codec@100200a4 { - compatible = "ingenic,jz4725b-codec"; - reg = <0x100200a4 0x8>; - - #sound-dai-cells = <0>; - - clocks = <&cgu JZ4725B_CLK_AIC>; - clock-names = "aic"; -}; diff --git a/Documentation/devicetree/bindings/sound/ingenic,jz4740-codec.txt b/Documentation/devicetree/bindings/sound/ingenic,jz4740-codec.txt deleted file mode 100644 index 1ffcade87e7b..000000000000 --- a/Documentation/devicetree/bindings/sound/ingenic,jz4740-codec.txt +++ /dev/null @@ -1,20 +0,0 @@ -Ingenic JZ4740 codec controller - -Required properties: -- compatible : "ingenic,jz4740-codec" -- reg : codec registers location and length -- clocks : phandle to the AIC clock. -- clock-names: must be set to "aic". -- #sound-dai-cells: Must be set to 0. - -Example: - -codec: audio-codec@10020080 { - compatible = "ingenic,jz4740-codec"; - reg = <0x10020080 0x8>; - - #sound-dai-cells = <0>; - - clocks = <&cgu JZ4740_CLK_AIC>; - clock-names = "aic"; -}; -- cgit v1.2.3 From 2159a6810e96c38a469c39df8e109edb7232d3c9 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Tue, 24 Dec 2019 01:27:08 +0100 Subject: ASoC: codecs: Add jz4770-codec driver Add jz4770-codec driver to support the internal CODEC found in the JZ4770 SoC from Ingenic. Signed-off-by: Paul Cercueil Signed-off-by: Maarten ter Huurne Link: https://lore.kernel.org/r/20191224002708.1207884-2-paul@crapouillou.net Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 12 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/jz4770.c | 948 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 962 insertions(+) create mode 100644 sound/soc/codecs/jz4770.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2f52e4cac96a..de3f13dafc3c 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -101,6 +101,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ISABELLE if I2C select SND_SOC_JZ4740_CODEC select SND_SOC_JZ4725B_CODEC + select SND_SOC_JZ4770_CODEC select SND_SOC_LM4857 if I2C select SND_SOC_LM49453 if I2C select SND_SOC_LOCHNAGAR_SC if MFD_LOCHNAGAR @@ -678,6 +679,17 @@ config SND_SOC_JZ4725B_CODEC This driver can also be built as a module. If so, the module will be called snd-soc-jz4725b-codec. +config SND_SOC_JZ4770_CODEC + depends on MIPS || COMPILE_TEST + select REGMAP + tristate "Ingenic JZ4770 internal CODEC" + help + Enable support for the internal CODEC found in the JZ4770 SoC + from Ingenic. + + This driver can also be built as a module. If so, the module + will be called snd-soc-jz4770-codec. + config SND_SOC_L3 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 66aa452f5aa2..751f2b4d095b 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -97,6 +97,7 @@ snd-soc-inno-rk3036-objs := inno_rk3036.o snd-soc-isabelle-objs := isabelle.o snd-soc-jz4740-codec-objs := jz4740.o snd-soc-jz4725b-codec-objs := jz4725b.o +snd-soc-jz4770-codec-objs := jz4770.o snd-soc-l3-objs := l3.o snd-soc-lm4857-objs := lm4857.o snd-soc-lm49453-objs := lm49453.o @@ -392,6 +393,7 @@ obj-$(CONFIG_SND_SOC_INNO_RK3036) += snd-soc-inno-rk3036.o obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_JZ4725B_CODEC) += snd-soc-jz4725b-codec.o +obj-$(CONFIG_SND_SOC_JZ4770_CODEC) += snd-soc-jz4770-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o obj-$(CONFIG_SND_SOC_LM4857) += snd-soc-lm4857.o obj-$(CONFIG_SND_SOC_LM49453) += snd-soc-lm49453.o diff --git a/sound/soc/codecs/jz4770.c b/sound/soc/codecs/jz4770.c new file mode 100644 index 000000000000..e7cf2c107607 --- /dev/null +++ b/sound/soc/codecs/jz4770.c @@ -0,0 +1,948 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Ingenic JZ4770 CODEC driver +// +// Copyright (C) 2012, Maarten ter Huurne +// Copyright (C) 2019, Paul Cercueil + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define ICDC_RGADW_OFFSET 0x00 +#define ICDC_RGDATA_OFFSET 0x04 + +/* ICDC internal register access control register(RGADW) */ +#define ICDC_RGADW_RGWR BIT(16) + +#define ICDC_RGADW_RGADDR_OFFSET 8 +#define ICDC_RGADW_RGADDR_MASK GENMASK(14, ICDC_RGADW_RGADDR_OFFSET) + +#define ICDC_RGADW_RGDIN_OFFSET 0 +#define ICDC_RGADW_RGDIN_MASK GENMASK(7, ICDC_RGADW_RGDIN_OFFSET) + +/* ICDC internal register data output register (RGDATA)*/ +#define ICDC_RGDATA_IRQ BIT(8) + +#define ICDC_RGDATA_RGDOUT_OFFSET 0 +#define ICDC_RGDATA_RGDOUT_MASK GENMASK(7, ICDC_RGDATA_RGDOUT_OFFSET) + +/* Internal register space, accessed through regmap */ +enum { + JZ4770_CODEC_REG_SR, + JZ4770_CODEC_REG_AICR_DAC, + JZ4770_CODEC_REG_AICR_ADC, + JZ4770_CODEC_REG_CR_LO, + JZ4770_CODEC_REG_CR_HP, + + JZ4770_CODEC_REG_MISSING_REG1, + + JZ4770_CODEC_REG_CR_DAC, + JZ4770_CODEC_REG_CR_MIC, + JZ4770_CODEC_REG_CR_LI, + JZ4770_CODEC_REG_CR_ADC, + JZ4770_CODEC_REG_CR_MIX, + JZ4770_CODEC_REG_CR_VIC, + JZ4770_CODEC_REG_CCR, + JZ4770_CODEC_REG_FCR_DAC, + JZ4770_CODEC_REG_FCR_ADC, + JZ4770_CODEC_REG_ICR, + JZ4770_CODEC_REG_IMR, + JZ4770_CODEC_REG_IFR, + JZ4770_CODEC_REG_GCR_HPL, + JZ4770_CODEC_REG_GCR_HPR, + JZ4770_CODEC_REG_GCR_LIBYL, + JZ4770_CODEC_REG_GCR_LIBYR, + JZ4770_CODEC_REG_GCR_DACL, + JZ4770_CODEC_REG_GCR_DACR, + JZ4770_CODEC_REG_GCR_MIC1, + JZ4770_CODEC_REG_GCR_MIC2, + JZ4770_CODEC_REG_GCR_ADCL, + JZ4770_CODEC_REG_GCR_ADCR, + + JZ4770_CODEC_REG_MISSING_REG2, + + JZ4770_CODEC_REG_GCR_MIXADC, + JZ4770_CODEC_REG_GCR_MIXDAC, + JZ4770_CODEC_REG_AGC1, + JZ4770_CODEC_REG_AGC2, + JZ4770_CODEC_REG_AGC3, + JZ4770_CODEC_REG_AGC4, + JZ4770_CODEC_REG_AGC5, +}; + +#define REG_AICR_DAC_ADWL_OFFSET 6 +#define REG_AICR_DAC_ADWL_MASK (0x3 << REG_AICR_DAC_ADWL_OFFSET) +#define REG_AICR_DAC_SERIAL BIT(1) +#define REG_AICR_DAC_I2S BIT(0) + +#define REG_AICR_ADC_ADWL_OFFSET 6 +#define REG_AICR_ADC_ADWL_MASK (0x3 << REG_AICR_ADC_ADWL_OFFSET) +#define REG_AICR_ADC_SERIAL BIT(1) +#define REG_AICR_ADC_I2S BIT(0) + +#define REG_CR_LO_MUTE_OFFSET 7 +#define REG_CR_LO_SB_OFFSET 4 +#define REG_CR_LO_SEL_OFFSET 0 +#define REG_CR_LO_SEL_MASK (0x3 << REG_CR_LO_SEL_OFFSET) + +#define REG_CR_HP_MUTE BIT(7) +#define REG_CR_HP_LOAD BIT(6) +#define REG_CR_HP_SB_OFFSET 4 +#define REG_CR_HP_SB_HPCM BIT(3) +#define REG_CR_HP_SEL_OFFSET 0 +#define REG_CR_HP_SEL_MASK (0x3 << REG_CR_HP_SEL_OFFSET) + +#define REG_CR_DAC_MUTE BIT(7) +#define REG_CR_DAC_MONO BIT(6) +#define REG_CR_DAC_LEFT_ONLY BIT(5) +#define REG_CR_DAC_SB_OFFSET 4 +#define REG_CR_DAC_LRSWAP BIT(3) + +#define REG_CR_MIC_STEREO_OFFSET 7 +#define REG_CR_MIC_IDIFF_OFFSET 6 +#define REG_CR_MIC_SB_MIC2_OFFSET 5 +#define REG_CR_MIC_SB_MIC1_OFFSET 4 +#define REG_CR_MIC_BIAS_V0_OFFSET 1 +#define REG_CR_MIC_BIAS_SB_OFFSET 0 + +#define REG_CR_LI_LIBY_OFFSET 4 +#define REG_CR_LI_SB_OFFSET 0 + +#define REG_CR_ADC_DMIC_SEL BIT(7) +#define REG_CR_ADC_MONO BIT(6) +#define REG_CR_ADC_LEFT_ONLY BIT(5) +#define REG_CR_ADC_SB_OFFSET 4 +#define REG_CR_ADC_LRSWAP BIT(3) +#define REG_CR_ADC_IN_SEL_OFFSET 0 +#define REG_CR_ADC_IN_SEL_MASK (0x3 << REG_CR_ADC_IN_SEL_OFFSET) + +#define REG_CR_VIC_SB_SLEEP BIT(1) +#define REG_CR_VIC_SB BIT(0) + +#define REG_CCR_CRYSTAL_OFFSET 0 +#define REG_CCR_CRYSTAL_MASK (0xf << REG_CCR_CRYSTAL_OFFSET) + +#define REG_FCR_DAC_FREQ_OFFSET 0 +#define REG_FCR_DAC_FREQ_MASK (0xf << REG_FCR_DAC_FREQ_OFFSET) + +#define REG_FCR_ADC_FREQ_OFFSET 0 +#define REG_FCR_ADC_FREQ_MASK (0xf << REG_FCR_ADC_FREQ_OFFSET) + +#define REG_ICR_INT_FORM_OFFSET 6 +#define REG_ICR_INT_FORM_MASK (0x3 << REG_ICR_INT_FORM_OFFSET) + +#define REG_IMR_ALL_MASK (0x7f) +#define REG_IMR_SCLR_MASK BIT(6) +#define REG_IMR_JACK_MASK BIT(5) +#define REG_IMR_SCMC_MASK BIT(4) +#define REG_IMR_RUP_MASK BIT(3) +#define REG_IMR_RDO_MASK BIT(2) +#define REG_IMR_GUP_MASK BIT(1) +#define REG_IMR_GDO_MASK BIT(0) + +#define REG_IFR_ALL_MASK (0x7f) +#define REG_IFR_SCLR BIT(6) +#define REG_IFR_JACK BIT(5) +#define REG_IFR_SCMC BIT(4) +#define REG_IFR_RUP BIT(3) +#define REG_IFR_RDO BIT(2) +#define REG_IFR_GUP BIT(1) +#define REG_IFR_GDO BIT(0) + +#define REG_GCR_HPL_LRGO BIT(7) + +#define REG_GCR_DACL_RLGOD BIT(7) + +#define REG_GCR_GAIN_OFFSET 0 +#define REG_GCR_GAIN_MAX 0x1f + +#define REG_GCR_MIC_GAIN_OFFSET 0 +#define REG_GCR_MIC_GAIN_MAX 5 + +#define REG_GCR_ADC_GAIN_OFFSET 0 +#define REG_GCR_ADC_GAIN_MAX 23 + +#define REG_AGC1_EN BIT(7) + +/* codec private data */ +struct jz_codec { + struct device *dev; + struct regmap *regmap; + void __iomem *base; + struct clk *clk; +}; + +static int jz4770_codec_set_bias_level(struct snd_soc_component *codec, + enum snd_soc_bias_level level) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + struct regmap *regmap = jz_codec->regmap; + + switch (level) { + case SND_SOC_BIAS_PREPARE: + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_VIC, + REG_CR_VIC_SB, 0); + msleep(250); + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_VIC, + REG_CR_VIC_SB_SLEEP, 0); + msleep(400); + break; + case SND_SOC_BIAS_STANDBY: + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_VIC, + REG_CR_VIC_SB_SLEEP, REG_CR_VIC_SB_SLEEP); + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_VIC, + REG_CR_VIC_SB, REG_CR_VIC_SB); + /* fall-through */ + default: + break; + } + + return 0; +} + +static int jz4770_codec_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + + /* + * SYSCLK output from the codec to the AIC is required to keep the + * DMA transfer going during playback when all audible outputs have + * been disabled. + */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_dapm_force_enable_pin(dapm, "SYSCLK"); + + return 0; +} + +static void jz4770_codec_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(codec); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_dapm_disable_pin(dapm, "SYSCLK"); +} + + +static int jz4770_codec_pcm_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct snd_soc_component *codec = dai->component; + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) + snd_soc_component_force_bias_level(codec, + SND_SOC_BIAS_ON); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + /* do nothing */ + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static int jz4770_codec_digital_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_component *codec = dai->component; + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + unsigned int gain_bit = mute ? REG_IFR_GDO : REG_IFR_GUP; + unsigned int val; + int change, err; + + change = snd_soc_component_update_bits(codec, JZ4770_CODEC_REG_CR_DAC, + REG_CR_DAC_MUTE, + mute ? REG_CR_DAC_MUTE : 0); + if (change == 1) { + regmap_read(jz_codec->regmap, JZ4770_CODEC_REG_CR_DAC, &val); + + if (val & BIT(REG_CR_DAC_SB_OFFSET)) + return 1; + + err = regmap_read_poll_timeout(jz_codec->regmap, + JZ4770_CODEC_REG_IFR, + val, val & gain_bit, + 1000, 100 * USEC_PER_MSEC); + if (err) { + dev_err(jz_codec->dev, + "Timeout while setting digital mute: %d", err); + return err; + } + + /* clear GUP/GDO flag */ + regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, + gain_bit, gain_bit); + } + + return 0; +} + +/* unit: 0.01dB */ +static const DECLARE_TLV_DB_MINMAX_MUTE(dac_tlv, -3100, 0); +static const DECLARE_TLV_DB_SCALE(adc_tlv, 0, 100, 0); +static const DECLARE_TLV_DB_MINMAX(out_tlv, -2500, 600); +static const DECLARE_TLV_DB_SCALE(mic_boost_tlv, 0, 400, 0); +static const DECLARE_TLV_DB_SCALE(linein_tlv, -2500, 100, 0); + +/* Unconditional controls. */ +static const struct snd_kcontrol_new jz4770_codec_snd_controls[] = { + /* record gain control */ + SOC_DOUBLE_R_TLV("PCM Capture Volume", + JZ4770_CODEC_REG_GCR_ADCL, JZ4770_CODEC_REG_GCR_ADCR, + REG_GCR_ADC_GAIN_OFFSET, REG_GCR_ADC_GAIN_MAX, + 0, adc_tlv), + + SOC_DOUBLE_R_TLV("Line In Bypass Playback Volume", + JZ4770_CODEC_REG_GCR_LIBYL, JZ4770_CODEC_REG_GCR_LIBYR, + REG_GCR_GAIN_OFFSET, REG_GCR_GAIN_MAX, 1, linein_tlv), +}; + +static const struct snd_kcontrol_new jz4770_codec_pcm_playback_controls[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Volume", + .info = snd_soc_info_volsw, + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ + | SNDRV_CTL_ELEM_ACCESS_READWRITE, + .tlv.p = dac_tlv, + .get = snd_soc_dapm_get_volsw, + .put = snd_soc_dapm_put_volsw, + /* + * NOTE: DACR/DACL are inversed; the gain value written to DACR + * seems to affect the left channel, and the gain value written + * to DACL seems to affect the right channel. + */ + .private_value = SOC_DOUBLE_R_VALUE(JZ4770_CODEC_REG_GCR_DACR, + JZ4770_CODEC_REG_GCR_DACL, + REG_GCR_GAIN_OFFSET, + REG_GCR_GAIN_MAX, 1), + }, +}; + +static const struct snd_kcontrol_new jz4770_codec_hp_playback_controls[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Volume", + .info = snd_soc_info_volsw, + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ + | SNDRV_CTL_ELEM_ACCESS_READWRITE, + .tlv.p = out_tlv, + .get = snd_soc_dapm_get_volsw, + .put = snd_soc_dapm_put_volsw, + /* HPR/HPL inversed for the same reason as above */ + .private_value = SOC_DOUBLE_R_VALUE(JZ4770_CODEC_REG_GCR_HPR, + JZ4770_CODEC_REG_GCR_HPL, + REG_GCR_GAIN_OFFSET, + REG_GCR_GAIN_MAX, 1), + }, +}; + +static int hpout_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm); + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + unsigned int val; + int err; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + /* set cap-less, unmute HP */ + regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SB_HPCM | REG_CR_HP_MUTE, 0); + break; + + case SND_SOC_DAPM_POST_PMU: + /* wait for ramp-up complete (RUP) */ + err = regmap_read_poll_timeout(jz_codec->regmap, + JZ4770_CODEC_REG_IFR, + val, val & REG_IFR_RUP, + 1000, 100 * USEC_PER_MSEC); + if (err) { + dev_err(jz_codec->dev, "RUP timeout: %d", err); + return err; + } + + /* clear RUP flag */ + regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, + REG_IFR_RUP, REG_IFR_RUP); + + break; + + case SND_SOC_DAPM_POST_PMD: + /* set cap-couple, mute HP */ + regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SB_HPCM | REG_CR_HP_MUTE, + REG_CR_HP_SB_HPCM | REG_CR_HP_MUTE); + + err = regmap_read_poll_timeout(jz_codec->regmap, + JZ4770_CODEC_REG_IFR, + val, val & REG_IFR_RDO, + 1000, 100 * USEC_PER_MSEC); + if (err) { + dev_err(jz_codec->dev, "RDO timeout: %d", err); + return err; + } + + /* clear RDO flag */ + regmap_update_bits(jz_codec->regmap, JZ4770_CODEC_REG_IFR, + REG_IFR_RDO, REG_IFR_RDO); + + break; + } + + return 0; +} + +static int adc_poweron_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event == SND_SOC_DAPM_POST_PMU) + msleep(1000); + + return 0; +} + +static const char * const jz4770_codec_hp_texts[] = { + "PCM", "Line In", "Mic 1", "Mic 2" +}; +static const unsigned int jz4770_codec_hp_values[] = { 3, 2, 0, 1 }; +static SOC_VALUE_ENUM_SINGLE_DECL(jz4770_codec_hp_enum, + JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SEL_OFFSET, + REG_CR_HP_SEL_MASK, + jz4770_codec_hp_texts, + jz4770_codec_hp_values); +static const struct snd_kcontrol_new jz4770_codec_hp_source = + SOC_DAPM_ENUM("Route", jz4770_codec_hp_enum); + +static SOC_VALUE_ENUM_SINGLE_DECL(jz4770_codec_lo_enum, + JZ4770_CODEC_REG_CR_LO, + REG_CR_LO_SEL_OFFSET, + REG_CR_LO_SEL_MASK, + jz4770_codec_hp_texts, + jz4770_codec_hp_values); +static const struct snd_kcontrol_new jz4770_codec_lo_source = + SOC_DAPM_ENUM("Route", jz4770_codec_lo_enum); + +static const char * const jz4770_codec_cap_texts[] = { + "Line In", "Mic 1", "Mic 2" +}; +static const unsigned int jz4770_codec_cap_values[] = { 2, 0, 1 }; +static SOC_VALUE_ENUM_SINGLE_DECL(jz4770_codec_cap_enum, + JZ4770_CODEC_REG_CR_ADC, + REG_CR_ADC_IN_SEL_OFFSET, + REG_CR_ADC_IN_SEL_MASK, + jz4770_codec_cap_texts, + jz4770_codec_cap_values); +static const struct snd_kcontrol_new jz4770_codec_cap_source = + SOC_DAPM_ENUM("Route", jz4770_codec_cap_enum); + +static const struct snd_kcontrol_new jz4770_codec_mic_controls[] = { + SOC_DAPM_SINGLE("Stereo Capture Switch", JZ4770_CODEC_REG_CR_MIC, + REG_CR_MIC_STEREO_OFFSET, 1, 0), +}; + +static const struct snd_soc_dapm_widget jz4770_codec_dapm_widgets[] = { + SND_SOC_DAPM_PGA_E("HP Out", JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SB_OFFSET, 1, NULL, 0, hpout_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_PGA("Line Out", JZ4770_CODEC_REG_CR_LO, + REG_CR_LO_SB_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_PGA("Line Out Switch 2", JZ4770_CODEC_REG_CR_LO, + REG_CR_LO_MUTE_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_PGA("Line In", JZ4770_CODEC_REG_CR_LI, + REG_CR_LI_SB_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_MUX("Headphones Source", SND_SOC_NOPM, 0, 0, + &jz4770_codec_hp_source), + SND_SOC_DAPM_MUX("Capture Source", SND_SOC_NOPM, 0, 0, + &jz4770_codec_cap_source), + SND_SOC_DAPM_MUX("Line Out Source", SND_SOC_NOPM, 0, 0, + &jz4770_codec_lo_source), + + SND_SOC_DAPM_PGA("Mic 1", JZ4770_CODEC_REG_CR_MIC, + REG_CR_MIC_SB_MIC1_OFFSET, 1, NULL, 0), + SND_SOC_DAPM_PGA("Mic 2", JZ4770_CODEC_REG_CR_MIC, + REG_CR_MIC_SB_MIC2_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_PGA("Mic Diff", JZ4770_CODEC_REG_CR_MIC, + REG_CR_MIC_IDIFF_OFFSET, 0, NULL, 0), + + SND_SOC_DAPM_MIXER("Mic", SND_SOC_NOPM, 0, 0, + jz4770_codec_mic_controls, + ARRAY_SIZE(jz4770_codec_mic_controls)), + + SND_SOC_DAPM_PGA("Line In Bypass", JZ4770_CODEC_REG_CR_LI, + REG_CR_LI_LIBY_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_ADC_E("ADC", "HiFi Capture", JZ4770_CODEC_REG_CR_ADC, + REG_CR_ADC_SB_OFFSET, 1, adc_poweron_event, + SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_DAC("DAC", "HiFi Playback", JZ4770_CODEC_REG_CR_DAC, + REG_CR_DAC_SB_OFFSET, 1), + + SND_SOC_DAPM_MIXER("PCM Playback", SND_SOC_NOPM, 0, 0, + jz4770_codec_pcm_playback_controls, + ARRAY_SIZE(jz4770_codec_pcm_playback_controls)), + SND_SOC_DAPM_MIXER("Headphones Playback", SND_SOC_NOPM, 0, 0, + jz4770_codec_hp_playback_controls, + ARRAY_SIZE(jz4770_codec_hp_playback_controls)), + + SND_SOC_DAPM_SUPPLY("MICBIAS", JZ4770_CODEC_REG_CR_MIC, + REG_CR_MIC_BIAS_SB_OFFSET, 1, NULL, 0), + + SND_SOC_DAPM_INPUT("MIC1P"), + SND_SOC_DAPM_INPUT("MIC1N"), + SND_SOC_DAPM_INPUT("MIC2P"), + SND_SOC_DAPM_INPUT("MIC2N"), + + SND_SOC_DAPM_OUTPUT("LOUT"), + SND_SOC_DAPM_OUTPUT("ROUT"), + + SND_SOC_DAPM_OUTPUT("LHPOUT"), + SND_SOC_DAPM_OUTPUT("RHPOUT"), + + SND_SOC_DAPM_INPUT("LLINEIN"), + SND_SOC_DAPM_INPUT("RLINEIN"), + + SND_SOC_DAPM_OUTPUT("SYSCLK"), +}; + +/* Unconditional routes. */ +static const struct snd_soc_dapm_route jz4770_codec_dapm_routes[] = { + { "Mic 1", NULL, "MIC1P" }, + { "Mic Diff", NULL, "MIC1N" }, + { "Mic 1", NULL, "Mic Diff" }, + { "Mic 2", NULL, "MIC2P" }, + { "Mic Diff", NULL, "MIC2N" }, + { "Mic 2", NULL, "Mic Diff" }, + + { "Line In", NULL, "LLINEIN" }, + { "Line In", NULL, "RLINEIN" }, + + { "Mic", "Stereo Capture Switch", "Mic 1" }, + { "Mic", "Stereo Capture Switch", "Mic 2" }, + { "Headphones Source", "Mic 1", "Mic" }, + { "Headphones Source", "Mic 2", "Mic" }, + { "Capture Source", "Mic 1", "Mic" }, + { "Capture Source", "Mic 2", "Mic" }, + + { "Headphones Source", "Mic 1", "Mic 1" }, + { "Headphones Source", "Mic 2", "Mic 2" }, + { "Headphones Source", "Line In", "Line In Bypass" }, + { "Headphones Source", "PCM", "Headphones Playback" }, + { "HP Out", NULL, "Headphones Source" }, + + { "Capture Source", "Line In", "Line In" }, + { "Capture Source", "Mic 1", "Mic 1" }, + { "Capture Source", "Mic 2", "Mic 2" }, + { "ADC", NULL, "Capture Source" }, + + { "Line In Bypass", NULL, "Line In" }, + { "Line Out Source", "Line In", "Line In Bypass" }, + { "Line Out Source", "PCM", "PCM Playback" }, + + { "LHPOUT", NULL, "HP Out"}, + { "RHPOUT", NULL, "HP Out"}, + + { "Line Out", NULL, "Line Out Source" }, + { "Line Out Switch 2", NULL, "Line Out" }, + + { "LOUT", NULL, "Line Out Switch 2"}, + { "ROUT", NULL, "Line Out Switch 2"}, + + { "PCM Playback", "Volume", "DAC" }, + { "Headphones Playback", "Volume", "PCM Playback" }, + + { "SYSCLK", NULL, "DAC" }, +}; + +static void jz4770_codec_codec_init_regs(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + struct regmap *regmap = jz_codec->regmap; + + /* Collect updates for later sending. */ + regcache_cache_only(regmap, true); + + /* default HP output to PCM */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SEL_MASK, REG_CR_HP_SEL_MASK); + + /* default line output to PCM */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_LO, + REG_CR_LO_SEL_MASK, REG_CR_LO_SEL_MASK); + + /* Disable stereo mic */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_MIC, + BIT(REG_CR_MIC_STEREO_OFFSET), 0); + + /* Set mic 1 as default source for ADC */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_ADC, + REG_CR_ADC_IN_SEL_MASK, 0); + + /* ADC/DAC: serial + i2s */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_AICR_ADC, + REG_AICR_ADC_SERIAL | REG_AICR_ADC_I2S, + REG_AICR_ADC_SERIAL | REG_AICR_ADC_I2S); + regmap_update_bits(regmap, JZ4770_CODEC_REG_AICR_DAC, + REG_AICR_DAC_SERIAL | REG_AICR_DAC_I2S, + REG_AICR_DAC_SERIAL | REG_AICR_DAC_I2S); + + /* The generated IRQ is a high level */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_ICR, + REG_ICR_INT_FORM_MASK, 0); + regmap_update_bits(regmap, JZ4770_CODEC_REG_IMR, REG_IMR_ALL_MASK, + REG_IMR_JACK_MASK | REG_IMR_RUP_MASK | + REG_IMR_RDO_MASK | REG_IMR_GUP_MASK | + REG_IMR_GDO_MASK); + + /* 12M oscillator */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CCR, + REG_CCR_CRYSTAL_MASK, 0); + + /* 0: 16ohm/220uF, 1: 10kohm/1uF */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_LOAD, 0); + + /* disable automatic gain */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_AGC1, REG_AGC1_EN, 0); + + /* Disable DAC lrswap */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_DAC, + REG_CR_DAC_LRSWAP, REG_CR_DAC_LRSWAP); + + /* Independent L/R DAC gain control */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_GCR_DACL, + REG_GCR_DACL_RLGOD, 0); + + /* Disable ADC lrswap */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_ADC, + REG_CR_ADC_LRSWAP, REG_CR_ADC_LRSWAP); + + /* default to cap-less mode(0) */ + regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_HP, + REG_CR_HP_SB_HPCM, 0); + + /* Send collected updates. */ + regcache_cache_only(regmap, false); + regcache_sync(regmap); + + /* Reset all interrupt flags. */ + regmap_write(regmap, JZ4770_CODEC_REG_IFR, REG_IFR_ALL_MASK); +} + +static int jz4770_codec_codec_probe(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + + clk_prepare_enable(jz_codec->clk); + + jz4770_codec_codec_init_regs(codec); + + return 0; +} + +static void jz4770_codec_codec_remove(struct snd_soc_component *codec) +{ + struct jz_codec *jz_codec = snd_soc_component_get_drvdata(codec); + + clk_disable_unprepare(jz_codec->clk); +} + +static const struct snd_soc_component_driver jz4770_codec_soc_codec_dev = { + .probe = jz4770_codec_codec_probe, + .remove = jz4770_codec_codec_remove, + .set_bias_level = jz4770_codec_set_bias_level, + .controls = jz4770_codec_snd_controls, + .num_controls = ARRAY_SIZE(jz4770_codec_snd_controls), + .dapm_widgets = jz4770_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(jz4770_codec_dapm_widgets), + .dapm_routes = jz4770_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(jz4770_codec_dapm_routes), + .suspend_bias_off = 1, + .use_pmdown_time = 1, +}; + +static const unsigned int jz4770_codec_sample_rates[] = { + 96000, 48000, 44100, 32000, + 24000, 22050, 16000, 12000, + 11025, 9600, 8000, +}; + +static int jz4770_codec_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct jz_codec *codec = snd_soc_component_get_drvdata(dai->component); + unsigned int rate, bit_width; + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + bit_width = 0; + break; + case SNDRV_PCM_FORMAT_S18_3LE: + bit_width = 1; + break; + case SNDRV_PCM_FORMAT_S20_3LE: + bit_width = 2; + break; + case SNDRV_PCM_FORMAT_S24_3LE: + bit_width = 3; + break; + default: + return -EINVAL; + } + + for (rate = 0; rate < ARRAY_SIZE(jz4770_codec_sample_rates); rate++) { + if (jz4770_codec_sample_rates[rate] == params_rate(params)) + break; + } + + if (rate == ARRAY_SIZE(jz4770_codec_sample_rates)) + return -EINVAL; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_DAC, + REG_AICR_DAC_ADWL_MASK, + bit_width << REG_AICR_DAC_ADWL_OFFSET); + regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_DAC, + REG_FCR_DAC_FREQ_MASK, + rate << REG_FCR_DAC_FREQ_OFFSET); + } else { + regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_AICR_ADC, + REG_AICR_ADC_ADWL_MASK, + bit_width << REG_AICR_ADC_ADWL_OFFSET); + regmap_update_bits(codec->regmap, JZ4770_CODEC_REG_FCR_ADC, + REG_FCR_ADC_FREQ_MASK, + rate << REG_FCR_ADC_FREQ_OFFSET); + } + + return 0; +} + +static const struct snd_soc_dai_ops jz4770_codec_dai_ops = { + .startup = jz4770_codec_startup, + .shutdown = jz4770_codec_shutdown, + .hw_params = jz4770_codec_hw_params, + .trigger = jz4770_codec_pcm_trigger, + .digital_mute = jz4770_codec_digital_mute, +}; + +#define JZ_CODEC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S18_3LE | \ + SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_3LE) + +static struct snd_soc_dai_driver jz4770_codec_dai = { + .name = "jz4770-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = JZ_CODEC_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_96000, + .formats = JZ_CODEC_FORMATS, + }, + .ops = &jz4770_codec_dai_ops, +}; + +static bool jz4770_codec_volatile(struct device *dev, unsigned int reg) +{ + return reg == JZ4770_CODEC_REG_SR || reg == JZ4770_CODEC_REG_IFR; +} + +static bool jz4770_codec_readable(struct device *dev, unsigned int reg) +{ + switch (reg) { + case JZ4770_CODEC_REG_MISSING_REG1: + case JZ4770_CODEC_REG_MISSING_REG2: + return false; + default: + return true; + } +} + +static bool jz4770_codec_writeable(struct device *dev, unsigned int reg) +{ + switch (reg) { + case JZ4770_CODEC_REG_SR: + case JZ4770_CODEC_REG_MISSING_REG1: + case JZ4770_CODEC_REG_MISSING_REG2: + return false; + default: + return true; + } +} + +static int jz4770_codec_io_wait(struct jz_codec *codec) +{ + u32 reg; + + return readl_poll_timeout(codec->base + ICDC_RGADW_OFFSET, reg, + !(reg & ICDC_RGADW_RGWR), + 1000, 10 * USEC_PER_MSEC); +} + +static int jz4770_codec_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct jz_codec *codec = context; + unsigned int i; + u32 tmp; + int ret; + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + tmp = readl(codec->base + ICDC_RGADW_OFFSET); + tmp = (tmp & ~ICDC_RGADW_RGADDR_MASK) + | (reg << ICDC_RGADW_RGADDR_OFFSET); + writel(tmp, codec->base + ICDC_RGADW_OFFSET); + + /* wait 6+ cycles */ + for (i = 0; i < 6; i++) + *val = readl(codec->base + ICDC_RGDATA_OFFSET) & + ICDC_RGDATA_RGDOUT_MASK; + + return 0; +} + +static int jz4770_codec_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct jz_codec *codec = context; + int ret; + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + writel(ICDC_RGADW_RGWR | (reg << ICDC_RGADW_RGADDR_OFFSET) | val, + codec->base + ICDC_RGADW_OFFSET); + + ret = jz4770_codec_io_wait(codec); + if (ret) + return ret; + + return 0; +} + +static const u8 jz4770_codec_reg_defaults[] = { + 0x00, 0xC3, 0xC3, 0x90, 0x98, 0xFF, 0x90, 0xB1, + 0x11, 0x10, 0x00, 0x03, 0x00, 0x00, 0x40, 0x00, + 0xFF, 0x00, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x34, + 0x07, 0x44, 0x1F, 0x00 +}; + +static struct regmap_config jz4770_codec_regmap_config = { + .reg_bits = 7, + .val_bits = 8, + + .max_register = JZ4770_CODEC_REG_AGC5, + .volatile_reg = jz4770_codec_volatile, + .readable_reg = jz4770_codec_readable, + .writeable_reg = jz4770_codec_writeable, + + .reg_read = jz4770_codec_reg_read, + .reg_write = jz4770_codec_reg_write, + + .reg_defaults_raw = jz4770_codec_reg_defaults, + .num_reg_defaults_raw = ARRAY_SIZE(jz4770_codec_reg_defaults), + .cache_type = REGCACHE_FLAT, +}; + +static int jz4770_codec_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct jz_codec *codec; + int ret; + + codec = devm_kzalloc(dev, sizeof(*codec), GFP_KERNEL); + if (!codec) + return -ENOMEM; + + codec->dev = dev; + + codec->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(codec->base)) { + ret = PTR_ERR(codec->base); + dev_err(dev, "Failed to ioremap mmio memory: %d\n", ret); + return ret; + } + + codec->regmap = devm_regmap_init(dev, NULL, codec, + &jz4770_codec_regmap_config); + if (IS_ERR(codec->regmap)) + return PTR_ERR(codec->regmap); + + codec->clk = devm_clk_get(dev, "aic"); + if (IS_ERR(codec->clk)) + return PTR_ERR(codec->clk); + + platform_set_drvdata(pdev, codec); + + ret = devm_snd_soc_register_component(dev, &jz4770_codec_soc_codec_dev, + &jz4770_codec_dai, 1); + if (ret) { + dev_err(dev, "Failed to register codec: %d\n", ret); + return ret; + } + + return 0; +} + +static const struct of_device_id jz4770_codec_of_matches[] = { + { .compatible = "ingenic,jz4770-codec", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, jz4770_codec_of_matches); + +static struct platform_driver jz4770_codec_driver = { + .probe = jz4770_codec_probe, + .driver = { + .name = "jz4770-codec", + .of_match_table = of_match_ptr(jz4770_codec_of_matches), + }, +}; +module_platform_driver(jz4770_codec_driver); + +MODULE_DESCRIPTION("JZ4770 SoC internal codec driver"); +MODULE_AUTHOR("Maarten ter Huurne "); +MODULE_AUTHOR("Paul Cercueil "); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From e19ecbf105b236a6334fab64d8fd5437b12ee019 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 20 Dec 2019 17:44:50 +0100 Subject: ASoC: sgtl5000: Fix VDDA and VDDIO comparison Comparing the voltage of VDDA and VDDIO to determine whether or not to enable VDDC manual override is insufficient. This is a problem in case the VDDA is supplied from different regulator than VDDIO, while both report the same voltage to the regulator framework. In that case where VDDA and VDDIO is supplied by different regulators, the VDDC manual override must not be applied. Fixes: b6319b061ba2 ("ASoC: sgtl5000: Fix charge pump source assignment") Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Igor Opaniuk Cc: Marcel Ziswiler Cc: Mark Brown Cc: Oleksandr Suvorov Link: https://lore.kernel.org/r/20191220164450.1395038-2-marex@denx.de Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index aa1f9637d895..e949b372cead 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1344,7 +1344,8 @@ static int sgtl5000_set_power_regs(struct snd_soc_component *component) * if vddio == vdda the source of charge pump should be * assigned manually to VDDIO */ - if (vddio == vdda) { + if (regulator_is_equal(sgtl5000->supplies[VDDA].consumer, + sgtl5000->supplies[VDDIO].consumer)) { lreg_ctrl |= SGTL5000_VDDC_ASSN_OVRD; lreg_ctrl |= SGTL5000_VDDC_MAN_ASSN_VDDIO << SGTL5000_VDDC_MAN_ASSN_SHIFT; -- cgit v1.2.3 From 8441f87eadf6d6bba542e7a5bf3888595248d888 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Wed, 4 Dec 2019 20:00:18 +0800 Subject: ASoC: dt-bindings: fsl_asrc: add compatible string for imx8qm & imx8qxp Add compatible string "fsl,imx8qm-asrc" for imx8qm platform, "fsl,imx8qxp-asrc" for imx8qxp platform. There are two asrc modules in imx8qm & imx8qxp, the clock mapping is different for each other, so add new property "fsl,asrc-clk-map" to distinguish them. Signed-off-by: Shengjiu Wang Acked-by: Rob Herring Link: https://lore.kernel.org/r/b9352edb014c1ee8530c0fd8829c2b044b3da649.1575452454.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/fsl,asrc.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/fsl,asrc.txt b/Documentation/devicetree/bindings/sound/fsl,asrc.txt index 1d4d9f938689..cb9a25165503 100644 --- a/Documentation/devicetree/bindings/sound/fsl,asrc.txt +++ b/Documentation/devicetree/bindings/sound/fsl,asrc.txt @@ -8,7 +8,12 @@ three substreams within totally 10 channels. Required properties: - - compatible : Contains "fsl,imx35-asrc" or "fsl,imx53-asrc". + - compatible : Compatible list, should contain one of the following + compatibles: + "fsl,imx35-asrc", + "fsl,imx53-asrc", + "fsl,imx8qm-asrc", + "fsl,imx8qxp-asrc", - reg : Offset and length of the register set for the device. @@ -35,6 +40,11 @@ Required properties: - fsl,asrc-width : Defines a mutual sample width used by DPCM Back Ends. + - fsl,asrc-clk-map : Defines clock map used in driver. which is required + by imx8qm/imx8qxp platform + <0> - select the map for asrc0 in imx8qm/imx8qxp + <1> - select the map for asrc1 in imx8qm/imx8qxp + Optional properties: - big-endian : If this property is absent, the little endian mode -- cgit v1.2.3 From c05f10f28ef697aae8f1d82012d660af3cfc8cf9 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Wed, 4 Dec 2019 20:00:19 +0800 Subject: ASoC: fsl_asrc: Add support for imx8qm & imx8qxp There are two asrc module in imx8qm & imx8qxp, each module has different clock configuration, and the DMA type is EDMA. So in this patch, we define the new clocks, refine the clock map, and include struct fsl_asrc_soc_data for different soc usage. The EDMA channel is fixed with each dma request, one dma request corresponding to one dma channel. So we need to request dma channel with dma request of asrc module. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/f33dfe3157b5ab200e09ccbf9ab73d31fac6664b.1575452454.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 125 ++++++++++++++++++++++++++++++++++++------- sound/soc/fsl/fsl_asrc.h | 64 +++++++++++++++++++++- sound/soc/fsl/fsl_asrc_dma.c | 41 +++++++++----- 3 files changed, 194 insertions(+), 36 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index a3cfceea7d2f..0dcebc24c312 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -41,26 +41,65 @@ static struct snd_pcm_hw_constraint_list fsl_asrc_rate_constraints = { * The following tables map the relationship between asrc_inclk/asrc_outclk in * fsl_asrc.h and the registers of ASRCSR */ -static unsigned char input_clk_map_imx35[] = { +static unsigned char input_clk_map_imx35[ASRC_CLK_MAP_LEN] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }; -static unsigned char output_clk_map_imx35[] = { +static unsigned char output_clk_map_imx35[ASRC_CLK_MAP_LEN] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, }; /* i.MX53 uses the same map for input and output */ -static unsigned char input_clk_map_imx53[] = { +static unsigned char input_clk_map_imx53[ASRC_CLK_MAP_LEN] = { /* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf */ 0x0, 0x1, 0x2, 0x7, 0x4, 0x5, 0x6, 0x3, 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0xe, 0xd, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, }; -static unsigned char output_clk_map_imx53[] = { +static unsigned char output_clk_map_imx53[ASRC_CLK_MAP_LEN] = { /* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf */ 0x8, 0x9, 0xa, 0x7, 0xc, 0x5, 0x6, 0xb, 0x0, 0x1, 0x2, 0x3, 0x4, 0xf, 0xe, 0xd, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, + 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, }; -static unsigned char *clk_map[2]; +/** + * i.MX8QM/i.MX8QXP uses the same map for input and output. + * clk_map_imx8qm[0] is for i.MX8QM asrc0 + * clk_map_imx8qm[1] is for i.MX8QM asrc1 + * clk_map_imx8qxp[0] is for i.MX8QXP asrc0 + * clk_map_imx8qxp[1] is for i.MX8QXP asrc1 + */ +static unsigned char clk_map_imx8qm[2][ASRC_CLK_MAP_LEN] = { + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0xb, 0xc, 0xf, 0xf, 0xd, 0xe, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + 0x4, 0x5, 0x6, 0xf, 0x8, 0x9, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, +}; + +static unsigned char clk_map_imx8qxp[2][ASRC_CLK_MAP_LEN] = { + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xf, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0xf, + 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, + { + 0xf, 0xf, 0xf, 0xf, 0xf, 0x7, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x0, + 0x0, 0x1, 0x2, 0x3, 0x7, 0x8, 0xf, 0xf, 0x9, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + 0xf, 0xf, 0x6, 0xf, 0xf, 0xf, 0xa, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, + }, +}; /** * Select the pre-processing and post-processing options @@ -353,8 +392,8 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) } /* Validate input and output clock sources */ - clk_index[IN] = clk_map[IN][config->inclk]; - clk_index[OUT] = clk_map[OUT][config->outclk]; + clk_index[IN] = asrc_priv->clk_map[IN][config->inclk]; + clk_index[OUT] = asrc_priv->clk_map[OUT][config->outclk]; /* We only have output clock for ideal ratio mode */ clk = asrc_priv->asrck_clk[clk_index[ideal ? OUT : IN]]; @@ -398,13 +437,13 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair, bool use_ideal_rate) /* Set the channel number */ channels = config->channel_num; - if (asrc_priv->channel_bits < 4) + if (asrc_priv->soc->channel_bits < 4) channels /= 2; /* Update channels for current pair */ regmap_update_bits(asrc_priv->regmap, REG_ASRCNCR, - ASRCNCR_ANCi_MASK(index, asrc_priv->channel_bits), - ASRCNCR_ANCi(index, channels, asrc_priv->channel_bits)); + ASRCNCR_ANCi_MASK(index, asrc_priv->soc->channel_bits), + ASRCNCR_ANCi(index, channels, asrc_priv->soc->channel_bits)); /* Default setting: Automatic selection for processing mode */ regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, @@ -531,7 +570,7 @@ static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream, struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai); /* Odd channel number is not valid for older ASRC (channel_bits==3) */ - if (asrc_priv->channel_bits == 3) + if (asrc_priv->soc->channel_bits == 3) snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 2); @@ -905,6 +944,7 @@ static int fsl_asrc_probe(struct platform_device *pdev) struct resource *res; void __iomem *regs; int irq, ret, i; + u32 map_idx; char tmp[16]; asrc_priv = devm_kzalloc(&pdev->dev, sizeof(*asrc_priv), GFP_KERNEL); @@ -964,14 +1004,37 @@ static int fsl_asrc_probe(struct platform_device *pdev) } } + asrc_priv->soc = of_device_get_match_data(&pdev->dev); + if (!asrc_priv->soc) { + dev_err(&pdev->dev, "failed to get soc data\n"); + return -ENODEV; + } + if (of_device_is_compatible(np, "fsl,imx35-asrc")) { - asrc_priv->channel_bits = 3; - clk_map[IN] = input_clk_map_imx35; - clk_map[OUT] = output_clk_map_imx35; - } else { - asrc_priv->channel_bits = 4; - clk_map[IN] = input_clk_map_imx53; - clk_map[OUT] = output_clk_map_imx53; + asrc_priv->clk_map[IN] = input_clk_map_imx35; + asrc_priv->clk_map[OUT] = output_clk_map_imx35; + } else if (of_device_is_compatible(np, "fsl,imx53-asrc")) { + asrc_priv->clk_map[IN] = input_clk_map_imx53; + asrc_priv->clk_map[OUT] = output_clk_map_imx53; + } else if (of_device_is_compatible(np, "fsl,imx8qm-asrc") || + of_device_is_compatible(np, "fsl,imx8qxp-asrc")) { + ret = of_property_read_u32(np, "fsl,asrc-clk-map", &map_idx); + if (ret) { + dev_err(&pdev->dev, "failed to get clk map index\n"); + return ret; + } + + if (map_idx > 1) { + dev_err(&pdev->dev, "unsupported clk map index\n"); + return -EINVAL; + } + if (of_device_is_compatible(np, "fsl,imx8qm-asrc")) { + asrc_priv->clk_map[IN] = clk_map_imx8qm[map_idx]; + asrc_priv->clk_map[OUT] = clk_map_imx8qm[map_idx]; + } else { + asrc_priv->clk_map[IN] = clk_map_imx8qxp[map_idx]; + asrc_priv->clk_map[OUT] = clk_map_imx8qxp[map_idx]; + } } ret = fsl_asrc_init(asrc_priv); @@ -1113,9 +1176,31 @@ static const struct dev_pm_ops fsl_asrc_pm = { SET_SYSTEM_SLEEP_PM_OPS(fsl_asrc_suspend, fsl_asrc_resume) }; +static const struct fsl_asrc_soc_data fsl_asrc_imx35_data = { + .use_edma = false, + .channel_bits = 3, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx53_data = { + .use_edma = false, + .channel_bits = 4, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx8qm_data = { + .use_edma = true, + .channel_bits = 4, +}; + +static const struct fsl_asrc_soc_data fsl_asrc_imx8qxp_data = { + .use_edma = true, + .channel_bits = 4, +}; + static const struct of_device_id fsl_asrc_ids[] = { - { .compatible = "fsl,imx35-asrc", }, - { .compatible = "fsl,imx53-asrc", }, + { .compatible = "fsl,imx35-asrc", .data = &fsl_asrc_imx35_data }, + { .compatible = "fsl,imx53-asrc", .data = &fsl_asrc_imx53_data }, + { .compatible = "fsl,imx8qm-asrc", .data = &fsl_asrc_imx8qm_data }, + { .compatible = "fsl,imx8qxp-asrc", .data = &fsl_asrc_imx8qxp_data }, {} }; MODULE_DEVICE_TABLE(of, fsl_asrc_ids); diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 2b57e8c53728..8a821132d9d0 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -308,6 +308,29 @@ enum asrc_inclk { INCLK_SSI3_TX = 0x0b, INCLK_SPDIF_TX = 0x0c, INCLK_ASRCK1_CLK = 0x0f, + + /* clocks for imx8 */ + INCLK_AUD_PLL_DIV_CLK0 = 0x10, + INCLK_AUD_PLL_DIV_CLK1 = 0x11, + INCLK_AUD_CLK0 = 0x12, + INCLK_AUD_CLK1 = 0x13, + INCLK_ESAI0_RX_CLK = 0x14, + INCLK_ESAI0_TX_CLK = 0x15, + INCLK_SPDIF0_RX = 0x16, + INCLK_SPDIF1_RX = 0x17, + INCLK_SAI0_RX_BCLK = 0x18, + INCLK_SAI0_TX_BCLK = 0x19, + INCLK_SAI1_RX_BCLK = 0x1a, + INCLK_SAI1_TX_BCLK = 0x1b, + INCLK_SAI2_RX_BCLK = 0x1c, + INCLK_SAI3_RX_BCLK = 0x1d, + INCLK_ASRC0_MUX_CLK = 0x1e, + + INCLK_ESAI1_RX_CLK = 0x20, + INCLK_ESAI1_TX_CLK = 0x21, + INCLK_SAI6_TX_BCLK = 0x22, + INCLK_HDMI_RX_SAI0_RX_BCLK = 0x24, + INCLK_HDMI_TX_SAI0_TX_BCLK = 0x25, }; enum asrc_outclk { @@ -325,9 +348,33 @@ enum asrc_outclk { OUTCLK_SSI3_RX = 0x0b, OUTCLK_SPDIF_RX = 0x0c, OUTCLK_ASRCK1_CLK = 0x0f, + + /* clocks for imx8 */ + OUTCLK_AUD_PLL_DIV_CLK0 = 0x10, + OUTCLK_AUD_PLL_DIV_CLK1 = 0x11, + OUTCLK_AUD_CLK0 = 0x12, + OUTCLK_AUD_CLK1 = 0x13, + OUTCLK_ESAI0_RX_CLK = 0x14, + OUTCLK_ESAI0_TX_CLK = 0x15, + OUTCLK_SPDIF0_RX = 0x16, + OUTCLK_SPDIF1_RX = 0x17, + OUTCLK_SAI0_RX_BCLK = 0x18, + OUTCLK_SAI0_TX_BCLK = 0x19, + OUTCLK_SAI1_RX_BCLK = 0x1a, + OUTCLK_SAI1_TX_BCLK = 0x1b, + OUTCLK_SAI2_RX_BCLK = 0x1c, + OUTCLK_SAI3_RX_BCLK = 0x1d, + OUTCLK_ASRCO_MUX_CLK = 0x1e, + + OUTCLK_ESAI1_RX_CLK = 0x20, + OUTCLK_ESAI1_TX_CLK = 0x21, + OUTCLK_SAI6_TX_BCLK = 0x22, + OUTCLK_HDMI_RX_SAI0_RX_BCLK = 0x24, + OUTCLK_HDMI_TX_SAI0_TX_BCLK = 0x25, }; #define ASRC_CLK_MAX_NUM 16 +#define ASRC_CLK_MAP_LEN 0x30 enum asrc_word_width { ASRC_WIDTH_24_BIT = 0, @@ -387,6 +434,17 @@ struct dma_block { unsigned int length; }; +/** + * fsl_asrc_soc_data: soc specific data + * + * @use_edma: using edma as dma device or not + * @channel_bits: width of ASRCNCR register for each pair + */ +struct fsl_asrc_soc_data { + bool use_edma; + unsigned int channel_bits; +}; + /** * fsl_asrc_pair: ASRC Pair private data * @@ -431,8 +489,9 @@ struct fsl_asrc_pair { * @asrck_clk: clock sources to driver ASRC internal logic * @lock: spin lock for resource protection * @pair: pair pointers - * @channel_bits: width of ASRCNCR register for each pair + * @soc: soc specific data * @channel_avail: non-occupied channel numbers + * @clk_map: clock map for input/output clock * @asrc_rate: default sample rate for ASoC Back-Ends * @asrc_width: default sample width for ASoC Back-Ends * @regcache_cfg: store register value of REG_ASRCFG @@ -450,8 +509,9 @@ struct fsl_asrc { spinlock_t lock; struct fsl_asrc_pair *pair[ASRC_PAIR_MAX_NUM]; - unsigned int channel_bits; + const struct fsl_asrc_soc_data *soc; unsigned int channel_avail; + unsigned char *clk_map[2]; int asrc_rate; int asrc_width; diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index 79d66224c0a8..ece130f59d15 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -197,21 +197,34 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, dma_cap_set(DMA_SLAVE, mask); dma_cap_set(DMA_CYCLIC, mask); - /* Get DMA request of Back-End */ - tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx"); - tmp_data = tmp_chan->private; - pair->dma_data.dma_request = tmp_data->dma_request; - dma_release_channel(tmp_chan); - - /* Get DMA request of Front-End */ - tmp_chan = fsl_asrc_get_dma_channel(pair, dir); - tmp_data = tmp_chan->private; - pair->dma_data.dma_request2 = tmp_data->dma_request; - pair->dma_data.peripheral_type = tmp_data->peripheral_type; - pair->dma_data.priority = tmp_data->priority; - dma_release_channel(tmp_chan); + /* + * An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each + * peripheral, unlike SDMA channel that is allocated dynamically. So no + * need to configure dma_request and dma_request2, but get dma_chan via + * dma_request_slave_channel directly with dma name of Front-End device + */ + if (!asrc_priv->soc->use_edma) { + /* Get DMA request of Back-End */ + tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx"); + tmp_data = tmp_chan->private; + pair->dma_data.dma_request = tmp_data->dma_request; + dma_release_channel(tmp_chan); + + /* Get DMA request of Front-End */ + tmp_chan = fsl_asrc_get_dma_channel(pair, dir); + tmp_data = tmp_chan->private; + pair->dma_data.dma_request2 = tmp_data->dma_request; + pair->dma_data.peripheral_type = tmp_data->peripheral_type; + pair->dma_data.priority = tmp_data->priority; + dma_release_channel(tmp_chan); + + pair->dma_chan[dir] = + dma_request_channel(mask, filter, &pair->dma_data); + } else { + pair->dma_chan[dir] = + fsl_asrc_get_dma_channel(pair, dir); + } - pair->dma_chan[dir] = dma_request_channel(mask, filter, &pair->dma_data); if (!pair->dma_chan[dir]) { dev_err(dev, "failed to request DMA channel for Back-End\n"); return -EINVAL; -- cgit v1.2.3 From 06bf8ea4f8ae34f91e60d27c8065f55d7a88c682 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 19 Dec 2019 22:32:19 +0100 Subject: ASoC: sgtl5000: add multi endpoint support Support multiple endpoints on SGTL5000 codec port when used in of_graph context. This patch allows to share the codec port between two CPU DAIs. Example: Custom STM32MP157C board uses SGTL5000 audio codec. This codec is connected to two serial audio interfaces, which are configured either as rx or tx. From AsoC point of view the topolgy is the following: // 2 CPU DAIs (SAI2A/B), 1 Codec (SGTL5000) Playback: CPU-A-DAI(slave) -> (master)CODEC-DAI/port0 Record: CPU-B-DAI(slave) <- (master)CODEC-DAI/port0 In the DT two endpoints have to be associated to the codec port: sgtl5000_port: port { sgtl5000_tx_endpoint: endpoint@0 { remote-endpoint = <&sai2a_endpoint>; }; sgtl5000_rx_endpoint: endpoint@1 { remote-endpoint = <&sai2b_endpoint>; }; }; However, when the audio graph card parses the codec nodes, it expects to find DAI interface indexes matching the endpoints indexes. The current patch forces the use of DAI id 0 for both endpoints, which allows to share the codec DAI between the two CPU DAIs for playback and capture streams respectively. Signed-off-by: Marek Vasut Cc: Mark Brown Link: https://lore.kernel.org/r/20191219213219.366073-1-marex@denx.de Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index e949b372cead..d5130193b4a2 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1514,6 +1514,13 @@ err: return ret; } +static int sgtl5000_of_xlate_dai_id(struct snd_soc_component *component, + struct device_node *endpoint) +{ + /* return dai id 0, whatever the endpoint index */ + return 0; +} + static const struct snd_soc_component_driver sgtl5000_driver = { .probe = sgtl5000_probe, .set_bias_level = sgtl5000_set_bias_level, @@ -1523,6 +1530,7 @@ static const struct snd_soc_component_driver sgtl5000_driver = { .num_dapm_widgets = ARRAY_SIZE(sgtl5000_dapm_widgets), .dapm_routes = sgtl5000_dapm_routes, .num_dapm_routes = ARRAY_SIZE(sgtl5000_dapm_routes), + .of_xlate_dai_id = sgtl5000_of_xlate_dai_id, .suspend_bias_off = 1, .idle_bias_on = 1, .use_pmdown_time = 1, -- cgit v1.2.3 From a3afa29942b84b4e2548beacccc3a68b8d77e3dc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 15 Jan 2020 20:46:04 +0300 Subject: ALSA: usb-audio: unlock on error in probe We need to unlock before we returning on this error path. Fixes: 73ac9f5e5b43 ("ALSA: usb-audio: Add boot quirk for MOTU M Series") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20200115174604.rhanfgy4j3uc65cx@kili.mountain Signed-off-by: Takashi Iwai --- sound/usb/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 2f582ac7cf78..827fb0bc8b56 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -602,7 +602,7 @@ static int usb_audio_probe(struct usb_interface *intf, if (! chip) { err = snd_usb_apply_boot_quirk_once(dev, intf, quirk, id); if (err < 0) - return err; + goto __error; /* it's a fresh one. * now look for an empty slot and create a new card instance -- cgit v1.2.3 From c249177944b650816069f6c49b769baaa94339dc Mon Sep 17 00:00:00 2001 From: Alexander Tsoy Date: Wed, 15 Jan 2020 18:13:58 +0300 Subject: ALSA: usb-audio: add implicit fb quirk for MOTU M Series This fixes crackling sound during playback. Further note: MOTU is known for reusing Product IDs for different devices or different generations of the device (e.g. MicroBook I/II/IIc shares a single Product ID). This patch was only tested with M4 audio interface, but the same Product ID is also used by M2. Hope it will work for M2 as well. Signed-off-by: Alexander Tsoy Link: https://lore.kernel.org/r/20200115151358.56672-1-alexander@tsoy.me Signed-off-by: Takashi Iwai --- sound/usb/pcm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 2f6a80ca36fc..5844a0c9d0db 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -361,6 +361,10 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, ep = 0x84; ifnum = 0; goto add_sync_ep_from_ifnum; + case USB_ID(0x07fd, 0x0008): /* MOTU M Series */ + ep = 0x81; + ifnum = 2; + goto add_sync_ep_from_ifnum; case USB_ID(0x0582, 0x01d8): /* BOSS Katana */ /* BOSS Katana amplifiers do not need quirks */ return 0; -- cgit v1.2.3 From 2ba0176c709c103974cf55b6d373c4ea749c6391 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 15 Jan 2020 11:00:35 +0100 Subject: ALSA: hda/analog - Minor optimization for SPDIF mux connections AD HD-audio codec driver has a few code lines invoking snd_get_num_conns() and using its return value as the array index without checking. This is basically safe in all those places; at the second and later calls snd_get_num_conns() returns the value cached from the first invocation, hence the value is always consistent. However, it looks a bit confusing as if a lack of the proper check. This patch introduces a new field num_smux_conns in ad198x_spec for simplifying the code. Now we store and refer to the value more locally without invoking the extra function at each time. Reported-by: Colin King Link: https://lore.kernel.org/r/20200115100035.22511-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 88c46b051d14..2132b2acec4d 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -28,6 +28,7 @@ struct ad198x_spec { hda_nid_t eapd_nid; unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ + int num_smux_conns; }; @@ -453,8 +454,7 @@ static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol, struct ad198x_spec *spec = codec->spec; static const char * const texts2[] = { "PCM", "ADC" }; static const char * const texts3[] = { "PCM", "ADC1", "ADC2" }; - hda_nid_t dig_out = spec->gen.multiout.dig_out_nid; - int num_conns = snd_hda_get_num_conns(codec, dig_out); + int num_conns = spec->num_smux_conns; if (num_conns == 2) return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2); @@ -481,7 +481,7 @@ static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol, struct ad198x_spec *spec = codec->spec; unsigned int val = ucontrol->value.enumerated.item[0]; hda_nid_t dig_out = spec->gen.multiout.dig_out_nid; - int num_conns = snd_hda_get_num_conns(codec, dig_out); + int num_conns = spec->num_smux_conns; if (val >= num_conns) return -EINVAL; @@ -512,6 +512,7 @@ static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec) num_conns = snd_hda_get_num_conns(codec, dig_out); if (num_conns != 2 && num_conns != 3) return 0; + spec->num_smux_conns = num_conns; if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer)) return -ENOMEM; return 0; @@ -730,10 +731,12 @@ static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; static const char * const texts[] = { "PCM", "ADC1", "ADC2", "ADC3", }; - int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; + int num_conns = spec->num_smux_conns; + if (num_conns > 4) num_conns = 4; return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts); @@ -756,7 +759,7 @@ static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol, struct ad198x_spec *spec = codec->spec; unsigned int val = ucontrol->value.enumerated.item[0]; struct nid_path *path; - int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; + int num_conns = spec->num_smux_conns; if (val >= num_conns) return -EINVAL; @@ -847,6 +850,7 @@ static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec) num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1; if (num_conns != 3 && num_conns != 4) return 0; + spec->num_smux_conns = num_conns; for (i = 0; i < num_conns; i++) { struct nid_path *path = snd_array_new(&spec->gen.paths); -- cgit v1.2.3 From d662117c7a91b4f4db1d5458fe782cdf54f8359a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 16 Jan 2020 17:28:25 +0100 Subject: ALSA: pcm: Make snd_pcm_hw_constraints_init() and _complete() static Both snd_pcm_hw_constraints_init() and _complete() functions are called only from pcm_native.c, hence they can be static for further optimization. Link: https://lore.kernel.org/r/20200116162825.24792-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/pcm_local.h | 3 --- sound/core/pcm_native.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/core/pcm_local.h b/sound/core/pcm_local.h index 384efd002984..17a1a5d87098 100644 --- a/sound/core/pcm_local.h +++ b/sound/core/pcm_local.h @@ -20,9 +20,6 @@ void snd_interval_muldivk(const struct snd_interval *a, void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, const struct snd_interval *b, struct snd_interval *c); -int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream); -int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream); - int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int32_t mask); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index c375c41496f8..bb23f5066654 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2308,7 +2308,7 @@ static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params, return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) +static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; @@ -2432,7 +2432,7 @@ int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) return 0; } -int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) +static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_hardware *hw = &runtime->hw; -- cgit v1.2.3 From 5af29028fd6db9438b5584ab7179710a0a22569d Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Fri, 17 Jan 2020 14:04:01 +0800 Subject: ALSA: hda/realtek - Add Headset Mic supported for HP cPC HP ALC671 need to support Headset Mic. Signed-off-by: Kailang Yang Link: https://lore.kernel.org/r/06a9d2b176e14706976d6584cbe2d92a@realtek.com Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 27b522b9dfda..3b38a13abb7a 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -8484,6 +8484,29 @@ static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec, } } +static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + struct alc_spec *spec = codec->spec; + + static const struct hda_pintbl pincfgs[] = { + { 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */ + { 0x1b, 0x0181304f }, + { } + }; + + switch (action) { + case HDA_FIXUP_ACT_PRE_PROBE: + spec->gen.mixer_nid = 0; + spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; + snd_hda_apply_pincfgs(codec, pincfgs); + break; + case HDA_FIXUP_ACT_INIT: + alc_write_coef_idx(codec, 0x19, 0xa054); + break; + } +} + static const struct coef_fw alc668_coefs[] = { WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0), WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80), @@ -8557,6 +8580,7 @@ enum { ALC662_FIXUP_LENOVO_MULTI_CODECS, ALC669_FIXUP_ACER_ASPIRE_ETHOS, ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET, + ALC671_FIXUP_HP_HEADSET_MIC2, }; static const struct hda_fixup alc662_fixups[] = { @@ -8898,6 +8922,10 @@ static const struct hda_fixup alc662_fixups[] = { .chained = true, .chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET }, + [ALC671_FIXUP_HP_HEADSET_MIC2] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc671_fixup_hp_headset_mic2, + }, }; static const struct snd_pci_quirk alc662_fixup_tbl[] = { @@ -9080,6 +9108,22 @@ static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = { {0x12, 0x90a60130}, {0x14, 0x90170110}, {0x15, 0x0321101f}), + SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2, + {0x14, 0x01014010}, + {0x17, 0x90170150}, + {0x1b, 0x01813030}, + {0x21, 0x02211020}), + SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2, + {0x14, 0x01014010}, + {0x18, 0x01a19040}, + {0x1b, 0x01813030}, + {0x21, 0x02211020}), + SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2, + {0x14, 0x01014020}, + {0x17, 0x90170110}, + {0x18, 0x01a19050}, + {0x1b, 0x01813040}, + {0x21, 0x02211030}), {} }; -- cgit v1.2.3 From 73ecf1a673d3502dff1445f06675aba65ff20ce7 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 14 Jan 2020 16:18:38 +0000 Subject: ASoC: wm_adsp: Correct cache handling of new kernel control API The recently added API that exposes firmware mixer controls to the kernel is missing cache handling and all writes bypass the cache, this obviously causes the cache to get out of sync with the hardware. Factor out the cache handling into two new helper functions and call those from both the normal ALSA control handlers and the new kernel API. Fixes: eb65ccdb0836 ("ASoC: wm_adsp: Expose mixer control API") Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200114161841.451-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 98 ++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 2a9b610f6d43..d3d32b501aca 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1030,8 +1030,8 @@ static int wm_coeff_write_acked_control(struct wm_coeff_ctl *ctl, return -ETIMEDOUT; } -static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, - const void *buf, size_t len) +static int wm_coeff_write_ctrl_raw(struct wm_coeff_ctl *ctl, + const void *buf, size_t len) { struct wm_adsp *dsp = ctl->dsp; void *scratch; @@ -1061,6 +1061,23 @@ static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, return 0; } +static int wm_coeff_write_ctrl(struct wm_coeff_ctl *ctl, + const void *buf, size_t len) +{ + int ret = 0; + + if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) + ret = -EPERM; + else if (buf != ctl->cache) + memcpy(ctl->cache, buf, len); + + ctl->set = 1; + if (ctl->enabled && ctl->dsp->running) + ret = wm_coeff_write_ctrl_raw(ctl, buf, len); + + return ret; +} + static int wm_coeff_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { @@ -1071,16 +1088,7 @@ static int wm_coeff_put(struct snd_kcontrol *kctl, int ret = 0; mutex_lock(&ctl->dsp->pwr_lock); - - if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) - ret = -EPERM; - else - memcpy(ctl->cache, p, ctl->len); - - ctl->set = 1; - if (ctl->enabled && ctl->dsp->running) - ret = wm_coeff_write_control(ctl, p, ctl->len); - + ret = wm_coeff_write_ctrl(ctl, p, ctl->len); mutex_unlock(&ctl->dsp->pwr_lock); return ret; @@ -1096,15 +1104,10 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl, mutex_lock(&ctl->dsp->pwr_lock); - if (copy_from_user(ctl->cache, bytes, size)) { + if (copy_from_user(ctl->cache, bytes, size)) ret = -EFAULT; - } else { - ctl->set = 1; - if (ctl->enabled && ctl->dsp->running) - ret = wm_coeff_write_control(ctl, ctl->cache, size); - else if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) - ret = -EPERM; - } + else + ret = wm_coeff_write_ctrl(ctl, ctl->cache, size); mutex_unlock(&ctl->dsp->pwr_lock); @@ -1135,8 +1138,8 @@ static int wm_coeff_put_acked(struct snd_kcontrol *kctl, return ret; } -static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, - void *buf, size_t len) +static int wm_coeff_read_ctrl_raw(struct wm_coeff_ctl *ctl, + void *buf, size_t len) { struct wm_adsp *dsp = ctl->dsp; void *scratch; @@ -1166,29 +1169,37 @@ static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, return 0; } -static int wm_coeff_get(struct snd_kcontrol *kctl, - struct snd_ctl_elem_value *ucontrol) +static int wm_coeff_read_ctrl(struct wm_coeff_ctl *ctl, void *buf, size_t len) { - struct soc_bytes_ext *bytes_ext = - (struct soc_bytes_ext *)kctl->private_value; - struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); - char *p = ucontrol->value.bytes.data; int ret = 0; - mutex_lock(&ctl->dsp->pwr_lock); - if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { if (ctl->enabled && ctl->dsp->running) - ret = wm_coeff_read_control(ctl, p, ctl->len); + return wm_coeff_read_ctrl_raw(ctl, buf, len); else - ret = -EPERM; + return -EPERM; } else { if (!ctl->flags && ctl->enabled && ctl->dsp->running) - ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); + ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); - memcpy(p, ctl->cache, ctl->len); + if (buf != ctl->cache) + memcpy(buf, ctl->cache, len); } + return ret; +} + +static int wm_coeff_get(struct snd_kcontrol *kctl, + struct snd_ctl_elem_value *ucontrol) +{ + struct soc_bytes_ext *bytes_ext = + (struct soc_bytes_ext *)kctl->private_value; + struct wm_coeff_ctl *ctl = bytes_ext_to_ctl(bytes_ext); + char *p = ucontrol->value.bytes.data; + int ret; + + mutex_lock(&ctl->dsp->pwr_lock); + ret = wm_coeff_read_ctrl(ctl, p, ctl->len); mutex_unlock(&ctl->dsp->pwr_lock); return ret; @@ -1204,15 +1215,7 @@ static int wm_coeff_tlv_get(struct snd_kcontrol *kctl, mutex_lock(&ctl->dsp->pwr_lock); - if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { - if (ctl->enabled && ctl->dsp->running) - ret = wm_coeff_read_control(ctl, ctl->cache, size); - else - ret = -EPERM; - } else { - if (!ctl->flags && ctl->enabled && ctl->dsp->running) - ret = wm_coeff_read_control(ctl, ctl->cache, size); - } + ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, size); if (!ret && copy_to_user(bytes, ctl->cache, size)) ret = -EFAULT; @@ -1340,7 +1343,7 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp) * created so we don't need to do anything. */ if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { - ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); + ret = wm_coeff_read_ctrl_raw(ctl, ctl->cache, ctl->len); if (ret < 0) return ret; } @@ -1358,7 +1361,8 @@ static int wm_coeff_sync_controls(struct wm_adsp *dsp) if (!ctl->enabled) continue; if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { - ret = wm_coeff_write_control(ctl, ctl->cache, ctl->len); + ret = wm_coeff_write_ctrl_raw(ctl, ctl->cache, + ctl->len); if (ret < 0) return ret; } @@ -2048,7 +2052,7 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, if (len > ctl->len) return -EINVAL; - ret = wm_coeff_write_control(ctl, buf, len); + ret = wm_coeff_write_ctrl(ctl, buf, len); kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl->name); snd_ctl_notify(dsp->component->card->snd_card, @@ -2070,7 +2074,7 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, if (len > ctl->len) return -EINVAL; - return wm_coeff_read_control(ctl, buf, len); + return wm_coeff_read_ctrl(ctl, buf, len); } EXPORT_SYMBOL_GPL(wm_adsp_read_ctl); -- cgit v1.2.3 From 8ab6ddc5c51b09630f3c89eb410ac48e13a2f0ff Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 14 Jan 2020 16:18:41 +0000 Subject: ASoC: madera: Update handling of DAPM routes for mono muxed outputs Correctly link both channels on the DAC if an output muxed between a stereo and mono output. Without this one channel of the DAC may be erroneously powered down whilst in mono mode. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200114161841.451-4-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l15.c | 13 ++++++++++++- sound/soc/codecs/cs47l35.c | 12 +++++++++++- sound/soc/codecs/cs47l85.c | 3 ++- sound/soc/codecs/cs47l90.c | 3 ++- sound/soc/codecs/cs47l92.c | 14 +++++++++++++- sound/soc/codecs/madera.c | 13 ++++++++++--- sound/soc/codecs/madera.h | 4 +++- 7 files changed, 53 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/cs47l15.c b/sound/soc/codecs/cs47l15.c index ece1276f38eb..6533c4f5a1de 100644 --- a/sound/soc/codecs/cs47l15.c +++ b/sound/soc/codecs/cs47l15.c @@ -529,6 +529,7 @@ SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), SND_SOC_DAPM_OUTPUT("DSP Trigger Out"), SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l15_outdemux), +SND_SOC_DAPM_MUX("HPOUT1 Mono Mux", SND_SOC_NOPM, 0, 0, &cs47l15_outdemux), SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT, 0, NULL, 0), @@ -1084,6 +1085,9 @@ static const struct snd_soc_dapm_route cs47l15_dapm_routes[] = { { "AEC2 Loopback", "HPOUT1R", "OUT1R" }, { "HPOUT1 Demux", NULL, "OUT1L" }, { "HPOUT1 Demux", NULL, "OUT1R" }, + + { "OUT1R", NULL, "HPOUT1 Mono Mux" }, + { "HPOUTL", "HPOUT", "HPOUT1 Demux" }, { "HPOUTR", "HPOUT", "HPOUT1 Demux" }, { "EPOUTP", "EPOUT", "HPOUT1 Demux" }, @@ -1261,6 +1265,11 @@ static irqreturn_t cs47l15_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } +static const struct snd_soc_dapm_route cs47l15_mono_routes[] = { + { "HPOUT1 Mono Mux", "HPOUT", "OUT1L" }, + { "HPOUT1 Mono Mux", "EPOUT", "OUT1L" }, +}; + static int cs47l15_component_probe(struct snd_soc_component *component) { struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component); @@ -1277,7 +1286,9 @@ static int cs47l15_component_probe(struct snd_soc_component *component) if (ret) return ret; - ret = madera_init_outputs(component, CS47L15_MONO_OUTPUTS); + ret = madera_init_outputs(component, cs47l15_mono_routes, + ARRAY_SIZE(cs47l15_mono_routes), + CS47L15_MONO_OUTPUTS); if (ret) return ret; diff --git a/sound/soc/codecs/cs47l35.c b/sound/soc/codecs/cs47l35.c index d396a8545d51..bd172e170088 100644 --- a/sound/soc/codecs/cs47l35.c +++ b/sound/soc/codecs/cs47l35.c @@ -631,6 +631,7 @@ SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), SND_SOC_DAPM_OUTPUT("DSP Trigger Out"), SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), +SND_SOC_DAPM_MUX("HPOUT1 Mono Mux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux), SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT, 0, NULL, 0), @@ -1309,6 +1310,8 @@ static const struct snd_soc_dapm_route cs47l35_dapm_routes[] = { { "SPKOUTN", NULL, "OUT4L" }, { "SPKOUTP", NULL, "OUT4L" }, + { "OUT1R", NULL, "HPOUT1 Mono Mux" }, + { "HPOUTL", "HPOUT", "HPOUT1 Demux" }, { "HPOUTR", "HPOUT", "HPOUT1 Demux" }, { "EPOUTP", "EPOUT", "HPOUT1 Demux" }, @@ -1552,6 +1555,11 @@ static irqreturn_t cs47l35_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } +static const struct snd_soc_dapm_route cs47l35_mono_routes[] = { + { "HPOUT1 Mono Mux", "HPOUT", "OUT1L" }, + { "HPOUT1 Mono Mux", "EPOUT", "OUT1L" }, +}; + static int cs47l35_component_probe(struct snd_soc_component *component) { struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component); @@ -1568,7 +1576,9 @@ static int cs47l35_component_probe(struct snd_soc_component *component) if (ret) return ret; - ret = madera_init_outputs(component, CS47L35_MONO_OUTPUTS); + ret = madera_init_outputs(component, cs47l35_mono_routes, + ARRAY_SIZE(cs47l35_mono_routes), + CS47L35_MONO_OUTPUTS); if (ret) return ret; diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c index 32fe7ffb7526..a69311008134 100644 --- a/sound/soc/codecs/cs47l85.c +++ b/sound/soc/codecs/cs47l85.c @@ -2507,7 +2507,8 @@ static int cs47l85_component_probe(struct snd_soc_component *component) if (ret) return ret; - ret = madera_init_outputs(component, CS47L85_MONO_OUTPUTS); + ret = madera_init_outputs(component, NULL, CS47L85_MONO_OUTPUTS, + CS47L85_MONO_OUTPUTS); if (ret) return ret; diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c index 67cac60a859d..5448e4506741 100644 --- a/sound/soc/codecs/cs47l90.c +++ b/sound/soc/codecs/cs47l90.c @@ -2418,7 +2418,8 @@ static int cs47l90_component_probe(struct snd_soc_component *component) if (ret) return ret; - ret = madera_init_outputs(component, CS47L90_MONO_OUTPUTS); + ret = madera_init_outputs(component, NULL, CS47L90_MONO_OUTPUTS, + CS47L90_MONO_OUTPUTS); if (ret) return ret; diff --git a/sound/soc/codecs/cs47l92.c b/sound/soc/codecs/cs47l92.c index d50f75f3b3e4..3c108b936419 100644 --- a/sound/soc/codecs/cs47l92.c +++ b/sound/soc/codecs/cs47l92.c @@ -730,6 +730,7 @@ SND_SOC_DAPM_MUX("IN2L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), SND_SOC_DAPM_MUX("IN2R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]), SND_SOC_DAPM_DEMUX("OUT3 Demux", SND_SOC_NOPM, 0, 0, &cs47l92_outdemux), +SND_SOC_DAPM_MUX("OUT3 Mono Mux", SND_SOC_NOPM, 0, 0, &cs47l92_outdemux), SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"), SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"), @@ -1584,6 +1585,8 @@ static const struct snd_soc_dapm_route cs47l92_dapm_routes[] = { { "OUT3 Demux", NULL, "OUT3L" }, { "OUT3 Demux", NULL, "OUT3R" }, + { "OUT3R", NULL, "OUT3 Mono Mux" }, + { "HPOUT3L", "HPOUT3", "OUT3 Demux" }, { "HPOUT3R", "HPOUT3", "OUT3 Demux" }, { "HPOUT4L", "HPOUT4", "OUT3 Demux" }, @@ -1817,6 +1820,13 @@ static irqreturn_t cs47l92_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } +static const struct snd_soc_dapm_route cs47l92_mono_routes[] = { + { "OUT1R", NULL, "OUT1L" }, + { "OUT2R", NULL, "OUT2L" }, + { "OUT3 Mono Mux", "HPOUT3", "OUT3L" }, + { "OUT3 Mono Mux", "HPOUT4", "OUT3L" }, +}; + static int cs47l92_component_probe(struct snd_soc_component *component) { struct cs47l92 *cs47l92 = snd_soc_component_get_drvdata(component); @@ -1833,7 +1843,9 @@ static int cs47l92_component_probe(struct snd_soc_component *component) if (ret) return ret; - ret = madera_init_outputs(component, CS47L92_MONO_OUTPUTS); + ret = madera_init_outputs(component, cs47l92_mono_routes, + ARRAY_SIZE(cs47l92_mono_routes), + CS47L92_MONO_OUTPUTS); if (ret) return ret; diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 52639811cc52..b537e60ef7c0 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -1162,7 +1162,9 @@ static const struct snd_soc_dapm_route madera_mono_routes[] = { { "OUT6R", NULL, "OUT6L" }, }; -int madera_init_outputs(struct snd_soc_component *component, int n_mono_routes) +int madera_init_outputs(struct snd_soc_component *component, + const struct snd_soc_dapm_route *routes, + int n_mono_routes, int n_real) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); @@ -1179,16 +1181,21 @@ int madera_init_outputs(struct snd_soc_component *component, int n_mono_routes) n_mono_routes = MADERA_MAX_OUTPUT; } + if (!routes) + routes = madera_mono_routes; + for (i = 0; i < n_mono_routes; i++) { /* Default is 0 so noop with defaults */ if (pdata->out_mono[i]) { val = MADERA_OUT1_MONO; - snd_soc_dapm_add_routes(dapm, - &madera_mono_routes[i], 1); + snd_soc_dapm_add_routes(dapm, &routes[i], 1); } else { val = 0; } + if (i >= n_real) + continue; + regmap_update_bits(madera->regmap, MADERA_OUTPUT_PATH_CONFIG_1L + (i * 8), MADERA_OUT1_MONO, val); diff --git a/sound/soc/codecs/madera.h b/sound/soc/codecs/madera.h index 6d8938a3fb64..bff084695961 100644 --- a/sound/soc/codecs/madera.h +++ b/sound/soc/codecs/madera.h @@ -421,7 +421,9 @@ int madera_core_free(struct madera_priv *priv); int madera_init_overheat(struct madera_priv *priv); int madera_free_overheat(struct madera_priv *priv); int madera_init_inputs(struct snd_soc_component *component); -int madera_init_outputs(struct snd_soc_component *component, int n_mono_routes); +int madera_init_outputs(struct snd_soc_component *component, + const struct snd_soc_dapm_route *routes, + int n_mono_routes, int n_real); int madera_init_bus_error_irq(struct madera_priv *priv, int dsp_num, irq_handler_t handler); void madera_free_bus_error_irq(struct madera_priv *priv, int dsp_num); -- cgit v1.2.3 From a6947c9d86bcfd61b758b5693eba58defe7fd2ae Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Mon, 13 Jan 2020 12:40:54 +0100 Subject: ASoC: SOF: Intel: hda: Fix SKL dai count With fourth pin added for iDisp for skl_dai, update SOF_SKL_DAI_NUM to account for the change. Without this, dais from the bottom of the list are skipped. In current state that's the case for 'Alt Analog CPU DAI'. Fixes: ac42b142cd76 ("ASoC: SOF: Intel: hda: Add iDisp4 DAI") Signed-off-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200113114054.9716-1-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/sof/intel/hda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 18d7e72bf9b7..8981c00c4d94 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -345,7 +345,7 @@ /* Number of DAIs */ #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) -#define SOF_SKL_NUM_DAIS 14 +#define SOF_SKL_NUM_DAIS 15 #else #define SOF_SKL_NUM_DAIS 8 #endif -- cgit v1.2.3 From 4061fdc89ff7704a71dc6df8e5841f861138e7e1 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 14 Jan 2020 16:18:40 +0000 Subject: ASoC: madera: Correct error path handling in madera_out1_demux_put Should the write to MADERA_OUTPUT_ENABLES_1 fail and out_clamp[0] not be set an additional error message will be printed. Clear the ret variable to avoid this. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200114161841.451-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/madera.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 12dc468ae6bf..2be64422adf9 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -575,6 +575,7 @@ int madera_out1_demux_put(struct snd_kcontrol *kcontrol, usleep_range(2000, 3000); /* wait for wseq to complete */ /* change demux setting */ + ret = 0; if (madera->out_clamp[0]) ret = regmap_update_bits(madera->regmap, MADERA_OUTPUT_ENABLES_1, -- cgit v1.2.3 From 0e4ba0290e5851833f17b2b56deab6a28827bb07 Mon Sep 17 00:00:00 2001 From: Shuming Fan Date: Thu, 16 Jan 2020 17:18:54 +0800 Subject: ASoC: rt1011: set the different setting for QFN/WLCSP package The QFN package is a new one. There is a different initial setting to the chip of QFN and WLCSP package. Signed-off-by: Shuming Fan Link: https://lore.kernel.org/r/20200116091854.18095-1-shumingf@realtek.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt1011.c | 17 +++++++++++++++-- sound/soc/codecs/rt1011.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt1011.c b/sound/soc/codecs/rt1011.c index 2552073e54ce..dec5638060c3 100644 --- a/sound/soc/codecs/rt1011.c +++ b/sound/soc/codecs/rt1011.c @@ -40,7 +40,6 @@ static const struct reg_sequence init_list[] = { { RT1011_ADC_SET_5, 0x0a20 }, { RT1011_DAC_SET_2, 0xa032 }, - { RT1011_ADC_SET_1, 0x2925 }, { RT1011_SPK_PRO_DC_DET_1, 0xb00c }, { RT1011_SPK_PRO_DC_DET_2, 0xcccc }, @@ -2186,7 +2185,6 @@ static int rt1011_calibrate(struct rt1011_priv *rt1011, unsigned char cali_flag) /* ADC/DAC setting */ regmap_write(rt1011->regmap, RT1011_ADC_SET_5, 0x0a20); regmap_write(rt1011->regmap, RT1011_DAC_SET_2, 0xe232); - regmap_write(rt1011->regmap, RT1011_ADC_SET_1, 0x2925); regmap_write(rt1011->regmap, RT1011_ADC_SET_4, 0xc000); /* DC detection */ @@ -2235,8 +2233,18 @@ static int rt1011_calibrate(struct rt1011_priv *rt1011, unsigned char cali_flag) dc_offset |= (value & 0xffff); dev_info(dev, "Gain1 offset=0x%x\n", dc_offset); + /* check the package info. */ + regmap_read(rt1011->regmap, RT1011_EFUSE_MATCH_DONE, &value); + if (value & 0x4) + rt1011->pack_id = 1; if (cali_flag) { + + if (rt1011->pack_id) + regmap_write(rt1011->regmap, RT1011_ADC_SET_1, 0x292c); + else + regmap_write(rt1011->regmap, RT1011_ADC_SET_1, 0x2925); + /* Class D on */ regmap_write(rt1011->regmap, RT1011_CLASS_D_POS, 0x010e); regmap_write(rt1011->regmap, @@ -2361,6 +2369,11 @@ static void rt1011_calibration_work(struct work_struct *work) rt1011_r0_load(rt1011); } + + if (rt1011->pack_id) + snd_soc_component_write(component, RT1011_ADC_SET_1, 0x292c); + else + snd_soc_component_write(component, RT1011_ADC_SET_1, 0x2925); } static int rt1011_parse_dp(struct rt1011_priv *rt1011, struct device *dev) diff --git a/sound/soc/codecs/rt1011.h b/sound/soc/codecs/rt1011.h index 68fadc15fa8c..f3a9a96640f1 100644 --- a/sound/soc/codecs/rt1011.h +++ b/sound/soc/codecs/rt1011.h @@ -692,6 +692,7 @@ struct rt1011_priv { unsigned int r0_reg, cali_done; unsigned int r0_calib, temperature_calib; int recv_spk_mode; + unsigned int pack_id; /* 0: WLCSP; 1: QFN */ }; #endif /* end of _RT1011_H_ */ -- cgit v1.2.3 From a62c449f4cc1498d040d84e6210209c474b5c746 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 16 Jan 2020 02:11:42 +0000 Subject: ASoC: rt715: remove unused including Remove including that don't need it. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20200116021142.149000-1-yuehaibing@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt715.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c index 4c746938a062..2cbc57b16b13 100644 --- a/sound/soc/codecs/rt715.c +++ b/sound/soc/codecs/rt715.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 20435df1c1d708b44f58da17653f2ea609aee790 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Wed, 15 Jan 2020 14:30:27 +0000 Subject: ASoC: rt700: fix return value check in rt700_sdw_probe() In case of error, the function devm_regmap_init() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: 7d2a5f9ae41e ("ASoC: rt700: add rt700 codec driver") Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200115143027.94364-1-weiyongjun1@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt700-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c index 314103601af3..a4b95425886f 100644 --- a/sound/soc/codecs/rt700-sdw.c +++ b/sound/soc/codecs/rt700-sdw.c @@ -460,8 +460,8 @@ static int rt700_sdw_probe(struct sdw_slave *slave, regmap = devm_regmap_init(&slave->dev, NULL, &slave->dev, &rt700_regmap); - if (!regmap) - return -EINVAL; + if (IS_ERR(regmap)) + return PTR_ERR(regmap); rt700_init(&slave->dev, sdw_regmap, regmap, slave); -- cgit v1.2.3 From b03c29c1b13afa18ee88cce07bbe87298eb0d3a3 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Wed, 15 Jan 2020 14:30:34 +0000 Subject: ASoC: rt711: fix return value check in rt711_sdw_probe() In case of error, the function devm_regmap_init() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: 320b8b0d13b8 ("ASoC: rt711: add rt711 codec driver") Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200115143034.94492-1-weiyongjun1@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt711-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt711-sdw.c b/sound/soc/codecs/rt711-sdw.c index e28dc84ede5b..85e62e1059cd 100644 --- a/sound/soc/codecs/rt711-sdw.c +++ b/sound/soc/codecs/rt711-sdw.c @@ -460,8 +460,8 @@ static int rt711_sdw_probe(struct sdw_slave *slave, regmap = devm_regmap_init(&slave->dev, NULL, &slave->dev, &rt711_regmap); - if (!regmap) - return -EINVAL; + if (IS_ERR(regmap)) + return PTR_ERR(regmap); rt711_init(&slave->dev, sdw_regmap, regmap, slave); -- cgit v1.2.3 From f9f5bbf5783cd63369d3e6c8cf27e2bd7c5ac2c3 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 17 Jan 2020 02:41:49 +0000 Subject: ASoC: rt715: fix return value check in rt715_sdw_probe() In case of error, the function devm_regmap_init() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Fixes: d1ede0641b05 ("ASoC: rt715: add RT715 codec driver") Signed-off-by: Wei Yongjun Link: https://lore.kernel.org/r/20200117024149.75515-1-weiyongjun1@huawei.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt715-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt715-sdw.c b/sound/soc/codecs/rt715-sdw.c index 18868e4ae6e8..6d892c44c522 100644 --- a/sound/soc/codecs/rt715-sdw.c +++ b/sound/soc/codecs/rt715-sdw.c @@ -535,8 +535,8 @@ static int rt715_sdw_probe(struct sdw_slave *slave, regmap = devm_regmap_init(&slave->dev, NULL, &slave->dev, &rt715_regmap); - if (!regmap) - return -EINVAL; + if (IS_ERR(regmap)) + return PTR_ERR(regmap); rt715_init(&slave->dev, sdw_regmap, regmap, slave); -- cgit v1.2.3 From a174a6c226796824cb2f78157c0b183ed472fa3f Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu vardhan rao Date: Fri, 17 Jan 2020 17:15:09 +0530 Subject: ASoC: amd: Additional DAI for I2S SP instance. I2S SP instance has separate BCLK and LRCLK for Tx and Rx. Creating additional DAI for Rx. Signed-off-by: Ravulapati Vishnu vardhan rao Link: https://lore.kernel.org/r/1579261510-12580-1-git-send-email-Vishnuvardhanrao.Ravulapati@amd.com Signed-off-by: Mark Brown --- sound/soc/amd/raven/acp3x.h | 2 +- sound/soc/amd/raven/pci-acp3x.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h index b6a80dc0b641..21e7ac017f2b 100644 --- a/sound/soc/amd/raven/acp3x.h +++ b/sound/soc/amd/raven/acp3x.h @@ -13,7 +13,7 @@ #define TDM_ENABLE 1 #define TDM_DISABLE 0 -#define ACP3x_DEVS 3 +#define ACP3x_DEVS 4 #define ACP3x_PHY_BASE_ADDRESS 0x1240000 #define ACP3x_I2S_MODE 0 #define ACP3x_REG_START 0x1240000 diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c index 2f9f52905853..65330bb50e74 100644 --- a/sound/soc/amd/raven/pci-acp3x.c +++ b/sound/soc/amd/raven/pci-acp3x.c @@ -225,7 +225,13 @@ static int snd_acp3x_probe(struct pci_dev *pci, pdevinfo[2].id = 1; pdevinfo[2].parent = &pci->dev; pdevinfo[2].num_res = 1; - pdevinfo[2].res = &adata->res[2]; + pdevinfo[2].res = &adata->res[1]; + + pdevinfo[3].name = "acp3x_i2s_playcap"; + pdevinfo[3].id = 2; + pdevinfo[3].parent = &pci->dev; + pdevinfo[3].num_res = 1; + pdevinfo[3].res = &adata->res[2]; for (i = 0; i < ACP3x_DEVS; i++) { adata->pdev[i] = platform_device_register_full(&pdevinfo[i]); -- cgit v1.2.3 From 65fe457e7bafcbb844c66e8c54a414f090967eaa Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Tue, 14 Jan 2020 19:12:28 +0100 Subject: ASoC: msm8916-wcd-analog: Simplify MIC BIAS Internal At the moment, MIC BIAS Internal* and MIC BIAS External* both reference the same register, and have a part of their initialization sequence duplicated. For example, the sequence for enabling MIC BIAS Internal1 is: I1. Enable MIC_BIAS1 supply (MICB_EN bit in CDC_A_MICB_1_EN) I2. Enable internal RBIAS (TX1_INT_RBIAS_EN bit in CDC_A_MICB_1_INT_RBIAS) The sequence for enabling MIC BIAS External1 is: E1. Enable MIC_BIAS1 supply (MICB_EN bit in CDC_A_MICB_1_EN) (E2. Ideally, make sure internal RBIAS is disabled. However, this should not happen in practice because DAPM will disable unused supplies...) Right now we have: SND_SOC_DAPM_SUPPLY("MIC BIAS Internal1", CDC_A_MICB_1_EN, 7, 0, ...) // I1 SND_SOC_DAPM_SUPPLY("MIC BIAS External1", CDC_A_MICB_1_EN, 7, 0, ...) // E1 and I2 is done in the PM event handler (pm8916_wcd_analog_enable_micbias_int1). We can simplify this by defining a common DAPM supply for I1/E1 ("MIC_BIAS1"), and one DAPM supply for I2 ("MIC BIAS Internal1"). Additional DAPM routes ensure that we also enable the MIC_BIAS1 supply for the internal and external pull up resistor. Another advantage of this is that we now disable the internal RBIAS when it is not needed. This makes it much easier to add support for MIC BIAS Internal3 as a next step. Tested-by: Nikita Travkin # longcheer-l8150 Cc: Srinivas Kandagatla Signed-off-by: Stephan Gerhold Reviewed-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20200114181229.42302-1-stephan@gerhold.net Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 112 +++++++++++++--------------------- 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 1f7964beb20c..d6d727f5bae5 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -374,9 +374,8 @@ static void pm8916_wcd_analog_micbias_enable(struct snd_soc_component *component } -static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component - *component, int event, - int reg, unsigned int cap_mode) +static int pm8916_wcd_analog_enable_micbias(struct snd_soc_component *component, + int event, unsigned int cap_mode) { switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -389,72 +388,44 @@ static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component return 0; } -static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_component - *component, int event, - int reg, u32 cap_mode) +static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) { + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_component_update_bits(component, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_OPA_STG2_TAIL_CURR_MASK, MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA); - - break; - case SND_SOC_DAPM_POST_PMU: - pm8916_wcd_analog_micbias_enable(component); - snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, - MICB_1_EN_BYP_CAP_MASK, cap_mode); break; } return 0; } -static int pm8916_wcd_analog_enable_micbias_ext1(struct - snd_soc_dapm_widget - *w, struct snd_kcontrol - *kcontrol, int event) +static int pm8916_wcd_analog_enable_micbias1(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, - wcd->micbias1_cap_mode); + return pm8916_wcd_analog_enable_micbias(component, event, + wcd->micbias1_cap_mode); } -static int pm8916_wcd_analog_enable_micbias_ext2(struct - snd_soc_dapm_widget - *w, struct snd_kcontrol - *kcontrol, int event) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - - return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, - wcd->micbias2_cap_mode); - -} - -static int pm8916_wcd_analog_enable_micbias_int1(struct - snd_soc_dapm_widget - *w, struct snd_kcontrol - *kcontrol, int event) +static int pm8916_wcd_analog_enable_micbias2(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, - MICB_1_INT_TX1_INT_RBIAS_EN_MASK, - MICB_1_INT_TX1_INT_RBIAS_EN_ENABLE); - break; - } + return pm8916_wcd_analog_enable_micbias(component, event, + wcd->micbias2_cap_mode); - return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, - wcd->micbias1_cap_mode); } static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, @@ -564,9 +535,8 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, - MICB_1_INT_TX2_INT_RBIAS_EN_MASK, - MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); + snd_soc_component_update_bits(component, CDC_A_MICB_2_EN, + CDC_A_MICB_2_PULL_DOWN_EN_MASK, 0); break; case SND_SOC_DAPM_POST_PMU: pm8916_mbhc_configure_bias(wcd, true); @@ -576,8 +546,7 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct break; } - return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, - wcd->micbias2_cap_mode); + return pm8916_wcd_analog_enable_micbias_int(w, kcontrol, event); } static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, @@ -878,14 +847,15 @@ static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = { {"SPK PA", NULL, "SPK DAC"}, {"SPK DAC", "Switch", "PDM_RX3"}, - {"MIC BIAS Internal1", NULL, "INT_LDO_H"}, - {"MIC BIAS Internal2", NULL, "INT_LDO_H"}, - {"MIC BIAS External1", NULL, "INT_LDO_H"}, - {"MIC BIAS External2", NULL, "INT_LDO_H"}, - {"MIC BIAS Internal1", NULL, "vdd-micbias"}, - {"MIC BIAS Internal2", NULL, "vdd-micbias"}, - {"MIC BIAS External1", NULL, "vdd-micbias"}, - {"MIC BIAS External2", NULL, "vdd-micbias"}, + {"MIC_BIAS1", NULL, "INT_LDO_H"}, + {"MIC_BIAS2", NULL, "INT_LDO_H"}, + {"MIC_BIAS1", NULL, "vdd-micbias"}, + {"MIC_BIAS2", NULL, "vdd-micbias"}, + + {"MIC BIAS External1", NULL, "MIC_BIAS1"}, + {"MIC BIAS Internal1", NULL, "MIC_BIAS1"}, + {"MIC BIAS External2", NULL, "MIC_BIAS2"}, + {"MIC BIAS Internal2", NULL, "MIC_BIAS2"}, }; static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { @@ -937,22 +907,24 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("RX_BIAS", CDC_A_RX_COM_BIAS_DAC, 7, 0, NULL, 0), /* TX */ - SND_SOC_DAPM_SUPPLY("MIC BIAS Internal1", CDC_A_MICB_1_EN, 7, 0, - pm8916_wcd_analog_enable_micbias_int1, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_SUPPLY("MIC BIAS Internal2", CDC_A_MICB_2_EN, 7, 0, + SND_SOC_DAPM_SUPPLY("MIC_BIAS1", CDC_A_MICB_1_EN, 7, 0, + pm8916_wcd_analog_enable_micbias1, + SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_SUPPLY("MIC_BIAS2", CDC_A_MICB_2_EN, 7, 0, + pm8916_wcd_analog_enable_micbias2, + SND_SOC_DAPM_POST_PMU), + + SND_SOC_DAPM_SUPPLY("MIC BIAS External1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MIC BIAS External2", SND_SOC_NOPM, 0, 0, NULL, 0), + + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal1", CDC_A_MICB_1_INT_RBIAS, 7, 0, + pm8916_wcd_analog_enable_micbias_int, + SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal2", CDC_A_MICB_1_INT_RBIAS, 4, 0, pm8916_wcd_analog_enable_micbias_int2, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_SUPPLY("MIC BIAS External1", CDC_A_MICB_1_EN, 7, 0, - pm8916_wcd_analog_enable_micbias_ext1, - SND_SOC_DAPM_POST_PMU), - SND_SOC_DAPM_SUPPLY("MIC BIAS External2", CDC_A_MICB_2_EN, 7, 0, - pm8916_wcd_analog_enable_micbias_ext2, - SND_SOC_DAPM_POST_PMU), - SND_SOC_DAPM_ADC_E("ADC1", NULL, CDC_A_TX_1_EN, 7, 0, pm8916_wcd_analog_enable_adc, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | -- cgit v1.2.3 From 00d852326e524214f046a5e1301eee84535a6863 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Tue, 14 Jan 2020 19:12:29 +0100 Subject: ASoC: msm8916-wcd-analog: Add MIC BIAS Internal3 PM8916 has three TX inputs that each have an (optional) internal RBIAS resistor. MIC BIAS Internal1/2 (for TX1/2) are already supported. TX3 does not have its own MIC BIAS supply, instead it is also supplied from MIC_BIAS1. Now that we have simplified the MIC BIAS Internal* implementation we can easily add support for it: Add a MIC BIAS Internal3 supply that enables the internal RBIAS resistor on TX3, and make sure to also enable the MIC_BIAS1 supply. Tested-by: Nikita Travkin # longcheer-l8150 Cc: Srinivas Kandagatla Signed-off-by: Stephan Gerhold Reviewed-by: Srinivas Kandagatla Link: https://lore.kernel.org/r/20200114181229.42302-2-stephan@gerhold.net Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index d6d727f5bae5..85bc7ae4d267 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -856,6 +856,7 @@ static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = { {"MIC BIAS Internal1", NULL, "MIC_BIAS1"}, {"MIC BIAS External2", NULL, "MIC_BIAS2"}, {"MIC BIAS Internal2", NULL, "MIC_BIAS2"}, + {"MIC BIAS Internal3", NULL, "MIC_BIAS1"}, }; static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { @@ -924,6 +925,9 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { pm8916_wcd_analog_enable_micbias_int2, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_SUPPLY("MIC BIAS Internal3", CDC_A_MICB_1_INT_RBIAS, 1, 0, + pm8916_wcd_analog_enable_micbias_int, + SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_ADC_E("ADC1", NULL, CDC_A_TX_1_EN, 7, 0, pm8916_wcd_analog_enable_adc, -- cgit v1.2.3 From 332719b1840b9bf3e09938d1fda566f414fcf0e6 Mon Sep 17 00:00:00 2001 From: Erik Bussing Date: Wed, 15 Jan 2020 17:46:16 +0100 Subject: ASoC: Intel: bytcr_rt5640: Remove code duplication in byt_rt5640_codec_fixup The 16 and 24 bit paths in byt_rt5640_codec_fixup are mostly identical, introduce a local bits variable to address the only difference and move the common bits out of the if ... else ... . Signed-off-by: Erik Bussing Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200115164619.101705-2-hdegoede@redhat.com Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5640.c | 68 ++++++++++++----------------------- 1 file changed, 23 insertions(+), 45 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index dd6310fe8914..c19ae4fbf955 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -940,65 +940,43 @@ static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - int ret; + int ret, bits; /* The DSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || - (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { - + (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { /* set SSP0 to 16-bit */ params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); - - /* - * Default mode for SSP configuration is TDM 4 slot, override config - * with explicit setting to I2S 2ch 16-bit. The word length is set with - * dai_set_tdm_slot() since there is no other API exposed - */ - ret = snd_soc_dai_set_fmt(rtd->cpu_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS - ); - if (ret < 0) { - dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); - return ret; - } - - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16); - if (ret < 0) { - dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); - return ret; - } - + bits = 16; } else { - /* set SSP2 to 24-bit */ params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + bits = 24; + } - /* - * Default mode for SSP configuration is TDM 4 slot, override config - * with explicit setting to I2S 2ch 24-bit. The word length is set with - * dai_set_tdm_slot() since there is no other API exposed - */ - ret = snd_soc_dai_set_fmt(rtd->cpu_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS - ); - if (ret < 0) { - dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); - return ret; - } + /* + * Default mode for SSP configuration is TDM 4 slot, override config + * with explicit setting to I2S 2ch. The word length is set with + * dai_set_tdm_slot() since there is no other API exposed + */ + ret = snd_soc_dai_set_fmt(rtd->cpu_dai, + SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS); + if (ret < 0) { + dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); + return ret; + } - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); - if (ret < 0) { - dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); - return ret; - } + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, bits); + if (ret < 0) { + dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); + return ret; } + return 0; } -- cgit v1.2.3 From 296868315c692a1f63465a9ec27cdfa3a46ec840 Mon Sep 17 00:00:00 2001 From: Nariman Etemadi Date: Wed, 15 Jan 2020 17:46:17 +0100 Subject: ASoC: Intel: bytcr_rt5640: Remove unnecessary string buffers and snprintf calls The snprintf calls filling byt_rt56*_codec_aif_name/byt_rt56*_cpu_dai_name always fill them with the same string ("rt56*-aif2" resp. ssp0-port"). So instead of keeping these buffers around and making codecs->dai_name / cpus->dai_name point to them, simply update the *->dai_name pointers to directly point to a string constant containing the desired string. Signed-off-by: Nariman Etemadi Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200115164619.101705-3-hdegoede@redhat.com Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5640.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index c19ae4fbf955..6bd9ae813be2 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1054,8 +1054,6 @@ static struct snd_soc_dai_link byt_rt5640_dais[] = { /* SoC card */ static char byt_rt5640_codec_name[SND_ACPI_I2C_ID_LEN]; -static char byt_rt5640_codec_aif_name[12]; /* = "rt5640-aif[1|2]" */ -static char byt_rt5640_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) static char byt_rt5640_long_name[40]; /* = "bytcr-rt5640-*-spk-*-mic" */ #endif @@ -1239,28 +1237,12 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) log_quirks(&pdev->dev); if ((byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) || - (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { - - /* fixup codec aif name */ - snprintf(byt_rt5640_codec_aif_name, - sizeof(byt_rt5640_codec_aif_name), - "%s", "rt5640-aif2"); - - byt_rt5640_dais[dai_index].codecs->dai_name = - byt_rt5640_codec_aif_name; - } + (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) + byt_rt5640_dais[dai_index].codecs->dai_name = "rt5640-aif2"; if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) || - (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) { - - /* fixup cpu dai name name */ - snprintf(byt_rt5640_cpu_dai_name, - sizeof(byt_rt5640_cpu_dai_name), - "%s", "ssp0-port"); - - byt_rt5640_dais[dai_index].cpus->dai_name = - byt_rt5640_cpu_dai_name; - } + (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) + byt_rt5640_dais[dai_index].cpus->dai_name = "ssp0-port"; if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) { priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); -- cgit v1.2.3 From fcce38d85cb865346da9b8f2d87c9427153dc5ca Mon Sep 17 00:00:00 2001 From: Jordy Ubink Date: Wed, 15 Jan 2020 17:46:18 +0100 Subject: ASoC: Intel: bytcr_rt5651: Remove unnecessary string buffers and snprintf calls The snprintf calls filling byt_rt56*_codec_aif_name/byt_rt56*_cpu_dai_name always fill them with the same string ("rt56*-aif2" resp. ssp0-port"). So instead of keeping these buffers around and making codecs->dai_name / cpus->dai_name point to them, simply update the *->dai_name pointers to directly point to a string constant containing the desired string. Signed-off-by: Jordy Ubink Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200115164619.101705-4-hdegoede@redhat.com Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 6d71352ea864..5074bb53f98e 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -787,8 +787,6 @@ static struct snd_soc_dai_link byt_rt5651_dais[] = { /* SoC card */ static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; -static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ -static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) static char byt_rt5651_long_name[50]; /* = "bytcr-rt5651-*-spk-*-mic[-swapped-hp]" */ #endif @@ -1037,26 +1035,12 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) log_quirks(&pdev->dev); if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) || - (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { - /* fixup codec aif name */ - snprintf(byt_rt5651_codec_aif_name, - sizeof(byt_rt5651_codec_aif_name), - "%s", "rt5651-aif2"); - - byt_rt5651_dais[dai_index].codecs->dai_name = - byt_rt5651_codec_aif_name; - } + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) + byt_rt5651_dais[dai_index].codecs->dai_name = "rt5651-aif2"; if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || - (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { - /* fixup cpu dai name name */ - snprintf(byt_rt5651_cpu_dai_name, - sizeof(byt_rt5651_cpu_dai_name), - "%s", "ssp0-port"); - - byt_rt5651_dais[dai_index].cpus->dai_name = - byt_rt5651_cpu_dai_name; - } + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) + byt_rt5651_dais[dai_index].cpus->dai_name = "ssp0-port"; if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); -- cgit v1.2.3 From 791a0059e2585c094c2b8ff61983074c657dabf8 Mon Sep 17 00:00:00 2001 From: Damian van Soelen Date: Wed, 15 Jan 2020 17:46:19 +0100 Subject: ASoC: Intel: cht_bsw_rt5645: Remove unnecessary string buffers and snprintf calls The snprintf calls filling cht_rt5645_cpu_dai_name / cht_rt5645_codec_aif_name always fill them with the same string ("ssp0-port" resp "rt5645-aif2") so instead of keeping these buffers around and making cpus->dai_name / codecs->dai_name point to this, simply update the *->dai_name pointers to directly point to a string constant containing the desired string. Signed-off-by: Damian van Soelen Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200115164619.101705-5-hdegoede@redhat.com Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/intel/boards/cht_bsw_rt5645.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c index c68a5b85a4a0..b5b016d493f1 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5645.c +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c @@ -515,8 +515,6 @@ static struct cht_acpi_card snd_soc_cards[] = { }; static char cht_rt5645_codec_name[SND_ACPI_I2C_ID_LEN]; -static char cht_rt5645_codec_aif_name[12]; /* = "rt5645-aif[1|2]" */ -static char cht_rt5645_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ u64 aif_value; /* 1: AIF1, 2: AIF2 */ @@ -641,28 +639,12 @@ static int snd_cht_mc_probe(struct platform_device *pdev) log_quirks(&pdev->dev); if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) || - (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) { - - /* fixup codec aif name */ - snprintf(cht_rt5645_codec_aif_name, - sizeof(cht_rt5645_codec_aif_name), - "%s", "rt5645-aif2"); - - cht_dailink[dai_index].codecs->dai_name = - cht_rt5645_codec_aif_name; - } + (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) + cht_dailink[dai_index].codecs->dai_name = "rt5645-aif2"; if ((cht_rt5645_quirk & CHT_RT5645_SSP0_AIF1) || - (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) { - - /* fixup cpu dai name name */ - snprintf(cht_rt5645_cpu_dai_name, - sizeof(cht_rt5645_cpu_dai_name), - "%s", "ssp0-port"); - - cht_dailink[dai_index].cpus->dai_name = - cht_rt5645_cpu_dai_name; - } + (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) + cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; /* override plaform name, if required */ platform_name = mach->mach_params.platform; -- cgit v1.2.3 From 4d024fe8f806e20e577cc934204c5784c7063293 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Jan 2020 11:41:27 +0100 Subject: ALSA: hda: Apply aligned MMIO access only conditionally It turned out that the recent simplification of HD-audio bus access helpers caused a regression on the virtual HD-audio device on QEMU with ARM platforms. The driver got a CORB/RIRB timeout and couldn't probe any codecs. The essential difference that caused a problem was the enforced aligned MMIO accesses by simplification. Since snd-hda-tegra driver is enabled on ARM, it enables CONFIG_SND_HDA_ALIGNED_MMIO, which makes the all HD-audio drivers using the aligned MMIO accesses. While this is mandatory for snd-hda-tegra, it seems that snd-hda-intel on ARM gets broken by this access pattern. For addressing the regression, this patch introduces a new flag, aligned_mmio, to hdac_bus object, and applies the aligned MMIO only when this flag is set. This change affects only platforms with CONFIG_SND_HDA_ALIGNED_MMIO set, i.e. mostly only for ARM platforms. Unfortunately the patch became a big bigger than it should be, just because the former calls didn't take hdac_bus object in the argument, hence we had to extend the call patterns. Fixes: 19abfefd4c76 ("ALSA: hda: Direct MMIO accesses") BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1161152 Cc: Link: https://lore.kernel.org/r/20200120104127.28985-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/hdaudio.h | 77 ++++++++++++++++++++++++++++++++--------------- sound/pci/hda/hda_tegra.c | 1 + 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index e05b95e83d5a..fb9dce4c6928 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -330,6 +331,7 @@ struct hdac_bus { bool chip_init:1; /* h/w initialized */ /* behavior flags */ + bool aligned_mmio:1; /* aligned MMIO access */ bool sync_write:1; /* sync after verb write */ bool use_posbuf:1; /* use position buffer */ bool snoop:1; /* enable snooping */ @@ -405,34 +407,61 @@ void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus); unsigned int snd_hdac_aligned_read(void __iomem *addr, unsigned int mask); void snd_hdac_aligned_write(unsigned int val, void __iomem *addr, unsigned int mask); -#define snd_hdac_reg_writeb(v, addr) snd_hdac_aligned_write(v, addr, 0xff) -#define snd_hdac_reg_writew(v, addr) snd_hdac_aligned_write(v, addr, 0xffff) -#define snd_hdac_reg_readb(addr) snd_hdac_aligned_read(addr, 0xff) -#define snd_hdac_reg_readw(addr) snd_hdac_aligned_read(addr, 0xffff) -#else /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writeb(val, addr) writeb(val, addr) -#define snd_hdac_reg_writew(val, addr) writew(val, addr) -#define snd_hdac_reg_readb(addr) readb(addr) -#define snd_hdac_reg_readw(addr) readw(addr) -#endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writel(val, addr) writel(val, addr) -#define snd_hdac_reg_readl(addr) readl(addr) +#define snd_hdac_aligned_mmio(bus) (bus)->aligned_mmio +#else +#define snd_hdac_aligned_mmio(bus) false +#define snd_hdac_aligned_read(addr, mask) 0 +#define snd_hdac_aligned_write(val, addr, mask) do {} while (0) +#endif + +static inline void snd_hdac_reg_writeb(struct hdac_bus *bus, void __iomem *addr, + u8 val) +{ + if (snd_hdac_aligned_mmio(bus)) + snd_hdac_aligned_write(val, addr, 0xff); + else + writeb(val, addr); +} + +static inline void snd_hdac_reg_writew(struct hdac_bus *bus, void __iomem *addr, + u16 val) +{ + if (snd_hdac_aligned_mmio(bus)) + snd_hdac_aligned_write(val, addr, 0xffff); + else + writew(val, addr); +} + +static inline u8 snd_hdac_reg_readb(struct hdac_bus *bus, void __iomem *addr) +{ + return snd_hdac_aligned_mmio(bus) ? + snd_hdac_aligned_read(addr, 0xff) : readb(addr); +} + +static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr) +{ + return snd_hdac_aligned_mmio(bus) ? + snd_hdac_aligned_read(addr, 0xffff) : readw(addr); +} + +#define snd_hdac_reg_writel(bus, addr, val) writel(val, addr) +#define snd_hdac_reg_readl(bus, addr) readl(addr) /* * macros for easy use */ #define _snd_hdac_chip_writeb(chip, reg, value) \ - snd_hdac_reg_writeb(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writeb(chip, (chip)->remap_addr + (reg), value) #define _snd_hdac_chip_readb(chip, reg) \ - snd_hdac_reg_readb((chip)->remap_addr + (reg)) + snd_hdac_reg_readb(chip, (chip)->remap_addr + (reg)) #define _snd_hdac_chip_writew(chip, reg, value) \ - snd_hdac_reg_writew(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writew(chip, (chip)->remap_addr + (reg), value) #define _snd_hdac_chip_readw(chip, reg) \ - snd_hdac_reg_readw((chip)->remap_addr + (reg)) + snd_hdac_reg_readw(chip, (chip)->remap_addr + (reg)) #define _snd_hdac_chip_writel(chip, reg, value) \ - snd_hdac_reg_writel(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writel(chip, (chip)->remap_addr + (reg), value) #define _snd_hdac_chip_readl(chip, reg) \ - snd_hdac_reg_readl((chip)->remap_addr + (reg)) + snd_hdac_reg_readl(chip, (chip)->remap_addr + (reg)) /* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_chip_writel(chip, reg, value) \ @@ -540,17 +569,17 @@ int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus, */ /* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_writel(dev, reg, value) \ - snd_hdac_reg_writel(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writel((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) #define snd_hdac_stream_writew(dev, reg, value) \ - snd_hdac_reg_writew(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writew((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) #define snd_hdac_stream_writeb(dev, reg, value) \ - snd_hdac_reg_writeb(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writeb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) #define snd_hdac_stream_readl(dev, reg) \ - snd_hdac_reg_readl((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readl((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) #define snd_hdac_stream_readw(dev, reg) \ - snd_hdac_reg_readw((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readw((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) #define snd_hdac_stream_readb(dev, reg) \ - snd_hdac_reg_readb((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) /* update a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_updatel(dev, reg, mask, val) \ diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 8350954b7986..e5191584638a 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -398,6 +398,7 @@ static int hda_tegra_create(struct snd_card *card, return err; chip->bus.needs_damn_long_delay = 1; + chip->bus.core.aligned_mmio = 1; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); if (err < 0) { -- cgit v1.2.3 From d4cfb30fce03093ad944e0b44bd8f40bdad5330e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Jan 2020 13:44:22 +0100 Subject: ALSA: pcm: Set per-card upper limit of PCM buffer allocations Currently, the available buffer allocation size for a PCM stream depends on the preallocated size; when a buffer has been preallocated, the max buffer size is set to that size, so that application won't re-allocate too much memory. OTOH, when no preallocation is done, each substream may allocate arbitrary size of buffers as long as snd_pcm_hardware.buffer_bytes_max allows -- which can be quite high, HD-audio sets 1GB there. It means that the system may consume a high amount of pages for PCM buffers, and they are pinned and never swapped out. This can lead to OOM easily. For avoiding such a situation, this patch adds the upper limit per card. Each snd_pcm_lib_malloc_pages() and _free_pages() calls are tracked and it will return an error if the total amount of buffers goes over the defined upper limit. The default value is set to 32MB, which should be really large enough for usual operations. If larger buffers are needed for any specific usage, it can be adjusted (also dynamically) via snd_pcm.max_alloc_per_card option. Setting zero there means no chceck is performed, and again, unlimited amount of buffers are allowed. Link: https://lore.kernel.org/r/20200120124423.11862-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- include/sound/core.h | 3 +++ sound/core/init.c | 1 + sound/core/pcm_memory.c | 69 ++++++++++++++++++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 0e14b7a3e67b..ac8b692b69b4 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -120,6 +120,9 @@ struct snd_card { int sync_irq; /* assigned irq, used for PCM sync */ wait_queue_head_t remove_sleep; + size_t total_pcm_alloc_bytes; /* total amount of allocated buffers */ + struct mutex memory_mutex; /* protection for the above */ + #ifdef CONFIG_PM unsigned int power_state; /* power state */ wait_queue_head_t power_sleep; diff --git a/sound/core/init.c b/sound/core/init.c index faa9f03c01ca..b02a99766351 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -211,6 +211,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid, INIT_LIST_HEAD(&card->ctl_files); spin_lock_init(&card->files_lock); INIT_LIST_HEAD(&card->files_list); + mutex_init(&card->memory_mutex); #ifdef CONFIG_PM init_waitqueue_head(&card->power_sleep); #endif diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index d4702cc1d376..fcab37ea6641 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -27,6 +27,38 @@ MODULE_PARM_DESC(maximum_substreams, "Maximum substreams with preallocated DMA m static const size_t snd_minimum_buffer = 16384; +static unsigned long max_alloc_per_card = 32UL * 1024UL * 1024UL; +module_param(max_alloc_per_card, ulong, 0644); +MODULE_PARM_DESC(max_alloc_per_card, "Max total allocation bytes per card."); + +static int do_alloc_pages(struct snd_card *card, int type, struct device *dev, + size_t size, struct snd_dma_buffer *dmab) +{ + int err; + + if (max_alloc_per_card && + card->total_pcm_alloc_bytes + size > max_alloc_per_card) + return -ENOMEM; + err = snd_dma_alloc_pages(type, dev, size, dmab); + if (!err) { + mutex_lock(&card->memory_mutex); + card->total_pcm_alloc_bytes += dmab->bytes; + mutex_unlock(&card->memory_mutex); + } + return err; +} + +static void do_free_pages(struct snd_card *card, struct snd_dma_buffer *dmab) +{ + if (!dmab->area) + return; + mutex_lock(&card->memory_mutex); + WARN_ON(card->total_pcm_alloc_bytes < dmab->bytes); + card->total_pcm_alloc_bytes -= dmab->bytes; + mutex_unlock(&card->memory_mutex); + snd_dma_free_pages(dmab); + dmab->area = NULL; +} /* * try to allocate as the large pages as possible. @@ -37,16 +69,15 @@ static const size_t snd_minimum_buffer = 16384; static int preallocate_pcm_pages(struct snd_pcm_substream *substream, size_t size) { struct snd_dma_buffer *dmab = &substream->dma_buffer; + struct snd_card *card = substream->pcm->card; size_t orig_size = size; int err; do { - if ((err = snd_dma_alloc_pages(dmab->dev.type, dmab->dev.dev, - size, dmab)) < 0) { - if (err != -ENOMEM) - return err; /* fatal error */ - } else - return 0; + err = do_alloc_pages(card, dmab->dev.type, dmab->dev.dev, + size, dmab); + if (err != -ENOMEM) + return err; size >>= 1; } while (size >= snd_minimum_buffer); dmab->bytes = 0; /* tell error */ @@ -62,10 +93,7 @@ static int preallocate_pcm_pages(struct snd_pcm_substream *substream, size_t siz */ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream) { - if (substream->dma_buffer.area == NULL) - return; - snd_dma_free_pages(&substream->dma_buffer); - substream->dma_buffer.area = NULL; + do_free_pages(substream->pcm->card, &substream->dma_buffer); } /** @@ -130,6 +158,7 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct snd_pcm_substream *substream = entry->private_data; + struct snd_card *card = substream->pcm->card; char line[64], str[64]; size_t size; struct snd_dma_buffer new_dmab; @@ -150,9 +179,10 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, memset(&new_dmab, 0, sizeof(new_dmab)); new_dmab.dev = substream->dma_buffer.dev; if (size > 0) { - if (snd_dma_alloc_pages(substream->dma_buffer.dev.type, - substream->dma_buffer.dev.dev, - size, &new_dmab) < 0) { + if (do_alloc_pages(card, + substream->dma_buffer.dev.type, + substream->dma_buffer.dev.dev, + size, &new_dmab) < 0) { buffer->error = -ENOMEM; return; } @@ -161,7 +191,7 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, substream->buffer_bytes_max = UINT_MAX; } if (substream->dma_buffer.area) - snd_dma_free_pages(&substream->dma_buffer); + do_free_pages(card, &substream->dma_buffer); substream->dma_buffer = new_dmab; } else { buffer->error = -EINVAL; @@ -346,6 +376,7 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne */ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) { + struct snd_card *card = substream->pcm->card; struct snd_pcm_runtime *runtime; struct snd_dma_buffer *dmab = NULL; @@ -374,9 +405,10 @@ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) if (! dmab) return -ENOMEM; dmab->dev = substream->dma_buffer.dev; - if (snd_dma_alloc_pages(substream->dma_buffer.dev.type, - substream->dma_buffer.dev.dev, - size, dmab) < 0) { + if (do_alloc_pages(card, + substream->dma_buffer.dev.type, + substream->dma_buffer.dev.dev, + size, dmab) < 0) { kfree(dmab); return -ENOMEM; } @@ -397,6 +429,7 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages); */ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) { + struct snd_card *card = substream->pcm->card; struct snd_pcm_runtime *runtime; if (PCM_RUNTIME_CHECK(substream)) @@ -406,7 +439,7 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) return 0; if (runtime->dma_buffer_p != &substream->dma_buffer) { /* it's a newly allocated buffer. release it now. */ - snd_dma_free_pages(runtime->dma_buffer_p); + do_free_pages(card, runtime->dma_buffer_p); kfree(runtime->dma_buffer_p); } snd_pcm_set_runtime_buffer(substream, NULL); -- cgit v1.2.3 From c31427d0d21e198c74d5d92082c4b8194b257f82 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Jan 2020 13:44:23 +0100 Subject: ALSA: hda: No preallocation on x86 platforms Like many other drivers, HD-audio drivers also do PCM buffer preallocation to assure the buffer pages allocated at the early boot stage. This step is useful for platforms that may fail to allocate the PCM hardware buffers -- which is mostly for either large continuous pages or with the specific DMA mask (like emu10k1). OTOH, when a buffer is allocated as SG-buffer and the DMA mask is either 32 or 64 bits, the allocation almost never fails unless it hits the real OOM situation. In such a case, we don't need the preallocation inevitably unlike the cases above. That said, we may drop the preallocation for HD-audio that does allocate via SG-buffers, and the patch achieves it. However, there is one caveat: the buffer allocation behavior depends on CONFIG_SND_DMA_SGBUF, and it falls back to the continuous pages when it's not set. And, currently this SG buffer allocation is enabled only on x86 platforms. So, covering those fall-outs, the patch adjusts CONFIG_SND_HDA_PREALLOC_SIZE depending on the condition, and keeps the old behavior as-is for non-x86 platforms. On x86, the kconfig item is no longer adjustable but always set to zero for disabling the preallocation. You can still enable the preallocation via procfs interface at any time later, too. Link: https://lore.kernel.org/r/20200120124423.11862-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/hda/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/hda/Kconfig b/sound/hda/Kconfig index b0c88fe040ee..4ca6b09056f3 100644 --- a/sound/hda/Kconfig +++ b/sound/hda/Kconfig @@ -21,14 +21,16 @@ config SND_HDA_EXT_CORE select SND_HDA_CORE config SND_HDA_PREALLOC_SIZE - int "Pre-allocated buffer size for HD-audio driver" + int "Pre-allocated buffer size for HD-audio driver" if !SND_DMA_SGBUF range 0 32768 - default 64 + default 0 if SND_DMA_SGBUF + default 64 if !SND_DMA_SGBUF help Specifies the default pre-allocated buffer-size in kB for the HD-audio driver. A larger buffer (e.g. 2048) is preferred for systems using PulseAudio. The default 64 is chosen just for compatibility reasons. + On x86 systems, the default is zero as we need no preallocation. Note that the pre-allocation size can be changed dynamically via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too. -- cgit v1.2.3 From 2928fa0a97ebb9549cb877fdc99aed9b95438c3a Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Mon, 20 Jan 2020 18:01:17 +0200 Subject: ALSA: hda/hdmi - add retry logic to parse_intel_hdmi() The initial snd_hda_get_sub_node() can fail on certain devices (e.g. some Chromebook models using Intel GLK). The failure rate is very low, but as this is is part of the probe process, end-user impact is high. In observed cases, related hardware status registers have expected values, but the node query still fails. Retrying the node query does seem to help, so fix the problem by adding retry logic to the query. This does not impact non-Intel platforms. BugLink: https://github.com/thesofproject/linux/issues/1642 Signed-off-by: Kai Vehmanen Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20200120160117.29130-4-kai.vehmanen@linux.intel.com Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index ce3c212ee467..48bddc218829 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2833,9 +2833,12 @@ static int alloc_intel_hdmi(struct hda_codec *codec) /* parse and post-process for Intel codecs */ static int parse_intel_hdmi(struct hda_codec *codec) { - int err; + int err, retries = 3; + + do { + err = hdmi_parse_codec(codec); + } while (err < 0 && retries--); - err = hdmi_parse_codec(codec); if (err < 0) { generic_spec_free(codec); return err; -- cgit v1.2.3 From af4bac11531fbc0b5955fdccbe3f5ea265cd7374 Mon Sep 17 00:00:00 2001 From: Sameer Pujar Date: Sun, 19 Jan 2020 19:49:23 +0530 Subject: ASoC: soc-pcm: crash in snd_soc_dapm_new_dai Crash happens in snd_soc_dapm_new_dai() when substream->private_data access is made and substream is NULL here. This is seen for DAIs where only playback or capture stream is defined. This seems to be happening for codec2codec DAI link. Both playback and capture are 0 during soc_new_pcm(). This is probably happening because cpu_dai and codec_dai are both validated either for SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE. Shouldn't be playback = 1 when, - playback stream is available for codec_dai AND - capture stream is available for cpu_dai and vice-versa for capture = 1? Signed-off-by: Sameer Pujar Link: https://lore.kernel.org/r/1579443563-12287-1-git-send-email-spujar@nvidia.com Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b78f6ff2b1d3..f70bec7815ee 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2916,10 +2916,10 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) for_each_rtd_codec_dai(rtd, i, codec_dai) { if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && - snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) + snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) playback = 1; if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) && - snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) + snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) capture = 1; } -- cgit v1.2.3 From 130128098a4e5ce9a0dfbdf9a7e27a43579901fd Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Mon, 20 Jan 2020 15:28:06 +0800 Subject: ASoC: soc-generic-dmaengine-pcm: Fix error handling Remove the return value checking, that is to align with the code before adding snd_dmaengine_pcm_refine_runtime_hwparams function. Otherwise it causes a regression on the HiKey board: [ 17.721424] hi6210_i2s f7118000.i2s: ASoC: can't open component f7118000.i2s: -6 Fixes: e957204e732b ("ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams") Signed-off-by: Shengjiu Wang Reported-by: John Stultz Link: https://lore.kernel.org/r/1579505286-32085-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index a428ff393ea2..2b5f3b1b062b 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -117,7 +117,6 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component, struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_hardware hw; - int ret; if (pcm->config && pcm->config->pcm_hardware) return snd_soc_set_runtime_hwparams(substream, @@ -138,12 +137,15 @@ dmaengine_pcm_set_runtime_hwparams(struct snd_soc_component *component, if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) hw.info |= SNDRV_PCM_INFO_BATCH; - ret = snd_dmaengine_pcm_refine_runtime_hwparams(substream, - dma_data, - &hw, - chan); - if (ret) - return ret; + /** + * FIXME: Remove the return value check to align with the code + * before adding snd_dmaengine_pcm_refine_runtime_hwparams + * function. + */ + snd_dmaengine_pcm_refine_runtime_hwparams(substream, + dma_data, + &hw, + chan); return snd_soc_set_runtime_hwparams(substream, &hw); } -- cgit v1.2.3 From 7307d33a280b300f69c00580be9fa210f8587039 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:03:43 +0900 Subject: ASoC: bcm: cygnus-ssp: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87blqzym4w.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-ssp.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 2f9357d7da96..257f5048061e 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -1052,10 +1052,13 @@ static int cygnus_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, } #ifdef CONFIG_PM_SLEEP -static int cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai) +static int __cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai) { struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai); + if (!cpu_dai->active) + return 0; + if (!aio->is_slave) { u32 val; @@ -1078,11 +1081,25 @@ static int cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai) return 0; } -static int cygnus_ssp_resume(struct snd_soc_dai *cpu_dai) +static int cygnus_ssp_suspend(struct snd_soc_component *component) +{ + struct snd_soc_dai *dai; + int ret = 0; + + for_each_component_dais(component, dai) + ret |= __cygnus_ssp_suspend(dai); + + return ret; +} + +static int __cygnus_ssp_resume(struct snd_soc_dai *cpu_dai) { struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai); int error; + if (!cpu_dai->active) + return 0; + if (!aio->is_slave) { if (aio->clk_trace.cap_clk_en) { error = clk_prepare_enable(aio->cygaud-> @@ -1109,6 +1126,18 @@ static int cygnus_ssp_resume(struct snd_soc_dai *cpu_dai) return 0; } + +static int cygnus_ssp_resume(struct snd_soc_component *component) +{ + struct snd_soc_dai *dai; + int ret = 0; + + for_each_component_dais(component, dai) + ret |= __cygnus_ssp_resume(dai); + + return ret; +} + #else #define cygnus_ssp_suspend NULL #define cygnus_ssp_resume NULL @@ -1149,8 +1178,6 @@ static const struct snd_soc_dai_ops cygnus_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE, \ }, \ .ops = &cygnus_ssp_dai_ops, \ - .suspend = cygnus_ssp_suspend, \ - .resume = cygnus_ssp_resume, \ } static const struct snd_soc_dai_driver cygnus_ssp_dai_info[] = { @@ -1169,14 +1196,14 @@ static const struct snd_soc_dai_driver cygnus_spdif_dai_info = { SNDRV_PCM_FMTBIT_S32_LE, }, .ops = &cygnus_spdif_dai_ops, - .suspend = cygnus_ssp_suspend, - .resume = cygnus_ssp_resume, }; static struct snd_soc_dai_driver cygnus_ssp_dai[CYGNUS_MAX_PORTS]; static const struct snd_soc_component_driver cygnus_ssp_component = { .name = "cygnus-audio", + .suspend = cygnus_ssp_suspend, + .resume = cygnus_ssp_resume, }; /* -- cgit v1.2.3 From e4f8bb37efae2b2be51f4d872fffcd09001c1f75 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:03:36 +0900 Subject: ASoC: atmel: atmel_ssc_dai: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87d0bfym53.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index ca603397651c..1073f468f21f 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -760,12 +760,12 @@ static int atmel_ssc_trigger(struct snd_pcm_substream *substream, } #ifdef CONFIG_PM -static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) +static int atmel_ssc_suspend(struct snd_soc_component *component) { struct atmel_ssc_info *ssc_p; - struct platform_device *pdev = to_platform_device(cpu_dai->dev); + struct platform_device *pdev = to_platform_device(component->dev); - if (!cpu_dai->active) + if (!component->active) return 0; ssc_p = &ssc_info[pdev->id]; @@ -787,15 +787,13 @@ static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) return 0; } - - -static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai) +static int atmel_ssc_resume(struct snd_soc_component *component) { struct atmel_ssc_info *ssc_p; - struct platform_device *pdev = to_platform_device(cpu_dai->dev); + struct platform_device *pdev = to_platform_device(component->dev); u32 cr; - if (!cpu_dai->active) + if (!component->active) return 0; ssc_p = &ssc_info[pdev->id]; @@ -839,8 +837,6 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = { }; static struct snd_soc_dai_driver atmel_ssc_dai = { - .suspend = atmel_ssc_suspend, - .resume = atmel_ssc_resume, .playback = { .channels_min = 1, .channels_max = 2, @@ -860,6 +856,8 @@ static struct snd_soc_dai_driver atmel_ssc_dai = { static const struct snd_soc_component_driver atmel_ssc_component = { .name = "atmel-ssc", + .suspend = atmel_ssc_suspend, + .resume = atmel_ssc_resume, }; static int asoc_ssc_init(struct device *dev) -- cgit v1.2.3 From 7b6e7b137e2ae5f789d2c8ab7df9f3650b5deaf1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:03:50 +0900 Subject: ASoC: cirrus: ep93xx-i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87a76jym4p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/cirrus/ep93xx-i2s.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/cirrus/ep93xx-i2s.c b/sound/soc/cirrus/ep93xx-i2s.c index 7d9cf67129d4..723f4cf19467 100644 --- a/sound/soc/cirrus/ep93xx-i2s.c +++ b/sound/soc/cirrus/ep93xx-i2s.c @@ -364,11 +364,11 @@ static int ep93xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, } #ifdef CONFIG_PM -static int ep93xx_i2s_suspend(struct snd_soc_dai *dai) +static int ep93xx_i2s_suspend(struct snd_soc_component *component) { - struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); + struct ep93xx_i2s_info *info = snd_soc_component_get_drvdata(component); - if (!dai->active) + if (!component->active) return 0; ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_PLAYBACK); @@ -377,11 +377,11 @@ static int ep93xx_i2s_suspend(struct snd_soc_dai *dai) return 0; } -static int ep93xx_i2s_resume(struct snd_soc_dai *dai) +static int ep93xx_i2s_resume(struct snd_soc_component *component) { - struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); + struct ep93xx_i2s_info *info = snd_soc_component_get_drvdata(component); - if (!dai->active) + if (!component->active) return 0; ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); @@ -406,8 +406,6 @@ static const struct snd_soc_dai_ops ep93xx_i2s_dai_ops = { static struct snd_soc_dai_driver ep93xx_i2s_dai = { .symmetric_rates= 1, .probe = ep93xx_i2s_dai_probe, - .suspend = ep93xx_i2s_suspend, - .resume = ep93xx_i2s_resume, .playback = { .channels_min = 2, .channels_max = 2, @@ -425,6 +423,8 @@ static struct snd_soc_dai_driver ep93xx_i2s_dai = { static const struct snd_soc_component_driver ep93xx_i2s_component = { .name = "ep93xx-i2s", + .suspend = ep93xx_i2s_suspend, + .resume = ep93xx_i2s_resume, }; static int ep93xx_i2s_probe(struct platform_device *pdev) -- cgit v1.2.3 From aa3c4765b3e8931e2e3c70894b717a993f96fff5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:03:56 +0900 Subject: ASoC: jz4740: jz4740-i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/878sm3ym4j.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/jz4740/jz4740-i2s.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 38d48d101783..9d5405881209 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -324,12 +324,12 @@ static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, return ret; } -static int jz4740_i2s_suspend(struct snd_soc_dai *dai) +static int jz4740_i2s_suspend(struct snd_soc_component *component) { - struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); + struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); uint32_t conf; - if (dai->active) { + if (component->active) { conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); conf &= ~JZ_AIC_CONF_ENABLE; jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); @@ -342,9 +342,9 @@ static int jz4740_i2s_suspend(struct snd_soc_dai *dai) return 0; } -static int jz4740_i2s_resume(struct snd_soc_dai *dai) +static int jz4740_i2s_resume(struct snd_soc_component *component) { - struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); + struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); uint32_t conf; int ret; @@ -352,7 +352,7 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai) if (ret) return ret; - if (dai->active) { + if (component->active) { ret = clk_prepare_enable(i2s->clk_i2s); if (ret) { clk_disable_unprepare(i2s->clk_aic); @@ -455,8 +455,6 @@ static struct snd_soc_dai_driver jz4740_i2s_dai = { }, .symmetric_rates = 1, .ops = &jz4740_i2s_dai_ops, - .suspend = jz4740_i2s_suspend, - .resume = jz4740_i2s_resume, }; static struct snd_soc_dai_driver jz4780_i2s_dai = { @@ -475,12 +473,12 @@ static struct snd_soc_dai_driver jz4780_i2s_dai = { .formats = JZ4740_I2S_FMTS, }, .ops = &jz4740_i2s_dai_ops, - .suspend = jz4740_i2s_suspend, - .resume = jz4740_i2s_resume, }; static const struct snd_soc_component_driver jz4740_i2s_component = { .name = "jz4740-i2s", + .suspend = jz4740_i2s_suspend, + .resume = jz4740_i2s_resume, }; #ifdef CONFIG_OF -- cgit v1.2.3 From 7ec6b43125c070fadf389b80083d939014e13ac9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:01 +0900 Subject: ASoC: mediatek: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/877e1nym4e.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 12 ++++++------ sound/soc/mediatek/common/mtk-afe-fe-dai.h | 4 ++-- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 14 ++------------ sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 10 ++++------ 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index 8f314e15ce73..4254f3a954dd 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -319,9 +319,9 @@ int mtk_dynamic_irq_release(struct mtk_base_afe *afe, int irq_id) } EXPORT_SYMBOL_GPL(mtk_dynamic_irq_release); -int mtk_afe_dai_suspend(struct snd_soc_dai *dai) +int mtk_afe_suspend(struct snd_soc_component *component) { - struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct device *dev = afe->dev; struct regmap *regmap = afe->regmap; int i; @@ -342,11 +342,11 @@ int mtk_afe_dai_suspend(struct snd_soc_dai *dai) afe->runtime_suspend(dev); return 0; } -EXPORT_SYMBOL_GPL(mtk_afe_dai_suspend); +EXPORT_SYMBOL_GPL(mtk_afe_suspend); -int mtk_afe_dai_resume(struct snd_soc_dai *dai) +int mtk_afe_resume(struct snd_soc_component *component) { - struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct device *dev = afe->dev; struct regmap *regmap = afe->regmap; int i = 0; @@ -366,7 +366,7 @@ int mtk_afe_dai_resume(struct snd_soc_dai *dai) afe->suspended = false; return 0; } -EXPORT_SYMBOL_GPL(mtk_afe_dai_resume); +EXPORT_SYMBOL_GPL(mtk_afe_resume); int mtk_memif_set_enable(struct mtk_base_afe *afe, int id) { diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.h b/sound/soc/mediatek/common/mtk-afe-fe-dai.h index 507e3e7c3c7d..8cec90671827 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.h +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.h @@ -31,8 +31,8 @@ extern const struct snd_soc_dai_ops mtk_afe_fe_ops; int mtk_dynamic_irq_acquire(struct mtk_base_afe *afe); int mtk_dynamic_irq_release(struct mtk_base_afe *afe, int irq_id); -int mtk_afe_dai_suspend(struct snd_soc_dai *dai); -int mtk_afe_dai_resume(struct snd_soc_dai *dai); +int mtk_afe_suspend(struct snd_soc_component *component); +int mtk_afe_resume(struct snd_soc_component *component); int mtk_memif_set_enable(struct mtk_base_afe *afe, int id); int mtk_memif_set_disable(struct mtk_base_afe *afe, int id); diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index 76502ba261c8..488603a0c4b1 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -549,8 +549,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCMO0", .id = MT2701_MEMIF_DL1, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .playback = { .stream_name = "DL1", .channels_min = 1, @@ -565,8 +563,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCM_multi", .id = MT2701_MEMIF_DLM, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .playback = { .stream_name = "DLM", .channels_min = 1, @@ -582,8 +578,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCM0", .id = MT2701_MEMIF_UL1, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .capture = { .stream_name = "UL1", .channels_min = 1, @@ -598,8 +592,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCM1", .id = MT2701_MEMIF_UL2, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .capture = { .stream_name = "UL2", .channels_min = 1, @@ -615,8 +607,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCM_BT_DL", .id = MT2701_MEMIF_DLBT, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .playback = { .stream_name = "DLBT", .channels_min = 1, @@ -630,8 +620,6 @@ static struct snd_soc_dai_driver mt2701_afe_pcm_dais[] = { { .name = "PCM_BT_UL", .id = MT2701_MEMIF_ULBT, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .capture = { .stream_name = "ULBT", .channels_min = 1, @@ -982,6 +970,8 @@ static const struct snd_soc_component_driver mt2701_afe_pcm_dai_component = { .num_dapm_widgets = ARRAY_SIZE(mt2701_afe_pcm_widgets), .dapm_routes = mt2701_afe_pcm_routes, .num_dapm_routes = ARRAY_SIZE(mt2701_afe_pcm_routes), + .suspend = mtk_afe_suspend, + .resume = mtk_afe_resume, }; static const struct mtk_base_memif_data memif_data[MT2701_MEMIF_NUM] = { diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index 0ee29255e731..461e4de8c918 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -533,8 +533,6 @@ static struct snd_soc_dai_driver mt8173_afe_pcm_dais[] = { { .name = "DL1", /* downlink 1 */ .id = MT8173_AFE_MEMIF_DL1, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .playback = { .stream_name = "DL1", .channels_min = 1, @@ -546,8 +544,6 @@ static struct snd_soc_dai_driver mt8173_afe_pcm_dais[] = { }, { .name = "VUL", /* voice uplink */ .id = MT8173_AFE_MEMIF_VUL, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .capture = { .stream_name = "VUL", .channels_min = 1, @@ -584,8 +580,6 @@ static struct snd_soc_dai_driver mt8173_afe_hdmi_dais[] = { { .name = "HDMI", .id = MT8173_AFE_MEMIF_HDMI, - .suspend = mtk_afe_dai_suspend, - .resume = mtk_afe_dai_resume, .playback = { .stream_name = "HDMI", .channels_min = 2, @@ -681,12 +675,16 @@ static const struct snd_soc_component_driver mt8173_afe_pcm_dai_component = { .num_dapm_widgets = ARRAY_SIZE(mt8173_afe_pcm_widgets), .dapm_routes = mt8173_afe_pcm_routes, .num_dapm_routes = ARRAY_SIZE(mt8173_afe_pcm_routes), + .suspend = mtk_afe_suspend, + .resume = mtk_afe_resume, }; static const struct snd_soc_component_driver mt8173_afe_hdmi_dai_component = { .name = "mt8173-afe-hdmi-dai", .dapm_routes = mt8173_afe_hdmi_routes, .num_dapm_routes = ARRAY_SIZE(mt8173_afe_hdmi_routes), + .suspend = mtk_afe_suspend, + .resume = mtk_afe_resume, }; static const char *aud_clks[MT8173_CLK_NUM] = { -- cgit v1.2.3 From 45cfa792f6608dc1b3e0fdc354716e87a40a747d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:07 +0900 Subject: ASoC: samsung: s3c24xx-i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/875zh7ym48.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/samsung/s3c24xx-i2s.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c index 92bdaf0878f8..60bfaed5f7a6 100644 --- a/sound/soc/samsung/s3c24xx-i2s.c +++ b/sound/soc/samsung/s3c24xx-i2s.c @@ -361,7 +361,7 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) } #ifdef CONFIG_PM -static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) +static int s3c24xx_i2s_suspend(struct snd_soc_component *component) { s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); @@ -373,7 +373,7 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) return 0; } -static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) +static int s3c24xx_i2s_resume(struct snd_soc_component *component) { int ret; @@ -408,8 +408,6 @@ static const struct snd_soc_dai_ops s3c24xx_i2s_dai_ops = { static struct snd_soc_dai_driver s3c24xx_i2s_dai = { .probe = s3c24xx_i2s_probe, - .suspend = s3c24xx_i2s_suspend, - .resume = s3c24xx_i2s_resume, .playback = { .channels_min = 2, .channels_max = 2, @@ -425,6 +423,8 @@ static struct snd_soc_dai_driver s3c24xx_i2s_dai = { static const struct snd_soc_component_driver s3c24xx_i2s_component = { .name = "s3c24xx-i2s", + .suspend = s3c24xx_i2s_suspend, + .resume = s3c24xx_i2s_resume, }; static int s3c24xx_iis_dev_probe(struct platform_device *pdev) -- cgit v1.2.3 From 79a5cf90f8719c3f69a0dc53efebb38da654512f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:13 +0900 Subject: ASoC: samsung: spdif: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/874kwrym42.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/samsung/spdif.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c index 805c57986e0b..1a9f08a50394 100644 --- a/sound/soc/samsung/spdif.c +++ b/sound/soc/samsung/spdif.c @@ -91,6 +91,12 @@ struct samsung_spdif_info { static struct snd_dmaengine_dai_dma_data spdif_stereo_out; static struct samsung_spdif_info spdif_info; +static inline struct samsung_spdif_info +*component_to_info(struct snd_soc_component *component) +{ + return snd_soc_component_get_drvdata(component); +} + static inline struct samsung_spdif_info *to_info(struct snd_soc_dai *cpu_dai) { return snd_soc_dai_get_drvdata(cpu_dai); @@ -290,9 +296,9 @@ static void spdif_shutdown(struct snd_pcm_substream *substream, } #ifdef CONFIG_PM -static int spdif_suspend(struct snd_soc_dai *cpu_dai) +static int spdif_suspend(struct snd_soc_component *component) { - struct samsung_spdif_info *spdif = to_info(cpu_dai); + struct samsung_spdif_info *spdif = component_to_info(component); u32 con = spdif->saved_con; dev_dbg(spdif->dev, "Entered %s\n", __func__); @@ -307,9 +313,9 @@ static int spdif_suspend(struct snd_soc_dai *cpu_dai) return 0; } -static int spdif_resume(struct snd_soc_dai *cpu_dai) +static int spdif_resume(struct snd_soc_component *component) { - struct samsung_spdif_info *spdif = to_info(cpu_dai); + struct samsung_spdif_info *spdif = component_to_info(component); dev_dbg(spdif->dev, "Entered %s\n", __func__); @@ -343,12 +349,12 @@ static struct snd_soc_dai_driver samsung_spdif_dai = { SNDRV_PCM_RATE_96000), .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = &spdif_dai_ops, - .suspend = spdif_suspend, - .resume = spdif_resume, }; static const struct snd_soc_component_driver samsung_spdif_component = { .name = "samsung-spdif", + .suspend = spdif_suspend, + .resume = spdif_resume, }; static int spdif_probe(struct platform_device *pdev) -- cgit v1.2.3 From 4a58fb71b5799328ea4ec84f3caee2fd4419404d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:18 +0900 Subject: ASoC: sti: sti_uniperif: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/8736cbym3x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/sti/sti_uniperif.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c index ee4a0151e63e..7b9169f04d6e 100644 --- a/sound/soc/sti/sti_uniperif.c +++ b/sound/soc/sti/sti_uniperif.c @@ -308,9 +308,9 @@ int sti_uniperiph_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai) +static int sti_uniperiph_suspend(struct snd_soc_component *component) { - struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai); + struct sti_uniperiph_data *priv = snd_soc_component_get_drvdata(component); struct uniperif *uni = priv->dai_data.uni; int ret; @@ -330,9 +330,9 @@ static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai) return ret; } -static int sti_uniperiph_dai_resume(struct snd_soc_dai *dai) +static int sti_uniperiph_resume(struct snd_soc_component *component) { - struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai); + struct sti_uniperiph_data *priv = snd_soc_component_get_drvdata(component); struct uniperif *uni = priv->dai_data.uni; int ret; @@ -370,12 +370,12 @@ static int sti_uniperiph_dai_probe(struct snd_soc_dai *dai) static const struct snd_soc_dai_driver sti_uniperiph_dai_template = { .probe = sti_uniperiph_dai_probe, - .suspend = sti_uniperiph_dai_suspend, - .resume = sti_uniperiph_dai_resume }; static const struct snd_soc_component_driver sti_uniperiph_dai_component = { .name = "sti_cpu_dai", + .suspend = sti_uniperiph_suspend, + .resume = sti_uniperiph_resume }; static int sti_uniperiph_cpu_dai_of(struct device_node *node, -- cgit v1.2.3 From 78dbafbd04ddcc3a21879c4403c57d979689a3fe Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:26 +0900 Subject: ASoC: ti: omap-mcpdm: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/871rrvym3p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/ti/omap-mcpdm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/ti/omap-mcpdm.c b/sound/soc/ti/omap-mcpdm.c index b8c8290265c7..a726cd7a8252 100644 --- a/sound/soc/ti/omap-mcpdm.c +++ b/sound/soc/ti/omap-mcpdm.c @@ -458,11 +458,11 @@ static int omap_mcpdm_remove(struct snd_soc_dai *dai) } #ifdef CONFIG_PM_SLEEP -static int omap_mcpdm_suspend(struct snd_soc_dai *dai) +static int omap_mcpdm_suspend(struct snd_soc_component *component) { - struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); + struct omap_mcpdm *mcpdm = snd_soc_component_get_drvdata(component); - if (dai->active) { + if (component->active) { omap_mcpdm_stop(mcpdm); omap_mcpdm_close_streams(mcpdm); } @@ -476,15 +476,15 @@ static int omap_mcpdm_suspend(struct snd_soc_dai *dai) return 0; } -static int omap_mcpdm_resume(struct snd_soc_dai *dai) +static int omap_mcpdm_resume(struct snd_soc_component *component) { - struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); + struct omap_mcpdm *mcpdm = snd_soc_component_get_drvdata(component); if (mcpdm->pm_active_count) { while (mcpdm->pm_active_count--) pm_runtime_get_sync(mcpdm->dev); - if (dai->active) { + if (component->active) { omap_mcpdm_open_streams(mcpdm); omap_mcpdm_start(mcpdm); } @@ -504,8 +504,6 @@ static int omap_mcpdm_resume(struct snd_soc_dai *dai) static struct snd_soc_dai_driver omap_mcpdm_dai = { .probe = omap_mcpdm_probe, .remove = omap_mcpdm_remove, - .suspend = omap_mcpdm_suspend, - .resume = omap_mcpdm_resume, .probe_order = SND_SOC_COMP_ORDER_LATE, .remove_order = SND_SOC_COMP_ORDER_EARLY, .playback = { @@ -527,6 +525,8 @@ static struct snd_soc_dai_driver omap_mcpdm_dai = { static const struct snd_soc_component_driver omap_mcpdm_component = { .name = "omap-mcpdm", + .suspend = omap_mcpdm_suspend, + .resume = omap_mcpdm_resume, }; void omap_mcpdm_configure_dn_offsets(struct snd_soc_pcm_runtime *rtd, -- cgit v1.2.3 From 9b79b1cd164f4ec64dc0847b03297095e39cdee9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:31 +0900 Subject: ASoC: uniphier: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87zhejx7j4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-cpu.c | 31 +++++++++++++++++++++++++++---- sound/soc/uniphier/aio-ld11.c | 18 ------------------ sound/soc/uniphier/aio-pxs2.c | 14 -------------- sound/soc/uniphier/aio.h | 2 -- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index 2ae582a99b63..fdaa6522720f 100644 --- a/sound/soc/uniphier/aio-cpu.c +++ b/sound/soc/uniphier/aio-cpu.c @@ -420,25 +420,37 @@ int uniphier_aio_dai_remove(struct snd_soc_dai *dai) } EXPORT_SYMBOL_GPL(uniphier_aio_dai_remove); -int uniphier_aio_dai_suspend(struct snd_soc_dai *dai) +static void uniphier_aio_dai_suspend(struct snd_soc_dai *dai) { struct uniphier_aio *aio = uniphier_priv(dai); + if (!dai->active) + return; + aio->chip->num_wup_aios--; if (!aio->chip->num_wup_aios) { reset_control_assert(aio->chip->rst); clk_disable_unprepare(aio->chip->clk); } +} + +static int uniphier_aio_suspend(struct snd_soc_component *component) +{ + struct snd_soc_dai *dai; + for_each_component_dais(component, dai) + uniphier_aio_dai_suspend(dai); return 0; } -EXPORT_SYMBOL_GPL(uniphier_aio_dai_suspend); -int uniphier_aio_dai_resume(struct snd_soc_dai *dai) +static int uniphier_aio_dai_resume(struct snd_soc_dai *dai) { struct uniphier_aio *aio = uniphier_priv(dai); int ret, i; + if (!dai->active) + return 0; + if (!aio->chip->active) return 0; @@ -484,7 +496,16 @@ err_out_clock: return ret; } -EXPORT_SYMBOL_GPL(uniphier_aio_dai_resume); + +static int uniphier_aio_resume(struct snd_soc_component *component) +{ + struct snd_soc_dai *dai; + int ret = 0; + + for_each_component_dais(component, dai) + ret |= uniphier_aio_dai_resume(dai); + return ret; +} static int uniphier_aio_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) @@ -596,6 +617,8 @@ static const struct snd_soc_component_driver uniphier_aio_component = { .name = "uniphier-aio", .controls = uniphier_aio_controls, .num_controls = ARRAY_SIZE(uniphier_aio_controls), + .suspend = uniphier_aio_suspend, + .resume = uniphier_aio_resume, }; int uniphier_aio_probe(struct platform_device *pdev) diff --git a/sound/soc/uniphier/aio-ld11.c b/sound/soc/uniphier/aio-ld11.c index de962df245ba..8b44f8dc4970 100644 --- a/sound/soc/uniphier/aio-ld11.c +++ b/sound/soc/uniphier/aio-ld11.c @@ -218,8 +218,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_GNAME_HDMI, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_PCMOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -242,8 +240,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_PCMIN2, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .capture = { .stream_name = AUD_NAME_PCMIN2, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -257,8 +253,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_GNAME_LINE, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_PCMOUT2, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -279,8 +273,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_HPCMOUT1, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_HPCMOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -294,8 +286,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_PCMOUT3, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_PCMOUT3, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -309,8 +299,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_HIECOUT1, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_HIECOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -324,8 +312,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_EPCMOUT2, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_EPCMOUT2, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -341,8 +327,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_EPCMOUT3, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_EPCMOUT3, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -358,8 +342,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { .name = AUD_NAME_HIECCOMPOUT1, .probe = uniphier_aio_ld11_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .compress_new = snd_soc_new_compress, .playback = { .stream_name = AUD_NAME_HIECCOMPOUT1, diff --git a/sound/soc/uniphier/aio-pxs2.c b/sound/soc/uniphier/aio-pxs2.c index 69cd5b0af948..a1d05fe9d3c2 100644 --- a/sound/soc/uniphier/aio-pxs2.c +++ b/sound/soc/uniphier/aio-pxs2.c @@ -171,8 +171,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_GNAME_HDMI, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_HPCMOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -186,8 +184,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_GNAME_LINE, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_PCMOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -208,8 +204,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_GNAME_AUX, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_PCMOUT2, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -230,8 +224,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_NAME_HIECOUT1, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_HIECOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -245,8 +237,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_NAME_IECOUT1, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .playback = { .stream_name = AUD_NAME_IECOUT1, .formats = SNDRV_PCM_FMTBIT_S32_LE, @@ -260,8 +250,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_NAME_HIECCOMPOUT1, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .compress_new = snd_soc_new_compress, .playback = { .stream_name = AUD_NAME_HIECCOMPOUT1, @@ -274,8 +262,6 @@ static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { .name = AUD_NAME_IECCOMPOUT1, .probe = uniphier_aio_pxs2_probe, .remove = uniphier_aio_dai_remove, - .suspend = uniphier_aio_dai_suspend, - .resume = uniphier_aio_dai_resume, .compress_new = snd_soc_new_compress, .playback = { .stream_name = AUD_NAME_IECCOMPOUT1, diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index a7ff7e556429..694ac030950e 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -308,8 +308,6 @@ extern const struct snd_compr_ops uniphier_aio_compr_ops; int uniphier_aio_dai_probe(struct snd_soc_dai *dai); int uniphier_aio_dai_remove(struct snd_soc_dai *dai); -int uniphier_aio_dai_suspend(struct snd_soc_dai *dai); -int uniphier_aio_dai_resume(struct snd_soc_dai *dai); int uniphier_aio_probe(struct platform_device *pdev); int uniphier_aio_remove(struct platform_device *pdev); extern const struct snd_soc_dai_ops uniphier_aio_i2s_ops; -- cgit v1.2.3 From ef20061a34e0e6822cbfd20c11667ae23a96798d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:37 +0900 Subject: ASoC: dwc: dwc-i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87y2u3x7iy.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-i2s.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index 65112b9d8588..7eeca2150b2d 100644 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -390,10 +390,6 @@ static const struct snd_soc_dai_ops dw_i2s_dai_ops = { .set_fmt = dw_i2s_set_fmt, }; -static const struct snd_soc_component_driver dw_i2s_component = { - .name = "dw-i2s", -}; - #ifdef CONFIG_PM static int dw_i2s_runtime_suspend(struct device *dev) { @@ -413,26 +409,30 @@ static int dw_i2s_runtime_resume(struct device *dev) return 0; } -static int dw_i2s_suspend(struct snd_soc_dai *dai) +static int dw_i2s_suspend(struct snd_soc_component *component) { - struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); + struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component); if (dev->capability & DW_I2S_MASTER) clk_disable(dev->clk); return 0; } -static int dw_i2s_resume(struct snd_soc_dai *dai) +static int dw_i2s_resume(struct snd_soc_component *component) { - struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); + struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component); + struct snd_soc_dai *dai; if (dev->capability & DW_I2S_MASTER) clk_enable(dev->clk); - if (dai->playback_active) - dw_i2s_config(dev, SNDRV_PCM_STREAM_PLAYBACK); - if (dai->capture_active) - dw_i2s_config(dev, SNDRV_PCM_STREAM_CAPTURE); + for_each_component_dais(component, dai) { + if (dai->playback_active) + dw_i2s_config(dev, SNDRV_PCM_STREAM_PLAYBACK); + if (dai->capture_active) + dw_i2s_config(dev, SNDRV_PCM_STREAM_CAPTURE); + } + return 0; } @@ -441,6 +441,12 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) #define dw_i2s_resume NULL #endif +static const struct snd_soc_component_driver dw_i2s_component = { + .name = "dw-i2s", + .suspend = dw_i2s_suspend, + .resume = dw_i2s_resume, +}; + /* * The following tables allow a direct lookup of various parameters * defined in the I2S block's configuration in terms of sound system @@ -629,8 +635,6 @@ static int dw_i2s_probe(struct platform_device *pdev) return -ENOMEM; dw_i2s_dai->ops = &dw_i2s_dai_ops; - dw_i2s_dai->suspend = dw_i2s_suspend; - dw_i2s_dai->resume = dw_i2s_resume; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dev->i2s_base = devm_ioremap_resource(&pdev->dev, res); -- cgit v1.2.3 From 21385a4faa8469b129af56a8c5a9405e3189c787 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:42 +0900 Subject: ASoC: samsung: i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87wo9nx7it.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 9722940da6a4..a57bb989a0ef 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1024,14 +1024,14 @@ i2s_delay(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) } #ifdef CONFIG_PM -static int i2s_suspend(struct snd_soc_dai *dai) +static int i2s_suspend(struct snd_soc_component *component) { - return pm_runtime_force_suspend(dai->dev); + return pm_runtime_force_suspend(component->dev); } -static int i2s_resume(struct snd_soc_dai *dai) +static int i2s_resume(struct snd_soc_component *component) { - return pm_runtime_force_resume(dai->dev); + return pm_runtime_force_resume(component->dev); } #else #define i2s_suspend NULL @@ -1140,6 +1140,9 @@ static const struct snd_soc_component_driver samsung_i2s_component = { .dapm_routes = samsung_i2s_dapm_routes, .num_dapm_routes = ARRAY_SIZE(samsung_i2s_dapm_routes), + + .suspend = i2s_suspend, + .resume = i2s_resume, }; #define SAMSUNG_I2S_FMTS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \ @@ -1171,8 +1174,6 @@ static int i2s_alloc_dais(struct samsung_i2s_priv *priv, dai_drv->probe = samsung_i2s_dai_probe; dai_drv->remove = samsung_i2s_dai_remove; - dai_drv->suspend = i2s_suspend; - dai_drv->resume = i2s_resume; dai_drv->symmetric_rates = 1; dai_drv->ops = &samsung_i2s_dai_ops; -- cgit v1.2.3 From 2db023cdb386874c51f4219508bd2d5f0caa7ffa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:47 +0900 Subject: ASoC: ux500: ux500_msp_dai: remove unused DAI .suspend/.resume This patch removes unused DAI driver .suspend/.resume Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87v9p7x7io.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/ux500/ux500_msp_dai.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c index dec065fb3e54..21052378a32e 100644 --- a/sound/soc/ux500/ux500_msp_dai.c +++ b/sound/soc/ux500/ux500_msp_dai.c @@ -719,8 +719,6 @@ static const struct snd_soc_dai_ops ux500_msp_dai_ops[] = { static struct snd_soc_dai_driver ux500_msp_dai_drv = { .probe = ux500_msp_dai_probe, - .suspend = NULL, - .resume = NULL, .playback.channels_min = UX500_MSP_MIN_CHANNELS, .playback.channels_max = UX500_MSP_MAX_CHANNELS, .playback.rates = UX500_I2S_RATES, -- cgit v1.2.3 From 2c55f0be586a14a35f67baf76df4d5c7782ed36a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:52 +0900 Subject: ASoC: pxa: pxa-ssp: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can swtcih all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. This patch moves DAI driver .suspend/.resume to Component driver Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87tv4rx7ij.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index f37ea0fb4f3f..e615acaa0199 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -133,12 +133,12 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream, #ifdef CONFIG_PM -static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) +static int pxa_ssp_suspend(struct snd_soc_component *component) { - struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); + struct ssp_priv *priv = snd_soc_component_get_drvdata(component); struct ssp_device *ssp = priv->ssp; - if (!cpu_dai->active) + if (!component->active) clk_prepare_enable(ssp->clk); priv->cr0 = __raw_readl(ssp->mmio_base + SSCR0); @@ -151,9 +151,9 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) return 0; } -static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) +static int pxa_ssp_resume(struct snd_soc_component *component) { - struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); + struct ssp_priv *priv = snd_soc_component_get_drvdata(component); struct ssp_device *ssp = priv->ssp; uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE; @@ -165,7 +165,7 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) __raw_writel(priv->to, ssp->mmio_base + SSTO); __raw_writel(priv->psp, ssp->mmio_base + SSPSP); - if (cpu_dai->active) + if (component->active) pxa_ssp_enable(ssp); else clk_disable_unprepare(ssp->clk); @@ -850,8 +850,6 @@ static const struct snd_soc_dai_ops pxa_ssp_dai_ops = { static struct snd_soc_dai_driver pxa_ssp_dai = { .probe = pxa_ssp_probe, .remove = pxa_ssp_remove, - .suspend = pxa_ssp_suspend, - .resume = pxa_ssp_resume, .playback = { .channels_min = 1, .channels_max = 8, @@ -879,6 +877,8 @@ static const struct snd_soc_component_driver pxa_ssp_component = { .trigger = pxa2xx_soc_pcm_trigger, .pointer = pxa2xx_soc_pcm_pointer, .mmap = pxa2xx_soc_pcm_mmap, + .suspend = pxa_ssp_suspend, + .resume = pxa_ssp_resume, }; #ifdef CONFIG_OF -- cgit v1.2.3 From 0b1c89944207975dac17a176052b92780642b90b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:04:59 +0900 Subject: ASoC: pxa: pxa2xx-i2s: move .suspend/.resume to component There is no big difference at implementation for .suspend/.resume between DAI driver and Component driver. But because some driver is using DAI version, thus ALSA SoC needs to keep supporting it, hence, framework becoming verbose. If we can switch all DAI driver .suspend/.resume to Component driver, we can remove verbose code from ALSA SoC. Driver is getting its private data via dai->dev. But dai->dev and component->dev are same dev, thus, we can convert these. For same reason, we can convert dai->active to component->active if necessary. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87sgkbx7ic.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-i2s.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index d9d366a8df11..5f1c477b5833 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -261,7 +261,7 @@ static void pxa2xx_i2s_shutdown(struct snd_pcm_substream *substream, } #ifdef CONFIG_PM -static int pxa2xx_i2s_suspend(struct snd_soc_dai *dai) +static int pxa2xx_soc_pcm_suspend(struct snd_soc_component *component) { /* store registers */ pxa_i2s.sacr0 = SACR0; @@ -275,7 +275,7 @@ static int pxa2xx_i2s_suspend(struct snd_soc_dai *dai) return 0; } -static int pxa2xx_i2s_resume(struct snd_soc_dai *dai) +static int pxa2xx_soc_pcm_resume(struct snd_soc_component *component) { pxa_i2s_wait(); @@ -290,8 +290,8 @@ static int pxa2xx_i2s_resume(struct snd_soc_dai *dai) } #else -#define pxa2xx_i2s_suspend NULL -#define pxa2xx_i2s_resume NULL +#define pxa2xx_soc_pcm_suspend NULL +#define pxa2xx_soc_pcm_resume NULL #endif static int pxa2xx_i2s_probe(struct snd_soc_dai *dai) @@ -342,8 +342,6 @@ static const struct snd_soc_dai_ops pxa_i2s_dai_ops = { static struct snd_soc_dai_driver pxa_i2s_dai = { .probe = pxa2xx_i2s_probe, .remove = pxa2xx_i2s_remove, - .suspend = pxa2xx_i2s_suspend, - .resume = pxa2xx_i2s_resume, .playback = { .channels_min = 2, .channels_max = 2, @@ -370,6 +368,8 @@ static const struct snd_soc_component_driver pxa_i2s_component = { .trigger = pxa2xx_soc_pcm_trigger, .pointer = pxa2xx_soc_pcm_pointer, .mmap = pxa2xx_soc_pcm_mmap, + .suspend = pxa2xx_soc_pcm_suspend, + .resume = pxa2xx_soc_pcm_resume, }; static int pxa2xx_i2s_drv_probe(struct platform_device *pdev) -- cgit v1.2.3 From 450312b640f9c6caeeaf4bd8d4130f86ea27f456 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:05:03 +0900 Subject: ASoC: soc-core: remove DAI suspend/resume Historically, CPU and Codec were implemented different, but now it is merged as Component. ALSA SoC is supporting suspend/resume at DAI and Component level. The method is like below. 1) Suspend/Resume all CPU DAI if bus-control was 0 2) Suspend/Resume all Component 3) Suspend/Resume all CPU DAI if bus-control was 1 Historically 2) was Codec special operation. Because CPU and Codec were merged into Component, CPU suspend/resume has 3 chance to suspend(= 1/2/3), but Codec suspend/resume has 1 chance (= 2). Here, DAI side suspend/resume is caring bus-control, but no driver which is supporting suspend/resume is setting bus-control. This means 3) was never used. Here, used parameter for suspend/resume component->dev and dai->dev are same pointer. For that reason, we can merge DAI and Component suspend/resume. One note is that we should use 2), because it is caring BIAS level. This patch removes 1) and 3). Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87r1zvx7i8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc-dai.h | 2 -- sound/soc/soc-core.c | 41 ----------------------------------------- sound/soc/soc-dai.c | 12 ------------ 3 files changed, 55 deletions(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 939c73db6a03..2ccecf3e03d5 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -286,8 +286,6 @@ struct snd_soc_dai_driver { /* DAI driver callbacks */ int (*probe)(struct snd_soc_dai *dai); int (*remove)(struct snd_soc_dai *dai); - int (*suspend)(struct snd_soc_dai *dai); - int (*resume)(struct snd_soc_dai *dai); /* compress dai */ int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num); /* Optional Callback used at pcm creation*/ diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index acf6f141fd2d..b0ec3233125a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -558,16 +558,6 @@ int snd_soc_suspend(struct device *dev) if (card->suspend_pre) card->suspend_pre(card); - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (rtd->dai_link->ignore_suspend) - continue; - - if (!cpu_dai->driver->bus_control) - snd_soc_dai_suspend(cpu_dai); - } - /* close any waiting streams */ snd_soc_flush_all_delayed_work(card); @@ -639,16 +629,6 @@ int snd_soc_suspend(struct device *dev) } } - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (rtd->dai_link->ignore_suspend) - continue; - - if (cpu_dai->driver->bus_control) - snd_soc_dai_suspend(cpu_dai); - } - if (card->suspend_post) card->suspend_post(card); @@ -682,17 +662,6 @@ static void soc_resume_deferred(struct work_struct *work) if (card->resume_pre) card->resume_pre(card); - /* resume control bus DAIs */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (rtd->dai_link->ignore_suspend) - continue; - - if (cpu_dai->driver->bus_control) - snd_soc_dai_resume(cpu_dai); - } - for_each_card_components(card, component) { if (snd_soc_component_is_suspended(component)) snd_soc_component_resume(component); @@ -726,16 +695,6 @@ static void soc_resume_deferred(struct work_struct *work) } } - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - if (rtd->dai_link->ignore_suspend) - continue; - - if (!cpu_dai->driver->bus_control) - snd_soc_dai_resume(cpu_dai); - } - if (card->resume_post) card->resume_post(card); diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 1c7f63871c1d..51031e330179 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -354,18 +354,6 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai, return delay; } -void snd_soc_dai_suspend(struct snd_soc_dai *dai) -{ - if (dai->driver->suspend) - dai->driver->suspend(dai); -} - -void snd_soc_dai_resume(struct snd_soc_dai *dai) -{ - if (dai->driver->resume) - dai->driver->resume(dai); -} - int snd_soc_dai_probe(struct snd_soc_dai *dai) { if (dai->driver->probe) -- cgit v1.2.3 From 250a15cf575a655097151ad887cea02dd0977136 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 20 Jan 2020 10:05:07 +0900 Subject: ASoC: soc-core: remove bus_control Now, snd_soc_dai_driver::bus_control is used for how to resume. But, no driver which has bus_control has DAI driver suspend/resume support. This patch removes pointless bus_control from ALSA SoC. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87pnffx7i4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- include/sound/soc-dai.h | 1 - sound/soc/au1x/ac97c.c | 1 - sound/soc/au1x/psc-ac97.c | 1 - sound/soc/cirrus/ep93xx-ac97.c | 1 - sound/soc/fsl/fsl_ssi.c | 1 - sound/soc/fsl/imx-ssi.c | 1 - sound/soc/fsl/mpc5200_psc_ac97.c | 2 -- sound/soc/pxa/pxa2xx-ac97.c | 3 --- sound/soc/sh/hac.c | 1 - sound/soc/soc-core.c | 24 +++--------------------- sound/soc/tegra/tegra20_ac97.c | 1 - sound/soc/txx9/txx9aclc-ac97.c | 1 - 12 files changed, 3 insertions(+), 35 deletions(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 2ccecf3e03d5..eaaeb00e9e84 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -302,7 +302,6 @@ struct snd_soc_dai_driver { unsigned int symmetric_rates:1; unsigned int symmetric_channels:1; unsigned int symmetric_samplebits:1; - unsigned int bus_control:1; /* DAI is also used for the control bus */ /* probe ordering - for components with runtime dependencies */ int probe_order; diff --git a/sound/soc/au1x/ac97c.c b/sound/soc/au1x/ac97c.c index 0792c40e6cc1..73c6a0edb3d8 100644 --- a/sound/soc/au1x/ac97c.c +++ b/sound/soc/au1x/ac97c.c @@ -206,7 +206,6 @@ static int au1xac97c_dai_probe(struct snd_soc_dai *dai) static struct snd_soc_dai_driver au1xac97c_dai_driver = { .name = "alchemy-ac97c", - .bus_control = true, .probe = au1xac97c_dai_probe, .playback = { .rates = AC97_RATES, diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index 08bc04e2da2a..0227993c5da8 100644 --- a/sound/soc/au1x/psc-ac97.c +++ b/sound/soc/au1x/psc-ac97.c @@ -339,7 +339,6 @@ static const struct snd_soc_dai_ops au1xpsc_ac97_dai_ops = { }; static const struct snd_soc_dai_driver au1xpsc_ac97_dai_template = { - .bus_control = true, .probe = au1xpsc_ac97_probe, .playback = { .rates = AC97_RATES, diff --git a/sound/soc/cirrus/ep93xx-ac97.c b/sound/soc/cirrus/ep93xx-ac97.c index e21eaa1893d1..1c45fb9ff990 100644 --- a/sound/soc/cirrus/ep93xx-ac97.c +++ b/sound/soc/cirrus/ep93xx-ac97.c @@ -336,7 +336,6 @@ static const struct snd_soc_dai_ops ep93xx_ac97_dai_ops = { static struct snd_soc_dai_driver ep93xx_ac97_dai = { .name = "ep93xx-ac97", .id = 0, - .bus_control = true, .probe = ep93xx_ac97_dai_probe, .playback = { .stream_name = "AC97 Playback", diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 537dc69256f0..5c97269be346 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1136,7 +1136,6 @@ static const struct snd_soc_component_driver fsl_ssi_component = { }; static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { - .bus_control = true, .symmetric_channels = 1, .probe = fsl_ssi_dai_probe, .playback = { diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index 42031ba7da31..f8488e8f5f5b 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c @@ -373,7 +373,6 @@ static struct snd_soc_dai_driver imx_ssi_dai = { static struct snd_soc_dai_driver imx_ac97_dai = { .probe = imx_ssi_dai_probe, - .bus_control = true, .playback = { .stream_name = "AC97 Playback", .channels_min = 2, diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index e5b9c04d1565..a082ae636a4f 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -233,7 +233,6 @@ static const struct snd_soc_dai_ops psc_ac97_digital_ops = { static struct snd_soc_dai_driver psc_ac97_dai[] = { { .name = "mpc5200-psc-ac97.0", - .bus_control = true, .probe = psc_ac97_probe, .playback = { .stream_name = "AC97 Playback", @@ -253,7 +252,6 @@ static struct snd_soc_dai_driver psc_ac97_dai[] = { }, { .name = "mpc5200-psc-ac97.1", - .bus_control = true, .playback = { .stream_name = "AC97 SPDIF", .channels_min = 1, diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 22fe77955c2c..4240fde6aae8 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -157,7 +157,6 @@ static const struct snd_soc_dai_ops pxa_ac97_mic_dai_ops = { static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { { .name = "pxa2xx-ac97", - .bus_control = true, .playback = { .stream_name = "AC97 Playback", .channels_min = 2, @@ -174,7 +173,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { }, { .name = "pxa2xx-ac97-aux", - .bus_control = true, .playback = { .stream_name = "AC97 Aux Playback", .channels_min = 1, @@ -191,7 +189,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { }, { .name = "pxa2xx-ac97-mic", - .bus_control = true, .capture = { .stream_name = "AC97 Mic Capture", .channels_min = 1, diff --git a/sound/soc/sh/hac.c b/sound/soc/sh/hac.c index 17622ceb98c0..475fc984f8c5 100644 --- a/sound/soc/sh/hac.c +++ b/sound/soc/sh/hac.c @@ -270,7 +270,6 @@ static const struct snd_soc_dai_ops hac_dai_ops = { static struct snd_soc_dai_driver sh4_hac_dai[] = { { .name = "hac-dai.0", - .bus_control = true, .playback = { .rates = AC97_RATES, .formats = AC97_FMTS, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b0ec3233125a..f969a3b8c82b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -712,8 +712,6 @@ static void soc_resume_deferred(struct work_struct *work) int snd_soc_resume(struct device *dev) { struct snd_soc_card *card = dev_get_drvdata(dev); - bool bus_control = false; - struct snd_soc_pcm_runtime *rtd; struct snd_soc_component *component; /* If the card is not initialized yet there is nothing to do */ @@ -725,25 +723,9 @@ int snd_soc_resume(struct device *dev) if (component->active) pinctrl_pm_select_default_state(component->dev); - /* - * DAIs that also act as the control bus master might have other drivers - * hanging off them so need to resume immediately. Other drivers don't - * have that problem and may take a substantial amount of time to resume - * due to I/O costs and anti-pop so handle them out of line. - */ - for_each_card_rtds(card, rtd) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - - bus_control |= cpu_dai->driver->bus_control; - } - if (bus_control) { - dev_dbg(dev, "ASoC: Resuming control bus master immediately\n"); - soc_resume_deferred(&card->deferred_resume_work); - } else { - dev_dbg(dev, "ASoC: Scheduling resume work\n"); - if (!schedule_work(&card->deferred_resume_work)) - dev_err(dev, "ASoC: resume work item may be lost\n"); - } + dev_dbg(dev, "ASoC: Scheduling resume work\n"); + if (!schedule_work(&card->deferred_resume_work)) + dev_err(dev, "ASoC: resume work item may be lost\n"); return 0; } diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c index 09c8516d7c4d..06c728ae17ed 100644 --- a/sound/soc/tegra/tegra20_ac97.c +++ b/sound/soc/tegra/tegra20_ac97.c @@ -219,7 +219,6 @@ static int tegra20_ac97_probe(struct snd_soc_dai *dai) static struct snd_soc_dai_driver tegra20_ac97_dai = { .name = "tegra-ac97-pcm", - .bus_control = true, .probe = tegra20_ac97_probe, .playback = { .stream_name = "PCM Playback", diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c index bfaa9b3fda43..b1d9615f2375 100644 --- a/sound/soc/txx9/txx9aclc-ac97.c +++ b/sound/soc/txx9/txx9aclc-ac97.c @@ -148,7 +148,6 @@ static int txx9aclc_ac97_remove(struct snd_soc_dai *dai) } static struct snd_soc_dai_driver txx9aclc_ac97_dai = { - .bus_control = true, .probe = txx9aclc_ac97_probe, .remove = txx9aclc_ac97_remove, .playback = { -- cgit v1.2.3 From 08df0d9a00f7ca07511614dd3b137fadd2de56fc Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Fri, 17 Jan 2020 15:38:12 +0800 Subject: ASoC: max98090: revert "ASoC: max98090: fix lockdep warning" Commit 2dc98af62c32 ("ASoC: max98090: fix lockdep warning") introduced a helpful-less small lock: shdn_lock. Reverts the commit. Reasons: 1. Lockdep should not be happy by either the original or current code. From lockdep's point of view, there is a lock inversion anyway. Let d = dapm_mutex, c = controls_rwsem, s = shdn_lock, From the reported calling stack: lock acquisition order of snd_soc_register_card() is: d -> c. > snd_ctl_add_replace+0x3c/0x84 > dapm_create_or_share_kcontrol+0x24c/0x2e0 > snd_soc_dapm_new_widgets+0x308/0x594 > snd_soc_bind_card+0x80c/0xad4 > devm_snd_soc_register_card+0x34/0x6c If calling snd_soc_dapm_put_enum_double() in kcontrol's put (e.g. SOC_DAPM_ENUM_EXT), lock acquisition order is: c -> d. Note that, snd_soc_dapm_put_enum_double() acquires d. The possible lock inversion is always there if registering sound card and putting mixer control happen at the same time. In fact, it never happens because the control device don't show up to the userspace until the sound card build success. Commit 2dc98af62c32 ("ASoC: max98090: fix lockdep warning") changes the order to: c -> s -> d. The lock inversion is still there. 2. Commit 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers SHDN bit") designed to use dapm_mutex to protect SHDN bit. Use a separate lock breaks the protection. DAPM changes SHDN bit automatically when it finds the path. Thus, any code wants to change the SHDN bit, need to acquire the dapm_mutex first. > SND_SOC_DAPM_SUPPLY("SHDN", M98090_REG_DEVICE_SHUTDOWN, > M98090_SHDNN_SHIFT, 0, NULL, 0), Fixes: 2dc98af62c32 ("ASoC: max98090: fix lockdep warning") Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200117073814.82441-2-tzungbi@google.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 10 ++++------ sound/soc/codecs/max98090.h | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 454cb8e5b0a1..c01ce4a3f86d 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -52,14 +52,14 @@ static void max98090_shdn_restore_locked(struct max98090_priv *max98090) static void max98090_shdn_save(struct max98090_priv *max98090) { - mutex_lock(&max98090->shdn_lock); + mutex_lock(&max98090->component->card->dapm_mutex); max98090_shdn_save_locked(max98090); } static void max98090_shdn_restore(struct max98090_priv *max98090) { max98090_shdn_restore_locked(max98090); - mutex_unlock(&max98090->shdn_lock); + mutex_unlock(&max98090->component->card->dapm_mutex); } static int max98090_put_volsw(struct snd_kcontrol *kcontrol, @@ -2313,12 +2313,12 @@ static void max98090_pll_work(struct max98090_priv *max98090) */ /* Toggle shutdown OFF then ON */ - mutex_lock(&max98090->shdn_lock); + mutex_lock(&component->card->dapm_mutex); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, 0); snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, M98090_SHDNN_MASK); - mutex_unlock(&max98090->shdn_lock); + mutex_unlock(&component->card->dapm_mutex); for (i = 0; i < 10; ++i) { /* Give PLL time to lock */ @@ -2731,8 +2731,6 @@ static int max98090_i2c_probe(struct i2c_client *i2c, if (max98090 == NULL) return -ENOMEM; - mutex_init(&max98090->shdn_lock); - if (ACPI_HANDLE(&i2c->dev)) { acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, &i2c->dev); diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index dabd8be34a01..0a31708b7df7 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h @@ -1539,7 +1539,6 @@ struct max98090_priv { unsigned int pa2en; unsigned int sidetone; bool master; - struct mutex shdn_lock; int saved_count; int saved_shdn; }; -- cgit v1.2.3 From 839284e794822ebc8b66f32006a5d4cad863e1fb Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Fri, 17 Jan 2020 15:38:13 +0800 Subject: ASoC: dapm: add snd_soc_dapm_put_enum_double_locked Adds snd_soc_dapm_put_enum_double_locked() for those use cases if dapm_mutex has already locked. Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200117073814.82441-3-tzungbi@google.com Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 2 ++ sound/soc/soc-dapm.c | 54 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 1b6afbc1a4ed..2a306c6f3fbc 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -392,6 +392,8 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_put_enum_double_locked(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 442846f12cd4..bc20ad9abf8b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3441,17 +3441,8 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, } EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); -/** - * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback - * @kcontrol: mixer control - * @ucontrol: control element information - * - * Callback to set the value of a dapm enumerated double mixer control. - * - * Returns 0 for success. - */ -int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) +static int __snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, int locked) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct snd_soc_card *card = dapm->card; @@ -3474,7 +3465,9 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, mask |= e->mask << e->shift_r; } - mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); + if (!locked) + mutex_lock_nested(&card->dapm_mutex, + SND_SOC_DAPM_CLASS_RUNTIME); change = dapm_kcontrol_set_value(kcontrol, val); @@ -3496,15 +3489,50 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, card->update = NULL; } - mutex_unlock(&card->dapm_mutex); + if (!locked) + mutex_unlock(&card->dapm_mutex); if (ret > 0) soc_dpcm_runtime_update(card); return change; } + +/** + * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to set the value of a dapm enumerated double mixer control. + * + * Returns 0 for success. + */ +int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return __snd_soc_dapm_put_enum_double(kcontrol, ucontrol, 0); +} EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); +/** + * snd_soc_dapm_put_enum_double_locked - dapm enumerated double mixer set + * callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to set the value of a dapm enumerated double mixer control. + * Must acquire dapm_mutex before calling the function. + * + * Returns 0 for success. + */ +int snd_soc_dapm_put_enum_double_locked(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + dapm_assert_locked(snd_soc_dapm_kcontrol_dapm(kcontrol)); + return __snd_soc_dapm_put_enum_double(kcontrol, ucontrol, 1); +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double_locked); + /** * snd_soc_dapm_info_pin_switch - Info for a pin switch * -- cgit v1.2.3 From 294b7380ffe88d4a0626af1fee5843a3db0c913c Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Fri, 17 Jan 2020 15:38:14 +0800 Subject: ASoC: max98090: fix deadlock in max98090_dapm_put_enum_double() Commit 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers SHDN bit") uses dapm_mutex to protect SHDN bit. However, snd_soc_dapm_put_enum_double() in max98090_dapm_put_enum_double() acquires the dapm_mutex again which cause a deadlock. Use snd_soc_dapm_put_enum_double_locked() instead to fix the deadlock. Fixes: 62d5ae4cafb7 ("ASoC: max98090: save and restore SHDN when changing sensitive registers SHDN bit") Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/20200117073814.82441-4-tzungbi@google.com Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index c01ce4a3f86d..0313e1183167 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -88,7 +88,7 @@ static int max98090_dapm_put_enum_double(struct snd_kcontrol *kcontrol, int ret; max98090_shdn_save(max98090); - ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); + ret = snd_soc_dapm_put_enum_double_locked(kcontrol, ucontrol); max98090_shdn_restore(max98090); return ret; -- cgit v1.2.3 From 26aa19174f0d1837cb268b744f6dcb013265ab03 Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Tue, 14 Jan 2020 16:01:50 +0100 Subject: ASoC: dt-bindings: rt5645: add suppliers The rt5645 and rt5650 have two suppliers, document them. Signed-off-by: Matthias Brugger Link: https://lore.kernel.org/r/20200114150151.8537-1-matthias.bgg@kernel.org Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/rt5645.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5645.txt b/Documentation/devicetree/bindings/sound/rt5645.txt index a03f9a872a71..41a62fd2ae1f 100644 --- a/Documentation/devicetree/bindings/sound/rt5645.txt +++ b/Documentation/devicetree/bindings/sound/rt5645.txt @@ -10,6 +10,10 @@ Required properties: - interrupts : The CODEC's interrupt output. +- avdd-supply: Power supply for AVDD, providing 1.8V. + +- cpvdd-supply: Power supply for CPVDD, providing 3.5V. + Optional properties: - hp-detect-gpios: -- cgit v1.2.3 From f289e55c6eeb4391101a42334e8c69bf8c9fe987 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Thu, 16 Jan 2020 13:46:37 +0800 Subject: ASoC: Add MediaTek MT6660 Speaker Amp Driver The MT6660 is a boosted BTL class-D amplifier with V/I sensing. A built-in DC-DC step-up converter is used to provide efficient power for class-D amplifier with multi-level class-G operation. The digital audio interface supports I2S, left-justified, right-justified, TDM and DSP A/B format for audio in with a data out used for chip information like voltage sense and current sense, which are able to be monitored via DATAO through proper Signed-off-by: Jeff Chang Link: https://lore.kernel.org/r/1579153597-23286-1-git-send-email-richtek.jeff.chang@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 10 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/mt6660.c | 509 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/mt6660.h | 77 +++++++ 4 files changed, 598 insertions(+) create mode 100644 sound/soc/codecs/mt6660.c create mode 100644 sound/soc/codecs/mt6660.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index de3f13dafc3c..52c51a9c5505 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -125,6 +125,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ML26124 if I2C select SND_SOC_MT6351 if MTK_PMIC_WRAP select SND_SOC_MT6358 if MTK_PMIC_WRAP + select SND_SOC_MT6660 if I2C select SND_SOC_NAU8540 if I2C select SND_SOC_NAU8810 if I2C select SND_SOC_NAU8822 if I2C @@ -1573,6 +1574,15 @@ config SND_SOC_MT6358 Enable support for the platform which uses MT6358 as external codec device. +config SND_SOC_MT6660 + tristate "Mediatek MT6660 Speaker Amplifier" + depends on I2C + help + MediaTek MT6660 is a smart power amplifier which contain + speaker protection, multi-band DRC, equalizer functions. + Select N if you don't have MT6660 on board. + Select M to build this as module. + config SND_SOC_NAU8540 tristate "Nuvoton Technology Corporation NAU85L40 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 751f2b4d095b..7bd87a6371cf 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -123,6 +123,7 @@ snd-soc-msm8916-analog-objs := msm8916-wcd-analog.o snd-soc-msm8916-digital-objs := msm8916-wcd-digital.o snd-soc-mt6351-objs := mt6351.o snd-soc-mt6358-objs := mt6358.o +snd-soc-mt6660-objs := mt6660.o snd-soc-nau8540-objs := nau8540.o snd-soc-nau8810-objs := nau8810.o snd-soc-nau8822-objs := nau8822.o @@ -419,6 +420,7 @@ obj-$(CONFIG_SND_SOC_MSM8916_WCD_ANALOG) +=snd-soc-msm8916-analog.o obj-$(CONFIG_SND_SOC_MSM8916_WCD_DIGITAL) +=snd-soc-msm8916-digital.o obj-$(CONFIG_SND_SOC_MT6351) += snd-soc-mt6351.o obj-$(CONFIG_SND_SOC_MT6358) += snd-soc-mt6358.o +obj-$(CONFIG_SND_SOC_MT6660) += snd-soc-mt6660.o obj-$(CONFIG_SND_SOC_NAU8540) += snd-soc-nau8540.o obj-$(CONFIG_SND_SOC_NAU8810) += snd-soc-nau8810.o obj-$(CONFIG_SND_SOC_NAU8822) += snd-soc-nau8822.o diff --git a/sound/soc/codecs/mt6660.c b/sound/soc/codecs/mt6660.c new file mode 100644 index 000000000000..a36c416caad4 --- /dev/null +++ b/sound/soc/codecs/mt6660.c @@ -0,0 +1,509 @@ +// SPDX-License-Identifier: GPL-2.0 // + +// Copyright (c) 2019 MediaTek Inc. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mt6660.h" + +struct reg_size_table { + u32 addr; + u8 size; +}; + +static const struct reg_size_table mt6660_reg_size_table[] = { + { MT6660_REG_HPF1_COEF, 4 }, + { MT6660_REG_HPF2_COEF, 4 }, + { MT6660_REG_TDM_CFG3, 2 }, + { MT6660_REG_RESV17, 2 }, + { MT6660_REG_RESV23, 2 }, + { MT6660_REG_SIGMAX, 2 }, + { MT6660_REG_DEVID, 2 }, + { MT6660_REG_HCLIP_CTRL, 2 }, + { MT6660_REG_DA_GAIN, 2 }, +}; + +static int mt6660_get_reg_size(uint32_t addr) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(mt6660_reg_size_table); i++) { + if (mt6660_reg_size_table[i].addr == addr) + return mt6660_reg_size_table[i].size; + } + return 1; +} + +static int mt6660_reg_write(void *context, unsigned int reg, unsigned int val) +{ + struct mt6660_chip *chip = context; + int size = mt6660_get_reg_size(reg); + u8 reg_data[4]; + int i, ret; + + for (i = 0; i < size; i++) + reg_data[size - i - 1] = (val >> (8 * i)) & 0xff; + + ret = i2c_smbus_write_i2c_block_data(chip->i2c, reg, size, reg_data); + return ret; +} + +static int mt6660_reg_read(void *context, unsigned int reg, unsigned int *val) +{ + struct mt6660_chip *chip = context; + int size = mt6660_get_reg_size(reg); + int i, ret; + u8 data[4]; + u32 reg_data = 0; + + ret = i2c_smbus_read_i2c_block_data(chip->i2c, reg, size, data); + if (ret < 0) + return ret; + for (i = 0; i < size; i++) { + reg_data <<= 8; + reg_data |= data[i]; + } + *val = reg_data; + return 0; +} + +static const struct regmap_config mt6660_regmap_config = { + .reg_bits = 8, + .val_bits = 32, + .reg_write = mt6660_reg_write, + .reg_read = mt6660_reg_read, +}; + +static int mt6660_codec_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event == SND_SOC_DAPM_POST_PMU) + usleep_range(1000, 1100); + return 0; +} + +static int mt6660_codec_classd_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + int ret; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dev_dbg(component->dev, + "%s: before classd turn on\n", __func__); + /* config to adaptive mode */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_BST_CTRL, 0x03, 0x03); + if (ret < 0) { + dev_err(component->dev, "config mode adaptive fail\n"); + return ret; + } + break; + case SND_SOC_DAPM_POST_PMU: + /* voltage sensing enable */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_RESV7, 0x04, 0x04); + if (ret < 0) { + dev_err(component->dev, + "enable voltage sensing fail\n"); + return ret; + } + dev_dbg(component->dev, "Amp on\n"); + break; + case SND_SOC_DAPM_PRE_PMD: + dev_dbg(component->dev, "Amp off\n"); + /* voltage sensing disable */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_RESV7, 0x04, 0x00); + if (ret < 0) { + dev_err(component->dev, + "disable voltage sensing fail\n"); + return ret; + } + /* pop-noise improvement 1 */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_RESV10, 0x10, 0x10); + if (ret < 0) { + dev_err(component->dev, + "pop-noise improvement 1 fail\n"); + return ret; + } + break; + case SND_SOC_DAPM_POST_PMD: + dev_dbg(component->dev, + "%s: after classd turn off\n", __func__); + /* pop-noise improvement 2 */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_RESV10, 0x10, 0x00); + if (ret < 0) { + dev_err(component->dev, + "pop-noise improvement 2 fail\n"); + return ret; + } + /* config to off mode */ + ret = snd_soc_component_update_bits(component, + MT6660_REG_BST_CTRL, 0x03, 0x00); + if (ret < 0) { + dev_err(component->dev, "config mode off fail\n"); + return ret; + } + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget mt6660_component_dapm_widgets[] = { + SND_SOC_DAPM_DAC_E("DAC", NULL, MT6660_REG_PLL_CFG1, + 0, 1, mt6660_codec_dac_event, SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_ADC("VI ADC", NULL, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_PGA("PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_OUT_DRV_E("ClassD", MT6660_REG_SYSTEM_CTRL, 2, 0, + NULL, 0, mt6660_codec_classd_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_OUTPUT("OUTP"), + SND_SOC_DAPM_OUTPUT("OUTN"), +}; + +static const struct snd_soc_dapm_route mt6660_component_dapm_routes[] = { + { "DAC", NULL, "aif_playback" }, + { "PGA", NULL, "DAC" }, + { "ClassD", NULL, "PGA" }, + { "OUTP", NULL, "ClassD" }, + { "OUTN", NULL, "ClassD" }, + { "VI ADC", NULL, "ClassD" }, + { "aif_capture", NULL, "VI ADC" }, +}; + +static int mt6660_component_get_volsw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct mt6660_chip *chip = (struct mt6660_chip *) + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = chip->chip_rev & 0x0f; + return 0; +} + +static const DECLARE_TLV_DB_SCALE(vol_ctl_tlv, -1155, 5, 0); + +static const struct snd_kcontrol_new mt6660_component_snd_controls[] = { + SOC_SINGLE_TLV("Digital Volume", MT6660_REG_VOL_CTRL, 0, 255, + 1, vol_ctl_tlv), + SOC_SINGLE("Hard Clip Switch", MT6660_REG_HCLIP_CTRL, 8, 1, 0), + SOC_SINGLE("Clip Switch", MT6660_REG_SPS_CTRL, 0, 1, 0), + SOC_SINGLE("Boost Mode", MT6660_REG_BST_CTRL, 0, 3, 0), + SOC_SINGLE("DRE Switch", MT6660_REG_DRE_CTRL, 0, 1, 0), + SOC_SINGLE("DC Protect Switch", MT6660_REG_DC_PROTECT_CTRL, 3, 1, 0), + SOC_SINGLE("Data Output Left Channel Selection", + MT6660_REG_DATAO_SEL, 3, 7, 0), + SOC_SINGLE("Data Output Right Channel Selection", + MT6660_REG_DATAO_SEL, 0, 7, 0), + SOC_SINGLE_EXT("T0 SEL", MT6660_REG_CALI_T0, 0, 7, 0, + snd_soc_get_volsw, NULL), + SOC_SINGLE_EXT("Chip Rev", MT6660_REG_DEVID, 8, 15, 0, + mt6660_component_get_volsw, NULL), +}; + +static int _mt6660_chip_power_on(struct mt6660_chip *chip, int on_off) +{ + return regmap_write_bits(chip->regmap, MT6660_REG_SYSTEM_CTRL, + 0x01, on_off ? 0x00 : 0x01); +} + +static int mt6660_component_probe(struct snd_soc_component *component) +{ + struct mt6660_chip *chip = snd_soc_component_get_drvdata(component); + + dev_dbg(component->dev, "%s\n", __func__); + snd_soc_component_init_regmap(component, chip->regmap); + + return 0; +} + +static void mt6660_component_remove(struct snd_soc_component *component) +{ + dev_dbg(component->dev, "%s\n", __func__); + snd_soc_component_exit_regmap(component); +} + +static const struct snd_soc_component_driver mt6660_component_driver = { + .probe = mt6660_component_probe, + .remove = mt6660_component_remove, + + .controls = mt6660_component_snd_controls, + .num_controls = ARRAY_SIZE(mt6660_component_snd_controls), + .dapm_widgets = mt6660_component_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(mt6660_component_dapm_widgets), + .dapm_routes = mt6660_component_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(mt6660_component_dapm_routes), + + .idle_bias_on = false, /* idle_bias_off = true */ +}; + +static int mt6660_component_aif_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) +{ + int word_len = params_physical_width(hw_params); + int aud_bit = params_width(hw_params); + u16 reg_data = 0; + int ret; + + dev_dbg(dai->dev, "%s: ++\n", __func__); + dev_dbg(dai->dev, "format: 0x%08x\n", params_format(hw_params)); + dev_dbg(dai->dev, "rate: 0x%08x\n", params_rate(hw_params)); + dev_dbg(dai->dev, "word_len: %d, aud_bit: %d\n", word_len, aud_bit); + if (word_len > 32 || word_len < 16) { + dev_err(dai->dev, "not supported word length\n"); + return -ENOTSUPP; + } + switch (aud_bit) { + case 16: + reg_data = 3; + break; + case 18: + reg_data = 2; + break; + case 20: + reg_data = 1; + break; + case 24: + case 32: + reg_data = 0; + break; + default: + return -ENOTSUPP; + } + ret = snd_soc_component_update_bits(dai->component, + MT6660_REG_SERIAL_CFG1, 0xc0, (reg_data << 6)); + if (ret < 0) { + dev_err(dai->dev, "config aud bit fail\n"); + return ret; + } + ret = snd_soc_component_update_bits(dai->component, + MT6660_REG_TDM_CFG3, 0x3f0, word_len << 4); + if (ret < 0) { + dev_err(dai->dev, "config word len fail\n"); + return ret; + } + dev_dbg(dai->dev, "%s: --\n", __func__); + return 0; +} + +static const struct snd_soc_dai_ops mt6660_component_aif_ops = { + .hw_params = mt6660_component_aif_hw_params, +}; + +#define STUB_RATES SNDRV_PCM_RATE_8000_192000 +#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_U16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_U24_LE | \ + SNDRV_PCM_FMTBIT_S32_LE | \ + SNDRV_PCM_FMTBIT_U32_LE) + +static struct snd_soc_dai_driver mt6660_codec_dai = { + .name = "mt6660-aif", + .playback = { + .stream_name = "aif_playback", + .channels_min = 1, + .channels_max = 2, + .rates = STUB_RATES, + .formats = STUB_FORMATS, + }, + .capture = { + .stream_name = "aif_capture", + .channels_min = 1, + .channels_max = 2, + .rates = STUB_RATES, + .formats = STUB_FORMATS, + }, + /* dai properties */ + .symmetric_rates = 1, + .symmetric_channels = 1, + .symmetric_samplebits = 1, + /* dai operations */ + .ops = &mt6660_component_aif_ops, +}; + +static int _mt6660_chip_id_check(struct mt6660_chip *chip) +{ + int ret; + unsigned int val; + + ret = regmap_read(chip->regmap, MT6660_REG_DEVID, &val); + if (ret < 0) + return ret; + val &= 0x0ff0; + if (val != 0x00e0 && val != 0x01e0) { + dev_err(chip->dev, "%s id(%x) not match\n", __func__, val); + return -ENODEV; + } + return 0; +} + +static int _mt6660_chip_sw_reset(struct mt6660_chip *chip) +{ + int ret; + + /* turn on main pll first, then trigger reset */ + ret = regmap_write(chip->regmap, MT6660_REG_SYSTEM_CTRL, 0x00); + if (ret < 0) + return ret; + ret = regmap_write(chip->regmap, MT6660_REG_SYSTEM_CTRL, 0x80); + if (ret < 0) + return ret; + msleep(30); + return 0; +} + +static int _mt6660_read_chip_revision(struct mt6660_chip *chip) +{ + int ret; + unsigned int val; + + ret = regmap_read(chip->regmap, MT6660_REG_DEVID, &val); + if (ret < 0) { + dev_err(chip->dev, "get chip revision fail\n"); + return ret; + } + chip->chip_rev = val&0xff; + dev_info(chip->dev, "%s chip_rev = %x\n", __func__, chip->chip_rev); + return 0; +} + +static int mt6660_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct mt6660_chip *chip = NULL; + int ret; + + dev_dbg(&client->dev, "%s\n", __func__); + chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + chip->i2c = client; + chip->dev = &client->dev; + mutex_init(&chip->io_lock); + i2c_set_clientdata(client, chip); + + chip->regmap = devm_regmap_init(&client->dev, + NULL, chip, &mt6660_regmap_config); + if (IS_ERR(chip->regmap)) { + ret = PTR_ERR(chip->regmap); + dev_err(&client->dev, "failed to initialise regmap: %d\n", ret); + return ret; + } + + /* chip reset first */ + ret = _mt6660_chip_sw_reset(chip); + if (ret < 0) { + dev_err(chip->dev, "chip reset fail\n"); + goto probe_fail; + } + /* chip power on */ + ret = _mt6660_chip_power_on(chip, 1); + if (ret < 0) { + dev_err(chip->dev, "chip power on 2 fail\n"); + goto probe_fail; + } + /* chip devid check */ + ret = _mt6660_chip_id_check(chip); + if (ret < 0) { + dev_err(chip->dev, "chip id check fail\n"); + goto probe_fail; + } + /* chip revision get */ + ret = _mt6660_read_chip_revision(chip); + if (ret < 0) { + dev_err(chip->dev, "read chip revision fail\n"); + goto probe_fail; + } + pm_runtime_set_active(chip->dev); + pm_runtime_enable(chip->dev); + + ret = devm_snd_soc_register_component(chip->dev, + &mt6660_component_driver, + &mt6660_codec_dai, 1); + return ret; +probe_fail: + _mt6660_chip_power_on(chip, 0); + mutex_destroy(&chip->io_lock); + return ret; +} + +static int mt6660_i2c_remove(struct i2c_client *client) +{ + struct mt6660_chip *chip = i2c_get_clientdata(client); + + pm_runtime_disable(chip->dev); + pm_runtime_set_suspended(chip->dev); + mutex_destroy(&chip->io_lock); + return 0; +} + +static int __maybe_unused mt6660_i2c_runtime_suspend(struct device *dev) +{ + struct mt6660_chip *chip = dev_get_drvdata(dev); + + dev_dbg(dev, "enter low power mode\n"); + return regmap_update_bits(chip->regmap, + MT6660_REG_SYSTEM_CTRL, 0x01, 0x01); +} + +static int __maybe_unused mt6660_i2c_runtime_resume(struct device *dev) +{ + struct mt6660_chip *chip = dev_get_drvdata(dev); + + dev_dbg(dev, "exit low power mode\n"); + return regmap_update_bits(chip->regmap, + MT6660_REG_SYSTEM_CTRL, 0x01, 0x00); +} + +static const struct dev_pm_ops mt6660_dev_pm_ops = { + SET_RUNTIME_PM_OPS(mt6660_i2c_runtime_suspend, + mt6660_i2c_runtime_resume, NULL) +}; + +static const struct of_device_id __maybe_unused mt6660_of_id[] = { + { .compatible = "mediatek,mt6660",}, + {}, +}; +MODULE_DEVICE_TABLE(of, mt6660_of_id); + +static const struct i2c_device_id mt6660_i2c_id[] = { + {"mt6660", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(i2c, mt6660_i2c_id); + +static struct i2c_driver mt6660_i2c_driver = { + .driver = { + .name = "mt6660", + .of_match_table = of_match_ptr(mt6660_of_id), + .pm = &mt6660_dev_pm_ops, + }, + .probe = mt6660_i2c_probe, + .remove = mt6660_i2c_remove, + .id_table = mt6660_i2c_id, +}; +module_i2c_driver(mt6660_i2c_driver); + +MODULE_AUTHOR("Jeff Chang "); +MODULE_DESCRIPTION("MT6660 SPKAMP Driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0.7_G"); diff --git a/sound/soc/codecs/mt6660.h b/sound/soc/codecs/mt6660.h new file mode 100644 index 000000000000..054a3c56ec1f --- /dev/null +++ b/sound/soc/codecs/mt6660.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#ifndef __SND_SOC_MT6660_H +#define __SND_SOC_MT6660_H + +#include +#include + +#pragma pack(push, 1) +struct mt6660_platform_data { + u8 init_setting_num; + u32 *init_setting_addr; + u32 *init_setting_mask; + u32 *init_setting_val; +}; + +struct mt6660_chip { + struct i2c_client *i2c; + struct device *dev; + struct platform_device *param_dev; + struct mt6660_platform_data plat_data; + struct mutex io_lock; + struct regmap *regmap; + u16 chip_rev; +}; +#pragma pack(pop) + +#define MT6660_REG_DEVID (0x00) +#define MT6660_REG_SYSTEM_CTRL (0x03) +#define MT6660_REG_IRQ_STATUS1 (0x05) +#define MT6660_REG_ADDA_CLOCK (0x07) +#define MT6660_REG_SERIAL_CFG1 (0x10) +#define MT6660_REG_DATAO_SEL (0x12) +#define MT6660_REG_TDM_CFG3 (0x15) +#define MT6660_REG_HPF_CTRL (0x18) +#define MT6660_REG_HPF1_COEF (0x1A) +#define MT6660_REG_HPF2_COEF (0x1B) +#define MT6660_REG_PATH_BYPASS (0x1E) +#define MT6660_REG_WDT_CTRL (0x20) +#define MT6660_REG_HCLIP_CTRL (0x24) +#define MT6660_REG_VOL_CTRL (0x29) +#define MT6660_REG_SPS_CTRL (0x30) +#define MT6660_REG_SIGMAX (0x33) +#define MT6660_REG_CALI_T0 (0x3F) +#define MT6660_REG_BST_CTRL (0x40) +#define MT6660_REG_PROTECTION_CFG (0x46) +#define MT6660_REG_DA_GAIN (0x4c) +#define MT6660_REG_AUDIO_IN2_SEL (0x50) +#define MT6660_REG_SIG_GAIN (0x51) +#define MT6660_REG_PLL_CFG1 (0x60) +#define MT6660_REG_DRE_CTRL (0x68) +#define MT6660_REG_DRE_THDMODE (0x69) +#define MT6660_REG_DRE_CORASE (0x6B) +#define MT6660_REG_PWM_CTRL (0x70) +#define MT6660_REG_DC_PROTECT_CTRL (0x74) +#define MT6660_REG_ADC_USB_MODE (0x7c) +#define MT6660_REG_INTERNAL_CFG (0x88) +#define MT6660_REG_RESV0 (0x98) +#define MT6660_REG_RESV1 (0x99) +#define MT6660_REG_RESV2 (0x9A) +#define MT6660_REG_RESV3 (0x9B) +#define MT6660_REG_RESV6 (0xA2) +#define MT6660_REG_RESV7 (0xA3) +#define MT6660_REG_RESV10 (0xB0) +#define MT6660_REG_RESV11 (0xB1) +#define MT6660_REG_RESV16 (0xB6) +#define MT6660_REG_RESV17 (0xB7) +#define MT6660_REG_RESV19 (0xB9) +#define MT6660_REG_RESV21 (0xBB) +#define MT6660_REG_RESV23 (0xBD) +#define MT6660_REG_RESV31 (0xD3) +#define MT6660_REG_RESV40 (0xE0) + +#endif /* __SND_SOC_MT6660_H */ -- cgit v1.2.3 From ef7d84caa5928b40b1c93a26dbe5a3f12737c6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Gro=C3=9Fe?= Date: Wed, 22 Jan 2020 19:01:06 +0100 Subject: ALSA: hda - Add docking station support for Lenovo Thinkpad T420s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lenovo Thinkpad T420s uses the same codec as T420, so apply the same quirk to enable audio output on a docking station. Signed-off-by: Peter Große Link: https://lore.kernel.org/r/20200122180106.9351-1-pegro@friiks.de Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 90aa0f400a57..1e20e85e9b46 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -922,6 +922,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = { SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x21ce, "Lenovo T420", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), + SND_PCI_QUIRK(0x17aa, 0x21d2, "Lenovo T420s", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD), -- cgit v1.2.3 From 5396c4bd9fd8429050f6191663b6c491e6402da2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Jan 2020 00:00:50 +0000 Subject: ALSA: cs46xx: fix spelling mistake "to" -> "too" There is a spelling mistake in a dev_err message. Fix it. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200123000050.2831088-1-colin.king@canonical.com Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/dsp_spos_scb_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 2c5c9d4c1d94..6b536fc23ca6 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -1293,7 +1293,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, if (src_scb == NULL) { if (ins->nsrc_scb >= DSP_MAX_SRC_NR) { dev_err(chip->card->dev, - "dsp_spos: to many SRC instances\n!"); + "dsp_spos: too many SRC instances\n!"); return NULL; } -- cgit v1.2.3 From ca34fa860fd34b0b22ff829aeb51884429a3a753 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 22 Jan 2020 10:41:43 +0000 Subject: ASoC: madera: Correct DMIC only input hook ups Both the data and clock should be connected to both the left and right inputs for DMIC only inputs, add the missing routes. Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200122104143.16725-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l85.c | 6 ++++++ sound/soc/codecs/cs47l90.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/sound/soc/codecs/cs47l85.c b/sound/soc/codecs/cs47l85.c index a69311008134..33ecff45bd6e 100644 --- a/sound/soc/codecs/cs47l85.c +++ b/sound/soc/codecs/cs47l85.c @@ -2005,12 +2005,18 @@ static const struct snd_soc_dapm_route cs47l85_dapm_routes[] = { { "IN3R", NULL, "IN3R Mode" }, { "IN4L", NULL, "DMICCLK4" }, + { "IN4L", NULL, "DMICDAT4" }, + { "IN4R", NULL, "DMICCLK4" }, { "IN4R", NULL, "DMICDAT4" }, { "IN5L", NULL, "DMICCLK5" }, + { "IN5L", NULL, "DMICDAT5" }, + { "IN5R", NULL, "DMICCLK5" }, { "IN5R", NULL, "DMICDAT5" }, { "IN6L", NULL, "DMICCLK6" }, + { "IN6L", NULL, "DMICDAT6" }, + { "IN6R", NULL, "DMICCLK6" }, { "IN6R", NULL, "DMICDAT6" }, MADERA_MIXER_ROUTES("OUT1L", "HPOUT1L"), diff --git a/sound/soc/codecs/cs47l90.c b/sound/soc/codecs/cs47l90.c index 5448e4506741..16504d26dcf2 100644 --- a/sound/soc/codecs/cs47l90.c +++ b/sound/soc/codecs/cs47l90.c @@ -1935,12 +1935,18 @@ static const struct snd_soc_dapm_route cs47l90_dapm_routes[] = { { "IN2R", NULL, "IN2R Mode" }, { "IN3L", NULL, "DMICCLK3" }, + { "IN3L", NULL, "DMICDAT3" }, + { "IN3R", NULL, "DMICCLK3" }, { "IN3R", NULL, "DMICDAT3" }, { "IN4L", NULL, "DMICCLK4" }, + { "IN4L", NULL, "DMICDAT4" }, + { "IN4R", NULL, "DMICCLK4" }, { "IN4R", NULL, "DMICDAT4" }, { "IN5L", NULL, "DMICCLK5" }, + { "IN5L", NULL, "DMICDAT5" }, + { "IN5R", NULL, "DMICCLK5" }, { "IN5R", NULL, "DMICDAT5" }, MADERA_MIXER_ROUTES("OUT1L", "HPOUT1L"), -- cgit v1.2.3 From 15adb20f64c302b31e10ad50f22bb224052ce1df Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Wed, 22 Jan 2020 19:12:54 +0100 Subject: ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug Definitions for idisp snd_soc_dai_links within skl_hda_dsp_common are missing platform component. Add it to address following bug reported by KASAN: [ 10.538502] BUG: KASAN: global-out-of-bounds in skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538509] Write of size 8 at addr ffffffffc0606840 by task systemd-udevd/299 (...) [ 10.538519] Call Trace: [ 10.538524] dump_stack+0x62/0x95 [ 10.538528] print_address_description+0x2f5/0x3b0 [ 10.538532] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538535] __kasan_report+0x134/0x191 [ 10.538538] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538542] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538544] kasan_report+0x12/0x20 [ 10.538546] __asan_store8+0x57/0x90 [ 10.538550] skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538553] platform_drv_probe+0x51/0xb0 [ 10.538556] really_probe+0x311/0x600 [ 10.538559] driver_probe_device+0x87/0x1b0 [ 10.538562] device_driver_attach+0x8f/0xa0 [ 10.538565] ? device_driver_attach+0xa0/0xa0 [ 10.538567] __driver_attach+0x102/0x1a0 [ 10.538569] ? device_driver_attach+0xa0/0xa0 [ 10.538572] bus_for_each_dev+0xe8/0x160 [ 10.538574] ? subsys_dev_iter_exit+0x10/0x10 [ 10.538577] ? preempt_count_sub+0x18/0xc0 [ 10.538580] ? _raw_write_unlock+0x1f/0x40 [ 10.538582] driver_attach+0x2b/0x30 [ 10.538585] bus_add_driver+0x251/0x340 [ 10.538588] driver_register+0xd3/0x1c0 [ 10.538590] __platform_driver_register+0x6c/0x80 [ 10.538592] ? 0xffffffffc03e8000 [ 10.538595] skl_hda_audio_init+0x1c/0x1000 [snd_soc_skl_hda_dsp] [ 10.538598] do_one_initcall+0xd0/0x36a [ 10.538600] ? trace_event_raw_event_initcall_finish+0x160/0x160 [ 10.538602] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538605] ? __kasan_kmalloc+0xcc/0xe0 [ 10.538607] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538609] ? kasan_poison_shadow+0x2f/0x40 [ 10.538612] ? __asan_register_globals+0x65/0x80 [ 10.538615] do_init_module+0xf9/0x36f [ 10.538619] load_module+0x398e/0x4590 [ 10.538625] ? module_frob_arch_sections+0x20/0x20 [ 10.538628] ? __kasan_check_write+0x14/0x20 [ 10.538630] ? kernel_read+0x9a/0xc0 [ 10.538632] ? __kasan_check_write+0x14/0x20 [ 10.538634] ? kernel_read_file+0x1d3/0x3c0 [ 10.538638] ? cap_capable+0xca/0x110 [ 10.538642] __do_sys_finit_module+0x190/0x1d0 [ 10.538644] ? __do_sys_finit_module+0x190/0x1d0 [ 10.538646] ? __x64_sys_init_module+0x50/0x50 [ 10.538649] ? expand_files+0x380/0x380 [ 10.538652] ? __kasan_check_write+0x14/0x20 [ 10.538654] ? fput_many+0x20/0xc0 [ 10.538658] __x64_sys_finit_module+0x43/0x50 [ 10.538660] do_syscall_64+0xce/0x700 [ 10.538662] ? syscall_return_slowpath+0x230/0x230 [ 10.538665] ? __do_page_fault+0x51e/0x640 [ 10.538668] ? __kasan_check_read+0x11/0x20 [ 10.538670] ? prepare_exit_to_usermode+0xc7/0x200 [ 10.538673] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: a78959f407e6 ("ASoC: Intel: skl_hda_dsp_common: use modern dai_link style") Signed-off-by: Cezary Rojewski Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200122181254.22801-1-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/intel/boards/skl_hda_dsp_common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.c b/sound/soc/intel/boards/skl_hda_dsp_common.c index eb419e1ec42b..78ff5f24c40e 100644 --- a/sound/soc/intel/boards/skl_hda_dsp_common.c +++ b/sound/soc/intel/boards/skl_hda_dsp_common.c @@ -41,16 +41,19 @@ int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device) return 0; } -SND_SOC_DAILINK_DEFS(idisp1, - DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")), +SND_SOC_DAILINK_DEF(idisp1_cpu, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); +SND_SOC_DAILINK_DEF(idisp1_codec, DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); -SND_SOC_DAILINK_DEFS(idisp2, - DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")), +SND_SOC_DAILINK_DEF(idisp2_cpu, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); +SND_SOC_DAILINK_DEF(idisp2_codec, DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); -SND_SOC_DAILINK_DEFS(idisp3, - DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")), +SND_SOC_DAILINK_DEF(idisp3_cpu, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); +SND_SOC_DAILINK_DEF(idisp3_codec, DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); SND_SOC_DAILINK_DEF(analog_cpu, @@ -83,21 +86,21 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { .id = 1, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp1), + SND_SOC_DAILINK_REG(idisp1_cpu, idisp1_codec, platform), }, { .name = "iDisp2", .id = 2, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp2), + SND_SOC_DAILINK_REG(idisp2_cpu, idisp2_codec, platform), }, { .name = "iDisp3", .id = 3, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp3), + SND_SOC_DAILINK_REG(idisp3_cpu, idisp3_codec, platform), }, { .name = "Analog Playback and Capture", -- cgit v1.2.3 From 8ce1cbd6ce0b1bda0c980c64fee4c1e1378355f1 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 22 Jan 2020 20:07:52 +0100 Subject: ASoC: topology: fix soc_tplg_fe_link_create() - link->dobj initialization order The code which checks the return value for snd_soc_add_dai_link() call in soc_tplg_fe_link_create() moved the snd_soc_add_dai_link() call before link->dobj members initialization. While it does not affect the latest kernels, the old soc-core.c code in the stable kernels is affected. The snd_soc_add_dai_link() function uses the link->dobj.type member to check, if the link structure is valid. Reorder the link->dobj initialization to make things work again. It's harmless for the recent code (and the structure should be properly initialized before other calls anyway). The problem is in stable linux-5.4.y since version 5.4.11 when the upstream commit 76d270364932 was applied. Fixes: 76d270364932 ("ASoC: topology: Check return value for snd_soc_add_dai_link()") Cc: Dragos Tarcatu Cc: Pierre-Louis Bossart Cc: Ranjani Sridharan Cc: Mark Brown Cc: Signed-off-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20200122190752.3081016-1-perex@perex.cz Signed-off-by: Mark Brown --- sound/soc/soc-topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 92e4f4d08bfa..4e1fe623c390 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1906,6 +1906,10 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, link->num_codecs = 1; link->num_platforms = 1; + link->dobj.index = tplg->index; + link->dobj.ops = tplg->ops; + link->dobj.type = SND_SOC_DOBJ_DAI_LINK; + if (strlen(pcm->pcm_name)) { link->name = kstrdup(pcm->pcm_name, GFP_KERNEL); link->stream_name = kstrdup(pcm->pcm_name, GFP_KERNEL); @@ -1942,9 +1946,6 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg, goto err; } - link->dobj.index = tplg->index; - link->dobj.ops = tplg->ops; - link->dobj.type = SND_SOC_DOBJ_DAI_LINK; list_add(&link->dobj.list, &tplg->comp->dobj_list); return 0; -- cgit v1.2.3 From b2333f7fcd950854afe9c428377e105425d5083a Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 22 Jan 2020 10:45:59 +0000 Subject: ASoC: madera: Correct some kernel doc Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200122104559.17043-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/codecs/madera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/madera.c b/sound/soc/codecs/madera.c index 2be64422adf9..7eccff62c3e1 100644 --- a/sound/soc/codecs/madera.c +++ b/sound/soc/codecs/madera.c @@ -4707,7 +4707,7 @@ EXPORT_SYMBOL_GPL(madera_fllhj_set_refclk); * * @component: Device to configure * @output: Output number - * @diff: True to set the output to differential mode + * @differential: True to set the output to differential mode * * Some systems use external analogue switches to connect more * analogue devices to the CODEC than are supported by the device. In -- cgit v1.2.3 From df31007400c3905ec15b1065241baf3864decbfa Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Wed, 15 Jan 2020 19:25:19 +0800 Subject: ASoC: rt1015: add rt1015 amplifier driver This is initial amplifier driver for rt1015. Signed-off-by: Jack Yu Link: https://lore.kernel.org/r/20200115112519.22050-1-jack.yu@realtek.com Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/rt1015.txt | 17 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt1015.c | 993 +++++++++++++++++++++ sound/soc/codecs/rt1015.h | 375 ++++++++ 5 files changed, 1393 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rt1015.txt create mode 100644 sound/soc/codecs/rt1015.c create mode 100644 sound/soc/codecs/rt1015.h diff --git a/Documentation/devicetree/bindings/sound/rt1015.txt b/Documentation/devicetree/bindings/sound/rt1015.txt new file mode 100644 index 000000000000..fcfd02d8d32f --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rt1015.txt @@ -0,0 +1,17 @@ +RT1015 Mono Class D Audio Amplifier + +This device supports I2C only. + +Required properties: + +- compatible : "realtek,rt1015". + +- reg : The I2C address of the device. + + +Example: + +rt1015: codec@28 { + compatible = "realtek,rt1015"; + reg = <0x28>; +}; diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 52c51a9c5505..c9eb683bd1b0 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -151,6 +151,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT286 if I2C select SND_SOC_RT298 if I2C select SND_SOC_RT1011 if I2C + select SND_SOC_RT1015 if I2C select SND_SOC_RT1305 if I2C select SND_SOC_RT1308 if I2C select SND_SOC_RT5514 if I2C @@ -970,6 +971,7 @@ config SND_SOC_RL6231 default y if SND_SOC_RT5677=y default y if SND_SOC_RT5682=y default y if SND_SOC_RT1011=y + default y if SND_SOC_RT1015=y default y if SND_SOC_RT1305=y default y if SND_SOC_RT1308=y default m if SND_SOC_RT5514=m @@ -986,6 +988,7 @@ config SND_SOC_RL6231 default m if SND_SOC_RT5677=m default m if SND_SOC_RT5682=m default m if SND_SOC_RT1011=m + default m if SND_SOC_RT1015=m default m if SND_SOC_RT1305=m default m if SND_SOC_RT1308=m @@ -1013,6 +1016,9 @@ config SND_SOC_RT298 config SND_SOC_RT1011 tristate +config SND_SOC_RT1015 + tristate + config SND_SOC_RT1305 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 7bd87a6371cf..ba1b4b3fa2da 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -154,6 +154,7 @@ snd-soc-rk3328-objs := rk3328_codec.o snd-soc-rl6231-objs := rl6231.o snd-soc-rl6347a-objs := rl6347a.o snd-soc-rt1011-objs := rt1011.o +snd-soc-rt1015-objs := rt1015.o snd-soc-rt1305-objs := rt1305.o snd-soc-rt1308-objs := rt1308.o snd-soc-rt1308-sdw-objs := rt1308-sdw.o @@ -451,6 +452,7 @@ obj-$(CONFIG_SND_SOC_RK3328) += snd-soc-rk3328.o obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o obj-$(CONFIG_SND_SOC_RT1011) += snd-soc-rt1011.o +obj-$(CONFIG_SND_SOC_RT1015) += snd-soc-rt1015.o obj-$(CONFIG_SND_SOC_RT1305) += snd-soc-rt1305.o obj-$(CONFIG_SND_SOC_RT1308) += snd-soc-rt1308.o obj-$(CONFIG_SND_SOC_RT1308_SDW) += snd-soc-rt1308-sdw.o diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c new file mode 100644 index 000000000000..4a9c5b54008f --- /dev/null +++ b/sound/soc/codecs/rt1015.c @@ -0,0 +1,993 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt1015.c -- RT1015 ALSA SoC audio amplifier driver +// +// Copyright 2019 Realtek Semiconductor Corp. +// +// Author: Jack Yu +// +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rl6231.h" +#include "rt1015.h" + +static const struct reg_default rt1015_reg[] = { + { 0x0000, 0x0000 }, + { 0x0004, 0xa000 }, + { 0x0006, 0x0003 }, + { 0x000a, 0x0802 }, + { 0x000c, 0x0020 }, + { 0x000e, 0x0000 }, + { 0x0010, 0x0000 }, + { 0x0012, 0x0000 }, + { 0x0020, 0x8000 }, + { 0x0022, 0x471b }, + { 0x006a, 0x0000 }, + { 0x006c, 0x4020 }, + { 0x0076, 0x0000 }, + { 0x0078, 0x0000 }, + { 0x007a, 0x0000 }, + { 0x007c, 0x10ec }, + { 0x007d, 0x1015 }, + { 0x00f0, 0x5000 }, + { 0x00f2, 0x0774 }, + { 0x00f3, 0x8400 }, + { 0x00f4, 0x0000 }, + { 0x0100, 0x0028 }, + { 0x0102, 0xff02 }, + { 0x0104, 0x8232 }, + { 0x0106, 0x200c }, + { 0x010c, 0x002f }, + { 0x010e, 0xc000 }, + { 0x0111, 0x0200 }, + { 0x0112, 0x0400 }, + { 0x0114, 0x0022 }, + { 0x0116, 0x0000 }, + { 0x0118, 0x0000 }, + { 0x011a, 0x0123 }, + { 0x011c, 0x4567 }, + { 0x0300, 0xdddd }, + { 0x0302, 0x0000 }, + { 0x0311, 0x9330 }, + { 0x0313, 0x0000 }, + { 0x0314, 0x0000 }, + { 0x031a, 0x00a0 }, + { 0x031c, 0x001f }, + { 0x031d, 0xffff }, + { 0x031e, 0x0000 }, + { 0x031f, 0x0000 }, + { 0x0321, 0x0000 }, + { 0x0322, 0x0000 }, + { 0x0328, 0x0000 }, + { 0x0329, 0x0000 }, + { 0x032a, 0x0000 }, + { 0x032b, 0x0000 }, + { 0x032c, 0x0000 }, + { 0x032d, 0x0000 }, + { 0x032e, 0x030e }, + { 0x0330, 0x0080 }, + { 0x0332, 0x0034 }, + { 0x0334, 0x0000 }, + { 0x0336, 0x0000 }, + { 0x0506, 0x04ff }, + { 0x0508, 0x0030 }, + { 0x050a, 0x0018 }, + { 0x0519, 0x307f }, + { 0x051a, 0xffff }, + { 0x051b, 0x4000 }, + { 0x051d, 0x0000 }, + { 0x051f, 0x0000 }, + { 0x0536, 0x1000 }, + { 0x0538, 0x0000 }, + { 0x053a, 0x0000 }, + { 0x053c, 0x0000 }, + { 0x053d, 0x0000 }, + { 0x053e, 0x0000 }, + { 0x053f, 0x0000 }, + { 0x0540, 0x0000 }, + { 0x0541, 0x0000 }, + { 0x0542, 0x0000 }, + { 0x0543, 0x0000 }, + { 0x0544, 0x0000 }, + { 0x0568, 0x0000 }, + { 0x056a, 0x0000 }, + { 0x1000, 0x0000 }, + { 0x1002, 0x6505 }, + { 0x1006, 0x5515 }, + { 0x1007, 0x003f }, + { 0x1009, 0x770f }, + { 0x100a, 0x01ff }, + { 0x100c, 0x0000 }, + { 0x100d, 0x0003 }, + { 0x1010, 0xa433 }, + { 0x1020, 0x0000 }, + { 0x1200, 0x3d02 }, + { 0x1202, 0x0813 }, + { 0x1204, 0x0211 }, + { 0x1206, 0x0000 }, + { 0x1208, 0x0000 }, + { 0x120a, 0x0000 }, + { 0x120c, 0x0000 }, + { 0x120e, 0x0000 }, + { 0x1210, 0x0000 }, + { 0x1212, 0x0000 }, + { 0x1300, 0x0701 }, + { 0x1302, 0x12f9 }, + { 0x1304, 0x3405 }, + { 0x1305, 0x0844 }, + { 0x1306, 0x1611 }, + { 0x1308, 0x555e }, + { 0x130a, 0x0000 }, + { 0x130c, 0x2400}, + { 0x130e, 0x7700 }, + { 0x130f, 0x0000 }, + { 0x1310, 0x0000 }, + { 0x1312, 0x0000 }, + { 0x1314, 0x0000 }, + { 0x1316, 0x0000 }, + { 0x1318, 0x0000 }, + { 0x131a, 0x0000 }, + { 0x1322, 0x0029 }, + { 0x1323, 0x4a52 }, + { 0x1324, 0x002c }, + { 0x1325, 0x0b02 }, + { 0x1326, 0x002d }, + { 0x1327, 0x6b5a }, + { 0x1328, 0x002e }, + { 0x1329, 0xcbb2 }, + { 0x132a, 0x0030 }, + { 0x132b, 0x2c0b }, + { 0x1330, 0x0031 }, + { 0x1331, 0x8c63 }, + { 0x1332, 0x0032 }, + { 0x1333, 0xecbb }, + { 0x1334, 0x0034 }, + { 0x1335, 0x4d13 }, + { 0x1336, 0x0037 }, + { 0x1337, 0x0dc3 }, + { 0x1338, 0x003d }, + { 0x1339, 0xef7b }, + { 0x133a, 0x0044 }, + { 0x133b, 0xd134 }, + { 0x133c, 0x0047 }, + { 0x133d, 0x91e4 }, + { 0x133e, 0x004d }, + { 0x133f, 0xc370 }, + { 0x1340, 0x0053 }, + { 0x1341, 0xf4fd }, + { 0x1342, 0x0060 }, + { 0x1343, 0x5816 }, + { 0x1344, 0x006c }, + { 0x1345, 0xbb2e }, + { 0x1346, 0x0072 }, + { 0x1347, 0xecbb }, + { 0x1348, 0x0076 }, + { 0x1349, 0x5d97 }, +}; + +static bool rt1015_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case RT1015_RESET: + case RT1015_CLK_DET: + case RT1015_SIL_DET: + case RT1015_VER_ID: + case RT1015_VENDOR_ID: + case RT1015_DEVICE_ID: + case RT1015_PRO_ALT: + case RT1015_DAC3: + case RT1015_VBAT_TEST_OUT1: + case RT1015_VBAT_TEST_OUT2: + case RT1015_VBAT_PROT_ATT: + case RT1015_VBAT_DET_CODE: + case RT1015_SMART_BST_CTRL1: + case RT1015_SPK_DC_DETECT1: + case RT1015_SPK_DC_DETECT4: + case RT1015_SPK_DC_DETECT5: + case RT1015_DC_CALIB_CLSD1: + case RT1015_DC_CALIB_CLSD5: + case RT1015_DC_CALIB_CLSD6: + case RT1015_DC_CALIB_CLSD7: + case RT1015_DC_CALIB_CLSD8: + case RT1015_S_BST_TIMING_INTER1: + return true; + + default: + return false; + } +} + +static bool rt1015_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case RT1015_RESET: + case RT1015_CLK2: + case RT1015_CLK3: + case RT1015_PLL1: + case RT1015_PLL2: + case RT1015_CLK_DET: + case RT1015_SIL_DET: + case RT1015_CUSTOMER_ID: + case RT1015_PCODE_FWVER: + case RT1015_VER_ID: + case RT1015_VENDOR_ID: + case RT1015_DEVICE_ID: + case RT1015_PAD_DRV1: + case RT1015_PAD_DRV2: + case RT1015_GAT_BOOST: + case RT1015_PRO_ALT: + case RT1015_MAN_I2C: + case RT1015_DAC1: + case RT1015_DAC2: + case RT1015_DAC3: + case RT1015_ADC1: + case RT1015_ADC2: + case RT1015_TDM_MASTER: + case RT1015_TDM_TCON: + case RT1015_TDM1_1: + case RT1015_TDM1_2: + case RT1015_TDM1_3: + case RT1015_TDM1_4: + case RT1015_TDM1_5: + case RT1015_MIXER1: + case RT1015_MIXER2: + case RT1015_ANA_PROTECT1: + case RT1015_ANA_CTRL_SEQ1: + case RT1015_ANA_CTRL_SEQ2: + case RT1015_VBAT_DET_DEB: + case RT1015_VBAT_VOLT_DET1: + case RT1015_VBAT_VOLT_DET2: + case RT1015_VBAT_TEST_OUT1: + case RT1015_VBAT_TEST_OUT2: + case RT1015_VBAT_PROT_ATT: + case RT1015_VBAT_DET_CODE: + case RT1015_PWR1: + case RT1015_PWR4: + case RT1015_PWR5: + case RT1015_PWR6: + case RT1015_PWR7: + case RT1015_PWR8: + case RT1015_PWR9: + case RT1015_CLASSD_SEQ: + case RT1015_SMART_BST_CTRL1: + case RT1015_SMART_BST_CTRL2: + case RT1015_ANA_CTRL1: + case RT1015_ANA_CTRL2: + case RT1015_SPK_VOL: + case RT1015_SHORT_DETTOP1: + case RT1015_SHORT_DETTOP2: + case RT1015_SPK_DC_DETECT1: + case RT1015_SPK_DC_DETECT2: + case RT1015_SPK_DC_DETECT3: + case RT1015_SPK_DC_DETECT4: + case RT1015_SPK_DC_DETECT5: + case RT1015_BAT_RPO_STEP1: + case RT1015_BAT_RPO_STEP2: + case RT1015_BAT_RPO_STEP3: + case RT1015_BAT_RPO_STEP4: + case RT1015_BAT_RPO_STEP5: + case RT1015_BAT_RPO_STEP6: + case RT1015_BAT_RPO_STEP7: + case RT1015_BAT_RPO_STEP8: + case RT1015_BAT_RPO_STEP9: + case RT1015_BAT_RPO_STEP10: + case RT1015_BAT_RPO_STEP11: + case RT1015_BAT_RPO_STEP12: + case RT1015_SPREAD_SPEC1: + case RT1015_SPREAD_SPEC2: + case RT1015_PAD_STATUS: + case RT1015_PADS_PULLING_CTRL1: + case RT1015_PADS_DRIVING: + case RT1015_SYS_RST1: + case RT1015_SYS_RST2: + case RT1015_SYS_GATING1: + case RT1015_TEST_MODE1: + case RT1015_TEST_MODE2: + case RT1015_TIMING_CTRL1: + case RT1015_PLL_INT: + case RT1015_TEST_OUT1: + case RT1015_DC_CALIB_CLSD1: + case RT1015_DC_CALIB_CLSD2: + case RT1015_DC_CALIB_CLSD3: + case RT1015_DC_CALIB_CLSD4: + case RT1015_DC_CALIB_CLSD5: + case RT1015_DC_CALIB_CLSD6: + case RT1015_DC_CALIB_CLSD7: + case RT1015_DC_CALIB_CLSD8: + case RT1015_DC_CALIB_CLSD9: + case RT1015_DC_CALIB_CLSD10: + case RT1015_CLSD_INTERNAL1: + case RT1015_CLSD_INTERNAL2: + case RT1015_CLSD_INTERNAL3: + case RT1015_CLSD_INTERNAL4: + case RT1015_CLSD_INTERNAL5: + case RT1015_CLSD_INTERNAL6: + case RT1015_CLSD_INTERNAL7: + case RT1015_CLSD_INTERNAL8: + case RT1015_CLSD_INTERNAL9: + case RT1015_CLSD_OCP_CTRL: + case RT1015_VREF_LV: + case RT1015_MBIAS1: + case RT1015_MBIAS2: + case RT1015_MBIAS3: + case RT1015_MBIAS4: + case RT1015_VREF_LV1: + case RT1015_S_BST_TIMING_INTER1: + case RT1015_S_BST_TIMING_INTER2: + case RT1015_S_BST_TIMING_INTER3: + case RT1015_S_BST_TIMING_INTER4: + case RT1015_S_BST_TIMING_INTER5: + case RT1015_S_BST_TIMING_INTER6: + case RT1015_S_BST_TIMING_INTER7: + case RT1015_S_BST_TIMING_INTER8: + case RT1015_S_BST_TIMING_INTER9: + case RT1015_S_BST_TIMING_INTER10: + case RT1015_S_BST_TIMING_INTER11: + case RT1015_S_BST_TIMING_INTER12: + case RT1015_S_BST_TIMING_INTER13: + case RT1015_S_BST_TIMING_INTER14: + case RT1015_S_BST_TIMING_INTER15: + case RT1015_S_BST_TIMING_INTER16: + case RT1015_S_BST_TIMING_INTER17: + case RT1015_S_BST_TIMING_INTER18: + case RT1015_S_BST_TIMING_INTER19: + case RT1015_S_BST_TIMING_INTER20: + case RT1015_S_BST_TIMING_INTER21: + case RT1015_S_BST_TIMING_INTER22: + case RT1015_S_BST_TIMING_INTER23: + case RT1015_S_BST_TIMING_INTER24: + case RT1015_S_BST_TIMING_INTER25: + case RT1015_S_BST_TIMING_INTER26: + case RT1015_S_BST_TIMING_INTER27: + case RT1015_S_BST_TIMING_INTER28: + case RT1015_S_BST_TIMING_INTER29: + case RT1015_S_BST_TIMING_INTER30: + case RT1015_S_BST_TIMING_INTER31: + case RT1015_S_BST_TIMING_INTER32: + case RT1015_S_BST_TIMING_INTER33: + case RT1015_S_BST_TIMING_INTER34: + case RT1015_S_BST_TIMING_INTER35: + case RT1015_S_BST_TIMING_INTER36: + return true; + + default: + return false; + } +} + +static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9525, 75, 0); + +static const char * const rt1015_din_source_select[] = { + "Left", + "Right", + "Left + Right average", +}; + +static SOC_ENUM_SINGLE_DECL(rt1015_mono_lr_sel, RT1015_PAD_DRV2, 4, + rt1015_din_source_select); + +static const char * const rt1015_boost_mode[] = { + "Bypass", "Adaptive", "Fixed Adaptive" +}; + +static const SOC_ENUM_SINGLE_DECL(rt1015_boost_mode_enum, 0, 0, + rt1015_boost_mode); + +static int rt1015_boost_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = rt1015->boost_mode; + + return 0; +} + +static int rt1015_boost_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + rt1015->boost_mode = ucontrol->value.integer.value[0]; + + switch (rt1015->boost_mode) { + case BYPASS: + snd_soc_component_update_bits(component, + RT1015_SMART_BST_CTRL1, RT1015_ABST_AUTO_EN_MASK | + RT1015_ABST_FIX_TGT_MASK | RT1015_BYPASS_SWR_REG_MASK, + RT1015_ABST_REG_MODE | RT1015_ABST_FIX_TGT_DIS | + RT1015_BYPASS_SWRREG_BYPASS); + break; + case ADAPTIVE: + snd_soc_component_update_bits(component, + RT1015_SMART_BST_CTRL1, RT1015_ABST_AUTO_EN_MASK | + RT1015_ABST_FIX_TGT_MASK | RT1015_BYPASS_SWR_REG_MASK, + RT1015_ABST_AUTO_MODE | RT1015_ABST_FIX_TGT_DIS | + RT1015_BYPASS_SWRREG_PASS); + break; + case FIXED_ADAPTIVE: + snd_soc_component_update_bits(component, + RT1015_SMART_BST_CTRL1, RT1015_ABST_AUTO_EN_MASK | + RT1015_ABST_FIX_TGT_MASK | RT1015_BYPASS_SWR_REG_MASK, + RT1015_ABST_AUTO_MODE | RT1015_ABST_FIX_TGT_EN | + RT1015_BYPASS_SWRREG_PASS); + break; + default: + dev_err(component->dev, "Unknown boost control.\n"); + } + + return 0; +} + +static int rt5518_bypass_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = rt1015->bypass_boost; + + return 0; +} + +static int rt5518_bypass_boost_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + if (!rt1015->dac_is_used) { + rt1015->bypass_boost = ucontrol->value.integer.value[0]; + if (rt1015->bypass_boost == 1) { + snd_soc_component_write(component, + RT1015_PWR4, 0x00b2); + snd_soc_component_write(component, + RT1015_CLSD_INTERNAL8, 0x2008); + snd_soc_component_write(component, + RT1015_CLSD_INTERNAL9, 0x0140); + snd_soc_component_write(component, + RT1015_GAT_BOOST, 0x00fe); + snd_soc_component_write(component, + RT1015_PWR_STATE_CTRL, 0x000d); + msleep(500); + snd_soc_component_write(component, + RT1015_PWR_STATE_CTRL, 0x000e); + } + } else + dev_err(component->dev, "DAC is being used!\n"); + + return 0; +} + +static const struct snd_kcontrol_new rt1015_snd_controls[] = { + SOC_SINGLE_TLV("DAC Playback Volume", RT1015_DAC1, RT1015_DAC_VOL_SFT, + 127, 0, dac_vol_tlv), + SOC_DOUBLE("DAC Playback Switch", RT1015_DAC3, + RT1015_DA_MUTE_SFT, RT1015_DVOL_MUTE_FLAG_SFT, 1, 1), + SOC_ENUM_EXT("Boost Mode", rt1015_boost_mode_enum, + rt1015_boost_mode_get, rt1015_boost_mode_put), + SOC_ENUM("Mono LR Select", rt1015_mono_lr_sel), + SOC_SINGLE_EXT("Bypass Boost", SND_SOC_NOPM, 0, 1, 0, + rt5518_bypass_boost_get, rt5518_bypass_boost_put), +}; + +static int rt1015_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, + struct snd_soc_dapm_widget *sink) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(source->dapm); + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + if (rt1015->sysclk_src == RT1015_SCLK_S_PLL) + return 1; + else + return 0; +} + +static int r1015_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + rt1015->dac_is_used = 1; + if (rt1015->bypass_boost == 0) { + snd_soc_component_write(component, + RT1015_SYS_RST1, 0x05f7); + snd_soc_component_write(component, + RT1015_GAT_BOOST, 0xacfe); + snd_soc_component_write(component, + RT1015_PWR9, 0xaa00); + snd_soc_component_write(component, + RT1015_GAT_BOOST, 0xecfe); + } else { + snd_soc_component_write(component, + RT1015_SYS_RST1, 0x05f7); + snd_soc_component_write(component, + RT1015_PWR_STATE_CTRL, 0x026e); + } + break; + + case SND_SOC_DAPM_POST_PMD: + if (rt1015->bypass_boost == 0) { + snd_soc_component_write(component, + RT1015_PWR9, 0xa800); + snd_soc_component_write(component, + RT1015_SYS_RST1, 0x05f5); + } else { + snd_soc_component_write(component, + RT1015_PWR_STATE_CTRL, 0x0268); + snd_soc_component_write(component, + RT1015_SYS_RST1, 0x05f5); + } + rt1015->dac_is_used = 0; + break; + + default: + break; + } + return 0; +} + +static const struct snd_soc_dapm_widget rt1015_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("LDO2", RT1015_PWR1, RT1015_PWR_LDO2_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("INT RC CLK", RT1015_PWR1, RT1015_PWR_INTCLK_BIT, + 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("ISENSE", RT1015_PWR1, RT1015_PWR_ISENSE_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("VSENSE", RT1015_PWR1, RT1015_PWR_VSENSE_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("PLL", RT1015_PWR1, RT1015_PWR_PLL_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("BG1 BG2", RT1015_PWR1, RT1015_PWR_BG_1_2_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("MBIAS BG", RT1015_PWR1, RT1015_PWR_MBIAS_BG_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("VBAT", RT1015_PWR1, RT1015_PWR_VBAT_BIT, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY("MBIAS", RT1015_PWR1, RT1015_PWR_MBIAS_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("ADCV", RT1015_PWR1, RT1015_PWR_ADCV_BIT, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY("MIXERV", RT1015_PWR1, RT1015_PWR_MIXERV_BIT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("SUMV", RT1015_PWR1, RT1015_PWR_SUMV_BIT, 0, NULL, + 0), + SND_SOC_DAPM_SUPPLY("VREFLV", RT1015_PWR1, RT1015_PWR_VREFLV_BIT, 0, + NULL, 0), + + SND_SOC_DAPM_AIF_IN("AIFRX", "AIF Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_DAC_E("DAC", NULL, RT1015_PWR1, RT1015_PWR_DAC_BIT, 0, + r1015_dac_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + + SND_SOC_DAPM_OUTPUT("SPO"), +}; + +static const struct snd_soc_dapm_route rt1015_dapm_routes[] = { + { "DAC", NULL, "AIFRX" }, + { "DAC", NULL, "LDO2" }, + { "DAC", NULL, "PLL", rt1015_is_sys_clk_from_pll}, + { "DAC", NULL, "INT RC CLK" }, + { "DAC", NULL, "ISENSE" }, + { "DAC", NULL, "VSENSE" }, + { "DAC", NULL, "BG1 BG2" }, + { "DAC", NULL, "MBIAS BG" }, + { "DAC", NULL, "VBAT" }, + { "DAC", NULL, "MBIAS" }, + { "DAC", NULL, "ADCV" }, + { "DAC", NULL, "MIXERV" }, + { "DAC", NULL, "SUMV" }, + { "DAC", NULL, "VREFLV" }, + { "SPO", NULL, "DAC" }, +}; + +static int rt1015_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + int pre_div, bclk_ms, frame_size; + unsigned int val_len = 0; + + rt1015->lrck = params_rate(params); + pre_div = rl6231_get_clk_info(rt1015->sysclk, rt1015->lrck); + if (pre_div < 0) { + dev_err(component->dev, "Unsupported clock rate\n"); + return -EINVAL; + } + + frame_size = snd_soc_params_to_frame_size(params); + if (frame_size < 0) { + dev_err(component->dev, "Unsupported frame size: %d\n", + frame_size); + return -EINVAL; + } + + bclk_ms = frame_size > 32; + rt1015->bclk = rt1015->lrck * (32 << bclk_ms); + + dev_dbg(component->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", + bclk_ms, pre_div, dai->id); + + dev_dbg(component->dev, "lrck is %dHz and pre_div is %d for iis %d\n", + rt1015->lrck, pre_div, dai->id); + + switch (params_width(params)) { + case 16: + break; + case 20: + val_len = RT1015_I2S_DL_20; + break; + case 24: + val_len = RT1015_I2S_DL_24; + break; + case 8: + val_len = RT1015_I2S_DL_8; + break; + default: + return -EINVAL; + } + + snd_soc_component_update_bits(component, RT1015_TDM_MASTER, + RT1015_I2S_DL_MASK, val_len); + snd_soc_component_update_bits(component, RT1015_CLK2, + RT1015_FS_PD_MASK, pre_div); + + return 0; +} + +static int rt1015_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_component *component = dai->component; + unsigned int reg_val = 0, reg_val2 = 0; + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + reg_val |= RT1015_TCON_TDM_MS_M; + break; + case SND_SOC_DAIFMT_CBS_CFS: + reg_val |= RT1015_TCON_TDM_MS_S; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + break; + case SND_SOC_DAIFMT_IB_NF: + reg_val2 |= RT1015_TDM_INV_BCLK; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + break; + + case SND_SOC_DAIFMT_LEFT_J: + reg_val |= RT1015_I2S_M_DF_LEFT; + break; + + case SND_SOC_DAIFMT_DSP_A: + reg_val |= RT1015_I2S_M_DF_PCM_A; + break; + + case SND_SOC_DAIFMT_DSP_B: + reg_val |= RT1015_I2S_M_DF_PCM_B; + break; + + default: + return -EINVAL; + } + + snd_soc_component_update_bits(component, RT1015_TDM_MASTER, + RT1015_TCON_TDM_MS_MASK | RT1015_I2S_M_DF_MASK, + reg_val); + snd_soc_component_update_bits(component, RT1015_TDM1_1, + RT1015_TDM_INV_BCLK_MASK, reg_val2); + + return 0; +} + +static int rt1015_set_component_sysclk(struct snd_soc_component *component, + int clk_id, int source, unsigned int freq, int dir) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + unsigned int reg_val = 0; + + if (freq == rt1015->sysclk && clk_id == rt1015->sysclk_src) + return 0; + + switch (clk_id) { + case RT1015_SCLK_S_MCLK: + reg_val |= RT1015_CLK_SYS_PRE_SEL_MCLK; + break; + + case RT1015_SCLK_S_PLL: + reg_val |= RT1015_CLK_SYS_PRE_SEL_PLL; + break; + + default: + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); + return -EINVAL; + } + + rt1015->sysclk = freq; + rt1015->sysclk_src = clk_id; + + dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", + freq, clk_id); + + snd_soc_component_update_bits(component, RT1015_CLK2, + RT1015_CLK_SYS_PRE_SEL_MASK, reg_val); + + return 0; +} + +static int rt1015_set_component_pll(struct snd_soc_component *component, + int pll_id, int source, unsigned int freq_in, + unsigned int freq_out) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + struct rl6231_pll_code pll_code; + int ret; + + if (!freq_in || !freq_out) { + dev_dbg(component->dev, "PLL disabled\n"); + + rt1015->pll_in = 0; + rt1015->pll_out = 0; + + return 0; + } + + if (source == rt1015->pll_src && freq_in == rt1015->pll_in && + freq_out == rt1015->pll_out) + return 0; + + switch (source) { + case RT1015_PLL_S_MCLK: + snd_soc_component_update_bits(component, RT1015_CLK2, + RT1015_PLL_SEL_MASK, RT1015_PLL_SEL_PLL_SRC2); + break; + + case RT1015_PLL_S_BCLK: + snd_soc_component_update_bits(component, RT1015_CLK2, + RT1015_PLL_SEL_MASK, RT1015_PLL_SEL_BCLK); + break; + + default: + dev_err(component->dev, "Unknown PLL Source %d\n", source); + return -EINVAL; + } + + ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); + if (ret < 0) { + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); + return ret; + } + + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", + pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), + pll_code.n_code, pll_code.k_code); + + snd_soc_component_write(component, RT1015_PLL1, + (pll_code.m_bp ? 0 : pll_code.m_code) << RT1015_PLL_M_SFT | + pll_code.m_bp << RT1015_PLL_M_BP_SFT | pll_code.n_code); + snd_soc_component_write(component, RT1015_PLL2, + pll_code.k_code); + + rt1015->pll_in = freq_in; + rt1015->pll_out = freq_out; + rt1015->pll_src = source; + + return 0; +} + +static int rt1015_probe(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = + snd_soc_component_get_drvdata(component); + + rt1015->component = component; + snd_soc_component_write(component, RT1015_BAT_RPO_STEP1, 0x061c); + + return 0; +} + +static void rt1015_remove(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regmap_write(rt1015->regmap, RT1015_RESET, 0); +} + +#define RT1015_STEREO_RATES SNDRV_PCM_RATE_8000_192000 +#define RT1015_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) + +struct snd_soc_dai_ops rt1015_aif_dai_ops = { + .hw_params = rt1015_hw_params, + .set_fmt = rt1015_set_dai_fmt, +}; + +struct snd_soc_dai_driver rt1015_dai[] = { + { + .name = "rt1015-aif", + .id = 0, + .playback = { + .stream_name = "AIF Playback", + .channels_min = 1, + .channels_max = 4, + .rates = RT1015_STEREO_RATES, + .formats = RT1015_FORMATS, + }, + } +}; + +#ifdef CONFIG_PM +static int rt1015_suspend(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regcache_cache_only(rt1015->regmap, true); + regcache_mark_dirty(rt1015->regmap); + + return 0; +} + +static int rt1015_resume(struct snd_soc_component *component) +{ + struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component); + + regcache_cache_only(rt1015->regmap, false); + regcache_sync(rt1015->regmap); + return 0; +} +#else +#define rt1015_suspend NULL +#define rt1015_resume NULL +#endif + +static const struct snd_soc_component_driver soc_component_dev_rt1015 = { + .probe = rt1015_probe, + .remove = rt1015_remove, + .suspend = rt1015_suspend, + .resume = rt1015_resume, + .controls = rt1015_snd_controls, + .num_controls = ARRAY_SIZE(rt1015_snd_controls), + .dapm_widgets = rt1015_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt1015_dapm_widgets), + .dapm_routes = rt1015_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt1015_dapm_routes), + .set_sysclk = rt1015_set_component_sysclk, + .set_pll = rt1015_set_component_pll, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + +static const struct regmap_config rt1015_regmap = { + .reg_bits = 16, + .val_bits = 16, + .max_register = RT1015_S_BST_TIMING_INTER36, + .volatile_reg = rt1015_volatile_register, + .readable_reg = rt1015_readable_register, + .cache_type = REGCACHE_RBTREE, + .reg_defaults = rt1015_reg, + .num_reg_defaults = ARRAY_SIZE(rt1015_reg), +}; + +static const struct i2c_device_id rt1015_i2c_id[] = { + { "rt1015", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, rt1015_i2c_id); + +#if defined(CONFIG_OF) +static const struct of_device_id rt1015_of_match[] = { + { .compatible = "realtek,rt1015", }, + {}, +}; +MODULE_DEVICE_TABLE(of, rt1015_of_match); +#endif + +#ifdef CONFIG_ACPI +static struct acpi_device_id rt1015_acpi_match[] = { + {"10EC1015", 0,}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, rt1015_acpi_match); +#endif + +static int rt1015_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct rt1015_priv *rt1015; + int ret; + unsigned int val; + + rt1015 = devm_kzalloc(&i2c->dev, sizeof(struct rt1015_priv), + GFP_KERNEL); + if (rt1015 == NULL) + return -ENOMEM; + + i2c_set_clientdata(i2c, rt1015); + + rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap); + if (IS_ERR(rt1015->regmap)) { + ret = PTR_ERR(rt1015->regmap); + dev_err(&i2c->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + regmap_read(rt1015->regmap, RT1015_DEVICE_ID, &val); + if ((val != RT1015_DEVICE_ID_VAL) && (val != RT1015_DEVICE_ID_VAL2)) { + dev_err(&i2c->dev, + "Device with ID register %x is not rt1015\n", val); + return -ENODEV; + } + + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt1015, + rt1015_dai, ARRAY_SIZE(rt1015_dai)); +} + +static void rt1015_i2c_shutdown(struct i2c_client *client) +{ + struct rt1015_priv *rt1015 = i2c_get_clientdata(client); + + regmap_write(rt1015->regmap, RT1015_RESET, 0); +} + +static struct i2c_driver rt1015_i2c_driver = { + .driver = { + .name = "rt1015", + .of_match_table = of_match_ptr(rt1015_of_match), + .acpi_match_table = ACPI_PTR(rt1015_acpi_match), + }, + .probe = rt1015_i2c_probe, + .shutdown = rt1015_i2c_shutdown, + .id_table = rt1015_i2c_id, +}; +module_i2c_driver(rt1015_i2c_driver); + +MODULE_DESCRIPTION("ASoC RT1015 driver"); +MODULE_AUTHOR("Jack Yu "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h new file mode 100644 index 000000000000..ef3745a4faae --- /dev/null +++ b/sound/soc/codecs/rt1015.h @@ -0,0 +1,375 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// rt1015.h -- RT1015 ALSA SoC audio amplifier driver +// +// Copyright 2019 Realtek Semiconductor Corp. +// Author: Jack Yu +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// + +#ifndef __RT1015_H__ +#define __RT1015_H__ + +#define RT1015_DEVICE_ID_VAL 0x1011 +#define RT1015_DEVICE_ID_VAL2 0x1015 + +#define RT1015_RESET 0x0000 +#define RT1015_CLK2 0x0004 +#define RT1015_CLK3 0x0006 +#define RT1015_PLL1 0x000a +#define RT1015_PLL2 0x000c +#define RT1015_CLK_DET 0x0020 +#define RT1015_SIL_DET 0x0022 +#define RT1015_CUSTOMER_ID 0x0076 +#define RT1015_PCODE_FWVER 0x0078 +#define RT1015_VER_ID 0x007a +#define RT1015_VENDOR_ID 0x007c +#define RT1015_DEVICE_ID 0x007d +#define RT1015_PAD_DRV1 0x00f0 +#define RT1015_PAD_DRV2 0x00f2 +#define RT1015_GAT_BOOST 0x00f3 +#define RT1015_PRO_ALT 0x00f4 +#define RT1015_MAN_I2C 0x0100 +#define RT1015_DAC1 0x0102 +#define RT1015_DAC2 0x0104 +#define RT1015_DAC3 0x0106 +#define RT1015_ADC1 0x010c +#define RT1015_ADC2 0x010e +#define RT1015_TDM_MASTER 0x0111 +#define RT1015_TDM_TCON 0x0112 +#define RT1015_TDM1_1 0x0114 +#define RT1015_TDM1_2 0x0116 +#define RT1015_TDM1_3 0x0118 +#define RT1015_TDM1_4 0x011a +#define RT1015_TDM1_5 0x011c +#define RT1015_MIXER1 0x0300 +#define RT1015_MIXER2 0x0302 +#define RT1015_ANA_PROTECT1 0x0311 +#define RT1015_ANA_CTRL_SEQ1 0x0313 +#define RT1015_ANA_CTRL_SEQ2 0x0314 +#define RT1015_VBAT_DET_DEB 0x031a +#define RT1015_VBAT_VOLT_DET1 0x031c +#define RT1015_VBAT_VOLT_DET2 0x031d +#define RT1015_VBAT_TEST_OUT1 0x031e +#define RT1015_VBAT_TEST_OUT2 0x031f +#define RT1015_VBAT_PROT_ATT 0x0320 +#define RT1015_VBAT_DET_CODE 0x0321 +#define RT1015_PWR1 0x0322 +#define RT1015_PWR4 0x0328 +#define RT1015_PWR5 0x0329 +#define RT1015_PWR6 0x032a +#define RT1015_PWR7 0x032b +#define RT1015_PWR8 0x032c +#define RT1015_PWR9 0x032d +#define RT1015_CLASSD_SEQ 0x032e +#define RT1015_SMART_BST_CTRL1 0x0330 +#define RT1015_SMART_BST_CTRL2 0x0332 +#define RT1015_ANA_CTRL1 0x0334 +#define RT1015_ANA_CTRL2 0x0336 +#define RT1015_PWR_STATE_CTRL 0x0338 +#define RT1015_SPK_VOL 0x0506 +#define RT1015_SHORT_DETTOP1 0x0508 +#define RT1015_SHORT_DETTOP2 0x050a +#define RT1015_SPK_DC_DETECT1 0x0519 +#define RT1015_SPK_DC_DETECT2 0x051a +#define RT1015_SPK_DC_DETECT3 0x051b +#define RT1015_SPK_DC_DETECT4 0x051d +#define RT1015_SPK_DC_DETECT5 0x051f +#define RT1015_BAT_RPO_STEP1 0x0536 +#define RT1015_BAT_RPO_STEP2 0x0538 +#define RT1015_BAT_RPO_STEP3 0x053a +#define RT1015_BAT_RPO_STEP4 0x053c +#define RT1015_BAT_RPO_STEP5 0x053d +#define RT1015_BAT_RPO_STEP6 0x053e +#define RT1015_BAT_RPO_STEP7 0x053f +#define RT1015_BAT_RPO_STEP8 0x0540 +#define RT1015_BAT_RPO_STEP9 0x0541 +#define RT1015_BAT_RPO_STEP10 0x0542 +#define RT1015_BAT_RPO_STEP11 0x0543 +#define RT1015_BAT_RPO_STEP12 0x0544 +#define RT1015_SPREAD_SPEC1 0x0568 +#define RT1015_SPREAD_SPEC2 0x056a +#define RT1015_PAD_STATUS 0x1000 +#define RT1015_PADS_PULLING_CTRL1 0x1002 +#define RT1015_PADS_DRIVING 0x1006 +#define RT1015_SYS_RST1 0x1007 +#define RT1015_SYS_RST2 0x1009 +#define RT1015_SYS_GATING1 0x100a +#define RT1015_TEST_MODE1 0x100c +#define RT1015_TEST_MODE2 0x100d +#define RT1015_TIMING_CTRL1 0x100e +#define RT1015_PLL_INT 0x1010 +#define RT1015_TEST_OUT1 0x1020 +#define RT1015_DC_CALIB_CLSD1 0x1200 +#define RT1015_DC_CALIB_CLSD2 0x1202 +#define RT1015_DC_CALIB_CLSD3 0x1204 +#define RT1015_DC_CALIB_CLSD4 0x1206 +#define RT1015_DC_CALIB_CLSD5 0x1208 +#define RT1015_DC_CALIB_CLSD6 0x120a +#define RT1015_DC_CALIB_CLSD7 0x120c +#define RT1015_DC_CALIB_CLSD8 0x120e +#define RT1015_DC_CALIB_CLSD9 0x1210 +#define RT1015_DC_CALIB_CLSD10 0x1212 +#define RT1015_CLSD_INTERNAL1 0x1300 +#define RT1015_CLSD_INTERNAL2 0x1302 +#define RT1015_CLSD_INTERNAL3 0x1304 +#define RT1015_CLSD_INTERNAL4 0x1305 +#define RT1015_CLSD_INTERNAL5 0x1306 +#define RT1015_CLSD_INTERNAL6 0x1308 +#define RT1015_CLSD_INTERNAL7 0x130a +#define RT1015_CLSD_INTERNAL8 0x130c +#define RT1015_CLSD_INTERNAL9 0x130e +#define RT1015_CLSD_OCP_CTRL 0x130f +#define RT1015_VREF_LV 0x1310 +#define RT1015_MBIAS1 0x1312 +#define RT1015_MBIAS2 0x1314 +#define RT1015_MBIAS3 0x1316 +#define RT1015_MBIAS4 0x1318 +#define RT1015_VREF_LV1 0x131a +#define RT1015_S_BST_TIMING_INTER1 0x1322 +#define RT1015_S_BST_TIMING_INTER2 0x1323 +#define RT1015_S_BST_TIMING_INTER3 0x1324 +#define RT1015_S_BST_TIMING_INTER4 0x1325 +#define RT1015_S_BST_TIMING_INTER5 0x1326 +#define RT1015_S_BST_TIMING_INTER6 0x1327 +#define RT1015_S_BST_TIMING_INTER7 0x1328 +#define RT1015_S_BST_TIMING_INTER8 0x1329 +#define RT1015_S_BST_TIMING_INTER9 0x132a +#define RT1015_S_BST_TIMING_INTER10 0x132b +#define RT1015_S_BST_TIMING_INTER11 0x1330 +#define RT1015_S_BST_TIMING_INTER12 0x1331 +#define RT1015_S_BST_TIMING_INTER13 0x1332 +#define RT1015_S_BST_TIMING_INTER14 0x1333 +#define RT1015_S_BST_TIMING_INTER15 0x1334 +#define RT1015_S_BST_TIMING_INTER16 0x1335 +#define RT1015_S_BST_TIMING_INTER17 0x1336 +#define RT1015_S_BST_TIMING_INTER18 0x1337 +#define RT1015_S_BST_TIMING_INTER19 0x1338 +#define RT1015_S_BST_TIMING_INTER20 0x1339 +#define RT1015_S_BST_TIMING_INTER21 0x133a +#define RT1015_S_BST_TIMING_INTER22 0x133b +#define RT1015_S_BST_TIMING_INTER23 0x133c +#define RT1015_S_BST_TIMING_INTER24 0x133d +#define RT1015_S_BST_TIMING_INTER25 0x133e +#define RT1015_S_BST_TIMING_INTER26 0x133f +#define RT1015_S_BST_TIMING_INTER27 0x1340 +#define RT1015_S_BST_TIMING_INTER28 0x1341 +#define RT1015_S_BST_TIMING_INTER29 0x1342 +#define RT1015_S_BST_TIMING_INTER30 0x1343 +#define RT1015_S_BST_TIMING_INTER31 0x1344 +#define RT1015_S_BST_TIMING_INTER32 0x1345 +#define RT1015_S_BST_TIMING_INTER33 0x1346 +#define RT1015_S_BST_TIMING_INTER34 0x1347 +#define RT1015_S_BST_TIMING_INTER35 0x1348 +#define RT1015_S_BST_TIMING_INTER36 0x1349 + +/* 0x0004 */ +#define RT1015_CLK_SYS_PRE_SEL_MASK (0x3 << 14) +#define RT1015_CLK_SYS_PRE_SEL_SFT 14 +#define RT1015_CLK_SYS_PRE_SEL_MCLK (0x0 << 14) +#define RT1015_CLK_SYS_PRE_SEL_PLL (0x2 << 14) +#define RT1015_PLL_SEL_MASK (0x1 << 13) +#define RT1015_PLL_SEL_SFT 13 +#define RT1015_PLL_SEL_PLL_SRC2 (0x0 << 13) +#define RT1015_PLL_SEL_BCLK (0x1 << 13) +#define RT1015_FS_PD_MASK (0x7 << 4) +#define RT1015_FS_PD_SFT 4 + +/* 0x000a */ +#define RT1015_PLL_M_MAX 0xf +#define RT1015_PLL_M_MASK (RT1015_PLL_M_MAX << 12) +#define RT1015_PLL_M_SFT 12 +#define RT1015_PLL_M_BP (0x1 << 11) +#define RT1015_PLL_M_BP_SFT 11 +#define RT1015_PLL_N_MAX 0x1ff +#define RT1015_PLL_N_MASK (RT1015_PLL_N_MAX << 0) +#define RT1015_PLL_N_SFT 0 + +/* 0x000c */ +#define RT1015_PLL_BPK_MASK (0x1 << 5) +#define RT1015_PLL_BPK (0x0 << 5) +#define RT1015_PLL_K_MAX 0x1f +#define RT1015_PLL_K_MASK (RT1015_PLL_K_MAX) +#define RT1015_PLL_K_SFT 0 + +/* 0x007a */ +#define RT1015_ID_MASK 0xff +#define RT1015_ID_VERA 0x0 +#define RT1015_ID_VERB 0x1 + +/* 0x0102 */ +#define RT1015_DAC_VOL_MASK (0x7f << 9) +#define RT1015_DAC_VOL_SFT 9 + +/* 0x0104 */ +#define RT1015_DAC_CLK (0x1 << 13) +#define RT1015_DAC_CLK_BIT 13 + +/* 0x0106 */ +#define RT1015_DAC_MUTE_MASK (0x1 << 15) +#define RT1015_DA_MUTE_SFT 15 +#define RT1015_DVOL_MUTE_FLAG_SFT 12 + +/* 0x0111 */ +#define RT1015_TCON_TDM_MS_MASK (0x1 << 14) +#define RT1015_TCON_TDM_MS_SFT 14 +#define RT1015_TCON_TDM_MS_S (0x0 << 14) +#define RT1015_TCON_TDM_MS_M (0x1 << 14) +#define RT1015_I2S_DL_MASK (0x7 << 8) +#define RT1015_I2S_DL_SFT 8 +#define RT1015_I2S_DL_16 (0x0 << 8) +#define RT1015_I2S_DL_20 (0x1 << 8) +#define RT1015_I2S_DL_24 (0x2 << 8) +#define RT1015_I2S_DL_8 (0x3 << 8) +#define RT1015_I2S_M_DF_MASK (0x7 << 0) +#define RT1015_I2S_M_DF_SFT 0 +#define RT1015_I2S_M_DF_I2S (0x0) +#define RT1015_I2S_M_DF_LEFT (0x1) +#define RT1015_I2S_M_DF_PCM_A (0x2) +#define RT1015_I2S_M_DF_PCM_B (0x3) +#define RT1015_I2S_M_DF_PCM_A_N (0x6) +#define RT1015_I2S_M_DF_PCM_B_N (0x7) + +/* TDM_tcon Setting (0x0112) */ +#define RT1015_I2S_TCON_DF_MASK (0x7 << 13) +#define RT1015_I2S_TCON_DF_SFT 13 +#define RT1015_I2S_TCON_DF_I2S (0x0 << 13) +#define RT1015_I2S_TCON_DF_LEFT (0x1 << 13) +#define RT1015_I2S_TCON_DF_PCM_A (0x2 << 13) +#define RT1015_I2S_TCON_DF_PCM_B (0x3 << 13) +#define RT1015_I2S_TCON_DF_PCM_A_N (0x6 << 13) +#define RT1015_I2S_TCON_DF_PCM_B_N (0x7 << 13) +#define RT1015_TCON_BCLK_SEL_MASK (0x3 << 10) +#define RT1015_TCON_BCLK_SEL_SFT 10 +#define RT1015_TCON_BCLK_SEL_32FS (0x0 << 10) +#define RT1015_TCON_BCLK_SEL_64FS (0x1 << 10) +#define RT1015_TCON_BCLK_SEL_128FS (0x2 << 10) +#define RT1015_TCON_BCLK_SEL_256FS (0x3 << 10) +#define RT1015_TCON_CH_LEN_MASK (0x3 << 5) +#define RT1015_TCON_CH_LEN_SFT 5 +#define RT1015_TCON_CH_LEN_16B (0x0 << 5) +#define RT1015_TCON_CH_LEN_20B (0x1 << 5) +#define RT1015_TCON_CH_LEN_24B (0x2 << 5) +#define RT1015_TCON_CH_LEN_32B (0x3 << 5) +#define RT1015_TCON_BCLK_MST_MASK (0x1 << 4) +#define RT1015_TCON_BCLK_MST_SFT 4 +#define RT1015_TCON_BCLK_MST_INV (0x1 << 4) + +/* TDM1 Setting-1 (0x0114) */ +#define RT1015_TDM_INV_BCLK_MASK (0x1 << 15) +#define RT1015_TDM_INV_BCLK_SFT 15 +#define RT1015_TDM_INV_BCLK (0x1 << 15) + +/* 0x0330 */ +#define RT1015_ABST_AUTO_EN_MASK (0x1 << 13) +#define RT1015_ABST_AUTO_MODE (0x1 << 13) +#define RT1015_ABST_REG_MODE (0x0 << 13) +#define RT1015_ABST_FIX_TGT_MASK (0x1 << 12) +#define RT1015_ABST_FIX_TGT_EN (0x1 << 12) +#define RT1015_ABST_FIX_TGT_DIS (0x0 << 12) +#define RT1015_BYPASS_SWR_REG_MASK (0x1 << 7) +#define RT1015_BYPASS_SWRREG_BYPASS (0x1 << 7) +#define RT1015_BYPASS_SWRREG_PASS (0x0 << 7) + +/* 0x0322 */ +#define RT1015_PWR_LDO2 (0x1 << 15) +#define RT1015_PWR_LDO2_BIT 15 +#define RT1015_PWR_DAC (0x1 << 14) +#define RT1015_PWR_DAC_BIT 14 +#define RT1015_PWR_INTCLK (0x1 << 13) +#define RT1015_PWR_INTCLK_BIT 13 +#define RT1015_PWR_ISENSE (0x1 << 12) +#define RT1015_PWR_ISENSE_BIT 12 +#define RT1015_PWR_VSENSE (0x1 << 10) +#define RT1015_PWR_VSENSE_BIT 10 +#define RT1015_PWR_PLL (0x1 << 9) +#define RT1015_PWR_PLL_BIT 9 +#define RT1015_PWR_BG_1_2 (0x1 << 8) +#define RT1015_PWR_BG_1_2_BIT 8 +#define RT1015_PWR_MBIAS_BG (0x1 << 7) +#define RT1015_PWR_MBIAS_BG_BIT 7 +#define RT1015_PWR_VBAT (0x1 << 6) +#define RT1015_PWR_VBAT_BIT 6 +#define RT1015_PWR_MBIAS (0x1 << 4) +#define RT1015_PWR_MBIAS_BIT 4 +#define RT1015_PWR_ADCV (0x1 << 3) +#define RT1015_PWR_ADCV_BIT 3 +#define RT1015_PWR_MIXERV (0x1 << 2) +#define RT1015_PWR_MIXERV_BIT 2 +#define RT1015_PWR_SUMV (0x1 << 1) +#define RT1015_PWR_SUMV_BIT 1 +#define RT1015_PWR_VREFLV (0x1 << 0) +#define RT1015_PWR_VREFLV_BIT 0 + +/* 0x0324 */ +#define RT1015_PWR_BASIC (0x1 << 15) +#define RT1015_PWR_BASIC_BIT 15 +#define RT1015_PWR_SD (0x1 << 14) +#define RT1015_PWR_SD_BIT 14 +#define RT1015_PWR_IBIAS (0x1 << 13) +#define RT1015_PWR_IBIAS_BIT 13 +#define RT1015_PWR_VCM (0x1 << 11) +#define RT1015_PWR_VCM_BIT 11 + +/* 0x0328 */ +#define RT1015_PWR_SWR (0x1 << 12) +#define RT1015_PWR_SWR_BIT 12 + +/* 0x1300 */ +#define RT1015_PWR_CLSD (0x1 << 12) +#define RT1015_PWR_CLSD_BIT 12 + +/* 0x007a */ +#define RT1015_ID_MASK 0xff +#define RT1015_ID_VERA 0x0 +#define RT1015_ID_VERB 0x1 + +/* System Clock Source */ +enum { + RT1015_SCLK_S_MCLK, + RT1015_SCLK_S_PLL, +}; + +/* PLL1 Source */ +enum { + RT1015_PLL_S_MCLK, + RT1015_PLL_S_BCLK, +}; + +enum { + RT1015_AIF1, + RT1015_AIFS, +}; + +enum { + RT1015_VERA, + RT1015_VERB, +}; + +enum { + BYPASS, + ADAPTIVE, + FIXED_ADAPTIVE, +}; + +struct rt1015_priv { + struct snd_soc_component *component; + struct regmap *regmap; + int sysclk; + int sysclk_src; + int lrck; + int bclk; + int id; + int pll_src; + int pll_in; + int pll_out; + int boost_mode; + int bypass_boost; + int amp_ver; + int dac_is_used; +}; + +#endif /* __RT1015_H__ */ -- cgit v1.2.3 From f183f9277a0f16e340bbcb28bf30834652ef10e1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:35 +0900 Subject: ASoC: soc-pcm: add soc_rtd_startup() Add soc_rtd_startup() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/878sm0mia4.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 74d340d1c9f7..c0018293c67b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -28,6 +28,15 @@ #define DPCM_MAX_BE_USERS 8 +static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->startup) + return rtd->dai_link->ops->startup(substream); + return 0; +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -522,13 +531,11 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) codec_dai->rx_mask = 0; } - if (rtd->dai_link->ops->startup) { - ret = rtd->dai_link->ops->startup(substream); - if (ret < 0) { - pr_err("ASoC: %s startup failed: %d\n", - rtd->dai_link->name, ret); - goto machine_err; - } + ret = soc_rtd_startup(rtd, substream); + if (ret < 0) { + pr_err("ASoC: %s startup failed: %d\n", + rtd->dai_link->name, ret); + goto machine_err; } /* Dynamic PCM DAI links compat checks use dynamic capabilities */ -- cgit v1.2.3 From 0be429f9fcfccfbbbcdb40e154a5c2328da17ca9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:40 +0900 Subject: ASoC: soc-pcm: add soc_rtd_shutdown() Add soc_rtd_shutdown() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/877e1kmi9z.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index c0018293c67b..8095c64c4e3e 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -37,6 +37,14 @@ static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd, return 0; } +static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->shutdown) + rtd->dai_link->ops->shutdown(substream); +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -602,8 +610,7 @@ dynamic: return 0; config_err: - if (rtd->dai_link->ops->shutdown) - rtd->dai_link->ops->shutdown(substream); + soc_rtd_shutdown(rtd, substream); machine_err: i = rtd->num_codecs; @@ -674,8 +681,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) for_each_rtd_codec_dai(rtd, i, codec_dai) snd_soc_dai_shutdown(codec_dai, substream); - if (rtd->dai_link->ops->shutdown) - rtd->dai_link->ops->shutdown(substream); + soc_rtd_shutdown(rtd, substream); soc_pcm_components_close(substream, NULL); -- cgit v1.2.3 From 44c1a75b0d889b3a5faff9edc837d972806bb46a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:44 +0900 Subject: ASoC: soc-pcm: add soc_rtd_prepare() Add soc_rtd_prepare() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/875zh4mi9v.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 8095c64c4e3e..ccd6c9ca55ab 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -45,6 +45,15 @@ static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd, rtd->dai_link->ops->shutdown(substream); } +static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->prepare) + return rtd->dai_link->ops->prepare(substream); + return 0; +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -716,13 +725,11 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); - if (rtd->dai_link->ops->prepare) { - ret = rtd->dai_link->ops->prepare(substream); - if (ret < 0) { - dev_err(rtd->card->dev, "ASoC: machine prepare error:" - " %d\n", ret); - goto out; - } + ret = soc_rtd_prepare(rtd, substream); + if (ret < 0) { + dev_err(rtd->card->dev, + "ASoC: machine prepare error: %d\n", ret); + goto out; } for_each_rtd_components(rtd, i, component) { -- cgit v1.2.3 From de9ad990284f16a435675e4e73c7ffaaea9ee4b2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:48 +0900 Subject: ASoC: soc-pcm: add soc_rtd_hw_params() Add soc_rtd_hw_params() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/874kwomi9r.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index ccd6c9ca55ab..d7fc6c5d7906 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -54,6 +54,16 @@ static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd, return 0; } +static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->hw_params) + return rtd->dai_link->ops->hw_params(substream, params); + return 0; +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -826,13 +836,11 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret) goto out; - if (rtd->dai_link->ops->hw_params) { - ret = rtd->dai_link->ops->hw_params(substream, params); - if (ret < 0) { - dev_err(rtd->card->dev, "ASoC: machine hw_params" - " failed: %d\n", ret); - goto out; - } + ret = soc_rtd_hw_params(rtd, substream, params); + if (ret < 0) { + dev_err(rtd->card->dev, + "ASoC: machine hw_params failed: %d\n", ret); + goto out; } for_each_rtd_codec_dai(rtd, i, codec_dai) { -- cgit v1.2.3 From 49f020e5714d2c48c8ed9a89169ef6a058e54c2f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:52 +0900 Subject: ASoC: soc-pcm: add soc_rtd_hw_free() Add soc_rtd_hw_free() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/8736c8mi9n.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index d7fc6c5d7906..718749f12979 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -64,6 +64,14 @@ static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd, return 0; } +static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->hw_free) + rtd->dai_link->ops->hw_free(substream); +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -935,8 +943,7 @@ codec_err: codec_dai->rate = 0; } - if (rtd->dai_link->ops->hw_free) - rtd->dai_link->ops->hw_free(substream); + soc_rtd_hw_free(rtd, substream); mutex_unlock(&rtd->card->pcm_mutex); return ret; @@ -979,8 +986,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) } /* free any machine hw params */ - if (rtd->dai_link->ops->hw_free) - rtd->dai_link->ops->hw_free(substream); + soc_rtd_hw_free(rtd, substream); /* free any component resources */ soc_pcm_components_hw_free(substream, NULL); -- cgit v1.2.3 From ad2bf9f252d667b385df606b4b762c26151bee78 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:44:56 +0900 Subject: ASoC: soc-pcm: add soc_rtd_trigger() Add soc_rtd_trigger() to make the code easier to read Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/871rrsmi9j.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 718749f12979..e66ac9ce321b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -72,6 +72,16 @@ static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd, rtd->dai_link->ops->hw_free(substream); } +static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_substream *substream, + int cmd) +{ + if (rtd->dai_link->ops && + rtd->dai_link->ops->trigger) + return rtd->dai_link->ops->trigger(substream, cmd); + return 0; +} + /** * snd_soc_runtime_activate() - Increment active count for PCM runtime components * @rtd: ASoC PCM runtime that is activated @@ -1013,11 +1023,9 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd) struct snd_soc_dai *codec_dai; int i, ret; - if (rtd->dai_link->ops->trigger) { - ret = rtd->dai_link->ops->trigger(substream, cmd); - if (ret < 0) - return ret; - } + ret = soc_rtd_trigger(rtd, substream, cmd); + if (ret < 0) + return ret; for_each_rtd_components(rtd, i, component) { ret = snd_soc_component_trigger(component, substream, cmd); @@ -1062,11 +1070,9 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd) return ret; } - if (rtd->dai_link->ops->trigger) { - ret = rtd->dai_link->ops->trigger(substream, cmd); - if (ret < 0) - return ret; - } + ret = soc_rtd_trigger(rtd, substream, cmd); + if (ret < 0) + return ret; return 0; } -- cgit v1.2.3 From d8e2e0d2491e78f3f7b451c3a93ba29950efe2cf Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 22 Jan 2020 09:45:00 +0900 Subject: ASoC: soc-core: remove null_snd_soc_ops All rtd->dai_link callback functions are controlled by soc_rtd_xxxx(), and checking rtd->dai_link->ops. We don't need to have null_snd_soc_ops anymore. This patch removes it. Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87zhegl3oz.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index f969a3b8c82b..068d809c349a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -342,8 +342,6 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev, } EXPORT_SYMBOL_GPL(snd_soc_lookup_component); -static const struct snd_soc_ops null_snd_soc_ops; - struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) @@ -488,8 +486,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( */ rtd->card = card; rtd->dai_link = dai_link; - if (!rtd->dai_link->ops) - rtd->dai_link->ops = &null_snd_soc_ops; /* see for_each_card_rtds */ list_add_tail(&rtd->list, &card->rtd_list); -- cgit v1.2.3 From d8feb6080bb0c9f4d799a423d9453048fdd06990 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 25 Jan 2020 19:10:21 +0100 Subject: ALSA: hda: Add Clevo W65_67SB the power_save blacklist Using HDA power-saving on the Clevo W65_67SB causes the first 0.5 seconds of audio to be missing every time audio starts playing. This commit adds the Clevo W65_67SB the power_save blacklist to avoid this issue. Cc: stable@vger.kernel.org BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1525104 Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20200125181021.70446-1-hdegoede@redhat.com Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 8ef223aa1e37..e2d0a7c3ab26 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2188,6 +2188,8 @@ static struct snd_pci_quirk power_save_blacklist[] = { /* https://bugzilla.redhat.com/show_bug.cgi?id=1581607 */ SND_PCI_QUIRK(0x1558, 0x3501, "Clevo W35xSS_370SS", 0), /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ + SND_PCI_QUIRK(0x1558, 0x6504, "Clevo W65_67SB", 0), + /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ SND_PCI_QUIRK(0x1028, 0x0497, "Dell Precision T3600", 0), /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */ -- cgit v1.2.3 From b81cbf7abfc94878a3c6f0789f2185ee55b1cc21 Mon Sep 17 00:00:00 2001 From: Nicola Lunghi Date: Sat, 25 Jan 2020 15:09:17 +0000 Subject: ALSA: usb-audio: add quirks for Line6 Helix devices fw>=2.82 With firmware 2.82 Line6 changed the usb id of some of the Helix devices but the quirks is still needed. Add it to the quirk list for line6 helix family of devices. Thanks to Jens for pointing out the missing ids. Signed-off-by: Nicola Lunghi Link: https://lore.kernel.org/r/20200125150917.5040-1-nick83ola@gmail.com Signed-off-by: Takashi Iwai --- sound/usb/format.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/usb/format.c b/sound/usb/format.c index d79db71305f6..53922f73467f 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -296,6 +296,9 @@ static int line6_parse_audio_format_rates_quirk(struct snd_usb_audio *chip, case USB_ID(0x0E41, 0x4242): /* Line6 Helix Rack */ case USB_ID(0x0E41, 0x4244): /* Line6 Helix LT */ case USB_ID(0x0E41, 0x4246): /* Line6 HX-Stomp */ + case USB_ID(0x0E41, 0x4248): /* Line6 Helix >= fw 2.82 */ + case USB_ID(0x0E41, 0x4249): /* Line6 Helix Rack >= fw 2.82 */ + case USB_ID(0x0E41, 0x424a): /* Line6 Helix LT >= fw 2.82 */ /* supported rates: 48Khz */ kfree(fp->rate_table); fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); -- cgit v1.2.3